Просмотр исходного кода

feature: #69 - Add action confirmation (#208)

* feature: #69 - Add action confirmation

* fmt: style
James Read 2 лет назад
Родитель
Сommit
f559a2f9c9
2 измененных файлов с 16 добавлено и 0 удалено
  1. 7 0
      config.yaml
  2. 9 0
      webui/js/ArgumentForm.js

+ 7 - 0
config.yaml

@@ -85,3 +85,10 @@ actions:
   shell: sleep 5
   timeout: 5
   icon: "&#x1F62A"
+
+- title: Delete old backups
+  icon: ashtonished
+  shell: rm -rf /opt/oldBackups/
+  arguments:
+    - type: confirmation
+      title: Are you sure?!

+ 9 - 0
webui/js/ArgumentForm.js

@@ -93,6 +93,15 @@ class ArgumentForm extends window.HTMLElement {
       for (const choice of arg.choices) {
         domEl.appendChild(this.createSelectOption(choice))
       }
+    } else if (arg.type === 'confirmation') {
+      this.domBtnStart.disabled = true
+
+      domEl = document.createElement('input')
+      domEl.setAttribute('type', 'checkbox')
+      domEl.onchange = () => {
+        this.domBtnStart.disabled = false
+        domEl.disabled = true
+      }
     } else {
       domEl = document.createElement('input')
       domEl.onchange = () => {