changeset 3777:c373758ca2df

client: Improved import retry ui.
author Raimund Renkert <raimund.renkert@intevation.de>
date Thu, 04 Jul 2019 16:16:44 +0200
parents 6521c962a7b6
children 1b11ff97c1d1
files client/src/components/importconfiguration/ScheduledImports.vue client/src/store/importschedule.js
diffstat 2 files changed, 270 insertions(+), 210 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/components/importconfiguration/ScheduledImports.vue	Tue Jul 02 16:44:04 2019 +0200
+++ b/client/src/components/importconfiguration/ScheduledImports.vue	Thu Jul 04 16:16:44 2019 +0200
@@ -132,241 +132,281 @@
       :sortBy="sortBy"
     />
 
-    <div class="d-flex p-2">
-      <template v-if="!directImport || !directImportAvailable">
-        <div class="flex-column mr-4">
-          <div class="flex-row text-left">
-            <small class="text-muted">
-              <translate>Scheduled</translate>?
-            </small>
-          </div>
-          <div class="flex-flex-row text-left">
-            <toggle-button
-              :value="scheduled"
-              v-model="scheduled"
-              :sync="true"
-              class="mt-2"
-              :speed="100"
-              :labels="{
-                checked: this.$options.on,
-                unchecked: this.$options.off
-              }"
-              :width="60"
-              :height="30"
-            />
-          </div>
-        </div>
-        <div class="flex-column mr-2">
-          <div class="flex-row text-left">
-            <small class="text-muted">
-              <translate>Simple</translate>
-            </small>
-          </div>
-          <div class="flex-flex-row text-left">
-            <toggle-button
-              :disabled="!scheduled"
-              :value="easyCron"
-              v-model="easyCron"
-              :sync="true"
-              class="mt-2"
-              :speed="100"
-              :labels="{
-                checked: this.$options.on,
-                unchecked: this.$options.off
-              }"
-              :width="60"
-              :height="30"
-            />
+    <template v-if="!directImport || !directImportAvailable">
+      <div class="d-flex p-2">
+        <div class="flex-column w-50">
+          <div class="d-flex flex-row">
+            <div class="flex-column mr-4">
+              <div class="flex-row text-left">
+                <small class="text-muted">
+                  <translate>Scheduled</translate>?
+                </small>
+              </div>
+              <div class="flex-row text-left">
+                <toggle-button
+                  :value="scheduled"
+                  v-model="scheduled"
+                  :sync="true"
+                  class="mt-2"
+                  :speed="100"
+                  :labels="{
+                    checked: this.$options.on,
+                    unchecked: this.$options.off
+                  }"
+                  :width="60"
+                  :height="30"
+                />
+              </div>
+            </div>
+            <div class="flex-column mr-2">
+              <div class="flex-row text-left">
+                <small class="text-muted">
+                  <translate>Simple</translate>
+                </small>
+              </div>
+              <div class="flex-flex-row text-left">
+                <toggle-button
+                  :disabled="!scheduled"
+                  :value="easyCron"
+                  v-model="easyCron"
+                  :sync="true"
+                  class="mt-2"
+                  :speed="100"
+                  :labels="{
+                    checked: this.$options.on,
+                    unchecked: this.$options.off
+                  }"
+                  :width="60"
+                  :height="30"
+                />
+              </div>
+            </div>
           </div>
         </div>
-        <div class="ml-auto flex-column">
+        <div class="flex-column ml-2">
+          <div class="ml-auto flex-column">
+            <div class="flex-row text-left">
+              <small class="text-muted">
+                <translate>Retry on failure</translate>
+              </small>
+            </div>
+            <div class="flex-row text-left">
+              <toggle-button
+                :value="retry"
+                v-model="retry"
+                :sync="true"
+                class="mt-2"
+                :speed="100"
+                :labels="{
+                  checked: this.$options.on,
+                  unchecked: this.$options.off
+                }"
+                v-tooltip.bottom="ttRetry"
+                :width="60"
+                :height="30"
+              />
+            </div>
+          </div>
+        </div>
+      </div>
+    </template>
+    <template v-if="!directImport || !directImportAvailable">
+      <div class="d-flex flex-row">
+        <div class="flex-column w-50 px-2 pb-3">
           <div class="flex-row text-left">
             <small class="text-muted">
-              <translate>Tries</translate>
-            </small>
-          </div>
-          <div>
-            <input
-              style="width:120px;"
-              v-model="trys"
-              class="mr-1 form-control form-control-sm"
-              type="number"
-            />
-          </div>
-        </div>
-        <div class="flex-column">
-          <div class="flex-row text-left">
-            <small class="text-muted">
-              <translate>Wait to retry</translate>
+              <translate>Schedule</translate>
             </small>
           </div>
-          <div>
-            <input
-              style="width:120px;"
-              v-model="waitRetry"
-              class="ml-1 form-control form-control-sm"
-            />
-          </div>
-        </div>
-      </template>
-    </div>
-    <template v-if="!directImport || !directImportAvailable">
-      <div class="flex-column w-100 px-2 pb-3">
-        <div class="flex-row text-left">
-          <small class="text-muted">
-            <translate>Schedule</translate>
-          </small>
-        </div>
-        <div v-if="easyCron" class="text-left w-50">
-          <select
-            :disabled="!scheduled"
-            v-model="simple"
-            class="form-control form-control-sm"
-            ><option value="weekly"><translate>Weekly</translate></option>
-            <option value="monthly"><translate>Monthly</translate> </option>
-          </select>
-        </div>
-        <div v-if="!easyCron" class="text-left w-100">
-          <div class="d-flex flex-row">
-            <div class="my-auto mr-2">{{ $options.EVERY }}</div>
+          <div v-if="easyCron" class="text-left w-100">
             <select
               :disabled="!scheduled"
-              style="width: 130px;"
-              v-model="cronMode"
+              v-model="simple"
               class="form-control form-control-sm"
-              @change="clearInputs"
             >
-              <option :value="null"></option>
-              <option
-                v-for="(option, key) in $options.CRONMODE"
-                :value="key"
-                :key="key"
-                >{{ option }}</option
-              >
+              <option value="weekly"><translate>Weekly</translate></option>
+              <option value="monthly"><translate>Monthly</translate> </option>
             </select>
-            <div v-if="cronMode == 'hour'" class="ml-1 d-flex flex-row">
-              <div class="mt-auto mb-auto">{{ $options.ON }}</div>
-              <input
-                :disabled="!scheduled"
-                v-model="minutes"
-                class="cronfield ml-1 mr-1 form-control form-control-sm"
-                type="number"
-              />
-              <div class="mt-auto mb-auto">{{ $options.MINUTESPAST }}</div>
-            </div>
-            <div v-if="cronMode == 'day'" class="ml-1 d-flex flex-row">
-              <div class="mt-auto mb-auto">{{ $options.AT }}</div>
-              <input
-                :disabled="!scheduled"
-                v-model="hour"
-                class="cronfield ml-1 mr-1 form-control form-control-sm"
-                type="number"
-              />
-              <input
-                :disabled="!scheduled"
-                v-model="minutes"
-                class="cronfield ml-1 mr-1 form-control form-control-sm"
-                type="number"
-              />
-              <div class="mt-auto mb-auto">{{ $options.OCLOCK }}</div>
-            </div>
-            <div v-if="cronMode == 'week'" class="ml-1 d-flex flex-row">
-              <div class="ml-1 mr-1 mt-auto mb-auto">{{ $options.ON }}</div>
+          </div>
+          <div v-if="!easyCron" class="text-left w-100">
+            <div class="d-flex flex-row">
+              <div class="my-auto mr-2">{{ $options.EVERY }}</div>
               <select
                 :disabled="!scheduled"
-                v-model="day"
+                style="width: 130px;"
+                v-model="cronMode"
                 class="form-control form-control-sm"
+                @change="clearInputs"
               >
+                <option :value="null"></option>
                 <option
-                  v-for="(option, key) in $options.DAYSOFWEEK"
-                  :key="key"
-                  :value="key"
-                  >{{ option }}</option
-                >
-              </select>
-              <div class="ml-1 mt-auto mb-auto">{{ $options.AT }}</div>
-              <input
-                :disabled="!scheduled"
-                v-model="hour"
-                class="cronfield ml-1 mr-1 form-control form-control-sm"
-                type="number"
-              />
-              <input
-                :disabled="!scheduled"
-                v-model="minutes"
-                class="cronfield ml-1 mr-1 form-control form-control-sm"
-                type="number"
-              />
-            </div>
-            <div v-if="cronMode == 'month'" class="ml-1 d-flex flex-row">
-              <div class="ml-1 mt-auto mb-auto">{{ $options.ON }}</div>
-              <input
-                :disabled="!scheduled"
-                v-model="dayOfMonth"
-                class="cronfield ml-1 mr-1 form-control form-control-sm"
-                type="number"
-              />
-              <div class="mt-auto mb-auto">{{ $options.AT }}</div>
-              <input
-                :disabled="!scheduled"
-                v-model="hour"
-                class="cronfield ml-1 mr-2 form-control form-control-sm"
-                type="number"
-              />
-              <input
-                :disabled="!scheduled"
-                v-model="minutes"
-                class="cronfield ml-1 mr-2 form-control form-control-sm"
-                type="number"
-              />
-              <div class="mt-auto mb-auto">{{ $options.OCLOCK }}</div>
-            </div>
-            <div v-if="cronMode == 'year'" class="ml-1 d-flex flex-row">
-              <div class="ml-1 mt-auto mb-auto">{{ $options.ON }}</div>
-              <input
-                :disabled="!scheduled"
-                v-model="dayOfMonth"
-                class="cronfield ml-1 mr-1 form-control form-control-sm"
-                type="number"
-              />
-              <div class="mt-auto mb-auto">{{ $options.OF }}</div>
-              <select
-                :disabled="!scheduled"
-                v-model="month"
-                class="ml-1 mr-1 form-control form-control-sm"
-              >
-                <option
-                  v-for="(option, key) in $options.MONTHS"
+                  v-for="(option, key) in $options.CRONMODE"
                   :value="key"
                   :key="key"
                   >{{ option }}</option
                 >
               </select>
-              <div class="mt-auto mb-auto">{{ $options.ON }}</div>
+              <div v-if="cronMode == 'hour'" class="ml-1 d-flex flex-row">
+                <div class="mt-auto mb-auto">{{ $options.ON }}</div>
+                <input
+                  :disabled="!scheduled"
+                  v-model="minutes"
+                  class="cronfield ml-1 mr-1 form-control form-control-sm"
+                  type="number"
+                />
+                <div class="mt-auto mb-auto">{{ $options.MINUTESPAST }}</div>
+              </div>
+              <div v-if="cronMode == 'day'" class="ml-1 d-flex flex-row">
+                <div class="mt-auto mb-auto">{{ $options.AT }}</div>
+                <input
+                  :disabled="!scheduled"
+                  v-model="hour"
+                  class="cronfield ml-1 mr-1 form-control form-control-sm"
+                  type="number"
+                />
+                <input
+                  :disabled="!scheduled"
+                  v-model="minutes"
+                  class="cronfield ml-1 mr-1 form-control form-control-sm"
+                  type="number"
+                />
+                <div class="mt-auto mb-auto">{{ $options.OCLOCK }}</div>
+              </div>
+              <div v-if="cronMode == 'week'" class="ml-1 d-flex flex-row">
+                <div class="ml-1 mr-1 mt-auto mb-auto">{{ $options.ON }}</div>
+                <select
+                  :disabled="!scheduled"
+                  v-model="day"
+                  class="form-control form-control-sm"
+                >
+                  <option
+                    v-for="(option, key) in $options.DAYSOFWEEK"
+                    :key="key"
+                    :value="key"
+                    >{{ option }}</option
+                  >
+                </select>
+                <div class="ml-1 mt-auto mb-auto">{{ $options.AT }}</div>
+                <input
+                  :disabled="!scheduled"
+                  v-model="hour"
+                  class="cronfield ml-1 mr-1 form-control form-control-sm"
+                  type="number"
+                />
+                <input
+                  :disabled="!scheduled"
+                  v-model="minutes"
+                  class="cronfield ml-1 mr-1 form-control form-control-sm"
+                  type="number"
+                />
+              </div>
+              <div v-if="cronMode == 'month'" class="ml-1 d-flex flex-row">
+                <div class="ml-1 mt-auto mb-auto">{{ $options.ON }}</div>
+                <input
+                  :disabled="!scheduled"
+                  v-model="dayOfMonth"
+                  class="cronfield ml-1 mr-1 form-control form-control-sm"
+                  type="number"
+                />
+                <div class="mt-auto mb-auto">{{ $options.AT }}</div>
+                <input
+                  :disabled="!scheduled"
+                  v-model="hour"
+                  class="cronfield ml-1 mr-2 form-control form-control-sm"
+                  type="number"
+                />
+                <input
+                  :disabled="!scheduled"
+                  v-model="minutes"
+                  class="cronfield ml-1 mr-2 form-control form-control-sm"
+                  type="number"
+                />
+                <div class="mt-auto mb-auto">{{ $options.OCLOCK }}</div>
+              </div>
+              <div v-if="cronMode == 'year'" class="ml-1 d-flex flex-row">
+                <div class="ml-1 mt-auto mb-auto">{{ $options.ON }}</div>
+                <input
+                  :disabled="!scheduled"
+                  v-model="dayOfMonth"
+                  class="cronfield ml-1 mr-1 form-control form-control-sm"
+                  type="number"
+                />
+                <div class="mt-auto mb-auto">{{ $options.OF }}</div>
+                <select
+                  :disabled="!scheduled"
+                  v-model="month"
+                  class="ml-1 mr-1 form-control form-control-sm"
+                >
+                  <option
+                    v-for="(option, key) in $options.MONTHS"
+                    :value="key"
+                    :key="key"
+                    >{{ option }}</option
+                  >
+                </select>
+                <div class="mt-auto mb-auto">{{ $options.ON }}</div>
+                <input
+                  :disabled="!scheduled"
+                  v-model="hour"
+                  class="cronfield ml-1 mr-1 form-control form-control-sm"
+                  type="number"
+                />
+                <input
+                  :disabled="!scheduled"
+                  v-model="minutes"
+                  class="cronfield ml-1 mr-1 form-control form-control-sm"
+                  type="number"
+                />
+              </div>
+            </div>
+            <div class="mt-3 w-50 d-flex">
+              <div class="my-auto mr-2">
+                <translate>Cronstring</translate>
+              </div>
               <input
                 :disabled="!scheduled"
-                v-model="hour"
-                class="cronfield ml-1 mr-1 form-control form-control-sm"
-                type="number"
-              />
-              <input
-                :disabled="!scheduled"
-                v-model="minutes"
-                class="cronfield ml-1 mr-1 form-control form-control-sm"
-                type="number"
+                class="form-control form-control-sm"
+                v-model="cronString"
+                type="text"
               />
             </div>
           </div>
-          <div class="mt-3 w-50 d-flex">
-            <div class="my-auto mr-2">
-              <translate>Cronstring</translate>
+        </div>
+        <div class="d-flex flex-column ml-2">
+          <div class="d-flex flex-row ">
+            <div class="ml-1 flex-column">
+              <div class="flex-row text-left">
+                <small class="text-muted">
+                  <translate>Tries</translate>
+                </small>
+              </div>
+              <div>
+                <input
+                  :disabled="!retry"
+                  style="width:120px;"
+                  v-model="trys"
+                  class="mr-1 form-control form-control-sm"
+                  v-tooltip.bottom="ttRetries"
+                  type="number"
+                />
+              </div>
             </div>
-            <input
-              :disabled="!scheduled"
-              class="form-control form-control-sm"
-              v-model="cronString"
-              type="text"
-            />
+            <div class="flex-column">
+              <div class="flex-row text-left">
+                <small class="text-muted">
+                  <translate>Wait to retry</translate>
+                </small>
+              </div>
+              <div>
+                <input
+                  :disabled="!retry"
+                  style="width:120px;"
+                  v-model="waitRetry"
+                  v-tooltip.bottom="ttWaitRetry"
+                  class="ml-1 form-control form-control-sm"
+                />
+              </div>
+            </div>
           </div>
         </div>
       </div>
@@ -458,6 +498,7 @@
       passwordVisible: false,
       uploadLabel: this.$gettext("choose file to upload"),
       uploadFile: null,
+      retry: false,
       ...initializeCurrentSchedule()
     };
   },
@@ -493,6 +534,12 @@
       if (this.isMonthly(this.cronString)) {
         this.simple = "monthly";
       }
+    },
+    retry() {
+      if (!this.retry) {
+        this.trys = 0;
+        this.waitRetry = "";
+      }
     }
   },
   computed: {
@@ -606,6 +653,15 @@
         }
       }
       return true;
+    },
+    ttWaitRetry() {
+      return this.$gettext("retryDescription");
+    },
+    ttRetries() {
+      return this.$gettext("retryCountDescription");
+    },
+    ttRetry() {
+      return this.$gettext("retryDelayDescription");
     }
   },
   methods: {
@@ -704,6 +760,10 @@
       this.directImport = false;
       this.trys = this.currentSchedule.trys;
       this.waitRetry = this.currentSchedule.waitRetry;
+      this.retry =
+        this.currentSchedule.trys === null ||
+        this.currentSchedule.trys === undefined ||
+        this.currentSchedule === 0 ? false : true;
     },
     isWeekly(cron) {
       return /0 \d{1,2} \d{1,2} \* \* \d{1}/.test(cron);
--- a/client/src/store/importschedule.js	Tue Jul 02 16:44:04 2019 +0200
+++ b/client/src/store/importschedule.js	Thu Jul 04 16:16:44 2019 +0200
@@ -140,11 +140,11 @@
       const { cron, url } = config;
       Vue.set(state.currentSchedule, "importType", KINDIMPORTTYPE[kind]);
       Vue.set(state.currentSchedule, "id", id);
+      Vue.set(state.currentSchedule, "trys", config["trys"]);
+      Vue.set(state.currentSchedule, "waitRetry", config["wait-retry"]);
       if (cron) {
         Vue.set(state.currentSchedule, "scheduled", true);
         Vue.set(state.currentSchedule, "cronString", cron);
-        Vue.set(state.currentSchedule, "trys", config["trys"]);
-        Vue.set(state.currentSchedule, "waitRetry", config["wait-retry"]);
         // simple weekly  or monthly?
         if (cron === "0 0 0 * * 0") {
           Vue.set(state.currentSchedule, "simple", "weekly");