Skip to content

Commit 39ed4a1

Browse files
committed
refactor(ui): add common method loadProjectResouces for loading project related items
1 parent 6da1198 commit 39ed4a1

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

web/src/components/ItemListPageBase.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,5 +141,13 @@ export default {
141141
responseType: 'json',
142142
})).data;
143143
},
144+
145+
async loadProjectResources(name) {
146+
return (await axios({
147+
method: 'get',
148+
url: `/api/project/${this.projectId}/${name}`,
149+
responseType: 'json',
150+
})).data;
151+
},
144152
},
145153
};

web/src/views/project/Templates.vue

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -501,23 +501,15 @@ export default {
501501
},
502502
503503
async loadData() {
504-
this.inventory = (await axios({
505-
method: 'get',
506-
url: `/api/project/${this.projectId}/inventory`,
507-
responseType: 'json',
508-
})).data;
509-
510-
this.environment = (await axios({
511-
method: 'get',
512-
url: `/api/project/${this.projectId}/environment`,
513-
responseType: 'json',
514-
})).data;
515-
516-
this.repositories = (await axios({
517-
method: 'get',
518-
url: `/api/project/${this.projectId}/repositories`,
519-
responseType: 'json',
520-
})).data;
504+
[
505+
this.inventory,
506+
this.environment,
507+
this.repositories,
508+
] = await Promise.all([
509+
this.loadProjectResources('inventory'),
510+
this.loadProjectResources('environment'),
511+
this.loadProjectResources('repositories'),
512+
]);
521513
},
522514
523515
onTableSettingsChange({ headers }) {

0 commit comments

Comments
 (0)