@girder/core 3.2.7 → 5.0.0-a6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (231) hide show
  1. package/README.md +61 -0
  2. package/package.json +79 -31
  3. package/assets/Girder_Mark.png +0 -0
  4. package/auth.js +0 -152
  5. package/collections/ApiKeyCollection.js +0 -9
  6. package/collections/AssetstoreCollection.js +0 -9
  7. package/collections/Collection.js +0 -295
  8. package/collections/CollectionCollection.js +0 -9
  9. package/collections/FileCollection.js +0 -11
  10. package/collections/FolderCollection.js +0 -11
  11. package/collections/GroupCollection.js +0 -9
  12. package/collections/ItemCollection.js +0 -11
  13. package/collections/UserCollection.js +0 -24
  14. package/collections/index.js +0 -21
  15. package/constants.js +0 -33
  16. package/dialog.js +0 -128
  17. package/events.js +0 -6
  18. package/index.js +0 -31
  19. package/main.js +0 -21
  20. package/misc.js +0 -260
  21. package/models/AccessControlledModel.js +0 -76
  22. package/models/ApiKeyModel.js +0 -31
  23. package/models/AssetstoreModel.js +0 -43
  24. package/models/CollectionCreationPolicyModel.js +0 -20
  25. package/models/CollectionModel.js +0 -12
  26. package/models/FileModel.js +0 -310
  27. package/models/FolderModel.js +0 -33
  28. package/models/GroupModel.js +0 -197
  29. package/models/ItemModel.js +0 -72
  30. package/models/MetadataMixin.js +0 -88
  31. package/models/Model.js +0 -187
  32. package/models/UserModel.js +0 -189
  33. package/models/index.js +0 -25
  34. package/pluginUtils.js +0 -11
  35. package/rest.js +0 -216
  36. package/router.js +0 -58
  37. package/routes.js +0 -231
  38. package/stylesheets/apidocs/apidocs.styl +0 -50
  39. package/stylesheets/body/adminConsole.styl +0 -21
  40. package/stylesheets/body/assetstores.styl +0 -46
  41. package/stylesheets/body/collectionList.styl +0 -39
  42. package/stylesheets/body/collectionPage.styl +0 -6
  43. package/stylesheets/body/frontPage.styl +0 -48
  44. package/stylesheets/body/groupList.styl +0 -43
  45. package/stylesheets/body/groupPage.styl +0 -116
  46. package/stylesheets/body/itemPage.styl +0 -81
  47. package/stylesheets/body/plugins.styl +0 -61
  48. package/stylesheets/body/searchResultsList.styl +0 -51
  49. package/stylesheets/body/systemConfig.styl +0 -56
  50. package/stylesheets/body/userAccount.styl +0 -57
  51. package/stylesheets/body/userList.styl +0 -79
  52. package/stylesheets/body/userPage.styl +0 -6
  53. package/stylesheets/layout/footer.styl +0 -19
  54. package/stylesheets/layout/global.styl +0 -154
  55. package/stylesheets/layout/globalNav.styl +0 -89
  56. package/stylesheets/layout/header.styl +0 -29
  57. package/stylesheets/layout/headerUser.styl +0 -33
  58. package/stylesheets/layout/layout.styl +0 -75
  59. package/stylesheets/layout/layoutVars.styl +0 -9
  60. package/stylesheets/layout/loading.styl +0 -37
  61. package/stylesheets/layout/progressArea.styl +0 -17
  62. package/stylesheets/widgets/accessWidget.styl +0 -106
  63. package/stylesheets/widgets/browserWidget.styl +0 -9
  64. package/stylesheets/widgets/hierarchyWidget.styl +0 -188
  65. package/stylesheets/widgets/markdownWidget.styl +0 -92
  66. package/stylesheets/widgets/metadataWidget.styl +0 -92
  67. package/stylesheets/widgets/searchFieldWidget.styl +0 -70
  68. package/stylesheets/widgets/taskProgress.styl +0 -41
  69. package/stylesheets/widgets/timelineWidget.styl +0 -41
  70. package/stylesheets/widgets/uploadWidget.styl +0 -43
  71. package/stylesheets/widgets/userOtpManagementWidget.styl +0 -159
  72. package/templates/body/adminConsole.pug +0 -13
  73. package/templates/body/assetstores.pug +0 -98
  74. package/templates/body/collectionList.pug +0 -40
  75. package/templates/body/collectionPage.pug +0 -36
  76. package/templates/body/filesystemImport.pug +0 -41
  77. package/templates/body/frontPage.pug +0 -83
  78. package/templates/body/groupList.pug +0 -30
  79. package/templates/body/groupPage.pug +0 -116
  80. package/templates/body/itemPage.pug +0 -61
  81. package/templates/body/plugins.pug +0 -20
  82. package/templates/body/s3Import.pug +0 -35
  83. package/templates/body/searchResults.pug +0 -15
  84. package/templates/body/searchResultsType.pug +0 -13
  85. package/templates/body/systemConfiguration.pug +0 -221
  86. package/templates/body/userAccount.pug +0 -83
  87. package/templates/body/userList.pug +0 -43
  88. package/templates/body/userPage.pug +0 -40
  89. package/templates/layout/alert.pug +0 -5
  90. package/templates/layout/layout.pug +0 -12
  91. package/templates/layout/layoutFooter.pug +0 -11
  92. package/templates/layout/layoutGlobalNav.pug +0 -7
  93. package/templates/layout/layoutHeader.pug +0 -8
  94. package/templates/layout/layoutHeaderUser.pug +0 -26
  95. package/templates/layout/layoutProgressArea.pug +0 -1
  96. package/templates/layout/loginDialog.pug +0 -30
  97. package/templates/layout/registerDialog.pug +0 -35
  98. package/templates/layout/resetPasswordDialog.pug +0 -25
  99. package/templates/widgets/accessEditor.pug +0 -23
  100. package/templates/widgets/accessEditorMixins.pug +0 -57
  101. package/templates/widgets/accessEditorNonModal.pug +0 -11
  102. package/templates/widgets/accessEntry.pug +0 -32
  103. package/templates/widgets/apiKeyList.pug +0 -50
  104. package/templates/widgets/browserWidget.pug +0 -32
  105. package/templates/widgets/checkedActionsMenu.pug +0 -46
  106. package/templates/widgets/collectionInfoDialog.pug +0 -37
  107. package/templates/widgets/confirmDialog.pug +0 -14
  108. package/templates/widgets/dateTimeRangeWidget.pug +0 -20
  109. package/templates/widgets/dateTimeWidget.pug +0 -8
  110. package/templates/widgets/editApiKeyWidget.pug +0 -43
  111. package/templates/widgets/editAssetstoreWidget.pug +0 -78
  112. package/templates/widgets/editCollectionWidget.pug +0 -27
  113. package/templates/widgets/editFileWidget.pug +0 -21
  114. package/templates/widgets/editFolderWidget.pug +0 -27
  115. package/templates/widgets/editGroupWidget.pug +0 -54
  116. package/templates/widgets/editItemWidget.pug +0 -27
  117. package/templates/widgets/fileInfoDialog.pug +0 -33
  118. package/templates/widgets/fileList.pug +0 -33
  119. package/templates/widgets/folderInfoDialog.pug +0 -42
  120. package/templates/widgets/folderList.pug +0 -21
  121. package/templates/widgets/groupAdminList.pug +0 -33
  122. package/templates/widgets/groupInviteDialog.pug +0 -76
  123. package/templates/widgets/groupInviteList.pug +0 -14
  124. package/templates/widgets/groupMemberList.pug +0 -39
  125. package/templates/widgets/groupModList.pug +0 -23
  126. package/templates/widgets/hierarchyBreadcrumb.pug +0 -37
  127. package/templates/widgets/hierarchyPaginated.pug +0 -19
  128. package/templates/widgets/hierarchyWidget.pug +0 -96
  129. package/templates/widgets/itemBreadcrumb.pug +0 -16
  130. package/templates/widgets/itemList.pug +0 -27
  131. package/templates/widgets/jsonMetadatumEditWidget.pug +0 -13
  132. package/templates/widgets/jsonMetadatumView.pug +0 -6
  133. package/templates/widgets/loadingAnimation.pug +0 -4
  134. package/templates/widgets/markdownWidget.pug +0 -34
  135. package/templates/widgets/metadataWidget.pug +0 -16
  136. package/templates/widgets/metadatumEditWidget.pug +0 -15
  137. package/templates/widgets/metadatumView.pug +0 -5
  138. package/templates/widgets/newAssetstore.pug +0 -118
  139. package/templates/widgets/paginateWidget.pug +0 -7
  140. package/templates/widgets/pluginConfigBreadcrumb.pug +0 -13
  141. package/templates/widgets/rootSelectorWidget.pug +0 -13
  142. package/templates/widgets/searchField.pug +0 -10
  143. package/templates/widgets/searchHelp.pug +0 -12
  144. package/templates/widgets/searchModeSelect.pug +0 -9
  145. package/templates/widgets/searchResults.pug +0 -14
  146. package/templates/widgets/sortCollectionWidget.pug +0 -14
  147. package/templates/widgets/taskProgress.pug +0 -16
  148. package/templates/widgets/timeline.pug +0 -15
  149. package/templates/widgets/uploadWidget.pug +0 -15
  150. package/templates/widgets/uploadWidgetMixins.pug +0 -31
  151. package/templates/widgets/uploadWidgetNonModal.pug +0 -10
  152. package/templates/widgets/userOtpBegin.pug +0 -4
  153. package/templates/widgets/userOtpDisable.pug +0 -6
  154. package/templates/widgets/userOtpEnable.pug +0 -44
  155. package/utilities/EventStream.js +0 -177
  156. package/utilities/PluginUtils.js +0 -36
  157. package/utilities/S3UploadHandler.js +0 -303
  158. package/utilities/index.js +0 -9
  159. package/utilities/jquery/girderEnable.js +0 -19
  160. package/utilities/jquery/girderModal.js +0 -48
  161. package/version.js +0 -10
  162. package/views/App.js +0 -359
  163. package/views/View.js +0 -78
  164. package/views/body/AdminView.js +0 -29
  165. package/views/body/AssetstoresView.js +0 -235
  166. package/views/body/CollectionView.js +0 -188
  167. package/views/body/CollectionsView.js +0 -120
  168. package/views/body/FilesystemImportView.js +0 -83
  169. package/views/body/FolderView.js +0 -54
  170. package/views/body/FrontPageView.js +0 -47
  171. package/views/body/GroupView.js +0 -336
  172. package/views/body/GroupsView.js +0 -106
  173. package/views/body/ItemView.js +0 -177
  174. package/views/body/PluginsView.js +0 -73
  175. package/views/body/S3ImportView.js +0 -80
  176. package/views/body/SearchResultsView.js +0 -162
  177. package/views/body/SystemConfigurationView.js +0 -196
  178. package/views/body/UserAccountView.js +0 -179
  179. package/views/body/UserView.js +0 -165
  180. package/views/body/UsersView.js +0 -124
  181. package/views/body/index.js +0 -37
  182. package/views/index.js +0 -13
  183. package/views/layout/FooterView.js +0 -29
  184. package/views/layout/GlobalNavView.js +0 -103
  185. package/views/layout/HeaderUserView.js +0 -45
  186. package/views/layout/HeaderView.js +0 -83
  187. package/views/layout/LoginView.js +0 -100
  188. package/views/layout/ProgressListView.js +0 -70
  189. package/views/layout/RegisterView.js +0 -101
  190. package/views/layout/ResetPasswordView.js +0 -70
  191. package/views/layout/index.js +0 -19
  192. package/views/widgets/AccessWidget.js +0 -427
  193. package/views/widgets/ApiKeyListWidget.js +0 -140
  194. package/views/widgets/BrowserWidget.js +0 -317
  195. package/views/widgets/CheckedMenuWidget.js +0 -68
  196. package/views/widgets/CollectionInfoWidget.js +0 -40
  197. package/views/widgets/DateTimeRangeWidget.js +0 -179
  198. package/views/widgets/DateTimeWidget.js +0 -109
  199. package/views/widgets/EditApiKeyWidget.js +0 -122
  200. package/views/widgets/EditAssetstoreWidget.js +0 -148
  201. package/views/widgets/EditCollectionWidget.js +0 -93
  202. package/views/widgets/EditFileWidget.js +0 -56
  203. package/views/widgets/EditFolderWidget.js +0 -116
  204. package/views/widgets/EditGroupWidget.js +0 -125
  205. package/views/widgets/EditItemWidget.js +0 -110
  206. package/views/widgets/FileInfoWidget.js +0 -26
  207. package/views/widgets/FileListWidget.js +0 -151
  208. package/views/widgets/FolderInfoWidget.js +0 -39
  209. package/views/widgets/FolderListWidget.js +0 -106
  210. package/views/widgets/GroupAdminsWidget.js +0 -88
  211. package/views/widgets/GroupInvitesWidget.js +0 -56
  212. package/views/widgets/GroupMembersWidget.js +0 -185
  213. package/views/widgets/GroupModsWidget.js +0 -77
  214. package/views/widgets/HierarchyWidget.js +0 -1097
  215. package/views/widgets/ItemBreadcrumbWidget.js +0 -38
  216. package/views/widgets/ItemListWidget.js +0 -345
  217. package/views/widgets/LoadingAnimation.js +0 -17
  218. package/views/widgets/MarkdownWidget.js +0 -217
  219. package/views/widgets/MetadataWidget.js +0 -504
  220. package/views/widgets/NewAssetstoreWidget.js +0 -81
  221. package/views/widgets/PaginateWidget.js +0 -37
  222. package/views/widgets/PluginConfigBreadcrumbWidget.js +0 -33
  223. package/views/widgets/RootSelectorWidget.js +0 -192
  224. package/views/widgets/SearchFieldWidget.js +0 -365
  225. package/views/widgets/SearchPaginateWidget.js +0 -149
  226. package/views/widgets/SortCollectionWidget.js +0 -53
  227. package/views/widgets/TaskProgressWidget.js +0 -91
  228. package/views/widgets/TimelineWidget.js +0 -155
  229. package/views/widgets/UploadWidget.js +0 -340
  230. package/views/widgets/UserOtpManagementWidget.js +0 -105
  231. package/views/widgets/index.js +0 -75
@@ -1,88 +0,0 @@
1
- import _ from 'underscore';
2
-
3
- import { restRequest } from '@girder/core/rest';
4
-
5
- var MetadataMixin = {
6
- _sendMetadata: function (metadata, successCallback, errorCallback, opts) {
7
- opts = opts || {};
8
- restRequest({
9
- url: opts.path ||
10
- ((this.altUrl || this.resourceName) + `/${this.id}/metadata?allowNull=true`),
11
- contentType: 'application/json',
12
- data: JSON.stringify(metadata),
13
- method: 'PUT',
14
- error: null
15
- }).done((resp) => {
16
- this.set(opts.field || 'meta', resp.meta);
17
- if (_.isFunction(successCallback)) {
18
- successCallback();
19
- }
20
- }).fail((err) => {
21
- err.message = err.responseJSON.message;
22
- if (_.isFunction(errorCallback)) {
23
- errorCallback(err);
24
- }
25
- });
26
- },
27
-
28
- addMetadata: function (key, value, successCallback, errorCallback, opts) {
29
- opts = opts || {};
30
- var datum = {};
31
- datum[key] = value;
32
- var meta = this.get(opts.field || 'meta');
33
- if (meta && _.has(meta, key)) {
34
- if (_.isFunction(errorCallback)) {
35
- errorCallback({ message: key + ' is already a metadata key' });
36
- }
37
- } else {
38
- this._sendMetadata(datum, successCallback, errorCallback, opts);
39
- }
40
- },
41
-
42
- removeMetadata: function (key, successCallback, errorCallback, opts) {
43
- if (!_.isArray(key)) {
44
- key = [key];
45
- }
46
- restRequest({
47
- url: opts.path ||
48
- ((this.altUrl || this.resourceName) + `/${this.id}/metadata`),
49
- contentType: 'application/json',
50
- data: JSON.stringify(key),
51
- method: 'DELETE',
52
- error: null
53
- }).done((resp) => {
54
- this.set(opts.field || 'meta', resp.meta);
55
- if (_.isFunction(successCallback)) {
56
- successCallback();
57
- }
58
- }).fail((err) => {
59
- err.message = err.responseJSON.message;
60
- if (_.isFunction(errorCallback)) {
61
- errorCallback(err);
62
- }
63
- });
64
- },
65
-
66
- editMetadata: function (newKey, oldKey, value, successCallback, errorCallback, opts) {
67
- opts = opts || {};
68
-
69
- if (newKey === oldKey) {
70
- var datum = {};
71
- datum[newKey] = value;
72
- this._sendMetadata(datum, successCallback, errorCallback, opts);
73
- } else {
74
- if (_.has(this.get(opts.field || 'meta'), newKey)) {
75
- if (_.isFunction(errorCallback)) {
76
- errorCallback({ message: newKey + ' is already a metadata key' });
77
- }
78
- } else {
79
- var metas = {};
80
- metas[oldKey] = null;
81
- metas[newKey] = value;
82
- this._sendMetadata(metas, successCallback, errorCallback, opts);
83
- }
84
- }
85
- }
86
- };
87
-
88
- export default MetadataMixin;
package/models/Model.js DELETED
@@ -1,187 +0,0 @@
1
- import $ from 'jquery';
2
- import _ from 'underscore';
3
- import Backbone from 'backbone';
4
-
5
- import { restRequest, getApiRoot } from '@girder/core/rest';
6
-
7
- /**
8
- * All models should descend from this base model, which provides a number
9
- * of utilities for synchronization.
10
- */
11
- var Model = Backbone.Model.extend({
12
- resourceName: null,
13
- altUrl: null,
14
- idAttribute: '_id',
15
-
16
- /**
17
- * Convenience method for incrementing numeric properties.
18
- * @param {string} attr The attribute to increment.
19
- * @param {number} [amount] The amount to increment by. Defaults to 1.
20
- */
21
- increment: function (attr, amount) {
22
- if (amount === undefined) {
23
- amount = 1;
24
- }
25
- if (!amount) {
26
- return;
27
- }
28
- return this.set(attr, this.get(attr) + amount);
29
- },
30
-
31
- /**
32
- * Get the name for this resource. By default, just the name attribute.
33
- */
34
- name: function () {
35
- return this.get('name');
36
- },
37
-
38
- /**
39
- * Save this model to the server. If this is a new model, meaning it has no
40
- * _id attribute, this will create it. If the _id is set, we update the
41
- * existing model. Triggers g:saved on success, and g:error on error.
42
- */
43
- save: function () {
44
- if (this.altUrl === null && this.resourceName === null) {
45
- throw new Error('An altUrl or resourceName must be set on the Model.');
46
- }
47
-
48
- var path, type;
49
- if (this.has('_id')) {
50
- path = (this.altUrl || this.resourceName) + '/' + this.get('_id');
51
- type = 'PUT';
52
- } else {
53
- path = (this.altUrl || this.resourceName);
54
- type = 'POST';
55
- }
56
- /* Don't save attributes which are objects using this call. For
57
- * instance, if the metadata of an item has keys that contain non-ascii
58
- * values, they won't get handled by the rest call. */
59
- var data = {};
60
- _.each(this.keys(), function (key) {
61
- var value = this.get(key);
62
- if (!_.isObject(value)) {
63
- data[key] = value;
64
- }
65
- }, this);
66
-
67
- return restRequest({
68
- url: path,
69
- method: type,
70
- data: data,
71
- error: null // don't do default error behavior (validation may fail)
72
- }).done((resp) => {
73
- this.set(resp);
74
- this.trigger('g:saved');
75
- }).fail((err) => {
76
- this.trigger('g:error', err);
77
- });
78
- },
79
-
80
- /**
81
- * Fetch a single resource from the server. Triggers g:fetched on success,
82
- * or g:error on error.
83
- *
84
- * @param {object|undefined} opts: additional options, which can include:
85
- * ignoreError: true - ignore the default error handler
86
- * extraPath - a string to append to the end of the resource URL
87
- * data - a dictionary of parameters to pass to the endpoint.
88
- */
89
- fetch: function (opts) {
90
- if (this.altUrl === null && this.resourceName === null) {
91
- throw new Error('An altUrl or resourceName must be set on the Model.');
92
- }
93
-
94
- opts = opts || {};
95
- var restOpts = {
96
- url: `${this.altUrl || this.resourceName}/${this.id}`
97
- };
98
- if (opts.extraPath) {
99
- restOpts.url += '/' + opts.extraPath;
100
- }
101
- if (opts.ignoreError) {
102
- restOpts.error = null;
103
- }
104
- if (opts.data) {
105
- restOpts.data = opts.data;
106
- }
107
- return restRequest(restOpts).done((resp) => {
108
- this.set(resp);
109
- if (opts.extraPath) {
110
- this.trigger('g:fetched.' + opts.extraPath);
111
- } else {
112
- this.trigger('g:fetched');
113
- }
114
- }).fail((err) => {
115
- this.trigger('g:error', err);
116
- });
117
- },
118
-
119
- /**
120
- * Get the path for downloading this resource via the API. Can be used
121
- * as the href property of a direct download link.
122
- * @param params {Object} list of key-value parameters to include in the
123
- * query string.
124
- */
125
- downloadUrl: function (params) {
126
- let url = `${getApiRoot()}/${this.altUrl || this.resourceName}/${this.id}/download`;
127
-
128
- if (params) {
129
- url += '?' + $.param(params);
130
- }
131
-
132
- return url;
133
- },
134
-
135
- /**
136
- * For models that can be downloaded, this method can be used to
137
- * initiate the download in the browser.
138
- */
139
- download: function () {
140
- window.location.assign(this.downloadUrl());
141
- },
142
-
143
- /**
144
- * Delete the model on the server.
145
- * @param opts Options, may contain:
146
- * throwError Whether to throw an error (bool, default=true)
147
- * progress Whether to record progress (bool, default=false)
148
- */
149
- destroy: function (opts) {
150
- if (this.altUrl === null && this.resourceName === null) {
151
- throw new Error('An altUrl or resourceName must be set on the Model.');
152
- }
153
-
154
- var args = {
155
- url: `${this.altUrl || this.resourceName}/${this.id}`,
156
- method: 'DELETE'
157
- };
158
-
159
- opts = opts || {};
160
- if (opts.progress === true) {
161
- args.url += '?progress=true';
162
- }
163
-
164
- if (opts.throwError !== false) {
165
- args.error = null;
166
- }
167
-
168
- return restRequest(args).done(() => {
169
- if (this.collection) {
170
- this.collection.remove(this);
171
- }
172
- this.trigger('g:deleted');
173
- }).fail((err) => {
174
- this.trigger('g:error', err);
175
- });
176
- },
177
-
178
- /**
179
- * Return the access level with respect to the current user
180
- */
181
- getAccessLevel: function () {
182
- return this.get('_accessLevel');
183
- }
184
-
185
- });
186
-
187
- export default Model;
@@ -1,189 +0,0 @@
1
- import _ from 'underscore';
2
-
3
- import { fetchCurrentUser, setCurrentToken, setCurrentUser } from '@girder/core/auth';
4
- import events from '@girder/core/events';
5
- import Model from '@girder/core/models/Model';
6
- import { restRequest } from '@girder/core/rest';
7
- import eventStream from '@girder/core/utilities/EventStream';
8
-
9
- var UserModel = Model.extend({
10
- resourceName: 'user',
11
-
12
- /**
13
- * Calling this function mutates the model in one of two ways: (1) if a user
14
- * is currently logged into Girder, the model will reflect that user; (2) if
15
- * no user is logged in, the model will become clear. To know which path
16
- * occurred, you can call this method, then install a one-time event handler
17
- * for the model's change event. In that handler, calling isNew() on the
18
- * model will tell if you if a user is logged in (false) or not (true).
19
- *
20
- * This is equivalent to invoking fetchCurrentUser(), then calling
21
- * clear() or set() on the model depending on whether the result of the call
22
- * is null or not.
23
- */
24
- current: function () {
25
- fetchCurrentUser()
26
- .done((user) => {
27
- if (user) {
28
- this.set(user);
29
- } else {
30
- this.clear();
31
- }
32
- });
33
- },
34
-
35
- name: function () {
36
- return this.get('firstName') + ' ' + this.get('lastName');
37
- },
38
-
39
- /**
40
- * When this user is added to a group, call this on the user model.
41
- */
42
- addToGroup: function (groupId) {
43
- var groups = this.get('groups') || [];
44
- groups.push(groupId);
45
- this.set('groups', groups);
46
- },
47
-
48
- /**
49
- * When this user is removed from a group, call this on the user model.
50
- */
51
- removeFromGroup: function (groupId) {
52
- var groups = this.get('groups') || [];
53
- var index = groups.indexOf(groupId);
54
-
55
- while (index >= 0) {
56
- groups.splice(index, 1);
57
- index = groups.indexOf(groupId);
58
- }
59
-
60
- this.set('groups', groups);
61
- },
62
-
63
- /**
64
- * When this user is invited to a group, call this on the user model.
65
- */
66
- addInvitation: function (groupId, level) {
67
- var invites = this.get('groupInvites') || [];
68
- invites.push({
69
- groupId: groupId,
70
- level: level
71
- });
72
-
73
- this.set('groupInvites', invites);
74
- },
75
-
76
- /**
77
- * When this user's invitation is deleted, either by joining the group or
78
- * having the invitation deleted manually, this should be called on the user
79
- * model.
80
- */
81
- removeInvitation: function (groupId) {
82
- var invites = this.get('groupInvites') || [];
83
- var filtered = _.reject(invites, _.matcher({ groupId: groupId }));
84
-
85
- this.set('groupInvites', filtered);
86
- },
87
-
88
- /**
89
- * Change the password for this user.
90
- */
91
- changePassword: function (oldPassword, newPassword) {
92
- return restRequest({
93
- url: `${this.resourceName}/password`,
94
- data: {
95
- old: oldPassword,
96
- new: newPassword
97
- },
98
- method: 'PUT',
99
- error: null
100
- }).done(() => {
101
- this.trigger('g:passwordChanged');
102
- }).fail((err) => {
103
- this.trigger('g:error', err);
104
- });
105
- },
106
-
107
- /**
108
- * Change the password for another user (as an admin).
109
- */
110
- adminChangePassword: function (newPassword) {
111
- return restRequest({
112
- url: `${this.resourceName}/${this.id}/password`,
113
- data: {
114
- password: newPassword
115
- },
116
- method: 'PUT',
117
- error: null
118
- }).done(() => {
119
- this.trigger('g:passwordChanged');
120
- }).fail((err) => {
121
- this.trigger('g:error', err);
122
- });
123
- },
124
-
125
- initializeEnableOtp: function () {
126
- return restRequest({
127
- url: `user/${this.id}/otp`,
128
- method: 'POST',
129
- error: null
130
- })
131
- .then((resp) => {
132
- return resp.totpUri;
133
- });
134
- },
135
-
136
- finializeEnableOtp: function (otpToken) {
137
- return restRequest({
138
- url: `user/${this.id}/otp`,
139
- method: 'PUT',
140
- headers: {
141
- 'Girder-OTP': otpToken
142
- },
143
- error: null
144
- })
145
- .done(() => {
146
- this.set('otp', true);
147
- });
148
- },
149
-
150
- disableOtp: function () {
151
- return restRequest({
152
- url: `user/${this.id}/otp`,
153
- method: 'DELETE',
154
- error: null
155
- })
156
- .done(() => {
157
- this.set('otp', false);
158
- });
159
- }
160
- }, {
161
- fromTemporaryToken: function (userId, token) {
162
- return restRequest({
163
- url: `user/password/temporary/${userId}`,
164
- method: 'GET',
165
- data: { token: token },
166
- error: null
167
- }).done((resp) => {
168
- resp.user.token = resp.authToken.token;
169
- eventStream.close();
170
- setCurrentUser(new UserModel(resp.user));
171
- setCurrentToken(resp.authToken.token);
172
- eventStream.open();
173
- events.trigger('g:login-changed');
174
- });
175
- },
176
-
177
- sendVerificationEmail: function (login) {
178
- return restRequest({
179
- url: 'user/verification',
180
- method: 'POST',
181
- data: {
182
- login: login
183
- },
184
- error: null
185
- });
186
- }
187
- });
188
-
189
- export default UserModel;
package/models/index.js DELETED
@@ -1,25 +0,0 @@
1
- import AccessControlledModel from './AccessControlledModel';
2
- import ApiKeyModel from './ApiKeyModel';
3
- import AssetstoreModel from './AssetstoreModel';
4
- import CollectionModel from './CollectionModel';
5
- import FileModel from './FileModel';
6
- import FolderModel from './FolderModel';
7
- import GroupModel from './GroupModel';
8
- import ItemModel from './ItemModel';
9
- import MetadataMixin from './MetadataMixin';
10
- import Model from './Model';
11
- import UserModel from './UserModel';
12
-
13
- export {
14
- AccessControlledModel,
15
- ApiKeyModel,
16
- AssetstoreModel,
17
- CollectionModel,
18
- FileModel,
19
- FolderModel,
20
- GroupModel,
21
- ItemModel,
22
- MetadataMixin,
23
- Model,
24
- UserModel
25
- };
package/pluginUtils.js DELETED
@@ -1,11 +0,0 @@
1
- /**
2
- * Expose the symbols for a girder plugin under the window.girder.plugins
3
- * namespace. Required since each plugin is loaded dynamically.
4
- */
5
- var registerPluginNamespace = function (pluginName, symbols) {
6
- window.girder.plugins[pluginName] = symbols;
7
- };
8
-
9
- export {
10
- registerPluginNamespace
11
- };