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

Allow multiple semanticIds for UserPlugins #16

Merged
merged 2 commits into from
Sep 13, 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
9 changes: 5 additions & 4 deletions aas-web-ui/src/UserPlugins/HelloWorldPlugin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
<!-- Plugin Title -->
<v-card class="mb-3">
<v-card-title>
<div class="text-subtitle-1">{{ 'Hello World Plugin:' }}</div>
<div class="text-subtitle-1">{{ nameToDisplay(submodelElementData) }}</div>
</v-card-title>
</v-card>
<!-- Iterate over all SubmodelElements of the HelloWorld-Plugin -->
<div v-for="SubmodelElement in pluginData" :key="SubmodelElement.idShort" class="mb-3">
<!-- Display SubmodelElement -->
<SubmodelElementWrapper
:SubmodelElementObject="SubmodelElement"

Check warning on line 13 in aas-web-ui/src/UserPlugins/HelloWorldPlugin.vue

View workflow job for this annotation

GitHub Actions / build

Attribute ':SubmodelElementObject' must be hyphenated
@update-value="updatePluginValue"></SubmodelElementWrapper>
</div>
</v-container>
Expand All @@ -25,13 +25,14 @@
import { useAASStore } from '@/store/AASDataStore';

export default defineComponent({
name: 'PluginJSONArray',
SemanticID: 'http://hello.world.de/plugin_submodel',
name: 'HelloWorldPlugin',
// semanticId: 'http://hello.world.de/plugin_submodel', // semanticId of the HelloWorld-Plugin as string
semanticId: ['http://hello.world.de/plugin_submodel', 'http://hello.world.de/plugin_property'], // semanticId of the HelloWorld-Plugin as array to use multiple semanticIds
components: {
SubmodelElementWrapper,
},
mixins: [RequestHandling, SubmodelElementHandling], // SemanticID of the HelloWorld-Plugin
mixins: [RequestHandling, SubmodelElementHandling],
props: ['submodelElementData'],

Check warning on line 35 in aas-web-ui/src/UserPlugins/HelloWorldPlugin.vue

View workflow job for this annotation

GitHub Actions / build

Prop "submodelElementData" should define at least its type

setup() {
const theme = useTheme();
Expand All @@ -45,7 +46,7 @@

data() {
return {
pluginData: {} as any, // Data of the HelloWorld-Plugin

Check warning on line 49 in aas-web-ui/src/UserPlugins/HelloWorldPlugin.vue

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
};
},

Expand Down Expand Up @@ -80,8 +81,8 @@
},

// Function to prepare the Plugin Data
preparePluginData(pluginSubmodelElements: Array<any>, path: string = ''): Array<any> {

Check warning on line 84 in aas-web-ui/src/UserPlugins/HelloWorldPlugin.vue

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type

Check warning on line 84 in aas-web-ui/src/UserPlugins/HelloWorldPlugin.vue

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
pluginSubmodelElements.forEach((submodelElement: any) => {

Check warning on line 85 in aas-web-ui/src/UserPlugins/HelloWorldPlugin.vue

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
submodelElement.id = this.UUID(); // add a unique id to the SubmodelElement
submodelElement.path = path + '/' + submodelElement.idShort; // add the path to the SubmodelElement
// the next Step is not needed for the HelloWorld-Plugin, but it is still displayed as an Example for more complex Situations using SubmodelElementCollections
Expand Down
13 changes: 11 additions & 2 deletions aas-web-ui/src/components/SubmodelPlugins/_SubmodelEntrypoint.vue
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,17 @@
// Filtered Plugins
filteredPlugins() {
return this.ImportedPlugins.filter((plugin: any) => {
// console.log(plugin.SemanticID === this.submodelElementData.semanticId.keys[0].value ? 'Plugin found: ' + plugin.SemanticID : 'Plugin not found: ' + plugin.SemanticID);
return plugin.SemanticID === this.submodelElementData.semanticId.keys[0].value;
if (!plugin.semanticId) return false;

if (typeof plugin.semanticId === 'string') {
return this.checkSemanticId(this.submodelElementData, plugin.semanticId);
} else if (plugin.semanticId.constructor === Array) {
for (const pluginSemanticId of plugin.semanticId) {
if (this.checkSemanticId(this.submodelElementData, pluginSemanticId)) return true;
}
return false;
}
return false;
});
},

Expand Down
4 changes: 2 additions & 2 deletions aas-web-ui/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// Types
interface PluginType {
name: string;
SemanticID: string;
semanticId: string;
}

// Components
Expand Down Expand Up @@ -61,9 +61,9 @@
await Promise.all(
files.map(async (path) => {
const componentName = path.replace('./UserPlugins/', '').replace('.vue', '');
const component: any = await pluginFiles[path]();

Check warning on line 64 in aas-web-ui/src/main.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
app.component(componentName, (component.default || component) as ReturnType<typeof defineComponent>);
plugins.push({ name: componentName, SemanticID: component.default.SemanticID });
plugins.push({ name: componentName, semanticId: component.default.semanticId });
})
);

Expand Down Expand Up @@ -111,7 +111,7 @@
setInterval(() => {
keycloak
.updateToken(70)
.then((refreshed) => {

Check warning on line 114 in aas-web-ui/src/main.ts

View workflow job for this annotation

GitHub Actions / build

Avoid nesting promises
if (refreshed) {
// console.log('Token refreshed');
authStore.setToken(keycloak.token);
Expand All @@ -119,7 +119,7 @@
}
authStore.setAuthStatus(true);
})
.catch(() => {

Check warning on line 122 in aas-web-ui/src/main.ts

View workflow job for this annotation

GitHub Actions / build

Avoid nesting promises
console.error('Failed to refresh token');
authStore.setAuthStatus(false);
});
Expand Down
2 changes: 1 addition & 1 deletion aas-web-ui/src/store/NavigationStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export interface PlatformType {

export interface PluginType {
name: string;
SemanticID: string;
semanticId: string;
}

import { defineStore } from 'pinia';
Expand Down
Loading