Skip to content

Commit daf2a05

Browse files
committed
feat(ui): improve task log view performance
1 parent f94764d commit daf2a05

File tree

7 files changed

+194
-70
lines changed

7 files changed

+194
-70
lines changed

web/src/App.vue

Lines changed: 14 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -54,32 +54,12 @@
5454
</template>
5555
</EditDialog>
5656

57-
<EditDialog
57+
<TaskLogDialog
5858
v-model="taskLogDialog"
59-
:max-width="1000"
60-
:hide-buttons="true"
61-
:expandable="true"
62-
name="TaskLogDialog"
6359
@close="onTaskLogDialogClosed()"
64-
no-body-paddings
65-
test-id="taskLogDialog"
66-
>
67-
<template v-slot:title={}>
68-
<div class="text-truncate" style="max-width: calc(100% - 36px);">
69-
<router-link
70-
class="breadcrumbs__item breadcrumbs__item--link"
71-
:to="`/project/${projectId}/templates/${template ? template.id : null}`"
72-
@click="taskLogDialog = false"
73-
>{{ template ? template.name : null }}
74-
</router-link>
75-
<v-icon>mdi-chevron-right</v-icon>
76-
<span class="breadcrumbs__item">{{ $t('task', {expr: task ? task.id : null}) }}</span>
77-
</div>
78-
</template>
79-
<template v-slot:form="{}">
80-
<TaskLogView :project-id="projectId" :item="task" />
81-
</template>
82-
</EditDialog>
60+
:project-id="projectId"
61+
:item-id="taskId"
62+
/>
8363

8464
<EditDialog
8565
v-model="newProjectDialog"
@@ -625,13 +605,16 @@
625605
.DarkModeSwitch {
626606
.v-input__prepend-outer {
627607
transform: translateY(1px);
608+
628609
.v-icon {
629610
color: #cacaca !important;
630611
}
631612
}
613+
632614
.v-input__append-outer {
633615
margin-left: 5px;
634616
transform: translateY(-1px);
617+
635618
.v-icon {
636619
color: #2196f3 !important;
637620
}
@@ -649,7 +632,6 @@
649632
650633
.v-data-table tbody tr.v-data-table__expanded__content {
651634
box-shadow: none !important;
652-
653635
}
654636
655637
.v-data-table a {
@@ -712,6 +694,7 @@
712694
td:first-child, th:first-child {
713695
padding-left: 2px !important;
714696
}
697+
715698
td:last-child, th:last-child {
716699
padding-right: 2px !important;
717700
}
@@ -723,6 +706,7 @@
723706
724707
.v-data-table__wrapper > table > tbody > tr {
725708
background: transparent !important;
709+
726710
&:hover {
727711
background-color: rgba(143, 143, 143, 0.04) !important;
728712
}
@@ -783,13 +767,13 @@
783767
import axios from 'axios';
784768
import { getErrorMessage } from '@/lib/error';
785769
import EditDialog from '@/components/EditDialog.vue';
786-
import TaskLogView from '@/components/TaskLogView.vue';
787770
import ProjectForm from '@/components/ProjectForm.vue';
788771
import UserForm from '@/components/UserForm.vue';
789772
import EventBus from '@/event-bus';
790773
import socket from '@/socket';
791774
import RestoreProjectForm from '@/components/RestoreProjectForm.vue';
792775
import YesNoDialog from '@/components/YesNoDialog.vue';
776+
import TaskLogDialog from '@/components/TaskLogDialog.vue';
793777
794778
const PROJECT_COLORS = [
795779
'red',
@@ -866,11 +850,11 @@ function getSystemLang() {
866850
export default {
867851
name: 'App',
868852
components: {
853+
TaskLogDialog,
869854
YesNoDialog,
870855
RestoreProjectForm,
871856
UserForm,
872857
EditDialog,
873-
TaskLogView,
874858
ProjectForm,
875859
},
876860
data() {
@@ -893,7 +877,7 @@ export default {
893877
restoreProjectResultDialog: null,
894878
895879
taskLogDialog: null,
896-
task: null,
880+
taskId: null,
897881
template: null,
898882
darkMode: false,
899883
languages: [
@@ -1021,21 +1005,10 @@ export default {
10211005
if (parseInt(this.$route.query.t || '', 10) !== e.taskId) {
10221006
const query = { ...this.$route.query, t: e.taskId };
10231007
await this.$router.replace({ query });
1024-
return; // router has watcher and emits `i-show-task` again after load.
1008+
return;
10251009
}
10261010
1027-
this.task = (await axios({
1028-
method: 'get',
1029-
url: `/api/project/${this.projectId}/tasks/${e.taskId}`,
1030-
responseType: 'json',
1031-
})).data;
1032-
1033-
this.template = (await axios({
1034-
method: 'get',
1035-
url: `/api/project/${this.projectId}/templates/${this.task.template_id}`,
1036-
responseType: 'json',
1037-
})).data;
1038-
1011+
this.taskId = e.taskId;
10391012
this.taskLogDialog = true;
10401013
});
10411014

web/src/components/EditTemplateDialog.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
:source-item-id="sourceItemId"
2323
:app="itemApp"
2424
:premium-features="premiumFeatures"
25+
:task-type="taskType"
2526
/>
2627
</template>
2728
</EditDialog>
@@ -51,6 +52,7 @@ export default {
5152
itemId: [String, Number],
5253
sourceItemId: Number,
5354
premiumFeatures: Object,
55+
taskType: String,
5456
},
5557
5658
data() {

web/src/components/ItemFormBase.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,6 @@ export default {
9595

9696
afterLoadData() {},
9797

98-
onLoadData() {},
99-
10098
getNewItem() {
10199
return {};
102100
},
@@ -110,14 +108,9 @@ export default {
110108
try {
111109
await this.beforeLoadData();
112110

113-
[
114-
this.item,
115-
] = await Promise.all([
116-
this.isNew
117-
? Promise.resolve(this.getNewItem())
118-
: this.loadEndpoint(this.getSingleItemUrl()),
119-
this.onLoadData(),
120-
]);
111+
this.item = this.isNew
112+
? this.getNewItem()
113+
: await this.loadEndpoint(this.getSingleItemUrl());
121114

122115
await this.afterLoadData();
123116
} catch (err) {

web/src/components/TaskLogDialog.vue

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
<template>
2+
<EditDialog
3+
v-model="dialog"
4+
:max-width="1000"
5+
:hide-buttons="true"
6+
:expandable="true"
7+
no-body-paddings
8+
@close="onClose()"
9+
test-id="taskLogDialog"
10+
>
11+
<template v-slot:title={}>
12+
<div class="text-truncate" style="max-width: calc(100% - 36px);">
13+
<v-skeleton-loader
14+
v-if="template == null"
15+
type="button"
16+
style="display: inline-block; margin-right: 10px;"
17+
></v-skeleton-loader>
18+
<router-link
19+
v-else
20+
class="breadcrumbs__item breadcrumbs__item--link"
21+
:to="`/project/${projectId}/templates/${template ? template.id : null}`"
22+
@click="close()"
23+
>{{ template ? template.name : null }}</router-link>
24+
<v-icon>mdi-chevron-right</v-icon>
25+
<span class="breadcrumbs__item">{{ $t('task', {expr: item ? item.id : null}) }}</span>
26+
</div>
27+
</template>
28+
<template v-slot:form="{}">
29+
<TaskLogView v-if="item != null" :project-id="projectId" :item="item" />
30+
<v-skeleton-loader
31+
class="task-log-view__placeholder"
32+
v-else
33+
type="
34+
table-heading,
35+
image,
36+
list-item-two-line,
37+
list-item-two-line,
38+
list-item-two-line,
39+
list-item-two-line,
40+
list-item-two-line,
41+
list-item-two-line,
42+
list-item-two-line,
43+
list-item-two-line"
44+
></v-skeleton-loader>
45+
</template>
46+
</EditDialog>
47+
</template>
48+
<style lang="scss">
49+
.task-log-view__placeholder {
50+
margin-left: 24px;
51+
margin-right: 24px;
52+
height: calc(100vh - 208px);
53+
}
54+
</style>
55+
<script>
56+
import TaskLogView from '@/components/TaskLogView.vue';
57+
import EditDialog from '@/components/EditDialog.vue';
58+
import ProjectMixin from '@/components/ProjectMixin';
59+
60+
export default {
61+
components: { EditDialog, TaskLogView },
62+
63+
mixins: [ProjectMixin],
64+
65+
props: {
66+
value: Boolean,
67+
projectId: Number,
68+
itemId: Number,
69+
},
70+
71+
watch: {
72+
async dialog(val) {
73+
this.$emit('input', val);
74+
},
75+
76+
async value(val) {
77+
this.item = null;
78+
this.template = null;
79+
this.dialog = val;
80+
await this.loadData();
81+
},
82+
83+
async itemId() {
84+
await this.loadData();
85+
},
86+
},
87+
88+
data() {
89+
return {
90+
item: null,
91+
dialog: null,
92+
template: null,
93+
};
94+
},
95+
96+
methods: {
97+
close() {
98+
this.dialog = false;
99+
this.item = null;
100+
this.template = null;
101+
this.onClose();
102+
},
103+
104+
async loadData() {
105+
this.item = await this.loadProjectResource('tasks', this.itemId);
106+
this.template = await this.loadProjectResource('templates', this.item.template_id);
107+
},
108+
109+
onClose() {
110+
this.$emit('close');
111+
},
112+
},
113+
};
114+
</script>

0 commit comments

Comments
 (0)