@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,336 @@
|
|
|
1
|
+
import $ from 'jquery';
|
|
2
|
+
import _ from 'underscore';
|
|
3
|
+
|
|
4
|
+
import EditGroupWidget from '@girder/core/views/widgets/EditGroupWidget';
|
|
5
|
+
import GroupAdminsWidget from '@girder/core/views/widgets/GroupAdminsWidget';
|
|
6
|
+
import GroupInvitesWidget from '@girder/core/views/widgets/GroupInvitesWidget';
|
|
7
|
+
import GroupMembersWidget from '@girder/core/views/widgets/GroupMembersWidget';
|
|
8
|
+
import GroupModel from '@girder/core/models/GroupModel';
|
|
9
|
+
import GroupModsWidget from '@girder/core/views/widgets/GroupModsWidget';
|
|
10
|
+
import LoadingAnimation from '@girder/core/views/widgets/LoadingAnimation';
|
|
11
|
+
import router from '@girder/core/router';
|
|
12
|
+
import UserCollection from '@girder/core/collections/UserCollection';
|
|
13
|
+
import View from '@girder/core/views/View';
|
|
14
|
+
import { AccessType } from '@girder/core/constants';
|
|
15
|
+
import { cancelRestRequests } from '@girder/core/rest';
|
|
16
|
+
import { confirm } from '@girder/core/dialog';
|
|
17
|
+
import events from '@girder/core/events';
|
|
18
|
+
import { getCurrentUser } from '@girder/core/auth';
|
|
19
|
+
|
|
20
|
+
import GroupPageTemplate from '@girder/core/templates/body/groupPage.pug';
|
|
21
|
+
|
|
22
|
+
import '@girder/core/stylesheets/body/groupPage.styl';
|
|
23
|
+
|
|
24
|
+
import 'bootstrap/js/dropdown';
|
|
25
|
+
import 'bootstrap/js/tab';
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* This view shows a single group's page.
|
|
29
|
+
*/
|
|
30
|
+
var GroupView = View.extend({
|
|
31
|
+
events: {
|
|
32
|
+
'click .g-edit-group': 'editGroup',
|
|
33
|
+
'click .g-group-join': 'joinGroup',
|
|
34
|
+
'click .g-group-leave': 'leaveGroup',
|
|
35
|
+
'click .g-group-delete': 'deleteGroup',
|
|
36
|
+
'click .g-group-request-invite': 'requestInvitation',
|
|
37
|
+
'click .g-group-request-accept': 'acceptMembershipRequest',
|
|
38
|
+
'click .g-group-request-deny': 'denyMembershipRequest',
|
|
39
|
+
|
|
40
|
+
'click #g-group-tab-pending a.g-member-name': function (e) {
|
|
41
|
+
var userId = $(e.currentTarget).parents('li').attr('userid');
|
|
42
|
+
router.navigate('user/' + userId, { trigger: true });
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
initialize: function (settings) {
|
|
47
|
+
cancelRestRequests('fetch');
|
|
48
|
+
this.tab = settings.tab || 'roles';
|
|
49
|
+
this.edit = settings.edit || false;
|
|
50
|
+
|
|
51
|
+
// If group model is already passed, there is no need to fetch.
|
|
52
|
+
if (settings.group) {
|
|
53
|
+
this.model = settings.group;
|
|
54
|
+
this.model.on('g:accessFetched', function () {
|
|
55
|
+
this.render();
|
|
56
|
+
}, this).fetchAccess();
|
|
57
|
+
} else if (settings.id) {
|
|
58
|
+
this.model = new GroupModel();
|
|
59
|
+
this.model.set('_id', settings.id);
|
|
60
|
+
|
|
61
|
+
this.model.on('g:fetched', function () {
|
|
62
|
+
this.model.on('g:accessFetched', function () {
|
|
63
|
+
this.render();
|
|
64
|
+
}, this).fetchAccess();
|
|
65
|
+
}, this).fetch();
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
editGroup: function () {
|
|
70
|
+
var container = $('#g-dialog-container');
|
|
71
|
+
|
|
72
|
+
if (!this.editGroupWidget) {
|
|
73
|
+
this.editGroupWidget = new EditGroupWidget({
|
|
74
|
+
el: container,
|
|
75
|
+
model: this.model,
|
|
76
|
+
parentView: this
|
|
77
|
+
}).off('g:saved').on('g:saved', function () {
|
|
78
|
+
this.render();
|
|
79
|
+
}, this);
|
|
80
|
+
}
|
|
81
|
+
this.editGroupWidget.render();
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
deleteGroup: function () {
|
|
85
|
+
confirm({
|
|
86
|
+
text: 'Are you sure you want to delete the group <b>' +
|
|
87
|
+
this.model.escape('name') + '</b>?',
|
|
88
|
+
escapedHtml: true,
|
|
89
|
+
confirmCallback: () => {
|
|
90
|
+
this.model.on('g:deleted', function () {
|
|
91
|
+
router.navigate('groups', { trigger: true });
|
|
92
|
+
}).destroy();
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
render: function () {
|
|
98
|
+
this.isMember = false;
|
|
99
|
+
this.isInvited = false;
|
|
100
|
+
this.isRequested = false;
|
|
101
|
+
this.isModerator = false;
|
|
102
|
+
this.isAdmin = false;
|
|
103
|
+
|
|
104
|
+
if (getCurrentUser()) {
|
|
105
|
+
_.every(getCurrentUser().get('groups'), function (groupId) {
|
|
106
|
+
if (groupId === this.model.get('_id')) {
|
|
107
|
+
this.isMember = true;
|
|
108
|
+
return false; // 'break;'
|
|
109
|
+
}
|
|
110
|
+
return true;
|
|
111
|
+
}, this);
|
|
112
|
+
|
|
113
|
+
_.every(getCurrentUser().get('groupInvites'), function (inv) {
|
|
114
|
+
if (inv.groupId === this.model.get('_id')) {
|
|
115
|
+
this.isInvited = true;
|
|
116
|
+
return false; // 'break;'
|
|
117
|
+
}
|
|
118
|
+
return true;
|
|
119
|
+
}, this);
|
|
120
|
+
|
|
121
|
+
_.every(this.model.get('requests') || [], function (user) {
|
|
122
|
+
if (user.id === getCurrentUser().get('_id')) {
|
|
123
|
+
this.isRequested = true;
|
|
124
|
+
return false; // 'break;'
|
|
125
|
+
}
|
|
126
|
+
return true;
|
|
127
|
+
}, this);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (this.isMember) {
|
|
131
|
+
_.every(this.model.get('access').users || [], function (access) {
|
|
132
|
+
if (access.id === getCurrentUser().get('_id')) {
|
|
133
|
+
if (access.level === AccessType.WRITE) {
|
|
134
|
+
this.isModerator = true;
|
|
135
|
+
} else if (access.level === AccessType.ADMIN) {
|
|
136
|
+
this.isAdmin = true;
|
|
137
|
+
}
|
|
138
|
+
return false; // 'break';
|
|
139
|
+
}
|
|
140
|
+
return true;
|
|
141
|
+
}, this);
|
|
142
|
+
}
|
|
143
|
+
this.$el.html(GroupPageTemplate({
|
|
144
|
+
group: this.model,
|
|
145
|
+
getCurrentUser: getCurrentUser,
|
|
146
|
+
AccessType: AccessType,
|
|
147
|
+
isInvited: this.isInvited,
|
|
148
|
+
isRequested: this.isRequested,
|
|
149
|
+
isMember: this.isMember,
|
|
150
|
+
isModerator: this.isModerator,
|
|
151
|
+
isAdmin: this.isAdmin
|
|
152
|
+
}));
|
|
153
|
+
|
|
154
|
+
if (this.invitees) {
|
|
155
|
+
this._renderInvitesWidget();
|
|
156
|
+
} else {
|
|
157
|
+
var container = this.$('.g-group-invites-body');
|
|
158
|
+
new LoadingAnimation({
|
|
159
|
+
el: container,
|
|
160
|
+
parentView: this
|
|
161
|
+
}).render();
|
|
162
|
+
|
|
163
|
+
this.invitees = new UserCollection();
|
|
164
|
+
this.invitees.altUrl =
|
|
165
|
+
'group/' + this.model.get('_id') + '/invitation';
|
|
166
|
+
this.invitees.on('g:changed', () => {
|
|
167
|
+
this._renderInvitesWidget();
|
|
168
|
+
this.updatePendingStatus();
|
|
169
|
+
}, this).fetch();
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
this._updateRolesLists();
|
|
173
|
+
|
|
174
|
+
router.navigate('group/' + this.model.get('_id') + '/' +
|
|
175
|
+
this.tab, { replace: true });
|
|
176
|
+
|
|
177
|
+
if (this.edit) {
|
|
178
|
+
if (this.model.get('_accessLevel') >= AccessType.ADMIN) {
|
|
179
|
+
this.editGroup();
|
|
180
|
+
}
|
|
181
|
+
this.edit = false;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
_.each($('.g-group-tabs>li>a'), (el) => {
|
|
185
|
+
var tabLink = $(el);
|
|
186
|
+
tabLink.tab().on('shown.bs.tab', (e) => {
|
|
187
|
+
this.tab = $(e.currentTarget).attr('name');
|
|
188
|
+
router.navigate('group/' + this.model.get('_id') + '/' + this.tab);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
if (tabLink.attr('name') === this.tab) {
|
|
192
|
+
tabLink.tab('show');
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
return this;
|
|
197
|
+
},
|
|
198
|
+
|
|
199
|
+
_renderInvitesWidget: function () {
|
|
200
|
+
new GroupInvitesWidget({
|
|
201
|
+
el: this.$('.g-group-invites-body'),
|
|
202
|
+
invitees: this.invitees,
|
|
203
|
+
group: this.model,
|
|
204
|
+
parentView: this
|
|
205
|
+
}).render();
|
|
206
|
+
this.updatePendingStatus();
|
|
207
|
+
},
|
|
208
|
+
|
|
209
|
+
updatePendingStatus: function () {
|
|
210
|
+
var count = this.invitees.length +
|
|
211
|
+
this.model.get('requests').length;
|
|
212
|
+
$('#g-group-tab-pending-status').text(' (' + count + ')');
|
|
213
|
+
},
|
|
214
|
+
|
|
215
|
+
joinGroup: function () {
|
|
216
|
+
this.model.off('g:joined').on('g:joined', function () {
|
|
217
|
+
this.invitees.fetch(null, true);
|
|
218
|
+
}, this).joinGroup();
|
|
219
|
+
},
|
|
220
|
+
|
|
221
|
+
leaveGroup: function () {
|
|
222
|
+
confirm({
|
|
223
|
+
text: 'Are you sure you want to leave this group?',
|
|
224
|
+
confirmCallback: () => {
|
|
225
|
+
this.model.off('g:removed').on('g:removed', () => {
|
|
226
|
+
this.render();
|
|
227
|
+
}).removeMember(getCurrentUser().get('_id'));
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
},
|
|
231
|
+
|
|
232
|
+
removeMember: function (user) {
|
|
233
|
+
var id = user;
|
|
234
|
+
if ($.type(user) !== 'string') {
|
|
235
|
+
id = user.get('_id');
|
|
236
|
+
}
|
|
237
|
+
this.model.off('g:removed').on('g:removed', function () {
|
|
238
|
+
this.render();
|
|
239
|
+
}, this).removeMember(id);
|
|
240
|
+
},
|
|
241
|
+
|
|
242
|
+
requestInvitation: function () {
|
|
243
|
+
this.model.off('g:inviteRequested').on('g:inviteRequested', function () {
|
|
244
|
+
this.render();
|
|
245
|
+
}, this).requestInvitation();
|
|
246
|
+
},
|
|
247
|
+
|
|
248
|
+
acceptMembershipRequest: function (e) {
|
|
249
|
+
var userId = $(e.currentTarget).parents('li').attr('userid');
|
|
250
|
+
this.model.off('g:invited').on('g:invited', this.render, this)
|
|
251
|
+
.sendInvitation(userId, AccessType.READ, true);
|
|
252
|
+
},
|
|
253
|
+
|
|
254
|
+
denyMembershipRequest: function (e) {
|
|
255
|
+
var userId = $(e.currentTarget).parents('li').attr('userid');
|
|
256
|
+
this.model.off('g:removed').on('g:removed', this.render, this)
|
|
257
|
+
.removeMember(userId);
|
|
258
|
+
},
|
|
259
|
+
|
|
260
|
+
_updateRolesLists: function () {
|
|
261
|
+
var mods = [],
|
|
262
|
+
admins = [];
|
|
263
|
+
|
|
264
|
+
_.each(this.model.get('access').users, function (userAccess) {
|
|
265
|
+
if (userAccess.level === AccessType.WRITE) {
|
|
266
|
+
mods.push(userAccess);
|
|
267
|
+
} else if (userAccess.level === AccessType.ADMIN) {
|
|
268
|
+
admins.push(userAccess);
|
|
269
|
+
}
|
|
270
|
+
}, this);
|
|
271
|
+
|
|
272
|
+
this.adminsWidget = new GroupAdminsWidget({
|
|
273
|
+
el: this.$('.g-group-admins-container'),
|
|
274
|
+
group: this.model,
|
|
275
|
+
admins: admins,
|
|
276
|
+
parentView: this
|
|
277
|
+
}).off().on('g:demoteUser', function (userId) {
|
|
278
|
+
this.model.off('g:demoted').on('g:demoted', this.render, this)
|
|
279
|
+
.demoteUser(userId, AccessType.ADMIN);
|
|
280
|
+
}, this).on('g:removeMember', this.removeMember, this)
|
|
281
|
+
.on('g:moderatorAdded', this.render, this)
|
|
282
|
+
.render();
|
|
283
|
+
|
|
284
|
+
this.modsWidget = new GroupModsWidget({
|
|
285
|
+
el: this.$('.g-group-mods-container'),
|
|
286
|
+
group: this.model,
|
|
287
|
+
moderators: mods,
|
|
288
|
+
parentView: this
|
|
289
|
+
}).on('g:demoteUser', function (userId) {
|
|
290
|
+
this.model.off('g:demoted').on('g:demoted', this.render, this)
|
|
291
|
+
.demoteUser(userId, AccessType.WRITE);
|
|
292
|
+
}, this).on('g:removeMember', this.removeMember, this)
|
|
293
|
+
.on('g:adminAdded', this.render, this)
|
|
294
|
+
.render();
|
|
295
|
+
|
|
296
|
+
this.membersWidget = new GroupMembersWidget({
|
|
297
|
+
el: this.$('.g-group-members-container'),
|
|
298
|
+
group: this.model,
|
|
299
|
+
admins: admins,
|
|
300
|
+
moderators: mods,
|
|
301
|
+
parentView: this
|
|
302
|
+
}).on('g:sendInvite', function (params) {
|
|
303
|
+
var opts = {
|
|
304
|
+
force: params.force || false
|
|
305
|
+
};
|
|
306
|
+
this.model.off('g:invited').on('g:invited', function () {
|
|
307
|
+
this.invitees.fetch(null, true);
|
|
308
|
+
if (params.force) {
|
|
309
|
+
this.model.fetchAccess();
|
|
310
|
+
}
|
|
311
|
+
}, this).off('g:error').on('g:error', function (err) {
|
|
312
|
+
events.trigger('g:alert', {
|
|
313
|
+
text: err.responseJSON.message,
|
|
314
|
+
type: 'warning'
|
|
315
|
+
});
|
|
316
|
+
}, this).sendInvitation(params.user.id, params.level, false, opts);
|
|
317
|
+
}, this).on('g:removeMember', this.removeMember, this)
|
|
318
|
+
.on('g:moderatorAdded', this.render, this)
|
|
319
|
+
.on('g:adminAdded', this.render, this);
|
|
320
|
+
}
|
|
321
|
+
}, {
|
|
322
|
+
/**
|
|
323
|
+
* Helper function for fetching the user and rendering the view with
|
|
324
|
+
* an arbitrary set of extra parameters.
|
|
325
|
+
*/
|
|
326
|
+
fetchAndInit: function (groupId, params) {
|
|
327
|
+
var group = new GroupModel();
|
|
328
|
+
group.set({ _id: groupId }).once('g:fetched', function () {
|
|
329
|
+
events.trigger('g:navigateTo', GroupView, _.extend({
|
|
330
|
+
group: group
|
|
331
|
+
}, params || {}));
|
|
332
|
+
}, this).fetch();
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
export default GroupView;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import $ from 'jquery';
|
|
2
|
+
|
|
3
|
+
import EditGroupWidget from '@girder/core/views/widgets/EditGroupWidget';
|
|
4
|
+
import GroupCollection from '@girder/core/collections/GroupCollection';
|
|
5
|
+
import GroupModel from '@girder/core/models/GroupModel';
|
|
6
|
+
import PaginateWidget from '@girder/core/views/widgets/PaginateWidget';
|
|
7
|
+
import router from '@girder/core/router';
|
|
8
|
+
import SearchFieldWidget from '@girder/core/views/widgets/SearchFieldWidget';
|
|
9
|
+
import View from '@girder/core/views/View';
|
|
10
|
+
import { cancelRestRequests } from '@girder/core/rest';
|
|
11
|
+
import { formatDate, DATE_DAY } from '@girder/core/misc';
|
|
12
|
+
import { getCurrentUser } from '@girder/core/auth';
|
|
13
|
+
|
|
14
|
+
import GroupListTemplate from '@girder/core/templates/body/groupList.pug';
|
|
15
|
+
|
|
16
|
+
import '@girder/core/stylesheets/body/groupList.styl';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* This view lists groups.
|
|
20
|
+
*/
|
|
21
|
+
var GroupsView = View.extend({
|
|
22
|
+
events: {
|
|
23
|
+
'click a.g-group-link': function (event) {
|
|
24
|
+
var cid = $(event.currentTarget).attr('g-group-cid');
|
|
25
|
+
router.navigate('group/' + this.collection.get(cid).id, { trigger: true });
|
|
26
|
+
},
|
|
27
|
+
'submit .g-group-search-form': function (event) {
|
|
28
|
+
event.preventDefault();
|
|
29
|
+
},
|
|
30
|
+
'click .g-group-create-button': function () {
|
|
31
|
+
this.createGroupDialog();
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
initialize: function (settings) {
|
|
36
|
+
cancelRestRequests('fetch');
|
|
37
|
+
this.collection = new GroupCollection();
|
|
38
|
+
this.collection.on('g:changed', function () {
|
|
39
|
+
this.render();
|
|
40
|
+
}, this).fetch();
|
|
41
|
+
|
|
42
|
+
this.paginateWidget = new PaginateWidget({
|
|
43
|
+
collection: this.collection,
|
|
44
|
+
parentView: this
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
this.searchWidget = new SearchFieldWidget({
|
|
48
|
+
placeholder: 'Search groups...',
|
|
49
|
+
types: ['group'],
|
|
50
|
+
parentView: this
|
|
51
|
+
}).on('g:resultClicked', this._gotoGroup, this);
|
|
52
|
+
|
|
53
|
+
this.create = settings.dialog === 'create';
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
render: function () {
|
|
57
|
+
this.$el.html(GroupListTemplate({
|
|
58
|
+
groups: this.collection.toArray(),
|
|
59
|
+
getCurrentUser: getCurrentUser,
|
|
60
|
+
formatDate: formatDate,
|
|
61
|
+
DATE_DAY: DATE_DAY
|
|
62
|
+
}));
|
|
63
|
+
|
|
64
|
+
this.paginateWidget.setElement(this.$('.g-group-pagination')).render();
|
|
65
|
+
this.searchWidget.setElement(this.$('.g-groups-search-container')).render();
|
|
66
|
+
|
|
67
|
+
if (this.create) {
|
|
68
|
+
this.createGroupDialog();
|
|
69
|
+
this.create = false;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return this;
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Prompt the user to create a new group
|
|
77
|
+
*/
|
|
78
|
+
createGroupDialog: function () {
|
|
79
|
+
new EditGroupWidget({
|
|
80
|
+
el: $('#g-dialog-container'),
|
|
81
|
+
parentView: this
|
|
82
|
+
}).off('g:saved').on('g:saved', function (group) {
|
|
83
|
+
// Since the user has now joined this group, we can append its ID
|
|
84
|
+
// to their groups list
|
|
85
|
+
var userGroups = getCurrentUser().get('groups') || [];
|
|
86
|
+
userGroups.push(group.get('_id'));
|
|
87
|
+
getCurrentUser().set('groups', userGroups);
|
|
88
|
+
|
|
89
|
+
router.navigate('group/' + group.get('_id'), { trigger: true });
|
|
90
|
+
}, this).render();
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* When the user clicks a search result group, this helper method
|
|
95
|
+
* will navigate them to the view for that group.
|
|
96
|
+
*/
|
|
97
|
+
_gotoGroup: function (result) {
|
|
98
|
+
var group = new GroupModel();
|
|
99
|
+
group.set('_id', result.id).on('g:fetched', function () {
|
|
100
|
+
router.navigate('group/' + group.get('_id'), { trigger: true });
|
|
101
|
+
}, this).fetch();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
export default GroupsView;
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import $ from 'jquery';
|
|
2
|
+
import _ from 'underscore';
|
|
3
|
+
|
|
4
|
+
import EditItemWidget from '@girder/core/views/widgets/EditItemWidget';
|
|
5
|
+
import FileListWidget from '@girder/core/views/widgets/FileListWidget';
|
|
6
|
+
import ItemBreadcrumbWidget from '@girder/core/views/widgets/ItemBreadcrumbWidget';
|
|
7
|
+
import ItemModel from '@girder/core/models/ItemModel';
|
|
8
|
+
import MetadataWidget from '@girder/core/views/widgets/MetadataWidget';
|
|
9
|
+
import router from '@girder/core/router';
|
|
10
|
+
import UploadWidget from '@girder/core/views/widgets/UploadWidget';
|
|
11
|
+
import View from '@girder/core/views/View';
|
|
12
|
+
import { AccessType } from '@girder/core/constants';
|
|
13
|
+
import { cancelRestRequests } from '@girder/core/rest';
|
|
14
|
+
import { confirm, handleClose } from '@girder/core/dialog';
|
|
15
|
+
import events from '@girder/core/events';
|
|
16
|
+
import { formatSize, formatDate, renderMarkdown, DATE_SECOND } from '@girder/core/misc';
|
|
17
|
+
|
|
18
|
+
import ItemPageTemplate from '@girder/core/templates/body/itemPage.pug';
|
|
19
|
+
|
|
20
|
+
import '@girder/core/stylesheets/body/itemPage.styl';
|
|
21
|
+
|
|
22
|
+
import 'bootstrap/js/dropdown';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* This view shows a single item's page.
|
|
26
|
+
*/
|
|
27
|
+
var ItemView = View.extend({
|
|
28
|
+
events: {
|
|
29
|
+
'click .g-edit-item': 'editItem',
|
|
30
|
+
'click .g-delete-item': 'deleteItem',
|
|
31
|
+
'click .g-upload-into-item': 'uploadIntoItem'
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
initialize: function (settings) {
|
|
35
|
+
cancelRestRequests('fetch');
|
|
36
|
+
this.edit = settings.edit || false;
|
|
37
|
+
this.fileEdit = settings.fileEdit || false;
|
|
38
|
+
this.upload = settings.upload || false;
|
|
39
|
+
|
|
40
|
+
// If collection model is already passed, there is no need to fetch.
|
|
41
|
+
if (settings.item) {
|
|
42
|
+
this.model = settings.item;
|
|
43
|
+
this.render();
|
|
44
|
+
} else {
|
|
45
|
+
console.error('Implement fetch then render item');
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
uploadIntoItem: function () {
|
|
50
|
+
new UploadWidget({
|
|
51
|
+
el: $('#g-dialog-container'),
|
|
52
|
+
parent: this.model,
|
|
53
|
+
parentType: 'item',
|
|
54
|
+
parentView: this
|
|
55
|
+
}).on('g:uploadFinished', function () {
|
|
56
|
+
handleClose('upload');
|
|
57
|
+
this.upload = false;
|
|
58
|
+
|
|
59
|
+
events.trigger('g:alert', {
|
|
60
|
+
icon: 'ok',
|
|
61
|
+
text: 'Files added.',
|
|
62
|
+
type: 'success',
|
|
63
|
+
timeout: 4000
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
this.fileListWidget.collection.fetch(null, true);
|
|
67
|
+
}, this).render();
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
editItem: function () {
|
|
71
|
+
var container = $('#g-dialog-container');
|
|
72
|
+
|
|
73
|
+
if (!this.editItemWidget) {
|
|
74
|
+
this.editItemWidget = new EditItemWidget({
|
|
75
|
+
el: container,
|
|
76
|
+
item: this.model,
|
|
77
|
+
parentView: this
|
|
78
|
+
}).off('g:saved').on('g:saved', function () {
|
|
79
|
+
this.render();
|
|
80
|
+
}, this);
|
|
81
|
+
}
|
|
82
|
+
this.editItemWidget.render();
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
deleteItem: function () {
|
|
86
|
+
var folderId = this.model.get('folderId');
|
|
87
|
+
var parentRoute = this.model.get('baseParentType') + '/' +
|
|
88
|
+
this.model.get('baseParentId') + '/folder/' + folderId;
|
|
89
|
+
confirm({
|
|
90
|
+
text: 'Are you sure you want to delete <b>' + this.model.escape('name') + '</b>?',
|
|
91
|
+
yesText: 'Delete',
|
|
92
|
+
escapedHtml: true,
|
|
93
|
+
confirmCallback: () => {
|
|
94
|
+
this.model.on('g:deleted', () => {
|
|
95
|
+
router.navigate(parentRoute, { trigger: true });
|
|
96
|
+
}).off('g:error').on('g:error', () => {
|
|
97
|
+
this.render();
|
|
98
|
+
events.trigger('g:alert', {
|
|
99
|
+
icon: 'cancel',
|
|
100
|
+
text: 'Failed to delete item.',
|
|
101
|
+
type: 'danger',
|
|
102
|
+
timeout: 4000
|
|
103
|
+
});
|
|
104
|
+
}, this).destroy();
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
render: function () {
|
|
110
|
+
// Fetch the access level asynchronously and render once we have
|
|
111
|
+
// it. TODO: load the page and adjust only the action menu once
|
|
112
|
+
// the access level is fetched.
|
|
113
|
+
this.model.getAccessLevel((accessLevel) => {
|
|
114
|
+
this.accessLevel = accessLevel;
|
|
115
|
+
this.$el.html(ItemPageTemplate({
|
|
116
|
+
item: this.model,
|
|
117
|
+
accessLevel: accessLevel,
|
|
118
|
+
AccessType: AccessType,
|
|
119
|
+
formatSize: formatSize,
|
|
120
|
+
formatDate: formatDate,
|
|
121
|
+
renderMarkdown: renderMarkdown,
|
|
122
|
+
DATE_SECOND: DATE_SECOND
|
|
123
|
+
}));
|
|
124
|
+
|
|
125
|
+
this.fileListWidget = new FileListWidget({
|
|
126
|
+
el: this.$('.g-item-files-container'),
|
|
127
|
+
item: this.model,
|
|
128
|
+
fileEdit: this.fileEdit,
|
|
129
|
+
upload: this.upload,
|
|
130
|
+
parentView: this
|
|
131
|
+
});
|
|
132
|
+
this.fileListWidget.once('g:changed', function () {
|
|
133
|
+
this.trigger('g:rendered');
|
|
134
|
+
}, this);
|
|
135
|
+
|
|
136
|
+
this.fileEdit = false;
|
|
137
|
+
this.upload = false;
|
|
138
|
+
|
|
139
|
+
this.metadataWidget = new MetadataWidget({
|
|
140
|
+
el: this.$('.g-item-metadata'),
|
|
141
|
+
item: this.model,
|
|
142
|
+
accessLevel: accessLevel,
|
|
143
|
+
parentView: this
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
this.model.getRootPath((resp) => {
|
|
147
|
+
this.breadcrumbWidget = new ItemBreadcrumbWidget({
|
|
148
|
+
el: this.$('.g-item-breadcrumb-container'),
|
|
149
|
+
parentChain: resp,
|
|
150
|
+
parentView: this
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
if (this.edit) {
|
|
155
|
+
this.editItem();
|
|
156
|
+
this.edit = false;
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
return this;
|
|
161
|
+
}
|
|
162
|
+
}, {
|
|
163
|
+
/**
|
|
164
|
+
* Helper function for fetching the user and rendering the view with
|
|
165
|
+
* an arbitrary set of extra parameters.
|
|
166
|
+
*/
|
|
167
|
+
fetchAndInit: function (itemId, params) {
|
|
168
|
+
var item = new ItemModel();
|
|
169
|
+
item.set({ _id: itemId }).on('g:fetched', function () {
|
|
170
|
+
events.trigger('g:navigateTo', ItemView, _.extend({
|
|
171
|
+
item: item
|
|
172
|
+
}, params || {}));
|
|
173
|
+
}, this).fetch();
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
export default ItemView;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import $ from 'jquery';
|
|
2
|
+
import _ from 'underscore';
|
|
3
|
+
|
|
4
|
+
import router from '@girder/core/router';
|
|
5
|
+
import View from '@girder/core/views/View';
|
|
6
|
+
import { getPluginConfigRoute } from '@girder/core/utilities/PluginUtils';
|
|
7
|
+
import { restRequest, cancelRestRequests } from '@girder/core/rest';
|
|
8
|
+
|
|
9
|
+
import PluginsTemplate from '@girder/core/templates/body/plugins.pug';
|
|
10
|
+
|
|
11
|
+
import '@girder/core/stylesheets/body/plugins.styl';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* This is the plugin management page for administrators.
|
|
15
|
+
*/
|
|
16
|
+
var PluginsView = View.extend({
|
|
17
|
+
events: {
|
|
18
|
+
'click a.g-plugin-config-link': function (evt) {
|
|
19
|
+
var route = $(evt.currentTarget).attr('g-route');
|
|
20
|
+
router.navigate(route, { trigger: true });
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
initialize: function (settings) {
|
|
25
|
+
cancelRestRequests('fetch');
|
|
26
|
+
if (settings.all) {
|
|
27
|
+
this.allPlugins = settings.all;
|
|
28
|
+
this.render();
|
|
29
|
+
} else {
|
|
30
|
+
// Fetch the plugin list
|
|
31
|
+
restRequest({
|
|
32
|
+
url: 'system/plugins',
|
|
33
|
+
method: 'GET'
|
|
34
|
+
})
|
|
35
|
+
.done((resp) => {
|
|
36
|
+
this.allPlugins = resp.all;
|
|
37
|
+
this.render();
|
|
38
|
+
}).fail(() => {
|
|
39
|
+
router.navigate('/', { trigger: true });
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
render: function () {
|
|
45
|
+
_.each(this.allPlugins, function (info, name) {
|
|
46
|
+
info.configRoute = getPluginConfigRoute(name);
|
|
47
|
+
}, this);
|
|
48
|
+
|
|
49
|
+
this.$el.html(PluginsTemplate({
|
|
50
|
+
allPlugins: this._sortPlugins(this.allPlugins)
|
|
51
|
+
}));
|
|
52
|
+
|
|
53
|
+
return this;
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
_sortPlugins: function (plugins) {
|
|
57
|
+
/* Sort a dictionary of plugins alphabetically so that the appear in a
|
|
58
|
+
* predictable order to the user.
|
|
59
|
+
*
|
|
60
|
+
* @param plugins: a dictionary to sort. Each entry has a .name
|
|
61
|
+
* attribute used for sorting.
|
|
62
|
+
* @returns sortedPlugins: the sorted list. */
|
|
63
|
+
var sortedPlugins = _.map(plugins, function (value, key) {
|
|
64
|
+
return { key: key, value: value };
|
|
65
|
+
});
|
|
66
|
+
sortedPlugins.sort(function (a, b) {
|
|
67
|
+
return a.value.name.localeCompare(b.value.name);
|
|
68
|
+
});
|
|
69
|
+
return sortedPlugins;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
export default PluginsView;
|