-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
418 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
162 changes: 162 additions & 0 deletions
162
packages/client/hmi-client/src/components/home/tera-project-table.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
<template> | ||
<DataTable | ||
:value="projects" | ||
dataKey="id" | ||
:rowsPerPageOptions="[10, 20, 50]" | ||
scrollable | ||
scrollHeight="45rem" | ||
> | ||
<Column | ||
v-for="(col, index) in selectedColumns" | ||
:field="col.field" | ||
:header="col.header" | ||
:sortable="col.field !== 'stats'" | ||
:key="index" | ||
:style="`width: ${getColumnWidth(col.field)}%`" | ||
> | ||
<template v-if="col.field !== 'username'" #body="{ data }"> | ||
<a | ||
v-if="col.field === 'name'" | ||
class="project-title-link" | ||
@click.stop="emit('open-project', data.id)" | ||
> | ||
{{ data.name }} | ||
</a> | ||
<tera-show-more-text | ||
v-else-if="col.field === 'description'" | ||
:text="data.description" | ||
:lines="1" | ||
/> | ||
<div v-else-if="col.field === 'stats'" class="stats"> | ||
<span><i class="pi pi-user" />1</span> | ||
<span><i class="pi pi-file" /> {{ data.metadata?.['publications-count'] }}</span> | ||
<span> | ||
<dataset-icon fill="var(--text-color-secondary)" /> | ||
{{ data.metadata?.['datasets-count'] }} | ||
</span> | ||
<span><i class="pi pi-share-alt" /> {{ data.metadata?.['models-count'] }}</span> | ||
</div> | ||
<!--FIXME: There is no 'last updated' property in project yet--> | ||
<template v-else-if="col.field === 'timestamp'"> | ||
{{ formatDdMmmYyyy(data.timestamp) }} | ||
</template> | ||
</template> | ||
</Column> | ||
<Column style="width: 0"> | ||
<template #body="{ data }"> | ||
<Button | ||
icon="pi pi-ellipsis-v" | ||
class="project-options p-button-icon-only p-button-text p-button-rounded" | ||
@click.stop="(event) => showProjectMenu(event, data)" | ||
/> | ||
<Menu ref="projectMenu" :model="projectMenuItems" :popup="true" /> | ||
</template> | ||
</Column> | ||
</DataTable> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ref } from 'vue'; | ||
import DataTable from 'primevue/datatable'; | ||
import Column from 'primevue/column'; | ||
import TeraShowMoreText from '@/components/widgets/tera-show-more-text.vue'; | ||
import { formatDdMmmYyyy } from '@/utils/date'; | ||
import DatasetIcon from '@/assets/svg/icons/dataset.svg?component'; | ||
import Menu from 'primevue/menu'; | ||
import { Project } from '@/types/Types'; | ||
import Button from 'primevue/button'; | ||
defineProps<{ | ||
projects: Project[]; | ||
projectMenuItems?: any[]; | ||
selectedColumns: { field: string; header: string }[]; | ||
}>(); | ||
const emit = defineEmits(['open-project', 'update-chosen-project-menu']); | ||
const projectMenu = ref(); | ||
const showProjectMenu = (event, project: Project) => { | ||
projectMenu.value.toggle(event); | ||
emit('update-chosen-project-menu', project); | ||
}; | ||
function getColumnWidth(columnField: string) { | ||
switch (columnField) { | ||
case 'description': | ||
return 60; | ||
case 'name': | ||
return 20; | ||
default: | ||
return 5; | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
.stats { | ||
display: flex; | ||
width: fit-content; | ||
gap: 0.5rem; | ||
font-size: var(--font-caption); | ||
vertical-align: bottom; | ||
} | ||
.stats span { | ||
display: flex; | ||
gap: 0.1rem; | ||
align-items: center; | ||
width: 2rem; | ||
} | ||
.p-datatable { | ||
border: 1px solid var(--surface-border-light); | ||
border-radius: var(--border-radius); | ||
} | ||
.p-datatable:deep(.p-datatable-tbody > tr > td), | ||
.p-datatable:deep(.p-datatable-thead > tr > th) { | ||
white-space: nowrap; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
vertical-align: top; | ||
} | ||
.p-datatable:deep(.p-datatable-thead > tr > th) { | ||
padding: 1rem 0.5rem; | ||
background-color: var(--surface-ground); | ||
} | ||
.p-datatable:deep(.p-datatable-tbody > tr:not(.p-highlight):focus) { | ||
background-color: transparent; | ||
} | ||
.p-datatable:deep(.p-datatable-tbody > tr > td) { | ||
color: var(--text-color-secondary); | ||
padding: 0.5rem; | ||
max-width: 32rem; | ||
} | ||
.p-datatable:deep(.p-datatable-tbody > tr > td:not(:last-child)) { | ||
padding-top: 1rem; | ||
} | ||
.p-datatable:deep(.p-datatable-tbody > tr .project-options) { | ||
visibility: hidden; | ||
float: right; | ||
} | ||
.p-datatable:deep(.p-datatable-tbody > tr:hover .project-options) { | ||
visibility: visible; | ||
} | ||
.p-datatable:deep(.p-datatable-tbody > tr > td > a) { | ||
color: var(--text-color-primary); | ||
font-weight: var(--font-weight-semibold); | ||
cursor: pointer; | ||
} | ||
.p-datatable:deep(.p-datatable-tbody > tr > td > a:hover) { | ||
color: var(--primary-color); | ||
text-decoration: underline; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.