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

Operator input/output label reactive #6581

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from 14 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
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,6 @@
@menu-selection="(operatorType) => emit('menu-selection', operatorType, output)"
/>
</Transition>
<!--TODO: We will see how to integrate port actions into this button later-->
<!-- <Button
size="small"
text
label="output.actionLabel"
@click.stop="console.log('Do output.action() here')"
/> -->
</li>
</ul>
</template>
Expand Down
4 changes: 2 additions & 2 deletions packages/client/hmi-client/src/composables/activeProject.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { computed, shallowRef } from 'vue';
import { computed, ref } from 'vue';
import type { Project } from '@/types/Types';

export const activeProject = shallowRef<Project | null>(null);
export const activeProject = ref<Project | null>(null);
export const activeProjectId = computed<string>(() => activeProject.value?.id ?? '');
6 changes: 3 additions & 3 deletions packages/client/hmi-client/src/composables/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { activeProject, activeProjectId } from '@/composables/activeProject';
import * as ProjectService from '@/services/project';
import type { PermissionRelationships, Project, ProjectAsset } from '@/types/Types';
import { AssetType } from '@/types/Types';
import { shallowRef } from 'vue';
import { computed, ComputedRef, shallowRef } from 'vue';
import { useToastService } from '@/services/toast';

const TIMEOUT_MS = 100;
Expand Down Expand Up @@ -137,8 +137,8 @@ export function useProjects() {
* @param {ProjectAsset['assetId]} assetId
* @returns {ProjectAsset['assetName']}
*/
function getAssetName(assetId: ProjectAsset['assetId']): ProjectAsset['assetName'] {
return findAsset(assetId)?.assetName ?? '';
function getAssetName(assetId: ProjectAsset['assetId']): ComputedRef<ProjectAsset['assetName']> {
return computed(() => findAsset(assetId)?.assetName ?? '');
}

/**
Expand Down
31 changes: 16 additions & 15 deletions packages/client/hmi-client/src/services/workflow.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component } from 'vue';
import { Component, computed } from 'vue';
import { v4 as uuidv4 } from 'uuid';
import _, { cloneDeep } from 'lodash';
import _, { cloneDeep, isEmpty } from 'lodash';
import API from '@/api/api';
import { logger } from '@/utils/logger';
import { EventEmitter } from '@/utils/emitter';
Expand All @@ -14,21 +14,17 @@ import type {
WorkflowNode,
WorkflowPort,
WorkflowOutput,
WorkflowAnnotation
} from '@/types/workflow';
import {
WorkflowPortStatus,
OperatorStatus,
WorkflowOperationTypes,
WorkflowTransformations,
WorkflowAnnotation,
Transform
} from '@/types/workflow';
import { OperatorStatus, WorkflowOperationTypes, WorkflowPortStatus, WorkflowTransformations } from '@/types/workflow';
import { useProjects } from '@/composables/project';
import useAuthStore from '@/stores/auth';
import dagre from 'dagre';
import { ProjectAsset } from '@/types/Types';

/**
* A wrapper class around the workflow data struture to make it easier
* A wrapper class around the workflow data structure to make it easier
* to deal with CURD operations
* */
export class WorkflowWrapper {
Expand All @@ -42,8 +38,7 @@ export class WorkflowWrapper {
}
}

// This will replace the entire workflow, should only use for initial load
// as there it will not propapate reactivity
// This will replace the entire workflow, should only use for initial load as there it will not propagate reactivity
load(wf: Workflow) {
this.wf = _.cloneDeep(wf);
}
Expand Down Expand Up @@ -649,14 +644,20 @@ export function getOutputLabel(outputs: WorkflowOutput<any>[], id: string) {
const selectedOutput = outputs.find((output) => output.id === id);
if (!selectedOutput) return '';

let assetId: ProjectAsset['assetId'];

// multiple output types, choose first name to use as label arbitrarily
if (selectedOutput.type.includes('|')) {
const outputType = selectedOutput.type.split('|');
return useProjects().getAssetName(selectedOutput.value?.[0]?.[outputType?.[0]]) || selectedOutput.label;
assetId = selectedOutput.value?.[0]?.[outputType?.[0]];

// default use single output type
} else {
assetId = selectedOutput.value?.[0];
}

// default use single output type
return useProjects().getAssetName(selectedOutput.value?.[0]) || selectedOutput.label;
const label = useProjects().getAssetName(assetId).value;
return computed(() => (!isEmpty(label) ? label : (selectedOutput.label ?? '')));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to be a couple of extra layers of unnecessary computed going. on here, what is the problem here? The PR description is blank so I am not even sure what to test for ??


// Checker for resource-operators (e.g. model, dataset) that automatically create an output
Expand Down
Loading