@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,165 @@
|
|
|
1
|
+
import _ from 'underscore';
|
|
2
|
+
|
|
3
|
+
import FolderModel from '@girder/core/models/FolderModel';
|
|
4
|
+
import HierarchyWidget from '@girder/core/views/widgets/HierarchyWidget';
|
|
5
|
+
import router from '@girder/core/router';
|
|
6
|
+
import UserModel from '@girder/core/models/UserModel';
|
|
7
|
+
import UsersView from '@girder/core/views/body/UsersView';
|
|
8
|
+
import View from '@girder/core/views/View';
|
|
9
|
+
import { AccessType } from '@girder/core/constants';
|
|
10
|
+
import { cancelRestRequests } from '@girder/core/rest';
|
|
11
|
+
import { confirm } from '@girder/core/dialog';
|
|
12
|
+
import events from '@girder/core/events';
|
|
13
|
+
|
|
14
|
+
import UserPageTemplate from '@girder/core/templates/body/userPage.pug';
|
|
15
|
+
|
|
16
|
+
import '@girder/core/stylesheets/body/userPage.styl';
|
|
17
|
+
|
|
18
|
+
import 'bootstrap/js/dropdown';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* This view shows a single user's page.
|
|
22
|
+
*/
|
|
23
|
+
var UserView = View.extend({
|
|
24
|
+
events: {
|
|
25
|
+
'click a.g-edit-user': function () {
|
|
26
|
+
var editUrl = 'useraccount/' + this.model.get('_id') + '/info';
|
|
27
|
+
router.navigate(editUrl, { trigger: true });
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
'click a.g-delete-user': function () {
|
|
31
|
+
confirm({
|
|
32
|
+
text: 'Are you sure you want to delete the user <b>' +
|
|
33
|
+
this.model.escape('login') + '</b>?',
|
|
34
|
+
yesText: 'Delete',
|
|
35
|
+
escapedHtml: true,
|
|
36
|
+
confirmCallback: () => {
|
|
37
|
+
this.model.on('g:deleted', function () {
|
|
38
|
+
router.navigate('', { trigger: true });
|
|
39
|
+
}).destroy();
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
'click a.g-approve-user': function () {
|
|
45
|
+
this._setAndSave(
|
|
46
|
+
{ status: 'enabled' }, 'Approved user account.');
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
'click a.g-disable-user': function () {
|
|
50
|
+
this._setAndSave(
|
|
51
|
+
{ status: 'disabled' }, 'Disabled user account.');
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
'click a.g-enable-user': function () {
|
|
55
|
+
this._setAndSave(
|
|
56
|
+
{ status: 'enabled' }, 'Enabled user account.');
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
initialize: function (settings) {
|
|
61
|
+
cancelRestRequests('fetch');
|
|
62
|
+
this.folderId = settings.folderId || null;
|
|
63
|
+
this.upload = settings.upload || false;
|
|
64
|
+
this.folderAccess = settings.folderAccess || false;
|
|
65
|
+
this.folderCreate = settings.folderCreate || false;
|
|
66
|
+
this.folderEdit = settings.folderEdit || false;
|
|
67
|
+
this.itemCreate = settings.itemCreate || false;
|
|
68
|
+
|
|
69
|
+
if (settings.user) {
|
|
70
|
+
this.model = settings.user;
|
|
71
|
+
|
|
72
|
+
if (settings.folderId) {
|
|
73
|
+
this.folder = new FolderModel();
|
|
74
|
+
this.folder.set({
|
|
75
|
+
_id: settings.folderId
|
|
76
|
+
}).on('g:fetched', function () {
|
|
77
|
+
this.render();
|
|
78
|
+
}, this).on('g:error', function () {
|
|
79
|
+
this.folder = null;
|
|
80
|
+
this.render();
|
|
81
|
+
}, this).fetch();
|
|
82
|
+
} else {
|
|
83
|
+
this.render();
|
|
84
|
+
}
|
|
85
|
+
} else if (settings.id) {
|
|
86
|
+
this.model = new UserModel();
|
|
87
|
+
this.model.set('_id', settings.id);
|
|
88
|
+
|
|
89
|
+
this.model.on('g:fetched', function () {
|
|
90
|
+
this.render();
|
|
91
|
+
}, this).fetch();
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
render: function () {
|
|
96
|
+
this.$el.html(UserPageTemplate({
|
|
97
|
+
user: this.model,
|
|
98
|
+
AccessType: AccessType
|
|
99
|
+
}));
|
|
100
|
+
|
|
101
|
+
if (!this.hierarchyWidget) {
|
|
102
|
+
// The HierarchyWidget will self-render when instantiated
|
|
103
|
+
this.hierarchyWidget = new HierarchyWidget({
|
|
104
|
+
el: this.$('.g-user-hierarchy-container'),
|
|
105
|
+
parentModel: this.folder || this.model,
|
|
106
|
+
upload: this.upload,
|
|
107
|
+
folderAccess: this.folderAccess,
|
|
108
|
+
folderEdit: this.folderEdit,
|
|
109
|
+
folderCreate: this.folderCreate,
|
|
110
|
+
itemCreate: this.itemCreate,
|
|
111
|
+
parentView: this
|
|
112
|
+
});
|
|
113
|
+
} else {
|
|
114
|
+
this.hierarchyWidget
|
|
115
|
+
.setElement(this.$('.g-user-hierarchy-container'))
|
|
116
|
+
.render();
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
this.upload = false;
|
|
120
|
+
this.folderAccess = false;
|
|
121
|
+
this.folderEdit = false;
|
|
122
|
+
this.folderCreate = false;
|
|
123
|
+
this.itemCreate = false;
|
|
124
|
+
|
|
125
|
+
return this;
|
|
126
|
+
},
|
|
127
|
+
|
|
128
|
+
_setAndSave: function (data, message) {
|
|
129
|
+
this.model.set(data);
|
|
130
|
+
this.model.off('g:saved').on('g:saved', function () {
|
|
131
|
+
events.trigger('g:alert', {
|
|
132
|
+
icon: 'ok',
|
|
133
|
+
text: message,
|
|
134
|
+
type: 'success',
|
|
135
|
+
timeout: 4000
|
|
136
|
+
});
|
|
137
|
+
this.render();
|
|
138
|
+
}, this).off('g:error').on('g:error', function (err) {
|
|
139
|
+
events.trigger('g:alert', {
|
|
140
|
+
icon: 'cancel',
|
|
141
|
+
text: err.responseJSON.message,
|
|
142
|
+
type: 'danger'
|
|
143
|
+
});
|
|
144
|
+
}).save();
|
|
145
|
+
}
|
|
146
|
+
}, {
|
|
147
|
+
/**
|
|
148
|
+
* Helper function for fetching the user and rendering the view with
|
|
149
|
+
* an arbitrary set of extra parameters.
|
|
150
|
+
*/
|
|
151
|
+
fetchAndInit: function (userId, params) {
|
|
152
|
+
var user = new UserModel();
|
|
153
|
+
user.set({
|
|
154
|
+
_id: userId
|
|
155
|
+
}).on('g:fetched', function () {
|
|
156
|
+
events.trigger('g:navigateTo', UserView, _.extend({
|
|
157
|
+
user: user
|
|
158
|
+
}, params || {}));
|
|
159
|
+
}, this).on('g:error', function () {
|
|
160
|
+
events.trigger('g:navigateTo', UsersView);
|
|
161
|
+
}, this).fetch();
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
export default UserView;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import $ from 'jquery';
|
|
2
|
+
|
|
3
|
+
import PaginateWidget from '@girder/core/views/widgets/PaginateWidget';
|
|
4
|
+
import RegisterView from '@girder/core/views/layout/RegisterView';
|
|
5
|
+
import router from '@girder/core/router';
|
|
6
|
+
import SearchFieldWidget from '@girder/core/views/widgets/SearchFieldWidget';
|
|
7
|
+
import SortCollectionWidget from '@girder/core/views/widgets/SortCollectionWidget';
|
|
8
|
+
import UserCollection from '@girder/core/collections/UserCollection';
|
|
9
|
+
import UserModel from '@girder/core/models/UserModel';
|
|
10
|
+
import View from '@girder/core/views/View';
|
|
11
|
+
import { cancelRestRequests } from '@girder/core/rest';
|
|
12
|
+
import { formatDate, formatSize, DATE_DAY } from '@girder/core/misc';
|
|
13
|
+
import { getCurrentUser } from '@girder/core/auth';
|
|
14
|
+
|
|
15
|
+
import UserListTemplate from '@girder/core/templates/body/userList.pug';
|
|
16
|
+
|
|
17
|
+
import '@girder/core/stylesheets/body/userList.styl';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* This view lists users.
|
|
21
|
+
*/
|
|
22
|
+
var UsersView = View.extend({
|
|
23
|
+
events: {
|
|
24
|
+
'click a.g-user-link': function (event) {
|
|
25
|
+
var cid = $(event.currentTarget).attr('g-user-cid');
|
|
26
|
+
router.navigate('user/' + this.collection.get(cid).id, { trigger: true });
|
|
27
|
+
},
|
|
28
|
+
'click button.g-user-create-button': 'createUserDialog',
|
|
29
|
+
'submit .g-user-search-form': function (event) {
|
|
30
|
+
event.preventDefault();
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
initialize: function (settings) {
|
|
35
|
+
cancelRestRequests('fetch');
|
|
36
|
+
this.collection = new UserCollection();
|
|
37
|
+
|
|
38
|
+
const promiseArray = [];
|
|
39
|
+
promiseArray.push(this.collection.fetch());
|
|
40
|
+
|
|
41
|
+
this.paginateWidget = new PaginateWidget({
|
|
42
|
+
collection: this.collection,
|
|
43
|
+
parentView: this
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
this.sortCollectionWidget = new SortCollectionWidget({
|
|
47
|
+
collection: this.collection,
|
|
48
|
+
parentView: this,
|
|
49
|
+
fields: {
|
|
50
|
+
lastName: 'Last Name',
|
|
51
|
+
created: 'Creation Date',
|
|
52
|
+
size: 'Used Space'
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
this.searchWidget = new SearchFieldWidget({
|
|
57
|
+
placeholder: 'Search users...',
|
|
58
|
+
types: ['user'],
|
|
59
|
+
modes: 'prefix',
|
|
60
|
+
parentView: this
|
|
61
|
+
}).on('g:resultClicked', this._gotoUser, this);
|
|
62
|
+
|
|
63
|
+
if (getCurrentUser()) {
|
|
64
|
+
const userCountPromise = UserCollection.getTotalCount()
|
|
65
|
+
.done((count) => {
|
|
66
|
+
this.usersCount = count;
|
|
67
|
+
});
|
|
68
|
+
promiseArray.push(userCountPromise);
|
|
69
|
+
}
|
|
70
|
+
this.register = settings.dialog === 'register' && getCurrentUser() &&
|
|
71
|
+
getCurrentUser().get('admin');
|
|
72
|
+
|
|
73
|
+
$.when(...promiseArray)
|
|
74
|
+
.done(() => {
|
|
75
|
+
this.listenTo(this.collection, 'g:changed', this.render);
|
|
76
|
+
this.render();
|
|
77
|
+
});
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
render: function () {
|
|
81
|
+
this.$el.html(UserListTemplate({
|
|
82
|
+
users: this.collection.toArray(),
|
|
83
|
+
currentUser: getCurrentUser(),
|
|
84
|
+
usersCount: this.usersCount,
|
|
85
|
+
formatDate: formatDate,
|
|
86
|
+
formatSize: formatSize,
|
|
87
|
+
DATE_DAY: DATE_DAY
|
|
88
|
+
}));
|
|
89
|
+
|
|
90
|
+
this.paginateWidget.setElement(this.$('.g-user-pagination')).render();
|
|
91
|
+
this.sortCollectionWidget.setElement(this.$('.g-user-sort')).render();
|
|
92
|
+
this.searchWidget.setElement(this.$('.g-users-search-container')).render();
|
|
93
|
+
|
|
94
|
+
if (this.register) {
|
|
95
|
+
this.createUserDialog();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return this;
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* When the user clicks a search result user, this helper method
|
|
103
|
+
* will navigate them to the view for that specific user.
|
|
104
|
+
*/
|
|
105
|
+
_gotoUser: function (result) {
|
|
106
|
+
var user = new UserModel();
|
|
107
|
+
user.set('_id', result.id).on('g:fetched', function () {
|
|
108
|
+
router.navigate('user/' + user.get('_id'), { trigger: true });
|
|
109
|
+
}, this).fetch();
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
createUserDialog: function () {
|
|
113
|
+
var container = $('#g-dialog-container');
|
|
114
|
+
|
|
115
|
+
new RegisterView({
|
|
116
|
+
el: container,
|
|
117
|
+
parentView: this
|
|
118
|
+
}).on('g:userCreated', function (info) {
|
|
119
|
+
router.navigate('user/' + info.user.id, { trigger: true });
|
|
120
|
+
}, this).render();
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
export default UsersView;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import AdminView from './AdminView';
|
|
2
|
+
import AssetstoresView from './AssetstoresView';
|
|
3
|
+
import CollectionView from './CollectionView';
|
|
4
|
+
import CollectionsView from './CollectionsView';
|
|
5
|
+
import FilesystemImportView from './FilesystemImportView';
|
|
6
|
+
import FolderView from './FolderView';
|
|
7
|
+
import FrontPageView from './FrontPageView';
|
|
8
|
+
import GroupView from './GroupView';
|
|
9
|
+
import GroupsView from './GroupsView';
|
|
10
|
+
import ItemView from './ItemView';
|
|
11
|
+
import PluginsView from './PluginsView';
|
|
12
|
+
import S3ImportView from './S3ImportView';
|
|
13
|
+
import SearchResultsView from './SearchResultsView';
|
|
14
|
+
import SystemConfigurationView from './SystemConfigurationView';
|
|
15
|
+
import UserAccountView from './UserAccountView';
|
|
16
|
+
import UserView from './UserView';
|
|
17
|
+
import UsersView from './UsersView';
|
|
18
|
+
|
|
19
|
+
export {
|
|
20
|
+
AdminView,
|
|
21
|
+
AssetstoresView,
|
|
22
|
+
CollectionView,
|
|
23
|
+
CollectionsView,
|
|
24
|
+
FilesystemImportView,
|
|
25
|
+
FolderView,
|
|
26
|
+
FrontPageView,
|
|
27
|
+
GroupView,
|
|
28
|
+
GroupsView,
|
|
29
|
+
ItemView,
|
|
30
|
+
PluginsView,
|
|
31
|
+
S3ImportView,
|
|
32
|
+
SearchResultsView,
|
|
33
|
+
SystemConfigurationView,
|
|
34
|
+
UserAccountView,
|
|
35
|
+
UserView,
|
|
36
|
+
UsersView
|
|
37
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import View from '@girder/core/views/View';
|
|
2
|
+
import { getApiRoot } from '@girder/core/rest';
|
|
3
|
+
|
|
4
|
+
import LayoutFooterTemplate from '@girder/core/templates/layout/layoutFooter.pug';
|
|
5
|
+
|
|
6
|
+
import '@girder/core/stylesheets/layout/footer.styl';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* This view shows the footer in the layout.
|
|
10
|
+
*/
|
|
11
|
+
var LayoutFooterView = View.extend({
|
|
12
|
+
|
|
13
|
+
initialize: function (settings) {
|
|
14
|
+
const contactEmail = settings.contactEmail || null;
|
|
15
|
+
this.contactHref = contactEmail !== null ? `mailto:${contactEmail}` : null;
|
|
16
|
+
this.privacyNoticeHref = settings.privacyNoticeHref || null;
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
render: function () {
|
|
20
|
+
this.$el.html(LayoutFooterTemplate({
|
|
21
|
+
apiRoot: getApiRoot(),
|
|
22
|
+
contactHref: this.contactHref,
|
|
23
|
+
privacyNoticeLink: this.privacyNoticeHref
|
|
24
|
+
}));
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export default LayoutFooterView;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import $ from 'jquery';
|
|
2
|
+
import Backbone from 'backbone';
|
|
3
|
+
|
|
4
|
+
import router from '@girder/core/router';
|
|
5
|
+
import View from '@girder/core/views/View';
|
|
6
|
+
import events from '@girder/core/events';
|
|
7
|
+
import { getCurrentUser } from '@girder/core/auth';
|
|
8
|
+
|
|
9
|
+
import LayoutGlobalNavTemplate from '@girder/core/templates/layout/layoutGlobalNav.pug';
|
|
10
|
+
|
|
11
|
+
import '@girder/core/stylesheets/layout/globalNav.styl';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* This view shows a list of global navigation links that should be
|
|
15
|
+
* displayed at all times.
|
|
16
|
+
*/
|
|
17
|
+
var LayoutGlobalNavView = View.extend({
|
|
18
|
+
events: {
|
|
19
|
+
'click .g-nav-link': function (event) {
|
|
20
|
+
event.preventDefault(); // so we can keep the href
|
|
21
|
+
|
|
22
|
+
var link = $(event.currentTarget);
|
|
23
|
+
|
|
24
|
+
router.navigate(link.attr('g-target'), { trigger: true });
|
|
25
|
+
|
|
26
|
+
// Must call this after calling navigateTo, since that
|
|
27
|
+
// deactivates all global nav links.
|
|
28
|
+
link.parent().addClass('g-active');
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
initialize: function (settings) {
|
|
33
|
+
events.on('g:highlightItem', this.selectForView, this);
|
|
34
|
+
events.on('g:login', this.render, this);
|
|
35
|
+
events.on('g:logout', this.render, this);
|
|
36
|
+
events.on('g:login-changed', this.render, this);
|
|
37
|
+
|
|
38
|
+
settings = settings || {};
|
|
39
|
+
if (settings.navItems) {
|
|
40
|
+
this.navItems = settings.navItems;
|
|
41
|
+
} else {
|
|
42
|
+
this.defaultNavItems = [{
|
|
43
|
+
name: 'Collections',
|
|
44
|
+
icon: 'icon-sitemap',
|
|
45
|
+
target: 'collections'
|
|
46
|
+
}, {
|
|
47
|
+
name: 'Groups',
|
|
48
|
+
icon: 'icon-users',
|
|
49
|
+
target: 'groups'
|
|
50
|
+
}];
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
render: function () {
|
|
55
|
+
var navItems;
|
|
56
|
+
if (this.navItems) {
|
|
57
|
+
navItems = this.navItems;
|
|
58
|
+
} else {
|
|
59
|
+
navItems = this.defaultNavItems;
|
|
60
|
+
if (getCurrentUser()) {
|
|
61
|
+
// copy navItems so that this.defaultNavItems is unchanged
|
|
62
|
+
navItems = navItems.slice();
|
|
63
|
+
navItems.push({
|
|
64
|
+
name: 'Users',
|
|
65
|
+
icon: 'icon-user',
|
|
66
|
+
target: 'users'
|
|
67
|
+
});
|
|
68
|
+
if (getCurrentUser().get('admin')) {
|
|
69
|
+
navItems.push({
|
|
70
|
+
name: 'Admin console',
|
|
71
|
+
icon: 'icon-wrench',
|
|
72
|
+
target: 'admin'
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
this.$el.html(LayoutGlobalNavTemplate({
|
|
78
|
+
navItems: navItems
|
|
79
|
+
}));
|
|
80
|
+
|
|
81
|
+
if (Backbone.history.fragment) {
|
|
82
|
+
this.$('[g-target="' + Backbone.history.fragment + '"]')
|
|
83
|
+
.parent().addClass('g-active');
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return this;
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Highlight the item with the given target attribute, which is the name
|
|
91
|
+
* of the view it navigates to.
|
|
92
|
+
*/
|
|
93
|
+
selectForView: function (viewName) {
|
|
94
|
+
this.deactivateAll();
|
|
95
|
+
this.$('[g-name="' + viewName.slice(0, -4) + '"]').parent().addClass('g-active');
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
deactivateAll: function () {
|
|
99
|
+
this.$('.g-global-nav-li').removeClass('g-active');
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
export default LayoutGlobalNavView;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import View from '@girder/core/views/View';
|
|
2
|
+
import events from '@girder/core/events';
|
|
3
|
+
import { logout, getCurrentUser } from '@girder/core/auth';
|
|
4
|
+
|
|
5
|
+
import LayoutHeaderUserTemplate from '@girder/core/templates/layout/layoutHeaderUser.pug';
|
|
6
|
+
|
|
7
|
+
import '@girder/core/stylesheets/layout/headerUser.styl';
|
|
8
|
+
|
|
9
|
+
import 'bootstrap/js/dropdown';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* This view shows the user menu, or register/sign in links if the user is
|
|
13
|
+
* not logged in.
|
|
14
|
+
*/
|
|
15
|
+
var LayoutHeaderUserView = View.extend({
|
|
16
|
+
events: {
|
|
17
|
+
'click a.g-login': function () {
|
|
18
|
+
events.trigger('g:loginUi');
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
'click a.g-register': function () {
|
|
22
|
+
events.trigger('g:registerUi');
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
'click a.g-logout': logout
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
initialize: function (settings) {
|
|
29
|
+
this.registrationPolicy = settings.registrationPolicy;
|
|
30
|
+
|
|
31
|
+
events.on('g:login', this.render, this);
|
|
32
|
+
events.on('g:login-changed', this.render, this);
|
|
33
|
+
events.on('g:logout', this.render, this);
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
render: function () {
|
|
37
|
+
this.$el.html(LayoutHeaderUserTemplate({
|
|
38
|
+
user: getCurrentUser(),
|
|
39
|
+
registrationPolicy: this.registrationPolicy
|
|
40
|
+
}));
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
export default LayoutHeaderUserView;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import _ from 'underscore';
|
|
2
|
+
|
|
3
|
+
import LayoutHeaderUserView from '@girder/core/views/layout/HeaderUserView';
|
|
4
|
+
import router from '@girder/core/router';
|
|
5
|
+
import SearchFieldWidget from '@girder/core/views/widgets/SearchFieldWidget';
|
|
6
|
+
import View from '@girder/core/views/View';
|
|
7
|
+
|
|
8
|
+
import LayoutHeaderTemplate from '@girder/core/templates/layout/layoutHeader.pug';
|
|
9
|
+
|
|
10
|
+
import '@girder/core/stylesheets/layout/header.styl';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* This view shows the header in the layout.
|
|
14
|
+
*/
|
|
15
|
+
var LayoutHeaderView = View.extend({
|
|
16
|
+
events: {
|
|
17
|
+
'click .g-app-title': function () {
|
|
18
|
+
router.navigate('', { trigger: true });
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
initialize: function (settings) {
|
|
23
|
+
this.brandName = settings.brandName || 'Girder';
|
|
24
|
+
this.bannerColor = settings.bannerColor || '#3F3B3B';
|
|
25
|
+
|
|
26
|
+
this.userView = new LayoutHeaderUserView({
|
|
27
|
+
parentView: this,
|
|
28
|
+
registrationPolicy: settings.registrationPolicy
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
/*
|
|
32
|
+
* The order of types correspond to the order of the displayed types results on the dialog box.
|
|
33
|
+
*/
|
|
34
|
+
this.searchWidget = new SearchFieldWidget({
|
|
35
|
+
placeholder: 'Quick search...',
|
|
36
|
+
types: ['collection', 'folder', 'item', 'group', 'user'],
|
|
37
|
+
parentView: this
|
|
38
|
+
}).on('g:resultClicked', function (result) {
|
|
39
|
+
this.searchWidget.resetState();
|
|
40
|
+
router.navigate(result.type + '/' + result.id, {
|
|
41
|
+
trigger: true
|
|
42
|
+
});
|
|
43
|
+
}, this);
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
render: function () {
|
|
47
|
+
var textColor = this._getTextColor(this.bannerColor);
|
|
48
|
+
this.$el.html(LayoutHeaderTemplate({
|
|
49
|
+
brandName: this.brandName,
|
|
50
|
+
bannerColor: this.bannerColor,
|
|
51
|
+
textColor: textColor
|
|
52
|
+
}));
|
|
53
|
+
this.userView.setElement(this.$('.g-current-user-wrapper')).render();
|
|
54
|
+
if (textColor !== '#ffffff') {
|
|
55
|
+
// We will lose the hover color by setting this, so only do that if necessary
|
|
56
|
+
this.userView.$('.g-user-text a').css('color', textColor);
|
|
57
|
+
}
|
|
58
|
+
this.searchWidget.setElement(this.$('.g-quick-search-container')).render();
|
|
59
|
+
|
|
60
|
+
return this;
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
_getTextColor: function (bannerColor) {
|
|
64
|
+
// https://stackoverflow.com/a/3943023
|
|
65
|
+
const hexRed = bannerColor.substr(1, 2);
|
|
66
|
+
const hexGreen = bannerColor.substr(3, 2);
|
|
67
|
+
const hexBlue = bannerColor.substr(5, 2);
|
|
68
|
+
const sRGB = _.map([hexRed, hexGreen, hexBlue], (hexComponent) =>
|
|
69
|
+
parseInt(hexComponent, 16) / 255.0
|
|
70
|
+
);
|
|
71
|
+
const linearRBG = _.map(sRGB, (component) =>
|
|
72
|
+
(component <= 0.03928)
|
|
73
|
+
? component / 12.92
|
|
74
|
+
: Math.pow((component + 0.055) / 1.055, 2.4)
|
|
75
|
+
);
|
|
76
|
+
const L = 0.2126 * linearRBG[0] + 0.7152 * linearRBG[1] + 0.0722 * linearRBG[2];
|
|
77
|
+
return ((L + 0.05) / (0.0 + 0.05) > (1.0 + 0.05) / (L + 0.05))
|
|
78
|
+
? '#000000'
|
|
79
|
+
: '#ffffff';
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
export default LayoutHeaderView;
|