-
Notifications
You must be signed in to change notification settings - Fork 21
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
Implement bulk import #1457
Merged
Merged
Implement bulk import #1457
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
400583b
Implement bulk import
jjnesbitt 8039311
Name jobs based on dataset ID, instead of name
jjnesbitt ada08c9
Fix test against pipeline run working directory name
jjnesbitt f7c6336
Wrap text for dataset name and import path
jjnesbitt 4d48397
Remove unnecessary eslint rule ignore
jjnesbitt 52e09dd
Display number of currently selected datasets in bulk import dialog
jjnesbitt c140013
Handle bulk import with no results
jjnesbitt 0d167ca
Fix sporatic failures in bulk import
jjnesbitt 40ac579
Split up import dialogs
jjnesbitt ca5e0bc
Prevent v-data-table overflow on smaller screen sizes
jjnesbitt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
193 changes: 193 additions & 0 deletions
193
client/platform/desktop/frontend/components/BulkImportDialog.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,193 @@ | ||
<script lang="ts"> | ||
import { | ||
defineComponent, ref, PropType, | ||
computed, | ||
} from 'vue'; | ||
import { DesktopMediaImportResponse } from 'platform/desktop/constants'; | ||
import { clone, cloneDeep } from 'lodash'; | ||
import ImportDialog from './ImportDialog.vue'; | ||
|
||
const headers = [ | ||
{ | ||
text: 'Dataset Name', | ||
align: 'start', | ||
sortable: false, | ||
value: 'name', | ||
}, | ||
{ | ||
text: 'Path', | ||
align: 'start', | ||
sortable: false, | ||
value: 'path', | ||
}, | ||
{ | ||
text: 'Dataset Type', | ||
align: 'start', | ||
sortable: false, | ||
value: 'jsonMeta.type', | ||
width: '150', | ||
}, | ||
{ | ||
text: 'Config', | ||
align: 'end', | ||
sortable: false, | ||
value: 'config', | ||
}, | ||
]; | ||
|
||
export default defineComponent({ | ||
name: 'BulkImportDialog', | ||
components: { | ||
ImportDialog, | ||
}, | ||
props: { | ||
importData: { | ||
type: Array as PropType<DesktopMediaImportResponse[]>, | ||
required: true, | ||
}, | ||
}, | ||
setup(props, ctx) { | ||
// Map imports to include generated "id" field, used in rendering. | ||
const imports = ref(props.importData.map((im) => { | ||
const cloned = cloneDeep(im); | ||
cloned.jsonMeta.id = (Math.random() + 1).toString(36).substring(2); | ||
|
||
return cloned; | ||
})); | ||
|
||
// The dataset import currently being configured | ||
const currentImport = ref<DesktopMediaImportResponse>(); | ||
|
||
// Selected state and selected imports maintain the ordering of `imports` | ||
const selectedState = ref(imports.value.map(() => true)); | ||
const selectedImports = computed(() => imports.value.filter((_, index) => selectedState.value[index])); | ||
function updateSelected(val: DesktopMediaImportResponse[]) { | ||
selectedState.value = imports.value.map((im) => val.includes(im)); | ||
} | ||
|
||
function stripId(item: DesktopMediaImportResponse) { | ||
const cloned = cloneDeep(item); | ||
cloned.jsonMeta.id = ''; | ||
return item; | ||
} | ||
|
||
function finalizeImport() { | ||
const finalImports = imports.value.filter((im) => selectedImports.value.includes(im)).map((im) => stripId(im)); | ||
ctx.emit('finalize-import', finalImports); | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
function updateImportConfig(oldItem: DesktopMediaImportResponse, newItem: DesktopMediaImportResponse) { | ||
const itemIndex = imports.value.indexOf(oldItem); | ||
|
||
// Need to modify the imports array ref to contain the new item | ||
const newArray = clone(imports.value); | ||
newArray.splice(itemIndex, 1, newItem); | ||
imports.value = newArray; | ||
|
||
currentImport.value = undefined; | ||
} | ||
|
||
function formatPath(item: DesktopMediaImportResponse) { | ||
let path = item.jsonMeta.originalBasePath; | ||
|
||
if (item.jsonMeta.originalVideoFile !== '') { | ||
path = `${path}/${item.jsonMeta.originalVideoFile}`; | ||
} | ||
|
||
return path; | ||
} | ||
|
||
return { | ||
updateSelected, | ||
updateImportConfig, | ||
formatPath, | ||
imports, | ||
headers, | ||
selectedImports, | ||
currentImport, | ||
finalizeImport, | ||
}; | ||
}, | ||
}); | ||
</script> | ||
|
||
<template> | ||
<v-card outlined class="import-card" style="overflow-x: hidden;"> | ||
<v-card-title class="text-h5"> | ||
Bulk Import (Selecting {{ selectedImports.length }} of {{ imports.length }}) | ||
</v-card-title> | ||
|
||
<v-dialog :value="currentImport !== undefined" width="800"> | ||
<ImportDialog | ||
v-if="currentImport !== undefined" | ||
:import-data="currentImport" | ||
:embedded="true" | ||
@abort="currentImport = undefined" | ||
@finalize-import="updateImportConfig(currentImport, $event)" | ||
/> | ||
</v-dialog> | ||
|
||
<v-data-table | ||
:value="selectedImports" | ||
:items="imports" | ||
item-key="jsonMeta.id" | ||
:headers="headers" | ||
show-select | ||
disable-sort | ||
@input="updateSelected" | ||
> | ||
<template #item.name="{ item }"> | ||
<div class="text-wrap" style="word-break: break-word;"> | ||
{{ item.jsonMeta.name }} | ||
</div> | ||
</template> | ||
|
||
<template #item.path="{ item }"> | ||
<div class="text-wrap" style="word-break: break-word;"> | ||
{{ formatPath(item) }} | ||
</div> | ||
</template> | ||
|
||
<template #item.config="{ item }"> | ||
<v-btn | ||
icon | ||
:disabled="!selectedImports.includes(item)" | ||
@click="currentImport = item" | ||
> | ||
<v-icon> | ||
mdi-cog | ||
</v-icon> | ||
</v-btn> | ||
</template> | ||
</v-data-table> | ||
|
||
<v-card-text> | ||
<div class="d-flex flex-row mt-4"> | ||
<v-spacer /> | ||
<v-btn | ||
text | ||
outlined | ||
class="mr-5" | ||
@click="$emit('abort')" | ||
> | ||
Cancel | ||
</v-btn> | ||
<v-btn | ||
color="primary" | ||
@click="finalizeImport" | ||
> | ||
Import Selected | ||
</v-btn> | ||
</div> | ||
</v-card-text> | ||
</v-card> | ||
</template> | ||
|
||
<style lang="scss"> | ||
@import 'dive-common/components/styles/KeyValueTable.scss'; | ||
|
||
.v-data-table__selected { | ||
background: unset !important; | ||
} | ||
</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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Believe you still need to set some sort of max width on the data table:
DIVE-Bulk-Issue.mp4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A specific
max-width
style wasn't necessary with the fix I implemented, but it still prevents overflow on all screen sizes (wraps text instead).