@girder/core 5.0.0-beta.1 → 5.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (239) 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.js +48560 -0
  4. package/dist-lib/girder-core.js.map +1 -0
  5. package/dist-lib/girder-core.umd.cjs +630 -0
  6. package/dist-lib/girder-core.umd.cjs.map +1 -0
  7. package/dist-lib/index.d.ts +1 -0
  8. package/dist-lib/src/auth.js +112 -0
  9. package/dist-lib/src/collections/ApiKeyCollection.js +9 -0
  10. package/dist-lib/src/collections/AssetstoreCollection.js +9 -0
  11. package/dist-lib/src/collections/Collection.js +295 -0
  12. package/dist-lib/src/collections/CollectionCollection.js +9 -0
  13. package/dist-lib/src/collections/FileCollection.js +11 -0
  14. package/dist-lib/src/collections/FolderCollection.js +11 -0
  15. package/dist-lib/src/collections/GroupCollection.js +9 -0
  16. package/dist-lib/src/collections/ItemCollection.js +11 -0
  17. package/dist-lib/src/collections/UserCollection.js +24 -0
  18. package/dist-lib/src/collections/index.js +21 -0
  19. package/dist-lib/src/constants.js +32 -0
  20. package/dist-lib/src/dialog.js +128 -0
  21. package/dist-lib/src/events.js +6 -0
  22. package/dist-lib/src/index.d.ts +23 -0
  23. package/dist-lib/src/index.ts +80 -0
  24. package/dist-lib/src/main.ts +45 -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 +84 -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 +199 -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 +66 -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 +83 -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 +177 -0
  161. package/dist-lib/src/utilities/PluginUtils.js +36 -0
  162. package/dist-lib/src/utilities/S3UploadHandler.js +303 -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 +234 -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 +182 -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 +37 -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 +122 -0
  205. package/dist-lib/src/views/widgets/EditAssetstoreWidget.js +133 -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 +71 -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 +75 -0
  237. package/dist-lib/src/vite-env.d.ts +5 -0
  238. package/dist-lib/style.css +16 -0
  239. package/package.json +1 -1
@@ -0,0 +1,128 @@
1
+ import $ from 'jquery';
2
+ import _ from 'underscore';
3
+ import Backbone from 'backbone';
4
+
5
+ import router from '@girder/core/router';
6
+ import { parseQueryString, splitRoute } from '@girder/core/misc';
7
+
8
+ import ConfirmDialogTemplate from '@girder/core/templates/widgets/confirmDialog.pug';
9
+
10
+ import '@girder/core/utilities/jquery/girderModal';
11
+
12
+ function handleClose(name, options, nameId) {
13
+ if (!router.enabled()) {
14
+ return;
15
+ }
16
+ var curRoute = Backbone.history.fragment,
17
+ routeParts = splitRoute(curRoute),
18
+ queryString = parseQueryString(routeParts.name),
19
+ dialogName = queryString.dialog,
20
+ dialogId = queryString.dialogid;
21
+ delete queryString.dialog;
22
+ delete queryString.dialogid;
23
+ var unparsedQueryString = $.param(queryString);
24
+ if (unparsedQueryString.length > 0) {
25
+ unparsedQueryString = '?' + unparsedQueryString;
26
+ }
27
+ if (dialogName === name && dialogId === nameId) {
28
+ router.navigate(routeParts.base + unparsedQueryString, options);
29
+ }
30
+ }
31
+
32
+ function handleOpen(name, options, nameId) {
33
+ if (!router.enabled()) {
34
+ return;
35
+ }
36
+ var curRoute = Backbone.history.fragment,
37
+ routeParts = splitRoute(curRoute),
38
+ queryString = parseQueryString(routeParts.name),
39
+ dialogName = queryString.dialog,
40
+ dialogId = queryString.dialogid;
41
+
42
+ if (dialogName !== name || nameId !== dialogId) {
43
+ queryString.dialog = name;
44
+ if (nameId) {
45
+ queryString.dialogid = nameId;
46
+ }
47
+ var unparsedQueryString = $.param(queryString);
48
+ if (unparsedQueryString.length > 0) {
49
+ unparsedQueryString = '?' + unparsedQueryString;
50
+ }
51
+ router.navigate(routeParts.base + unparsedQueryString, options);
52
+ }
53
+ }
54
+
55
+ /**
56
+ * Prompt the user to confirm an action.
57
+ * @param {Object} [params] Parameters controlling this function's behavior.
58
+ * @param {String} [params.text] The text to prompt the user with.
59
+ * @param {String} [params.yesText] The text for the confirm button.
60
+ * @param {String} [params.yesClass] Class string to apply to the confirm button.
61
+ * @param {String} [params.noText] The text for the no/cancel button.
62
+ * @param {Boolean} [params.escapedHtml] If you want to render the text as HTML rather than
63
+ * plain text, set this to true to acknowledge that you have escaped any
64
+ * user-created data within the text to prevent XSS exploits.
65
+ * @param {Boolean} [params.msgConfirmation] If you want to add a new security before
66
+ * perform an action. This will ask to enter a specific string "params.yesText params.name"
67
+ * @param {String} [params.additionalText] Additional text to display before the confirmation
68
+ * input.
69
+ * @param {String} [params.name] The name to enter in order to confirm an action.
70
+ * @param {Function} [params.confirmCallback]Callback function when the user confirms the action.
71
+ */
72
+ function confirm(params) {
73
+ params = _.extend({
74
+ text: 'Are you sure?',
75
+ yesText: 'Yes',
76
+ yesClass: 'btn-danger',
77
+ noText: 'Cancel',
78
+ escapedHtml: false,
79
+ msgConfirmation: false,
80
+ additionalText: '',
81
+ name: ''
82
+ }, params);
83
+ $('#g-dialog-container').html(ConfirmDialogTemplate({
84
+ params: params
85
+ })).girderModal(false).one('hidden.bs.modal', function () {
86
+ $('#g-confirm-button').off('click');
87
+ });
88
+
89
+ const el = $('#g-dialog-container').find('.modal-body>p:first-child');
90
+ if (params.escapedHtml) {
91
+ el.html(params.text);
92
+ } else {
93
+ el.text(params.text);
94
+ }
95
+ if (params.msgConfirmation) {
96
+ if (params.escapedHtml) {
97
+ $('.g-additional-text').html(params.additionalText);
98
+ } else {
99
+ $('.g-additional-text').text(params.additionalText);
100
+ }
101
+ }
102
+
103
+ $('#g-confirm-button').off('click').on('click', function () {
104
+ if (params.msgConfirmation) {
105
+ const key = `${params.yesText.toUpperCase()} ${params.name}`;
106
+ const msg = $('#g-confirm-text').val();
107
+ if (msg.toUpperCase() === key.toUpperCase()) {
108
+ $('#g-dialog-container').modal('hide');
109
+ params.confirmCallback();
110
+ } else if (msg.toUpperCase() === '') {
111
+ $('.g-msg-error').html(`Error: You need to enter <b>'${key}'</b>.`);
112
+ $('.g-msg-error').css('color', 'red');
113
+ } else {
114
+ $('.g-msg-error').html(`Error: <b>'${msg}'</b> isn't <b>'${key}'</b>`);
115
+ $('.g-msg-error').css('color', 'red');
116
+ }
117
+ } else {
118
+ $('#g-dialog-container').modal('hide');
119
+ params.confirmCallback();
120
+ }
121
+ });
122
+ }
123
+
124
+ export {
125
+ confirm,
126
+ handleClose,
127
+ handleOpen
128
+ };
@@ -0,0 +1,6 @@
1
+ import _ from 'underscore';
2
+ import Backbone from 'backbone';
3
+
4
+ var girderEvents = _.clone(Backbone.Events);
5
+
6
+ export default girderEvents;
@@ -0,0 +1,23 @@
1
+ declare const girder: {
2
+ $: any;
3
+ _: any;
4
+ Backbone: any;
5
+ moment: any;
6
+ initializeDefaultApp: (apiRoot: string, el?: string | HTMLElement) => Promise<unknown>;
7
+ auth: any;
8
+ collections: any;
9
+ constants: any;
10
+ dialog: any;
11
+ events: any;
12
+ misc: any;
13
+ models: any;
14
+ plugins: {};
15
+ pluginUtils: any;
16
+ rest: any;
17
+ router: any;
18
+ utilities: any;
19
+ version: any;
20
+ views: any;
21
+ };
22
+ export type Girder = typeof girder;
23
+ export { girder, };
@@ -0,0 +1,80 @@
1
+ import $ from 'jquery';
2
+
3
+ import _ from 'underscore';
4
+
5
+ import Backbone from 'backbone';
6
+
7
+ import moment from 'moment';
8
+
9
+ import * as auth from './auth';
10
+ import * as collections from './collections';
11
+ import * as constants from './constants';
12
+ import * as dialog from './dialog';
13
+ import * as misc from './misc';
14
+ import * as models from './models';
15
+ import * as pluginUtils from './pluginUtils';
16
+ import * as rest from './rest';
17
+ import * as utilities from './utilities';
18
+ import * as views from './views';
19
+ import events from './events';
20
+ import router from './router';
21
+ import version from './version';
22
+
23
+ const initializeDefaultApp = async (apiRoot: string, el: string | HTMLElement = 'body') => {
24
+ return new Promise((resolve, reject) => {
25
+ $(() => {
26
+ rest.setApiRoot(apiRoot);
27
+ events.trigger('g:appload.before');
28
+ rest.restRequest({
29
+ url: `system/public_settings`,
30
+ method: 'GET',
31
+ }).done((resp: any) => {
32
+ const app = new views.App({
33
+ el,
34
+ parentView: null,
35
+ contactEmail: resp['core.contact_email_address'],
36
+ privacyNoticeHref: resp['core.privacy_notice'],
37
+ brandName: resp['core.brand_name'],
38
+ bannerColor: resp['core.banner_color'],
39
+ registrationPolicy: resp['core.registration_policy'],
40
+ enablePasswordLogin: resp['core.enable_password_login'],
41
+ });
42
+ app.render();
43
+ document.title = resp['core.brand_name'];
44
+ events.trigger('g:appload.after', app);
45
+ resolve(app);
46
+ }).fail((resp: any) => {
47
+ events.trigger('g:error', resp);
48
+ reject(new Error("Could not retrieve public settings from server."));
49
+ });
50
+ });
51
+ });
52
+ };
53
+
54
+ const girder = {
55
+ $,
56
+ _,
57
+ Backbone,
58
+ moment,
59
+ initializeDefaultApp,
60
+ auth,
61
+ collections,
62
+ constants,
63
+ dialog,
64
+ events,
65
+ misc,
66
+ models,
67
+ plugins: {},
68
+ pluginUtils,
69
+ rest,
70
+ router,
71
+ utilities,
72
+ version,
73
+ views
74
+ };
75
+
76
+ export type Girder = typeof girder;
77
+
78
+ export {
79
+ girder,
80
+ };
@@ -0,0 +1,45 @@
1
+ import { girder } from '.';
2
+
3
+ declare global {
4
+ interface Window {
5
+ girder: typeof girder;
6
+ }
7
+ }
8
+ window.girder = girder;
9
+
10
+ interface StaticFilesSpec {
11
+ css: string[],
12
+ js: string[],
13
+ }
14
+
15
+ const apiRoot = import.meta.env.VITE_API_ROOT ?? '/api/v1';
16
+
17
+ (async () => {
18
+ const origin = apiRoot.startsWith('/') ? window.origin : new URL(apiRoot).origin;
19
+ const staticFilesResp = await fetch(`${apiRoot}/system/plugin_static_files`);
20
+ const staticFiles: StaticFilesSpec = await staticFilesResp.json();
21
+
22
+ staticFiles.css.forEach((href) => {
23
+ const link = document.createElement('link');
24
+ link.rel = 'stylesheet';
25
+ link.type = 'text/css';
26
+ link.href = new URL(href, origin).href;
27
+ document.head.appendChild(link);
28
+ });
29
+
30
+ const scriptPromises: Promise<void>[] = [];
31
+ staticFiles.js.forEach((href) => {
32
+ scriptPromises.push(new Promise((resolve) => {
33
+ const script = document.createElement('script');
34
+ script.type = 'text/javascript';
35
+ script.src = new URL(href, origin).href;
36
+ document.head.appendChild(script);
37
+ script.addEventListener('load', function() {
38
+ resolve();
39
+ });
40
+ }));
41
+ });
42
+
43
+ await Promise.all(scriptPromises);
44
+ await girder.initializeDefaultApp(apiRoot);
45
+ })();
@@ -0,0 +1,260 @@
1
+ import $ from 'jquery';
2
+ import _ from 'underscore';
3
+
4
+ import { MONTHS } from '@girder/core/constants';
5
+
6
+ import { Remarkable } from 'remarkable';
7
+
8
+ import { linkify } from 'remarkable/linkify';
9
+
10
+ /**
11
+ * This file contains utility functions for general use in the application
12
+ */
13
+ var DATE_MONTH = 0;
14
+ var DATE_DAY = 1;
15
+ var DATE_MINUTE = 2;
16
+ var DATE_SECOND = 3;
17
+
18
+ /**
19
+ * Format a date string to the given resolution.
20
+ * @param datestr The date string to format.
21
+ * @param resolution The resolution, defaults to 'day'. Minimum is month.
22
+ */
23
+ function formatDate(datestr, resolution) {
24
+ datestr = datestr.replace(' ', 'T'); // Cross-browser accepted date format
25
+ var date = new Date(datestr);
26
+ var output = MONTHS[date.getMonth()];
27
+
28
+ resolution = resolution || DATE_MONTH;
29
+
30
+ if (resolution >= DATE_DAY) {
31
+ output += ' ' + date.getDate() + ',';
32
+ }
33
+
34
+ output += ' ' + date.getFullYear();
35
+
36
+ if (resolution >= DATE_MINUTE) {
37
+ output += ' at ' + date.getHours() + ':' +
38
+ ('0' + date.getMinutes()).slice(-2);
39
+ }
40
+ if (resolution >= DATE_SECOND) {
41
+ output += ':' + ('0' + date.getSeconds()).slice(-2);
42
+ }
43
+
44
+ return output;
45
+ }
46
+
47
+ /**
48
+ * Format a size in bytes into a human-readable string with metric unit
49
+ * prefixes.
50
+ */
51
+ function formatSize(sizeBytes) {
52
+ if (sizeBytes < 1024) {
53
+ return sizeBytes + ' B';
54
+ }
55
+ var i, sizeVal = sizeBytes, precision = 1;
56
+ for (i = 0; sizeVal >= 1024; i += 1) {
57
+ sizeVal /= 1024;
58
+ }
59
+ // If we are just reporting a low number, no need for decimal places.
60
+ if (sizeVal < 10) {
61
+ precision = 3;
62
+ } else if (sizeVal < 100) {
63
+ precision = 2;
64
+ }
65
+ return sizeVal.toFixed(precision) + ' ' +
66
+ ['B', 'kB', 'MB', 'GB', 'TB'][Math.min(i, 4)];
67
+ }
68
+
69
+ /**
70
+ * Like formatSize, but more generic. Returns a human-readable format
71
+ * of an integer using metric prefixes. The caller is expected to append any
72
+ * unit string if necessary.
73
+ *
74
+ * @param {integer} n The number to format.
75
+ * @param {Object} [opts={}] Formatting options. These include:
76
+ * - {integer} [maxLen] Max number of digits in the output.
77
+ * - {integer} [base=1000] Base for the prefixes (usually 1000 or 1024).
78
+ * - {string} [sep=''] Separator between numeric value and metric prefix.
79
+ */
80
+ function formatCount(n, opts) {
81
+ n = n || 0;
82
+ opts = opts || {};
83
+
84
+ var i = 0,
85
+ base = opts.base || 1000,
86
+ sep = opts.sep || '',
87
+ maxLen = opts.maxLen || 3,
88
+ precision = maxLen - 1;
89
+
90
+ for (; n > base; i += 1) {
91
+ n /= base;
92
+ }
93
+
94
+ if (!i) {
95
+ precision = 0;
96
+ } else if (n > 100) {
97
+ precision -= 2;
98
+ } else if (n > 10) {
99
+ precision -= 1;
100
+ }
101
+
102
+ return n.toFixed(Math.max(0, precision)) + sep +
103
+ ['', 'k', 'M', 'G', 'T'][Math.min(i, 4)];
104
+ }
105
+
106
+ /**
107
+ * This comparator can be used by collections that wish to support locale-based
108
+ * sorting. The locale specifies how upper and lower case are compared.
109
+ */
110
+ function localeComparator(model1, model2) {
111
+ var a1 = model1.get(this.sortField),
112
+ a2 = model2.get(this.sortField);
113
+
114
+ if (a1 !== undefined && a1.localeCompare) {
115
+ var result = a1.localeCompare(a2) * this.sortDir;
116
+ if (result || !this.secondarySortField) {
117
+ return result;
118
+ }
119
+ a1 = model1.get(this.secondarySortField);
120
+ a2 = model2.get(this.secondarySortField);
121
+ return a1.localeCompare(a2) * this.sortDir;
122
+ }
123
+
124
+ return a1 > a2 ? this.sortDir : (a1 < a2 ? -this.sortDir : 0);
125
+ }
126
+
127
+ /**
128
+ * This comparator can be passed to the sort function on javascript arrays.
129
+ */
130
+ function localeSort(a1, a2) {
131
+ if (a1 !== undefined && a1.localeCompare) {
132
+ return a1.localeCompare(a2);
133
+ }
134
+ return a1 > a2 ? 1 : (a1 < a2 ? -1 : 0);
135
+ }
136
+
137
+ /**
138
+ * Return the model class name given its collection name.
139
+ * @param name Collection name, e.g. 'user'
140
+ */
141
+ function getModelClassByName(name) {
142
+ var className = name.charAt(0).toUpperCase();
143
+ return className + name.substr(1) + 'Model';
144
+ }
145
+
146
+ function parseQueryString(queryString) {
147
+ var params = {};
148
+ if (queryString) {
149
+ _.each(queryString.replace(/\+/g, ' ').split(/&/g), function (el) {
150
+ var aux = el.split('='), val;
151
+ if (aux.length > 1) {
152
+ val = decodeURIComponent(el.substr(aux[0].length + 1));
153
+ }
154
+ params[decodeURIComponent(aux[0])] = val;
155
+ });
156
+ }
157
+ return params;
158
+ }
159
+
160
+ /**
161
+ * Create a set of flags that can be OR'd (|) together to define a set of
162
+ * options.
163
+ *
164
+ * @param {Array} options An array of strings defining the option names.
165
+ * @param {string} allOption If you want an option that enables all options,
166
+ * pass its name as this parameter.
167
+ * @return {Object} An object mapping the names of options to values.
168
+ */
169
+ function defineFlags(options, allOption) {
170
+ var i = 0,
171
+ obj = {};
172
+
173
+ if (allOption) {
174
+ obj[allOption] = 1;
175
+ }
176
+ _.each(options, function (opt) {
177
+ obj[opt] = 1 << i;
178
+
179
+ if (allOption) {
180
+ obj[allOption] |= obj[opt];
181
+ }
182
+
183
+ i += 1;
184
+ });
185
+
186
+ return obj;
187
+ }
188
+
189
+ /**
190
+ * Transform markdown into HTML and render it into the given element. If no
191
+ * element is provided, simply returns the HTML.
192
+ *
193
+ * @param val The markdown text input.
194
+ * @param el The element to render the output HTML into, or falsy to simply
195
+ * return the HTML value.
196
+ */
197
+ var renderMarkdown = (function () {
198
+ var md = new Remarkable().use(linkify);
199
+ return function (val, el) {
200
+ if (el) {
201
+ $(el).html(md.render(val));
202
+ } else {
203
+ return md.render(val);
204
+ }
205
+ };
206
+ }());
207
+
208
+ /**
209
+ * Capitalize the first character of a string.
210
+ */
211
+ function capitalize(str) {
212
+ return str.charAt(0).toUpperCase() + str.substring(1);
213
+ }
214
+
215
+ function splitRoute(route) {
216
+ if (!route) {
217
+ return { base: '', name: '' };
218
+ }
219
+ var firstIndex = route.indexOf('?'),
220
+ lastIndex = route.lastIndexOf('?'),
221
+ dialogName,
222
+ baseRoute;
223
+
224
+ if (firstIndex === -1) {
225
+ baseRoute = route;
226
+ } else {
227
+ baseRoute = route.slice(0, firstIndex);
228
+ }
229
+
230
+ if (lastIndex === -1) {
231
+ dialogName = '';
232
+ } else {
233
+ dialogName = route.slice(lastIndex + 1);
234
+ }
235
+
236
+ return { name: dialogName, base: baseRoute };
237
+ }
238
+
239
+ function _whenAll(promises) {
240
+ return $.when(...promises).then((...results) => results);
241
+ }
242
+
243
+ export {
244
+ DATE_MONTH,
245
+ DATE_DAY,
246
+ DATE_MINUTE,
247
+ DATE_SECOND,
248
+ formatDate,
249
+ formatSize,
250
+ formatCount,
251
+ localeComparator,
252
+ localeSort,
253
+ getModelClassByName,
254
+ parseQueryString,
255
+ defineFlags,
256
+ renderMarkdown,
257
+ capitalize,
258
+ splitRoute,
259
+ _whenAll
260
+ };
@@ -0,0 +1,76 @@
1
+ import $ from 'jquery';
2
+ import _ from 'underscore';
3
+
4
+ import Model from '@girder/core/models/Model';
5
+ import { restRequest } from '@girder/core/rest';
6
+
7
+ /**
8
+ * Models corresponding to AccessControlledModels on the server should extend
9
+ * from this object. It provides utilities for managing and storing the
10
+ * access control list on
11
+ */
12
+ var AccessControlledModel = Model.extend({
13
+ /**
14
+ * Saves the access control list on this model to the server. Saves the
15
+ * state of whatever this model's "access" parameter is set to, which
16
+ * should be an object of the form:
17
+ * {groups: [{id: <groupId>, level: <accessLevel>}, ...],
18
+ * users: [{id: <userId>, level: <accessLevel>}, ...]}
19
+ * The "public" attribute of this model should also be set as a boolean.
20
+ * When done, triggers the 'g:accessListSaved' event on the model.
21
+ */
22
+ updateAccess: function (params) {
23
+ if (this.altUrl === null && this.resourceName === null) {
24
+ throw new Error('An altUrl or resourceName must be set on the Model.');
25
+ }
26
+
27
+ return restRequest({
28
+ url: `${this.altUrl || this.resourceName}/${this.id}/access`,
29
+ method: 'PUT',
30
+ data: _.extend({
31
+ access: JSON.stringify(this.get('access')),
32
+ public: this.get('public'),
33
+ publicFlags: JSON.stringify(this.get('publicFlags') || [])
34
+ }, params || {})
35
+ }).done(() => {
36
+ this.trigger('g:accessListSaved');
37
+ }).fail((err) => {
38
+ this.trigger('g:error', err);
39
+ });
40
+ },
41
+
42
+ /**
43
+ * Fetches the access control list from the server, and sets it as the
44
+ * access property.
45
+ * @param force By default, this only fetches access if it hasn't already
46
+ * been set on the model. If you want to force a refresh
47
+ * anyway, set this param to true.
48
+ */
49
+ fetchAccess: function (force) {
50
+ if (this.altUrl === null && this.resourceName === null) {
51
+ throw new Error('An altUrl or resourceName must be set on the Model.');
52
+ }
53
+
54
+ if (!this.get('access') || force) {
55
+ return restRequest({
56
+ url: `${this.altUrl || this.resourceName}/${this.id}/access`,
57
+ method: 'GET'
58
+ }).done((resp) => {
59
+ if (resp.access) {
60
+ this.set(resp);
61
+ } else {
62
+ this.set('access', resp);
63
+ }
64
+ this.trigger('g:accessFetched');
65
+ return resp;
66
+ }).fail((err) => {
67
+ this.trigger('g:error', err);
68
+ });
69
+ } else {
70
+ this.trigger('g:accessFetched');
71
+ return $.Deferred().resolve(this.get('access')).promise();
72
+ }
73
+ }
74
+ });
75
+
76
+ export default AccessControlledModel;
@@ -0,0 +1,31 @@
1
+ import AccessControlledModel from '@girder/core/models/AccessControlledModel';
2
+ import { restRequest } from '@girder/core/rest';
3
+
4
+ var ApiKeyModel = AccessControlledModel.extend({
5
+ resourceName: 'api_key',
6
+
7
+ setActive: function (active) {
8
+ return restRequest({
9
+ url: `api_key/${this.id}`,
10
+ method: 'PUT',
11
+ data: {
12
+ active: active
13
+ }
14
+ }).done(() => {
15
+ this.set({ active: active });
16
+ this.trigger('g:setActive');
17
+ });
18
+ },
19
+
20
+ save: function () {
21
+ // Scope needs to be sent to the server as JSON
22
+ var scope = this.get('scope');
23
+ this.set('scope', JSON.stringify(scope), { silent: true }); // eslint-disable-line backbone/no-silent
24
+ var promise = AccessControlledModel.prototype.save.call(this, arguments);
25
+ // Restore scope to its original state
26
+ this.set('scope', scope, { silent: true }); // eslint-disable-line backbone/no-silent
27
+ return promise;
28
+ }
29
+ });
30
+
31
+ export default ApiKeyModel;
@@ -0,0 +1,43 @@
1
+ import _ from 'underscore';
2
+
3
+ import { formatSize } from '@girder/core/misc';
4
+ import Model from '@girder/core/models/Model';
5
+ import { restRequest } from '@girder/core/rest';
6
+
7
+ var AssetstoreModel = Model.extend({
8
+ resourceName: 'assetstore',
9
+
10
+ capacityKnown: function () {
11
+ var cap = this.get('capacity');
12
+ return cap && cap.free !== null && cap.total !== null;
13
+ },
14
+
15
+ capacityString: function () {
16
+ var cap = this.get('capacity');
17
+ return formatSize(cap.free) + ' free of ' +
18
+ formatSize(cap.total) + ' total';
19
+ },
20
+
21
+ import: function (params) {
22
+ return restRequest({
23
+ url: `assetstore/${this.id}/import`,
24
+ method: 'POST',
25
+ data: params,
26
+ error: null
27
+ }).done((resp) => {
28
+ this.trigger('g:imported', resp);
29
+ }).fail((resp) => {
30
+ this.trigger('g:error', resp);
31
+ });
32
+ },
33
+
34
+ save: function () {
35
+ if (_.isNumber(this.get('perms'))) {
36
+ // Coerce to an octal string to disambiguate
37
+ this.set('perms', this.get('perms').toString(8));
38
+ }
39
+ return Model.prototype.save.call(this, arguments);
40
+ }
41
+ });
42
+
43
+ export default AssetstoreModel;