-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17105 from jmchilton/tool_link
Expose more tool information / navigability in UI.
- Loading branch information
Showing
17 changed files
with
510 additions
and
77 deletions.
There are no files selected for viewing
126 changes: 126 additions & 0 deletions
126
client/src/components/Markdown/Elements/HistoryDatasetAsTable.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,126 @@ | ||
<script setup lang="ts"> | ||
import { computed } from "vue"; | ||
import { UrlDataProvider } from "@/components/providers/UrlDataProvider.js"; | ||
import LoadingSpan from "@/components/LoadingSpan.vue"; | ||
interface HistoryDatasetAsTableProps { | ||
historyDatasetId: string; | ||
compact: boolean; | ||
showColumnHeaders: boolean; | ||
title?: string; | ||
footer?: string; | ||
} | ||
const props = withDefaults(defineProps<HistoryDatasetAsTableProps>(), { | ||
compact: false, | ||
showColumnHeaders: true, | ||
title: undefined, | ||
footer: undefined, | ||
}); | ||
const itemUrl = computed(() => { | ||
return `/api/datasets/${props.historyDatasetId}/get_content_as_text`; | ||
}); | ||
const metaUrl = computed(() => { | ||
return `/api/datasets/${props.historyDatasetId}`; | ||
}); | ||
const expanded = false; | ||
const contentClass = computed(() => { | ||
if (expanded) { | ||
return "embedded-dataset-expanded"; | ||
} else { | ||
return "embedded-dataset"; | ||
} | ||
}); | ||
function getFields(metaData: any) { | ||
const fields = []; | ||
const columnNames = metaData.metadata_column_names || []; | ||
const columnCount = metaData.metadata_columns; | ||
for (let i = 0; i < columnCount; i++) { | ||
fields.push({ | ||
key: `${i}`, | ||
label: columnNames[i] || i, | ||
sortable: true, | ||
}); | ||
} | ||
return fields; | ||
} | ||
function getItems(textData: any, metaData: any) { | ||
const tableData: object[] = []; | ||
const delimiter: string = metaData.metadata_delimiter || "\t"; | ||
const comments: number = metaData.metadata_comment_lines || 0; | ||
const lines = textData.split("\n"); | ||
lines.forEach((line: string, i: number) => { | ||
if (i >= comments) { | ||
const tabs = line.split(delimiter); | ||
const rowData: string[] = []; | ||
let hasData = false; | ||
tabs.forEach((cellData: string, j: number) => { | ||
const cellDataTrimmed = cellData.trim(); | ||
if (cellDataTrimmed) { | ||
hasData = true; | ||
} | ||
rowData[j] = cellDataTrimmed; | ||
}); | ||
if (hasData) { | ||
tableData.push(rowData); | ||
} | ||
} | ||
}); | ||
return tableData; | ||
} | ||
</script> | ||
|
||
<template> | ||
<b-card :no-body="props.compact"> | ||
<b-card-title v-if="title"> | ||
<b>{{ title }}</b> | ||
</b-card-title> | ||
<UrlDataProvider v-slot="{ result: itemContent, loading, error }" :url="itemUrl"> | ||
<LoadingSpan v-if="loading" message="Loading Dataset" /> | ||
<div v-else-if="error">{{ error }}</div> | ||
<div v-else :class="contentClass"> | ||
<div v-if="itemContent.item_data"> | ||
<div> | ||
<UrlDataProvider | ||
v-slot="{ result: metaData, loading: metaLoading, error: metaError }" | ||
:url="metaUrl"> | ||
<LoadingSpan v-if="metaLoading" message="Loading Metadata" /> | ||
<div v-else-if="metaError">{{ metaError }}</div> | ||
<b-table | ||
v-else | ||
:thead-class="props.showColumnHeaders ? '' : 'd-none'" | ||
striped | ||
hover | ||
:fields="getFields(metaData)" | ||
:items="getItems(itemContent.item_data, metaData)" /> | ||
</UrlDataProvider> | ||
</div> | ||
</div> | ||
<div v-else>No content found.</div> | ||
<b-link v-if="itemContent.truncated" :href="itemContent.item_url"> Show More... </b-link> | ||
</div> | ||
</UrlDataProvider> | ||
<b-card-footer v-if="footer"> | ||
{{ footer }} | ||
</b-card-footer> | ||
</b-card> | ||
</template> | ||
|
||
<style scoped> | ||
.embedded-dataset { | ||
max-height: 20rem; | ||
overflow-y: auto; | ||
} | ||
.embedded-dataset-expanded { | ||
max-height: 40rem; | ||
overflow-y: auto; | ||
} | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,55 @@ | ||
<script setup lang="ts"> | ||
import { computed, watch } from "vue"; | ||
import { useJobStore } from "@/stores/jobStore"; | ||
import JobMetrics from "@/components/JobMetrics/JobMetrics.vue"; | ||
import ToolLinkPopover from "@/components/Tool/ToolLinkPopover.vue"; | ||
interface JobMetricsProps { | ||
jobId: string; | ||
title?: string; | ||
footer?: string; | ||
} | ||
const props = withDefaults(defineProps<JobMetricsProps>(), { | ||
title: undefined, | ||
footer: undefined, | ||
}); | ||
const jobStore = useJobStore(); | ||
const toolId = computed(() => { | ||
return jobStore.getJob(props.jobId)?.tool_id; | ||
}); | ||
const toolVersion = computed(() => { | ||
return jobStore.getJob(props.jobId)?.tool_version; | ||
}); | ||
watch( | ||
props, | ||
() => { | ||
jobStore.fetchJob(props.jobId); | ||
}, | ||
{ immediate: true } | ||
); | ||
</script> | ||
|
||
<template> | ||
<b-card nobody> | ||
<b-card-title v-if="title"> | ||
<b>{{ title }}</b> | ||
<icon ref="info" icon="info-circle" size="sm" /> | ||
<ToolLinkPopover :target="() => $refs.info" :tool-id="toolId" :tool-version="toolVersion" /> | ||
</b-card-title> | ||
<JobMetrics | ||
class="job-metrics" | ||
:job-id="args.job_id" | ||
:job-id="jobId" | ||
:should-show-aws-estimate="false" | ||
:should-show-carbon-emissions-estimates="false" | ||
:include-title="false" /> | ||
<b-card-footer v-if="footer"> | ||
{{ footer }} | ||
</b-card-footer> | ||
</b-card> | ||
</template> | ||
|
||
<script> | ||
import JobMetrics from "components/JobMetrics/JobMetrics"; | ||
export default { | ||
components: { | ||
JobMetrics, | ||
}, | ||
props: { | ||
args: { | ||
type: Object, | ||
default: null, | ||
}, | ||
}, | ||
}; | ||
</script> |
65 changes: 48 additions & 17 deletions
65
client/src/components/Markdown/Elements/JobParameters.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 |
---|---|---|
@@ -1,21 +1,52 @@ | ||
<template> | ||
<b-card nobody> | ||
<JobParameters class="job-parameters" :job-id="args.job_id" :param="args.param" :include-title="false" /> | ||
</b-card> | ||
</template> | ||
<script setup lang="ts"> | ||
import { computed, watch } from "vue"; | ||
<script> | ||
import JobParameters from "components/JobParameters/JobParameters"; | ||
import { useJobStore } from "@/stores/jobStore"; | ||
export default { | ||
components: { | ||
JobParameters, | ||
}, | ||
props: { | ||
args: { | ||
type: Object, | ||
default: null, | ||
}, | ||
import JobParameters from "@/components/JobParameters/JobParameters.vue"; | ||
import ToolLinkPopover from "@/components/Tool/ToolLinkPopover.vue"; | ||
interface JobParametersProps { | ||
jobId: string; | ||
param?: string; | ||
title?: string; | ||
footer?: string; | ||
} | ||
const props = withDefaults(defineProps<JobParametersProps>(), { | ||
param: undefined, | ||
title: undefined, | ||
footer: undefined, | ||
}); | ||
const jobStore = useJobStore(); | ||
const toolId = computed(() => { | ||
return jobStore.getJob(props.jobId)?.tool_id; | ||
}); | ||
const toolVersion = computed(() => { | ||
return jobStore.getJob(props.jobId)?.tool_version; | ||
}); | ||
watch( | ||
props, | ||
() => { | ||
jobStore.fetchJob(props.jobId); | ||
}, | ||
}; | ||
{ immediate: true } | ||
); | ||
</script> | ||
|
||
<template> | ||
<b-card nobody> | ||
<b-card-title v-if="title"> | ||
<b>{{ title }}</b> | ||
<icon ref="info" icon="info-circle" size="sm" /> | ||
<ToolLinkPopover :target="() => $refs.info" :tool-id="toolId" :tool-version="toolVersion" /> | ||
</b-card-title> | ||
<JobParameters class="job-parameters" :job-id="jobId" :param="param" :include-title="false" /> | ||
<b-card-footer v-if="footer"> | ||
{{ footer }} | ||
</b-card-footer> | ||
</b-card> | ||
</template> |
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.