@eclipse-slm/ui 1.5.0-snapshot.868 → 1.5.0-snapshot.877
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -1
- package/src/app/navigation.ts +7 -0
- package/src/app/routes.ts +6 -0
- package/src/components/base/ConfirmDialog.vue +39 -25
- package/src/components/base/CustomDialog.vue +31 -3
- package/src/components/base/IconPickerDialog.vue +155 -0
- package/src/components/capabilities/CapabilitiesTable.vue +209 -0
- package/src/components/capabilities/CapabilityActionCard.vue +76 -0
- package/src/components/capabilities/CapabilityCreateDialog.vue +86 -0
- package/src/components/capabilities/CapabilityCreateForm.vue +275 -0
- package/src/components/capabilities/CapabilityImportDialog.vue +99 -0
- package/src/components/capabilities/capabilityForm.ts +201 -0
- package/src/components/core/Drawer.vue +12 -2
- package/src/components/resources/dialogs/AddItemChooserDialog.vue +68 -0
- package/src/localisation/en.json +3 -0
- package/src/pages/AdminCapabilitiesPage.vue +60 -0
- package/src/pages/ResourceInstancesPage.vue +71 -0
- package/src/stores/capabilitiesStore.ts +45 -2
- package/src/utils/mdiIcons.ts +49 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import CustomDialog from '@/components/base/CustomDialog.vue';
|
|
3
|
+
|
|
4
|
+
defineProps({
|
|
5
|
+
show: {
|
|
6
|
+
type: Boolean,
|
|
7
|
+
default: false
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
const emit = defineEmits(['device', 'capability', 'canceled']);
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<template>
|
|
14
|
+
<CustomDialog
|
|
15
|
+
:show="show"
|
|
16
|
+
title="Add"
|
|
17
|
+
width="500"
|
|
18
|
+
:hide-actions="true"
|
|
19
|
+
@canceled="emit('canceled')"
|
|
20
|
+
>
|
|
21
|
+
<template #content>
|
|
22
|
+
<div class="d-flex ga-4">
|
|
23
|
+
<v-card
|
|
24
|
+
class="chooser-tile flex-1-1 text-center pa-4"
|
|
25
|
+
variant="outlined"
|
|
26
|
+
hover
|
|
27
|
+
@click="emit('device')"
|
|
28
|
+
>
|
|
29
|
+
<v-icon
|
|
30
|
+
icon="mdi-devices"
|
|
31
|
+
size="48"
|
|
32
|
+
color="primary"
|
|
33
|
+
/>
|
|
34
|
+
<div class="text-h6 mt-2">
|
|
35
|
+
Device
|
|
36
|
+
</div>
|
|
37
|
+
<div class="text-caption">
|
|
38
|
+
Register a new device
|
|
39
|
+
</div>
|
|
40
|
+
</v-card>
|
|
41
|
+
<v-card
|
|
42
|
+
class="chooser-tile flex-1-1 text-center pa-4"
|
|
43
|
+
variant="outlined"
|
|
44
|
+
hover
|
|
45
|
+
@click="emit('capability')"
|
|
46
|
+
>
|
|
47
|
+
<v-icon
|
|
48
|
+
icon="mdi-puzzle"
|
|
49
|
+
size="48"
|
|
50
|
+
color="primary"
|
|
51
|
+
/>
|
|
52
|
+
<div class="text-h6 mt-2">
|
|
53
|
+
Capability
|
|
54
|
+
</div>
|
|
55
|
+
<div class="text-caption">
|
|
56
|
+
Define a new capability
|
|
57
|
+
</div>
|
|
58
|
+
</v-card>
|
|
59
|
+
</div>
|
|
60
|
+
</template>
|
|
61
|
+
</CustomDialog>
|
|
62
|
+
</template>
|
|
63
|
+
|
|
64
|
+
<style scoped>
|
|
65
|
+
.chooser-tile {
|
|
66
|
+
cursor: pointer;
|
|
67
|
+
}
|
|
68
|
+
</style>
|
package/src/localisation/en.json
CHANGED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<v-container
|
|
3
|
+
id="admin-capabilities"
|
|
4
|
+
fluid
|
|
5
|
+
tag="section"
|
|
6
|
+
>
|
|
7
|
+
<div
|
|
8
|
+
v-if="apiStateLoading"
|
|
9
|
+
class="text-center"
|
|
10
|
+
>
|
|
11
|
+
<v-progress-circular
|
|
12
|
+
:size="70"
|
|
13
|
+
:width="7"
|
|
14
|
+
color="primary"
|
|
15
|
+
indeterminate
|
|
16
|
+
/>
|
|
17
|
+
</div>
|
|
18
|
+
<div v-if="apiStateError">
|
|
19
|
+
Error
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
<div v-if="apiStateLoaded">
|
|
23
|
+
<CapabilitiesTable />
|
|
24
|
+
<CapabilityCreateDialog
|
|
25
|
+
:show="showCreateDialog"
|
|
26
|
+
@canceled="showCreateDialog = false"
|
|
27
|
+
@confirmed="showCreateDialog = false"
|
|
28
|
+
/>
|
|
29
|
+
<v-fab
|
|
30
|
+
icon="mdi-plus"
|
|
31
|
+
class="mx-4"
|
|
32
|
+
elevation="15"
|
|
33
|
+
color="primary"
|
|
34
|
+
location="right bottom"
|
|
35
|
+
:app="true"
|
|
36
|
+
@click="showCreateDialog = true"
|
|
37
|
+
/>
|
|
38
|
+
</div>
|
|
39
|
+
</v-container>
|
|
40
|
+
</template>
|
|
41
|
+
|
|
42
|
+
<script setup lang="ts">
|
|
43
|
+
import { computed, onMounted, ref } from 'vue';
|
|
44
|
+
import ApiState from '@/api/apiState';
|
|
45
|
+
import CapabilitiesTable from '@/components/capabilities/CapabilitiesTable.vue';
|
|
46
|
+
import CapabilityCreateDialog from '@/components/capabilities/CapabilityCreateDialog.vue';
|
|
47
|
+
import { useCapabilitiesStore } from '@/stores/capabilitiesStore';
|
|
48
|
+
|
|
49
|
+
const capabilitiesStore = useCapabilitiesStore();
|
|
50
|
+
|
|
51
|
+
const showCreateDialog = ref(false);
|
|
52
|
+
|
|
53
|
+
const apiStateLoaded = computed(() => capabilitiesStore.apiState === ApiState.LOADED || capabilitiesStore.apiState === ApiState.UPDATING);
|
|
54
|
+
const apiStateLoading = computed(() => capabilitiesStore.apiState === ApiState.LOADING || capabilitiesStore.apiState === ApiState.INIT);
|
|
55
|
+
const apiStateError = computed(() => capabilitiesStore.apiState === ApiState.ERROR);
|
|
56
|
+
|
|
57
|
+
onMounted(() => {
|
|
58
|
+
capabilitiesStore.updateStore();
|
|
59
|
+
});
|
|
60
|
+
</script>
|
|
@@ -52,7 +52,70 @@
|
|
|
52
52
|
@canceled="showCreateDialog = false"
|
|
53
53
|
@confirmed="showCreateDialog = false"
|
|
54
54
|
/>
|
|
55
|
+
<CapabilityCreateDialog
|
|
56
|
+
:show="showCapabilityDialog"
|
|
57
|
+
@canceled="showCapabilityDialog = false"
|
|
58
|
+
@confirmed="showCapabilityDialog = false"
|
|
59
|
+
/>
|
|
60
|
+
<AddItemChooserDialog
|
|
61
|
+
:show="showChooserDialog"
|
|
62
|
+
@canceled="showChooserDialog = false"
|
|
63
|
+
@device="showChooserDialog = false; showCreateDialog = true"
|
|
64
|
+
@capability="showChooserDialog = false; showCapabilityDialog = true"
|
|
65
|
+
/>
|
|
66
|
+
<!-- Speed dial sits inside the fab with activator="parent": with :app the fab's root element is the
|
|
67
|
+
full-height layout wrapper, so using it as activator would anchor the sub-buttons at the top of the page -->
|
|
68
|
+
<v-fab
|
|
69
|
+
v-if="isAdmin"
|
|
70
|
+
:active="!showCreateButton"
|
|
71
|
+
icon
|
|
72
|
+
class="mx-4"
|
|
73
|
+
elevation="15"
|
|
74
|
+
color="primary"
|
|
75
|
+
location="right bottom"
|
|
76
|
+
:app="true"
|
|
77
|
+
@click="showChooserDialog = true"
|
|
78
|
+
>
|
|
79
|
+
<v-icon>mdi-plus</v-icon>
|
|
80
|
+
<v-speed-dial
|
|
81
|
+
activator="parent"
|
|
82
|
+
open-on-hover
|
|
83
|
+
location="left center"
|
|
84
|
+
>
|
|
85
|
+
<v-fab
|
|
86
|
+
key="device"
|
|
87
|
+
icon
|
|
88
|
+
size="small"
|
|
89
|
+
color="primary"
|
|
90
|
+
@click="showCreateDialog = true"
|
|
91
|
+
>
|
|
92
|
+
<v-icon>mdi-devices</v-icon>
|
|
93
|
+
<v-tooltip
|
|
94
|
+
activator="parent"
|
|
95
|
+
location="top"
|
|
96
|
+
>
|
|
97
|
+
Add device
|
|
98
|
+
</v-tooltip>
|
|
99
|
+
</v-fab>
|
|
100
|
+
<v-fab
|
|
101
|
+
key="capability"
|
|
102
|
+
icon
|
|
103
|
+
size="small"
|
|
104
|
+
color="primary"
|
|
105
|
+
@click="showCapabilityDialog = true"
|
|
106
|
+
>
|
|
107
|
+
<v-icon>mdi-puzzle</v-icon>
|
|
108
|
+
<v-tooltip
|
|
109
|
+
activator="parent"
|
|
110
|
+
location="top"
|
|
111
|
+
>
|
|
112
|
+
Add capability
|
|
113
|
+
</v-tooltip>
|
|
114
|
+
</v-fab>
|
|
115
|
+
</v-speed-dial>
|
|
116
|
+
</v-fab>
|
|
55
117
|
<v-fab
|
|
118
|
+
v-else
|
|
56
119
|
:active="!showCreateButton"
|
|
57
120
|
icon="mdi-plus"
|
|
58
121
|
class="mx-4"
|
|
@@ -77,14 +140,22 @@ import DeviceInfoView from "@/components/resources/deviceinfo/DeviceInfoView.vue
|
|
|
77
140
|
import OverviewHeading from "@/components/base/OverviewHeading.vue";
|
|
78
141
|
import ResourcesTableDevices from "@/components/resources/ResourcesTableDevices.vue";
|
|
79
142
|
import {useCapabilitiesStore} from "@/stores/capabilitiesStore";
|
|
143
|
+
import {useUserStore} from "@/stores/userStore";
|
|
144
|
+
import AddItemChooserDialog from "@/components/resources/dialogs/AddItemChooserDialog.vue";
|
|
145
|
+
import CapabilityCreateDialog from "@/components/capabilities/CapabilityCreateDialog.vue";
|
|
80
146
|
|
|
81
147
|
const resourceDevicesStore = useResourceDevicesStore();
|
|
82
148
|
const capabilitiesStore = useCapabilitiesStore();
|
|
149
|
+
const userStore = useUserStore();
|
|
150
|
+
|
|
151
|
+
const isAdmin = computed(() => userStore.userRoles.includes('slm-admin'));
|
|
83
152
|
|
|
84
153
|
const selectedResource = ref(null);
|
|
85
154
|
const selectedSection = ref("common");
|
|
86
155
|
const showCreateDialog = ref(false);
|
|
87
156
|
const showCreateButton = ref(false);
|
|
157
|
+
const showChooserDialog = ref(false);
|
|
158
|
+
const showCapabilityDialog = ref(false);
|
|
88
159
|
|
|
89
160
|
const resources = computed(() => resourceDevicesStore.resources);
|
|
90
161
|
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import ApiState from '@/api/apiState'
|
|
2
2
|
import {defineStore} from "pinia";
|
|
3
3
|
import ResourceManagementClient from "@/api/resource-management/resource-management-client";
|
|
4
|
-
import {CapabilityServiceDTO, ResourceDTO} from "@/api/resource-management/client";
|
|
4
|
+
import {CapabilityServiceDTO, GetCapabilities200ResponseInner, ResourceDTO} from "@/api/resource-management/client";
|
|
5
|
+
|
|
6
|
+
export class CapabilityInUseError extends Error {
|
|
7
|
+
constructor(public installCount: number) {
|
|
8
|
+
super(`Capability is installed ${installCount} time(s)`)
|
|
9
|
+
this.name = 'CapabilityInUseError'
|
|
10
|
+
}
|
|
11
|
+
}
|
|
5
12
|
|
|
6
13
|
interface CapabilitiesStoreState{
|
|
7
14
|
apiState: number,
|
|
@@ -47,6 +54,10 @@ export const useCapabilitiesStore = defineStore('capabilitiesStore', {
|
|
|
47
54
|
return capability;
|
|
48
55
|
},
|
|
49
56
|
|
|
57
|
+
installCountOfCapability: (state) => (capabilityId: string) => {
|
|
58
|
+
return state.capabilityServices.filter(capabilityService => capabilityService.capabilityId === capabilityId).length
|
|
59
|
+
},
|
|
60
|
+
|
|
50
61
|
isCapabilityInstalledOnResource: (state) => (resource: ResourceDTO, capabilityId) => {
|
|
51
62
|
for (const capabilityServiceId of resource.capabilityServiceIds) {
|
|
52
63
|
const capabilityService = state.capabilityServices.find(capabilityService => capabilityService.id === capabilityServiceId)
|
|
@@ -93,6 +104,39 @@ export const useCapabilitiesStore = defineStore('capabilitiesStore', {
|
|
|
93
104
|
})
|
|
94
105
|
},
|
|
95
106
|
|
|
107
|
+
async createCapability(body: GetCapabilities200ResponseInner) {
|
|
108
|
+
await ResourceManagementClient.capabilityApi.createCapability(body)
|
|
109
|
+
await this.reloadAfterChange()
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
async deleteCapability(capabilityId: string) {
|
|
113
|
+
// Fetch directly (not via getCapabilityServices, which swallows errors) so a failed fetch aborts the delete
|
|
114
|
+
const response = await ResourceManagementClient.capabilityApi.getAllCapabilityServices()
|
|
115
|
+
if (!Array.isArray(response.data)) {
|
|
116
|
+
throw new Error("Could not verify where the capability is installed")
|
|
117
|
+
}
|
|
118
|
+
this.capabilityServices = response.data
|
|
119
|
+
|
|
120
|
+
const installCount = this.installCountOfCapability(capabilityId)
|
|
121
|
+
if (installCount > 0) {
|
|
122
|
+
throw new CapabilityInUseError(installCount)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
await ResourceManagementClient.capabilityApi.deleteCapability(capabilityId)
|
|
126
|
+
await this.reloadAfterChange()
|
|
127
|
+
// A successful delete is authoritative even if the list reload failed or returned stale data.
|
|
128
|
+
this.capabilities = this.capabilities.filter(capability => capability.id !== capabilityId)
|
|
129
|
+
},
|
|
130
|
+
|
|
131
|
+
// The change already succeeded; a failed reload must not make it look failed (a retry would duplicate it)
|
|
132
|
+
async reloadAfterChange() {
|
|
133
|
+
try {
|
|
134
|
+
await this.getCapabilities()
|
|
135
|
+
} catch (e) {
|
|
136
|
+
console.error('Failed to reload capabilities after a successful change', e)
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
|
|
96
140
|
async updateStore () {
|
|
97
141
|
if (this.apiState === ApiState.INIT) {
|
|
98
142
|
this.apiState = ApiState.LOADING;
|
|
@@ -113,4 +157,3 @@ export const useCapabilitiesStore = defineStore('capabilitiesStore', {
|
|
|
113
157
|
},
|
|
114
158
|
},
|
|
115
159
|
});
|
|
116
|
-
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export const MDI_META_URL = 'https://cdn.jsdelivr.net/npm/@mdi/svg@latest/meta.json'
|
|
2
|
+
|
|
3
|
+
export interface MdiIconMeta {
|
|
4
|
+
name: string
|
|
5
|
+
aliases: string[]
|
|
6
|
+
tags: string[]
|
|
7
|
+
deprecated: boolean
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
let cache: Promise<MdiIconMeta[]> | null = null
|
|
11
|
+
|
|
12
|
+
export function resetMdiIconCache(): void {
|
|
13
|
+
cache = null
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function loadMdiIcons(fetchFn: typeof fetch = fetch): Promise<MdiIconMeta[]> {
|
|
17
|
+
if (cache) return cache
|
|
18
|
+
const pending = (async () => {
|
|
19
|
+
const response = await fetchFn(MDI_META_URL)
|
|
20
|
+
if (!response.ok) {
|
|
21
|
+
throw new Error(`Failed to load MDI icon list (HTTP ${response.status})`)
|
|
22
|
+
}
|
|
23
|
+
const data = (await response.json()) as MdiIconMeta[]
|
|
24
|
+
return data
|
|
25
|
+
.filter((icon) => !icon.deprecated)
|
|
26
|
+
.map((icon) => ({
|
|
27
|
+
name: icon.name,
|
|
28
|
+
aliases: icon.aliases ?? [],
|
|
29
|
+
tags: icon.tags ?? [],
|
|
30
|
+
deprecated: false,
|
|
31
|
+
}))
|
|
32
|
+
})()
|
|
33
|
+
cache = pending
|
|
34
|
+
pending.catch(() => {
|
|
35
|
+
if (cache === pending) cache = null
|
|
36
|
+
})
|
|
37
|
+
return pending
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function filterIcons(icons: MdiIconMeta[], query: string | null | undefined): MdiIconMeta[] {
|
|
41
|
+
const q = (query ?? '').trim().toLowerCase()
|
|
42
|
+
if (!q) return icons
|
|
43
|
+
return icons.filter(
|
|
44
|
+
(icon) =>
|
|
45
|
+
icon.name.toLowerCase().includes(q) ||
|
|
46
|
+
icon.aliases.some((a) => a.toLowerCase().includes(q)) ||
|
|
47
|
+
icon.tags.some((t) => t.toLowerCase().includes(q)),
|
|
48
|
+
)
|
|
49
|
+
}
|