@girder/core 5.0.0-beta.1 → 5.0.0

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 (238) hide show
  1. package/dist-lib/Girder_Favicon.png +0 -0
  2. package/dist-lib/Girder_Mark.png +0 -0
  3. package/dist-lib/girder-core.css +2 -0
  4. package/dist-lib/girder-core.js +60421 -0
  5. package/dist-lib/girder-core.js.map +1 -0
  6. package/dist-lib/girder-core.umd.cjs +1484 -0
  7. package/dist-lib/girder-core.umd.cjs.map +1 -0
  8. package/dist-lib/index.d.ts +1 -0
  9. package/dist-lib/src/auth.js +112 -0
  10. package/dist-lib/src/collections/ApiKeyCollection.js +9 -0
  11. package/dist-lib/src/collections/AssetstoreCollection.js +10 -0
  12. package/dist-lib/src/collections/Collection.js +295 -0
  13. package/dist-lib/src/collections/CollectionCollection.js +9 -0
  14. package/dist-lib/src/collections/FileCollection.js +11 -0
  15. package/dist-lib/src/collections/FolderCollection.js +11 -0
  16. package/dist-lib/src/collections/GroupCollection.js +9 -0
  17. package/dist-lib/src/collections/ItemCollection.js +11 -0
  18. package/dist-lib/src/collections/UserCollection.js +24 -0
  19. package/dist-lib/src/collections/index.js +21 -0
  20. package/dist-lib/src/constants.js +32 -0
  21. package/dist-lib/src/dialog.js +128 -0
  22. package/dist-lib/src/events.js +6 -0
  23. package/dist-lib/src/index.ts +80 -0
  24. package/dist-lib/src/main.ts +61 -0
  25. package/dist-lib/src/misc.js +260 -0
  26. package/dist-lib/src/models/AccessControlledModel.js +76 -0
  27. package/dist-lib/src/models/ApiKeyModel.js +31 -0
  28. package/dist-lib/src/models/AssetstoreModel.js +43 -0
  29. package/dist-lib/src/models/CollectionCreationPolicyModel.js +20 -0
  30. package/dist-lib/src/models/CollectionModel.js +12 -0
  31. package/dist-lib/src/models/FileModel.js +310 -0
  32. package/dist-lib/src/models/FolderModel.js +33 -0
  33. package/dist-lib/src/models/GroupModel.js +197 -0
  34. package/dist-lib/src/models/ItemModel.js +72 -0
  35. package/dist-lib/src/models/MetadataMixin.js +88 -0
  36. package/dist-lib/src/models/Model.js +187 -0
  37. package/dist-lib/src/models/UserModel.js +189 -0
  38. package/dist-lib/src/models/index.js +25 -0
  39. package/dist-lib/src/pluginUtils.js +11 -0
  40. package/dist-lib/src/rest.js +221 -0
  41. package/dist-lib/src/router.js +58 -0
  42. package/dist-lib/src/routes.js +229 -0
  43. package/dist-lib/src/stylesheets/apidocs/apidocs.styl +50 -0
  44. package/dist-lib/src/stylesheets/body/adminConsole.styl +21 -0
  45. package/dist-lib/src/stylesheets/body/assetstores.styl +46 -0
  46. package/dist-lib/src/stylesheets/body/collectionList.styl +39 -0
  47. package/dist-lib/src/stylesheets/body/collectionPage.styl +6 -0
  48. package/dist-lib/src/stylesheets/body/frontPage.styl +48 -0
  49. package/dist-lib/src/stylesheets/body/groupList.styl +43 -0
  50. package/dist-lib/src/stylesheets/body/groupPage.styl +116 -0
  51. package/dist-lib/src/stylesheets/body/itemPage.styl +81 -0
  52. package/dist-lib/src/stylesheets/body/plugins.styl +61 -0
  53. package/dist-lib/src/stylesheets/body/searchResultsList.styl +51 -0
  54. package/dist-lib/src/stylesheets/body/systemConfig.styl +56 -0
  55. package/dist-lib/src/stylesheets/body/userAccount.styl +57 -0
  56. package/dist-lib/src/stylesheets/body/userList.styl +79 -0
  57. package/dist-lib/src/stylesheets/body/userPage.styl +6 -0
  58. package/dist-lib/src/stylesheets/layout/footer.styl +19 -0
  59. package/dist-lib/src/stylesheets/layout/global.styl +154 -0
  60. package/dist-lib/src/stylesheets/layout/globalNav.styl +89 -0
  61. package/dist-lib/src/stylesheets/layout/header.styl +29 -0
  62. package/dist-lib/src/stylesheets/layout/headerUser.styl +33 -0
  63. package/dist-lib/src/stylesheets/layout/layout.styl +75 -0
  64. package/dist-lib/src/stylesheets/layout/layoutVars.styl +9 -0
  65. package/dist-lib/src/stylesheets/layout/loading.styl +37 -0
  66. package/dist-lib/src/stylesheets/layout/progressArea.styl +17 -0
  67. package/dist-lib/src/stylesheets/widgets/accessWidget.styl +106 -0
  68. package/dist-lib/src/stylesheets/widgets/browserWidget.styl +9 -0
  69. package/dist-lib/src/stylesheets/widgets/hierarchyWidget.styl +188 -0
  70. package/dist-lib/src/stylesheets/widgets/markdownWidget.styl +92 -0
  71. package/dist-lib/src/stylesheets/widgets/metadataWidget.styl +92 -0
  72. package/dist-lib/src/stylesheets/widgets/searchFieldWidget.styl +70 -0
  73. package/dist-lib/src/stylesheets/widgets/taskProgress.styl +41 -0
  74. package/dist-lib/src/stylesheets/widgets/timelineWidget.styl +41 -0
  75. package/dist-lib/src/stylesheets/widgets/uploadWidget.styl +43 -0
  76. package/dist-lib/src/stylesheets/widgets/userOtpManagementWidget.styl +159 -0
  77. package/dist-lib/src/templates/body/adminConsole.pug +13 -0
  78. package/dist-lib/src/templates/body/assetstores.pug +83 -0
  79. package/dist-lib/src/templates/body/collectionList.pug +40 -0
  80. package/dist-lib/src/templates/body/collectionPage.pug +36 -0
  81. package/dist-lib/src/templates/body/filesystemImport.pug +41 -0
  82. package/dist-lib/src/templates/body/frontPage.pug +83 -0
  83. package/dist-lib/src/templates/body/groupList.pug +30 -0
  84. package/dist-lib/src/templates/body/groupPage.pug +116 -0
  85. package/dist-lib/src/templates/body/itemPage.pug +61 -0
  86. package/dist-lib/src/templates/body/plugins.pug +20 -0
  87. package/dist-lib/src/templates/body/s3Import.pug +35 -0
  88. package/dist-lib/src/templates/body/searchResults.pug +15 -0
  89. package/dist-lib/src/templates/body/searchResultsType.pug +13 -0
  90. package/dist-lib/src/templates/body/systemConfiguration.pug +215 -0
  91. package/dist-lib/src/templates/body/userAccount.pug +83 -0
  92. package/dist-lib/src/templates/body/userList.pug +43 -0
  93. package/dist-lib/src/templates/body/userPage.pug +40 -0
  94. package/dist-lib/src/templates/layout/alert.pug +5 -0
  95. package/dist-lib/src/templates/layout/layout.pug +12 -0
  96. package/dist-lib/src/templates/layout/layoutFooter.pug +11 -0
  97. package/dist-lib/src/templates/layout/layoutGlobalNav.pug +7 -0
  98. package/dist-lib/src/templates/layout/layoutHeader.pug +8 -0
  99. package/dist-lib/src/templates/layout/layoutHeaderUser.pug +26 -0
  100. package/dist-lib/src/templates/layout/layoutProgressArea.pug +1 -0
  101. package/dist-lib/src/templates/layout/loginDialog.pug +30 -0
  102. package/dist-lib/src/templates/layout/registerDialog.pug +35 -0
  103. package/dist-lib/src/templates/layout/resetPasswordDialog.pug +25 -0
  104. package/dist-lib/src/templates/widgets/accessEditor.pug +23 -0
  105. package/dist-lib/src/templates/widgets/accessEditorMixins.pug +57 -0
  106. package/dist-lib/src/templates/widgets/accessEditorNonModal.pug +11 -0
  107. package/dist-lib/src/templates/widgets/accessEntry.pug +32 -0
  108. package/dist-lib/src/templates/widgets/apiKeyList.pug +50 -0
  109. package/dist-lib/src/templates/widgets/browserWidget.pug +32 -0
  110. package/dist-lib/src/templates/widgets/checkedActionsMenu.pug +46 -0
  111. package/dist-lib/src/templates/widgets/collectionInfoDialog.pug +37 -0
  112. package/dist-lib/src/templates/widgets/confirmDialog.pug +14 -0
  113. package/dist-lib/src/templates/widgets/dateTimeRangeWidget.pug +20 -0
  114. package/dist-lib/src/templates/widgets/dateTimeWidget.pug +8 -0
  115. package/dist-lib/src/templates/widgets/editApiKeyWidget.pug +43 -0
  116. package/dist-lib/src/templates/widgets/editAssetstoreWidget.pug +70 -0
  117. package/dist-lib/src/templates/widgets/editCollectionWidget.pug +27 -0
  118. package/dist-lib/src/templates/widgets/editFileWidget.pug +21 -0
  119. package/dist-lib/src/templates/widgets/editFolderWidget.pug +27 -0
  120. package/dist-lib/src/templates/widgets/editGroupWidget.pug +54 -0
  121. package/dist-lib/src/templates/widgets/editItemWidget.pug +27 -0
  122. package/dist-lib/src/templates/widgets/fileInfoDialog.pug +33 -0
  123. package/dist-lib/src/templates/widgets/fileList.pug +33 -0
  124. package/dist-lib/src/templates/widgets/folderInfoDialog.pug +42 -0
  125. package/dist-lib/src/templates/widgets/folderList.pug +21 -0
  126. package/dist-lib/src/templates/widgets/groupAdminList.pug +33 -0
  127. package/dist-lib/src/templates/widgets/groupInviteDialog.pug +76 -0
  128. package/dist-lib/src/templates/widgets/groupInviteList.pug +14 -0
  129. package/dist-lib/src/templates/widgets/groupMemberList.pug +39 -0
  130. package/dist-lib/src/templates/widgets/groupModList.pug +23 -0
  131. package/dist-lib/src/templates/widgets/hierarchyBreadcrumb.pug +37 -0
  132. package/dist-lib/src/templates/widgets/hierarchyPaginated.pug +19 -0
  133. package/dist-lib/src/templates/widgets/hierarchyWidget.pug +96 -0
  134. package/dist-lib/src/templates/widgets/itemBreadcrumb.pug +16 -0
  135. package/dist-lib/src/templates/widgets/itemList.pug +27 -0
  136. package/dist-lib/src/templates/widgets/jsonMetadatumEditWidget.pug +13 -0
  137. package/dist-lib/src/templates/widgets/jsonMetadatumView.pug +6 -0
  138. package/dist-lib/src/templates/widgets/loadingAnimation.pug +4 -0
  139. package/dist-lib/src/templates/widgets/markdownWidget.pug +34 -0
  140. package/dist-lib/src/templates/widgets/metadataWidget.pug +16 -0
  141. package/dist-lib/src/templates/widgets/metadatumEditWidget.pug +15 -0
  142. package/dist-lib/src/templates/widgets/metadatumView.pug +5 -0
  143. package/dist-lib/src/templates/widgets/newAssetstore.pug +87 -0
  144. package/dist-lib/src/templates/widgets/paginateWidget.pug +7 -0
  145. package/dist-lib/src/templates/widgets/pluginConfigBreadcrumb.pug +13 -0
  146. package/dist-lib/src/templates/widgets/rootSelectorWidget.pug +13 -0
  147. package/dist-lib/src/templates/widgets/searchField.pug +10 -0
  148. package/dist-lib/src/templates/widgets/searchHelp.pug +12 -0
  149. package/dist-lib/src/templates/widgets/searchModeSelect.pug +9 -0
  150. package/dist-lib/src/templates/widgets/searchResults.pug +14 -0
  151. package/dist-lib/src/templates/widgets/sortCollectionWidget.pug +14 -0
  152. package/dist-lib/src/templates/widgets/taskProgress.pug +16 -0
  153. package/dist-lib/src/templates/widgets/timeline.pug +15 -0
  154. package/dist-lib/src/templates/widgets/uploadWidget.pug +15 -0
  155. package/dist-lib/src/templates/widgets/uploadWidgetMixins.pug +31 -0
  156. package/dist-lib/src/templates/widgets/uploadWidgetNonModal.pug +10 -0
  157. package/dist-lib/src/templates/widgets/userOtpBegin.pug +4 -0
  158. package/dist-lib/src/templates/widgets/userOtpDisable.pug +6 -0
  159. package/dist-lib/src/templates/widgets/userOtpEnable.pug +44 -0
  160. package/dist-lib/src/utilities/EventStream.js +119 -0
  161. package/dist-lib/src/utilities/PluginUtils.js +36 -0
  162. package/dist-lib/src/utilities/S3UploadHandler.js +263 -0
  163. package/dist-lib/src/utilities/index.js +9 -0
  164. package/dist-lib/src/utilities/jquery/girderEnable.js +19 -0
  165. package/dist-lib/src/utilities/jquery/girderModal.js +48 -0
  166. package/dist-lib/src/version.js +6 -0
  167. package/dist-lib/src/views/App.js +359 -0
  168. package/dist-lib/src/views/View.js +79 -0
  169. package/dist-lib/src/views/body/AdminView.js +29 -0
  170. package/dist-lib/src/views/body/AssetstoresView.js +233 -0
  171. package/dist-lib/src/views/body/CollectionView.js +188 -0
  172. package/dist-lib/src/views/body/CollectionsView.js +120 -0
  173. package/dist-lib/src/views/body/FilesystemImportView.js +83 -0
  174. package/dist-lib/src/views/body/FolderView.js +54 -0
  175. package/dist-lib/src/views/body/FrontPageView.js +47 -0
  176. package/dist-lib/src/views/body/GroupView.js +336 -0
  177. package/dist-lib/src/views/body/GroupsView.js +106 -0
  178. package/dist-lib/src/views/body/ItemView.js +177 -0
  179. package/dist-lib/src/views/body/PluginsView.js +73 -0
  180. package/dist-lib/src/views/body/S3ImportView.js +80 -0
  181. package/dist-lib/src/views/body/SearchResultsView.js +162 -0
  182. package/dist-lib/src/views/body/SystemConfigurationView.js +177 -0
  183. package/dist-lib/src/views/body/UserAccountView.js +179 -0
  184. package/dist-lib/src/views/body/UserView.js +165 -0
  185. package/dist-lib/src/views/body/UsersView.js +124 -0
  186. package/dist-lib/src/views/body/index.js +38 -0
  187. package/dist-lib/src/views/index.js +13 -0
  188. package/dist-lib/src/views/layout/FooterView.js +29 -0
  189. package/dist-lib/src/views/layout/GlobalNavView.js +103 -0
  190. package/dist-lib/src/views/layout/HeaderUserView.js +45 -0
  191. package/dist-lib/src/views/layout/HeaderView.js +83 -0
  192. package/dist-lib/src/views/layout/LoginView.js +100 -0
  193. package/dist-lib/src/views/layout/ProgressListView.js +70 -0
  194. package/dist-lib/src/views/layout/RegisterView.js +101 -0
  195. package/dist-lib/src/views/layout/ResetPasswordView.js +70 -0
  196. package/dist-lib/src/views/layout/index.js +19 -0
  197. package/dist-lib/src/views/widgets/AccessWidget.js +427 -0
  198. package/dist-lib/src/views/widgets/ApiKeyListWidget.js +140 -0
  199. package/dist-lib/src/views/widgets/BrowserWidget.js +317 -0
  200. package/dist-lib/src/views/widgets/CheckedMenuWidget.js +68 -0
  201. package/dist-lib/src/views/widgets/CollectionInfoWidget.js +40 -0
  202. package/dist-lib/src/views/widgets/DateTimeRangeWidget.js +180 -0
  203. package/dist-lib/src/views/widgets/DateTimeWidget.js +110 -0
  204. package/dist-lib/src/views/widgets/EditApiKeyWidget.js +124 -0
  205. package/dist-lib/src/views/widgets/EditAssetstoreWidget.js +136 -0
  206. package/dist-lib/src/views/widgets/EditCollectionWidget.js +93 -0
  207. package/dist-lib/src/views/widgets/EditFileWidget.js +56 -0
  208. package/dist-lib/src/views/widgets/EditFolderWidget.js +116 -0
  209. package/dist-lib/src/views/widgets/EditGroupWidget.js +125 -0
  210. package/dist-lib/src/views/widgets/EditItemWidget.js +110 -0
  211. package/dist-lib/src/views/widgets/FileInfoWidget.js +26 -0
  212. package/dist-lib/src/views/widgets/FileListWidget.js +151 -0
  213. package/dist-lib/src/views/widgets/FolderInfoWidget.js +39 -0
  214. package/dist-lib/src/views/widgets/FolderListWidget.js +106 -0
  215. package/dist-lib/src/views/widgets/GroupAdminsWidget.js +88 -0
  216. package/dist-lib/src/views/widgets/GroupInvitesWidget.js +56 -0
  217. package/dist-lib/src/views/widgets/GroupMembersWidget.js +185 -0
  218. package/dist-lib/src/views/widgets/GroupModsWidget.js +77 -0
  219. package/dist-lib/src/views/widgets/HierarchyWidget.js +1097 -0
  220. package/dist-lib/src/views/widgets/ItemBreadcrumbWidget.js +38 -0
  221. package/dist-lib/src/views/widgets/ItemListWidget.js +345 -0
  222. package/dist-lib/src/views/widgets/LoadingAnimation.js +17 -0
  223. package/dist-lib/src/views/widgets/MarkdownWidget.js +217 -0
  224. package/dist-lib/src/views/widgets/MetadataWidget.js +508 -0
  225. package/dist-lib/src/views/widgets/NewAssetstoreWidget.js +72 -0
  226. package/dist-lib/src/views/widgets/PaginateWidget.js +37 -0
  227. package/dist-lib/src/views/widgets/PluginConfigBreadcrumbWidget.js +33 -0
  228. package/dist-lib/src/views/widgets/RootSelectorWidget.js +192 -0
  229. package/dist-lib/src/views/widgets/SearchFieldWidget.js +365 -0
  230. package/dist-lib/src/views/widgets/SearchPaginateWidget.js +149 -0
  231. package/dist-lib/src/views/widgets/SortCollectionWidget.js +53 -0
  232. package/dist-lib/src/views/widgets/TaskProgressWidget.js +91 -0
  233. package/dist-lib/src/views/widgets/TimelineWidget.js +155 -0
  234. package/dist-lib/src/views/widgets/UploadWidget.js +340 -0
  235. package/dist-lib/src/views/widgets/UserOtpManagementWidget.js +105 -0
  236. package/dist-lib/src/views/widgets/index.js +81 -0
  237. package/dist-lib/src/vite-env.d.ts +5 -0
  238. package/package.json +17 -15
@@ -0,0 +1,221 @@
1
+ import $ from 'jquery';
2
+ import _ from 'underscore';
3
+ import Backbone from 'backbone';
4
+
5
+ import events from '@girder/core/events';
6
+ import { getCurrentToken, setCurrentUser, setCurrentToken } from '@girder/core/auth';
7
+
8
+ let apiRoot;
9
+ var uploadHandlers = {};
10
+ var uploadChunkSize = 1024 * 1024 * 64; // 64MB
11
+
12
+ /**
13
+ * Get the root path to the API.
14
+ *
15
+ * This may be an absolute path, or a path relative to the application root. It will never include
16
+ * a trailing slash.
17
+ *
18
+ * @returns {string}
19
+ */
20
+ function getApiRoot() {
21
+ return apiRoot;
22
+ }
23
+
24
+ /**
25
+ * Set the root path to the API.
26
+ *
27
+ * @param {string} root The root path for the API.
28
+ */
29
+ function setApiRoot(root) {
30
+ // Strip trailing slash
31
+ apiRoot = root.replace(/\/$/, '');
32
+ }
33
+
34
+ /**
35
+ * Make a request to the REST API.
36
+ *
37
+ * This is a wrapper around {@link http://api.jquery.com/jQuery.ajax/ $.ajax}, which also handles
38
+ * authentication and routing to the Girder API, and provides a default for error notification.
39
+ *
40
+ * Most users of this method should attach a "done" handler to the return value. In cases where the
41
+ * server is ordinarily expected to return a non-200 status (e.g. validating user input), the
42
+ * "error: null" argument should probably be provided, and errors should be processed via an
43
+ * attached "fail" handler.
44
+ *
45
+ * Before this function is called, the API root must be set (which typically happens automatically).
46
+ *
47
+ * @param {Object} opts Options for the request, most of which will be passed through to $.ajax.
48
+ * @param {string} opts.url The resource path, relative to the API root, without leading or trailing
49
+ * slashes. e.g. "user/login"
50
+ * @param {string} [opts.method='GET'] The HTTP method to invoke.
51
+ * @param {string|Object} [opts.data] The query string or form parameter object.
52
+ * @param {?Function} [opts.error] An error callback, as documented in
53
+ * {@link http://api.jquery.com/jQuery.ajax/ $.ajax}, or null. If not provided, this will
54
+ * have a default behavior of triggering a 'g:alert' global event, with details of the
55
+ * error, and logging the error to the console. It is recommended that you do not ever pass
56
+ * a non-null callback function, and handle errors via promise rejection handlers instead.
57
+ * @param {string} [opts.girderToken] An alternative auth token to use for this request.
58
+ * @returns {$.Promise} A jqXHR promise, which resolves and rejects
59
+ * {@link http://api.jquery.com/jQuery.ajax/#jqXHR as documented by $.ajax}.
60
+ */
61
+ const restRequest = function (opts) {
62
+ opts = opts || {};
63
+ const defaults = {
64
+ // the default 'method' is 'GET', as set by 'jquery.ajax'
65
+
66
+ girderToken: getCurrentToken() || window.localStorage.getItem('girderToken'),
67
+
68
+ error: (error, status) => {
69
+ let info;
70
+ if (error.status === 401) {
71
+ setCurrentUser(null);
72
+ setCurrentToken(null);
73
+ events.trigger('g:loginUi');
74
+ info = {
75
+ text: 'You must log in to view this resource',
76
+ type: 'warning',
77
+ timeout: 4000,
78
+ icon: 'info'
79
+ };
80
+ } else if (error.status === 403) {
81
+ info = {
82
+ text: 'Access denied. See the console for more details.',
83
+ type: 'danger',
84
+ timeout: 5000,
85
+ icon: 'attention'
86
+ };
87
+ } else if (error.status === 0 && error.statusText === 'abort') {
88
+ /* We expected this abort, so do nothing. */
89
+ return;
90
+ } else if (error.status === 500 && error.responseJSON &&
91
+ error.responseJSON.type === 'girder') {
92
+ info = {
93
+ text: error.responseJSON.message,
94
+ type: 'warning',
95
+ timeout: 5000,
96
+ icon: 'info'
97
+ };
98
+ } else if (status === 'parsererror') {
99
+ info = {
100
+ text: 'A parser error occurred while communicating with the ' +
101
+ 'server (did you use the correct value for `dataType`?). ' +
102
+ 'Details have been logged in the console.',
103
+ type: 'danger',
104
+ timeout: 5000,
105
+ icon: 'attention'
106
+ };
107
+ } else {
108
+ info = {
109
+ text: 'An error occurred while communicating with the ' +
110
+ 'server. Details have been logged in the console.',
111
+ type: 'danger',
112
+ timeout: 5000,
113
+ icon: 'attention'
114
+ };
115
+ }
116
+ events.trigger('g:alert', info);
117
+ console.error(error.status + ' ' + error.statusText, error.responseText);
118
+ }
119
+ };
120
+
121
+ // Overwrite defaults with passed opts, but do not mutate opts
122
+ const args = _.extend({}, defaults, opts);
123
+
124
+ try {
125
+ // If the data is too large for a GET or PUT request, convert it to a POST request.
126
+ // Girder's REST API handles this for all requests.
127
+ if ((!args.method || args.method === 'GET' || args.method === 'PUT') && args.data && !args.contentType) {
128
+ if (JSON.stringify(args.data).length > 1536) {
129
+ args.headers = args.header || {};
130
+ args.headers['X-HTTP-Method-Override'] = args.method || 'GET';
131
+ args.method = 'POST';
132
+ }
133
+ }
134
+ } catch (err) { }
135
+
136
+ if (!args.url) {
137
+ throw new Error('restRequest requires a "url" argument');
138
+ }
139
+ args.url = `${getApiRoot()}${args.url.substring(0, 1) === '/' ? '' : '/'}${args.url}`;
140
+
141
+ if (args.girderToken) {
142
+ args.headers = args.headers || {};
143
+ args.headers['Girder-Token'] = args.girderToken;
144
+ delete args.girderToken;
145
+ }
146
+
147
+ return Backbone.$.ajax(args);
148
+ };
149
+
150
+ // All requests from Backbone should go through restRequest, adding authentication and the API root.
151
+ Backbone.ajax = restRequest;
152
+
153
+ /* Pending rest requests are listed in this pool so that they can be aborted or
154
+ * checked if still processing. */
155
+ var restXhrPool = {};
156
+ var restXhrCount = 0;
157
+ $(document).ajaxSend(function (event, xhr) {
158
+ restXhrCount += 1;
159
+ xhr.girderXhrNumber = restXhrCount;
160
+ restXhrPool[restXhrCount] = xhr;
161
+ });
162
+ $(document).ajaxComplete(function (event, xhr) {
163
+ var num = xhr.girderXhrNumber;
164
+ if (num && restXhrPool[num]) {
165
+ delete restXhrPool[num];
166
+ }
167
+ });
168
+
169
+ /* Get the number of outstanding rest requests.
170
+ * :param category: if specified, only count those requests that have
171
+ * xhr.girder[category] set to a truthy value.
172
+ * :returns: the number of outstanding requests.
173
+ */
174
+ function numberOutstandingRestRequests(category) {
175
+ if (category) {
176
+ return _.filter(restXhrPool, function (xhr) {
177
+ return xhr.girder && xhr.girder[category];
178
+ }).length;
179
+ }
180
+ return _.size(restXhrPool);
181
+ }
182
+
183
+ /* Cancel outstanding rest requests.
184
+ * :param category: if specified, only abort those requests that have
185
+ * xhr.girder[category] set to a truthy value.
186
+ */
187
+ function cancelRestRequests(category) {
188
+ _.each(restXhrPool, function (xhr) {
189
+ if (category && (!xhr.girder || !xhr.girder[category])) {
190
+ return;
191
+ }
192
+ if (xhr.abort) {
193
+ xhr.abort();
194
+ }
195
+ });
196
+ }
197
+
198
+ /*
199
+ * Get Upload Chunk Size
200
+ */
201
+ function getUploadChunkSize() {
202
+ return uploadChunkSize;
203
+ }
204
+
205
+ /*
206
+ * Set Upload Chunk Size
207
+ */
208
+ function setUploadChunkSize(val) {
209
+ uploadChunkSize = val;
210
+ }
211
+
212
+ export {
213
+ getApiRoot,
214
+ setApiRoot,
215
+ uploadHandlers,
216
+ restRequest,
217
+ numberOutstandingRestRequests,
218
+ cancelRestRequests,
219
+ getUploadChunkSize,
220
+ setUploadChunkSize
221
+ };
@@ -0,0 +1,58 @@
1
+ import $ from 'jquery';
2
+ import Backbone from 'backbone';
3
+
4
+ import events from '@girder/core/events';
5
+ import { parseQueryString } from '@girder/core/misc';
6
+
7
+ import '@girder/core/utilities/jquery/girderModal';
8
+
9
+ var Router = Backbone.Router.extend({
10
+ initialize: function () {
11
+ this._enabled = true;
12
+ },
13
+
14
+ execute: function (callback, args) {
15
+ args.push(parseQueryString(args.pop()));
16
+ var queryString = args[args.length - 1];
17
+ if (callback) {
18
+ callback.apply(this, args);
19
+ }
20
+
21
+ // handle "top level" dialogs
22
+ if (queryString.dialog === 'login') {
23
+ events.trigger('g:loginUi');
24
+ } else if (queryString.dialog === 'register') {
25
+ events.trigger('g:registerUi');
26
+ } else if (queryString.dialog === 'resetpassword') {
27
+ events.trigger('g:resetPasswordUi');
28
+ }
29
+ },
30
+
31
+ /**
32
+ * Set or get the enabled state of the router. Call with a boolean argument
33
+ * to set the enabled state, or with no arguments to get the state.
34
+ */
35
+ enabled: function () {
36
+ if (arguments.length) {
37
+ this._enabled = !!arguments[0];
38
+ }
39
+ return this._enabled;
40
+ },
41
+
42
+ navigate: function () {
43
+ if (this._enabled) {
44
+ Backbone.Router.prototype.navigate.apply(this, arguments);
45
+ }
46
+ }
47
+ });
48
+
49
+ var router = new Router();
50
+
51
+ // When the back button is pressed, we want to close open modals.
52
+ router.on('route', function (route, params) {
53
+ if (!params.slice(-1)[0].dialog) {
54
+ $('.modal').girderModal('close');
55
+ }
56
+ });
57
+
58
+ export default router;
@@ -0,0 +1,229 @@
1
+ import router from '@girder/core/router';
2
+ import events from '@girder/core/events';
3
+ import eventStream from '@girder/core/utilities/EventStream';
4
+ import { getCurrentUser, setCurrentUser } from '@girder/core/auth';
5
+ import { restRequest } from '@girder/core/rest';
6
+
7
+ /**
8
+ * Admin
9
+ */
10
+ import AdminView from '@girder/core/views/body/AdminView';
11
+
12
+ /**
13
+ * Assetstores
14
+ */
15
+ import AssetstoresView from '@girder/core/views/body/AssetstoresView';
16
+
17
+ /**
18
+ * Collections
19
+ */
20
+ import CollectionsView from '@girder/core/views/body/CollectionsView';
21
+
22
+ /**
23
+ * Collection
24
+ */
25
+ import CollectionView from '@girder/core/views/body/CollectionView';
26
+
27
+ /**
28
+ * Folder
29
+ */
30
+ import FolderView from '@girder/core/views/body/FolderView';
31
+
32
+ /**
33
+ * FrontPage
34
+ */
35
+ import FrontPageView from '@girder/core/views/body/FrontPageView';
36
+
37
+ /**
38
+ * Groups
39
+ */
40
+ import GroupsView from '@girder/core/views/body/GroupsView';
41
+
42
+ /**
43
+ * Group
44
+ */
45
+ import GroupView from '@girder/core/views/body/GroupView';
46
+
47
+ /**
48
+ * Item
49
+ */
50
+ import ItemView from '@girder/core/views/body/ItemView';
51
+
52
+ /**
53
+ * Plugins
54
+ */
55
+ import PluginsView from '@girder/core/views/body/PluginsView';
56
+ import UsersView from '@girder/core/views/body/UsersView';
57
+
58
+ /**
59
+ * SystemConfiguration
60
+ */
61
+ import SystemConfigurationView from '@girder/core/views/body/SystemConfigurationView';
62
+
63
+ /**
64
+ * UserAccount
65
+ */
66
+ import UserAccountView from '@girder/core/views/body/UserAccountView';
67
+ import UserModel from '@girder/core/models/UserModel';
68
+
69
+ /**
70
+ * User
71
+ */
72
+ import UserView from '@girder/core/views/body/UserView';
73
+
74
+ /**
75
+ * SearchResults
76
+ */
77
+ import SearchResultsView from '@girder/core/views/body/SearchResultsView';
78
+ router.route('admin', 'admin', function () {
79
+ events.trigger('g:navigateTo', AdminView);
80
+ });
81
+ router.route('assetstores', 'assetstores', function (params) {
82
+ events.trigger('g:navigateTo', AssetstoresView, {
83
+ assetstoreEdit: params.dialog === 'assetstoreedit' ? params.dialogid : false
84
+ });
85
+ });
86
+ router.route('assetstore/:id/import', 'assetstoreImport', function (assetstoreId) {
87
+ AssetstoresView.import(assetstoreId);
88
+ });
89
+ router.route('collections', 'collections', function (params) {
90
+ events.trigger('g:navigateTo', CollectionsView, params || {});
91
+ events.trigger('g:highlightItem', 'CollectionsView');
92
+ });
93
+ router.route('collection/:id', 'collectionAccess', function (cid, params) {
94
+ CollectionView.fetchAndInit(cid, {
95
+ access: params.dialog === 'access',
96
+ edit: params.dialog === 'edit',
97
+ folderCreate: params.dialog === 'foldercreate',
98
+ dialog: params.dialog
99
+ });
100
+ });
101
+ router.route('collection/:id/folder/:id', 'collectionFolder', function (cid, folderId, params) {
102
+ CollectionView.fetchAndInit(cid, {
103
+ folderId: folderId,
104
+ upload: params.dialog === 'upload',
105
+ access: params.dialog === 'access',
106
+ edit: params.dialog === 'edit',
107
+ folderAccess: params.dialog === 'folderaccess',
108
+ folderCreate: params.dialog === 'foldercreate',
109
+ folderEdit: params.dialog === 'folderedit',
110
+ itemCreate: params.dialog === 'itemcreate'
111
+ });
112
+ });
113
+ router.route('folder/:id', 'folder', function (id, params) {
114
+ FolderView.fetchAndInit(id, {
115
+ upload: params.dialog === 'upload',
116
+ folderAccess: params.dialog === 'folderaccess',
117
+ folderCreate: params.dialog === 'foldercreate',
118
+ folderEdit: params.dialog === 'folderedit',
119
+ itemCreate: params.dialog === 'itemcreate'
120
+ });
121
+ });
122
+ router.route('', 'index', function () {
123
+ events.trigger('g:navigateTo', FrontPageView);
124
+ });
125
+ router.route('groups', 'groups', function (params) {
126
+ events.trigger('g:navigateTo', GroupsView, params || {});
127
+ events.trigger('g:highlightItem', 'GroupsView');
128
+ });
129
+ router.route('group/:id', 'groupView', function (groupId, params) {
130
+ GroupView.fetchAndInit(groupId, {
131
+ edit: params.dialog === 'edit'
132
+ });
133
+ });
134
+ router.route('group/:id/:tab', 'groupView', function (groupId, tab, params) {
135
+ GroupView.fetchAndInit(groupId, {
136
+ edit: params.dialog === 'edit',
137
+ tab: tab
138
+ });
139
+ });
140
+ router.route('item/:id', 'item', function (itemId, params) {
141
+ ItemView.fetchAndInit(itemId, {
142
+ edit: params.dialog === 'itemedit',
143
+ fileEdit: params.dialog === 'fileedit' ? params.dialogid : false,
144
+ upload: params.dialog === 'upload' ? params.dialogid : false
145
+ });
146
+ });
147
+ router.route('plugins', 'plugins', function () {
148
+ events.trigger('g:navigateTo', PluginsView);
149
+ });
150
+ router.route('settings', 'settings', function () {
151
+ events.trigger('g:navigateTo', SystemConfigurationView);
152
+ });
153
+ router.route('useraccount/:id/:tab', 'accountTab', function (id, tab) {
154
+ UserAccountView.fetchAndInit(id, tab);
155
+ });
156
+ router.route('useraccount/:id/token/:token', 'accountToken', function (id, token) {
157
+ UserModel.fromTemporaryToken(id, token)
158
+ .done(() => {
159
+ events.trigger('g:navigateTo', UserAccountView, {
160
+ user: getCurrentUser(),
161
+ tab: 'password',
162
+ temporary: token
163
+ });
164
+ }).fail(() => {
165
+ router.navigate('', { trigger: true });
166
+ });
167
+ });
168
+
169
+ router.route('useraccount/:id/verification/:token', 'accountVerify', function (id, token) {
170
+ restRequest({
171
+ url: `user/${id}/verification`,
172
+ method: 'PUT',
173
+ data: { token: token },
174
+ error: null
175
+ }).done((resp) => {
176
+ if (resp.authToken) {
177
+ resp.user.token = resp.authToken.token;
178
+ eventStream.close();
179
+ setCurrentUser(new UserModel(resp.user));
180
+ eventStream.open();
181
+ events.trigger('g:login-changed');
182
+ }
183
+ events.trigger('g:navigateTo', FrontPageView);
184
+ events.trigger('g:alert', {
185
+ icon: 'ok',
186
+ text: 'Email verified.',
187
+ type: 'success',
188
+ timeout: 4000
189
+ });
190
+ }).fail(() => {
191
+ events.trigger('g:navigateTo', FrontPageView);
192
+ events.trigger('g:alert', {
193
+ icon: 'cancel',
194
+ text: 'Could not verify email.',
195
+ type: 'danger',
196
+ timeout: 4000
197
+ });
198
+ });
199
+ });
200
+
201
+ /**
202
+ * Users
203
+ */
204
+ router.route('users', 'users', function (params) {
205
+ events.trigger('g:navigateTo', UsersView, params || {});
206
+ events.trigger('g:highlightItem', 'UsersView');
207
+ });
208
+ router.route('user/:id', 'user', function (userId, params) {
209
+ UserView.fetchAndInit(userId, {
210
+ folderCreate: params.dialog === 'foldercreate',
211
+ dialog: params.dialog
212
+ });
213
+ });
214
+ router.route('user/:id/folder/:id', 'userFolder', function (userId, folderId, params) {
215
+ UserView.fetchAndInit(userId, {
216
+ folderId: folderId,
217
+ upload: params.dialog === 'upload',
218
+ folderAccess: params.dialog === 'folderaccess',
219
+ folderCreate: params.dialog === 'foldercreate',
220
+ folderEdit: params.dialog === 'folderedit',
221
+ itemCreate: params.dialog === 'itemcreate'
222
+ });
223
+ });
224
+ router.route('search/results', 'SearchResults', function (params) {
225
+ events.trigger('g:navigateTo', SearchResultsView, {
226
+ query: params.query,
227
+ mode: params.mode
228
+ });
229
+ });
@@ -0,0 +1,50 @@
1
+ @import "nib"
2
+
3
+ $radius = 6px
4
+ $border = 1px solid #d7d7d7
5
+
6
+ body
7
+ font-family "Open Sans", sans-serif
8
+ background-color #adada1
9
+ margin 0
10
+
11
+ .right
12
+ float right
13
+
14
+ .docs-header
15
+ color white
16
+ background-color #3f3b3b
17
+ padding 11px 18px
18
+ font-size 24px
19
+ font-weight bold
20
+
21
+ .docs-body
22
+ background-color white
23
+ padding 15px 18px 5px
24
+
25
+ p
26
+ margin-bottom 13px
27
+
28
+ .docs-swagger-container
29
+ background-color #f0fafc
30
+ padding 5px 18px 12px
31
+ border-top $border
32
+
33
+ @media screen and (min-width 990px)
34
+ .docs-header
35
+ .docs-body
36
+ .docs-swagger-container
37
+ max-width 960px
38
+ margin-left auto
39
+ margin-right auto
40
+ box-shadow 0 5px 12px 0 rgba(0, 0, 0, 0.2)
41
+
42
+ body
43
+ padding-bottom 25px
44
+ padding-top 25px
45
+
46
+ .docs-header
47
+ border-radius $radius $radius 0 0
48
+
49
+ .docs-swagger-container
50
+ border-radius 0 0 $radius $radius
@@ -0,0 +1,21 @@
1
+ ul.g-admin-options
2
+ list-style-type none
3
+ font-size 18px
4
+ padding-left 0
5
+ margin 0
6
+
7
+ >li
8
+ display block
9
+ padding 0
10
+ font-weight bold
11
+ color #666
12
+
13
+ >a
14
+ padding 12px 10px
15
+ color inherit
16
+ display block
17
+
18
+ >li:hover
19
+ background-color #f4f4f4
20
+ cursor pointer
21
+ color #222
@@ -0,0 +1,46 @@
1
+ .g-current-assetstores-container
2
+ padding-bottom 10px
3
+ border-bottom 1px solid #d7d7d7
4
+
5
+ .g-assetstore-buttons
6
+ margin-top 10px
7
+ .btn
8
+ margin-right 12px
9
+
10
+ #g-new-assetstore-container
11
+ margin-top 10px
12
+
13
+ .g-assetstore-capacity-chart
14
+ height 150px
15
+ width 280px
16
+
17
+ .g-assetstore-container .panel-body
18
+ &:before
19
+ display none
20
+ &:after
21
+ display none
22
+
23
+ .g-assetstore-current-text
24
+ font-weight bold
25
+ margin-left 10px
26
+
27
+ .g-assetstore-current
28
+ background rgba(50, 118, 177, 0.25)
29
+ border-color #444
30
+
31
+ .g-assetstore-button-container
32
+ display inline-block
33
+
34
+ .jqplot-data-label
35
+ color black
36
+
37
+ .g-assetstore-import-button-container
38
+ display inline-block
39
+
40
+ .g-import-instructions
41
+ margin-bottom 22px
42
+ padding-top 8px
43
+ border-top 1px solid #eee
44
+
45
+ .g-submit-assetstore-import
46
+ margin-top 7px
@@ -0,0 +1,39 @@
1
+ .g-collection-list-entry
2
+
3
+ .g-collection-title
4
+ font-size 17px
5
+
6
+ .g-collection-right-column
7
+ border-left 1px solid #ddd
8
+ padding-left 8px
9
+ display inline
10
+ width 290px
11
+ font-size 14px
12
+ float right
13
+ color #909090
14
+
15
+ .g-collection-description
16
+ background-color white
17
+ padding 8px 12px
18
+ border-radius 3px
19
+ border 1px solid #dedede
20
+
21
+ .g-collection-list-header
22
+ padding-bottom 10px
23
+
24
+ .g-collection-pagination
25
+ display inline-block
26
+ >ul
27
+ margin 0 15px 0 0
28
+
29
+ .pagination>li>a
30
+ float none
31
+ line-height 1.5
32
+ padding 7px 12px
33
+
34
+ .g-collection-search-form
35
+ display inline
36
+ margin-right 15px
37
+
38
+ .form-group
39
+ display inline-block
@@ -0,0 +1,6 @@
1
+ .g-collection-header
2
+ border-bottom 1px solid #ddd
3
+ margin-bottom 15px
4
+
5
+ .g-collection-folders-container
6
+ margin-top 15px