summaryrefslogtreecommitdiff
path: root/editor/example.ts
diff options
context:
space:
mode:
Diffstat (limited to 'editor/example.ts')
-rw-r--r--editor/example.ts57
1 files changed, 57 insertions, 0 deletions
diff --git a/editor/example.ts b/editor/example.ts
new file mode 100644
index 0000000..f953f06
--- /dev/null
+++ b/editor/example.ts
@@ -0,0 +1,57 @@
+import { WuiEditor, WuiEditorOptions } from "./editor.js"
+import { WuiVfsNodeInterface } from "../vfs/vfs.js"
+
+let nodeFile: WuiVfsNodeInterface = {
+ name: "Test",
+ path: "/test",
+ is_dir: false,
+ content_type: "text/plain",
+ mod_time: 0,
+ size: 0,
+ mode: "",
+ childs: [],
+ content: btoa(`mkdir -p \${HOME}/aur/stackdriver-collectd
+
+git -C \${HOME}/aur/stackdriver-collectd clone \\
+ ssh://aur@aur.archlinux.org/stackdriver-collectd.git .
+
+sh -c "cd \${HOME}/aur/stackdriver-collectd; \\
+ makepkg --force --install --noconfirm"
+pacman -Ql stackdriver-collectd
+
+sudo systemctl enable stackdriver-collectd
+
+#put! {{.BaseDir}}/_template/etc/collectd-influxdb.conf /opt/collectd/etc/collectd.conf
+
+sudo systemctl restart stackdriver-collectd
+sudo systemctl status stackdriver-collectd
+
+##---- Connect telegraf with collectd
+
+{{.Val "influxdb::dir"}}/bin/influx bucket create \\
+ --name stackdriver_collectd \\
+ --description "stackdriver collectd" \\
+ --org {{.Val "influxdb::org"}} \\
+ --token {{.Val "influxdb:telegraf:token"}} \\
+ --retention "3d"
+
+#put: {{.BaseDir}}/_template/etc/telegraf/telegraf.d/stackdriver-collectd.conf \\
+ {{.Val "influxdb::dir"}}/etc/telegraf/telegraf.d/stackdriver-collectd.conf
+
+sudo systemctl restart telegraf
+sudo systemctl status telegraf
+`),
+}
+
+let opts = {
+ id: "editor",
+ is_editable: true,
+ OnSelection: (begin: number, end: number) => {
+ console.log("OnSelection: ", begin, end)
+ },
+ OnSave: (content: string) => {
+ console.log("OnSave: ", content)
+ }
+}
+let wuiEditor = new WuiEditor(opts)
+wuiEditor.Open(nodeFile)