@nethserver/ns8-ui-lib 0.0.42 → 0.0.43

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": "@nethserver/ns8-ui-lib",
3
- "version": "0.0.42",
3
+ "version": "0.0.43",
4
4
  "description": "Vue.js library for NethServer 8 UI",
5
5
  "keywords": [
6
6
  "nethserver",
@@ -61,6 +61,7 @@
61
61
  "@rollup/plugin-json": "^4.1.0",
62
62
  "core-js": "^3.15.2",
63
63
  "date-fns": "^2.23.0",
64
- "date-fns-tz": "^1.1.6"
64
+ "date-fns-tz": "^1.1.6",
65
+ "vue-date-fns": "^2.0.1"
65
66
  }
66
67
  }
@@ -0,0 +1,340 @@
1
+ <template>
2
+ <cv-tile kind="standard" :light="light" class="ns-backup-card">
3
+ <!-- icon -->
4
+ <div class="row">
5
+ <NsSvg :svg="Save32" />
6
+ </div>
7
+ <div class="row">
8
+ <h3 class="title">{{ title }}</h3>
9
+ </div>
10
+ <div v-if="loading" class="row">
11
+ <cv-skeleton-text
12
+ :paragraph="true"
13
+ :line-count="5"
14
+ class="mg-top-sm"
15
+ ></cv-skeleton-text>
16
+ </div>
17
+ <template v-else-if="!backupsContainingInstance.length">
18
+ <div class="row">
19
+ <!-- no backup -->
20
+ <NsInlineNotification
21
+ kind="warning"
22
+ :title="noBackupMessage"
23
+ :showCloseButton="false"
24
+ :actionLabel="scheduleBackupLabel"
25
+ @action="goToBackup"
26
+ />
27
+ </div>
28
+ </template>
29
+ <template v-else>
30
+ <div v-for="backup in backupsContainingInstance" :key="backup.id">
31
+ <div class="row">
32
+ <h5
33
+ v-if="backupsContainingInstance.length > 1"
34
+ class="title mg-top-sm"
35
+ >
36
+ {{ backup.name }}
37
+ </h5>
38
+ </div>
39
+ <div class="table-wrapper">
40
+ <div class="table">
41
+ <!-- status -->
42
+ <div class="tr">
43
+ <div class="td label">{{ statusLabel }}</div>
44
+ <div class="td status">
45
+ <span v-if="!backup.enabled" class="ns-warning">
46
+ {{ backupDisabledLabel }}
47
+ </span>
48
+ <span
49
+ v-else-if="
50
+ status[backup.id] && status[backup.id].success == true
51
+ "
52
+ class="ns-success"
53
+ >
54
+ <span>{{ statusSuccessLabel }}</span>
55
+ </span>
56
+ <span
57
+ v-else-if="
58
+ status[backup.id] && status[backup.id].success == false
59
+ "
60
+ class="ns-error"
61
+ >
62
+ {{ statusErrorLabel }}
63
+ </span>
64
+ <span v-else class="ns-warning">
65
+ {{ statusNotRunLabel }}
66
+ </span>
67
+ </div>
68
+ </div>
69
+ <!-- repository -->
70
+ <div class="tr">
71
+ <div class="td label">{{ repositoryLabel }}</div>
72
+ <div class="td">
73
+ {{ backup.repoName }}
74
+ </div>
75
+ </div>
76
+ <!-- completed -->
77
+ <div class="tr">
78
+ <div class="td label">{{ completedLabel }}</div>
79
+ <div class="td">
80
+ <span v-if="status[backup.id] && status[backup.id].end">
81
+ {{
82
+ (status[backup.id].end * 1000) | date("yyyy-MM-dd HH:mm:ss")
83
+ }}
84
+ </span>
85
+ <span v-else>-</span>
86
+ </div>
87
+ </div>
88
+ <!-- duration -->
89
+ <div class="tr">
90
+ <div class="td label">{{ durationLabel }}</div>
91
+ <div class="td">
92
+ <span
93
+ v-if="
94
+ status[backup.id] &&
95
+ status[backup.id].end &&
96
+ status[backup.id].start
97
+ "
98
+ >
99
+ {{
100
+ (status[backup.id].end - status[backup.id].start)
101
+ | secondsFormat
102
+ }}
103
+ </span>
104
+ <span v-else>-</span>
105
+ </div>
106
+ </div>
107
+ <!-- total size -->
108
+ <div class="tr">
109
+ <div class="td label">{{ totalSizeLabel }}</div>
110
+ <div class="td">
111
+ <span v-if="status[backup.id] && status[backup.id].total_size">
112
+ {{ status[backup.id].total_size | byteFormat }}
113
+ </span>
114
+ <span v-else>-</span>
115
+ </div>
116
+ </div>
117
+ <!-- total file count -->
118
+ <div class="tr">
119
+ <div class="td label">{{ totalFileCountLabel }}</div>
120
+ <div class="td">
121
+ <span
122
+ v-if="status[backup.id] && status[backup.id].total_file_count"
123
+ >
124
+ {{ status[backup.id].total_file_count | humanFormat }}
125
+ ({{ status[backup.id].total_file_count }})
126
+ </span>
127
+ <span v-else>-</span>
128
+ </div>
129
+ </div>
130
+ </div>
131
+ </div>
132
+ </div>
133
+ </template>
134
+ <div>
135
+ <div class="row mg-top-sm">
136
+ <NsButton
137
+ kind="ghost"
138
+ :icon="ArrowRight20"
139
+ @click="goToBackup"
140
+ :disabled="loading"
141
+ >{{ goToBackupLabel }}
142
+ </NsButton>
143
+ </div>
144
+ </div>
145
+ </cv-tile>
146
+ </template>
147
+
148
+ <script>
149
+ import IconService from "../lib-mixins/icon.js";
150
+
151
+ export default {
152
+ name: "NsBackupCard",
153
+ mixins: [IconService],
154
+ props: {
155
+ title: {
156
+ type: String,
157
+ default: "Backup",
158
+ },
159
+ noBackupMessage: {
160
+ type: String,
161
+ default: "No backup configured",
162
+ },
163
+ scheduleBackupLabel: {
164
+ type: String,
165
+ default: "Configure",
166
+ },
167
+ goToBackupLabel: {
168
+ type: String,
169
+ default: "Go to Backup",
170
+ },
171
+ repositoryLabel: {
172
+ type: String,
173
+ default: "Repository",
174
+ },
175
+ statusLabel: {
176
+ type: String,
177
+ default: "Status",
178
+ },
179
+ statusSuccessLabel: {
180
+ type: String,
181
+ default: "Success",
182
+ },
183
+ statusNotRunLabel: {
184
+ type: String,
185
+ default: "Backup has not run yet",
186
+ },
187
+ statusErrorLabel: {
188
+ type: String,
189
+ default: "Error",
190
+ },
191
+ completedLabel: {
192
+ type: String,
193
+ default: "Completed",
194
+ },
195
+ durationLabel: {
196
+ type: String,
197
+ default: "Duration",
198
+ },
199
+ totalSizeLabel: {
200
+ type: String,
201
+ default: "Total size",
202
+ },
203
+ totalFileCountLabel: {
204
+ type: String,
205
+ default: "Total file count",
206
+ },
207
+ backupDisabledLabel: {
208
+ type: String,
209
+ default: "Disabled",
210
+ },
211
+ moduleId: {
212
+ type: String,
213
+ required: true,
214
+ },
215
+ moduleUiName: {
216
+ type: String,
217
+ default: "",
218
+ },
219
+ repositories: {
220
+ type: Array,
221
+ required: true,
222
+ },
223
+ backups: {
224
+ type: Array,
225
+ required: true,
226
+ },
227
+ loading: {
228
+ type: Boolean,
229
+ default: false,
230
+ },
231
+ coreContext: {
232
+ type: Object,
233
+ required: true,
234
+ },
235
+ light: Boolean,
236
+ },
237
+ data() {
238
+ return {
239
+ backupsContainingInstance: [],
240
+ status: [],
241
+ };
242
+ },
243
+ watch: {
244
+ repositories: function () {
245
+ this.updateData();
246
+ },
247
+ backups: function () {
248
+ this.updateData();
249
+ },
250
+ },
251
+ created() {
252
+ this.updateData();
253
+ },
254
+ methods: {
255
+ updateData() {
256
+ let backupsContainingInstance = [];
257
+
258
+ for (const backup of this.backups) {
259
+ for (const instance of backup.instances) {
260
+ if (instance.module_id == this.moduleId) {
261
+ backupsContainingInstance.push(backup);
262
+ }
263
+ }
264
+ }
265
+ this.backupsContainingInstance = backupsContainingInstance;
266
+
267
+ // status
268
+ for (const backup of this.backupsContainingInstance) {
269
+ const instance = backup.instances.find(
270
+ (i) => i.module_id == this.moduleId
271
+ );
272
+ const status = instance.status;
273
+ this.status[backup.id] = status;
274
+ }
275
+ },
276
+ goToBackup() {
277
+ if (this.coreContext) {
278
+ this.coreContext.$router.push("/backup");
279
+ }
280
+ },
281
+ },
282
+ };
283
+ </script>
284
+
285
+ <style scoped lang="scss">
286
+ .ns-backup-card {
287
+ display: flex;
288
+ flex-direction: column;
289
+ justify-content: center;
290
+ min-height: 7rem;
291
+ }
292
+
293
+ .row {
294
+ display: flex;
295
+ align-items: center;
296
+ justify-content: center;
297
+ margin-bottom: 0.5rem;
298
+ }
299
+
300
+ .title {
301
+ margin-left: 0.25rem;
302
+ margin-right: 0.25rem;
303
+ overflow: hidden;
304
+ text-overflow: ellipsis;
305
+ white-space: nowrap;
306
+ }
307
+
308
+ .table-wrapper {
309
+ display: flex;
310
+ justify-content: center;
311
+ margin-top: 0.5rem;
312
+ }
313
+
314
+ .table {
315
+ display: table;
316
+ }
317
+
318
+ .tr {
319
+ display: table-row;
320
+ }
321
+
322
+ .td {
323
+ display: table-cell;
324
+ }
325
+
326
+ .label {
327
+ padding-right: 0.75rem;
328
+ font-weight: bold;
329
+ text-align: right;
330
+ padding-bottom: 0.5rem;
331
+ }
332
+
333
+ .status {
334
+ font-weight: bold;
335
+ }
336
+
337
+ .backup-status-icon {
338
+ margin-right: 0.25rem;
339
+ }
340
+ </style>