-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathExportRecordTable.vue
More file actions
137 lines (118 loc) · 4.58 KB
/
ExportRecordTable.vue
File metadata and controls
137 lines (118 loc) · 4.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<script setup lang="ts">
import {
faCheckCircle,
faDownload,
faExclamationCircle,
faFileImport,
faLink,
faSpinner,
} from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
import type { TableField } from "@/components/Common/GTable.types";
import type { ExportRecord } from "./models/exportRecordModel";
import GButton from "@/components/BaseComponents/GButton.vue";
import GButtonGroup from "@/components/BaseComponents/GButtonGroup.vue";
import GTable from "@/components/Common/GTable.vue";
interface Props {
records: ExportRecord[];
}
const props = defineProps<Props>();
const emit = defineEmits<{
(e: "onReimport", record: ExportRecord): void;
(e: "onDownload", record: ExportRecord): void;
(e: "onCopyDownloadLink", record: ExportRecord): void;
}>();
const fields: TableField[] = [
{ key: "elapsedTime", label: "Exported" },
{ key: "format", label: "Format" },
{ key: "expires", label: "Expires" },
{ key: "isUpToDate", label: "Up to date", align: "center" },
{ key: "isReady", label: "Ready", align: "center" },
{ key: "actions", label: "Actions", align: "center" },
];
async function reimportObject(record: ExportRecord) {
emit("onReimport", record);
}
function downloadObject(record: ExportRecord) {
emit("onDownload", record);
}
function copyDownloadLink(record: ExportRecord) {
emit("onCopyDownloadLink", record);
}
</script>
<template>
<GTable :items="props.records" :fields="fields">
<template v-slot:cell(elapsedTime)="row">
<span :title="row.item.date.toLocaleString()">{{ row.value }}</span>
</template>
<template v-slot:cell(format)="row">
<span>{{ row.item.modelStoreFormat }}</span>
</template>
<template v-slot:cell(expires)="row">
<span v-if="row.item.hasExpired">Expired</span>
<span v-else-if="row.item.expirationDate" :title="row.item.expirationDate.toLocaleString()">
{{ row.item.expirationElapsedTime }}
</span>
<span v-else>No</span>
</template>
<template v-slot:cell(isUpToDate)="row">
<FontAwesomeIcon
v-if="row.item.isUpToDate"
:icon="faCheckCircle"
class="text-success"
title="This export record contains the latest changes." />
<FontAwesomeIcon
v-else
:icon="faExclamationCircle"
class="text-danger"
title="This export record is outdated. Please consider generating a new export if you need the latest changes." />
</template>
<template v-slot:cell(isReady)="row">
<FontAwesomeIcon
v-if="row.item.isReady"
:icon="faCheckCircle"
class="text-success"
title="Ready to download or import." />
<FontAwesomeIcon
v-else-if="row.item.isPreparing"
:icon="faSpinner"
spin
class="text-info"
title="Exporting in progress..." />
<FontAwesomeIcon
v-else-if="row.item.hasExpired"
:icon="faExclamationCircle"
class="text-danger"
title="The export has expired." />
<FontAwesomeIcon v-else :icon="faExclamationCircle" class="text-danger" title="The export failed." />
</template>
<template v-slot:cell(actions)="row">
<GButtonGroup aria-label="Actions">
<GButton
tooltip
tooltip-placement="bottom"
:disabled="!row.item.canDownload"
title="Download"
@click="downloadObject(row.item)">
<FontAwesomeIcon :icon="faDownload" />
</GButton>
<GButton
v-if="row.item.canDownload"
tooltip
tooltip-placement="bottom"
title="Copy Download Link"
@click.stop="copyDownloadLink(row.item)">
<FontAwesomeIcon :icon="faLink" />
</GButton>
<GButton
tooltip
tooltip-placement="bottom"
:disabled="!row.item.canReimport"
title="Reimport"
@click="reimportObject(row.item)">
<FontAwesomeIcon :icon="faFileImport" />
</GButton>
</GButtonGroup>
</template>
</GTable>
</template>