@kestra-io/ui-libs 0.0.283 → 0.0.284

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": "@kestra-io/ui-libs",
3
- "version": "0.0.283",
3
+ "version": "0.0.284",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/kestra-io/ui-libs"
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <tooltip :key="lastStep.date.toString()">
2
+ <tooltip :key="lastStep?.date?.valueOf() ?? $t('no_history')">
3
3
  <template #content>
4
4
  <span
5
5
  v-for="(history, index) in filteredHistories"
@@ -34,7 +34,7 @@
34
34
  watch(
35
35
  () => props.histories,
36
36
  (newValue, oldValue) => {
37
- if (oldValue[0].date !== newValue[0].date) {
37
+ if (newValue?.[0]?.date?.valueOf() !== oldValue?.[0]?.date?.valueOf()) {
38
38
  paint();
39
39
  }
40
40
  }
@@ -48,11 +48,11 @@
48
48
  });
49
49
 
50
50
  const start = computed(() => {
51
- return props.histories?.length && new Date(props.histories[0].date.toString()).getTime();
51
+ return props.histories?.[0]?.date?.valueOf() ?? null;
52
52
  });
53
53
 
54
54
  const lastStep = computed(() => {
55
- return props.histories[props.histories.length - 1];
55
+ return props.histories?.length ? props.histories[props.histories.length - 1] : undefined;
56
56
  });
57
57
 
58
58
  const filteredHistories = computed(() => {
@@ -63,10 +63,10 @@
63
63
  if (!refreshHandler.value) {
64
64
  refreshHandler.value = setInterval(() => {
65
65
  computeDuration();
66
- if (props.histories && !State.isRunning(lastStep.value.state)) {
66
+ if (lastStep.value && !State.isRunning(lastStep.value.state)) {
67
67
  cancel();
68
68
  }
69
- }, 100);
69
+ }, 10);
70
70
  }
71
71
  }
72
72
 
@@ -78,21 +78,28 @@
78
78
  }
79
79
 
80
80
  function delta() {
81
- return stop() - start.value;
81
+ const startValue = start.value;
82
+ if (startValue === null) {
83
+ return 0;
84
+ }
85
+ return Math.max(0, stop() - startValue);
82
86
  }
83
87
 
84
88
  function stop() {
85
- if (!props.histories || State.isRunning(lastStep.value.state)) {
89
+ if (!lastStep.value || State.isRunning(lastStep.value.state)) {
86
90
  return +new Date();
87
91
  }
88
- return new Date(lastStep.value.date.toString()).getTime();
92
+ return lastStep.value.date.valueOf();
89
93
  }
90
94
 
91
95
  function computeDuration() {
92
96
  duration.value =
93
97
  filteredHistories.value.length === 0
94
98
  ? "&nbsp;"
95
- : Utils.humanDuration(delta() / 1000);
99
+ : Utils.humanDuration(delta() / 1000, {
100
+ maxDecimalPoints: 2,
101
+ units: ["h", "m", "s"],
102
+ });
96
103
  }
97
104
 
98
105
  function squareClass(state: string) {