@girder/core 3.2.8 → 5.0.0-a7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -0
- package/package.json +79 -31
- package/assets/Girder_Mark.png +0 -0
- package/auth.js +0 -152
- package/collections/ApiKeyCollection.js +0 -9
- package/collections/AssetstoreCollection.js +0 -9
- package/collections/Collection.js +0 -295
- package/collections/CollectionCollection.js +0 -9
- package/collections/FileCollection.js +0 -11
- package/collections/FolderCollection.js +0 -11
- package/collections/GroupCollection.js +0 -9
- package/collections/ItemCollection.js +0 -11
- package/collections/UserCollection.js +0 -24
- package/collections/index.js +0 -21
- package/constants.js +0 -33
- package/dialog.js +0 -128
- package/events.js +0 -6
- package/index.js +0 -31
- package/main.js +0 -21
- package/misc.js +0 -260
- package/models/AccessControlledModel.js +0 -76
- package/models/ApiKeyModel.js +0 -31
- package/models/AssetstoreModel.js +0 -43
- package/models/CollectionCreationPolicyModel.js +0 -20
- package/models/CollectionModel.js +0 -12
- package/models/FileModel.js +0 -310
- package/models/FolderModel.js +0 -33
- package/models/GroupModel.js +0 -197
- package/models/ItemModel.js +0 -72
- package/models/MetadataMixin.js +0 -88
- package/models/Model.js +0 -187
- package/models/UserModel.js +0 -189
- package/models/index.js +0 -25
- package/pluginUtils.js +0 -11
- package/rest.js +0 -216
- package/router.js +0 -58
- package/routes.js +0 -231
- package/stylesheets/apidocs/apidocs.styl +0 -50
- package/stylesheets/body/adminConsole.styl +0 -21
- package/stylesheets/body/assetstores.styl +0 -46
- package/stylesheets/body/collectionList.styl +0 -39
- package/stylesheets/body/collectionPage.styl +0 -6
- package/stylesheets/body/frontPage.styl +0 -48
- package/stylesheets/body/groupList.styl +0 -43
- package/stylesheets/body/groupPage.styl +0 -116
- package/stylesheets/body/itemPage.styl +0 -81
- package/stylesheets/body/plugins.styl +0 -61
- package/stylesheets/body/searchResultsList.styl +0 -51
- package/stylesheets/body/systemConfig.styl +0 -56
- package/stylesheets/body/userAccount.styl +0 -57
- package/stylesheets/body/userList.styl +0 -79
- package/stylesheets/body/userPage.styl +0 -6
- package/stylesheets/layout/footer.styl +0 -19
- package/stylesheets/layout/global.styl +0 -154
- package/stylesheets/layout/globalNav.styl +0 -89
- package/stylesheets/layout/header.styl +0 -29
- package/stylesheets/layout/headerUser.styl +0 -33
- package/stylesheets/layout/layout.styl +0 -75
- package/stylesheets/layout/layoutVars.styl +0 -9
- package/stylesheets/layout/loading.styl +0 -37
- package/stylesheets/layout/progressArea.styl +0 -17
- package/stylesheets/widgets/accessWidget.styl +0 -106
- package/stylesheets/widgets/browserWidget.styl +0 -9
- package/stylesheets/widgets/hierarchyWidget.styl +0 -188
- package/stylesheets/widgets/markdownWidget.styl +0 -92
- package/stylesheets/widgets/metadataWidget.styl +0 -92
- package/stylesheets/widgets/searchFieldWidget.styl +0 -70
- package/stylesheets/widgets/taskProgress.styl +0 -41
- package/stylesheets/widgets/timelineWidget.styl +0 -41
- package/stylesheets/widgets/uploadWidget.styl +0 -43
- package/stylesheets/widgets/userOtpManagementWidget.styl +0 -159
- package/templates/body/adminConsole.pug +0 -13
- package/templates/body/assetstores.pug +0 -98
- package/templates/body/collectionList.pug +0 -40
- package/templates/body/collectionPage.pug +0 -36
- package/templates/body/filesystemImport.pug +0 -41
- package/templates/body/frontPage.pug +0 -83
- package/templates/body/groupList.pug +0 -30
- package/templates/body/groupPage.pug +0 -116
- package/templates/body/itemPage.pug +0 -61
- package/templates/body/plugins.pug +0 -20
- package/templates/body/s3Import.pug +0 -35
- package/templates/body/searchResults.pug +0 -15
- package/templates/body/searchResultsType.pug +0 -13
- package/templates/body/systemConfiguration.pug +0 -221
- package/templates/body/userAccount.pug +0 -83
- package/templates/body/userList.pug +0 -43
- package/templates/body/userPage.pug +0 -40
- package/templates/layout/alert.pug +0 -5
- package/templates/layout/layout.pug +0 -12
- package/templates/layout/layoutFooter.pug +0 -11
- package/templates/layout/layoutGlobalNav.pug +0 -7
- package/templates/layout/layoutHeader.pug +0 -8
- package/templates/layout/layoutHeaderUser.pug +0 -26
- package/templates/layout/layoutProgressArea.pug +0 -1
- package/templates/layout/loginDialog.pug +0 -30
- package/templates/layout/registerDialog.pug +0 -35
- package/templates/layout/resetPasswordDialog.pug +0 -25
- package/templates/widgets/accessEditor.pug +0 -23
- package/templates/widgets/accessEditorMixins.pug +0 -57
- package/templates/widgets/accessEditorNonModal.pug +0 -11
- package/templates/widgets/accessEntry.pug +0 -32
- package/templates/widgets/apiKeyList.pug +0 -50
- package/templates/widgets/browserWidget.pug +0 -32
- package/templates/widgets/checkedActionsMenu.pug +0 -46
- package/templates/widgets/collectionInfoDialog.pug +0 -37
- package/templates/widgets/confirmDialog.pug +0 -14
- package/templates/widgets/dateTimeRangeWidget.pug +0 -20
- package/templates/widgets/dateTimeWidget.pug +0 -8
- package/templates/widgets/editApiKeyWidget.pug +0 -43
- package/templates/widgets/editAssetstoreWidget.pug +0 -78
- package/templates/widgets/editCollectionWidget.pug +0 -27
- package/templates/widgets/editFileWidget.pug +0 -21
- package/templates/widgets/editFolderWidget.pug +0 -27
- package/templates/widgets/editGroupWidget.pug +0 -54
- package/templates/widgets/editItemWidget.pug +0 -27
- package/templates/widgets/fileInfoDialog.pug +0 -33
- package/templates/widgets/fileList.pug +0 -33
- package/templates/widgets/folderInfoDialog.pug +0 -42
- package/templates/widgets/folderList.pug +0 -21
- package/templates/widgets/groupAdminList.pug +0 -33
- package/templates/widgets/groupInviteDialog.pug +0 -76
- package/templates/widgets/groupInviteList.pug +0 -14
- package/templates/widgets/groupMemberList.pug +0 -39
- package/templates/widgets/groupModList.pug +0 -23
- package/templates/widgets/hierarchyBreadcrumb.pug +0 -37
- package/templates/widgets/hierarchyPaginated.pug +0 -19
- package/templates/widgets/hierarchyWidget.pug +0 -96
- package/templates/widgets/itemBreadcrumb.pug +0 -16
- package/templates/widgets/itemList.pug +0 -27
- package/templates/widgets/jsonMetadatumEditWidget.pug +0 -13
- package/templates/widgets/jsonMetadatumView.pug +0 -6
- package/templates/widgets/loadingAnimation.pug +0 -4
- package/templates/widgets/markdownWidget.pug +0 -34
- package/templates/widgets/metadataWidget.pug +0 -16
- package/templates/widgets/metadatumEditWidget.pug +0 -15
- package/templates/widgets/metadatumView.pug +0 -5
- package/templates/widgets/newAssetstore.pug +0 -118
- package/templates/widgets/paginateWidget.pug +0 -7
- package/templates/widgets/pluginConfigBreadcrumb.pug +0 -13
- package/templates/widgets/rootSelectorWidget.pug +0 -13
- package/templates/widgets/searchField.pug +0 -10
- package/templates/widgets/searchHelp.pug +0 -12
- package/templates/widgets/searchModeSelect.pug +0 -9
- package/templates/widgets/searchResults.pug +0 -14
- package/templates/widgets/sortCollectionWidget.pug +0 -14
- package/templates/widgets/taskProgress.pug +0 -16
- package/templates/widgets/timeline.pug +0 -15
- package/templates/widgets/uploadWidget.pug +0 -15
- package/templates/widgets/uploadWidgetMixins.pug +0 -31
- package/templates/widgets/uploadWidgetNonModal.pug +0 -10
- package/templates/widgets/userOtpBegin.pug +0 -4
- package/templates/widgets/userOtpDisable.pug +0 -6
- package/templates/widgets/userOtpEnable.pug +0 -44
- package/utilities/EventStream.js +0 -177
- package/utilities/PluginUtils.js +0 -36
- package/utilities/S3UploadHandler.js +0 -303
- package/utilities/index.js +0 -9
- package/utilities/jquery/girderEnable.js +0 -19
- package/utilities/jquery/girderModal.js +0 -48
- package/version.js +0 -10
- package/views/App.js +0 -359
- package/views/View.js +0 -78
- package/views/body/AdminView.js +0 -29
- package/views/body/AssetstoresView.js +0 -235
- package/views/body/CollectionView.js +0 -188
- package/views/body/CollectionsView.js +0 -120
- package/views/body/FilesystemImportView.js +0 -83
- package/views/body/FolderView.js +0 -54
- package/views/body/FrontPageView.js +0 -47
- package/views/body/GroupView.js +0 -336
- package/views/body/GroupsView.js +0 -106
- package/views/body/ItemView.js +0 -177
- package/views/body/PluginsView.js +0 -73
- package/views/body/S3ImportView.js +0 -80
- package/views/body/SearchResultsView.js +0 -162
- package/views/body/SystemConfigurationView.js +0 -196
- package/views/body/UserAccountView.js +0 -179
- package/views/body/UserView.js +0 -165
- package/views/body/UsersView.js +0 -124
- package/views/body/index.js +0 -37
- package/views/index.js +0 -13
- package/views/layout/FooterView.js +0 -29
- package/views/layout/GlobalNavView.js +0 -103
- package/views/layout/HeaderUserView.js +0 -45
- package/views/layout/HeaderView.js +0 -83
- package/views/layout/LoginView.js +0 -100
- package/views/layout/ProgressListView.js +0 -70
- package/views/layout/RegisterView.js +0 -101
- package/views/layout/ResetPasswordView.js +0 -70
- package/views/layout/index.js +0 -19
- package/views/widgets/AccessWidget.js +0 -427
- package/views/widgets/ApiKeyListWidget.js +0 -140
- package/views/widgets/BrowserWidget.js +0 -317
- package/views/widgets/CheckedMenuWidget.js +0 -68
- package/views/widgets/CollectionInfoWidget.js +0 -40
- package/views/widgets/DateTimeRangeWidget.js +0 -179
- package/views/widgets/DateTimeWidget.js +0 -109
- package/views/widgets/EditApiKeyWidget.js +0 -122
- package/views/widgets/EditAssetstoreWidget.js +0 -148
- package/views/widgets/EditCollectionWidget.js +0 -93
- package/views/widgets/EditFileWidget.js +0 -56
- package/views/widgets/EditFolderWidget.js +0 -116
- package/views/widgets/EditGroupWidget.js +0 -125
- package/views/widgets/EditItemWidget.js +0 -110
- package/views/widgets/FileInfoWidget.js +0 -26
- package/views/widgets/FileListWidget.js +0 -151
- package/views/widgets/FolderInfoWidget.js +0 -39
- package/views/widgets/FolderListWidget.js +0 -106
- package/views/widgets/GroupAdminsWidget.js +0 -88
- package/views/widgets/GroupInvitesWidget.js +0 -56
- package/views/widgets/GroupMembersWidget.js +0 -185
- package/views/widgets/GroupModsWidget.js +0 -77
- package/views/widgets/HierarchyWidget.js +0 -1097
- package/views/widgets/ItemBreadcrumbWidget.js +0 -38
- package/views/widgets/ItemListWidget.js +0 -345
- package/views/widgets/LoadingAnimation.js +0 -17
- package/views/widgets/MarkdownWidget.js +0 -217
- package/views/widgets/MetadataWidget.js +0 -504
- package/views/widgets/NewAssetstoreWidget.js +0 -81
- package/views/widgets/PaginateWidget.js +0 -37
- package/views/widgets/PluginConfigBreadcrumbWidget.js +0 -33
- package/views/widgets/RootSelectorWidget.js +0 -192
- package/views/widgets/SearchFieldWidget.js +0 -365
- package/views/widgets/SearchPaginateWidget.js +0 -149
- package/views/widgets/SortCollectionWidget.js +0 -53
- package/views/widgets/TaskProgressWidget.js +0 -91
- package/views/widgets/TimelineWidget.js +0 -155
- package/views/widgets/UploadWidget.js +0 -340
- package/views/widgets/UserOtpManagementWidget.js +0 -105
- package/views/widgets/index.js +0 -75
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
p.g-search-help-text= modeHelp
|
|
2
|
-
if mode === 'text'
|
|
3
|
-
ul.g-search-examples-list
|
|
4
|
-
li
|
|
5
|
-
code cat dog
|
|
6
|
-
| returns documents containing either "cat" or "dog".
|
|
7
|
-
li
|
|
8
|
-
code "cat" "dog"
|
|
9
|
-
| returns documents containing both "cat" and "dog".
|
|
10
|
-
li
|
|
11
|
-
code "cat dog"
|
|
12
|
-
| returns documents containing the phrase "cat dog".
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
each result in results
|
|
2
|
-
li.g-search-result
|
|
3
|
-
a.g-search-result-element(data-resource-id=result.id, data-resource-type=result.type, data-resource-icon=result.icon, tabindex="-1")
|
|
4
|
-
i(class=`icon-${result.icon}`)
|
|
5
|
-
| #{result.text}
|
|
6
|
-
if results.length === 0
|
|
7
|
-
li.g-no-search-results.disabled
|
|
8
|
-
a(tabindex="-1")
|
|
9
|
-
i.icon-block
|
|
10
|
-
| No results found
|
|
11
|
-
else
|
|
12
|
-
li.g-search-result
|
|
13
|
-
a.g-search-result-page-link(data-resource-type="resultPage")
|
|
14
|
-
| ...
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
.btn-group
|
|
2
|
-
a.g-sort-order-button.g-up.btn.btn-sm(title="Sort order")
|
|
3
|
-
i.icon-sort-name-up
|
|
4
|
-
a.g-sort-order-button.g-down.btn.btn-sm(title="Sort order")
|
|
5
|
-
i.icon-sort-name-down
|
|
6
|
-
button.g-collection-sort-actions.btn.btn-sm.btn-default.dropdown-toggle(
|
|
7
|
-
data-toggle="dropdown", title="Sort by Field")
|
|
8
|
-
| Sort by
|
|
9
|
-
i.icon-down-dir
|
|
10
|
-
ul.g-collection-sort-menu.dropdown-menu(role="menu")
|
|
11
|
-
each fieldName, field in fields
|
|
12
|
-
li(role="presentation")
|
|
13
|
-
a.g-collection-sort-link(role="menuitem", g-sort=field)
|
|
14
|
-
= fieldName
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
.g-task-progress-top
|
|
2
|
-
.g-task-progress-bar.progress(class=progressClass)
|
|
3
|
-
.progress-bar(class=barClass, style=`width: ${width};`)
|
|
4
|
-
.progress-status
|
|
5
|
-
.progress-percent
|
|
6
|
-
= percentText
|
|
7
|
-
.progress-left
|
|
8
|
-
= timeLeftText
|
|
9
|
-
.g-task-progress-title(title=progress.data.title)
|
|
10
|
-
if progress.data.resource && progress.data.resource._id && progress.data.resourceName
|
|
11
|
-
a(title=progress.data.title, href='#' + progress.data.resourceName + '/' + progress.data.resource._id)
|
|
12
|
-
= progress.data.title
|
|
13
|
-
else
|
|
14
|
-
= progress.data.title
|
|
15
|
-
.g-task-progress-bottom
|
|
16
|
-
.g-task-progress-message= progress.data.message
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
.g-timeline-widget-wrapper
|
|
2
|
-
.g-timeline-container
|
|
3
|
-
each segment in segments
|
|
4
|
-
.g-timeline-segment(
|
|
5
|
-
title=segment.tooltip, class=segment.class,
|
|
6
|
-
style=`left: ${segment.left}; width: ${segment.width}; ${segment.color}`)
|
|
7
|
-
each point in points
|
|
8
|
-
.g-timeline-point(
|
|
9
|
-
title=point.tooltip, class=point.class, style=`left: calc(${point.left} - 10px); ${point.color}`)
|
|
10
|
-
if startLabel !== undefined || endLabel !== undefined
|
|
11
|
-
.g-timeline-labels-container
|
|
12
|
-
if startLabel !== undefined
|
|
13
|
-
.g-timeline-start-label= startLabel
|
|
14
|
-
if endLabel !== undefined
|
|
15
|
-
.g-timeline-end-label= endLabel
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
include uploadWidgetMixins
|
|
2
|
-
|
|
3
|
-
.modal-dialog
|
|
4
|
-
.modal-content
|
|
5
|
-
form#g-upload-form.modal-form(role="form")
|
|
6
|
-
.modal-header
|
|
7
|
-
button.close(data-dismiss="modal", aria-hidden="true", type="button") ×
|
|
8
|
-
h4.modal-title= title
|
|
9
|
-
+g-upload-widget-subtitle
|
|
10
|
-
.modal-body
|
|
11
|
-
+g-upload-widget-browse-or-drop
|
|
12
|
-
+g-upload-widget-progress
|
|
13
|
-
.modal-footer
|
|
14
|
-
a.btn.btn-small.btn-default(data-dismiss="modal") Close
|
|
15
|
-
+g-upload-widget-start-button
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
mixin g-upload-widget-subtitle
|
|
2
|
-
if parent && parentType
|
|
3
|
-
.g-dialog-subtitle
|
|
4
|
-
if (parentType === 'folder')
|
|
5
|
-
i.icon-folder-open
|
|
6
|
-
else if (parentType === 'item')
|
|
7
|
-
i.icon-doc-text-inv
|
|
8
|
-
else if (parentType === 'file')
|
|
9
|
-
i.icon-doc-inv
|
|
10
|
-
= parent.name()
|
|
11
|
-
|
|
12
|
-
mixin g-upload-widget-browse-or-drop
|
|
13
|
-
.g-drop-zone
|
|
14
|
-
i.icon-docs
|
|
15
|
-
| #{browseText}
|
|
16
|
-
.form-group.hide
|
|
17
|
-
input#g-files(type="file", multiple=(multiFile ? 'multiple' : null))
|
|
18
|
-
|
|
19
|
-
mixin g-upload-widget-progress
|
|
20
|
-
.g-current-progress-message
|
|
21
|
-
.g-progress-current.progress.progress-striped.hide
|
|
22
|
-
.progress-bar.progress-bar-info(role="progressbar")
|
|
23
|
-
.g-overall-progress-message= noneSelectedText
|
|
24
|
-
.g-progress-overall.progress.progress-striped.hide
|
|
25
|
-
.progress-bar.progress-bar-info(role="progressbar")
|
|
26
|
-
.g-upload-error-message.g-validation-failed-message
|
|
27
|
-
|
|
28
|
-
mixin g-upload-widget-start-button
|
|
29
|
-
button.g-start-upload.btn.btn-small.btn-primary.disabled(type="submit", disabled)
|
|
30
|
-
i.icon-upload
|
|
31
|
-
| Start Upload
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
h2 Enable Two-factor authentication
|
|
2
|
-
|
|
3
|
-
ol.g-account-otp-steps
|
|
4
|
-
li.g-account-otp-step
|
|
5
|
-
h3 Install an authenticator app on your mobile device.
|
|
6
|
-
div.
|
|
7
|
-
There are many compatible apps, including, but not limited to
|
|
8
|
-
#[a(href='https://support.google.com/accounts/answer/1066447?hl=en', target='_blank', rel='noopener') Google Authenticator],
|
|
9
|
-
#[a(href='https://guide.duo.com/third-party-accounts', target='_blank', rel='noopener') Duo Mobile], and
|
|
10
|
-
#[a(href='https://freeotp.github.io/', target='_blank', rel='noopener') FreeOTP].
|
|
11
|
-
li.g-account-otp-step
|
|
12
|
-
h3 Enter your key into the authenticator app
|
|
13
|
-
.g-account-otp-scan-qr
|
|
14
|
-
h4 Scan with your mobile device's camera:
|
|
15
|
-
canvas#g-user-otp-qr
|
|
16
|
-
.g-account-otp-enter-manual
|
|
17
|
-
h4 Advanced Users:
|
|
18
|
-
span You may enter your information manually, instead:
|
|
19
|
-
table
|
|
20
|
-
tr
|
|
21
|
-
th Service
|
|
22
|
-
td
|
|
23
|
-
code= totpInfo.issuer
|
|
24
|
-
tr
|
|
25
|
-
th Account
|
|
26
|
-
td
|
|
27
|
-
code= totpInfo.account
|
|
28
|
-
tr
|
|
29
|
-
th Key
|
|
30
|
-
td
|
|
31
|
-
// Split into 4-character chunks for human readability
|
|
32
|
-
code= totpInfo.key.match(/.{1,4}/g).join('-')
|
|
33
|
-
tr
|
|
34
|
-
th Type
|
|
35
|
-
td
|
|
36
|
-
span #[code Time-based] / #[code TOTP]
|
|
37
|
-
li.g-account-otp-step
|
|
38
|
-
h3 Enter the authentication code from your app
|
|
39
|
-
input#g-user-otp-token(type='text', minlength=6, maxlength=6, placeholder='Your 6-digit code')
|
|
40
|
-
div
|
|
41
|
-
span#g-account-otp-error.g-validation-failed-message
|
|
42
|
-
.g-user-otp-footer
|
|
43
|
-
a#g-user-otp-cancel-enable.btn.btn-default Cancel
|
|
44
|
-
button#g-user-otp-finalize-enable.btn.btn-primary.btn-success(type="submit") Enable Two-Factor
|
package/utilities/EventStream.js
DELETED
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
import $ from 'jquery';
|
|
2
|
-
import _ from 'underscore';
|
|
3
|
-
import Backbone from 'backbone';
|
|
4
|
-
|
|
5
|
-
import { getApiRoot, restRequest } from '@girder/core/rest';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* The EventStream type wraps window.EventSource to listen to the unified
|
|
9
|
-
* per-user event channel endpoint using the SSE protocol. When events are
|
|
10
|
-
* received on the SSE channel, this triggers a Backbone event of the form
|
|
11
|
-
* 'g:event.<type>' where <type> is the value of the event type field.
|
|
12
|
-
* Listeners can bind to specific event types on the channel.
|
|
13
|
-
*/
|
|
14
|
-
function EventStream(settings) {
|
|
15
|
-
const defaults = {
|
|
16
|
-
timeout: null,
|
|
17
|
-
streamPath: '/notification/stream'
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
// User-provided settings from initialization
|
|
21
|
-
this.settings = _.extend(defaults, settings);
|
|
22
|
-
// Possible states are 'closed', 'stopped', 'started'
|
|
23
|
-
this._state = 'closed';
|
|
24
|
-
// Whether this is started (if so, holds the EventSource instance)
|
|
25
|
-
this._eventSource = null;
|
|
26
|
-
|
|
27
|
-
// Create context bindings only once, so they can be referenced when unbinding events
|
|
28
|
-
this._onVisibilityStateChange = _.bind(this._onVisibilityStateChange, this);
|
|
29
|
-
this._onMessage = _.bind(this._onMessage, this);
|
|
30
|
-
this._onError = _.bind(this._onError, this);
|
|
31
|
-
|
|
32
|
-
return _.extend(this, Backbone.Events);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
EventStream.prototype._onVisibilityStateChange = function () {
|
|
36
|
-
if (document.visibilityState === 'visible' && this._state === 'stopped') {
|
|
37
|
-
this._start();
|
|
38
|
-
} else if (document.visibilityState === 'hidden' && this._state === 'started') {
|
|
39
|
-
this._stop();
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
EventStream.prototype._onMessage = function (e) {
|
|
44
|
-
let obj;
|
|
45
|
-
try {
|
|
46
|
-
obj = window.JSON.parse(e.data);
|
|
47
|
-
} catch (err) {
|
|
48
|
-
console.error('Invalid JSON from SSE stream: ' + e.data + ',' + err);
|
|
49
|
-
this.trigger('g:error', e);
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
EventStream.setLastTimestamp(obj._girderTime);
|
|
53
|
-
this.trigger('g:event.' + obj.type, obj);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
EventStream.prototype._onError = function () {
|
|
57
|
-
// The EventSource.onerror API does not provide the HTTP status code of the error, so send an Ajax HEAD request to
|
|
58
|
-
// capture the status code.
|
|
59
|
-
restRequest({
|
|
60
|
-
url: this.settings.streamPath,
|
|
61
|
-
method: 'HEAD',
|
|
62
|
-
error: null
|
|
63
|
-
})
|
|
64
|
-
.fail((jqXHR) => {
|
|
65
|
-
if (jqXHR.status === 503) {
|
|
66
|
-
// Notification stream is disabled, so close this EventStream
|
|
67
|
-
this.trigger('g:eventStream.disable', jqXHR);
|
|
68
|
-
this.close();
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
// In all other cases (HEAD doesn't fail, or fails with a non-503 code), assume this is a temporary outage and allow
|
|
72
|
-
// the EventStream to continue attempting to auto-connect
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
EventStream.prototype.open = function () {
|
|
76
|
-
if (!window.EventSource) {
|
|
77
|
-
console.error('EventSource is not supported on this platform.');
|
|
78
|
-
this.trigger('g:eventStream.disable');
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
if (this._state !== 'closed') {
|
|
82
|
-
console.warn('EventStream should be closed.');
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
this._state = 'stopped';
|
|
87
|
-
this._start();
|
|
88
|
-
|
|
89
|
-
document.addEventListener('visibilitychange', this._onVisibilityStateChange);
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
EventStream.prototype._start = function () {
|
|
93
|
-
if (this._state !== 'stopped') {
|
|
94
|
-
console.warn('EventStream should be stopped');
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
const params = {};
|
|
99
|
-
|
|
100
|
-
if (this.settings.timeout) {
|
|
101
|
-
params.timeout = this.settings.timeout;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// Set the "since" argument to filter out notifications that have already been sent to this client.
|
|
105
|
-
const timestamp = EventStream.getLastTimestamp();
|
|
106
|
-
if (_.isNumber(timestamp)) {
|
|
107
|
-
params.since = timestamp;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
const url = getApiRoot() + this.settings.streamPath + '?' + $.param(params);
|
|
111
|
-
|
|
112
|
-
this._eventSource = new window.EventSource(url);
|
|
113
|
-
this._eventSource.onmessage = this._onMessage;
|
|
114
|
-
this._eventSource.onerror = this._onError;
|
|
115
|
-
|
|
116
|
-
this._state = 'started';
|
|
117
|
-
this.trigger('g:eventStream.start');
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
EventStream.prototype._stop = function () {
|
|
121
|
-
if (this._state !== 'started') {
|
|
122
|
-
console.warn('EventStream should be started');
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
this._eventSource.close();
|
|
127
|
-
this._eventSource = null;
|
|
128
|
-
|
|
129
|
-
this._state = 'stopped';
|
|
130
|
-
this.trigger('g:eventStream.stop');
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
EventStream.prototype.close = function () {
|
|
134
|
-
if (this._state === 'closed') {
|
|
135
|
-
console.warn('EventStream should not be closed');
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
document.removeEventListener('visibilitychange', this._onVisibilityStateChange);
|
|
140
|
-
|
|
141
|
-
if (this._state === 'started') {
|
|
142
|
-
this._stop();
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
this._state = 'closed';
|
|
146
|
-
this.trigger('g:eventStream.close');
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
// Static methods
|
|
150
|
-
EventStream._lastTimestamp = null;
|
|
151
|
-
EventStream.setLastTimestamp = function (timestamp) {
|
|
152
|
-
try {
|
|
153
|
-
window.localStorage.setItem('sseTimestamp', timestamp);
|
|
154
|
-
} catch (e) {
|
|
155
|
-
// Ignore any errors raised by localStorage
|
|
156
|
-
}
|
|
157
|
-
EventStream._lastTimestamp = timestamp;
|
|
158
|
-
};
|
|
159
|
-
EventStream.getLastTimestamp = function () {
|
|
160
|
-
let timestamp;
|
|
161
|
-
try {
|
|
162
|
-
timestamp = parseInt(window.localStorage.getItem('sseTimestamp'), 10);
|
|
163
|
-
} catch (e) {
|
|
164
|
-
// Ignore any errors raised by localStorage
|
|
165
|
-
}
|
|
166
|
-
if (!_.isNaN(timestamp)) {
|
|
167
|
-
// An int was parsed
|
|
168
|
-
return timestamp;
|
|
169
|
-
} else {
|
|
170
|
-
// Value could not be gotten from localStorage, so return from fallback (which is also the default of null)f
|
|
171
|
-
return EventStream._lastTimestamp;
|
|
172
|
-
}
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
const eventStream = new EventStream();
|
|
176
|
-
|
|
177
|
-
export default eventStream;
|
package/utilities/PluginUtils.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import _ from 'underscore';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Wrap the prototype method of a given object.
|
|
5
|
-
*
|
|
6
|
-
* @param obj The object whose prototype to extend, e.g. MyView
|
|
7
|
-
* @param funcName The name of the function to wrap, e.g. "render"
|
|
8
|
-
* @param wrapper The wrapper function, which should be a function taking the
|
|
9
|
-
* underlying wrapped function as its first argument. The wrapped function
|
|
10
|
-
* should be called with .call(this[, arguments]) inside of the wrapper in
|
|
11
|
-
* order to preserve "this" semantics.
|
|
12
|
-
*/
|
|
13
|
-
function wrap(obj, funcName, wrapper) {
|
|
14
|
-
obj.prototype[funcName] = _.wrap(obj.prototype[funcName], wrapper);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
var _pluginConfigRoutes = {};
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Expose a plugin configuration page via the admin plugins page.
|
|
21
|
-
* @param pluginName The canonical plugin name, i.e. its directory name
|
|
22
|
-
* @param route The route to trigger that will render the plugin config.
|
|
23
|
-
*/
|
|
24
|
-
function exposePluginConfig(pluginName, route) {
|
|
25
|
-
_pluginConfigRoutes[pluginName] = route;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function getPluginConfigRoute(pluginName) {
|
|
29
|
-
return _pluginConfigRoutes[pluginName];
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export {
|
|
33
|
-
exposePluginConfig,
|
|
34
|
-
getPluginConfigRoute,
|
|
35
|
-
wrap
|
|
36
|
-
};
|