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 shortDescription #5780

Merged
merged 1 commit into from
Dec 9, 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
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,11 @@
:asset="asset"
@click="emit('open-asset', data.id, asset.assetId, asset.assetType)"
/>
<p class="font-semibold">{{ capitalize(asset.embeddingType) }}</p>
<tera-show-more-text :text="asset.embeddingContent" :lines="3" />
<tera-show-more-text :text="asset.assetShortDescription" :lines="3" />
<template v-if="visibleEmbeddingResult(asset.embeddingType)">
YohannParis marked this conversation as resolved.
Show resolved Hide resolved
<p class="font-semibold">{{ capitalize(asset.embeddingType) }}</p>
<tera-show-more-text :text="asset.embeddingContent" :lines="3" />
</template>
</div>
</template>
</DataTable>
Expand All @@ -87,7 +90,7 @@ import TeraAssetButton from '@/components/asset/tera-asset-button.vue';
import TeraAssetIcon from '@/components/widgets/tera-asset-icon.vue';
import TeraProjectMenu from '@/components/home/tera-project-menu.vue';
import TeraShowMoreText from '@/components/widgets/tera-show-more-text.vue';
import { AssetType } from '@/types/Types';
import { AssetType, TerariumAssetEmbeddingType } from '@/types/Types';
import type { ProjectWithKnnData } from '@/types/Project';
import { isEmpty } from 'lodash';

Expand Down Expand Up @@ -127,6 +130,14 @@ function formatStatTooltip(amount: number, itemName: string) {
return `${amount} ${itemName}${amount === 1 ? '' : 's'}`;
}

function visibleEmbeddingResult(embeddingType: TerariumAssetEmbeddingType) {
return ![
TerariumAssetEmbeddingType.Name,
TerariumAssetEmbeddingType.Description,
TerariumAssetEmbeddingType.Overview
].includes(embeddingType);
}

watch(
() => props.projects,
() => {
Expand Down
1 change: 1 addition & 0 deletions packages/client/hmi-client/src/types/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface ProjectSearchResultAsset {
assetId: string;
assetType: AssetType;
assetName: string;
assetShortDescription: string;
createdOn: Date;
embeddingContent: string;
embeddingType: TerariumAssetEmbeddingType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import software.uncharted.terarium.hmiserver.models.TerariumAssetEmbeddingType;
import software.uncharted.terarium.hmiserver.models.dataservice.AssetType;
import software.uncharted.terarium.hmiserver.models.dataservice.ResponseDeleted;
import software.uncharted.terarium.hmiserver.models.dataservice.model.Model;
import software.uncharted.terarium.hmiserver.models.dataservice.project.Contributor;
import software.uncharted.terarium.hmiserver.models.dataservice.project.Project;
import software.uncharted.terarium.hmiserver.models.dataservice.project.ProjectAsset;
Expand Down Expand Up @@ -1015,6 +1016,7 @@ public static class ProjectSearchResultAsset {
final UUID assetId;
final AssetType assetType;
final String assetName;
final String assetShortDescription;
final Timestamp createdOn;
final String embeddingContent;
final TerariumAssetEmbeddingType embeddingType;
Expand Down Expand Up @@ -1127,10 +1129,24 @@ private ProjectSearchResultAsset createProjectSearchResultAsset(final ProjectSea
default -> asset.getName();
};

// Get the description of the asset to be displayed nontheless
String assetShortDescription =
switch (hit.getAssetType()) {
case PROJECT -> ((Project) asset).getOverviewAsReadableString();
case MODEL -> ((Model) asset).getDescriptionAsReadableString();
default -> asset.getDescription();
};

// Only keep the first 100 characters of the description, followed by an ellipsis
if (assetShortDescription.length() > 100) {
assetShortDescription = assetShortDescription.substring(0, 100) + "...";
}

return new ProjectSearchResultAsset(
hit.getAssetId(),
hit.getAssetType(),
asset.getName(),
assetShortDescription,
asset.getCreatedOn(),
embeddingContent,
hit.getEmbeddingType(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,9 @@ public boolean isPetrinet() {
return this.getHeader().getSchemaName().equalsIgnoreCase("petrinet");
}

private String getDescriptionAsReadableString() {
@JsonIgnore
@TSIgnore
public String getDescriptionAsReadableString() {
if (getMetadata().getDescription() == null) {
return null;
}
Expand Down