@eclipse-slm/ui 0.0.0-stage → 1.5.0-snapshot.1
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 +270 -2
- package/index.html +19 -0
- package/package.json +103 -4
- package/public/favicon.ico +0 -0
- package/public/favicon.png +0 -0
- package/public/favicon_white.png +0 -0
- package/public/sidebar-image.jpg +0 -0
- package/src/App.vue +40 -0
- package/src/api/apiState.js +7 -0
- package/src/api/catalog/catalogRestApi.js +17 -0
- package/src/api/notification-service/notification-service-client.ts +7 -0
- package/src/api/notification-service/notificationServiceActuatorRestApi.js +26 -0
- package/src/api/notification-service/notificationServiceWebsocketClient.js +60 -0
- package/src/api/platform-management/platform-management-client.ts +46 -0
- package/src/api/platform-management/platformManagementActuatorRestApi.js +26 -0
- package/src/api/resource-management/resource-management-client.ts +39 -0
- package/src/api/resource-management/resourceManagementActuatorRestApi.js +26 -0
- package/src/api/restApiHelper.js +11 -0
- package/src/api/service-management/service-management-client.ts +31 -0
- package/src/api/service-management/serviceManagementActuatorRestApi.ts +26 -0
- package/src/app/navigation.ts +203 -0
- package/src/app/routes.ts +192 -0
- package/src/assets/clint-mckoy.jpg +0 -0
- package/src/assets/img/avatarImg.jpg +0 -0
- package/src/assets/img/fabos_logo.png +0 -0
- package/src/assets/img/fabos_logo_fabweiss.png +0 -0
- package/src/assets/img/fraunhofer-logo.png +0 -0
- package/src/assets/img/sidebar-1.jpg +0 -0
- package/src/assets/img/sidebar-2.jpg +0 -0
- package/src/assets/img/sidebar-3.jpg +0 -0
- package/src/assets/img/sidebar-4.jpg +0 -0
- package/src/assets/img/sidebar-5.jpg +0 -0
- package/src/assets/img/sidebar-image.jpg +0 -0
- package/src/assets/img/vue-logo.png +0 -0
- package/src/assets/lock.jpg +0 -0
- package/src/assets/login.jpg +0 -0
- package/src/assets/logo.png +0 -0
- package/src/assets/pricing.jpg +0 -0
- package/src/assets/register.jpg +0 -0
- package/src/assets/vuetify.svg +1 -0
- package/src/components/admin/VersionsOverview.vue +149 -0
- package/src/components/base/ActionButton.vue +63 -0
- package/src/components/base/ActionButtonType.ts +5 -0
- package/src/components/base/Card.vue +17 -0
- package/src/components/base/ConfirmDialog.vue +87 -0
- package/src/components/base/CustomDialog.vue +88 -0
- package/src/components/base/Item.vue +79 -0
- package/src/components/base/ItemGroup.vue +131 -0
- package/src/components/base/ItemSubGroup.vue +25 -0
- package/src/components/base/MaterialAlert.vue +56 -0
- package/src/components/base/MaterialCard.vue +166 -0
- package/src/components/base/MaterialChartCard.vue +95 -0
- package/src/components/base/MaterialSnackbar.vue +71 -0
- package/src/components/base/MaterialStatsCard.vue +115 -0
- package/src/components/base/MaterialTabs.vue +43 -0
- package/src/components/base/MaterialTestimony.vue +79 -0
- package/src/components/base/NoItemAvailableNote.vue +22 -0
- package/src/components/base/OverviewHeading.vue +25 -0
- package/src/components/base/ProgressCircular.vue +68 -0
- package/src/components/base/RowWithLabel.vue +228 -0
- package/src/components/base/Subheading.vue +35 -0
- package/src/components/base/TextWithLabel.vue +41 -0
- package/src/components/base/VComponent.vue +40 -0
- package/src/components/charts/AasCircularChart.vue +170 -0
- package/src/components/charts/AasCircularChartFilterBar.vue +72 -0
- package/src/components/charts/LineChart.js +14 -0
- package/src/components/clusters/ClustersOverview.vue +76 -0
- package/src/components/clusters/dialogs/ClusterDeleteDialog.vue +125 -0
- package/src/components/clusters/dialogs/ClusterScaleDialog.vue +272 -0
- package/src/components/clusters/dialogs/ClustersCreateDialog.vue +112 -0
- package/src/components/clusters/dialogs/ClustersCreateDialogPage.ts +7 -0
- package/src/components/clusters/dialogs/ClustersCreateDialogPageAddExistingCluster.vue +261 -0
- package/src/components/clusters/dialogs/ClustersCreateDialogPageCreateNewCluster.vue +244 -0
- package/src/components/clusters/dialogs/ClustersCreateDialogPageStart.vue +75 -0
- package/src/components/core/AppBar.vue +301 -0
- package/src/components/core/Drawer.vue +207 -0
- package/src/components/core/Footer.vue +43 -0
- package/src/components/core/View.vue +32 -0
- package/src/components/credentials/CredentialCreateDialog.vue +121 -0
- package/src/components/credentials/CredentialDisplay.vue +105 -0
- package/src/components/credentials/CredentialForm.vue +394 -0
- package/src/components/credentials/CredentialTypes.ts +26 -0
- package/src/components/dashboard/Buttons.vue +431 -0
- package/src/components/dashboard/DashboardResourceStatistics.vue +53 -0
- package/src/components/dashboard/Grid.vue +300 -0
- package/src/components/dashboard/Icons.vue +300 -0
- package/src/components/dashboard/Notifications.vue +402 -0
- package/src/components/dashboard/Tabs.vue +418 -0
- package/src/components/dashboard/Typography.vue +120 -0
- package/src/components/discovery/DiscoverDialog.vue +186 -0
- package/src/components/discovery/DiscoveredResourcesTable.vue +176 -0
- package/src/components/discovery/DiscoveryJobDetailsDialog.vue +65 -0
- package/src/components/discovery/DiscoveryJobsDeleteDialog.vue +88 -0
- package/src/components/discovery/DiscoveryJobsTable.vue +131 -0
- package/src/components/discovery/DiscoveryOverview.vue +99 -0
- package/src/components/discovery/DriversTable.vue +70 -0
- package/src/components/discovery/OnboardingDialog.vue +82 -0
- package/src/components/jobs/JobsOverview.vue +173 -0
- package/src/components/notifications/NotificationsOverview.vue +154 -0
- package/src/components/provider/ProviderOverview.vue +64 -0
- package/src/components/provider/ServiceHosterTable.vue +47 -0
- package/src/components/provider/VirtualResourceProviderTable.vue +73 -0
- package/src/components/provider/dialogs/VmCreateDialog.vue +99 -0
- package/src/components/provider/dialogs/VmCreateDialogForm.vue +59 -0
- package/src/components/resources/ResourceConnectionIcon.vue +40 -0
- package/src/components/resources/ResourcesDeleteDialog.vue +102 -0
- package/src/components/resources/ResourcesTableClusters.vue +192 -0
- package/src/components/resources/ResourcesTableDevices.vue +338 -0
- package/src/components/resources/ResourcesTableTypes.vue +106 -0
- package/src/components/resources/capabilities/CapabilitiesButton.vue +164 -0
- package/src/components/resources/capabilities/CapabilityIcon.vue +44 -0
- package/src/components/resources/capabilities/CapabilityParamsDialog.vue +119 -0
- package/src/components/resources/capabilities/CapabilityParamsDialogInputField.vue +51 -0
- package/src/components/resources/deviceinfo/DeviceInfoCapabilitiesView.vue +239 -0
- package/src/components/resources/deviceinfo/DeviceInfoCredentialsView.vue +205 -0
- package/src/components/resources/deviceinfo/DeviceInfoHardwareView.vue +162 -0
- package/src/components/resources/deviceinfo/DeviceInfoNameplateView.vue +201 -0
- package/src/components/resources/deviceinfo/DeviceInfoSubmodelsView.vue +173 -0
- package/src/components/resources/deviceinfo/DeviceInfoView.vue +199 -0
- package/src/components/resources/deviceinfo/common/DeviceInfoCommonBasicsSection.vue +101 -0
- package/src/components/resources/deviceinfo/common/DeviceInfoCommonRemoteAccessSection.vue +224 -0
- package/src/components/resources/deviceinfo/common/DeviceInfoCommonView.vue +43 -0
- package/src/components/resources/deviceinfo/firmware/DeviceInfoFirmwareView.vue +113 -0
- package/src/components/resources/deviceinfo/firmware/FirmwareAvailableVersionsSection.vue +193 -0
- package/src/components/resources/deviceinfo/firmware/FirmwareCredentialsSection.vue +250 -0
- package/src/components/resources/deviceinfo/firmware/FirmwareUpdateJobsSection.vue +149 -0
- package/src/components/resources/deviceinfo/firmware/FirmwareUpdateStatusSection.vue +117 -0
- package/src/components/resources/deviceinfo/firmware/sectionState.ts +12 -0
- package/src/components/resources/devicetypeinfo/DeviceTypeInfoCommonView.vue +58 -0
- package/src/components/resources/devicetypeinfo/DeviceTypeInfoFirmwareView.vue +270 -0
- package/src/components/resources/devicetypeinfo/DeviceTypeInfoView.vue +110 -0
- package/src/components/resources/dialogs/DeviceCreateDeviceDetailsForm.vue +109 -0
- package/src/components/resources/dialogs/DeviceCreateDialog.vue +224 -0
- package/src/components/resources/dialogs/DeviceDialogCreateTypes.ts +11 -0
- package/src/components/resources/remoteaccess/RemoteAccessDialog.vue +82 -0
- package/src/components/resources/remoteaccess/RemoteAccessForm.vue +149 -0
- package/src/components/resources/remoteaccess/RemoteAccessHandler.ts +73 -0
- package/src/components/resources/remoteaccess/RemoteAccessTypes.ts +11 -0
- package/src/components/service_offerings/ServiceCategoriesTable.vue +154 -0
- package/src/components/service_offerings/ServiceCategoryCreateOrEditDialog.vue +117 -0
- package/src/components/service_offerings/ServiceOfferingCardGrid.vue +173 -0
- package/src/components/service_offerings/ServiceOfferingCardList.vue +117 -0
- package/src/components/service_offerings/ServiceOfferingDetailsOverview.vue +89 -0
- package/src/components/service_offerings/ServiceOfferingDetailsRequirements.vue +89 -0
- package/src/components/service_offerings/ServiceOfferingTable.vue +291 -0
- package/src/components/service_offerings/ServiceOfferingToolbar.vue +133 -0
- package/src/components/service_offerings/ServiceOptionValue.vue +213 -0
- package/src/components/service_offerings/dialogs/ServiceOfferingCreateDialog.vue +70 -0
- package/src/components/service_offerings/wizard_service_offering/ServiceOfferingWizardGitStep1Common.vue +214 -0
- package/src/components/service_offerings/wizard_service_offering/ServiceOfferingWizardManualStep1Common.vue +196 -0
- package/src/components/service_offerings/wizard_service_offering_version/Docker/DockerContainerImageName.vue +112 -0
- package/src/components/service_offerings/wizard_service_offering_version/Docker/DockerContainerLabels.vue +158 -0
- package/src/components/service_offerings/wizard_service_offering_version/Docker/DockerContainerPortMappings.vue +177 -0
- package/src/components/service_offerings/wizard_service_offering_version/Docker/DockerContainerRestartPolicy.vue +63 -0
- package/src/components/service_offerings/wizard_service_offering_version/Docker/DockerContainerVolumes.vue +157 -0
- package/src/components/service_offerings/wizard_service_offering_version/Docker/DockerEnvironmentVariables.vue +163 -0
- package/src/components/service_offerings/wizard_service_offering_version/ServiceOfferingVersionWizardStep1Common.vue +154 -0
- package/src/components/service_offerings/wizard_service_offering_version/ServiceOfferingVersionWizardStep2DeploymentDefinitionCodesys.vue +139 -0
- package/src/components/service_offerings/wizard_service_offering_version/ServiceOfferingVersionWizardStep2DeploymentDefinitionDockerCompose.vue +424 -0
- package/src/components/service_offerings/wizard_service_offering_version/ServiceOfferingVersionWizardStep2DeploymentDefinitionDockerContainer.vue +293 -0
- package/src/components/service_offerings/wizard_service_offering_version/ServiceOfferingVersionWizardStep2DeploymentDefinitionKubernetes.vue +383 -0
- package/src/components/service_offerings/wizard_service_offering_version/ServiceOfferingVersionWizardStep3ServiceOptions.vue +193 -0
- package/src/components/service_offerings/wizard_service_offering_version/ServiceOfferingVersionWizardStep4Requirements.vue +238 -0
- package/src/components/service_offerings/wizard_service_offering_version/ServiceRepositorySelect.vue +90 -0
- package/src/components/service_offerings/wizard_service_offering_version/serviceOptions/serviceOptionsDefinitionTable.vue +210 -0
- package/src/components/service_vendors/ServiceRepositoryCreateDialog.vue +165 -0
- package/src/components/service_vendors/ServiceVendorCreateOrEditDialog.vue +171 -0
- package/src/components/service_vendors/ServiceVendorDevelopersTable.vue +201 -0
- package/src/components/service_vendors/ServiceVendorTable.vue +158 -0
- package/src/components/services/ServiceInstanceDeleteDialog.vue +29 -0
- package/src/components/services/ServiceInstancesOverview.vue +63 -0
- package/src/components/services/ServiceInstancesTable.vue +379 -0
- package/src/components/services/dialog/ServiceInstanceDetailsDialog.vue +369 -0
- package/src/components/services/serviceInstanceMixin.js +29 -0
- package/src/components/tables/RegularTables.vue +186 -0
- package/src/components/updates/FirmwareUpdateStatusIcon.vue +54 -0
- package/src/components/updates/FirmwareUpdateVersion.vue +65 -0
- package/src/components/user/UserCredentials.vue +278 -0
- package/src/components/user/UserProfileDetails.vue +89 -0
- package/src/customization/customizeApp.ts +6 -0
- package/src/customization/customizeMessages.ts +6 -0
- package/src/customization/customizeNavigation.ts +6 -0
- package/src/customization/customizeRoutes.ts +6 -0
- package/src/customization/deepMerge.ts +28 -0
- package/src/customization/theme.ts +15 -0
- package/src/design/overrides.sass +62 -0
- package/src/design/serviceOfferingCard.scss +38 -0
- package/src/design/variables.scss +34 -0
- package/src/design/vuetify-material/_appbar.sass +54 -0
- package/src/design/vuetify-material/_buttons.sass +67 -0
- package/src/design/vuetify-material/_card.sass +107 -0
- package/src/design/vuetify-material/_chip.sass +9 -0
- package/src/design/vuetify-material/_footer.sass +29 -0
- package/src/design/vuetify-material/_map.sass +3 -0
- package/src/design/vuetify-material/_modal.sass +25 -0
- package/src/design/vuetify-material/_notification.sass +12 -0
- package/src/design/vuetify-material/_pagination.sass +5 -0
- package/src/design/vuetify-material/_settings.sass +36 -0
- package/src/design/vuetify-material/_sidebar.sass +69 -0
- package/src/design/vuetify-material/_tab.sass +12 -0
- package/src/design/vuetify-material/_table.sass +22 -0
- package/src/design/vuetify-material/_view.sass +23 -0
- package/src/docker/entrypoint.sh +85 -0
- package/src/docker/nginx.conf +35 -0
- package/src/docker/slm.conf +15 -0
- package/src/localisation/de.json +91 -0
- package/src/localisation/en.json +294 -0
- package/src/main.ts +170 -0
- package/src/pages/AccessDeniedPage.vue +10 -0
- package/src/pages/AdminComponentsPage.vue +34 -0
- package/src/pages/AdminPage.vue +68 -0
- package/src/pages/AdminServiceCategoriesPage.vue +34 -0
- package/src/pages/AdminServiceVendorsPage.vue +53 -0
- package/src/pages/AdminUsersPage.vue +367 -0
- package/src/pages/ClustersPage.vue +64 -0
- package/src/pages/DashboardPage.vue +379 -0
- package/src/pages/DiscoveryDriversPage.vue +35 -0
- package/src/pages/DiscoveryInboxPage.vue +31 -0
- package/src/pages/DiscoveryJobsPage.vue +34 -0
- package/src/pages/IndexPage.vue +29 -0
- package/src/pages/JobsPage.vue +18 -0
- package/src/pages/NotificationsPage.vue +13 -0
- package/src/pages/ProviderPage.vue +18 -0
- package/src/pages/ResourceInstancesPage.vue +106 -0
- package/src/pages/ResourceTypesPage.vue +102 -0
- package/src/pages/ServiceInstancesPage.vue +33 -0
- package/src/pages/ServiceOfferingCreateOrEditPage.vue +197 -0
- package/src/pages/ServiceOfferingDetailsPage.vue +180 -0
- package/src/pages/ServiceOfferingOrderPage.vue +300 -0
- package/src/pages/ServiceOfferingVersionCreateOrEditPage.vue +431 -0
- package/src/pages/ServiceOfferingsPage.vue +149 -0
- package/src/pages/ServiceVendorPage.vue +431 -0
- package/src/pages/UserProfilePage.vue +64 -0
- package/src/pages/router.js +34 -0
- package/src/shims-vue.d.ts +5 -0
- package/src/stores/capabilitiesStore.ts +116 -0
- package/src/stores/catalogStore.ts +50 -0
- package/src/stores/discoveryStore.ts +88 -0
- package/src/stores/environmentStore.ts +61 -0
- package/src/stores/jobsStore.ts +73 -0
- package/src/stores/notificationStore.ts +155 -0
- package/src/stores/providerStore.ts +52 -0
- package/src/stores/resourceClustersStore.ts +98 -0
- package/src/stores/resourceDevicesStore.ts +294 -0
- package/src/stores/serviceInstancesStore.ts +93 -0
- package/src/stores/serviceOfferingsStore.ts +208 -0
- package/src/stores/store.ts +66 -0
- package/src/stores/userStore.ts +126 -0
- package/src/utils/capabilityUtils.js +114 -0
- package/src/utils/dateUtils.js +21 -0
- package/src/utils/deviceUtils.js +74 -0
- package/src/utils/firmwareUtils.ts +35 -0
- package/src/utils/i18n.ts +26 -0
- package/src/utils/imageUtil.js +37 -0
- package/src/utils/notificationTextGenerator.ts +82 -0
- package/src/utils/serviceOptionUtil.js +106 -0
- package/src/utils/tokenInterceptor.js +59 -0
- package/src/utils/updateToken.js +18 -0
- package/src/utils/yup.custom.js +11 -0
- package/vite/dist/apiClients.d.ts +5 -0
- package/vite/dist/apiClients.js +58 -0
- package/vite/dist/drift.d.ts +9 -0
- package/vite/dist/drift.js +57 -0
- package/vite/dist/index.d.ts +4 -0
- package/vite/dist/index.js +73 -0
- package/vite/dist/overrides.d.ts +3 -0
- package/vite/dist/overrides.js +71 -0
- package/vite/dist/paths.d.ts +18 -0
- package/vite/dist/paths.js +22 -0
- package/vite/package.json +1 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import RowWithLabel from "@/components/base/RowWithLabel.vue";
|
|
3
|
+
import { computed } from 'vue'
|
|
4
|
+
import {CredentialDataType} from "@/api/platform-management/client";
|
|
5
|
+
import {useToast} from "vue-toast-notification";
|
|
6
|
+
import {useClipboard} from "@vueuse/core";
|
|
7
|
+
|
|
8
|
+
const props = defineProps({
|
|
9
|
+
credential: { type: Object, required: true },
|
|
10
|
+
hideName: { type: Boolean, default: false },
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
const $toast = useToast();
|
|
14
|
+
const { copy, isSupported } = useClipboard()
|
|
15
|
+
|
|
16
|
+
const credentialDataType = computed(() => props.credential?.data?.credentialDataType)
|
|
17
|
+
|
|
18
|
+
const copyToClipboard = (content) => {
|
|
19
|
+
copy(content)
|
|
20
|
+
$toast.info(`Copied to clipboard`)
|
|
21
|
+
}
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<template>
|
|
25
|
+
<div>
|
|
26
|
+
<!-- CREDENTIAL NAME -->
|
|
27
|
+
<RowWithLabel
|
|
28
|
+
v-if="!props.hideName"
|
|
29
|
+
label="Name"
|
|
30
|
+
:text="props.credential?.name ?? '-'"
|
|
31
|
+
/>
|
|
32
|
+
<!-- USERNAME / PASSWORD -->
|
|
33
|
+
<div v-if="credentialDataType === CredentialDataType.UsernamePassword">
|
|
34
|
+
<RowWithLabel
|
|
35
|
+
label="Username"
|
|
36
|
+
:text="props.credential?.data?.username"
|
|
37
|
+
:copyable="true"
|
|
38
|
+
/>
|
|
39
|
+
|
|
40
|
+
<RowWithLabel label="Password" :divider="false">
|
|
41
|
+
<template #content>
|
|
42
|
+
<v-tooltip>
|
|
43
|
+
<template #activator="{ props: tp }">
|
|
44
|
+
<span v-bind="tp">••••••••</span>
|
|
45
|
+
</template>
|
|
46
|
+
<span>Password is secret and cannot be read.</span>
|
|
47
|
+
</v-tooltip>
|
|
48
|
+
</template>
|
|
49
|
+
</RowWithLabel>
|
|
50
|
+
</div>
|
|
51
|
+
|
|
52
|
+
<!-- KEY PAIR -->
|
|
53
|
+
<div v-else-if="credentialDataType === CredentialDataType.KeyPair">
|
|
54
|
+
<RowWithLabel label="Public Key" >
|
|
55
|
+
<template #content>
|
|
56
|
+
<v-row>
|
|
57
|
+
<v-col cols="11">
|
|
58
|
+
<v-textarea
|
|
59
|
+
readonly
|
|
60
|
+
:value="credential?.data?.publicKey ?? ''"
|
|
61
|
+
auto-grow
|
|
62
|
+
rows="1"
|
|
63
|
+
max-rows="6"
|
|
64
|
+
outlined
|
|
65
|
+
class="public-key-textarea"
|
|
66
|
+
/>
|
|
67
|
+
</v-col>
|
|
68
|
+
<v-col cols="1" v-if="isSupported">
|
|
69
|
+
<v-btn
|
|
70
|
+
color="secondary"
|
|
71
|
+
size="small"
|
|
72
|
+
@click="copyToClipboard(props.credential?.data?.publicKey)"
|
|
73
|
+
>
|
|
74
|
+
<v-icon icon="mdi-content-copy" color="white" />
|
|
75
|
+
</v-btn>
|
|
76
|
+
</v-col>
|
|
77
|
+
</v-row>
|
|
78
|
+
</template>
|
|
79
|
+
</RowWithLabel>
|
|
80
|
+
|
|
81
|
+
<RowWithLabel label="Private Key">
|
|
82
|
+
<template #content>
|
|
83
|
+
<v-tooltip>
|
|
84
|
+
<template #activator="{ props: tp }">
|
|
85
|
+
<span v-bind="tp">••••••••</span>
|
|
86
|
+
</template>
|
|
87
|
+
<span>Private key is secret and cannot be read.</span>
|
|
88
|
+
</v-tooltip>
|
|
89
|
+
</template>
|
|
90
|
+
</RowWithLabel>
|
|
91
|
+
</div>
|
|
92
|
+
|
|
93
|
+
<div v-else>
|
|
94
|
+
Unsupported credential type '{{ credentialDataType }}', cannot display.
|
|
95
|
+
</div>
|
|
96
|
+
|
|
97
|
+
</div>
|
|
98
|
+
</template>
|
|
99
|
+
|
|
100
|
+
<style scoped>
|
|
101
|
+
.public-key-textarea textarea {
|
|
102
|
+
max-height: 160px;
|
|
103
|
+
overflow-y: auto;
|
|
104
|
+
}
|
|
105
|
+
</style>
|
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ref, watch, computed, onMounted } from 'vue';
|
|
3
|
+
import {useToast} from "vue-toast-notification";
|
|
4
|
+
import {CredentialDataType} from "@/api/platform-management/client";
|
|
5
|
+
import {debounce} from "chart.js/helpers";
|
|
6
|
+
import {CredentialFormData, KeyPairData, UsernamePasswordData} from "@/components/credentials/CredentialTypes";
|
|
7
|
+
import { useForm, useField } from 'vee-validate';
|
|
8
|
+
import PlatformManagementClient from '@/api/platform-management/platform-management-client'
|
|
9
|
+
import type { CredentialReadDTO } from '@/api/platform-management/client'
|
|
10
|
+
import CredentialDisplay from '@/components/credentials/CredentialDisplay.vue'
|
|
11
|
+
|
|
12
|
+
const $toast = useToast();
|
|
13
|
+
|
|
14
|
+
const emit = defineEmits<{ (e: 'update:modelValue', value: CredentialFormData): void }>();
|
|
15
|
+
const props = defineProps({
|
|
16
|
+
modelValue: { type: Object as () => CredentialFormData, required: false },
|
|
17
|
+
allowExisting: { type: Boolean, default: false },
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// vee-validate form + fields
|
|
21
|
+
const { validate } = useForm();
|
|
22
|
+
|
|
23
|
+
const credentialNameRule = (v: any) => {
|
|
24
|
+
if (credentialDataTypeVal.value && credentialDataTypeVal.value !== USE_EXISTING_VALUE) {
|
|
25
|
+
return v ? true : 'Credential Name is required';
|
|
26
|
+
}
|
|
27
|
+
return true;
|
|
28
|
+
};
|
|
29
|
+
const { value: credentialNameVal, errorMessage: credentialNameError } = useField<string>('credentialName', credentialNameRule);
|
|
30
|
+
|
|
31
|
+
const USE_EXISTING_VALUE = 'USE_EXISTING';
|
|
32
|
+
type CredentialTypeOption = { title: string, value: string };
|
|
33
|
+
const { value: credentialDataTypeVal, errorMessage: credentialDataTypeError } = useField<string | undefined>('credentialDataType', (v: any) => v ? true : 'Credential Type is required');
|
|
34
|
+
|
|
35
|
+
const { value: usernameVal, errorMessage: usernameError } = useField<string>('username', (v: any) => {
|
|
36
|
+
if (credentialDataTypeVal.value === CredentialDataType.UsernamePassword) return v ? true : 'Username is required';
|
|
37
|
+
return true;
|
|
38
|
+
});
|
|
39
|
+
const { value: passwordVal, errorMessage: passwordError } = useField<string>('password', (v: any) => {
|
|
40
|
+
if (credentialDataTypeVal.value === CredentialDataType.UsernamePassword) return v ? true : 'Password is required';
|
|
41
|
+
return true;
|
|
42
|
+
});
|
|
43
|
+
const { value: publicKeyVal, errorMessage: publicKeyError } = useField<string>('publicKey', (v: any) => {
|
|
44
|
+
if (credentialDataTypeVal.value === CredentialDataType.KeyPair) return v ? true : 'Public key is required';
|
|
45
|
+
return true;
|
|
46
|
+
});
|
|
47
|
+
const { value: privateKeyVal, errorMessage: privateKeyError } = useField<string>('privateKey', (v: any) => {
|
|
48
|
+
if (credentialDataTypeVal.value === CredentialDataType.KeyPair) return v ? true : 'Private key is required';
|
|
49
|
+
return true;
|
|
50
|
+
});
|
|
51
|
+
const { value: existingCredentialIdVal, errorMessage: existingCredentialIdError } = useField<string>('existingCredentialId', (v: any) => {
|
|
52
|
+
if (credentialDataTypeVal.value === USE_EXISTING_VALUE) return v ? true : 'Existing credential is required';
|
|
53
|
+
return true;
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const credentialTypeOptions = computed(() => {
|
|
57
|
+
const options: CredentialTypeOption[] = [
|
|
58
|
+
{
|
|
59
|
+
title: 'Username / Password',
|
|
60
|
+
value: CredentialDataType.UsernamePassword
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
title: 'Key Pair',
|
|
64
|
+
value: CredentialDataType.KeyPair
|
|
65
|
+
}
|
|
66
|
+
];
|
|
67
|
+
if (props.allowExisting) {
|
|
68
|
+
options.push({
|
|
69
|
+
title: 'Use existing credential',
|
|
70
|
+
value: USE_EXISTING_VALUE,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return options;
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const showPassword = ref(false);
|
|
77
|
+
const publicKeyFileName = ref<string | null>(null);
|
|
78
|
+
const privateKeyFileName = ref<string | null>(null);
|
|
79
|
+
|
|
80
|
+
const existingCredentials = ref<CredentialReadDTO[]>([])
|
|
81
|
+
const existingCredentialsLoading = ref(false);
|
|
82
|
+
const existingCredentialsError = ref<string | null>(null);
|
|
83
|
+
|
|
84
|
+
const existingCredentialOptions = computed(() => {
|
|
85
|
+
return existingCredentials.value.map((credential) => {
|
|
86
|
+
const type = credential.data?.credentialDataType;
|
|
87
|
+
const username = (credential.data as any)?.username;
|
|
88
|
+
const name = credential.name;
|
|
89
|
+
const typeLabel = type === CredentialDataType.UsernamePassword ? 'Username / Password' : 'Key Pair';
|
|
90
|
+
const detail = username ? ` - ${username}` : '';
|
|
91
|
+
return {
|
|
92
|
+
title: `${name ? name + ' | ' : ''}${typeLabel}${detail} (${credential.id})`,
|
|
93
|
+
value: credential.id,
|
|
94
|
+
};
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
const selectedExistingCredential = computed(() => {
|
|
99
|
+
return existingCredentials.value.find((credential) => credential.id === existingCredentialIdVal.value) ?? null;
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
const emitDebounced = debounce(() => {
|
|
103
|
+
validate().then((validationResult) => {
|
|
104
|
+
const formData = createFormData(validationResult.valid);
|
|
105
|
+
emit('update:modelValue', formData);
|
|
106
|
+
})
|
|
107
|
+
}, 300);
|
|
108
|
+
|
|
109
|
+
watch([
|
|
110
|
+
credentialDataTypeVal, usernameVal, passwordVal, publicKeyVal, privateKeyVal, existingCredentialIdVal, credentialNameVal
|
|
111
|
+
], () => {
|
|
112
|
+
emitDebounced();
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
onMounted(() => {
|
|
116
|
+
if (props.allowExisting) {
|
|
117
|
+
loadExistingCredentials();
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
watch(credentialDataTypeVal, (value) => {
|
|
122
|
+
if (
|
|
123
|
+
value === USE_EXISTING_VALUE &&
|
|
124
|
+
props.allowExisting &&
|
|
125
|
+
existingCredentials.value.length === 0
|
|
126
|
+
) {
|
|
127
|
+
loadExistingCredentials();
|
|
128
|
+
}
|
|
129
|
+
if (value !== USE_EXISTING_VALUE) {
|
|
130
|
+
existingCredentialIdVal.value = '';
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
function clearPublicKeyFile() {
|
|
135
|
+
publicKeyFileName.value = null;
|
|
136
|
+
publicKeyVal.value = '';
|
|
137
|
+
}
|
|
138
|
+
function clearPrivateKeyFile() {
|
|
139
|
+
privateKeyFileName.value = null;
|
|
140
|
+
privateKeyVal.value = '';
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function onPublicKeyFileChange(file: File | null) {
|
|
144
|
+
if (!file) {
|
|
145
|
+
publicKeyFileName.value = null;
|
|
146
|
+
publicKeyVal.value = '';
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
publicKeyFileName.value = file.name;
|
|
150
|
+
const reader = new FileReader();
|
|
151
|
+
reader.onload = () => {
|
|
152
|
+
publicKeyVal.value = String(reader.result ?? '');
|
|
153
|
+
};
|
|
154
|
+
reader.onerror = () => {
|
|
155
|
+
$toast.error("Error reading file");
|
|
156
|
+
};
|
|
157
|
+
reader.readAsText(file);
|
|
158
|
+
}
|
|
159
|
+
function onPrivateKeyFileChange(file: File | null) {
|
|
160
|
+
if (!file) {
|
|
161
|
+
privateKeyFileName.value = null;
|
|
162
|
+
privateKeyVal.value = '';
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
privateKeyFileName.value = file.name;
|
|
166
|
+
const reader = new FileReader();
|
|
167
|
+
reader.onload = () => {
|
|
168
|
+
privateKeyVal.value = String(reader.result ?? '');
|
|
169
|
+
};
|
|
170
|
+
reader.onerror = () => {
|
|
171
|
+
$toast.error("Error reading file");
|
|
172
|
+
};
|
|
173
|
+
reader.readAsText(file);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function onPublicKeyFileChangeWrapper(files: File | File[] | null) {
|
|
177
|
+
let file: File | null = files && Array.isArray(files) ? files[0] ?? null : (files as File | null);
|
|
178
|
+
onPublicKeyFileChange(file);
|
|
179
|
+
}
|
|
180
|
+
function onPrivateKeyFileChangeWrapper(files: File | File[] | null) {
|
|
181
|
+
let file: File | null = files && Array.isArray(files) ? files[0] ?? null : (files as File | null);
|
|
182
|
+
onPrivateKeyFileChange(file);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
async function loadExistingCredentials() {
|
|
186
|
+
if (existingCredentialsLoading.value) return;
|
|
187
|
+
existingCredentialsLoading.value = true;
|
|
188
|
+
existingCredentialsError.value = null;
|
|
189
|
+
try {
|
|
190
|
+
const response = await PlatformManagementClient.credentialsApi.getCredentialsOfUser();
|
|
191
|
+
existingCredentials.value = response.data ?? [];
|
|
192
|
+
} catch (err: any) {
|
|
193
|
+
existingCredentialsError.value = err?.message ?? 'Error loading credentials';
|
|
194
|
+
} finally {
|
|
195
|
+
existingCredentialsLoading.value = false;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function clearForm() {
|
|
200
|
+
credentialDataTypeVal.value = undefined;
|
|
201
|
+
credentialNameVal.value = '';
|
|
202
|
+
usernameVal.value = '';
|
|
203
|
+
passwordVal.value = '';
|
|
204
|
+
publicKeyVal.value = '';
|
|
205
|
+
privateKeyVal.value = '';
|
|
206
|
+
publicKeyFileName.value = null;
|
|
207
|
+
privateKeyFileName.value = null;
|
|
208
|
+
existingCredentialIdVal.value = '';
|
|
209
|
+
existingCredentialsError.value = null;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
defineExpose({ clearForm, createFormData });
|
|
213
|
+
|
|
214
|
+
function createFormData(isFormValid: boolean): CredentialFormData {
|
|
215
|
+
let formData = {
|
|
216
|
+
credentialName: credentialNameVal.value,
|
|
217
|
+
} as CredentialFormData['formData'];
|
|
218
|
+
|
|
219
|
+
if (credentialDataTypeVal.value === USE_EXISTING_VALUE) {
|
|
220
|
+
formData.useExisting = true;
|
|
221
|
+
formData.existingCredentialId = existingCredentialIdVal.value;
|
|
222
|
+
formData.existingCredentialDataType = selectedExistingCredential.value?.data?.credentialDataType;
|
|
223
|
+
return {
|
|
224
|
+
isFormValid,
|
|
225
|
+
formData
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
if (credentialDataTypeVal.value === CredentialDataType.UsernamePassword) {
|
|
230
|
+
formData.data = {
|
|
231
|
+
credentialDataType: credentialDataTypeVal.value,
|
|
232
|
+
username: usernameVal.value,
|
|
233
|
+
password: passwordVal.value,
|
|
234
|
+
} as UsernamePasswordData
|
|
235
|
+
} else if (credentialDataTypeVal.value === CredentialDataType.KeyPair) {
|
|
236
|
+
formData.data = {
|
|
237
|
+
credentialDataType: credentialDataTypeVal.value,
|
|
238
|
+
publicKey: publicKeyVal.value,
|
|
239
|
+
privateKey: privateKeyVal.value,
|
|
240
|
+
} as KeyPairData
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
return {
|
|
244
|
+
isFormValid,
|
|
245
|
+
formData
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function customCredentialFilter(item: any, queryText: string, itemText: string) {
|
|
250
|
+
const lowerQuery = queryText.toLowerCase();
|
|
251
|
+
const credential = existingCredentials.value.find(c => c.id === item.value);
|
|
252
|
+
if (!credential) return false;
|
|
253
|
+
const name = credential.name?.toLowerCase() || '';
|
|
254
|
+
const type = (credential.data?.credentialDataType || '').toLowerCase();
|
|
255
|
+
const username = (credential.data as any)?.username?.toLowerCase() || '';
|
|
256
|
+
const id = credential.id?.toLowerCase() || '';
|
|
257
|
+
return (
|
|
258
|
+
name.includes(lowerQuery) ||
|
|
259
|
+
type.includes(lowerQuery) ||
|
|
260
|
+
username.includes(lowerQuery) ||
|
|
261
|
+
id.includes(lowerQuery)
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
</script>
|
|
265
|
+
|
|
266
|
+
<template>
|
|
267
|
+
<div>
|
|
268
|
+
<!-- STEP 1: Credential Type -->
|
|
269
|
+
<v-select
|
|
270
|
+
v-model="credentialDataTypeVal"
|
|
271
|
+
:items="credentialTypeOptions"
|
|
272
|
+
item-title="title"
|
|
273
|
+
item-value="value"
|
|
274
|
+
label="Credential Type"
|
|
275
|
+
placeholder="Select type of credential"
|
|
276
|
+
density="comfortable"
|
|
277
|
+
:error="!!credentialDataTypeError"
|
|
278
|
+
:error-messages="credentialDataTypeError"
|
|
279
|
+
/>
|
|
280
|
+
|
|
281
|
+
<v-text-field
|
|
282
|
+
v-if="credentialDataTypeVal && credentialDataTypeVal !== USE_EXISTING_VALUE"
|
|
283
|
+
v-model="credentialNameVal"
|
|
284
|
+
label="Credential Name"
|
|
285
|
+
:error="!!credentialNameError"
|
|
286
|
+
:error-messages="credentialNameError"
|
|
287
|
+
class="mb-2"
|
|
288
|
+
/>
|
|
289
|
+
|
|
290
|
+
<div v-if="credentialDataTypeVal === USE_EXISTING_VALUE && selectedExistingCredential">
|
|
291
|
+
<div class="mb-2">
|
|
292
|
+
<span class="text-caption">Credential Name:</span>
|
|
293
|
+
<span class="font-weight-bold ml-1">{{ (selectedExistingCredential.data as any)?.name ?? '-' }}</span>
|
|
294
|
+
</div>
|
|
295
|
+
</div>
|
|
296
|
+
|
|
297
|
+
<div v-if="credentialDataTypeVal === USE_EXISTING_VALUE">
|
|
298
|
+
<v-alert v-if="existingCredentialsError" type="error" variant="tonal" class="mb-2">
|
|
299
|
+
{{ existingCredentialsError }}
|
|
300
|
+
</v-alert>
|
|
301
|
+
|
|
302
|
+
<v-autocomplete
|
|
303
|
+
v-model="existingCredentialIdVal"
|
|
304
|
+
:items="existingCredentialOptions"
|
|
305
|
+
item-title="title"
|
|
306
|
+
item-value="value"
|
|
307
|
+
label="Existing Credential"
|
|
308
|
+
placeholder="Select existing credential"
|
|
309
|
+
density="comfortable"
|
|
310
|
+
:loading="existingCredentialsLoading"
|
|
311
|
+
:error="!!existingCredentialIdError"
|
|
312
|
+
:error-messages="existingCredentialIdError"
|
|
313
|
+
:filter="customCredentialFilter"
|
|
314
|
+
clearable
|
|
315
|
+
/>
|
|
316
|
+
|
|
317
|
+
<div v-if="selectedExistingCredential" class="mt-2">
|
|
318
|
+
<CredentialDisplay :credential="selectedExistingCredential" />
|
|
319
|
+
</div>
|
|
320
|
+
</div>
|
|
321
|
+
|
|
322
|
+
<!-- STEP 2: Fields based on selected Credential Type -->
|
|
323
|
+
<!-- STEP 2: Username/Password -->
|
|
324
|
+
<div v-else-if="credentialDataTypeVal === CredentialDataType.UsernamePassword">
|
|
325
|
+
<v-text-field
|
|
326
|
+
v-model="usernameVal"
|
|
327
|
+
label="Username"
|
|
328
|
+
:error="!!usernameError"
|
|
329
|
+
:error-messages="usernameError"
|
|
330
|
+
/>
|
|
331
|
+
<v-text-field
|
|
332
|
+
v-model="passwordVal"
|
|
333
|
+
label="Password"
|
|
334
|
+
:type="showPassword ? 'text' : 'password'"
|
|
335
|
+
:append-inner-icon="showPassword ? 'mdi-eye' : 'mdi-eye-off'"
|
|
336
|
+
@click:append-inner="showPassword = !showPassword"
|
|
337
|
+
:error="!!passwordError"
|
|
338
|
+
:error-messages="passwordError"
|
|
339
|
+
/>
|
|
340
|
+
</div>
|
|
341
|
+
|
|
342
|
+
<!-- STEP 2: Key Pair -->
|
|
343
|
+
<div v-else-if="credentialDataTypeVal === CredentialDataType.KeyPair">
|
|
344
|
+
<div class="mt-2 mb-2">
|
|
345
|
+
<div class="text-subtitle-2">Public Key</div>
|
|
346
|
+
<div class="text-caption">Enter public key or upload key file</div>
|
|
347
|
+
</div>
|
|
348
|
+
<div>
|
|
349
|
+
<v-file-input
|
|
350
|
+
id="public-key-file-input"
|
|
351
|
+
accept=".pem,.key,text/plain"
|
|
352
|
+
density="compact"
|
|
353
|
+
clearable
|
|
354
|
+
@click:clear="clearPublicKeyFile"
|
|
355
|
+
@update:modelValue="onPublicKeyFileChangeWrapper"
|
|
356
|
+
/>
|
|
357
|
+
<v-textarea
|
|
358
|
+
v-model="publicKeyVal"
|
|
359
|
+
auto-grow
|
|
360
|
+
rows="1"
|
|
361
|
+
max-rows="6"
|
|
362
|
+
:error="!!publicKeyError"
|
|
363
|
+
:error-messages="publicKeyError"
|
|
364
|
+
/>
|
|
365
|
+
</div>
|
|
366
|
+
|
|
367
|
+
<div class="mt-2 mb-2">
|
|
368
|
+
<div class="text-subtitle-2">Private Key</div>
|
|
369
|
+
<div class="text-caption">Enter private key or upload key file</div>
|
|
370
|
+
</div>
|
|
371
|
+
<div>
|
|
372
|
+
<v-file-input
|
|
373
|
+
id="private-key-file-input"
|
|
374
|
+
accept=".pem,.key,text/plain"
|
|
375
|
+
density="compact"
|
|
376
|
+
no-resize
|
|
377
|
+
@click:clear="clearPrivateKeyFile"
|
|
378
|
+
@update:modelValue="onPrivateKeyFileChangeWrapper"
|
|
379
|
+
/>
|
|
380
|
+
<v-textarea
|
|
381
|
+
v-model="privateKeyVal"
|
|
382
|
+
rows="6"
|
|
383
|
+
no-resize
|
|
384
|
+
:auto-grow="false"
|
|
385
|
+
:error="!!privateKeyError"
|
|
386
|
+
:error-messages="privateKeyError"
|
|
387
|
+
/>
|
|
388
|
+
</div>
|
|
389
|
+
</div>
|
|
390
|
+
</div>
|
|
391
|
+
</template>
|
|
392
|
+
|
|
393
|
+
<style scoped>
|
|
394
|
+
</style>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { CredentialDataType } from "@/api/platform-management/client";
|
|
2
|
+
|
|
3
|
+
export interface UsernamePasswordData {
|
|
4
|
+
credentialDataType: CredentialDataType.UsernamePassword;
|
|
5
|
+
username: string;
|
|
6
|
+
password: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface KeyPairData {
|
|
10
|
+
credentialDataType: CredentialDataType.KeyPair;
|
|
11
|
+
publicKey: string;
|
|
12
|
+
privateKey: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type CredentialData = UsernamePasswordData | KeyPairData;
|
|
16
|
+
|
|
17
|
+
export interface CredentialFormData {
|
|
18
|
+
isFormValid: boolean;
|
|
19
|
+
formData: {
|
|
20
|
+
credentialName?: string;
|
|
21
|
+
data?: CredentialData;
|
|
22
|
+
useExisting?: boolean;
|
|
23
|
+
existingCredentialId?: string;
|
|
24
|
+
existingCredentialDataType?: CredentialDataType;
|
|
25
|
+
};
|
|
26
|
+
}
|