@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.
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,427 +0,0 @@
1
- import $ from 'jquery';
2
- import _ from 'underscore';
3
- // Bootstrap tooltip is required by popover
4
- import 'bootstrap/js/tooltip';
5
- import 'bootstrap/js/popover';
6
-
7
- import accessEditorNonModalTemplate from '@girder/core/templates/widgets/accessEditorNonModal.pug';
8
- import accessEditorTemplate from '@girder/core/templates/widgets/accessEditor.pug';
9
- import accessEntryTemplate from '@girder/core/templates/widgets/accessEntry.pug';
10
- import GroupModel from '@girder/core/models/GroupModel';
11
- import LoadingAnimation from '@girder/core/views/widgets/LoadingAnimation';
12
- import SearchFieldWidget from '@girder/core/views/widgets/SearchFieldWidget';
13
- import UserModel from '@girder/core/models/UserModel';
14
- import View from '@girder/core/views/View';
15
- import { getCurrentUser } from '@girder/core/auth';
16
- import { AccessType } from '@girder/core/constants';
17
- import { handleClose, handleOpen } from '@girder/core/dialog';
18
- import { restRequest } from '@girder/core/rest';
19
-
20
- import '@girder/core/stylesheets/widgets/accessWidget.styl';
21
-
22
- import '@girder/core/utilities/jquery/girderModal';
23
-
24
- /**
25
- * This view allows users to see and control access on a resource.
26
- */
27
- var AccessWidget = View.extend({
28
- events: {
29
- 'click button.g-save-access-list': function (e) {
30
- $(e.currentTarget).girderEnable(false);
31
- this.saveAccessList();
32
- },
33
- 'click .g-close-flags-popover': function (e) {
34
- $(e.currentTarget).parents('.g-access-action-container')
35
- .find('.g-action-manage-flags').popover('hide');
36
- },
37
- 'click .g-close-public-flags-popover': function (e) {
38
- $(e.currentTarget).parents('.g-public-container')
39
- .find('.g-action-manage-public-flags').popover('hide');
40
- },
41
- 'click a.g-action-remove-access': 'removeAccessEntry',
42
- 'change .g-public-container .radio input': 'privacyChanged',
43
- 'change .g-flag-checkbox': '_toggleAccessFlag',
44
- 'change .g-public-flag-checkbox': '_togglePublicAccessFlag'
45
- },
46
-
47
- /**
48
- * @param settings.modelType {string} Display name for the resource type
49
- * being edited.
50
- * @param [settings.hideRecurseOption=false] {bool} Whether to hide the recursive
51
- * propagation setting widgets.
52
- * @param [settings.hideSaveButton=false] {bool} Whether to hide the "save"
53
- * button in non-modal view. This allows for users of this widget to
54
- * provide their own save button elsewhere on the page that can call the
55
- * saveAccessList() method of this widget when pressed.
56
- * @param [settings.modal=true] {bool} Whether to render the widget as a
57
- * modal dialog or not.
58
- */
59
- initialize: function (settings) {
60
- this.modelType = settings.modelType;
61
- this.hideRecurseOption = settings.hideRecurseOption || false;
62
- this.hideSaveButton = settings.hideSaveButton || false;
63
- this.hidePrivacyEditor = settings.hidePrivacyEditor || false;
64
- this.hideAccessType = settings.hideAccessType || false;
65
- this.noAccessFlag = settings.noAccessFlag || false;
66
- this.modal = _.has(settings, 'modal') ? settings.modal : true;
67
- this.currentUser = getCurrentUser();
68
- this.isAdmin = !!(this.currentUser && this.currentUser.get('admin'));
69
- this.searchWidget = new SearchFieldWidget({
70
- placeholder: 'Start typing a name...',
71
- noResultsPage: true,
72
- modes: ['prefix', 'text'],
73
- types: ['group', 'user'],
74
- parentView: this
75
- }).on('g:resultClicked', this.addEntry, this);
76
-
77
- var flagListPromise = null;
78
- if (!this.noAccessFlag) {
79
- flagListPromise = restRequest({
80
- url: 'system/access_flag'
81
- }).done((resp) => {
82
- this.flagList = resp;
83
- });
84
- } else {
85
- this.flagList = [];
86
- }
87
-
88
- $.when(
89
- flagListPromise,
90
- this.model.fetchAccess()
91
- ).done(() => {
92
- this.render();
93
- });
94
- },
95
-
96
- render: function () {
97
- if (!this.model.get('access') || !this.flagList) {
98
- new LoadingAnimation({
99
- el: this.$el,
100
- parentView: this
101
- }).render();
102
- return;
103
- }
104
-
105
- var closeFunction;
106
- if (this.modal && this.modelType === 'folder') {
107
- handleOpen('folderaccess');
108
- closeFunction = function () {
109
- handleClose('folderaccess');
110
- };
111
- } else if (this.modal) {
112
- handleOpen('access');
113
- closeFunction = function () {
114
- handleClose('access');
115
- };
116
- }
117
-
118
- var template = this.modal ? accessEditorTemplate : accessEditorNonModalTemplate;
119
-
120
- this.$el.html(template({
121
- _,
122
- model: this.model,
123
- modelType: this.modelType,
124
- publicFlag: this.model.get('public'),
125
- publicFlags: this.model.get('publicFlags'),
126
- hideRecurseOption: this.hideRecurseOption,
127
- hideSaveButton: this.hideSaveButton,
128
- hidePrivacyEditor: this.hidePrivacyEditor,
129
- flagList: this.flagList,
130
- isAdmin: this.isAdmin
131
- }));
132
-
133
- if (this.modal) {
134
- this.$el.girderModal(this).on('hidden.bs.modal', closeFunction);
135
- }
136
-
137
- _.each(this.model.get('access').groups, function (groupAccess) {
138
- this.$('#g-ac-list-groups').append(accessEntryTemplate({
139
- _,
140
- accessTypes: AccessType,
141
- type: 'group',
142
- flagList: this.flagList,
143
- isAdmin: this.isAdmin,
144
- hideAccessType: this.hideAccessType,
145
- noAccessFlag: this.noAccessFlag,
146
- entry: _.extend(groupAccess, {
147
- title: groupAccess.name,
148
- subtitle: groupAccess.description
149
- })
150
- }));
151
- }, this);
152
-
153
- _.each(this.model.get('access').users, function (userAccess) {
154
- this.$('#g-ac-list-users').append(accessEntryTemplate({
155
- _,
156
- accessTypes: AccessType,
157
- type: 'user',
158
- flagList: this.flagList,
159
- isAdmin: this.isAdmin,
160
- hideAccessType: this.hideAccessType,
161
- noAccessFlag: this.noAccessFlag,
162
- entry: _.extend(userAccess, {
163
- title: userAccess.name,
164
- subtitle: userAccess.login
165
- })
166
- }));
167
- }, this);
168
- this._makeTooltips();
169
-
170
- this.searchWidget.setElement(this.$('.g-search-field-container')).render();
171
-
172
- this.privacyChanged();
173
-
174
- return this;
175
- },
176
-
177
- _makeTooltips: function () {
178
- // Re-binding popovers actually breaks them, so we make sure to
179
- // only bind ones that aren't already bound.
180
- _.each(this.$('.g-action-manage-flags'), (el) => {
181
- if (!$(el).data('bs.popover')) {
182
- $(el).popover({
183
- trigger: 'manual',
184
- placement: 'left',
185
- viewport: {
186
- selector: 'body',
187
- padding: 10
188
- },
189
- content: function () {
190
- return $(this).parent().find('.g-flags-popover-container').html();
191
- },
192
- html: true,
193
- sanitize: false
194
- }).on('click', function () {
195
- $(this).popover('toggle');
196
- });
197
- }
198
- });
199
-
200
- // Re-binding popovers actually breaks them, so we make sure to
201
- // only bind ones that aren't already bound.
202
- _.each(this.$('.g-action-manage-public-flags'), (el) => {
203
- if (!$(el).data('bs.popover')) {
204
- $(el).popover({
205
- trigger: 'manual',
206
- placement: 'right',
207
- viewport: {
208
- selector: 'body',
209
- padding: 10
210
- },
211
- content: function () {
212
- return $(this).parent().find('.g-public-flags-popover-container').html();
213
- },
214
- html: true,
215
- sanitize: false
216
- }).on('click', function () {
217
- $(this).popover('toggle');
218
- });
219
- }
220
- });
221
- },
222
-
223
- /**
224
- * Add a new user or group entry to the access control list UI. If the
225
- * given user or group already has an entry there, this does nothing.
226
- */
227
- addEntry: function (entry) {
228
- this.searchWidget.resetState();
229
- if (entry.type === 'user') {
230
- this._addUserEntry(entry);
231
- } else if (entry.type === 'group') {
232
- this._addGroupEntry(entry);
233
- }
234
- },
235
-
236
- _addUserEntry: function (entry) {
237
- var exists = false;
238
- _.every(this.$('.g-user-access-entry'), function (el) {
239
- if ($(el).attr('resourceid') === entry.id) {
240
- exists = true;
241
- }
242
- return !exists;
243
- }, this);
244
-
245
- if (!exists) {
246
- var model = new UserModel();
247
- model.set('_id', entry.id).on('g:fetched', function () {
248
- this.$('#g-ac-list-users').append(accessEntryTemplate({
249
- _,
250
- accessTypes: AccessType,
251
- type: 'user',
252
- entry: {
253
- title: model.name(),
254
- subtitle: model.get('login'),
255
- id: entry.id,
256
- level: AccessType.READ
257
- },
258
- isAdmin: this.isAdmin,
259
- hideAccessType: this.hideAccessType,
260
- noAccessFlag: this.noAccessFlag,
261
- flagList: this.flagList
262
- }));
263
- this._makeTooltips();
264
- }, this).fetch();
265
- }
266
- },
267
-
268
- _addGroupEntry: function (entry) {
269
- var exists = false;
270
- _.every(this.$('.g-group-access-entry'), function (el) {
271
- if ($(el).attr('resourceid') === entry.id) {
272
- exists = true;
273
- }
274
- return !exists;
275
- }, this);
276
-
277
- if (!exists) {
278
- var model = new GroupModel();
279
- model.set('_id', entry.id).on('g:fetched', function () {
280
- this.$('#g-ac-list-groups').append(accessEntryTemplate({
281
- _,
282
- accessTypes: AccessType,
283
- type: 'group',
284
- entry: {
285
- title: model.name(),
286
- subtitle: model.get('description'),
287
- id: entry.id,
288
- level: AccessType.READ
289
- },
290
- isAdmin: this.isAdmin,
291
- hideAccessType: this.hideAccessType,
292
- noAccessFlag: this.noAccessFlag,
293
- flagList: this.flagList
294
- }));
295
-
296
- this._makeTooltips();
297
- }, this).fetch();
298
- }
299
- },
300
-
301
- saveAccessList: function () {
302
- var acList = this.getAccessList();
303
-
304
- var publicFlags = _.map(this.$('.g-public-flag-checkbox:checked'), (checkbox) => {
305
- return $(checkbox).attr('flag');
306
- });
307
-
308
- this.model.set({
309
- access: acList,
310
- public: this.$('#g-access-public').is(':checked'),
311
- publicFlags: publicFlags
312
- });
313
-
314
- var recurse = this.$('#g-apply-recursive').is(':checked');
315
-
316
- this.model.off('g:accessListSaved', null, this)
317
- .on('g:accessListSaved', function () {
318
- if (this.modal) {
319
- this.$el.modal('hide');
320
- }
321
-
322
- this.trigger('g:accessListSaved', {
323
- recurse: recurse
324
- });
325
- }, this).updateAccess({
326
- recurse: recurse,
327
- progress: true
328
- });
329
- },
330
-
331
- getAccessList: function () {
332
- // Rebuild the access list
333
- var acList = {
334
- users: [],
335
- groups: []
336
- };
337
-
338
- _.each(this.$('.g-group-access-entry'), function (el) {
339
- var $el = $(el);
340
- acList.groups.push({
341
- name: $el.find('.g-desc-title').html(),
342
- id: $el.attr('resourceid'),
343
- level: parseInt(
344
- $el.find('.g-access-col-right>select').val() || 0,
345
- 10
346
- ),
347
- flags: _.map($el.find('.g-flag-checkbox:checked'),
348
- (checkbox) => $(checkbox).attr('flag')
349
- )
350
- });
351
- }, this);
352
-
353
- _.each(this.$('.g-user-access-entry'), function (el) {
354
- var $el = $(el);
355
- acList.users.push({
356
- login: $el.find('.g-desc-subtitle').html(),
357
- name: $el.find('.g-desc-title').html(),
358
- id: $el.attr('resourceid'),
359
- level: parseInt(
360
- $el.find('.g-access-col-right>select').val() || 0,
361
- 10
362
- ),
363
- flags: _.map($el.find('.g-flag-checkbox:checked'),
364
- (checkbox) => $(checkbox).attr('flag')
365
- )
366
- });
367
- }, this);
368
-
369
- return acList;
370
- },
371
-
372
- removeAccessEntry: function (event) {
373
- var sel = '.g-user-access-entry,.g-group-access-entry';
374
- $(event.currentTarget).parents(sel).remove();
375
- },
376
-
377
- privacyChanged: function () {
378
- this.$('.g-public-container .radio').removeClass('g-selected');
379
- var selected = this.$('.g-public-container .radio input:checked');
380
- selected.parents('.radio').addClass('g-selected');
381
-
382
- if (this.$('#g-access-public').is(':checked')) {
383
- this.$('.g-action-manage-public-flags').removeClass('hide');
384
- } else {
385
- this.$('.g-action-manage-public-flags').addClass('hide');
386
- }
387
- },
388
-
389
- _toggleAccessFlag: function (e) {
390
- var el = $(e.currentTarget),
391
- type = el.attr('resourcetype'),
392
- id = el.attr('resourceid'),
393
- flag = el.attr('flag'),
394
- container = this.$(`.g-flags-popover-container[resourcetype='${type}'][resourceid='${id}']`);
395
-
396
- // Since we clicked in a cloned popover element, we must apply this
397
- // change within the original element as well.
398
- container.find(`.g-flag-checkbox[flag="${flag}"]`)
399
- .attr('checked', el.is(':checked') ? 'checked' : null);
400
- this._updateFlagCount(container, '.g-flag-checkbox');
401
- },
402
-
403
- _togglePublicAccessFlag: function (e) {
404
- var el = $(e.currentTarget),
405
- flag = el.attr('flag'),
406
- container = this.$('.g-public-flags-popover-container');
407
-
408
- // Since we clicked in a cloned popover element, we must apply this
409
- // change within the original element as well.
410
- container.find(`.g-public-flag-checkbox[flag="${flag}"]`)
411
- .attr('checked', el.is(':checked') ? 'checked' : null);
412
- this._updateFlagCount(container, '.g-public-flag-checkbox');
413
- },
414
-
415
- _updateFlagCount: function (container, sel) {
416
- const nChecked = container.find(`${sel}[checked="checked"]`).length;
417
- const countEl = container.parent().find('.g-flag-count-indicator');
418
- countEl.text(nChecked);
419
- if (nChecked) {
420
- countEl.removeClass('hide');
421
- } else {
422
- countEl.addClass('hide');
423
- }
424
- }
425
- });
426
-
427
- export default AccessWidget;
@@ -1,140 +0,0 @@
1
- import $ from 'jquery';
2
- import moment from 'moment';
3
- // Bootstrap tooltip is required by popover
4
- import 'bootstrap/js/tooltip';
5
- import 'bootstrap/js/popover';
6
-
7
- import ApiKeyCollection from '@girder/core/collections/ApiKeyCollection';
8
- import EditApiKeyWidget from '@girder/core/views/widgets/EditApiKeyWidget';
9
- import PaginateWidget from '@girder/core/views/widgets/PaginateWidget';
10
- import View from '@girder/core/views/View';
11
- import { confirm } from '@girder/core/dialog';
12
- import events from '@girder/core/events';
13
-
14
- import ApiKeyListTemplate from '@girder/core/templates/widgets/apiKeyList.pug';
15
-
16
- var ApiKeyListWidget = View.extend({
17
- events: {
18
- 'click .g-api-key-toggle-active': function (e) {
19
- var apiKey = this._getModelFromEvent(e);
20
- var toggleActive = () => {
21
- apiKey.once('g:setActive', function () {
22
- this.render();
23
- }, this).setActive(!apiKey.get('active'));
24
- };
25
-
26
- if (apiKey.get('active')) {
27
- confirm({
28
- text: 'Deactivating this API key will delete any existing tokens ' +
29
- 'created with it, and will not be usable until it is activated ' +
30
- 'again. Are you sure you want to deactivate it?',
31
- yesText: 'Yes',
32
- yesClass: 'btn-warning',
33
- escapedHtml: true,
34
- confirmCallback: toggleActive
35
- });
36
- } else {
37
- toggleActive();
38
- }
39
- },
40
-
41
- 'click .g-api-key-new': function (e) {
42
- this._renderEditWidget();
43
- },
44
-
45
- 'click .g-api-key-edit': function (e) {
46
- var apiKey = this._getModelFromEvent(e);
47
- this._renderEditWidget(apiKey);
48
- },
49
-
50
- 'click .g-api-key-delete': function (e) {
51
- var apiKey = this._getModelFromEvent(e);
52
-
53
- confirm({
54
- text: 'Are you sure you want to delete the API key <b>' +
55
- apiKey.escape('name') + '</b>? Any client applications using ' +
56
- 'this key will no longer be able to authenticate.',
57
- yesText: 'Delete',
58
- escapedHtml: true,
59
- confirmCallback: () => {
60
- apiKey.on('g:deleted', function () {
61
- events.trigger('g:alert', {
62
- icon: 'ok',
63
- text: 'API key deleted.',
64
- type: 'success',
65
- timeout: 3000
66
- });
67
- this.render();
68
- }, this).destroy();
69
- }
70
- });
71
- }
72
- },
73
-
74
- /**
75
- * A widget for listing and editing API keys for a user.
76
- *
77
- * @param settings.user {UserModel} The user whose keys to show.
78
- */
79
- initialize: function (settings) {
80
- this.model = settings.user;
81
- this.fetched = false;
82
-
83
- this.collection = new ApiKeyCollection();
84
- this.collection.on('g:changed', function () {
85
- this.fetched = true;
86
- this.render();
87
- this.trigger('g:changed');
88
- }, this).fetch({
89
- userId: this.model.id
90
- });
91
-
92
- this.paginateWidget = new PaginateWidget({
93
- collection: this.collection,
94
- parentView: this
95
- });
96
- },
97
-
98
- render: function () {
99
- if (!this.fetched) {
100
- return;
101
- }
102
-
103
- this.$el.html(ApiKeyListTemplate({
104
- apiKeys: this.collection.toArray(),
105
- moment: moment
106
- }));
107
-
108
- this.$('.g-show-api-key').popover({
109
- container: this.$('.g-api-key-table'),
110
- placement: 'top'
111
- });
112
-
113
- this.paginateWidget.setElement(this.$('.g-paginate-container')).render();
114
-
115
- return this;
116
- },
117
-
118
- _getModelFromEvent: function (e) {
119
- var cid = $(e.currentTarget).parents('.g-api-key-container').attr('cid');
120
- return this.collection.get(cid);
121
- },
122
-
123
- _renderEditWidget: function (apiKey) {
124
- if (!this.editApiKeyWidget) {
125
- this.editApiKeyWidget = new EditApiKeyWidget({
126
- el: $('#g-dialog-container'),
127
- parentView: this
128
- }).on('g:saved', function (model) {
129
- if (!this.collection.get(model.cid)) {
130
- this.collection.add(model);
131
- }
132
- this.render();
133
- }, this);
134
- }
135
- this.editApiKeyWidget.model = apiKey || null;
136
- this.editApiKeyWidget.render();
137
- }
138
- });
139
-
140
- export default ApiKeyListWidget;