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

Display all assets in the ressources panel #2769

Merged
merged 27 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
1b3f539
feat: darker text in content switcher buttons
jamiewaese-uncharted Jul 13, 2023
696ff88
Merge branch 'main' of https://github.com/DARPA-ASKEM/Terarium
jamiewaese-uncharted Jul 14, 2023
3f29442
Merge branch 'main' of https://github.com/DARPA-ASKEM/Terarium
jamiewaese-uncharted Jul 14, 2023
8d271e0
Merge branch 'main' of https://github.com/DARPA-ASKEM/Terarium
jamiewaese-uncharted Jul 14, 2023
9e059d3
Merge branch 'main' of https://github.com/DARPA-ASKEM/Terarium
jamiewaese-uncharted Jul 17, 2023
0733410
Merge branch 'main' of https://github.com/DARPA-ASKEM/Terarium
jamiewaese-uncharted Jul 17, 2023
36bbf01
Merge branch 'main' of https://github.com/DARPA-ASKEM/Terarium
jamiewaese-uncharted Jul 18, 2023
fb88e51
Merge branch 'main' of https://github.com/DARPA-ASKEM/Terarium
jamiewaese-uncharted Jul 19, 2023
6bb287f
Merge branch 'main' of https://github.com/DARPA-ASKEM/Terarium
jamiewaese-uncharted Jul 19, 2023
1cdc024
Merge branch 'main' of https://github.com/DARPA-ASKEM/Terarium
jamiewaese-uncharted Jul 19, 2023
1919fd1
Merge branch 'main' of https://github.com/DARPA-ASKEM/Terarium
jamiewaese-uncharted Jul 20, 2023
dc47094
Merge branch 'main' of https://github.com/DARPA-ASKEM/Terarium
jamiewaese-uncharted Jul 21, 2023
6f52d1e
Merge branch 'main' of https://github.com/DARPA-ASKEM/Terarium
jamiewaese-uncharted Jul 24, 2023
305bf66
Merge branch 'main' of https://github.com/DARPA-ASKEM/Terarium
jamiewaese-uncharted Jan 4, 2024
3e34780
Merge branch 'main' of https://github.com/DARPA-ASKEM/Terarium
jamiewaese-uncharted Jan 8, 2024
a5d6c81
Merge branch 'main' of https://github.com/DARPA-ASKEM/Terarium
jamiewaese-uncharted Jan 11, 2024
305a650
Merge branch 'main' of https://github.com/DARPA-ASKEM/Terarium
jamiewaese-uncharted Jan 22, 2024
ee17593
Merge branch 'main' of https://github.com/DARPA-ASKEM/Terarium
jamiewaese-uncharted Jan 24, 2024
83d6dcf
Merge branch 'main' of https://github.com/DARPA-ASKEM/Terarium
jamiewaese-uncharted Jan 26, 2024
e06bc7a
Merge branch 'main' of https://github.com/DARPA-ASKEM/Terarium
jamiewaese-uncharted Jan 26, 2024
3350006
Merge branch 'main' of https://github.com/DARPA-ASKEM/Terarium
jamiewaese-uncharted Feb 7, 2024
4f5ef99
Merge branch 'main' of https://github.com/DARPA-ASKEM/Terarium
jamiewaese-uncharted Feb 8, 2024
24ff234
Merge branch 'main' of https://github.com/DARPA-ASKEM/Terarium
jamiewaese-uncharted Feb 14, 2024
6ea41bf
Merge branch 'main' of https://github.com/DARPA-ASKEM/Terarium
jamiewaese-uncharted Feb 15, 2024
ffd2532
Display all asset types in the ressources sidebar
YohannParis Feb 16, 2024
6ef125a
Merge branch 'main' into yohannparis/fix-project-view
YohannParis Feb 21, 2024
47ac9ed
make all operator same default size
YohannParis Feb 21, 2024
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 @@ -16,27 +16,6 @@
<i class="pi pi-filter"></i>
</span>
</div>
<!--
<SplitButton
class="new-resource-button"
label="New"
size="small"
severity="secondary"
outlined
@click="toggleOptionsMenu"
:model="optionsMenuItems"
/>
<Menu ref="optionsMenu" :model="optionsMenuItems" :popup="true">
<template #item="slotProps">
<a class="p-menuitem-link">
<tera-asset-icon :asset-type="slotProps.item.key as AssetType" />
<span class="p-menuitem-text">
{{ slotProps.item.label }}
</span>
</a>
</template>
</Menu>
-->
</header>
<Button
class="asset-button"
Expand Down Expand Up @@ -198,14 +177,12 @@ import { useDragEvent } from '@/services/drag-drop';
import { ProjectPages } from '@/types/Project';
import { AssetType } from '@/types/Types';
import { AssetItem, AssetRoute } from '@/types/common';
import { generateProjectAssetsMap } from '@/utils/map-project-assets';
import { generateProjectAssetsMap, getNonNullSetOfVisibleItems } from '@/utils/map-project-assets';
import { capitalize, isEmpty, isEqual } from 'lodash';
import Accordion from 'primevue/accordion';
import AccordionTab from 'primevue/accordiontab';
import Button from 'primevue/button';
// import SplitButton from 'primevue/splitbutton';
import InputText from 'primevue/inputtext';
// import Menu from 'primevue/menu';
import Skeleton from 'primevue/skeleton';
import { computed, ref } from 'vue';

Expand All @@ -225,14 +202,15 @@ const assetToDelete = ref<AssetItem | null>(null);
const searchAsset = ref<string>('');
const inputFocused = ref(false);

const assetItemsMap = computed(() => generateProjectAssetsMap(searchAsset.value));
const assetItemsKeysNotEmpty = computed(() => getNonNullSetOfVisibleItems(assetItemsMap.value));
const activeAccordionTabs = ref(
new Set(
localStorage.getItem('activeResourceBarTabs')?.split(',').map(Number) ?? [0, 1, 2, 3, 4, 5, 6]
localStorage.getItem('activeResourceBarTabs')?.split(',').map(Number) ??
assetItemsKeysNotEmpty.value ?? [0, 1, 2, 3, 4, 5, 6]
)
);

const assetItemsMap = computed(() => generateProjectAssetsMap(searchAsset.value));

function clearSearch() {
searchAsset.value = '';
}
Expand Down Expand Up @@ -261,35 +239,6 @@ function endDrag() {
deleteDragData('assetNode');
draggedAsset.value = null;
}

// const optionsMenu = ref();
// const optionsMenuItems = ref([
// {
// key: AssetType.Code,
// label: 'New code',
// command() {
// emit('open-new-asset', AssetType.Code);
// }
// },
// {
// key: AssetType.Model,
// label: 'New model',
// command() {
// emit('open-new-asset', AssetType.Model);
// }
// },
// {
// key: AssetType.Workflow,
// label: 'New workflow',
// command() {
// emit('open-new-asset', AssetType.Workflow);
// }
// }
// ]);

// const toggleOptionsMenu = (event) => {
// optionsMenu.value.toggle(event);
// };
</script>

<style scoped>
Expand Down Expand Up @@ -328,36 +277,6 @@ header {
overflow: visible;
}

/* Split button
* This needs to be into its own component
*/

:deep(.new-resource-button) {
color: var(--text-color-primary);
}

:deep(.new-resource-button.p-splitbutton .p-button:first-of-type) {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
border-right: 0 none;
padding-left: 0;
color: var(--text-color);
}

:deep(.new-resource-button.p-splitbutton .p-button:last-of-type) {
background-color: var(--surface-200);
border-top-left-radius: 0;
border-bottom-left-radius: 0;
color: var(--text-color-light);
padding: 0.65rem 0;
width: 2rem;

&:hover {
background-color: var(--surface-50);
color: var(--text-color);
}
}

.removeResourceButton {
color: var(--text-color-subdued);
margin-right: 0.75rem;
Expand Down Expand Up @@ -404,7 +323,7 @@ header {
overflow: hidden;
padding: 0;
border-radius: 0;
/* Remove the border-radius to end nitely with the border of the sidebar */
/* Remove the border-radius to end neatly with the border of the sidebar */
}

:deep(.asset-button.p-button > span) {
Expand Down
19 changes: 19 additions & 0 deletions packages/client/hmi-client/src/types/Project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,24 @@ export enum ProjectPages {
OVERVIEW = 'overview'
}

/**
* Return the list of AssetTypes that are visible in the project
* This takes the Types from the AssetType enum and filters out the ones that are not visible
*/
export const listOfVisibleAssetTypes: AssetType[] = Object.values(AssetType).filter(
(type) => ![AssetType.Publication, AssetType.Artifact].includes(type)
);

/**
* Check if the asset type is a project asset type
* @param type
*/
export const isProjectAssetTypes = (type: AssetType | string): boolean =>
Object.values(AssetType).includes(type.toUpperCase() as AssetType);

/**
* Check if the asset type is a project visible asset type
* @param type
*/
export const isVisibleProjectAssetTypes = (type: AssetType | string): boolean =>
listOfVisibleAssetTypes.includes(type.toUpperCase() as AssetType);
26 changes: 23 additions & 3 deletions packages/client/hmi-client/src/utils/map-project-assets.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
import _ from 'lodash';
import { AssetItem } from '@/types/common';
import { useProjects } from '@/composables/project';
import { isProjectAssetTypes } from '@/types/Project';
import { isVisibleProjectAssetTypes, listOfVisibleAssetTypes } from '@/types/Project';
import { formatShort } from '@/utils/date';

// Map of asset types to their respective asset items
type ProjectAssetItems = Map<string, Set<AssetItem>>;

/**
* Generate a map of all the visible asset types and their respective asset items
* @param searchAsset - the search term to filter the assets
*/
export const generateProjectAssetsMap = (searchAsset: string): ProjectAssetItems => {
const assetItemsMap = new Map<string, Set<AssetItem>>();
// Create a map of all the visible asset types
const assetItemsMap: ProjectAssetItems = new Map<string, Set<AssetItem>>();
listOfVisibleAssetTypes.forEach((type) => assetItemsMap.set(type, new Set<AssetItem>()));

// Check if the project has any assets
const projectAssets = useProjects().activeProject?.value?.projectAssets;
if (!projectAssets) return assetItemsMap;

// Run through all the assets type within the project
const cleanAssets = projectAssets
.filter((asset) => isProjectAssetTypes(asset.assetType))
.filter((asset) => isVisibleProjectAssetTypes(asset.assetType))
.map(
(asset) =>
({
Expand All @@ -32,9 +40,21 @@ export const generateProjectAssetsMap = (searchAsset: string): ProjectAssetItems
return asset.assetName.toLowerCase().includes(searchTermLower);
});

// Assign the assets to the map
Object.entries(_.groupBy(cleanAssets, 'pageType')).forEach(([type, assetList]) =>
assetItemsMap.set(type, new Set(assetList as AssetItem[]))
);

return assetItemsMap;
};

// Function to filter out keys with non-null sets
export function getNonNullSetOfVisibleItems(map: ProjectAssetItems): number[] {
const nonNullSet: number[] = [];
map.forEach((value, key) => {
if (value !== null && value.size > 0) {
nonNullSet.push(listOfVisibleAssetTypes.findIndex((type) => type === key));
}
});
return nonNullSet;
}
12 changes: 6 additions & 6 deletions packages/client/hmi-client/src/workflow/tera-workflow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -525,29 +525,29 @@ const contextMenuItems: MenuItem[] = [
items: [
{
label: CalibrateJuliaOp.operation.displayName,
command: addOperatorToWorkflow(CalibrateJuliaOp, OperatorNodeSize.xlarge)
command: addOperatorToWorkflow(CalibrateJuliaOp)
},
{
label: SimulateJuliaOp.operation.displayName,
command: addOperatorToWorkflow(SimulateJuliaOp, OperatorNodeSize.xlarge)
command: addOperatorToWorkflow(SimulateJuliaOp)
},
{ separator: true },
{
label: SimulateCiemssOp.operation.displayName,
command: addOperatorToWorkflow(SimulateCiemssOp, OperatorNodeSize.xlarge)
command: addOperatorToWorkflow(SimulateCiemssOp)
},
{
label: CalibrateCiemssOp.operation.displayName,
command: addOperatorToWorkflow(CalibrateCiemssOp, OperatorNodeSize.xlarge)
command: addOperatorToWorkflow(CalibrateCiemssOp)
},
{ separator: true },
{
label: CalibrateEnsembleCiemssOp.operation.displayName,
command: addOperatorToWorkflow(CalibrateEnsembleCiemssOp, OperatorNodeSize.xlarge)
command: addOperatorToWorkflow(CalibrateEnsembleCiemssOp)
},
{
label: SimulateEnsembleCiemssOp.operation.displayName,
command: addOperatorToWorkflow(SimulateEnsembleCiemssOp, OperatorNodeSize.xlarge)
command: addOperatorToWorkflow(SimulateEnsembleCiemssOp)
}
]
},
Expand Down
Loading