|
1 | 1 | <template>
|
| 2 | + <div> |
| 3 | + <div id="projectsToolbar" class="bs-table-custom-toolbar"> |
| 4 | + <c-switch style="margin-left:1rem; margin-right:.5rem" id="showInactiveProjects" color="primary" v-model="showInactiveProjects" label v-bind="labelIcon" /><span class="text-muted">{{ $t('message.show_inactive_projects') }}</span> |
| 5 | + </div> |
2 | 6 | <bootstrap-table
|
3 | 7 | ref="table"
|
4 | 8 | :columns="columns"
|
5 | 9 | :data="data"
|
6 | 10 | :options="options"
|
7 |
| - @on-load-success="tableLoaded"> |
| 11 | + @on-load-success="tableLoaded" |
| 12 | + @on-post-body="onPostBody"> |
8 | 13 | </bootstrap-table>
|
| 14 | + </div> |
9 | 15 | </template>
|
10 | 16 |
|
11 | 17 | <script>
|
12 | 18 | import xssFilters from "xss-filters";
|
13 | 19 | import permissionsMixin from "../../../mixins/permissionsMixin";
|
| 20 | + import { Switch as cSwitch } from '@coreui/vue'; |
| 21 | +
|
14 | 22 |
|
15 | 23 | export default {
|
16 | 24 | mixins: [permissionsMixin],
|
| 25 | + components: { |
| 26 | + cSwitch |
| 27 | + }, |
| 28 | + beforeCreate() { |
| 29 | + this.showInactiveProjects = (localStorage && localStorage.getItem("AffectedProjectListShowInactiveProjects") !== null) ? (localStorage.getItem("AffectedProjectListShowInactiveProjects") === "true") : false; |
| 30 | + }, |
17 | 31 | props: {
|
18 | 32 | source: String,
|
19 | 33 | vulnId: String,
|
20 | 34 | vulnerability: String
|
21 | 35 | },
|
22 | 36 | data() {
|
23 | 37 | return {
|
| 38 | + showInactiveProjects: this.showInactiveProjects, |
| 39 | + labelIcon: { |
| 40 | + dataOn: '\u2713', |
| 41 | + dataOff: '\u2715' |
| 42 | + }, |
24 | 43 | columns: [
|
25 | 44 | {
|
26 | 45 | title: this.$t('message.name'),
|
|
45 | 64 | title: this.$t('message.version'),
|
46 | 65 | field: "version",
|
47 | 66 | sortable: true,
|
| 67 | + }, |
| 68 | + { |
| 69 | + title: this.$t('message.active'), |
| 70 | + field: "active", |
| 71 | + formatter(value) { |
| 72 | + return value === true ? '<i class="fa fa-check-square-o" />' : ""; |
| 73 | + }, |
| 74 | + align: "center", |
| 75 | + sortable: true |
48 | 76 | }
|
49 | 77 | ],
|
50 | 78 | data: [],
|
|
58 | 86 | queryParamsType: 'pageSize',
|
59 | 87 | pageList: '[10, 25, 50, 100]',
|
60 | 88 | pageSize: 10,
|
| 89 | + toolbar: '#projectsToolbar', |
61 | 90 | icons: {
|
62 | 91 | refresh: 'fa-refresh'
|
63 | 92 | },
|
64 |
| - url: `${this.$api.BASE_URL}/${this.$api.URL_VULNERABILITY}/source/${this.source}/vuln/${this.vulnId}/projects` |
| 93 | + url: this.apiUrl() |
65 | 94 | }
|
66 | 95 | };
|
67 | 96 | },
|
68 | 97 | methods: {
|
| 98 | + apiUrl: function () { |
| 99 | + let url = `${this.$api.BASE_URL}/${this.$api.URL_VULNERABILITY}/source/${this.source}/vuln/${this.vulnId}/projects`; |
| 100 | + if (this.showInactiveProjects === undefined) { |
| 101 | + url += "?excludeInactive=true"; |
| 102 | + } else { |
| 103 | + url += "?excludeInactive=" + !this.showInactiveProjects; |
| 104 | + } |
| 105 | + return url; |
| 106 | + }, |
69 | 107 | tableLoaded: function(array) {
|
70 | 108 | this.$emit('total', array.length);
|
| 109 | + }, |
| 110 | + refreshTable: function () { |
| 111 | + this.$refs.table.refresh({ |
| 112 | + url: this.apiUrl(), |
| 113 | + silent: true, |
| 114 | + pageNumber: 1 |
| 115 | + }); |
| 116 | + }, |
| 117 | + onPostBody: function () { |
| 118 | + this.$refs.table.hideLoading(); |
71 | 119 | }
|
| 120 | + }, |
| 121 | + watch: { |
| 122 | + showInactiveProjects() { |
| 123 | + if (localStorage) { |
| 124 | + localStorage.setItem("AffectedProjectListShowInactiveProjects", this.showInactiveProjects.toString()); |
| 125 | + } |
| 126 | + this.$refs.table.showLoading(); |
| 127 | + this.currentPage = 1; |
| 128 | + this.refreshTable(); |
| 129 | + }, |
72 | 130 | }
|
73 | 131 | };
|
74 | 132 | </script>
|
0 commit comments