@girder/core 3.2.7 → 5.0.0-a6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -0
- package/package.json +79 -31
- package/assets/Girder_Mark.png +0 -0
- package/auth.js +0 -152
- package/collections/ApiKeyCollection.js +0 -9
- package/collections/AssetstoreCollection.js +0 -9
- package/collections/Collection.js +0 -295
- package/collections/CollectionCollection.js +0 -9
- package/collections/FileCollection.js +0 -11
- package/collections/FolderCollection.js +0 -11
- package/collections/GroupCollection.js +0 -9
- package/collections/ItemCollection.js +0 -11
- package/collections/UserCollection.js +0 -24
- package/collections/index.js +0 -21
- package/constants.js +0 -33
- package/dialog.js +0 -128
- package/events.js +0 -6
- package/index.js +0 -31
- package/main.js +0 -21
- package/misc.js +0 -260
- package/models/AccessControlledModel.js +0 -76
- package/models/ApiKeyModel.js +0 -31
- package/models/AssetstoreModel.js +0 -43
- package/models/CollectionCreationPolicyModel.js +0 -20
- package/models/CollectionModel.js +0 -12
- package/models/FileModel.js +0 -310
- package/models/FolderModel.js +0 -33
- package/models/GroupModel.js +0 -197
- package/models/ItemModel.js +0 -72
- package/models/MetadataMixin.js +0 -88
- package/models/Model.js +0 -187
- package/models/UserModel.js +0 -189
- package/models/index.js +0 -25
- package/pluginUtils.js +0 -11
- package/rest.js +0 -216
- package/router.js +0 -58
- package/routes.js +0 -231
- package/stylesheets/apidocs/apidocs.styl +0 -50
- package/stylesheets/body/adminConsole.styl +0 -21
- package/stylesheets/body/assetstores.styl +0 -46
- package/stylesheets/body/collectionList.styl +0 -39
- package/stylesheets/body/collectionPage.styl +0 -6
- package/stylesheets/body/frontPage.styl +0 -48
- package/stylesheets/body/groupList.styl +0 -43
- package/stylesheets/body/groupPage.styl +0 -116
- package/stylesheets/body/itemPage.styl +0 -81
- package/stylesheets/body/plugins.styl +0 -61
- package/stylesheets/body/searchResultsList.styl +0 -51
- package/stylesheets/body/systemConfig.styl +0 -56
- package/stylesheets/body/userAccount.styl +0 -57
- package/stylesheets/body/userList.styl +0 -79
- package/stylesheets/body/userPage.styl +0 -6
- package/stylesheets/layout/footer.styl +0 -19
- package/stylesheets/layout/global.styl +0 -154
- package/stylesheets/layout/globalNav.styl +0 -89
- package/stylesheets/layout/header.styl +0 -29
- package/stylesheets/layout/headerUser.styl +0 -33
- package/stylesheets/layout/layout.styl +0 -75
- package/stylesheets/layout/layoutVars.styl +0 -9
- package/stylesheets/layout/loading.styl +0 -37
- package/stylesheets/layout/progressArea.styl +0 -17
- package/stylesheets/widgets/accessWidget.styl +0 -106
- package/stylesheets/widgets/browserWidget.styl +0 -9
- package/stylesheets/widgets/hierarchyWidget.styl +0 -188
- package/stylesheets/widgets/markdownWidget.styl +0 -92
- package/stylesheets/widgets/metadataWidget.styl +0 -92
- package/stylesheets/widgets/searchFieldWidget.styl +0 -70
- package/stylesheets/widgets/taskProgress.styl +0 -41
- package/stylesheets/widgets/timelineWidget.styl +0 -41
- package/stylesheets/widgets/uploadWidget.styl +0 -43
- package/stylesheets/widgets/userOtpManagementWidget.styl +0 -159
- package/templates/body/adminConsole.pug +0 -13
- package/templates/body/assetstores.pug +0 -98
- package/templates/body/collectionList.pug +0 -40
- package/templates/body/collectionPage.pug +0 -36
- package/templates/body/filesystemImport.pug +0 -41
- package/templates/body/frontPage.pug +0 -83
- package/templates/body/groupList.pug +0 -30
- package/templates/body/groupPage.pug +0 -116
- package/templates/body/itemPage.pug +0 -61
- package/templates/body/plugins.pug +0 -20
- package/templates/body/s3Import.pug +0 -35
- package/templates/body/searchResults.pug +0 -15
- package/templates/body/searchResultsType.pug +0 -13
- package/templates/body/systemConfiguration.pug +0 -221
- package/templates/body/userAccount.pug +0 -83
- package/templates/body/userList.pug +0 -43
- package/templates/body/userPage.pug +0 -40
- package/templates/layout/alert.pug +0 -5
- package/templates/layout/layout.pug +0 -12
- package/templates/layout/layoutFooter.pug +0 -11
- package/templates/layout/layoutGlobalNav.pug +0 -7
- package/templates/layout/layoutHeader.pug +0 -8
- package/templates/layout/layoutHeaderUser.pug +0 -26
- package/templates/layout/layoutProgressArea.pug +0 -1
- package/templates/layout/loginDialog.pug +0 -30
- package/templates/layout/registerDialog.pug +0 -35
- package/templates/layout/resetPasswordDialog.pug +0 -25
- package/templates/widgets/accessEditor.pug +0 -23
- package/templates/widgets/accessEditorMixins.pug +0 -57
- package/templates/widgets/accessEditorNonModal.pug +0 -11
- package/templates/widgets/accessEntry.pug +0 -32
- package/templates/widgets/apiKeyList.pug +0 -50
- package/templates/widgets/browserWidget.pug +0 -32
- package/templates/widgets/checkedActionsMenu.pug +0 -46
- package/templates/widgets/collectionInfoDialog.pug +0 -37
- package/templates/widgets/confirmDialog.pug +0 -14
- package/templates/widgets/dateTimeRangeWidget.pug +0 -20
- package/templates/widgets/dateTimeWidget.pug +0 -8
- package/templates/widgets/editApiKeyWidget.pug +0 -43
- package/templates/widgets/editAssetstoreWidget.pug +0 -78
- package/templates/widgets/editCollectionWidget.pug +0 -27
- package/templates/widgets/editFileWidget.pug +0 -21
- package/templates/widgets/editFolderWidget.pug +0 -27
- package/templates/widgets/editGroupWidget.pug +0 -54
- package/templates/widgets/editItemWidget.pug +0 -27
- package/templates/widgets/fileInfoDialog.pug +0 -33
- package/templates/widgets/fileList.pug +0 -33
- package/templates/widgets/folderInfoDialog.pug +0 -42
- package/templates/widgets/folderList.pug +0 -21
- package/templates/widgets/groupAdminList.pug +0 -33
- package/templates/widgets/groupInviteDialog.pug +0 -76
- package/templates/widgets/groupInviteList.pug +0 -14
- package/templates/widgets/groupMemberList.pug +0 -39
- package/templates/widgets/groupModList.pug +0 -23
- package/templates/widgets/hierarchyBreadcrumb.pug +0 -37
- package/templates/widgets/hierarchyPaginated.pug +0 -19
- package/templates/widgets/hierarchyWidget.pug +0 -96
- package/templates/widgets/itemBreadcrumb.pug +0 -16
- package/templates/widgets/itemList.pug +0 -27
- package/templates/widgets/jsonMetadatumEditWidget.pug +0 -13
- package/templates/widgets/jsonMetadatumView.pug +0 -6
- package/templates/widgets/loadingAnimation.pug +0 -4
- package/templates/widgets/markdownWidget.pug +0 -34
- package/templates/widgets/metadataWidget.pug +0 -16
- package/templates/widgets/metadatumEditWidget.pug +0 -15
- package/templates/widgets/metadatumView.pug +0 -5
- package/templates/widgets/newAssetstore.pug +0 -118
- package/templates/widgets/paginateWidget.pug +0 -7
- package/templates/widgets/pluginConfigBreadcrumb.pug +0 -13
- package/templates/widgets/rootSelectorWidget.pug +0 -13
- package/templates/widgets/searchField.pug +0 -10
- package/templates/widgets/searchHelp.pug +0 -12
- package/templates/widgets/searchModeSelect.pug +0 -9
- package/templates/widgets/searchResults.pug +0 -14
- package/templates/widgets/sortCollectionWidget.pug +0 -14
- package/templates/widgets/taskProgress.pug +0 -16
- package/templates/widgets/timeline.pug +0 -15
- package/templates/widgets/uploadWidget.pug +0 -15
- package/templates/widgets/uploadWidgetMixins.pug +0 -31
- package/templates/widgets/uploadWidgetNonModal.pug +0 -10
- package/templates/widgets/userOtpBegin.pug +0 -4
- package/templates/widgets/userOtpDisable.pug +0 -6
- package/templates/widgets/userOtpEnable.pug +0 -44
- package/utilities/EventStream.js +0 -177
- package/utilities/PluginUtils.js +0 -36
- package/utilities/S3UploadHandler.js +0 -303
- package/utilities/index.js +0 -9
- package/utilities/jquery/girderEnable.js +0 -19
- package/utilities/jquery/girderModal.js +0 -48
- package/version.js +0 -10
- package/views/App.js +0 -359
- package/views/View.js +0 -78
- package/views/body/AdminView.js +0 -29
- package/views/body/AssetstoresView.js +0 -235
- package/views/body/CollectionView.js +0 -188
- package/views/body/CollectionsView.js +0 -120
- package/views/body/FilesystemImportView.js +0 -83
- package/views/body/FolderView.js +0 -54
- package/views/body/FrontPageView.js +0 -47
- package/views/body/GroupView.js +0 -336
- package/views/body/GroupsView.js +0 -106
- package/views/body/ItemView.js +0 -177
- package/views/body/PluginsView.js +0 -73
- package/views/body/S3ImportView.js +0 -80
- package/views/body/SearchResultsView.js +0 -162
- package/views/body/SystemConfigurationView.js +0 -196
- package/views/body/UserAccountView.js +0 -179
- package/views/body/UserView.js +0 -165
- package/views/body/UsersView.js +0 -124
- package/views/body/index.js +0 -37
- package/views/index.js +0 -13
- package/views/layout/FooterView.js +0 -29
- package/views/layout/GlobalNavView.js +0 -103
- package/views/layout/HeaderUserView.js +0 -45
- package/views/layout/HeaderView.js +0 -83
- package/views/layout/LoginView.js +0 -100
- package/views/layout/ProgressListView.js +0 -70
- package/views/layout/RegisterView.js +0 -101
- package/views/layout/ResetPasswordView.js +0 -70
- package/views/layout/index.js +0 -19
- package/views/widgets/AccessWidget.js +0 -427
- package/views/widgets/ApiKeyListWidget.js +0 -140
- package/views/widgets/BrowserWidget.js +0 -317
- package/views/widgets/CheckedMenuWidget.js +0 -68
- package/views/widgets/CollectionInfoWidget.js +0 -40
- package/views/widgets/DateTimeRangeWidget.js +0 -179
- package/views/widgets/DateTimeWidget.js +0 -109
- package/views/widgets/EditApiKeyWidget.js +0 -122
- package/views/widgets/EditAssetstoreWidget.js +0 -148
- package/views/widgets/EditCollectionWidget.js +0 -93
- package/views/widgets/EditFileWidget.js +0 -56
- package/views/widgets/EditFolderWidget.js +0 -116
- package/views/widgets/EditGroupWidget.js +0 -125
- package/views/widgets/EditItemWidget.js +0 -110
- package/views/widgets/FileInfoWidget.js +0 -26
- package/views/widgets/FileListWidget.js +0 -151
- package/views/widgets/FolderInfoWidget.js +0 -39
- package/views/widgets/FolderListWidget.js +0 -106
- package/views/widgets/GroupAdminsWidget.js +0 -88
- package/views/widgets/GroupInvitesWidget.js +0 -56
- package/views/widgets/GroupMembersWidget.js +0 -185
- package/views/widgets/GroupModsWidget.js +0 -77
- package/views/widgets/HierarchyWidget.js +0 -1097
- package/views/widgets/ItemBreadcrumbWidget.js +0 -38
- package/views/widgets/ItemListWidget.js +0 -345
- package/views/widgets/LoadingAnimation.js +0 -17
- package/views/widgets/MarkdownWidget.js +0 -217
- package/views/widgets/MetadataWidget.js +0 -504
- package/views/widgets/NewAssetstoreWidget.js +0 -81
- package/views/widgets/PaginateWidget.js +0 -37
- package/views/widgets/PluginConfigBreadcrumbWidget.js +0 -33
- package/views/widgets/RootSelectorWidget.js +0 -192
- package/views/widgets/SearchFieldWidget.js +0 -365
- package/views/widgets/SearchPaginateWidget.js +0 -149
- package/views/widgets/SortCollectionWidget.js +0 -53
- package/views/widgets/TaskProgressWidget.js +0 -91
- package/views/widgets/TimelineWidget.js +0 -155
- package/views/widgets/UploadWidget.js +0 -340
- package/views/widgets/UserOtpManagementWidget.js +0 -105
- package/views/widgets/index.js +0 -75
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import _ from 'underscore';
|
|
2
|
-
import moment from 'moment';
|
|
3
|
-
|
|
4
|
-
import View from '@girder/core/views/View';
|
|
5
|
-
|
|
6
|
-
import dateTimeWidgetTemplate from '@girder/core/templates/widgets/dateTimeWidget.pug';
|
|
7
|
-
|
|
8
|
-
import 'eonasdan-bootstrap-datetimepicker'; // /src/js/bootstrap-datetimepicker.js'
|
|
9
|
-
import 'eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.css';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* This widget provides a text input field to specify a date/time. The user
|
|
13
|
-
* chooses the date/time using a popup picker.
|
|
14
|
-
*/
|
|
15
|
-
var DateTimeWidget = View.extend({
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @param [settings.defaultDate=false] The default date/time when not set
|
|
19
|
-
* explicitly. Set to false to have no default.
|
|
20
|
-
* @param [settings.showIcon=true] Whether to show a calendar icon beside
|
|
21
|
-
* the input field. When true, clicking the icon shows the popup. Otherwise,
|
|
22
|
-
* focusing the input field shows the popup.
|
|
23
|
-
*/
|
|
24
|
-
initialize: function (settings) {
|
|
25
|
-
this.defaultDate = settings.defaultDate || false;
|
|
26
|
-
this.showIcon = _.has(settings, 'showIcon') ? settings.showIcon : true;
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
render: function () {
|
|
30
|
-
this.$el.html(dateTimeWidgetTemplate({
|
|
31
|
-
showIcon: this.showIcon
|
|
32
|
-
}));
|
|
33
|
-
|
|
34
|
-
this.$('.g-datetime-widget').datetimepicker({
|
|
35
|
-
showClear: true,
|
|
36
|
-
showTodayButton: true,
|
|
37
|
-
useCurrent: 'day',
|
|
38
|
-
icons: {
|
|
39
|
-
time: 'icon-clock',
|
|
40
|
-
date: 'icon-calendar',
|
|
41
|
-
up: 'icon-up-open',
|
|
42
|
-
down: 'icon-down-open',
|
|
43
|
-
previous: 'icon-left-open',
|
|
44
|
-
next: 'icon-right-open',
|
|
45
|
-
clear: 'icon-trash',
|
|
46
|
-
close: 'icon-cancel',
|
|
47
|
-
today: 'icon-target'
|
|
48
|
-
},
|
|
49
|
-
defaultDate: this.defaultDate
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
return this;
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Set date/time. Argument can be an ISO 8601-formatted date string, a
|
|
57
|
-
* moment object, or a Date object. Call with null or the empty string to
|
|
58
|
-
* clear. When called with a string, the widget displays in local time.
|
|
59
|
-
*
|
|
60
|
-
* @param date Date/time to display.
|
|
61
|
-
*/
|
|
62
|
-
setDate: function (date) {
|
|
63
|
-
var picker = this._picker();
|
|
64
|
-
if (_.isEmpty(date)) {
|
|
65
|
-
picker.clear();
|
|
66
|
-
} else if (_.isString(date)) {
|
|
67
|
-
var localDate = moment.utc(date).local();
|
|
68
|
-
picker.date(localDate);
|
|
69
|
-
} else {
|
|
70
|
-
picker.date(date);
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Get the date/time as a moment object in UTC. Returns null if no date is
|
|
76
|
-
* set.
|
|
77
|
-
*/
|
|
78
|
-
date: function () {
|
|
79
|
-
var picker = this._picker();
|
|
80
|
-
var date = picker.date();
|
|
81
|
-
if (date !== null) {
|
|
82
|
-
date = moment(date);
|
|
83
|
-
date.utc();
|
|
84
|
-
}
|
|
85
|
-
return date;
|
|
86
|
-
},
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Convenience function to return the date/time as a string in UTC. Returns
|
|
90
|
-
* the empty string if no date is set.
|
|
91
|
-
*/
|
|
92
|
-
dateString: function () {
|
|
93
|
-
var date = this.date();
|
|
94
|
-
if (date === null) {
|
|
95
|
-
return '';
|
|
96
|
-
}
|
|
97
|
-
return date.format();
|
|
98
|
-
},
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Convenience function to access the datetimepicker on an element.
|
|
102
|
-
*/
|
|
103
|
-
_picker: function () {
|
|
104
|
-
var picker = this.$('.g-datetime-widget').data('DateTimePicker');
|
|
105
|
-
return picker;
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
export default DateTimeWidget;
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import $ from 'jquery';
|
|
2
|
-
import _ from 'underscore';
|
|
3
|
-
|
|
4
|
-
import ApiKeyModel from '@girder/core/models/ApiKeyModel';
|
|
5
|
-
import View from '@girder/core/views/View';
|
|
6
|
-
import { getCurrentUser } from '@girder/core/auth';
|
|
7
|
-
import { restRequest } from '@girder/core/rest';
|
|
8
|
-
|
|
9
|
-
import EditApiKeyWidgetTemplate from '@girder/core/templates/widgets/editApiKeyWidget.pug';
|
|
10
|
-
|
|
11
|
-
import '@girder/core/utilities/jquery/girderEnable';
|
|
12
|
-
import '@girder/core/utilities/jquery/girderModal';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* This widget is used to create a new API key or edit an existing one.
|
|
16
|
-
*/
|
|
17
|
-
var EditApiKeyWidget = View.extend({
|
|
18
|
-
events: {
|
|
19
|
-
'submit #g-api-key-edit-form': function (e) {
|
|
20
|
-
e.preventDefault();
|
|
21
|
-
|
|
22
|
-
var fields = {
|
|
23
|
-
name: this.$('#g-api-key-name').val(),
|
|
24
|
-
tokenDuration: this.$('#g-api-key-token-duration').val(),
|
|
25
|
-
scope: null
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
if (this._getSelectedScopeMode() === 'custom') {
|
|
29
|
-
fields.scope = _.map(this.$('.g-custom-scope-checkbox:checked'), function (el) {
|
|
30
|
-
return $(el).val();
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
this.saveModel(this.model, fields);
|
|
35
|
-
|
|
36
|
-
this.$('button.g-save-api-key').girderEnable(false);
|
|
37
|
-
this.$('.g-validation-failed-message').text('');
|
|
38
|
-
},
|
|
39
|
-
|
|
40
|
-
'change .g-scope-selection-container .radio input': function () {
|
|
41
|
-
var mode = this._getSelectedScopeMode();
|
|
42
|
-
if (mode === 'full') {
|
|
43
|
-
this.$('.g-custom-scope-checkbox').girderEnable(false)
|
|
44
|
-
.parent().parent().girderEnable(false);
|
|
45
|
-
} else if (mode === 'custom') {
|
|
46
|
-
this.$('.g-custom-scope-checkbox').girderEnable(true)
|
|
47
|
-
.parent().parent().girderEnable(true);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
initialize: function (settings) {
|
|
53
|
-
this.model = settings.model || null;
|
|
54
|
-
this.scopeInfo = null;
|
|
55
|
-
this._shouldRender = false;
|
|
56
|
-
|
|
57
|
-
restRequest({
|
|
58
|
-
url: 'token/scopes'
|
|
59
|
-
}).done((resp) => {
|
|
60
|
-
this.scopeInfo = resp;
|
|
61
|
-
if (this._shouldRender) {
|
|
62
|
-
this._shouldRender = false;
|
|
63
|
-
this.render();
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
},
|
|
67
|
-
|
|
68
|
-
render: function () {
|
|
69
|
-
if (!this.scopeInfo) { // Wait for scope list to be fetched
|
|
70
|
-
this._shouldRender = true;
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
let tokenScopes = this.scopeInfo.custom;
|
|
75
|
-
if (getCurrentUser().get('admin')) {
|
|
76
|
-
tokenScopes = tokenScopes.concat(this.scopeInfo.adminCustom);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
var modal = this.$el.html(EditApiKeyWidgetTemplate({
|
|
80
|
-
apiKey: this.model,
|
|
81
|
-
tokenScopes: tokenScopes
|
|
82
|
-
})).girderModal(this).on('shown.bs.modal', () => {
|
|
83
|
-
this.$('#g-api-key-name').trigger('focus');
|
|
84
|
-
}).on('ready.girder.modal', () => {
|
|
85
|
-
if (this.model) {
|
|
86
|
-
this.$('#g-api-key-name').val(this.model.get('name'));
|
|
87
|
-
this.$('#g-api-key-token-duration').val(this.model.get('tokenDuration') || '');
|
|
88
|
-
if (this.model.get('scope')) {
|
|
89
|
-
this.$('#g-scope-mode-custom').attr('checked', 'checked').trigger('change');
|
|
90
|
-
this.$('.g-custom-scope-checkbox').girderEnable(true);
|
|
91
|
-
_.each(this.model.get('scope'), function (scope) {
|
|
92
|
-
this.$('.g-custom-scope-checkbox[value="' + scope + '"]').attr('checked', 'checked');
|
|
93
|
-
}, this);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
modal.trigger($.Event('ready.girder.modal', { relatedTarget: modal }));
|
|
98
|
-
|
|
99
|
-
this.$('#g-api-key-name').trigger('focus');
|
|
100
|
-
|
|
101
|
-
return this;
|
|
102
|
-
},
|
|
103
|
-
|
|
104
|
-
saveModel: function (model, fields) {
|
|
105
|
-
model = model || new ApiKeyModel();
|
|
106
|
-
|
|
107
|
-
model.set(fields);
|
|
108
|
-
model.once('g:saved', function () {
|
|
109
|
-
this.$el.modal('hide');
|
|
110
|
-
this.trigger('g:saved', model);
|
|
111
|
-
}, this).off('g:error', null, this).on('g:error', function (err) {
|
|
112
|
-
this.$('.g-validation-failed-message').text(err.responseJSON.message);
|
|
113
|
-
this.$('button.g-save-api-key').girderEnable(true);
|
|
114
|
-
}, this).save();
|
|
115
|
-
},
|
|
116
|
-
|
|
117
|
-
_getSelectedScopeMode: function () {
|
|
118
|
-
return this.$('.g-scope-selection-container .radio input:checked').attr('value');
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
export default EditApiKeyWidget;
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import $ from 'jquery';
|
|
2
|
-
import _ from 'underscore';
|
|
3
|
-
|
|
4
|
-
import View from '@girder/core/views/View';
|
|
5
|
-
import { AssetstoreType } from '@girder/core/constants';
|
|
6
|
-
import { handleClose, handleOpen } from '@girder/core/dialog';
|
|
7
|
-
|
|
8
|
-
import EditAssetstoreWidgetTemplate from '@girder/core/templates/widgets/editAssetstoreWidget.pug';
|
|
9
|
-
|
|
10
|
-
import '@girder/core/utilities/jquery/girderEnable';
|
|
11
|
-
import '@girder/core/utilities/jquery/girderModal';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* This widget is used to edit an existing assetstore.
|
|
15
|
-
*/
|
|
16
|
-
var EditAssetstoreWidget = View.extend({
|
|
17
|
-
events: {
|
|
18
|
-
'submit #g-assetstore-edit-form': function (e) {
|
|
19
|
-
e.preventDefault();
|
|
20
|
-
|
|
21
|
-
var fields = this.fieldsMap[this.model.get('type')].get.call(this);
|
|
22
|
-
fields.name = this.$('#g-edit-name').val();
|
|
23
|
-
|
|
24
|
-
this.updateAssetstore(fields);
|
|
25
|
-
|
|
26
|
-
this.$('button.g-save-assetstore').girderEnable(false);
|
|
27
|
-
this.$('.g-validation-failed-message').text('');
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
initialize: function (settings) {
|
|
32
|
-
this.model = settings.model || null;
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* This maps each type of assetstore to a function to getter and setter
|
|
37
|
-
* functions. The set functions are responsible for populating the dialog
|
|
38
|
-
* fields with the appropriate current model values, and the get functions
|
|
39
|
-
* are responsible for reading the user input values from the dialog and
|
|
40
|
-
* returning a set of fields (excluding the name field) to set on the model.
|
|
41
|
-
*
|
|
42
|
-
* This is meant to make it easy for plugins that add new assetstore types
|
|
43
|
-
* to extend this dialog to allow the setting of custom fields using whatever
|
|
44
|
-
* widgets make the most sense. By adding a new field to this object, this
|
|
45
|
-
* edit dialog can support any type of assetstore dynamically.
|
|
46
|
-
*
|
|
47
|
-
* Since the keys of this array are values defined by variables,
|
|
48
|
-
* we set them after this class rather than inline with object creation syntax.
|
|
49
|
-
*/
|
|
50
|
-
fieldsMap: {},
|
|
51
|
-
|
|
52
|
-
render: function () {
|
|
53
|
-
var modal = this.$el.html(EditAssetstoreWidgetTemplate({
|
|
54
|
-
assetstore: this.model,
|
|
55
|
-
types: AssetstoreType
|
|
56
|
-
})).girderModal(this).on('shown.bs.modal', () => {
|
|
57
|
-
this.$('#g-edit-name').trigger('focus');
|
|
58
|
-
handleOpen('assetstoreedit', undefined, this.model.get('id'));
|
|
59
|
-
this.$('#g-edit-name').val(this.model.get('name'));
|
|
60
|
-
this.fieldsMap[this.model.get('type')].set.call(this);
|
|
61
|
-
}).on('hidden.bs.modal', () => {
|
|
62
|
-
handleClose('assetstoreedit', undefined, this.model.get('id'));
|
|
63
|
-
});
|
|
64
|
-
modal.trigger($.Event('ready.girder.modal', { relatedTarget: modal }));
|
|
65
|
-
return this;
|
|
66
|
-
},
|
|
67
|
-
|
|
68
|
-
updateAssetstore: function (fields) {
|
|
69
|
-
var oldfields = {};
|
|
70
|
-
var model = this.model;
|
|
71
|
-
_.each(fields, function (value, key) {
|
|
72
|
-
oldfields[key] = model.get(key);
|
|
73
|
-
});
|
|
74
|
-
this.model.set(fields);
|
|
75
|
-
this.model.on('g:saved', function () {
|
|
76
|
-
this.$el.modal('hide');
|
|
77
|
-
this.trigger('g:saved', this.model);
|
|
78
|
-
}, this).on('g:error', function (err) {
|
|
79
|
-
this.$('.g-validation-failed-message').text(err.responseJSON.message);
|
|
80
|
-
this.$('button.g-save-assetstore').girderEnable(true);
|
|
81
|
-
this.$('#g-' + err.responseJSON.field).trigger('focus');
|
|
82
|
-
this.model.set(oldfields);
|
|
83
|
-
}, this).save();
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
var fieldsMap = EditAssetstoreWidget.prototype.fieldsMap;
|
|
88
|
-
|
|
89
|
-
fieldsMap[AssetstoreType.FILESYSTEM] = {
|
|
90
|
-
get: function () {
|
|
91
|
-
return {
|
|
92
|
-
root: this.$('#g-edit-fs-root').val(),
|
|
93
|
-
perms: this.$('#g-edit-fs-perms').val()
|
|
94
|
-
};
|
|
95
|
-
},
|
|
96
|
-
set: function () {
|
|
97
|
-
var permStr = this.model.get('perms') ? this.model.get('perms').toString(8) : '600';
|
|
98
|
-
this.$('#g-edit-fs-perms').val(permStr);
|
|
99
|
-
this.$('#g-edit-fs-root').val(this.model.get('root'));
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
fieldsMap[AssetstoreType.GRIDFS] = {
|
|
104
|
-
get: function () {
|
|
105
|
-
return {
|
|
106
|
-
db: this.$('#g-edit-gridfs-db').val(),
|
|
107
|
-
mongohost: this.$('#g-edit-gridfs-mongohost').val(),
|
|
108
|
-
replicaset: this.$('#g-edit-gridfs-replicaset').val()
|
|
109
|
-
};
|
|
110
|
-
},
|
|
111
|
-
set: function () {
|
|
112
|
-
this.$('#g-edit-gridfs-db').val(this.model.get('db'));
|
|
113
|
-
this.$('#g-edit-gridfs-mongohost').val(this.model.get('mongohost'));
|
|
114
|
-
this.$('#g-edit-gridfs-replicaset').val(this.model.get('replicaset'));
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
fieldsMap[AssetstoreType.S3] = {
|
|
119
|
-
get: function () {
|
|
120
|
-
return {
|
|
121
|
-
bucket: this.$('#g-edit-s3-bucket').val(),
|
|
122
|
-
prefix: this.$('#g-edit-s3-prefix').val(),
|
|
123
|
-
accessKeyId: this.$('#g-edit-s3-access-key-id').val(),
|
|
124
|
-
secret: this.$('#g-edit-s3-secret').val(),
|
|
125
|
-
service: this.$('#g-edit-s3-service').val(),
|
|
126
|
-
region: this.$('#g-edit-s3-region').val(),
|
|
127
|
-
readOnly: this.$('#g-edit-s3-readonly').is(':checked'),
|
|
128
|
-
inferCredentials: this.$('#g-edit-s3-infercredentials').is(':checked'),
|
|
129
|
-
serverSideEncryption: this.$('#g-edit-s3-sse').is(':checked')
|
|
130
|
-
};
|
|
131
|
-
},
|
|
132
|
-
set: function () {
|
|
133
|
-
this.$('#g-edit-s3-bucket').val(this.model.get('bucket'));
|
|
134
|
-
this.$('#g-edit-s3-prefix').val(this.model.get('prefix'));
|
|
135
|
-
this.$('#g-edit-s3-access-key-id').val(this.model.get('accessKeyId'));
|
|
136
|
-
this.$('#g-edit-s3-secret').val(this.model.get('secret'));
|
|
137
|
-
this.$('#g-edit-s3-service').val(this.model.get('service'));
|
|
138
|
-
this.$('#g-edit-s3-region').val(this.model.get('region'));
|
|
139
|
-
this.$('#g-edit-s3-readonly').attr('checked',
|
|
140
|
-
this.model.get('readOnly') ? 'checked' : undefined);
|
|
141
|
-
this.$('#g-edit-s3-infercredentials').attr('checked',
|
|
142
|
-
(this.model.get('inferCredentials') ? 'checked' : undefined));
|
|
143
|
-
this.$('#g-edit-s3-sse').attr('checked',
|
|
144
|
-
(this.model.get('serverSideEncryption') ? 'checked' : undefined));
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
export default EditAssetstoreWidget;
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import $ from 'jquery';
|
|
2
|
-
|
|
3
|
-
import CollectionModel from '@girder/core/models/CollectionModel';
|
|
4
|
-
import View from '@girder/core/views/View';
|
|
5
|
-
import MarkdownWidget from '@girder/core/views/widgets/MarkdownWidget';
|
|
6
|
-
import { handleClose, handleOpen } from '@girder/core/dialog';
|
|
7
|
-
|
|
8
|
-
import EditCollectionWidgetTemplate from '@girder/core/templates/widgets/editCollectionWidget.pug';
|
|
9
|
-
|
|
10
|
-
import '@girder/core/utilities/jquery/girderEnable';
|
|
11
|
-
import '@girder/core/utilities/jquery/girderModal';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* This widget is used to create a new collection or edit an existing one.
|
|
15
|
-
*/
|
|
16
|
-
const EditCollectionWidget = View.extend({
|
|
17
|
-
events: {
|
|
18
|
-
'submit #g-collection-edit-form': function (e) {
|
|
19
|
-
e.preventDefault();
|
|
20
|
-
|
|
21
|
-
const fields = {
|
|
22
|
-
name: this.$('#g-name').val(),
|
|
23
|
-
description: this.descriptionEditor.val()
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
this.descriptionEditor.saveText();
|
|
27
|
-
this.$('button.g-save-collection').girderEnable(false);
|
|
28
|
-
this.$('.g-validation-failed-message').text('');
|
|
29
|
-
|
|
30
|
-
this._saveCollection(fields)
|
|
31
|
-
.always(() => {
|
|
32
|
-
this.$('button.g-save-collection').girderEnable(true);
|
|
33
|
-
})
|
|
34
|
-
.done(() => {
|
|
35
|
-
this.$el.modal('hide');
|
|
36
|
-
})
|
|
37
|
-
.fail((err) => {
|
|
38
|
-
this.$('.g-validation-failed-message').text(err.responseJSON.message);
|
|
39
|
-
this.$('#g-' + err.responseJSON.field).trigger('focus');
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
initialize: function (settings) {
|
|
45
|
-
this.create = !settings.model;
|
|
46
|
-
this.model = settings.model || new CollectionModel();
|
|
47
|
-
this.descriptionEditor = new MarkdownWidget({
|
|
48
|
-
text: this.model ? this.model.get('description') : '',
|
|
49
|
-
prefix: 'collection-description',
|
|
50
|
-
placeholder: 'Enter a description',
|
|
51
|
-
enableUploads: false,
|
|
52
|
-
parentView: this
|
|
53
|
-
});
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
render: function () {
|
|
57
|
-
this.$el.html(EditCollectionWidgetTemplate({
|
|
58
|
-
create: this.create,
|
|
59
|
-
collection: this.model
|
|
60
|
-
}));
|
|
61
|
-
const modal = this.$el
|
|
62
|
-
.girderModal(this)
|
|
63
|
-
.on('shown.bs.modal', () => {
|
|
64
|
-
this.$('#g-name').trigger('focus');
|
|
65
|
-
})
|
|
66
|
-
.on('hidden.bs.modal', () => {
|
|
67
|
-
handleClose(this.create ? 'create' : 'edit');
|
|
68
|
-
})
|
|
69
|
-
.on('ready.girder.modal', () => {
|
|
70
|
-
if (!this.create) {
|
|
71
|
-
this.$('#g-name').val(this.model.get('name'));
|
|
72
|
-
this.$('#g-description').val(this.model.get('description'));
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
modal.trigger($.Event('ready.girder.modal', { relatedTarget: modal }));
|
|
76
|
-
this.descriptionEditor.setElement(this.$('.g-description-editor-container')).render();
|
|
77
|
-
this.$('#g-name').trigger('focus');
|
|
78
|
-
|
|
79
|
-
handleOpen(this.create ? 'create' : 'edit');
|
|
80
|
-
|
|
81
|
-
return this;
|
|
82
|
-
},
|
|
83
|
-
|
|
84
|
-
_saveCollection: function (fields) {
|
|
85
|
-
this.model.set(fields);
|
|
86
|
-
return this.model.save()
|
|
87
|
-
.done(() => {
|
|
88
|
-
this.trigger('g:saved', this.model);
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
export default EditCollectionWidget;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import View from '@girder/core/views/View';
|
|
2
|
-
import { handleClose, handleOpen } from '@girder/core/dialog';
|
|
3
|
-
|
|
4
|
-
import EditFileWidgetTemplate from '@girder/core/templates/widgets/editFileWidget.pug';
|
|
5
|
-
|
|
6
|
-
import '@girder/core/utilities/jquery/girderEnable';
|
|
7
|
-
import '@girder/core/utilities/jquery/girderModal';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* This widget is used to edit file information.
|
|
11
|
-
*/
|
|
12
|
-
var EditFileWidget = View.extend({
|
|
13
|
-
events: {
|
|
14
|
-
'submit #g-file-edit-form': function () {
|
|
15
|
-
var fields = {
|
|
16
|
-
name: this.$('#g-name').val(),
|
|
17
|
-
mimeType: this.$('#g-mimetype').val()
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
this.file.set(fields);
|
|
21
|
-
this.file.off(null, null, this).on('g:saved', function () {
|
|
22
|
-
this.$el.modal('hide');
|
|
23
|
-
this.trigger('g:saved', this.file);
|
|
24
|
-
}, this).on('g:error', function (err) {
|
|
25
|
-
this.$('.g-validation-failed-message').text(err.responseJSON.message);
|
|
26
|
-
this.$('button.g-save-file').girderEnable(true);
|
|
27
|
-
this.$('#g-' + err.responseJSON.field).trigger('focus');
|
|
28
|
-
}, this).save();
|
|
29
|
-
|
|
30
|
-
this.$('button.g-save-file').girderEnable(false);
|
|
31
|
-
this.$('.g-validation-failed-message').empty();
|
|
32
|
-
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
initialize: function (settings) {
|
|
38
|
-
this.file = settings.file || null;
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
render: function () {
|
|
42
|
-
if (this.file.get('mimeType') === undefined) {
|
|
43
|
-
this.file.set('mimeType', '');
|
|
44
|
-
}
|
|
45
|
-
this.$el.html(EditFileWidgetTemplate({ file: this.file }))
|
|
46
|
-
.girderModal(this).on('shown.bs.modal', () => {
|
|
47
|
-
this.$('#g-name').trigger('select').trigger('focus');
|
|
48
|
-
}).on('hidden.bs.modal', () => {
|
|
49
|
-
handleClose('fileedit', undefined, this.file.get('_id'));
|
|
50
|
-
});
|
|
51
|
-
handleOpen('fileedit', undefined, this.file.get('_id'));
|
|
52
|
-
return this;
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
export default EditFileWidget;
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import $ from 'jquery';
|
|
2
|
-
import _ from 'underscore';
|
|
3
|
-
|
|
4
|
-
import FolderModel from '@girder/core/models/FolderModel';
|
|
5
|
-
import MarkdownWidget from '@girder/core/views/widgets/MarkdownWidget';
|
|
6
|
-
import View from '@girder/core/views/View';
|
|
7
|
-
import { handleClose, handleOpen } from '@girder/core/dialog';
|
|
8
|
-
|
|
9
|
-
import EditFolderWidgetTemplate from '@girder/core/templates/widgets/editFolderWidget.pug';
|
|
10
|
-
|
|
11
|
-
import '@girder/core/utilities/jquery/girderEnable';
|
|
12
|
-
import '@girder/core/utilities/jquery/girderModal';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* This widget is used to create a new folder or edit an existing one.
|
|
16
|
-
*/
|
|
17
|
-
var EditFolderWidget = View.extend({
|
|
18
|
-
events: {
|
|
19
|
-
'submit #g-folder-edit-form': function (e) {
|
|
20
|
-
e.preventDefault();
|
|
21
|
-
var fields = {
|
|
22
|
-
name: this.$('#g-name').val(),
|
|
23
|
-
description: this.descriptionEditor.val()
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
if (this.folder) {
|
|
27
|
-
this.updateFolder(fields);
|
|
28
|
-
} else {
|
|
29
|
-
this.createFolder(fields);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
this.descriptionEditor.saveText();
|
|
33
|
-
this.$('button.g-save-folder').girderEnable(false);
|
|
34
|
-
this.$('.g-validation-failed-message').text('');
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
|
|
38
|
-
initialize: function (settings) {
|
|
39
|
-
this.folder = settings.folder || null;
|
|
40
|
-
this.parentModel = settings.parentModel;
|
|
41
|
-
this.descriptionEditor = new MarkdownWidget({
|
|
42
|
-
text: this.folder ? this.folder.get('description') : '',
|
|
43
|
-
prefix: 'folder-description',
|
|
44
|
-
placeholder: 'Enter a description',
|
|
45
|
-
parent: this.folder,
|
|
46
|
-
allowedExtensions: ['png', 'jpg', 'jpeg', 'gif'],
|
|
47
|
-
enableUploads: !!this.folder,
|
|
48
|
-
parentView: this
|
|
49
|
-
}).on('g:fileUploaded', function (args) {
|
|
50
|
-
this.trigger('g:fileUploaded', args);
|
|
51
|
-
}, this);
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
-
render: function () {
|
|
55
|
-
var modal = this.$el.html(EditFolderWidgetTemplate({
|
|
56
|
-
folder: this.folder
|
|
57
|
-
})).girderModal(this).on('shown.bs.modal', () => {
|
|
58
|
-
this.$('#g-name').trigger('focus');
|
|
59
|
-
if (this.folder) {
|
|
60
|
-
handleOpen('folderedit');
|
|
61
|
-
} else {
|
|
62
|
-
handleOpen('foldercreate');
|
|
63
|
-
}
|
|
64
|
-
}).on('hidden.bs.modal', () => {
|
|
65
|
-
if (this.create) {
|
|
66
|
-
handleClose('foldercreate');
|
|
67
|
-
} else {
|
|
68
|
-
handleClose('folderedit');
|
|
69
|
-
}
|
|
70
|
-
}).on('ready.girder.modal', () => {
|
|
71
|
-
if (this.folder) {
|
|
72
|
-
this.$('#g-name').val(this.folder.get('name'));
|
|
73
|
-
this.descriptionEditor.val(this.folder.get('description'));
|
|
74
|
-
this.create = false;
|
|
75
|
-
} else {
|
|
76
|
-
this.create = true;
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
modal.trigger($.Event('ready.girder.modal', { relatedTarget: modal }));
|
|
80
|
-
this.$('#g-name').trigger('focus');
|
|
81
|
-
this.descriptionEditor.setElement(
|
|
82
|
-
this.$('.g-description-editor-container')).render();
|
|
83
|
-
|
|
84
|
-
return this;
|
|
85
|
-
},
|
|
86
|
-
|
|
87
|
-
createFolder: function (fields) {
|
|
88
|
-
var folder = new FolderModel();
|
|
89
|
-
folder.set(_.extend(fields, {
|
|
90
|
-
parentType: this.parentModel.resourceName,
|
|
91
|
-
parentId: this.parentModel.get('_id')
|
|
92
|
-
}));
|
|
93
|
-
folder.on('g:saved', function () {
|
|
94
|
-
this.$el.modal('hide');
|
|
95
|
-
this.trigger('g:saved', folder);
|
|
96
|
-
}, this).on('g:error', function (err) {
|
|
97
|
-
this.$('.g-validation-failed-message').text(err.responseJSON.message);
|
|
98
|
-
this.$('button.g-save-folder').girderEnable(true);
|
|
99
|
-
this.$('#g-' + err.responseJSON.field).trigger('focus');
|
|
100
|
-
}, this).save();
|
|
101
|
-
},
|
|
102
|
-
|
|
103
|
-
updateFolder: function (fields) {
|
|
104
|
-
this.folder.set(fields);
|
|
105
|
-
this.folder.off().on('g:saved', function () {
|
|
106
|
-
this.$el.modal('hide');
|
|
107
|
-
this.trigger('g:saved', this.folder);
|
|
108
|
-
}, this).on('g:error', function (err) {
|
|
109
|
-
this.$('.g-validation-failed-message').text(err.responseJSON.message);
|
|
110
|
-
this.$('button.g-save-folder').girderEnable(true);
|
|
111
|
-
this.$('#g-' + err.responseJSON.field).trigger('focus');
|
|
112
|
-
}, this).save();
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
export default EditFolderWidget;
|