@kalisio/kdk 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.codeclimate.yml +0 -1
- package/.travis.test.sh +3 -0
- package/core/api/application.js +591 -0
- package/core/api/authentication.js +203 -0
- package/core/api/db.js +226 -0
- package/core/api/hooks/hooks.authentication.js +74 -0
- package/core/api/hooks/hooks.authorisations.js +376 -0
- package/core/api/hooks/hooks.groups.js +48 -0
- package/core/api/hooks/hooks.logger.js +26 -0
- package/core/api/hooks/hooks.model.js +290 -0
- package/core/api/hooks/hooks.organisations.js +156 -0
- package/core/api/hooks/hooks.push.js +54 -0
- package/core/api/hooks/hooks.query.js +246 -0
- package/core/api/hooks/hooks.schemas.js +73 -0
- package/core/api/hooks/hooks.service.js +78 -0
- package/core/api/hooks/hooks.storage.js +36 -0
- package/core/api/hooks/hooks.users.js +261 -0
- package/core/api/hooks/index.js +12 -0
- package/core/api/index.js +21 -0
- package/core/api/marshall.js +90 -0
- package/core/api/models/groups.model.mongodb.js +8 -0
- package/core/api/models/organisations.model.mongodb.js +3 -0
- package/core/api/models/tags.model.mongodb.js +10 -0
- package/core/api/models/users.model.mongodb.js +10 -0
- package/core/api/services/account/account.hooks.js +37 -0
- package/core/api/services/account/account.service.js +120 -0
- package/core/api/services/authorisations/authorisations.hooks.js +33 -0
- package/core/api/services/authorisations/authorisations.service.js +139 -0
- package/core/api/services/databases/databases.hooks.js +36 -0
- package/core/api/services/databases/databases.service.js +5 -0
- package/core/api/services/groups/groups.hooks.js +31 -0
- package/core/api/services/index.js +126 -0
- package/core/api/services/mailer/mailer.hooks.js +35 -0
- package/core/api/services/mailer/mailer.service.js +11 -0
- package/core/api/services/organisations/organisations.hooks.js +31 -0
- package/core/api/services/organisations/organisations.service.js +86 -0
- package/core/api/services/push/push.hooks.js +35 -0
- package/core/api/services/push/push.service.js +12 -0
- package/core/api/services/storage/storage.hooks.js +35 -0
- package/core/api/services/storage/storage.service.js +29 -0
- package/core/api/services/tags/tags.hooks.js +31 -0
- package/core/api/services/users/users.hooks.js +75 -0
- package/core/api/utils.js +11 -0
- package/core/client/api.js +293 -0
- package/core/client/capabilities.js +22 -0
- package/core/client/components/KAction.vue +393 -0
- package/core/client/components/KAvatar.vue +129 -0
- package/core/client/components/KBlock.vue +67 -0
- package/core/client/components/KChip.vue +68 -0
- package/core/client/components/KChipsPane.vue +103 -0
- package/core/client/components/KContent.vue +105 -0
- package/core/client/components/KDialog.vue +160 -0
- package/core/client/components/KExpandable.vue +49 -0
- package/core/client/components/KLogo.vue +32 -0
- package/core/client/components/KModal.vue +173 -0
- package/core/client/components/KPanel.vue +64 -0
- package/core/client/components/KScrollArea.vue +88 -0
- package/core/client/components/KSponsor.vue +40 -0
- package/core/client/components/KStamp.vue +65 -0
- package/core/client/components/KStore.vue +102 -0
- package/core/client/components/KTextArea.vue +143 -0
- package/core/client/components/KTree.vue +31 -0
- package/core/client/components/KVersion.vue +19 -0
- package/core/client/components/account/KAccount.vue +68 -0
- package/core/client/components/account/KDeleteAccountManager.vue +62 -0
- package/core/client/components/account/KEmailManager.vue +128 -0
- package/core/client/components/account/KPasswordManager.vue +90 -0
- package/core/client/components/account/KProfile.vue +109 -0
- package/core/client/components/account/KResetPassword.vue +120 -0
- package/core/client/components/account/KSendResetPassword.vue +90 -0
- package/core/client/components/account/KSubscription.vue +71 -0
- package/core/client/components/account/KSubscriptionsManager.vue +46 -0
- package/core/client/components/account/KVerifyEmailManager.vue +105 -0
- package/core/client/components/account/index.js +7 -0
- package/core/client/components/app/KAbout.vue +98 -0
- package/core/client/components/app/KHome.vue +12 -0
- package/core/client/components/app/KPlatform.vue +55 -0
- package/core/client/components/app/KSettings.vue +43 -0
- package/core/client/components/app/KTerms.vue +41 -0
- package/core/client/components/app/KTour.vue +448 -0
- package/core/client/components/app/KWelcome.vue +133 -0
- package/core/client/components/app/index.js +11 -0
- package/core/client/components/chart/KChart.vue +197 -0
- package/core/client/components/chart/KDataTable.vue +183 -0
- package/core/client/components/chart/KStatisticsChart.vue +94 -0
- package/core/client/components/chart/KTimeSeriesChart.vue +431 -0
- package/core/client/components/chart/index.js +9 -0
- package/core/client/components/collection/KBoard.vue +65 -0
- package/core/client/components/collection/KCard.vue +196 -0
- package/core/client/components/collection/KCardSection.vue +52 -0
- package/core/client/components/collection/KColumn.vue +225 -0
- package/core/client/components/collection/KFilter.vue +158 -0
- package/core/client/components/collection/KGrid.vue +121 -0
- package/core/client/components/collection/KHistory.vue +112 -0
- package/core/client/components/collection/KHistoryEntry.vue +111 -0
- package/core/client/components/collection/KItem.vue +128 -0
- package/core/client/components/collection/KList.vue +135 -0
- package/core/client/components/collection/KSorter.vue +46 -0
- package/core/client/components/collection/KTable.vue +238 -0
- package/core/client/components/collection/index.js +19 -0
- package/core/client/components/editor/KEditor.vue +52 -0
- package/core/client/components/editor/KModalEditor.vue +96 -0
- package/core/client/components/editor/index.js +7 -0
- package/core/client/components/form/KChipsField.vue +162 -0
- package/core/client/components/form/KColorField.vue +69 -0
- package/core/client/components/form/KColorScaleField.vue +86 -0
- package/core/client/components/form/KDateTimeRangeField.vue +65 -0
- package/core/client/components/form/KDatetimeField.vue +70 -0
- package/core/client/components/form/KEmailField.vue +33 -0
- package/core/client/components/form/KFileField.vue +161 -0
- package/core/client/components/form/KForm.vue +247 -0
- package/core/client/components/form/KIconField.vue +101 -0
- package/core/client/components/form/KItemField.vue +123 -0
- package/core/client/components/form/KNumberField.vue +33 -0
- package/core/client/components/form/KOptionsField.vue +63 -0
- package/core/client/components/form/KPasswordField.vue +57 -0
- package/core/client/components/form/KPhoneField.vue +32 -0
- package/core/client/components/form/KPropertyItemField.vue +119 -0
- package/core/client/components/form/KRoleField.vue +60 -0
- package/core/client/components/form/KSelectField.vue +143 -0
- package/core/client/components/form/KTextField.vue +48 -0
- package/core/client/components/form/KTextareaField.vue +88 -0
- package/core/client/components/form/KToggleField.vue +46 -0
- package/core/client/components/form/KTokenField.vue +80 -0
- package/core/client/components/form/KUnitField.vue +57 -0
- package/core/client/components/form/KUrlField.vue +32 -0
- package/core/client/components/form/KView.vue +118 -0
- package/core/client/components/form/index.js +7 -0
- package/core/client/components/index.js +48 -0
- package/core/client/components/input/KColorChooser.vue +63 -0
- package/core/client/components/input/KIconChooser.vue +308 -0
- package/core/client/components/input/KOptionsChooser.vue +122 -0
- package/core/client/components/input/KPalette.vue +40 -0
- package/core/client/components/input/index.js +11 -0
- package/core/client/components/layout/KFab.vue +113 -0
- package/core/client/components/layout/KLayout.vue +64 -0
- package/core/client/components/layout/KOpener.vue +140 -0
- package/core/client/components/layout/KPage.vue +320 -0
- package/core/client/components/layout/KPageSticky.vue +53 -0
- package/core/client/components/layout/KWindow.vue +443 -0
- package/core/client/components/layout/index.js +13 -0
- package/core/client/components/media/KColorScale.vue +254 -0
- package/core/client/components/media/KImageViewer.vue +44 -0
- package/core/client/components/media/KMarkdownViewer.vue +55 -0
- package/core/client/components/media/KMediaBrowser.vue +340 -0
- package/core/client/components/media/KShape.vue +120 -0
- package/core/client/components/media/index.js +13 -0
- package/core/client/components/menu/KMenu.vue +147 -0
- package/core/client/components/menu/KRadialFab.vue +122 -0
- package/core/client/components/menu/KRadialFabItem.vue +73 -0
- package/core/client/components/menu/index.js +9 -0
- package/core/client/components/screen/KEndpointScreen.vue +80 -0
- package/core/client/components/screen/KErrorScreen.vue +24 -0
- package/core/client/components/screen/KLoginScreen.vue +79 -0
- package/core/client/components/screen/KLogoutScreen.vue +20 -0
- package/core/client/components/screen/KRegisterScreen.vue +114 -0
- package/core/client/components/screen/KScreen.vue +106 -0
- package/core/client/components/screen/KScreenFooter.vue +32 -0
- package/core/client/components/screen/KScreenHeader.vue +17 -0
- package/core/client/components/screen/index.js +5 -0
- package/core/client/components/team/KAddMember.vue +375 -0
- package/core/client/components/team/KAddTag.vue +121 -0
- package/core/client/components/team/KChangeRole.vue +118 -0
- package/core/client/components/team/KGroupCard.vue +110 -0
- package/core/client/components/team/KGroupsActivity.vue +66 -0
- package/core/client/components/team/KJoinGroup.vue +132 -0
- package/core/client/components/team/KMemberCard.vue +328 -0
- package/core/client/components/team/KMemberFilter.vue +49 -0
- package/core/client/components/team/KMembersActivity.vue +126 -0
- package/core/client/components/team/KOrganisationsActivity.vue +53 -0
- package/core/client/components/team/KTagCard.vue +72 -0
- package/core/client/components/team/KTagsActivity.vue +61 -0
- package/core/client/components/team/index.js +9 -0
- package/core/client/components/time/KAbsoluteTimeRange.vue +183 -0
- package/core/client/components/time/KDate.vue +75 -0
- package/core/client/components/time/KDateTime.vue +172 -0
- package/core/client/components/time/KDateTimeRange.vue +118 -0
- package/core/client/components/time/KRelativeTimeRanges.vue +193 -0
- package/core/client/components/time/KTime.vue +74 -0
- package/core/client/components/time/index.js +7 -0
- package/core/client/components/viewer/KModalViewer.vue +47 -0
- package/core/client/components/viewer/KViewer.vue +30 -0
- package/core/client/composables/activity.js +67 -0
- package/core/client/composables/collection.js +181 -0
- package/core/client/composables/index.js +8 -0
- package/core/client/composables/pwa.js +71 -0
- package/core/client/composables/schema.js +64 -0
- package/core/client/composables/selection.js +88 -0
- package/core/client/composables/session.js +150 -0
- package/core/client/composables/store.js +49 -0
- package/core/client/composables/version.js +47 -0
- package/core/client/events.js +3 -0
- package/core/client/filter.js +60 -0
- package/core/client/guards.js +101 -0
- package/core/client/hooks/hooks.events.js +7 -0
- package/core/client/hooks/hooks.logger.js +24 -0
- package/core/client/hooks/hooks.users.js +22 -0
- package/core/client/hooks/index.js +3 -0
- package/core/client/i18n/core_en.json +840 -0
- package/core/client/i18n/core_fr.json +838 -0
- package/core/client/i18n.js +88 -0
- package/core/client/index.js +84 -0
- package/core/client/layout.js +323 -0
- package/core/client/local-storage.js +28 -0
- package/core/client/mixins/index.js +12 -0
- package/core/client/mixins/mixin.account.js +61 -0
- package/core/client/mixins/mixin.base-activity.js +232 -0
- package/core/client/mixins/mixin.base-collection.js +162 -0
- package/core/client/mixins/mixin.base-context.js +54 -0
- package/core/client/mixins/mixin.base-editor.js +194 -0
- package/core/client/mixins/mixin.base-field.js +105 -0
- package/core/client/mixins/mixin.base-item.js +166 -0
- package/core/client/mixins/mixin.base-modal.js +36 -0
- package/core/client/mixins/mixin.base-viewer.js +43 -0
- package/core/client/mixins/mixin.object-proxy.js +46 -0
- package/core/client/mixins/mixin.schema-proxy.js +97 -0
- package/core/client/mixins/mixin.service.js +22 -0
- package/core/client/reader.js +65 -0
- package/core/client/readers/index.js +3 -0
- package/core/client/readers/reader.blob.js +39 -0
- package/core/client/readers/reader.csv.js +36 -0
- package/core/client/readers/reader.json.js +34 -0
- package/core/client/search.js +47 -0
- package/core/client/services/index.js +47 -0
- package/core/client/services/local-settings.service.js +67 -0
- package/core/client/sorter.js +31 -0
- package/core/client/storage.js +102 -0
- package/core/client/store.js +39 -0
- package/core/client/theme.js +40 -0
- package/core/client/time.js +167 -0
- package/core/client/units.js +218 -0
- package/core/client/utils/index.js +203 -0
- package/core/client/utils/utils.account.js +47 -0
- package/core/client/utils/utils.colors.js +36 -0
- package/core/client/utils/utils.content.js +185 -0
- package/core/client/utils/utils.locale.js +28 -0
- package/core/client/utils/utils.platform.js +11 -0
- package/core/client/utils/utils.push.js +53 -0
- package/core/client/utils/utils.pwa.js +63 -0
- package/core/client/utils/utils.session.js +89 -0
- package/core/common/errors.js +1 -0
- package/core/common/index.js +10 -0
- package/core/common/permissions.js +318 -0
- package/core/common/schema.js +35 -0
- package/core/common/schemas/groups.create.json +28 -0
- package/core/common/schemas/groups.update.json +28 -0
- package/core/common/schemas/organisations.create.json +28 -0
- package/core/common/schemas/organisations.update.json +49 -0
- package/core/common/schemas/settings.update.json +234 -0
- package/core/common/schemas/tags.create.json +35 -0
- package/core/common/schemas/tags.update.json +35 -0
- package/core/common/schemas/users.update-profile.json +33 -0
- package/core/common/utils.js +45 -0
- package/coverage/base.css +224 -0
- package/coverage/block-navigation.js +87 -0
- package/coverage/core/api/application.js.html +1849 -0
- package/coverage/core/api/authentication.js.html +694 -0
- package/coverage/core/api/db.js.html +763 -0
- package/coverage/core/api/hooks/hooks.account.js.html +169 -0
- package/coverage/core/api/hooks/hooks.authentication.js.html +274 -0
- package/coverage/core/api/hooks/hooks.authorisations.js.html +1213 -0
- package/coverage/core/api/hooks/hooks.groups.js.html +229 -0
- package/coverage/core/api/hooks/hooks.logger.js.html +163 -0
- package/coverage/core/api/hooks/hooks.model.js.html +994 -0
- package/coverage/core/api/hooks/hooks.organisations.js.html +553 -0
- package/coverage/core/api/hooks/hooks.push.js.html +232 -0
- package/coverage/core/api/hooks/hooks.query.js.html +838 -0
- package/coverage/core/api/hooks/hooks.schemas.js.html +304 -0
- package/coverage/core/api/hooks/hooks.service.js.html +319 -0
- package/coverage/core/api/hooks/hooks.storage.js.html +193 -0
- package/coverage/core/api/hooks/hooks.tags.js.html +850 -0
- package/coverage/core/api/hooks/hooks.users.js.html +826 -0
- package/coverage/core/api/hooks/index.html +296 -0
- package/coverage/core/api/hooks/index.js.html +121 -0
- package/coverage/core/api/index.html +191 -0
- package/coverage/core/api/index.js.html +148 -0
- package/coverage/core/api/marshall.js.html +355 -0
- package/coverage/core/api/models/groups.model.mongodb.js.html +109 -0
- package/coverage/core/api/models/index.html +161 -0
- package/coverage/core/api/models/organisations.model.mongodb.js.html +94 -0
- package/coverage/core/api/models/tags.model.mongodb.js.html +115 -0
- package/coverage/core/api/models/users.model.mongodb.js.html +115 -0
- package/coverage/core/api/services/account/account.hooks.js.html +196 -0
- package/coverage/core/api/services/account/account.service.js.html +445 -0
- package/coverage/core/api/services/account/index.html +131 -0
- package/coverage/core/api/services/authorisations/authorisations.hooks.js.html +184 -0
- package/coverage/core/api/services/authorisations/authorisations.service.js.html +502 -0
- package/coverage/core/api/services/authorisations/index.html +131 -0
- package/coverage/core/api/services/databases/databases.hooks.js.html +193 -0
- package/coverage/core/api/services/databases/databases.service.js.html +100 -0
- package/coverage/core/api/services/databases/index.html +131 -0
- package/coverage/core/api/services/groups/groups.hooks.js.html +178 -0
- package/coverage/core/api/services/groups/index.html +116 -0
- package/coverage/core/api/services/index.html +116 -0
- package/coverage/core/api/services/index.js.html +475 -0
- package/coverage/core/api/services/mailer/index.html +131 -0
- package/coverage/core/api/services/mailer/mailer.hooks.js.html +190 -0
- package/coverage/core/api/services/mailer/mailer.service.js.html +118 -0
- package/coverage/core/api/services/organisations/index.html +131 -0
- package/coverage/core/api/services/organisations/organisations.hooks.js.html +178 -0
- package/coverage/core/api/services/organisations/organisations.service.js.html +343 -0
- package/coverage/core/api/services/push/index.html +131 -0
- package/coverage/core/api/services/push/push.hooks.js.html +193 -0
- package/coverage/core/api/services/push/push.service.js.html +121 -0
- package/coverage/core/api/services/storage/index.html +131 -0
- package/coverage/core/api/services/storage/storage.hooks.js.html +190 -0
- package/coverage/core/api/services/storage/storage.service.js.html +172 -0
- package/coverage/core/api/services/tags/index.html +116 -0
- package/coverage/core/api/services/tags/tags.hooks.js.html +178 -0
- package/coverage/core/api/services/users/index.html +116 -0
- package/coverage/core/api/services/users/users.hooks.js.html +313 -0
- package/coverage/core/api/utils.js.html +118 -0
- package/coverage/core/common/errors.js.html +88 -0
- package/coverage/core/common/index.html +176 -0
- package/coverage/core/common/index.js.html +115 -0
- package/coverage/core/common/permissions.js.html +1039 -0
- package/coverage/core/common/schema.js.html +190 -0
- package/coverage/core/common/utils.js.html +220 -0
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +476 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/core/api/application.js.html +1849 -0
- package/coverage/lcov-report/core/api/authentication.js.html +694 -0
- package/coverage/lcov-report/core/api/db.js.html +763 -0
- package/coverage/lcov-report/core/api/hooks/hooks.account.js.html +169 -0
- package/coverage/lcov-report/core/api/hooks/hooks.authentication.js.html +274 -0
- package/coverage/lcov-report/core/api/hooks/hooks.authorisations.js.html +1213 -0
- package/coverage/lcov-report/core/api/hooks/hooks.groups.js.html +229 -0
- package/coverage/lcov-report/core/api/hooks/hooks.logger.js.html +163 -0
- package/coverage/lcov-report/core/api/hooks/hooks.model.js.html +994 -0
- package/coverage/lcov-report/core/api/hooks/hooks.organisations.js.html +553 -0
- package/coverage/lcov-report/core/api/hooks/hooks.push.js.html +232 -0
- package/coverage/lcov-report/core/api/hooks/hooks.query.js.html +838 -0
- package/coverage/lcov-report/core/api/hooks/hooks.schemas.js.html +304 -0
- package/coverage/lcov-report/core/api/hooks/hooks.service.js.html +319 -0
- package/coverage/lcov-report/core/api/hooks/hooks.storage.js.html +193 -0
- package/coverage/lcov-report/core/api/hooks/hooks.tags.js.html +850 -0
- package/coverage/lcov-report/core/api/hooks/hooks.users.js.html +826 -0
- package/coverage/lcov-report/core/api/hooks/index.html +296 -0
- package/coverage/lcov-report/core/api/hooks/index.js.html +121 -0
- package/coverage/lcov-report/core/api/index.html +191 -0
- package/coverage/lcov-report/core/api/index.js.html +148 -0
- package/coverage/lcov-report/core/api/marshall.js.html +355 -0
- package/coverage/lcov-report/core/api/models/groups.model.mongodb.js.html +109 -0
- package/coverage/lcov-report/core/api/models/index.html +161 -0
- package/coverage/lcov-report/core/api/models/organisations.model.mongodb.js.html +94 -0
- package/coverage/lcov-report/core/api/models/tags.model.mongodb.js.html +115 -0
- package/coverage/lcov-report/core/api/models/users.model.mongodb.js.html +115 -0
- package/coverage/lcov-report/core/api/services/account/account.hooks.js.html +196 -0
- package/coverage/lcov-report/core/api/services/account/account.service.js.html +445 -0
- package/coverage/lcov-report/core/api/services/account/index.html +131 -0
- package/coverage/lcov-report/core/api/services/authorisations/authorisations.hooks.js.html +184 -0
- package/coverage/lcov-report/core/api/services/authorisations/authorisations.service.js.html +502 -0
- package/coverage/lcov-report/core/api/services/authorisations/index.html +131 -0
- package/coverage/lcov-report/core/api/services/databases/databases.hooks.js.html +193 -0
- package/coverage/lcov-report/core/api/services/databases/databases.service.js.html +100 -0
- package/coverage/lcov-report/core/api/services/databases/index.html +131 -0
- package/coverage/lcov-report/core/api/services/groups/groups.hooks.js.html +178 -0
- package/coverage/lcov-report/core/api/services/groups/index.html +116 -0
- package/coverage/lcov-report/core/api/services/index.html +116 -0
- package/coverage/lcov-report/core/api/services/index.js.html +475 -0
- package/coverage/lcov-report/core/api/services/mailer/index.html +131 -0
- package/coverage/lcov-report/core/api/services/mailer/mailer.hooks.js.html +190 -0
- package/coverage/lcov-report/core/api/services/mailer/mailer.service.js.html +118 -0
- package/coverage/lcov-report/core/api/services/organisations/index.html +131 -0
- package/coverage/lcov-report/core/api/services/organisations/organisations.hooks.js.html +178 -0
- package/coverage/lcov-report/core/api/services/organisations/organisations.service.js.html +343 -0
- package/coverage/lcov-report/core/api/services/push/index.html +131 -0
- package/coverage/lcov-report/core/api/services/push/push.hooks.js.html +193 -0
- package/coverage/lcov-report/core/api/services/push/push.service.js.html +121 -0
- package/coverage/lcov-report/core/api/services/storage/index.html +131 -0
- package/coverage/lcov-report/core/api/services/storage/storage.hooks.js.html +190 -0
- package/coverage/lcov-report/core/api/services/storage/storage.service.js.html +172 -0
- package/coverage/lcov-report/core/api/services/tags/index.html +116 -0
- package/coverage/lcov-report/core/api/services/tags/tags.hooks.js.html +178 -0
- package/coverage/lcov-report/core/api/services/users/index.html +116 -0
- package/coverage/lcov-report/core/api/services/users/users.hooks.js.html +313 -0
- package/coverage/lcov-report/core/api/utils.js.html +118 -0
- package/coverage/lcov-report/core/common/errors.js.html +88 -0
- package/coverage/lcov-report/core/common/index.html +176 -0
- package/coverage/lcov-report/core/common/index.js.html +115 -0
- package/coverage/lcov-report/core/common/permissions.js.html +1039 -0
- package/coverage/lcov-report/core/common/schema.js.html +190 -0
- package/coverage/lcov-report/core/common/utils.js.html +220 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +476 -0
- package/coverage/lcov-report/map/api/hooks/hooks.catalog.js.html +340 -0
- package/coverage/lcov-report/map/api/hooks/hooks.features.js.html +337 -0
- package/coverage/lcov-report/map/api/hooks/hooks.query.js.html +1168 -0
- package/coverage/lcov-report/map/api/hooks/index.html +161 -0
- package/coverage/lcov-report/map/api/hooks/index.js.html +94 -0
- package/coverage/lcov-report/map/api/index.html +131 -0
- package/coverage/lcov-report/map/api/index.js.html +139 -0
- package/coverage/lcov-report/map/api/marshall.js.html +178 -0
- package/coverage/lcov-report/map/api/models/alerts.model.mongodb.js.html +106 -0
- package/coverage/lcov-report/map/api/models/catalog.model.mongodb.js.html +127 -0
- package/coverage/lcov-report/map/api/models/features.model.mongodb.js.html +196 -0
- package/coverage/lcov-report/map/api/models/index.html +146 -0
- package/coverage/lcov-report/map/api/services/alerts/alerts.hooks.js.html +274 -0
- package/coverage/lcov-report/map/api/services/alerts/alerts.service.js.html +610 -0
- package/coverage/lcov-report/map/api/services/alerts/index.html +131 -0
- package/coverage/lcov-report/map/api/services/catalog/catalog.hooks.js.html +313 -0
- package/coverage/lcov-report/map/api/services/catalog/index.html +116 -0
- package/coverage/lcov-report/map/api/services/daptiles/daptiles.service.js.html +1510 -0
- package/coverage/lcov-report/map/api/services/daptiles/index.html +116 -0
- package/coverage/lcov-report/map/api/services/features/features.hooks.js.html +205 -0
- package/coverage/lcov-report/map/api/services/features/features.service.js.html +241 -0
- package/coverage/lcov-report/map/api/services/features/index.html +131 -0
- package/coverage/lcov-report/map/api/services/geocoder/geocoder.hooks.js.html +178 -0
- package/coverage/lcov-report/map/api/services/geocoder/geocoder.service.js.html +322 -0
- package/coverage/lcov-report/map/api/services/geocoder/index.html +131 -0
- package/coverage/lcov-report/map/api/services/index.html +116 -0
- package/coverage/lcov-report/map/api/services/index.js.html +769 -0
- package/coverage/lcov-report/map/common/dynamic-grid-source.js.html +466 -0
- package/coverage/lcov-report/map/common/errors.js.html +94 -0
- package/coverage/lcov-report/map/common/geotiff-grid-source.js.html +535 -0
- package/coverage/lcov-report/map/common/grid.js.html +1612 -0
- package/coverage/lcov-report/map/common/index.html +371 -0
- package/coverage/lcov-report/map/common/index.js.html +172 -0
- package/coverage/lcov-report/map/common/meteo-model-grid-source.js.html +556 -0
- package/coverage/lcov-report/map/common/moment-utils.js.html +157 -0
- package/coverage/lcov-report/map/common/opendap-grid-source.js.html +868 -0
- package/coverage/lcov-report/map/common/opendap-utils.js.html +826 -0
- package/coverage/lcov-report/map/common/permissions.js.html +118 -0
- package/coverage/lcov-report/map/common/time-based-grid-source.js.html +418 -0
- package/coverage/lcov-report/map/common/tms-utils.js.html +274 -0
- package/coverage/lcov-report/map/common/wcs-grid-source.js.html +364 -0
- package/coverage/lcov-report/map/common/wcs-utils.js.html +586 -0
- package/coverage/lcov-report/map/common/weacast-grid-source.js.html +1033 -0
- package/coverage/lcov-report/map/common/wfs-utils.js.html +574 -0
- package/coverage/lcov-report/map/common/wms-utils.js.html +436 -0
- package/coverage/lcov-report/map/common/wmts-utils.js.html +547 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov.info +10742 -0
- package/coverage/map/api/hooks/hooks.catalog.js.html +340 -0
- package/coverage/map/api/hooks/hooks.features.js.html +337 -0
- package/coverage/map/api/hooks/hooks.query.js.html +1168 -0
- package/coverage/map/api/hooks/index.html +161 -0
- package/coverage/map/api/hooks/index.js.html +94 -0
- package/coverage/map/api/index.html +131 -0
- package/coverage/map/api/index.js.html +139 -0
- package/coverage/map/api/marshall.js.html +178 -0
- package/coverage/map/api/models/alerts.model.mongodb.js.html +106 -0
- package/coverage/map/api/models/catalog.model.mongodb.js.html +127 -0
- package/coverage/map/api/models/features.model.mongodb.js.html +196 -0
- package/coverage/map/api/models/index.html +146 -0
- package/coverage/map/api/services/alerts/alerts.hooks.js.html +274 -0
- package/coverage/map/api/services/alerts/alerts.service.js.html +610 -0
- package/coverage/map/api/services/alerts/index.html +131 -0
- package/coverage/map/api/services/catalog/catalog.hooks.js.html +313 -0
- package/coverage/map/api/services/catalog/index.html +116 -0
- package/coverage/map/api/services/daptiles/daptiles.service.js.html +1510 -0
- package/coverage/map/api/services/daptiles/index.html +116 -0
- package/coverage/map/api/services/features/features.hooks.js.html +205 -0
- package/coverage/map/api/services/features/features.service.js.html +241 -0
- package/coverage/map/api/services/features/index.html +131 -0
- package/coverage/map/api/services/geocoder/geocoder.hooks.js.html +178 -0
- package/coverage/map/api/services/geocoder/geocoder.service.js.html +322 -0
- package/coverage/map/api/services/geocoder/index.html +131 -0
- package/coverage/map/api/services/index.html +116 -0
- package/coverage/map/api/services/index.js.html +769 -0
- package/coverage/map/common/dynamic-grid-source.js.html +466 -0
- package/coverage/map/common/errors.js.html +94 -0
- package/coverage/map/common/geotiff-grid-source.js.html +535 -0
- package/coverage/map/common/grid.js.html +1612 -0
- package/coverage/map/common/index.html +371 -0
- package/coverage/map/common/index.js.html +172 -0
- package/coverage/map/common/meteo-model-grid-source.js.html +556 -0
- package/coverage/map/common/moment-utils.js.html +157 -0
- package/coverage/map/common/opendap-grid-source.js.html +868 -0
- package/coverage/map/common/opendap-utils.js.html +826 -0
- package/coverage/map/common/permissions.js.html +118 -0
- package/coverage/map/common/time-based-grid-source.js.html +418 -0
- package/coverage/map/common/tms-utils.js.html +274 -0
- package/coverage/map/common/wcs-grid-source.js.html +364 -0
- package/coverage/map/common/wcs-utils.js.html +586 -0
- package/coverage/map/common/weacast-grid-source.js.html +1033 -0
- package/coverage/map/common/wfs-utils.js.html +574 -0
- package/coverage/map/common/wms-utils.js.html +436 -0
- package/coverage/map/common/wmts-utils.js.html +547 -0
- package/coverage/prettify.css +1 -0
- package/coverage/prettify.js +2 -0
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +196 -0
- package/coverage/tmp/coverage-59096-1692631696256-0.json +1 -0
- package/coverage/tmp/coverage-59108-1692631696233-0.json +1 -0
- package/coverage/tmp/coverage-59119-1692631696222-0.json +1 -0
- package/coverage/tmp/coverage-59131-1692631696200-0.json +1 -0
- package/coverage/tmp/coverage-59138-1692631696175-0.json +1 -0
- package/extras/css/core.variables.scss +5 -1
- package/extras/tours/core/account-profile.js +14 -31
- package/extras/tours/core/account.js +143 -0
- package/extras/tours/core/add-member.js +7 -6
- package/extras/tours/core/add-tag.js +13 -0
- package/extras/tours/core/create-tag.js +26 -0
- package/extras/tours/core/edit-member-role.js +13 -0
- package/extras/tours/core/join-group.js +0 -12
- package/extras/tours/core/login.js +0 -7
- package/extras/tours/core/members.js +13 -26
- package/extras/tours/core/send-reset-password.js +1 -1
- package/extras/tours/core/tags.js +17 -4
- package/extras/tours/map/navigation-bar.js +1 -1
- package/extras/tours/map/side-nav.js +3 -2
- package/map/api/config/categories.cjs +42 -0
- package/map/api/config/layers.cjs +43 -0
- package/map/api/config/sublegends.cjs +42 -0
- package/map/api/hooks/hooks.catalog.js +85 -0
- package/map/api/hooks/hooks.features.js +84 -0
- package/map/api/hooks/hooks.query.js +361 -0
- package/map/api/hooks/index.js +3 -0
- package/map/api/index.js +18 -0
- package/map/api/marshall.js +31 -0
- package/map/api/models/alerts.model.mongodb.js +7 -0
- package/map/api/models/catalog.model.mongodb.js +14 -0
- package/map/api/models/features.model.mongodb.js +37 -0
- package/map/api/services/alerts/alerts.hooks.js +63 -0
- package/map/api/services/alerts/alerts.service.js +175 -0
- package/map/api/services/catalog/catalog.hooks.js +76 -0
- package/map/api/services/daptiles/daptiles.service.js +475 -0
- package/map/api/services/features/features.hooks.js +40 -0
- package/map/api/services/features/features.service.js +52 -0
- package/map/api/services/geocoder/geocoder.hooks.js +31 -0
- package/map/api/services/geocoder/geocoder.service.js +79 -0
- package/map/api/services/index.js +228 -0
- package/map/client/canvas-draw-context.js +16 -0
- package/map/client/cesium/utils.js +132 -0
- package/map/client/components/KCaptureToolbar.vue +155 -0
- package/map/client/components/KColorLegend.vue +349 -0
- package/map/client/components/KCompass.vue +143 -0
- package/map/client/components/KEditLayerData.vue +85 -0
- package/map/client/components/KFeatureActionButton.vue +119 -0
- package/map/client/components/KFeatureEditor.vue +92 -0
- package/map/client/components/KFeaturesChart.vue +285 -0
- package/map/client/components/KFeaturesFilter.vue +259 -0
- package/map/client/components/KFeaturesTable.vue +99 -0
- package/map/client/components/KLayerEditionToolbar.vue +54 -0
- package/map/client/components/KLayerEditor.vue +48 -0
- package/map/client/components/KLayerStyleEditor.vue +118 -0
- package/map/client/components/KLayerStyleForm.vue +906 -0
- package/map/client/components/KLevelSlider.vue +100 -0
- package/map/client/components/KMeasureTool.vue +568 -0
- package/map/client/components/KPositionIndicator.vue +90 -0
- package/map/client/components/KTimeline.vue +293 -0
- package/map/client/components/KTimezoneMap.vue +158 -0
- package/map/client/components/KUrlLegend.vue +122 -0
- package/map/client/components/catalog/KAddLayer.vue +66 -0
- package/map/client/components/catalog/KBaseLayersSelector.vue +114 -0
- package/map/client/components/catalog/KConnectLayer.vue +323 -0
- package/map/client/components/catalog/KCreateLayer.vue +184 -0
- package/map/client/components/catalog/KCreateView.vue +108 -0
- package/map/client/components/catalog/KFilteredLayerItem.vue +53 -0
- package/map/client/components/catalog/KImportLayer.vue +168 -0
- package/map/client/components/catalog/KLayerCategories.vue +274 -0
- package/map/client/components/catalog/KLayerItem.vue +71 -0
- package/map/client/components/catalog/KLayersPanel.vue +137 -0
- package/map/client/components/catalog/KLayersSelector.vue +73 -0
- package/map/client/components/catalog/KViewSelector.vue +46 -0
- package/map/client/components/catalog/KViewsPanel.vue +118 -0
- package/map/client/components/catalog/KWeatherLayersSelector.vue +129 -0
- package/map/client/components/form/KDirectionField.vue +113 -0
- package/map/client/components/form/KLayerCategoryField.vue +46 -0
- package/map/client/components/form/KLocationField.vue +189 -0
- package/map/client/components/form/KOwsLayerField.vue +130 -0
- package/map/client/components/form/KOwsServiceField.vue +238 -0
- package/map/client/components/form/KTimezoneField.vue +142 -0
- package/map/client/components/index.js +1 -0
- package/map/client/components/legend/KColorScaleLegend.vue +31 -0
- package/map/client/components/legend/KImageLegend.vue +52 -0
- package/map/client/components/legend/KLegend.vue +191 -0
- package/map/client/components/legend/KLegendRenderer.vue +20 -0
- package/map/client/components/legend/KSymbolsLegend.vue +101 -0
- package/map/client/components/location/KGeocodersFilter.vue +44 -0
- package/map/client/components/location/KLocationCardSection.vue +61 -0
- package/map/client/components/location/KLocationMap.vue +280 -0
- package/map/client/components/location/KLocationSearch.vue +144 -0
- package/map/client/components/location/KLocationTip.vue +29 -0
- package/map/client/components/tools/KGeolocateTool.vue +46 -0
- package/map/client/components/tools/KSearchTool.vue +93 -0
- package/map/client/components/widget/KElevationProfile.vue +454 -0
- package/map/client/components/widget/KInformationBox.vue +145 -0
- package/map/client/components/widget/KMapillaryViewer.vue +178 -0
- package/map/client/components/widget/KStackableTimeSeries.vue +214 -0
- package/map/client/components/widget/KTimeSeries.vue +500 -0
- package/map/client/composables/activity.js +88 -0
- package/map/client/composables/highlight.js +216 -0
- package/map/client/composables/index.js +7 -0
- package/map/client/composables/location.js +53 -0
- package/map/client/composables/measure.js +42 -0
- package/map/client/composables/probe.js +133 -0
- package/map/client/composables/selection.js +300 -0
- package/map/client/composables/weather.js +213 -0
- package/map/client/elevation-utils.js +258 -0
- package/map/client/geolocation.js +119 -0
- package/map/client/globe.js +13 -0
- package/map/client/i18n/map_en.json +645 -0
- package/map/client/i18n/map_fr.json +646 -0
- package/map/client/index.js +18 -0
- package/map/client/init.js +80 -0
- package/map/client/leaflet/BoxSelection.js +142 -0
- package/map/client/leaflet/GSMaPLayer.js +55 -0
- package/map/client/leaflet/GradientPath.js +180 -0
- package/map/client/leaflet/MaskLayer.js +57 -0
- package/map/client/leaflet/TiledFeatureLayer.js +572 -0
- package/map/client/leaflet/TiledMeshLayer.js +486 -0
- package/map/client/leaflet/TiledWindLayer.js +384 -0
- package/map/client/leaflet/utils.js +246 -0
- package/map/client/map.js +15 -0
- package/map/client/mixins/globe/index.js +8 -0
- package/map/client/mixins/globe/mixin.base-globe.js +462 -0
- package/map/client/mixins/globe/mixin.file-layers.js +40 -0
- package/map/client/mixins/globe/mixin.geojson-layers.js +314 -0
- package/map/client/mixins/globe/mixin.globe-activity.js +52 -0
- package/map/client/mixins/globe/mixin.opendap-layers.js +51 -0
- package/map/client/mixins/globe/mixin.popup.js +82 -0
- package/map/client/mixins/globe/mixin.style.js +110 -0
- package/map/client/mixins/globe/mixin.tooltip.js +101 -0
- package/map/client/mixins/index.js +9 -0
- package/map/client/mixins/map/index.js +16 -0
- package/map/client/mixins/map/mixin.base-map.js +592 -0
- package/map/client/mixins/map/mixin.canvas-layers.js +529 -0
- package/map/client/mixins/map/mixin.edit-layers.js +474 -0
- package/map/client/mixins/map/mixin.file-layers.js +49 -0
- package/map/client/mixins/map/mixin.forecast-layers.js +79 -0
- package/map/client/mixins/map/mixin.geojson-layers.js +557 -0
- package/map/client/mixins/map/mixin.georaster-layers.js +114 -0
- package/map/client/mixins/map/mixin.gsmap-layers.js +27 -0
- package/map/client/mixins/map/mixin.heatmap-layers.js +116 -0
- package/map/client/mixins/map/mixin.map-activity.js +38 -0
- package/map/client/mixins/map/mixin.mapillary-layers.js +45 -0
- package/map/client/mixins/map/mixin.popup.js +53 -0
- package/map/client/mixins/map/mixin.style.js +73 -0
- package/map/client/mixins/map/mixin.tiled-mesh-layers.js +120 -0
- package/map/client/mixins/map/mixin.tiled-wind-layers.js +126 -0
- package/map/client/mixins/map/mixin.tooltip.js +47 -0
- package/map/client/mixins/mixin.activity.js +477 -0
- package/map/client/mixins/mixin.catalog-panel.js +25 -0
- package/map/client/mixins/mixin.context.js +252 -0
- package/map/client/mixins/mixin.feature-selection.js +28 -0
- package/map/client/mixins/mixin.feature-service.js +403 -0
- package/map/client/mixins/mixin.infobox.js +29 -0
- package/map/client/mixins/mixin.levels.js +66 -0
- package/map/client/mixins/mixin.style.js +29 -0
- package/map/client/mixins/mixin.weacast.js +212 -0
- package/map/client/pixi-utils.js +256 -0
- package/map/client/readers/index.js +4 -0
- package/map/client/readers/reader.geojson.js +64 -0
- package/map/client/readers/reader.gpx.js +36 -0
- package/map/client/readers/reader.kml.js +36 -0
- package/map/client/readers/reader.shp.js +82 -0
- package/map/client/utils/utils.location.js +45 -0
- package/map/client/utils.js +303 -0
- package/map/common/dynamic-grid-source.js +127 -0
- package/map/common/errors.js +3 -0
- package/map/common/geotiff-grid-source.js +150 -0
- package/map/common/grid.js +509 -0
- package/map/common/index.js +29 -0
- package/map/common/meteo-model-grid-source.js +157 -0
- package/map/common/moment-utils.js +24 -0
- package/map/common/opendap-grid-source.js +261 -0
- package/map/common/opendap-utils.js +247 -0
- package/map/common/permissions.js +11 -0
- package/map/common/schemas/catalog.update.json +28 -0
- package/map/common/time-based-grid-source.js +111 -0
- package/map/common/tms-utils.js +63 -0
- package/map/common/wcs-grid-source.js +93 -0
- package/map/common/wcs-utils.js +167 -0
- package/map/common/weacast-grid-source.js +316 -0
- package/map/common/wfs-utils.js +163 -0
- package/map/common/wms-utils.js +117 -0
- package/map/common/wmts-utils.js +154 -0
- package/package.json +18 -15
- package/test/api/core/account.test.js +452 -0
- package/test/api/core/client.test.js.skip +37 -0
- package/test/api/core/config/default.cjs +115 -0
- package/test/api/core/config/email-templates/confirmInvitation/html.ejs +18 -0
- package/test/api/core/config/email-templates/identityChange/html.ejs +14 -0
- package/test/api/core/config/email-templates/newDevice/html.ejs +7 -0
- package/test/api/core/config/email-templates/newSubscription/html.ejs +7 -0
- package/test/api/core/config/email-templates/passwordChange/html.ejs +5 -0
- package/test/api/core/config/email-templates/resendVerifySignup/html.ejs +12 -0
- package/test/api/core/config/email-templates/resetPwd/html.ejs +5 -0
- package/test/api/core/config/email-templates/sendResetPwd/html.ejs +12 -0
- package/test/api/core/config/email-templates/verifySignup/html.ejs +3 -0
- package/test/api/core/data/10k_most_common_passwords.txt +10000 -0
- package/test/api/core/data/invalid-objects.json +60 -0
- package/test/api/core/data/logo.png +0 -0
- package/test/api/core/data/schema.json +57 -0
- package/test/api/core/data/valid-objects.json +38 -0
- package/test/api/core/hooks.test.js +330 -0
- package/test/api/core/index.js +1 -0
- package/test/api/core/index.test.js +478 -0
- package/test/api/core/push.test.js +191 -0
- package/test/api/core/schemas.test.js +82 -0
- package/test/api/core/storage.test.js +153 -0
- package/test/api/core/team.test.js +670 -0
- package/test/api/core/test-log-2023-07-04.log +0 -0
- package/test/api/core/test-log-2023-07-10.log +2 -0
- package/test/api/core/test-log-2023-07-12.log +0 -0
- package/test/api/core/test-log-2023-07-18.log +78 -0
- package/test/api/core/test-log-2023-07-19.log +44 -0
- package/test/api/core/test-log-2023-08-01.log +162 -0
- package/test/api/core/test-log-2023-08-21.log +66 -0
- package/test/api/core/test-log-2023-08-22.log +96 -0
- package/test/api/core/test-log-2023-08-23.log +22 -0
- package/test/api/core/test-log-2023-09-20.log +22 -0
- package/test/api/core/utils.js +83 -0
- package/test/api/index.js +4 -0
- package/test/api/map/alerts.test.js +560 -0
- package/test/api/map/config/default.cjs +125 -0
- package/test/api/map/config/layers.json +38 -0
- package/test/api/map/data/DescribeCoverage.xml +55 -0
- package/test/api/map/data/GetCoverage.tif +0 -0
- package/test/api/map/data/adsb.observations.json +132 -0
- package/test/api/map/data/dataset.grb.das +55 -0
- package/test/api/map/data/dataset.grb.dds +17 -0
- package/test/api/map/data/dataset.grb.dods +0 -0
- package/test/api/map/data/lat_lon_bounds.grb.dods +0 -0
- package/test/api/map/data/subdataset.grb.dods +0 -0
- package/test/api/map/data/vigicrues.observations.json +47042 -0
- package/test/api/map/data/vigicrues.stations.json +15422 -0
- package/test/api/map/data/zones.json +1228 -0
- package/test/api/map/grid-sources.test.js +313 -0
- package/test/api/map/hooks.test.js +98 -0
- package/test/api/map/index.js +0 -0
- package/test/api/map/index.test.js +563 -0
- package/test/api/map/test-log-2023-07-18.log +62 -0
- package/test/api/map/test-log-2023-07-19.log +13 -0
- package/test/api/map/test-log-2023-08-21.log +65 -0
- package/test/api/map/test-log-2023-09-20.log +60 -0
- package/test/client/core/account.js +36 -0
- package/test/client/core/api.js +361 -0
- package/test/client/core/collection.js +64 -0
- package/test/client/core/index.js +8 -0
- package/test/client/core/layout.js +116 -0
- package/test/client/core/runner.js +224 -0
- package/test/client/core/screens.js +35 -0
- package/test/client/core/time.js +10 -0
- package/test/client/core/utils.js +260 -0
- package/test/client/index.js +4 -0
- package/test/client/map/catalog.js +175 -0
- package/test/client/map/controls.js +41 -0
- package/test/client/map/index.js +4 -0
- package/test/client/map/time.js +24 -0
- package/test/client/map/utils.js +27 -0
- package/extras/tours/core/account-dz.js +0 -37
- package/extras/tours/core/account-security.js +0 -52
- package/extras/tours/core/change-password.js +0 -34
- package/extras/tours/core/edit-member-tags.js +0 -18
- package/extras/tours/core/send-change-identity.js +0 -28
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import _ from 'lodash'
|
|
2
|
+
import * as math from 'mathjs'
|
|
3
|
+
import config from 'config'
|
|
4
|
+
import { i18n } from './i18n.js'
|
|
5
|
+
import { Store } from './store.js'
|
|
6
|
+
|
|
7
|
+
// Default units organised by physical quantity
|
|
8
|
+
// Each key is the internal mathjs "identifier" of the unit
|
|
9
|
+
const length = {
|
|
10
|
+
m: {
|
|
11
|
+
symbol: 'units.METER_SYMBOL',
|
|
12
|
+
label: 'units.METER_LABEL'
|
|
13
|
+
},
|
|
14
|
+
mi: {
|
|
15
|
+
symbol: 'units.MILE_SYMBOL',
|
|
16
|
+
label: 'units.MILE_LABEL'
|
|
17
|
+
},
|
|
18
|
+
NM: {
|
|
19
|
+
symbol: 'units.NAUTICAL_MILE_SYMBOL',
|
|
20
|
+
label: 'units.NAUTICAL_MILE_LABEL',
|
|
21
|
+
definition: '1852 m'
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const altitude = {
|
|
25
|
+
m: {
|
|
26
|
+
symbol: 'units.METER_SYMBOL',
|
|
27
|
+
label: 'units.METER_LABEL'
|
|
28
|
+
},
|
|
29
|
+
ft: {
|
|
30
|
+
symbol: 'units.FEET_SYMBOL',
|
|
31
|
+
label: 'units.FEET_LABEL'
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const area = {
|
|
35
|
+
'm^2': {
|
|
36
|
+
symbol: 'units.SQUARED_METER_SYMBOL',
|
|
37
|
+
label: 'units.SQUARED_METER_LABEL'
|
|
38
|
+
},
|
|
39
|
+
'km^2': {
|
|
40
|
+
symbol: 'units.SQUARED_KILOMETER_SYMBOL',
|
|
41
|
+
label: 'units.SQUARED_KILOMETER_LABEL'
|
|
42
|
+
},
|
|
43
|
+
acre: {
|
|
44
|
+
symbol: 'units.ACRE_SYMBOL',
|
|
45
|
+
label: 'units.ACRE_LABEL'
|
|
46
|
+
},
|
|
47
|
+
hectare: {
|
|
48
|
+
symbol: 'units.HECTARE_SYMBOL',
|
|
49
|
+
label: 'units.HECTARE_LABEL'
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const velocity = {
|
|
53
|
+
'm/s': {
|
|
54
|
+
symbol: 'units.METER_PER_SECOND_SYMBOL',
|
|
55
|
+
label: 'units.METER_PER_SECOND_LABEL'
|
|
56
|
+
},
|
|
57
|
+
'km/h': {
|
|
58
|
+
symbol: 'units.KILOMETER_PER_HOUR_SYMBOL',
|
|
59
|
+
label: 'units.KILOMETER_PER_HOUR_LABEL'
|
|
60
|
+
},
|
|
61
|
+
'mi/h': {
|
|
62
|
+
symbol: 'units.MILES_PER_HOUR_SYMBOL',
|
|
63
|
+
label: 'units.MILES_PER_HOUR_LABEL'
|
|
64
|
+
},
|
|
65
|
+
kt: {
|
|
66
|
+
symbol: 'units.KNOT_SYMBOL',
|
|
67
|
+
label: 'units.KNOT_LABEL',
|
|
68
|
+
definition: '0.514444 m/s',
|
|
69
|
+
override: true // because kt can be kilo ton :(
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const temperature = {
|
|
73
|
+
degC: {
|
|
74
|
+
symbol: 'units.CELSIUS_SYMBOL',
|
|
75
|
+
label: 'units.CELSIUS_LABEL'
|
|
76
|
+
},
|
|
77
|
+
degF: {
|
|
78
|
+
symbol: 'units.FAHRENHEIT_SYMBOL',
|
|
79
|
+
label: 'units.FAHRENHEIT_LABEL'
|
|
80
|
+
},
|
|
81
|
+
K: {
|
|
82
|
+
symbol: 'units.KELVIN_SYMBOL',
|
|
83
|
+
label: 'units.KELVIN_LABEL'
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
const angle = {
|
|
87
|
+
deg: {
|
|
88
|
+
symbol: 'units.DEGREE_SYMBOL',
|
|
89
|
+
label: 'units.DEGREE_LABEL'
|
|
90
|
+
},
|
|
91
|
+
rad: {
|
|
92
|
+
symbol: 'units.RADIAN_SYMBOL',
|
|
93
|
+
label: 'units.RADIAN_LABEL'
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const quantities = {
|
|
98
|
+
length,
|
|
99
|
+
altitude,
|
|
100
|
+
area,
|
|
101
|
+
velocity,
|
|
102
|
+
temperature,
|
|
103
|
+
angle
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Export singleton
|
|
107
|
+
export const Units = {
|
|
108
|
+
initialize () {
|
|
109
|
+
// Set the units object within the store
|
|
110
|
+
Store.set('units', _.merge(config.units || {},
|
|
111
|
+
quantities, {
|
|
112
|
+
default: {
|
|
113
|
+
length: 'm',
|
|
114
|
+
altitude: 'm',
|
|
115
|
+
area: 'm^2',
|
|
116
|
+
velocity: 'm/s',
|
|
117
|
+
temperature: 'degC',
|
|
118
|
+
angle: 'deg',
|
|
119
|
+
notation: 'auto',
|
|
120
|
+
precision: 3
|
|
121
|
+
}
|
|
122
|
+
}))
|
|
123
|
+
// Create units not defined by default in mathjs
|
|
124
|
+
this.getQuantities().forEach(quantity => {
|
|
125
|
+
this.createUnits(quantity)
|
|
126
|
+
})
|
|
127
|
+
},
|
|
128
|
+
createUnits (quantity) {
|
|
129
|
+
// Some units are defined according to existing base units
|
|
130
|
+
// So that we need to create the later ones first
|
|
131
|
+
const units = _.sortBy(this.getUnits(quantity), [(unit) => (unit.baseName ? 0 : 1)])
|
|
132
|
+
// Create units not defined by default in mathjs
|
|
133
|
+
units.forEach(unit => {
|
|
134
|
+
// Check if already exist first
|
|
135
|
+
if (math.Unit.isValuelessUnit(unit.name)) {
|
|
136
|
+
// Maybe we'd like to override it
|
|
137
|
+
if (!unit.override) return
|
|
138
|
+
}
|
|
139
|
+
// If it has any option required by mathjs to create a new unit then proceed
|
|
140
|
+
if (unit.definition || unit.baseName) {
|
|
141
|
+
math.createUnit(unit.name, _.omit(unit, ['label', 'override']), { override: _.get(unit, 'override', false) })
|
|
142
|
+
}
|
|
143
|
+
})
|
|
144
|
+
},
|
|
145
|
+
get () {
|
|
146
|
+
return Store.get('units')
|
|
147
|
+
},
|
|
148
|
+
getDefaultNotation () {
|
|
149
|
+
return Store.get('units.default.notation', 'auto')
|
|
150
|
+
},
|
|
151
|
+
getDefaultPrecision () {
|
|
152
|
+
return Store.get('units.default.precision', 3)
|
|
153
|
+
},
|
|
154
|
+
getQuantities () {
|
|
155
|
+
return _.keys(_.omit(this.get(), ['default']))
|
|
156
|
+
},
|
|
157
|
+
setUnits (quantity, units) {
|
|
158
|
+
Store.set(`units.${quantity}`, units)
|
|
159
|
+
this.createUnits(quantity)
|
|
160
|
+
},
|
|
161
|
+
getUnits (quantity) {
|
|
162
|
+
// Get units for a given quantity
|
|
163
|
+
if (quantity) {
|
|
164
|
+
const units = Store.get(`units.${quantity}`, {})
|
|
165
|
+
return _.values(_.mapValues(units, (value, key) => Object.assign({ name: key, quantity }, value)))
|
|
166
|
+
} else { // Or all units
|
|
167
|
+
let units = []
|
|
168
|
+
this.getQuantities().forEach(quantity => {
|
|
169
|
+
units = units.concat(this.getUnits(quantity))
|
|
170
|
+
})
|
|
171
|
+
return units
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
getUnit (unit) {
|
|
175
|
+
return _.find(this.getUnits(), { name: unit })
|
|
176
|
+
},
|
|
177
|
+
getUnitSymbol (unit) {
|
|
178
|
+
const definition = this.getUnit(unit)
|
|
179
|
+
return (definition ? i18n.t(definition.symbol) : unit)
|
|
180
|
+
},
|
|
181
|
+
getDefaultUnit (quantityOrUnit) {
|
|
182
|
+
// Check for quantity first
|
|
183
|
+
let defaultUnit = Store.get(`units.default.${quantityOrUnit}`)
|
|
184
|
+
// If not check by matching quantity based on given unit
|
|
185
|
+
if (!defaultUnit) {
|
|
186
|
+
const baseUnit = Units.getUnit(quantityOrUnit)
|
|
187
|
+
// Get default unit for this quantity instead
|
|
188
|
+
if (baseUnit) defaultUnit = Units.getDefaultUnit(baseUnit.quantity)
|
|
189
|
+
}
|
|
190
|
+
return defaultUnit
|
|
191
|
+
},
|
|
192
|
+
convert (value, sourceUnit, targetUnit) {
|
|
193
|
+
if (sourceUnit === targetUnit) return value
|
|
194
|
+
let n = math.unit(value, sourceUnit)
|
|
195
|
+
n = n.toNumber(targetUnit)
|
|
196
|
+
// Remap from [-180,+180[ to [0,360[ for angles
|
|
197
|
+
n = (targetUnit === 'deg' ? (n < 0.0 ? n + 360.0 : n) : n)
|
|
198
|
+
return n
|
|
199
|
+
},
|
|
200
|
+
format (value, sourceUnit, targetUnit, options) {
|
|
201
|
+
// If target unit is not given use default one
|
|
202
|
+
if (!targetUnit) targetUnit = this.getDefaultUnit(sourceUnit)
|
|
203
|
+
const n = (targetUnit ? this.convert(value, sourceUnit, targetUnit) : value)
|
|
204
|
+
// Let options overrides defaults
|
|
205
|
+
options = Object.assign({
|
|
206
|
+
symbol: true,
|
|
207
|
+
notation: this.getDefaultNotation(),
|
|
208
|
+
precision: this.getDefaultPrecision(),
|
|
209
|
+
lowerExp: -this.getDefaultPrecision(),
|
|
210
|
+
upperExp: this.getDefaultPrecision()
|
|
211
|
+
}, options)
|
|
212
|
+
let output = math.format(n, options)
|
|
213
|
+
if (options.symbol) {
|
|
214
|
+
output += ` ${targetUnit ? this.getUnitSymbol(targetUnit) : this.getUnitSymbol(sourceUnit)}`
|
|
215
|
+
}
|
|
216
|
+
return output
|
|
217
|
+
}
|
|
218
|
+
}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import _ from 'lodash'
|
|
2
|
+
import logger from 'loglevel'
|
|
3
|
+
import moment from 'moment'
|
|
4
|
+
import emailValidator from 'email-validator'
|
|
5
|
+
import { Notify, Dialog, Loading, exportFile } from 'quasar'
|
|
6
|
+
import { defineAsyncComponent, markRaw } from 'vue'
|
|
7
|
+
|
|
8
|
+
export * from './utils.account.js'
|
|
9
|
+
export * from './utils.colors.js'
|
|
10
|
+
export * from './utils.content.js'
|
|
11
|
+
export * from './utils.locale.js'
|
|
12
|
+
export * from './utils.platform.js'
|
|
13
|
+
export * from './utils.push.js'
|
|
14
|
+
export * from './utils.pwa.js'
|
|
15
|
+
export * from './utils.session.js'
|
|
16
|
+
|
|
17
|
+
Notify.setDefaults({
|
|
18
|
+
position: 'bottom-left',
|
|
19
|
+
timeout: 5000,
|
|
20
|
+
textColor: 'white'
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
Loading.setDefaults({
|
|
24
|
+
spinnerColor: 'primary',
|
|
25
|
+
spinnerSize: 140,
|
|
26
|
+
messageColor: 'white',
|
|
27
|
+
customClass: 'full-width'
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* This function allow you to modify a JS Promise by adding some status properties.
|
|
32
|
+
* Based on: http://stackoverflow.com/questions/21485545/is-there-a-way-to-tell-if-an-es6-promise-is-fulfilled-rejected-resolved
|
|
33
|
+
* But modified according to the specs of promises : https://promisesaplus.com/
|
|
34
|
+
*/
|
|
35
|
+
export function createQuerablePromise (promiseOrExecutor) {
|
|
36
|
+
let promise = promiseOrExecutor
|
|
37
|
+
if (typeof promiseOrExecutor === 'function') {
|
|
38
|
+
promise = new Promise(promiseOrExecutor)
|
|
39
|
+
}
|
|
40
|
+
// Don't modify any promise that has been already modified.
|
|
41
|
+
if (promise.isResolved) return promise
|
|
42
|
+
|
|
43
|
+
// Set initial state
|
|
44
|
+
let isPending = true
|
|
45
|
+
let isRejected = false
|
|
46
|
+
let isFulfilled = false
|
|
47
|
+
|
|
48
|
+
// Observe the promise, saving the fulfillment in a closure scope.
|
|
49
|
+
const result = promise.then(
|
|
50
|
+
(value) => {
|
|
51
|
+
isFulfilled = true
|
|
52
|
+
isPending = false
|
|
53
|
+
return value
|
|
54
|
+
},
|
|
55
|
+
(error) => {
|
|
56
|
+
isRejected = true
|
|
57
|
+
isPending = false
|
|
58
|
+
throw error
|
|
59
|
+
}
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
result.isFulfilled = () => { return isFulfilled }
|
|
63
|
+
result.isPending = () => { return isPending }
|
|
64
|
+
result.isRejected = () => { return isRejected }
|
|
65
|
+
|
|
66
|
+
return result
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function getInitials (name) {
|
|
70
|
+
const initials = name.toUpperCase().match(/\b\w/g) || []
|
|
71
|
+
return initials.join('')
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function isEmailValid (email) {
|
|
75
|
+
return emailValidator.validate(email)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function createThumbnail (imageDataUri, width, height, quality, callback) {
|
|
79
|
+
const image = document.createElement('img')
|
|
80
|
+
image.onload = function () {
|
|
81
|
+
const canvas = document.createElement('canvas')
|
|
82
|
+
const ctx = canvas.getContext('2d')
|
|
83
|
+
// set its dimension to target size
|
|
84
|
+
canvas.width = width
|
|
85
|
+
canvas.height = height
|
|
86
|
+
ctx.drawImage(this, 0, 0, width, height)
|
|
87
|
+
callback(canvas.toDataURL('image/jpeg', quality))
|
|
88
|
+
}
|
|
89
|
+
image.src = imageDataUri
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function dataUriToBlob (dataUri) {
|
|
93
|
+
// convert base64 to raw binary data held in a string
|
|
94
|
+
// doesn't handle URLEncoded DataURIs - see SO answer #6850276 for code that does this
|
|
95
|
+
const byteString = atob(dataUri.split(',')[1])
|
|
96
|
+
// separate out the mime component
|
|
97
|
+
const mimeType = dataUri.split(',')[0].split(':')[1].split(';')[0]
|
|
98
|
+
// write the bytes of the string to an ArrayBuffer
|
|
99
|
+
const ab = new ArrayBuffer(byteString.length)
|
|
100
|
+
// create a view into the buffer
|
|
101
|
+
const ia = new Uint8Array(ab)
|
|
102
|
+
// set the bytes of the buffer to the correct values
|
|
103
|
+
for (let i = 0; i < byteString.length; i++) {
|
|
104
|
+
ia[i] = byteString.charCodeAt(i)
|
|
105
|
+
}
|
|
106
|
+
// write the ArrayBuffer to a blob, and you're done
|
|
107
|
+
return new Blob([ab], { type: mimeType })
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export function downloadAsBlob (data, filename, mimeType) {
|
|
111
|
+
const blob = new Blob([data], { type: mimeType })
|
|
112
|
+
exportFile(filename, blob)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Simplify Quasar dialog plugin usage with async/await
|
|
116
|
+
export async function dialog (options) {
|
|
117
|
+
return new Promise((resolve, reject) => {
|
|
118
|
+
Dialog.create(options)
|
|
119
|
+
.onOk((data) => resolve({ ok: true, data }))
|
|
120
|
+
.onCancel(() => resolve({ cancel: true }))
|
|
121
|
+
.onDismiss(() => resolve({ dismiss: true }))
|
|
122
|
+
})
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Extract icon name from a given icon property on a given target object
|
|
126
|
+
export function getIconName (object, path = 'icon.name') {
|
|
127
|
+
// Make function work in a generic way, sometimes the provided input is directly the icon name
|
|
128
|
+
const icon = (typeof object === 'object' ? _.get(object, path, '') : object)
|
|
129
|
+
// Check whether the returned icon is an object (can be true in some cases)
|
|
130
|
+
if (typeof icon === 'object') return ''
|
|
131
|
+
// Name icons to ensure backward compatibility with font awesome 4
|
|
132
|
+
return (icon.startsWith('fa-') ? `fas ${icon}` : icon)
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export function processIcon (object, path = 'icon.name') {
|
|
136
|
+
// Process icons for backward compatibility with font awesome 4
|
|
137
|
+
_.set(object, path, getIconName(object, path))
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Function to map kdk icons with QIcon from Quasar
|
|
141
|
+
// https://quasar.dev/vue-components/icon#custom-mapping
|
|
142
|
+
export function mapIconFunction (iconName) {
|
|
143
|
+
if (iconName.startsWith('kdk:') === true) {
|
|
144
|
+
// we strip the "kdk:" part
|
|
145
|
+
const name = iconName.substring(4)
|
|
146
|
+
// Return the inlined icon
|
|
147
|
+
return { icon: 'img:icons/kdk/' + name }
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Transform nested object to dot notation
|
|
152
|
+
export function dotify (object) {
|
|
153
|
+
const dotifiedObject = {}
|
|
154
|
+
function recurse (object, current) {
|
|
155
|
+
_.forOwn(object, (value, key) => {
|
|
156
|
+
const newKey = (current ? current + '.' + key : key) // joined key with dot
|
|
157
|
+
if (value && typeof value === 'object') {
|
|
158
|
+
recurse(value, newKey) // it's a nested object, so do it again
|
|
159
|
+
} else {
|
|
160
|
+
dotifiedObject[newKey] = value // it's not an object, so set the property
|
|
161
|
+
}
|
|
162
|
+
})
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
recurse(object)
|
|
166
|
+
return dotifiedObject
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// Regular expression that checks for hex value
|
|
170
|
+
const checkForHexRegExp = /^[0-9a-fA-F]{24}$/
|
|
171
|
+
|
|
172
|
+
// Check if a string is a valid MongoDB Object ID
|
|
173
|
+
export function isObjectID (id) {
|
|
174
|
+
return (id.length === 24 && checkForHexRegExp.test(id))
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// Add UTC offset to timezone name
|
|
178
|
+
export function getTimezoneLabel (timezone) {
|
|
179
|
+
const offset = moment().tz(timezone).format('Z')
|
|
180
|
+
return `${timezone} (${offset})`
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// Helper function to load a schema
|
|
184
|
+
// @schema alias shoud be added in the quasar.config build section
|
|
185
|
+
export async function loadSchema (schemaName) {
|
|
186
|
+
try {
|
|
187
|
+
const schemaModule = await import(`@schemas/${schemaName}.json`)
|
|
188
|
+
return schemaModule.default
|
|
189
|
+
} catch (error) {
|
|
190
|
+
logger.error(error)
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// Helper function to load a component
|
|
195
|
+
// https://vuejs.org/guide/components/async.html
|
|
196
|
+
// @components alias shoud be added in the quasar.config build section
|
|
197
|
+
export function loadComponent (componentName) {
|
|
198
|
+
try {
|
|
199
|
+
return markRaw(defineAsyncComponent(() => import(`@components/${componentName}.vue`)))
|
|
200
|
+
} catch (error) {
|
|
201
|
+
logger.error(error)
|
|
202
|
+
}
|
|
203
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { api } from '../api.js'
|
|
2
|
+
|
|
3
|
+
export function resendVerifySignup (email) {
|
|
4
|
+
return api.getService('account').create({
|
|
5
|
+
action: 'resendVerifySignup',
|
|
6
|
+
value: { email }
|
|
7
|
+
})
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function verifySignup (token, email) {
|
|
11
|
+
return api.getService('account').create({
|
|
12
|
+
action: 'verifySignupShort',
|
|
13
|
+
value: { user: { email }, token }
|
|
14
|
+
})
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function sendResetPassword (email) {
|
|
18
|
+
return api.getService('account').create({
|
|
19
|
+
action: 'sendResetPwd',
|
|
20
|
+
value: { email }
|
|
21
|
+
})
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function resetPassword (email, token, password) {
|
|
25
|
+
return api.getService('account').create({
|
|
26
|
+
action: 'resetPwdShort',
|
|
27
|
+
value: { user: { email }, token, password }
|
|
28
|
+
})
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function changePassword (email, oldPassword, password) {
|
|
32
|
+
return api.getService('account').create({
|
|
33
|
+
action: 'passwordChange',
|
|
34
|
+
value: { user: { email }, oldPassword, password }
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function sendChangeIdentity (oldEmail, email, password) {
|
|
39
|
+
return api.getService('account').create({
|
|
40
|
+
action: 'identityChange',
|
|
41
|
+
value: { user: { email: oldEmail }, changes: { email }, password }
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function changeIdentity (token) {
|
|
46
|
+
return verifySignup(token)
|
|
47
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import _ from 'lodash'
|
|
2
|
+
|
|
3
|
+
export const Colors = {
|
|
4
|
+
dark: '#333',
|
|
5
|
+
red: '#f44336',
|
|
6
|
+
pink: '#e91e63',
|
|
7
|
+
purple: '#9c27b0',
|
|
8
|
+
'deep-purple': '#673ab7',
|
|
9
|
+
indigo: '#3f51b5',
|
|
10
|
+
blue: '#2196f3',
|
|
11
|
+
'light-blue': '#03a9f4',
|
|
12
|
+
cyan: '#00bcd4',
|
|
13
|
+
teal: '#009688',
|
|
14
|
+
green: '#4caf50',
|
|
15
|
+
'light-green': '#8bc34a',
|
|
16
|
+
lime: '#cddc39',
|
|
17
|
+
yellow: '#ffeb3b',
|
|
18
|
+
amber: '#ffc107',
|
|
19
|
+
orange: '#ff9800',
|
|
20
|
+
'deep-orange': '#ff5722',
|
|
21
|
+
brown: '#795548',
|
|
22
|
+
grey: '#9e9e9e',
|
|
23
|
+
'blue-grey': '#607d8b'
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function getPaletteFromColor (color) {
|
|
27
|
+
// Check if already a color of the palette
|
|
28
|
+
if (Colors[color]) return color
|
|
29
|
+
else return _.findKey(Colors, item => item === color) || 'white'
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function getColorFromPalette (color) {
|
|
33
|
+
// Check if already a RGB color
|
|
34
|
+
if (color.startsWith('#')) return color
|
|
35
|
+
else return Colors[color] || '#ffffff'
|
|
36
|
+
}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import _ from 'lodash'
|
|
2
|
+
import logger from 'loglevel'
|
|
3
|
+
import sift from 'sift'
|
|
4
|
+
import { Store } from '../store.js'
|
|
5
|
+
|
|
6
|
+
const Handlers = ['handler', 'visible', 'hidden', 'disabled', 'on.listener']
|
|
7
|
+
// Some bindings are not managed when reading content from config but externally on-demand, e.g. by KContent or KAction
|
|
8
|
+
// The content 'reserved' property is also used to recurse at caller level
|
|
9
|
+
const ReservedBindings = ['content', 'visible', 'hidden', 'route']
|
|
10
|
+
|
|
11
|
+
// Check if an object has a property according to its path.
|
|
12
|
+
// Similar to lodash has function which causes a bug in production build with Vue proxy objects
|
|
13
|
+
// It appears that with proxy objects it is safer to use the in operator or Reflect.has()
|
|
14
|
+
function hasProperty (object, path) {
|
|
15
|
+
const keys = path.split('.')
|
|
16
|
+
let currentObject = object
|
|
17
|
+
for (const key of keys) {
|
|
18
|
+
if (!currentObject || !(key in currentObject)) {
|
|
19
|
+
return false
|
|
20
|
+
}
|
|
21
|
+
currentObject = currentObject[key]
|
|
22
|
+
}
|
|
23
|
+
return true
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function filterContent (content, filter) {
|
|
27
|
+
// Handle non object content
|
|
28
|
+
if (typeof content !== 'object') return content
|
|
29
|
+
// Handle array and object case
|
|
30
|
+
const isArray = Array.isArray(content)
|
|
31
|
+
const modes = _.keys(content)
|
|
32
|
+
let filteredContent = content
|
|
33
|
+
if (!isArray) {
|
|
34
|
+
// Recurse ?
|
|
35
|
+
if (filteredContent.content) {
|
|
36
|
+
filteredContent.content = filterContent(filteredContent.content, filter)
|
|
37
|
+
} else {
|
|
38
|
+
modes.forEach(mode => {
|
|
39
|
+
const contentForMode = filteredContent[mode]
|
|
40
|
+
filteredContent[mode] = filterContent(contentForMode, filter)
|
|
41
|
+
})
|
|
42
|
+
}
|
|
43
|
+
filteredContent = [filteredContent]
|
|
44
|
+
} else {
|
|
45
|
+
filteredContent.forEach(item => {
|
|
46
|
+
// Recurse ?
|
|
47
|
+
if (item.content) {
|
|
48
|
+
item.content = filterContent(item.content, filter)
|
|
49
|
+
}
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
|
+
// Apply filtering
|
|
53
|
+
filteredContent = filteredContent.filter(sift(filter))
|
|
54
|
+
return (isArray ? filteredContent : filteredContent[0])
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Perform binding between a configuration object and a given context object
|
|
58
|
+
export function bindContent (content, context, omit = []) {
|
|
59
|
+
const components = _.flatMapDeep(content)
|
|
60
|
+
_.forEach(components, (component) => {
|
|
61
|
+
// Process component handlers
|
|
62
|
+
Handlers.forEach(handler => bindHandler(component, handler, context))
|
|
63
|
+
// Then process component props
|
|
64
|
+
// It allows to write any property like { label: ':xxx' } and bind it
|
|
65
|
+
// to a component property from the context like we do for handler
|
|
66
|
+
bindProperties(component, context, omit)
|
|
67
|
+
// Recursively bind the props/handlers on the sub content object
|
|
68
|
+
if (component.content) bindContent(component.content, context, omit)
|
|
69
|
+
})
|
|
70
|
+
return content
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function bindProperties (item, context, omit = []) {
|
|
74
|
+
if (Array.isArray(item)) {
|
|
75
|
+
for (let i = 0; i < item.length; i++) {
|
|
76
|
+
item[i] = bindProperties(item[i], context)
|
|
77
|
+
}
|
|
78
|
+
} else if (typeof item === 'object') {
|
|
79
|
+
_.forOwn(item, (value, key) => {
|
|
80
|
+
// Bind required properties only
|
|
81
|
+
if (!ReservedBindings.includes(key) && !omit.includes(key)) {
|
|
82
|
+
if (typeof value === 'string') {
|
|
83
|
+
item[key] = getBoundValue(value, context)
|
|
84
|
+
} else {
|
|
85
|
+
item[key] = bindProperties(value, context)
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
})
|
|
89
|
+
}
|
|
90
|
+
return item
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function bindHandler (component, path, context) {
|
|
94
|
+
const handler = _.get(component, path)
|
|
95
|
+
// Could be an array if multiple handlers to be called
|
|
96
|
+
if (Array.isArray(handler)) {
|
|
97
|
+
// Process all array elements, manage the case where the handler is simply a function/property name
|
|
98
|
+
const handlers = handler.map(h => generateHandler(context, h.name || h, h.params))
|
|
99
|
+
// In that specific case the result is a boolean AND operation
|
|
100
|
+
_.set(component, path, (...args) => handlers.reduce((result, h) => result && h(...args), true))
|
|
101
|
+
} else if (handler && typeof handler === 'object') {
|
|
102
|
+
// Could be a structure with name and possibly params specified
|
|
103
|
+
// :xxx is reserved for binding to internal property not function call
|
|
104
|
+
if (handler.name) {
|
|
105
|
+
if (!handler.name.startsWith(':')) {
|
|
106
|
+
_.set(component, path, generateHandler(context, handler.name, handler.params))
|
|
107
|
+
}
|
|
108
|
+
} else {
|
|
109
|
+
logger.debug(`[KDK] invalid handler binding for ${handler}: you must provide the name to the function to be called`)
|
|
110
|
+
}
|
|
111
|
+
} else if ((typeof handler === 'string') && !handler.startsWith(':')) {
|
|
112
|
+
// Or only name if no params are specified
|
|
113
|
+
// :xxx is reserved for binding to internal property not function call
|
|
114
|
+
_.set(component, path, generateHandler(context, handler))
|
|
115
|
+
}
|
|
116
|
+
// Get back processed handler function
|
|
117
|
+
return _.get(component, path)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function generateHandler (context, name, params) {
|
|
121
|
+
// When the handler can be a simple getter, eg is visible use case,
|
|
122
|
+
// we allow a property value instead of a function and a logical NOT
|
|
123
|
+
const isNot = name.startsWith('!')
|
|
124
|
+
if (isNot) name = name.substring(1)
|
|
125
|
+
return (...args) => {
|
|
126
|
+
let result
|
|
127
|
+
const handler = _.get(context, name)
|
|
128
|
+
// Function call or property value read ?
|
|
129
|
+
if (typeof handler === 'function') {
|
|
130
|
+
// Provided parameters or simply forward arguments ?
|
|
131
|
+
result = (params ? handler(...bindParams(params, context)) : handler(...args))
|
|
132
|
+
} else {
|
|
133
|
+
result = handler
|
|
134
|
+
}
|
|
135
|
+
// Logical NOT to be performed ?
|
|
136
|
+
return (isNot ? !result : result)
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export function bindParams (params, context) {
|
|
141
|
+
// A parameter like :xxx means xxx is a property of the component, not a static value
|
|
142
|
+
// In that case remove trailing : and get property value dynamically
|
|
143
|
+
if (_.isNil(params)) {
|
|
144
|
+
return params
|
|
145
|
+
} else if (Array.isArray(params)) {
|
|
146
|
+
return params.map(param => bindParams(param, context))
|
|
147
|
+
} else if (typeof params === 'object') {
|
|
148
|
+
return _.mapValues(params, (value, key) => bindParams(value, context))
|
|
149
|
+
} else {
|
|
150
|
+
return getBoundValue(params, context)
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export function getBoundValue (value, context) {
|
|
155
|
+
if ((typeof value === 'string') && value.startsWith(':')) {
|
|
156
|
+
// From store or context ?
|
|
157
|
+
if (value.startsWith(':store.')) {
|
|
158
|
+
const path = value.replace(':store.', '')
|
|
159
|
+
if (Store.has(path)) return Store.get(path)
|
|
160
|
+
} else if (value.startsWith(':storeRef.')) {
|
|
161
|
+
const path = value.replace(':storeRef.', '')
|
|
162
|
+
// FIXME: we should test if the path exists but this causes
|
|
163
|
+
// a bug in production build with Vue proxy objects
|
|
164
|
+
// if (Store.has(path)) return Store.getRef(path)
|
|
165
|
+
if (hasProperty(Store, path)) return Store.getRef(path)
|
|
166
|
+
// Workaround if not possible to correctly check the path first
|
|
167
|
+
// but it causes problems with values initialized to null
|
|
168
|
+
// const result = Store.getRef(path)
|
|
169
|
+
// if (!_.isNil(result)) return result
|
|
170
|
+
} else {
|
|
171
|
+
const path = value.substring(1)
|
|
172
|
+
// FIXME: we should test if the path exists but this causes
|
|
173
|
+
// a bug in production build with Vue proxy objects
|
|
174
|
+
// if (_.has(context, path)) return _.get(context, path)
|
|
175
|
+
if (hasProperty(context, path)) return _.get(context, path)
|
|
176
|
+
// Workaround if not possible to correctly check the path first
|
|
177
|
+
// but it causes problems with values initialized to null
|
|
178
|
+
// const result = _.get(context, path)
|
|
179
|
+
// if (!_.isNil(result)) return result
|
|
180
|
+
}
|
|
181
|
+
// Bound value not found
|
|
182
|
+
return undefined
|
|
183
|
+
}
|
|
184
|
+
return value
|
|
185
|
+
}
|