@girder/core 3.2.7 → 5.0.0-a6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (231) hide show
  1. package/README.md +61 -0
  2. package/package.json +79 -31
  3. package/assets/Girder_Mark.png +0 -0
  4. package/auth.js +0 -152
  5. package/collections/ApiKeyCollection.js +0 -9
  6. package/collections/AssetstoreCollection.js +0 -9
  7. package/collections/Collection.js +0 -295
  8. package/collections/CollectionCollection.js +0 -9
  9. package/collections/FileCollection.js +0 -11
  10. package/collections/FolderCollection.js +0 -11
  11. package/collections/GroupCollection.js +0 -9
  12. package/collections/ItemCollection.js +0 -11
  13. package/collections/UserCollection.js +0 -24
  14. package/collections/index.js +0 -21
  15. package/constants.js +0 -33
  16. package/dialog.js +0 -128
  17. package/events.js +0 -6
  18. package/index.js +0 -31
  19. package/main.js +0 -21
  20. package/misc.js +0 -260
  21. package/models/AccessControlledModel.js +0 -76
  22. package/models/ApiKeyModel.js +0 -31
  23. package/models/AssetstoreModel.js +0 -43
  24. package/models/CollectionCreationPolicyModel.js +0 -20
  25. package/models/CollectionModel.js +0 -12
  26. package/models/FileModel.js +0 -310
  27. package/models/FolderModel.js +0 -33
  28. package/models/GroupModel.js +0 -197
  29. package/models/ItemModel.js +0 -72
  30. package/models/MetadataMixin.js +0 -88
  31. package/models/Model.js +0 -187
  32. package/models/UserModel.js +0 -189
  33. package/models/index.js +0 -25
  34. package/pluginUtils.js +0 -11
  35. package/rest.js +0 -216
  36. package/router.js +0 -58
  37. package/routes.js +0 -231
  38. package/stylesheets/apidocs/apidocs.styl +0 -50
  39. package/stylesheets/body/adminConsole.styl +0 -21
  40. package/stylesheets/body/assetstores.styl +0 -46
  41. package/stylesheets/body/collectionList.styl +0 -39
  42. package/stylesheets/body/collectionPage.styl +0 -6
  43. package/stylesheets/body/frontPage.styl +0 -48
  44. package/stylesheets/body/groupList.styl +0 -43
  45. package/stylesheets/body/groupPage.styl +0 -116
  46. package/stylesheets/body/itemPage.styl +0 -81
  47. package/stylesheets/body/plugins.styl +0 -61
  48. package/stylesheets/body/searchResultsList.styl +0 -51
  49. package/stylesheets/body/systemConfig.styl +0 -56
  50. package/stylesheets/body/userAccount.styl +0 -57
  51. package/stylesheets/body/userList.styl +0 -79
  52. package/stylesheets/body/userPage.styl +0 -6
  53. package/stylesheets/layout/footer.styl +0 -19
  54. package/stylesheets/layout/global.styl +0 -154
  55. package/stylesheets/layout/globalNav.styl +0 -89
  56. package/stylesheets/layout/header.styl +0 -29
  57. package/stylesheets/layout/headerUser.styl +0 -33
  58. package/stylesheets/layout/layout.styl +0 -75
  59. package/stylesheets/layout/layoutVars.styl +0 -9
  60. package/stylesheets/layout/loading.styl +0 -37
  61. package/stylesheets/layout/progressArea.styl +0 -17
  62. package/stylesheets/widgets/accessWidget.styl +0 -106
  63. package/stylesheets/widgets/browserWidget.styl +0 -9
  64. package/stylesheets/widgets/hierarchyWidget.styl +0 -188
  65. package/stylesheets/widgets/markdownWidget.styl +0 -92
  66. package/stylesheets/widgets/metadataWidget.styl +0 -92
  67. package/stylesheets/widgets/searchFieldWidget.styl +0 -70
  68. package/stylesheets/widgets/taskProgress.styl +0 -41
  69. package/stylesheets/widgets/timelineWidget.styl +0 -41
  70. package/stylesheets/widgets/uploadWidget.styl +0 -43
  71. package/stylesheets/widgets/userOtpManagementWidget.styl +0 -159
  72. package/templates/body/adminConsole.pug +0 -13
  73. package/templates/body/assetstores.pug +0 -98
  74. package/templates/body/collectionList.pug +0 -40
  75. package/templates/body/collectionPage.pug +0 -36
  76. package/templates/body/filesystemImport.pug +0 -41
  77. package/templates/body/frontPage.pug +0 -83
  78. package/templates/body/groupList.pug +0 -30
  79. package/templates/body/groupPage.pug +0 -116
  80. package/templates/body/itemPage.pug +0 -61
  81. package/templates/body/plugins.pug +0 -20
  82. package/templates/body/s3Import.pug +0 -35
  83. package/templates/body/searchResults.pug +0 -15
  84. package/templates/body/searchResultsType.pug +0 -13
  85. package/templates/body/systemConfiguration.pug +0 -221
  86. package/templates/body/userAccount.pug +0 -83
  87. package/templates/body/userList.pug +0 -43
  88. package/templates/body/userPage.pug +0 -40
  89. package/templates/layout/alert.pug +0 -5
  90. package/templates/layout/layout.pug +0 -12
  91. package/templates/layout/layoutFooter.pug +0 -11
  92. package/templates/layout/layoutGlobalNav.pug +0 -7
  93. package/templates/layout/layoutHeader.pug +0 -8
  94. package/templates/layout/layoutHeaderUser.pug +0 -26
  95. package/templates/layout/layoutProgressArea.pug +0 -1
  96. package/templates/layout/loginDialog.pug +0 -30
  97. package/templates/layout/registerDialog.pug +0 -35
  98. package/templates/layout/resetPasswordDialog.pug +0 -25
  99. package/templates/widgets/accessEditor.pug +0 -23
  100. package/templates/widgets/accessEditorMixins.pug +0 -57
  101. package/templates/widgets/accessEditorNonModal.pug +0 -11
  102. package/templates/widgets/accessEntry.pug +0 -32
  103. package/templates/widgets/apiKeyList.pug +0 -50
  104. package/templates/widgets/browserWidget.pug +0 -32
  105. package/templates/widgets/checkedActionsMenu.pug +0 -46
  106. package/templates/widgets/collectionInfoDialog.pug +0 -37
  107. package/templates/widgets/confirmDialog.pug +0 -14
  108. package/templates/widgets/dateTimeRangeWidget.pug +0 -20
  109. package/templates/widgets/dateTimeWidget.pug +0 -8
  110. package/templates/widgets/editApiKeyWidget.pug +0 -43
  111. package/templates/widgets/editAssetstoreWidget.pug +0 -78
  112. package/templates/widgets/editCollectionWidget.pug +0 -27
  113. package/templates/widgets/editFileWidget.pug +0 -21
  114. package/templates/widgets/editFolderWidget.pug +0 -27
  115. package/templates/widgets/editGroupWidget.pug +0 -54
  116. package/templates/widgets/editItemWidget.pug +0 -27
  117. package/templates/widgets/fileInfoDialog.pug +0 -33
  118. package/templates/widgets/fileList.pug +0 -33
  119. package/templates/widgets/folderInfoDialog.pug +0 -42
  120. package/templates/widgets/folderList.pug +0 -21
  121. package/templates/widgets/groupAdminList.pug +0 -33
  122. package/templates/widgets/groupInviteDialog.pug +0 -76
  123. package/templates/widgets/groupInviteList.pug +0 -14
  124. package/templates/widgets/groupMemberList.pug +0 -39
  125. package/templates/widgets/groupModList.pug +0 -23
  126. package/templates/widgets/hierarchyBreadcrumb.pug +0 -37
  127. package/templates/widgets/hierarchyPaginated.pug +0 -19
  128. package/templates/widgets/hierarchyWidget.pug +0 -96
  129. package/templates/widgets/itemBreadcrumb.pug +0 -16
  130. package/templates/widgets/itemList.pug +0 -27
  131. package/templates/widgets/jsonMetadatumEditWidget.pug +0 -13
  132. package/templates/widgets/jsonMetadatumView.pug +0 -6
  133. package/templates/widgets/loadingAnimation.pug +0 -4
  134. package/templates/widgets/markdownWidget.pug +0 -34
  135. package/templates/widgets/metadataWidget.pug +0 -16
  136. package/templates/widgets/metadatumEditWidget.pug +0 -15
  137. package/templates/widgets/metadatumView.pug +0 -5
  138. package/templates/widgets/newAssetstore.pug +0 -118
  139. package/templates/widgets/paginateWidget.pug +0 -7
  140. package/templates/widgets/pluginConfigBreadcrumb.pug +0 -13
  141. package/templates/widgets/rootSelectorWidget.pug +0 -13
  142. package/templates/widgets/searchField.pug +0 -10
  143. package/templates/widgets/searchHelp.pug +0 -12
  144. package/templates/widgets/searchModeSelect.pug +0 -9
  145. package/templates/widgets/searchResults.pug +0 -14
  146. package/templates/widgets/sortCollectionWidget.pug +0 -14
  147. package/templates/widgets/taskProgress.pug +0 -16
  148. package/templates/widgets/timeline.pug +0 -15
  149. package/templates/widgets/uploadWidget.pug +0 -15
  150. package/templates/widgets/uploadWidgetMixins.pug +0 -31
  151. package/templates/widgets/uploadWidgetNonModal.pug +0 -10
  152. package/templates/widgets/userOtpBegin.pug +0 -4
  153. package/templates/widgets/userOtpDisable.pug +0 -6
  154. package/templates/widgets/userOtpEnable.pug +0 -44
  155. package/utilities/EventStream.js +0 -177
  156. package/utilities/PluginUtils.js +0 -36
  157. package/utilities/S3UploadHandler.js +0 -303
  158. package/utilities/index.js +0 -9
  159. package/utilities/jquery/girderEnable.js +0 -19
  160. package/utilities/jquery/girderModal.js +0 -48
  161. package/version.js +0 -10
  162. package/views/App.js +0 -359
  163. package/views/View.js +0 -78
  164. package/views/body/AdminView.js +0 -29
  165. package/views/body/AssetstoresView.js +0 -235
  166. package/views/body/CollectionView.js +0 -188
  167. package/views/body/CollectionsView.js +0 -120
  168. package/views/body/FilesystemImportView.js +0 -83
  169. package/views/body/FolderView.js +0 -54
  170. package/views/body/FrontPageView.js +0 -47
  171. package/views/body/GroupView.js +0 -336
  172. package/views/body/GroupsView.js +0 -106
  173. package/views/body/ItemView.js +0 -177
  174. package/views/body/PluginsView.js +0 -73
  175. package/views/body/S3ImportView.js +0 -80
  176. package/views/body/SearchResultsView.js +0 -162
  177. package/views/body/SystemConfigurationView.js +0 -196
  178. package/views/body/UserAccountView.js +0 -179
  179. package/views/body/UserView.js +0 -165
  180. package/views/body/UsersView.js +0 -124
  181. package/views/body/index.js +0 -37
  182. package/views/index.js +0 -13
  183. package/views/layout/FooterView.js +0 -29
  184. package/views/layout/GlobalNavView.js +0 -103
  185. package/views/layout/HeaderUserView.js +0 -45
  186. package/views/layout/HeaderView.js +0 -83
  187. package/views/layout/LoginView.js +0 -100
  188. package/views/layout/ProgressListView.js +0 -70
  189. package/views/layout/RegisterView.js +0 -101
  190. package/views/layout/ResetPasswordView.js +0 -70
  191. package/views/layout/index.js +0 -19
  192. package/views/widgets/AccessWidget.js +0 -427
  193. package/views/widgets/ApiKeyListWidget.js +0 -140
  194. package/views/widgets/BrowserWidget.js +0 -317
  195. package/views/widgets/CheckedMenuWidget.js +0 -68
  196. package/views/widgets/CollectionInfoWidget.js +0 -40
  197. package/views/widgets/DateTimeRangeWidget.js +0 -179
  198. package/views/widgets/DateTimeWidget.js +0 -109
  199. package/views/widgets/EditApiKeyWidget.js +0 -122
  200. package/views/widgets/EditAssetstoreWidget.js +0 -148
  201. package/views/widgets/EditCollectionWidget.js +0 -93
  202. package/views/widgets/EditFileWidget.js +0 -56
  203. package/views/widgets/EditFolderWidget.js +0 -116
  204. package/views/widgets/EditGroupWidget.js +0 -125
  205. package/views/widgets/EditItemWidget.js +0 -110
  206. package/views/widgets/FileInfoWidget.js +0 -26
  207. package/views/widgets/FileListWidget.js +0 -151
  208. package/views/widgets/FolderInfoWidget.js +0 -39
  209. package/views/widgets/FolderListWidget.js +0 -106
  210. package/views/widgets/GroupAdminsWidget.js +0 -88
  211. package/views/widgets/GroupInvitesWidget.js +0 -56
  212. package/views/widgets/GroupMembersWidget.js +0 -185
  213. package/views/widgets/GroupModsWidget.js +0 -77
  214. package/views/widgets/HierarchyWidget.js +0 -1097
  215. package/views/widgets/ItemBreadcrumbWidget.js +0 -38
  216. package/views/widgets/ItemListWidget.js +0 -345
  217. package/views/widgets/LoadingAnimation.js +0 -17
  218. package/views/widgets/MarkdownWidget.js +0 -217
  219. package/views/widgets/MetadataWidget.js +0 -504
  220. package/views/widgets/NewAssetstoreWidget.js +0 -81
  221. package/views/widgets/PaginateWidget.js +0 -37
  222. package/views/widgets/PluginConfigBreadcrumbWidget.js +0 -33
  223. package/views/widgets/RootSelectorWidget.js +0 -192
  224. package/views/widgets/SearchFieldWidget.js +0 -365
  225. package/views/widgets/SearchPaginateWidget.js +0 -149
  226. package/views/widgets/SortCollectionWidget.js +0 -53
  227. package/views/widgets/TaskProgressWidget.js +0 -91
  228. package/views/widgets/TimelineWidget.js +0 -155
  229. package/views/widgets/UploadWidget.js +0 -340
  230. package/views/widgets/UserOtpManagementWidget.js +0 -105
  231. package/views/widgets/index.js +0 -75
package/README.md ADDED
@@ -0,0 +1,61 @@
1
+ ## Recommended IDE Setup
2
+
3
+ [VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).
4
+
5
+ ## Type Support for `.vue` Imports in TS
6
+
7
+ TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin) to make the TypeScript language service aware of `.vue` types.
8
+
9
+ If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a [Take Over Mode](https://github.com/johnsoncodehk/volar/discussions/471#discussioncomment-1361669) that is more performant. You can enable it by the following steps:
10
+
11
+ 1. Disable the built-in TypeScript Extension
12
+ 1) Run `Extensions: Show Built-in Extensions` from VSCode's command palette
13
+ 2) Find `TypeScript and JavaScript Language Features`, right click and select `Disable (Workspace)`
14
+ 2. Reload the VSCode window by running `Developer: Reload Window` from the command palette.
15
+
16
+ ## Customize configuration
17
+
18
+ See [Vite Configuration Reference](https://vitejs.dev/config/).
19
+
20
+ ## Project Setup
21
+
22
+ ```sh
23
+ npm install
24
+ ```
25
+
26
+ ### Compile and Hot-Reload for Development
27
+
28
+ ```sh
29
+ npm run dev
30
+ ```
31
+
32
+ ### Type-Check, Compile and Minify for Production
33
+
34
+ ```sh
35
+ npm run build
36
+ ```
37
+
38
+ ### Run Unit Tests with [Vitest](https://vitest.dev/)
39
+
40
+ ```sh
41
+ npm run test:unit
42
+ ```
43
+
44
+ ### Run End-to-End Tests with [Playwright](https://playwright.dev)
45
+
46
+ ```sh
47
+ # Install browsers for the first run
48
+ npx playwright install
49
+
50
+ # When testing on CI, must build the project first
51
+ npm run build
52
+
53
+ # Runs the end-to-end tests
54
+ npm run test:e2e
55
+ # Runs the tests only on Chromium
56
+ npm run test:e2e -- --project=chromium
57
+ # Runs the tests of a specific file
58
+ npm run test:e2e -- tests/example.spec.ts
59
+ # Runs the tests in debug mode
60
+ npm run test:e2e -- --debug
61
+ ```
package/package.json CHANGED
@@ -1,34 +1,82 @@
1
1
  {
2
- "name": "@girder/core",
3
- "version": "3.2.7",
4
- "description": "Extensible data management platform",
5
- "homepage": "https://girder.readthedocs.org",
6
- "bugs": {
7
- "url": "https://github.com/girder/girder/issues"
2
+ "name": "@girder/core",
3
+ "license": "Apache-2.0",
4
+ "version": "5.0.0-a6",
5
+ "type": "module",
6
+ "files": [
7
+ "dist-lib"
8
+ ],
9
+ "main": "./dist-lib/girder-core.umd.cjs",
10
+ "module": "./dist-lib/girder-core.js",
11
+ "types": "./dist-lib/index.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "import": {
15
+ "types": "./dist-lib/index.d.ts",
16
+ "default": "./dist-lib/girder-core.js"
17
+ },
18
+ "require": {
19
+ "types": "./dist-lib/index.d.ts",
20
+ "default": "./dist-lib/girder-core.umd.cjs"
21
+ }
8
22
  },
9
- "license": "Apache-2.0",
10
- "repository": {
11
- "type": "git",
12
- "url": "https://github.com/girder/girder.git"
13
- },
14
- "dependencies": {
15
- "as-jqplot": "^1.0.8",
16
- "backbone": "^1.4.0",
17
- "bootstrap": "^3.4.1",
18
- "bootstrap-switch": "~3.3.4",
19
- "eonasdan-bootstrap-datetimepicker": "^4.17",
20
- "@girder/fontello": "*",
21
- "jquery": "^3.7.0",
22
- "jsoneditor": "~5.9.3",
23
- "moment": "^2.24.0",
24
- "moment-timezone": "^0.5.27",
25
- "qrcode": "~1.4.4",
26
- "remarkable": "^2.0.0",
27
- "sprintf-js": "^1.1.2",
28
- "swagger-ui-dist": "^5.7.2",
29
- "typeface-open-sans": "^0.0.75",
30
- "underscore": "^1.13.6",
31
- "url-otpauth": "^2.0.0"
32
- },
33
- "main": "./index.js"
23
+ "./style.css": "./dist-lib/style.css"
24
+ },
25
+ "scripts": {
26
+ "dev": "vite",
27
+ "build": "run-p type-check build-only",
28
+ "preview": "vite preview",
29
+ "test": "playwright test",
30
+ "show-coverage": "http-server coverage/report --port 8888 -o",
31
+ "build-only": "vite build",
32
+ "build-lib": "BUILD_LIB=true vite build",
33
+ "type-check": "vue-tsc --noEmit -p tsconfig.json --composite false",
34
+ "install-browsers": "playwright install --with-deps"
35
+ },
36
+ "dependencies": {
37
+ "@girder/fontello": "^3.1.20",
38
+ "apexcharts": "^4.5.0",
39
+ "backbone": "~1.4.0",
40
+ "bootstrap": "~3.4.1",
41
+ "bootstrap-switch": "~3.3.4",
42
+ "eonasdan-bootstrap-datetimepicker": "~4.17",
43
+ "jquery": "~3.5.1",
44
+ "jsoneditor": "~5.9.3",
45
+ "moment": "~2.24.0",
46
+ "moment-timezone": "~0.5.27",
47
+ "qrcode": "~1.4.4",
48
+ "remarkable": "~2.0.0",
49
+ "typeface-open-sans": "^0.0.75",
50
+ "underscore": "~1.13.6",
51
+ "url-otpauth": "~2.0.0",
52
+ "vue": "^3.2.47"
53
+ },
54
+ "devDependencies": {
55
+ "@playwright/test": "^1.34.3",
56
+ "@rollup/plugin-inject": "^5.0.3",
57
+ "@tsconfig/node18": "^2.0.1",
58
+ "@types/istanbul-lib-report": "^3.0.0",
59
+ "@types/istanbul-reports": "^3.0.1",
60
+ "@types/jsdom": "^21.1.1",
61
+ "@types/node": "^18.16.16",
62
+ "@types/pug": "^2.0.6",
63
+ "@vitejs/plugin-vue": "^4.2.3",
64
+ "@vue/test-utils": "^2.3.2",
65
+ "@vue/tsconfig": "^0.4.0",
66
+ "http-server": "^14.1.1",
67
+ "istanbul-lib-report": "^3.0.0",
68
+ "istanbul-reports": "^3.1.5",
69
+ "jsdom": "^22.0.0",
70
+ "npm-run-all": "^4.1.5",
71
+ "playwright": "^1.34.3",
72
+ "playwright-test-coverage": "^1.2.12",
73
+ "pug": "^3.0.2",
74
+ "stylus": "^0.54.5",
75
+ "typescript": "~5.0.4",
76
+ "v8-to-istanbul": "^9.1.0",
77
+ "vite": "^4.3.5",
78
+ "vite-plugin-dts": "^2.3.0",
79
+ "vite-plugin-static-copy": "^0.16.0",
80
+ "vue-tsc": "^1.6.4"
81
+ }
34
82
  }
Binary file
package/auth.js DELETED
@@ -1,152 +0,0 @@
1
- import _ from 'underscore';
2
-
3
- import UserModel from '@girder/core/models/UserModel';
4
- import events from '@girder/core/events';
5
- import { restRequest } from '@girder/core/rest';
6
-
7
- // TODO: this might need some fixing/testing, as it seems that
8
- // girder.corsAuth could be an override. See login doc below.
9
- var corsAuth = false;
10
-
11
- // TODO delete in next major version
12
- var cookie = {
13
- findAll: function () {
14
- var cookies = {};
15
- _(document.cookie.split(';'))
16
- .chain()
17
- .map(function (m) {
18
- return m.replace(/^\s+/, '').replace(/\s+$/, '');
19
- })
20
- .each(function (c) {
21
- var arr = c.split('='),
22
- key = arr[0],
23
- value = null,
24
- size = _.size(arr);
25
- if (size > 1) {
26
- value = arr.slice(1).join('');
27
- }
28
- cookies[key] = value;
29
- });
30
- return cookies;
31
- },
32
-
33
- find: function (name) {
34
- var foundCookie = null,
35
- list = this.findAll();
36
-
37
- _.each(list, function (value, key) {
38
- if (key === name) {
39
- foundCookie = value;
40
- }
41
- });
42
- return foundCookie;
43
- }
44
- };
45
-
46
- var currentUser = null;
47
- var currentToken = window.localStorage.getItem('girderToken');
48
-
49
- function getCurrentUser() {
50
- return currentUser;
51
- }
52
-
53
- function setCurrentUser(user) {
54
- currentUser = user;
55
- }
56
-
57
- function getCurrentToken() {
58
- return currentToken;
59
- }
60
-
61
- function setCurrentToken(token) {
62
- currentToken = token;
63
- }
64
-
65
- function fetchCurrentUser() {
66
- return restRequest({
67
- method: 'GET',
68
- url: '/user/me'
69
- });
70
- }
71
-
72
- /**
73
- * Encode password using TextEncoder to support unicode
74
- */
75
- function basicAuthEncode(username, password) {
76
- const encoder = new TextEncoder();
77
- const data = encoder.encode(username + ':' + password);
78
- return 'Basic ' + btoa(String.fromCharCode(...data));
79
- }
80
-
81
- /**
82
- * Log in to the server. If successful, sets the value of currentUser
83
- * and currentToken and triggers the "g:login" and "g:login.success".
84
- * On failure, triggers the "g:login.error" event.
85
- *
86
- * @param username The username or email to login as.
87
- * @param password The password to use.
88
- * @param cors If the girder server is on a different origin, set this
89
- * to "true" to save the auth cookie on the current domain. Alternatively,
90
- * you may set the global option "girder.corsAuth = true".
91
- * @param otpToken An optional one-time password to include with the login.
92
- */
93
- function login(username, password, cors = corsAuth, otpToken = null) {
94
- var auth = basicAuthEncode(username, password);
95
-
96
- const headers = {
97
- Authorization: auth
98
- };
99
- if (_.isString(otpToken)) {
100
- // Use _.isString to send header with empty string
101
- headers['Girder-OTP'] = otpToken;
102
- }
103
- return restRequest({
104
- method: 'GET',
105
- url: '/user/authentication',
106
- headers: headers,
107
- error: null
108
- }).then(function (response) {
109
- response.user.token = response.authToken;
110
-
111
- setCurrentUser(new UserModel(response.user));
112
- setCurrentToken(response.user.token.token);
113
-
114
- window.localStorage.setItem('girderToken', response.user.token.token);
115
-
116
- events.trigger('g:login.success', response.user);
117
- events.trigger('g:login', response);
118
-
119
- return response.user;
120
- }).fail(function (jqxhr) {
121
- events.trigger('g:login.error', jqxhr.status, jqxhr);
122
- });
123
- }
124
-
125
- function logout() {
126
- return restRequest({
127
- method: 'DELETE',
128
- url: '/user/authentication'
129
- }).done(function () {
130
- setCurrentUser(null);
131
- setCurrentToken(null);
132
-
133
- window.localStorage.removeItem('girderToken');
134
-
135
- events.trigger('g:login', null);
136
- events.trigger('g:logout.success');
137
- }).fail(function (jqxhr) {
138
- events.trigger('g:logout.error', jqxhr.status, jqxhr);
139
- });
140
- }
141
-
142
- export {
143
- cookie,
144
- corsAuth,
145
- getCurrentUser,
146
- setCurrentUser,
147
- getCurrentToken,
148
- setCurrentToken,
149
- fetchCurrentUser,
150
- login,
151
- logout
152
- };
@@ -1,9 +0,0 @@
1
- import ApiKeyModel from '@girder/core/models/ApiKeyModel';
2
- import Collection from '@girder/core/collections/Collection';
3
-
4
- var ApiKeyCollection = Collection.extend({
5
- resourceName: 'api_key',
6
- model: ApiKeyModel
7
- });
8
-
9
- export default ApiKeyCollection;
@@ -1,9 +0,0 @@
1
- import AssetstoreModel from '@girder/core/models/AssetstoreModel';
2
- import Collection from '@girder/core/collections/Collection';
3
-
4
- var AssetstoreCollection = Collection.extend({
5
- resourceName: 'assetstore',
6
- model: AssetstoreModel
7
- });
8
-
9
- export default AssetstoreCollection;
@@ -1,295 +0,0 @@
1
- import _ from 'underscore';
2
- import Backbone from 'backbone';
3
-
4
- import { localeComparator } from '@girder/core/misc';
5
- import Model from '@girder/core/models/Model';
6
- import { restRequest } from '@girder/core/rest';
7
- import { SORT_ASC } from '@girder/core/constants';
8
-
9
- /**
10
- * All collections should descend from this collection base class, which
11
- * provides nice utilities for pagination and sorting.
12
- */
13
- var Collection = Backbone.Collection.extend({
14
- model: Model,
15
- resourceName: null,
16
-
17
- sortField: 'name',
18
- sortDir: SORT_ASC,
19
- comparator: localeComparator,
20
-
21
- // Number of records to fetch per page
22
- pageLimit: 25,
23
- offset: 0,
24
-
25
- // Alternative fetch URL
26
- altUrl: null,
27
-
28
- /**
29
- * Append mode can be used to append pages to the collection rather than
30
- * simply replacing its contents when a new page is fetched. For the sake
31
- * of least surprise, this property should not be changed in the definition
32
- * of collections, but after they are instantiated.
33
- */
34
- append: false,
35
-
36
- /**
37
- * Client-side filtering: set to a function that takes an instance of this
38
- * collection's model and returns true for each instance that should be
39
- * included in this collection. For the sake of least surprise, this
40
- * property should not be changed in the definition of collections, but
41
- * after they are instantiated.
42
- */
43
- filterFunc: null,
44
-
45
- /**
46
- * If filtering and not appending, this stack is used to record the offsets
47
- * at which prior pages had been fetched.
48
- */
49
- pageOffsetStack: null,
50
-
51
- /**
52
- * Number of items in the collection returned by 'girder-total-count' header
53
- */
54
- _totalCount: 0,
55
-
56
- /**
57
- * Returns a boolean of whether or not this collection has previous pages,
58
- * i.e. if the offset of the current page start is > 0
59
- */
60
- hasPreviousPage: function () {
61
- if (this.filterFunc) {
62
- if (this.append) { return false; }
63
- this.pageOffsetStack = this.pageOffsetStack || [];
64
- return (this.pageOffsetStack.length > 1);
65
- }
66
- return this.offset - this.length > 0;
67
- },
68
-
69
- /**
70
- * After you have called fetch() on a collection, this method will tell
71
- * you whether there are more pages remaining to be fetched, or if you
72
- * have hit the end.
73
- */
74
- hasNextPage: function () {
75
- return this._hasMorePages;
76
- },
77
- /**
78
- * This value is populated whenever the list length exceeds the pageLimit.
79
- * It is used to determine how many pages are needed based on the page limit
80
- * it is retrieved from the response header 'girder-total-count'
81
- * @returns {number} total number of items retrieved
82
- */
83
- getTotalCount: function () {
84
- return this._totalCount || 0;
85
- },
86
- /**
87
- * Fetch the previous page of this collection, emitting g:changed when done.
88
- */
89
- fetchPreviousPage: function (params) {
90
- if (this.filterFunc) {
91
- if (this.append) {
92
- this.offset = 0;
93
- } else {
94
- this.pageOffsetStack = this.pageOffsetStack || [];
95
- if (this.pageOffsetStack.length) {
96
- this.pageOffsetStack.pop();
97
- }
98
-
99
- this.offset = (
100
- this.pageOffsetStack.length ? this.pageOffsetStack.pop() : 0
101
- );
102
- }
103
- } else {
104
- this.offset = Math.max(
105
- 0,
106
- this.offset - this.length - this.pageLimit);
107
- }
108
- return this.fetch(_.extend({}, this.params, params || {}));
109
- },
110
-
111
- /**
112
- * Fetch the next page of this collection, emitting g:changed when done.
113
- */
114
- fetchNextPage: function (params) {
115
- return this.fetch(_.extend({}, this.params, params || {}));
116
- },
117
-
118
- /**
119
- * @returns {number} the 0-indexed page number of the current page. Add 1 to this
120
- * result when displaying it to the user.
121
- *
122
- * If this collection hasn't been fully initialized (i.e.: before any pages
123
- * have been fetched), pageNum() may return a page number < 0 to signal that
124
- * there is no "current page".
125
- */
126
- pageNum: function () {
127
- if (this.filterFunc) {
128
- if (this.append) { return 0; }
129
- this.pageOffsetStack = this.pageOffsetStack || [];
130
- return this.pageOffsetStack.length - 1;
131
- }
132
- return Math.ceil((this.offset - this.length) / this.pageLimit);
133
- },
134
-
135
- /**
136
- * Sets a specific pagenumber for loading by calculating the offset
137
- * @param {Number} pageNumber The 0 indexed page that should be loaded based on the pageLimit size
138
- * @param {Object} params Additional parameters to pass to the fetch call
139
- * @returns {Promise} a fetch promise to retrieve more data
140
- */
141
- fetchPage: function (pageNumber, params) {
142
- // Make sure the page Number is within range, pageNumber is indexed at 0
143
- if (!this.append && pageNumber * this.pageLimit < this._totalCount && pageNumber >= 0) {
144
- this.offset = pageNumber * this.pageLimit;
145
- return this.fetch(_.extend({}, this.params, params || {}));
146
- }
147
- },
148
-
149
- /**
150
- * Fetches the next page of this collection, replacing the existing models
151
- * of this collection with the requested page. If the next page contains
152
- * any records (i.e. it was not already on the last page), this will
153
- * trigger g:changed.
154
- * @param params Any additional parameters to be passed with the request.
155
- * @param reset Set this to true to re-fetch the current page.
156
- */
157
- fetch: function (params, reset) {
158
- if (this.altUrl === null && this.resourceName === null) {
159
- throw new Error('An altUrl or resourceName must be set on the Collection.');
160
- }
161
-
162
- if (this.filterFunc && !this.append) {
163
- this.pageOffsetStack = this.pageOffsetStack || [];
164
- }
165
-
166
- if (reset) {
167
- if (this.filterFunc && !this.append) {
168
- this.pageOffsetStack = [];
169
- }
170
- this.offset = 0;
171
- } else {
172
- this.params = params || {};
173
- }
174
-
175
- if (this.filterFunc && !this.append) {
176
- this.pageOffsetStack.push(this.offset);
177
- }
178
-
179
- var limit = this.pageLimit > 0 ? this.pageLimit + 1 : 0;
180
-
181
- var finalList = []; /* will be built up in pieces */
182
-
183
- function fetchListFragment() {
184
- var xhr = restRequest({
185
- url: this.altUrl || this.resourceName,
186
- data: _.extend({
187
- limit: limit,
188
- offset: this.offset,
189
- sort: this.sortField,
190
- sortdir: this.sortDir
191
- }, this.params)
192
- });
193
-
194
- var result = xhr.then((list) => {
195
- if (this.pageLimit > 0 && list.length > this.pageLimit) {
196
- // This means we have more pages to display still. Pop off
197
- // the extra that we fetched.
198
- list.pop();
199
- this._totalCount = xhr.getResponseHeader('girder-total-count');
200
- this._hasMorePages = true;
201
- } else {
202
- this._hasMorePages = false;
203
- }
204
-
205
- var offsetDelta = list.length;
206
-
207
- /*
208
- * If filtering, decorate the list with their pre-filtered
209
- * indexes. The index will be needed when adjusting the offset.
210
- */
211
- if (this.filterFunc) {
212
- var filter = this.filterFunc;
213
- list = (
214
- list
215
- .map(function (x, index) { return [index, x]; })
216
- .filter(function (tuple) {
217
- return filter(tuple[1]);
218
- })
219
- );
220
- }
221
-
222
- var numUsed = list.length;
223
- var wantMorePages = (
224
- (this.pageLimit === 0) ||
225
- (finalList.length + numUsed < this.pageLimit)
226
- );
227
-
228
- /* page is complete */
229
- if (!wantMorePages && this.pageLimit > 0) {
230
- /*
231
- * If we fetched more data than we needed to complete the
232
- * page, then newNumUsed will be < numUsed ...
233
- */
234
- var newNumUsed = this.pageLimit - finalList.length;
235
- if (numUsed > newNumUsed) {
236
- /*
237
- * ...therefore, entries are being left out at the end,
238
- * so they necessarily remain to be fetched.
239
- */
240
- this._hasMorePages = true;
241
- numUsed = newNumUsed;
242
- }
243
-
244
- /*
245
- * correct the offset: it must be advanced beyond the
246
- * last element that got used.
247
- */
248
- if (this.filterFunc) {
249
- /*
250
- * If filtering, consult the index for the last element
251
- * to be featured on this page.
252
- */
253
- offsetDelta = list[numUsed - 1][0] + 1;
254
- } else {
255
- /*
256
- * Otherwise, the first numUsed elements will be
257
- * unconditionally featured.
258
- */
259
- offsetDelta = numUsed;
260
- }
261
- }
262
-
263
- list = list.slice(0, numUsed);
264
- /* If filtering, undecorate the list. */
265
- if (this.filterFunc) {
266
- list = list.map(function (tuple) { return tuple[1]; });
267
- }
268
-
269
- finalList = finalList.concat(list);
270
- this.offset += offsetDelta;
271
-
272
- if (wantMorePages && this._hasMorePages) {
273
- return fetchListFragment.apply(this);
274
- } else {
275
- if (finalList.length > 0 || reset) {
276
- if (this.append && !reset) {
277
- this.add(finalList);
278
- } else {
279
- this.reset(finalList);
280
- }
281
- }
282
-
283
- this.trigger('g:changed');
284
- }
285
- return undefined;
286
- });
287
- xhr.girder = { fetch: true };
288
- return result;
289
- }
290
-
291
- return fetchListFragment.apply(this);
292
- }
293
- });
294
-
295
- export default Collection;
@@ -1,9 +0,0 @@
1
- import Collection from '@girder/core/collections/Collection';
2
- import CollectionModel from '@girder/core/models/CollectionModel';
3
-
4
- var CollectionCollection = Collection.extend({
5
- resourceName: 'collection',
6
- model: CollectionModel
7
- });
8
-
9
- export default CollectionCollection;
@@ -1,11 +0,0 @@
1
- import Collection from '@girder/core/collections/Collection';
2
- import FileModel from '@girder/core/models/FileModel';
3
-
4
- var FileCollection = Collection.extend({
5
- resourceName: 'file',
6
- model: FileModel,
7
-
8
- pageLimit: 100
9
- });
10
-
11
- export default FileCollection;
@@ -1,11 +0,0 @@
1
- import Collection from '@girder/core/collections/Collection';
2
- import FolderModel from '@girder/core/models/FolderModel';
3
-
4
- var FolderCollection = Collection.extend({
5
- resourceName: 'folder',
6
- model: FolderModel,
7
-
8
- pageLimit: 100
9
- });
10
-
11
- export default FolderCollection;