@northern.tech/store 0.1.1 → 0.1.3
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/dist/actions.d.mts +95 -0
- package/dist/actions.d.ts +95 -0
- package/dist/actions.js +1746 -0
- package/dist/actions.js.map +1 -0
- package/dist/actions.mjs +21 -0
- package/dist/actions.mjs.map +1 -0
- package/dist/api/general-api.d.mts +21 -0
- package/dist/api/general-api.d.ts +21 -0
- package/dist/api/general-api.js +1002 -0
- package/dist/api/general-api.js.map +1 -0
- package/dist/api/general-api.mjs +18 -0
- package/dist/api/general-api.mjs.map +1 -0
- package/dist/api/types/Address.ts +6 -0
- package/dist/api/types/AddressUpdate.ts +12 -0
- package/dist/api/types/AuthSet.ts +37 -0
- package/{api/types/AuthSet.ts → dist/api/types/AuthSetIot_manager.ts} +2 -2
- package/dist/api/types/BillingProfile.ts +37 -0
- package/dist/api/types/BillingProfileUpdate.ts +37 -0
- package/{api → dist/api}/types/BinaryDeltaLimits.ts +6 -0
- package/{api → dist/api}/types/BoundingBox.ts +1 -3
- package/dist/api/types/Deployment.ts +45 -0
- package/{api → dist/api}/types/DeploymentAggregation.ts +1 -3
- package/{api → dist/api}/types/DeploymentAggregationItem.ts +1 -3
- package/{api → dist/api}/types/DeploymentAggregationTerm.ts +1 -2
- package/{api → dist/api}/types/DeploymentAggregationTerms.ts +1 -3
- package/{api → dist/api}/types/DeploymentAttributeProjection.ts +1 -2
- package/{api → dist/api}/types/DeploymentDeployments.ts +4 -5
- package/{api → dist/api}/types/DeploymentFilterTerm.ts +1 -3
- package/dist/api/types/DeploymentPhaseDeployments.ts +23 -0
- package/{api → dist/api}/types/DeploymentSearchTerms.ts +1 -3
- package/{api → dist/api}/types/DeploymentSortTerm.ts +1 -3
- package/dist/api/types/DeploymentStatisticsDeployments.ts +15 -0
- package/dist/api/types/DeploymentStatusStatisticsDeployments.ts +54 -0
- package/dist/api/types/Device.ts +20 -0
- package/{api → dist/api}/types/DeviceAggregation.ts +1 -3
- package/{api → dist/api}/types/DeviceAggregationItem.ts +1 -3
- package/{api → dist/api}/types/DeviceAggregationTerm.ts +1 -2
- package/{api → dist/api}/types/DeviceAggregationTerms.ts +1 -3
- package/{api → dist/api}/types/DeviceAttribute.ts +1 -2
- package/{api → dist/api}/types/DeviceAttributeProjection.ts +1 -2
- package/{api/types/Device.ts → dist/api/types/DeviceDeployments.ts} +1 -1
- package/{api → dist/api}/types/DeviceFilterAttribute.ts +1 -2
- package/{api → dist/api}/types/DeviceFilterTerm.ts +1 -3
- package/{api → dist/api}/types/DeviceSearchTerms.ts +1 -3
- package/{api → dist/api}/types/DeviceSortTerm.ts +1 -3
- package/{api → dist/api}/types/Error.ts +1 -1
- package/{api/types/FilterInventory.ts → dist/api/types/Filter.ts} +3 -4
- package/{api/types/Filter.ts → dist/api/types/FilterInventory.ts} +1 -1
- package/dist/api/types/FilterPredicate.ts +48 -0
- package/{api/types/FilterPredicate.ts → dist/api/types/FilterPredicateInventory.ts} +3 -3
- package/{api → dist/api}/types/GeoBoundingBox.ts +1 -3
- package/{api → dist/api}/types/GeoBoundingBoxFilter.ts +1 -2
- package/{api → dist/api}/types/GeoDistance.ts +1 -3
- package/{api → dist/api}/types/GeoDistanceFilter.ts +1 -3
- package/{api → dist/api}/types/GeoPoint.ts +1 -2
- package/{api → dist/api}/types/Integration.ts +6 -0
- package/{api → dist/api}/types/MenderTypes.ts +41 -11
- package/{api → dist/api}/types/NewDeploymentV2.ts +3 -0
- package/{api → dist/api}/types/NewTenant.ts +16 -8
- package/{api → dist/api}/types/Object.ts +3 -0
- package/{api → dist/api}/types/PreAuthSet.ts +1 -1
- package/{api → dist/api}/types/Settings.ts +3 -3
- package/{api → dist/api}/types/Status.ts +5 -4
- package/{api → dist/api}/types/StatusTenantadm.ts +1 -3
- package/dist/api/types/Tenant.ts +21 -0
- package/{api → dist/api}/types/TenantTenantadm.ts +16 -0
- package/dist/api/types/UpdateChildTenant.ts +17 -0
- package/{api → dist/api}/types/UpdateDeployments.ts +1 -1
- package/{api → dist/api}/types/UpgradeCompleteRequest.ts +2 -0
- package/{api → dist/api}/types/UserWithTenantInfo.ts +7 -3
- package/dist/api/users-api.d.mts +16 -0
- package/dist/api/users-api.d.ts +16 -0
- package/dist/api/users-api.js +1026 -0
- package/dist/api/users-api.js.map +1 -0
- package/dist/api/users-api.mjs +15 -0
- package/dist/api/users-api.mjs.map +1 -0
- package/dist/appSlice/constants.d.mts +210 -0
- package/dist/appSlice/constants.d.ts +210 -0
- package/dist/appSlice/constants.js +221 -0
- package/dist/appSlice/constants.js.map +1 -0
- package/dist/appSlice/constants.mjs +42 -0
- package/dist/appSlice/constants.mjs.map +1 -0
- package/dist/appSlice/index.d.mts +1557 -0
- package/dist/appSlice/index.d.ts +1557 -0
- package/dist/appSlice/index.js +1067 -0
- package/dist/appSlice/index.js.map +1 -0
- package/dist/appSlice/index.mjs +21 -0
- package/dist/appSlice/index.mjs.map +1 -0
- package/dist/appSlice/selectors.d.mts +91 -0
- package/dist/appSlice/selectors.d.ts +91 -0
- package/dist/appSlice/selectors.js +90 -0
- package/dist/appSlice/selectors.js.map +1 -0
- package/dist/appSlice/selectors.mjs +20 -0
- package/dist/appSlice/selectors.mjs.map +1 -0
- package/dist/appSlice/thunks.d.mts +46 -0
- package/dist/appSlice/thunks.d.ts +46 -0
- package/dist/appSlice/thunks.js +5655 -0
- package/dist/appSlice/thunks.js.map +1 -0
- package/dist/appSlice/thunks.mjs +45 -0
- package/dist/appSlice/thunks.mjs.map +1 -0
- package/dist/auth.d.mts +17 -0
- package/dist/auth.d.ts +17 -0
- package/dist/auth.js +985 -0
- package/dist/auth.js.map +1 -0
- package/dist/auth.mjs +23 -0
- package/dist/auth.mjs.map +1 -0
- package/dist/chunk-6667TCAJ.mjs +135 -0
- package/dist/chunk-6667TCAJ.mjs.map +1 -0
- package/{releasesSlice/index.ts → dist/chunk-7E7KJHY3.mjs} +33 -32
- package/dist/chunk-7E7KJHY3.mjs.map +1 -0
- package/{usersSlice/index.ts → dist/chunk-BJSH2G7W.mjs} +39 -58
- package/dist/chunk-BJSH2G7W.mjs.map +1 -0
- package/dist/chunk-BOSBROA3.mjs +168 -0
- package/dist/chunk-BOSBROA3.mjs.map +1 -0
- package/dist/chunk-BRHSKNFC.mjs +70 -0
- package/dist/chunk-BRHSKNFC.mjs.map +1 -0
- package/dist/chunk-C2YZYTJ6.mjs +37 -0
- package/dist/chunk-C2YZYTJ6.mjs.map +1 -0
- package/dist/chunk-DZBVTSIX.mjs +55 -0
- package/dist/chunk-DZBVTSIX.mjs.map +1 -0
- package/{appSlice/index.ts → dist/chunk-F37LUTBX.mjs} +58 -68
- package/dist/chunk-F37LUTBX.mjs.map +1 -0
- package/dist/chunk-G32LAKW4.mjs +239 -0
- package/dist/chunk-G32LAKW4.mjs.map +1 -0
- package/dist/chunk-G3I53JGW.mjs +243 -0
- package/dist/chunk-G3I53JGW.mjs.map +1 -0
- package/dist/chunk-G4FGNSV3.mjs +13 -0
- package/dist/chunk-G4FGNSV3.mjs.map +1 -0
- package/dist/chunk-G7LATUT6.mjs +110 -0
- package/dist/chunk-G7LATUT6.mjs.map +1 -0
- package/dist/chunk-H2PQQMRY.mjs +7 -0
- package/dist/chunk-H2PQQMRY.mjs.map +1 -0
- package/{devicesSlice/index.ts → dist/chunk-HRWZJQMH.mjs} +57 -77
- package/dist/chunk-HRWZJQMH.mjs.map +1 -0
- package/dist/chunk-HVHZG2H4.mjs +56 -0
- package/dist/chunk-HVHZG2H4.mjs.map +1 -0
- package/dist/chunk-HXPYJ6QN.mjs +75 -0
- package/dist/chunk-HXPYJ6QN.mjs.map +1 -0
- package/dist/chunk-IPPIKGIB.mjs +35 -0
- package/dist/chunk-IPPIKGIB.mjs.map +1 -0
- package/dist/chunk-IU4OXOPA.mjs +46 -0
- package/dist/chunk-IU4OXOPA.mjs.map +1 -0
- package/dist/chunk-IVSYYXTC.mjs +36 -0
- package/dist/chunk-IVSYYXTC.mjs.map +1 -0
- package/{onboardingSlice/index.ts → dist/chunk-M4U5R7A4.mjs} +19 -22
- package/dist/chunk-M4U5R7A4.mjs.map +1 -0
- package/dist/chunk-N7G6QK2E.mjs +414 -0
- package/dist/chunk-N7G6QK2E.mjs.map +1 -0
- package/dist/chunk-O6O3D52B.mjs +39 -0
- package/dist/chunk-O6O3D52B.mjs.map +1 -0
- package/dist/chunk-QBKCUIWO.mjs +7 -0
- package/dist/chunk-QBKCUIWO.mjs.map +1 -0
- package/dist/chunk-R2GBNXLV.mjs +57 -0
- package/dist/chunk-R2GBNXLV.mjs.map +1 -0
- package/dist/chunk-RH6ONMG7.mjs +65 -0
- package/dist/chunk-RH6ONMG7.mjs.map +1 -0
- package/dist/chunk-RQOE5OOT.mjs +284 -0
- package/dist/chunk-RQOE5OOT.mjs.map +1 -0
- package/dist/chunk-TD45YTYK.mjs +108 -0
- package/dist/chunk-TD45YTYK.mjs.map +1 -0
- package/dist/chunk-V32GTKOS.mjs +1 -0
- package/dist/chunk-V32GTKOS.mjs.map +1 -0
- package/dist/chunk-XWBD7VOK.mjs +93 -0
- package/dist/chunk-XWBD7VOK.mjs.map +1 -0
- package/dist/chunk-XYVPYFSM.mjs +106 -0
- package/dist/chunk-XYVPYFSM.mjs.map +1 -0
- package/dist/chunk-YNVSU3AA.mjs +2977 -0
- package/dist/chunk-YNVSU3AA.mjs.map +1 -0
- package/dist/chunk-ZIYGEXSJ.mjs +145 -0
- package/dist/chunk-ZIYGEXSJ.mjs.map +1 -0
- package/dist/chunk-ZNST5R6O.mjs +658 -0
- package/dist/chunk-ZNST5R6O.mjs.map +1 -0
- package/dist/commonConstants.d.mts +248 -0
- package/dist/commonConstants.d.ts +248 -0
- package/dist/commonConstants.js +303 -0
- package/dist/commonConstants.js.map +1 -0
- package/dist/commonConstants.mjs +40 -0
- package/dist/commonConstants.mjs.map +1 -0
- package/dist/commonSelectors.d.mts +896 -0
- package/dist/commonSelectors.d.ts +896 -0
- package/dist/commonSelectors.js +1482 -0
- package/dist/commonSelectors.js.map +1 -0
- package/dist/commonSelectors.mjs +54 -0
- package/dist/commonSelectors.mjs.map +1 -0
- package/dist/constants.d.mts +12 -0
- package/dist/constants.d.ts +12 -0
- package/dist/constants.js +1246 -0
- package/dist/constants.js.map +1 -0
- package/dist/constants.mjs +219 -0
- package/dist/constants.mjs.map +1 -0
- package/dist/deploymentsSlice/constants.d.mts +142 -0
- package/dist/deploymentsSlice/constants.d.ts +142 -0
- package/dist/deploymentsSlice/constants.js +969 -0
- package/dist/deploymentsSlice/constants.js.map +1 -0
- package/dist/deploymentsSlice/constants.mjs +42 -0
- package/dist/deploymentsSlice/constants.mjs.map +1 -0
- package/dist/deploymentsSlice/index.d.mts +2373 -0
- package/dist/deploymentsSlice/index.d.ts +2373 -0
- package/dist/deploymentsSlice/index.js +1053 -0
- package/dist/deploymentsSlice/index.js.map +1 -0
- package/dist/deploymentsSlice/index.mjs +21 -0
- package/dist/deploymentsSlice/index.mjs.map +1 -0
- package/dist/deploymentsSlice/selectors.d.mts +59 -0
- package/dist/deploymentsSlice/selectors.d.ts +59 -0
- package/dist/deploymentsSlice/selectors.js +969 -0
- package/dist/deploymentsSlice/selectors.js.map +1 -0
- package/dist/deploymentsSlice/selectors.mjs +25 -0
- package/dist/deploymentsSlice/selectors.mjs.map +1 -0
- package/dist/deploymentsSlice/thunks.d.mts +202 -0
- package/dist/deploymentsSlice/thunks.d.ts +202 -0
- package/dist/deploymentsSlice/thunks.js +5671 -0
- package/dist/deploymentsSlice/thunks.js.map +1 -0
- package/dist/deploymentsSlice/thunks.mjs +63 -0
- package/dist/deploymentsSlice/thunks.mjs.map +1 -0
- package/dist/devicesSlice/constants.d.mts +44 -0
- package/dist/devicesSlice/constants.d.ts +44 -0
- package/dist/devicesSlice/constants.js +969 -0
- package/dist/devicesSlice/constants.js.map +1 -0
- package/dist/devicesSlice/constants.mjs +40 -0
- package/dist/devicesSlice/constants.mjs.map +1 -0
- package/dist/devicesSlice/index.d.mts +2223 -0
- package/dist/devicesSlice/index.d.ts +2223 -0
- package/dist/devicesSlice/index.js +1109 -0
- package/dist/devicesSlice/index.js.map +1 -0
- package/dist/devicesSlice/index.mjs +21 -0
- package/dist/devicesSlice/index.mjs.map +1 -0
- package/dist/devicesSlice/selectors.d.mts +261 -0
- package/dist/devicesSlice/selectors.d.ts +261 -0
- package/dist/devicesSlice/selectors.js +1084 -0
- package/dist/devicesSlice/selectors.js.map +1 -0
- package/dist/devicesSlice/selectors.mjs +53 -0
- package/dist/devicesSlice/selectors.mjs.map +1 -0
- package/dist/devicesSlice/thunks.d.mts +742 -0
- package/dist/devicesSlice/thunks.d.ts +742 -0
- package/dist/devicesSlice/thunks.js +5743 -0
- package/dist/devicesSlice/thunks.js.map +1 -0
- package/dist/devicesSlice/thunks.mjs +135 -0
- package/dist/devicesSlice/thunks.mjs.map +1 -0
- package/dist/monitorSlice/constants.d.mts +6 -0
- package/dist/monitorSlice/constants.d.ts +6 -0
- package/dist/monitorSlice/constants.js +919 -0
- package/dist/monitorSlice/constants.js.map +1 -0
- package/dist/monitorSlice/constants.mjs +14 -0
- package/dist/monitorSlice/constants.mjs.map +1 -0
- package/dist/monitorSlice/index.d.mts +291 -0
- package/dist/monitorSlice/index.d.ts +291 -0
- package/dist/monitorSlice/index.js +971 -0
- package/dist/monitorSlice/index.js.map +1 -0
- package/dist/monitorSlice/index.mjs +21 -0
- package/dist/monitorSlice/index.mjs.map +1 -0
- package/dist/monitorSlice/selectors.d.mts +3 -0
- package/dist/monitorSlice/selectors.d.ts +3 -0
- package/dist/monitorSlice/selectors.js +31 -0
- package/dist/monitorSlice/selectors.js.map +1 -0
- package/dist/monitorSlice/selectors.mjs +8 -0
- package/dist/monitorSlice/selectors.mjs.map +1 -0
- package/dist/monitorSlice/thunks.d.mts +71 -0
- package/dist/monitorSlice/thunks.d.ts +71 -0
- package/dist/monitorSlice/thunks.js +2531 -0
- package/dist/monitorSlice/thunks.js.map +1 -0
- package/dist/monitorSlice/thunks.mjs +44 -0
- package/dist/monitorSlice/thunks.mjs.map +1 -0
- package/dist/onboardingSlice/constants.d.mts +23 -0
- package/dist/onboardingSlice/constants.d.ts +23 -0
- package/dist/onboardingSlice/constants.js +71 -0
- package/dist/onboardingSlice/constants.js.map +1 -0
- package/dist/onboardingSlice/constants.mjs +10 -0
- package/dist/onboardingSlice/constants.mjs.map +1 -0
- package/dist/onboardingSlice/index.d.mts +237 -0
- package/dist/onboardingSlice/index.d.ts +237 -0
- package/dist/onboardingSlice/index.js +94 -0
- package/dist/onboardingSlice/index.js.map +1 -0
- package/dist/onboardingSlice/index.mjs +16 -0
- package/dist/onboardingSlice/index.mjs.map +1 -0
- package/dist/onboardingSlice/selectors.d.mts +3 -0
- package/dist/onboardingSlice/selectors.d.ts +3 -0
- package/dist/onboardingSlice/selectors.js +31 -0
- package/dist/onboardingSlice/selectors.js.map +1 -0
- package/dist/onboardingSlice/selectors.mjs +8 -0
- package/dist/onboardingSlice/selectors.mjs.map +1 -0
- package/dist/onboardingSlice/thunks.d.mts +172 -0
- package/dist/onboardingSlice/thunks.d.ts +172 -0
- package/dist/onboardingSlice/thunks.js +5661 -0
- package/dist/onboardingSlice/thunks.js.map +1 -0
- package/dist/onboardingSlice/thunks.mjs +51 -0
- package/dist/onboardingSlice/thunks.mjs.map +1 -0
- package/dist/organizationSlice/constants.d.mts +134 -0
- package/dist/organizationSlice/constants.d.ts +134 -0
- package/dist/organizationSlice/constants.js +978 -0
- package/dist/organizationSlice/constants.js.map +1 -0
- package/dist/organizationSlice/constants.mjs +34 -0
- package/dist/organizationSlice/constants.mjs.map +1 -0
- package/dist/organizationSlice/index.d.mts +1097 -0
- package/dist/organizationSlice/index.d.ts +1097 -0
- package/dist/organizationSlice/index.js +1015 -0
- package/dist/organizationSlice/index.js.map +1 -0
- package/dist/organizationSlice/index.mjs +21 -0
- package/dist/organizationSlice/index.mjs.map +1 -0
- package/dist/organizationSlice/selectors.d.mts +134 -0
- package/dist/organizationSlice/selectors.d.ts +134 -0
- package/dist/organizationSlice/selectors.js +977 -0
- package/dist/organizationSlice/selectors.js.map +1 -0
- package/dist/organizationSlice/selectors.mjs +39 -0
- package/dist/organizationSlice/selectors.mjs.map +1 -0
- package/dist/organizationSlice/thunks.d.mts +502 -0
- package/dist/organizationSlice/thunks.d.ts +502 -0
- package/dist/organizationSlice/thunks.js +5709 -0
- package/dist/organizationSlice/thunks.js.map +1 -0
- package/dist/organizationSlice/thunks.mjs +101 -0
- package/dist/organizationSlice/thunks.mjs.map +1 -0
- package/dist/releasesSlice/constants.d.mts +14 -0
- package/dist/releasesSlice/constants.d.ts +14 -0
- package/dist/releasesSlice/constants.js +40 -0
- package/dist/releasesSlice/constants.js.map +1 -0
- package/dist/releasesSlice/constants.mjs +14 -0
- package/dist/releasesSlice/constants.mjs.map +1 -0
- package/dist/releasesSlice/index.d.mts +483 -0
- package/dist/releasesSlice/index.d.ts +483 -0
- package/dist/releasesSlice/index.js +1034 -0
- package/dist/releasesSlice/index.js.map +1 -0
- package/dist/releasesSlice/index.mjs +21 -0
- package/dist/releasesSlice/index.mjs.map +1 -0
- package/dist/releasesSlice/selectors.d.mts +92 -0
- package/dist/releasesSlice/selectors.d.ts +92 -0
- package/dist/releasesSlice/selectors.js +967 -0
- package/dist/releasesSlice/selectors.js.map +1 -0
- package/dist/releasesSlice/selectors.mjs +28 -0
- package/dist/releasesSlice/selectors.mjs.map +1 -0
- package/dist/releasesSlice/thunks.d.mts +276 -0
- package/dist/releasesSlice/thunks.d.ts +276 -0
- package/dist/releasesSlice/thunks.js +2843 -0
- package/dist/releasesSlice/thunks.js.map +1 -0
- package/dist/releasesSlice/thunks.mjs +66 -0
- package/dist/releasesSlice/thunks.mjs.map +1 -0
- package/dist/selectors.d.mts +10 -0
- package/dist/selectors.d.ts +10 -0
- package/dist/selectors.js +1636 -0
- package/dist/selectors.js.map +1 -0
- package/dist/selectors.mjs +207 -0
- package/dist/selectors.mjs.map +1 -0
- package/dist/store.d.mts +2306 -0
- package/dist/store.d.ts +2306 -0
- package/dist/store.js +1877 -0
- package/dist/store.js.map +1 -0
- package/dist/store.mjs +32 -0
- package/dist/store.mjs.map +1 -0
- package/dist/storehooks.d.mts +4 -0
- package/dist/storehooks.d.ts +4 -0
- package/dist/storehooks.js +5844 -0
- package/dist/storehooks.js.map +1 -0
- package/dist/storehooks.mjs +265 -0
- package/dist/storehooks.mjs.map +1 -0
- package/dist/thunks.d.mts +12 -0
- package/dist/thunks.d.ts +12 -0
- package/dist/thunks.js +5973 -0
- package/dist/thunks.js.map +1 -0
- package/dist/thunks.mjs +363 -0
- package/dist/thunks.mjs.map +1 -0
- package/dist/usersSlice/constants.d.mts +635 -0
- package/dist/usersSlice/constants.d.ts +635 -0
- package/dist/usersSlice/constants.js +967 -0
- package/dist/usersSlice/constants.js.map +1 -0
- package/dist/usersSlice/constants.mjs +43 -0
- package/dist/usersSlice/constants.mjs.map +1 -0
- package/dist/usersSlice/index.d.mts +6993 -0
- package/dist/usersSlice/index.d.ts +6993 -0
- package/dist/usersSlice/index.js +1054 -0
- package/dist/usersSlice/index.js.map +1 -0
- package/dist/usersSlice/index.mjs +21 -0
- package/dist/usersSlice/index.mjs.map +1 -0
- package/dist/usersSlice/selectors.d.mts +209 -0
- package/dist/usersSlice/selectors.d.ts +209 -0
- package/dist/usersSlice/selectors.js +997 -0
- package/dist/usersSlice/selectors.js.map +1 -0
- package/dist/usersSlice/selectors.mjs +38 -0
- package/dist/usersSlice/selectors.mjs.map +1 -0
- package/dist/usersSlice/thunks.d.mts +881 -0
- package/dist/usersSlice/thunks.d.ts +881 -0
- package/dist/usersSlice/thunks.js +5717 -0
- package/dist/usersSlice/thunks.js.map +1 -0
- package/dist/usersSlice/thunks.mjs +109 -0
- package/dist/usersSlice/thunks.mjs.map +1 -0
- package/dist/utils.d.mts +60 -0
- package/dist/utils.d.ts +60 -0
- package/dist/utils.js +1160 -0
- package/dist/utils.js.map +1 -0
- package/dist/utils.mjs +49 -0
- package/dist/utils.mjs.map +1 -0
- package/package.json +22 -5
- package/.eslintrc.cjs +0 -9
- package/.prettierignore +0 -1
- package/CHANGELOG.md +0 -19
- package/actions.ts +0 -32
- package/api/general-api.test.ts +0 -51
- package/api/general-api.ts +0 -60
- package/api/types/Deployment.ts +0 -95
- package/api/types/DeviceDeployments.ts +0 -31
- package/api/types/FilterPredicateInventory.ts +0 -76
- package/api/types/Tenant.ts +0 -38
- package/api/users-api.ts +0 -34
- package/appSlice/constants.ts +0 -166
- package/appSlice/reducer.test.ts +0 -97
- package/appSlice/selectors.ts +0 -33
- package/appSlice/thunks.test.ts +0 -118
- package/appSlice/thunks.ts +0 -148
- package/auth.test.ts +0 -36
- package/auth.ts +0 -82
- package/commonConstants.tsx +0 -252
- package/commonSelectors.ts +0 -255
- package/constants.ts +0 -22
- package/deploymentsSlice/constants.ts +0 -175
- package/deploymentsSlice/index.ts +0 -145
- package/deploymentsSlice/reducer.test.ts +0 -108
- package/deploymentsSlice/selectors.ts +0 -58
- package/deploymentsSlice/thunks.test.ts +0 -425
- package/deploymentsSlice/thunks.ts +0 -382
- package/devicesSlice/constants.ts +0 -56
- package/devicesSlice/reducer.test.ts +0 -194
- package/devicesSlice/selectors.ts +0 -127
- package/devicesSlice/thunks.test.tsx +0 -1245
- package/devicesSlice/thunks.tsx +0 -1098
- package/monitorSlice/constants.ts +0 -17
- package/monitorSlice/index.ts +0 -65
- package/monitorSlice/reducer.test.ts +0 -79
- package/monitorSlice/selectors.ts +0 -15
- package/monitorSlice/thunks.test.ts +0 -112
- package/monitorSlice/thunks.ts +0 -101
- package/onboardingSlice/constants.ts +0 -53
- package/onboardingSlice/reducer.test.ts +0 -45
- package/onboardingSlice/selectors.ts +0 -15
- package/onboardingSlice/thunks.test.ts +0 -235
- package/onboardingSlice/thunks.ts +0 -142
- package/organizationSlice/constants.ts +0 -82
- package/organizationSlice/index.ts +0 -111
- package/organizationSlice/reducer.test.ts +0 -78
- package/organizationSlice/selectors.ts +0 -45
- package/organizationSlice/thunks.test.ts +0 -619
- package/organizationSlice/thunks.ts +0 -383
- package/releasesSlice/constants.ts +0 -18
- package/releasesSlice/reducer.test.ts +0 -78
- package/releasesSlice/selectors.ts +0 -33
- package/releasesSlice/thunks.test.ts +0 -389
- package/releasesSlice/thunks.ts +0 -379
- package/selectors.ts +0 -22
- package/store.ts +0 -89
- package/storehooks.test.tsx +0 -386
- package/storehooks.ts +0 -250
- package/thunks.ts +0 -21
- package/tsconfig.json +0 -11
- package/tsup.config.ts +0 -11
- package/usersSlice/constants.ts +0 -374
- package/usersSlice/reducer.test.ts +0 -141
- package/usersSlice/selectors.ts +0 -60
- package/usersSlice/thunks.test.ts +0 -660
- package/usersSlice/thunks.ts +0 -773
- package/utils.test.ts +0 -187
- package/utils.ts +0 -249
- /package/{api → dist/api}/types/AWSCredentials.ts +0 -0
- /package/{api → dist/api}/types/Actor.ts +0 -0
- /package/{api → dist/api}/types/Addon.ts +0 -0
- /package/{api → dist/api}/types/AddonTenantadm.ts +0 -0
- /package/{api → dist/api}/types/Alert.ts +0 -0
- /package/{api → dist/api}/types/AlertDetails.ts +0 -0
- /package/{api → dist/api}/types/AlertSubject.ts +0 -0
- /package/{api → dist/api}/types/ApiBurst.ts +0 -0
- /package/{api → dist/api}/types/ApiBurstTenantadm.ts +0 -0
- /package/{api → dist/api}/types/ApiLimits.ts +0 -0
- /package/{api → dist/api}/types/ApiLimitsTenantadm.ts +0 -0
- /package/{api → dist/api}/types/ApiQuota.ts +0 -0
- /package/{api → dist/api}/types/ApiQuotaTenantadm.ts +0 -0
- /package/{api → dist/api}/types/Artifact.ts +0 -0
- /package/{api → dist/api}/types/ArtifactDeployments.ts +0 -0
- /package/{api → dist/api}/types/ArtifactInfo.ts +0 -0
- /package/{api → dist/api}/types/ArtifactInfoDeployments.ts +0 -0
- /package/{api → dist/api}/types/ArtifactLink.ts +0 -0
- /package/{api → dist/api}/types/ArtifactTypeInfo.ts +0 -0
- /package/{api → dist/api}/types/ArtifactTypeInfoDeployments.ts +0 -0
- /package/{api → dist/api}/types/ArtifactUpdate.ts +0 -0
- /package/{api → dist/api}/types/ArtifactUploadLink.ts +0 -0
- /package/{api → dist/api}/types/Attribute.ts +0 -0
- /package/{api → dist/api}/types/AttributeInventory.ts +0 -0
- /package/{api → dist/api}/types/AuditLog.ts +0 -0
- /package/{api → dist/api}/types/AuthSetDeviceauth.ts +0 -0
- /package/{api → dist/api}/types/AutoAuthRequest.ts +0 -0
- /package/{api → dist/api}/types/AzureSharedAccessSecret.ts +0 -0
- /package/{api → dist/api}/types/BillingInfo.ts +0 -0
- /package/{api → dist/api}/types/BinaryDeltaConfiguration.ts +0 -0
- /package/{api → dist/api}/types/BinaryDeltaConfigurationDeployments.ts +0 -0
- /package/{api → dist/api}/types/BinaryDeltaLimitsDeployments.ts +0 -0
- /package/{api → dist/api}/types/CancelRequest.ts +0 -0
- /package/{api → dist/api}/types/CardData.ts +0 -0
- /package/{api → dist/api}/types/CardSetupData.ts +0 -0
- /package/{api → dist/api}/types/CheckoutData.ts +0 -0
- /package/{api → dist/api}/types/Configuration.ts +0 -0
- /package/{api → dist/api}/types/Count.ts +0 -0
- /package/{api → dist/api}/types/Credentials.ts +0 -0
- /package/{api → dist/api}/types/DBusSubsystem.ts +0 -0
- /package/{api → dist/api}/types/DeltaConfiguration.ts +0 -0
- /package/{api → dist/api}/types/DeltaConfigurationDeployments.ts +0 -0
- /package/{api → dist/api}/types/DeploymentAuditlogs.ts +0 -0
- /package/{api → dist/api}/types/DeploymentIdentifier.ts +0 -0
- /package/{api → dist/api}/types/DeploymentPhase.ts +0 -0
- /package/{api → dist/api}/types/DeploymentReporting.ts +0 -0
- /package/{api → dist/api}/types/DeploymentStatistics.ts +0 -0
- /package/{api → dist/api}/types/DeploymentStatusStatistics.ts +0 -0
- /package/{api → dist/api}/types/DeviceAuditlogs.ts +0 -0
- /package/{api → dist/api}/types/DeviceAuthEvent.ts +0 -0
- /package/{api → dist/api}/types/DeviceConfiguration.ts +0 -0
- /package/{api → dist/api}/types/DeviceDeployment.ts +0 -0
- /package/{api → dist/api}/types/DeviceDeviceauth.ts +0 -0
- /package/{api → dist/api}/types/DeviceInventory.ts +0 -0
- /package/{api → dist/api}/types/DeviceInventoryInventory.ts +0 -0
- /package/{api → dist/api}/types/DeviceReporting.ts +0 -0
- /package/{api → dist/api}/types/DeviceState.ts +0 -0
- /package/{api → dist/api}/types/DeviceStateDeviceconnect.ts +0 -0
- /package/{api → dist/api}/types/DeviceStateIot_manager.ts +0 -0
- /package/{api → dist/api}/types/DeviceStatus.ts +0 -0
- /package/{api → dist/api}/types/DeviceWithImage.ts +0 -0
- /package/{api → dist/api}/types/DirectUploadMetadata.ts +0 -0
- /package/{api → dist/api}/types/EmailVerificationCompletion.ts +0 -0
- /package/{api → dist/api}/types/EmailVerificationRequest.ts +0 -0
- /package/{api → dist/api}/types/ErrorAuditlogs.ts +0 -0
- /package/{api → dist/api}/types/ErrorDeployments.ts +0 -0
- /package/{api → dist/api}/types/ErrorDeviceauth.ts +0 -0
- /package/{api → dist/api}/types/ErrorDeviceconfig.ts +0 -0
- /package/{api → dist/api}/types/ErrorDeviceconnect.ts +0 -0
- /package/{api → dist/api}/types/ErrorDevicemonitor.ts +0 -0
- /package/{api → dist/api}/types/ErrorExt.ts +0 -0
- /package/{api → dist/api}/types/ErrorInventory.ts +0 -0
- /package/{api → dist/api}/types/ErrorIot_manager.ts +0 -0
- /package/{api → dist/api}/types/ErrorNotFound.ts +0 -0
- /package/{api → dist/api}/types/ErrorReporting.ts +0 -0
- /package/{api → dist/api}/types/ErrorTenantadm.ts +0 -0
- /package/{api → dist/api}/types/ErrorUseradm.ts +0 -0
- /package/{api → dist/api}/types/Event.ts +0 -0
- /package/{api → dist/api}/types/ExternalIdentity.ts +0 -0
- /package/{api → dist/api}/types/Features.ts +0 -0
- /package/{api → dist/api}/types/FileUpload.ts +0 -0
- /package/{api → dist/api}/types/FilterAttribute.ts +0 -0
- /package/{api → dist/api}/types/FilterDefinition.ts +0 -0
- /package/{api → dist/api}/types/FilterDeployments.ts +0 -0
- /package/{api → dist/api}/types/FilterPredicateDeployments.ts +0 -0
- /package/{api → dist/api}/types/Group.ts +0 -0
- /package/{api → dist/api}/types/HTTP.ts +0 -0
- /package/{api → dist/api}/types/IdentityData.ts +0 -0
- /package/{api → dist/api}/types/InputParameter.ts +0 -0
- /package/{api → dist/api}/types/JobStatus.ts +0 -0
- /package/{api → dist/api}/types/Limit.ts +0 -0
- /package/{api → dist/api}/types/LimitDeployments.ts +0 -0
- /package/{api → dist/api}/types/LimitDeviceauth.ts +0 -0
- /package/{api → dist/api}/types/LimitUseradm.ts +0 -0
- /package/{api → dist/api}/types/Limits.ts +0 -0
- /package/{api → dist/api}/types/LineDescriptor.ts +0 -0
- /package/{api → dist/api}/types/LogSubsystem.ts +0 -0
- /package/{api → dist/api}/types/LoginOptions.ts +0 -0
- /package/{api → dist/api}/types/ManagementAPIConfiguration.ts +0 -0
- /package/{api → dist/api}/types/MonitorConfiguration.ts +0 -0
- /package/{api → dist/api}/types/NewConfigurationDeployment.ts +0 -0
- /package/{api → dist/api}/types/NewConfigurationDeploymentResponse.ts +0 -0
- /package/{api → dist/api}/types/NewDeployment.ts +0 -0
- /package/{api → dist/api}/types/NewDeploymentForGroup.ts +0 -0
- /package/{api → dist/api}/types/NewDeploymentPhase.ts +0 -0
- /package/{api → dist/api}/types/NewDeploymentPhaseDeployments.ts +0 -0
- /package/{api → dist/api}/types/OwnUserUpdate.ts +0 -0
- /package/{api → dist/api}/types/PasswordResetCompletion.ts +0 -0
- /package/{api → dist/api}/types/PasswordResetRequest.ts +0 -0
- /package/{api → dist/api}/types/Permission.ts +0 -0
- /package/{api → dist/api}/types/PermissionObject.ts +0 -0
- /package/{api → dist/api}/types/PermissionSet.ts +0 -0
- /package/{api → dist/api}/types/PermissionSetWithScope.ts +0 -0
- /package/{api → dist/api}/types/PersonalAccessToken.ts +0 -0
- /package/{api → dist/api}/types/PersonalAccessTokenRequest.ts +0 -0
- /package/{api → dist/api}/types/Plan.ts +0 -0
- /package/{api → dist/api}/types/PlanBindingDetails.ts +0 -0
- /package/{api → dist/api}/types/PlanChangeRequest.ts +0 -0
- /package/{api → dist/api}/types/PlanLimits.ts +0 -0
- /package/{api → dist/api}/types/Release.ts +0 -0
- /package/{api → dist/api}/types/ReleaseDeployments.ts +0 -0
- /package/{api → dist/api}/types/ReleaseUpdate.ts +0 -0
- /package/{api → dist/api}/types/Releases.ts +0 -0
- /package/{api → dist/api}/types/ReleasesDeleteError.ts +0 -0
- /package/{api → dist/api}/types/ReleasesDeployments.ts +0 -0
- /package/{api → dist/api}/types/Role.ts +0 -0
- /package/{api → dist/api}/types/RolePermission.ts +0 -0
- /package/{api → dist/api}/types/RolePermissionObject.ts +0 -0
- /package/{api → dist/api}/types/RoleUseradm.ts +0 -0
- /package/{api → dist/api}/types/SAMLMetadata.ts +0 -0
- /package/{api → dist/api}/types/Scope.ts +0 -0
- /package/{api → dist/api}/types/SelectAttribute.ts +0 -0
- /package/{api → dist/api}/types/ServiceSubsystem.ts +0 -0
- /package/{api → dist/api}/types/SortCriteria.ts +0 -0
- /package/{api → dist/api}/types/SsoObject.ts +0 -0
- /package/{api → dist/api}/types/StatusDeviceauth.ts +0 -0
- /package/{api → dist/api}/types/StorageLimit.ts +0 -0
- /package/{api → dist/api}/types/SubscriptionData.ts +0 -0
- /package/{api → dist/api}/types/SupportRequest.ts +0 -0
- /package/{api → dist/api}/types/Tag.ts +0 -0
- /package/{api → dist/api}/types/Tags.ts +0 -0
- /package/{api → dist/api}/types/TaskResult.ts +0 -0
- /package/{api → dist/api}/types/TaskResultCLI.ts +0 -0
- /package/{api → dist/api}/types/TaskResultHTTPRequest.ts +0 -0
- /package/{api → dist/api}/types/TaskResultHTTPResponse.ts +0 -0
- /package/{api → dist/api}/types/TenantApiLimits.ts +0 -0
- /package/{api → dist/api}/types/TenantApiLimitsTenantadm.ts +0 -0
- /package/{api → dist/api}/types/TenantIdName.ts +0 -0
- /package/{api → dist/api}/types/TenantIdsData.ts +0 -0
- /package/{api → dist/api}/types/TenantInfo.ts +0 -0
- /package/{api → dist/api}/types/TenantShortInfo.ts +0 -0
- /package/{api → dist/api}/types/TenantsIdName.ts +0 -0
- /package/{api → dist/api}/types/Update.ts +0 -0
- /package/{api → dist/api}/types/UpdateFile.ts +0 -0
- /package/{api → dist/api}/types/UpdateFileDeployments.ts +0 -0
- /package/{api → dist/api}/types/UpdateTypes.ts +0 -0
- /package/{api → dist/api}/types/User.ts +0 -0
- /package/{api → dist/api}/types/UserAuditlogs.ts +0 -0
- /package/{api → dist/api}/types/UserNew.ts +0 -0
- /package/{api → dist/api}/types/UserUpdate.ts +0 -0
- /package/{api → dist/api}/types/UserUseradm.ts +0 -0
- /package/{api → dist/api}/types/XDeltaArgs.ts +0 -0
- /package/{api → dist/api}/types/XDeltaArgsDeployments.ts +0 -0
- /package/{api → dist/api}/types/XDeltaArgsLimits.ts +0 -0
- /package/{api → dist/api}/types/XDeltaArgsLimitsDeployments.ts +0 -0
|
@@ -0,0 +1,2977 @@
|
|
|
1
|
+
import {
|
|
2
|
+
v4_default
|
|
3
|
+
} from "./chunk-N7G6QK2E.mjs";
|
|
4
|
+
import {
|
|
5
|
+
getDeviceMonitorConfig,
|
|
6
|
+
getLatestDeviceAlerts
|
|
7
|
+
} from "./chunk-G7LATUT6.mjs";
|
|
8
|
+
import {
|
|
9
|
+
users_api_default
|
|
10
|
+
} from "./chunk-IVSYYXTC.mjs";
|
|
11
|
+
import {
|
|
12
|
+
general_api_default
|
|
13
|
+
} from "./chunk-R2GBNXLV.mjs";
|
|
14
|
+
import {
|
|
15
|
+
getAttrsEndpoint,
|
|
16
|
+
getOnboardingState,
|
|
17
|
+
getSearchEndpoint,
|
|
18
|
+
getTenantCapabilities,
|
|
19
|
+
getUserCapabilities
|
|
20
|
+
} from "./chunk-RQOE5OOT.mjs";
|
|
21
|
+
import {
|
|
22
|
+
getCurrentSession,
|
|
23
|
+
getCurrentUser,
|
|
24
|
+
getGlobalSettings,
|
|
25
|
+
getIdAttribute,
|
|
26
|
+
getOfflineThresholdSettings,
|
|
27
|
+
getRolesById,
|
|
28
|
+
getTooltipsState,
|
|
29
|
+
getUserSettings
|
|
30
|
+
} from "./chunk-BRHSKNFC.mjs";
|
|
31
|
+
import {
|
|
32
|
+
getAuditlogState,
|
|
33
|
+
getDeviceTwinIntegrations,
|
|
34
|
+
getOrganization,
|
|
35
|
+
getTenantsList
|
|
36
|
+
} from "./chunk-HVHZG2H4.mjs";
|
|
37
|
+
import {
|
|
38
|
+
getDeploymentsById,
|
|
39
|
+
getDeploymentsByStatus
|
|
40
|
+
} from "./chunk-DZBVTSIX.mjs";
|
|
41
|
+
import {
|
|
42
|
+
getDeviceById,
|
|
43
|
+
getDeviceFilters,
|
|
44
|
+
getDeviceListState,
|
|
45
|
+
getDevicesById,
|
|
46
|
+
getGroups,
|
|
47
|
+
getGroupsById,
|
|
48
|
+
getSelectedGroup
|
|
49
|
+
} from "./chunk-ZIYGEXSJ.mjs";
|
|
50
|
+
import {
|
|
51
|
+
getFeatures,
|
|
52
|
+
getSearchState
|
|
53
|
+
} from "./chunk-C2YZYTJ6.mjs";
|
|
54
|
+
import {
|
|
55
|
+
commonErrorFallback,
|
|
56
|
+
commonErrorHandler
|
|
57
|
+
} from "./chunk-XYVPYFSM.mjs";
|
|
58
|
+
import {
|
|
59
|
+
actions_default
|
|
60
|
+
} from "./chunk-IPPIKGIB.mjs";
|
|
61
|
+
import {
|
|
62
|
+
actions as actions6,
|
|
63
|
+
sliceName as sliceName6
|
|
64
|
+
} from "./chunk-BJSH2G7W.mjs";
|
|
65
|
+
import {
|
|
66
|
+
actions as actions5,
|
|
67
|
+
sliceName as sliceName5
|
|
68
|
+
} from "./chunk-TD45YTYK.mjs";
|
|
69
|
+
import {
|
|
70
|
+
actions as actions4,
|
|
71
|
+
sliceName as sliceName4
|
|
72
|
+
} from "./chunk-M4U5R7A4.mjs";
|
|
73
|
+
import {
|
|
74
|
+
actions as actions2,
|
|
75
|
+
sliceName as sliceName2
|
|
76
|
+
} from "./chunk-6667TCAJ.mjs";
|
|
77
|
+
import {
|
|
78
|
+
actions as actions3,
|
|
79
|
+
sliceName as sliceName3
|
|
80
|
+
} from "./chunk-HRWZJQMH.mjs";
|
|
81
|
+
import {
|
|
82
|
+
actions,
|
|
83
|
+
sliceName
|
|
84
|
+
} from "./chunk-F37LUTBX.mjs";
|
|
85
|
+
import {
|
|
86
|
+
cleanUp,
|
|
87
|
+
getSessionInfo,
|
|
88
|
+
maxSessionAge,
|
|
89
|
+
setSessionInfo
|
|
90
|
+
} from "./chunk-HXPYJ6QN.mjs";
|
|
91
|
+
import {
|
|
92
|
+
convertDeviceListStateToFilters,
|
|
93
|
+
extractErrorMessage,
|
|
94
|
+
filtersFilter,
|
|
95
|
+
getComparisonCompatibleVersion,
|
|
96
|
+
mapDeviceAttributes,
|
|
97
|
+
mapFiltersToTerms,
|
|
98
|
+
mapTermsToFilters,
|
|
99
|
+
mergePermissions,
|
|
100
|
+
preformatWithRequestID,
|
|
101
|
+
progress
|
|
102
|
+
} from "./chunk-G32LAKW4.mjs";
|
|
103
|
+
import {
|
|
104
|
+
ALL_DEVICE_STATES,
|
|
105
|
+
DEPLOYMENT_ROUTES,
|
|
106
|
+
DEPLOYMENT_STATES,
|
|
107
|
+
DEPLOYMENT_TYPES,
|
|
108
|
+
DEVICE_STATES,
|
|
109
|
+
OWN_USER_ID,
|
|
110
|
+
PermissionTypes,
|
|
111
|
+
READ_STATES,
|
|
112
|
+
SSO_TYPES,
|
|
113
|
+
TENANT_LIST_DEFAULT,
|
|
114
|
+
USER_LOGOUT,
|
|
115
|
+
auditLogsApiUrl,
|
|
116
|
+
defaultPermissionSets,
|
|
117
|
+
deploymentPrototype,
|
|
118
|
+
deploymentsApiUrl,
|
|
119
|
+
deploymentsApiUrlV2,
|
|
120
|
+
deviceAuthV2,
|
|
121
|
+
deviceConfig,
|
|
122
|
+
deviceConnect,
|
|
123
|
+
emptyFilter,
|
|
124
|
+
geoAttributes,
|
|
125
|
+
inventoryApiUrl,
|
|
126
|
+
inventoryApiUrlV2,
|
|
127
|
+
iotManagerBaseURL,
|
|
128
|
+
itemUiPermissionsReducer,
|
|
129
|
+
reportingApiUrl,
|
|
130
|
+
rolesById,
|
|
131
|
+
scopedPermissionAreas,
|
|
132
|
+
settingsKeys,
|
|
133
|
+
ssoIdpApiUrlv1,
|
|
134
|
+
tenantadmApiUrlv1,
|
|
135
|
+
tenantadmApiUrlv2,
|
|
136
|
+
twoFAStates,
|
|
137
|
+
uiPermissionsByArea,
|
|
138
|
+
uiPermissionsById,
|
|
139
|
+
useradmApiUrlv1,
|
|
140
|
+
useradmApiUrlv2
|
|
141
|
+
} from "./chunk-ZNST5R6O.mjs";
|
|
142
|
+
import {
|
|
143
|
+
rootfsImageVersion
|
|
144
|
+
} from "./chunk-G4FGNSV3.mjs";
|
|
145
|
+
import {
|
|
146
|
+
onboardingSteps,
|
|
147
|
+
orderedOnboardingSteps
|
|
148
|
+
} from "./chunk-IU4OXOPA.mjs";
|
|
149
|
+
import {
|
|
150
|
+
APPLICATION_JSON_CONTENT_TYPE,
|
|
151
|
+
APPLICATION_JWT_CONTENT_TYPE,
|
|
152
|
+
apiRoot,
|
|
153
|
+
defaultReports,
|
|
154
|
+
headerNames,
|
|
155
|
+
locations
|
|
156
|
+
} from "./chunk-BOSBROA3.mjs";
|
|
157
|
+
import {
|
|
158
|
+
ALL_DEVICES,
|
|
159
|
+
ALL_RELEASES,
|
|
160
|
+
DEVICE_FILTERING_OPTIONS,
|
|
161
|
+
DEVICE_LIST_DEFAULTS,
|
|
162
|
+
EXTERNAL_PROVIDER,
|
|
163
|
+
MAX_PAGE_SIZE,
|
|
164
|
+
SORTING_OPTIONS,
|
|
165
|
+
TIMEOUTS,
|
|
166
|
+
UNGROUPED_GROUP,
|
|
167
|
+
emptyRole,
|
|
168
|
+
emptyUiPermissions
|
|
169
|
+
} from "./chunk-G3I53JGW.mjs";
|
|
170
|
+
import {
|
|
171
|
+
__async,
|
|
172
|
+
__commonJS,
|
|
173
|
+
__objRest,
|
|
174
|
+
__require,
|
|
175
|
+
__spreadProps,
|
|
176
|
+
__spreadValues,
|
|
177
|
+
__toESM
|
|
178
|
+
} from "./chunk-XWBD7VOK.mjs";
|
|
179
|
+
|
|
180
|
+
// ../../node_modules/pluralize/pluralize.js
|
|
181
|
+
var require_pluralize = __commonJS({
|
|
182
|
+
"../../node_modules/pluralize/pluralize.js"(exports, module) {
|
|
183
|
+
"use strict";
|
|
184
|
+
(function(root, pluralize2) {
|
|
185
|
+
if (typeof __require === "function" && typeof exports === "object" && typeof module === "object") {
|
|
186
|
+
module.exports = pluralize2();
|
|
187
|
+
} else if (typeof define === "function" && define.amd) {
|
|
188
|
+
define(function() {
|
|
189
|
+
return pluralize2();
|
|
190
|
+
});
|
|
191
|
+
} else {
|
|
192
|
+
root.pluralize = pluralize2();
|
|
193
|
+
}
|
|
194
|
+
})(exports, function() {
|
|
195
|
+
var pluralRules = [];
|
|
196
|
+
var singularRules = [];
|
|
197
|
+
var uncountables = {};
|
|
198
|
+
var irregularPlurals = {};
|
|
199
|
+
var irregularSingles = {};
|
|
200
|
+
function sanitizeRule(rule) {
|
|
201
|
+
if (typeof rule === "string") {
|
|
202
|
+
return new RegExp("^" + rule + "$", "i");
|
|
203
|
+
}
|
|
204
|
+
return rule;
|
|
205
|
+
}
|
|
206
|
+
function restoreCase(word, token) {
|
|
207
|
+
if (word === token) return token;
|
|
208
|
+
if (word === word.toLowerCase()) return token.toLowerCase();
|
|
209
|
+
if (word === word.toUpperCase()) return token.toUpperCase();
|
|
210
|
+
if (word[0] === word[0].toUpperCase()) {
|
|
211
|
+
return token.charAt(0).toUpperCase() + token.substr(1).toLowerCase();
|
|
212
|
+
}
|
|
213
|
+
return token.toLowerCase();
|
|
214
|
+
}
|
|
215
|
+
function interpolate(str, args) {
|
|
216
|
+
return str.replace(/\$(\d{1,2})/g, function(match, index) {
|
|
217
|
+
return args[index] || "";
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
function replace(word, rule) {
|
|
221
|
+
return word.replace(rule[0], function(match, index) {
|
|
222
|
+
var result = interpolate(rule[1], arguments);
|
|
223
|
+
if (match === "") {
|
|
224
|
+
return restoreCase(word[index - 1], result);
|
|
225
|
+
}
|
|
226
|
+
return restoreCase(match, result);
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
function sanitizeWord(token, word, rules) {
|
|
230
|
+
if (!token.length || uncountables.hasOwnProperty(token)) {
|
|
231
|
+
return word;
|
|
232
|
+
}
|
|
233
|
+
var len = rules.length;
|
|
234
|
+
while (len--) {
|
|
235
|
+
var rule = rules[len];
|
|
236
|
+
if (rule[0].test(word)) return replace(word, rule);
|
|
237
|
+
}
|
|
238
|
+
return word;
|
|
239
|
+
}
|
|
240
|
+
function replaceWord(replaceMap, keepMap, rules) {
|
|
241
|
+
return function(word) {
|
|
242
|
+
var token = word.toLowerCase();
|
|
243
|
+
if (keepMap.hasOwnProperty(token)) {
|
|
244
|
+
return restoreCase(word, token);
|
|
245
|
+
}
|
|
246
|
+
if (replaceMap.hasOwnProperty(token)) {
|
|
247
|
+
return restoreCase(word, replaceMap[token]);
|
|
248
|
+
}
|
|
249
|
+
return sanitizeWord(token, word, rules);
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
function checkWord(replaceMap, keepMap, rules, bool) {
|
|
253
|
+
return function(word) {
|
|
254
|
+
var token = word.toLowerCase();
|
|
255
|
+
if (keepMap.hasOwnProperty(token)) return true;
|
|
256
|
+
if (replaceMap.hasOwnProperty(token)) return false;
|
|
257
|
+
return sanitizeWord(token, token, rules) === token;
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
function pluralize2(word, count, inclusive) {
|
|
261
|
+
var pluralized = count === 1 ? pluralize2.singular(word) : pluralize2.plural(word);
|
|
262
|
+
return (inclusive ? count + " " : "") + pluralized;
|
|
263
|
+
}
|
|
264
|
+
pluralize2.plural = replaceWord(
|
|
265
|
+
irregularSingles,
|
|
266
|
+
irregularPlurals,
|
|
267
|
+
pluralRules
|
|
268
|
+
);
|
|
269
|
+
pluralize2.isPlural = checkWord(
|
|
270
|
+
irregularSingles,
|
|
271
|
+
irregularPlurals,
|
|
272
|
+
pluralRules
|
|
273
|
+
);
|
|
274
|
+
pluralize2.singular = replaceWord(
|
|
275
|
+
irregularPlurals,
|
|
276
|
+
irregularSingles,
|
|
277
|
+
singularRules
|
|
278
|
+
);
|
|
279
|
+
pluralize2.isSingular = checkWord(
|
|
280
|
+
irregularPlurals,
|
|
281
|
+
irregularSingles,
|
|
282
|
+
singularRules
|
|
283
|
+
);
|
|
284
|
+
pluralize2.addPluralRule = function(rule, replacement) {
|
|
285
|
+
pluralRules.push([sanitizeRule(rule), replacement]);
|
|
286
|
+
};
|
|
287
|
+
pluralize2.addSingularRule = function(rule, replacement) {
|
|
288
|
+
singularRules.push([sanitizeRule(rule), replacement]);
|
|
289
|
+
};
|
|
290
|
+
pluralize2.addUncountableRule = function(word) {
|
|
291
|
+
if (typeof word === "string") {
|
|
292
|
+
uncountables[word.toLowerCase()] = true;
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
pluralize2.addPluralRule(word, "$0");
|
|
296
|
+
pluralize2.addSingularRule(word, "$0");
|
|
297
|
+
};
|
|
298
|
+
pluralize2.addIrregularRule = function(single, plural) {
|
|
299
|
+
plural = plural.toLowerCase();
|
|
300
|
+
single = single.toLowerCase();
|
|
301
|
+
irregularSingles[single] = plural;
|
|
302
|
+
irregularPlurals[plural] = single;
|
|
303
|
+
};
|
|
304
|
+
[
|
|
305
|
+
// Pronouns.
|
|
306
|
+
["I", "we"],
|
|
307
|
+
["me", "us"],
|
|
308
|
+
["he", "they"],
|
|
309
|
+
["she", "they"],
|
|
310
|
+
["them", "them"],
|
|
311
|
+
["myself", "ourselves"],
|
|
312
|
+
["yourself", "yourselves"],
|
|
313
|
+
["itself", "themselves"],
|
|
314
|
+
["herself", "themselves"],
|
|
315
|
+
["himself", "themselves"],
|
|
316
|
+
["themself", "themselves"],
|
|
317
|
+
["is", "are"],
|
|
318
|
+
["was", "were"],
|
|
319
|
+
["has", "have"],
|
|
320
|
+
["this", "these"],
|
|
321
|
+
["that", "those"],
|
|
322
|
+
// Words ending in with a consonant and `o`.
|
|
323
|
+
["echo", "echoes"],
|
|
324
|
+
["dingo", "dingoes"],
|
|
325
|
+
["volcano", "volcanoes"],
|
|
326
|
+
["tornado", "tornadoes"],
|
|
327
|
+
["torpedo", "torpedoes"],
|
|
328
|
+
// Ends with `us`.
|
|
329
|
+
["genus", "genera"],
|
|
330
|
+
["viscus", "viscera"],
|
|
331
|
+
// Ends with `ma`.
|
|
332
|
+
["stigma", "stigmata"],
|
|
333
|
+
["stoma", "stomata"],
|
|
334
|
+
["dogma", "dogmata"],
|
|
335
|
+
["lemma", "lemmata"],
|
|
336
|
+
["schema", "schemata"],
|
|
337
|
+
["anathema", "anathemata"],
|
|
338
|
+
// Other irregular rules.
|
|
339
|
+
["ox", "oxen"],
|
|
340
|
+
["axe", "axes"],
|
|
341
|
+
["die", "dice"],
|
|
342
|
+
["yes", "yeses"],
|
|
343
|
+
["foot", "feet"],
|
|
344
|
+
["eave", "eaves"],
|
|
345
|
+
["goose", "geese"],
|
|
346
|
+
["tooth", "teeth"],
|
|
347
|
+
["quiz", "quizzes"],
|
|
348
|
+
["human", "humans"],
|
|
349
|
+
["proof", "proofs"],
|
|
350
|
+
["carve", "carves"],
|
|
351
|
+
["valve", "valves"],
|
|
352
|
+
["looey", "looies"],
|
|
353
|
+
["thief", "thieves"],
|
|
354
|
+
["groove", "grooves"],
|
|
355
|
+
["pickaxe", "pickaxes"],
|
|
356
|
+
["passerby", "passersby"]
|
|
357
|
+
].forEach(function(rule) {
|
|
358
|
+
return pluralize2.addIrregularRule(rule[0], rule[1]);
|
|
359
|
+
});
|
|
360
|
+
[
|
|
361
|
+
[/s?$/i, "s"],
|
|
362
|
+
[/[^\u0000-\u007F]$/i, "$0"],
|
|
363
|
+
[/([^aeiou]ese)$/i, "$1"],
|
|
364
|
+
[/(ax|test)is$/i, "$1es"],
|
|
365
|
+
[/(alias|[^aou]us|t[lm]as|gas|ris)$/i, "$1es"],
|
|
366
|
+
[/(e[mn]u)s?$/i, "$1s"],
|
|
367
|
+
[/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i, "$1"],
|
|
368
|
+
[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, "$1i"],
|
|
369
|
+
[/(alumn|alg|vertebr)(?:a|ae)$/i, "$1ae"],
|
|
370
|
+
[/(seraph|cherub)(?:im)?$/i, "$1im"],
|
|
371
|
+
[/(her|at|gr)o$/i, "$1oes"],
|
|
372
|
+
[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i, "$1a"],
|
|
373
|
+
[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i, "$1a"],
|
|
374
|
+
[/sis$/i, "ses"],
|
|
375
|
+
[/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i, "$1$2ves"],
|
|
376
|
+
[/([^aeiouy]|qu)y$/i, "$1ies"],
|
|
377
|
+
[/([^ch][ieo][ln])ey$/i, "$1ies"],
|
|
378
|
+
[/(x|ch|ss|sh|zz)$/i, "$1es"],
|
|
379
|
+
[/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i, "$1ices"],
|
|
380
|
+
[/\b((?:tit)?m|l)(?:ice|ouse)$/i, "$1ice"],
|
|
381
|
+
[/(pe)(?:rson|ople)$/i, "$1ople"],
|
|
382
|
+
[/(child)(?:ren)?$/i, "$1ren"],
|
|
383
|
+
[/eaux$/i, "$0"],
|
|
384
|
+
[/m[ae]n$/i, "men"],
|
|
385
|
+
["thou", "you"]
|
|
386
|
+
].forEach(function(rule) {
|
|
387
|
+
return pluralize2.addPluralRule(rule[0], rule[1]);
|
|
388
|
+
});
|
|
389
|
+
[
|
|
390
|
+
[/s$/i, ""],
|
|
391
|
+
[/(ss)$/i, "$1"],
|
|
392
|
+
[/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i, "$1fe"],
|
|
393
|
+
[/(ar|(?:wo|[ae])l|[eo][ao])ves$/i, "$1f"],
|
|
394
|
+
[/ies$/i, "y"],
|
|
395
|
+
[/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i, "$1ie"],
|
|
396
|
+
[/\b(mon|smil)ies$/i, "$1ey"],
|
|
397
|
+
[/\b((?:tit)?m|l)ice$/i, "$1ouse"],
|
|
398
|
+
[/(seraph|cherub)im$/i, "$1"],
|
|
399
|
+
[/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i, "$1"],
|
|
400
|
+
[/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i, "$1sis"],
|
|
401
|
+
[/(movie|twelve|abuse|e[mn]u)s$/i, "$1"],
|
|
402
|
+
[/(test)(?:is|es)$/i, "$1is"],
|
|
403
|
+
[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, "$1us"],
|
|
404
|
+
[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i, "$1um"],
|
|
405
|
+
[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i, "$1on"],
|
|
406
|
+
[/(alumn|alg|vertebr)ae$/i, "$1a"],
|
|
407
|
+
[/(cod|mur|sil|vert|ind)ices$/i, "$1ex"],
|
|
408
|
+
[/(matr|append)ices$/i, "$1ix"],
|
|
409
|
+
[/(pe)(rson|ople)$/i, "$1rson"],
|
|
410
|
+
[/(child)ren$/i, "$1"],
|
|
411
|
+
[/(eau)x?$/i, "$1"],
|
|
412
|
+
[/men$/i, "man"]
|
|
413
|
+
].forEach(function(rule) {
|
|
414
|
+
return pluralize2.addSingularRule(rule[0], rule[1]);
|
|
415
|
+
});
|
|
416
|
+
[
|
|
417
|
+
// Singular words with no plurals.
|
|
418
|
+
"adulthood",
|
|
419
|
+
"advice",
|
|
420
|
+
"agenda",
|
|
421
|
+
"aid",
|
|
422
|
+
"aircraft",
|
|
423
|
+
"alcohol",
|
|
424
|
+
"ammo",
|
|
425
|
+
"analytics",
|
|
426
|
+
"anime",
|
|
427
|
+
"athletics",
|
|
428
|
+
"audio",
|
|
429
|
+
"bison",
|
|
430
|
+
"blood",
|
|
431
|
+
"bream",
|
|
432
|
+
"buffalo",
|
|
433
|
+
"butter",
|
|
434
|
+
"carp",
|
|
435
|
+
"cash",
|
|
436
|
+
"chassis",
|
|
437
|
+
"chess",
|
|
438
|
+
"clothing",
|
|
439
|
+
"cod",
|
|
440
|
+
"commerce",
|
|
441
|
+
"cooperation",
|
|
442
|
+
"corps",
|
|
443
|
+
"debris",
|
|
444
|
+
"diabetes",
|
|
445
|
+
"digestion",
|
|
446
|
+
"elk",
|
|
447
|
+
"energy",
|
|
448
|
+
"equipment",
|
|
449
|
+
"excretion",
|
|
450
|
+
"expertise",
|
|
451
|
+
"firmware",
|
|
452
|
+
"flounder",
|
|
453
|
+
"fun",
|
|
454
|
+
"gallows",
|
|
455
|
+
"garbage",
|
|
456
|
+
"graffiti",
|
|
457
|
+
"hardware",
|
|
458
|
+
"headquarters",
|
|
459
|
+
"health",
|
|
460
|
+
"herpes",
|
|
461
|
+
"highjinks",
|
|
462
|
+
"homework",
|
|
463
|
+
"housework",
|
|
464
|
+
"information",
|
|
465
|
+
"jeans",
|
|
466
|
+
"justice",
|
|
467
|
+
"kudos",
|
|
468
|
+
"labour",
|
|
469
|
+
"literature",
|
|
470
|
+
"machinery",
|
|
471
|
+
"mackerel",
|
|
472
|
+
"mail",
|
|
473
|
+
"media",
|
|
474
|
+
"mews",
|
|
475
|
+
"moose",
|
|
476
|
+
"music",
|
|
477
|
+
"mud",
|
|
478
|
+
"manga",
|
|
479
|
+
"news",
|
|
480
|
+
"only",
|
|
481
|
+
"personnel",
|
|
482
|
+
"pike",
|
|
483
|
+
"plankton",
|
|
484
|
+
"pliers",
|
|
485
|
+
"police",
|
|
486
|
+
"pollution",
|
|
487
|
+
"premises",
|
|
488
|
+
"rain",
|
|
489
|
+
"research",
|
|
490
|
+
"rice",
|
|
491
|
+
"salmon",
|
|
492
|
+
"scissors",
|
|
493
|
+
"series",
|
|
494
|
+
"sewage",
|
|
495
|
+
"shambles",
|
|
496
|
+
"shrimp",
|
|
497
|
+
"software",
|
|
498
|
+
"species",
|
|
499
|
+
"staff",
|
|
500
|
+
"swine",
|
|
501
|
+
"tennis",
|
|
502
|
+
"traffic",
|
|
503
|
+
"transportation",
|
|
504
|
+
"trout",
|
|
505
|
+
"tuna",
|
|
506
|
+
"wealth",
|
|
507
|
+
"welfare",
|
|
508
|
+
"whiting",
|
|
509
|
+
"wildebeest",
|
|
510
|
+
"wildlife",
|
|
511
|
+
"you",
|
|
512
|
+
/pok[eé]mon$/i,
|
|
513
|
+
// Regexes.
|
|
514
|
+
/[^aeiou]ese$/i,
|
|
515
|
+
// "chinese", "japanese"
|
|
516
|
+
/deer$/i,
|
|
517
|
+
// "deer", "reindeer"
|
|
518
|
+
/fish$/i,
|
|
519
|
+
// "fish", "blowfish", "angelfish"
|
|
520
|
+
/measles$/i,
|
|
521
|
+
/o[iu]s$/i,
|
|
522
|
+
// "carnivorous"
|
|
523
|
+
/pox$/i,
|
|
524
|
+
// "chickpox", "smallpox"
|
|
525
|
+
/sheep$/i
|
|
526
|
+
].forEach(pluralize2.addUncountableRule);
|
|
527
|
+
return pluralize2;
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
});
|
|
531
|
+
|
|
532
|
+
// src/deploymentsSlice/thunks.ts
|
|
533
|
+
import { deepCompare, isEmpty, standardizePhases, startTimeSort } from "@northern.tech/utils/helpers";
|
|
534
|
+
import { createAsyncThunk } from "@reduxjs/toolkit";
|
|
535
|
+
import isUUID from "validator/lib/isUUID";
|
|
536
|
+
var { receivedDevice, setSnackbar } = actions_default;
|
|
537
|
+
var { page: defaultPage, perPage: defaultPerPage } = DEVICE_LIST_DEFAULTS;
|
|
538
|
+
var deriveDeploymentGroup = ({ filter = {}, group, groups = [], name }) => group || groups.length === 1 && !isUUID(name) ? groups[0] : filter.name;
|
|
539
|
+
var transformDeployments = (deployments, deploymentsById) => deployments.sort(startTimeSort).reduce(
|
|
540
|
+
(accu, item) => {
|
|
541
|
+
var _a, _b;
|
|
542
|
+
const filter = (_a = item.filter) != null ? _a : {};
|
|
543
|
+
let deployment = __spreadProps(__spreadValues(__spreadValues(__spreadValues({}, deploymentPrototype), deploymentsById[item.id]), item), {
|
|
544
|
+
filter: item.filter ? __spreadProps(__spreadValues({}, filter), { name: (_b = filter.name) != null ? _b : filter.id, filters: mapTermsToFilters(filter.terms) }) : void 0,
|
|
545
|
+
name: decodeURIComponent(item.name)
|
|
546
|
+
});
|
|
547
|
+
deployment = __spreadProps(__spreadValues({}, deployment), { group: deriveDeploymentGroup(deployment) });
|
|
548
|
+
accu.deployments[item.id] = deployment;
|
|
549
|
+
accu.deploymentIds.push(item.id);
|
|
550
|
+
return accu;
|
|
551
|
+
},
|
|
552
|
+
{ deployments: {}, deploymentIds: [] }
|
|
553
|
+
);
|
|
554
|
+
var getDeploymentsByStatus2 = createAsyncThunk(`${sliceName2}/getDeploymentsByStatus`, (options = {}, { dispatch, getState }) => {
|
|
555
|
+
const { status, page = defaultPage, per_page = defaultPerPage, startDate, endDate, group, type, shouldSelect = true, sort = SORTING_OPTIONS.desc } = options;
|
|
556
|
+
const created_after = startDate ? `&created_after=${startDate}` : "";
|
|
557
|
+
const created_before = endDate ? `&created_before=${endDate}` : "";
|
|
558
|
+
const search = group ? `&search=${group}` : "";
|
|
559
|
+
const typeFilter = type ? `&type=${type}` : "";
|
|
560
|
+
return general_api_default.get(
|
|
561
|
+
`${deploymentsApiUrl}/deployments?status=${status}&per_page=${per_page}&page=${page}${created_after}${created_before}${search}${typeFilter}&sort=${sort}`
|
|
562
|
+
).then((res) => {
|
|
563
|
+
const { deployments, deploymentIds } = transformDeployments(res.data, getState().deployments.byId);
|
|
564
|
+
const total = Number(res.headers[headerNames.total]);
|
|
565
|
+
let tasks = [
|
|
566
|
+
dispatch(actions2.receivedDeployments(deployments)),
|
|
567
|
+
dispatch(
|
|
568
|
+
actions2.receivedDeploymentsForStatus({
|
|
569
|
+
deploymentIds,
|
|
570
|
+
status,
|
|
571
|
+
total: !(startDate || endDate || group || type) ? total : getState().deployments.byStatus[status].total
|
|
572
|
+
})
|
|
573
|
+
)
|
|
574
|
+
];
|
|
575
|
+
tasks = deploymentIds.reduce((accu, deploymentId) => {
|
|
576
|
+
if (deployments[deploymentId].type === DEPLOYMENT_TYPES.configuration) {
|
|
577
|
+
accu.push(dispatch(getSingleDeployment(deploymentId)));
|
|
578
|
+
}
|
|
579
|
+
return accu;
|
|
580
|
+
}, tasks);
|
|
581
|
+
if (shouldSelect) {
|
|
582
|
+
tasks.push(dispatch(actions2.selectDeploymentsForStatus({ deploymentIds, status, total })));
|
|
583
|
+
}
|
|
584
|
+
tasks.push({ deploymentIds, total });
|
|
585
|
+
return Promise.all(tasks);
|
|
586
|
+
});
|
|
587
|
+
});
|
|
588
|
+
var MAX_PREVIOUS_PHASES_COUNT = 5;
|
|
589
|
+
var createDeployment = createAsyncThunk(`${sliceName2}/createDeployment`, ({ newDeployment, hasNewRetryDefault = false }, { dispatch, getState }) => {
|
|
590
|
+
let request;
|
|
591
|
+
if (newDeployment.filter_id) {
|
|
592
|
+
request = general_api_default.post(`${deploymentsApiUrlV2}/deployments`, newDeployment);
|
|
593
|
+
} else if (newDeployment.group) {
|
|
594
|
+
request = general_api_default.post(`${deploymentsApiUrl}/deployments/group/${newDeployment.group}`, newDeployment);
|
|
595
|
+
} else {
|
|
596
|
+
request = general_api_default.post(`${deploymentsApiUrl}/deployments`, newDeployment);
|
|
597
|
+
}
|
|
598
|
+
return request.catch((err) => commonErrorHandler(err, "Error creating deployment.", dispatch)).then((data) => {
|
|
599
|
+
const lastslashindex = data.headers.location.lastIndexOf("/");
|
|
600
|
+
const deploymentId = data.headers.location.substring(lastslashindex + 1);
|
|
601
|
+
const deployment = __spreadProps(__spreadValues({}, newDeployment), {
|
|
602
|
+
id: deploymentId,
|
|
603
|
+
devices: newDeployment.devices ? newDeployment.devices.map((id) => ({ id, status: "pending" })) : [],
|
|
604
|
+
statistics: { status: {} }
|
|
605
|
+
});
|
|
606
|
+
let tasks = [
|
|
607
|
+
dispatch(actions2.createdDeployment(deployment)),
|
|
608
|
+
dispatch(getSingleDeployment(deploymentId)),
|
|
609
|
+
dispatch(setSnackbar("Deployment created successfully", TIMEOUTS.fiveSeconds))
|
|
610
|
+
];
|
|
611
|
+
const { canManageUsers } = getUserCapabilities(getState());
|
|
612
|
+
if (canManageUsers) {
|
|
613
|
+
const { phases, retries } = newDeployment;
|
|
614
|
+
const { previousPhases = [], retries: previousRetries = 0 } = getGlobalSettings(getState());
|
|
615
|
+
let newSettings = { retries: hasNewRetryDefault ? retries : previousRetries, hasDeployments: true };
|
|
616
|
+
if (phases) {
|
|
617
|
+
const standardPhases = standardizePhases(phases);
|
|
618
|
+
let prevPhases = previousPhases.map(standardizePhases);
|
|
619
|
+
if (!prevPhases.find((previousPhaseList) => previousPhaseList.every((oldPhase) => standardPhases.find((phase) => deepCompare(phase, oldPhase))))) {
|
|
620
|
+
prevPhases.push(standardPhases);
|
|
621
|
+
}
|
|
622
|
+
newSettings.previousPhases = prevPhases.slice(-1 * MAX_PREVIOUS_PHASES_COUNT);
|
|
623
|
+
}
|
|
624
|
+
tasks.push(dispatch(saveGlobalSettings(newSettings)));
|
|
625
|
+
}
|
|
626
|
+
return Promise.all(tasks);
|
|
627
|
+
});
|
|
628
|
+
});
|
|
629
|
+
var getDeploymentDevices = createAsyncThunk(`${sliceName2}/getDeploymentDevices`, (options, { dispatch, getState }) => {
|
|
630
|
+
const { id, page = defaultPage, perPage = defaultPerPage } = options;
|
|
631
|
+
return general_api_default.get(`${deploymentsApiUrl}/deployments/${id}/devices/list?&page=${page}&per_page=${perPage}`).then((response) => {
|
|
632
|
+
const { devices: deploymentDevices = {} } = getState().deployments.byId[id] || {};
|
|
633
|
+
const devices = response.data.reduce((accu, item) => {
|
|
634
|
+
accu[item.id] = item;
|
|
635
|
+
const log = (deploymentDevices[item.id] || {}).log;
|
|
636
|
+
if (log) {
|
|
637
|
+
accu[item.id].log = log;
|
|
638
|
+
}
|
|
639
|
+
return accu;
|
|
640
|
+
}, {});
|
|
641
|
+
const selectedDeviceIds = Object.keys(devices);
|
|
642
|
+
let tasks = [
|
|
643
|
+
dispatch(
|
|
644
|
+
actions2.receivedDeploymentDevices({
|
|
645
|
+
id,
|
|
646
|
+
devices,
|
|
647
|
+
selectedDeviceIds,
|
|
648
|
+
totalDeviceCount: Number(response.headers[headerNames.total])
|
|
649
|
+
})
|
|
650
|
+
)
|
|
651
|
+
];
|
|
652
|
+
const devicesById = getDevicesById(getState());
|
|
653
|
+
const lackingData = selectedDeviceIds.reduce((accu, deviceId) => {
|
|
654
|
+
const device = devicesById[deviceId];
|
|
655
|
+
if (!device || !device.identity_data || !device.attributes || Object.keys(device.attributes).length === 0) {
|
|
656
|
+
accu.push(deviceId);
|
|
657
|
+
}
|
|
658
|
+
return accu;
|
|
659
|
+
}, []);
|
|
660
|
+
tasks = lackingData.reduce((accu, deviceId) => [...accu, dispatch(getDeviceById2(deviceId)), dispatch(getDeviceAuth(deviceId))], tasks);
|
|
661
|
+
return Promise.all(tasks);
|
|
662
|
+
});
|
|
663
|
+
});
|
|
664
|
+
var parseDeviceDeployment = ({
|
|
665
|
+
deployment: { id, artifact_name: release, status: deploymentStatus },
|
|
666
|
+
device: { created, deleted, id: deviceId, finished, status, log }
|
|
667
|
+
}) => ({
|
|
668
|
+
id,
|
|
669
|
+
release,
|
|
670
|
+
created,
|
|
671
|
+
deleted,
|
|
672
|
+
deviceId,
|
|
673
|
+
finished,
|
|
674
|
+
status,
|
|
675
|
+
log,
|
|
676
|
+
route: Object.values(DEPLOYMENT_ROUTES).reduce((accu, { key, states }) => {
|
|
677
|
+
if (!accu) {
|
|
678
|
+
return states.includes(deploymentStatus) ? key : accu;
|
|
679
|
+
}
|
|
680
|
+
return accu;
|
|
681
|
+
}, "")
|
|
682
|
+
});
|
|
683
|
+
var getDeviceDeployments = createAsyncThunk(`${sliceName2}/getDeviceDeployments`, (options, { dispatch }) => {
|
|
684
|
+
const { deviceId, filterSelection = [], page = defaultPage, perPage = defaultPerPage } = options;
|
|
685
|
+
const filters = filterSelection.map((item) => `&status=${item}`).join("");
|
|
686
|
+
return general_api_default.get(`${deploymentsApiUrl}/deployments/devices/${deviceId}?page=${page}&per_page=${perPage}${filters}`).then(
|
|
687
|
+
({ data, headers }) => Promise.resolve(
|
|
688
|
+
dispatch(
|
|
689
|
+
receivedDevice({
|
|
690
|
+
id: deviceId,
|
|
691
|
+
deviceDeployments: data.map(parseDeviceDeployment),
|
|
692
|
+
deploymentsCount: Number(headers[headerNames.total])
|
|
693
|
+
})
|
|
694
|
+
)
|
|
695
|
+
)
|
|
696
|
+
).catch((err) => commonErrorHandler(err, "There was an error retrieving the device deployment history:", dispatch));
|
|
697
|
+
});
|
|
698
|
+
var resetDeviceDeployments = createAsyncThunk(
|
|
699
|
+
`${sliceName2}/resetDeviceDeployments`,
|
|
700
|
+
(deviceId, { dispatch }) => general_api_default.delete(`${deploymentsApiUrl}/deployments/devices/${deviceId}/history`).then(() => Promise.resolve(dispatch(getDeviceDeployments({ deviceId })))).catch((err) => commonErrorHandler(err, "There was an error resetting the device deployment history:", dispatch))
|
|
701
|
+
);
|
|
702
|
+
var getSingleDeployment = createAsyncThunk(
|
|
703
|
+
`${sliceName2}/getSingleDeployment`,
|
|
704
|
+
(id, { dispatch, getState }) => general_api_default.get(`${deploymentsApiUrl}/deployments/${id}`).then(({ data }) => {
|
|
705
|
+
const { deployments } = transformDeployments([data], getState().deployments.byId);
|
|
706
|
+
return Promise.resolve(dispatch(actions2.receivedDeployment(deployments[id])));
|
|
707
|
+
})
|
|
708
|
+
);
|
|
709
|
+
var getDeviceLog = createAsyncThunk(
|
|
710
|
+
`${sliceName2}/getDeviceLog`,
|
|
711
|
+
({ deploymentId, deviceId }, { dispatch }) => general_api_default.get(`${deploymentsApiUrl}/deployments/${deploymentId}/devices/${deviceId}/log`).catch((e) => {
|
|
712
|
+
console.log("no log here", e);
|
|
713
|
+
return Promise.reject();
|
|
714
|
+
}).then(
|
|
715
|
+
({ data: log }) => Promise.all([Promise.resolve(dispatch(actions2.receivedDeploymentDeviceLog({ id: deploymentId, deviceId, log }))), Promise.resolve(log)])
|
|
716
|
+
)
|
|
717
|
+
);
|
|
718
|
+
var abortDeployment = createAsyncThunk(
|
|
719
|
+
`${sliceName2}/abortDeployment`,
|
|
720
|
+
(deploymentId, { dispatch, getState }) => general_api_default.put(`${deploymentsApiUrl}/deployments/${deploymentId}/status`, { status: "aborted" }).then(() => {
|
|
721
|
+
const deploymentsByStatus = getDeploymentsByStatus(getState());
|
|
722
|
+
let status = DEPLOYMENT_STATES.pending;
|
|
723
|
+
let index = deploymentsByStatus.pending.deploymentIds.findIndex((id) => id === deploymentId);
|
|
724
|
+
if (index < 0) {
|
|
725
|
+
status = DEPLOYMENT_STATES.inprogress;
|
|
726
|
+
index = deploymentsByStatus.inprogress.deploymentIds.findIndex((id) => id === deploymentId);
|
|
727
|
+
}
|
|
728
|
+
const deploymentIds = [...deploymentsByStatus[status].deploymentIds.slice(0, index), ...deploymentsByStatus[status].deploymentIds.slice(index + 1)];
|
|
729
|
+
const deploymentsById = getDeploymentsById(getState());
|
|
730
|
+
const deployments = deploymentIds.reduce((accu, id) => {
|
|
731
|
+
accu[id] = deploymentsById[id];
|
|
732
|
+
return accu;
|
|
733
|
+
}, {});
|
|
734
|
+
const total = Math.max(deploymentsByStatus[status].total - 1, 0);
|
|
735
|
+
return Promise.all([
|
|
736
|
+
dispatch(actions2.receivedDeployments(deployments)),
|
|
737
|
+
dispatch(actions2.receivedDeploymentsForStatus({ deploymentIds, status, total })),
|
|
738
|
+
dispatch(actions2.removedDeployment(deploymentId)),
|
|
739
|
+
dispatch(setSnackbar("The deployment was successfully aborted"))
|
|
740
|
+
]);
|
|
741
|
+
}).catch((err) => commonErrorHandler(err, "There was an error while aborting the deployment:", dispatch))
|
|
742
|
+
);
|
|
743
|
+
var updateDeploymentControlMap = createAsyncThunk(
|
|
744
|
+
`${sliceName2}/updateDeploymentControlMap`,
|
|
745
|
+
({ deploymentId, updateControlMap }, { dispatch }) => general_api_default.patch(`${deploymentsApiUrl}/deployments/${deploymentId}`, { update_control_map: updateControlMap }).catch((err) => commonErrorHandler(err, "There was an error while updating the deployment status:", dispatch)).then(() => Promise.resolve(dispatch(getSingleDeployment(deploymentId))))
|
|
746
|
+
);
|
|
747
|
+
var setDeploymentsState = createAsyncThunk(`${sliceName2}/setDeploymentsState`, (selection, { dispatch, getState }) => {
|
|
748
|
+
const _a = selection, { page, perPage } = _a, selectionState = __objRest(_a, ["page", "perPage"]);
|
|
749
|
+
const currentState = getState().deployments.selectionState;
|
|
750
|
+
let nextState = __spreadProps(__spreadValues(__spreadValues(__spreadValues({}, currentState), selectionState), Object.keys(DEPLOYMENT_STATES).reduce((accu, item) => {
|
|
751
|
+
accu[item] = __spreadValues(__spreadValues({}, currentState[item]), selectionState[item]);
|
|
752
|
+
return accu;
|
|
753
|
+
}, {})), {
|
|
754
|
+
general: __spreadValues(__spreadValues({}, currentState.general), selectionState.general)
|
|
755
|
+
});
|
|
756
|
+
let tasks = [dispatch(actions2.setDeploymentsState(nextState))];
|
|
757
|
+
if (nextState.selectedId && currentState.selectedId !== nextState.selectedId) {
|
|
758
|
+
tasks.push(dispatch(getSingleDeployment(nextState.selectedId)));
|
|
759
|
+
}
|
|
760
|
+
return Promise.all(tasks);
|
|
761
|
+
});
|
|
762
|
+
var deltaAttributeMappings = [
|
|
763
|
+
{ here: "compressionLevel", there: "compression_level" },
|
|
764
|
+
{ here: "disableChecksum", there: "disable_checksum" },
|
|
765
|
+
{ here: "disableDecompression", there: "disable_external_decompression" },
|
|
766
|
+
{ here: "sourceWindow", there: "source_window_size" },
|
|
767
|
+
{ here: "inputWindow", there: "input_window_size" },
|
|
768
|
+
{ here: "duplicatesWindow", there: "compression_duplicates_window" },
|
|
769
|
+
{ here: "instructionBuffer", there: "instruction_buffer_size" }
|
|
770
|
+
];
|
|
771
|
+
var mapExternalDeltaConfig = (config = {}) => deltaAttributeMappings.reduce((accu, { here, there }) => {
|
|
772
|
+
if (config[there] !== void 0) {
|
|
773
|
+
accu[here] = config[there];
|
|
774
|
+
}
|
|
775
|
+
return accu;
|
|
776
|
+
}, {});
|
|
777
|
+
var getDeploymentsConfig = createAsyncThunk(
|
|
778
|
+
`${sliceName2}/getDeploymentsConfig`,
|
|
779
|
+
(_, { dispatch, getState }) => general_api_default.get(`${deploymentsApiUrl}/config`).then(({ data }) => {
|
|
780
|
+
const oldConfig = getState().deployments.config;
|
|
781
|
+
const { delta = {} } = data;
|
|
782
|
+
const { binary_delta = {}, binary_delta_limits = {} } = delta;
|
|
783
|
+
const { xdelta_args = {}, timeout: timeoutConfig = oldConfig.binaryDelta.timeout } = binary_delta;
|
|
784
|
+
const { xdelta_args_limits = {}, timeout: timeoutLimit = oldConfig.binaryDeltaLimits.timeout } = binary_delta_limits;
|
|
785
|
+
const config = __spreadProps(__spreadValues({}, oldConfig), {
|
|
786
|
+
hasDelta: Boolean(delta.enabled),
|
|
787
|
+
binaryDelta: __spreadValues(__spreadProps(__spreadValues({}, oldConfig.binaryDelta), {
|
|
788
|
+
timeout: timeoutConfig
|
|
789
|
+
}), mapExternalDeltaConfig(xdelta_args)),
|
|
790
|
+
binaryDeltaLimits: __spreadValues(__spreadProps(__spreadValues({}, oldConfig.binaryDeltaLimits), {
|
|
791
|
+
timeout: timeoutLimit
|
|
792
|
+
}), mapExternalDeltaConfig(xdelta_args_limits))
|
|
793
|
+
});
|
|
794
|
+
return Promise.resolve(dispatch(actions2.setDeploymentsConfig(config)));
|
|
795
|
+
})
|
|
796
|
+
);
|
|
797
|
+
var deepClean = (source) => Object.entries(source).reduce((accu, [key, value]) => {
|
|
798
|
+
if (value !== void 0) {
|
|
799
|
+
let cleanedValue = typeof value === "object" ? deepClean(value) : value;
|
|
800
|
+
if (cleanedValue === void 0 || typeof cleanedValue === "object" && isEmpty(cleanedValue)) {
|
|
801
|
+
return accu;
|
|
802
|
+
}
|
|
803
|
+
accu = __spreadProps(__spreadValues({}, accu != null ? accu : {}), { [key]: cleanedValue });
|
|
804
|
+
}
|
|
805
|
+
return accu;
|
|
806
|
+
}, void 0);
|
|
807
|
+
var saveDeltaDeploymentsConfig = createAsyncThunk(`${sliceName2}/saveDeltaDeploymentsConfig`, (config, { dispatch, getState }) => {
|
|
808
|
+
const configChange = {
|
|
809
|
+
timeout: config.timeout,
|
|
810
|
+
xdelta_args: deltaAttributeMappings.reduce((accu, { here, there }) => {
|
|
811
|
+
if (config[here] !== void 0) {
|
|
812
|
+
accu[there] = config[here];
|
|
813
|
+
}
|
|
814
|
+
return accu;
|
|
815
|
+
}, {})
|
|
816
|
+
};
|
|
817
|
+
const result = deepClean(configChange);
|
|
818
|
+
if (!result) {
|
|
819
|
+
return Promise.resolve();
|
|
820
|
+
}
|
|
821
|
+
return general_api_default.put(`${deploymentsApiUrl}/config/binary_delta`, result).catch((err) => commonErrorHandler(err, "There was a problem storing your delta artifact generation configuration.", dispatch)).then(() => {
|
|
822
|
+
const oldConfig = getState().deployments.config;
|
|
823
|
+
const newConfig = __spreadProps(__spreadValues({}, oldConfig), {
|
|
824
|
+
binaryDelta: __spreadValues(__spreadValues({}, oldConfig.binaryDelta), config)
|
|
825
|
+
});
|
|
826
|
+
return Promise.all([dispatch(actions2.setDeploymentsConfig(newConfig)), dispatch(setSnackbar("Settings saved successfully"))]);
|
|
827
|
+
});
|
|
828
|
+
});
|
|
829
|
+
|
|
830
|
+
// src/devicesSlice/thunks.tsx
|
|
831
|
+
import React from "react";
|
|
832
|
+
import { Link } from "react-router-dom";
|
|
833
|
+
var import_pluralize = __toESM(require_pluralize());
|
|
834
|
+
import { attributeDuplicateFilter, deepCompare as deepCompare2, getSnackbarMessage } from "@northern.tech/utils/helpers";
|
|
835
|
+
import { createAsyncThunk as createAsyncThunk2 } from "@reduxjs/toolkit";
|
|
836
|
+
import { isCancel } from "axios";
|
|
837
|
+
var { cleanUpUpload, initUpload, setSnackbar: setSnackbar2, uploadProgress } = actions_default;
|
|
838
|
+
var { page: defaultPage2, perPage: defaultPerPage2 } = DEVICE_LIST_DEFAULTS;
|
|
839
|
+
var defaultAttributes = [
|
|
840
|
+
{ scope: "identity", attribute: "status" },
|
|
841
|
+
{ scope: "inventory", attribute: "artifact_name" },
|
|
842
|
+
{ scope: "inventory", attribute: "device_type" },
|
|
843
|
+
{ scope: "inventory", attribute: "mender_is_gateway" },
|
|
844
|
+
{ scope: "inventory", attribute: "mender_gateway_system_id" },
|
|
845
|
+
{ scope: "inventory", attribute: rootfsImageVersion },
|
|
846
|
+
{ scope: "monitor", attribute: "alerts" },
|
|
847
|
+
{ scope: "system", attribute: "created_ts" },
|
|
848
|
+
{ scope: "system", attribute: "updated_ts" },
|
|
849
|
+
{ scope: "system", attribute: "check_in_time" },
|
|
850
|
+
{ scope: "system", attribute: "group" },
|
|
851
|
+
{ scope: "tags", attribute: "name" }
|
|
852
|
+
];
|
|
853
|
+
var getGroups2 = createAsyncThunk2(
|
|
854
|
+
`${sliceName3}/getGroups`,
|
|
855
|
+
(_, { dispatch, getState }) => general_api_default.get(`${inventoryApiUrl}/groups`).then((res) => {
|
|
856
|
+
const state = getGroupsById(getState());
|
|
857
|
+
const dynamicGroups = Object.entries(state).reduce((accu, [id, group]) => {
|
|
858
|
+
var _a;
|
|
859
|
+
if (group.id || ((_a = group.filters) == null ? void 0 : _a.length) && id !== UNGROUPED_GROUP.id) {
|
|
860
|
+
accu[id] = group;
|
|
861
|
+
}
|
|
862
|
+
return accu;
|
|
863
|
+
}, {});
|
|
864
|
+
const groups = res.data.reduce((accu, group) => {
|
|
865
|
+
accu[group] = __spreadValues({ deviceIds: [], filters: [], total: 0 }, state[group]);
|
|
866
|
+
return accu;
|
|
867
|
+
}, dynamicGroups);
|
|
868
|
+
const filters = [{ key: "group", value: res.data, operator: DEVICE_FILTERING_OPTIONS.$nin.key, scope: "system" }];
|
|
869
|
+
return Promise.all([
|
|
870
|
+
dispatch(actions3.receivedGroups(groups)),
|
|
871
|
+
dispatch(getDevicesByStatus({ filterSelection: filters, group: 0, page: 1, perPage: 1, status: void 0 }))
|
|
872
|
+
]).then((promises) => {
|
|
873
|
+
const devicesRetrieval = promises[promises.length - 1] || [];
|
|
874
|
+
const { payload } = devicesRetrieval || {};
|
|
875
|
+
const result = payload[payload.length - 1] || {};
|
|
876
|
+
if (!result.total) {
|
|
877
|
+
return Promise.resolve();
|
|
878
|
+
}
|
|
879
|
+
return Promise.resolve(
|
|
880
|
+
dispatch(
|
|
881
|
+
actions3.addGroup({
|
|
882
|
+
groupName: UNGROUPED_GROUP.id,
|
|
883
|
+
group: { filters: [{ key: "group", value: res.data, operator: DEVICE_FILTERING_OPTIONS.$nin.key, scope: "system" }] }
|
|
884
|
+
})
|
|
885
|
+
)
|
|
886
|
+
);
|
|
887
|
+
});
|
|
888
|
+
})
|
|
889
|
+
);
|
|
890
|
+
var addDevicesToGroup = createAsyncThunk2(
|
|
891
|
+
`${sliceName3}/addDevicesToGroup`,
|
|
892
|
+
({ group, deviceIds, isCreation }, { dispatch }) => general_api_default.patch(`${inventoryApiUrl}/groups/${group}/devices`, deviceIds).then(() => dispatch(actions3.addToGroup({ group, deviceIds }))).finally(() => isCreation ? Promise.resolve(dispatch(getGroups2())) : {})
|
|
893
|
+
);
|
|
894
|
+
var removeDevicesFromGroup = createAsyncThunk2(
|
|
895
|
+
`${sliceName3}/removeDevicesFromGroup`,
|
|
896
|
+
({ group, deviceIds }, { dispatch }) => general_api_default.delete(`${inventoryApiUrl}/groups/${group}/devices`, deviceIds).then(
|
|
897
|
+
() => Promise.all([
|
|
898
|
+
dispatch(actions3.removeFromGroup({ group, deviceIds })),
|
|
899
|
+
dispatch(setSnackbar2(`The ${(0, import_pluralize.default)("devices", deviceIds.length)} ${(0, import_pluralize.default)("were", deviceIds.length)} removed from the group`, TIMEOUTS.fiveSeconds))
|
|
900
|
+
])
|
|
901
|
+
)
|
|
902
|
+
);
|
|
903
|
+
var getGroupNotification = (newGroup, selectedGroup) => {
|
|
904
|
+
const successMessage = "The group was updated successfully";
|
|
905
|
+
if (newGroup === selectedGroup) {
|
|
906
|
+
return [successMessage, TIMEOUTS.fiveSeconds];
|
|
907
|
+
}
|
|
908
|
+
return [
|
|
909
|
+
/* @__PURE__ */ React.createElement(React.Fragment, null, successMessage, " - ", /* @__PURE__ */ React.createElement(Link, { to: `/devices?inventory=group:eq:${newGroup}` }, "click here"), " to see it."),
|
|
910
|
+
5e3,
|
|
911
|
+
void 0,
|
|
912
|
+
void 0,
|
|
913
|
+
() => {
|
|
914
|
+
}
|
|
915
|
+
];
|
|
916
|
+
};
|
|
917
|
+
var addStaticGroup = createAsyncThunk2(
|
|
918
|
+
`${sliceName3}/addStaticGroup`,
|
|
919
|
+
({ group, devices }, { dispatch, getState }) => Promise.resolve(dispatch(addDevicesToGroup({ group, deviceIds: devices.map(({ id }) => id), isCreation: true }))).then(
|
|
920
|
+
() => Promise.resolve(
|
|
921
|
+
dispatch(
|
|
922
|
+
actions3.addGroup({
|
|
923
|
+
group: __spreadValues({ deviceIds: [], total: 0, filters: [] }, getState().devices.groups.byId[group]),
|
|
924
|
+
groupName: group
|
|
925
|
+
})
|
|
926
|
+
)
|
|
927
|
+
).then(
|
|
928
|
+
() => Promise.all([
|
|
929
|
+
dispatch(setDeviceListState({ setOnly: true })),
|
|
930
|
+
dispatch(getGroups2()),
|
|
931
|
+
dispatch(setSnackbar2(...getGroupNotification(group, getState().devices.groups.selectedGroup)))
|
|
932
|
+
])
|
|
933
|
+
)
|
|
934
|
+
).catch((err) => commonErrorHandler(err, `Group could not be updated:`, dispatch))
|
|
935
|
+
);
|
|
936
|
+
var removeStaticGroup = createAsyncThunk2(
|
|
937
|
+
`${sliceName3}/removeStaticGroup`,
|
|
938
|
+
(groupName, { dispatch }) => general_api_default.delete(`${inventoryApiUrl}/groups/${groupName}`).then(
|
|
939
|
+
() => Promise.all([
|
|
940
|
+
dispatch(actions3.removeGroup(groupName)),
|
|
941
|
+
dispatch(getGroups2()),
|
|
942
|
+
dispatch(setSnackbar2("Group was removed successfully", TIMEOUTS.fiveSeconds))
|
|
943
|
+
])
|
|
944
|
+
)
|
|
945
|
+
);
|
|
946
|
+
var getDynamicGroups = createAsyncThunk2(
|
|
947
|
+
`${sliceName3}/getDynamicGroups`,
|
|
948
|
+
(_, { dispatch, getState }) => general_api_default.get(`${inventoryApiUrlV2}/filters?per_page=${MAX_PAGE_SIZE}`).then(({ data: filters }) => {
|
|
949
|
+
const state = getGroupsById(getState());
|
|
950
|
+
const staticGroups = Object.entries(state).reduce((accu, [id, group]) => {
|
|
951
|
+
var _a;
|
|
952
|
+
if (!(group.id || ((_a = group.filters) == null ? void 0 : _a.length))) {
|
|
953
|
+
accu[id] = group;
|
|
954
|
+
}
|
|
955
|
+
return accu;
|
|
956
|
+
}, {});
|
|
957
|
+
const groups = (filters || []).reduce((accu, filter) => {
|
|
958
|
+
accu[filter.name] = __spreadProps(__spreadValues({
|
|
959
|
+
deviceIds: [],
|
|
960
|
+
total: 0
|
|
961
|
+
}, state[filter.name]), {
|
|
962
|
+
id: filter.id,
|
|
963
|
+
filters: mapTermsToFilters(filter.terms)
|
|
964
|
+
});
|
|
965
|
+
return accu;
|
|
966
|
+
}, staticGroups);
|
|
967
|
+
return Promise.resolve(dispatch(actions3.receivedGroups(groups)));
|
|
968
|
+
}).catch(() => console.log("Dynamic group retrieval failed - likely accessing a non-enterprise backend"))
|
|
969
|
+
);
|
|
970
|
+
var addDynamicGroup = createAsyncThunk2(
|
|
971
|
+
`${sliceName3}/addDynamicGroup`,
|
|
972
|
+
({ groupName, filterPredicates }, { dispatch, getState }) => general_api_default.post(`${inventoryApiUrlV2}/filters`, { name: groupName, terms: mapFiltersToTerms(filterPredicates) }).then(
|
|
973
|
+
(res) => Promise.resolve(
|
|
974
|
+
dispatch(
|
|
975
|
+
actions3.addGroup({
|
|
976
|
+
groupName,
|
|
977
|
+
group: {
|
|
978
|
+
id: res.headers[headerNames.location].substring(res.headers[headerNames.location].lastIndexOf("/") + 1),
|
|
979
|
+
filters: filterPredicates
|
|
980
|
+
}
|
|
981
|
+
})
|
|
982
|
+
)
|
|
983
|
+
).then(() => {
|
|
984
|
+
const { cleanedFilters } = getGroupFilters(groupName, getState().devices.groups);
|
|
985
|
+
return Promise.all([
|
|
986
|
+
dispatch(actions3.setDeviceFilters(cleanedFilters)),
|
|
987
|
+
dispatch(setSnackbar2(...getGroupNotification(groupName, getState().devices.groups.selectedGroup))),
|
|
988
|
+
dispatch(getDynamicGroups())
|
|
989
|
+
]);
|
|
990
|
+
})
|
|
991
|
+
).catch((err) => commonErrorHandler(err, `Group could not be updated:`, dispatch))
|
|
992
|
+
);
|
|
993
|
+
var updateDynamicGroup = createAsyncThunk2(`${sliceName3}/updateDynamicGroup`, ({ groupName, filterPredicates }, { dispatch, getState }) => {
|
|
994
|
+
const filterId = getState().devices.groups.byId[groupName].id;
|
|
995
|
+
return general_api_default.delete(`${inventoryApiUrlV2}/filters/${filterId}`).then(() => Promise.resolve(dispatch(addDynamicGroup({ groupName, filterPredicates }))));
|
|
996
|
+
});
|
|
997
|
+
var removeDynamicGroup = createAsyncThunk2(`${sliceName3}/removeDynamicGroup`, (groupName, { dispatch, getState }) => {
|
|
998
|
+
const filterId = getState().devices.groups.byId[groupName].id;
|
|
999
|
+
return general_api_default.delete(`${inventoryApiUrlV2}/filters/${filterId}`).then(
|
|
1000
|
+
() => Promise.all([dispatch(actions3.removeGroup(groupName)), dispatch(setSnackbar2("Group was removed successfully", TIMEOUTS.fiveSeconds))])
|
|
1001
|
+
);
|
|
1002
|
+
});
|
|
1003
|
+
var getGroupFilters = (group, groupsState, filters = []) => {
|
|
1004
|
+
var _a;
|
|
1005
|
+
const groupName = group === UNGROUPED_GROUP.id || group === UNGROUPED_GROUP.name ? UNGROUPED_GROUP.id : group;
|
|
1006
|
+
const selectedGroup = groupsState.byId[groupName];
|
|
1007
|
+
const groupFilterLength = ((_a = selectedGroup == null ? void 0 : selectedGroup.filters) == null ? void 0 : _a.length) || 0;
|
|
1008
|
+
const cleanedFilters = groupFilterLength ? [...filters, ...selectedGroup.filters].filter(filtersFilter) : filters;
|
|
1009
|
+
return { cleanedFilters, groupName, selectedGroup, groupFilterLength };
|
|
1010
|
+
};
|
|
1011
|
+
var selectGroup = createAsyncThunk2(`${sliceName3}/selectGroup`, ({ group, filters = [] }, { dispatch, getState }) => {
|
|
1012
|
+
const { cleanedFilters, groupName, selectedGroup, groupFilterLength } = getGroupFilters(group, getState().devices.groups, filters);
|
|
1013
|
+
if (getSelectedGroup(getState()) === groupName && (filters.length === 0 && !groupFilterLength || filters.length === cleanedFilters.length)) {
|
|
1014
|
+
return Promise.resolve();
|
|
1015
|
+
}
|
|
1016
|
+
let tasks = [];
|
|
1017
|
+
if (groupFilterLength) {
|
|
1018
|
+
tasks.push(dispatch(actions3.setDeviceFilters(cleanedFilters)));
|
|
1019
|
+
} else {
|
|
1020
|
+
tasks.push(dispatch(actions3.setDeviceFilters(filters)));
|
|
1021
|
+
tasks.push(dispatch(getGroupDevices({ group: groupName, perPage: 1, shouldIncludeAllStates: true })));
|
|
1022
|
+
}
|
|
1023
|
+
const selectedGroupName = selectedGroup || !Object.keys(getGroupsById(getState())).length ? groupName : void 0;
|
|
1024
|
+
tasks.push(dispatch(actions3.selectGroup(selectedGroupName)));
|
|
1025
|
+
return Promise.all(tasks);
|
|
1026
|
+
});
|
|
1027
|
+
var getEarliestTs = (dateA = "", dateB = "") => !dateA || !dateB ? dateA || dateB : dateA < dateB ? dateA : dateB;
|
|
1028
|
+
var reduceReceivedDevices = (devices, ids, state, status) => devices.reduce(
|
|
1029
|
+
(accu, device) => {
|
|
1030
|
+
var _a, _b, _c;
|
|
1031
|
+
const stateDevice = getDeviceById(state, device.id);
|
|
1032
|
+
const {
|
|
1033
|
+
attributes: storedAttributes = {},
|
|
1034
|
+
identity_data: storedIdentity = {},
|
|
1035
|
+
monitor: storedMonitor = {},
|
|
1036
|
+
tags: storedTags = {},
|
|
1037
|
+
group: storedGroup
|
|
1038
|
+
} = stateDevice;
|
|
1039
|
+
const { identity, inventory, monitor, system = {}, tags } = mapDeviceAttributes(device.attributes);
|
|
1040
|
+
device.tags = __spreadValues(__spreadValues({}, storedTags), tags);
|
|
1041
|
+
device.group = (_a = system.group) != null ? _a : storedGroup;
|
|
1042
|
+
device.monitor = __spreadValues(__spreadValues({}, storedMonitor), monitor);
|
|
1043
|
+
device.identity_data = __spreadValues(__spreadValues(__spreadValues({}, storedIdentity), identity), device.identity_data ? device.identity_data : {});
|
|
1044
|
+
device.status = status ? status : device.status || identity.status;
|
|
1045
|
+
device.check_in_time_rounded = (_b = system.check_in_time) != null ? _b : stateDevice.check_in_time_rounded;
|
|
1046
|
+
device.check_in_time_exact = (_c = device.check_in_time) != null ? _c : stateDevice.check_in_time_exact;
|
|
1047
|
+
device.created_ts = getEarliestTs(getEarliestTs(system.created_ts, device.created_ts), stateDevice.created_ts);
|
|
1048
|
+
device.updated_ts = device.attributes ? device.updated_ts : stateDevice.updated_ts;
|
|
1049
|
+
device.isNew = new Date(device.created_ts) > new Date(state.app.newThreshold);
|
|
1050
|
+
device.isOffline = new Date(device.check_in_time_rounded) < new Date(state.app.offlineThreshold) || device.check_in_time_rounded === void 0;
|
|
1051
|
+
device.attributes = device.attributes ? __spreadValues(__spreadValues({}, storedAttributes), inventory) : storedAttributes;
|
|
1052
|
+
accu.devicesById[device.id] = __spreadValues(__spreadValues({}, stateDevice), device);
|
|
1053
|
+
accu.ids.push(device.id);
|
|
1054
|
+
return accu;
|
|
1055
|
+
},
|
|
1056
|
+
{ ids, devicesById: {} }
|
|
1057
|
+
);
|
|
1058
|
+
var getGroupDevices = createAsyncThunk2(`${sliceName3}/getGroupDevices`, (options, { dispatch, getState }) => {
|
|
1059
|
+
const _a = options, { group, shouldIncludeAllStates } = _a, remainder = __objRest(_a, ["group", "shouldIncludeAllStates"]);
|
|
1060
|
+
const { cleanedFilters: filterSelection } = getGroupFilters(group, getState().devices.groups);
|
|
1061
|
+
return Promise.resolve(
|
|
1062
|
+
dispatch(getDevicesByStatus(__spreadProps(__spreadValues({}, remainder), { filterSelection, group, status: shouldIncludeAllStates ? void 0 : DEVICE_STATES.accepted })))
|
|
1063
|
+
).unwrap().then((results) => {
|
|
1064
|
+
if (!group) {
|
|
1065
|
+
return Promise.resolve();
|
|
1066
|
+
}
|
|
1067
|
+
const { deviceAccu, total } = results[results.length - 1];
|
|
1068
|
+
const stateGroup = getState().devices.groups.byId[group];
|
|
1069
|
+
if (!stateGroup && !total && !deviceAccu.ids.length) {
|
|
1070
|
+
return Promise.resolve();
|
|
1071
|
+
}
|
|
1072
|
+
return Promise.resolve(
|
|
1073
|
+
dispatch(
|
|
1074
|
+
actions3.addGroup({
|
|
1075
|
+
group: {
|
|
1076
|
+
deviceIds: deviceAccu.ids.length === total || deviceAccu.ids.length > (stateGroup == null ? void 0 : stateGroup.deviceIds) ? deviceAccu.ids : stateGroup.deviceIds,
|
|
1077
|
+
total
|
|
1078
|
+
},
|
|
1079
|
+
groupName: group
|
|
1080
|
+
})
|
|
1081
|
+
)
|
|
1082
|
+
);
|
|
1083
|
+
});
|
|
1084
|
+
});
|
|
1085
|
+
var getAllGroupDevices = createAsyncThunk2(`${sliceName3}/getAllGroupDevices`, (group, { dispatch, getState }) => {
|
|
1086
|
+
if (!group || !!group && (!getGroupsById(getState())[group] || getGroupsById(getState())[group].filters.length)) {
|
|
1087
|
+
return Promise.resolve();
|
|
1088
|
+
}
|
|
1089
|
+
const { attributes, filterTerms } = prepareSearchArguments({
|
|
1090
|
+
filters: [],
|
|
1091
|
+
group,
|
|
1092
|
+
state: getState(),
|
|
1093
|
+
status: DEVICE_STATES.accepted
|
|
1094
|
+
});
|
|
1095
|
+
const getAllDevices = (perPage = MAX_PAGE_SIZE, page = defaultPage2, devices = []) => general_api_default.post(getSearchEndpoint(getState()), {
|
|
1096
|
+
page,
|
|
1097
|
+
per_page: perPage,
|
|
1098
|
+
filters: filterTerms,
|
|
1099
|
+
attributes
|
|
1100
|
+
}).then((res) => {
|
|
1101
|
+
const state = getState();
|
|
1102
|
+
const deviceAccu = reduceReceivedDevices(res.data, devices, state);
|
|
1103
|
+
dispatch(actions3.receivedDevices(deviceAccu.devicesById));
|
|
1104
|
+
const total = Number(res.headers[headerNames.total]);
|
|
1105
|
+
if (total > perPage * page) {
|
|
1106
|
+
return getAllDevices(perPage, page + 1, deviceAccu.ids);
|
|
1107
|
+
}
|
|
1108
|
+
return Promise.resolve(dispatch(actions3.addGroup({ group: { deviceIds: deviceAccu.ids, total: deviceAccu.ids.length }, groupName: group })));
|
|
1109
|
+
});
|
|
1110
|
+
return getAllDevices();
|
|
1111
|
+
});
|
|
1112
|
+
var getAllDynamicGroupDevices = createAsyncThunk2(`${sliceName3}/getAllDynamicGroupDevices`, (group, { dispatch, getState }) => {
|
|
1113
|
+
if (!!group && (!getGroupsById(getState())[group] || !getGroupsById(getState())[group].filters.length)) {
|
|
1114
|
+
return Promise.resolve();
|
|
1115
|
+
}
|
|
1116
|
+
const { attributes, filterTerms: filters } = prepareSearchArguments({
|
|
1117
|
+
filters: getState().devices.groups.byId[group].filters,
|
|
1118
|
+
state: getState(),
|
|
1119
|
+
status: DEVICE_STATES.accepted
|
|
1120
|
+
});
|
|
1121
|
+
const getAllDevices = (perPage = MAX_PAGE_SIZE, page = defaultPage2, devices = []) => general_api_default.post(getSearchEndpoint(getState()), { page, per_page: perPage, filters, attributes }).then((res) => {
|
|
1122
|
+
const state = getState();
|
|
1123
|
+
const deviceAccu = reduceReceivedDevices(res.data, devices, state);
|
|
1124
|
+
dispatch(actions3.receivedDevices(deviceAccu.devicesById));
|
|
1125
|
+
const total = Number(res.headers[headerNames.total]);
|
|
1126
|
+
if (total > deviceAccu.ids.length) {
|
|
1127
|
+
return getAllDevices(perPage, page + 1, deviceAccu.ids);
|
|
1128
|
+
}
|
|
1129
|
+
return Promise.resolve(dispatch(actions3.addGroup({ group: { deviceIds: deviceAccu.ids, total }, groupName: group })));
|
|
1130
|
+
});
|
|
1131
|
+
return getAllDevices();
|
|
1132
|
+
});
|
|
1133
|
+
var getDeviceById2 = createAsyncThunk2(
|
|
1134
|
+
`${sliceName3}/getDeviceById`,
|
|
1135
|
+
(id, { dispatch, getState }) => general_api_default.get(`${inventoryApiUrl}/devices/${id}`).then((res) => {
|
|
1136
|
+
const device = reduceReceivedDevices([res.data], [], getState()).devicesById[id];
|
|
1137
|
+
device.etag = res.headers.etag;
|
|
1138
|
+
dispatch(actions3.receivedDevice(device));
|
|
1139
|
+
return Promise.resolve(device);
|
|
1140
|
+
}).catch((err) => {
|
|
1141
|
+
const errMsg = extractErrorMessage(err);
|
|
1142
|
+
if (errMsg.includes("Not Found")) {
|
|
1143
|
+
console.log(`${id} does not have any inventory information`);
|
|
1144
|
+
const device = reduceReceivedDevices(
|
|
1145
|
+
[
|
|
1146
|
+
{
|
|
1147
|
+
id,
|
|
1148
|
+
attributes: [
|
|
1149
|
+
{ name: "status", value: "decomissioned", scope: "identity" },
|
|
1150
|
+
{ name: "decomissioned", value: "true", scope: "inventory" }
|
|
1151
|
+
]
|
|
1152
|
+
}
|
|
1153
|
+
],
|
|
1154
|
+
[],
|
|
1155
|
+
getState()
|
|
1156
|
+
).devicesById[id];
|
|
1157
|
+
dispatch(actions3.receivedDevice(device));
|
|
1158
|
+
}
|
|
1159
|
+
})
|
|
1160
|
+
);
|
|
1161
|
+
var getDeviceInfo = createAsyncThunk2(`${sliceName3}/getDeviceInfo`, (deviceId, { dispatch, getState }) => {
|
|
1162
|
+
const device = getDeviceById(getState(), deviceId);
|
|
1163
|
+
const { hasDeviceConfig, hasDeviceConnect, hasMonitor } = getTenantCapabilities(getState());
|
|
1164
|
+
const { canConfigure } = getUserCapabilities(getState());
|
|
1165
|
+
const integrations = getDeviceTwinIntegrations(getState());
|
|
1166
|
+
let tasks = [dispatch(getDeviceAuth(deviceId)), ...integrations.map((integration) => dispatch(getDeviceTwin({ deviceId, integration })))];
|
|
1167
|
+
if (hasDeviceConfig && canConfigure && [DEVICE_STATES.accepted, DEVICE_STATES.preauth].includes(device.status)) {
|
|
1168
|
+
tasks.push(dispatch(getDeviceConfig(deviceId)));
|
|
1169
|
+
}
|
|
1170
|
+
if (device.status === DEVICE_STATES.accepted) {
|
|
1171
|
+
tasks.push(dispatch(getDeviceById2(deviceId)));
|
|
1172
|
+
if (hasDeviceConnect) {
|
|
1173
|
+
tasks.push(dispatch(getDeviceConnect(deviceId)));
|
|
1174
|
+
}
|
|
1175
|
+
if (hasMonitor) {
|
|
1176
|
+
tasks.push(dispatch(getLatestDeviceAlerts({ id: deviceId })));
|
|
1177
|
+
tasks.push(dispatch(getDeviceMonitorConfig(deviceId)));
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
return Promise.all(tasks);
|
|
1181
|
+
});
|
|
1182
|
+
var deriveInactiveDevices = createAsyncThunk2(`${sliceName3}/deriveInactiveDevices`, (deviceIds, { dispatch, getState }) => {
|
|
1183
|
+
const yesterday = /* @__PURE__ */ new Date();
|
|
1184
|
+
yesterday.setDate(yesterday.getDate() - 1);
|
|
1185
|
+
const yesterdaysIsoString = yesterday.toISOString();
|
|
1186
|
+
const devices = deviceIds.reduce(
|
|
1187
|
+
(accu, id) => {
|
|
1188
|
+
const device = getDeviceById(getState(), id);
|
|
1189
|
+
if (device && device.updated_ts > yesterdaysIsoString) {
|
|
1190
|
+
accu.active.push(id);
|
|
1191
|
+
} else {
|
|
1192
|
+
accu.inactive.push(id);
|
|
1193
|
+
}
|
|
1194
|
+
return accu;
|
|
1195
|
+
},
|
|
1196
|
+
{ active: [], inactive: [] }
|
|
1197
|
+
);
|
|
1198
|
+
return dispatch(actions3.setInactiveDevices({ activeDeviceTotal: devices.active.length, inactiveDeviceTotal: devices.inactive.length }));
|
|
1199
|
+
});
|
|
1200
|
+
var getDeviceCount = createAsyncThunk2(
|
|
1201
|
+
`${sliceName3}/getDeviceCount`,
|
|
1202
|
+
(status, { dispatch, getState }) => general_api_default.post(getSearchEndpoint(getState()), {
|
|
1203
|
+
page: 1,
|
|
1204
|
+
per_page: 1,
|
|
1205
|
+
filters: mapFiltersToTerms([{ key: "status", value: status, operator: DEVICE_FILTERING_OPTIONS.$eq.key, scope: "identity" }]),
|
|
1206
|
+
attributes: defaultAttributes
|
|
1207
|
+
}).then((response) => {
|
|
1208
|
+
const count = Number(response.headers[headerNames.total]);
|
|
1209
|
+
if (status) {
|
|
1210
|
+
return dispatch(actions3.setDevicesCountByStatus({ count, status }));
|
|
1211
|
+
}
|
|
1212
|
+
return dispatch(actions3.setTotalDevices(count));
|
|
1213
|
+
})
|
|
1214
|
+
);
|
|
1215
|
+
var getAllDeviceCounts = createAsyncThunk2(
|
|
1216
|
+
`${sliceName3}/getAllDeviceCounts`,
|
|
1217
|
+
(_, { dispatch }) => Promise.all([DEVICE_STATES.accepted, DEVICE_STATES.pending].map((status) => dispatch(getDeviceCount(status))))
|
|
1218
|
+
);
|
|
1219
|
+
var getDeviceLimit = createAsyncThunk2(
|
|
1220
|
+
`${sliceName3}/getDeviceLimit`,
|
|
1221
|
+
(_, { dispatch }) => general_api_default.get(`${deviceAuthV2}/limits/max_devices`).then((res) => dispatch(actions3.setDeviceLimit(res.data.limit)))
|
|
1222
|
+
);
|
|
1223
|
+
var setDeviceListState = createAsyncThunk2(
|
|
1224
|
+
`${sliceName3}/setDeviceListState`,
|
|
1225
|
+
(_a, { dispatch, getState }) => {
|
|
1226
|
+
var _b = _a, { shouldSelectDevices = true, forceRefresh, fetchAuth = true } = _b, selectionState = __objRest(_b, ["shouldSelectDevices", "forceRefresh", "fetchAuth"]);
|
|
1227
|
+
var _c;
|
|
1228
|
+
const currentState = getDeviceListState(getState());
|
|
1229
|
+
const refreshTrigger = forceRefresh ? !currentState.refreshTrigger : selectionState.refreshTrigger;
|
|
1230
|
+
let nextState = __spreadProps(__spreadValues(__spreadProps(__spreadValues({}, currentState), {
|
|
1231
|
+
setOnly: false,
|
|
1232
|
+
refreshTrigger
|
|
1233
|
+
}), selectionState), {
|
|
1234
|
+
sort: __spreadValues(__spreadValues({}, currentState.sort), selectionState.sort)
|
|
1235
|
+
});
|
|
1236
|
+
let tasks = [];
|
|
1237
|
+
const _a2 = currentState, { isLoading: currentLoading, deviceIds: currentDevices, selection: currentSelection } = _a2, currentRequestState = __objRest(_a2, ["isLoading", "deviceIds", "selection"]);
|
|
1238
|
+
const _b2 = nextState, { isLoading: nextLoading, deviceIds: nextDevices, selection: nextSelection } = _b2, nextRequestState = __objRest(_b2, ["isLoading", "deviceIds", "selection"]);
|
|
1239
|
+
if (!nextState.setOnly && !deepCompare2(currentRequestState, nextRequestState)) {
|
|
1240
|
+
const { direction: sortDown = SORTING_OPTIONS.desc, key: sortCol, scope: sortScope } = (_c = nextState.sort) != null ? _c : {};
|
|
1241
|
+
const sortBy = sortCol ? [{ attribute: sortCol, order: sortDown, scope: sortScope }] : void 0;
|
|
1242
|
+
const applicableSelectedState = nextState.state === ALL_DEVICE_STATES ? void 0 : nextState.state;
|
|
1243
|
+
nextState.isLoading = true;
|
|
1244
|
+
tasks.push(
|
|
1245
|
+
dispatch(getDevicesByStatus(__spreadProps(__spreadValues({}, nextState), { status: applicableSelectedState, sortOptions: sortBy, fetchAuth }))).unwrap().then((results) => {
|
|
1246
|
+
const { deviceAccu, total } = results[results.length - 1];
|
|
1247
|
+
const devicesState = shouldSelectDevices ? { deviceIds: deviceAccu.ids, total, isLoading: false } : { isLoading: false };
|
|
1248
|
+
return Promise.resolve(dispatch(actions3.setDeviceListState(devicesState)));
|
|
1249
|
+
}).catch(() => Promise.resolve({ isLoading: false }))
|
|
1250
|
+
);
|
|
1251
|
+
}
|
|
1252
|
+
tasks.push(dispatch(actions3.setDeviceListState(nextState)));
|
|
1253
|
+
return Promise.all(tasks);
|
|
1254
|
+
}
|
|
1255
|
+
);
|
|
1256
|
+
var getDevicesByStatus = createAsyncThunk2(`${sliceName3}/getDevicesByStatus`, (options, { dispatch, getState }) => {
|
|
1257
|
+
const {
|
|
1258
|
+
status,
|
|
1259
|
+
fetchAuth = true,
|
|
1260
|
+
filterSelection,
|
|
1261
|
+
group,
|
|
1262
|
+
selectedIssues = [],
|
|
1263
|
+
page = defaultPage2,
|
|
1264
|
+
perPage = defaultPerPage2,
|
|
1265
|
+
sortOptions = [],
|
|
1266
|
+
selectedAttributes = []
|
|
1267
|
+
} = options;
|
|
1268
|
+
const state = getState();
|
|
1269
|
+
const { applicableFilters, filterTerms } = convertDeviceListStateToFilters({
|
|
1270
|
+
filters: filterSelection != null ? filterSelection : getDeviceFilters(state),
|
|
1271
|
+
group: group != null ? group : getSelectedGroup(state),
|
|
1272
|
+
groups: state.devices.groups,
|
|
1273
|
+
offlineThreshold: state.app.offlineThreshold,
|
|
1274
|
+
selectedIssues,
|
|
1275
|
+
status
|
|
1276
|
+
});
|
|
1277
|
+
const attributes = [...defaultAttributes, getIdAttribute(getState()), ...selectedAttributes];
|
|
1278
|
+
return general_api_default.post(getSearchEndpoint(getState()), {
|
|
1279
|
+
page,
|
|
1280
|
+
per_page: perPage,
|
|
1281
|
+
filters: filterTerms,
|
|
1282
|
+
sort: sortOptions,
|
|
1283
|
+
attributes
|
|
1284
|
+
}).then((response) => {
|
|
1285
|
+
const state2 = getState();
|
|
1286
|
+
const deviceAccu = reduceReceivedDevices(response.data, [], state2, status);
|
|
1287
|
+
let total = !applicableFilters.length ? Number(response.headers[headerNames.total]) : null;
|
|
1288
|
+
if (status && state2.devices.byStatus[status].total === deviceAccu.ids.length) {
|
|
1289
|
+
total = deviceAccu.ids.length;
|
|
1290
|
+
}
|
|
1291
|
+
let tasks = [dispatch(actions3.receivedDevices(deviceAccu.devicesById))];
|
|
1292
|
+
if (status) {
|
|
1293
|
+
tasks.push(dispatch(actions3.setDevicesByStatus({ deviceIds: deviceAccu.ids, status, total })));
|
|
1294
|
+
}
|
|
1295
|
+
const receivedDevices = Object.values(deviceAccu.devicesById);
|
|
1296
|
+
if (receivedDevices.length && fetchAuth) {
|
|
1297
|
+
tasks.push(dispatch(getDevicesWithAuth(receivedDevices)));
|
|
1298
|
+
}
|
|
1299
|
+
tasks.push(Promise.resolve({ deviceAccu, total: Number(response.headers[headerNames.total]) }));
|
|
1300
|
+
return Promise.all(tasks);
|
|
1301
|
+
}).catch((err) => commonErrorHandler(err, `${status} devices couldn't be loaded.`, dispatch, commonErrorFallback));
|
|
1302
|
+
});
|
|
1303
|
+
var getAllDevicesByStatus = createAsyncThunk2(`${sliceName3}/getAllDevicesByStatus`, (status, { dispatch, getState }) => {
|
|
1304
|
+
const attributes = [...defaultAttributes, getIdAttribute(getState())];
|
|
1305
|
+
const getAllDevices = (perPage = MAX_PAGE_SIZE, page = 1, devices = []) => general_api_default.post(getSearchEndpoint(getState()), {
|
|
1306
|
+
page,
|
|
1307
|
+
per_page: perPage,
|
|
1308
|
+
filters: mapFiltersToTerms([{ key: "status", value: status, operator: DEVICE_FILTERING_OPTIONS.$eq.key, scope: "identity" }]),
|
|
1309
|
+
attributes
|
|
1310
|
+
}).then((res) => {
|
|
1311
|
+
const state = getState();
|
|
1312
|
+
const deviceAccu = reduceReceivedDevices(res.data, devices, state, status);
|
|
1313
|
+
dispatch(actions3.receivedDevices(deviceAccu.devicesById));
|
|
1314
|
+
const total = Number(res.headers[headerNames.total]);
|
|
1315
|
+
if (total > state.deployments.deploymentDeviceLimit) {
|
|
1316
|
+
return Promise.resolve();
|
|
1317
|
+
}
|
|
1318
|
+
if (total > perPage * page) {
|
|
1319
|
+
return getAllDevices(perPage, page + 1, deviceAccu.ids);
|
|
1320
|
+
}
|
|
1321
|
+
let tasks = [dispatch(actions3.setDevicesByStatus({ deviceIds: deviceAccu.ids, forceUpdate: true, status, total: deviceAccu.ids.length }))];
|
|
1322
|
+
if (status === DEVICE_STATES.accepted && deviceAccu.ids.length === total) {
|
|
1323
|
+
tasks.push(dispatch(deriveInactiveDevices(deviceAccu.ids)));
|
|
1324
|
+
tasks.push(dispatch(deriveReportsData()));
|
|
1325
|
+
}
|
|
1326
|
+
return Promise.all(tasks);
|
|
1327
|
+
});
|
|
1328
|
+
return getAllDevices();
|
|
1329
|
+
});
|
|
1330
|
+
var searchDevices = createAsyncThunk2(`${sliceName3}/searchDevices`, (passedOptions = {}, { dispatch, getState }) => {
|
|
1331
|
+
const state = getState();
|
|
1332
|
+
let options = __spreadValues(__spreadValues({}, state.app.searchState), passedOptions);
|
|
1333
|
+
const { page = defaultPage2, searchTerm, sortOptions = [] } = options;
|
|
1334
|
+
const { columnSelection = [] } = getUserSettings(state);
|
|
1335
|
+
const selectedAttributes = columnSelection.map((column) => ({ attribute: column.key, scope: column.scope }));
|
|
1336
|
+
const attributes = attributeDuplicateFilter([...defaultAttributes, getIdAttribute(state), ...selectedAttributes], "attribute");
|
|
1337
|
+
return general_api_default.post(getSearchEndpoint(getState()), {
|
|
1338
|
+
page,
|
|
1339
|
+
per_page: 10,
|
|
1340
|
+
filters: [],
|
|
1341
|
+
sort: sortOptions,
|
|
1342
|
+
text: searchTerm,
|
|
1343
|
+
attributes
|
|
1344
|
+
}).then((response) => {
|
|
1345
|
+
const deviceAccu = reduceReceivedDevices(response.data, [], getState());
|
|
1346
|
+
return Promise.all([
|
|
1347
|
+
dispatch(actions3.receivedDevices(deviceAccu.devicesById)),
|
|
1348
|
+
Promise.resolve({ deviceIds: deviceAccu.ids, searchTotal: Number(response.headers[headerNames.total]) })
|
|
1349
|
+
]);
|
|
1350
|
+
}).catch((err) => commonErrorHandler(err, `devices couldn't be searched.`, dispatch, commonErrorFallback));
|
|
1351
|
+
});
|
|
1352
|
+
var ATTRIBUTE_LIST_CUTOFF = 100;
|
|
1353
|
+
var attributeReducer = (attributes = []) => attributes.slice(0, ATTRIBUTE_LIST_CUTOFF).reduce(
|
|
1354
|
+
(accu, { name, scope }) => {
|
|
1355
|
+
if (!accu[scope]) {
|
|
1356
|
+
accu[scope] = [];
|
|
1357
|
+
}
|
|
1358
|
+
accu[scope].push(name);
|
|
1359
|
+
return accu;
|
|
1360
|
+
},
|
|
1361
|
+
{ identity: [], inventory: [], system: [], tags: [] }
|
|
1362
|
+
);
|
|
1363
|
+
var getDeviceAttributes = createAsyncThunk2(
|
|
1364
|
+
`${sliceName3}/getDeviceAttributes`,
|
|
1365
|
+
(_, { dispatch, getState }) => general_api_default.get(getAttrsEndpoint(getState())).then(({ data }) => {
|
|
1366
|
+
const { identity: identityAttributes, inventory: inventoryAttributes, system: systemAttributes, tags: tagAttributes } = attributeReducer(data || []);
|
|
1367
|
+
return dispatch(actions3.setFilterAttributes({ identityAttributes, inventoryAttributes, systemAttributes, tagAttributes }));
|
|
1368
|
+
})
|
|
1369
|
+
);
|
|
1370
|
+
var getReportingLimits = createAsyncThunk2(
|
|
1371
|
+
`${sliceName3}/getReportingLimits`,
|
|
1372
|
+
(_, { dispatch }) => general_api_default.get(`${reportingApiUrl}/devices/attributes`).catch((err) => commonErrorHandler(err, `filterable attributes limit & usage could not be retrieved.`, dispatch, commonErrorFallback)).then(({ data }) => {
|
|
1373
|
+
const { attributes, count, limit } = data;
|
|
1374
|
+
const groupedAttributes = attributeReducer(attributes);
|
|
1375
|
+
return Promise.resolve(dispatch(actions3.setFilterablesConfig({ count, limit, attributes: groupedAttributes })));
|
|
1376
|
+
})
|
|
1377
|
+
);
|
|
1378
|
+
var ensureVersionString = (software, fallback) => software.length && software !== "artifact_name" ? software.endsWith(".version") ? software : `${software}.version` : fallback;
|
|
1379
|
+
var REPORT_CHART_SIZE_LIMIT = 6;
|
|
1380
|
+
var getSingleReportData = (reportConfig, groups) => {
|
|
1381
|
+
const { attribute, group, software = "" } = reportConfig;
|
|
1382
|
+
const filters = [{ key: "status", scope: "identity", operator: DEVICE_FILTERING_OPTIONS.$eq.key, value: "accepted" }];
|
|
1383
|
+
if (group) {
|
|
1384
|
+
const staticGroupFilter = { key: "group", scope: "system", operator: DEVICE_FILTERING_OPTIONS.$eq.key, value: group };
|
|
1385
|
+
const { cleanedFilters: groupFilters } = getGroupFilters(group, groups);
|
|
1386
|
+
filters.push(...groupFilters.length ? groupFilters : [staticGroupFilter]);
|
|
1387
|
+
}
|
|
1388
|
+
const aggregationAttribute = ensureVersionString(software, attribute);
|
|
1389
|
+
return general_api_default.post(`${reportingApiUrl}/devices/aggregate`, {
|
|
1390
|
+
aggregations: [{ attribute: aggregationAttribute, name: "*", scope: "inventory", size: REPORT_CHART_SIZE_LIMIT }],
|
|
1391
|
+
filters: mapFiltersToTerms(filters)
|
|
1392
|
+
}).then(({ data }) => ({ data, reportConfig }));
|
|
1393
|
+
};
|
|
1394
|
+
var getReportsData = createAsyncThunk2(`${sliceName3}/getReportsData`, (_, { dispatch, getState }) => {
|
|
1395
|
+
const state = getState();
|
|
1396
|
+
const currentUserId = getCurrentUser(state).id;
|
|
1397
|
+
const reports = getUserSettings(state).reports || getGlobalSettings(state)[`${currentUserId}-reports`] || (Object.keys(getDevicesById(state)).length ? defaultReports : []);
|
|
1398
|
+
return Promise.all(reports.map((report) => getSingleReportData(report, getState().devices.groups))).then((results) => {
|
|
1399
|
+
const devicesState = getState().devices;
|
|
1400
|
+
const totalDeviceCount = devicesState.byStatus.accepted.total;
|
|
1401
|
+
const newReports = results.map(({ data, reportConfig }) => {
|
|
1402
|
+
let { items, other_count } = data[0];
|
|
1403
|
+
const { attribute, group, software = "" } = reportConfig;
|
|
1404
|
+
const dataCount = items.reduce((accu, item) => accu + item.count, 0);
|
|
1405
|
+
const otherCount = !group && (software === rootfsImageVersion || attribute === "artifact_name") ? totalDeviceCount - dataCount : other_count;
|
|
1406
|
+
return { items, otherCount, total: otherCount + dataCount };
|
|
1407
|
+
});
|
|
1408
|
+
return Promise.resolve(dispatch(actions3.setDeviceReports(newReports)));
|
|
1409
|
+
});
|
|
1410
|
+
});
|
|
1411
|
+
var initializeDistributionData = (report, groups, devices, totalDeviceCount) => {
|
|
1412
|
+
const { attribute, group = "", software = "" } = report;
|
|
1413
|
+
const effectiveAttribute = software ? software : attribute;
|
|
1414
|
+
const { deviceIds, total = 0 } = groups[group] || {};
|
|
1415
|
+
const relevantDevices = groups[group] ? deviceIds.map((id) => devices[id]) : Object.values(devices);
|
|
1416
|
+
const distributionByAttribute = relevantDevices.reduce((accu, item) => {
|
|
1417
|
+
if (!item.attributes || item.status !== DEVICE_STATES.accepted) return accu;
|
|
1418
|
+
if (!accu[item.attributes[effectiveAttribute]]) {
|
|
1419
|
+
accu[item.attributes[effectiveAttribute]] = 0;
|
|
1420
|
+
}
|
|
1421
|
+
accu[item.attributes[effectiveAttribute]] = accu[item.attributes[effectiveAttribute]] + 1;
|
|
1422
|
+
return accu;
|
|
1423
|
+
}, {});
|
|
1424
|
+
const distributionByAttributeSorted = Object.entries(distributionByAttribute).sort((pairA, pairB) => pairB[1] - pairA[1]);
|
|
1425
|
+
const items = distributionByAttributeSorted.map(([key, count]) => ({ key, count }));
|
|
1426
|
+
const dataCount = items.reduce((accu, item) => accu + item.count, 0);
|
|
1427
|
+
const otherCount = (groups[group] ? total : totalDeviceCount) - dataCount;
|
|
1428
|
+
return { items, otherCount, total: otherCount + dataCount };
|
|
1429
|
+
};
|
|
1430
|
+
var deriveReportsData = createAsyncThunk2(`${sliceName3}/deriveReportsData`, (_, { dispatch, getState }) => {
|
|
1431
|
+
const state = getState();
|
|
1432
|
+
const {
|
|
1433
|
+
groups: { byId: groupsById },
|
|
1434
|
+
byId,
|
|
1435
|
+
byStatus: {
|
|
1436
|
+
accepted: { total }
|
|
1437
|
+
}
|
|
1438
|
+
} = state.devices;
|
|
1439
|
+
const reports = getUserSettings(state).reports || state.users.globalSettings[`${state.users.currentUser}-reports`] || (Object.keys(byId).length ? defaultReports : []);
|
|
1440
|
+
const newReports = reports.map((report) => initializeDistributionData(report, groupsById, byId, total));
|
|
1441
|
+
return Promise.resolve(dispatch(actions3.setDeviceReports(newReports)));
|
|
1442
|
+
});
|
|
1443
|
+
var getReportsDataWithoutBackendSupport = createAsyncThunk2(
|
|
1444
|
+
`${sliceName3}/getReportsDataWithoutBackendSupport`,
|
|
1445
|
+
(_, { dispatch, getState }) => Promise.all([dispatch(getAllDevicesByStatus(DEVICE_STATES.accepted)), dispatch(getGroups2()), dispatch(getDynamicGroups())]).then(() => {
|
|
1446
|
+
const { dynamic: dynamicGroups, static: staticGroups } = getGroups(getState());
|
|
1447
|
+
return Promise.all([
|
|
1448
|
+
...staticGroups.map(({ groupId }) => dispatch(getAllGroupDevices(groupId))),
|
|
1449
|
+
...dynamicGroups.map(({ groupId }) => dispatch(getAllDynamicGroupDevices(groupId)))
|
|
1450
|
+
]).then(() => dispatch(deriveReportsData()));
|
|
1451
|
+
})
|
|
1452
|
+
);
|
|
1453
|
+
var getDeviceConnect = createAsyncThunk2(
|
|
1454
|
+
`${sliceName3}/getDeviceConnect`,
|
|
1455
|
+
(id, { dispatch }) => general_api_default.get(`${deviceConnect}/devices/${id}`).then(
|
|
1456
|
+
({ data }) => Promise.all([dispatch(actions3.receivedDevice({ connect_status: data.status, connect_updated_ts: data.updated_ts, id })), Promise.resolve(data)])
|
|
1457
|
+
)
|
|
1458
|
+
);
|
|
1459
|
+
var getSessionDetails = createAsyncThunk2(`${sliceName3}/getSessionDetails`, ({ sessionId, deviceId, userId, startDate, endDate }) => {
|
|
1460
|
+
const createdAfter = startDate ? `&created_after=${Math.round(Date.parse(startDate) / 1e3)}` : "";
|
|
1461
|
+
const createdBefore = endDate ? `&created_before=${Math.round(Date.parse(endDate) / 1e3)}` : "";
|
|
1462
|
+
const objectSearch = `&object_id=${deviceId}`;
|
|
1463
|
+
return general_api_default.get(`${auditLogsApiUrl}/logs?per_page=500${createdAfter}${createdBefore}&actor_id=${userId}${objectSearch}`).then(
|
|
1464
|
+
({ data: auditLogEntries }) => {
|
|
1465
|
+
const { start, end } = auditLogEntries.reduce(
|
|
1466
|
+
(accu, item) => {
|
|
1467
|
+
var _a, _b;
|
|
1468
|
+
if ((_b = (_a = item.meta) == null ? void 0 : _a.session_id) == null ? void 0 : _b.includes(sessionId)) {
|
|
1469
|
+
accu.start = new Date(item.action.startsWith("open") ? item.time : accu.start);
|
|
1470
|
+
accu.end = new Date(item.action.startsWith("close") ? item.time : accu.end);
|
|
1471
|
+
}
|
|
1472
|
+
return accu;
|
|
1473
|
+
},
|
|
1474
|
+
{ start: startDate || endDate, end: endDate || startDate }
|
|
1475
|
+
);
|
|
1476
|
+
return Promise.resolve({ start, end });
|
|
1477
|
+
}
|
|
1478
|
+
);
|
|
1479
|
+
});
|
|
1480
|
+
var getDeviceFileDownloadLink = createAsyncThunk2(
|
|
1481
|
+
`${sliceName3}/getDeviceFileDownloadLink`,
|
|
1482
|
+
({ deviceId, path }) => Promise.resolve(`${window.location.origin}${deviceConnect}/devices/${deviceId}/download?path=${encodeURIComponent(path)}`)
|
|
1483
|
+
);
|
|
1484
|
+
var deviceFileUpload = createAsyncThunk2(`${sliceName3}/deviceFileUpload`, ({ deviceId, path, file }, { dispatch }) => {
|
|
1485
|
+
let formData = new FormData();
|
|
1486
|
+
formData.append("path", path);
|
|
1487
|
+
formData.append("file", file);
|
|
1488
|
+
const uploadId = v4_default();
|
|
1489
|
+
const cancelSource = new AbortController();
|
|
1490
|
+
return Promise.all([
|
|
1491
|
+
dispatch(setSnackbar2("Uploading file")),
|
|
1492
|
+
dispatch(initUpload({ id: uploadId, upload: { inprogress: true, uploadProgress: 0, cancelSource } })),
|
|
1493
|
+
general_api_default.uploadPut(
|
|
1494
|
+
`${deviceConnect}/devices/${deviceId}/upload`,
|
|
1495
|
+
formData,
|
|
1496
|
+
(e) => dispatch(uploadProgress({ id: uploadId, progress: progress(e) })),
|
|
1497
|
+
cancelSource.signal
|
|
1498
|
+
)
|
|
1499
|
+
]).then(() => Promise.resolve(dispatch(setSnackbar2("Upload successful", TIMEOUTS.fiveSeconds)))).catch((err) => {
|
|
1500
|
+
if (isCancel(err)) {
|
|
1501
|
+
return dispatch(setSnackbar2("The upload has been cancelled", TIMEOUTS.fiveSeconds));
|
|
1502
|
+
}
|
|
1503
|
+
return commonErrorHandler(err, `Error uploading file to device.`, dispatch);
|
|
1504
|
+
}).finally(() => dispatch(cleanUpUpload(uploadId)));
|
|
1505
|
+
});
|
|
1506
|
+
var getDeviceAuth = createAsyncThunk2(
|
|
1507
|
+
`${sliceName3}/getDeviceAuth`,
|
|
1508
|
+
(id, { dispatch }) => dispatch(getDevicesWithAuth([{ id }])).unwrap().then((results) => {
|
|
1509
|
+
if (results[results.length - 1]) {
|
|
1510
|
+
return Promise.resolve(results[results.length - 1][0]);
|
|
1511
|
+
}
|
|
1512
|
+
return Promise.resolve();
|
|
1513
|
+
})
|
|
1514
|
+
);
|
|
1515
|
+
var getDevicesWithAuth = createAsyncThunk2(
|
|
1516
|
+
`${sliceName3}/getDevicesWithAuth`,
|
|
1517
|
+
(devices, { dispatch, getState }) => devices.length ? general_api_default.get(`${deviceAuthV2}/devices?id=${devices.map((device) => device.id).join("&id=")}`).then(({ data: receivedDevices }) => {
|
|
1518
|
+
const { devicesById } = reduceReceivedDevices(receivedDevices, [], getState());
|
|
1519
|
+
return Promise.all([dispatch(actions3.receivedDevices(devicesById)), Promise.resolve(receivedDevices)]);
|
|
1520
|
+
}).catch((err) => commonErrorHandler(err, `Error: ${err}`, dispatch)) : Promise.resolve([[], []])
|
|
1521
|
+
);
|
|
1522
|
+
var updateDeviceAuth = createAsyncThunk2(
|
|
1523
|
+
`${sliceName3}/updateDeviceAuth`,
|
|
1524
|
+
({ deviceId, authId, status }, { dispatch, getState }) => general_api_default.put(`${deviceAuthV2}/devices/${deviceId}/auth/${authId}/status`, { status }).then(() => Promise.all([dispatch(getDeviceAuth(deviceId)), dispatch(setSnackbar2("Device authorization status was updated successfully"))])).catch((err) => commonErrorHandler(err, "There was a problem updating the device authorization status:", dispatch)).then(() => Promise.resolve(dispatch(actions3.maybeUpdateDevicesByStatus({ deviceId, authId })))).finally(() => dispatch(setDeviceListState({ refreshTrigger: !getDeviceListState(getState()).refreshTrigger })))
|
|
1525
|
+
);
|
|
1526
|
+
var updateDevicesAuth = createAsyncThunk2(`${sliceName3}/updateDevicesAuth`, ({ deviceIds, status }, { dispatch, getState }) => {
|
|
1527
|
+
let devices = getDevicesById(getState());
|
|
1528
|
+
const deviceIdsWithoutAuth = deviceIds.reduce((accu, id) => devices[id].auth_sets ? accu : [...accu, { id }], []);
|
|
1529
|
+
return dispatch(getDevicesWithAuth(deviceIdsWithoutAuth)).then(() => {
|
|
1530
|
+
devices = getDevicesById(getState());
|
|
1531
|
+
const deviceAuthUpdates = deviceIds.map((id) => {
|
|
1532
|
+
const device = devices[id];
|
|
1533
|
+
if (device.auth_sets.length !== 1) {
|
|
1534
|
+
return Promise.reject();
|
|
1535
|
+
}
|
|
1536
|
+
return dispatch(updateDeviceAuth({ authId: device.auth_sets[0].id, deviceId: device.id, status })).unwrap().catch((err) => commonErrorHandler(err, "The action was stopped as there was a problem updating a device authorization status: ", dispatch, "", false));
|
|
1537
|
+
});
|
|
1538
|
+
return Promise.allSettled(deviceAuthUpdates).then((results) => {
|
|
1539
|
+
const { skipped, count } = results.reduce(
|
|
1540
|
+
(accu, item) => {
|
|
1541
|
+
if (item.status === "rejected") {
|
|
1542
|
+
accu.skipped = accu.skipped + 1;
|
|
1543
|
+
} else {
|
|
1544
|
+
accu.count = accu.count + 1;
|
|
1545
|
+
}
|
|
1546
|
+
return accu;
|
|
1547
|
+
},
|
|
1548
|
+
{ skipped: 0, count: 0 }
|
|
1549
|
+
);
|
|
1550
|
+
const message = getSnackbarMessage(skipped, count);
|
|
1551
|
+
return dispatch(setSnackbar2(message));
|
|
1552
|
+
});
|
|
1553
|
+
});
|
|
1554
|
+
});
|
|
1555
|
+
var deleteAuthset = createAsyncThunk2(
|
|
1556
|
+
`${sliceName3}/deleteAuthset`,
|
|
1557
|
+
({ deviceId, authId }, { dispatch, getState }) => general_api_default.delete(`${deviceAuthV2}/devices/${deviceId}/auth/${authId}`).then(() => Promise.all([dispatch(setSnackbar2("Device authorization status was updated successfully"))])).catch((err) => commonErrorHandler(err, "There was a problem updating the device authorization status:", dispatch)).then(() => Promise.resolve(dispatch(actions3.maybeUpdateDevicesByStatus({ deviceId, authId })))).finally(() => dispatch(setDeviceListState({ refreshTrigger: !getState().devices.deviceList.refreshTrigger })))
|
|
1558
|
+
);
|
|
1559
|
+
var preauthDevice = createAsyncThunk2(
|
|
1560
|
+
`${sliceName3}/preauthDevice`,
|
|
1561
|
+
(authset, { dispatch }) => general_api_default.post(`${deviceAuthV2}/devices`, authset).catch((err) => {
|
|
1562
|
+
if (err.response.status === 409) {
|
|
1563
|
+
return Promise.reject("A device with a matching identity data set already exists");
|
|
1564
|
+
}
|
|
1565
|
+
return commonErrorHandler(err, "The device could not be added:", dispatch);
|
|
1566
|
+
}).then(() => Promise.resolve(dispatch(setSnackbar2("Device was successfully added to the preauthorization list", TIMEOUTS.fiveSeconds))))
|
|
1567
|
+
);
|
|
1568
|
+
var decommissionDevice = createAsyncThunk2(
|
|
1569
|
+
`${sliceName3}/decommissionDevice`,
|
|
1570
|
+
({ deviceId, authId }, { dispatch, getState }) => general_api_default.delete(`${deviceAuthV2}/devices/${deviceId}`).then(() => Promise.resolve(dispatch(setSnackbar2("Device was decommissioned successfully")))).catch((err) => commonErrorHandler(err, "There was a problem decommissioning the device:", dispatch)).then(() => Promise.resolve(dispatch(actions3.maybeUpdateDevicesByStatus({ deviceId, authId })))).finally(() => dispatch(setDeviceListState({ refreshTrigger: !getState().devices.deviceList.refreshTrigger })))
|
|
1571
|
+
);
|
|
1572
|
+
var getDeviceConfig = createAsyncThunk2(
|
|
1573
|
+
`${sliceName3}/getDeviceConfig`,
|
|
1574
|
+
(deviceId, { dispatch }) => general_api_default.get(`${deviceConfig}/${deviceId}`).then(({ data }) => Promise.all([dispatch(actions3.receivedDevice({ id: deviceId, config: data })), Promise.resolve(data)])).catch((err) => {
|
|
1575
|
+
var _a, _b;
|
|
1576
|
+
if (((_b = (_a = err.response) == null ? void 0 : _a.data) == null ? void 0 : _b.error.status_code) !== 404) {
|
|
1577
|
+
return commonErrorHandler(err, `There was an error retrieving the configuration for device ${deviceId}.`, dispatch, commonErrorFallback);
|
|
1578
|
+
}
|
|
1579
|
+
})
|
|
1580
|
+
);
|
|
1581
|
+
var setDeviceConfig = createAsyncThunk2(
|
|
1582
|
+
`${sliceName3}/setDeviceConfig`,
|
|
1583
|
+
({ deviceId, config }, { dispatch }) => general_api_default.put(`${deviceConfig}/${deviceId}`, config).catch((err) => commonErrorHandler(err, `There was an error setting the configuration for device ${deviceId}.`, dispatch, commonErrorFallback)).then(() => Promise.resolve(dispatch(getDeviceConfig(deviceId))))
|
|
1584
|
+
);
|
|
1585
|
+
var applyDeviceConfig = createAsyncThunk2(
|
|
1586
|
+
`${sliceName3}/applyDeviceConfig`,
|
|
1587
|
+
({ deviceId, configDeploymentConfiguration, isDefault, config }, { dispatch, getState }) => general_api_default.post(`${deviceConfig}/${deviceId}/deploy`, configDeploymentConfiguration).catch((err) => commonErrorHandler(err, `There was an error deploying the configuration to device ${deviceId}.`, dispatch, commonErrorFallback)).then(({ data }) => {
|
|
1588
|
+
var _a;
|
|
1589
|
+
const device = getDeviceById(getState(), deviceId);
|
|
1590
|
+
const { canManageUsers } = getUserCapabilities(getState());
|
|
1591
|
+
let tasks = [
|
|
1592
|
+
dispatch(actions3.receivedDevice(__spreadProps(__spreadValues({}, device), { config: __spreadProps(__spreadValues({}, device.config), { deployment_id: data.deployment_id }) }))),
|
|
1593
|
+
new Promise((resolve) => setTimeout(() => resolve(dispatch(getSingleDeployment(data.deployment_id))), TIMEOUTS.oneSecond))
|
|
1594
|
+
];
|
|
1595
|
+
if (isDefault && canManageUsers) {
|
|
1596
|
+
const { previous } = (_a = getGlobalSettings(getState()).defaultDeviceConfig) != null ? _a : {};
|
|
1597
|
+
tasks.push(dispatch(saveGlobalSettings({ defaultDeviceConfig: { current: config, previous } })));
|
|
1598
|
+
}
|
|
1599
|
+
return Promise.all(tasks);
|
|
1600
|
+
})
|
|
1601
|
+
);
|
|
1602
|
+
var setDeviceTags = createAsyncThunk2(
|
|
1603
|
+
`${sliceName3}/setDeviceTags`,
|
|
1604
|
+
({ deviceId, tags }, { dispatch }) => (
|
|
1605
|
+
// to prevent tag set failures, retrieve the device & use the freshest etag we can get
|
|
1606
|
+
Promise.resolve(dispatch(getDeviceById2(deviceId))).then((device) => {
|
|
1607
|
+
const headers = device.etag ? { "If-Match": device.etag } : {};
|
|
1608
|
+
return general_api_default.put(
|
|
1609
|
+
`${inventoryApiUrl}/devices/${deviceId}/tags`,
|
|
1610
|
+
Object.entries(tags).map(([name, value]) => ({ name, value })),
|
|
1611
|
+
{ headers }
|
|
1612
|
+
).catch((err) => commonErrorHandler(err, `There was an error setting tags for device ${deviceId}.`, dispatch, "Please check your connection.")).then(() => Promise.all([dispatch(actions3.receivedDevice(__spreadProps(__spreadValues({}, device), { id: deviceId, tags }))), dispatch(setSnackbar2("Device name changed"))]));
|
|
1613
|
+
})
|
|
1614
|
+
)
|
|
1615
|
+
);
|
|
1616
|
+
var getDeviceTwin = createAsyncThunk2(`${sliceName3}/getDeviceTwin`, ({ deviceId, integration }, { dispatch, getState }) => {
|
|
1617
|
+
let providerResult = {};
|
|
1618
|
+
return general_api_default.get(`${iotManagerBaseURL}/devices/${deviceId}/state`).then(({ data }) => {
|
|
1619
|
+
providerResult = __spreadProps(__spreadValues({}, data), { twinError: "" });
|
|
1620
|
+
}).catch((err) => {
|
|
1621
|
+
providerResult = {
|
|
1622
|
+
twinError: `There was an error getting the ${EXTERNAL_PROVIDER[integration.provider].twinTitle.toLowerCase()} for device ${deviceId}. ${err}`
|
|
1623
|
+
};
|
|
1624
|
+
}).finally(() => {
|
|
1625
|
+
const device = getDeviceById(getState(), deviceId);
|
|
1626
|
+
Promise.resolve(dispatch(actions3.receivedDevice(__spreadProps(__spreadValues({}, device), { twinsByIntegration: __spreadValues(__spreadValues({}, device.twinsByIntegration), providerResult) }))));
|
|
1627
|
+
});
|
|
1628
|
+
});
|
|
1629
|
+
var setDeviceTwin = createAsyncThunk2(
|
|
1630
|
+
`${sliceName3}/setDeviceTwin`,
|
|
1631
|
+
({ deviceId, integration, settings }, { dispatch, getState }) => general_api_default.put(`${iotManagerBaseURL}/devices/${deviceId}/state/${integration.id}`, { desired: settings }).catch(
|
|
1632
|
+
(err) => commonErrorHandler(
|
|
1633
|
+
err,
|
|
1634
|
+
`There was an error updating the ${EXTERNAL_PROVIDER[integration.provider].twinTitle.toLowerCase()} for device ${deviceId}.`,
|
|
1635
|
+
dispatch
|
|
1636
|
+
)
|
|
1637
|
+
).then(() => {
|
|
1638
|
+
const device = getDeviceById(getState(), deviceId);
|
|
1639
|
+
const { twinsByIntegration = {} } = device;
|
|
1640
|
+
const { [integration.id]: currentState = {} } = twinsByIntegration;
|
|
1641
|
+
return Promise.resolve(
|
|
1642
|
+
dispatch(actions3.receivedDevice(__spreadProps(__spreadValues({}, device), { twinsByIntegration: __spreadProps(__spreadValues({}, twinsByIntegration), { [integration.id]: __spreadProps(__spreadValues({}, currentState), { desired: settings }) }) })))
|
|
1643
|
+
);
|
|
1644
|
+
})
|
|
1645
|
+
);
|
|
1646
|
+
var prepareSearchArguments = ({ filters, group, state, status }) => {
|
|
1647
|
+
const { filterTerms } = convertDeviceListStateToFilters({ filters, group, offlineThreshold: state.app.offlineThreshold, selectedIssues: [], status });
|
|
1648
|
+
const { columnSelection = [] } = getUserSettings(state);
|
|
1649
|
+
const selectedAttributes = columnSelection.map((column) => ({ attribute: column.key, scope: column.scope }));
|
|
1650
|
+
const attributes = [...defaultAttributes, getIdAttribute(state), ...selectedAttributes];
|
|
1651
|
+
return { attributes, filterTerms };
|
|
1652
|
+
};
|
|
1653
|
+
var getSystemDevices = createAsyncThunk2(`${sliceName3}/getSystemDevices`, (options, { dispatch, getState }) => {
|
|
1654
|
+
const { id, page = defaultPage2, perPage = defaultPerPage2, sortOptions = [] } = options;
|
|
1655
|
+
const state = getState();
|
|
1656
|
+
const { hasFullFiltering } = getTenantCapabilities(state);
|
|
1657
|
+
if (!hasFullFiltering) {
|
|
1658
|
+
return Promise.resolve();
|
|
1659
|
+
}
|
|
1660
|
+
const { attributes: deviceAttributes = {} } = getDeviceById(state, id);
|
|
1661
|
+
const { mender_gateway_system_id = "" } = deviceAttributes;
|
|
1662
|
+
const filters = [
|
|
1663
|
+
__spreadProps(__spreadValues({}, emptyFilter), { key: "mender_is_gateway", operator: DEVICE_FILTERING_OPTIONS.$ne.key, value: "true", scope: "inventory" }),
|
|
1664
|
+
__spreadProps(__spreadValues({}, emptyFilter), { key: "mender_gateway_system_id", value: mender_gateway_system_id, scope: "inventory" })
|
|
1665
|
+
];
|
|
1666
|
+
const { attributes, filterTerms } = prepareSearchArguments({ filters, state });
|
|
1667
|
+
return general_api_default.post(getSearchEndpoint(getState()), {
|
|
1668
|
+
page,
|
|
1669
|
+
per_page: perPage,
|
|
1670
|
+
filters: filterTerms,
|
|
1671
|
+
sort: sortOptions,
|
|
1672
|
+
attributes
|
|
1673
|
+
}).catch((err) => commonErrorHandler(err, `There was an error getting system devices device ${id}.`, dispatch, "Please check your connection.")).then(({ data, headers }) => {
|
|
1674
|
+
const state2 = getState();
|
|
1675
|
+
const { devicesById, ids } = reduceReceivedDevices(data, [], state2);
|
|
1676
|
+
const device = __spreadProps(__spreadValues({}, getDeviceById(state2, id)), {
|
|
1677
|
+
systemDeviceIds: ids,
|
|
1678
|
+
systemDeviceTotal: Number(headers[headerNames.total])
|
|
1679
|
+
});
|
|
1680
|
+
return Promise.resolve(dispatch(actions3.receivedDevices(__spreadProps(__spreadValues({}, devicesById), { [id]: device }))));
|
|
1681
|
+
});
|
|
1682
|
+
});
|
|
1683
|
+
var getGatewayDevices = createAsyncThunk2(`${sliceName3}/getGatewayDevices`, (deviceId, { dispatch, getState }) => {
|
|
1684
|
+
const state = getState();
|
|
1685
|
+
const { attributes = {} } = getDeviceById(state, deviceId);
|
|
1686
|
+
const { mender_gateway_system_id = "" } = attributes;
|
|
1687
|
+
const filters = [
|
|
1688
|
+
__spreadProps(__spreadValues({}, emptyFilter), { key: "id", operator: DEVICE_FILTERING_OPTIONS.$ne.key, value: deviceId, scope: "identity" }),
|
|
1689
|
+
__spreadProps(__spreadValues({}, emptyFilter), { key: "mender_is_gateway", value: "true", scope: "inventory" }),
|
|
1690
|
+
__spreadProps(__spreadValues({}, emptyFilter), { key: "mender_gateway_system_id", value: mender_gateway_system_id, scope: "inventory" })
|
|
1691
|
+
];
|
|
1692
|
+
const { attributes: attributeSelection, filterTerms } = prepareSearchArguments({ filters, state });
|
|
1693
|
+
return general_api_default.post(getSearchEndpoint(getState()), {
|
|
1694
|
+
page: 1,
|
|
1695
|
+
per_page: MAX_PAGE_SIZE,
|
|
1696
|
+
filters: filterTerms,
|
|
1697
|
+
attributes: attributeSelection
|
|
1698
|
+
}).then(({ data }) => {
|
|
1699
|
+
const { ids } = reduceReceivedDevices(data, [], getState());
|
|
1700
|
+
let tasks = ids.map((deviceId2) => dispatch(getDeviceInfo(deviceId2)));
|
|
1701
|
+
tasks.push(dispatch(actions3.receivedDevice({ id: deviceId, gatewayIds: ids })));
|
|
1702
|
+
return Promise.all(tasks);
|
|
1703
|
+
});
|
|
1704
|
+
});
|
|
1705
|
+
var getDevicesInBounds = createAsyncThunk2(`${sliceName3}/getDevicesInBounds`, ({ bounds, group }, { dispatch, getState }) => {
|
|
1706
|
+
const state = getState();
|
|
1707
|
+
const { filterTerms } = convertDeviceListStateToFilters({
|
|
1708
|
+
group: group === ALL_DEVICES ? void 0 : group,
|
|
1709
|
+
groups: state.devices.groups,
|
|
1710
|
+
status: DEVICE_STATES.accepted
|
|
1711
|
+
});
|
|
1712
|
+
return general_api_default.post(getSearchEndpoint(getState()), {
|
|
1713
|
+
page: 1,
|
|
1714
|
+
per_page: MAX_PAGE_SIZE,
|
|
1715
|
+
filters: filterTerms,
|
|
1716
|
+
attributes: geoAttributes,
|
|
1717
|
+
geo_bounding_box_filter: {
|
|
1718
|
+
geo_bounding_box: {
|
|
1719
|
+
location: {
|
|
1720
|
+
top_left: { lat: bounds._northEast.lat, lon: bounds._southWest.lng },
|
|
1721
|
+
bottom_right: { lat: bounds._southWest.lat, lon: bounds._northEast.lng }
|
|
1722
|
+
}
|
|
1723
|
+
}
|
|
1724
|
+
}
|
|
1725
|
+
}).then(({ data }) => {
|
|
1726
|
+
const { devicesById } = reduceReceivedDevices(data, [], getState());
|
|
1727
|
+
return Promise.resolve(dispatch(actions3.receivedDevices(devicesById)));
|
|
1728
|
+
});
|
|
1729
|
+
});
|
|
1730
|
+
|
|
1731
|
+
// src/onboardingSlice/thunks.ts
|
|
1732
|
+
import { getDemoDeviceAddress } from "@northern.tech/utils/helpers";
|
|
1733
|
+
import { createAsyncThunk as createAsyncThunk3 } from "@reduxjs/toolkit";
|
|
1734
|
+
import Cookies from "universal-cookie";
|
|
1735
|
+
var cookies = new Cookies();
|
|
1736
|
+
var applyOnboardingFallbacks = (progress2) => {
|
|
1737
|
+
const step = orderedOnboardingSteps[progress2];
|
|
1738
|
+
if (step && step.fallbackStep) {
|
|
1739
|
+
return step.fallbackStep;
|
|
1740
|
+
}
|
|
1741
|
+
return progress2;
|
|
1742
|
+
};
|
|
1743
|
+
var determineProgress = (acceptedDevices, pendingDevices, releases, pastDeployments) => {
|
|
1744
|
+
const steps = orderedOnboardingSteps;
|
|
1745
|
+
let progress2 = -1;
|
|
1746
|
+
progress2 = pendingDevices.length > 1 ? steps.findIndex((step) => step === onboardingSteps.DEVICES_PENDING_ACCEPTING_ONBOARDING) : progress2;
|
|
1747
|
+
progress2 = acceptedDevices.length >= 1 ? steps.findIndex((step) => step === onboardingSteps.DEVICES_ACCEPTED_ONBOARDING) : progress2;
|
|
1748
|
+
progress2 = acceptedDevices.length > 1 && releases.length > 1 && pastDeployments.length > 1 ? steps.findIndex((step) => step === onboardingSteps.DEPLOYMENTS_PAST_COMPLETED) : progress2;
|
|
1749
|
+
return steps[progress2];
|
|
1750
|
+
};
|
|
1751
|
+
var deductOnboardingState = ({ devicesById, devicesByStatus, onboardingState, pastDeployments, releases, userCapabilities, userId }) => {
|
|
1752
|
+
var _a;
|
|
1753
|
+
const { canDeploy, canManageDevices, canReadDeployments, canReadDevices, canReadReleases, canUploadReleases } = userCapabilities;
|
|
1754
|
+
const userCookie = cookies.get(`${userId}-onboarded`);
|
|
1755
|
+
const acceptedDevices = devicesByStatus[DEVICE_STATES.accepted].deviceIds;
|
|
1756
|
+
const pendingDevices = devicesByStatus[DEVICE_STATES.pending].deviceIds;
|
|
1757
|
+
let deviceType = (_a = onboardingState.deviceType) != null ? _a : [];
|
|
1758
|
+
deviceType = !deviceType.length && acceptedDevices.length && devicesById[acceptedDevices[0]].hasOwnProperty("attributes") ? devicesById[acceptedDevices[0]].attributes.device_type : deviceType;
|
|
1759
|
+
const progress2 = applyOnboardingFallbacks(onboardingState.progress || determineProgress(acceptedDevices, pendingDevices, releases, pastDeployments));
|
|
1760
|
+
return __spreadProps(__spreadValues({}, onboardingState), {
|
|
1761
|
+
complete: !!(Boolean(userCookie) || onboardingState.complete || acceptedDevices.length > 1 && pendingDevices.length > 0 && releases.length > 1 && pastDeployments.length > 1 || acceptedDevices.length >= 1 && releases.length >= 2 && pastDeployments.length > 2 || acceptedDevices.length >= 1 && pendingDevices.length > 0 && releases.length >= 2 && pastDeployments.length >= 2 || orderedOnboardingSteps.findIndex((step) => step === progress2) >= orderedOnboardingSteps.length - 1 || onboardingState.disable || ![canDeploy, canManageDevices, canReadDeployments, canReadDevices, canReadReleases, canUploadReleases].every((i) => i)),
|
|
1762
|
+
showTips: onboardingState.showTips != null ? onboardingState.showTips : true,
|
|
1763
|
+
deviceType,
|
|
1764
|
+
approach: onboardingState.approach || (deviceType.some((type) => type.startsWith("qemu")) ? "virtual" : "physical"),
|
|
1765
|
+
progress: progress2
|
|
1766
|
+
});
|
|
1767
|
+
};
|
|
1768
|
+
var getOnboardingState2 = createAsyncThunk3(`${sliceName4}/getOnboardingState`, (_, { dispatch, getState }) => {
|
|
1769
|
+
const state = getState();
|
|
1770
|
+
let onboardingState = getOnboardingState(state);
|
|
1771
|
+
if (!onboardingState.complete) {
|
|
1772
|
+
const userId = state.users.currentUser;
|
|
1773
|
+
onboardingState = deductOnboardingState({
|
|
1774
|
+
devicesById: state.devices.byId,
|
|
1775
|
+
devicesByStatus: state.devices.byStatus,
|
|
1776
|
+
onboardingState,
|
|
1777
|
+
pastDeployments: state.deployments.byStatus.finished.deploymentIds,
|
|
1778
|
+
releases: Object.values(state.releases.byId),
|
|
1779
|
+
userCapabilities: getUserCapabilities(state),
|
|
1780
|
+
userId
|
|
1781
|
+
});
|
|
1782
|
+
}
|
|
1783
|
+
onboardingState.progress = onboardingState.progress || onboardingSteps.DASHBOARD_ONBOARDING_START;
|
|
1784
|
+
const demoDeviceAddress = `http://${getDemoDeviceAddress(Object.values(state.devices.byId), onboardingState.approach)}`;
|
|
1785
|
+
onboardingState.address = state.onboarding.demoArtifactPort ? `${demoDeviceAddress}:${state.onboarding.demoArtifactPort}` : demoDeviceAddress;
|
|
1786
|
+
return Promise.all([
|
|
1787
|
+
dispatch(actions4.setOnboardingComplete(onboardingState.complete)),
|
|
1788
|
+
dispatch(actions4.setOnboardingState(onboardingState)),
|
|
1789
|
+
dispatch(saveUserSettings({ onboarding: onboardingState }))
|
|
1790
|
+
]);
|
|
1791
|
+
});
|
|
1792
|
+
var setOnboardingDeviceType = createAsyncThunk3(
|
|
1793
|
+
`${sliceName4}/setOnboardingDeviceType`,
|
|
1794
|
+
(value, { dispatch }) => Promise.all([dispatch(actions4.setOnboardingDeviceType(value)), dispatch(saveUserSettings({ onboarding: { deviceType: value } }))])
|
|
1795
|
+
);
|
|
1796
|
+
var setOnboardingApproach = createAsyncThunk3(
|
|
1797
|
+
`${sliceName4}/setOnboardingApproach`,
|
|
1798
|
+
(value, { dispatch }) => Promise.all([dispatch(actions4.setOnboardingApproach(value)), dispatch(saveUserSettings({ onboarding: { approach: value } }))])
|
|
1799
|
+
);
|
|
1800
|
+
var setOnboardingComplete = createAsyncThunk3(`${sliceName4}/setOnboardingComplete`, (value, { dispatch }) => {
|
|
1801
|
+
let tasks = [Promise.resolve(dispatch(actions4.setOnboardingComplete(value)))];
|
|
1802
|
+
if (value) {
|
|
1803
|
+
tasks.push(Promise.resolve(dispatch(actions4.setShowOnboardingHelp(false))));
|
|
1804
|
+
tasks.push(Promise.resolve(dispatch(advanceOnboarding(onboardingSteps.DEPLOYMENTS_PAST_COMPLETED))));
|
|
1805
|
+
}
|
|
1806
|
+
return Promise.all(tasks);
|
|
1807
|
+
});
|
|
1808
|
+
var setOnboardingCanceled = createAsyncThunk3(
|
|
1809
|
+
`${sliceName4}/setOnboardingCanceled`,
|
|
1810
|
+
(_, { dispatch }) => Promise.all([
|
|
1811
|
+
Promise.resolve(dispatch(actions4.setShowOnboardingHelp(false))),
|
|
1812
|
+
Promise.resolve(dispatch(actions4.setShowDismissOnboardingTipsDialog(false))),
|
|
1813
|
+
Promise.resolve(dispatch(actions4.setOnboardingComplete(true)))
|
|
1814
|
+
]).then(() => dispatch(advanceOnboarding(onboardingSteps.DEPLOYMENTS_PAST_COMPLETED_FAILURE)))
|
|
1815
|
+
);
|
|
1816
|
+
var advanceOnboarding = createAsyncThunk3(`${sliceName4}/advanceOnboarding`, (stepId, { dispatch, getState }) => {
|
|
1817
|
+
const steps = orderedOnboardingSteps;
|
|
1818
|
+
const progress2 = steps.findIndex((step) => step === getState().onboarding.progress);
|
|
1819
|
+
const stepIndex = steps.findIndex((step) => step === stepId);
|
|
1820
|
+
if (progress2 > stepIndex || getState().onboarding.progress === null) {
|
|
1821
|
+
return;
|
|
1822
|
+
}
|
|
1823
|
+
const madeProgress = steps[stepIndex + 1];
|
|
1824
|
+
const state = __spreadProps(__spreadValues({}, getOnboardingState(getState())), { progress: madeProgress });
|
|
1825
|
+
state.complete = stepIndex + 1 >= steps.findIndex((step) => step === onboardingSteps.DEPLOYMENTS_PAST_COMPLETED_FAILURE) ? true : state.complete;
|
|
1826
|
+
return Promise.all([dispatch(actions4.setOnboardingProgress(madeProgress)), dispatch(saveUserSettings({ onboarding: state }))]);
|
|
1827
|
+
});
|
|
1828
|
+
|
|
1829
|
+
// src/organizationSlice/thunks.ts
|
|
1830
|
+
import { deepCompare as deepCompare3 } from "@northern.tech/utils/helpers";
|
|
1831
|
+
import { createAsyncThunk as createAsyncThunk4 } from "@reduxjs/toolkit";
|
|
1832
|
+
import { jwtDecode } from "jwt-decode";
|
|
1833
|
+
import hashString from "md5";
|
|
1834
|
+
import Cookies2 from "universal-cookie";
|
|
1835
|
+
var cookies2 = new Cookies2();
|
|
1836
|
+
var { setAnnouncement, setSnackbar: setSnackbar3 } = actions_default;
|
|
1837
|
+
var { page: defaultPage3, perPage: defaultPerPage3 } = DEVICE_LIST_DEFAULTS;
|
|
1838
|
+
var cancelRequest = createAsyncThunk4(`${sliceName5}/cancelRequest`, (reason, { dispatch, getState }) => {
|
|
1839
|
+
const { id: tenantId } = getOrganization(getState());
|
|
1840
|
+
return general_api_default.post(`${tenantadmApiUrlv2}/tenants/${tenantId}/cancel`, { reason }).then(
|
|
1841
|
+
() => Promise.resolve(dispatch(setSnackbar3({ message: "Deactivation request was sent successfully", autoHideDuration: TIMEOUTS.fiveSeconds })))
|
|
1842
|
+
);
|
|
1843
|
+
});
|
|
1844
|
+
var getTargetLocation = (key) => {
|
|
1845
|
+
if (devLocations.includes(window.location.hostname)) {
|
|
1846
|
+
return "";
|
|
1847
|
+
}
|
|
1848
|
+
let subdomainSections = window.location.hostname.substring(0, window.location.hostname.indexOf(locations.us.location)).split(".");
|
|
1849
|
+
subdomainSections = subdomainSections.splice(0, subdomainSections.length - 1);
|
|
1850
|
+
if (!subdomainSections.find((section) => section === key)) {
|
|
1851
|
+
subdomainSections = key === locations.us.key ? subdomainSections.filter((section) => !locations[section]) : [...subdomainSections, key];
|
|
1852
|
+
return `https://${[...subdomainSections, ...locations.us.location.split(".")].join(".")}`;
|
|
1853
|
+
}
|
|
1854
|
+
return `https://${window.location.hostname}`;
|
|
1855
|
+
};
|
|
1856
|
+
var devLocations = ["localhost", "docker.mender.io"];
|
|
1857
|
+
var createOrganizationTrial = createAsyncThunk4(`${sliceName5}/createOrganizationTrial`, (data, { dispatch }) => {
|
|
1858
|
+
const { key } = locations[data.location];
|
|
1859
|
+
const targetLocation = getTargetLocation(key);
|
|
1860
|
+
const target = `${targetLocation}${tenantadmApiUrlv2}/tenants/trial`;
|
|
1861
|
+
return general_api_default.postUnauthorized(target, data).catch((err) => {
|
|
1862
|
+
if (err.response.status >= 400 && err.response.status < 500) {
|
|
1863
|
+
dispatch(setSnackbar3({ message: err.response.data.error, autoHideDuration: TIMEOUTS.fiveSeconds }));
|
|
1864
|
+
return Promise.reject(err);
|
|
1865
|
+
}
|
|
1866
|
+
}).then(({ headers }) => {
|
|
1867
|
+
cookies2.remove("oauth");
|
|
1868
|
+
cookies2.remove("externalID");
|
|
1869
|
+
cookies2.remove("email");
|
|
1870
|
+
dispatch(setFirstLoginAfterSignup(true));
|
|
1871
|
+
return new Promise(
|
|
1872
|
+
(resolve) => setTimeout(() => {
|
|
1873
|
+
window.location.assign(`${targetLocation}${headers.location || ""}`);
|
|
1874
|
+
return resolve();
|
|
1875
|
+
}, TIMEOUTS.fiveSeconds)
|
|
1876
|
+
);
|
|
1877
|
+
});
|
|
1878
|
+
});
|
|
1879
|
+
var startCardUpdate = createAsyncThunk4(
|
|
1880
|
+
`${sliceName5}/startCardUpdate`,
|
|
1881
|
+
(_, { dispatch }) => general_api_default.post(`${tenantadmApiUrlv2}/billing/card`).then(({ data }) => {
|
|
1882
|
+
dispatch(actions5.receiveSetupIntent(data.intent_id));
|
|
1883
|
+
return Promise.resolve(data.secret);
|
|
1884
|
+
}).catch((err) => commonErrorHandler(err, `Updating the card failed:`, dispatch))
|
|
1885
|
+
);
|
|
1886
|
+
var confirmCardUpdate = createAsyncThunk4(
|
|
1887
|
+
`${sliceName5}/confirmCardUpdate`,
|
|
1888
|
+
(_, { dispatch, getState }) => general_api_default.post(`${tenantadmApiUrlv2}/billing/card/${getState().organization.intentId}/confirm`).then(() => Promise.all([dispatch(setSnackbar3("Payment card was updated successfully")), dispatch(actions5.receiveSetupIntent(null))])).catch((err) => commonErrorHandler(err, `Updating the card failed:`, dispatch))
|
|
1889
|
+
);
|
|
1890
|
+
var getCurrentCard = createAsyncThunk4(
|
|
1891
|
+
`${sliceName5}/getCurrentCard`,
|
|
1892
|
+
(_, { dispatch }) => general_api_default.get(`${tenantadmApiUrlv2}/billing`).then((res) => {
|
|
1893
|
+
const { last4, exp_month, exp_year, brand } = res.data.card || {};
|
|
1894
|
+
return Promise.resolve(dispatch(actions5.receiveCurrentCard({ brand, last4, expiration: { month: exp_month, year: exp_year } })));
|
|
1895
|
+
})
|
|
1896
|
+
);
|
|
1897
|
+
var startUpgrade = createAsyncThunk4(
|
|
1898
|
+
`${sliceName5}/startUpgrade`,
|
|
1899
|
+
(tenantId, { dispatch }) => general_api_default.post(`${tenantadmApiUrlv2}/tenants/${tenantId}/upgrade/start`).then(({ data }) => Promise.resolve(data.secret)).catch((err) => commonErrorHandler(err, `There was an error upgrading your account:`, dispatch))
|
|
1900
|
+
);
|
|
1901
|
+
var cancelUpgrade = createAsyncThunk4(`${sliceName5}/cancelUpgrade`, (tenantId) => general_api_default.post(`${tenantadmApiUrlv2}/tenants/${tenantId}/upgrade/cancel`));
|
|
1902
|
+
var completeUpgrade = createAsyncThunk4(
|
|
1903
|
+
`${sliceName5}/completeUpgrade`,
|
|
1904
|
+
({ tenantId, plan }, { dispatch }) => general_api_default.post(`${tenantadmApiUrlv2}/tenants/${tenantId}/upgrade/complete`, { plan }).catch((err) => commonErrorHandler(err, `There was an error upgrading your account:`, dispatch)).then(() => Promise.resolve(dispatch(getUserOrganization())))
|
|
1905
|
+
);
|
|
1906
|
+
var prepareAuditlogQuery = ({ startDate, endDate, user: userFilter, type, detail: detailFilter, sort = {} }) => {
|
|
1907
|
+
const userId = (userFilter == null ? void 0 : userFilter.id) || userFilter;
|
|
1908
|
+
const detail = (detailFilter == null ? void 0 : detailFilter.id) || detailFilter;
|
|
1909
|
+
const createdAfter = startDate ? `&created_after=${Math.round(Date.parse(startDate) / 1e3)}` : "";
|
|
1910
|
+
const createdBefore = endDate ? `&created_before=${Math.round(Date.parse(endDate) / 1e3)}` : "";
|
|
1911
|
+
const typeSearch = type ? `&object_type=${type.value}`.toLowerCase() : "";
|
|
1912
|
+
const userSearch = userId ? `&actor_id=${userId}` : "";
|
|
1913
|
+
const objectSearch = type && detail ? `&${type.queryParameter}=${encodeURIComponent(detail)}` : "";
|
|
1914
|
+
const { direction = SORTING_OPTIONS.desc } = sort;
|
|
1915
|
+
return `${createdAfter}${createdBefore}${userSearch}${typeSearch}${objectSearch}&sort=${direction}`;
|
|
1916
|
+
};
|
|
1917
|
+
var getAuditLogs = createAsyncThunk4(`${sliceName5}/getAuditLogs`, (selectionState, { dispatch, getState }) => {
|
|
1918
|
+
const { page, perPage } = selectionState;
|
|
1919
|
+
const { hasAuditlogs } = getTenantCapabilities(getState());
|
|
1920
|
+
if (!hasAuditlogs) {
|
|
1921
|
+
return Promise.resolve();
|
|
1922
|
+
}
|
|
1923
|
+
return general_api_default.get(`${auditLogsApiUrl}/logs?page=${page}&per_page=${perPage}${prepareAuditlogQuery(selectionState)}`).then(({ data, headers }) => {
|
|
1924
|
+
let total = headers[headerNames.total];
|
|
1925
|
+
total = Number(total || data.length);
|
|
1926
|
+
return Promise.resolve(dispatch(actions5.receiveAuditLogs({ events: data, total })));
|
|
1927
|
+
}).catch((err) => commonErrorHandler(err, `There was an error retrieving audit logs:`, dispatch));
|
|
1928
|
+
});
|
|
1929
|
+
var getAuditLogsCsvLink = createAsyncThunk4(
|
|
1930
|
+
`${sliceName5}/getAuditLogsCsvLink`,
|
|
1931
|
+
(_, { getState }) => Promise.resolve(`${window.location.origin}${auditLogsApiUrl}/logs/export?limit=20000${prepareAuditlogQuery(getAuditlogState(getState()))}`)
|
|
1932
|
+
);
|
|
1933
|
+
var setAuditlogsState = createAsyncThunk4(`${sliceName5}/setAuditlogsState`, (selectionState, { dispatch, getState }) => {
|
|
1934
|
+
const currentState = getAuditlogState(getState());
|
|
1935
|
+
let nextState = __spreadProps(__spreadValues(__spreadValues({}, currentState), selectionState), {
|
|
1936
|
+
sort: __spreadValues(__spreadValues({}, currentState.sort), selectionState.sort)
|
|
1937
|
+
});
|
|
1938
|
+
let tasks = [];
|
|
1939
|
+
const _a = currentState, { isLoading: currentLoading, selectedIssue: currentIssue } = _a, currentRequestState = __objRest(_a, ["isLoading", "selectedIssue"]);
|
|
1940
|
+
const _b = nextState, { isLoading: selectionLoading, selectedIssue: selectionIssue } = _b, selectionRequestState = __objRest(_b, ["isLoading", "selectedIssue"]);
|
|
1941
|
+
if (!deepCompare3(currentRequestState, selectionRequestState)) {
|
|
1942
|
+
nextState.isLoading = true;
|
|
1943
|
+
tasks.push(dispatch(getAuditLogs(nextState)).finally(() => dispatch(actions5.setAuditLogState({ isLoading: false }))));
|
|
1944
|
+
}
|
|
1945
|
+
tasks.push(dispatch(actions5.setAuditLogState(nextState)));
|
|
1946
|
+
return Promise.all(tasks);
|
|
1947
|
+
});
|
|
1948
|
+
var tenantDataDivergedMessage = "The system detected there is a change in your plan or purchased add-ons. Please log out and log in again";
|
|
1949
|
+
var addTenant = createAsyncThunk4(`${sliceName5}/createTenant`, (selectionState, { dispatch }) => {
|
|
1950
|
+
return general_api_default.post(`${tenantadmApiUrlv2}/tenants`, selectionState).then(() => Promise.all([dispatch(getTenants()), dispatch(setSnackbar3("Tenant was created successfully."))])).catch((err) => commonErrorHandler(err, "There was an error creating tenant", dispatch, commonErrorFallback));
|
|
1951
|
+
});
|
|
1952
|
+
var tenantListRetrieval = (config) => __async(void 0, null, function* () {
|
|
1953
|
+
const { page, perPage } = config;
|
|
1954
|
+
const params = new URLSearchParams({ page, per_page: perPage }).toString();
|
|
1955
|
+
const tenantList = yield general_api_default.get(`${tenantadmApiUrlv2}/tenants?${params}`);
|
|
1956
|
+
const totalCount = tenantList.headers[headerNames.total] || TENANT_LIST_DEFAULT.perPage;
|
|
1957
|
+
return [tenantList.data, totalCount];
|
|
1958
|
+
});
|
|
1959
|
+
var getTenants = createAsyncThunk4(`${sliceName5}/getTenants`, (_0, _1) => __async(void 0, [_0, _1], function* (_, { dispatch, getState }) {
|
|
1960
|
+
const currentState = getTenantsList(getState());
|
|
1961
|
+
const [tenants, pageCount] = yield tenantListRetrieval(currentState);
|
|
1962
|
+
dispatch(actions5.setTenantListState(__spreadProps(__spreadValues({}, currentState), { total: pageCount, tenants })));
|
|
1963
|
+
}));
|
|
1964
|
+
var setTenantsListState = createAsyncThunk4(`${sliceName5}/setTenantsListState`, (_0, _1) => __async(void 0, [_0, _1], function* (selectionState, { dispatch, getState }) {
|
|
1965
|
+
const currentState = getTenantsList(getState());
|
|
1966
|
+
const nextState = __spreadValues(__spreadValues({}, currentState), selectionState);
|
|
1967
|
+
if (!deepCompare3(currentState, selectionState)) {
|
|
1968
|
+
const [tenants, pageCount] = yield tenantListRetrieval(nextState);
|
|
1969
|
+
return dispatch(actions5.setTenantListState(__spreadProps(__spreadValues({}, nextState), { tenants, total: pageCount })));
|
|
1970
|
+
}
|
|
1971
|
+
return dispatch(actions5.setTenantListState(__spreadValues({}, nextState)));
|
|
1972
|
+
}));
|
|
1973
|
+
var editTenantDeviceLimit = createAsyncThunk4(`${sliceName5}/editDeviceLimit`, ({ newLimit, id, name }, { dispatch }) => {
|
|
1974
|
+
return general_api_default.put(`${tenantadmApiUrlv2}/tenants/${id}/child`, { device_limit: newLimit, name }).catch((err) => commonErrorHandler(err, `Device Limit cannot be changed`, dispatch)).then(() => {
|
|
1975
|
+
const tasks = [Promise.resolve(dispatch(setSnackbar3("Device Limit was changed successfully")))];
|
|
1976
|
+
tasks.push(dispatch(getTenants()));
|
|
1977
|
+
tasks.push(dispatch(getUserOrganization()));
|
|
1978
|
+
return Promise.all(tasks);
|
|
1979
|
+
});
|
|
1980
|
+
});
|
|
1981
|
+
var removeTenant = createAsyncThunk4(`${sliceName5}/editDeviceLimit`, ({ id }, { dispatch }) => {
|
|
1982
|
+
return general_api_default.post(`${tenantadmApiUrlv2}/tenants/${id}/remove/start`).catch((err) => commonErrorHandler(err, `There was an error removing the tenant`, dispatch)).then(
|
|
1983
|
+
() => Promise.all([Promise.resolve(dispatch(setSnackbar3("Device Limit was changed successfully"))), dispatch(getTenants()), dispatch(getUserOrganization())])
|
|
1984
|
+
);
|
|
1985
|
+
});
|
|
1986
|
+
var getUserOrganization = createAsyncThunk4(`${sliceName5}/getUserOrganization`, (_, { dispatch, getState }) => {
|
|
1987
|
+
return general_api_default.get(`${tenantadmApiUrlv1}/user/tenant`).then((res) => {
|
|
1988
|
+
let tasks = [dispatch(actions5.setOrganization(res.data))];
|
|
1989
|
+
const { addons, plan, trial } = res.data;
|
|
1990
|
+
const { token } = getCurrentSession(getState());
|
|
1991
|
+
const jwt = jwtDecode(token);
|
|
1992
|
+
const jwtData = { addons: jwt["mender.addons"], plan: jwt["mender.plan"], trial: jwt["mender.trial"] };
|
|
1993
|
+
if (!deepCompare3({ addons, plan, trial }, jwtData)) {
|
|
1994
|
+
const hash = hashString(tenantDataDivergedMessage);
|
|
1995
|
+
cookies2.remove(`${jwt.sub}${hash}`);
|
|
1996
|
+
tasks.push(dispatch(setAnnouncement(tenantDataDivergedMessage)));
|
|
1997
|
+
}
|
|
1998
|
+
return Promise.all(tasks);
|
|
1999
|
+
});
|
|
2000
|
+
});
|
|
2001
|
+
var sendSupportMessage = createAsyncThunk4(
|
|
2002
|
+
`${sliceName5}/sendSupportMessage`,
|
|
2003
|
+
(content, { dispatch }) => general_api_default.post(`${tenantadmApiUrlv2}/contact/support`, content).catch((err) => commonErrorHandler(err, "There was an error sending your request", dispatch, commonErrorFallback)).then(() => Promise.resolve(dispatch(setSnackbar3({ message: "Your request was sent successfully", autoHideDuration: TIMEOUTS.fiveSeconds }))))
|
|
2004
|
+
);
|
|
2005
|
+
var requestPlanChange = createAsyncThunk4(
|
|
2006
|
+
`${sliceName5}/requestPlanChange`,
|
|
2007
|
+
({ content, tenantId }, { dispatch }) => general_api_default.post(`${tenantadmApiUrlv2}/tenants/${tenantId}/plan`, content).catch((err) => commonErrorHandler(err, "There was an error sending your request", dispatch, commonErrorFallback)).then(() => Promise.resolve(dispatch(setSnackbar3({ message: "Your request was sent successfully", autoHideDuration: TIMEOUTS.fiveSeconds }))))
|
|
2008
|
+
);
|
|
2009
|
+
var downloadLicenseReport = createAsyncThunk4(
|
|
2010
|
+
`${sliceName5}/downloadLicenseReport`,
|
|
2011
|
+
(_, { dispatch }) => general_api_default.get(`${deviceAuthV2}/reports/devices`).catch((err) => commonErrorHandler(err, "There was an error downloading the report", dispatch, commonErrorFallback)).then((res) => res.data)
|
|
2012
|
+
);
|
|
2013
|
+
var createIntegration = createAsyncThunk4(
|
|
2014
|
+
`${sliceName5}/createIntegration`,
|
|
2015
|
+
(_a, { dispatch }) => {
|
|
2016
|
+
var _b = _a, { id } = _b, integration = __objRest(_b, ["id"]);
|
|
2017
|
+
return general_api_default.post(`${iotManagerBaseURL}/integrations`, integration).catch((err) => commonErrorHandler(err, "There was an error creating the integration", dispatch, commonErrorFallback)).then(() => Promise.all([dispatch(setSnackbar3("The integration was set up successfully")), dispatch(getIntegrations())]));
|
|
2018
|
+
}
|
|
2019
|
+
);
|
|
2020
|
+
var changeIntegration = createAsyncThunk4(
|
|
2021
|
+
`${sliceName5}/changeIntegration`,
|
|
2022
|
+
({ id, credentials }, { dispatch }) => general_api_default.put(`${iotManagerBaseURL}/integrations/${id}/credentials`, credentials).catch((err) => commonErrorHandler(err, "There was an error updating the integration", dispatch, commonErrorFallback)).then(() => Promise.all([dispatch(setSnackbar3("The integration was updated successfully")), dispatch(getIntegrations())]))
|
|
2023
|
+
);
|
|
2024
|
+
var deleteIntegration = createAsyncThunk4(
|
|
2025
|
+
`${sliceName5}/deleteIntegration`,
|
|
2026
|
+
({ id, provider }, { dispatch, getState }) => general_api_default.delete(`${iotManagerBaseURL}/integrations/${id}`, {}).catch((err) => commonErrorHandler(err, "There was an error removing the integration", dispatch, commonErrorFallback)).then(() => {
|
|
2027
|
+
const integrations = getState().organization.externalDeviceIntegrations.filter((item) => provider !== item.provider);
|
|
2028
|
+
return Promise.all([
|
|
2029
|
+
dispatch(setSnackbar3("The integration was removed successfully")),
|
|
2030
|
+
dispatch(actions5.receiveExternalDeviceIntegrations(integrations))
|
|
2031
|
+
]);
|
|
2032
|
+
})
|
|
2033
|
+
);
|
|
2034
|
+
var getIntegrations = createAsyncThunk4(
|
|
2035
|
+
`${sliceName5}/getIntegrations`,
|
|
2036
|
+
(_, { dispatch, getState }) => general_api_default.get(`${iotManagerBaseURL}/integrations`).catch((err) => commonErrorHandler(err, "There was an error retrieving the integration", dispatch, commonErrorFallback)).then(({ data }) => {
|
|
2037
|
+
const existingIntegrations = getState().organization.externalDeviceIntegrations;
|
|
2038
|
+
const integrations = data.reduce((accu, item) => {
|
|
2039
|
+
var _a;
|
|
2040
|
+
const existingIntegration = (_a = existingIntegrations.find((integration2) => item.id === integration2.id)) != null ? _a : {};
|
|
2041
|
+
const integration = __spreadValues(__spreadValues({}, existingIntegration), item);
|
|
2042
|
+
accu.push(integration);
|
|
2043
|
+
return accu;
|
|
2044
|
+
}, []);
|
|
2045
|
+
return Promise.resolve(dispatch(actions5.receiveExternalDeviceIntegrations(integrations)));
|
|
2046
|
+
})
|
|
2047
|
+
);
|
|
2048
|
+
var getWebhookEvents = createAsyncThunk4(`${sliceName5}/getWebhookEvents`, (config = {}, { dispatch, getState }) => {
|
|
2049
|
+
const { isFollowUp, page = defaultPage3, perPage = defaultPerPage3 } = config;
|
|
2050
|
+
return general_api_default.get(`${iotManagerBaseURL}/events?page=${page}&per_page=${perPage}`).catch((err) => commonErrorHandler(err, "There was an error retrieving activity for this integration", dispatch, commonErrorFallback)).then(({ data }) => {
|
|
2051
|
+
let tasks = [
|
|
2052
|
+
dispatch(
|
|
2053
|
+
actions5.receiveWebhookEvents({
|
|
2054
|
+
value: isFollowUp ? getState().organization.webhooks.events : data,
|
|
2055
|
+
total: (page - 1) * perPage + data.length
|
|
2056
|
+
})
|
|
2057
|
+
)
|
|
2058
|
+
];
|
|
2059
|
+
if (data.length >= perPage && !isFollowUp) {
|
|
2060
|
+
tasks.push(dispatch(getWebhookEvents({ isFollowUp: true, page: page + 1, perPage: 1 })));
|
|
2061
|
+
}
|
|
2062
|
+
return Promise.all(tasks);
|
|
2063
|
+
});
|
|
2064
|
+
});
|
|
2065
|
+
var ssoConfigActions = {
|
|
2066
|
+
create: { success: "stored", error: "storing" },
|
|
2067
|
+
edit: { success: "updated", error: "updating" },
|
|
2068
|
+
read: { success: "", error: "retrieving" },
|
|
2069
|
+
remove: { success: "removed", error: "removing" },
|
|
2070
|
+
readMultiple: { success: "", error: "retrieving" }
|
|
2071
|
+
};
|
|
2072
|
+
var ssoConfigActionErrorHandler = (err, type) => (dispatch) => commonErrorHandler(err, `There was an error ${ssoConfigActions[type].error} the SSO configuration.`, dispatch, commonErrorFallback);
|
|
2073
|
+
var ssoConfigActionSuccessHandler = (type) => (dispatch) => dispatch(setSnackbar3(`The SSO configuration was ${ssoConfigActions[type].success} successfully`));
|
|
2074
|
+
var storeSsoConfig = createAsyncThunk4(
|
|
2075
|
+
`${sliceName5}/storeSsoConfig`,
|
|
2076
|
+
({ config, contentType }, { dispatch }) => general_api_default.post(ssoIdpApiUrlv1, config, { headers: { "Content-Type": contentType, Accept: "application/json" } }).catch((err) => dispatch(ssoConfigActionErrorHandler(err, "create"))).then(() => Promise.all([dispatch(ssoConfigActionSuccessHandler("create")), dispatch(getSsoConfigs())]))
|
|
2077
|
+
);
|
|
2078
|
+
var changeSsoConfig = createAsyncThunk4(
|
|
2079
|
+
`${sliceName5}/changeSsoConfig`,
|
|
2080
|
+
({ config, contentType }, { dispatch }) => general_api_default.put(`${ssoIdpApiUrlv1}/${config.id}`, config, { headers: { "Content-Type": contentType, Accept: "application/json" } }).catch((err) => dispatch(ssoConfigActionErrorHandler(err, "edit"))).then(() => Promise.all([dispatch(ssoConfigActionSuccessHandler("edit")), dispatch(getSsoConfigs())]))
|
|
2081
|
+
);
|
|
2082
|
+
var deleteSsoConfig = createAsyncThunk4(
|
|
2083
|
+
`${sliceName5}/deleteSsoConfig`,
|
|
2084
|
+
({ id }, { dispatch, getState }) => general_api_default.delete(`${ssoIdpApiUrlv1}/${id}`).catch((err) => dispatch(ssoConfigActionErrorHandler(err, "remove"))).then(() => {
|
|
2085
|
+
const configs = getState().organization.ssoConfigs.filter((item) => id !== item.id);
|
|
2086
|
+
return Promise.all([dispatch(ssoConfigActionSuccessHandler("remove")), dispatch(actions5.receiveSsoConfigs(configs))]);
|
|
2087
|
+
})
|
|
2088
|
+
);
|
|
2089
|
+
var getSsoConfigById = createAsyncThunk4(
|
|
2090
|
+
`${sliceName5}/getSsoConfigById`,
|
|
2091
|
+
(config, { dispatch }) => general_api_default.get(`${ssoIdpApiUrlv1}/${config.id}`).catch((err) => dispatch(ssoConfigActionErrorHandler(err, "read"))).then(({ data, headers }) => {
|
|
2092
|
+
const sso = Object.values(SSO_TYPES).find(({ contentType }) => contentType === headers["content-type"]);
|
|
2093
|
+
return sso ? Promise.resolve(__spreadProps(__spreadValues({}, config), { config: data, type: sso.id })) : Promise.reject("Unsupported SSO config content type.");
|
|
2094
|
+
})
|
|
2095
|
+
);
|
|
2096
|
+
var getSsoConfigs = createAsyncThunk4(
|
|
2097
|
+
`${sliceName5}/getSsoConfigs`,
|
|
2098
|
+
(_, { dispatch }) => general_api_default.get(ssoIdpApiUrlv1).catch((err) => dispatch(ssoConfigActionErrorHandler(err, "readMultiple"))).then(
|
|
2099
|
+
({ data }) => Promise.all(data.map((config) => dispatch(getSsoConfigById(config)).unwrap())).then((configs) => dispatch(actions5.receiveSsoConfigs(configs))).catch((err) => commonErrorHandler(err, err, dispatch, ""))
|
|
2100
|
+
)
|
|
2101
|
+
);
|
|
2102
|
+
|
|
2103
|
+
// src/usersSlice/thunks.ts
|
|
2104
|
+
import { duplicateFilter, isEmpty as isEmpty2 } from "@northern.tech/utils/helpers";
|
|
2105
|
+
import { clearAllRetryTimers } from "@northern.tech/utils/retrytimer";
|
|
2106
|
+
import { createAsyncThunk as createAsyncThunk5 } from "@reduxjs/toolkit";
|
|
2107
|
+
import hashString2 from "md5";
|
|
2108
|
+
import Cookies3 from "universal-cookie";
|
|
2109
|
+
var cookies3 = new Cookies3();
|
|
2110
|
+
var { setAnnouncement: setAnnouncement2, setSnackbar: setSnackbar4 } = actions_default;
|
|
2111
|
+
var handleLoginError = (err, { token2fa: has2FA, password }, rejectWithValue) => (dispatch) => {
|
|
2112
|
+
const errorText = extractErrorMessage(err);
|
|
2113
|
+
const is2FABackend = errorText.includes("2fa");
|
|
2114
|
+
if (is2FABackend && !has2FA) {
|
|
2115
|
+
return rejectWithValue({ error: "2fa code missing" });
|
|
2116
|
+
}
|
|
2117
|
+
if (password === void 0) {
|
|
2118
|
+
return Promise.reject();
|
|
2119
|
+
}
|
|
2120
|
+
const twoFAError = is2FABackend ? " and verification code" : "";
|
|
2121
|
+
const errorMessage = `There was a problem logging in. Please check your email${twoFAError ? "," : " and"} password${twoFAError}. If you still have problems, contact an administrator.`;
|
|
2122
|
+
return Promise.reject(dispatch(setSnackbar4(preformatWithRequestID(err.response, errorMessage), null, "Copy to clipboard")));
|
|
2123
|
+
};
|
|
2124
|
+
var loginUser = createAsyncThunk5(
|
|
2125
|
+
`${sliceName6}/loginUser`,
|
|
2126
|
+
(_a, { dispatch, rejectWithValue }) => {
|
|
2127
|
+
var _b = _a, { stayLoggedIn } = _b, userData = __objRest(_b, ["stayLoggedIn"]);
|
|
2128
|
+
return users_api_default.postLogin(`${useradmApiUrlv1}/auth/login`, __spreadProps(__spreadValues({}, userData), { no_expiry: stayLoggedIn })).catch((err) => {
|
|
2129
|
+
cleanUp();
|
|
2130
|
+
return Promise.reject(dispatch(handleLoginError(err, userData, rejectWithValue)));
|
|
2131
|
+
}).then(({ text: response, contentType }) => {
|
|
2132
|
+
if (contentType.includes(APPLICATION_JSON_CONTENT_TYPE)) {
|
|
2133
|
+
const { id, kind } = response;
|
|
2134
|
+
const type = kind.split("/")[1];
|
|
2135
|
+
const ssoLoginUrl = SSO_TYPES[type].getStartUrl(id);
|
|
2136
|
+
window.location.replace(ssoLoginUrl);
|
|
2137
|
+
return;
|
|
2138
|
+
}
|
|
2139
|
+
const token = response;
|
|
2140
|
+
if (contentType !== APPLICATION_JWT_CONTENT_TYPE || !token) {
|
|
2141
|
+
return;
|
|
2142
|
+
}
|
|
2143
|
+
let now = /* @__PURE__ */ new Date();
|
|
2144
|
+
now.setSeconds(now.getSeconds() + maxSessionAge);
|
|
2145
|
+
const expiresAt = stayLoggedIn ? void 0 : now.toISOString();
|
|
2146
|
+
setSessionInfo({ token, expiresAt });
|
|
2147
|
+
cookies3.remove("JWT", { path: "/" });
|
|
2148
|
+
return (
|
|
2149
|
+
// @ts-ignore
|
|
2150
|
+
Promise.resolve(dispatch(getUser(OWN_USER_ID))).unwrap().catch((e) => {
|
|
2151
|
+
cleanUp();
|
|
2152
|
+
return Promise.reject(dispatch(setSnackbar4(extractErrorMessage(e))));
|
|
2153
|
+
}).then(() => {
|
|
2154
|
+
window.sessionStorage.removeItem("pendings-redirect");
|
|
2155
|
+
if (window.location.pathname !== "/ui/") {
|
|
2156
|
+
window.location.replace("/ui/");
|
|
2157
|
+
}
|
|
2158
|
+
return Promise.resolve(dispatch(actions6.successfullyLoggedIn({ expiresAt, token })));
|
|
2159
|
+
})
|
|
2160
|
+
);
|
|
2161
|
+
});
|
|
2162
|
+
}
|
|
2163
|
+
);
|
|
2164
|
+
var logoutUser = createAsyncThunk5(`${sliceName6}/logoutUser`, (_, { dispatch, getState }) => {
|
|
2165
|
+
if (Object.keys(getState().app.uploadsById).length) {
|
|
2166
|
+
return Promise.reject();
|
|
2167
|
+
}
|
|
2168
|
+
return general_api_default.post(`${useradmApiUrlv1}/auth/logout`).finally(() => {
|
|
2169
|
+
cleanUp();
|
|
2170
|
+
clearAllRetryTimers(setSnackbar4);
|
|
2171
|
+
return Promise.resolve(dispatch({ type: USER_LOGOUT }));
|
|
2172
|
+
});
|
|
2173
|
+
});
|
|
2174
|
+
var switchUserOrganization = createAsyncThunk5(`${sliceName6}/switchUserOrganization`, (tenantId, { getState }) => {
|
|
2175
|
+
if (Object.keys(getState().app.uploadsById).length) {
|
|
2176
|
+
return Promise.reject();
|
|
2177
|
+
}
|
|
2178
|
+
return general_api_default.get(`${useradmApiUrlv1}/users/tenants/${tenantId}/token`).then(({ data: token }) => {
|
|
2179
|
+
setSessionInfo(__spreadProps(__spreadValues({}, getSessionInfo()), { token }));
|
|
2180
|
+
window.location.reload();
|
|
2181
|
+
});
|
|
2182
|
+
});
|
|
2183
|
+
var passwordResetStart = createAsyncThunk5(
|
|
2184
|
+
`${sliceName6}/passwordResetStart`,
|
|
2185
|
+
(email, { dispatch }) => general_api_default.post(`${useradmApiUrlv1}/auth/password-reset/start`, { email }).catch(
|
|
2186
|
+
(err) => commonErrorHandler(err, `The password reset request cannot be processed:`, dispatch, void 0, true)
|
|
2187
|
+
)
|
|
2188
|
+
);
|
|
2189
|
+
var passwordResetComplete = createAsyncThunk5(
|
|
2190
|
+
`${sliceName6}/passwordResetComplete`,
|
|
2191
|
+
({ secretHash, newPassword }, { dispatch }) => general_api_default.post(`${useradmApiUrlv1}/auth/password-reset/complete`, { secret_hash: secretHash, password: newPassword }).catch((err = {}) => {
|
|
2192
|
+
const { error, response = {} } = err;
|
|
2193
|
+
let errorMsg = "";
|
|
2194
|
+
if (response.status == 400) {
|
|
2195
|
+
errorMsg = "the link you are using expired or the request is not valid, please try again.";
|
|
2196
|
+
} else {
|
|
2197
|
+
errorMsg = error;
|
|
2198
|
+
}
|
|
2199
|
+
dispatch(setSnackbar4("The password reset request cannot be processed: " + errorMsg));
|
|
2200
|
+
return Promise.reject(err);
|
|
2201
|
+
})
|
|
2202
|
+
);
|
|
2203
|
+
var verifyEmailStart = createAsyncThunk5(
|
|
2204
|
+
`${sliceName6}/verifyEmailStart`,
|
|
2205
|
+
(_, { dispatch, getState }) => general_api_default.post(`${useradmApiUrlv1}/auth/verify-email/start`, { email: getCurrentUser(getState()).email }).catch((err) => commonErrorHandler(err, "An error occured starting the email verification process:", dispatch)).finally(() => Promise.resolve(dispatch(getUser(OWN_USER_ID))))
|
|
2206
|
+
);
|
|
2207
|
+
var verifyEmailComplete = createAsyncThunk5(
|
|
2208
|
+
`${sliceName6}/verifyEmailComplete`,
|
|
2209
|
+
(secret_hash, { dispatch }) => general_api_default.post(`${useradmApiUrlv1}/auth/verify-email/complete`, { secret_hash }).catch((err) => commonErrorHandler(err, "An error occured completing the email verification process:", dispatch)).finally(() => Promise.resolve(dispatch(getUser(OWN_USER_ID))))
|
|
2210
|
+
);
|
|
2211
|
+
var verify2FA = createAsyncThunk5(
|
|
2212
|
+
`${sliceName6}/verify2FA`,
|
|
2213
|
+
(tfaData, { dispatch }) => users_api_default.putVerifyTFA(`${useradmApiUrlv1}/2faverify`, tfaData).then(() => Promise.resolve(dispatch(getUser(OWN_USER_ID)))).catch(
|
|
2214
|
+
(err) => commonErrorHandler(err, "An error occured validating the verification code: failed to verify token, please try again.", dispatch, void 0, true)
|
|
2215
|
+
)
|
|
2216
|
+
);
|
|
2217
|
+
var getUserList = createAsyncThunk5(
|
|
2218
|
+
`${sliceName6}/getUserList`,
|
|
2219
|
+
(_, { dispatch }) => general_api_default.get(`${useradmApiUrlv1}/users`).then((res) => {
|
|
2220
|
+
const users = res.data.reduce((accu, item) => {
|
|
2221
|
+
accu[item.id] = item;
|
|
2222
|
+
return accu;
|
|
2223
|
+
}, {});
|
|
2224
|
+
return dispatch(actions6.receivedUserList(users));
|
|
2225
|
+
}).catch((err) => commonErrorHandler(err, `Users couldn't be loaded.`, dispatch, commonErrorFallback))
|
|
2226
|
+
);
|
|
2227
|
+
var getUser = createAsyncThunk5(
|
|
2228
|
+
`${sliceName6}/getUser`,
|
|
2229
|
+
(id, { dispatch, rejectWithValue }) => general_api_default.get(`${useradmApiUrlv1}/users/${id}`).then(
|
|
2230
|
+
({ data: user }) => Promise.all([
|
|
2231
|
+
dispatch(actions6.receivedUser(user)),
|
|
2232
|
+
// @ts-ignore
|
|
2233
|
+
dispatch(setHideAnnouncement({ shouldHide: false, userId: user.id })),
|
|
2234
|
+
// @ts-ignore
|
|
2235
|
+
dispatch(updateUserColumnSettings({ currentUserId: user.id })),
|
|
2236
|
+
user
|
|
2237
|
+
])
|
|
2238
|
+
).catch((e) => rejectWithValue(e))
|
|
2239
|
+
);
|
|
2240
|
+
var initializeSelf = createAsyncThunk5(`${sliceName6}/initializeSelf`, (_, { dispatch }) => dispatch(getUser(OWN_USER_ID)));
|
|
2241
|
+
var updateUserColumnSettings = createAsyncThunk5(`${sliceName6}/updateUserColumnSettings`, ({ columns, currentUserId }, { dispatch, getState }) => {
|
|
2242
|
+
const userId = currentUserId != null ? currentUserId : getCurrentUser(getState()).id;
|
|
2243
|
+
const storageKey = `${userId}-column-widths`;
|
|
2244
|
+
let customColumns = [];
|
|
2245
|
+
if (!columns) {
|
|
2246
|
+
try {
|
|
2247
|
+
customColumns = JSON.parse(window.localStorage.getItem(storageKey)) || customColumns;
|
|
2248
|
+
} catch (e) {
|
|
2249
|
+
}
|
|
2250
|
+
} else {
|
|
2251
|
+
customColumns = columns;
|
|
2252
|
+
}
|
|
2253
|
+
window.localStorage.setItem(storageKey, JSON.stringify(customColumns));
|
|
2254
|
+
return Promise.resolve(dispatch(actions6.setCustomColumns(customColumns)));
|
|
2255
|
+
});
|
|
2256
|
+
var userActions = {
|
|
2257
|
+
add: {
|
|
2258
|
+
successMessage: "The user was added successfully.",
|
|
2259
|
+
errorMessage: "adding"
|
|
2260
|
+
},
|
|
2261
|
+
create: {
|
|
2262
|
+
successMessage: "The user was created successfully.",
|
|
2263
|
+
errorMessage: "creating"
|
|
2264
|
+
},
|
|
2265
|
+
edit: {
|
|
2266
|
+
successMessage: "The user has been updated.",
|
|
2267
|
+
errorMessage: "editing"
|
|
2268
|
+
},
|
|
2269
|
+
remove: {
|
|
2270
|
+
successMessage: "The user was removed from the system.",
|
|
2271
|
+
errorMessage: "removing"
|
|
2272
|
+
}
|
|
2273
|
+
};
|
|
2274
|
+
var userActionErrorHandler = (err, type, dispatch) => commonErrorHandler(err, `There was an error ${userActions[type].errorMessage} the user.`, dispatch);
|
|
2275
|
+
var createUser = createAsyncThunk5(
|
|
2276
|
+
`${sliceName6}/createUser`,
|
|
2277
|
+
(_a, { dispatch }) => {
|
|
2278
|
+
var _b = _a, { shouldResetPassword } = _b, userData = __objRest(_b, ["shouldResetPassword"]);
|
|
2279
|
+
return general_api_default.post(`${useradmApiUrlv1}/users`, __spreadProps(__spreadValues({}, userData), { send_reset_password: shouldResetPassword })).then(() => Promise.all([dispatch(actions6.createdUser(userData)), dispatch(getUserList()), dispatch(setSnackbar4(userActions.create.successMessage))])).catch((err) => userActionErrorHandler(err, "create", dispatch));
|
|
2280
|
+
}
|
|
2281
|
+
);
|
|
2282
|
+
var removeUser = createAsyncThunk5(
|
|
2283
|
+
`${sliceName6}/removeUser`,
|
|
2284
|
+
(userId, { dispatch }) => (
|
|
2285
|
+
// @ts-ignore
|
|
2286
|
+
general_api_default.delete(`${useradmApiUrlv1}/users/${userId}`).then(() => Promise.all([dispatch(actions6.removedUser(userId)), dispatch(getUserList()), dispatch(setSnackbar4(userActions.remove.successMessage))])).catch((err) => userActionErrorHandler(err, "remove", dispatch))
|
|
2287
|
+
)
|
|
2288
|
+
);
|
|
2289
|
+
var editUser = createAsyncThunk5(
|
|
2290
|
+
`${sliceName6}/editUser`,
|
|
2291
|
+
(_a, { dispatch, getState }) => {
|
|
2292
|
+
var _b = _a, { id } = _b, userData = __objRest(_b, ["id"]);
|
|
2293
|
+
return general_api_default.put(`${useradmApiUrlv1}/users/${id}`, userData).then(
|
|
2294
|
+
() => Promise.all([
|
|
2295
|
+
dispatch(actions6.updatedUser(__spreadProps(__spreadValues({}, userData), { id: id === OWN_USER_ID ? getCurrentUser(getState()).id : id }))),
|
|
2296
|
+
dispatch(setSnackbar4(userActions.edit.successMessage))
|
|
2297
|
+
])
|
|
2298
|
+
);
|
|
2299
|
+
}
|
|
2300
|
+
);
|
|
2301
|
+
var addUserToCurrentTenant = createAsyncThunk5(`${sliceName6}/addUserToTenant`, (userId, { dispatch, getState }) => {
|
|
2302
|
+
const { id } = getOrganization(getState());
|
|
2303
|
+
return general_api_default.post(`${useradmApiUrlv1}/users/${userId}/assign`, { tenant_ids: [id] }).catch((err) => commonErrorHandler(err, `There was an error adding the user to your organization:`, dispatch)).then(() => Promise.all([dispatch(setSnackbar4(userActions.add.successMessage)), dispatch(getUserList())]));
|
|
2304
|
+
});
|
|
2305
|
+
var enableUser2fa = createAsyncThunk5(
|
|
2306
|
+
`${sliceName6}/enableUser2fa`,
|
|
2307
|
+
(userId = OWN_USER_ID, { dispatch }) => general_api_default.post(`${useradmApiUrlv1}/users/${userId}/2fa/enable`).catch((err) => commonErrorHandler(err, `There was an error enabling Two Factor authentication for the user.`, dispatch)).then(() => Promise.resolve(dispatch(getUser(userId))))
|
|
2308
|
+
);
|
|
2309
|
+
var disableUser2fa = createAsyncThunk5(
|
|
2310
|
+
`${sliceName6}/disableUser2fa`,
|
|
2311
|
+
(userId = OWN_USER_ID, { dispatch }) => general_api_default.post(`${useradmApiUrlv1}/users/${userId}/2fa/disable`).catch((err) => commonErrorHandler(err, `There was an error disabling Two Factor authentication for the user.`, dispatch)).then(() => Promise.resolve(dispatch(getUser(userId))))
|
|
2312
|
+
);
|
|
2313
|
+
var mapHttpPermission = (permission) => Object.entries(uiPermissionsByArea).reduce(
|
|
2314
|
+
(accu, [area, definition]) => {
|
|
2315
|
+
const endpointMatches = definition.endpoints.filter(
|
|
2316
|
+
(endpoint) => endpoint.path.test(permission.value) && (endpoint.types.includes(permission.type) || permission.type === PermissionTypes.Any)
|
|
2317
|
+
);
|
|
2318
|
+
if (permission.value === PermissionTypes.Any || permission.value.includes(apiRoot) && endpointMatches.length) {
|
|
2319
|
+
const endpointUiPermission = endpointMatches.reduce((endpointAccu, endpoint) => [...endpointAccu, ...endpoint.uiPermissions], []);
|
|
2320
|
+
const collector = (endpointUiPermission || definition.uiPermissions).reduce((permissionsAccu, uiPermission) => {
|
|
2321
|
+
if (permission.type === PermissionTypes.Any || !endpointMatches.length && uiPermission.verbs.some((verb) => verb === permission.type)) {
|
|
2322
|
+
permissionsAccu.push(uiPermission.value);
|
|
2323
|
+
}
|
|
2324
|
+
return permissionsAccu;
|
|
2325
|
+
}, []).filter(duplicateFilter);
|
|
2326
|
+
if (Array.isArray(accu[area])) {
|
|
2327
|
+
accu[area] = [...accu[area], ...collector].filter(duplicateFilter);
|
|
2328
|
+
} else {
|
|
2329
|
+
accu[area] = mergePermissions(accu[area], { [scopedPermissionAreas[area].excessiveAccessSelector]: collector });
|
|
2330
|
+
}
|
|
2331
|
+
}
|
|
2332
|
+
return accu;
|
|
2333
|
+
},
|
|
2334
|
+
__spreadValues({}, emptyUiPermissions)
|
|
2335
|
+
);
|
|
2336
|
+
var permissionActionTypes = {
|
|
2337
|
+
any: mapHttpPermission,
|
|
2338
|
+
CREATE_DEPLOYMENT: (permission) => permission.type === PermissionTypes.DeviceGroup ? {
|
|
2339
|
+
deployments: [uiPermissionsById.deploy.value],
|
|
2340
|
+
groups: { [permission.value]: [uiPermissionsById.deploy.value] }
|
|
2341
|
+
} : {},
|
|
2342
|
+
http: mapHttpPermission,
|
|
2343
|
+
REMOTE_TERMINAL: (permission) => permission.type === PermissionTypes.DeviceGroup ? {
|
|
2344
|
+
groups: { [permission.value]: [uiPermissionsById.connect.value] }
|
|
2345
|
+
} : {},
|
|
2346
|
+
VIEW_DEVICE: (permission) => permission.type === PermissionTypes.DeviceGroup ? {
|
|
2347
|
+
groups: { [permission.value]: [uiPermissionsById.read.value] }
|
|
2348
|
+
} : {}
|
|
2349
|
+
};
|
|
2350
|
+
var combinePermissions = (existingPermissions, additionalPermissions = {}) => Object.entries(additionalPermissions).reduce((accu, [name, permissions]) => {
|
|
2351
|
+
let maybeExistingPermissions = accu[name] || [];
|
|
2352
|
+
accu[name] = [...permissions, ...maybeExistingPermissions].filter(duplicateFilter);
|
|
2353
|
+
return accu;
|
|
2354
|
+
}, existingPermissions);
|
|
2355
|
+
var tryParseCustomPermission = (permission) => {
|
|
2356
|
+
const uiPermissions = permissionActionTypes[permission.action](permission.object);
|
|
2357
|
+
const result = mergePermissions(__spreadValues({}, emptyUiPermissions), uiPermissions);
|
|
2358
|
+
return { isCustom: true, permission, result };
|
|
2359
|
+
};
|
|
2360
|
+
var customPermissionHandler = (accu, permission) => {
|
|
2361
|
+
let processor = tryParseCustomPermission(permission);
|
|
2362
|
+
return __spreadProps(__spreadValues({}, accu), {
|
|
2363
|
+
isCustom: accu.isCustom || processor.isCustom,
|
|
2364
|
+
uiPermissions: mergePermissions(accu.uiPermissions, processor.result)
|
|
2365
|
+
});
|
|
2366
|
+
};
|
|
2367
|
+
var mapPermissionSet = (permissionSetName, names, scope, existingGroupsPermissions = {}) => {
|
|
2368
|
+
const permission = Object.values(uiPermissionsById).find((permission2) => permission2.permissionSets[scope] === permissionSetName).value;
|
|
2369
|
+
const scopedPermissions = names.reduce((accu, name) => combinePermissions(accu, { [name]: [permission] }), existingGroupsPermissions);
|
|
2370
|
+
return Object.entries(scopedPermissions).reduce((accu, [key, permissions]) => __spreadProps(__spreadValues({}, accu), { [key]: deriveImpliedAreaPermissions(scope, permissions) }), {});
|
|
2371
|
+
};
|
|
2372
|
+
var isEmptyPermissionSet = (permissionSet) => !Object.values(permissionSet).reduce((accu, permissions) => {
|
|
2373
|
+
if (Array.isArray(permissions)) {
|
|
2374
|
+
return accu || !!permissions.length;
|
|
2375
|
+
}
|
|
2376
|
+
return accu || !isEmpty2(permissions);
|
|
2377
|
+
}, false);
|
|
2378
|
+
var parseRolePermissions = ({ permission_sets_with_scope = [], permissions = [] }, permissionSets) => {
|
|
2379
|
+
const preliminaryResult = permission_sets_with_scope.reduce(
|
|
2380
|
+
(accu, permissionSet) => {
|
|
2381
|
+
let processor = permissionSets[permissionSet.name];
|
|
2382
|
+
if (!processor) {
|
|
2383
|
+
return accu;
|
|
2384
|
+
}
|
|
2385
|
+
const scope = Object.keys(scopedPermissionAreas).find((scope2) => {
|
|
2386
|
+
var _a;
|
|
2387
|
+
return uiPermissionsByArea[scope2].scope === ((_a = permissionSet.scope) == null ? void 0 : _a.type);
|
|
2388
|
+
});
|
|
2389
|
+
if (scope) {
|
|
2390
|
+
const result = mapPermissionSet(permissionSet.name, permissionSet.scope.value, scope, accu.uiPermissions[scope]);
|
|
2391
|
+
return __spreadProps(__spreadValues({}, accu), { uiPermissions: __spreadProps(__spreadValues({}, accu.uiPermissions), { [scope]: result }) });
|
|
2392
|
+
} else if (isEmptyPermissionSet(processor.result)) {
|
|
2393
|
+
return processor.permissions.reduce(customPermissionHandler, accu);
|
|
2394
|
+
}
|
|
2395
|
+
return __spreadProps(__spreadValues({}, accu), {
|
|
2396
|
+
isCustom: accu.isCustom || processor.isCustom,
|
|
2397
|
+
uiPermissions: mergePermissions(accu.uiPermissions, processor.result)
|
|
2398
|
+
});
|
|
2399
|
+
},
|
|
2400
|
+
{ isCustom: false, uiPermissions: __spreadProps(__spreadValues({}, emptyUiPermissions), { groups: {}, releases: {} }) }
|
|
2401
|
+
);
|
|
2402
|
+
return permissions.reduce(customPermissionHandler, preliminaryResult);
|
|
2403
|
+
};
|
|
2404
|
+
var normalizeRbacRoles = (roles, rolesById2, permissionSets) => roles.reduce(
|
|
2405
|
+
(accu, role) => {
|
|
2406
|
+
var _a;
|
|
2407
|
+
let normalizedPermissions;
|
|
2408
|
+
let isCustom = false;
|
|
2409
|
+
if (rolesById2[role.name]) {
|
|
2410
|
+
normalizedPermissions = __spreadProps(__spreadValues({}, rolesById2[role.name].uiPermissions), {
|
|
2411
|
+
groups: __spreadValues({}, rolesById2[role.name].uiPermissions.groups),
|
|
2412
|
+
releases: __spreadValues({}, rolesById2[role.name].uiPermissions.releases)
|
|
2413
|
+
});
|
|
2414
|
+
} else {
|
|
2415
|
+
const result = parseRolePermissions(role, permissionSets);
|
|
2416
|
+
normalizedPermissions = result.uiPermissions;
|
|
2417
|
+
isCustom = result.isCustom;
|
|
2418
|
+
}
|
|
2419
|
+
const roleState = (_a = accu[role.name]) != null ? _a : __spreadValues({}, emptyRole);
|
|
2420
|
+
accu[role.name] = __spreadProps(__spreadValues(__spreadValues({}, roleState), role), {
|
|
2421
|
+
description: roleState.description ? roleState.description : role.description,
|
|
2422
|
+
editable: !rolesById[role.name] && !isCustom && (typeof roleState.editable !== "undefined" ? roleState.editable : true),
|
|
2423
|
+
isCustom,
|
|
2424
|
+
name: roleState.name ? roleState.name : role.name,
|
|
2425
|
+
uiPermissions: normalizedPermissions
|
|
2426
|
+
});
|
|
2427
|
+
return accu;
|
|
2428
|
+
},
|
|
2429
|
+
__spreadValues({}, rolesById2)
|
|
2430
|
+
);
|
|
2431
|
+
var getPermissionSets = createAsyncThunk5(
|
|
2432
|
+
`${sliceName6}/getPermissionSets`,
|
|
2433
|
+
(_, { dispatch, getState }) => general_api_default.get(`${useradmApiUrlv2}/permission_sets?per_page=500`).then(({ data }) => {
|
|
2434
|
+
const permissionSets = data.reduce(
|
|
2435
|
+
(accu, permissionSet) => {
|
|
2436
|
+
var _a, _b;
|
|
2437
|
+
const permissionSetState = (_a = accu[permissionSet.name]) != null ? _a : {};
|
|
2438
|
+
let permissionSetObject = __spreadValues(__spreadValues({}, permissionSetState), permissionSet);
|
|
2439
|
+
permissionSetObject.result = Object.values(uiPermissionsById).reduce(
|
|
2440
|
+
(accu2, item) => Object.entries(item.permissionSets).reduce((collector, [area, permissionSet2]) => {
|
|
2441
|
+
if (scopedPermissionAreas[area]) {
|
|
2442
|
+
return collector;
|
|
2443
|
+
}
|
|
2444
|
+
if (permissionSet2 === permissionSetObject.name) {
|
|
2445
|
+
collector[area] = [...collector[area], item.value].filter(duplicateFilter);
|
|
2446
|
+
}
|
|
2447
|
+
return collector;
|
|
2448
|
+
}, accu2),
|
|
2449
|
+
__spreadValues(__spreadValues({}, emptyUiPermissions), (_b = permissionSetObject.result) != null ? _b : {})
|
|
2450
|
+
);
|
|
2451
|
+
const scopes = Object.values(scopedPermissionAreas).reduce((accu2, { key, scopeType }) => {
|
|
2452
|
+
var _a2, _b2;
|
|
2453
|
+
if (((_a2 = permissionSetObject.supported_scope_types) == null ? void 0 : _a2.includes(key)) || ((_b2 = permissionSetObject.supported_scope_types) == null ? void 0 : _b2.includes(scopeType))) {
|
|
2454
|
+
accu2.push(key);
|
|
2455
|
+
}
|
|
2456
|
+
return accu2;
|
|
2457
|
+
}, []);
|
|
2458
|
+
permissionSetObject = scopes.reduce((accu2, scope) => {
|
|
2459
|
+
accu2.result[scope] = mapPermissionSet(permissionSetObject.name, [scopedPermissionAreas[scope].excessiveAccessSelector], scope);
|
|
2460
|
+
return accu2;
|
|
2461
|
+
}, permissionSetObject);
|
|
2462
|
+
accu[permissionSet.name] = permissionSetObject;
|
|
2463
|
+
return accu;
|
|
2464
|
+
},
|
|
2465
|
+
// @ts-ignore
|
|
2466
|
+
__spreadValues({}, getState().users.permissionSetsById)
|
|
2467
|
+
);
|
|
2468
|
+
return Promise.all([dispatch(actions6.receivedPermissionSets(permissionSets)), permissionSets]);
|
|
2469
|
+
}).catch(() => console.log("Permission set retrieval failed - likely accessing a non-RBAC backend"))
|
|
2470
|
+
);
|
|
2471
|
+
var getRoles = createAsyncThunk5(
|
|
2472
|
+
`${sliceName6}/getRoles`,
|
|
2473
|
+
(_, { dispatch, getState }) => Promise.all([general_api_default.get(`${useradmApiUrlv2}/roles?per_page=500`), dispatch(getPermissionSets())]).then((results) => {
|
|
2474
|
+
if (!results) {
|
|
2475
|
+
return Promise.resolve();
|
|
2476
|
+
}
|
|
2477
|
+
const [{ data: roles }, { payload: permissionSetTasks }] = results;
|
|
2478
|
+
const rolesById2 = normalizeRbacRoles(roles, getRolesById(getState()), permissionSetTasks[permissionSetTasks.length - 1]);
|
|
2479
|
+
return Promise.resolve(dispatch(actions6.receivedRoles(rolesById2)));
|
|
2480
|
+
}).catch(() => console.log("Role retrieval failed - likely accessing a non-RBAC backend"))
|
|
2481
|
+
);
|
|
2482
|
+
var deriveImpliedAreaPermissions = (area, areaPermissions, skipPermissions = []) => {
|
|
2483
|
+
const highestAreaPermissionLevelSelected = areaPermissions.reduce(
|
|
2484
|
+
(highest, current) => uiPermissionsById[current].permissionLevel > highest ? uiPermissionsById[current].permissionLevel : highest,
|
|
2485
|
+
1
|
|
2486
|
+
);
|
|
2487
|
+
return uiPermissionsByArea[area].uiPermissions.reduce((permissions, current) => {
|
|
2488
|
+
if ((current.permissionLevel < highestAreaPermissionLevelSelected || areaPermissions.includes(current.value)) && !skipPermissions.includes(current.value)) {
|
|
2489
|
+
permissions.push(current.value);
|
|
2490
|
+
}
|
|
2491
|
+
return permissions;
|
|
2492
|
+
}, []);
|
|
2493
|
+
};
|
|
2494
|
+
var transformAreaRoleDataToScopedPermissionsSets = (area, areaPermissions, excessiveAccessSelector) => {
|
|
2495
|
+
const permissionSetObject = areaPermissions.reduce((accu, { item, uiPermissions }) => {
|
|
2496
|
+
const skipPermissions = scopedPermissionAreas.releases.key === area && item !== ALL_RELEASES ? [uiPermissionsById.upload.value] : [];
|
|
2497
|
+
const impliedPermissions = deriveImpliedAreaPermissions(area, uiPermissions, skipPermissions);
|
|
2498
|
+
accu = impliedPermissions.reduce((itemPermissionAccu, impliedPermission) => {
|
|
2499
|
+
var _a;
|
|
2500
|
+
const permissionSetState = (_a = itemPermissionAccu[uiPermissionsById[impliedPermission].permissionSets[area]]) != null ? _a : {
|
|
2501
|
+
type: uiPermissionsByArea[area].scope,
|
|
2502
|
+
value: []
|
|
2503
|
+
};
|
|
2504
|
+
itemPermissionAccu[uiPermissionsById[impliedPermission].permissionSets[area]] = __spreadProps(__spreadValues({}, permissionSetState), {
|
|
2505
|
+
value: [...permissionSetState.value, item]
|
|
2506
|
+
});
|
|
2507
|
+
return itemPermissionAccu;
|
|
2508
|
+
}, accu);
|
|
2509
|
+
return accu;
|
|
2510
|
+
}, {});
|
|
2511
|
+
return Object.entries(permissionSetObject).map((_a) => {
|
|
2512
|
+
var [name, _b] = _a, _c = _b, { value } = _c, scope = __objRest(_c, ["value"]);
|
|
2513
|
+
if (value.includes(excessiveAccessSelector)) {
|
|
2514
|
+
return { name };
|
|
2515
|
+
}
|
|
2516
|
+
return { name, scope: __spreadProps(__spreadValues({}, scope), { value: value.filter(duplicateFilter) }) };
|
|
2517
|
+
});
|
|
2518
|
+
};
|
|
2519
|
+
var transformRoleDataToRole = (roleData, roleState = {}) => {
|
|
2520
|
+
const role = __spreadValues(__spreadValues({}, roleState), roleData);
|
|
2521
|
+
const { description = "", name, uiPermissions = emptyUiPermissions } = role;
|
|
2522
|
+
const { maybeUiPermissions, remainderKeys } = Object.entries(emptyUiPermissions).reduce(
|
|
2523
|
+
(accu, [key, emptyPermissions]) => {
|
|
2524
|
+
if (!scopedPermissionAreas[key]) {
|
|
2525
|
+
accu.remainderKeys.push(key);
|
|
2526
|
+
} else if (uiPermissions[key]) {
|
|
2527
|
+
accu.maybeUiPermissions[key] = uiPermissions[key].reduce(itemUiPermissionsReducer, emptyPermissions);
|
|
2528
|
+
}
|
|
2529
|
+
return accu;
|
|
2530
|
+
},
|
|
2531
|
+
{ maybeUiPermissions: {}, remainderKeys: [] }
|
|
2532
|
+
);
|
|
2533
|
+
const { permissionSetsWithScope, roleUiPermissions } = remainderKeys.reduce(
|
|
2534
|
+
(accu, area) => {
|
|
2535
|
+
const areaPermissions = role.uiPermissions[area];
|
|
2536
|
+
if (!Array.isArray(areaPermissions)) {
|
|
2537
|
+
return accu;
|
|
2538
|
+
}
|
|
2539
|
+
const impliedPermissions = deriveImpliedAreaPermissions(area, areaPermissions);
|
|
2540
|
+
accu.roleUiPermissions[area] = impliedPermissions;
|
|
2541
|
+
const mappedPermissions = impliedPermissions.map((uiPermission) => ({ name: uiPermissionsById[uiPermission].permissionSets[area] }));
|
|
2542
|
+
accu.permissionSetsWithScope.push(...mappedPermissions);
|
|
2543
|
+
return accu;
|
|
2544
|
+
},
|
|
2545
|
+
{ permissionSetsWithScope: [{ name: defaultPermissionSets.Basic.name }], roleUiPermissions: {} }
|
|
2546
|
+
);
|
|
2547
|
+
const scopedPermissionSets = Object.values(scopedPermissionAreas).reduce((accu, { key, excessiveAccessSelector }) => {
|
|
2548
|
+
if (!uiPermissions[key]) {
|
|
2549
|
+
return accu;
|
|
2550
|
+
}
|
|
2551
|
+
accu.push(...transformAreaRoleDataToScopedPermissionsSets(key, uiPermissions[key], excessiveAccessSelector));
|
|
2552
|
+
return accu;
|
|
2553
|
+
}, []);
|
|
2554
|
+
return {
|
|
2555
|
+
permissionSetsWithScope: [...permissionSetsWithScope, ...scopedPermissionSets],
|
|
2556
|
+
role: __spreadProps(__spreadValues({}, emptyRole), {
|
|
2557
|
+
name,
|
|
2558
|
+
// @ts-ignore
|
|
2559
|
+
description: description ? description : roleState.description,
|
|
2560
|
+
uiPermissions: __spreadValues(__spreadValues(__spreadValues({}, emptyUiPermissions), roleUiPermissions), maybeUiPermissions)
|
|
2561
|
+
})
|
|
2562
|
+
};
|
|
2563
|
+
};
|
|
2564
|
+
var roleActions = {
|
|
2565
|
+
create: {
|
|
2566
|
+
successMessage: "The role was created successfully.",
|
|
2567
|
+
errorMessage: "creating"
|
|
2568
|
+
},
|
|
2569
|
+
edit: {
|
|
2570
|
+
successMessage: "The role has been updated.",
|
|
2571
|
+
errorMessage: "editing"
|
|
2572
|
+
},
|
|
2573
|
+
remove: {
|
|
2574
|
+
successMessage: "The role was deleted successfully.",
|
|
2575
|
+
errorMessage: "removing"
|
|
2576
|
+
}
|
|
2577
|
+
};
|
|
2578
|
+
var roleActionErrorHandler = (err, type, dispatch) => commonErrorHandler(err, `There was an error ${roleActions[type].errorMessage} the role.`, dispatch);
|
|
2579
|
+
var createRole = createAsyncThunk5(`${sliceName6}/createRole`, (roleData, { dispatch }) => {
|
|
2580
|
+
const { permissionSetsWithScope, role } = transformRoleDataToRole(roleData);
|
|
2581
|
+
return general_api_default.post(`${useradmApiUrlv2}/roles`, {
|
|
2582
|
+
name: role.name,
|
|
2583
|
+
description: role.description,
|
|
2584
|
+
permission_sets_with_scope: permissionSetsWithScope
|
|
2585
|
+
}).then(() => Promise.all([dispatch(actions6.createdRole(role)), dispatch(getRoles()), dispatch(setSnackbar4(roleActions.create.successMessage))])).catch((err) => roleActionErrorHandler(err, "create", dispatch));
|
|
2586
|
+
});
|
|
2587
|
+
var editRole = createAsyncThunk5(`${sliceName6}/editRole`, (roleData, { dispatch, getState }) => {
|
|
2588
|
+
const { permissionSetsWithScope, role } = transformRoleDataToRole(roleData, getRolesById(getState())[roleData.name]);
|
|
2589
|
+
return general_api_default.put(`${useradmApiUrlv2}/roles/${role.name}`, {
|
|
2590
|
+
description: role.description,
|
|
2591
|
+
name: role.name,
|
|
2592
|
+
permission_sets_with_scope: permissionSetsWithScope
|
|
2593
|
+
}).then(() => Promise.all([dispatch(actions6.createdRole(role)), dispatch(getRoles()), dispatch(setSnackbar4(roleActions.edit.successMessage))])).catch((err) => roleActionErrorHandler(err, "edit", dispatch));
|
|
2594
|
+
});
|
|
2595
|
+
var removeRole = createAsyncThunk5(
|
|
2596
|
+
`${sliceName6}/removeRole`,
|
|
2597
|
+
(roleId, { dispatch }) => (
|
|
2598
|
+
// @ts-ignore
|
|
2599
|
+
general_api_default.delete(`${useradmApiUrlv2}/roles/${roleId}`).then(() => Promise.all([dispatch(actions6.removedRole(roleId)), dispatch(getRoles()), dispatch(setSnackbar4(roleActions.remove.successMessage))])).catch((err) => roleActionErrorHandler(err, "remove", dispatch))
|
|
2600
|
+
)
|
|
2601
|
+
);
|
|
2602
|
+
var getGlobalSettings2 = createAsyncThunk5(
|
|
2603
|
+
`${sliceName6}/getGlobalSettings`,
|
|
2604
|
+
(_, { dispatch }) => general_api_default.get(`${useradmApiUrlv1}/settings`).then(({ data: settings, headers: { etag } }) => {
|
|
2605
|
+
window.sessionStorage.setItem(settingsKeys.initialized, true);
|
|
2606
|
+
return Promise.all([dispatch(actions6.setGlobalSettings(settings)), dispatch(setOfflineThreshold()), etag]);
|
|
2607
|
+
})
|
|
2608
|
+
);
|
|
2609
|
+
var saveGlobalSettings = createAsyncThunk5(
|
|
2610
|
+
`${sliceName6}/saveGlobalSettings`,
|
|
2611
|
+
// @ts-ignore
|
|
2612
|
+
(_a, { dispatch, getState }) => {
|
|
2613
|
+
var _b = _a, { beOptimistic = false, notify = false } = _b, settings = __objRest(_b, ["beOptimistic", "notify"]);
|
|
2614
|
+
if (!window.sessionStorage.getItem(settingsKeys.initialized) && !beOptimistic) {
|
|
2615
|
+
return;
|
|
2616
|
+
}
|
|
2617
|
+
return dispatch(getGlobalSettings2()).unwrap().then((result) => {
|
|
2618
|
+
let updatedSettings = __spreadValues(__spreadValues({}, getState().users.globalSettings), settings);
|
|
2619
|
+
if (getCurrentUser(getState()).verified) {
|
|
2620
|
+
updatedSettings["2fa"] = twoFAStates.enabled;
|
|
2621
|
+
} else {
|
|
2622
|
+
delete updatedSettings["2fa"];
|
|
2623
|
+
}
|
|
2624
|
+
let tasks = [dispatch(actions6.setGlobalSettings(updatedSettings))];
|
|
2625
|
+
const headers = result[result.length - 1] ? { "If-Match": result[result.length - 1] } : {};
|
|
2626
|
+
return general_api_default.post(`${useradmApiUrlv1}/settings`, updatedSettings, { headers }).then(() => {
|
|
2627
|
+
if (notify) {
|
|
2628
|
+
tasks.push(dispatch(setSnackbar4("Settings saved successfully")));
|
|
2629
|
+
}
|
|
2630
|
+
return Promise.all(tasks);
|
|
2631
|
+
}).catch((err) => {
|
|
2632
|
+
if (beOptimistic) {
|
|
2633
|
+
return Promise.all([tasks]);
|
|
2634
|
+
}
|
|
2635
|
+
console.log(err);
|
|
2636
|
+
return commonErrorHandler(err, `The settings couldn't be saved.`, dispatch);
|
|
2637
|
+
});
|
|
2638
|
+
});
|
|
2639
|
+
}
|
|
2640
|
+
);
|
|
2641
|
+
var getUserSettings2 = createAsyncThunk5(
|
|
2642
|
+
`${sliceName6}/getUserSettings`,
|
|
2643
|
+
(_, { dispatch }) => general_api_default.get(`${useradmApiUrlv1}/settings/me`).then(({ data: settings, headers: { etag } }) => {
|
|
2644
|
+
window.sessionStorage.setItem(settingsKeys.initialized, true);
|
|
2645
|
+
return Promise.all([dispatch(actions6.setUserSettings(settings)), etag]);
|
|
2646
|
+
})
|
|
2647
|
+
);
|
|
2648
|
+
var saveUserSettings = createAsyncThunk5(`${sliceName6}/saveUserSettings`, (settings = { onboarding: {} }, { dispatch, getState }) => {
|
|
2649
|
+
if (!getCurrentUser(getState()).id) {
|
|
2650
|
+
return Promise.resolve();
|
|
2651
|
+
}
|
|
2652
|
+
return dispatch(getUserSettings2()).unwrap().then((result) => {
|
|
2653
|
+
const userSettings = getUserSettings(getState());
|
|
2654
|
+
const onboardingState = getOnboardingState(getState());
|
|
2655
|
+
const tooltipState = getTooltipsState(getState());
|
|
2656
|
+
const updatedSettings = __spreadProps(__spreadValues(__spreadValues({}, userSettings), settings), {
|
|
2657
|
+
onboarding: __spreadValues(__spreadValues({}, onboardingState), settings.onboarding),
|
|
2658
|
+
tooltips: tooltipState
|
|
2659
|
+
});
|
|
2660
|
+
const headers = result[result.length - 1] ? { "If-Match": result[result.length - 1] } : {};
|
|
2661
|
+
return Promise.all([
|
|
2662
|
+
Promise.resolve(dispatch(actions6.setUserSettings(updatedSettings))),
|
|
2663
|
+
general_api_default.post(`${useradmApiUrlv1}/settings/me`, updatedSettings, { headers })
|
|
2664
|
+
]).catch(() => dispatch(actions6.setUserSettings(userSettings)));
|
|
2665
|
+
});
|
|
2666
|
+
});
|
|
2667
|
+
var get2FAQRCode = createAsyncThunk5(
|
|
2668
|
+
`${sliceName6}/get2FAQRCode`,
|
|
2669
|
+
(_, { dispatch }) => general_api_default.get(`${useradmApiUrlv1}/2faqr`).then((res) => dispatch(actions6.receivedQrCode(res.data.qr)))
|
|
2670
|
+
);
|
|
2671
|
+
var setHideAnnouncement = createAsyncThunk5(`${sliceName6}/setHideAnnouncement`, ({ shouldHide, userId }, { dispatch, getState }) => {
|
|
2672
|
+
const currentUserId = userId || getCurrentUser(getState()).id;
|
|
2673
|
+
const hash = getState().app.hostedAnnouncement ? hashString2(getState().app.hostedAnnouncement) : "";
|
|
2674
|
+
const announceCookie = cookies3.get(`${currentUserId}${hash}`);
|
|
2675
|
+
if (shouldHide || hash.length && typeof announceCookie !== "undefined") {
|
|
2676
|
+
cookies3.set(`${currentUserId}${hash}`, true, { maxAge: 604800 });
|
|
2677
|
+
return Promise.resolve(dispatch(setAnnouncement2()));
|
|
2678
|
+
}
|
|
2679
|
+
return Promise.resolve();
|
|
2680
|
+
});
|
|
2681
|
+
var getTokens = createAsyncThunk5(
|
|
2682
|
+
`${sliceName6}/getTokens`,
|
|
2683
|
+
(_, { dispatch, getState }) => general_api_default.get(`${useradmApiUrlv1}/settings/tokens`).then(({ data: tokens }) => {
|
|
2684
|
+
const user = getCurrentUser(getState());
|
|
2685
|
+
const updatedUser = __spreadProps(__spreadValues({}, user), {
|
|
2686
|
+
tokens
|
|
2687
|
+
});
|
|
2688
|
+
return Promise.resolve(dispatch(actions6.updatedUser(updatedUser)));
|
|
2689
|
+
})
|
|
2690
|
+
);
|
|
2691
|
+
var ONE_YEAR = 31536e3;
|
|
2692
|
+
var generateToken = createAsyncThunk5(
|
|
2693
|
+
`${sliceName6}/generateToken`,
|
|
2694
|
+
({ expiresIn = ONE_YEAR, name }, { dispatch }) => general_api_default.post(`${useradmApiUrlv1}/settings/tokens`, { name, expires_in: expiresIn }).then(({ data: token }) => Promise.all([dispatch(getTokens()), token])).catch((err) => commonErrorHandler(err, "There was an error creating the token:", dispatch))
|
|
2695
|
+
);
|
|
2696
|
+
var revokeToken = createAsyncThunk5(
|
|
2697
|
+
`${sliceName6}/revokeToken`,
|
|
2698
|
+
(token, { dispatch }) => (
|
|
2699
|
+
// @ts-ignore
|
|
2700
|
+
general_api_default.delete(`${useradmApiUrlv1}/settings/tokens/${token.id}`).then(() => Promise.resolve(dispatch(getTokens())))
|
|
2701
|
+
)
|
|
2702
|
+
);
|
|
2703
|
+
var setTooltipReadState = createAsyncThunk5(`${sliceName6}/setTooltipReadState`, (_a, { dispatch }) => {
|
|
2704
|
+
var _b = _a, { persist } = _b, remainder = __objRest(_b, ["persist"]);
|
|
2705
|
+
let tasks = [dispatch(actions6.setTooltipState(remainder))];
|
|
2706
|
+
if (persist) {
|
|
2707
|
+
tasks.push(dispatch(saveUserSettings()));
|
|
2708
|
+
}
|
|
2709
|
+
return Promise.all(tasks);
|
|
2710
|
+
});
|
|
2711
|
+
var setAllTooltipsReadState = createAsyncThunk5(`${sliceName6}/toggleHelptips`, ({ readState = READ_STATES.read, tooltips }, { dispatch }) => {
|
|
2712
|
+
const updatedTips = tooltips.reduce((accu, id) => __spreadProps(__spreadValues({}, accu), { [id]: { readState } }), {});
|
|
2713
|
+
return Promise.resolve(dispatch(actions6.setTooltipsState(updatedTips))).then(() => dispatch(saveUserSettings()));
|
|
2714
|
+
});
|
|
2715
|
+
var submitFeedback = createAsyncThunk5(
|
|
2716
|
+
`${sliceName6}/submitFeedback`,
|
|
2717
|
+
// @ts-ignore
|
|
2718
|
+
(_a, { dispatch }) => {
|
|
2719
|
+
var _b = _a, { satisfaction, feedback } = _b, meta = __objRest(_b, ["satisfaction", "feedback"]);
|
|
2720
|
+
return general_api_default.post(`${tenantadmApiUrlv2}/contact/support`, {
|
|
2721
|
+
subject: "feedback submission",
|
|
2722
|
+
body: JSON.stringify({ feedback, satisfaction, meta })
|
|
2723
|
+
}).then(() => {
|
|
2724
|
+
const today = /* @__PURE__ */ new Date();
|
|
2725
|
+
dispatch(saveUserSettings({ feedbackCollectedAt: today.toISOString().split("T")[0] }));
|
|
2726
|
+
setTimeout(() => dispatch(actions6.setShowFeedbackDialog(false)), TIMEOUTS.threeSeconds);
|
|
2727
|
+
});
|
|
2728
|
+
}
|
|
2729
|
+
);
|
|
2730
|
+
|
|
2731
|
+
// src/appSlice/thunks.ts
|
|
2732
|
+
import { deepCompare as deepCompare4 } from "@northern.tech/utils/helpers";
|
|
2733
|
+
import { createAsyncThunk as createAsyncThunk6 } from "@reduxjs/toolkit";
|
|
2734
|
+
import Cookies4 from "universal-cookie";
|
|
2735
|
+
var cookies4 = new Cookies4();
|
|
2736
|
+
var setFirstLoginAfterSignup = createAsyncThunk6(`${sliceName}/setFirstLoginAfterSignup`, (firstLoginAfterSignup, { dispatch }) => {
|
|
2737
|
+
cookies4.set("firstLoginAfterSignup", !!firstLoginAfterSignup, { maxAge: 60, path: "/", domain: ".mender.io", sameSite: false });
|
|
2738
|
+
dispatch(actions.setFirstLoginAfterSignup(!!firstLoginAfterSignup));
|
|
2739
|
+
});
|
|
2740
|
+
var dateFunctionMap = {
|
|
2741
|
+
getDays: "getDate",
|
|
2742
|
+
setDays: "setDate"
|
|
2743
|
+
};
|
|
2744
|
+
var setOfflineThreshold = createAsyncThunk6(`${sliceName}/setOfflineThreshold`, (_, { dispatch, getState }) => {
|
|
2745
|
+
var _a, _b;
|
|
2746
|
+
const { interval, intervalUnit } = getOfflineThresholdSettings(getState());
|
|
2747
|
+
const today = /* @__PURE__ */ new Date();
|
|
2748
|
+
const intervalName = `${intervalUnit.charAt(0).toUpperCase()}${intervalUnit.substring(1)}`;
|
|
2749
|
+
const setter = (_a = dateFunctionMap[`set${intervalName}`]) != null ? _a : `set${intervalName}`;
|
|
2750
|
+
const getter = (_b = dateFunctionMap[`get${intervalName}`]) != null ? _b : `get${intervalName}`;
|
|
2751
|
+
today[setter](today[getter]() - interval);
|
|
2752
|
+
let value;
|
|
2753
|
+
try {
|
|
2754
|
+
value = today.toISOString();
|
|
2755
|
+
} catch (e) {
|
|
2756
|
+
return Promise.resolve(dispatch(actions.setSnackbar("There was an error saving the offline threshold, please check your settings.")));
|
|
2757
|
+
}
|
|
2758
|
+
return Promise.resolve(dispatch(actions.setOfflineThreshold(value)));
|
|
2759
|
+
});
|
|
2760
|
+
var versionRegex = new RegExp(/\d+\.\d+/);
|
|
2761
|
+
var getLatestRelease = (thing) => {
|
|
2762
|
+
const latestKey = Object.keys(thing).filter((key) => versionRegex.test(key)).sort().reverse()[0];
|
|
2763
|
+
return thing[latestKey];
|
|
2764
|
+
};
|
|
2765
|
+
var repoKeyMap = {
|
|
2766
|
+
integration: "Integration",
|
|
2767
|
+
mender: "Mender-Client",
|
|
2768
|
+
"mender-artifact": "Mender-Artifact"
|
|
2769
|
+
};
|
|
2770
|
+
var deductSaasState = (latestRelease, guiTags, saasReleases) => {
|
|
2771
|
+
const latestGuiTag = guiTags.length ? guiTags[0].name : "";
|
|
2772
|
+
const latestSaasRelease = latestGuiTag.startsWith("saas-v") ? { date: latestGuiTag.split("-v")[1].replaceAll(".", "-"), tag: latestGuiTag } : saasReleases[0];
|
|
2773
|
+
return latestSaasRelease.date > latestRelease.release_date ? latestSaasRelease.tag : latestRelease.release;
|
|
2774
|
+
};
|
|
2775
|
+
var getLatestReleaseInfo = createAsyncThunk6(`${sliceName}/getLatestReleaseInfo`, (_, { dispatch, getState }) => {
|
|
2776
|
+
if (!getFeatures(getState()).isHosted) {
|
|
2777
|
+
return Promise.resolve();
|
|
2778
|
+
}
|
|
2779
|
+
return Promise.all([general_api_default.get("/versions.json"), general_api_default.get("/tags.json")]).catch((err) => {
|
|
2780
|
+
console.log("init error:", extractErrorMessage(err));
|
|
2781
|
+
return Promise.resolve([{ data: {} }, { data: [] }]);
|
|
2782
|
+
}).then(([{ data }, { data: guiTags }]) => {
|
|
2783
|
+
if (!guiTags.length) {
|
|
2784
|
+
return Promise.resolve();
|
|
2785
|
+
}
|
|
2786
|
+
const { releases, saas } = data;
|
|
2787
|
+
const latestRelease = getLatestRelease(getLatestRelease(releases));
|
|
2788
|
+
const { latestRepos, latestVersions } = latestRelease.repos.reduce(
|
|
2789
|
+
(accu, item) => {
|
|
2790
|
+
if (repoKeyMap[item.name]) {
|
|
2791
|
+
accu.latestVersions[repoKeyMap[item.name]] = getComparisonCompatibleVersion(item.version);
|
|
2792
|
+
}
|
|
2793
|
+
accu.latestRepos[item.name] = getComparisonCompatibleVersion(item.version);
|
|
2794
|
+
return accu;
|
|
2795
|
+
},
|
|
2796
|
+
{ latestVersions: __spreadValues({}, getState().app.versionInformation), latestRepos: {} }
|
|
2797
|
+
);
|
|
2798
|
+
const info = deductSaasState(latestRelease, guiTags, saas);
|
|
2799
|
+
return Promise.resolve(
|
|
2800
|
+
dispatch(
|
|
2801
|
+
actions.setVersionInformation(__spreadProps(__spreadValues({}, latestVersions), {
|
|
2802
|
+
backend: info,
|
|
2803
|
+
GUI: info,
|
|
2804
|
+
latestRelease: {
|
|
2805
|
+
releaseDate: latestRelease.release_date,
|
|
2806
|
+
repos: latestRepos
|
|
2807
|
+
}
|
|
2808
|
+
}))
|
|
2809
|
+
)
|
|
2810
|
+
);
|
|
2811
|
+
});
|
|
2812
|
+
});
|
|
2813
|
+
var setSearchState = createAsyncThunk6(`${sliceName}/setSearchState`, (searchState, { dispatch, getState }) => {
|
|
2814
|
+
const currentState = getSearchState(getState());
|
|
2815
|
+
let nextState = __spreadProps(__spreadValues(__spreadValues({}, currentState), searchState), {
|
|
2816
|
+
sort: __spreadValues(__spreadValues({}, currentState.sort), searchState.sort)
|
|
2817
|
+
});
|
|
2818
|
+
let tasks = [];
|
|
2819
|
+
const _a = currentState, { isSearching: currentSearching, deviceIds: currentDevices, searchTotal: currentTotal } = _a, currentRequestState = __objRest(_a, ["isSearching", "deviceIds", "searchTotal"]);
|
|
2820
|
+
const _b = nextState, { isSearching: nextSearching, deviceIds: nextDevices, searchTotal: nextTotal } = _b, nextRequestState = __objRest(_b, ["isSearching", "deviceIds", "searchTotal"]);
|
|
2821
|
+
if (nextRequestState.searchTerm && !deepCompare4(currentRequestState, nextRequestState)) {
|
|
2822
|
+
nextState.isSearching = true;
|
|
2823
|
+
tasks.push(
|
|
2824
|
+
dispatch(searchDevices(nextState)).unwrap().then((results) => {
|
|
2825
|
+
const searchResult = results[results.length - 1];
|
|
2826
|
+
return dispatch(actions.setSearchState(__spreadProps(__spreadValues({}, searchResult), { isSearching: false })));
|
|
2827
|
+
}).catch(() => dispatch(actions.setSearchState({ isSearching: false, searchTotal: 0 })))
|
|
2828
|
+
);
|
|
2829
|
+
}
|
|
2830
|
+
tasks.push(dispatch(actions.setSearchState(nextState)));
|
|
2831
|
+
return Promise.all(tasks);
|
|
2832
|
+
});
|
|
2833
|
+
|
|
2834
|
+
export {
|
|
2835
|
+
setFirstLoginAfterSignup,
|
|
2836
|
+
setOfflineThreshold,
|
|
2837
|
+
getLatestReleaseInfo,
|
|
2838
|
+
setSearchState,
|
|
2839
|
+
deriveDeploymentGroup,
|
|
2840
|
+
getDeploymentsByStatus2 as getDeploymentsByStatus,
|
|
2841
|
+
createDeployment,
|
|
2842
|
+
getDeploymentDevices,
|
|
2843
|
+
getDeviceDeployments,
|
|
2844
|
+
resetDeviceDeployments,
|
|
2845
|
+
getSingleDeployment,
|
|
2846
|
+
getDeviceLog,
|
|
2847
|
+
abortDeployment,
|
|
2848
|
+
updateDeploymentControlMap,
|
|
2849
|
+
setDeploymentsState,
|
|
2850
|
+
getDeploymentsConfig,
|
|
2851
|
+
saveDeltaDeploymentsConfig,
|
|
2852
|
+
getGroups2 as getGroups,
|
|
2853
|
+
addDevicesToGroup,
|
|
2854
|
+
removeDevicesFromGroup,
|
|
2855
|
+
addStaticGroup,
|
|
2856
|
+
removeStaticGroup,
|
|
2857
|
+
getDynamicGroups,
|
|
2858
|
+
addDynamicGroup,
|
|
2859
|
+
updateDynamicGroup,
|
|
2860
|
+
removeDynamicGroup,
|
|
2861
|
+
selectGroup,
|
|
2862
|
+
getGroupDevices,
|
|
2863
|
+
getAllGroupDevices,
|
|
2864
|
+
getAllDynamicGroupDevices,
|
|
2865
|
+
getDeviceById2 as getDeviceById,
|
|
2866
|
+
getDeviceInfo,
|
|
2867
|
+
deriveInactiveDevices,
|
|
2868
|
+
getDeviceCount,
|
|
2869
|
+
getAllDeviceCounts,
|
|
2870
|
+
getDeviceLimit,
|
|
2871
|
+
setDeviceListState,
|
|
2872
|
+
getDevicesByStatus,
|
|
2873
|
+
getAllDevicesByStatus,
|
|
2874
|
+
searchDevices,
|
|
2875
|
+
getDeviceAttributes,
|
|
2876
|
+
getReportingLimits,
|
|
2877
|
+
ensureVersionString,
|
|
2878
|
+
getReportsData,
|
|
2879
|
+
deriveReportsData,
|
|
2880
|
+
getReportsDataWithoutBackendSupport,
|
|
2881
|
+
getDeviceConnect,
|
|
2882
|
+
getSessionDetails,
|
|
2883
|
+
getDeviceFileDownloadLink,
|
|
2884
|
+
deviceFileUpload,
|
|
2885
|
+
getDeviceAuth,
|
|
2886
|
+
getDevicesWithAuth,
|
|
2887
|
+
updateDeviceAuth,
|
|
2888
|
+
updateDevicesAuth,
|
|
2889
|
+
deleteAuthset,
|
|
2890
|
+
preauthDevice,
|
|
2891
|
+
decommissionDevice,
|
|
2892
|
+
getDeviceConfig,
|
|
2893
|
+
setDeviceConfig,
|
|
2894
|
+
applyDeviceConfig,
|
|
2895
|
+
setDeviceTags,
|
|
2896
|
+
getDeviceTwin,
|
|
2897
|
+
setDeviceTwin,
|
|
2898
|
+
getSystemDevices,
|
|
2899
|
+
getGatewayDevices,
|
|
2900
|
+
getDevicesInBounds,
|
|
2901
|
+
applyOnboardingFallbacks,
|
|
2902
|
+
getOnboardingState2 as getOnboardingState,
|
|
2903
|
+
setOnboardingDeviceType,
|
|
2904
|
+
setOnboardingApproach,
|
|
2905
|
+
setOnboardingComplete,
|
|
2906
|
+
setOnboardingCanceled,
|
|
2907
|
+
advanceOnboarding,
|
|
2908
|
+
cancelRequest,
|
|
2909
|
+
getTargetLocation,
|
|
2910
|
+
createOrganizationTrial,
|
|
2911
|
+
startCardUpdate,
|
|
2912
|
+
confirmCardUpdate,
|
|
2913
|
+
getCurrentCard,
|
|
2914
|
+
startUpgrade,
|
|
2915
|
+
cancelUpgrade,
|
|
2916
|
+
completeUpgrade,
|
|
2917
|
+
getAuditLogs,
|
|
2918
|
+
getAuditLogsCsvLink,
|
|
2919
|
+
setAuditlogsState,
|
|
2920
|
+
tenantDataDivergedMessage,
|
|
2921
|
+
addTenant,
|
|
2922
|
+
getTenants,
|
|
2923
|
+
setTenantsListState,
|
|
2924
|
+
editTenantDeviceLimit,
|
|
2925
|
+
removeTenant,
|
|
2926
|
+
getUserOrganization,
|
|
2927
|
+
sendSupportMessage,
|
|
2928
|
+
requestPlanChange,
|
|
2929
|
+
downloadLicenseReport,
|
|
2930
|
+
createIntegration,
|
|
2931
|
+
changeIntegration,
|
|
2932
|
+
deleteIntegration,
|
|
2933
|
+
getIntegrations,
|
|
2934
|
+
getWebhookEvents,
|
|
2935
|
+
storeSsoConfig,
|
|
2936
|
+
changeSsoConfig,
|
|
2937
|
+
deleteSsoConfig,
|
|
2938
|
+
getSsoConfigById,
|
|
2939
|
+
getSsoConfigs,
|
|
2940
|
+
loginUser,
|
|
2941
|
+
logoutUser,
|
|
2942
|
+
switchUserOrganization,
|
|
2943
|
+
passwordResetStart,
|
|
2944
|
+
passwordResetComplete,
|
|
2945
|
+
verifyEmailStart,
|
|
2946
|
+
verifyEmailComplete,
|
|
2947
|
+
verify2FA,
|
|
2948
|
+
getUserList,
|
|
2949
|
+
getUser,
|
|
2950
|
+
initializeSelf,
|
|
2951
|
+
updateUserColumnSettings,
|
|
2952
|
+
createUser,
|
|
2953
|
+
removeUser,
|
|
2954
|
+
editUser,
|
|
2955
|
+
addUserToCurrentTenant,
|
|
2956
|
+
enableUser2fa,
|
|
2957
|
+
disableUser2fa,
|
|
2958
|
+
normalizeRbacRoles,
|
|
2959
|
+
getPermissionSets,
|
|
2960
|
+
getRoles,
|
|
2961
|
+
createRole,
|
|
2962
|
+
editRole,
|
|
2963
|
+
removeRole,
|
|
2964
|
+
getGlobalSettings2 as getGlobalSettings,
|
|
2965
|
+
saveGlobalSettings,
|
|
2966
|
+
getUserSettings2 as getUserSettings,
|
|
2967
|
+
saveUserSettings,
|
|
2968
|
+
get2FAQRCode,
|
|
2969
|
+
setHideAnnouncement,
|
|
2970
|
+
getTokens,
|
|
2971
|
+
generateToken,
|
|
2972
|
+
revokeToken,
|
|
2973
|
+
setTooltipReadState,
|
|
2974
|
+
setAllTooltipsReadState,
|
|
2975
|
+
submitFeedback
|
|
2976
|
+
};
|
|
2977
|
+
//# sourceMappingURL=chunk-YNVSU3AA.mjs.map
|