-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathUnusedIndex.vue
More file actions
95 lines (90 loc) · 2.61 KB
/
UnusedIndex.vue
File metadata and controls
95 lines (90 loc) · 2.61 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
<template>
<DependencyIndexWrapper
:loading="loading"
:error="error"
loading-message="Loading tool dependency resolver information">
<template v-slot:body>
<GTable id="unused-paths-table" striped :fields="fields" :items="items" class="mb-3">
<template v-slot:cell(selected)="data">
<BFormCheckbox v-model="data.item.selected" />
</template>
</GTable>
</template>
<template v-slot:actions>
<div>
<GButton @click="deleteSelected"> Delete Selected Environments </GButton>
</div>
</template>
</DependencyIndexWrapper>
</template>
<script>
import { BFormCheckbox } from "bootstrap-vue";
import { deletedUnusedPaths, getDependencyUnusedPaths } from "../AdminServices";
import DependencyIndexWrapper from "./DependencyIndexWrapper.vue";
import GButton from "@/components/BaseComponents/GButton.vue";
import GTable from "@/components/Common/GTable.vue";
export default {
components: {
BFormCheckbox,
DependencyIndexWrapper,
GButton,
GTable,
},
data() {
return {
error: null,
loading: true,
fields: [
{ key: "selected", label: "" },
{ key: "path", label: "Path" },
],
paths: [],
};
},
computed: {
items: function () {
return this.paths.map((path) => {
return { path: path, selected: false, _showDetails: false };
});
},
hasSelectedPaths: function () {
for (const item of this.items) {
if (item["selected"]) {
return true;
}
}
return false;
},
},
created: function () {
this.load();
},
methods: {
load() {
getDependencyUnusedPaths()
.then((response) => {
this.paths = response;
this.loading = false;
})
.catch(this.handleError);
},
deleteSelected() {
const paths = [];
for (const item of this.items) {
if (item["selected"]) {
paths.push(item["path"]);
}
}
this.loading = true;
deletedUnusedPaths(paths)
.then(() => {
this.load();
})
.catch(this.handleError);
},
handleError(e) {
this.error = e;
},
},
};
</script>