@girder/core 5.0.0-beta.1 → 5.0.0-beta.2
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/dist-lib/Girder_Favicon.png +0 -0
- package/dist-lib/Girder_Mark.png +0 -0
- package/dist-lib/girder-core.js +48560 -0
- package/dist-lib/girder-core.js.map +1 -0
- package/dist-lib/girder-core.umd.cjs +630 -0
- package/dist-lib/girder-core.umd.cjs.map +1 -0
- package/dist-lib/index.d.ts +1 -0
- package/dist-lib/src/auth.js +112 -0
- package/dist-lib/src/collections/ApiKeyCollection.js +9 -0
- package/dist-lib/src/collections/AssetstoreCollection.js +9 -0
- package/dist-lib/src/collections/Collection.js +295 -0
- package/dist-lib/src/collections/CollectionCollection.js +9 -0
- package/dist-lib/src/collections/FileCollection.js +11 -0
- package/dist-lib/src/collections/FolderCollection.js +11 -0
- package/dist-lib/src/collections/GroupCollection.js +9 -0
- package/dist-lib/src/collections/ItemCollection.js +11 -0
- package/dist-lib/src/collections/UserCollection.js +24 -0
- package/dist-lib/src/collections/index.js +21 -0
- package/dist-lib/src/constants.js +32 -0
- package/dist-lib/src/dialog.js +128 -0
- package/dist-lib/src/events.js +6 -0
- package/dist-lib/src/index.d.ts +23 -0
- package/dist-lib/src/index.ts +80 -0
- package/dist-lib/src/main.ts +45 -0
- package/dist-lib/src/misc.js +260 -0
- package/dist-lib/src/models/AccessControlledModel.js +76 -0
- package/dist-lib/src/models/ApiKeyModel.js +31 -0
- package/dist-lib/src/models/AssetstoreModel.js +43 -0
- package/dist-lib/src/models/CollectionCreationPolicyModel.js +20 -0
- package/dist-lib/src/models/CollectionModel.js +12 -0
- package/dist-lib/src/models/FileModel.js +310 -0
- package/dist-lib/src/models/FolderModel.js +33 -0
- package/dist-lib/src/models/GroupModel.js +197 -0
- package/dist-lib/src/models/ItemModel.js +72 -0
- package/dist-lib/src/models/MetadataMixin.js +88 -0
- package/dist-lib/src/models/Model.js +187 -0
- package/dist-lib/src/models/UserModel.js +189 -0
- package/dist-lib/src/models/index.js +25 -0
- package/dist-lib/src/pluginUtils.js +11 -0
- package/dist-lib/src/rest.js +221 -0
- package/dist-lib/src/router.js +58 -0
- package/dist-lib/src/routes.js +229 -0
- package/dist-lib/src/stylesheets/apidocs/apidocs.styl +50 -0
- package/dist-lib/src/stylesheets/body/adminConsole.styl +21 -0
- package/dist-lib/src/stylesheets/body/assetstores.styl +46 -0
- package/dist-lib/src/stylesheets/body/collectionList.styl +39 -0
- package/dist-lib/src/stylesheets/body/collectionPage.styl +6 -0
- package/dist-lib/src/stylesheets/body/frontPage.styl +48 -0
- package/dist-lib/src/stylesheets/body/groupList.styl +43 -0
- package/dist-lib/src/stylesheets/body/groupPage.styl +116 -0
- package/dist-lib/src/stylesheets/body/itemPage.styl +81 -0
- package/dist-lib/src/stylesheets/body/plugins.styl +61 -0
- package/dist-lib/src/stylesheets/body/searchResultsList.styl +51 -0
- package/dist-lib/src/stylesheets/body/systemConfig.styl +56 -0
- package/dist-lib/src/stylesheets/body/userAccount.styl +57 -0
- package/dist-lib/src/stylesheets/body/userList.styl +79 -0
- package/dist-lib/src/stylesheets/body/userPage.styl +6 -0
- package/dist-lib/src/stylesheets/layout/footer.styl +19 -0
- package/dist-lib/src/stylesheets/layout/global.styl +154 -0
- package/dist-lib/src/stylesheets/layout/globalNav.styl +89 -0
- package/dist-lib/src/stylesheets/layout/header.styl +29 -0
- package/dist-lib/src/stylesheets/layout/headerUser.styl +33 -0
- package/dist-lib/src/stylesheets/layout/layout.styl +75 -0
- package/dist-lib/src/stylesheets/layout/layoutVars.styl +9 -0
- package/dist-lib/src/stylesheets/layout/loading.styl +37 -0
- package/dist-lib/src/stylesheets/layout/progressArea.styl +17 -0
- package/dist-lib/src/stylesheets/widgets/accessWidget.styl +106 -0
- package/dist-lib/src/stylesheets/widgets/browserWidget.styl +9 -0
- package/dist-lib/src/stylesheets/widgets/hierarchyWidget.styl +188 -0
- package/dist-lib/src/stylesheets/widgets/markdownWidget.styl +92 -0
- package/dist-lib/src/stylesheets/widgets/metadataWidget.styl +92 -0
- package/dist-lib/src/stylesheets/widgets/searchFieldWidget.styl +70 -0
- package/dist-lib/src/stylesheets/widgets/taskProgress.styl +41 -0
- package/dist-lib/src/stylesheets/widgets/timelineWidget.styl +41 -0
- package/dist-lib/src/stylesheets/widgets/uploadWidget.styl +43 -0
- package/dist-lib/src/stylesheets/widgets/userOtpManagementWidget.styl +159 -0
- package/dist-lib/src/templates/body/adminConsole.pug +13 -0
- package/dist-lib/src/templates/body/assetstores.pug +83 -0
- package/dist-lib/src/templates/body/collectionList.pug +40 -0
- package/dist-lib/src/templates/body/collectionPage.pug +36 -0
- package/dist-lib/src/templates/body/filesystemImport.pug +41 -0
- package/dist-lib/src/templates/body/frontPage.pug +84 -0
- package/dist-lib/src/templates/body/groupList.pug +30 -0
- package/dist-lib/src/templates/body/groupPage.pug +116 -0
- package/dist-lib/src/templates/body/itemPage.pug +61 -0
- package/dist-lib/src/templates/body/plugins.pug +20 -0
- package/dist-lib/src/templates/body/s3Import.pug +35 -0
- package/dist-lib/src/templates/body/searchResults.pug +15 -0
- package/dist-lib/src/templates/body/searchResultsType.pug +13 -0
- package/dist-lib/src/templates/body/systemConfiguration.pug +199 -0
- package/dist-lib/src/templates/body/userAccount.pug +83 -0
- package/dist-lib/src/templates/body/userList.pug +43 -0
- package/dist-lib/src/templates/body/userPage.pug +40 -0
- package/dist-lib/src/templates/layout/alert.pug +5 -0
- package/dist-lib/src/templates/layout/layout.pug +12 -0
- package/dist-lib/src/templates/layout/layoutFooter.pug +11 -0
- package/dist-lib/src/templates/layout/layoutGlobalNav.pug +7 -0
- package/dist-lib/src/templates/layout/layoutHeader.pug +8 -0
- package/dist-lib/src/templates/layout/layoutHeaderUser.pug +26 -0
- package/dist-lib/src/templates/layout/layoutProgressArea.pug +1 -0
- package/dist-lib/src/templates/layout/loginDialog.pug +30 -0
- package/dist-lib/src/templates/layout/registerDialog.pug +35 -0
- package/dist-lib/src/templates/layout/resetPasswordDialog.pug +25 -0
- package/dist-lib/src/templates/widgets/accessEditor.pug +23 -0
- package/dist-lib/src/templates/widgets/accessEditorMixins.pug +57 -0
- package/dist-lib/src/templates/widgets/accessEditorNonModal.pug +11 -0
- package/dist-lib/src/templates/widgets/accessEntry.pug +32 -0
- package/dist-lib/src/templates/widgets/apiKeyList.pug +50 -0
- package/dist-lib/src/templates/widgets/browserWidget.pug +32 -0
- package/dist-lib/src/templates/widgets/checkedActionsMenu.pug +46 -0
- package/dist-lib/src/templates/widgets/collectionInfoDialog.pug +37 -0
- package/dist-lib/src/templates/widgets/confirmDialog.pug +14 -0
- package/dist-lib/src/templates/widgets/dateTimeRangeWidget.pug +20 -0
- package/dist-lib/src/templates/widgets/dateTimeWidget.pug +8 -0
- package/dist-lib/src/templates/widgets/editApiKeyWidget.pug +43 -0
- package/dist-lib/src/templates/widgets/editAssetstoreWidget.pug +66 -0
- package/dist-lib/src/templates/widgets/editCollectionWidget.pug +27 -0
- package/dist-lib/src/templates/widgets/editFileWidget.pug +21 -0
- package/dist-lib/src/templates/widgets/editFolderWidget.pug +27 -0
- package/dist-lib/src/templates/widgets/editGroupWidget.pug +54 -0
- package/dist-lib/src/templates/widgets/editItemWidget.pug +27 -0
- package/dist-lib/src/templates/widgets/fileInfoDialog.pug +33 -0
- package/dist-lib/src/templates/widgets/fileList.pug +33 -0
- package/dist-lib/src/templates/widgets/folderInfoDialog.pug +42 -0
- package/dist-lib/src/templates/widgets/folderList.pug +21 -0
- package/dist-lib/src/templates/widgets/groupAdminList.pug +33 -0
- package/dist-lib/src/templates/widgets/groupInviteDialog.pug +76 -0
- package/dist-lib/src/templates/widgets/groupInviteList.pug +14 -0
- package/dist-lib/src/templates/widgets/groupMemberList.pug +39 -0
- package/dist-lib/src/templates/widgets/groupModList.pug +23 -0
- package/dist-lib/src/templates/widgets/hierarchyBreadcrumb.pug +37 -0
- package/dist-lib/src/templates/widgets/hierarchyPaginated.pug +19 -0
- package/dist-lib/src/templates/widgets/hierarchyWidget.pug +96 -0
- package/dist-lib/src/templates/widgets/itemBreadcrumb.pug +16 -0
- package/dist-lib/src/templates/widgets/itemList.pug +27 -0
- package/dist-lib/src/templates/widgets/jsonMetadatumEditWidget.pug +13 -0
- package/dist-lib/src/templates/widgets/jsonMetadatumView.pug +6 -0
- package/dist-lib/src/templates/widgets/loadingAnimation.pug +4 -0
- package/dist-lib/src/templates/widgets/markdownWidget.pug +34 -0
- package/dist-lib/src/templates/widgets/metadataWidget.pug +16 -0
- package/dist-lib/src/templates/widgets/metadatumEditWidget.pug +15 -0
- package/dist-lib/src/templates/widgets/metadatumView.pug +5 -0
- package/dist-lib/src/templates/widgets/newAssetstore.pug +83 -0
- package/dist-lib/src/templates/widgets/paginateWidget.pug +7 -0
- package/dist-lib/src/templates/widgets/pluginConfigBreadcrumb.pug +13 -0
- package/dist-lib/src/templates/widgets/rootSelectorWidget.pug +13 -0
- package/dist-lib/src/templates/widgets/searchField.pug +10 -0
- package/dist-lib/src/templates/widgets/searchHelp.pug +12 -0
- package/dist-lib/src/templates/widgets/searchModeSelect.pug +9 -0
- package/dist-lib/src/templates/widgets/searchResults.pug +14 -0
- package/dist-lib/src/templates/widgets/sortCollectionWidget.pug +14 -0
- package/dist-lib/src/templates/widgets/taskProgress.pug +16 -0
- package/dist-lib/src/templates/widgets/timeline.pug +15 -0
- package/dist-lib/src/templates/widgets/uploadWidget.pug +15 -0
- package/dist-lib/src/templates/widgets/uploadWidgetMixins.pug +31 -0
- package/dist-lib/src/templates/widgets/uploadWidgetNonModal.pug +10 -0
- package/dist-lib/src/templates/widgets/userOtpBegin.pug +4 -0
- package/dist-lib/src/templates/widgets/userOtpDisable.pug +6 -0
- package/dist-lib/src/templates/widgets/userOtpEnable.pug +44 -0
- package/dist-lib/src/utilities/EventStream.js +177 -0
- package/dist-lib/src/utilities/PluginUtils.js +36 -0
- package/dist-lib/src/utilities/S3UploadHandler.js +303 -0
- package/dist-lib/src/utilities/index.js +9 -0
- package/dist-lib/src/utilities/jquery/girderEnable.js +19 -0
- package/dist-lib/src/utilities/jquery/girderModal.js +48 -0
- package/dist-lib/src/version.js +6 -0
- package/dist-lib/src/views/App.js +359 -0
- package/dist-lib/src/views/View.js +79 -0
- package/dist-lib/src/views/body/AdminView.js +29 -0
- package/dist-lib/src/views/body/AssetstoresView.js +234 -0
- package/dist-lib/src/views/body/CollectionView.js +188 -0
- package/dist-lib/src/views/body/CollectionsView.js +120 -0
- package/dist-lib/src/views/body/FilesystemImportView.js +83 -0
- package/dist-lib/src/views/body/FolderView.js +54 -0
- package/dist-lib/src/views/body/FrontPageView.js +47 -0
- package/dist-lib/src/views/body/GroupView.js +336 -0
- package/dist-lib/src/views/body/GroupsView.js +106 -0
- package/dist-lib/src/views/body/ItemView.js +177 -0
- package/dist-lib/src/views/body/PluginsView.js +73 -0
- package/dist-lib/src/views/body/S3ImportView.js +80 -0
- package/dist-lib/src/views/body/SearchResultsView.js +162 -0
- package/dist-lib/src/views/body/SystemConfigurationView.js +182 -0
- package/dist-lib/src/views/body/UserAccountView.js +179 -0
- package/dist-lib/src/views/body/UserView.js +165 -0
- package/dist-lib/src/views/body/UsersView.js +124 -0
- package/dist-lib/src/views/body/index.js +37 -0
- package/dist-lib/src/views/index.js +13 -0
- package/dist-lib/src/views/layout/FooterView.js +29 -0
- package/dist-lib/src/views/layout/GlobalNavView.js +103 -0
- package/dist-lib/src/views/layout/HeaderUserView.js +45 -0
- package/dist-lib/src/views/layout/HeaderView.js +83 -0
- package/dist-lib/src/views/layout/LoginView.js +100 -0
- package/dist-lib/src/views/layout/ProgressListView.js +70 -0
- package/dist-lib/src/views/layout/RegisterView.js +101 -0
- package/dist-lib/src/views/layout/ResetPasswordView.js +70 -0
- package/dist-lib/src/views/layout/index.js +19 -0
- package/dist-lib/src/views/widgets/AccessWidget.js +427 -0
- package/dist-lib/src/views/widgets/ApiKeyListWidget.js +140 -0
- package/dist-lib/src/views/widgets/BrowserWidget.js +317 -0
- package/dist-lib/src/views/widgets/CheckedMenuWidget.js +68 -0
- package/dist-lib/src/views/widgets/CollectionInfoWidget.js +40 -0
- package/dist-lib/src/views/widgets/DateTimeRangeWidget.js +180 -0
- package/dist-lib/src/views/widgets/DateTimeWidget.js +110 -0
- package/dist-lib/src/views/widgets/EditApiKeyWidget.js +122 -0
- package/dist-lib/src/views/widgets/EditAssetstoreWidget.js +133 -0
- package/dist-lib/src/views/widgets/EditCollectionWidget.js +93 -0
- package/dist-lib/src/views/widgets/EditFileWidget.js +56 -0
- package/dist-lib/src/views/widgets/EditFolderWidget.js +116 -0
- package/dist-lib/src/views/widgets/EditGroupWidget.js +125 -0
- package/dist-lib/src/views/widgets/EditItemWidget.js +110 -0
- package/dist-lib/src/views/widgets/FileInfoWidget.js +26 -0
- package/dist-lib/src/views/widgets/FileListWidget.js +151 -0
- package/dist-lib/src/views/widgets/FolderInfoWidget.js +39 -0
- package/dist-lib/src/views/widgets/FolderListWidget.js +106 -0
- package/dist-lib/src/views/widgets/GroupAdminsWidget.js +88 -0
- package/dist-lib/src/views/widgets/GroupInvitesWidget.js +56 -0
- package/dist-lib/src/views/widgets/GroupMembersWidget.js +185 -0
- package/dist-lib/src/views/widgets/GroupModsWidget.js +77 -0
- package/dist-lib/src/views/widgets/HierarchyWidget.js +1097 -0
- package/dist-lib/src/views/widgets/ItemBreadcrumbWidget.js +38 -0
- package/dist-lib/src/views/widgets/ItemListWidget.js +345 -0
- package/dist-lib/src/views/widgets/LoadingAnimation.js +17 -0
- package/dist-lib/src/views/widgets/MarkdownWidget.js +217 -0
- package/dist-lib/src/views/widgets/MetadataWidget.js +508 -0
- package/dist-lib/src/views/widgets/NewAssetstoreWidget.js +71 -0
- package/dist-lib/src/views/widgets/PaginateWidget.js +37 -0
- package/dist-lib/src/views/widgets/PluginConfigBreadcrumbWidget.js +33 -0
- package/dist-lib/src/views/widgets/RootSelectorWidget.js +192 -0
- package/dist-lib/src/views/widgets/SearchFieldWidget.js +365 -0
- package/dist-lib/src/views/widgets/SearchPaginateWidget.js +149 -0
- package/dist-lib/src/views/widgets/SortCollectionWidget.js +53 -0
- package/dist-lib/src/views/widgets/TaskProgressWidget.js +91 -0
- package/dist-lib/src/views/widgets/TimelineWidget.js +155 -0
- package/dist-lib/src/views/widgets/UploadWidget.js +340 -0
- package/dist-lib/src/views/widgets/UserOtpManagementWidget.js +105 -0
- package/dist-lib/src/views/widgets/index.js +75 -0
- package/dist-lib/src/vite-env.d.ts +5 -0
- package/dist-lib/style.css +16 -0
- package/package.json +1 -1
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import $ from 'jquery';
|
|
2
|
+
|
|
3
|
+
import BrowserWidget from '@girder/core/views/widgets/BrowserWidget';
|
|
4
|
+
import router from '@girder/core/router';
|
|
5
|
+
import View from '@girder/core/views/View';
|
|
6
|
+
import { restRequest } from '@girder/core/rest';
|
|
7
|
+
|
|
8
|
+
import S3ImportTemplate from '@girder/core/templates/body/s3Import.pug';
|
|
9
|
+
|
|
10
|
+
var S3ImportView = View.extend({
|
|
11
|
+
events: {
|
|
12
|
+
'submit .g-s3-import-form': function (e) {
|
|
13
|
+
e.preventDefault();
|
|
14
|
+
|
|
15
|
+
var destId = this.$('#g-s3-import-dest-id').val().trim().split(/\s/)[0],
|
|
16
|
+
destType = this.$('#g-s3-import-dest-type').val();
|
|
17
|
+
|
|
18
|
+
this.$('.g-validation-failed-message').empty();
|
|
19
|
+
|
|
20
|
+
this.assetstore.off('g:imported').on('g:imported', function () {
|
|
21
|
+
router.navigate(destType + '/' + destId, { trigger: true });
|
|
22
|
+
}, this).on('g:error', function (resp) {
|
|
23
|
+
this.$('.g-validation-failed-message').text(resp.responseJSON.message);
|
|
24
|
+
}, this).import({
|
|
25
|
+
importPath: this.$('#g-s3-import-path').val().trim(),
|
|
26
|
+
destinationId: destId,
|
|
27
|
+
destinationType: destType,
|
|
28
|
+
progress: true
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
'click .g-open-browser': '_openBrowser'
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
initialize: function (settings) {
|
|
35
|
+
this._browserWidgetView = new BrowserWidget({
|
|
36
|
+
parentView: this,
|
|
37
|
+
titleText: 'Destination',
|
|
38
|
+
helpText: 'Browse to a location to select it as the destination.',
|
|
39
|
+
submitText: 'Select Destination',
|
|
40
|
+
validate: function (model) {
|
|
41
|
+
const isValid = $.Deferred();
|
|
42
|
+
if (!model) {
|
|
43
|
+
isValid.reject('Please select a valid root.');
|
|
44
|
+
} else {
|
|
45
|
+
isValid.resolve();
|
|
46
|
+
}
|
|
47
|
+
return isValid.promise();
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
this.listenTo(this._browserWidgetView, 'g:saved', function (val) {
|
|
51
|
+
this.$('#g-s3-import-dest-id').val(val.id);
|
|
52
|
+
this.$('#g-s3-import-dest-type').val(val.get('_modelType'));
|
|
53
|
+
restRequest({
|
|
54
|
+
url: `resource/${val.id}/path`,
|
|
55
|
+
method: 'GET',
|
|
56
|
+
data: { type: val.get('_modelType') }
|
|
57
|
+
}).done((result) => {
|
|
58
|
+
// Only add the resource path if the value wasn't altered
|
|
59
|
+
if (this.$('#g-s3-import-dest-id').val() === val.id) {
|
|
60
|
+
this.$('#g-s3-import-dest-id').val(`${val.id} (${result})`);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
this.assetstore = settings.assetstore;
|
|
65
|
+
this.render();
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
render: function () {
|
|
69
|
+
this.$el.html(S3ImportTemplate({
|
|
70
|
+
assetstore: this.assetstore
|
|
71
|
+
}));
|
|
72
|
+
return this;
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
_openBrowser: function () {
|
|
76
|
+
this._browserWidgetView.setElement($('#g-dialog-container')).render();
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
export default S3ImportView;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import _ from 'underscore';
|
|
2
|
+
|
|
3
|
+
import View from '@girder/core/views/View';
|
|
4
|
+
import { restRequest } from '@girder/core/rest';
|
|
5
|
+
import SearchPaginateWidget from '@girder/core/views/widgets/SearchPaginateWidget';
|
|
6
|
+
import SearchFieldWidget from '@girder/core/views/widgets/SearchFieldWidget';
|
|
7
|
+
|
|
8
|
+
import SearchResultsTemplate from '@girder/core/templates/body/searchResults.pug';
|
|
9
|
+
import SearchResultsTypeTemplate from '@girder/core/templates/body/searchResultsType.pug';
|
|
10
|
+
import '@girder/core/stylesheets/body/searchResultsList.styl';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* This view display all the search results by instantiating a subview
|
|
14
|
+
* per each type found.
|
|
15
|
+
*/
|
|
16
|
+
var SearchResultsView = View.extend({
|
|
17
|
+
initialize: function (settings) {
|
|
18
|
+
this._query = settings.query || '';
|
|
19
|
+
this._mode = settings.mode || 'text';
|
|
20
|
+
|
|
21
|
+
this._sizeOneElement = 28;
|
|
22
|
+
this.pageLimit = 10;
|
|
23
|
+
|
|
24
|
+
this._request = restRequest({
|
|
25
|
+
url: 'resource/search',
|
|
26
|
+
data: {
|
|
27
|
+
q: this._query,
|
|
28
|
+
mode: this._mode,
|
|
29
|
+
types: JSON.stringify(SearchFieldWidget.getModeTypes(this._mode)),
|
|
30
|
+
limit: this.pageLimit
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
this.render();
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Return a consistent and semantically-meaningful type ordering.
|
|
38
|
+
*/
|
|
39
|
+
_getTypeOrdering: function (resultTypes) {
|
|
40
|
+
// This ordering places hopefully-more relevant types first
|
|
41
|
+
const builtinOrdering = ['collection', 'folder', 'item', 'group', 'user'];
|
|
42
|
+
|
|
43
|
+
// _.intersection will use the ordering of its first argument
|
|
44
|
+
const orderedKnownTypes = _.intersection(builtinOrdering, resultTypes);
|
|
45
|
+
const orderedUnknownTypes = _.difference(resultTypes, builtinOrdering).sort();
|
|
46
|
+
|
|
47
|
+
return orderedKnownTypes.concat(orderedUnknownTypes);
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
render: function () {
|
|
51
|
+
this.$el.html(SearchResultsTemplate({
|
|
52
|
+
query: this._query
|
|
53
|
+
}));
|
|
54
|
+
this._subviews = {};
|
|
55
|
+
|
|
56
|
+
this._request
|
|
57
|
+
.done((results) => {
|
|
58
|
+
this.$('.g-search-pending').hide();
|
|
59
|
+
|
|
60
|
+
const resultTypes = _.keys(results);
|
|
61
|
+
const orderedTypes = this._getTypeOrdering(resultTypes);
|
|
62
|
+
_.each(orderedTypes, (type) => {
|
|
63
|
+
if (results[type].length) {
|
|
64
|
+
this._subviews[type] = new SearchResultsTypeView({
|
|
65
|
+
parentView: this,
|
|
66
|
+
query: this._query,
|
|
67
|
+
mode: this._mode,
|
|
68
|
+
type: type,
|
|
69
|
+
limit: this.pageLimit,
|
|
70
|
+
initResults: results[type],
|
|
71
|
+
sizeOneElement: this._sizeOneElement
|
|
72
|
+
})
|
|
73
|
+
.render();
|
|
74
|
+
this._subviews[type].$el
|
|
75
|
+
.appendTo(this.$('.g-search-results-container'));
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
if (_.isEmpty(this._subviews)) {
|
|
80
|
+
this.$('.g-search-no-results').show();
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
return this;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* This subview display all the search results for one type.
|
|
90
|
+
* It also contain a pagination widget that provide a consistent widget
|
|
91
|
+
* for iterating amongst pages of a list of search results.
|
|
92
|
+
*/
|
|
93
|
+
var SearchResultsTypeView = View.extend({
|
|
94
|
+
className: 'g-search-results-type-container',
|
|
95
|
+
|
|
96
|
+
initialize: function (settings) {
|
|
97
|
+
this._query = settings.query;
|
|
98
|
+
this._mode = settings.mode;
|
|
99
|
+
this._type = settings.type;
|
|
100
|
+
this._initResults = settings.initResults || [];
|
|
101
|
+
this._pageLimit = settings.limit || 10;
|
|
102
|
+
this._sizeOneElement = settings.sizeOneElement || 30;
|
|
103
|
+
|
|
104
|
+
this._paginateWidget = new SearchPaginateWidget({
|
|
105
|
+
parentView: this,
|
|
106
|
+
type: this._type,
|
|
107
|
+
query: this._query,
|
|
108
|
+
mode: this._mode,
|
|
109
|
+
limit: this._pageLimit
|
|
110
|
+
})
|
|
111
|
+
.on('g:changed', () => {
|
|
112
|
+
this._results = this._paginateWidget.results;
|
|
113
|
+
this.render();
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
this._results = this._initResults;
|
|
117
|
+
},
|
|
118
|
+
|
|
119
|
+
_getTypeName: function (type) {
|
|
120
|
+
const names = {
|
|
121
|
+
collection: 'Collections',
|
|
122
|
+
group: 'Groups',
|
|
123
|
+
user: 'Users',
|
|
124
|
+
folder: 'Folders',
|
|
125
|
+
item: 'Items'
|
|
126
|
+
};
|
|
127
|
+
return names[type] || type;
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
_getTypeIcon: function (type) {
|
|
131
|
+
const icons = {
|
|
132
|
+
user: 'user',
|
|
133
|
+
group: 'users',
|
|
134
|
+
collection: 'sitemap',
|
|
135
|
+
folder: 'folder',
|
|
136
|
+
item: 'doc-text-inv'
|
|
137
|
+
};
|
|
138
|
+
return icons[type] || 'icon-attention-alt';
|
|
139
|
+
},
|
|
140
|
+
|
|
141
|
+
render: function () {
|
|
142
|
+
this.$el.html(SearchResultsTypeTemplate({
|
|
143
|
+
results: this._results,
|
|
144
|
+
collectionName: this._getTypeName(this._type),
|
|
145
|
+
type: this._type,
|
|
146
|
+
icon: this._getTypeIcon(this._type)
|
|
147
|
+
}));
|
|
148
|
+
|
|
149
|
+
/* This size of the results list cannot be known until after the fetch completes. And we don't want to set
|
|
150
|
+
the 'min-height' to the max results size, because we'd frequently have lots of whitespace for short result
|
|
151
|
+
lists. Do not try to move that set in stylesheet.
|
|
152
|
+
*/
|
|
153
|
+
this.$('.g-search-results-type').css('min-height', `${this._initResults.length * this._sizeOneElement}px`);
|
|
154
|
+
this._paginateWidget
|
|
155
|
+
.setElement(this.$(`#${this._type}Paginate`))
|
|
156
|
+
.render();
|
|
157
|
+
|
|
158
|
+
return this;
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
export default SearchResultsView;
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import _ from 'underscore';
|
|
2
|
+
|
|
3
|
+
import AccessWidget from '@girder/core/views/widgets/AccessWidget';
|
|
4
|
+
import View from '@girder/core/views/View';
|
|
5
|
+
import events from '@girder/core/events';
|
|
6
|
+
import { restRequest, cancelRestRequests } from '@girder/core/rest';
|
|
7
|
+
import CollectionCreationPolicyModel from '@girder/core/models/CollectionCreationPolicyModel';
|
|
8
|
+
|
|
9
|
+
import SystemConfigurationTemplate from '@girder/core/templates/body/systemConfiguration.pug';
|
|
10
|
+
|
|
11
|
+
import '@girder/core/stylesheets/body/systemConfig.styl';
|
|
12
|
+
|
|
13
|
+
import 'bootstrap/js/collapse';
|
|
14
|
+
import 'bootstrap/js/transition';
|
|
15
|
+
import 'bootstrap-switch'; // /dist/js/bootstrap-switch.js',
|
|
16
|
+
import 'bootstrap-switch/dist/css/bootstrap3/bootstrap-switch.css';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The system config page for administrators.
|
|
20
|
+
*/
|
|
21
|
+
var SystemConfigurationView = View.extend({
|
|
22
|
+
events: {
|
|
23
|
+
'submit .g-settings-form': function (event) {
|
|
24
|
+
event.preventDefault();
|
|
25
|
+
this.$('.g-submit-settings').girderEnable(false);
|
|
26
|
+
this.$('#g-settings-error-message').empty();
|
|
27
|
+
|
|
28
|
+
this.$('#g-core-collection-create-policy').val(JSON.stringify(this._covertCollectionCreationPolicy()));
|
|
29
|
+
var settings = _.map(this.settingsKeys, (key) => {
|
|
30
|
+
const element = this.$('#g-' + key.replace(/[_.]/g, '-'));
|
|
31
|
+
|
|
32
|
+
if (_.contains(
|
|
33
|
+
[
|
|
34
|
+
'core.api_keys',
|
|
35
|
+
'core.enable_password_login',
|
|
36
|
+
'core.enable_notification_stream'
|
|
37
|
+
],
|
|
38
|
+
key
|
|
39
|
+
)) { // booleans via checkboxes
|
|
40
|
+
return {
|
|
41
|
+
key,
|
|
42
|
+
value: element.is(':checked')
|
|
43
|
+
};
|
|
44
|
+
} else { // all other settings use $.fn.val()
|
|
45
|
+
return {
|
|
46
|
+
key,
|
|
47
|
+
value: element.val() || null
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
restRequest({
|
|
53
|
+
method: 'PUT',
|
|
54
|
+
url: 'system/setting',
|
|
55
|
+
data: {
|
|
56
|
+
list: JSON.stringify(settings)
|
|
57
|
+
},
|
|
58
|
+
error: null
|
|
59
|
+
}).done(() => {
|
|
60
|
+
this.$('.g-submit-settings').girderEnable(true);
|
|
61
|
+
events.trigger('g:alert', {
|
|
62
|
+
icon: 'ok',
|
|
63
|
+
text: 'Settings saved.',
|
|
64
|
+
type: 'success',
|
|
65
|
+
timeout: 4000
|
|
66
|
+
});
|
|
67
|
+
}).fail((resp) => {
|
|
68
|
+
this.$('.g-submit-settings').girderEnable(true);
|
|
69
|
+
this.$('#g-settings-error-message').text(resp.responseJSON.message);
|
|
70
|
+
});
|
|
71
|
+
},
|
|
72
|
+
'click #g-core-banner-default-color': function () {
|
|
73
|
+
this.$('#g-core-banner-color').val(this.defaults['core.banner_color']);
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
initialize: function () {
|
|
78
|
+
cancelRestRequests('fetch');
|
|
79
|
+
|
|
80
|
+
var keys = [
|
|
81
|
+
'core.api_keys',
|
|
82
|
+
'core.contact_email_address',
|
|
83
|
+
'core.brand_name',
|
|
84
|
+
'core.banner_color',
|
|
85
|
+
'core.privacy_notice',
|
|
86
|
+
'core.cookie_lifetime',
|
|
87
|
+
'core.enable_password_login',
|
|
88
|
+
'core.email_from_address',
|
|
89
|
+
'core.email_host',
|
|
90
|
+
'core.registration_policy',
|
|
91
|
+
'core.email_verification',
|
|
92
|
+
'core.server_root',
|
|
93
|
+
'core.smtp_host',
|
|
94
|
+
'core.smtp.port',
|
|
95
|
+
'core.smtp.encryption',
|
|
96
|
+
'core.smtp.username',
|
|
97
|
+
'core.smtp.password',
|
|
98
|
+
'core.upload_minimum_chunk_size',
|
|
99
|
+
'core.enable_notification_stream',
|
|
100
|
+
'core.cors.allow_origin',
|
|
101
|
+
'core.cors.allow_methods',
|
|
102
|
+
'core.cors.allow_headers',
|
|
103
|
+
'core.add_to_group_policy',
|
|
104
|
+
'core.collection_create_policy',
|
|
105
|
+
'core.user_default_folders',
|
|
106
|
+
];
|
|
107
|
+
this.settingsKeys = keys;
|
|
108
|
+
restRequest({
|
|
109
|
+
url: 'system/setting',
|
|
110
|
+
method: 'GET',
|
|
111
|
+
data: {
|
|
112
|
+
list: JSON.stringify(keys)
|
|
113
|
+
}
|
|
114
|
+
}).done((resp) => {
|
|
115
|
+
this.settings = resp;
|
|
116
|
+
this.render();
|
|
117
|
+
});
|
|
118
|
+
},
|
|
119
|
+
|
|
120
|
+
render: function () {
|
|
121
|
+
this.$el.html(SystemConfigurationTemplate({
|
|
122
|
+
settings: this.settings,
|
|
123
|
+
JSON: window.JSON
|
|
124
|
+
}));
|
|
125
|
+
|
|
126
|
+
var enableCollectionCreationPolicy = this.settings['core.collection_create_policy'] ? this.settings['core.collection_create_policy'].open : false;
|
|
127
|
+
|
|
128
|
+
this.$('.g-setting-switch')
|
|
129
|
+
.bootstrapSwitch()
|
|
130
|
+
.bootstrapSwitch('state', enableCollectionCreationPolicy)
|
|
131
|
+
.off('switchChange.bootstrapSwitch')
|
|
132
|
+
.on('switchChange.bootstrapSwitch', (event, state) => {
|
|
133
|
+
if (state) {
|
|
134
|
+
this._renderCollectionCreationPolicyAccessWidget();
|
|
135
|
+
} else {
|
|
136
|
+
this.accessWidget.destroy();
|
|
137
|
+
this.accessWidget = null;
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
if (enableCollectionCreationPolicy) {
|
|
142
|
+
this._renderCollectionCreationPolicyAccessWidget();
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return this;
|
|
146
|
+
},
|
|
147
|
+
|
|
148
|
+
_renderCollectionCreationPolicyAccessWidget: function () {
|
|
149
|
+
var collectionCreationPolicyModel = new CollectionCreationPolicyModel();
|
|
150
|
+
|
|
151
|
+
this.accessWidget = new AccessWidget({
|
|
152
|
+
el: this.$('.g-collection-create-policy-container .access-widget-container'),
|
|
153
|
+
modelType: 'collection_creation_policy',
|
|
154
|
+
model: collectionCreationPolicyModel,
|
|
155
|
+
parentView: this,
|
|
156
|
+
modal: false,
|
|
157
|
+
hideRecurseOption: true,
|
|
158
|
+
hideSaveButton: true,
|
|
159
|
+
hidePrivacyEditor: true,
|
|
160
|
+
hideAccessType: true,
|
|
161
|
+
noAccessFlag: true
|
|
162
|
+
});
|
|
163
|
+
},
|
|
164
|
+
|
|
165
|
+
_covertCollectionCreationPolicy: function () {
|
|
166
|
+
// get collection creation policy from AccessWidget and format the result properly
|
|
167
|
+
var settingValue = null;
|
|
168
|
+
if (this.$('.g-setting-switch').bootstrapSwitch('state')) {
|
|
169
|
+
settingValue = { open: this.$('.g-setting-switch').bootstrapSwitch('state') };
|
|
170
|
+
var accessList = this.accessWidget.getAccessList();
|
|
171
|
+
_.each(_.keys(accessList), (key) => {
|
|
172
|
+
settingValue[key] = _.pluck(accessList[key], 'id');
|
|
173
|
+
});
|
|
174
|
+
} else {
|
|
175
|
+
settingValue = this.settings['core.collection_create_policy'];
|
|
176
|
+
settingValue.open = false;
|
|
177
|
+
}
|
|
178
|
+
return settingValue;
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
export default SystemConfigurationView;
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import $ from 'jquery';
|
|
2
|
+
import _ from 'underscore';
|
|
3
|
+
|
|
4
|
+
import ApiKeyListWidget from '@girder/core/views/widgets/ApiKeyListWidget';
|
|
5
|
+
import UserOtpManagementWidget from '@girder/core/views/widgets/UserOtpManagementWidget';
|
|
6
|
+
import router from '@girder/core/router';
|
|
7
|
+
import UserModel from '@girder/core/models/UserModel';
|
|
8
|
+
import View from '@girder/core/views/View';
|
|
9
|
+
import { AccessType } from '@girder/core/constants';
|
|
10
|
+
import events from '@girder/core/events';
|
|
11
|
+
import { getCurrentUser } from '@girder/core/auth';
|
|
12
|
+
import { cancelRestRequests } from '@girder/core/rest';
|
|
13
|
+
|
|
14
|
+
import UserAccountTemplate from '@girder/core/templates/body/userAccount.pug';
|
|
15
|
+
|
|
16
|
+
import '@girder/core/stylesheets/body/userAccount.styl';
|
|
17
|
+
|
|
18
|
+
import 'bootstrap/js/tab';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* This is the view for the user account (profile) page.
|
|
22
|
+
*/
|
|
23
|
+
var UserAccountView = View.extend({
|
|
24
|
+
events: {
|
|
25
|
+
'submit #g-user-info-form': function (event) {
|
|
26
|
+
event.preventDefault();
|
|
27
|
+
this.$('#g-user-info-error-msg').empty();
|
|
28
|
+
|
|
29
|
+
var params = {
|
|
30
|
+
email: this.$('#g-email').val(),
|
|
31
|
+
firstName: this.$('#g-firstName').val(),
|
|
32
|
+
lastName: this.$('#g-lastName').val()
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
if (this.$('#g-admin').length > 0) {
|
|
36
|
+
params.admin = this.$('#g-admin').is(':checked');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
this.user.set(params);
|
|
40
|
+
|
|
41
|
+
this.user.off('g:error').on('g:error', function (err) {
|
|
42
|
+
var msg = err.responseJSON.message;
|
|
43
|
+
this.$('#g-' + err.responseJSON.field).trigger('focus');
|
|
44
|
+
this.$('#g-user-info-error-msg').text(msg);
|
|
45
|
+
}, this).off('g:saved')
|
|
46
|
+
.on('g:saved', function () {
|
|
47
|
+
events.trigger('g:alert', {
|
|
48
|
+
icon: 'ok',
|
|
49
|
+
text: 'Info saved.',
|
|
50
|
+
type: 'success',
|
|
51
|
+
timeout: 4000
|
|
52
|
+
});
|
|
53
|
+
}, this).save();
|
|
54
|
+
},
|
|
55
|
+
'submit #g-password-change-form': function (event) {
|
|
56
|
+
event.preventDefault();
|
|
57
|
+
this.$('#g-password-change-error-msg').empty();
|
|
58
|
+
|
|
59
|
+
if (this.$('#g-password-new').val() !==
|
|
60
|
+
this.$('#g-password-retype').val()) {
|
|
61
|
+
this.$('#g-password-change-error-msg').text(
|
|
62
|
+
'Passwords do not match, try again.'
|
|
63
|
+
);
|
|
64
|
+
this.$('#g-password-retype,#g-password-new').val('');
|
|
65
|
+
this.$('#g-password-new').trigger('focus');
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
this.user.off('g:error').on('g:error', function (err) {
|
|
70
|
+
var msg = err.responseJSON.message;
|
|
71
|
+
this.$('#g-password-change-error-msg').text(msg);
|
|
72
|
+
}, this).off('g:passwordChanged')
|
|
73
|
+
.on('g:passwordChanged', function () {
|
|
74
|
+
events.trigger('g:alert', {
|
|
75
|
+
icon: 'ok',
|
|
76
|
+
text: 'Password changed.',
|
|
77
|
+
type: 'success',
|
|
78
|
+
timeout: 4000
|
|
79
|
+
});
|
|
80
|
+
this.$('#g-password-old,#g-password-new,#g-password-retype').val('');
|
|
81
|
+
}, this);
|
|
82
|
+
|
|
83
|
+
// here and in the template, an admin user who wants to change their
|
|
84
|
+
// own password is intentionally forced to re-enter their old
|
|
85
|
+
// password
|
|
86
|
+
if (this.isCurrentUser) {
|
|
87
|
+
this.user.changePassword(
|
|
88
|
+
this.$('#g-password-old').val(),
|
|
89
|
+
this.$('#g-password-new').val()
|
|
90
|
+
);
|
|
91
|
+
} else {
|
|
92
|
+
this.user.adminChangePassword(this.$('#g-password-new').val());
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
initialize: function (settings) {
|
|
98
|
+
this.tab = settings.tab || 'info';
|
|
99
|
+
this.user = settings.user || getCurrentUser();
|
|
100
|
+
this.isCurrentUser = getCurrentUser() &&
|
|
101
|
+
settings.user.id === getCurrentUser().id;
|
|
102
|
+
|
|
103
|
+
this.model = this.user;
|
|
104
|
+
this.temporary = settings.temporary;
|
|
105
|
+
|
|
106
|
+
if (!this.user || this.user.getAccessLevel() < AccessType.WRITE) {
|
|
107
|
+
router.navigate('', { trigger: true });
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
cancelRestRequests('fetch');
|
|
112
|
+
|
|
113
|
+
this.apiKeyListWidget = new ApiKeyListWidget({
|
|
114
|
+
user: this.user,
|
|
115
|
+
parentView: this
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
this.userOtpManagementWidget = new UserOtpManagementWidget({
|
|
119
|
+
user: this.user,
|
|
120
|
+
parentView: this
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
this.render();
|
|
124
|
+
},
|
|
125
|
+
|
|
126
|
+
render: function () {
|
|
127
|
+
if (getCurrentUser() === null) {
|
|
128
|
+
router.navigate('', { trigger: true });
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
this.$el.html(UserAccountTemplate({
|
|
133
|
+
user: this.model,
|
|
134
|
+
isCurrentUser: this.isCurrentUser,
|
|
135
|
+
getCurrentUser: getCurrentUser,
|
|
136
|
+
temporaryToken: this.temporary
|
|
137
|
+
}));
|
|
138
|
+
|
|
139
|
+
_.each($('.g-account-tabs>li>a'), function (el) {
|
|
140
|
+
var tabLink = $(el);
|
|
141
|
+
tabLink.tab().on('shown.bs.tab', (e) => {
|
|
142
|
+
this.tab = $(e.currentTarget).attr('name');
|
|
143
|
+
router.navigate('useraccount/' + this.model.id + '/' + this.tab);
|
|
144
|
+
|
|
145
|
+
if (this.tab === 'apikeys') {
|
|
146
|
+
this.apiKeyListWidget.setElement(
|
|
147
|
+
this.$('.g-api-keys-list-container')).render();
|
|
148
|
+
} else if (this.tab === 'otp') {
|
|
149
|
+
this.userOtpManagementWidget
|
|
150
|
+
.setElement(this.$('.g-account-otp-container'))
|
|
151
|
+
.render();
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
if (tabLink.attr('name') === this.tab) {
|
|
156
|
+
tabLink.tab('show');
|
|
157
|
+
}
|
|
158
|
+
}, this);
|
|
159
|
+
|
|
160
|
+
return this;
|
|
161
|
+
}
|
|
162
|
+
}, {
|
|
163
|
+
/**
|
|
164
|
+
* Helper function for fetching the user by id, then render the view.
|
|
165
|
+
*/
|
|
166
|
+
fetchAndInit: function (id, tab) {
|
|
167
|
+
var user = new UserModel();
|
|
168
|
+
user.set({ _id: id }).on('g:fetched', function () {
|
|
169
|
+
events.trigger('g:navigateTo', UserAccountView, {
|
|
170
|
+
user: user,
|
|
171
|
+
tab: tab
|
|
172
|
+
});
|
|
173
|
+
}, this).on('g:error', function () {
|
|
174
|
+
router.navigate('', { trigger: true });
|
|
175
|
+
}, this).fetch();
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
export default UserAccountView;
|