@webitel/ui-sdk 0.1.13 → 0.1.100
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 +29 -29
- package/dist/img/plyr.svg +68 -0
- package/dist/img/sprite/account.svg +4 -0
- package/dist/img/sprite/adfs.svg +5 -0
- package/dist/img/sprite/app-navigator.svg +11 -0
- package/dist/img/sprite/arrow-down.svg +3 -0
- package/dist/img/sprite/arrow-left.svg +3 -0
- package/dist/img/sprite/arrow-right.svg +3 -0
- package/dist/img/sprite/arrow-up.svg +3 -0
- package/dist/img/sprite/attach.svg +3 -0
- package/dist/img/sprite/attention.svg +3 -0
- package/dist/img/sprite/back.svg +4 -0
- package/dist/img/sprite/bell-badged.svg +4 -0
- package/dist/img/sprite/bell.svg +3 -0
- package/dist/img/sprite/bucket.svg +3 -0
- package/dist/img/sprite/calendar.svg +3 -0
- package/dist/img/sprite/call--filled.svg +3 -0
- package/dist/img/sprite/call-add-to--filled.svg +4 -0
- package/dist/img/sprite/call-add-to.svg +4 -0
- package/dist/img/sprite/call-disconnect--filled.svg +3 -0
- package/dist/img/sprite/call-disconnect.svg +3 -0
- package/dist/img/sprite/call-end--filled.svg +3 -0
- package/dist/img/sprite/call-end.svg +3 -0
- package/dist/img/sprite/call-inbound--filled.svg +4 -0
- package/dist/img/sprite/call-inbound.svg +3 -0
- package/dist/img/sprite/call-missed--filled.svg +4 -0
- package/dist/img/sprite/call-missed.svg +3 -0
- package/dist/img/sprite/call-outbound--filled.svg +3 -0
- package/dist/img/sprite/call-outbound.svg +3 -0
- package/dist/img/sprite/call-ringing--filled.svg +5 -0
- package/dist/img/sprite/call-ringing.svg +3 -0
- package/dist/img/sprite/call-transfer--filled.svg +4 -0
- package/dist/img/sprite/call-transfer.svg +3 -0
- package/dist/img/sprite/call.svg +3 -0
- package/dist/img/sprite/chat--filled.svg +3 -0
- package/dist/img/sprite/chat-emoji.svg +3 -0
- package/dist/img/sprite/chat-end--filled.svg +3 -0
- package/dist/img/sprite/chat-end.svg +4 -0
- package/dist/img/sprite/chat-group.svg +5 -0
- package/dist/img/sprite/chat-join.svg +4 -0
- package/dist/img/sprite/chat-message-status-read.svg +3 -0
- package/dist/img/sprite/chat-message-status-sent.svg +3 -0
- package/dist/img/sprite/chat-quick-response--filled.svg +3 -0
- package/dist/img/sprite/chat-quick-response.svg +3 -0
- package/dist/img/sprite/chat-reply.svg +3 -0
- package/dist/img/sprite/chat-send.svg +6 -0
- package/dist/img/sprite/chat-transfer--filled.svg +3 -0
- package/dist/img/sprite/chat-transfer.svg +4 -0
- package/dist/img/sprite/chat.svg +3 -0
- package/dist/img/sprite/checkbox--checked--filled.svg +3 -0
- package/dist/img/sprite/checkbox--checked.svg +3 -0
- package/dist/img/sprite/checkbox.svg +3 -0
- package/dist/img/sprite/clear.svg +3 -0
- package/dist/img/sprite/close--filled.svg +3 -0
- package/dist/img/sprite/close.svg +3 -0
- package/dist/img/sprite/collapse.svg +5 -0
- package/dist/img/sprite/column-select.svg +4 -0
- package/dist/img/sprite/contacts.svg +3 -0
- package/dist/img/sprite/copy.svg +3 -0
- package/dist/img/sprite/docs.svg +6 -0
- package/dist/img/sprite/done.svg +4 -0
- package/dist/img/sprite/download.svg +5 -0
- package/dist/img/sprite/edit.svg +3 -0
- package/dist/img/sprite/expand.svg +5 -0
- package/dist/img/sprite/eye--closed.svg +5 -0
- package/dist/img/sprite/eye--opened.svg +4 -0
- package/dist/img/sprite/filter.svg +5 -0
- package/dist/img/sprite/generate.svg +4 -0
- package/dist/img/sprite/google.svg +6 -0
- package/dist/img/sprite/history.svg +4 -0
- package/dist/img/sprite/hold.svg +3 -0
- package/dist/img/sprite/index.js +120 -0
- package/dist/img/sprite/lock.svg +3 -0
- package/dist/img/sprite/logout.svg +3 -0
- package/dist/img/sprite/menu.svg +3 -0
- package/dist/img/sprite/messenger-facebook.svg +3 -0
- package/dist/img/sprite/messenger-infobip.svg +9 -0
- package/dist/img/sprite/messenger-telegram.svg +6 -0
- package/dist/img/sprite/messenger-viber.svg +3 -0
- package/dist/img/sprite/messenger-web-chat.svg +7 -0
- package/dist/img/sprite/messenger-whatsapp.svg +4 -0
- package/dist/img/sprite/mic-muted.svg +6 -0
- package/dist/img/sprite/mic.svg +4 -0
- package/dist/img/sprite/move.svg +6 -0
- package/dist/img/sprite/note.svg +3 -0
- package/dist/img/sprite/numpad.svg +24 -0
- package/dist/img/sprite/pause.svg +3 -0
- package/dist/img/sprite/play.svg +4 -0
- package/dist/img/sprite/plus.svg +3 -0
- package/dist/img/sprite/prompter.svg +3 -0
- package/dist/img/sprite/queue-member.svg +3 -0
- package/dist/img/sprite/radio--checked.svg +4 -0
- package/dist/img/sprite/radio.svg +3 -0
- package/dist/img/sprite/rec-off.svg +3 -0
- package/dist/img/sprite/rec.svg +4 -0
- package/dist/img/sprite/refresh.svg +4 -0
- package/dist/img/sprite/rounded-info.svg +3 -0
- package/dist/img/sprite/search.svg +3 -0
- package/dist/img/sprite/send-arrow.svg +4 -0
- package/dist/img/sprite/settings.svg +3 -0
- package/dist/img/sprite/sort-arrow-down.svg +4 -0
- package/dist/img/sprite/sort-arrow-up.svg +4 -0
- package/dist/img/sprite/sound-off.svg +4 -0
- package/dist/img/sprite/sound-on.svg +3 -0
- package/dist/img/sprite/star--filled.svg +3 -0
- package/dist/img/sprite/star.svg +3 -0
- package/dist/img/sprite/stop.svg +4 -0
- package/dist/img/sprite/tick.svg +3 -0
- package/dist/img/sprite/upload.svg +5 -0
- package/dist/img/sprite/video-off.svg +4 -0
- package/dist/img/sprite/video.svg +3 -0
- package/dist/img/sprite/widget-avg-hold.svg +3 -0
- package/dist/img/sprite/widget-avg-talk.svg +8 -0
- package/dist/img/sprite/widget-handles.svg +4 -0
- package/dist/img/sprite/widget-inbound.svg +6 -0
- package/dist/img/sprite/widget-missed.svg +5 -0
- package/dist/img/sprite/widget-occupancy.svg +5 -0
- package/dist/img/sprite/widget-utilization.svg +6 -0
- package/dist/img/sprite/zoom-in.svg +3 -0
- package/dist/img/sprite/zoom-out.svg +3 -0
- package/dist/ui-sdk.common.js +8729 -4165
- package/dist/ui-sdk.common.js.map +1 -1
- package/dist/ui-sdk.css +1 -1
- package/dist/ui-sdk.umd.js +8729 -4165
- package/dist/ui-sdk.umd.js.map +1 -1
- package/dist/ui-sdk.umd.min.js +3 -1
- package/dist/ui-sdk.umd.min.js.map +1 -1
- package/package.json +64 -42
- package/src/components/atoms/wt-badge/__tests__/WtBadge.spec.js +19 -0
- package/src/components/atoms/wt-badge/wt-badge.vue +23 -0
- package/src/components/atoms/wt-button/__tests__/WtButton.spec.js +29 -0
- package/src/components/atoms/wt-button/wt-button.vue +211 -0
- package/src/components/atoms/wt-context-menu/__tests__/WtContextMenu.spec.js +43 -0
- package/src/components/atoms/wt-context-menu/wt-context-menu.vue +78 -0
- package/src/components/atoms/wt-divider/__tests__/WtDivider.spec.js +9 -0
- package/src/components/atoms/wt-divider/wt-divider.vue +25 -0
- package/src/components/atoms/wt-icon/__tests__/WtIcon.spec.js +24 -0
- package/src/components/atoms/wt-icon/wt-icon.vue +134 -0
- package/src/components/atoms/wt-indicator/__tests__/WtIndicator.spec.js +29 -0
- package/src/components/atoms/wt-indicator/wt-indicator.vue +81 -0
- package/src/components/atoms/wt-input-info/__tests__/WtInputInfo.spec.js +9 -0
- package/src/components/atoms/wt-input-info/wt-input-info.vue +35 -0
- package/src/components/atoms/wt-loader/__tests__/WtLoader.spec.js +9 -0
- package/src/components/atoms/wt-loader/_internals/wt-loader--md.vue +83 -0
- package/src/components/atoms/wt-loader/_internals/wt-loader--sm.vue +189 -0
- package/src/components/atoms/wt-loader/wt-loader.vue +34 -0
- package/src/components/atoms/wt-rounded-action/__tests__/WtRoundedAction.spec.js +20 -0
- package/src/components/atoms/wt-rounded-action/wt-rounded-action.vue +227 -0
- package/src/components/atoms/wt-tooltip/__tests__/WtTooltip.spec.js +29 -0
- package/src/components/atoms/wt-tooltip/wt-tooltip.vue +54 -0
- package/src/components/index.js +102 -0
- package/src/components/molecules/wt-button-select/__tests__/WtButtonSelect.spec.js +63 -0
- package/src/components/molecules/wt-button-select/wt-button-select.vue +187 -0
- package/src/components/molecules/wt-checkbox/__tests__/WtCheckbox.spec.js +41 -0
- package/src/components/molecules/wt-checkbox/wt-checkbox.vue +175 -0
- package/src/components/molecules/wt-datepicker/__tests__/WtDatepicker.spec.js +28 -0
- package/src/components/molecules/wt-datepicker/wt-datepicker.vue +209 -0
- package/src/components/molecules/wt-datetimepicker/__tests__/WtDatetimepicker.spec.js +67 -0
- package/src/components/molecules/wt-datetimepicker/wt-datetimepicker.vue +314 -0
- package/src/components/molecules/wt-icon-btn/__tests__/WtIconBtn.spec.js +31 -0
- package/src/components/molecules/wt-icon-btn/wt-icon-btn.vue +113 -0
- package/src/components/molecules/wt-input/__tests__/WtInput.spec.js +25 -0
- package/src/components/molecules/wt-input/wt-input.vue +342 -0
- package/src/components/molecules/wt-label/__tests__/WtLabel.spec.js +9 -0
- package/src/components/molecules/wt-label/wt-label.vue +87 -0
- package/src/components/molecules/wt-notification/__tests__/WtNotification.spec.js +21 -0
- package/src/components/molecules/wt-notification/wt-notification.vue +74 -0
- package/src/components/molecules/wt-popup/__tests__/WtPopup.spec.js +47 -0
- package/src/components/molecules/wt-popup/wt-popup.vue +130 -0
- package/src/components/molecules/wt-progress-bar/__tests__/WtProgressBar.spec.js +17 -0
- package/src/components/molecules/wt-progress-bar/wt-progress-bar.vue +80 -0
- package/src/components/molecules/wt-radio/__tests__/WtRadio.spec.js +42 -0
- package/src/components/molecules/wt-radio/wt-radio.vue +168 -0
- package/src/components/molecules/wt-search-bar/__tests__/WtSearchBar.spec.js +36 -0
- package/src/components/molecules/wt-search-bar/wt-search-bar.vue +205 -0
- package/src/components/molecules/wt-select/__tests__/WtSelect.spec.js +53 -0
- package/src/components/molecules/wt-select/wt-select.vue +553 -0
- package/src/components/molecules/wt-slider/__tests__/WtSlider.spec.js +9 -0
- package/src/components/molecules/wt-slider/wt-slider.vue +175 -0
- package/src/components/molecules/wt-switcher/__tests__/WtSwitcher.spec.js +31 -0
- package/src/components/molecules/wt-switcher/wt-switcher.vue +177 -0
- package/src/components/molecules/wt-tabs/__tests__/WtTabs.spec.js +36 -0
- package/src/components/molecules/wt-tabs/wt-tabs.vue +127 -0
- package/src/components/molecules/wt-tags-input/__tests__/WtTagsInput.spec.js +45 -0
- package/src/components/molecules/wt-tags-input/wt-tags-input.vue +295 -0
- package/src/components/molecules/wt-textarea/__tests__/WtTextarea.spec.js +46 -0
- package/src/components/molecules/wt-textarea/wt-textarea.vue +185 -0
- package/src/components/molecules/wt-time-input/__tests__/WtTimeInput.spec.js +25 -0
- package/src/components/molecules/wt-time-input/wt-time-input.vue +192 -0
- package/src/components/molecules/wt-timepicker/__tests__/WtTimepicker.spec.js +60 -0
- package/src/components/molecules/wt-timepicker/wt-timepicker.vue +176 -0
- package/src/components/organisms/wt-app-header/__tests__/WtAppHeader.spec.js +19 -0
- package/src/components/organisms/wt-app-header/__tests__/WtAppNavigator.spec.js +23 -0
- package/src/components/organisms/wt-app-header/__tests__/WtHeaderActions.spec.js +21 -0
- package/src/components/organisms/wt-app-header/wt-app-header.vue +23 -0
- package/src/components/organisms/wt-app-header/wt-app-navigator.vue +245 -0
- package/src/components/organisms/wt-app-header/wt-header-actions.vue +177 -0
- package/src/components/organisms/wt-error-page/__tests__/wt-error-page.spec.js +17 -0
- package/src/components/organisms/wt-error-page/wt-error-page.vue +104 -0
- package/src/components/organisms/wt-filters-panel-wrapper/__tests__/wt-filters-panel-wrapper.spec.js +24 -0
- package/src/components/organisms/wt-filters-panel-wrapper/wt-filters-panel-wrapper.vue +146 -0
- package/src/components/organisms/wt-headline/__tests__/WtHeadline.spec.js +47 -0
- package/src/components/organisms/wt-headline/wt-headline.vue +46 -0
- package/src/components/organisms/wt-navigation-bar/__tests__/WtNavigationBar.spec.js +64 -0
- package/src/components/organisms/wt-navigation-bar/wt-navigation-bar.vue +249 -0
- package/src/components/organisms/wt-notifications-bar/__tests__/WtNotificationsBar.spec.js +50 -0
- package/src/components/organisms/wt-notifications-bar/wt-notifications-bar.vue +71 -0
- package/src/components/organisms/wt-page-wrapper/__tests__/WtPageWrapper.spec.js +33 -0
- package/src/components/organisms/wt-page-wrapper/wt-page-wrapper.vue +60 -0
- package/src/components/organisms/wt-pagination/__tests__/WtPagination.spec.js +38 -0
- package/src/components/organisms/wt-pagination/wt-pagination.vue +134 -0
- package/src/components/organisms/wt-player/__tests__/WtPlayer.spec.js +9 -0
- package/src/components/organisms/wt-player/wt-player.vue +139 -0
- package/src/components/organisms/wt-status-select/__tests__/WtStatusSelect.spec.js +25 -0
- package/src/components/organisms/wt-status-select/_internals/StatusOptions.lookup.js +24 -0
- package/src/components/organisms/wt-status-select/wt-status-select.vue +110 -0
- package/src/components/organisms/wt-table/__tests__/WtTable.spec.js +133 -0
- package/src/components/organisms/wt-table/__tests__/WtTableDeleteAction.spec.js +9 -0
- package/src/components/organisms/wt-table/__tests__/WtTableEditAction.spec.js +9 -0
- package/src/components/organisms/wt-table/_internals/getSortOrder.js +12 -0
- package/src/components/organisms/wt-table/table-cells/wt-table-delete-action.vue +18 -0
- package/src/components/organisms/wt-table/table-cells/wt-table-edit-action.vue +19 -0
- package/src/components/organisms/wt-table/wt-table.vue +241 -0
- package/src/components/organisms/wt-table-actions/__tests__/WtTableActions.spec.js +9 -0
- package/src/components/organisms/wt-table-actions/wt-table-actions.vue +90 -0
- package/src/components/organisms/wt-table-column-select/__tests__/WtTableColumnSelect.spec.js +31 -0
- package/src/components/organisms/wt-table-column-select/wt-table-column-select.vue +116 -0
- package/src/components/transitions/__tests__/ExpandTransition.spec.js +9 -0
- package/src/components/transitions/expand-transition.vue +70 -0
- package/src/css/colors/_colors.scss +151 -67
- package/src/css/components/_components.scss +41 -25
- package/src/css/components/atoms/wt-badge/_variables.scss +6 -5
- package/src/css/components/atoms/wt-badge/wt-badge.scss +40 -8
- package/src/css/components/atoms/wt-button/_variables.scss +45 -46
- package/src/css/components/atoms/wt-context-menu/_variables.scss +10 -0
- package/src/css/components/atoms/wt-divider/_variables.scss +4 -4
- package/src/css/components/atoms/wt-icon/_variables.scss +7 -28
- package/src/css/components/atoms/wt-indicator/_variables.scss +18 -0
- package/src/css/components/atoms/wt-input-info/_variables.scss +6 -5
- package/src/css/components/atoms/wt-label/_variables.scss +4 -4
- package/src/css/components/atoms/wt-loader/_variables.scss +7 -7
- package/src/css/components/atoms/wt-rounded-action/_variables.scss +30 -0
- package/src/css/components/atoms/wt-tooltip/_variables.scss +9 -9
- package/src/css/components/molecules/wt-button-select/_variables.scss +21 -0
- package/src/css/components/molecules/wt-checkbox/_variables.scss +3 -3
- package/src/css/components/molecules/wt-datepicker/_variables.scss +20 -20
- package/src/css/components/molecules/wt-datepicker/datepicker-calendar.scss +101 -100
- package/src/css/components/molecules/wt-datetimepicker/_variables.scss +11 -11
- package/src/css/components/molecules/wt-icon-btn/_variables.scss +2 -2
- package/src/css/components/molecules/wt-input/_variables.scss +7 -5
- package/src/css/components/molecules/wt-notification/_variables.scss +9 -9
- package/src/css/components/molecules/wt-popup/_variables.scss +11 -10
- package/src/css/components/molecules/wt-progress-bar/_variables.scss +11 -0
- package/src/css/components/molecules/wt-radio/_variables.scss +6 -6
- package/src/css/components/molecules/wt-search-bar/_variables.scss +3 -3
- package/src/css/components/molecules/wt-select/_variables.scss +25 -23
- package/src/css/components/molecules/wt-slider/_variables.scss +15 -0
- package/src/css/components/molecules/wt-switcher/_variables.scss +17 -14
- package/src/css/components/molecules/wt-tabs/_variables.scss +13 -13
- package/src/css/components/molecules/wt-tags-input/_variables.scss +25 -0
- package/src/css/components/molecules/wt-textarea/_variables.scss +4 -4
- package/src/css/components/molecules/wt-timepicker/_variables.scss +4 -3
- package/src/css/components/organisms/wt-app-header/_variables.scss +20 -0
- package/src/css/components/organisms/wt-headline/_variables.scss +7 -0
- package/src/css/components/organisms/wt-navigation-bar/_variables.scss +14 -0
- package/src/css/components/organisms/wt-notifications-bar/_variables.scss +7 -0
- package/src/css/components/organisms/wt-page-wrapper/_variables.scss +5 -0
- package/src/css/components/organisms/wt-pagination/_variables.scss +6 -6
- package/src/css/components/organisms/wt-player/_variables.scss +8 -0
- package/src/css/components/organisms/wt-status-select/_variables.scss +6 -0
- package/src/css/components/organisms/wt-table/_variables.scss +16 -0
- package/src/css/components/organisms/wt-table-actions/_variables.scss +4 -0
- package/src/css/display-helpers/_display-helpers.scss +21 -0
- package/src/css/fonts/_fonts.scss +9 -0
- package/src/css/main.scss +67 -65
- package/src/css/shadows/_shadows.scss +7 -0
- package/src/css/sizes/_sizes.scss +2 -0
- package/src/css/sizes/_spacing.scss +33 -0
- package/src/css/sizes/_viewport-breakpoints.scss +20 -0
- package/src/css/styleguide/{styleguide.scss → _styleguide.scss} +4 -3
- package/src/css/styleguide/scroll.scss +43 -40
- package/src/css/transitions/_transitions.scss +1 -0
- package/src/css/transitions/fade/_fade.scss +8 -0
- package/src/css/typography/_typography.scss +72 -72
- package/src/enums/AgentStatus/AgentStatus.enum.js +6 -0
- package/src/enums/WebitelApplications/AdminSections.enum.js +41 -0
- package/src/enums/WebitelApplications/SupervisorSections.enum.js +7 -0
- package/src/enums/WebitelApplications/WebitelApplications.enum.js +10 -0
- package/src/locale/en/en.js +192 -0
- package/src/locale/i18n.js +2 -0
- package/src/locale/ru/ru.js +192 -2
- package/src/locale/ua/ua.js +217 -0
- package/src/mixins/dataFilterMixins/__tests__/apiFilterMixin.spec.js +57 -0
- package/src/mixins/dataFilterMixins/__tests__/enumFilterMixin.spec.js +66 -0
- package/src/mixins/dataFilterMixins/__tests__/paginationFilterMixin.spec.js +93 -0
- package/src/mixins/dataFilterMixins/__tests__/sortFilterMixin.spec.js +60 -0
- package/src/mixins/dataFilterMixins/__tests__/urlControllerMixin.spec.js +48 -0
- package/src/mixins/dataFilterMixins/_urlControllerMixin/_urlControllerMixin.js +37 -0
- package/src/mixins/dataFilterMixins/apiFilterMixin.js +23 -0
- package/src/mixins/dataFilterMixins/baseFilterMixin/baseFilterMixin.js +29 -0
- package/src/mixins/dataFilterMixins/enumFilterMixin.js +30 -0
- package/src/mixins/dataFilterMixins/paginationFilterMixin.js +79 -0
- package/src/mixins/dataFilterMixins/sortFilterMixin.js +75 -0
- package/src/mixins/validationMixin/__tests__/validationMixin.spec.js +47 -0
- package/src/mixins/validationMixin/validationMixin.js +41 -0
- package/src/modules/CSVExport/CSVExport.js +88 -0
- package/src/modules/CSVExport/__tests__/CSVExport.spec.js +63 -0
- package/src/modules/CSVExport/mixins/exportCSVMixin.js +46 -0
- package/src/modules/FilesExport/FilesExport.js +110 -0
- package/src/modules/FilesExport/__tests__/FilesExport.spec.js +66 -0
- package/src/modules/FilesExport/mixins/exportFilesMixin.js +46 -0
- package/src/modules/FilesExport/scripts/generateMediaURL.js +7 -0
- package/src/modules/QueryFilters/api/__tests__/defaults.spec.js +18 -0
- package/src/modules/QueryFilters/api/defaults.js +16 -0
- package/src/modules/QueryFilters/classes/ApiFilterSchema.js +32 -0
- package/src/modules/QueryFilters/classes/BaseFilterSchema.js +6 -0
- package/src/modules/QueryFilters/classes/EnumFilterSchema.js +23 -0
- package/src/modules/QueryFilters/classes/__tests__/ApiFilterSchema.spec.js +25 -0
- package/src/modules/QueryFilters/components/__tests__/abstract-api-filter.spec.js +54 -0
- package/src/modules/QueryFilters/components/__tests__/abstract-enum-filter.spec.js +40 -0
- package/src/modules/QueryFilters/components/__tests__/filter-search.spec.js +49 -0
- package/src/modules/QueryFilters/components/abstract-api-filter.vue +42 -0
- package/src/modules/QueryFilters/components/abstract-enum-filter.vue +32 -0
- package/src/modules/QueryFilters/components/filter-search.vue +33 -0
- package/src/modules/QueryFilters/mixins/__tests__/apiFilterMixin.spec.js +48 -0
- package/src/modules/QueryFilters/mixins/__tests__/enumFilterMixin.spec.js +70 -0
- package/src/modules/QueryFilters/mixins/__tests__/paginationFilterMixin.spec.js +86 -0
- package/src/modules/QueryFilters/mixins/__tests__/sortFilterMixin.spec.js +58 -0
- package/src/modules/QueryFilters/mixins/__tests__/urlControllerMixin.spec.js +48 -0
- package/src/modules/QueryFilters/mixins/_urlControllerMixin/_urlControllerMixin.js +39 -0
- package/src/modules/QueryFilters/mixins/apiFilterMixin.js +36 -0
- package/src/modules/QueryFilters/mixins/baseFilterMixin/baseFilterMixin.js +34 -0
- package/src/modules/QueryFilters/mixins/enumFilterMixin.js +46 -0
- package/src/modules/QueryFilters/mixins/paginationFilterMixin.js +76 -0
- package/src/modules/QueryFilters/mixins/sortFilterMixin.js +56 -0
- package/src/modules/QueryFilters/store/QueryFiltersStoreModule.js +50 -0
- package/src/modules/QueryFilters/store/__tests__/QueryFiltersStoreModule.spec.js +83 -0
- package/src/modules/QueryFilters/store/queryFilters.js +6 -0
- package/src/modules/Userinfo/api/BaseAPIService.js +7 -0
- package/src/modules/Userinfo/api/auth.js +29 -0
- package/src/modules/Userinfo/api/userinfo.js +32 -0
- package/src/modules/Userinfo/classes/ApplicationsAccess.js +170 -0
- package/src/modules/Userinfo/components/__tests__/auth.spec.js +57 -0
- package/src/modules/Userinfo/components/the-auth.vue +75 -0
- package/src/modules/Userinfo/store/UserinfoStoreModule.js +112 -0
- package/src/scripts/__tests__/caseConverters.spec.js +72 -0
- package/src/scripts/__tests__/convertDuration.spec.js +21 -0
- package/src/scripts/__tests__/debounce.spec.js +15 -0
- package/src/scripts/__tests__/editProxy.spec.js +9 -0
- package/src/scripts/__tests__/isEmpty.spec.js +16 -0
- package/src/scripts/__tests__/prettifyFileSize.spec.js +18 -0
- package/src/scripts/__tests__/prettifyTime.spec.js +18 -0
- package/src/scripts/__tests__/preventHiddenPageCallsDecorator.spec.js +16 -0
- package/src/scripts/__tests__/sortQueryAdapters.spec.js +12 -0
- package/src/scripts/caseConverters.js +77 -0
- package/src/scripts/convertDuration.js +15 -0
- package/src/scripts/editProxy.js +9 -0
- package/src/scripts/eventBus.js +4 -0
- package/src/scripts/isEmpty.js +9 -0
- package/src/scripts/prettifyFileSize.js +11 -0
- package/src/scripts/prettifyTime.js +9 -0
- package/src/scripts/preventHiddenPageCallsDecorator.js +6 -0
- package/src/scripts/sortQueryAdapters.js +21 -0
- package/src/store/BaseStoreModules/BaseStoreModule.js +49 -0
- package/src/store/BaseStoreModules/__tests__/BaseStoreModule.spec.js +104 -0
- package/src/store/helpers/__tests__/getNamespacedState.spec.js +11 -0
- package/src/store/helpers/getNamespacedState.js +5 -0
- package/dist/img/arrow-down--active--md.7b60f2fb6090366652124f77c543a516.svg +0 -3
- package/dist/img/arrow-down--disabled--md.f58424cd673258365e78863edd1e92cc.svg +0 -3
- package/dist/img/arrow-down--md.1843b60e1c244e066a650e8d19ea83c9.svg +0 -3
- package/dist/img/calendar--active--md.7fd3d949ec7234a4940ea452d95b4165.svg +0 -6
- package/dist/img/calendar--disabled--md.8e7a1e18f93ae8af270060400e6f881c.svg +0 -3
- package/dist/img/calendar--md.9c265581c3a405ff0f0e46e8092f36b8.svg +0 -6
- package/src/css/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
- package/src/css/fonts/Montserrat/Montserrat-SemiBold.ttf +0 -0
- package/src/css/fonts.scss +0 -9
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import userinfo from '../api/userinfo';
|
|
2
|
+
import ApplicationsAccess from '../classes/ApplicationsAccess';
|
|
3
|
+
import BaseStoreModule from '../../../store/BaseStoreModules/BaseStoreModule';
|
|
4
|
+
|
|
5
|
+
const defaultState = () => ({
|
|
6
|
+
isLoading: true,
|
|
7
|
+
domainId: 0,
|
|
8
|
+
name: '',
|
|
9
|
+
username: '',
|
|
10
|
+
account: '',
|
|
11
|
+
userId: 0,
|
|
12
|
+
scope: {},
|
|
13
|
+
permissions: {},
|
|
14
|
+
roles: [],
|
|
15
|
+
license: [],
|
|
16
|
+
access: {},
|
|
17
|
+
language: localStorage.getItem('lang'),
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export default class UserinfoStoreModule extends BaseStoreModule {
|
|
21
|
+
state = {
|
|
22
|
+
...defaultState(),
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
getters = {
|
|
26
|
+
THIS_APP: (state) => state.thisApp,
|
|
27
|
+
// if no access[app] => accessed by default
|
|
28
|
+
CHECK_APP_ACCESS: (state) => (app) => !state.access[app] || state.access[app]?._enabled,
|
|
29
|
+
CHECK_OBJECT_ACCESS: (state, getters) => ({ name, route }) => {
|
|
30
|
+
if (!state.access[getters.THIS_APP] || !state.access[getters.THIS_APP]._enabled) return false;
|
|
31
|
+
if (route) return getters.CHECK_OBJECT_ACCESS_BY_ROUTE(route);
|
|
32
|
+
return getters.CHECK_OBJECT_ACCESS_BY_NAME(name);
|
|
33
|
+
},
|
|
34
|
+
CHECK_OBJECT_ACCESS_BY_NAME: (state, getters) => (name) => (
|
|
35
|
+
state.access[getters.THIS_APP][name]?._enabled
|
|
36
|
+
),
|
|
37
|
+
CHECK_OBJECT_ACCESS_BY_ROUTE: (state, getters) => (route) => {
|
|
38
|
+
const accessKey = Object.keys(state.access[getters.THIS_APP]).find((object) => route.name.includes(object));
|
|
39
|
+
return state.access[getters.THIS_APP][accessKey]?._enabled;
|
|
40
|
+
},
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
actions = {
|
|
44
|
+
BEFORE_OPEN_SESSION_HOOK: () => {},
|
|
45
|
+
AFTER_OPEN_SESSION_HOOK: () => {},
|
|
46
|
+
CONVERT_USER_SCOPE: (context, scope) => scope,
|
|
47
|
+
CONVERT_USER_PERMISSIONS: (context, permissions) => permissions,
|
|
48
|
+
|
|
49
|
+
OPEN_SESSION: async (context) => {
|
|
50
|
+
await context.dispatch('BEFORE_OPEN_SESSION_HOOK');
|
|
51
|
+
// !!! it should be checked in router.js beforeEach hook
|
|
52
|
+
// if (!localStorage.getItem('access-token')) {
|
|
53
|
+
// context.dispatch('REDIRECT_TO_AUTH');
|
|
54
|
+
// throw new Error('No access-token in localStorage');
|
|
55
|
+
// }
|
|
56
|
+
const session = await userinfo.getSession();
|
|
57
|
+
await context.dispatch('SET_SESSION', session);
|
|
58
|
+
const access = await userinfo.getApplicationsAccess();
|
|
59
|
+
await context.dispatch('SET_APPLICATIONS_ACCESS', new ApplicationsAccess({ access }).getAccess());
|
|
60
|
+
await context.dispatch('AFTER_OPEN_SESSION_HOOK');
|
|
61
|
+
},
|
|
62
|
+
SET_SESSION: async (context, _session) => {
|
|
63
|
+
const defaultSession = {
|
|
64
|
+
domainId: 0,
|
|
65
|
+
username: '',
|
|
66
|
+
userId: 0,
|
|
67
|
+
scope: [],
|
|
68
|
+
roles: [],
|
|
69
|
+
license: [],
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
try {
|
|
73
|
+
await context.dispatch('RESET_STATE');
|
|
74
|
+
const session = { ...defaultSession, ..._session };
|
|
75
|
+
const scope = await context.dispatch('CONVERT_USER_SCOPE', session.scope);
|
|
76
|
+
const permissions = await context.dispatch('CONVERT_USER_PERMISSIONS', session.permissions);
|
|
77
|
+
context.commit('SET_SESSION', { ...session, scope, permissions });
|
|
78
|
+
await context.dispatch('SET_LOADING', false);
|
|
79
|
+
} catch (err) {
|
|
80
|
+
throw err;
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
SET_APPLICATIONS_ACCESS: (context, access) => context.commit('SET_APPLICATIONS_ACCESS', access),
|
|
85
|
+
|
|
86
|
+
SET_LOADING: (context, isLoading) => {
|
|
87
|
+
context.commit('SET_LOADING', isLoading);
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
RESET_STATE: (context) => {
|
|
91
|
+
context.commit('RESET_STATE');
|
|
92
|
+
},
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
mutations = {
|
|
96
|
+
SET_SESSION: (state, session) => {
|
|
97
|
+
Object.assign(state, session);
|
|
98
|
+
},
|
|
99
|
+
|
|
100
|
+
SET_APPLICATIONS_ACCESS: (state, access) => {
|
|
101
|
+
state.access = access;
|
|
102
|
+
},
|
|
103
|
+
|
|
104
|
+
SET_LOADING: (state, isLoading) => {
|
|
105
|
+
state.isLoading = isLoading;
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
RESET_STATE: (state) => {
|
|
109
|
+
Object.assign(state, defaultState());
|
|
110
|
+
},
|
|
111
|
+
}
|
|
112
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import {
|
|
2
|
+
camelToKebab,
|
|
3
|
+
camelToSnake,
|
|
4
|
+
kebabToCamel,
|
|
5
|
+
objCamelToSnake,
|
|
6
|
+
objSnakeToCamel,
|
|
7
|
+
snakeToCamel,
|
|
8
|
+
} from '../caseConverters';
|
|
9
|
+
|
|
10
|
+
describe('Case converters', () => {
|
|
11
|
+
it('Camel-Kebab', () => {
|
|
12
|
+
const camelStr = 'camelToKebab';
|
|
13
|
+
const kebabStr = 'camel-to-kebab';
|
|
14
|
+
expect(camelToKebab(camelStr)).toBe(kebabStr);
|
|
15
|
+
expect(kebabToCamel(kebabStr)).toBe(camelStr);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('Camel-Snake', () => {
|
|
19
|
+
const camelStr = 'camelToSnake';
|
|
20
|
+
const snakeStr = 'camel_to_snake';
|
|
21
|
+
expect(camelToSnake(camelStr)).toBe(snakeStr);
|
|
22
|
+
expect(snakeToCamel(snakeStr)).toBe(camelStr);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('Camel-Snake, test case 1: do not convert 1st uppercase letter', () => {
|
|
26
|
+
const camelStr = 'Timer';
|
|
27
|
+
const snakeStr = 'Timer';
|
|
28
|
+
expect(camelToSnake(camelStr)).toBe(snakeStr);
|
|
29
|
+
expect(snakeToCamel(snakeStr)).toBe(camelStr);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('Camel <- Snake skips first char "_"', () => {
|
|
33
|
+
const camelStr = '_camelToSnake';
|
|
34
|
+
const snakeStr = '_camel_to_snake';
|
|
35
|
+
expect(snakeToCamel(snakeStr)).toBe(camelStr);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('Camel-Snake Objects', () => {
|
|
39
|
+
const camelObj = { camelToSnake: { camelToSnake: null, arr: [10] } };
|
|
40
|
+
const snakeObj = { camel_to_snake: { camel_to_snake: null, arr: [10] } };
|
|
41
|
+
expect(objCamelToSnake(camelObj)).toEqual(snakeObj);
|
|
42
|
+
expect(objSnakeToCamel(snakeObj)).toEqual(camelObj);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('Camel-Snake Objects: NULL VALUES', () => {
|
|
46
|
+
const camelObj = null;
|
|
47
|
+
const snakeObj = null;
|
|
48
|
+
expect(objCamelToSnake(camelObj)).toEqual(snakeObj);
|
|
49
|
+
expect(objSnakeToCamel(snakeObj)).toEqual(camelObj);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('Camel-Snake Arrays', () => {
|
|
53
|
+
const camelArr = ['camelToSnake', { camelToSnake: { camelToSnake: null } }];
|
|
54
|
+
const snakeArr = ['camel_to_snake', { camel_to_snake: { camel_to_snake: null } }];
|
|
55
|
+
expect(objCamelToSnake(camelArr)).toEqual(snakeArr);
|
|
56
|
+
expect(objSnakeToCamel(snakeArr)).toEqual(camelArr);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('Camel-to-Snake Object skips passed keys', () => {
|
|
60
|
+
const skippedKeys = ['skippedKey'];
|
|
61
|
+
const camelArr = { camelToSnake: null, skippedKey: null };
|
|
62
|
+
const snakeArr = { camel_to_snake: null, skippedKey: null };
|
|
63
|
+
expect(objCamelToSnake(camelArr, skippedKeys)).toEqual(snakeArr);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('Snake-to-Camel Object skips passed keys', () => {
|
|
67
|
+
const skippedKeys = ['skipped_key'];
|
|
68
|
+
const camelArr = { camelToSnake: null, skipped_key: null };
|
|
69
|
+
const snakeArr = { camel_to_snake: null, skipped_key: null };
|
|
70
|
+
expect(objSnakeToCamel(snakeArr, skippedKeys)).toEqual(camelArr);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import convertDuration from '../convertDuration';
|
|
2
|
+
|
|
3
|
+
describe('Case converters', () => {
|
|
4
|
+
it('duration from sec value', () => {
|
|
5
|
+
const time = 111;
|
|
6
|
+
const duration = '00:01:51';
|
|
7
|
+
expect(convertDuration(time)).toBe(duration);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it('duration from sec string value', () => {
|
|
11
|
+
const time = '61';
|
|
12
|
+
const duration = '00:01:01';
|
|
13
|
+
expect(convertDuration(time)).toBe(duration);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('duration from false value', () => {
|
|
17
|
+
const time = null;
|
|
18
|
+
const duration = '00:00:00';
|
|
19
|
+
expect(convertDuration(time)).toBe(duration);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import debounce from '../debounce';
|
|
2
|
+
|
|
3
|
+
describe('debounce', () => {
|
|
4
|
+
it('debounces call', async (done) => {
|
|
5
|
+
let isFnCalled = false;
|
|
6
|
+
let fn = () => { isFnCalled = true; };
|
|
7
|
+
fn = debounce(fn, 50);
|
|
8
|
+
fn();
|
|
9
|
+
expect(isFnCalled).toBeFalsy();
|
|
10
|
+
await setTimeout(() => {
|
|
11
|
+
expect(isFnCalled).toBeTruthy();
|
|
12
|
+
done();
|
|
13
|
+
}, 100);
|
|
14
|
+
});
|
|
15
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import editProxy from '../editProxy';
|
|
2
|
+
|
|
3
|
+
describe('editProxy', () => {
|
|
4
|
+
it('correctly updates _dirty prop at object property change', () => {
|
|
5
|
+
const object = editProxy({ value: 'jest', _dirty: false });
|
|
6
|
+
object.value = 'upd jest';
|
|
7
|
+
expect(object._dirty).toBe(true);
|
|
8
|
+
});
|
|
9
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import isEmpty from '../isEmpty';
|
|
2
|
+
|
|
3
|
+
describe('isEmpty', () => {
|
|
4
|
+
it('falsy cases (not empty)', () => {
|
|
5
|
+
expect(isEmpty(['jest'])).toBeFalsy();
|
|
6
|
+
expect(isEmpty({ jest: 'jest' })).toBeFalsy();
|
|
7
|
+
expect(isEmpty(1)).toBeFalsy();
|
|
8
|
+
expect(isEmpty('jest')).toBeFalsy();
|
|
9
|
+
});
|
|
10
|
+
it('truthy cases (empty)', () => {
|
|
11
|
+
expect(isEmpty([])).toBeTruthy();
|
|
12
|
+
expect(isEmpty({})).toBeTruthy();
|
|
13
|
+
expect(isEmpty(0)).toBeTruthy();
|
|
14
|
+
expect(isEmpty('')).toBeTruthy();
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import prettifyFileSize from '../prettifyFileSize';
|
|
2
|
+
|
|
3
|
+
describe('prettifyFileSize', () => {
|
|
4
|
+
it('prettifies bytes to kb\'s', () => {
|
|
5
|
+
const size = 1025;
|
|
6
|
+
expect(prettifyFileSize(size)).toBe('1 Kb');
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it('prettifies bytes to mb\'s', () => {
|
|
10
|
+
const size = 1205 ** 2;
|
|
11
|
+
expect(prettifyFileSize(size)).toBe('1.38 Mb');
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('handles 0 size', () => {
|
|
15
|
+
const size = 0;
|
|
16
|
+
expect(prettifyFileSize(size)).toBe('0');
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import prettifyTime from '../prettifyTime';
|
|
2
|
+
|
|
3
|
+
describe('prettifyTime', () => {
|
|
4
|
+
it('prettifies date-format time', () => {
|
|
5
|
+
const time = new Date(0);
|
|
6
|
+
expect(prettifyTime(time)).toBeTruthy();
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it('prettifies number-format time', () => {
|
|
10
|
+
const time = 0;
|
|
11
|
+
expect(prettifyTime(time)).toBeTruthy();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('prettifies string-format time', () => {
|
|
15
|
+
const time = '0';
|
|
16
|
+
expect(prettifyTime(time)).toBeTruthy();
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import preventHiddenPageCallsDecorator from '../preventHiddenPageCallsDecorator';
|
|
2
|
+
|
|
3
|
+
describe('preventHiddenPageCallsDecorator', () => {
|
|
4
|
+
it('prevents call on hidden page', () => {
|
|
5
|
+
let isFnCalled = false;
|
|
6
|
+
let fn = () => { isFnCalled = true; };
|
|
7
|
+
fn = preventHiddenPageCallsDecorator(fn, 50);
|
|
8
|
+
Object.defineProperty(document, 'hidden', {
|
|
9
|
+
configurable: true,
|
|
10
|
+
get() { return true; },
|
|
11
|
+
});
|
|
12
|
+
expect(isFnCalled).toBeFalsy();
|
|
13
|
+
fn();
|
|
14
|
+
expect(isFnCalled).toBeFalsy();
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as sortQueryAdapters from '../sortQueryAdapters';
|
|
2
|
+
|
|
3
|
+
test('sortToQueryAdapter', () => {
|
|
4
|
+
expect(sortQueryAdapters.sortToQueryAdapter('asc')).toBe('+');
|
|
5
|
+
expect(sortQueryAdapters.sortToQueryAdapter('desc')).toBe('-');
|
|
6
|
+
expect(sortQueryAdapters.sortToQueryAdapter(null)).toBe('');
|
|
7
|
+
});
|
|
8
|
+
test('queryToSortAdapter', () => {
|
|
9
|
+
expect(sortQueryAdapters.queryToSortAdapter('+')).toBe('asc');
|
|
10
|
+
expect(sortQueryAdapters.queryToSortAdapter('-')).toBe('desc');
|
|
11
|
+
expect(sortQueryAdapters.queryToSortAdapter('')).toBe(null);
|
|
12
|
+
});
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
export const snakeToCamel = (str) => str.replace(
|
|
2
|
+
/([a-z])([_])([a-z])/g,
|
|
3
|
+
(group, p1, p2, p3) => [p1, p3.toUpperCase()].join(''),
|
|
4
|
+
);
|
|
5
|
+
|
|
6
|
+
export const camelToSnake = (str) => str.replace(
|
|
7
|
+
/([a-z])([A-Z])/g,
|
|
8
|
+
(group, p1, p2) => [p1, '_', p2.toLowerCase()].join(''),
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
export const kebabToCamel = (str) => str.replace(
|
|
12
|
+
/([-_][a-z])/g,
|
|
13
|
+
(group) => group.toUpperCase()
|
|
14
|
+
.replace('-', ''),
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
export const camelToKebab = (str) => str.replace(
|
|
18
|
+
/([A-Z])/g,
|
|
19
|
+
(group) => group.toLowerCase()
|
|
20
|
+
.replace('', '-'),
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
export const objSnakeToCamel = (obj, skipKeys = []) => {
|
|
24
|
+
if (!obj) return obj;
|
|
25
|
+
const newObj = {};
|
|
26
|
+
if (Array.isArray(obj)) {
|
|
27
|
+
return obj.map((value) => {
|
|
28
|
+
if (typeof value === 'object') {
|
|
29
|
+
return objSnakeToCamel(value, skipKeys);
|
|
30
|
+
} if (typeof value === 'string') return snakeToCamel(value);
|
|
31
|
+
return value; // number
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
Object.keys(obj)
|
|
35
|
+
.forEach((oldKey) => {
|
|
36
|
+
if (skipKeys.includes(oldKey)) {
|
|
37
|
+
newObj[oldKey] = obj[oldKey];
|
|
38
|
+
} else {
|
|
39
|
+
const newKey = snakeToCamel(oldKey);
|
|
40
|
+
let value = obj[oldKey];
|
|
41
|
+
if (Array.isArray(value) || (value !== null && value.constructor === Object)) {
|
|
42
|
+
value = objSnakeToCamel(value, skipKeys);
|
|
43
|
+
}
|
|
44
|
+
newObj[newKey] = value;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
return newObj;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const objCamelToSnake = (obj, skipKeys = []) => {
|
|
52
|
+
if (!obj) return obj;
|
|
53
|
+
const newObj = {};
|
|
54
|
+
if (Array.isArray(obj)) {
|
|
55
|
+
return obj.map((value) => {
|
|
56
|
+
if (typeof value === 'object') {
|
|
57
|
+
return objCamelToSnake(value, skipKeys);
|
|
58
|
+
} if (typeof value === 'string') return camelToSnake(value);
|
|
59
|
+
return value; // number
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
Object.keys(obj)
|
|
63
|
+
.forEach((oldKey) => {
|
|
64
|
+
if (skipKeys.includes(oldKey)) {
|
|
65
|
+
newObj[oldKey] = obj[oldKey];
|
|
66
|
+
} else {
|
|
67
|
+
const newKey = camelToSnake(oldKey);
|
|
68
|
+
let value = obj[oldKey];
|
|
69
|
+
if (Array.isArray(value) || (value !== null && value.constructor === Object)) {
|
|
70
|
+
value = objCamelToSnake(value, skipKeys);
|
|
71
|
+
}
|
|
72
|
+
newObj[newKey] = value;
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
return newObj;
|
|
77
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const convertDuration = (duration) => {
|
|
2
|
+
if (!duration) return '00:00:00';
|
|
3
|
+
|
|
4
|
+
let hour = `${Math.floor(duration / 3600)}`;
|
|
5
|
+
let min = `${Math.floor((duration % 3600) / 60)}`;
|
|
6
|
+
let sec = `${Math.floor((duration % 3600) % 60)}`;
|
|
7
|
+
|
|
8
|
+
if (hour.length === 1) hour = `0${hour}`;
|
|
9
|
+
if (min.length === 1) min = `0${min}`;
|
|
10
|
+
if (sec.length === 1) sec = `0${sec}`;
|
|
11
|
+
|
|
12
|
+
return `${hour}:${min}:${sec}`;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default convertDuration;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// checks if value is Falsy,
|
|
2
|
+
// including empty arrays or objects
|
|
3
|
+
const isEmpty = (value) => {
|
|
4
|
+
if (Array.isArray(value)) return !value.length;
|
|
5
|
+
if (typeof value === 'object') return !value || !Object.keys(value).length;
|
|
6
|
+
return !value;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export default isEmpty;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const prettifyFileSize = (size) => {
|
|
2
|
+
// eslint-disable-next-line no-param-reassign
|
|
3
|
+
if (typeof size === 'string') size = +size;
|
|
4
|
+
if (!size) return '0';
|
|
5
|
+
const k = 1024;
|
|
6
|
+
const sizes = ['b', 'Kb', 'Mb', 'Gb', 'Tb', 'Pb', 'Eb', 'Zb', 'Yb'];
|
|
7
|
+
const i = Math.floor(Math.log(size) / Math.log(k));
|
|
8
|
+
return `${parseFloat((size / k ** i).toFixed(2))} ${sizes[i]}`;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default prettifyFileSize;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const prettifyTime = (time) => {
|
|
2
|
+
let date;
|
|
3
|
+
if (time instanceof Date) date = time;
|
|
4
|
+
else if (typeof time === 'number') date = new Date(time);
|
|
5
|
+
else date = new Date(+time);
|
|
6
|
+
return date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export default prettifyTime;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export const SortSymbols = Object.freeze({
|
|
2
|
+
ASC: 'asc',
|
|
3
|
+
DESC: 'desc',
|
|
4
|
+
NONE: null,
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
export const sortToQueryAdapter = (order) => {
|
|
8
|
+
switch (order) {
|
|
9
|
+
case SortSymbols.ASC: return '+';
|
|
10
|
+
case SortSymbols.DESC: return '-';
|
|
11
|
+
default: return '';
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const queryToSortAdapter = (order) => {
|
|
16
|
+
switch (order) {
|
|
17
|
+
case '+': return SortSymbols.ASC;
|
|
18
|
+
case '-': return SortSymbols.DESC;
|
|
19
|
+
default: return SortSymbols.NONE;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export default class BaseStoreModule {
|
|
2
|
+
state = {};
|
|
3
|
+
|
|
4
|
+
getters = {};
|
|
5
|
+
|
|
6
|
+
actions = {};
|
|
7
|
+
|
|
8
|
+
mutations = {};
|
|
9
|
+
|
|
10
|
+
modules = {};
|
|
11
|
+
|
|
12
|
+
attachAPIModule(APIModule) {
|
|
13
|
+
this._APIModule = APIModule;
|
|
14
|
+
return this;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
generateAPIActions() {
|
|
18
|
+
if (!this._APIModule) throw new ReferenceError('attach API module first!');
|
|
19
|
+
this.actions.GET_LIST = (context, params = {}) => this._APIModule.getList({ ...context.state, ...params });
|
|
20
|
+
this.actions.GET_ITEM = (context, params = {}) => this._APIModule.get({ ...context.state, ...params });
|
|
21
|
+
this.actions.POST_ITEM = (context) => this._APIModule.add(context.state);
|
|
22
|
+
this.actions.PATCH_ITEM = (context, { id, changes }) => (this._APIModule.patch({ ...context.state, id, changes }));
|
|
23
|
+
this.actions.UPD_ITEM = (context) => this._APIModule.update(context.state);
|
|
24
|
+
this.actions.DELETE_ITEM = (context, id) => this._APIModule.delete({ ...context.state, id });
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
setChildModules(modules) {
|
|
29
|
+
this.modules = modules;
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
getModule({
|
|
34
|
+
state = {},
|
|
35
|
+
getters = {},
|
|
36
|
+
actions = {},
|
|
37
|
+
mutations = {},
|
|
38
|
+
namespaced = true,
|
|
39
|
+
} = {}) {
|
|
40
|
+
return {
|
|
41
|
+
namespaced,
|
|
42
|
+
state: { ...this.state, ...state },
|
|
43
|
+
getters: { ...this.getters, ...getters },
|
|
44
|
+
actions: { ...this.actions, ...actions },
|
|
45
|
+
mutations: { ...this.mutations, ...mutations },
|
|
46
|
+
modules: this.modules,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import BaseStoreModule from '../BaseStoreModule';
|
|
2
|
+
|
|
3
|
+
const APIModule = {
|
|
4
|
+
getList: jest.fn(),
|
|
5
|
+
get: jest.fn(),
|
|
6
|
+
add: jest.fn(),
|
|
7
|
+
update: jest.fn(),
|
|
8
|
+
patch: jest.fn(),
|
|
9
|
+
delete: jest.fn(),
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
describe('Base Store Module', () => {
|
|
13
|
+
let module;
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
module = new BaseStoreModule();
|
|
16
|
+
});
|
|
17
|
+
it('attaches api module and generates API actions from it', () => {
|
|
18
|
+
const _module = module
|
|
19
|
+
.attachAPIModule(APIModule)
|
|
20
|
+
.generateAPIActions()
|
|
21
|
+
.getModule();
|
|
22
|
+
expect(_module.actions.GET_LIST).toBeTruthy();
|
|
23
|
+
expect(_module.actions.GET_ITEM).toBeTruthy();
|
|
24
|
+
expect(_module.actions.POST_ITEM).toBeTruthy();
|
|
25
|
+
expect(_module.actions.PATCH_ITEM).toBeTruthy();
|
|
26
|
+
expect(_module.actions.UPD_ITEM).toBeTruthy();
|
|
27
|
+
expect(_module.actions.DELETE_ITEM).toBeTruthy();
|
|
28
|
+
});
|
|
29
|
+
it('generated GET_LIST correctly gets passed params', () => {
|
|
30
|
+
const state = { jest: 'jest' };
|
|
31
|
+
const params = { jest2: 'jest1' };
|
|
32
|
+
const context = { state };
|
|
33
|
+
const expectedParams = { jest: 'jest', jest2: 'jest1' };
|
|
34
|
+
const _module = module
|
|
35
|
+
.attachAPIModule(APIModule)
|
|
36
|
+
.generateAPIActions()
|
|
37
|
+
.getModule();
|
|
38
|
+
_module.actions.GET_LIST(context, params);
|
|
39
|
+
expect(APIModule.getList).toHaveBeenCalledWith(expectedParams);
|
|
40
|
+
});
|
|
41
|
+
it('generated GET_ITEM correctly gets passed params', () => {
|
|
42
|
+
const state = { jest: 'jest' };
|
|
43
|
+
const params = { jest2: 'jest1' };
|
|
44
|
+
const context = { state };
|
|
45
|
+
const expectedParams = { jest: 'jest', jest2: 'jest1' };
|
|
46
|
+
const _module = module
|
|
47
|
+
.attachAPIModule(APIModule)
|
|
48
|
+
.generateAPIActions()
|
|
49
|
+
.getModule();
|
|
50
|
+
_module.actions.GET_ITEM(context, params);
|
|
51
|
+
expect(APIModule.get).toHaveBeenCalledWith(expectedParams);
|
|
52
|
+
});
|
|
53
|
+
it('generated POST_ITEM correctly gets passed params', () => {
|
|
54
|
+
const state = { jest: 'jest' };
|
|
55
|
+
const context = { state };
|
|
56
|
+
const expectedParams = { jest: 'jest' };
|
|
57
|
+
const _module = module
|
|
58
|
+
.attachAPIModule(APIModule)
|
|
59
|
+
.generateAPIActions()
|
|
60
|
+
.getModule();
|
|
61
|
+
_module.actions.POST_ITEM(context);
|
|
62
|
+
expect(APIModule.add).toHaveBeenCalledWith(expectedParams);
|
|
63
|
+
});
|
|
64
|
+
it('generated PATCH_ITEM correctly gets passed params', () => {
|
|
65
|
+
const state = { jest: 'jest' };
|
|
66
|
+
const params = { id: '1', changes: { jest: 'my change!' } };
|
|
67
|
+
const context = { state };
|
|
68
|
+
const expectedParams = { jest: 'jest', id: '1', changes: { jest: 'my change!' } };
|
|
69
|
+
const _module = module
|
|
70
|
+
.attachAPIModule(APIModule)
|
|
71
|
+
.generateAPIActions()
|
|
72
|
+
.getModule();
|
|
73
|
+
_module.actions.PATCH_ITEM(context, params);
|
|
74
|
+
expect(APIModule.patch).toHaveBeenCalledWith(expectedParams);
|
|
75
|
+
});
|
|
76
|
+
it('generated UPD_ITEM correctly gets passed params', () => {
|
|
77
|
+
const state = { jest: 'jest' };
|
|
78
|
+
const context = { state };
|
|
79
|
+
const expectedParams = { jest: 'jest' };
|
|
80
|
+
const _module = module
|
|
81
|
+
.attachAPIModule(APIModule)
|
|
82
|
+
.generateAPIActions()
|
|
83
|
+
.getModule();
|
|
84
|
+
_module.actions.UPD_ITEM(context);
|
|
85
|
+
expect(APIModule.update).toHaveBeenCalledWith(expectedParams);
|
|
86
|
+
});
|
|
87
|
+
it('generated DELETE_ITEM correctly gets passed params', () => {
|
|
88
|
+
const state = { jest: 'jest' };
|
|
89
|
+
const params = '1';
|
|
90
|
+
const context = { state };
|
|
91
|
+
const expectedParams = { jest: 'jest', id: '1' };
|
|
92
|
+
const _module = module
|
|
93
|
+
.attachAPIModule(APIModule)
|
|
94
|
+
.generateAPIActions()
|
|
95
|
+
.getModule();
|
|
96
|
+
_module.actions.DELETE_ITEM(context, params);
|
|
97
|
+
expect(APIModule.delete).toHaveBeenCalledWith(expectedParams);
|
|
98
|
+
});
|
|
99
|
+
it('sets child modules', () => {
|
|
100
|
+
const jest = { state: 'jest' };
|
|
101
|
+
const _module = module.setChildModules({ jest }).getModule();
|
|
102
|
+
expect(_module.modules).toEqual({ jest });
|
|
103
|
+
});
|
|
104
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import getNamespacedState from '../getNamespacedState';
|
|
2
|
+
|
|
3
|
+
describe('getNamespacedState', () => {
|
|
4
|
+
const searchedValue = 'jest!';
|
|
5
|
+
const state = { lvl1: { lvl2: { lvl3: searchedValue } } };
|
|
6
|
+
|
|
7
|
+
it('correctly returns nested object values', () => {
|
|
8
|
+
const namespace = 'lvl1/lvl2/lvl3';
|
|
9
|
+
expect(getNamespacedState(state, namespace)).toBe(searchedValue);
|
|
10
|
+
});
|
|
11
|
+
});
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
-
<path d="M11.5049 14.7841L7.20524 10.2583C6.93159 9.97038 6.93159 9.5036 7.20524 9.21584C7.47865 8.92805 7.9221 8.92805 8.19549 9.21584L12.0001 13.2205L15.8045 9.21595C16.078 8.92817 16.5214 8.92817 16.7949 9.21595C17.0684 9.50374 17.0684 9.97049 16.7949 10.2584L12.4951 14.7842C12.3583 14.9281 12.1792 15 12.0001 15C11.8209 15 11.6417 14.928 11.5049 14.7841Z" fill="black"/>
|
|
3
|
-
</svg>
|