-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Footprints: custom regions import (#2377)
* fix error message formatting * WIP: generalize file import component and adopt in footprints plugin * put implementation in select component * when clicking cancel, revert to previous selection (not always default) * improve public API for selecting file * support loading region from file in footprints plugin * currently without any repositioning support (region is static) * update changelog entry * support importing from API * update tests/docs * fix support for multiple file/objects across multiple viewers * ensure region(s) are sky, not pixel * fix traceback for parsing regions when file dialog open * set min-width of plugin tray to 250px * already set to have a min-width of 25% the app-width, but for small screens/browsers, this will impose a pixel minimum to prevent UI over-crowding (and in this case, allow us to assume the hint in the "preset" dropdown will remain on a single line). * support for non-polygon region objects Co-authored-by: P. L. Lim <[email protected]> * reset internal cache when API/file input is changed * allow file/object import without pysiaf * instead of disabling the plugin, options are removed from the preset dropdown and a warning is shown. * to avoid "From File..." from being the default, a "None" entry is added if pysiaf is not installed * this may largely be reverted in the future Co-authored-by: P. L. Lim <[email protected]> * Apply suggestions from code review Co-authored-by: P. L. Lim <[email protected]> * fix importing region before ever opening plugin --------- Co-authored-by: P. L. Lim <[email protected]>
- Loading branch information
Showing
14 changed files
with
539 additions
and
257 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
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,71 @@ | ||
<template> | ||
<div> | ||
<v-row> | ||
<v-select | ||
:menu-props="{ left: true }" | ||
attach | ||
:items="items.map(i => i.label)" | ||
v-model="selected" | ||
@change="$emit('update:selected', $event)" | ||
:label="label" | ||
:hint="hint" | ||
persistent-hint | ||
></v-select> | ||
<v-chip v-if="selected === 'From File...'" | ||
close | ||
close-icon="mdi-close" | ||
label | ||
@click:close="() => {this.$emit('click-cancel')}" | ||
style="margin-top: -50px; width: 100%" | ||
> | ||
<!-- @click:close resets from_file and relies on the @observe in python to reset preset | ||
to its default, but the traitlet change wouldn't be fired if from_file is already | ||
empty (which should only happen if setting from the API but not setting from_file) --> | ||
<span style="overflow-x: hidden; whitespace: nowrap; text-overflow: ellipsis; width: 100%"> | ||
{{from_file.split("/").slice(-1)[0]}} | ||
</span> | ||
</v-chip> | ||
</v-row> | ||
<v-dialog :value="selected === 'From File...' && from_file.length == 0" height="400" width="600"> | ||
<v-card> | ||
<v-card-title class="headline" color="primary" primary-title>{{ dialog_title || "Import File" }}</v-card-title> | ||
<v-card-text> | ||
{{ dialog_hint }} | ||
<v-container> | ||
<v-row> | ||
<v-col> | ||
<slot></slot> | ||
</v-col> | ||
</v-row> | ||
<v-row v-if="from_file_message.length > 0" :style='"color: red"'> | ||
{{from_file_message}} | ||
</v-row> | ||
<v-row v-else> | ||
Valid file | ||
</v-row> | ||
</v-container> | ||
</v-card-text> | ||
|
||
<v-card-actions> | ||
<div class="flex-grow-1"></div> | ||
<v-btn color="primary" text @click="$emit('click-cancel')">Cancel</v-btn> | ||
<v-btn color="primary" text @click="$emit('click-import')" :disabled="from_file_message.length > 0">Load</v-btn> | ||
</v-card-actions> | ||
|
||
</v-card> | ||
</v-dialog> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
module.exports = { | ||
props: ['items', 'selected', 'label', 'hint', 'rules', 'from_file', 'from_file_message', | ||
'dialog_title', 'dialog_hint'] | ||
}; | ||
</script> | ||
|
||
<style> | ||
.v-chip__content { | ||
width: 100% | ||
} | ||
</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
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,92 +1,45 @@ | ||
<template> | ||
<j-tray-plugin | ||
<j-tray-plugin | ||
description='Queries an area encompassed by the viewer using a specified catalog and marks all the objects found within the area.' | ||
:link="'https://jdaviz.readthedocs.io/en/'+vdocs+'/'+config+'/plugins.html#catalog-search'" | ||
:popout_button="popout_button"> | ||
|
||
<plugin-viewer-select | ||
<plugin-viewer-select | ||
:items="viewer_items" | ||
:selected.sync="viewer_selected" | ||
label="Viewer" | ||
:show_if_single_entry="false" | ||
hint="Select a viewer to search." | ||
/> | ||
|
||
<v-row> | ||
|
||
<v-select | ||
:menu-props="{ left: true }" | ||
attach | ||
:items="catalog_items.map(i => i.label)" | ||
v-model="catalog_selected" | ||
label="Catalog" | ||
hint="Select a catalog to search with." | ||
persistent-hint | ||
></v-select> | ||
<v-chip v-if="catalog_selected === 'From File...'" | ||
close | ||
close-icon="mdi-close" | ||
label | ||
@click:close="() => {if (from_file.length) {from_file = ''} else {catalog_selected = catalog_items[0].label}}" | ||
style="margin-top: -50px; width: 100%" | ||
> | ||
<!-- @click:close resets from_file and relies on the @observe in python to reset catalog | ||
to its default, but the traitlet change wouldn't be fired if from_file is already | ||
empty (which should only happen if setting from the API but not setting from_file) --> | ||
<span style="overflow-x: hidden; whitespace: nowrap; text-overflow: ellipsis; width: 100%"> | ||
{{from_file.split("/").slice(-1)[0]}} | ||
</span> | ||
</v-chip> | ||
</v-row> | ||
|
||
<v-dialog :value="catalog_selected === 'From File...' && from_file.length === 0" height="400" width="600"> | ||
<v-card> | ||
<v-card-title class="headline" color="primary" primary-title>Load Catalog</v-card-title> | ||
<v-card-text> | ||
Select a file containing a catalog. | ||
<v-container> | ||
<v-row> | ||
<v-col> | ||
<g-file-import id="file-uploader"></g-file-import> | ||
</v-col> | ||
</v-row> | ||
<v-row v-if="from_file_message.length > 0" :style='"color: red"'> | ||
{{from_file_message}} | ||
</v-row> | ||
<v-row v-else> | ||
Valid catalog file | ||
</v-row> | ||
</v-container> | ||
</v-card-text> | ||
|
||
<v-card-actions> | ||
<div class="flex-grow-1"></div> | ||
<v-btn color="primary" text @click="catalog_selected = catalog_items[0].label">Cancel</v-btn> | ||
<v-btn color="primary" text @click="set_file_from_dialog" :disabled="from_file_message.length > 0">Load</v-btn> | ||
</v-card-actions> | ||
|
||
</v-card> | ||
</v-dialog> | ||
|
||
<v-row class="row-no-outside-padding"> | ||
/> | ||
|
||
<plugin-file-import-select | ||
:items="catalog_items" | ||
:selected.sync="catalog_selected" | ||
label="Catalog" | ||
hint="Select a catalog to search." | ||
:from_file.sync="from_file" | ||
:from_file_message="from_file_message" | ||
dialog_title="Import Catalog" | ||
dialog_hint="Select a file containing a catalog" | ||
@click-cancel="file_import_cancel()" | ||
@click-import="file_import_accept()" | ||
> | ||
<g-file-import id="file-uploader"></g-file-import> | ||
</plugin-file-import-select> | ||
|
||
<v-row class="row-no-outside-padding"> | ||
<v-col> | ||
<v-btn color="primary" text @click="do_clear">Clear</v-btn> | ||
</v-col> | ||
<v-col> | ||
<v-btn color="primary" text @click="do_search">Search</v-btn> | ||
</v-col> | ||
</v-row> | ||
</v-row> | ||
|
||
<v-row> | ||
<v-row> | ||
<p class="font-weight-bold">Results:</p> | ||
<span style='padding-left: 4px' v-if="results_available">{{number_of_results}}</span> | ||
<v-row> | ||
<v-row> | ||
|
||
</j-tray-plugin> | ||
</template> | ||
|
||
<style scoped> | ||
.v-chip__content { | ||
width: 100% | ||
} | ||
</style> | ||
</j-tray-plugin> | ||
</template> |
Oops, something went wrong.