-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(frontend): add panel to browse experiment history
This commit adds the ability for user to browse Experiment history in the view/edit form. Clicking the toggle will bring out the right drawer containing the list of snapshots. Selecting a row loads the values into the form. Up/down keyboard navigation works once focus is on the table. The table can be sorted. The Queue dialog was also updated to use this SnapshotList component.
- Loading branch information
1 parent
dbd1f3e
commit 693317a
Showing
11 changed files
with
350 additions
and
198 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
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
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,106 @@ | ||
<template> | ||
<TableComponent | ||
:rows="snapshots" | ||
:columns="columns" | ||
v-model:selected="selected" | ||
:title="props.maxHeight ? '' : 'Snapshots'" | ||
:hideCreateBtn="true" | ||
:hideDeleteBtn="true" | ||
:hideEditBtn="true" | ||
:hideSearch="true" | ||
:disableRadio="true" | ||
rowKey="snapshot" | ||
:showAll="true" | ||
:style="{ | ||
marginTop: '0', | ||
maxHeight: props.maxHeight ? props.maxHeight + 'px' : '', | ||
height: props.maxHeight ? '' : 'calc(100vh - 50px)' | ||
}" | ||
> | ||
<template #body-cell-timestamp="props"> | ||
{{ | ||
new Intl.DateTimeFormat('en-US', { | ||
year: '2-digit', | ||
month: '2-digit', | ||
day: '2-digit', | ||
hour: 'numeric', | ||
minute: 'numeric', | ||
hour12: true | ||
}).format(new Date(props.row.snapshotCreatedOn)) | ||
}} | ||
<q-chip | ||
v-if="props.row.latestSnapshot" | ||
label="latest" | ||
size="md" | ||
dense | ||
color="orange" | ||
text-color="white" | ||
/> | ||
</template> | ||
</TableComponent> | ||
</template> | ||
|
||
<script setup> | ||
import { useLoginStore } from '@/stores/LoginStore' | ||
import { useRoute } from 'vue-router' | ||
import TableComponent from '@/components/TableComponent.vue' | ||
import { ref, watch } from 'vue' | ||
import * as api from '@/services/dataApi' | ||
const props = defineProps(['showDialogHistory', 'type', 'id', 'maxHeight']) | ||
const store = useLoginStore() | ||
const route = useRoute() | ||
const snapshots = ref([]) | ||
const selected = ref([]) | ||
async function getSnapshots() { | ||
try { | ||
const res = await api.getSnapshots(route.meta.type, route.params.id) | ||
snapshots.value = res.data.data.reverse() | ||
console.log('snapshots = ', snapshots.value) | ||
} catch(err) { | ||
console.warn(err) | ||
} | ||
} | ||
async function getDialogSnapshots() { | ||
try { | ||
const res = await api.getSnapshots(props.type, props.id) | ||
snapshots.value = res.data.data.reverse() | ||
console.log('snapshots = ', snapshots.value) | ||
} catch(err) { | ||
console.warn(err) | ||
} | ||
} | ||
watch(() => store.showRightDrawer, (history) => { | ||
if(history) { | ||
getSnapshots() | ||
} else { | ||
store.selectedSnapshot = null | ||
} | ||
}) | ||
watch(() => props.showDialogHistory, (history) => { | ||
if(history) { | ||
getDialogSnapshots() | ||
} else { | ||
store.selectedSnapshot = null | ||
} | ||
}) | ||
watch(selected, (newVal) => { | ||
if(newVal.length > 0) { | ||
store.selectedSnapshot = newVal[0] | ||
} | ||
}) | ||
const columns = [ | ||
{ name: 'timestamp', label: 'Created On', align: 'left', field: 'snapshotCreatedOn', sortable: true, }, | ||
] | ||
</script> |
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
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
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.