@eclipse-slm/ui 1.5.0-snapshot.1 → 1.5.0-snapshot.1017
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/README.md +8 -0
- package/package.json +9 -7
- package/src/api/ansible-service/ansible-service-client.ts +15 -0
- package/src/api/ansible-service/ansible-service-sse.ts +124 -0
- package/src/api/notification-service/notificationServiceWebsocketClient.js +5 -5
- package/src/api/platform-management/platform-management-client.ts +2 -2
- package/src/api/resource-management/resource-management-client.ts +0 -2
- package/src/app/appInstance.ts +8 -0
- package/src/app/navigation.ts +21 -0
- package/src/app/routes.ts +23 -0
- package/src/components/admin/ansible/AnsibleAdminImages.vue +113 -0
- package/src/components/admin/ansible/AnsibleAdminJobs.vue +179 -0
- package/src/components/admin/ansible/AnsibleAdminOperations.vue +124 -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 +77 -0
- package/src/components/capabilities/CapabilityCreateDialog.vue +86 -0
- package/src/components/capabilities/CapabilityCreateForm.vue +306 -0
- package/src/components/capabilities/CapabilityImportDialog.vue +108 -0
- package/src/components/capabilities/capabilityForm.ts +244 -0
- package/src/components/core/AppBar.vue +1 -1
- package/src/components/core/Drawer.vue +12 -2
- package/src/components/jobs/JobDetail.vue +413 -0
- package/src/components/jobs/JobStatusChip.vue +16 -0
- package/src/components/jobs/JobsOverview.vue +59 -72
- package/src/components/profilers/ProfilerDialog.vue +95 -0
- package/src/components/profilers/ProfilerForm.vue +102 -0
- package/src/components/profilers/ProfilersTable.vue +98 -0
- package/src/components/profilers/profilerForm.ts +61 -0
- package/src/components/resources/deviceinfo/DeviceInfoView.vue +9 -1
- package/src/components/resources/dialogs/AddItemChooserDialog.vue +68 -0
- package/src/components/service_offerings/ServiceOfferingCardGrid.vue +1 -1
- package/src/components/service_offerings/wizard_service_offering_version/ServiceOfferingVersionWizardStep2DeploymentDefinitionDockerCompose.vue +1 -2
- package/src/components/service_offerings/wizard_service_offering_version/ServiceOfferingVersionWizardStep2DeploymentDefinitionKubernetes.vue +1 -2
- package/src/components/service_vendors/ServiceVendorDevelopersTable.vue +1 -1
- package/src/docker/entrypoint.sh +2 -2
- package/src/localisation/en.json +93 -0
- package/src/main.ts +3 -6
- package/src/pages/AdminAnsibleServicePage.vue +111 -0
- package/src/pages/AdminCapabilitiesPage.vue +60 -0
- package/src/pages/AdminProfilersPage.vue +73 -0
- package/src/pages/DashboardPage.vue +28 -56
- package/src/pages/JobDetailPage.vue +7 -0
- package/src/pages/ResourceInstancesPage.vue +71 -0
- package/src/pages/ServiceOfferingCreateOrEditPage.vue +2 -2
- package/src/stores/ansibleAdminStore.ts +206 -0
- package/src/stores/capabilitiesStore.ts +45 -2
- package/src/stores/environmentStore.ts +3 -3
- package/src/stores/jobsStore.ts +39 -39
- package/src/stores/notificationStore.ts +15 -1
- package/src/stores/profilersStore.ts +80 -0
- package/src/stores/resourceDevicesStore.ts +2 -2
- package/src/stores/serviceInstancesStore.ts +0 -1
- package/src/stores/serviceOfferingsStore.ts +1 -1
- package/src/stores/userStore.ts +1 -1
- package/src/utils/i18n.ts +4 -2
- package/src/utils/imageUtil.js +1 -1
- package/src/utils/jobStatus.ts +76 -0
- package/src/utils/mdiIcons.ts +49 -0
- package/src/utils/notificationTextGenerator.ts +27 -1
- package/src/utils/tokenInterceptor.js +1 -1
- package/src/utils/updateToken.js +1 -1
- package/vite/dist/apiClients.d.ts +1 -1
- package/vite/dist/apiClients.js +1 -0
- package/vite/dist/index.js +25 -4
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<v-chip
|
|
3
|
+
:color="jobStatusColor(status)"
|
|
4
|
+
size="small"
|
|
5
|
+
variant="flat"
|
|
6
|
+
:prepend-icon="jobStatusIcon(status)"
|
|
7
|
+
>
|
|
8
|
+
{{ jobStatusLabel(status) }}
|
|
9
|
+
</v-chip>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script setup lang="ts">
|
|
13
|
+
import {jobStatusColor, jobStatusIcon, jobStatusLabel} from "@/utils/jobStatus";
|
|
14
|
+
|
|
15
|
+
defineProps<{ status?: string | null }>();
|
|
16
|
+
</script>
|
|
@@ -21,42 +21,54 @@
|
|
|
21
21
|
<overview-heading text="Jobs" />
|
|
22
22
|
</template>
|
|
23
23
|
|
|
24
|
+
<v-select
|
|
25
|
+
v-model="statusFilter"
|
|
26
|
+
:items="statuses"
|
|
27
|
+
label="Status"
|
|
28
|
+
multiple
|
|
29
|
+
chips
|
|
30
|
+
clearable
|
|
31
|
+
density="compact"
|
|
32
|
+
class="mb-2"
|
|
33
|
+
/>
|
|
34
|
+
|
|
24
35
|
<v-data-table
|
|
25
|
-
v-if="
|
|
36
|
+
v-if="filteredJobs.length > 0"
|
|
26
37
|
id="jobsTable"
|
|
27
38
|
v-model:sort-by="sortBy"
|
|
28
|
-
:footer-props="{
|
|
29
|
-
'items-per-page-options': [5, 10, 20, -1],
|
|
30
|
-
}"
|
|
31
39
|
:headers="DataTableHeaders"
|
|
32
40
|
item-key="id"
|
|
33
|
-
:items="
|
|
41
|
+
:items="filteredJobs"
|
|
42
|
+
hover
|
|
43
|
+
@click:row="(_event, row) => openJob(row.item.id)"
|
|
34
44
|
>
|
|
35
45
|
<template #item.id="{ item }">
|
|
36
|
-
<
|
|
37
|
-
:
|
|
38
|
-
|
|
39
|
-
>
|
|
46
|
+
<router-link
|
|
47
|
+
:to="`/jobs/${item.id}`"
|
|
48
|
+
@click.stop
|
|
49
|
+
>
|
|
50
|
+
{{ item.id.substring(0, 8) }}
|
|
51
|
+
</router-link>
|
|
40
52
|
</template>
|
|
41
53
|
|
|
42
54
|
<template #item.name="{ item }">
|
|
43
|
-
{{ item.
|
|
55
|
+
{{ item.serviceName || item.playbook }}
|
|
44
56
|
</template>
|
|
45
57
|
|
|
46
|
-
<template #item.
|
|
47
|
-
{{
|
|
58
|
+
<template #item.createdAt="{ item }">
|
|
59
|
+
{{ formatJobDate(item.createdAt) }}
|
|
48
60
|
</template>
|
|
49
61
|
|
|
50
|
-
<template #item.
|
|
51
|
-
{{
|
|
62
|
+
<template #item.finishedAt="{ item }">
|
|
63
|
+
{{ formatJobDate(item.finishedAt) }}
|
|
52
64
|
</template>
|
|
53
65
|
|
|
54
|
-
<template #item.
|
|
55
|
-
{{
|
|
66
|
+
<template #item.duration="{ item }">
|
|
67
|
+
{{ formatDuration(jobDurationMs(item, now)) }}
|
|
56
68
|
</template>
|
|
57
69
|
|
|
58
70
|
<template #item.status="{ item }">
|
|
59
|
-
|
|
71
|
+
<job-status-chip :status="item.status" />
|
|
60
72
|
</template>
|
|
61
73
|
</v-data-table>
|
|
62
74
|
|
|
@@ -73,26 +85,29 @@
|
|
|
73
85
|
|
|
74
86
|
import OverviewHeading from "@/components/base/OverviewHeading.vue";
|
|
75
87
|
import NoItemAvailableNote from "@/components/base/NoItemAvailableNote.vue";
|
|
88
|
+
import JobStatusChip from "@/components/jobs/JobStatusChip.vue";
|
|
76
89
|
import {useJobsStore} from "@/stores/jobsStore";
|
|
77
90
|
import ApiState from "@/api/apiState";
|
|
78
|
-
import {
|
|
91
|
+
import {JOB_STATUSES, formatDuration, formatJobDate, jobDurationMs} from "@/utils/jobStatus";
|
|
79
92
|
|
|
80
93
|
export default {
|
|
81
94
|
name: 'JobsOverview',
|
|
82
95
|
components: {
|
|
83
96
|
OverviewHeading,
|
|
84
|
-
NoItemAvailableNote
|
|
97
|
+
NoItemAvailableNote,
|
|
98
|
+
JobStatusChip,
|
|
85
99
|
},
|
|
86
100
|
setup(){
|
|
87
|
-
const envStore = useEnvStore();
|
|
88
101
|
const jobsStore = useJobsStore();
|
|
89
|
-
return {
|
|
102
|
+
return {jobsStore, formatJobDate, formatDuration, jobDurationMs}
|
|
90
103
|
},
|
|
91
104
|
data: function () {
|
|
92
105
|
return {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
106
|
+
sortBy: [{key: 'createdAt', order: 'desc'}],
|
|
107
|
+
statuses: JOB_STATUSES,
|
|
108
|
+
statusFilter: [],
|
|
109
|
+
now: Date.now(),
|
|
110
|
+
ticker: null,
|
|
96
111
|
}
|
|
97
112
|
},
|
|
98
113
|
computed: {
|
|
@@ -100,7 +115,7 @@ export default {
|
|
|
100
115
|
return this.jobsStore.apiState
|
|
101
116
|
},
|
|
102
117
|
apiStateLoaded () {
|
|
103
|
-
return this.apiStateJobs === ApiState.LOADED
|
|
118
|
+
return this.apiStateJobs === ApiState.LOADED || this.apiStateJobs === ApiState.UPDATING
|
|
104
119
|
},
|
|
105
120
|
apiStateLoading () {
|
|
106
121
|
if (this.apiStateJobs === ApiState.INIT) {
|
|
@@ -114,60 +129,32 @@ export default {
|
|
|
114
129
|
jobs () {
|
|
115
130
|
return this.jobsStore.jobs
|
|
116
131
|
},
|
|
117
|
-
|
|
118
|
-
return this.
|
|
132
|
+
filteredJobs () {
|
|
133
|
+
return this.statusFilter.length > 0
|
|
134
|
+
? this.jobs.filter(job => this.statusFilter.includes(job.status))
|
|
135
|
+
: this.jobs
|
|
119
136
|
},
|
|
120
137
|
DataTableHeaders () {
|
|
121
138
|
return [
|
|
122
|
-
{ title: 'ID',
|
|
123
|
-
{ title: 'Name',
|
|
124
|
-
{ title: '
|
|
125
|
-
{ title: 'Finished at',
|
|
126
|
-
{ title: 'Duration',
|
|
127
|
-
{ title: 'Status',
|
|
139
|
+
{ title: 'ID', key: 'id', sortable: true },
|
|
140
|
+
{ title: 'Name', key: 'name', value: item => item.serviceName || item.playbook, sortable: true },
|
|
141
|
+
{ title: 'Created at', key: 'createdAt', sortable: true },
|
|
142
|
+
{ title: 'Finished at', key: 'finishedAt', sortable: true },
|
|
143
|
+
{ title: 'Duration', key: 'duration', sortable: false },
|
|
144
|
+
{ title: 'Status', key: 'status', sortable: true },
|
|
128
145
|
]
|
|
129
146
|
},
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
147
|
+
},
|
|
148
|
+
mounted () {
|
|
149
|
+
this.ticker = setInterval(() => { this.now = Date.now() }, 1000)
|
|
150
|
+
},
|
|
151
|
+
beforeUnmount () {
|
|
152
|
+
clearInterval(this.ticker)
|
|
133
153
|
},
|
|
134
154
|
methods: {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
const location = 'de-DE'
|
|
138
|
-
|
|
139
|
-
if (time !== null) {
|
|
140
|
-
const date = new Date(time).toLocaleDateString(location, options)
|
|
141
|
-
return (date == 'Invalid Date') ? '' : date
|
|
142
|
-
} else {
|
|
143
|
-
return ''
|
|
144
|
-
}
|
|
155
|
+
openJob (id) {
|
|
156
|
+
this.$router.push({ path: `/jobs/${id}` })
|
|
145
157
|
},
|
|
146
|
-
|
|
147
|
-
// Hours, minutes and seconds
|
|
148
|
-
const hrs = ~~(duration / 3600);
|
|
149
|
-
const mins = ~~((duration % 3600) / 60);
|
|
150
|
-
const secs = ~~duration % 60;
|
|
151
|
-
|
|
152
|
-
// Output like "1:01" or "4:03:59" or "123:03:59"
|
|
153
|
-
let ret = "";
|
|
154
|
-
|
|
155
|
-
if (hrs > 0) {
|
|
156
|
-
ret += "" + hrs + ":" + (mins < 10 ? "0" : "");
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
ret += "" + mins + ":" + (secs < 10 ? "0" : "");
|
|
160
|
-
ret += "" + secs;
|
|
161
|
-
|
|
162
|
-
return ret;
|
|
163
|
-
|
|
164
|
-
// // const milliseconds = parseInt((time % 1000))
|
|
165
|
-
// const seconds = parseInt((time / 1000) % 60)
|
|
166
|
-
// const minutes = parseInt((time / (1000 * 60)) % 60)
|
|
167
|
-
// // const hours = parseInt((time / (1000 * 60 * 60)) % 24)
|
|
168
|
-
//
|
|
169
|
-
// return (minutes > 0) ? `${minutes}m ${seconds}s` : `${seconds}s`
|
|
170
|
-
},
|
|
171
|
-
},
|
|
158
|
+
}
|
|
172
159
|
}
|
|
173
160
|
</script>
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, ref, toRef, watch } from 'vue';
|
|
3
|
+
import { useToast } from 'vue-toast-notification';
|
|
4
|
+
import logRequestError from '@/api/restApiHelper';
|
|
5
|
+
import type { Profiler } from '@/api/resource-management/client';
|
|
6
|
+
import ConfirmDialog from '@/components/base/ConfirmDialog.vue';
|
|
7
|
+
import ProfilerForm from '@/components/profilers/ProfilerForm.vue';
|
|
8
|
+
import {
|
|
9
|
+
buildProfilerRequest,
|
|
10
|
+
newProfilerFormData,
|
|
11
|
+
profilerToFormData,
|
|
12
|
+
} from '@/components/profilers/profilerForm';
|
|
13
|
+
import type { ProfilerForm as ProfilerFormState } from './profilerForm';
|
|
14
|
+
import { useProfilersStore } from '@/stores/profilersStore';
|
|
15
|
+
|
|
16
|
+
const props = defineProps<{ show: boolean; profiler: Profiler | null }>();
|
|
17
|
+
const emit = defineEmits(['canceled', 'confirmed']);
|
|
18
|
+
|
|
19
|
+
const $toast = useToast();
|
|
20
|
+
const profilersStore = useProfilersStore();
|
|
21
|
+
|
|
22
|
+
const active = toRef(props, 'show');
|
|
23
|
+
const isEdit = computed(() => props.profiler !== null);
|
|
24
|
+
const loading = ref(false);
|
|
25
|
+
const formKey = ref(0);
|
|
26
|
+
const form = ref<ProfilerFormState>({ isFormValid: false, formData: newProfilerFormData() });
|
|
27
|
+
|
|
28
|
+
function loadForm() {
|
|
29
|
+
formKey.value++; // remount the form to reset vee-validate state
|
|
30
|
+
form.value = {
|
|
31
|
+
isFormValid: false,
|
|
32
|
+
formData: props.profiler ? profilerToFormData(props.profiler) : newProfilerFormData(),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
watch(() => props.show, (show) => {
|
|
37
|
+
if (show) loadForm();
|
|
38
|
+
}, { immediate: true });
|
|
39
|
+
|
|
40
|
+
function closeDialog() {
|
|
41
|
+
emit('canceled');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async function save() {
|
|
45
|
+
if (!form.value.isFormValid) {
|
|
46
|
+
$toast.error('Please fill in all required fields correctly');
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
loading.value = true;
|
|
50
|
+
try {
|
|
51
|
+
const profiler = props.profiler;
|
|
52
|
+
if (profiler) {
|
|
53
|
+
await profilersStore.updateProfiler(
|
|
54
|
+
profiler.id,
|
|
55
|
+
buildProfilerRequest(form.value.formData, profiler.id, profiler),
|
|
56
|
+
);
|
|
57
|
+
$toast.info('Profiler updated successfully');
|
|
58
|
+
} else {
|
|
59
|
+
await profilersStore.createProfiler(
|
|
60
|
+
buildProfilerRequest(form.value.formData, globalThis.crypto.randomUUID()),
|
|
61
|
+
);
|
|
62
|
+
$toast.info('Profiler created successfully');
|
|
63
|
+
}
|
|
64
|
+
emit('confirmed');
|
|
65
|
+
} catch (e) {
|
|
66
|
+
logRequestError(e);
|
|
67
|
+
$toast.error(isEdit.value ? 'Failed to update profiler' : 'Failed to create profiler');
|
|
68
|
+
} finally {
|
|
69
|
+
loading.value = false;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
</script>
|
|
73
|
+
|
|
74
|
+
<template>
|
|
75
|
+
<ConfirmDialog
|
|
76
|
+
:show="active"
|
|
77
|
+
:title="isEdit ? 'Edit profiler' : 'Add profiler'"
|
|
78
|
+
width="800px"
|
|
79
|
+
cancel-button-label="Cancel"
|
|
80
|
+
:confirm-button-label="isEdit ? 'Save changes' : 'Create profiler'"
|
|
81
|
+
:confirm-button-disabled="!form.isFormValid"
|
|
82
|
+
:confirm-loading="loading"
|
|
83
|
+
@canceled="closeDialog"
|
|
84
|
+
@confirmed="save"
|
|
85
|
+
>
|
|
86
|
+
<template #content>
|
|
87
|
+
<ProfilerForm
|
|
88
|
+
:key="formKey"
|
|
89
|
+
v-model="form"
|
|
90
|
+
:edit="isEdit"
|
|
91
|
+
:profiler="profiler"
|
|
92
|
+
/>
|
|
93
|
+
</template>
|
|
94
|
+
</ConfirmDialog>
|
|
95
|
+
</template>
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { nextTick, watch } from 'vue';
|
|
3
|
+
import { useField, useForm } from 'vee-validate';
|
|
4
|
+
import type { Profiler } from '@/api/resource-management/client';
|
|
5
|
+
import { useProfilersStore } from '@/stores/profilersStore';
|
|
6
|
+
import { isNameTaken } from './profilerForm';
|
|
7
|
+
import type { ProfilerForm, ProfilerFormData } from './profilerForm';
|
|
8
|
+
|
|
9
|
+
const props = defineProps<{ modelValue: ProfilerForm; edit: boolean; profiler?: Profiler | null }>();
|
|
10
|
+
const emit = defineEmits<{ (e: 'update:modelValue', value: ProfilerForm): void }>();
|
|
11
|
+
|
|
12
|
+
const profilersStore = useProfilersStore();
|
|
13
|
+
|
|
14
|
+
const parameterNames = (props.profiler?.action?.parameter ?? []).map((p) => p.variable);
|
|
15
|
+
|
|
16
|
+
const { validate } = useForm();
|
|
17
|
+
|
|
18
|
+
function required(label: string) {
|
|
19
|
+
return (v: string) => !!v && v.trim() !== '' || `${label} is required`;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const { value: name, errorMessage: nameError } = useField<string>('name', (v: string) => {
|
|
23
|
+
if (!v || !v.trim()) return 'Name is required';
|
|
24
|
+
return !isNameTaken(v, profilersStore.profilers, props.profiler?.id) || 'A profiler with this name already exists';
|
|
25
|
+
}, { initialValue: props.modelValue.formData.name, validateOnMount: props.edit });
|
|
26
|
+
const { value: repo, errorMessage: repoError } = useField<string>('repo', required('Repository'),
|
|
27
|
+
{ initialValue: props.modelValue.formData.repo });
|
|
28
|
+
const { value: gitRef, errorMessage: branchError } = useField<string>('ref', required('Branch'),
|
|
29
|
+
{ initialValue: props.modelValue.formData.ref });
|
|
30
|
+
const { value: playbook, errorMessage: playbookError } = useField<string>('playbook', required('Playbook'),
|
|
31
|
+
{ initialValue: props.modelValue.formData.playbook });
|
|
32
|
+
|
|
33
|
+
function currentFormData(): ProfilerFormData {
|
|
34
|
+
return {
|
|
35
|
+
name: name.value ?? '',
|
|
36
|
+
repo: repo.value ?? '',
|
|
37
|
+
ref: gitRef.value ?? '',
|
|
38
|
+
playbook: playbook.value ?? '',
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Sync incoming modelValue (e.g. dialog reset) to fields
|
|
43
|
+
watch(() => props.modelValue, (val) => {
|
|
44
|
+
if (JSON.stringify(val.formData) === JSON.stringify(currentFormData())) return;
|
|
45
|
+
const f = val.formData;
|
|
46
|
+
name.value = f.name;
|
|
47
|
+
repo.value = f.repo;
|
|
48
|
+
gitRef.value = f.ref;
|
|
49
|
+
playbook.value = f.playbook;
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// Emit changes to parent
|
|
53
|
+
let validationRun = 0;
|
|
54
|
+
watch([name, repo, gitRef, playbook], async () => {
|
|
55
|
+
const run = ++validationRun;
|
|
56
|
+
await nextTick();
|
|
57
|
+
const result = await validate({ mode: 'silent' }); // silent: do not flag untouched fields as errors
|
|
58
|
+
if (run !== validationRun) return; // a newer change superseded this run
|
|
59
|
+
emit('update:modelValue', { isFormValid: result.valid, formData: currentFormData() });
|
|
60
|
+
}, { immediate: true });
|
|
61
|
+
</script>
|
|
62
|
+
|
|
63
|
+
<template>
|
|
64
|
+
<form @submit.prevent>
|
|
65
|
+
<v-text-field
|
|
66
|
+
v-model="name"
|
|
67
|
+
label="Name"
|
|
68
|
+
required
|
|
69
|
+
:error-messages="nameError"
|
|
70
|
+
/>
|
|
71
|
+
<v-text-field
|
|
72
|
+
v-model="repo"
|
|
73
|
+
label="Repository"
|
|
74
|
+
required
|
|
75
|
+
:error-messages="repoError"
|
|
76
|
+
/>
|
|
77
|
+
<v-text-field
|
|
78
|
+
v-model="gitRef"
|
|
79
|
+
label="Branch"
|
|
80
|
+
required
|
|
81
|
+
:error-messages="branchError"
|
|
82
|
+
/>
|
|
83
|
+
<v-text-field
|
|
84
|
+
v-model="playbook"
|
|
85
|
+
label="Playbook"
|
|
86
|
+
required
|
|
87
|
+
:error-messages="playbookError"
|
|
88
|
+
/>
|
|
89
|
+
|
|
90
|
+
<div v-if="parameterNames.length" class="mt-2">
|
|
91
|
+
<div class="text-subtitle-2 mb-1">Parameters</div>
|
|
92
|
+
<v-chip
|
|
93
|
+
v-for="variable in parameterNames"
|
|
94
|
+
:key="variable"
|
|
95
|
+
class="mr-1"
|
|
96
|
+
size="small"
|
|
97
|
+
>
|
|
98
|
+
{{ variable }}
|
|
99
|
+
</v-chip>
|
|
100
|
+
</div>
|
|
101
|
+
</form>
|
|
102
|
+
</template>
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<base-material-card>
|
|
3
|
+
<template #heading>
|
|
4
|
+
<overview-heading text="Profilers" />
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<no-item-available-note
|
|
8
|
+
v-if="profilers.length === 0"
|
|
9
|
+
item="Profiler"
|
|
10
|
+
/>
|
|
11
|
+
|
|
12
|
+
<v-data-table
|
|
13
|
+
v-else
|
|
14
|
+
:headers="headers"
|
|
15
|
+
:items="profilers"
|
|
16
|
+
item-value="id"
|
|
17
|
+
>
|
|
18
|
+
<template #item.actions="{ item }">
|
|
19
|
+
<div class="d-flex flex-wrap justify-end ga-3 py-2">
|
|
20
|
+
<v-btn
|
|
21
|
+
prepend-icon="mdi-pencil"
|
|
22
|
+
size="small"
|
|
23
|
+
@click.stop="emit('edit', item)"
|
|
24
|
+
>
|
|
25
|
+
Edit
|
|
26
|
+
</v-btn>
|
|
27
|
+
<v-btn
|
|
28
|
+
prepend-icon="mdi-delete"
|
|
29
|
+
size="small"
|
|
30
|
+
color="error"
|
|
31
|
+
@click.stop="profilerToDelete = item"
|
|
32
|
+
>
|
|
33
|
+
Delete
|
|
34
|
+
</v-btn>
|
|
35
|
+
</div>
|
|
36
|
+
</template>
|
|
37
|
+
</v-data-table>
|
|
38
|
+
|
|
39
|
+
<ConfirmDialog
|
|
40
|
+
:show="profilerToDelete !== null"
|
|
41
|
+
attention
|
|
42
|
+
title="Delete profiler"
|
|
43
|
+
:text="`Delete profiler '${profilerToDelete?.name}'?`"
|
|
44
|
+
confirm-button-label="Delete"
|
|
45
|
+
cancel-button-label="Cancel"
|
|
46
|
+
:confirm-loading="deleting"
|
|
47
|
+
@canceled="profilerToDelete = null"
|
|
48
|
+
@confirmed="onDeleteConfirmed"
|
|
49
|
+
/>
|
|
50
|
+
</base-material-card>
|
|
51
|
+
</template>
|
|
52
|
+
|
|
53
|
+
<script setup lang="ts">
|
|
54
|
+
import { computed, ref } from 'vue';
|
|
55
|
+
import { useToast } from 'vue-toast-notification';
|
|
56
|
+
import logRequestError from '@/api/restApiHelper';
|
|
57
|
+
import type { Profiler } from '@/api/resource-management/client';
|
|
58
|
+
import ConfirmDialog from '@/components/base/ConfirmDialog.vue';
|
|
59
|
+
import NoItemAvailableNote from '@/components/base/NoItemAvailableNote.vue';
|
|
60
|
+
import OverviewHeading from '@/components/base/OverviewHeading.vue';
|
|
61
|
+
import { useProfilersStore } from '@/stores/profilersStore';
|
|
62
|
+
|
|
63
|
+
const emit = defineEmits<{ (e: 'edit', profiler: Profiler): void }>();
|
|
64
|
+
|
|
65
|
+
const $toast = useToast();
|
|
66
|
+
const profilersStore = useProfilersStore();
|
|
67
|
+
|
|
68
|
+
const profilerToDelete = ref<Profiler | null>(null);
|
|
69
|
+
const deleting = ref(false);
|
|
70
|
+
|
|
71
|
+
const profilers = computed(() => profilersStore.profilers);
|
|
72
|
+
|
|
73
|
+
const headers = [
|
|
74
|
+
{ title: 'Name', key: 'name' },
|
|
75
|
+
{ title: 'Repository', key: 'action.repo' },
|
|
76
|
+
{ title: 'Branch', key: 'action.ref' },
|
|
77
|
+
{ title: 'Playbook', key: 'action.playbook' },
|
|
78
|
+
{ title: '', key: 'actions', sortable: false, cellProps: { class: 'px-6' } },
|
|
79
|
+
];
|
|
80
|
+
|
|
81
|
+
async function onDeleteConfirmed() {
|
|
82
|
+
const profiler = profilerToDelete.value;
|
|
83
|
+
if (!profiler) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
deleting.value = true;
|
|
87
|
+
try {
|
|
88
|
+
await profilersStore.deleteProfiler(profiler.id);
|
|
89
|
+
$toast.success('Profiler deleted');
|
|
90
|
+
} catch (e) {
|
|
91
|
+
logRequestError(e);
|
|
92
|
+
$toast.error('Failed to delete profiler');
|
|
93
|
+
} finally {
|
|
94
|
+
deleting.value = false;
|
|
95
|
+
profilerToDelete.value = null;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
</script>
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { AnsibleAction, Profiler, ProfilerDTOApi } from '@/api/resource-management/client'
|
|
2
|
+
|
|
3
|
+
export interface ProfilerFormData {
|
|
4
|
+
name: string
|
|
5
|
+
repo: string
|
|
6
|
+
ref: string
|
|
7
|
+
playbook: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface ProfilerForm {
|
|
11
|
+
isFormValid: boolean
|
|
12
|
+
formData: ProfilerFormData
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const DEFAULT_BRANCH = 'main'
|
|
16
|
+
export const DEFAULT_PLAYBOOK = 'run.yml'
|
|
17
|
+
/** Playbook contract of profilers created in the form (Resource Management rejects profilers without one). */
|
|
18
|
+
export const DEFAULT_PLAYBOOK_CONTRACT = '1.0'
|
|
19
|
+
export const DEFAULT_CONNECTION_TYPES = ['ssh']
|
|
20
|
+
|
|
21
|
+
export function newProfilerFormData(): ProfilerFormData {
|
|
22
|
+
return { name: '', repo: '', ref: DEFAULT_BRANCH, playbook: DEFAULT_PLAYBOOK }
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function profilerToFormData(profiler: Profiler): ProfilerFormData {
|
|
26
|
+
return {
|
|
27
|
+
name: profiler.name,
|
|
28
|
+
repo: profiler.action?.repo ?? '',
|
|
29
|
+
ref: profiler.action?.ref ?? DEFAULT_BRANCH,
|
|
30
|
+
playbook: profiler.action?.playbook ?? DEFAULT_PLAYBOOK,
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Builds the request of the form. Fields the form does not show (image, connection types, playbook contract, ...) are
|
|
36
|
+
* kept from the original profiler; a new profiler gets the defaults above.
|
|
37
|
+
*/
|
|
38
|
+
export function buildProfilerRequest(form: ProfilerFormData, id: string, original?: Profiler): ProfilerDTOApi {
|
|
39
|
+
const action: Record<string, unknown> = {
|
|
40
|
+
connectionTypes: DEFAULT_CONNECTION_TYPES,
|
|
41
|
+
...original?.action,
|
|
42
|
+
actionClass: 'AnsibleAction',
|
|
43
|
+
actionType: 'RUN',
|
|
44
|
+
repo: form.repo.trim(),
|
|
45
|
+
ref: form.ref.trim(),
|
|
46
|
+
playbook: form.playbook.trim(),
|
|
47
|
+
}
|
|
48
|
+
const playbookContract = (original as { playbookContract?: string } | undefined)?.playbookContract
|
|
49
|
+
?? DEFAULT_PLAYBOOK_CONTRACT
|
|
50
|
+
return {
|
|
51
|
+
id,
|
|
52
|
+
name: form.name.trim(),
|
|
53
|
+
playbookContract,
|
|
54
|
+
action: action as unknown as AnsibleAction,
|
|
55
|
+
} as ProfilerDTOApi
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function isNameTaken(name: string, profilers: Profiler[], ownId?: string): boolean {
|
|
59
|
+
const wanted = name.trim().toLowerCase()
|
|
60
|
+
return profilers.some(p => p.id !== ownId && p.name.trim().toLowerCase() === wanted)
|
|
61
|
+
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
v-model="show"
|
|
4
4
|
width="90%"
|
|
5
5
|
height="90%"
|
|
6
|
+
scrollable
|
|
6
7
|
@click:outside="onCloseButtonClicked"
|
|
7
8
|
>
|
|
8
9
|
<template #default="{}">
|
|
@@ -15,7 +16,14 @@
|
|
|
15
16
|
color="primary"
|
|
16
17
|
theme="dark"
|
|
17
18
|
>
|
|
18
|
-
|
|
19
|
+
<v-toolbar-title>
|
|
20
|
+
{{ resource.hostname }}
|
|
21
|
+
</v-toolbar-title>
|
|
22
|
+
<v-spacer />
|
|
23
|
+
<v-btn
|
|
24
|
+
icon="mdi-close"
|
|
25
|
+
@click="onCloseButtonClicked"
|
|
26
|
+
/>
|
|
19
27
|
</v-toolbar>
|
|
20
28
|
|
|
21
29
|
<v-card-text>
|
|
@@ -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>
|