Skip to content

Commit f01fe97

Browse files
authored
Improve failed deployments (#4286)
* - Refactor failed deployments to be displayed on a table - Hide pagination if failed deployments less than 5 items * Fix lint * Fix lint issues * rm debugging logs * - Remove the alert inside the dialog - Rename the dialog header - Change the warning alert to error
1 parent 0896090 commit f01fe97

File tree

1 file changed

+52
-140
lines changed

1 file changed

+52
-140
lines changed

packages/playground/src/components/vm_deployment_table.vue

Lines changed: 52 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,48 @@
11
<template>
22
<div>
3-
<v-alert
4-
v-if="errorMessage"
5-
type="error"
6-
variant="tonal"
7-
>
3+
<v-alert v-if="errorMessage" type="error" variant="tonal">
84
{{ errorMessage }}
95
</v-alert>
10-
<v-alert
11-
v-if="!loading && count && items.length < count"
12-
type="warning"
13-
variant="tonal"
14-
>
6+
<v-alert v-if="!loading && count && items.length < count" type="error" variant="tonal">
157
Failed to load <strong>{{ count - items.length }}</strong> deployment{{ count - items.length > 1 ? "s" : "" }}.
168

179
<span>
1810
This might happen because the node is down or it's not reachable
1911
<span v-if="showEncryption">or the deployment{{ count - items.length > 1 ? "s are" : " is" }} encrypted by another key</span>.
2012
</span>
21-
<v-tooltip
22-
location="top"
23-
text="Show failed deployments"
24-
>
13+
<v-tooltip location="top" text="Show failed deployments">
2514
<template #activator="{ props: slotProps }">
26-
<v-icon
27-
v-bind="slotProps"
28-
class="custom-icon"
29-
@click="showDialog = true"
30-
>
15+
<v-icon v-bind="slotProps" class="custom-icon" @click="showDialog = true">
3116
mdi-file-document-refresh-outline
3217
</v-icon>
3318
</template>
3419
</v-tooltip>
3520

36-
<v-dialog
37-
v-model="showDialog"
38-
transition="dialog-bottom-transition"
39-
max-width="500px"
40-
scrollable
41-
attach="#modals"
42-
>
21+
<v-dialog v-model="showDialog" transition="dialog-bottom-transition" scrollable attach="#modals">
4322
<v-card>
44-
<v-card-title style="font-weight: bold">
45-
Failed Deployments
46-
</v-card-title>
23+
<v-card-title style="font-weight: bold"> Failed Deployments Details </v-card-title>
4724
<v-divider color="#FFCC00" />
4825
<v-card-text>
49-
<v-alert
50-
type="error"
51-
variant="tonal"
52-
>
53-
Failed to load
54-
<strong>{{ count - items.length }}</strong> deployment{{ count - items.length > 1 ? "s" : "" }}.
55-
56-
<span>
57-
This might happen because the node is down or it's not reachable
58-
<span v-if="showEncryption">or the deployment{{ count - items.length > 1 ? "s are" : " is" }} encrypted by another key</span>.
59-
</span>
60-
</v-alert>
61-
<v-list
26+
<v-data-table
27+
:headers="failedDeploymentsHeader"
6228
:items="failedDeploymentList"
63-
item-props
64-
lines="three"
65-
>
66-
<template #subtitle="{ subtitle }">
67-
<div v-html="subtitle" />
68-
</template>
69-
</v-list>
29+
:items-per-page-options="
30+
failedDeploymentList.length > 5
31+
? [
32+
{ value: 5, title: '5' },
33+
{ value: 10, title: '10' },
34+
{ value: 20, title: '20' },
35+
{ value: 50, title: '50' },
36+
]
37+
: undefined
38+
"
39+
:hide-default-footer="failedDeploymentList.length <= 5"
40+
class="mt-3"
41+
hover
42+
></v-data-table>
7043
</v-card-text>
7144
<v-card-actions class="justify-end my-1 mr-2">
72-
<v-btn
73-
color="anchor"
74-
@click="showDialog = false"
75-
>
76-
Close
77-
</v-btn>
45+
<v-btn color="anchor" @click="showDialog = false"> Close </v-btn>
7846
</v-card-actions>
7947
</v-card>
8048
</v-dialog>
@@ -139,10 +107,7 @@
139107
</template>
140108

141109
<template #[`item.flist`]="{ item }">
142-
<v-tooltip
143-
:text="item.flist"
144-
location="bottom right"
145-
>
110+
<v-tooltip :text="item.flist" location="bottom right">
146111
<template #activator="{ props: slotProps }">
147112
<p v-bind="slotProps">
148113
{{ renameFlist(item.flist) }}
@@ -158,40 +123,18 @@
158123
{{ toHumanDate(item.created) }}
159124
</template>
160125
<template #[`item.actions`]="{ item }">
161-
<v-chip
162-
v-if="deleting && ($props.modelValue || []).includes(item)"
163-
color="error"
164-
>
165-
Deleting...
166-
</v-chip>
167-
<v-btn-group
168-
v-else
169-
variant="tonal"
170-
>
171-
<slot
172-
:name="projectName + '-actions'"
173-
:item="item"
174-
:update="updateItem"
175-
/>
126+
<v-chip v-if="deleting && ($props.modelValue || []).includes(item)" color="error"> Deleting... </v-chip>
127+
<v-btn-group v-else variant="tonal">
128+
<slot :name="projectName + '-actions'" :item="item" :update="updateItem" />
176129
</v-btn-group>
177130
</template>
178131

179132
<template #[`item.status`]="{ item }">
180133
<v-chip :color="getNodeHealthColor(item.status as string).color">
181-
<v-tooltip
182-
v-if="item.status == NodeHealth.Error"
183-
activator="parent"
184-
location="top"
185-
>
186-
{{
187-
item.message
188-
}}
134+
<v-tooltip v-if="item.status == NodeHealth.Error" activator="parent" location="top">
135+
{{ item.message }}
189136
</v-tooltip>
190-
<v-tooltip
191-
v-if="item.status == NodeHealth.Paused"
192-
activator="parent"
193-
location="top"
194-
>
137+
<v-tooltip v-if="item.status == NodeHealth.Paused" activator="parent" location="top">
195138
The deployment contract is in grace period
196139
</v-tooltip>
197140
<span class="text-uppercase">
@@ -201,20 +144,10 @@
201144
</template>
202145
<template #[`item.health`]="{ item }">
203146
<v-chip :color="getNodeHealthColor(item[0].workloads[0].result.state as string).color">
204-
<v-tooltip
205-
v-if="item[0].workloads[0].result.state == NodeHealth.Error"
206-
activator="parent"
207-
location="top"
208-
>
209-
{{
210-
item.message
211-
}}
147+
<v-tooltip v-if="item[0].workloads[0].result.state == NodeHealth.Error" activator="parent" location="top">
148+
{{ item.message }}
212149
</v-tooltip>
213-
<v-tooltip
214-
v-if="item[0].workloads[0].result.state == NodeHealth.Paused"
215-
activator="parent"
216-
location="top"
217-
>
150+
<v-tooltip v-if="item[0].workloads[0].result.state == NodeHealth.Paused" activator="parent" location="top">
218151
The deployment contract is in grace period
219152
</v-tooltip>
220153
<span class="text-uppercase">
@@ -224,10 +157,7 @@
224157
</template>
225158

226159
<template #no-data-text>
227-
<div
228-
v-if="failedDeploymentList.length > 0"
229-
class="text-center"
230-
>
160+
<div v-if="failedDeploymentList.length > 0" class="text-center">
231161
<p v-text="'Couldn\'t load any of your ' + projectTitle + ' deployments.'" />
232162
<VBtn
233163
class="mt-4"
@@ -238,10 +168,7 @@
238168
@click="loadDeployments"
239169
/>
240170
</div>
241-
<p
242-
v-else
243-
v-text="'No ' + projectTitle + ' deployments found on this account.'"
244-
/>
171+
<p v-else v-text="'No ' + projectTitle + ' deployments found on this account.'" />
245172
</template>
246173
</ListTable>
247174
</div>
@@ -282,7 +209,11 @@ const failedDeployments = ref<
282209
>([]);
283210
const gridStore = useGrid();
284211
const grid = gridStore.client as GridClient;
285-
212+
const failedDeploymentsHeader = ref([
213+
{ title: "Name", key: "name", sortable: false },
214+
{ title: "Node ID", key: "nodes", sortable: false },
215+
{ title: "Contract ID", key: "contracts", sortable: false },
216+
]);
286217
onMounted(loadDeployments);
287218
288219
async function loadDomains() {
@@ -311,7 +242,7 @@ async function loadDeployments() {
311242
312243
items.value = [];
313244
loading.value = true;
314-
updateGrid(grid, { projectName: props.projectName});
245+
updateGrid(grid, { projectName: props.projectName });
315246
try {
316247
const chunk1 = await loadVms(grid!);
317248
if (chunk1.count > 0 && migrateGateways) {
@@ -483,36 +414,17 @@ const filteredHeaders = computed(() => {
483414
});
484415
485416
const failedDeploymentList = computed(() => {
486-
return failedDeployments.value
487-
.map(({ name, nodes = [], contracts = [] }, index) => {
488-
const nodeMessage =
489-
nodes.length > 0
490-
? `<span class="ml-4 text-primary font-weight-bold">On Node:</span> ${nodes.join(", ")}.<br/>`
491-
: "";
492-
const contractMessage =
493-
contracts.length > 0
494-
? ` <span class="ml-4 text-primary font-weight-bold">With Contract ID:</span> ${contracts
495-
.map(c => c.contractID)
496-
.join(", ")}.`
497-
: "";
498-
499-
const subtitle =
500-
nodeMessage + contractMessage === ""
501-
? `<span class="ml-4 text-error font-weight-bold">Error:</span> Failed to decrypt deployment data.`
502-
: nodeMessage + contractMessage;
503-
if (subtitle.includes("Failed to decrypt deployment data.")) {
504-
showEncryption.value = true;
505-
}
506-
507-
const item: any[] = [{ title: name, subtitle }];
508-
509-
if (index + 1 !== failedDeployments.value.length) {
510-
item.push({ type: "divider", inset: false });
511-
}
417+
return failedDeployments.value.map(({ name, nodes = [], contracts = [] }) => {
418+
if (nodes.length === 0 && contracts.length === 0) {
419+
showEncryption.value = true;
420+
}
512421
513-
return item;
514-
})
515-
.flat(1);
422+
return {
423+
name,
424+
nodes: nodes.length > 0 ? nodes.join(", ") : "N/A",
425+
contracts: contracts.length > 0 ? contracts.map(c => c.contractID).join(", ") : "N/A",
426+
};
427+
});
516428
});
517429
518430
function updateItem(newItem: any) {
@@ -539,7 +451,7 @@ import { ProjectName } from "../types";
539451
import { migrateModule } from "../utils/migration";
540452
import AccessDeploymentAlert from "./AccessDeploymentAlert.vue";
541453
import ListTable from "./list_table.vue";
542-
import { GridClient } from '@threefold/grid_client';
454+
import { GridClient } from "@threefold/grid_client";
543455
544456
export default {
545457
name: "VmDeploymentTable",

0 commit comments

Comments
 (0)