@monoui/vuejs 1.1.45 → 1.1.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monoui/vuejs",
3
- "version": "1.1.45",
3
+ "version": "1.1.48",
4
4
  "description": "This project will contain MonoFor UI Framework",
5
5
  "main": "./dist/main.js",
6
6
  "repository": "git@gitlab.com:monoui/vuejs.git",
@@ -34,6 +34,7 @@
34
34
  "vee-validate": "^3.0.11",
35
35
  "vue": "^2.6.12",
36
36
  "vue-cron-2": "^1.0.7",
37
+ "cron-parser": "^4.8.1",
37
38
  "vue-js-toggle-button": "^1.3.3",
38
39
  "vue-multiselect": "^2.1.6",
39
40
  "vue-server-renderer": "^2.6.12",
@@ -41,7 +42,7 @@
41
42
  "vue-sweetalert2": "^4.2",
42
43
  "vue-template-compiler": "^2.6.12",
43
44
  "vue-test-utils": "^1.0.0-beta.11",
44
- "vue2-datepicker": "^3.6.2",
45
+ "vue2-datepicker": "^3.11.1",
45
46
  "vuejs-noty": "^0.1.3"
46
47
  },
47
48
  "devDependencies": {
@@ -0,0 +1,479 @@
1
+ <template>
2
+ <div>
3
+ <div class="d-flex align-items-center mb-3">
4
+ <mui-button
5
+ variant="light"
6
+ class="border-0"
7
+ @click="add"
8
+ v-if="!single"
9
+ >
10
+ <mui-icon class="mr-1" icon="plus" /> {{ addTimingButtonText }}
11
+ </mui-button>
12
+ <div class="ml-2 d-flex align-items-center">
13
+ <div>
14
+ <span>
15
+ <mui-icon class="mr-1" icon="clock" />
16
+ </span>
17
+ <strong>LOCAL</strong>
18
+ <span class="text-monospace">
19
+ {{ currentLocalTime }}
20
+ </span>
21
+ </div>
22
+ <div class="ml-2">
23
+ <strong>UTC</strong>
24
+ <span class="text-monospace">
25
+ {{ currentUTCTime }}
26
+ </span>
27
+ </div>
28
+ </div>
29
+ </div>
30
+ <mui-modal title="Select Timezone" v-model="visible.timeZone" size="xs">
31
+ <v-select
32
+ v-model="selectedTimeZone"
33
+ :options="options.timeZones"
34
+ :clearable="false"
35
+ />
36
+ <template #modal-footer>
37
+ <mui-button @click="setTimeZone" variant="primary">
38
+ Use this Time Zone
39
+ </mui-button>
40
+ </template>
41
+ </mui-modal>
42
+ <div v-if="single">
43
+ <div class="d-flex mb-1">
44
+ <b-badge
45
+ pill
46
+ variant="light mr-2"
47
+ href="#"
48
+ @click="() => (cron = macro.value)"
49
+ v-for="(macro, index) in cronMacros"
50
+ :key="index"
51
+ >
52
+ {{ macro.text }}
53
+ </b-badge>
54
+ </div>
55
+ <div class="d-flex align-items-center">
56
+ <b-form-input
57
+ v-model="cron"
58
+ type="text"
59
+ class="text-monospace"
60
+ size="sm"
61
+ style="max-width: 220px"
62
+ placeholder="Type your cron expression"
63
+ />
64
+ <span class="ml-2" v-if="getNextInterval(singleTiming)">
65
+ This will run at
66
+ <b>{{
67
+ getNextInterval(singleTiming, "YYYY-MM-DD HH:mm")
68
+ }}</b>
69
+ ({{ getNextInterval(singleTiming) }})
70
+ </span>
71
+ </div>
72
+ </div>
73
+ <div v-else>
74
+ <div v-for="(timing, index) in timings" :key="timing.Id">
75
+ <div class="d-flex align-items-center mb-2">
76
+ <mui-button
77
+ variant="light"
78
+ class="border-0"
79
+ @click="remove(index)"
80
+ >
81
+ <mui-icon class="mr-1" icon="trash" />
82
+ </mui-button>
83
+ <div style="width: 140px" class="ml-2">
84
+ <v-select
85
+ size="sm"
86
+ v-model="timing.Name"
87
+ :options="options.macros"
88
+ :clearable="false"
89
+ :onChange="
90
+ (newValue, oldValue) =>
91
+ selectedMacro(timing, newValue, oldValue)
92
+ "
93
+ />
94
+ </div>
95
+ <mui-button
96
+ class="ml-2"
97
+ @click="showTimeZoneSelector(timing)"
98
+ >
99
+ {{ timing.TimeZone }}
100
+ </mui-button>
101
+ <div class="d-flex align-items-center">
102
+ <div
103
+ v-if="getMacro(timing.Name).hasDaySelector"
104
+ class="ml-2 d-flex align-items-center"
105
+ >
106
+ <div class="input-group input-group-sm ml-1">
107
+ <div class="input-group-prepend">
108
+ <span class="input-group-text pb-1">
109
+ Day
110
+ </span>
111
+ </div>
112
+ <v-select
113
+ size="sm"
114
+ style="width: 125px"
115
+ v-model="timing.WeekDay"
116
+ :options="weekDays"
117
+ :clearable="false"
118
+ :onChange="
119
+ event =>
120
+ changeCronPart(timing, 'day', event)
121
+ "
122
+ />
123
+ </div>
124
+ </div>
125
+ <div
126
+ v-if="getMacro(timing.Name).hasHourSelector"
127
+ class="ml-2 d-flex align-items-center"
128
+ >
129
+ <div class="input-group input-group-sm ml-1">
130
+ <div class="input-group-prepend">
131
+ <span class="input-group-text pb-1">
132
+ Hour
133
+ </span>
134
+ </div>
135
+ <input
136
+ class="form-control"
137
+ style="width: 40px;"
138
+ type="text"
139
+ :value="getCronPart(timing, 'hour')"
140
+ @input="
141
+ event =>
142
+ changeCronPart(
143
+ timing,
144
+ 'hour',
145
+ event.target.value
146
+ )
147
+ "
148
+ />
149
+ </div>
150
+ </div>
151
+ <div
152
+ v-if="getMacro(timing.Name).hasMinuteSelector"
153
+ class="ml-2 d-flex align-items-center"
154
+ >
155
+ <div class="input-group input-group-sm ml-1">
156
+ <div class="input-group-prepend">
157
+ <span class="input-group-text pb-1">
158
+ Minute
159
+ </span>
160
+ </div>
161
+ <input
162
+ class="form-control"
163
+ style="width: 40px;"
164
+ type="text"
165
+ :value="getCronPart(timing, 'minute')"
166
+ @input="
167
+ event =>
168
+ changeCronPart(
169
+ timing,
170
+ 'minute',
171
+ event.target.value
172
+ )
173
+ "
174
+ />
175
+ </div>
176
+ </div>
177
+ </div>
178
+ <b-form-input
179
+ v-model="timing.Cron"
180
+ type="text"
181
+ class="ml-2 text-monospace"
182
+ size="sm"
183
+ style="max-width: 220px"
184
+ placeholder="Type your cron expression"
185
+ v-if="timing.IsCustom"
186
+ />
187
+ <span class="ml-2" v-if="getNextInterval(timing)">
188
+ This will run at
189
+ <b>{{ getNextInterval(timing, "YYYY-MM-DD HH:mm") }}</b>
190
+ ({{ getNextInterval(timing) }})
191
+ </span>
192
+ </div>
193
+ </div>
194
+ </div>
195
+ </div>
196
+ </template>
197
+
198
+ <script>
199
+ import cronParser from "cron-parser";
200
+ import moment from "moment";
201
+ export default {
202
+ name: "mui-cron-modern",
203
+
204
+ props: {
205
+ value: {
206
+ type: [Array, String],
207
+ required: true
208
+ },
209
+
210
+ maxTiming: {
211
+ type: Number,
212
+ required: false,
213
+ default: 7
214
+ },
215
+
216
+ single: {
217
+ type: Boolean,
218
+ required: false,
219
+ default: false
220
+ },
221
+ timeZones: {
222
+ type: Array,
223
+ required: true
224
+ },
225
+ addTimingButtonText: {
226
+ type: String,
227
+ required: false,
228
+ default: "Add timing"
229
+ }
230
+ },
231
+
232
+ watch: {
233
+ timings: {
234
+ immediate: true,
235
+ deep: true,
236
+ handler() {
237
+ if (this.single) return;
238
+ this.$emit("input", this.timings);
239
+ }
240
+ },
241
+ cron: {
242
+ immediate: true,
243
+ deep: true,
244
+ handler() {
245
+ if (!this.single) return;
246
+ this.$emit("input", this.cron);
247
+ }
248
+ }
249
+ },
250
+
251
+ computed: {
252
+ singleTiming() {
253
+ return {
254
+ Cron: this.cron
255
+ };
256
+ }
257
+ },
258
+
259
+ mounted() {
260
+ this.setTime();
261
+ if (!this.timer) {
262
+ this.timer = setInterval(this.setTime, 1000);
263
+ }
264
+ this.options.macros = this.cronMacros.map(x => {
265
+ return {
266
+ id: x.name,
267
+ label: x.text,
268
+ value: x
269
+ };
270
+ });
271
+ this.options.timeZones = this.timeZones;
272
+
273
+ if (this.single) {
274
+ this.cron = this.value;
275
+ } else {
276
+ this.timings = this.value || [];
277
+ for (const timing of this.timings) {
278
+ if (!timing.Id) timing.Id = this.$helpers.guid();
279
+ if (!timing.Name) {
280
+ timing.Name = this.getMacroName(timing.Cron);
281
+ }
282
+ if (!timing.TimeZone) {
283
+ timing.TimeZone = "UTC";
284
+ }
285
+ }
286
+ }
287
+ },
288
+
289
+ data() {
290
+ return {
291
+ currentLocalTime: null,
292
+ currentUTCTime: null,
293
+ timer: null,
294
+ selectedTimeZone: "UTC",
295
+ currentTiming: null,
296
+ timings: [],
297
+ cron: "",
298
+ options: {
299
+ macros: [],
300
+ timeZones: []
301
+ },
302
+ visible: {
303
+ timeZone: false
304
+ },
305
+ cronMacros: [
306
+ {
307
+ text: "Every minute",
308
+ name: "every_minute",
309
+ value: "* * * * *",
310
+ isCustom: false
311
+ },
312
+ {
313
+ text: "Hourly",
314
+ name: "every_hour",
315
+ value: "0 * * * *",
316
+ isCustom: false,
317
+ hasMinuteSelector: true
318
+ },
319
+ {
320
+ text: "Daily",
321
+ name: "every_day",
322
+ value: "0 0 * * *",
323
+ isCustom: false,
324
+ hasHourSelector: true,
325
+ hasMinuteSelector: true
326
+ },
327
+ {
328
+ text: "Weekly",
329
+ name: "every_week",
330
+ value: "0 0 * * 0",
331
+ hasDaySelector: true,
332
+ hasHourSelector: true,
333
+ hasMinuteSelector: true,
334
+ isCustom: false
335
+ },
336
+ {
337
+ text: "Monthly",
338
+ name: "every_month",
339
+ value: "0 0 1 * *",
340
+ isCustom: false,
341
+ hasHourSelector: true,
342
+ hasMinuteSelector: true
343
+ },
344
+ {
345
+ text: "Annually",
346
+ name: "every_year",
347
+ value: "0 0 1 1 *",
348
+ isCustom: false,
349
+ hasHourSelector: true,
350
+ hasMinuteSelector: true
351
+ },
352
+ {
353
+ text: "Custom",
354
+ name: "custom",
355
+ value: "",
356
+ isCustom: true
357
+ }
358
+ ],
359
+ weekDays: [
360
+ { id: 0, label: "Sunday" },
361
+ { id: 1, label: "Monday" },
362
+ { id: 2, label: "Tuesday" },
363
+ { id: 3, label: "Wednesday" },
364
+ { id: 4, label: "Thursday" },
365
+ { id: 5, label: "Friday" },
366
+ { id: 6, label: "Saturday" }
367
+ ]
368
+ };
369
+ },
370
+
371
+ methods: {
372
+ setTime() {
373
+ this.currentLocalTime = moment().format("YYYY-MM-DD HH:mm:ss");
374
+ this.currentUTCTime = moment()
375
+ .utc()
376
+ .format("YYYY-MM-DD HH:mm:ss");
377
+ },
378
+ getCronPart(timing, part) {
379
+ let cronParts = timing.Cron.split(" ");
380
+
381
+ let partIndex = -1;
382
+ if (part === "minute") partIndex = cronParts.length === 6 ? 1 : 0;
383
+ if (part === "hour") partIndex = cronParts.length === 6 ? 2 : 1;
384
+ if (partIndex === -1) return "";
385
+
386
+ return cronParts[partIndex];
387
+ },
388
+
389
+ changeCronPart(timing, part, value) {
390
+ let cronParts = timing.Cron.split(" ");
391
+
392
+ let partIndex = -1;
393
+ if (part === "minute") partIndex = cronParts.length === 6 ? 1 : 0;
394
+ if (part === "hour") partIndex = cronParts.length === 6 ? 2 : 1;
395
+ if (part === "day") partIndex = cronParts.length - 1;
396
+
397
+ cronParts[partIndex] = value;
398
+ timing.Cron = cronParts.join(" ");
399
+ },
400
+
401
+ setTimeZone() {
402
+ this.currentTiming.TimeZone = this.selectedTimeZone;
403
+ this.$emit("input", this.timings);
404
+ this.selectedTimeZone = "UTC";
405
+ this.visible.timeZone = false;
406
+ },
407
+
408
+ showTimeZoneSelector(timing) {
409
+ this.currentTiming = timing;
410
+ this.selectedTimeZone = timing.TimeZone || "UTC";
411
+ this.visible.timeZone = true;
412
+ },
413
+
414
+ getNextInterval(timing, format) {
415
+ if (!timing.Cron) return "";
416
+ try {
417
+ const interval = cronParser.parseExpression(timing.Cron, {
418
+ tz: timing.TimeZone
419
+ });
420
+ const nextSchedule = interval.next();
421
+ if (format) return moment(nextSchedule.toDate()).format(format);
422
+ return moment(nextSchedule.toDate()).fromNow();
423
+ } catch (error) {
424
+ return null;
425
+ }
426
+ },
427
+
428
+ selectedMacro(timing, newValue, oldValue) {
429
+ let macro = this.cronMacros.find(x => x.name === newValue);
430
+
431
+ if (!macro) return;
432
+
433
+ timing.Name = macro.name;
434
+ timing.IsCustom = macro.isCustom;
435
+ if (!timing.TimeZone) timing.TimeZone = "UTC";
436
+
437
+ if (oldValue === newValue) return;
438
+
439
+ if (!timing.Cron) timing.Cron = macro.value;
440
+ else if (timing.Name !== "custom") timing.Cron = macro.value;
441
+ },
442
+
443
+ isCustom(cron) {
444
+ let macro = this.cronMacros.find(x => x.value === cron);
445
+ return macro === null || macro.isCustom;
446
+ },
447
+
448
+ getMacro(name) {
449
+ let macro = this.cronMacros.find(x => x.name === name);
450
+ return macro || {};
451
+ },
452
+
453
+ getMacroName(cron) {
454
+ let macro = this.cronMacros.find(x => x.value === cron);
455
+ return macro ? macro.name : "custom";
456
+ },
457
+
458
+ add() {
459
+ if (this.timings.length >= this.maxTiming) return;
460
+ this.addTiming();
461
+ },
462
+
463
+ addTiming() {
464
+ this.timings.push({
465
+ Id: this.$helpers.guid(),
466
+ Cron: "0 0 * * *",
467
+ IsCustom: false,
468
+ Name: "every_day",
469
+ TimeZone: "UTC",
470
+ WeekDay: 1
471
+ });
472
+ },
473
+
474
+ remove(index) {
475
+ this.timings.splice(index, 1);
476
+ }
477
+ }
478
+ };
479
+ </script>
@@ -1,3 +1,3 @@
1
1
  import Cron from "./Cron.vue";
2
-
3
- export default Cron;
2
+ import CronModern from "./CronModern.vue";
3
+ export { Cron, CronModern };
@@ -1,6 +1,7 @@
1
1
  <template>
2
2
  <div class="datePicker">
3
3
  <date-picker
4
+ :ref="refKey"
4
5
  :value="datetime"
5
6
  @input="updateDate($event)"
6
7
  :type="type"
@@ -15,6 +16,8 @@
15
16
  :clearable="clearable"
16
17
  :second-options="[]"
17
18
  :shortcuts="!range && shortcutsEnable ? shortcuts : []"
19
+ @change="handleChange"
20
+ :open.sync="open"
18
21
  >
19
22
  <template #header="{ emit }" v-if="!shortcutsEnable && todayHeader">
20
23
  <button class="mx-btn mx-btn-text" @click="emit(new Date())">
@@ -72,6 +75,7 @@ export default {
72
75
  },
73
76
  data() {
74
77
  return {
78
+ open: false,
75
79
  momentFormat: {
76
80
  stringify: date => {
77
81
  return date ? moment(date).format(this.dateFormat) : "";
@@ -107,6 +111,15 @@ export default {
107
111
  }
108
112
  },
109
113
  props: {
114
+ closeOnSelect: {
115
+ type: Boolean,
116
+ default: true
117
+ },
118
+ refKey: {
119
+ required: false,
120
+ type: String,
121
+ default: "muiDatePicker"
122
+ },
110
123
  /**
111
124
  * value.
112
125
  * It's used to bind v-model value from parent component to child component's input value.
@@ -286,6 +299,11 @@ export default {
286
299
  }
287
300
  },
288
301
  methods: {
302
+ handleChange(value, type) {
303
+ if (!this.range && this.type === "datetime") {
304
+ if (type === "minute") this.open = false;
305
+ }
306
+ },
289
307
  /**
290
308
  * updateDate
291
309
  * @input update value when input value changes
@@ -0,0 +1,23 @@
1
+ export default {
2
+ guid() {
3
+ function s4() {
4
+ return Math.floor((1 + Math.random()) * 0x10000)
5
+ .toString(16)
6
+ .substring(1);
7
+ }
8
+ return (
9
+ s4() +
10
+ s4() +
11
+ "-" +
12
+ s4() +
13
+ "-" +
14
+ s4() +
15
+ "-" +
16
+ s4() +
17
+ "-" +
18
+ s4() +
19
+ s4() +
20
+ s4()
21
+ );
22
+ }
23
+ };
package/src/index.js CHANGED
@@ -1,3 +1,5 @@
1
+ import Vue from "vue";
2
+
1
3
  // ***Components***
2
4
  import Loader from "./components/Loader";
3
5
  import { Button, ButtonCore } from "./components/Button";
@@ -20,7 +22,7 @@ import {
20
22
  RemoveAlert,
21
23
  UnsavedChangesAlert
22
24
  } from "./components/Modal";
23
- import Cron from "./components/Cron";
25
+ import { Cron, CronModern } from "./components/Cron";
24
26
  import Popover from "./components/Popover";
25
27
  import TagInput from "./components/TagInput";
26
28
  import Icon from "./components/Icon";
@@ -45,6 +47,12 @@ import Notification from "./functions/notification";
45
47
  import Alerte from "./functions/alert";
46
48
  // ***Functions***
47
49
 
50
+ import Helpers from "./functions/helpers";
51
+ /** VUE PROTOTYPE -> START */
52
+ Vue.prototype.$helpers = Helpers;
53
+
54
+ /** VUE PROTOTYPE -> END */
55
+
48
56
  // ***Plugins***
49
57
  import "bootstrap/dist/css/bootstrap.css";
50
58
  import "bootstrap-vue/dist/bootstrap-vue.css";
@@ -133,6 +141,7 @@ export default {
133
141
  Vue.component(Timeline.name, Timeline);
134
142
  Vue.component(TimelineItem.name, TimelineItem);
135
143
  Vue.component(ToggleSwitch.name, ToggleSwitch);
144
+ Vue.component(CronModern.name, CronModern);
136
145
 
137
146
  Vue.use(Notification);
138
147
  Vue.use(Alerte);