Skip to content
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

Allow configuring which metadata can be added to items #1202

Merged
merged 5 commits into from
Jun 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Added an internal field to report populated tile levels in some sources ([#1197](../../pull/1197), [#1199](../../pull/1199))
- Allow specifying an empty style dict ([#1200](../../pull/1200))
- Allow rounding histogram bin edges and reducing bin counts ([#1201](../../pull/1201))
- Allow configuring which metadata can be added to items ([#1202](../../pull/1202))

### Changes
- Change how extensions and fallback priorities interact ([#1192](../../pull/1192))
Expand Down
43 changes: 43 additions & 0 deletions docs/girder_config_options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ The yaml file has the following structure:
.large_image_config.yaml
~~~~~~~~~~~~~~~~~~~~~~~~

Items Lists
...........

This is used to specify how items appear in item lists. There are two settings, one for folders in the main Girder UI and one for folders in dialogs (such as when browsing in the file dialog).

::
Expand Down Expand Up @@ -128,6 +131,46 @@ This is used to specify how items appear in item lists. There are two settings,

If there are no large images in a folder, none of the image columns will appear.

Item Metadata
.............

By default, item metadata can contain any keys and values. These can be given better titles and restricted in their data types.

::

---
# If present, offer to add these specific keys and restrict their datatypes
itemMetadata:
-
# value is the key name within the metadata
value: stain
# title is the displayed titles
title: Stain
# description is used as both a tooltip and as placeholder text
description: Staining method
# if required is true, the delete button does not appear
required: true
# If a regex is specified, the value must match
# regex: '^(Eosin|H&E|Other)$'
# If an enum is specified, the value is set via a dropdown select box
enum:
- Eosin
- H&E
- Other
# If a default is specified, when the value is created, it will show
# this value in the control
default: H&E
-
value: rating
# type can be "number", "integer", or "text" (default)
type: number
# minimum and maximum are inclusive
minimum: 0
maximum: 10
# Exclusive values can be specified instead
# exclusiveMinimum: 0
# exclusiveMaximum: 10

Editing Configuration Files
---------------------------

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.g-widget-metadata-key-edit
font-weight bold

.g-widget-metadata-row.editing .g-widget-metadata-value-input.g-widget-metadata-lientry
height inherit
22 changes: 22 additions & 0 deletions girder/girder_large_image/web_client/templates/metadataWidget.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
if (accessLevel >= AccessType.WRITE)
.btn-group.pull-right
button.g-widget-metadata-add-button.btn.btn-sm.btn-primary.btn-default.dropdown-toggle(data-toggle="dropdown", title="Add Metadata")
i.icon-plus
ul.dropdown-menu.pull-right(role="menu")
if limetadata
for entry in limetadata
if entry && entry.value
li.li-metadata-menuitem(role="presentation")
a.li-add-metadata(metadata-key=entry.value)
= entry.title || entry.value
li(role="presentation")
a.g-add-simple-metadata(role="menuitem")
| Simple
li(role="presentation")
a.g-add-json-metadata
| JSON

.g-widget-metadata-header
i.icon-tags
| #{title}
.g-widget-metadata-container
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
if !lientry
input.input-sm.form-control.g-widget-metadata-key-input(type="text", value=key, placeholder="Key")
else
span.g-widget-metadata-key-edit.g-widget-metadata-key-input(key=key)
= lientry.title || key

if !lientry
- var rows = value.length <= 40 ? 1 : (value.length <= 100 ? 3 : 5)
textarea.input-sm.form-control.g-widget-metadata-value-input(placeholder="Value", rows=rows)
= value
else
if lientry.enum
select.input-sm.form-control.g-widget-metadata-value-input.g-widget-metadata-lientry(title=lientry.description)
for enumval in lientry.enum
option(value=enumval, selected=enumval === value ? 'selected' : null)
= enumval
else
input.input-sm.form-control.g-widget-metadata-value-input.g-widget-metadata-lientry(placeholder=lientry.description || "Value", value=value, title=lientry.description)

button.btn.btn-sm.btn-warning.g-widget-metadata-cancel-button(title="Cancel")
i.icon-cancel
button.btn.btn-sm.btn-primary.g-widget-metadata-save-button(title="Accept")
i.icon-ok
if !newDatum
if !lientry
button.btn.btn-sm.btn-primary.g-widget-metadata-toggle-button(title="Convert to JSON")
i.icon-cog
if !lientry || !lientry.required
button.btn.btn-sm.btn-danger.g-widget-metadata-delete-button(title="Delete")
i.icon-trash
8 changes: 4 additions & 4 deletions girder/girder_large_image/web_client/views/configView.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,15 +247,15 @@ var ConfigView = View.extend({
}
if (ConfigView._lastliconfig === folderId && !reload) {
if (callback) {
callback(ConfigView._liconfig);
callback(ConfigView._liconfig || {});
}
return $.Deferred().resolve(ConfigView._liconfig);
}
if (ConfigView._liconfigSettingsRequest) {
if (ConfigView._nextliconfig === folderId) {
if (callback) {
ConfigView._liconfigSettingsRequest.done(() => {
callback(ConfigView._liconfig);
ConfigView._liconfigSettingsRequest.done((val) => {
callback(val || {});
});
}
return ConfigView._liconfigSettingsRequest;
Expand All @@ -269,7 +269,7 @@ var ConfigView = View.extend({
val = val || {};
ConfigView._lastliconfig = folderId;
ConfigView._liconfigSettingsRequest = null;
ConfigView._liconfig = val || {};
ConfigView._liconfig = val;
if (callback) {
callback(ConfigView._liconfig);
}
Expand Down
4 changes: 3 additions & 1 deletion girder/girder_large_image/web_client/views/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import ConfigView from './configView';
import ImageViewerSelectWidget from './imageViewerSelectWidget';
import * as imageViewerWidget from './imageViewerWidget';
import ItemViewWidget from './itemViewWidget';
import * as MetadataWidget from './metadataWidget';

export {
ConfigView,
ImageViewerSelectWidget,
imageViewerWidget,
ItemViewWidget
ItemViewWidget,
MetadataWidget
};
Loading