Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Env variable for disabling path/url configuration to the BaSyx backend components #74

Merged
merged 6 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ docker run -p 3000:3000 eclipsebasyx/aas-ui

`-e BASE_PATH=<base_path>`

`-e ENDPOINT_CONFIG_AVAILABLE=<true/false>`

4. If you want to use a custom logo, you can mount a folder containing the logo and the favicon.ico to the container by adding the following argument to the run command:

`-v <local_path_to_logo_folder>:/usr/src/app/dist/Logo`
Expand Down Expand Up @@ -202,6 +204,7 @@ aas-web-gui:
PRIMARY_COLOR: "<primary_color>"
LOGO_PATH: "<logo_path>"
BASE_PATH: "<base_path>"
ENDPOINT_CONFIG_AVAILABLE: "<true/false>"
volumes:
- <local_path_to_logo_folder>:/usr/src/app/dist/Logo
```
Expand Down
4 changes: 4 additions & 0 deletions aas-web-ui/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ if [ -n "$KEYCLOAK_CLIENT_ID" ]; then
jq '.keycloakClientId = env.KEYCLOAK_CLIENT_ID' /usr/src/app/dist/config.json > /tmp/config.json && mv /tmp/config.json /usr/src/app/dist/config.json
fi

if [ -n "$ENDPOINT_CONFIG_AVAILABLE" ]; then
jq '.endpointConfigAvailable = env.ENDPOINT_CONFIG_AVAILABLE' /usr/src/app/dist/config.json > /tmp/config.json && mv /tmp/config.json /usr/src/app/dist/config.json
fi

if [ -n "$BASE_PATH" ]; then
echo "====================="
echo "BASE_PATH: $BASE_PATH"
Expand Down
33 changes: 17 additions & 16 deletions aas-web-ui/public/config.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
{
"logoPath": "Logo/Logo.svg",
"basePath": "",
"aasDiscoveryPath": "",
"aasRegistryPath": "",
"submodelRegistryPath": "",
"aasRepoPath": "",
"submodelRepoPath": "",
"cdRepoPath": "",
"dashboardServicePath": "",
"primaryColor": "#0cb2f0",
"influxdbToken": "",
"keycloakUrl": "",
"keycloakRealm": "",
"keycloakClientId": ""
}
{
"logoPath": "Logo/Logo.svg",
"basePath": "",
"aasDiscoveryPath": "",
"aasRegistryPath": "",
"submodelRegistryPath": "",
"aasRepoPath": "",
"submodelRepoPath": "",
"cdRepoPath": "",
"dashboardServicePath": "",
"primaryColor": "#0cb2f0",
"influxdbToken": "",
"keycloakUrl": "",
"keycloakRealm": "",
"keycloakClientId": "",
"endpointConfigAvailable": true
}
123 changes: 69 additions & 54 deletions aas-web-ui/src/components/AppNavigation/AppNavigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@
mainMenu: false, // Variable to show the Main Menu
mobileMenu: false, // Variable to show the Mobile Menu
dashboardAvailable: false, // Dashboard Availability
endpointConfigAvailable: true,
drawerVisibility: true, // Variable to show the AAS List Drawer
};
},
Expand Down Expand Up @@ -317,6 +318,10 @@
return this.envStore.getEnvLogoPath;
},

getEndpointConfigAvailable() {
return this.envStore.getEndpointConfigAvailable;
},

dashboardServicePath() {
return this.envStore.getEnvDashboardServicePath;
},
Expand Down Expand Up @@ -371,6 +376,7 @@

mounted() {
this.isDashboardAvailable();
this.endpointConfigAvailable = this.getEndpointConfigAvailable;
// check the local storage for a saved theme preference
let theme = localStorage.getItem('theme');
if (theme) {
Expand All @@ -394,88 +400,97 @@
}

// auto connect to aas discovery that was saved in local storage
let aasDiscoveryURL = window.localStorage.getItem('aasDiscoveryURL');
if (aasDiscoveryURL) {
this.aasDiscoveryURL = aasDiscoveryURL;
this.connectToAASDiscovery();
// console.log('DiscoveryURL was found in local storage', DiscoveryURL);
} else {
// if no discovery server was saved in local storage, check if an environment variable is set
if (this.EnvAASDiscoveryPath && this.EnvAASDiscoveryPath != '') {
this.aasDiscoveryURL = this.EnvAASDiscoveryPath;
if (this.endpointConfigAvailable) {
let aasDiscoveryURL = window.localStorage.getItem('aasDiscoveryURL');
if (aasDiscoveryURL) {
this.aasDiscoveryURL = aasDiscoveryURL;
this.connectToAASDiscovery();
// console.log('DiscoveryURL was found in local storage', DiscoveryURL);
}
}

if (!this.aasDiscoveryURL && this.EnvAASDiscoveryPath && this.EnvAASDiscoveryPath != '') {
this.aasDiscoveryURL = this.EnvAASDiscoveryPath;
this.connectToAASDiscovery();
}

// auto connect to aas registry that was saved in local storage
let aasRegistryURL = window.localStorage.getItem('aasRegistryURL');
if (aasRegistryURL) {
this.aasRegistryURL = aasRegistryURL;
this.connectToAASRegistry();
// console.log('RegistryURL was found in local storage', RegistryURL);
} else {
// if no registry server was saved in local storage, check if an environment variable is set
if (this.EnvAASRegistryPath && this.EnvAASRegistryPath != '') {
this.aasRegistryURL = this.EnvAASRegistryPath;
if (this.endpointConfigAvailable) {
let aasRegistryURL = window.localStorage.getItem('aasRegistryURL');
if (aasRegistryURL) {
this.aasRegistryURL = aasRegistryURL;
this.connectToAASRegistry();
// console.log('RegistryURL was found in local storage', RegistryURL);
}
}

if (!this.aasRegistryURL && this.EnvAASRegistryPath && this.EnvAASRegistryPath != '') {
this.aasRegistryURL = this.EnvAASRegistryPath;
this.connectToAASRegistry();
}

// auto connect to submodel registry that was saved in local storage
let submodelRegistryURL = window.localStorage.getItem('submodelRegistryURL');
if (submodelRegistryURL) {
this.submodelRegistryURL = submodelRegistryURL;
this.connectToSubmodelRegistry();
// console.log('SubmodelRegistryURL was found in local storage', SubmodelRegistryURL);
} else {
// if no submodel registry server was saved in local storage, check if an environment variable is set
if (this.EnvSubmodelRegistryPath && this.EnvSubmodelRegistryPath != '') {
this.submodelRegistryURL = this.EnvSubmodelRegistryPath;
if (this.endpointConfigAvailable) {
let submodelRegistryURL = window.localStorage.getItem('submodelRegistryURL');
if (submodelRegistryURL) {
this.submodelRegistryURL = submodelRegistryURL;
this.connectToSubmodelRegistry();
// console.log('SubmodelRegistryURL was found in local storage', SubmodelRegistryURL);
}
}
if (!this.submodelRegistryURL && this.EnvSubmodelRegistryPath && this.EnvSubmodelRegistryPath != '') {
this.submodelRegistryURL = this.EnvSubmodelRegistryPath;
this.connectToSubmodelRegistry();
}

// auto connect to AAS Repository that was saved in local storage
let aasRepoURL = window.localStorage.getItem('AASRepoURL');
if (aasRepoURL) {
this.AASRepoURL = aasRepoURL;
this.connectToEnvironment('AAS');
// console.log('AASRepoURL was found in local storage', AASRepoURL);
} else {
// if no aas server was saved in local storage, check if an environment variable is set
if (this.EnvAASRepoPath && this.EnvAASRepoPath != '') {
this.AASRepoURL = this.EnvAASRepoPath;
if (this.endpointConfigAvailable) {
let aasRepoURL = window.localStorage.getItem('AASRepoURL');
if (aasRepoURL) {
this.AASRepoURL = aasRepoURL;
this.connectToEnvironment('AAS');
// console.log('AASRepoURL was found in local storage', AASRepoURL);
}
}

if (!this.AASRepoURL && this.EnvAASRepoPath && this.EnvAASRepoPath != '') {
this.AASRepoURL = this.EnvAASRepoPath;
this.connectToEnvironment('AAS');
}

// auto connect to Submodel Repository that was saved in local storage
let submodelRepoURL = window.localStorage.getItem('SubmodelRepoURL');
if (submodelRepoURL) {
this.SubmodelRepoURL = submodelRepoURL;
this.connectToEnvironment('Submodel');
// console.log('SubmodelRepoURL was found in local storage', SubmodelRepoURL);
} else {
// if no submodel server was saved in local storage, check if an environment variable is set
if (this.EnvSubmodelRepoPath && this.EnvSubmodelRepoPath != '') {
this.SubmodelRepoURL = this.EnvSubmodelRepoPath;
if (this.endpointConfigAvailable) {
let submodelRepoURL = window.localStorage.getItem('SubmodelRepoURL');
if (submodelRepoURL) {
this.SubmodelRepoURL = submodelRepoURL;
this.connectToEnvironment('Submodel');
// // console.log('SubmodelRepoURL was found in local storage', SubmodelRepoURL);
}
}

if (!this.SubmodelRepoURL && this.EnvSubmodelRepoPath && this.EnvSubmodelRepoPath != '') {
this.SubmodelRepoURL = this.EnvSubmodelRepoPath;
this.connectToEnvironment('Submodel');
}

// auto connect to Concept Description Repository that was saved in local storage
let conceptDescriptionRepoURL = window.localStorage.getItem('ConceptDescriptionRepoURL');
if (conceptDescriptionRepoURL) {
this.ConceptDescriptionRepoURL = conceptDescriptionRepoURL;
this.connectToEnvironment('ConceptDescription');
// console.log('ConceptDescriptionRepoURL was found in local storage', ConceptDescriptionRepoURL);
} else {
// if no concept description server was saved in local storage, check if an environment variable is set
if (this.EnvConceptDescriptionRepoPath && this.EnvConceptDescriptionRepoPath != '') {
this.ConceptDescriptionRepoURL = this.EnvConceptDescriptionRepoPath;
if (this.endpointConfigAvailable) {
let conceptDescriptionRepoURL = window.localStorage.getItem('ConceptDescriptionRepoURL');
if (conceptDescriptionRepoURL) {
this.ConceptDescriptionRepoURL = conceptDescriptionRepoURL;
this.connectToEnvironment('ConceptDescription');
// console.log('ConceptDescriptionRepoURL was found in local storage', ConceptDescriptionRepoURL);
}
}

if (
!this.ConceptDescriptionRepoURL &&
this.EnvConceptDescriptionRepoPath &&
this.EnvConceptDescriptionRepoPath != ''
) {
this.ConceptDescriptionRepoURL = this.EnvConceptDescriptionRepoPath;
this.connectToEnvironment('ConceptDescription');
}
},

methods: {
Expand Down
47 changes: 36 additions & 11 deletions aas-web-ui/src/components/AppNavigation/MainMenu.vue
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
<template>
<v-container fluid class="pa-0">
<v-card
:min-width="isMobile ? 0 : 700"
:min-width="isMobile || !endpointConfigAvailable ? 200 : 700"
:flat="isMobile ? true : false"
:color="isMobile ? 'card' : 'navigationMenu'"
:style="{ 'border-style': isMobile ? '' : 'solid', 'border-width': isMobile ? '' : '1px' }">
<v-row>
<v-col :cols="isMobile ? 12 : 4" :class="isMobile ? 'bg-card' : 'bg-navigationMenuSecondary'">
<v-col
:cols="isMobile || !endpointConfigAvailable ? 12 : 4"
:class="isMobile ? 'bg-card' : 'bg-navigationMenuSecondary'">
<v-card
variant="flat"
style="border-radius: 0px"
class="pt-3"
:color="isMobile ? 'card' : 'navigationMenuSecondary'">
<template v-if="!isMobile">
<template v-if="!isMobile && endpointConfigAvailable">
<span class="mx-3 text-primary">General Settings</span>
<v-list
nav
Expand Down Expand Up @@ -46,6 +48,7 @@
</v-card>
</v-col>
<v-col
v-if="endpointConfigAvailable"
:cols="isMobile ? 12 : 8"
:class="isMobile ? 'pt-0 mb-2 px-6 bg-card' : 'pt-4 bg-navigationMenu'">
<!-- Configure AAS Discovery URL -->
Expand Down Expand Up @@ -247,6 +250,7 @@
loadingSubmodelRepo: false, // Loading State of the Submodel Repository Connection
loadingConceptDescriptionRepo: false, // Loading State of the Concept Description Repository Connection
dashboardAvailable: false, // Dashboard Availability
endpointConfigAvailable: true,
};
},

Expand Down Expand Up @@ -286,6 +290,10 @@
return this.navigationStore.getConceptDescriptionRepoURL;
},

getEndpointConfigAvailable() {
return this.envStore.getEndpointConfigAvailable;
},

// Check if the current Theme is dark
isDark() {
return this.theme.global.current.value.dark;
Expand All @@ -311,6 +319,7 @@
this.AASRepoURL = this.aasRepoURL;
this.SubmodelRepoURL = this.submodelRepoURL;
this.ConceptDescriptionRepoURL = this.conceptDescriptionRepoURL;
this.endpointConfigAvailable = this.getEndpointConfigAvailable;
this.isDashboardAvailable();
},

Expand All @@ -331,10 +340,14 @@
this.loadingAASDiscovery = false;
if (response.success) {
this.navigationStore.dispatchAASDiscoveryURL(this.aasDiscoveryURL); // save the URL in the NavigationStore
window.localStorage.setItem('aasDiscoveryURL', this.aasDiscoveryURL); // save the URL in the local storage
if (this.endpointConfigAvailable) {
window.localStorage.setItem('aasDiscoveryURL', this.aasDiscoveryURL); // save the URL in the local storage
}
} else {
this.navigationStore.dispatchAASDiscoveryURL(''); // clear the AAS Discovery Service URL in the NavigationStore
window.localStorage.removeItem('aasDiscoveryURL'); // remove the URL from the local storage
if (this.endpointConfigAvailable) {
window.localStorage.removeItem('aasDiscoveryURL'); // remove the URL from the local storage
}
}
});
}
Expand All @@ -356,10 +369,14 @@
this.loadingAASRegistry = false;
if (response.success) {
this.navigationStore.dispatchAASRegistryURL(this.aasRegistryURL); // save the URL in the NavigationStore
window.localStorage.setItem('aasRegistryURL', this.aasRegistryURL); // save the URL in the local storage
if (this.endpointConfigAvailable) {
window.localStorage.setItem('aasRegistryURL', this.aasRegistryURL); // save the URL in the local storage
}
} else {
this.navigationStore.dispatchAASRegistryURL(''); // clear the AAS Registry URL in the NavigationStore
window.localStorage.removeItem('aasRegistryURL'); // remove the URL from the local storage
if (this.endpointConfigAvailable) {
window.localStorage.removeItem('aasRegistryURL'); // remove the URL from the local storage
}
}
});
}
Expand All @@ -381,10 +398,14 @@
this.loadingSubmodelRegistry = false;
if (response.success) {
this.navigationStore.dispatchSubmodelRegistryURL(this.submodelRegistryURL); // save the URL in the NavigationStore
window.localStorage.setItem('submodelRegistryURL', this.submodelRegistryURL); // save the URL in the local storage
if (this.endpointConfigAvailable) {
window.localStorage.setItem('submodelRegistryURL', this.submodelRegistryURL); // save the URL in the local storage
}
} else {
this.navigationStore.dispatchSubmodelRegistryURL(''); // clear the Submodel Registry URL in the NavigationStore
window.localStorage.removeItem('submodelRegistryURL'); // remove the URL from the local storage
if (this.endpointConfigAvailable) {
window.localStorage.removeItem('submodelRegistryURL'); // remove the URL from the local storage
}
}
});
}
Expand All @@ -405,10 +426,14 @@
(this as any)['loading' + RepoType + 'Repo'] = false;
if (response.success) {
this.navigationStore.dispatchRepoURL(RepoType, (this as any)[RepoType + 'RepoURL']); // save the URL in the NavigationStore
window.localStorage.setItem(RepoType + 'RepoURL', (this as any)[RepoType + 'RepoURL']); // save the URL in the local storage
if (this.endpointConfigAvailable) {
window.localStorage.setItem(RepoType + 'RepoURL', (this as any)[RepoType + 'RepoURL']); // save the URL in the local storage
}
} else {
this.navigationStore.dispatchRepoURL(RepoType, ''); // clear the URL in the NavigationStore
window.localStorage.removeItem(RepoType + 'RepoURL'); // remove the URL from the local storage
if (this.endpointConfigAvailable) {
window.localStorage.removeItem(RepoType + 'RepoURL'); // remove the URL from the local storage
}
}
});
}
Expand Down
4 changes: 4 additions & 0 deletions aas-web-ui/src/store/EnvironmentStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const useEnvStore = defineStore({
keycloakUrl: '',
keycloakRealm: '',
keycloakClientId: '',
endpointConfigAvailable: true,
}),
getters: {
getEnvLogoPath: (state) => state.logoPath,
Expand All @@ -33,6 +34,7 @@ export const useEnvStore = defineStore({
getKeycloakUrl: (state) => state.keycloakUrl,
getKeycloakRealm: (state) => state.keycloakRealm,
getKeycloakClientId: (state) => state.keycloakClientId,
getEndpointConfigAvailable: (state) => state.endpointConfigAvailable,
},
actions: {
async fetchConfig() {
Expand All @@ -53,6 +55,8 @@ export const useEnvStore = defineStore({
this.keycloakUrl = config.keycloakUrl;
this.keycloakRealm = config.keycloakRealm;
this.keycloakClientId = config.keycloakClientId;
this.endpointConfigAvailable =
config.endpointConfigAvailable === true || config.endpointConfigAvailable === 'true' ? true : false;
} catch (error) {
console.error('Error fetching config.json: ', error);
}
Expand Down