@girder/core 3.2.8 → 5.0.0-a7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -0
- package/package.json +79 -31
- package/assets/Girder_Mark.png +0 -0
- package/auth.js +0 -152
- package/collections/ApiKeyCollection.js +0 -9
- package/collections/AssetstoreCollection.js +0 -9
- package/collections/Collection.js +0 -295
- package/collections/CollectionCollection.js +0 -9
- package/collections/FileCollection.js +0 -11
- package/collections/FolderCollection.js +0 -11
- package/collections/GroupCollection.js +0 -9
- package/collections/ItemCollection.js +0 -11
- package/collections/UserCollection.js +0 -24
- package/collections/index.js +0 -21
- package/constants.js +0 -33
- package/dialog.js +0 -128
- package/events.js +0 -6
- package/index.js +0 -31
- package/main.js +0 -21
- package/misc.js +0 -260
- package/models/AccessControlledModel.js +0 -76
- package/models/ApiKeyModel.js +0 -31
- package/models/AssetstoreModel.js +0 -43
- package/models/CollectionCreationPolicyModel.js +0 -20
- package/models/CollectionModel.js +0 -12
- package/models/FileModel.js +0 -310
- package/models/FolderModel.js +0 -33
- package/models/GroupModel.js +0 -197
- package/models/ItemModel.js +0 -72
- package/models/MetadataMixin.js +0 -88
- package/models/Model.js +0 -187
- package/models/UserModel.js +0 -189
- package/models/index.js +0 -25
- package/pluginUtils.js +0 -11
- package/rest.js +0 -216
- package/router.js +0 -58
- package/routes.js +0 -231
- package/stylesheets/apidocs/apidocs.styl +0 -50
- package/stylesheets/body/adminConsole.styl +0 -21
- package/stylesheets/body/assetstores.styl +0 -46
- package/stylesheets/body/collectionList.styl +0 -39
- package/stylesheets/body/collectionPage.styl +0 -6
- package/stylesheets/body/frontPage.styl +0 -48
- package/stylesheets/body/groupList.styl +0 -43
- package/stylesheets/body/groupPage.styl +0 -116
- package/stylesheets/body/itemPage.styl +0 -81
- package/stylesheets/body/plugins.styl +0 -61
- package/stylesheets/body/searchResultsList.styl +0 -51
- package/stylesheets/body/systemConfig.styl +0 -56
- package/stylesheets/body/userAccount.styl +0 -57
- package/stylesheets/body/userList.styl +0 -79
- package/stylesheets/body/userPage.styl +0 -6
- package/stylesheets/layout/footer.styl +0 -19
- package/stylesheets/layout/global.styl +0 -154
- package/stylesheets/layout/globalNav.styl +0 -89
- package/stylesheets/layout/header.styl +0 -29
- package/stylesheets/layout/headerUser.styl +0 -33
- package/stylesheets/layout/layout.styl +0 -75
- package/stylesheets/layout/layoutVars.styl +0 -9
- package/stylesheets/layout/loading.styl +0 -37
- package/stylesheets/layout/progressArea.styl +0 -17
- package/stylesheets/widgets/accessWidget.styl +0 -106
- package/stylesheets/widgets/browserWidget.styl +0 -9
- package/stylesheets/widgets/hierarchyWidget.styl +0 -188
- package/stylesheets/widgets/markdownWidget.styl +0 -92
- package/stylesheets/widgets/metadataWidget.styl +0 -92
- package/stylesheets/widgets/searchFieldWidget.styl +0 -70
- package/stylesheets/widgets/taskProgress.styl +0 -41
- package/stylesheets/widgets/timelineWidget.styl +0 -41
- package/stylesheets/widgets/uploadWidget.styl +0 -43
- package/stylesheets/widgets/userOtpManagementWidget.styl +0 -159
- package/templates/body/adminConsole.pug +0 -13
- package/templates/body/assetstores.pug +0 -98
- package/templates/body/collectionList.pug +0 -40
- package/templates/body/collectionPage.pug +0 -36
- package/templates/body/filesystemImport.pug +0 -41
- package/templates/body/frontPage.pug +0 -83
- package/templates/body/groupList.pug +0 -30
- package/templates/body/groupPage.pug +0 -116
- package/templates/body/itemPage.pug +0 -61
- package/templates/body/plugins.pug +0 -20
- package/templates/body/s3Import.pug +0 -35
- package/templates/body/searchResults.pug +0 -15
- package/templates/body/searchResultsType.pug +0 -13
- package/templates/body/systemConfiguration.pug +0 -221
- package/templates/body/userAccount.pug +0 -83
- package/templates/body/userList.pug +0 -43
- package/templates/body/userPage.pug +0 -40
- package/templates/layout/alert.pug +0 -5
- package/templates/layout/layout.pug +0 -12
- package/templates/layout/layoutFooter.pug +0 -11
- package/templates/layout/layoutGlobalNav.pug +0 -7
- package/templates/layout/layoutHeader.pug +0 -8
- package/templates/layout/layoutHeaderUser.pug +0 -26
- package/templates/layout/layoutProgressArea.pug +0 -1
- package/templates/layout/loginDialog.pug +0 -30
- package/templates/layout/registerDialog.pug +0 -35
- package/templates/layout/resetPasswordDialog.pug +0 -25
- package/templates/widgets/accessEditor.pug +0 -23
- package/templates/widgets/accessEditorMixins.pug +0 -57
- package/templates/widgets/accessEditorNonModal.pug +0 -11
- package/templates/widgets/accessEntry.pug +0 -32
- package/templates/widgets/apiKeyList.pug +0 -50
- package/templates/widgets/browserWidget.pug +0 -32
- package/templates/widgets/checkedActionsMenu.pug +0 -46
- package/templates/widgets/collectionInfoDialog.pug +0 -37
- package/templates/widgets/confirmDialog.pug +0 -14
- package/templates/widgets/dateTimeRangeWidget.pug +0 -20
- package/templates/widgets/dateTimeWidget.pug +0 -8
- package/templates/widgets/editApiKeyWidget.pug +0 -43
- package/templates/widgets/editAssetstoreWidget.pug +0 -78
- package/templates/widgets/editCollectionWidget.pug +0 -27
- package/templates/widgets/editFileWidget.pug +0 -21
- package/templates/widgets/editFolderWidget.pug +0 -27
- package/templates/widgets/editGroupWidget.pug +0 -54
- package/templates/widgets/editItemWidget.pug +0 -27
- package/templates/widgets/fileInfoDialog.pug +0 -33
- package/templates/widgets/fileList.pug +0 -33
- package/templates/widgets/folderInfoDialog.pug +0 -42
- package/templates/widgets/folderList.pug +0 -21
- package/templates/widgets/groupAdminList.pug +0 -33
- package/templates/widgets/groupInviteDialog.pug +0 -76
- package/templates/widgets/groupInviteList.pug +0 -14
- package/templates/widgets/groupMemberList.pug +0 -39
- package/templates/widgets/groupModList.pug +0 -23
- package/templates/widgets/hierarchyBreadcrumb.pug +0 -37
- package/templates/widgets/hierarchyPaginated.pug +0 -19
- package/templates/widgets/hierarchyWidget.pug +0 -96
- package/templates/widgets/itemBreadcrumb.pug +0 -16
- package/templates/widgets/itemList.pug +0 -27
- package/templates/widgets/jsonMetadatumEditWidget.pug +0 -13
- package/templates/widgets/jsonMetadatumView.pug +0 -6
- package/templates/widgets/loadingAnimation.pug +0 -4
- package/templates/widgets/markdownWidget.pug +0 -34
- package/templates/widgets/metadataWidget.pug +0 -16
- package/templates/widgets/metadatumEditWidget.pug +0 -15
- package/templates/widgets/metadatumView.pug +0 -5
- package/templates/widgets/newAssetstore.pug +0 -118
- package/templates/widgets/paginateWidget.pug +0 -7
- package/templates/widgets/pluginConfigBreadcrumb.pug +0 -13
- package/templates/widgets/rootSelectorWidget.pug +0 -13
- package/templates/widgets/searchField.pug +0 -10
- package/templates/widgets/searchHelp.pug +0 -12
- package/templates/widgets/searchModeSelect.pug +0 -9
- package/templates/widgets/searchResults.pug +0 -14
- package/templates/widgets/sortCollectionWidget.pug +0 -14
- package/templates/widgets/taskProgress.pug +0 -16
- package/templates/widgets/timeline.pug +0 -15
- package/templates/widgets/uploadWidget.pug +0 -15
- package/templates/widgets/uploadWidgetMixins.pug +0 -31
- package/templates/widgets/uploadWidgetNonModal.pug +0 -10
- package/templates/widgets/userOtpBegin.pug +0 -4
- package/templates/widgets/userOtpDisable.pug +0 -6
- package/templates/widgets/userOtpEnable.pug +0 -44
- package/utilities/EventStream.js +0 -177
- package/utilities/PluginUtils.js +0 -36
- package/utilities/S3UploadHandler.js +0 -303
- package/utilities/index.js +0 -9
- package/utilities/jquery/girderEnable.js +0 -19
- package/utilities/jquery/girderModal.js +0 -48
- package/version.js +0 -10
- package/views/App.js +0 -359
- package/views/View.js +0 -78
- package/views/body/AdminView.js +0 -29
- package/views/body/AssetstoresView.js +0 -235
- package/views/body/CollectionView.js +0 -188
- package/views/body/CollectionsView.js +0 -120
- package/views/body/FilesystemImportView.js +0 -83
- package/views/body/FolderView.js +0 -54
- package/views/body/FrontPageView.js +0 -47
- package/views/body/GroupView.js +0 -336
- package/views/body/GroupsView.js +0 -106
- package/views/body/ItemView.js +0 -177
- package/views/body/PluginsView.js +0 -73
- package/views/body/S3ImportView.js +0 -80
- package/views/body/SearchResultsView.js +0 -162
- package/views/body/SystemConfigurationView.js +0 -196
- package/views/body/UserAccountView.js +0 -179
- package/views/body/UserView.js +0 -165
- package/views/body/UsersView.js +0 -124
- package/views/body/index.js +0 -37
- package/views/index.js +0 -13
- package/views/layout/FooterView.js +0 -29
- package/views/layout/GlobalNavView.js +0 -103
- package/views/layout/HeaderUserView.js +0 -45
- package/views/layout/HeaderView.js +0 -83
- package/views/layout/LoginView.js +0 -100
- package/views/layout/ProgressListView.js +0 -70
- package/views/layout/RegisterView.js +0 -101
- package/views/layout/ResetPasswordView.js +0 -70
- package/views/layout/index.js +0 -19
- package/views/widgets/AccessWidget.js +0 -427
- package/views/widgets/ApiKeyListWidget.js +0 -140
- package/views/widgets/BrowserWidget.js +0 -317
- package/views/widgets/CheckedMenuWidget.js +0 -68
- package/views/widgets/CollectionInfoWidget.js +0 -40
- package/views/widgets/DateTimeRangeWidget.js +0 -179
- package/views/widgets/DateTimeWidget.js +0 -109
- package/views/widgets/EditApiKeyWidget.js +0 -122
- package/views/widgets/EditAssetstoreWidget.js +0 -148
- package/views/widgets/EditCollectionWidget.js +0 -93
- package/views/widgets/EditFileWidget.js +0 -56
- package/views/widgets/EditFolderWidget.js +0 -116
- package/views/widgets/EditGroupWidget.js +0 -125
- package/views/widgets/EditItemWidget.js +0 -110
- package/views/widgets/FileInfoWidget.js +0 -26
- package/views/widgets/FileListWidget.js +0 -151
- package/views/widgets/FolderInfoWidget.js +0 -39
- package/views/widgets/FolderListWidget.js +0 -106
- package/views/widgets/GroupAdminsWidget.js +0 -88
- package/views/widgets/GroupInvitesWidget.js +0 -56
- package/views/widgets/GroupMembersWidget.js +0 -185
- package/views/widgets/GroupModsWidget.js +0 -77
- package/views/widgets/HierarchyWidget.js +0 -1097
- package/views/widgets/ItemBreadcrumbWidget.js +0 -38
- package/views/widgets/ItemListWidget.js +0 -345
- package/views/widgets/LoadingAnimation.js +0 -17
- package/views/widgets/MarkdownWidget.js +0 -217
- package/views/widgets/MetadataWidget.js +0 -504
- package/views/widgets/NewAssetstoreWidget.js +0 -81
- package/views/widgets/PaginateWidget.js +0 -37
- package/views/widgets/PluginConfigBreadcrumbWidget.js +0 -33
- package/views/widgets/RootSelectorWidget.js +0 -192
- package/views/widgets/SearchFieldWidget.js +0 -365
- package/views/widgets/SearchPaginateWidget.js +0 -149
- package/views/widgets/SortCollectionWidget.js +0 -53
- package/views/widgets/TaskProgressWidget.js +0 -91
- package/views/widgets/TimelineWidget.js +0 -155
- package/views/widgets/UploadWidget.js +0 -340
- package/views/widgets/UserOtpManagementWidget.js +0 -105
- package/views/widgets/index.js +0 -75
package/views/App.js
DELETED
|
@@ -1,359 +0,0 @@
|
|
|
1
|
-
import $ from 'jquery';
|
|
2
|
-
import _ from 'underscore';
|
|
3
|
-
import Backbone from 'backbone';
|
|
4
|
-
import 'typeface-open-sans';
|
|
5
|
-
import 'bootstrap/dist/css/bootstrap.css';
|
|
6
|
-
import 'bootstrap/js/alert';
|
|
7
|
-
import '@girder/fontello/dist/css/animation.css';
|
|
8
|
-
import '@girder/fontello/dist/css/fontello.css';
|
|
9
|
-
|
|
10
|
-
import '@girder/core/utilities/jquery/girderModal';
|
|
11
|
-
|
|
12
|
-
import events from '@girder/core/events';
|
|
13
|
-
import eventStream from '@girder/core/utilities/EventStream';
|
|
14
|
-
import LayoutFooterView from '@girder/core/views/layout/FooterView';
|
|
15
|
-
import LayoutGlobalNavView from '@girder/core/views/layout/GlobalNavView';
|
|
16
|
-
import LayoutHeaderView from '@girder/core/views/layout/HeaderView';
|
|
17
|
-
import LoginView from '@girder/core/views/layout/LoginView';
|
|
18
|
-
import ProgressListView from '@girder/core/views/layout/ProgressListView';
|
|
19
|
-
import RegisterView from '@girder/core/views/layout/RegisterView';
|
|
20
|
-
import ResetPasswordView from '@girder/core/views/layout/ResetPasswordView';
|
|
21
|
-
import router from '@girder/core/router';
|
|
22
|
-
import UserModel from '@girder/core/models/UserModel';
|
|
23
|
-
import View from '@girder/core/views/View';
|
|
24
|
-
import { fetchCurrentUser, setCurrentUser, getCurrentUser } from '@girder/core/auth';
|
|
25
|
-
import { Layout } from '@girder/core/constants';
|
|
26
|
-
import { splitRoute } from '@girder/core/misc';
|
|
27
|
-
|
|
28
|
-
import AlertTemplate from '@girder/core/templates/layout/alert.pug';
|
|
29
|
-
import LayoutTemplate from '@girder/core/templates/layout/layout.pug';
|
|
30
|
-
|
|
31
|
-
import '@girder/core/routes';
|
|
32
|
-
|
|
33
|
-
import '@girder/core/stylesheets/layout/global.styl';
|
|
34
|
-
import '@girder/core/stylesheets/layout/layout.styl';
|
|
35
|
-
|
|
36
|
-
var App = View.extend({
|
|
37
|
-
/**
|
|
38
|
-
* @param {object} [settings]
|
|
39
|
-
* @param {bool} [settings.start=true] Run start after initialization
|
|
40
|
-
*/
|
|
41
|
-
initialize: function (settings) {
|
|
42
|
-
this._started = false;
|
|
43
|
-
settings = settings || {};
|
|
44
|
-
this.contactEmail = settings.contactEmail || null;
|
|
45
|
-
this.privacyNoticeHref = settings.privacyNoticeHref || null;
|
|
46
|
-
this.brandName = settings.brandName || null;
|
|
47
|
-
this.bannerColor = settings.bannerColor || null;
|
|
48
|
-
this.registrationPolicy = settings.registrationPolicy || null;
|
|
49
|
-
this.enablePasswordLogin = _.has(settings, 'enablePasswordLogin') ? settings.enablePasswordLogin : true;
|
|
50
|
-
|
|
51
|
-
if (settings.start === undefined || settings.start) {
|
|
52
|
-
this.start();
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Start the application with optional components.
|
|
58
|
-
* @param {object} [settings]
|
|
59
|
-
* @param {bool} [settings.fetch=true] Fetch the current user modal
|
|
60
|
-
* @param {bool} [settings.render=true] Render the layout after starting
|
|
61
|
-
* @param {bool} [settings.history=true] Start backbone's history api
|
|
62
|
-
* @returns {$.Deferred} A promise-like object that resolves when the app is ready
|
|
63
|
-
*/
|
|
64
|
-
start: function (settings) {
|
|
65
|
-
// start is a noop if the app is already running
|
|
66
|
-
var promise = new $.Deferred().resolve(null).promise();
|
|
67
|
-
if (this._started) {
|
|
68
|
-
return promise;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// set defaults
|
|
72
|
-
settings = _.defaults(settings || {}, {
|
|
73
|
-
fetch: true,
|
|
74
|
-
render: true,
|
|
75
|
-
history: true
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
// define a function to be run after fetching the user model
|
|
79
|
-
var afterFetch = (user) => {
|
|
80
|
-
this._createLayout();
|
|
81
|
-
|
|
82
|
-
if (user) {
|
|
83
|
-
setCurrentUser(new UserModel(user));
|
|
84
|
-
eventStream.open();
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
this._started = true;
|
|
88
|
-
|
|
89
|
-
if (settings.render) {
|
|
90
|
-
this.render();
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (settings.history) {
|
|
94
|
-
Backbone.history.stop();
|
|
95
|
-
Backbone.history.start({
|
|
96
|
-
pushState: false
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
// If fetching the user from the server then we return the jqxhr object
|
|
102
|
-
// from the request, otherwise just call the callback.
|
|
103
|
-
if (settings.fetch) {
|
|
104
|
-
promise = fetchCurrentUser()
|
|
105
|
-
.done(afterFetch);
|
|
106
|
-
} else {
|
|
107
|
-
afterFetch(null);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
this.bindGirderEvents();
|
|
111
|
-
return promise;
|
|
112
|
-
},
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Bind the application to the global event object.
|
|
116
|
-
*/
|
|
117
|
-
bindGirderEvents: function () {
|
|
118
|
-
// Unbind any current handlers in case this happens to be called twice.
|
|
119
|
-
events.off(null, null, this);
|
|
120
|
-
|
|
121
|
-
events.on('g:navigateTo', this.navigateTo, this);
|
|
122
|
-
events.on('g:loginUi', this.loginDialog, this);
|
|
123
|
-
events.on('g:registerUi', this.registerDialog, this);
|
|
124
|
-
events.on('g:resetPasswordUi', this.resetPasswordDialog, this);
|
|
125
|
-
events.on('g:alert', this.alert, this);
|
|
126
|
-
events.on('g:login', this.login, this);
|
|
127
|
-
},
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Create the main layout views.
|
|
131
|
-
* @private
|
|
132
|
-
*/
|
|
133
|
-
_createLayout: function () {
|
|
134
|
-
this.headerView = new LayoutHeaderView({
|
|
135
|
-
parentView: this,
|
|
136
|
-
brandName: this.brandName,
|
|
137
|
-
bannerColor: this.bannerColor,
|
|
138
|
-
registrationPolicy: this.registrationPolicy
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
this.globalNavView = new LayoutGlobalNavView({
|
|
142
|
-
parentView: this
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
this.footerView = new LayoutFooterView({
|
|
146
|
-
parentView: this,
|
|
147
|
-
contactEmail: this.contactEmail,
|
|
148
|
-
privacyNoticeHref: this.privacyNoticeHref
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
this.progressListView = new ProgressListView({
|
|
152
|
-
eventStream: eventStream,
|
|
153
|
-
parentView: this
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
this.layoutRenderMap = {};
|
|
157
|
-
this.layoutRenderMap[Layout.DEFAULT] = this._defaultLayout;
|
|
158
|
-
this.layoutRenderMap[Layout.EMPTY] = this._emptyLayout;
|
|
159
|
-
},
|
|
160
|
-
|
|
161
|
-
_layout: 'default',
|
|
162
|
-
|
|
163
|
-
_defaultLayout: {
|
|
164
|
-
show: function () {
|
|
165
|
-
this.$('#g-app-header-container,#g-global-nav-container,#g-app-footer-container').show();
|
|
166
|
-
this.$('#g-app-body-container').addClass('g-default-layout');
|
|
167
|
-
},
|
|
168
|
-
|
|
169
|
-
hide: function () {
|
|
170
|
-
this.$('#g-app-header-container,#g-global-nav-container,#g-app-footer-container').hide();
|
|
171
|
-
this.$('#g-app-body-container').removeClass('g-default-layout');
|
|
172
|
-
}
|
|
173
|
-
},
|
|
174
|
-
|
|
175
|
-
_emptyLayout: {
|
|
176
|
-
show: function () {
|
|
177
|
-
this.$('#g-app-body-container').addClass('g-empty-layout');
|
|
178
|
-
},
|
|
179
|
-
|
|
180
|
-
hide: function () {
|
|
181
|
-
this.$('#g-app-body-container').removeClass('g-empty-layout');
|
|
182
|
-
}
|
|
183
|
-
},
|
|
184
|
-
|
|
185
|
-
render: function () {
|
|
186
|
-
if (!this._started) {
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
this.$el.html(LayoutTemplate());
|
|
190
|
-
|
|
191
|
-
this.globalNavView.setElement(this.$('#g-global-nav-container')).render();
|
|
192
|
-
this.headerView.setElement(this.$('#g-app-header-container')).render();
|
|
193
|
-
this.footerView.setElement(this.$('#g-app-footer-container')).render();
|
|
194
|
-
this.progressListView.setElement(this.$('#g-app-progress-container')).render();
|
|
195
|
-
|
|
196
|
-
return this;
|
|
197
|
-
},
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Changes the current body view to the view class specified by view.
|
|
201
|
-
* @param view The view to display in the body.
|
|
202
|
-
* @param [settings={}] Settings to pass to the view initialize() method.
|
|
203
|
-
* @param opts Additional options for navigateTo, if any.
|
|
204
|
-
*/
|
|
205
|
-
navigateTo: function (view, settings, opts) {
|
|
206
|
-
this.globalNavView.deactivateAll();
|
|
207
|
-
|
|
208
|
-
settings = settings || {};
|
|
209
|
-
opts = opts || {};
|
|
210
|
-
|
|
211
|
-
if (opts.layout) {
|
|
212
|
-
if (this._layout !== opts.layout) {
|
|
213
|
-
if (_.has(this.layoutRenderMap, opts.layout)) {
|
|
214
|
-
// set a layout if opts specifies one different from current
|
|
215
|
-
this.layoutRenderMap[this._layout].hide.call(this, opts);
|
|
216
|
-
this._layout = opts.layout;
|
|
217
|
-
this.layoutRenderMap[this._layout].show.call(this, opts);
|
|
218
|
-
} else {
|
|
219
|
-
console.error('Attempting to set unknown layout type: ' + opts.layout);
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
} else if (this._layout !== Layout.DEFAULT) {
|
|
223
|
-
// reset to default as needed when nothing specified in opts
|
|
224
|
-
this.layoutRenderMap[this._layout].hide.call(this, opts);
|
|
225
|
-
this._layout = Layout.DEFAULT;
|
|
226
|
-
this.layoutRenderMap[this._layout].show.call(this, opts);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
if (view) {
|
|
230
|
-
if (this.bodyView) {
|
|
231
|
-
this.bodyView.destroy();
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
settings = _.extend(settings, {
|
|
235
|
-
el: this.$('#g-app-body-container'),
|
|
236
|
-
parentView: this,
|
|
237
|
-
brandName: this.brandName
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
/* We let the view be created in this way even though it is
|
|
241
|
-
* normally against convention.
|
|
242
|
-
*/
|
|
243
|
-
this.bodyView = new view(settings); // eslint-disable-line new-cap
|
|
244
|
-
|
|
245
|
-
if (opts.renderNow) {
|
|
246
|
-
this.bodyView.render();
|
|
247
|
-
}
|
|
248
|
-
} else {
|
|
249
|
-
console.error('Undefined page.');
|
|
250
|
-
}
|
|
251
|
-
return this;
|
|
252
|
-
},
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* Close any open dialog if we are already logged in.
|
|
256
|
-
* :returns: true if we have a current user.
|
|
257
|
-
*/
|
|
258
|
-
closeDialogIfUser: function () {
|
|
259
|
-
if (getCurrentUser()) {
|
|
260
|
-
$('.modal').girderModal('close');
|
|
261
|
-
return true;
|
|
262
|
-
}
|
|
263
|
-
return false;
|
|
264
|
-
},
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* Show a dialog allowing a user to login or register.
|
|
268
|
-
*/
|
|
269
|
-
loginDialog: function () {
|
|
270
|
-
if (this.closeDialogIfUser()) {
|
|
271
|
-
return;
|
|
272
|
-
}
|
|
273
|
-
if (!this.loginView) {
|
|
274
|
-
this.loginView = new LoginView({
|
|
275
|
-
el: this.$('#g-dialog-container'),
|
|
276
|
-
parentView: this,
|
|
277
|
-
registrationPolicy: this.registrationPolicy,
|
|
278
|
-
enablePasswordLogin: this.enablePasswordLogin
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
this.loginView.render();
|
|
282
|
-
},
|
|
283
|
-
|
|
284
|
-
registerDialog: function () {
|
|
285
|
-
if (this.closeDialogIfUser()) {
|
|
286
|
-
return;
|
|
287
|
-
}
|
|
288
|
-
if (!this.registerView) {
|
|
289
|
-
this.registerView = new RegisterView({
|
|
290
|
-
el: this.$('#g-dialog-container'),
|
|
291
|
-
parentView: this
|
|
292
|
-
});
|
|
293
|
-
}
|
|
294
|
-
this.registerView.render();
|
|
295
|
-
},
|
|
296
|
-
|
|
297
|
-
resetPasswordDialog: function () {
|
|
298
|
-
if (this.closeDialogIfUser()) {
|
|
299
|
-
return;
|
|
300
|
-
}
|
|
301
|
-
if (!this.resetPasswordView) {
|
|
302
|
-
this.resetPasswordView = new ResetPasswordView({
|
|
303
|
-
el: this.$('#g-dialog-container'),
|
|
304
|
-
parentView: this,
|
|
305
|
-
registrationPolicy: this.registrationPolicy
|
|
306
|
-
});
|
|
307
|
-
}
|
|
308
|
-
this.resetPasswordView.render();
|
|
309
|
-
},
|
|
310
|
-
|
|
311
|
-
/**
|
|
312
|
-
* Display a brief alert on the screen with the following options:
|
|
313
|
-
* - text: The text to be displayed
|
|
314
|
-
* - [type]: The alert class ('info', 'warning', 'success', 'danger').
|
|
315
|
-
* Default is 'info'.
|
|
316
|
-
* - [icon]: An optional icon to display in the alert.
|
|
317
|
-
* - [timeout]: How long before the alert should automatically disappear.
|
|
318
|
-
* Default is 6000ms. Set to <= 0 to have no timeout.
|
|
319
|
-
*/
|
|
320
|
-
alert: function (options) {
|
|
321
|
-
var el = $(AlertTemplate({
|
|
322
|
-
text: options.text,
|
|
323
|
-
type: options.type || 'info',
|
|
324
|
-
icon: options.icon
|
|
325
|
-
}));
|
|
326
|
-
$('#g-alerts-container').append(el);
|
|
327
|
-
el.fadeIn(500);
|
|
328
|
-
|
|
329
|
-
if (options.timeout === undefined) {
|
|
330
|
-
options.timeout = 6000;
|
|
331
|
-
}
|
|
332
|
-
if (options.timeout > 0) {
|
|
333
|
-
window.setTimeout(function () {
|
|
334
|
-
el.fadeOut(750, function () {
|
|
335
|
-
$(this).remove();
|
|
336
|
-
});
|
|
337
|
-
}, options.timeout);
|
|
338
|
-
}
|
|
339
|
-
},
|
|
340
|
-
|
|
341
|
-
/**
|
|
342
|
-
* On login we re-render the current body view; whereas on
|
|
343
|
-
* logout, we redirect to the front page.
|
|
344
|
-
*/
|
|
345
|
-
login: function () {
|
|
346
|
-
var route = splitRoute(Backbone.history.fragment).base;
|
|
347
|
-
Backbone.history.fragment = null;
|
|
348
|
-
eventStream.close();
|
|
349
|
-
|
|
350
|
-
if (getCurrentUser()) {
|
|
351
|
-
eventStream.open();
|
|
352
|
-
router.navigate(route, { trigger: true });
|
|
353
|
-
} else {
|
|
354
|
-
router.navigate('/', { trigger: true });
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
});
|
|
358
|
-
|
|
359
|
-
export default App;
|
package/views/View.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import _ from 'underscore';
|
|
2
|
-
import Backbone from 'backbone';
|
|
3
|
-
|
|
4
|
-
import events from '@girder/core/events';
|
|
5
|
-
import eventStream from '@girder/core/utilities/EventStream';
|
|
6
|
-
|
|
7
|
-
var View = Backbone.View.extend({
|
|
8
|
-
constructor: function (opts) { // eslint-disable-line backbone/no-constructor
|
|
9
|
-
if (opts && _.has(opts, 'parentView')) {
|
|
10
|
-
if (opts.parentView) {
|
|
11
|
-
opts.parentView.registerChildView(this);
|
|
12
|
-
this.parentView = opts.parentView;
|
|
13
|
-
}
|
|
14
|
-
} else {
|
|
15
|
-
console.error('View created with no parentView property set. ' +
|
|
16
|
-
'This view may not be garbage collected.');
|
|
17
|
-
}
|
|
18
|
-
Backbone.View.prototype.constructor.apply(this, arguments);
|
|
19
|
-
},
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Remove a view, unbinding its events and removing its listeners on
|
|
23
|
-
* events so that it can be garbage collected.
|
|
24
|
-
*/
|
|
25
|
-
destroy: function () {
|
|
26
|
-
_.each(this._childViews, function (child) {
|
|
27
|
-
child.destroy();
|
|
28
|
-
});
|
|
29
|
-
this._childViews = null;
|
|
30
|
-
|
|
31
|
-
this.undelegateEvents();
|
|
32
|
-
this.stopListening();
|
|
33
|
-
this.off();
|
|
34
|
-
events.off(null, null, this);
|
|
35
|
-
eventStream.off(null, null, this);
|
|
36
|
-
|
|
37
|
-
if (this.parentView) {
|
|
38
|
-
this.parentView.unregisterChildView(this);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Modal views need special cleanup.
|
|
42
|
-
if (this.$el.is('.modal')) {
|
|
43
|
-
var el = this.$el;
|
|
44
|
-
if (el.data('bs.modal') && el.data('bs.modal').isShown) {
|
|
45
|
-
el.on('hidden.bs.modal', function () {
|
|
46
|
-
el.empty().off().removeData();
|
|
47
|
-
}).modal('hide');
|
|
48
|
-
el.modal('removeBackdrop');
|
|
49
|
-
} else {
|
|
50
|
-
el.modal('hideModal');
|
|
51
|
-
el.modal('removeBackdrop');
|
|
52
|
-
el.empty().off().removeData();
|
|
53
|
-
}
|
|
54
|
-
} else {
|
|
55
|
-
this.$el.empty().off().removeData();
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* It's typically not necessary to call this directly. Instead, instantiate
|
|
61
|
-
* child views with the "parentView" field.
|
|
62
|
-
*/
|
|
63
|
-
registerChildView: function (child) {
|
|
64
|
-
this._childViews = this._childViews || [];
|
|
65
|
-
this._childViews.push(child);
|
|
66
|
-
},
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Typically, you will not need to call this method directly. Calling
|
|
70
|
-
* destroy on a child element will automatically unregister it from its
|
|
71
|
-
* parent view if the parent view was specified.
|
|
72
|
-
*/
|
|
73
|
-
unregisterChildView: function (child) {
|
|
74
|
-
this._childViews = _.without(this._childViews, child);
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
export default View;
|
package/views/body/AdminView.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import View from '@girder/core/views/View';
|
|
2
|
-
import { cancelRestRequests } from '@girder/core/rest';
|
|
3
|
-
import { getCurrentUser } from '@girder/core/auth';
|
|
4
|
-
|
|
5
|
-
import AdminConsoleTemplate from '@girder/core/templates/body/adminConsole.pug';
|
|
6
|
-
|
|
7
|
-
import '@girder/core/stylesheets/body/adminConsole.styl';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* This view shows the admin console, which links to all available admin pages.
|
|
11
|
-
*/
|
|
12
|
-
var AdminView = View.extend({
|
|
13
|
-
initialize: function () {
|
|
14
|
-
cancelRestRequests('fetch');
|
|
15
|
-
this.render();
|
|
16
|
-
},
|
|
17
|
-
|
|
18
|
-
render: function () {
|
|
19
|
-
if (!getCurrentUser() || !getCurrentUser().get('admin')) {
|
|
20
|
-
this.$el.text('Must be logged in as admin to view this page.');
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
this.$el.html(AdminConsoleTemplate());
|
|
24
|
-
|
|
25
|
-
return this;
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
export default AdminView;
|
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
import $ from 'jquery';
|
|
2
|
-
import _ from 'underscore';
|
|
3
|
-
|
|
4
|
-
import AssetstoreCollection from '@girder/core/collections/AssetstoreCollection';
|
|
5
|
-
import AssetstoreModel from '@girder/core/models/AssetstoreModel';
|
|
6
|
-
import EditAssetstoreWidget from '@girder/core/views/widgets/EditAssetstoreWidget';
|
|
7
|
-
import NewAssetstoreWidget from '@girder/core/views/widgets/NewAssetstoreWidget';
|
|
8
|
-
import View from '@girder/core/views/View';
|
|
9
|
-
import { AssetstoreType } 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
|
-
import { formatSize } from '@girder/core/misc';
|
|
14
|
-
import { getCurrentUser } from '@girder/core/auth';
|
|
15
|
-
|
|
16
|
-
import AssetstoresTemplate from '@girder/core/templates/body/assetstores.pug';
|
|
17
|
-
|
|
18
|
-
import '@girder/core/stylesheets/body/assetstores.styl';
|
|
19
|
-
|
|
20
|
-
import 'as-jqplot/dist/jquery.jqplot.js';
|
|
21
|
-
import 'as-jqplot/dist/jquery.jqplot.css'; // jquery.jqplot.min.css
|
|
22
|
-
import 'as-jqplot/dist/plugins/jqplot.pieRenderer.js';
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* This private data structure is a dynamic way to map assetstore types to the views
|
|
26
|
-
* that should be rendered to import data into them.
|
|
27
|
-
*/
|
|
28
|
-
import FilesystemImportView from '@girder/core/views/body/FilesystemImportView';
|
|
29
|
-
import S3ImportView from '@girder/core/views/body/S3ImportView';
|
|
30
|
-
var assetstoreImportViewMap = {};
|
|
31
|
-
assetstoreImportViewMap[AssetstoreType.FILESYSTEM] = FilesystemImportView;
|
|
32
|
-
assetstoreImportViewMap[AssetstoreType.S3] = S3ImportView;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* This view shows the admin console, which links to all available admin pages.
|
|
36
|
-
*/
|
|
37
|
-
var AssetstoresView = View.extend({
|
|
38
|
-
events: {
|
|
39
|
-
'click .g-set-current': 'setCurrentAssetstore',
|
|
40
|
-
'click .g-delete-assetstore': 'deleteAssetstore',
|
|
41
|
-
'click .g-edit-assetstore': 'editAssetstore'
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
initialize: function (settings) {
|
|
45
|
-
cancelRestRequests('fetch');
|
|
46
|
-
this.plots = [];
|
|
47
|
-
this.assetstoreEdit = settings.assetstoreEdit || false;
|
|
48
|
-
this.importableTypes = [
|
|
49
|
-
AssetstoreType.FILESYSTEM,
|
|
50
|
-
AssetstoreType.S3
|
|
51
|
-
].concat(settings.importableTypes || []);
|
|
52
|
-
|
|
53
|
-
this.newAssetstoreWidget = new NewAssetstoreWidget({
|
|
54
|
-
parentView: this
|
|
55
|
-
}).on('g:created', this.addAssetstore, this);
|
|
56
|
-
|
|
57
|
-
// Fetch all of the current assetstores
|
|
58
|
-
this.collection = new AssetstoreCollection();
|
|
59
|
-
this.collection.on('g:changed', function () {
|
|
60
|
-
this.render();
|
|
61
|
-
}, this).fetch();
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
destroy: function () {
|
|
65
|
-
this._destroyPlots();
|
|
66
|
-
View.prototype.destroy.call(this);
|
|
67
|
-
},
|
|
68
|
-
|
|
69
|
-
_destroyPlots: function () {
|
|
70
|
-
for (const plot of this.plots) {
|
|
71
|
-
plot.data('jqplot').destroy();
|
|
72
|
-
}
|
|
73
|
-
this.plots = [];
|
|
74
|
-
},
|
|
75
|
-
|
|
76
|
-
render: function () {
|
|
77
|
-
if (!getCurrentUser() || !getCurrentUser().get('admin')) {
|
|
78
|
-
this.$el.text('Must be logged in as admin to view this page.');
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
this._destroyPlots();
|
|
82
|
-
this.$el.html(AssetstoresTemplate({
|
|
83
|
-
assetstores: this.collection.toArray(),
|
|
84
|
-
types: AssetstoreType,
|
|
85
|
-
importableTypes: this.importableTypes,
|
|
86
|
-
getAssetstoreImportRoute: this.getAssetstoreImportRoute
|
|
87
|
-
}));
|
|
88
|
-
|
|
89
|
-
this.newAssetstoreWidget.setElement(this.$('#g-new-assetstore-container')).render();
|
|
90
|
-
|
|
91
|
-
_.each(this.$('.g-assetstore-capacity-chart'),
|
|
92
|
-
this.capacityChart, this);
|
|
93
|
-
|
|
94
|
-
if (this.assetstoreEdit) {
|
|
95
|
-
this.editAssetstoreDialog(this.assetstoreEdit);
|
|
96
|
-
this.assetstoreEdit = false;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return this;
|
|
100
|
-
},
|
|
101
|
-
|
|
102
|
-
addAssetstore: function (assetstore) {
|
|
103
|
-
this.collection.add(assetstore);
|
|
104
|
-
this.render();
|
|
105
|
-
},
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Renders the capacities of the assetstores in a pie chart using Chart.js.
|
|
109
|
-
* @param el The canvas element to render in.
|
|
110
|
-
*/
|
|
111
|
-
capacityChart: function (el) {
|
|
112
|
-
var assetstore = this.collection.get($(el).attr('cid'));
|
|
113
|
-
var capacity = assetstore.get('capacity');
|
|
114
|
-
var used = capacity.total - capacity.free;
|
|
115
|
-
var data = [
|
|
116
|
-
['Used (' + formatSize(used) + ')', used],
|
|
117
|
-
['Free (' + formatSize(capacity.free) + ')', capacity.free]
|
|
118
|
-
];
|
|
119
|
-
var plot = $(el).jqplot([data], {
|
|
120
|
-
seriesDefaults: {
|
|
121
|
-
renderer: $.jqplot.PieRenderer,
|
|
122
|
-
rendererOptions: {
|
|
123
|
-
sliceMargin: 2,
|
|
124
|
-
shadow: false,
|
|
125
|
-
highlightMouseOver: false,
|
|
126
|
-
showDataLabels: true,
|
|
127
|
-
padding: 5,
|
|
128
|
-
startAngle: 180
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
|
-
legend: {
|
|
132
|
-
show: true,
|
|
133
|
-
location: 'e',
|
|
134
|
-
background: 'transparent',
|
|
135
|
-
border: 'none'
|
|
136
|
-
},
|
|
137
|
-
grid: {
|
|
138
|
-
background: 'transparent',
|
|
139
|
-
border: 'none',
|
|
140
|
-
borderWidth: 0,
|
|
141
|
-
shadow: false
|
|
142
|
-
},
|
|
143
|
-
gridPadding: { top: 10, right: 10, bottom: 10, left: 10 }
|
|
144
|
-
});
|
|
145
|
-
this.plots.push(plot);
|
|
146
|
-
},
|
|
147
|
-
|
|
148
|
-
setCurrentAssetstore: function (evt) {
|
|
149
|
-
var el = $(evt.currentTarget);
|
|
150
|
-
var assetstore = this.collection.get(el.attr('cid'));
|
|
151
|
-
assetstore.set({ current: true });
|
|
152
|
-
assetstore.off('g:saved').on('g:saved', function () {
|
|
153
|
-
events.trigger('g:alert', {
|
|
154
|
-
icon: 'ok',
|
|
155
|
-
text: 'Changed current assetstore.',
|
|
156
|
-
type: 'success',
|
|
157
|
-
timeout: 4000
|
|
158
|
-
});
|
|
159
|
-
this.collection.fetch({}, true);
|
|
160
|
-
}, this).off('g:error').on('g:error', function (err) {
|
|
161
|
-
events.trigger('g:alert', {
|
|
162
|
-
icon: 'cancel',
|
|
163
|
-
text: err.responseJSON.message,
|
|
164
|
-
type: 'danger'
|
|
165
|
-
});
|
|
166
|
-
}).save();
|
|
167
|
-
},
|
|
168
|
-
|
|
169
|
-
deleteAssetstore: function (evt) {
|
|
170
|
-
var el = $(evt.currentTarget);
|
|
171
|
-
var assetstore = this.collection.get(el.attr('cid'));
|
|
172
|
-
|
|
173
|
-
confirm({
|
|
174
|
-
text: 'Are you sure you want to delete the assetstore <b>' +
|
|
175
|
-
assetstore.escape('name') + '</b>? There are no files ' +
|
|
176
|
-
'stored in it, and no data will be lost.',
|
|
177
|
-
escapedHtml: true,
|
|
178
|
-
yesText: 'Delete',
|
|
179
|
-
confirmCallback: () => {
|
|
180
|
-
assetstore.on('g:deleted', function () {
|
|
181
|
-
events.trigger('g:alert', {
|
|
182
|
-
icon: 'ok',
|
|
183
|
-
text: 'Assetstore deleted.',
|
|
184
|
-
type: 'success',
|
|
185
|
-
timeout: 4000
|
|
186
|
-
});
|
|
187
|
-
this.collection.fetch({}, true);
|
|
188
|
-
}, this).off('g:error').on('g:error', function (resp) {
|
|
189
|
-
events.trigger('g:alert', {
|
|
190
|
-
icon: 'attention',
|
|
191
|
-
text: resp.responseJSON.message,
|
|
192
|
-
type: 'danger',
|
|
193
|
-
timeout: 4000
|
|
194
|
-
});
|
|
195
|
-
}, this).destroy();
|
|
196
|
-
}
|
|
197
|
-
});
|
|
198
|
-
},
|
|
199
|
-
|
|
200
|
-
editAssetstore: function (evt) {
|
|
201
|
-
var cid = $(evt.currentTarget).attr('cid');
|
|
202
|
-
this.editAssetstoreDialog(cid);
|
|
203
|
-
},
|
|
204
|
-
|
|
205
|
-
editAssetstoreDialog: function (cid) {
|
|
206
|
-
var assetstore = this.collection.get(cid);
|
|
207
|
-
var container = $('#g-dialog-container');
|
|
208
|
-
|
|
209
|
-
var editAssetstoreWidget = new EditAssetstoreWidget({
|
|
210
|
-
el: container,
|
|
211
|
-
model: assetstore,
|
|
212
|
-
parentView: this
|
|
213
|
-
}).off('g:saved').on('g:saved', function () {
|
|
214
|
-
this.render();
|
|
215
|
-
}, this);
|
|
216
|
-
editAssetstoreWidget.render();
|
|
217
|
-
}
|
|
218
|
-
}, {
|
|
219
|
-
import: function (assetstoreId) {
|
|
220
|
-
var assetstore = new AssetstoreModel({ _id: assetstoreId });
|
|
221
|
-
assetstore.once('g:fetched', function () {
|
|
222
|
-
var View = assetstoreImportViewMap[assetstore.get('type')];
|
|
223
|
-
if (View) {
|
|
224
|
-
events.trigger('g:navigateTo', View, {
|
|
225
|
-
assetstore: assetstore
|
|
226
|
-
});
|
|
227
|
-
} else {
|
|
228
|
-
throw new Error('No such view');
|
|
229
|
-
}
|
|
230
|
-
}).fetch();
|
|
231
|
-
}
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
export { assetstoreImportViewMap };
|
|
235
|
-
export default AssetstoresView;
|