@northern.tech/store 0.3.3 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions.cjs +80 -833
- package/dist/actions.cjs.map +1 -1
- package/dist/actions.d.cts +229 -85
- package/dist/actions.d.ts +229 -85
- package/dist/actions.js +14 -14
- package/dist/api/general-api.cjs +274 -148
- package/dist/api/general-api.cjs.map +1 -1
- package/dist/api/general-api.d.cts +1 -1
- package/dist/api/general-api.d.ts +1 -1
- package/dist/api/general-api.js +7 -7
- package/dist/api/users-api.cjs +274 -148
- package/dist/api/users-api.cjs.map +1 -1
- package/dist/api/users-api.d.cts +7 -5
- package/dist/api/users-api.d.ts +7 -5
- package/dist/api/users-api.js +8 -8
- package/dist/appSlice/constants.cjs +23 -43
- package/dist/appSlice/constants.cjs.map +1 -1
- package/dist/appSlice/constants.d.cts +109 -119
- package/dist/appSlice/constants.d.ts +109 -119
- package/dist/appSlice/constants.js +1 -11
- package/dist/appSlice/index.cjs +25 -242
- package/dist/appSlice/index.cjs.map +1 -1
- package/dist/appSlice/index.d.cts +119 -1531
- package/dist/appSlice/index.d.ts +119 -1531
- package/dist/appSlice/index.js +6 -6
- package/dist/appSlice/mocks.cjs +186 -0
- package/dist/appSlice/mocks.cjs.map +1 -0
- package/dist/appSlice/mocks.d.cts +39 -0
- package/dist/appSlice/mocks.d.ts +39 -0
- package/dist/appSlice/mocks.js +27 -0
- package/dist/appSlice/mocks.js.map +1 -0
- package/dist/appSlice/selectors.cjs +31 -5
- package/dist/appSlice/selectors.cjs.map +1 -1
- package/dist/appSlice/selectors.d.cts +709 -23
- package/dist/appSlice/selectors.d.ts +709 -23
- package/dist/appSlice/selectors.js +21 -1
- package/dist/appSlice/thunks.cjs +1563 -1790
- package/dist/appSlice/thunks.cjs.map +1 -1
- package/dist/appSlice/thunks.d.cts +34 -14
- package/dist/appSlice/thunks.d.ts +34 -14
- package/dist/appSlice/thunks.js +30 -29
- package/dist/auth.cjs +276 -153
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +13 -10
- package/dist/auth.d.ts +13 -10
- package/dist/auth.js +6 -8
- package/dist/{chunk-CK6YE6AN.js → chunk-2DYA3X77.js} +3 -1
- package/dist/{chunk-CK6YE6AN.js.map → chunk-2DYA3X77.js.map} +1 -1
- package/dist/{chunk-2CYOM4BK.js → chunk-4TUJPE6G.js} +19 -4
- package/dist/chunk-4TUJPE6G.js.map +1 -0
- package/dist/{chunk-7PVGDMNM.js → chunk-6KGTHJKC.js} +23 -27
- package/dist/chunk-6KGTHJKC.js.map +1 -0
- package/dist/chunk-7C4SQBEE.js +715 -0
- package/dist/chunk-7C4SQBEE.js.map +1 -0
- package/dist/{chunk-QRGTG4YB.js → chunk-ABJLRDCO.js} +10 -11
- package/dist/chunk-ABJLRDCO.js.map +1 -0
- package/dist/{chunk-LEMVXAYP.js → chunk-CW5T6OGF.js} +56 -22
- package/dist/chunk-CW5T6OGF.js.map +1 -0
- package/dist/{chunk-MRCFLG45.js → chunk-FAJ3I2UQ.js} +2 -1
- package/dist/chunk-FAJ3I2UQ.js.map +1 -0
- package/dist/{chunk-DCK2DBOA.js → chunk-IQG5I7AM.js} +29 -39
- package/dist/chunk-IQG5I7AM.js.map +1 -0
- package/dist/chunk-JUGE7L3K.js +110 -0
- package/dist/chunk-JUGE7L3K.js.map +1 -0
- package/dist/{chunk-7JKWI5FK.js → chunk-JXQUFKID.js} +2 -2
- package/dist/chunk-JXQUFKID.js.map +1 -0
- package/dist/chunk-KC7SKI3U.js +389 -0
- package/dist/chunk-KC7SKI3U.js.map +1 -0
- package/dist/{chunk-YDS36ALB.js → chunk-KJNNEDRV.js} +11 -7
- package/dist/chunk-KJNNEDRV.js.map +1 -0
- package/dist/chunk-MBKAZVE3.js +44 -0
- package/dist/chunk-MBKAZVE3.js.map +1 -0
- package/dist/{chunk-TI2RL5P2.js → chunk-MZNANSS2.js} +12 -7
- package/dist/chunk-MZNANSS2.js.map +1 -0
- package/dist/{chunk-LTKOV26W.js → chunk-N2KLYPS5.js} +138 -95
- package/dist/chunk-N2KLYPS5.js.map +1 -0
- package/dist/{chunk-UWMYZNUB.js → chunk-OHF3YUXX.js} +25 -40
- package/dist/chunk-OHF3YUXX.js.map +1 -0
- package/dist/{chunk-CYV6632F.js → chunk-OOICURFL.js} +2 -2
- package/dist/chunk-OOICURFL.js.map +1 -0
- package/dist/{chunk-VMNMD6KF.js → chunk-PGFVHKP5.js} +5 -7
- package/dist/chunk-PGFVHKP5.js.map +1 -0
- package/dist/{chunk-JAROCU6M.js → chunk-QHK7GGV4.js} +3 -3
- package/dist/chunk-QHK7GGV4.js.map +1 -0
- package/dist/{chunk-YT73QWCN.js → chunk-RS37Y2PQ.js} +3 -3
- package/dist/chunk-RS37Y2PQ.js.map +1 -0
- package/dist/{chunk-TUACATJA.js → chunk-UGSLGUS6.js} +8 -6
- package/dist/chunk-UGSLGUS6.js.map +1 -0
- package/dist/{chunk-DAPAXWA5.js → chunk-URNS6A5T.js} +14 -14
- package/dist/{chunk-FGKMJS3B.js → chunk-VANBSJS5.js} +2 -4
- package/dist/chunk-VANBSJS5.js.map +1 -0
- package/dist/{chunk-HPBE6KYY.js → chunk-VUFRP6P3.js} +5 -6
- package/dist/chunk-VUFRP6P3.js.map +1 -0
- package/dist/{chunk-X7IEZBM4.js → chunk-X4GUACQO.js} +8 -5
- package/dist/chunk-X4GUACQO.js.map +1 -0
- package/dist/{chunk-4XJMRVFI.js → chunk-XWYJACQC.js} +45 -22
- package/dist/chunk-XWYJACQC.js.map +1 -0
- package/dist/{chunk-AMGWP7A4.js → chunk-ZJW3QIPM.js} +8 -9
- package/dist/chunk-ZJW3QIPM.js.map +1 -0
- package/dist/chunk-ZKAH3APE.js +1 -0
- package/dist/chunk-ZKAH3APE.js.map +1 -0
- package/dist/{chunk-2JHFUQ6B.js → chunk-ZN5TB2NJ.js} +963 -883
- package/dist/chunk-ZN5TB2NJ.js.map +1 -0
- package/dist/{chunk-WXL7PVI5.js → chunk-ZRSYBSSY.js} +18 -12
- package/dist/chunk-ZRSYBSSY.js.map +1 -0
- package/dist/commonConstants.cjs +279 -173
- package/dist/commonConstants.cjs.map +1 -1
- package/dist/commonConstants.d.cts +46 -212
- package/dist/commonConstants.d.ts +46 -212
- package/dist/commonConstants.js +11 -19
- package/dist/commonSelectors.cjs +513 -778
- package/dist/commonSelectors.cjs.map +1 -1
- package/dist/commonSelectors.d.cts +4307 -279
- package/dist/commonSelectors.d.ts +4307 -279
- package/dist/commonSelectors.js +13 -13
- package/dist/constants.cjs +355 -655
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts +11 -9
- package/dist/constants.d.ts +11 -9
- package/dist/constants.js +37 -29
- package/dist/deploymentsSlice/constants.cjs +5 -360
- package/dist/deploymentsSlice/constants.cjs.map +1 -1
- package/dist/deploymentsSlice/constants.d.cts +59 -39
- package/dist/deploymentsSlice/constants.d.ts +59 -39
- package/dist/deploymentsSlice/constants.js +5 -11
- package/dist/deploymentsSlice/index.cjs +17 -365
- package/dist/deploymentsSlice/index.cjs.map +1 -1
- package/dist/deploymentsSlice/index.d.cts +142 -2359
- package/dist/deploymentsSlice/index.d.ts +142 -2359
- package/dist/deploymentsSlice/index.js +6 -6
- package/dist/deploymentsSlice/mocks.cjs +429 -0
- package/dist/deploymentsSlice/mocks.cjs.map +1 -0
- package/dist/deploymentsSlice/mocks.d.cts +189 -0
- package/dist/deploymentsSlice/mocks.d.ts +189 -0
- package/dist/deploymentsSlice/mocks.js +146 -0
- package/dist/deploymentsSlice/mocks.js.map +1 -0
- package/dist/deploymentsSlice/selectors.cjs +5 -353
- package/dist/deploymentsSlice/selectors.cjs.map +1 -1
- package/dist/deploymentsSlice/selectors.d.cts +167 -11
- package/dist/deploymentsSlice/selectors.d.ts +167 -11
- package/dist/deploymentsSlice/selectors.js +6 -6
- package/dist/deploymentsSlice/thunks.cjs +1551 -1778
- package/dist/deploymentsSlice/thunks.cjs.map +1 -1
- package/dist/deploymentsSlice/thunks.d.cts +134 -76
- package/dist/deploymentsSlice/thunks.d.ts +134 -76
- package/dist/deploymentsSlice/thunks.js +30 -29
- package/dist/devicesSlice/constants.cjs +5 -375
- package/dist/devicesSlice/constants.cjs.map +1 -1
- package/dist/devicesSlice/constants.d.cts +8 -16
- package/dist/devicesSlice/constants.d.ts +8 -16
- package/dist/devicesSlice/constants.js +7 -25
- package/dist/devicesSlice/index.cjs +17 -381
- package/dist/devicesSlice/index.cjs.map +1 -1
- package/dist/devicesSlice/index.d.cts +196 -2208
- package/dist/devicesSlice/index.d.ts +196 -2208
- package/dist/devicesSlice/index.js +6 -6
- package/dist/devicesSlice/mocks.cjs +336 -0
- package/dist/devicesSlice/mocks.cjs.map +1 -0
- package/dist/devicesSlice/mocks.d.cts +154 -0
- package/dist/devicesSlice/mocks.d.ts +154 -0
- package/dist/devicesSlice/mocks.js +136 -0
- package/dist/devicesSlice/mocks.js.map +1 -0
- package/dist/devicesSlice/selectors.cjs +280 -293
- package/dist/devicesSlice/selectors.cjs.map +1 -1
- package/dist/devicesSlice/selectors.d.cts +1791 -82
- package/dist/devicesSlice/selectors.d.ts +1791 -82
- package/dist/devicesSlice/selectors.js +8 -6
- package/dist/devicesSlice/thunks.cjs +1699 -1936
- package/dist/devicesSlice/thunks.cjs.map +1 -1
- package/dist/devicesSlice/thunks.d.cts +374 -291
- package/dist/devicesSlice/thunks.d.ts +374 -291
- package/dist/devicesSlice/thunks.js +36 -45
- package/dist/liststatehook.cjs +935 -0
- package/dist/liststatehook.cjs.map +1 -0
- package/dist/liststatehook.d.cts +234 -0
- package/dist/liststatehook.d.ts +234 -0
- package/dist/liststatehook.js +88 -0
- package/dist/liststatehook.js.map +1 -0
- package/dist/locationutils.cjs +906 -0
- package/dist/locationutils.cjs.map +1 -0
- package/dist/locationutils.d.cts +114 -0
- package/dist/locationutils.d.ts +114 -0
- package/dist/locationutils.js +46 -0
- package/dist/locationutils.js.map +1 -0
- package/dist/monitorSlice/constants.cjs +0 -146
- package/dist/monitorSlice/constants.cjs.map +1 -1
- package/dist/monitorSlice/constants.d.cts +4 -5
- package/dist/monitorSlice/constants.d.ts +4 -5
- package/dist/monitorSlice/constants.js +1 -12
- package/dist/monitorSlice/index.cjs +5 -353
- package/dist/monitorSlice/index.cjs.map +1 -1
- package/dist/monitorSlice/index.d.cts +63 -260
- package/dist/monitorSlice/index.d.ts +63 -260
- package/dist/monitorSlice/index.js +6 -6
- package/dist/monitorSlice/mocks.cjs +130 -0
- package/dist/monitorSlice/mocks.cjs.map +1 -0
- package/dist/monitorSlice/mocks.d.cts +57 -0
- package/dist/monitorSlice/mocks.d.ts +57 -0
- package/dist/monitorSlice/mocks.js +65 -0
- package/dist/monitorSlice/mocks.js.map +1 -0
- package/dist/monitorSlice/thunks.cjs +633 -880
- package/dist/monitorSlice/thunks.cjs.map +1 -1
- package/dist/monitorSlice/thunks.d.cts +90 -21
- package/dist/monitorSlice/thunks.d.ts +90 -21
- package/dist/monitorSlice/thunks.js +26 -26
- package/dist/onboardingSlice/constants.cjs +1 -0
- package/dist/onboardingSlice/constants.cjs.map +1 -1
- package/dist/onboardingSlice/constants.d.cts +23 -20
- package/dist/onboardingSlice/constants.d.ts +23 -20
- package/dist/onboardingSlice/constants.js +1 -1
- package/dist/onboardingSlice/index.cjs +1 -3
- package/dist/onboardingSlice/index.cjs.map +1 -1
- package/dist/onboardingSlice/index.d.cts +50 -225
- package/dist/onboardingSlice/index.d.ts +50 -225
- package/dist/onboardingSlice/index.js +1 -1
- package/dist/onboardingSlice/mocks.cjs +83 -0
- package/dist/onboardingSlice/mocks.cjs.map +1 -0
- package/dist/onboardingSlice/mocks.d.cts +19 -0
- package/dist/onboardingSlice/mocks.d.ts +19 -0
- package/dist/onboardingSlice/mocks.js +17 -0
- package/dist/onboardingSlice/mocks.js.map +1 -0
- package/dist/onboardingSlice/thunks.cjs +1787 -2020
- package/dist/onboardingSlice/thunks.cjs.map +1 -1
- package/dist/onboardingSlice/thunks.d.cts +63 -36
- package/dist/onboardingSlice/thunks.d.ts +63 -36
- package/dist/onboardingSlice/thunks.js +30 -31
- package/dist/organizationSlice/constants.cjs +8 -748
- package/dist/organizationSlice/constants.cjs.map +1 -1
- package/dist/organizationSlice/constants.d.cts +36 -116
- package/dist/organizationSlice/constants.d.ts +36 -116
- package/dist/organizationSlice/constants.js +7 -17
- package/dist/organizationSlice/index.cjs +14 -368
- package/dist/organizationSlice/index.cjs.map +1 -1
- package/dist/organizationSlice/index.d.cts +45 -73
- package/dist/organizationSlice/index.d.ts +45 -73
- package/dist/organizationSlice/index.js +6 -6
- package/dist/organizationSlice/mocks.cjs +234 -0
- package/dist/organizationSlice/mocks.cjs.map +1 -0
- package/dist/organizationSlice/mocks.d.cts +107 -0
- package/dist/organizationSlice/mocks.d.ts +107 -0
- package/dist/organizationSlice/mocks.js +101 -0
- package/dist/organizationSlice/mocks.js.map +1 -0
- package/dist/organizationSlice/selectors.cjs +301 -146
- package/dist/organizationSlice/selectors.cjs.map +1 -1
- package/dist/organizationSlice/selectors.d.cts +888 -51
- package/dist/organizationSlice/selectors.d.ts +888 -51
- package/dist/organizationSlice/selectors.js +14 -6
- package/dist/organizationSlice/thunks.cjs +2616 -2759
- package/dist/organizationSlice/thunks.cjs.map +1 -1
- package/dist/organizationSlice/thunks.d.cts +322 -131
- package/dist/organizationSlice/thunks.d.ts +322 -131
- package/dist/organizationSlice/thunks.js +44 -29
- package/dist/organizationSlice/types.cjs.map +1 -1
- package/dist/organizationSlice/types.d.cts +62 -79
- package/dist/organizationSlice/types.d.ts +62 -79
- package/dist/releasesSlice/constants.cjs +3 -0
- package/dist/releasesSlice/constants.cjs.map +1 -1
- package/dist/releasesSlice/constants.d.cts +2 -1
- package/dist/releasesSlice/constants.d.ts +2 -1
- package/dist/releasesSlice/constants.js +3 -1
- package/dist/releasesSlice/index.cjs +5 -222
- package/dist/releasesSlice/index.cjs.map +1 -1
- package/dist/releasesSlice/index.d.cts +52 -473
- package/dist/releasesSlice/index.d.ts +52 -473
- package/dist/releasesSlice/index.js +6 -6
- package/dist/releasesSlice/mocks.cjs +177 -0
- package/dist/releasesSlice/mocks.cjs.map +1 -0
- package/dist/releasesSlice/mocks.d.cts +49 -0
- package/dist/releasesSlice/mocks.d.ts +49 -0
- package/dist/releasesSlice/mocks.js +61 -0
- package/dist/releasesSlice/mocks.js.map +1 -0
- package/dist/releasesSlice/selectors.cjs +293 -165
- package/dist/releasesSlice/selectors.cjs.map +1 -1
- package/dist/releasesSlice/selectors.d.cts +886 -24
- package/dist/releasesSlice/selectors.d.ts +886 -24
- package/dist/releasesSlice/selectors.js +9 -7
- package/dist/releasesSlice/thunks.cjs +827 -1017
- package/dist/releasesSlice/thunks.cjs.map +1 -1
- package/dist/releasesSlice/thunks.d.cts +150 -130
- package/dist/releasesSlice/thunks.d.ts +150 -130
- package/dist/releasesSlice/thunks.js +33 -26
- package/dist/selectors.cjs +565 -780
- package/dist/selectors.cjs.map +1 -1
- package/dist/selectors.d.cts +37 -8
- package/dist/selectors.d.ts +37 -8
- package/dist/selectors.js +54 -18
- package/dist/sockethook.cjs +519 -0
- package/dist/sockethook.cjs.map +1 -0
- package/dist/sockethook.d.cts +10 -0
- package/dist/sockethook.d.ts +10 -0
- package/dist/sockethook.js +139 -0
- package/dist/sockethook.js.map +1 -0
- package/dist/store.cjs +121 -840
- package/dist/store.cjs.map +1 -1
- package/dist/store.d.cts +697 -1961
- package/dist/store.d.ts +697 -1961
- package/dist/store.js +18 -16
- package/dist/storehooks.cjs +1854 -1968
- package/dist/storehooks.cjs.map +1 -1
- package/dist/storehooks.js +46 -63
- package/dist/storehooks.js.map +1 -1
- package/dist/thunks.cjs +2138 -2231
- package/dist/thunks.cjs.map +1 -1
- package/dist/thunks.d.cts +25 -7
- package/dist/thunks.d.ts +25 -7
- package/dist/thunks.js +54 -45
- package/dist/{deploymentdevicehook.cjs → useDeploymentDevice.cjs} +1797 -2026
- package/dist/useDeploymentDevice.cjs.map +1 -0
- package/dist/useDeploymentDevice.js +63 -0
- package/dist/useDeploymentDevice.js.map +1 -0
- package/dist/usersSlice/constants.cjs +5 -747
- package/dist/usersSlice/constants.cjs.map +1 -1
- package/dist/usersSlice/constants.d.cts +16 -774
- package/dist/usersSlice/constants.d.ts +16 -774
- package/dist/usersSlice/constants.js +7 -30
- package/dist/usersSlice/index.cjs +10 -721
- package/dist/usersSlice/index.cjs.map +1 -1
- package/dist/usersSlice/index.d.cts +136 -7900
- package/dist/usersSlice/index.d.ts +136 -7900
- package/dist/usersSlice/index.js +6 -6
- package/dist/usersSlice/mocks.cjs +200 -0
- package/dist/usersSlice/mocks.cjs.map +1 -0
- package/dist/usersSlice/mocks.d.cts +83 -0
- package/dist/usersSlice/mocks.d.ts +83 -0
- package/dist/usersSlice/mocks.js +47 -0
- package/dist/usersSlice/mocks.js.map +1 -0
- package/dist/usersSlice/selectors.cjs +319 -566
- package/dist/usersSlice/selectors.cjs.map +1 -1
- package/dist/usersSlice/selectors.d.cts +1651 -59
- package/dist/usersSlice/selectors.d.ts +1651 -59
- package/dist/usersSlice/selectors.js +13 -9
- package/dist/usersSlice/thunks.cjs +1666 -1893
- package/dist/usersSlice/thunks.cjs.map +1 -1
- package/dist/usersSlice/thunks.d.cts +362 -312
- package/dist/usersSlice/thunks.d.ts +362 -312
- package/dist/usersSlice/thunks.js +30 -29
- package/dist/utils.cjs +428 -292
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +44 -22
- package/dist/utils.d.ts +44 -22
- package/dist/utils.js +12 -6
- package/package.json +18 -8
- package/dist/api/types/AWSCredentials.ts +0 -16
- package/dist/api/types/Actor.ts +0 -35
- package/dist/api/types/Addon.ts +0 -17
- package/dist/api/types/AddonTenantadm.ts +0 -17
- package/dist/api/types/Address.ts +0 -6
- package/dist/api/types/AddressUpdate.ts +0 -12
- package/dist/api/types/Alert.ts +0 -34
- package/dist/api/types/AlertDetails.ts +0 -23
- package/dist/api/types/AlertSubject.ts +0 -23
- package/dist/api/types/ApiBurst.ts +0 -21
- package/dist/api/types/ApiBurstTenantadm.ts +0 -21
- package/dist/api/types/ApiLimits.ts +0 -16
- package/dist/api/types/ApiLimitsTenantadm.ts +0 -16
- package/dist/api/types/ApiQuota.ts +0 -17
- package/dist/api/types/ApiQuotaTenantadm.ts +0 -17
- package/dist/api/types/Artifact.ts +0 -48
- package/dist/api/types/ArtifactDeployments.ts +0 -48
- package/dist/api/types/ArtifactInfo.ts +0 -11
- package/dist/api/types/ArtifactInfoDeployments.ts +0 -11
- package/dist/api/types/ArtifactLink.ts +0 -11
- package/dist/api/types/ArtifactTypeInfo.ts +0 -13
- package/dist/api/types/ArtifactTypeInfoDeployments.ts +0 -13
- package/dist/api/types/ArtifactUpdate.ts +0 -10
- package/dist/api/types/ArtifactUploadLink.ts +0 -15
- package/dist/api/types/Attribute.ts +0 -36
- package/dist/api/types/AttributeInventory.ts +0 -32
- package/dist/api/types/AuditLog.ts +0 -26
- package/dist/api/types/AuthSet.ts +0 -37
- package/dist/api/types/AuthSetDeviceauth.ts +0 -37
- package/dist/api/types/AuthSetIot_manager.ts +0 -33
- package/dist/api/types/AutoAuthRequest.ts +0 -23
- package/dist/api/types/AzureSharedAccessSecret.ts +0 -11
- package/dist/api/types/BillingInfo.ts +0 -13
- package/dist/api/types/BillingProfile.ts +0 -37
- package/dist/api/types/BillingProfileUpdate.ts +0 -37
- package/dist/api/types/BinaryDeltaConfiguration.ts +0 -15
- package/dist/api/types/BinaryDeltaConfigurationDeployments.ts +0 -15
- package/dist/api/types/BinaryDeltaLimits.ts +0 -21
- package/dist/api/types/BinaryDeltaLimitsDeployments.ts +0 -15
- package/dist/api/types/BoundingBox.ts +0 -9
- package/dist/api/types/CancelRequest.ts +0 -10
- package/dist/api/types/CardData.ts +0 -49
- package/dist/api/types/CardSetupData.ts +0 -17
- package/dist/api/types/CheckoutData.ts +0 -13
- package/dist/api/types/Configuration.ts +0 -11
- package/dist/api/types/Count.ts +0 -13
- package/dist/api/types/Credentials.ts +0 -23
- package/dist/api/types/DBusSubsystem.ts +0 -27
- package/dist/api/types/DeltaConfiguration.ts +0 -14
- package/dist/api/types/DeltaConfigurationDeployments.ts +0 -14
- package/dist/api/types/Deployment.ts +0 -45
- package/dist/api/types/DeploymentAggregation.ts +0 -16
- package/dist/api/types/DeploymentAggregationItem.ts +0 -16
- package/dist/api/types/DeploymentAggregationTerm.ts +0 -22
- package/dist/api/types/DeploymentAggregationTerms.ts +0 -16
- package/dist/api/types/DeploymentAttributeProjection.ts +0 -10
- package/dist/api/types/DeploymentAuditlogs.ts +0 -11
- package/dist/api/types/DeploymentDeployments.ts +0 -98
- package/dist/api/types/DeploymentFilterTerm.ts +0 -35
- package/dist/api/types/DeploymentIdentifier.ts +0 -10
- package/dist/api/types/DeploymentPhase.ts +0 -23
- package/dist/api/types/DeploymentPhaseDeployments.ts +0 -23
- package/dist/api/types/DeploymentReporting.ts +0 -46
- package/dist/api/types/DeploymentSearchTerms.ts +0 -37
- package/dist/api/types/DeploymentSortTerm.ts +0 -23
- package/dist/api/types/DeploymentStatistics.ts +0 -15
- package/dist/api/types/DeploymentStatisticsDeployments.ts +0 -15
- package/dist/api/types/DeploymentStatusStatistics.ts +0 -54
- package/dist/api/types/DeploymentStatusStatisticsDeployments.ts +0 -54
- package/dist/api/types/Device.ts +0 -20
- package/dist/api/types/DeviceAggregation.ts +0 -16
- package/dist/api/types/DeviceAggregationItem.ts +0 -16
- package/dist/api/types/DeviceAggregationTerm.ts +0 -26
- package/dist/api/types/DeviceAggregationTerms.ts +0 -20
- package/dist/api/types/DeviceAttribute.ts +0 -22
- package/dist/api/types/DeviceAttributeProjection.ts +0 -14
- package/dist/api/types/DeviceAuditlogs.ts +0 -17
- package/dist/api/types/DeviceAuthEvent.ts +0 -23
- package/dist/api/types/DeviceConfiguration.ts +0 -16
- package/dist/api/types/DeviceDeployment.ts +0 -11
- package/dist/api/types/DeviceDeployments.ts +0 -29
- package/dist/api/types/DeviceDeviceauth.ts +0 -42
- package/dist/api/types/DeviceFilterAttribute.ts +0 -21
- package/dist/api/types/DeviceFilterTerm.ts +0 -39
- package/dist/api/types/DeviceInventory.ts +0 -19
- package/dist/api/types/DeviceInventoryInventory.ts +0 -19
- package/dist/api/types/DeviceReporting.ts +0 -22
- package/dist/api/types/DeviceSearchTerms.ts +0 -37
- package/dist/api/types/DeviceSortTerm.ts +0 -27
- package/dist/api/types/DeviceState.ts +0 -32
- package/dist/api/types/DeviceStateDeviceconnect.ts +0 -33
- package/dist/api/types/DeviceStateIot_manager.ts +0 -14
- package/dist/api/types/DeviceStatus.ts +0 -19
- package/dist/api/types/DeviceWithImage.ts +0 -80
- package/dist/api/types/DirectUploadMetadata.ts +0 -18
- package/dist/api/types/EmailVerificationCompletion.ts +0 -13
- package/dist/api/types/EmailVerificationRequest.ts +0 -13
- package/dist/api/types/Error.ts +0 -17
- package/dist/api/types/ErrorAuditlogs.ts +0 -13
- package/dist/api/types/ErrorDeployments.ts +0 -17
- package/dist/api/types/ErrorDeviceauth.ts +0 -13
- package/dist/api/types/ErrorDeviceconfig.ts +0 -17
- package/dist/api/types/ErrorDeviceconnect.ts +0 -17
- package/dist/api/types/ErrorDevicemonitor.ts +0 -17
- package/dist/api/types/ErrorExt.ts +0 -18
- package/dist/api/types/ErrorInventory.ts +0 -17
- package/dist/api/types/ErrorIot_manager.ts +0 -17
- package/dist/api/types/ErrorNotFound.ts +0 -17
- package/dist/api/types/ErrorReporting.ts +0 -18
- package/dist/api/types/ErrorTenantadm.ts +0 -13
- package/dist/api/types/ErrorUseradm.ts +0 -17
- package/dist/api/types/Event.ts +0 -48
- package/dist/api/types/ExternalIdentity.ts +0 -17
- package/dist/api/types/Features.ts +0 -17
- package/dist/api/types/FileUpload.ts +0 -23
- package/dist/api/types/Filter.ts +0 -19
- package/dist/api/types/FilterAttribute.ts +0 -21
- package/dist/api/types/FilterDefinition.ts +0 -18
- package/dist/api/types/FilterDeployments.ts +0 -19
- package/dist/api/types/FilterInventory.ts +0 -19
- package/dist/api/types/FilterPredicate.ts +0 -48
- package/dist/api/types/FilterPredicateDeployments.ts +0 -48
- package/dist/api/types/FilterPredicateInventory.ts +0 -78
- package/dist/api/types/GeoBoundingBox.ts +0 -8
- package/dist/api/types/GeoBoundingBoxFilter.ts +0 -5
- package/dist/api/types/GeoDistance.ts +0 -15
- package/dist/api/types/GeoDistanceFilter.ts +0 -8
- package/dist/api/types/GeoPoint.ts +0 -14
- package/dist/api/types/Group.ts +0 -10
- package/dist/api/types/HTTP.ts +0 -19
- package/dist/api/types/IdentityData.ts +0 -25
- package/dist/api/types/InputParameter.ts +0 -8
- package/dist/api/types/Integration.ts +0 -30
- package/dist/api/types/JobStatus.ts +0 -13
- package/dist/api/types/Limit.ts +0 -21
- package/dist/api/types/LimitDeployments.ts +0 -21
- package/dist/api/types/LimitDeviceauth.ts +0 -10
- package/dist/api/types/LimitUseradm.ts +0 -11
- package/dist/api/types/Limits.ts +0 -11
- package/dist/api/types/LineDescriptor.ts +0 -11
- package/dist/api/types/LogSubsystem.ts +0 -23
- package/dist/api/types/LoginOptions.ts +0 -18
- package/dist/api/types/ManagementAPIConfiguration.ts +0 -5
- package/dist/api/types/MenderTypes.ts +0 -213
- package/dist/api/types/MonitorConfiguration.ts +0 -22
- package/dist/api/types/NewConfigurationDeployment.ts +0 -15
- package/dist/api/types/NewConfigurationDeploymentResponse.ts +0 -10
- package/dist/api/types/NewDeployment.ts +0 -42
- package/dist/api/types/NewDeploymentForGroup.ts +0 -33
- package/dist/api/types/NewDeploymentPhase.ts +0 -37
- package/dist/api/types/NewDeploymentPhaseDeployments.ts +0 -20
- package/dist/api/types/NewDeploymentV2.ts +0 -34
- package/dist/api/types/NewTenant.ts +0 -49
- package/dist/api/types/Object.ts +0 -38
- package/dist/api/types/OwnUserUpdate.ts +0 -21
- package/dist/api/types/PasswordResetCompletion.ts +0 -17
- package/dist/api/types/PasswordResetRequest.ts +0 -13
- package/dist/api/types/Permission.ts +0 -21
- package/dist/api/types/PermissionObject.ts +0 -14
- package/dist/api/types/PermissionSet.ts +0 -22
- package/dist/api/types/PermissionSetWithScope.ts +0 -15
- package/dist/api/types/PersonalAccessToken.ts +0 -29
- package/dist/api/types/PersonalAccessTokenRequest.ts +0 -18
- package/dist/api/types/Plan.ts +0 -19
- package/dist/api/types/PlanBindingDetails.ts +0 -13
- package/dist/api/types/PlanChangeRequest.ts +0 -14
- package/dist/api/types/PlanLimits.ts +0 -12
- package/dist/api/types/PreAuthSet.ts +0 -16
- package/dist/api/types/Release.ts +0 -32
- package/dist/api/types/ReleaseDeployments.ts +0 -32
- package/dist/api/types/ReleaseUpdate.ts +0 -13
- package/dist/api/types/Releases.ts +0 -9
- package/dist/api/types/ReleasesDeleteError.ts +0 -21
- package/dist/api/types/ReleasesDeployments.ts +0 -9
- package/dist/api/types/Role.ts +0 -19
- package/dist/api/types/RolePermission.ts +0 -25
- package/dist/api/types/RolePermissionObject.ts +0 -17
- package/dist/api/types/RoleUseradm.ts +0 -19
- package/dist/api/types/SAMLMetadata.ts +0 -21
- package/dist/api/types/Scope.ts +0 -19
- package/dist/api/types/SelectAttribute.ts +0 -17
- package/dist/api/types/ServiceSubsystem.ts +0 -19
- package/dist/api/types/Settings.ts +0 -23
- package/dist/api/types/SortCriteria.ts +0 -30
- package/dist/api/types/SsoObject.ts +0 -21
- package/dist/api/types/Status.ts +0 -18
- package/dist/api/types/StatusDeviceauth.ts +0 -18
- package/dist/api/types/StatusTenantadm.ts +0 -17
- package/dist/api/types/StorageLimit.ts +0 -17
- package/dist/api/types/SubscriptionData.ts +0 -8
- package/dist/api/types/SupportRequest.ts +0 -17
- package/dist/api/types/Tag.ts +0 -27
- package/dist/api/types/Tags.ts +0 -10
- package/dist/api/types/TaskResult.ts +0 -13
- package/dist/api/types/TaskResultCLI.ts +0 -10
- package/dist/api/types/TaskResultHTTPRequest.ts +0 -8
- package/dist/api/types/TaskResultHTTPResponse.ts +0 -10
- package/dist/api/types/Tenant.ts +0 -26
- package/dist/api/types/TenantApiLimits.ts +0 -12
- package/dist/api/types/TenantApiLimitsTenantadm.ts +0 -12
- package/dist/api/types/TenantIdName.ts +0 -14
- package/dist/api/types/TenantIdsData.ts +0 -10
- package/dist/api/types/TenantInfo.ts +0 -14
- package/dist/api/types/TenantShortInfo.ts +0 -21
- package/dist/api/types/TenantTenantadm.ts +0 -54
- package/dist/api/types/TenantsIdName.ts +0 -6
- package/dist/api/types/Update.ts +0 -17
- package/dist/api/types/UpdateChildTenant.ts +0 -17
- package/dist/api/types/UpdateDeployments.ts +0 -18
- package/dist/api/types/UpdateFile.ts +0 -13
- package/dist/api/types/UpdateFileDeployments.ts +0 -13
- package/dist/api/types/UpdateTypes.ts +0 -8
- package/dist/api/types/UpgradeCompleteRequest.ts +0 -25
- package/dist/api/types/User.ts +0 -13
- package/dist/api/types/UserAuditlogs.ts +0 -13
- package/dist/api/types/UserNew.ts +0 -26
- package/dist/api/types/UserUpdate.ts +0 -25
- package/dist/api/types/UserUseradm.ts +0 -45
- package/dist/api/types/UserWithTenantInfo.ts +0 -12
- package/dist/api/types/XDeltaArgs.ts +0 -9
- package/dist/api/types/XDeltaArgsDeployments.ts +0 -9
- package/dist/api/types/XDeltaArgsLimits.ts +0 -10
- package/dist/api/types/XDeltaArgsLimitsDeployments.ts +0 -10
- package/dist/chunk-2CYOM4BK.js.map +0 -1
- package/dist/chunk-2JHFUQ6B.js.map +0 -1
- package/dist/chunk-4B3IMP4I.js +0 -245
- package/dist/chunk-4B3IMP4I.js.map +0 -1
- package/dist/chunk-4XJMRVFI.js.map +0 -1
- package/dist/chunk-7JKWI5FK.js.map +0 -1
- package/dist/chunk-7PVGDMNM.js.map +0 -1
- package/dist/chunk-AMGWP7A4.js.map +0 -1
- package/dist/chunk-C5NEDBJI.js +0 -727
- package/dist/chunk-C5NEDBJI.js.map +0 -1
- package/dist/chunk-CYV6632F.js.map +0 -1
- package/dist/chunk-DCK2DBOA.js.map +0 -1
- package/dist/chunk-FGKMJS3B.js.map +0 -1
- package/dist/chunk-HPBE6KYY.js.map +0 -1
- package/dist/chunk-JAROCU6M.js.map +0 -1
- package/dist/chunk-LEMVXAYP.js.map +0 -1
- package/dist/chunk-LGNOTPUG.js +0 -106
- package/dist/chunk-LGNOTPUG.js.map +0 -1
- package/dist/chunk-LIJIIRON.js +0 -28
- package/dist/chunk-LIJIIRON.js.map +0 -1
- package/dist/chunk-LTKOV26W.js.map +0 -1
- package/dist/chunk-MRCFLG45.js.map +0 -1
- package/dist/chunk-QRGTG4YB.js.map +0 -1
- package/dist/chunk-TI2RL5P2.js.map +0 -1
- package/dist/chunk-TUACATJA.js.map +0 -1
- package/dist/chunk-UWMYZNUB.js.map +0 -1
- package/dist/chunk-VMNMD6KF.js.map +0 -1
- package/dist/chunk-WXL7PVI5.js.map +0 -1
- package/dist/chunk-X7IEZBM4.js.map +0 -1
- package/dist/chunk-YDS36ALB.js.map +0 -1
- package/dist/chunk-YT73QWCN.js.map +0 -1
- package/dist/deploymentdevicehook.cjs.map +0 -1
- package/dist/deploymentdevicehook.js +0 -62
- package/dist/deploymentdevicehook.js.map +0 -1
- /package/dist/{chunk-DAPAXWA5.js.map → chunk-URNS6A5T.js.map} +0 -0
- /package/dist/{deploymentdevicehook.d.cts → useDeploymentDevice.d.cts} +0 -0
- /package/dist/{deploymentdevicehook.d.ts → useDeploymentDevice.d.ts} +0 -0
|
@@ -1,20 +1,58 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getDeviceMonitorConfig,
|
|
3
3
|
getLatestDeviceAlerts
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-JUGE7L3K.js";
|
|
5
|
+
import {
|
|
6
|
+
commonErrorFallback,
|
|
7
|
+
commonErrorHandler,
|
|
8
|
+
createAppAsyncThunk
|
|
9
|
+
} from "./chunk-CW5T6OGF.js";
|
|
5
10
|
import {
|
|
6
11
|
users_api_default
|
|
7
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-QHK7GGV4.js";
|
|
8
13
|
import {
|
|
9
14
|
general_api_default
|
|
10
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-RS37Y2PQ.js";
|
|
16
|
+
import {
|
|
17
|
+
actions_default
|
|
18
|
+
} from "./chunk-URNS6A5T.js";
|
|
19
|
+
import {
|
|
20
|
+
actions as actions6,
|
|
21
|
+
sliceName as sliceName6
|
|
22
|
+
} from "./chunk-UGSLGUS6.js";
|
|
23
|
+
import {
|
|
24
|
+
actions as actions5,
|
|
25
|
+
sliceName as sliceName5
|
|
26
|
+
} from "./chunk-MZNANSS2.js";
|
|
27
|
+
import {
|
|
28
|
+
actions as actions4,
|
|
29
|
+
sliceName as sliceName4
|
|
30
|
+
} from "./chunk-VANBSJS5.js";
|
|
31
|
+
import {
|
|
32
|
+
actions as actions2,
|
|
33
|
+
sliceName as sliceName2
|
|
34
|
+
} from "./chunk-VUFRP6P3.js";
|
|
35
|
+
import {
|
|
36
|
+
actions,
|
|
37
|
+
sliceName
|
|
38
|
+
} from "./chunk-6KGTHJKC.js";
|
|
39
|
+
import {
|
|
40
|
+
actions as actions3,
|
|
41
|
+
sliceName as sliceName3
|
|
42
|
+
} from "./chunk-ABJLRDCO.js";
|
|
43
|
+
import {
|
|
44
|
+
cleanUp,
|
|
45
|
+
getSessionInfo,
|
|
46
|
+
setSessionInfo
|
|
47
|
+
} from "./chunk-ZJW3QIPM.js";
|
|
11
48
|
import {
|
|
12
49
|
getAttrsEndpoint,
|
|
50
|
+
getDeviceReportsForUser,
|
|
13
51
|
getOnboardingState,
|
|
14
52
|
getSearchEndpoint,
|
|
15
53
|
getTenantCapabilities,
|
|
16
54
|
getUserCapabilities
|
|
17
|
-
} from "./chunk-
|
|
55
|
+
} from "./chunk-IQG5I7AM.js";
|
|
18
56
|
import {
|
|
19
57
|
getCurrentSession,
|
|
20
58
|
getCurrentUser,
|
|
@@ -26,90 +64,66 @@ import {
|
|
|
26
64
|
getTooltipsState,
|
|
27
65
|
getUserSettings,
|
|
28
66
|
getUsersById
|
|
29
|
-
} from "./chunk-
|
|
67
|
+
} from "./chunk-ZRSYBSSY.js";
|
|
30
68
|
import {
|
|
31
69
|
getAuditlogState,
|
|
32
70
|
getDeviceTwinIntegrations,
|
|
33
71
|
getOrganization,
|
|
34
72
|
getTenantsList
|
|
35
|
-
} from "./chunk-
|
|
73
|
+
} from "./chunk-4TUJPE6G.js";
|
|
36
74
|
import {
|
|
37
75
|
getDeploymentsById,
|
|
38
76
|
getDeploymentsByStatus
|
|
39
|
-
} from "./chunk-
|
|
77
|
+
} from "./chunk-JXQUFKID.js";
|
|
40
78
|
import {
|
|
79
|
+
getAcceptedDevices,
|
|
41
80
|
getDeviceById,
|
|
42
81
|
getDeviceFilters,
|
|
43
82
|
getDeviceListState,
|
|
83
|
+
getDeviceReports,
|
|
44
84
|
getDevicesById,
|
|
45
|
-
getGroups,
|
|
46
85
|
getGroupsById,
|
|
47
86
|
getSelectedGroup
|
|
48
|
-
} from "./chunk-
|
|
87
|
+
} from "./chunk-KJNNEDRV.js";
|
|
88
|
+
import {
|
|
89
|
+
getFeatures,
|
|
90
|
+
getSearchState
|
|
91
|
+
} from "./chunk-MBKAZVE3.js";
|
|
49
92
|
import {
|
|
50
93
|
convertDeviceListStateToFilters,
|
|
94
|
+
extractErrorMessage,
|
|
51
95
|
filtersFilter,
|
|
52
96
|
getComparisonCompatibleVersion,
|
|
53
97
|
mapDeviceAttributes,
|
|
54
98
|
mapFiltersToTerms,
|
|
55
99
|
mapTermsToFilters,
|
|
56
100
|
mergePermissions,
|
|
101
|
+
parseSubscriptionPreview,
|
|
57
102
|
progress
|
|
58
|
-
} from "./chunk-
|
|
59
|
-
import {
|
|
60
|
-
getFeatures,
|
|
61
|
-
getSearchState
|
|
62
|
-
} from "./chunk-LIJIIRON.js";
|
|
63
|
-
import {
|
|
64
|
-
commonErrorFallback,
|
|
65
|
-
commonErrorHandler
|
|
66
|
-
} from "./chunk-LEMVXAYP.js";
|
|
67
|
-
import {
|
|
68
|
-
actions_default
|
|
69
|
-
} from "./chunk-DAPAXWA5.js";
|
|
70
|
-
import {
|
|
71
|
-
actions as actions6,
|
|
72
|
-
sliceName as sliceName6
|
|
73
|
-
} from "./chunk-TUACATJA.js";
|
|
74
|
-
import {
|
|
75
|
-
actions as actions5,
|
|
76
|
-
sliceName as sliceName5
|
|
77
|
-
} from "./chunk-TI2RL5P2.js";
|
|
78
|
-
import {
|
|
79
|
-
actions as actions2,
|
|
80
|
-
sliceName as sliceName2
|
|
81
|
-
} from "./chunk-HPBE6KYY.js";
|
|
82
|
-
import {
|
|
83
|
-
actions as actions4,
|
|
84
|
-
sliceName as sliceName4
|
|
85
|
-
} from "./chunk-FGKMJS3B.js";
|
|
86
|
-
import {
|
|
87
|
-
actions as actions3,
|
|
88
|
-
sliceName as sliceName3
|
|
89
|
-
} from "./chunk-QRGTG4YB.js";
|
|
90
|
-
import {
|
|
91
|
-
actions,
|
|
92
|
-
sliceName
|
|
93
|
-
} from "./chunk-7PVGDMNM.js";
|
|
94
|
-
import {
|
|
95
|
-
cleanUp,
|
|
96
|
-
getSessionInfo,
|
|
97
|
-
maxSessionAge,
|
|
98
|
-
setSessionInfo
|
|
99
|
-
} from "./chunk-AMGWP7A4.js";
|
|
103
|
+
} from "./chunk-XWYJACQC.js";
|
|
100
104
|
import {
|
|
101
105
|
ALL_DEVICE_STATES,
|
|
106
|
+
ALL_RELEASES,
|
|
107
|
+
APPLICATION_JSON_CONTENT_TYPE,
|
|
108
|
+
APPLICATION_JWT_CONTENT_TYPE,
|
|
102
109
|
DEPLOYMENT_ROUTES,
|
|
103
110
|
DEPLOYMENT_STATES,
|
|
104
111
|
DEPLOYMENT_TYPES,
|
|
112
|
+
DEVICE_FILTERING_OPTIONS,
|
|
113
|
+
DEVICE_LIST_DEFAULTS,
|
|
105
114
|
DEVICE_STATES,
|
|
115
|
+
EXTERNAL_PROVIDER,
|
|
116
|
+
MAX_PAGE_SIZE,
|
|
106
117
|
OWN_USER_ID,
|
|
107
118
|
PermissionTypes,
|
|
108
119
|
READ_STATES,
|
|
109
|
-
|
|
120
|
+
SORTING_OPTIONS,
|
|
110
121
|
SSO_TYPES,
|
|
111
122
|
TENANT_LIST_DEFAULT,
|
|
123
|
+
TIMEOUTS,
|
|
124
|
+
UNGROUPED_GROUP,
|
|
112
125
|
USER_LOGOUT,
|
|
126
|
+
apiRoot,
|
|
113
127
|
auditLogsApiUrl,
|
|
114
128
|
defaultPermissionSets,
|
|
115
129
|
deploymentPrototype,
|
|
@@ -119,12 +133,14 @@ import {
|
|
|
119
133
|
deviceConfig,
|
|
120
134
|
deviceConnect,
|
|
121
135
|
emptyFilter,
|
|
122
|
-
|
|
136
|
+
emptyRole,
|
|
137
|
+
emptyUiPermissions,
|
|
138
|
+
headerNames,
|
|
123
139
|
inventoryApiUrl,
|
|
124
140
|
inventoryApiUrlV2,
|
|
125
141
|
iotManagerBaseURL,
|
|
126
142
|
itemUiPermissionsReducer,
|
|
127
|
-
|
|
143
|
+
maxSessionAge,
|
|
128
144
|
rolesById,
|
|
129
145
|
scopedPermissionAreas,
|
|
130
146
|
settingsKeys,
|
|
@@ -134,53 +150,40 @@ import {
|
|
|
134
150
|
twoFAStates,
|
|
135
151
|
uiPermissionsByArea,
|
|
136
152
|
uiPermissionsById,
|
|
137
|
-
|
|
153
|
+
useradmApiUrl,
|
|
138
154
|
useradmApiUrlv2
|
|
139
|
-
} from "./chunk-
|
|
155
|
+
} from "./chunk-7C4SQBEE.js";
|
|
140
156
|
import {
|
|
141
157
|
rootfsImageVersion
|
|
142
|
-
} from "./chunk-
|
|
158
|
+
} from "./chunk-2DYA3X77.js";
|
|
143
159
|
import {
|
|
144
|
-
onboardingSteps
|
|
145
|
-
|
|
160
|
+
onboardingSteps,
|
|
161
|
+
orderedOnboardingSteps
|
|
162
|
+
} from "./chunk-FAJ3I2UQ.js";
|
|
146
163
|
import {
|
|
147
|
-
|
|
148
|
-
APPLICATION_JWT_CONTENT_TYPE,
|
|
149
|
-
apiRoot,
|
|
150
|
-
defaultReports,
|
|
151
|
-
headerNames,
|
|
164
|
+
PLANS,
|
|
152
165
|
locations
|
|
153
|
-
} from "./chunk-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
DEVICE_LIST_DEFAULTS,
|
|
159
|
-
EXTERNAL_PROVIDER,
|
|
160
|
-
MAX_PAGE_SIZE,
|
|
161
|
-
SORTING_OPTIONS,
|
|
162
|
-
TIMEOUTS,
|
|
163
|
-
UNGROUPED_GROUP,
|
|
164
|
-
emptyRole,
|
|
165
|
-
emptyUiPermissions
|
|
166
|
-
} from "./chunk-4B3IMP4I.js";
|
|
166
|
+
} from "./chunk-OHF3YUXX.js";
|
|
167
|
+
|
|
168
|
+
// src/appSlice/thunks.ts
|
|
169
|
+
import { deepCompare as deepCompare4, extractErrorMessage as extractErrorMessage3 } from "@northern.tech/utils/helpers";
|
|
170
|
+
import Cookies4 from "universal-cookie";
|
|
167
171
|
|
|
168
172
|
// src/deploymentsSlice/thunks.ts
|
|
169
|
-
import { deepCompare, isEmpty, standardizePhases
|
|
173
|
+
import { customSort, deepCompare, isEmpty, standardizePhases } from "@northern.tech/utils/helpers";
|
|
170
174
|
import Tracking from "@northern.tech/utils/tracking";
|
|
171
|
-
import
|
|
172
|
-
import { isUUID } from "validator";
|
|
175
|
+
import isUUID from "validator/lib/isUUID";
|
|
173
176
|
var { receivedDevice, setSnackbar } = actions_default;
|
|
174
177
|
var { page: defaultPage, perPage: defaultPerPage } = DEVICE_LIST_DEFAULTS;
|
|
175
|
-
var deriveDeploymentGroup = ({ filter
|
|
176
|
-
var transformDeployments = (deployments, deploymentsById) => deployments.sort(
|
|
178
|
+
var deriveDeploymentGroup = ({ filter, group, groups = [], name }) => group || groups.length === 1 && !isUUID(name) ? groups[0] : filter?.name;
|
|
179
|
+
var transformDeployments = (deployments, deploymentsById) => deployments.sort(customSort(true, "created")).reduce(
|
|
177
180
|
(accu, item) => {
|
|
178
|
-
const filter = item.filter
|
|
181
|
+
const filter = item.filter;
|
|
179
182
|
let deployment = {
|
|
180
183
|
...deploymentPrototype,
|
|
181
184
|
...deploymentsById[item.id],
|
|
182
185
|
...item,
|
|
183
|
-
filter:
|
|
186
|
+
filter: filter ? { ...filter, name: filter.name ?? filter.id, filters: mapTermsToFilters(filter.terms) } : void 0,
|
|
184
187
|
name: decodeURIComponent(item.name)
|
|
185
188
|
};
|
|
186
189
|
deployment = { ...deployment, group: deriveDeploymentGroup(deployment) };
|
|
@@ -190,40 +193,43 @@ var transformDeployments = (deployments, deploymentsById) => deployments.sort(st
|
|
|
190
193
|
},
|
|
191
194
|
{ deployments: {}, deploymentIds: [] }
|
|
192
195
|
);
|
|
193
|
-
var getDeploymentsByStatus2 =
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
actions2.
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
196
|
+
var getDeploymentsByStatus2 = createAppAsyncThunk(
|
|
197
|
+
`${sliceName2}/getDeploymentsByStatus`,
|
|
198
|
+
(options, { dispatch, getState }) => {
|
|
199
|
+
const { status, page = defaultPage, perPage = defaultPerPage, startDate, endDate, group, type, shouldSelect = true, sort = SORTING_OPTIONS.desc } = options;
|
|
200
|
+
const created_after = startDate ? `&created_after=${startDate}` : "";
|
|
201
|
+
const created_before = endDate ? `&created_before=${endDate}` : "";
|
|
202
|
+
const search = group ? `&search=${group}` : "";
|
|
203
|
+
const typeFilter = type ? `&type=${type}` : "";
|
|
204
|
+
return general_api_default.get(
|
|
205
|
+
`${deploymentsApiUrl}/deployments?status=${status}&per_page=${perPage}&page=${page}${created_after}${created_before}${search}${typeFilter}&sort=${sort}`
|
|
206
|
+
).then((res) => {
|
|
207
|
+
const { deployments, deploymentIds } = transformDeployments(res.data, getState().deployments.byId);
|
|
208
|
+
const total = Number(res.headers[headerNames.total]);
|
|
209
|
+
let tasks = [
|
|
210
|
+
dispatch(actions2.receivedDeployments(deployments)),
|
|
211
|
+
dispatch(
|
|
212
|
+
actions2.receivedDeploymentsForStatus({
|
|
213
|
+
deploymentIds,
|
|
214
|
+
status,
|
|
215
|
+
total: !(startDate || endDate || group || type) ? total : getState().deployments.byStatus[status].total
|
|
216
|
+
})
|
|
217
|
+
)
|
|
218
|
+
];
|
|
219
|
+
tasks = deploymentIds.reduce((accu, deploymentId) => {
|
|
220
|
+
if (deployments[deploymentId].type === DEPLOYMENT_TYPES.configuration) {
|
|
221
|
+
accu.push(dispatch(getSingleDeployment(deploymentId)));
|
|
222
|
+
}
|
|
223
|
+
return accu;
|
|
224
|
+
}, tasks);
|
|
225
|
+
if (shouldSelect) {
|
|
226
|
+
tasks.push(dispatch(actions2.selectDeploymentsForStatus({ deploymentIds, status, total })));
|
|
217
227
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
tasks.push({ deploymentIds, total });
|
|
224
|
-
return Promise.all(tasks);
|
|
225
|
-
});
|
|
226
|
-
});
|
|
228
|
+
tasks.push({ deploymentIds, total });
|
|
229
|
+
return Promise.all(tasks);
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
);
|
|
227
233
|
var isWithinFirstMonth = (expirationDate) => {
|
|
228
234
|
if (!expirationDate) {
|
|
229
235
|
return false;
|
|
@@ -245,86 +251,98 @@ var trackDeploymentCreation = (totalDeploymentCount, hasDeployments, trial_expir
|
|
|
245
251
|
}
|
|
246
252
|
};
|
|
247
253
|
var MAX_PREVIOUS_PHASES_COUNT = 5;
|
|
248
|
-
var createDeployment =
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
const lastslashindex = data.headers.location.lastIndexOf("/");
|
|
262
|
-
const deploymentId = data.headers.location.substring(lastslashindex + 1);
|
|
263
|
-
const deployment = {
|
|
264
|
-
...newDeployment,
|
|
265
|
-
id: deploymentId,
|
|
266
|
-
devices: newDeployment.devices ? newDeployment.devices.map((id) => ({ id, status: "pending" })) : [],
|
|
267
|
-
statistics: { status: {} }
|
|
268
|
-
};
|
|
269
|
-
let tasks = [
|
|
270
|
-
dispatch(actions2.createdDeployment(deployment)),
|
|
271
|
-
dispatch(getSingleDeployment(deploymentId)),
|
|
272
|
-
dispatch(setSnackbar("Deployment created successfully", TIMEOUTS.fiveSeconds))
|
|
273
|
-
];
|
|
274
|
-
trackDeploymentCreation(totalDeploymentCount, hasDeployments, trial_expiration);
|
|
275
|
-
const { canManageUsers } = getUserCapabilities(getState());
|
|
276
|
-
if (canManageUsers) {
|
|
277
|
-
const { phases, retries } = newDeployment;
|
|
278
|
-
const { previousPhases = [], retries: previousRetries = 0 } = getGlobalSettings(getState());
|
|
279
|
-
let newSettings = { retries: hasNewRetryDefault ? retries : previousRetries, hasDeployments: true };
|
|
280
|
-
if (phases) {
|
|
281
|
-
const standardPhases = standardizePhases(phases);
|
|
282
|
-
let prevPhases = previousPhases.map(standardizePhases);
|
|
283
|
-
if (!prevPhases.find((previousPhaseList) => previousPhaseList.every((oldPhase) => standardPhases.find((phase) => deepCompare(phase, oldPhase))))) {
|
|
284
|
-
prevPhases.push(standardPhases);
|
|
285
|
-
}
|
|
286
|
-
newSettings.previousPhases = prevPhases.slice(-1 * MAX_PREVIOUS_PHASES_COUNT);
|
|
287
|
-
}
|
|
288
|
-
tasks.push(dispatch(saveGlobalSettings(newSettings)));
|
|
254
|
+
var createDeployment = createAppAsyncThunk(
|
|
255
|
+
`${sliceName2}/createDeployment`,
|
|
256
|
+
({
|
|
257
|
+
newDeployment,
|
|
258
|
+
hasNewRetryDefault = false
|
|
259
|
+
}, { dispatch, getState }) => {
|
|
260
|
+
let request;
|
|
261
|
+
if ("filter_id" in newDeployment && newDeployment.filter_id) {
|
|
262
|
+
request = general_api_default.post(`${deploymentsApiUrlV2}/deployments`, newDeployment);
|
|
263
|
+
} else if ("group" in newDeployment && newDeployment.group) {
|
|
264
|
+
request = general_api_default.post(`${deploymentsApiUrl}/deployments/group/${newDeployment.group}`, newDeployment);
|
|
265
|
+
} else {
|
|
266
|
+
request = general_api_default.post(`${deploymentsApiUrl}/deployments`, newDeployment);
|
|
289
267
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
const
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
268
|
+
const totalDeploymentCount = Object.values(getDeploymentsByStatus(getState())).reduce(
|
|
269
|
+
(accu, item) => accu + item.total,
|
|
270
|
+
0
|
|
271
|
+
);
|
|
272
|
+
const { hasDeployments } = getGlobalSettings(getState());
|
|
273
|
+
const { trial_expiration } = getOrganization(getState());
|
|
274
|
+
return request.catch((err) => commonErrorHandler(err, "Error creating deployment.", dispatch)).then((data) => {
|
|
275
|
+
const lastslashindex = data.headers.location.lastIndexOf("/");
|
|
276
|
+
const deploymentId = data.headers.location.substring(lastslashindex + 1);
|
|
277
|
+
const deployment = {
|
|
278
|
+
...newDeployment,
|
|
279
|
+
id: deploymentId,
|
|
280
|
+
devices: "devices" in newDeployment && newDeployment.devices ? newDeployment.devices.map((id) => ({ id, status: "pending" })) : [],
|
|
281
|
+
statistics: { status: {} }
|
|
282
|
+
};
|
|
283
|
+
const tasks = [
|
|
284
|
+
dispatch(actions2.createdDeployment(deployment)),
|
|
285
|
+
dispatch(getSingleDeployment(deploymentId)),
|
|
286
|
+
dispatch(setSnackbar({ message: "Deployment created successfully", autoHideDuration: TIMEOUTS.fiveSeconds }))
|
|
287
|
+
];
|
|
288
|
+
trackDeploymentCreation(totalDeploymentCount, hasDeployments, trial_expiration);
|
|
289
|
+
const { canManageUsers } = getUserCapabilities(getState());
|
|
290
|
+
if (canManageUsers) {
|
|
291
|
+
const { phases, retries } = newDeployment;
|
|
292
|
+
const { previousPhases = [], retries: previousRetries = 0 } = getGlobalSettings(getState());
|
|
293
|
+
const newSettings = { retries: hasNewRetryDefault ? retries : previousRetries, hasDeployments: true };
|
|
294
|
+
if (phases) {
|
|
295
|
+
const standardPhases = standardizePhases(phases);
|
|
296
|
+
const prevPhases = previousPhases.map(standardizePhases);
|
|
297
|
+
if (!prevPhases.find((previousPhaseList) => previousPhaseList.every((oldPhase) => standardPhases.find((phase) => deepCompare(phase, oldPhase))))) {
|
|
298
|
+
prevPhases.push(standardPhases);
|
|
299
|
+
}
|
|
300
|
+
newSettings.previousPhases = prevPhases.slice(-1 * MAX_PREVIOUS_PHASES_COUNT);
|
|
301
|
+
}
|
|
302
|
+
tasks.push(dispatch(saveGlobalSettings(newSettings)));
|
|
321
303
|
}
|
|
322
|
-
return
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
}
|
|
304
|
+
return Promise.all(tasks);
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
);
|
|
308
|
+
var getDeploymentDevices = createAppAsyncThunk(
|
|
309
|
+
`${sliceName2}/getDeploymentDevices`,
|
|
310
|
+
(options, { dispatch, getState }) => {
|
|
311
|
+
const { id, page = defaultPage, perPage = defaultPerPage } = options;
|
|
312
|
+
return general_api_default.get(`${deploymentsApiUrl}/deployments/${id}/devices/list?&page=${page}&per_page=${perPage}`).then((response) => {
|
|
313
|
+
const { devices: deploymentDevices = {} } = getState().deployments.byId[id] || {};
|
|
314
|
+
const devices = response.data.reduce((accu, item) => {
|
|
315
|
+
accu[item.id] = item;
|
|
316
|
+
const log = (deploymentDevices[item.id] || {}).log;
|
|
317
|
+
if (log) {
|
|
318
|
+
accu[item.id].log = log;
|
|
319
|
+
}
|
|
320
|
+
return accu;
|
|
321
|
+
}, {});
|
|
322
|
+
const selectedDeviceIds = Object.keys(devices);
|
|
323
|
+
let tasks = [
|
|
324
|
+
dispatch(
|
|
325
|
+
actions2.receivedDeploymentDevices({
|
|
326
|
+
id,
|
|
327
|
+
devices,
|
|
328
|
+
selectedDeviceIds,
|
|
329
|
+
totalDeviceCount: Number(response.headers[headerNames.total])
|
|
330
|
+
})
|
|
331
|
+
)
|
|
332
|
+
];
|
|
333
|
+
const devicesById = getDevicesById(getState());
|
|
334
|
+
const lackingData = selectedDeviceIds.reduce((accu, deviceId) => {
|
|
335
|
+
const device = devicesById[deviceId];
|
|
336
|
+
if (!device || !device.identity_data || !device.attributes || Object.keys(device.attributes).length === 0) {
|
|
337
|
+
accu.push(deviceId);
|
|
338
|
+
}
|
|
339
|
+
return accu;
|
|
340
|
+
}, []);
|
|
341
|
+
tasks = lackingData.reduce((accu, deviceId) => [...accu, dispatch(getDeviceById2(deviceId)), dispatch(getDeviceAuth(deviceId))], tasks);
|
|
342
|
+
return Promise.all(tasks);
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
);
|
|
328
346
|
var parseDeviceDeployment = ({
|
|
329
347
|
deployment: { id, artifact_name: release, status: deploymentStatus },
|
|
330
348
|
device: { created, deleted, id: deviceId, finished, status, log }
|
|
@@ -344,7 +362,7 @@ var parseDeviceDeployment = ({
|
|
|
344
362
|
return accu;
|
|
345
363
|
}, "")
|
|
346
364
|
});
|
|
347
|
-
var getDeviceDeployments =
|
|
365
|
+
var getDeviceDeployments = createAppAsyncThunk(`${sliceName2}/getDeviceDeployments`, (options, { dispatch }) => {
|
|
348
366
|
const { deviceId, filterSelection = [], page = defaultPage, perPage = defaultPerPage } = options;
|
|
349
367
|
const filters = filterSelection.map((item) => `&status=${item}`).join("");
|
|
350
368
|
return general_api_default.get(`${deploymentsApiUrl}/deployments/devices/${deviceId}?page=${page}&per_page=${perPage}${filters}`).then(
|
|
@@ -359,18 +377,18 @@ var getDeviceDeployments = createAsyncThunk(`${sliceName2}/getDeviceDeployments`
|
|
|
359
377
|
)
|
|
360
378
|
).catch((err) => commonErrorHandler(err, "There was an error retrieving the device deployment history:", dispatch));
|
|
361
379
|
});
|
|
362
|
-
var resetDeviceDeployments =
|
|
380
|
+
var resetDeviceDeployments = createAppAsyncThunk(
|
|
363
381
|
`${sliceName2}/resetDeviceDeployments`,
|
|
364
382
|
(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))
|
|
365
383
|
);
|
|
366
|
-
var getSingleDeployment =
|
|
384
|
+
var getSingleDeployment = createAppAsyncThunk(
|
|
367
385
|
`${sliceName2}/getSingleDeployment`,
|
|
368
386
|
(id, { dispatch, getState }) => general_api_default.get(`${deploymentsApiUrl}/deployments/${id}`).then(({ data }) => {
|
|
369
387
|
const { deployments } = transformDeployments([data], getState().deployments.byId);
|
|
370
388
|
return Promise.resolve(dispatch(actions2.receivedDeployment(deployments[id])));
|
|
371
389
|
})
|
|
372
390
|
);
|
|
373
|
-
var getDeviceLog =
|
|
391
|
+
var getDeviceLog = createAppAsyncThunk(
|
|
374
392
|
`${sliceName2}/getDeviceLog`,
|
|
375
393
|
({ deploymentId, deviceId }, { dispatch }) => general_api_default.get(`${deploymentsApiUrl}/deployments/${deploymentId}/devices/${deviceId}/log`).catch((e) => {
|
|
376
394
|
console.log("no log here", e);
|
|
@@ -379,7 +397,7 @@ var getDeviceLog = createAsyncThunk(
|
|
|
379
397
|
({ data: log }) => Promise.all([Promise.resolve(dispatch(actions2.receivedDeploymentDeviceLog({ id: deploymentId, deviceId, log }))), Promise.resolve(log)])
|
|
380
398
|
)
|
|
381
399
|
);
|
|
382
|
-
var abortDeployment =
|
|
400
|
+
var abortDeployment = createAppAsyncThunk(
|
|
383
401
|
`${sliceName2}/abortDeployment`,
|
|
384
402
|
(deploymentId, { dispatch, getState }) => general_api_default.put(`${deploymentsApiUrl}/deployments/${deploymentId}/status`, { status: "aborted" }).then(() => {
|
|
385
403
|
const deploymentsByStatus = getDeploymentsByStatus(getState());
|
|
@@ -404,14 +422,14 @@ var abortDeployment = createAsyncThunk(
|
|
|
404
422
|
]);
|
|
405
423
|
}).catch((err) => commonErrorHandler(err, "There was an error while aborting the deployment:", dispatch))
|
|
406
424
|
);
|
|
407
|
-
var updateDeploymentControlMap =
|
|
425
|
+
var updateDeploymentControlMap = createAppAsyncThunk(
|
|
408
426
|
`${sliceName2}/updateDeploymentControlMap`,
|
|
409
427
|
({ 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))))
|
|
410
428
|
);
|
|
411
|
-
var setDeploymentsState =
|
|
429
|
+
var setDeploymentsState = createAppAsyncThunk(`${sliceName2}/setDeploymentsState`, (selection, { dispatch, getState }) => {
|
|
412
430
|
const { page, perPage, ...selectionState } = selection;
|
|
413
431
|
const currentState = getState().deployments.selectionState;
|
|
414
|
-
|
|
432
|
+
const nextState = {
|
|
415
433
|
...currentState,
|
|
416
434
|
...selectionState,
|
|
417
435
|
...Object.keys(DEPLOYMENT_STATES).reduce((accu, item) => {
|
|
@@ -426,7 +444,7 @@ var setDeploymentsState = createAsyncThunk(`${sliceName2}/setDeploymentsState`,
|
|
|
426
444
|
...selectionState.general
|
|
427
445
|
}
|
|
428
446
|
};
|
|
429
|
-
|
|
447
|
+
const tasks = [dispatch(actions2.setDeploymentsState(nextState))];
|
|
430
448
|
if (nextState.selectedId && currentState.selectedId !== nextState.selectedId) {
|
|
431
449
|
tasks.push(dispatch(getSingleDeployment(nextState.selectedId)));
|
|
432
450
|
}
|
|
@@ -447,25 +465,23 @@ var mapExternalDeltaConfig = (config = {}) => deltaAttributeMappings.reduce((acc
|
|
|
447
465
|
}
|
|
448
466
|
return accu;
|
|
449
467
|
}, {});
|
|
450
|
-
var getDeploymentsConfig =
|
|
468
|
+
var getDeploymentsConfig = createAppAsyncThunk(
|
|
451
469
|
`${sliceName2}/getDeploymentsConfig`,
|
|
452
470
|
(_, { dispatch, getState }) => general_api_default.get(`${deploymentsApiUrl}/config`).then(({ data }) => {
|
|
453
471
|
const oldConfig = getState().deployments.config;
|
|
454
472
|
const { delta = {} } = data;
|
|
455
473
|
const { binary_delta = {}, binary_delta_limits = {} } = delta;
|
|
456
|
-
const { xdelta_args = {}
|
|
457
|
-
const { xdelta_args_limits = {}
|
|
474
|
+
const { xdelta_args = {} } = binary_delta;
|
|
475
|
+
const { xdelta_args_limits = {} } = binary_delta_limits;
|
|
458
476
|
const config = {
|
|
459
477
|
...oldConfig,
|
|
460
478
|
hasDelta: Boolean(delta.enabled),
|
|
461
479
|
binaryDelta: {
|
|
462
480
|
...oldConfig.binaryDelta,
|
|
463
|
-
timeout: timeoutConfig,
|
|
464
481
|
...mapExternalDeltaConfig(xdelta_args)
|
|
465
482
|
},
|
|
466
483
|
binaryDeltaLimits: {
|
|
467
484
|
...oldConfig.binaryDeltaLimits,
|
|
468
|
-
timeout: timeoutLimit,
|
|
469
485
|
...mapExternalDeltaConfig(xdelta_args_limits)
|
|
470
486
|
}
|
|
471
487
|
};
|
|
@@ -474,7 +490,7 @@ var getDeploymentsConfig = createAsyncThunk(
|
|
|
474
490
|
);
|
|
475
491
|
var deepClean = (source) => Object.entries(source).reduce((accu, [key, value]) => {
|
|
476
492
|
if (value !== void 0) {
|
|
477
|
-
|
|
493
|
+
const cleanedValue = typeof value === "object" ? deepClean(value) : value;
|
|
478
494
|
if (cleanedValue === void 0 || typeof cleanedValue === "object" && isEmpty(cleanedValue)) {
|
|
479
495
|
return accu;
|
|
480
496
|
}
|
|
@@ -482,37 +498,38 @@ var deepClean = (source) => Object.entries(source).reduce((accu, [key, value]) =
|
|
|
482
498
|
}
|
|
483
499
|
return accu;
|
|
484
500
|
}, void 0);
|
|
485
|
-
var saveDeltaDeploymentsConfig =
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
const result = deepClean(configChange);
|
|
496
|
-
if (!result) {
|
|
497
|
-
return Promise.resolve();
|
|
498
|
-
}
|
|
499
|
-
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(() => {
|
|
500
|
-
const oldConfig = getState().deployments.config;
|
|
501
|
-
const newConfig = {
|
|
502
|
-
...oldConfig,
|
|
503
|
-
binaryDelta: {
|
|
504
|
-
...oldConfig.binaryDelta,
|
|
505
|
-
...config
|
|
506
|
-
}
|
|
501
|
+
var saveDeltaDeploymentsConfig = createAppAsyncThunk(
|
|
502
|
+
`${sliceName2}/saveDeltaDeploymentsConfig`,
|
|
503
|
+
(config, { dispatch, getState }) => {
|
|
504
|
+
const configChange = {
|
|
505
|
+
xdelta_args: deltaAttributeMappings.reduce((accu, { here, there }) => {
|
|
506
|
+
if (config[here] !== void 0) {
|
|
507
|
+
accu[there] = config[here];
|
|
508
|
+
}
|
|
509
|
+
return accu;
|
|
510
|
+
}, {})
|
|
507
511
|
};
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
512
|
+
const result = deepClean(configChange);
|
|
513
|
+
if (!result) {
|
|
514
|
+
return Promise.resolve();
|
|
515
|
+
}
|
|
516
|
+
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(() => {
|
|
517
|
+
const oldConfig = getState().deployments.config;
|
|
518
|
+
const newConfig = {
|
|
519
|
+
...oldConfig,
|
|
520
|
+
binaryDelta: {
|
|
521
|
+
...oldConfig.binaryDelta,
|
|
522
|
+
...config
|
|
523
|
+
}
|
|
524
|
+
};
|
|
525
|
+
return Promise.all([dispatch(actions2.setDeploymentsConfig(newConfig)), dispatch(setSnackbar("Settings saved successfully"))]);
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
);
|
|
511
529
|
|
|
512
530
|
// src/devicesSlice/thunks.tsx
|
|
513
531
|
import { Link } from "react-router-dom";
|
|
514
|
-
import { attributeDuplicateFilter, dateRangeToUnix, deepCompare as deepCompare2,
|
|
515
|
-
import { createAsyncThunk as createAsyncThunk2 } from "@reduxjs/toolkit";
|
|
532
|
+
import { attributeDuplicateFilter, dateRangeToUnix, deepCompare as deepCompare2, getSnackbarMessage } from "@northern.tech/utils/helpers";
|
|
516
533
|
import { isCancel } from "axios";
|
|
517
534
|
import pluralize from "pluralize";
|
|
518
535
|
import { v4 as uuid } from "uuid";
|
|
@@ -533,7 +550,7 @@ var defaultAttributes = [
|
|
|
533
550
|
{ scope: "system", attribute: "group" },
|
|
534
551
|
{ scope: "tags", attribute: "name" }
|
|
535
552
|
];
|
|
536
|
-
var
|
|
553
|
+
var getGroups = createAppAsyncThunk(
|
|
537
554
|
`${sliceName3}/getGroups`,
|
|
538
555
|
(_, { dispatch, getState }) => general_api_default.get(`${inventoryApiUrl}/groups`).then((res) => {
|
|
539
556
|
const state = getGroupsById(getState());
|
|
@@ -550,7 +567,7 @@ var getGroups2 = createAsyncThunk2(
|
|
|
550
567
|
const filters = [{ key: "group", value: res.data, operator: DEVICE_FILTERING_OPTIONS.$nin.key, scope: "system" }];
|
|
551
568
|
return Promise.all([
|
|
552
569
|
dispatch(actions3.receivedGroups(groups)),
|
|
553
|
-
dispatch(getDevicesByStatus({ filterSelection: filters, group:
|
|
570
|
+
dispatch(getDevicesByStatus({ filterSelection: filters, group: "", page: 1, perPage: 1, status: void 0 }))
|
|
554
571
|
]).then((promises) => {
|
|
555
572
|
const devicesRetrieval = promises[promises.length - 1] || [];
|
|
556
573
|
const { payload } = devicesRetrieval || {};
|
|
@@ -569,39 +586,42 @@ var getGroups2 = createAsyncThunk2(
|
|
|
569
586
|
});
|
|
570
587
|
})
|
|
571
588
|
);
|
|
572
|
-
var addDevicesToGroup =
|
|
589
|
+
var addDevicesToGroup = createAppAsyncThunk(
|
|
573
590
|
`${sliceName3}/addDevicesToGroup`,
|
|
574
|
-
({ group, deviceIds, isCreation }, { dispatch }) => general_api_default.patch(`${inventoryApiUrl}/groups/${group}/devices`, deviceIds).then(() => dispatch(actions3.addToGroup({ group, deviceIds }))).finally(() => isCreation ? Promise.resolve(dispatch(
|
|
591
|
+
({ group, deviceIds, isCreation }, { dispatch }) => general_api_default.patch(`${inventoryApiUrl}/groups/${group}/devices`, deviceIds).then(() => dispatch(actions3.addToGroup({ group, deviceIds }))).finally(() => isCreation ? Promise.resolve(dispatch(getGroups())) : {})
|
|
575
592
|
);
|
|
576
|
-
var removeDevicesFromGroup =
|
|
593
|
+
var removeDevicesFromGroup = createAppAsyncThunk(
|
|
577
594
|
`${sliceName3}/removeDevicesFromGroup`,
|
|
578
595
|
({ group, deviceIds }, { dispatch }) => general_api_default.delete(`${inventoryApiUrl}/groups/${group}/devices`, deviceIds).then(
|
|
579
596
|
() => Promise.all([
|
|
580
597
|
dispatch(actions3.removeFromGroup({ group, deviceIds })),
|
|
581
|
-
dispatch(
|
|
598
|
+
dispatch(
|
|
599
|
+
setSnackbar2({
|
|
600
|
+
message: `The ${pluralize("devices", deviceIds.length)} ${pluralize("were", deviceIds.length)} removed from the group`,
|
|
601
|
+
autoHideDuration: TIMEOUTS.fiveSeconds
|
|
602
|
+
})
|
|
603
|
+
)
|
|
582
604
|
])
|
|
583
605
|
)
|
|
584
606
|
);
|
|
585
607
|
var getGroupNotification = (newGroup, selectedGroup) => {
|
|
586
|
-
const
|
|
608
|
+
const successMessage2 = "The group was updated successfully";
|
|
587
609
|
if (newGroup === selectedGroup) {
|
|
588
|
-
return
|
|
610
|
+
return { message: successMessage2, autoHideDuration: TIMEOUTS.fiveSeconds };
|
|
589
611
|
}
|
|
590
|
-
return
|
|
591
|
-
|
|
592
|
-
|
|
612
|
+
return {
|
|
613
|
+
action: "",
|
|
614
|
+
autoHideDuration: TIMEOUTS.fiveSeconds,
|
|
615
|
+
message: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
616
|
+
successMessage2,
|
|
593
617
|
" - ",
|
|
594
618
|
/* @__PURE__ */ jsx(Link, { to: `/devices?inventory=group:eq:${newGroup}`, children: "click here" }),
|
|
595
619
|
" to see it."
|
|
596
620
|
] }),
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
void 0,
|
|
600
|
-
() => {
|
|
601
|
-
}
|
|
602
|
-
];
|
|
621
|
+
preventClickToCopy: true
|
|
622
|
+
};
|
|
603
623
|
};
|
|
604
|
-
var addStaticGroup =
|
|
624
|
+
var addStaticGroup = createAppAsyncThunk(
|
|
605
625
|
`${sliceName3}/addStaticGroup`,
|
|
606
626
|
({ group, devices }, { dispatch, getState }) => Promise.resolve(dispatch(addDevicesToGroup({ group, deviceIds: devices.map(({ id }) => id), isCreation: true }))).then(
|
|
607
627
|
() => Promise.resolve(
|
|
@@ -614,23 +634,23 @@ var addStaticGroup = createAsyncThunk2(
|
|
|
614
634
|
).then(
|
|
615
635
|
() => Promise.all([
|
|
616
636
|
dispatch(setDeviceListState({ setOnly: true })),
|
|
617
|
-
dispatch(
|
|
618
|
-
dispatch(setSnackbar2(
|
|
637
|
+
dispatch(getGroups()),
|
|
638
|
+
dispatch(setSnackbar2(getGroupNotification(group, getState().devices.groups.selectedGroup)))
|
|
619
639
|
])
|
|
620
640
|
)
|
|
621
641
|
).catch((err) => commonErrorHandler(err, `Group could not be updated:`, dispatch))
|
|
622
642
|
);
|
|
623
|
-
var removeStaticGroup =
|
|
643
|
+
var removeStaticGroup = createAppAsyncThunk(
|
|
624
644
|
`${sliceName3}/removeStaticGroup`,
|
|
625
645
|
(groupName, { dispatch }) => general_api_default.delete(`${inventoryApiUrl}/groups/${groupName}`).then(
|
|
626
646
|
() => Promise.all([
|
|
627
647
|
dispatch(actions3.removeGroup(groupName)),
|
|
628
|
-
dispatch(
|
|
629
|
-
dispatch(setSnackbar2("Group was removed successfully", TIMEOUTS.fiveSeconds))
|
|
648
|
+
dispatch(getGroups()),
|
|
649
|
+
dispatch(setSnackbar2({ message: "Group was removed successfully", autoHideDuration: TIMEOUTS.fiveSeconds }))
|
|
630
650
|
])
|
|
631
651
|
)
|
|
632
652
|
);
|
|
633
|
-
var getDynamicGroups =
|
|
653
|
+
var getDynamicGroups = createAppAsyncThunk(
|
|
634
654
|
`${sliceName3}/getDynamicGroups`,
|
|
635
655
|
(_, { dispatch, getState }) => general_api_default.get(`${inventoryApiUrlV2}/filters?per_page=${MAX_PAGE_SIZE}`).then(({ data: filters }) => {
|
|
636
656
|
const state = getGroupsById(getState());
|
|
@@ -653,7 +673,7 @@ var getDynamicGroups = createAsyncThunk2(
|
|
|
653
673
|
return Promise.resolve(dispatch(actions3.receivedGroups(groups)));
|
|
654
674
|
}).catch(() => console.log("Dynamic group retrieval failed - likely accessing a non-enterprise backend"))
|
|
655
675
|
);
|
|
656
|
-
var addDynamicGroup =
|
|
676
|
+
var addDynamicGroup = createAppAsyncThunk(
|
|
657
677
|
`${sliceName3}/addDynamicGroup`,
|
|
658
678
|
({ groupName, filterPredicates }, { dispatch, getState }) => general_api_default.post(`${inventoryApiUrlV2}/filters`, { name: groupName, terms: mapFiltersToTerms(filterPredicates) }).then(
|
|
659
679
|
(res) => Promise.resolve(
|
|
@@ -670,45 +690,56 @@ var addDynamicGroup = createAsyncThunk2(
|
|
|
670
690
|
const { cleanedFilters } = getGroupFilters(groupName, getState().devices.groups);
|
|
671
691
|
return Promise.all([
|
|
672
692
|
dispatch(actions3.setDeviceFilters(cleanedFilters)),
|
|
673
|
-
dispatch(setSnackbar2(
|
|
693
|
+
dispatch(setSnackbar2(getGroupNotification(groupName, getState().devices.groups.selectedGroup))),
|
|
674
694
|
dispatch(getDynamicGroups())
|
|
675
695
|
]);
|
|
676
696
|
})
|
|
677
697
|
).catch((err) => commonErrorHandler(err, `Group could not be updated:`, dispatch))
|
|
678
698
|
);
|
|
679
|
-
var updateDynamicGroup =
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
699
|
+
var updateDynamicGroup = createAppAsyncThunk(
|
|
700
|
+
`${sliceName3}/updateDynamicGroup`,
|
|
701
|
+
({ groupName, filterPredicates }, { dispatch, getState }) => {
|
|
702
|
+
const filterId = getState().devices.groups.byId[groupName].id;
|
|
703
|
+
return general_api_default.delete(`${inventoryApiUrlV2}/filters/${filterId}`).then(
|
|
704
|
+
() => Promise.resolve(dispatch(addDynamicGroup({ groupName, filterPredicates })))
|
|
705
|
+
);
|
|
706
|
+
}
|
|
707
|
+
);
|
|
708
|
+
var removeDynamicGroup = createAppAsyncThunk(`${sliceName3}/removeDynamicGroup`, (groupName, { dispatch, getState }) => {
|
|
684
709
|
const filterId = getState().devices.groups.byId[groupName].id;
|
|
685
710
|
return general_api_default.delete(`${inventoryApiUrlV2}/filters/${filterId}`).then(
|
|
686
|
-
() => Promise.all([
|
|
711
|
+
() => Promise.all([
|
|
712
|
+
dispatch(actions3.removeGroup(groupName)),
|
|
713
|
+
dispatch(setSnackbar2({ message: "Group was removed successfully", autoHideDuration: TIMEOUTS.fiveSeconds }))
|
|
714
|
+
])
|
|
687
715
|
);
|
|
688
716
|
});
|
|
689
717
|
var getGroupFilters = (group, groupsState, filters = []) => {
|
|
690
718
|
const groupName = group === UNGROUPED_GROUP.id || group === UNGROUPED_GROUP.name ? UNGROUPED_GROUP.id : group;
|
|
691
719
|
const selectedGroup = groupsState.byId[groupName];
|
|
692
720
|
const groupFilterLength = selectedGroup?.filters?.length || 0;
|
|
693
|
-
const cleanedFilters = groupFilterLength ? [...filters, ...selectedGroup.filters].filter(filtersFilter) : filters;
|
|
721
|
+
const cleanedFilters = groupFilterLength ? [...filters, ...selectedGroup.filters || []].filter(filtersFilter) : filters;
|
|
694
722
|
return { cleanedFilters, groupName, selectedGroup, groupFilterLength };
|
|
695
723
|
};
|
|
696
|
-
var selectGroup =
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
tasks
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
724
|
+
var selectGroup = createAppAsyncThunk(
|
|
725
|
+
`${sliceName3}/selectGroup`,
|
|
726
|
+
({ group, filters = [] }, { dispatch, getState }) => {
|
|
727
|
+
const { cleanedFilters, groupName, selectedGroup, groupFilterLength } = getGroupFilters(group, getState().devices.groups, filters);
|
|
728
|
+
if (getSelectedGroup(getState()) === groupName && (filters.length === 0 && !groupFilterLength || filters.length === cleanedFilters.length)) {
|
|
729
|
+
return Promise.resolve();
|
|
730
|
+
}
|
|
731
|
+
const tasks = [];
|
|
732
|
+
if (groupFilterLength) {
|
|
733
|
+
tasks.push(dispatch(actions3.setDeviceFilters(cleanedFilters)));
|
|
734
|
+
} else {
|
|
735
|
+
tasks.push(dispatch(actions3.setDeviceFilters(filters)));
|
|
736
|
+
tasks.push(dispatch(getGroupDevices({ group: groupName, perPage: 1, shouldIncludeAllStates: true })));
|
|
737
|
+
}
|
|
738
|
+
const selectedGroupName = selectedGroup || !Object.keys(getGroupsById(getState())).length ? groupName : void 0;
|
|
739
|
+
tasks.push(dispatch(actions3.selectGroup(selectedGroupName)));
|
|
740
|
+
return Promise.all(tasks);
|
|
707
741
|
}
|
|
708
|
-
|
|
709
|
-
tasks.push(dispatch(actions3.selectGroup(selectedGroupName)));
|
|
710
|
-
return Promise.all(tasks);
|
|
711
|
-
});
|
|
742
|
+
);
|
|
712
743
|
var getEarliestTs = (dateA = "", dateB = "") => !dateA || !dateB ? dateA || dateB : dateA < dateB ? dateA : dateB;
|
|
713
744
|
var reduceReceivedDevices = (devices, ids, state, status) => devices.reduce(
|
|
714
745
|
(accu, device) => {
|
|
@@ -739,11 +770,16 @@ var reduceReceivedDevices = (devices, ids, state, status) => devices.reduce(
|
|
|
739
770
|
},
|
|
740
771
|
{ ids, devicesById: {} }
|
|
741
772
|
);
|
|
742
|
-
var getGroupDevices =
|
|
773
|
+
var getGroupDevices = createAppAsyncThunk(`${sliceName3}/getGroupDevices`, (options, { dispatch, getState }) => {
|
|
743
774
|
const { group, shouldIncludeAllStates, ...remainder } = options;
|
|
744
775
|
const { cleanedFilters: filterSelection } = getGroupFilters(group, getState().devices.groups);
|
|
745
|
-
return
|
|
746
|
-
|
|
776
|
+
return dispatch(
|
|
777
|
+
getDevicesByStatus({
|
|
778
|
+
...remainder,
|
|
779
|
+
filterSelection,
|
|
780
|
+
group,
|
|
781
|
+
status: shouldIncludeAllStates ? void 0 : DEVICE_STATES.accepted
|
|
782
|
+
})
|
|
747
783
|
).unwrap().then((results) => {
|
|
748
784
|
if (!group) {
|
|
749
785
|
return Promise.resolve();
|
|
@@ -757,7 +793,7 @@ var getGroupDevices = createAsyncThunk2(`${sliceName3}/getGroupDevices`, (option
|
|
|
757
793
|
dispatch(
|
|
758
794
|
actions3.addGroup({
|
|
759
795
|
group: {
|
|
760
|
-
deviceIds: deviceAccu.ids.length === total || deviceAccu.ids.length > stateGroup
|
|
796
|
+
deviceIds: deviceAccu.ids.length === total || stateGroup && stateGroup.deviceIds && deviceAccu.ids.length > stateGroup.deviceIds ? deviceAccu.ids : stateGroup.deviceIds,
|
|
761
797
|
total
|
|
762
798
|
},
|
|
763
799
|
groupName: group
|
|
@@ -766,55 +802,63 @@ var getGroupDevices = createAsyncThunk2(`${sliceName3}/getGroupDevices`, (option
|
|
|
766
802
|
);
|
|
767
803
|
});
|
|
768
804
|
});
|
|
769
|
-
var getAllGroupDevices =
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
filters: [],
|
|
775
|
-
group,
|
|
776
|
-
state: getState(),
|
|
777
|
-
status: DEVICE_STATES.accepted
|
|
778
|
-
});
|
|
779
|
-
const getAllDevices = (perPage = MAX_PAGE_SIZE, page = defaultPage2, devices = []) => general_api_default.post(getSearchEndpoint(getState()), {
|
|
780
|
-
page,
|
|
781
|
-
per_page: perPage,
|
|
782
|
-
filters: filterTerms,
|
|
783
|
-
attributes
|
|
784
|
-
}).then((res) => {
|
|
785
|
-
const state = getState();
|
|
786
|
-
const deviceAccu = reduceReceivedDevices(res.data, devices, state);
|
|
787
|
-
dispatch(actions3.receivedDevices(deviceAccu.devicesById));
|
|
788
|
-
const total = Number(res.headers[headerNames.total]);
|
|
789
|
-
if (total > perPage * page) {
|
|
790
|
-
return getAllDevices(perPage, page + 1, deviceAccu.ids);
|
|
805
|
+
var getAllGroupDevices = createAppAsyncThunk(
|
|
806
|
+
`${sliceName3}/getAllGroupDevices`,
|
|
807
|
+
({ group, attribute }, { dispatch, getState }) => {
|
|
808
|
+
if (!group || !!group && (!getGroupsById(getState())[group] || getGroupsById(getState())[group].filters.length)) {
|
|
809
|
+
return Promise.resolve();
|
|
791
810
|
}
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
811
|
+
const { attributes, filterTerms } = prepareSearchArguments({
|
|
812
|
+
filters: [],
|
|
813
|
+
group,
|
|
814
|
+
state: getState(),
|
|
815
|
+
status: DEVICE_STATES.accepted
|
|
816
|
+
});
|
|
817
|
+
const getAllDevices = (perPage = MAX_PAGE_SIZE, page = defaultPage2, devices = []) => general_api_default.post(getSearchEndpoint(getState()), {
|
|
818
|
+
page,
|
|
819
|
+
per_page: perPage,
|
|
820
|
+
filters: filterTerms,
|
|
821
|
+
attributes: [...attributes, { scope: "inventory", attribute }]
|
|
822
|
+
}).then((res) => {
|
|
823
|
+
const state = getState();
|
|
824
|
+
const deviceAccu = reduceReceivedDevices(res.data, devices, state);
|
|
825
|
+
dispatch(actions3.receivedDevices(deviceAccu.devicesById));
|
|
826
|
+
const total = Number(res.headers[headerNames.total]);
|
|
827
|
+
if (total > perPage * page) {
|
|
828
|
+
return getAllDevices(perPage, page + 1, deviceAccu.ids);
|
|
829
|
+
}
|
|
830
|
+
return Promise.resolve(dispatch(actions3.addGroup({ group: { deviceIds: deviceAccu.ids, total: deviceAccu.ids.length }, groupName: group })));
|
|
831
|
+
});
|
|
832
|
+
return getAllDevices();
|
|
799
833
|
}
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
const state = getState();
|
|
807
|
-
const deviceAccu = reduceReceivedDevices(res.data, devices, state);
|
|
808
|
-
dispatch(actions3.receivedDevices(deviceAccu.devicesById));
|
|
809
|
-
const total = Number(res.headers[headerNames.total]);
|
|
810
|
-
if (total > deviceAccu.ids.length) {
|
|
811
|
-
return getAllDevices(perPage, page + 1, deviceAccu.ids);
|
|
834
|
+
);
|
|
835
|
+
var getAllDynamicGroupDevices = createAppAsyncThunk(
|
|
836
|
+
`${sliceName3}/getAllDynamicGroupDevices`,
|
|
837
|
+
({ group, attribute }, { dispatch, getState }) => {
|
|
838
|
+
if (!!group && (!getGroupsById(getState())[group] || !getGroupsById(getState())[group].filters.length)) {
|
|
839
|
+
return Promise.resolve();
|
|
812
840
|
}
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
841
|
+
const { attributes, filterTerms: filters } = prepareSearchArguments({
|
|
842
|
+
filters: getState().devices.groups.byId[group].filters,
|
|
843
|
+
state: getState(),
|
|
844
|
+
status: DEVICE_STATES.accepted
|
|
845
|
+
});
|
|
846
|
+
const getAllDevices = (perPage = MAX_PAGE_SIZE, page = defaultPage2, devices = []) => general_api_default.post(getSearchEndpoint(getState()), { page, per_page: perPage, filters, attributes: [...attributes, { scope: "inventory", attribute }] }).then(
|
|
847
|
+
(res) => {
|
|
848
|
+
const state = getState();
|
|
849
|
+
const deviceAccu = reduceReceivedDevices(res.data, devices, state);
|
|
850
|
+
dispatch(actions3.receivedDevices(deviceAccu.devicesById));
|
|
851
|
+
const total = Number(res.headers[headerNames.total]);
|
|
852
|
+
if (total > deviceAccu.ids.length) {
|
|
853
|
+
return getAllDevices(perPage, page + 1, deviceAccu.ids);
|
|
854
|
+
}
|
|
855
|
+
return Promise.resolve(dispatch(actions3.addGroup({ group: { deviceIds: deviceAccu.ids, total }, groupName: group })));
|
|
856
|
+
}
|
|
857
|
+
);
|
|
858
|
+
return getAllDevices();
|
|
859
|
+
}
|
|
860
|
+
);
|
|
861
|
+
var getDeviceById2 = createAppAsyncThunk(
|
|
818
862
|
`${sliceName3}/getDeviceById`,
|
|
819
863
|
(id, { dispatch, getState }) => general_api_default.get(`${inventoryApiUrl}/devices/${id}`).then((res) => {
|
|
820
864
|
const device = reduceReceivedDevices([res.data], [], getState()).devicesById[id];
|
|
@@ -832,7 +876,8 @@ var getDeviceById2 = createAsyncThunk2(
|
|
|
832
876
|
attributes: [
|
|
833
877
|
{ name: "status", value: "decomissioned", scope: "identity" },
|
|
834
878
|
{ name: "decomissioned", value: "true", scope: "inventory" }
|
|
835
|
-
]
|
|
879
|
+
],
|
|
880
|
+
log: false
|
|
836
881
|
}
|
|
837
882
|
],
|
|
838
883
|
[],
|
|
@@ -842,17 +887,20 @@ var getDeviceById2 = createAsyncThunk2(
|
|
|
842
887
|
}
|
|
843
888
|
})
|
|
844
889
|
);
|
|
845
|
-
var getDeviceInfo =
|
|
890
|
+
var getDeviceInfo = createAppAsyncThunk(`${sliceName3}/getDeviceInfo`, (deviceId, { dispatch, getState }) => {
|
|
846
891
|
const device = getDeviceById(getState(), deviceId);
|
|
847
892
|
const { hasDeviceConfig, hasDeviceConnect, hasMonitor } = getTenantCapabilities(getState());
|
|
848
893
|
const { canConfigure } = getUserCapabilities(getState());
|
|
849
894
|
const integrations = getDeviceTwinIntegrations(getState());
|
|
850
|
-
|
|
851
|
-
|
|
895
|
+
const tasks = [
|
|
896
|
+
dispatch(getDeviceAuth(deviceId)),
|
|
897
|
+
dispatch(getDeviceById2(deviceId)),
|
|
898
|
+
...integrations.map((integration) => dispatch(getDeviceTwin({ deviceId, integration })))
|
|
899
|
+
];
|
|
900
|
+
if (hasDeviceConfig && canConfigure && (device.status === DEVICE_STATES.accepted || device.status === DEVICE_STATES.preauth)) {
|
|
852
901
|
tasks.push(dispatch(getDeviceConfig(deviceId)));
|
|
853
902
|
}
|
|
854
903
|
if (device.status === DEVICE_STATES.accepted) {
|
|
855
|
-
tasks.push(dispatch(getDeviceById2(deviceId)));
|
|
856
904
|
if (hasDeviceConnect) {
|
|
857
905
|
tasks.push(dispatch(getDeviceConnect(deviceId)));
|
|
858
906
|
}
|
|
@@ -863,25 +911,7 @@ var getDeviceInfo = createAsyncThunk2(`${sliceName3}/getDeviceInfo`, (deviceId,
|
|
|
863
911
|
}
|
|
864
912
|
return Promise.all(tasks);
|
|
865
913
|
});
|
|
866
|
-
var
|
|
867
|
-
const yesterday = /* @__PURE__ */ new Date();
|
|
868
|
-
yesterday.setDate(yesterday.getDate() - 1);
|
|
869
|
-
const yesterdaysIsoString = yesterday.toISOString();
|
|
870
|
-
const devices = deviceIds.reduce(
|
|
871
|
-
(accu, id) => {
|
|
872
|
-
const device = getDeviceById(getState(), id);
|
|
873
|
-
if (device && device.updated_ts > yesterdaysIsoString) {
|
|
874
|
-
accu.active.push(id);
|
|
875
|
-
} else {
|
|
876
|
-
accu.inactive.push(id);
|
|
877
|
-
}
|
|
878
|
-
return accu;
|
|
879
|
-
},
|
|
880
|
-
{ active: [], inactive: [] }
|
|
881
|
-
);
|
|
882
|
-
return dispatch(actions3.setInactiveDevices({ activeDeviceTotal: devices.active.length, inactiveDeviceTotal: devices.inactive.length }));
|
|
883
|
-
});
|
|
884
|
-
var getDeviceCount = createAsyncThunk2(
|
|
914
|
+
var getDeviceCount = createAppAsyncThunk(
|
|
885
915
|
`${sliceName3}/getDeviceCount`,
|
|
886
916
|
(status, { dispatch, getState }) => general_api_default.post(getSearchEndpoint(getState()), {
|
|
887
917
|
page: 1,
|
|
@@ -890,37 +920,34 @@ var getDeviceCount = createAsyncThunk2(
|
|
|
890
920
|
attributes: defaultAttributes
|
|
891
921
|
}).then((response) => {
|
|
892
922
|
const count = Number(response.headers[headerNames.total]);
|
|
893
|
-
|
|
894
|
-
return dispatch(actions3.setDevicesCountByStatus({ count, status }));
|
|
895
|
-
}
|
|
896
|
-
return dispatch(actions3.setTotalDevices(count));
|
|
923
|
+
return dispatch(actions3.setDevicesCountByStatus({ count, status }));
|
|
897
924
|
})
|
|
898
925
|
);
|
|
899
|
-
var getAllDeviceCounts =
|
|
926
|
+
var getAllDeviceCounts = createAppAsyncThunk(
|
|
900
927
|
`${sliceName3}/getAllDeviceCounts`,
|
|
901
928
|
(_, { dispatch }) => Promise.all([DEVICE_STATES.accepted, DEVICE_STATES.pending].map((status) => dispatch(getDeviceCount(status))))
|
|
902
929
|
);
|
|
903
|
-
var getDeviceLimit =
|
|
930
|
+
var getDeviceLimit = createAppAsyncThunk(
|
|
904
931
|
`${sliceName3}/getDeviceLimit`,
|
|
905
932
|
(_, { dispatch }) => general_api_default.get(`${deviceAuthV2}/limits/max_devices`).then((res) => dispatch(actions3.setDeviceLimit(res.data.limit)))
|
|
906
933
|
);
|
|
907
|
-
var setDeviceListState =
|
|
934
|
+
var setDeviceListState = createAppAsyncThunk(
|
|
908
935
|
`${sliceName3}/setDeviceListState`,
|
|
909
936
|
({ shouldSelectDevices = true, forceRefresh, fetchAuth = true, ...selectionState }, { dispatch, getState }) => {
|
|
910
937
|
const currentState = getDeviceListState(getState());
|
|
911
938
|
const refreshTrigger = forceRefresh ? !currentState.refreshTrigger : selectionState.refreshTrigger;
|
|
912
|
-
|
|
939
|
+
const nextState = {
|
|
913
940
|
...currentState,
|
|
914
941
|
setOnly: false,
|
|
915
942
|
refreshTrigger,
|
|
916
943
|
...selectionState,
|
|
917
944
|
sort: { ...currentState.sort, ...selectionState.sort }
|
|
918
945
|
};
|
|
919
|
-
|
|
946
|
+
const tasks = [];
|
|
920
947
|
const { isLoading: currentLoading, deviceIds: currentDevices, selection: currentSelection, ...currentRequestState } = currentState;
|
|
921
948
|
const { isLoading: nextLoading, deviceIds: nextDevices, selection: nextSelection, ...nextRequestState } = nextState;
|
|
922
949
|
if (!nextState.setOnly && !deepCompare2(currentRequestState, nextRequestState)) {
|
|
923
|
-
const { direction: sortDown = SORTING_OPTIONS.desc, key: sortCol, scope: sortScope } = nextState.sort ?? {};
|
|
950
|
+
const { direction: sortDown = SORTING_OPTIONS.desc, key: sortCol, scope: sortScope = "" } = nextState.sort ?? {};
|
|
924
951
|
const sortBy = sortCol ? [{ attribute: sortCol, order: sortDown, scope: sortScope }] : void 0;
|
|
925
952
|
const applicableSelectedState = nextState.state === ALL_DEVICE_STATES ? void 0 : nextState.state;
|
|
926
953
|
nextState.isLoading = true;
|
|
@@ -936,83 +963,84 @@ var setDeviceListState = createAsyncThunk2(
|
|
|
936
963
|
return Promise.all(tasks);
|
|
937
964
|
}
|
|
938
965
|
);
|
|
939
|
-
var getDevicesByStatus =
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
filters: filterSelection ?? getDeviceFilters(state),
|
|
954
|
-
group: group ?? getSelectedGroup(state),
|
|
955
|
-
groups: state.devices.groups,
|
|
956
|
-
offlineThreshold: state.app.offlineThreshold,
|
|
957
|
-
selectedIssues,
|
|
958
|
-
status
|
|
959
|
-
});
|
|
960
|
-
const attributes = [...defaultAttributes, getIdAttribute(getState()), ...selectedAttributes];
|
|
961
|
-
return general_api_default.post(getSearchEndpoint(getState()), {
|
|
962
|
-
page,
|
|
963
|
-
per_page: perPage,
|
|
964
|
-
filters: filterTerms,
|
|
965
|
-
sort: sortOptions,
|
|
966
|
-
attributes
|
|
967
|
-
}).then((response) => {
|
|
968
|
-
const state2 = getState();
|
|
969
|
-
const deviceAccu = reduceReceivedDevices(response.data, [], state2, status);
|
|
970
|
-
let total = !applicableFilters.length ? Number(response.headers[headerNames.total]) : null;
|
|
971
|
-
if (status && state2.devices.byStatus[status].total === deviceAccu.ids.length) {
|
|
972
|
-
total = deviceAccu.ids.length;
|
|
973
|
-
}
|
|
974
|
-
let tasks = [dispatch(actions3.receivedDevices(deviceAccu.devicesById))];
|
|
975
|
-
if (status) {
|
|
976
|
-
tasks.push(dispatch(actions3.setDevicesByStatus({ deviceIds: deviceAccu.ids, status, total })));
|
|
977
|
-
}
|
|
978
|
-
const receivedDevices = Object.values(deviceAccu.devicesById);
|
|
979
|
-
if (receivedDevices.length && fetchAuth) {
|
|
980
|
-
tasks.push(dispatch(getDevicesWithAuth(receivedDevices)));
|
|
981
|
-
}
|
|
982
|
-
tasks.push(Promise.resolve({ deviceAccu, total: Number(response.headers[headerNames.total]) }));
|
|
983
|
-
return Promise.all(tasks);
|
|
984
|
-
}).catch((err) => commonErrorHandler(err, `${status} devices couldn't be loaded.`, dispatch, commonErrorFallback));
|
|
985
|
-
});
|
|
986
|
-
var getAllDevicesByStatus = createAsyncThunk2(`${sliceName3}/getAllDevicesByStatus`, (status, { dispatch, getState }) => {
|
|
987
|
-
const attributes = [...defaultAttributes, getIdAttribute(getState())];
|
|
988
|
-
const getAllDevices = (perPage = MAX_PAGE_SIZE, page = 1, devices = []) => general_api_default.post(getSearchEndpoint(getState()), {
|
|
989
|
-
page,
|
|
990
|
-
per_page: perPage,
|
|
991
|
-
filters: mapFiltersToTerms([{ key: "status", value: status, operator: DEVICE_FILTERING_OPTIONS.$eq.key, scope: "identity" }]),
|
|
992
|
-
attributes
|
|
993
|
-
}).then((res) => {
|
|
966
|
+
var getDevicesByStatus = createAppAsyncThunk(
|
|
967
|
+
`${sliceName3}/getDevicesByStatus`,
|
|
968
|
+
(options, { dispatch, getState }) => {
|
|
969
|
+
const {
|
|
970
|
+
status,
|
|
971
|
+
fetchAuth = true,
|
|
972
|
+
filterSelection,
|
|
973
|
+
group,
|
|
974
|
+
selectedIssues = [],
|
|
975
|
+
page = defaultPage2,
|
|
976
|
+
perPage = defaultPerPage2,
|
|
977
|
+
sortOptions = [],
|
|
978
|
+
selectedAttributes = getSelectedDeviceAttribute(getState())
|
|
979
|
+
} = options;
|
|
994
980
|
const state = getState();
|
|
995
|
-
const
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
981
|
+
const { applicableFilters, filterTerms } = convertDeviceListStateToFilters({
|
|
982
|
+
filters: filterSelection ?? getDeviceFilters(state),
|
|
983
|
+
group: group ?? getSelectedGroup(state),
|
|
984
|
+
groups: state.devices.groups,
|
|
985
|
+
offlineThreshold: state.app.offlineThreshold,
|
|
986
|
+
selectedIssues,
|
|
987
|
+
status
|
|
988
|
+
});
|
|
989
|
+
const attributes = [...defaultAttributes, getIdAttribute(getState()), ...selectedAttributes];
|
|
990
|
+
return general_api_default.post(getSearchEndpoint(getState()), {
|
|
991
|
+
page,
|
|
992
|
+
per_page: perPage,
|
|
993
|
+
filters: filterTerms,
|
|
994
|
+
sort: sortOptions,
|
|
995
|
+
attributes
|
|
996
|
+
}).then((response) => {
|
|
997
|
+
const state2 = getState();
|
|
998
|
+
const deviceAccu = reduceReceivedDevices(response.data, [], state2, status);
|
|
999
|
+
let total = !applicableFilters.length ? Number(response.headers[headerNames.total]) : 0;
|
|
1000
|
+
if (status && state2.devices.byStatus[status].total === deviceAccu.ids.length) {
|
|
1001
|
+
total = deviceAccu.ids.length;
|
|
1002
|
+
}
|
|
1003
|
+
const tasks = [dispatch(actions3.receivedDevices(deviceAccu.devicesById))];
|
|
1004
|
+
if (status) {
|
|
1005
|
+
tasks.push(dispatch(actions3.setDevicesByStatus({ deviceIds: deviceAccu.ids, status, total })));
|
|
1006
|
+
}
|
|
1007
|
+
const receivedDevices = Object.values(deviceAccu.devicesById);
|
|
1008
|
+
if (receivedDevices.length && fetchAuth) {
|
|
1009
|
+
tasks.push(dispatch(getDevicesWithAuth(receivedDevices)));
|
|
1010
|
+
}
|
|
1011
|
+
tasks.push(Promise.resolve({ deviceAccu, total: Number(response.headers[headerNames.total]) }));
|
|
1012
|
+
return Promise.all(tasks);
|
|
1013
|
+
}).catch((err) => commonErrorHandler(err, `${status} devices couldn't be loaded.`, dispatch, commonErrorFallback));
|
|
1014
|
+
}
|
|
1015
|
+
);
|
|
1016
|
+
var getAllDevicesByStatus = createAppAsyncThunk(
|
|
1017
|
+
`${sliceName3}/getAllDevicesByStatus`,
|
|
1018
|
+
({ status, attribute }, { dispatch, getState }) => {
|
|
1019
|
+
const attributes = [...defaultAttributes, getIdAttribute(getState())];
|
|
1020
|
+
const getAllDevices = (perPage = MAX_PAGE_SIZE, page = 1, devices = []) => general_api_default.post(getSearchEndpoint(getState()), {
|
|
1021
|
+
page,
|
|
1022
|
+
per_page: perPage,
|
|
1023
|
+
filters: mapFiltersToTerms([{ key: "status", value: status, operator: DEVICE_FILTERING_OPTIONS.$eq.key, scope: "identity" }]),
|
|
1024
|
+
attributes: [...attributes, { scope: "inventory", attribute }]
|
|
1025
|
+
}).then((res) => {
|
|
1026
|
+
const state = getState();
|
|
1027
|
+
const deviceAccu = reduceReceivedDevices(res.data, devices, state, status);
|
|
1028
|
+
dispatch(actions3.receivedDevices(deviceAccu.devicesById));
|
|
1029
|
+
const total = Number(res.headers[headerNames.total]);
|
|
1030
|
+
if (total > state.deployments.deploymentDeviceLimit) {
|
|
1031
|
+
return Promise.resolve();
|
|
1032
|
+
}
|
|
1033
|
+
if (total > perPage * page) {
|
|
1034
|
+
return getAllDevices(perPage, page + 1, deviceAccu.ids);
|
|
1035
|
+
}
|
|
999
1036
|
return Promise.resolve();
|
|
1000
|
-
}
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
if (status === DEVICE_STATES.accepted && deviceAccu.ids.length === total) {
|
|
1006
|
-
tasks.push(dispatch(deriveInactiveDevices(deviceAccu.ids)));
|
|
1007
|
-
tasks.push(dispatch(deriveReportsData()));
|
|
1008
|
-
}
|
|
1009
|
-
return Promise.all(tasks);
|
|
1010
|
-
});
|
|
1011
|
-
return getAllDevices();
|
|
1012
|
-
});
|
|
1013
|
-
var searchDevices = createAsyncThunk2(`${sliceName3}/searchDevices`, (passedOptions = {}, { dispatch, getState }) => {
|
|
1037
|
+
});
|
|
1038
|
+
return getAllDevices();
|
|
1039
|
+
}
|
|
1040
|
+
);
|
|
1041
|
+
var searchDevices = createAppAsyncThunk(`${sliceName3}/searchDevices`, (passedOptions = {}, { dispatch, getState }) => {
|
|
1014
1042
|
const state = getState();
|
|
1015
|
-
|
|
1043
|
+
const options = { ...state.app.searchState, ...passedOptions };
|
|
1016
1044
|
const { page = defaultPage2, searchTerm, sortOptions = [] } = options;
|
|
1017
1045
|
const { columnSelection = [] } = getUserSettings(state);
|
|
1018
1046
|
const selectedAttributes = columnSelection.map((column) => ({ attribute: column.key, scope: column.scope }));
|
|
@@ -1043,64 +1071,25 @@ var attributeReducer = (attributes = []) => attributes.slice(0, ATTRIBUTE_LIST_C
|
|
|
1043
1071
|
},
|
|
1044
1072
|
{ identity: [], inventory: [], system: [], tags: [] }
|
|
1045
1073
|
);
|
|
1046
|
-
var getDeviceAttributes =
|
|
1074
|
+
var getDeviceAttributes = createAppAsyncThunk(
|
|
1047
1075
|
`${sliceName3}/getDeviceAttributes`,
|
|
1048
1076
|
(_, { dispatch, getState }) => general_api_default.get(getAttrsEndpoint(getState())).then(({ data }) => {
|
|
1049
1077
|
const { identity: identityAttributes, inventory: inventoryAttributes, system: systemAttributes, tags: tagAttributes } = attributeReducer(data || []);
|
|
1050
1078
|
return dispatch(actions3.setFilterAttributes({ identityAttributes, inventoryAttributes, systemAttributes, tagAttributes }));
|
|
1051
1079
|
})
|
|
1052
1080
|
);
|
|
1053
|
-
var getReportingLimits = createAsyncThunk2(
|
|
1054
|
-
`${sliceName3}/getReportingLimits`,
|
|
1055
|
-
(_, { dispatch }) => general_api_default.get(`${reportingApiUrl}/devices/attributes`).catch((err) => commonErrorHandler(err, `filterable attributes limit & usage could not be retrieved.`, dispatch, commonErrorFallback)).then(({ data }) => {
|
|
1056
|
-
const { attributes, count, limit } = data;
|
|
1057
|
-
const groupedAttributes = attributeReducer(attributes);
|
|
1058
|
-
return Promise.resolve(dispatch(actions3.setFilterablesConfig({ count, limit, attributes: groupedAttributes })));
|
|
1059
|
-
})
|
|
1060
|
-
);
|
|
1061
|
-
var ensureVersionString = (software, fallback) => software.length && software !== "artifact_name" ? software.endsWith(".version") ? software : `${software}.version` : fallback;
|
|
1062
|
-
var getSingleReportData = (reportConfig, groups) => {
|
|
1063
|
-
const { attribute, group, software = "" } = reportConfig;
|
|
1064
|
-
const filters = [{ key: "status", scope: "identity", operator: DEVICE_FILTERING_OPTIONS.$eq.key, value: "accepted" }];
|
|
1065
|
-
if (group) {
|
|
1066
|
-
const staticGroupFilter = { key: "group", scope: "system", operator: DEVICE_FILTERING_OPTIONS.$eq.key, value: group };
|
|
1067
|
-
const { cleanedFilters: groupFilters } = getGroupFilters(group, groups);
|
|
1068
|
-
filters.push(...groupFilters.length ? groupFilters : [staticGroupFilter]);
|
|
1069
|
-
}
|
|
1070
|
-
const aggregationAttribute = ensureVersionString(software, attribute);
|
|
1071
|
-
return general_api_default.post(`${reportingApiUrl}/devices/aggregate`, {
|
|
1072
|
-
aggregations: [{ attribute: aggregationAttribute, name: "*", scope: "inventory", size: REPORT_CHART_SIZE_LIMIT }],
|
|
1073
|
-
filters: mapFiltersToTerms(filters)
|
|
1074
|
-
}).then(({ data }) => ({ data, reportConfig }));
|
|
1075
|
-
};
|
|
1076
|
-
var getReportsData = createAsyncThunk2(`${sliceName3}/getReportsData`, (_, { dispatch, getState }) => {
|
|
1077
|
-
const state = getState();
|
|
1078
|
-
const currentUserId = getCurrentUser(state).id;
|
|
1079
|
-
const reports = getUserSettings(state).reports || getGlobalSettings(state)[`${currentUserId}-reports`] || (Object.keys(getDevicesById(state)).length ? defaultReports : []);
|
|
1080
|
-
return Promise.all(reports.map((report) => getSingleReportData(report, getState().devices.groups))).then((results) => {
|
|
1081
|
-
const devicesState = getState().devices;
|
|
1082
|
-
const totalDeviceCount = devicesState.byStatus.accepted.total;
|
|
1083
|
-
const newReports = results.map(({ data, reportConfig }) => {
|
|
1084
|
-
let { items, other_count } = data[0];
|
|
1085
|
-
const { attribute, group, software = "" } = reportConfig;
|
|
1086
|
-
const dataCount = items.reduce((accu, item) => accu + item.count, 0);
|
|
1087
|
-
const otherCount = !group && (software === rootfsImageVersion || attribute === "artifact_name") ? totalDeviceCount - dataCount : other_count;
|
|
1088
|
-
return { items, otherCount, total: otherCount + dataCount };
|
|
1089
|
-
});
|
|
1090
|
-
return Promise.resolve(dispatch(actions3.setDeviceReports(newReports)));
|
|
1091
|
-
});
|
|
1092
|
-
});
|
|
1093
1081
|
var initializeDistributionData = (report, groups, devices, totalDeviceCount) => {
|
|
1094
1082
|
const { attribute, group = "", software = "" } = report;
|
|
1095
1083
|
const effectiveAttribute = software ? software : attribute;
|
|
1096
1084
|
const { deviceIds, total = 0 } = groups[group] || {};
|
|
1097
|
-
const relevantDevices =
|
|
1085
|
+
const relevantDevices = deviceIds ? deviceIds.map((id) => devices[id]) : Object.values(devices);
|
|
1098
1086
|
const distributionByAttribute = relevantDevices.reduce((accu, item) => {
|
|
1099
1087
|
if (!item.attributes || item.status !== DEVICE_STATES.accepted) return accu;
|
|
1100
|
-
|
|
1101
|
-
|
|
1088
|
+
const attributeValue = item.attributes[effectiveAttribute];
|
|
1089
|
+
if (!accu[attributeValue]) {
|
|
1090
|
+
accu[attributeValue] = 0;
|
|
1102
1091
|
}
|
|
1103
|
-
accu[
|
|
1092
|
+
accu[attributeValue] = accu[attributeValue] + 1;
|
|
1104
1093
|
return accu;
|
|
1105
1094
|
}, {});
|
|
1106
1095
|
const distributionByAttributeSorted = Object.entries(distributionByAttribute).sort((pairA, pairB) => pairB[1] - pairA[1]);
|
|
@@ -1109,90 +1098,111 @@ var initializeDistributionData = (report, groups, devices, totalDeviceCount) =>
|
|
|
1109
1098
|
const otherCount = (groups[group] ? total : totalDeviceCount) - dataCount;
|
|
1110
1099
|
return { items, otherCount, total: otherCount + dataCount };
|
|
1111
1100
|
};
|
|
1112
|
-
var
|
|
1113
|
-
const
|
|
1114
|
-
const
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
const
|
|
1122
|
-
|
|
1101
|
+
var updateReportData = createAppAsyncThunk(`${sliceName3}/updateReportData`, (reportIndex, { dispatch, getState }) => {
|
|
1102
|
+
const reports = getDeviceReportsForUser(getState());
|
|
1103
|
+
const report = reports[reportIndex];
|
|
1104
|
+
const { group = "" } = report;
|
|
1105
|
+
const devicesById = getDevicesById(getState());
|
|
1106
|
+
const groups = getGroupsById(getState());
|
|
1107
|
+
const acceptedDevices = getAcceptedDevices(getState());
|
|
1108
|
+
const totalDeviceCount = groups[group] ? groups[group].total : acceptedDevices.total;
|
|
1109
|
+
const reportsData = getDeviceReports(getState());
|
|
1110
|
+
const newReports = [...reportsData];
|
|
1111
|
+
newReports[reportIndex] = initializeDistributionData(report, groups, devicesById, totalDeviceCount);
|
|
1123
1112
|
return Promise.resolve(dispatch(actions3.setDeviceReports(newReports)));
|
|
1124
1113
|
});
|
|
1125
|
-
var
|
|
1126
|
-
`${sliceName3}/
|
|
1127
|
-
(
|
|
1128
|
-
const
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1114
|
+
var getReportDataWithoutBackendSupport = createAppAsyncThunk(
|
|
1115
|
+
`${sliceName3}/getReportDataWithoutBackendSupport`,
|
|
1116
|
+
(reportIndex, { dispatch, getState }) => {
|
|
1117
|
+
const reports = getDeviceReportsForUser(getState());
|
|
1118
|
+
const report = reports[reportIndex];
|
|
1119
|
+
if (!report) {
|
|
1120
|
+
return;
|
|
1121
|
+
}
|
|
1122
|
+
const { attribute, group = "", software = "" } = report;
|
|
1123
|
+
const effectiveAttribute = software ? software : attribute;
|
|
1124
|
+
const devicesById = getDevicesById(getState());
|
|
1125
|
+
const acceptedDevices = getAcceptedDevices(getState());
|
|
1126
|
+
const groups = getGroupsById(getState());
|
|
1127
|
+
const { deviceIds = [], filters = [], total = 0 } = groups[group] || {};
|
|
1128
|
+
let groupDevicesRequest = Promise.resolve({
|
|
1129
|
+
payload: { groupName: "", group: { deviceIds: Object.keys(devicesById), total: Object.keys(devicesById).length } }
|
|
1130
|
+
});
|
|
1131
|
+
if (group && (!(deviceIds.length && total) || deviceIds.length !== total || !deviceIds.every((id) => !!devicesById[id]))) {
|
|
1132
|
+
groupDevicesRequest = filters.length ? dispatch(getAllDynamicGroupDevices({ group, attribute: effectiveAttribute })).unwrap() : dispatch(getAllGroupDevices({ group, attribute: effectiveAttribute })).unwrap();
|
|
1133
|
+
} else if (!group && (acceptedDevices.deviceIds.length !== acceptedDevices.total || !acceptedDevices.deviceIds.every((id) => !!devicesById[id]))) {
|
|
1134
|
+
groupDevicesRequest = dispatch(getAllDevicesByStatus({ status: DEVICE_STATES.accepted, attribute: effectiveAttribute })).unwrap();
|
|
1135
|
+
}
|
|
1136
|
+
return groupDevicesRequest.then(() => dispatch(updateReportData(reportIndex)));
|
|
1137
|
+
}
|
|
1134
1138
|
);
|
|
1135
|
-
var getDeviceConnect =
|
|
1139
|
+
var getDeviceConnect = createAppAsyncThunk(
|
|
1136
1140
|
`${sliceName3}/getDeviceConnect`,
|
|
1137
1141
|
(id, { dispatch }) => general_api_default.get(`${deviceConnect}/devices/${id}`).then(
|
|
1138
1142
|
({ data }) => Promise.all([dispatch(actions3.receivedDevice({ connect_status: data.status, connect_updated_ts: data.updated_ts, id })), Promise.resolve(data)])
|
|
1139
1143
|
)
|
|
1140
1144
|
);
|
|
1141
1145
|
var updateTypeMap = { deploymentUpdate: "check-update", inventoryUpdate: "send-inventory" };
|
|
1142
|
-
var triggerDeviceUpdate =
|
|
1146
|
+
var triggerDeviceUpdate = createAppAsyncThunk(
|
|
1143
1147
|
`${sliceName3}/triggerDeviceUpdate`,
|
|
1144
1148
|
({ id, type }, { dispatch }) => general_api_default.post(`${deviceConnect}/devices/${id}/${updateTypeMap[type] ?? updateTypeMap.deploymentUpdate}`).then(
|
|
1145
1149
|
() => new Promise((resolve) => setTimeout(() => resolve(dispatch(getDeviceById2(id))), TIMEOUTS.threeSeconds))
|
|
1146
1150
|
)
|
|
1147
1151
|
);
|
|
1148
|
-
var getSessionDetails =
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
}
|
|
1169
|
-
|
|
1152
|
+
var getSessionDetails = createAppAsyncThunk(
|
|
1153
|
+
`${sliceName3}/getSessionDetails`,
|
|
1154
|
+
({ sessionId, deviceId, userId, startDate, endDate }) => {
|
|
1155
|
+
const { start: startUnix, end: endUnix } = dateRangeToUnix(startDate, endDate);
|
|
1156
|
+
const createdAfter = startDate ? `&created_after=${startUnix}` : "";
|
|
1157
|
+
const createdBefore = endDate ? `&created_before=${endUnix}` : "";
|
|
1158
|
+
const objectSearch = `&object_id=${deviceId}`;
|
|
1159
|
+
return general_api_default.get(`${auditLogsApiUrl}/logs?per_page=500${createdAfter}${createdBefore}&actor_id=${userId}${objectSearch}`).then(
|
|
1160
|
+
({ data: auditLogEntries }) => {
|
|
1161
|
+
const { start, end } = auditLogEntries.reduce(
|
|
1162
|
+
(accu, item) => {
|
|
1163
|
+
if (item.meta?.session_id?.includes(sessionId)) {
|
|
1164
|
+
accu.start = new Date(item.action.startsWith("open") ? item.time : accu.start);
|
|
1165
|
+
accu.end = new Date(item.action.startsWith("close") ? item.time : accu.end);
|
|
1166
|
+
}
|
|
1167
|
+
return accu;
|
|
1168
|
+
},
|
|
1169
|
+
{ start: startDate || endDate, end: endDate || startDate }
|
|
1170
|
+
);
|
|
1171
|
+
return Promise.resolve({ start, end });
|
|
1172
|
+
}
|
|
1173
|
+
);
|
|
1174
|
+
}
|
|
1175
|
+
);
|
|
1176
|
+
var getDeviceFileDownloadLink = createAppAsyncThunk(
|
|
1170
1177
|
`${sliceName3}/getDeviceFileDownloadLink`,
|
|
1171
1178
|
({ deviceId, path }) => Promise.resolve(`${window.location.origin}${deviceConnect}/devices/${deviceId}/download?path=${encodeURIComponent(path)}`)
|
|
1172
1179
|
);
|
|
1173
|
-
var deviceFileUpload =
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1180
|
+
var deviceFileUpload = createAppAsyncThunk(
|
|
1181
|
+
`${sliceName3}/deviceFileUpload`,
|
|
1182
|
+
({ deviceId, path, file }, { dispatch }) => {
|
|
1183
|
+
const formData = new FormData();
|
|
1184
|
+
formData.append("path", path);
|
|
1185
|
+
formData.append("file", file);
|
|
1186
|
+
const uploadId = uuid();
|
|
1187
|
+
const cancelSource = new AbortController();
|
|
1188
|
+
return Promise.all([
|
|
1189
|
+
dispatch(setSnackbar2("Uploading file")),
|
|
1190
|
+
dispatch(initUpload({ id: uploadId, upload: { progress: 0, cancelSource } })),
|
|
1191
|
+
general_api_default.uploadPut(
|
|
1192
|
+
`${deviceConnect}/devices/${deviceId}/upload`,
|
|
1193
|
+
formData,
|
|
1194
|
+
(e) => dispatch(uploadProgress({ id: uploadId, progress: progress(e) })),
|
|
1195
|
+
cancelSource.signal
|
|
1196
|
+
)
|
|
1197
|
+
]).then(() => Promise.resolve(dispatch(setSnackbar2({ message: "Upload successful", autoHideDuration: TIMEOUTS.fiveSeconds })))).catch((err) => {
|
|
1198
|
+
if (isCancel(err)) {
|
|
1199
|
+
return dispatch(setSnackbar2({ message: "The upload has been cancelled", autoHideDuration: TIMEOUTS.fiveSeconds }));
|
|
1200
|
+
}
|
|
1201
|
+
return commonErrorHandler(err, `Error uploading file to device.`, dispatch);
|
|
1202
|
+
}).finally(() => dispatch(cleanUpUpload(uploadId)));
|
|
1203
|
+
}
|
|
1204
|
+
);
|
|
1205
|
+
var getDeviceAuth = createAppAsyncThunk(
|
|
1196
1206
|
`${sliceName3}/getDeviceAuth`,
|
|
1197
1207
|
(id, { dispatch }) => dispatch(getDevicesWithAuth([{ id }])).unwrap().then((results) => {
|
|
1198
1208
|
if (results[results.length - 1]) {
|
|
@@ -1201,64 +1211,69 @@ var getDeviceAuth = createAsyncThunk2(
|
|
|
1201
1211
|
return Promise.resolve();
|
|
1202
1212
|
})
|
|
1203
1213
|
);
|
|
1204
|
-
var getDevicesWithAuth =
|
|
1214
|
+
var getDevicesWithAuth = createAppAsyncThunk(
|
|
1205
1215
|
`${sliceName3}/getDevicesWithAuth`,
|
|
1206
1216
|
(devices, { dispatch, getState }) => devices.length ? general_api_default.get(`${deviceAuthV2}/devices?id=${devices.map((device) => device.id).join("&id=")}`).then(({ data: receivedDevices }) => {
|
|
1207
1217
|
const { devicesById } = reduceReceivedDevices(receivedDevices, [], getState());
|
|
1208
1218
|
return Promise.all([dispatch(actions3.receivedDevices(devicesById)), Promise.resolve(receivedDevices)]);
|
|
1209
1219
|
}).catch((err) => commonErrorHandler(err, `Error: ${err}`, dispatch)) : Promise.resolve([[], []])
|
|
1210
1220
|
);
|
|
1211
|
-
var updateDeviceAuth =
|
|
1221
|
+
var updateDeviceAuth = createAppAsyncThunk(
|
|
1212
1222
|
`${sliceName3}/updateDeviceAuth`,
|
|
1213
1223
|
({ 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 })))
|
|
1214
1224
|
);
|
|
1215
|
-
var updateDevicesAuth =
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1225
|
+
var updateDevicesAuth = createAppAsyncThunk(
|
|
1226
|
+
`${sliceName3}/updateDevicesAuth`,
|
|
1227
|
+
({ deviceIds, status }, { dispatch, getState }) => {
|
|
1228
|
+
let devices = getDevicesById(getState());
|
|
1229
|
+
const deviceIdsWithoutAuth = deviceIds.reduce((accu, id) => devices[id].auth_sets ? accu : [...accu, { id }], []);
|
|
1230
|
+
return dispatch(getDevicesWithAuth(deviceIdsWithoutAuth)).then(() => {
|
|
1231
|
+
devices = getDevicesById(getState());
|
|
1232
|
+
const deviceAuthUpdates = deviceIds.map((id) => {
|
|
1233
|
+
const device = devices[id];
|
|
1234
|
+
if (device.auth_sets && device.auth_sets.length !== 1) {
|
|
1235
|
+
return Promise.reject();
|
|
1236
|
+
}
|
|
1237
|
+
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));
|
|
1238
|
+
});
|
|
1239
|
+
return Promise.allSettled(deviceAuthUpdates).then((results) => {
|
|
1240
|
+
const { skipped, count } = results.reduce(
|
|
1241
|
+
(accu, item) => {
|
|
1242
|
+
if (item.status === "rejected") {
|
|
1243
|
+
accu.skipped = accu.skipped + 1;
|
|
1244
|
+
} else {
|
|
1245
|
+
accu.count = accu.count + 1;
|
|
1246
|
+
}
|
|
1247
|
+
return accu;
|
|
1248
|
+
},
|
|
1249
|
+
{ skipped: 0, count: 0 }
|
|
1250
|
+
);
|
|
1251
|
+
const message = getSnackbarMessage(skipped, count);
|
|
1252
|
+
return dispatch(setSnackbar2(message));
|
|
1253
|
+
});
|
|
1241
1254
|
});
|
|
1242
|
-
}
|
|
1243
|
-
|
|
1244
|
-
var deleteAuthset =
|
|
1255
|
+
}
|
|
1256
|
+
);
|
|
1257
|
+
var deleteAuthset = createAppAsyncThunk(
|
|
1245
1258
|
`${sliceName3}/deleteAuthset`,
|
|
1246
1259
|
({ 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 })))
|
|
1247
1260
|
);
|
|
1248
|
-
var preauthDevice =
|
|
1261
|
+
var preauthDevice = createAppAsyncThunk(
|
|
1249
1262
|
`${sliceName3}/preauthDevice`,
|
|
1250
|
-
(authset, { dispatch, rejectWithValue }) => general_api_default.post(`${deviceAuthV2}/devices`, authset).then(
|
|
1263
|
+
(authset, { dispatch, rejectWithValue }) => general_api_default.post(`${deviceAuthV2}/devices`, authset).then(
|
|
1264
|
+
() => Promise.resolve(dispatch(setSnackbar2({ message: "Device was successfully added to the preauthorization list", autoHideDuration: TIMEOUTS.fiveSeconds })))
|
|
1265
|
+
).catch((err) => {
|
|
1251
1266
|
if (err.response.status === 409) {
|
|
1252
1267
|
return rejectWithValue("A device with a matching identity data set already exists");
|
|
1253
1268
|
}
|
|
1254
1269
|
return commonErrorHandler(err, "The device could not be added:", dispatch);
|
|
1255
1270
|
})
|
|
1256
1271
|
);
|
|
1257
|
-
var decommissionDevice =
|
|
1272
|
+
var decommissionDevice = createAppAsyncThunk(
|
|
1258
1273
|
`${sliceName3}/decommissionDevice`,
|
|
1259
1274
|
({ 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 })))
|
|
1260
1275
|
);
|
|
1261
|
-
var getDeviceConfig =
|
|
1276
|
+
var getDeviceConfig = createAppAsyncThunk(
|
|
1262
1277
|
`${sliceName3}/getDeviceConfig`,
|
|
1263
1278
|
(deviceId, { dispatch }) => general_api_default.get(`${deviceConfig}/${deviceId}`).then(({ data }) => Promise.all([dispatch(actions3.receivedDevice({ id: deviceId, config: data })), Promise.resolve(data)])).catch((err) => {
|
|
1264
1279
|
if (err.response?.data?.error.status_code !== 404) {
|
|
@@ -1266,16 +1281,16 @@ var getDeviceConfig = createAsyncThunk2(
|
|
|
1266
1281
|
}
|
|
1267
1282
|
})
|
|
1268
1283
|
);
|
|
1269
|
-
var setDeviceConfig =
|
|
1284
|
+
var setDeviceConfig = createAppAsyncThunk(
|
|
1270
1285
|
`${sliceName3}/setDeviceConfig`,
|
|
1271
1286
|
({ 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))))
|
|
1272
1287
|
);
|
|
1273
|
-
var applyDeviceConfig =
|
|
1288
|
+
var applyDeviceConfig = createAppAsyncThunk(
|
|
1274
1289
|
`${sliceName3}/applyDeviceConfig`,
|
|
1275
1290
|
({ 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 }) => {
|
|
1276
1291
|
const device = getDeviceById(getState(), deviceId);
|
|
1277
1292
|
const { canManageUsers } = getUserCapabilities(getState());
|
|
1278
|
-
|
|
1293
|
+
const tasks = [
|
|
1279
1294
|
dispatch(actions3.receivedDevice({ ...device, config: { ...device.config, deployment_id: data.deployment_id } })),
|
|
1280
1295
|
new Promise((resolve) => setTimeout(() => resolve(dispatch(getSingleDeployment(data.deployment_id))), TIMEOUTS.oneSecond))
|
|
1281
1296
|
];
|
|
@@ -1286,21 +1301,24 @@ var applyDeviceConfig = createAsyncThunk2(
|
|
|
1286
1301
|
return Promise.all(tasks);
|
|
1287
1302
|
})
|
|
1288
1303
|
);
|
|
1289
|
-
var setDeviceTags =
|
|
1304
|
+
var setDeviceTags = createAppAsyncThunk(
|
|
1290
1305
|
`${sliceName3}/setDeviceTags`,
|
|
1291
1306
|
({ deviceId, tags }, { dispatch }) => (
|
|
1292
1307
|
// to prevent tag set failures, retrieve the device & use the freshest etag we can get
|
|
1293
|
-
|
|
1308
|
+
dispatch(getDeviceById2(deviceId)).unwrap().then((device) => {
|
|
1294
1309
|
const headers = device.etag ? { "If-Match": device.etag } : {};
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1310
|
+
const tagList = Object.entries(tags).map(([name, value]) => ({ name, value }));
|
|
1311
|
+
const isNameChange = tagList.some(({ name }) => name === "name");
|
|
1312
|
+
return general_api_default.put(`${inventoryApiUrl}/devices/${deviceId}/tags`, tagList, { headers }).catch((err) => commonErrorHandler(err, `There was an error setting tags for device ${deviceId}.`, dispatch, "Please check your connection.")).then(
|
|
1313
|
+
() => Promise.all([
|
|
1314
|
+
dispatch(actions3.receivedDevice({ ...device, id: deviceId, tags })),
|
|
1315
|
+
dispatch(setSnackbar2(`Device ${tagList.length === 1 && isNameChange ? "name" : "tags"} changed`))
|
|
1316
|
+
])
|
|
1317
|
+
);
|
|
1300
1318
|
})
|
|
1301
1319
|
)
|
|
1302
1320
|
);
|
|
1303
|
-
var getDeviceTwin =
|
|
1321
|
+
var getDeviceTwin = createAppAsyncThunk(`${sliceName3}/getDeviceTwin`, ({ deviceId, integration }, { dispatch, getState }) => {
|
|
1304
1322
|
let providerResult = {};
|
|
1305
1323
|
return general_api_default.get(`${iotManagerBaseURL}/devices/${deviceId}/state`).then(({ data }) => {
|
|
1306
1324
|
providerResult = { ...data, twinError: "" };
|
|
@@ -1313,7 +1331,7 @@ var getDeviceTwin = createAsyncThunk2(`${sliceName3}/getDeviceTwin`, ({ deviceId
|
|
|
1313
1331
|
Promise.resolve(dispatch(actions3.receivedDevice({ ...device, twinsByIntegration: { ...device.twinsByIntegration, ...providerResult } })));
|
|
1314
1332
|
});
|
|
1315
1333
|
});
|
|
1316
|
-
var setDeviceTwin =
|
|
1334
|
+
var setDeviceTwin = createAppAsyncThunk(
|
|
1317
1335
|
`${sliceName3}/setDeviceTwin`,
|
|
1318
1336
|
({ deviceId, integration, settings }, { dispatch, getState }) => general_api_default.put(`${iotManagerBaseURL}/devices/${deviceId}/state/${integration.id}`, { desired: settings }).catch(
|
|
1319
1337
|
(err) => commonErrorHandler(
|
|
@@ -1326,7 +1344,9 @@ var setDeviceTwin = createAsyncThunk2(
|
|
|
1326
1344
|
const { twinsByIntegration = {} } = device;
|
|
1327
1345
|
const { [integration.id]: currentState = {} } = twinsByIntegration;
|
|
1328
1346
|
return Promise.resolve(
|
|
1329
|
-
dispatch(
|
|
1347
|
+
dispatch(
|
|
1348
|
+
actions3.receivedDevice({ ...device, twinsByIntegration: { ...twinsByIntegration, [integration.id]: { ...currentState, desired: settings } } })
|
|
1349
|
+
)
|
|
1330
1350
|
);
|
|
1331
1351
|
})
|
|
1332
1352
|
);
|
|
@@ -1337,7 +1357,7 @@ var prepareSearchArguments = ({ filters, group, state, status }) => {
|
|
|
1337
1357
|
const attributes = [...defaultAttributes, getIdAttribute(state), ...selectedAttributes];
|
|
1338
1358
|
return { attributes, filterTerms };
|
|
1339
1359
|
};
|
|
1340
|
-
var getSystemDevices =
|
|
1360
|
+
var getSystemDevices = createAppAsyncThunk(`${sliceName3}/getSystemDevices`, (options, { dispatch, getState }) => {
|
|
1341
1361
|
const { id, page = defaultPage2, perPage = defaultPerPage2, sortOptions = [] } = options;
|
|
1342
1362
|
const state = getState();
|
|
1343
1363
|
const { hasFullFiltering } = getTenantCapabilities(state);
|
|
@@ -1368,7 +1388,7 @@ var getSystemDevices = createAsyncThunk2(`${sliceName3}/getSystemDevices`, (opti
|
|
|
1368
1388
|
return Promise.resolve(dispatch(actions3.receivedDevices({ ...devicesById, [id]: device })));
|
|
1369
1389
|
});
|
|
1370
1390
|
});
|
|
1371
|
-
var getGatewayDevices =
|
|
1391
|
+
var getGatewayDevices = createAppAsyncThunk(`${sliceName3}/getGatewayDevices`, (deviceId, { dispatch, getState }) => {
|
|
1372
1392
|
const state = getState();
|
|
1373
1393
|
const { attributes = {} } = getDeviceById(state, deviceId);
|
|
1374
1394
|
const { mender_gateway_system_id = "" } = attributes;
|
|
@@ -1385,53 +1405,26 @@ var getGatewayDevices = createAsyncThunk2(`${sliceName3}/getGatewayDevices`, (de
|
|
|
1385
1405
|
attributes: attributeSelection
|
|
1386
1406
|
}).then(({ data }) => {
|
|
1387
1407
|
const { ids } = reduceReceivedDevices(data, [], getState());
|
|
1388
|
-
|
|
1408
|
+
const tasks = ids.map((deviceId2) => dispatch(getDeviceInfo(deviceId2)));
|
|
1389
1409
|
tasks.push(dispatch(actions3.receivedDevice({ id: deviceId, gatewayIds: ids })));
|
|
1390
1410
|
return Promise.all(tasks);
|
|
1391
1411
|
});
|
|
1392
1412
|
});
|
|
1393
|
-
var getDevicesInBounds = createAsyncThunk2(`${sliceName3}/getDevicesInBounds`, ({ bounds, group }, { dispatch, getState }) => {
|
|
1394
|
-
const state = getState();
|
|
1395
|
-
const { filterTerms } = convertDeviceListStateToFilters({
|
|
1396
|
-
group: group === ALL_DEVICES ? void 0 : group,
|
|
1397
|
-
groups: state.devices.groups,
|
|
1398
|
-
status: DEVICE_STATES.accepted
|
|
1399
|
-
});
|
|
1400
|
-
return general_api_default.post(getSearchEndpoint(getState()), {
|
|
1401
|
-
page: 1,
|
|
1402
|
-
per_page: MAX_PAGE_SIZE,
|
|
1403
|
-
filters: filterTerms,
|
|
1404
|
-
attributes: geoAttributes,
|
|
1405
|
-
geo_bounding_box_filter: {
|
|
1406
|
-
geo_bounding_box: {
|
|
1407
|
-
location: {
|
|
1408
|
-
top_left: { lat: bounds._northEast.lat, lon: bounds._southWest.lng },
|
|
1409
|
-
bottom_right: { lat: bounds._southWest.lat, lon: bounds._northEast.lng }
|
|
1410
|
-
}
|
|
1411
|
-
}
|
|
1412
|
-
}
|
|
1413
|
-
}).then(({ data }) => {
|
|
1414
|
-
const { devicesById } = reduceReceivedDevices(data, [], getState());
|
|
1415
|
-
return Promise.resolve(dispatch(actions3.receivedDevices(devicesById)));
|
|
1416
|
-
});
|
|
1417
|
-
});
|
|
1418
1413
|
|
|
1419
1414
|
// src/onboardingSlice/thunks.ts
|
|
1420
1415
|
import { getDemoDeviceAddress } from "@northern.tech/utils/helpers";
|
|
1421
|
-
import { onboardingSteps as onboardingSteps2 } from "@northern.tech/utils/onboardingManager";
|
|
1422
1416
|
import Tracking2 from "@northern.tech/utils/tracking";
|
|
1423
|
-
import { createAsyncThunk as createAsyncThunk3 } from "@reduxjs/toolkit";
|
|
1424
1417
|
import Cookies from "universal-cookie";
|
|
1425
1418
|
var cookies = new Cookies();
|
|
1426
1419
|
var applyOnboardingFallbacks = (progress2) => {
|
|
1427
|
-
const step =
|
|
1420
|
+
const step = orderedOnboardingSteps[progress2];
|
|
1428
1421
|
if (step && step.fallbackStep) {
|
|
1429
1422
|
return step.fallbackStep;
|
|
1430
1423
|
}
|
|
1431
1424
|
return progress2;
|
|
1432
1425
|
};
|
|
1433
1426
|
var determineProgress = (acceptedDevices, pendingDevices, releases, pastDeployments) => {
|
|
1434
|
-
const steps =
|
|
1427
|
+
const steps = orderedOnboardingSteps;
|
|
1435
1428
|
let progress2 = -1;
|
|
1436
1429
|
progress2 = pendingDevices.length > 1 ? steps.findIndex((step) => step === onboardingSteps.DEVICES_PENDING_ACCEPTING_ONBOARDING) : progress2;
|
|
1437
1430
|
progress2 = acceptedDevices.length >= 1 ? steps.findIndex((step) => step === onboardingSteps.DEVICES_ACCEPTED_ONBOARDING) : progress2;
|
|
@@ -1448,14 +1441,14 @@ var deductOnboardingState = ({ devicesById, devicesByStatus, onboardingState, pa
|
|
|
1448
1441
|
const progress2 = applyOnboardingFallbacks(onboardingState.progress || determineProgress(acceptedDevices, pendingDevices, releases, pastDeployments));
|
|
1449
1442
|
return {
|
|
1450
1443
|
...onboardingState,
|
|
1451
|
-
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 ||
|
|
1444
|
+
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)),
|
|
1452
1445
|
showTips: onboardingState.showTips != null ? onboardingState.showTips : true,
|
|
1453
1446
|
deviceType,
|
|
1454
1447
|
approach: onboardingState.approach || (deviceType.some((type) => type.startsWith("qemu")) ? "virtual" : "physical"),
|
|
1455
1448
|
progress: progress2
|
|
1456
1449
|
};
|
|
1457
1450
|
};
|
|
1458
|
-
var getOnboardingState2 =
|
|
1451
|
+
var getOnboardingState2 = createAppAsyncThunk(`${sliceName4}/getOnboardingState`, (_, { dispatch, getState }) => {
|
|
1459
1452
|
const state = getState();
|
|
1460
1453
|
let onboardingState = getOnboardingState(state);
|
|
1461
1454
|
if (!onboardingState.complete) {
|
|
@@ -1479,32 +1472,32 @@ var getOnboardingState2 = createAsyncThunk3(`${sliceName4}/getOnboardingState`,
|
|
|
1479
1472
|
dispatch(saveUserSettings({ onboarding: onboardingState }))
|
|
1480
1473
|
]);
|
|
1481
1474
|
});
|
|
1482
|
-
var setOnboardingDeviceType =
|
|
1475
|
+
var setOnboardingDeviceType = createAppAsyncThunk(
|
|
1483
1476
|
`${sliceName4}/setOnboardingDeviceType`,
|
|
1484
1477
|
(value, { dispatch }) => Promise.all([dispatch(actions4.setOnboardingDeviceType(value)), dispatch(saveUserSettings({ onboarding: { deviceType: value } }))])
|
|
1485
1478
|
);
|
|
1486
|
-
var setOnboardingApproach =
|
|
1479
|
+
var setOnboardingApproach = createAppAsyncThunk(
|
|
1487
1480
|
`${sliceName4}/setOnboardingApproach`,
|
|
1488
1481
|
(value, { dispatch }) => Promise.all([dispatch(actions4.setOnboardingApproach(value)), dispatch(saveUserSettings({ onboarding: { approach: value } }))])
|
|
1489
1482
|
);
|
|
1490
|
-
var setOnboardingComplete =
|
|
1491
|
-
|
|
1483
|
+
var setOnboardingComplete = createAppAsyncThunk(`${sliceName4}/setOnboardingComplete`, (value, { dispatch }) => {
|
|
1484
|
+
const tasks = [Promise.resolve(dispatch(actions4.setOnboardingComplete(value)))];
|
|
1492
1485
|
if (value) {
|
|
1493
1486
|
tasks.push(Promise.resolve(dispatch(actions4.setShowOnboardingHelp(false))));
|
|
1494
1487
|
tasks.push(Promise.resolve(dispatch(advanceOnboarding(onboardingSteps.DEPLOYMENTS_PAST_COMPLETED))));
|
|
1495
1488
|
}
|
|
1496
1489
|
return Promise.all(tasks);
|
|
1497
1490
|
});
|
|
1498
|
-
var setOnboardingCanceled =
|
|
1491
|
+
var setOnboardingCanceled = createAppAsyncThunk(
|
|
1499
1492
|
`${sliceName4}/setOnboardingCanceled`,
|
|
1500
1493
|
(_, { dispatch }) => Promise.all([
|
|
1501
1494
|
Promise.resolve(dispatch(actions4.setShowOnboardingHelp(false))),
|
|
1502
1495
|
Promise.resolve(dispatch(actions4.setShowDismissOnboardingTipsDialog(false))),
|
|
1503
1496
|
Promise.resolve(dispatch(actions4.setOnboardingComplete(true)))
|
|
1504
|
-
]).then(() => dispatch(advanceOnboarding(onboardingSteps.DEPLOYMENTS_PAST_COMPLETED_FAILURE))).then(() => Tracking2.event({ category: "onboarding", action:
|
|
1497
|
+
]).then(() => dispatch(advanceOnboarding(onboardingSteps.DEPLOYMENTS_PAST_COMPLETED_FAILURE))).then(() => Tracking2.event({ category: "onboarding", action: onboardingSteps.ONBOARDING_CANCELED }))
|
|
1505
1498
|
);
|
|
1506
|
-
var advanceOnboarding =
|
|
1507
|
-
const steps =
|
|
1499
|
+
var advanceOnboarding = createAppAsyncThunk(`${sliceName4}/advanceOnboarding`, (stepId, { dispatch, getState }) => {
|
|
1500
|
+
const steps = orderedOnboardingSteps;
|
|
1508
1501
|
const progress2 = steps.findIndex((step) => step === getState().onboarding.progress);
|
|
1509
1502
|
const stepIndex = steps.findIndex((step) => step === stepId);
|
|
1510
1503
|
if (progress2 > stepIndex || getState().onboarding.progress === null) {
|
|
@@ -1512,21 +1505,24 @@ var advanceOnboarding = createAsyncThunk3(`${sliceName4}/advanceOnboarding`, (st
|
|
|
1512
1505
|
}
|
|
1513
1506
|
const madeProgress = steps[stepIndex + 1];
|
|
1514
1507
|
const state = { ...getOnboardingState(getState()), progress: madeProgress };
|
|
1515
|
-
state.complete = stepIndex + 1 >=
|
|
1508
|
+
state.complete = stepIndex + 1 >= orderedOnboardingSteps.findIndex((step) => step === onboardingSteps.DEPLOYMENTS_PAST_COMPLETED_FAILURE) ? true : state.complete;
|
|
1516
1509
|
Tracking2.event({ category: "onboarding", action: stepId });
|
|
1517
1510
|
return Promise.all([dispatch(actions4.setOnboardingProgress(madeProgress)), dispatch(saveUserSettings({ onboarding: state }))]);
|
|
1518
1511
|
});
|
|
1519
1512
|
|
|
1520
1513
|
// src/organizationSlice/thunks.ts
|
|
1514
|
+
import { PreviewRequest as PreviewRequestEnum } from "@northern.tech/types/MenderTypes";
|
|
1521
1515
|
import { dateRangeToUnix as dateRangeToUnix2, deepCompare as deepCompare3 } from "@northern.tech/utils/helpers";
|
|
1522
|
-
import
|
|
1516
|
+
import dayjs from "dayjs";
|
|
1517
|
+
import utc from "dayjs/plugin/utc";
|
|
1523
1518
|
import { jwtDecode } from "jwt-decode";
|
|
1524
1519
|
import hashString from "md5";
|
|
1525
1520
|
import Cookies2 from "universal-cookie";
|
|
1526
1521
|
var cookies2 = new Cookies2();
|
|
1522
|
+
dayjs.extend(utc);
|
|
1527
1523
|
var { setAnnouncement, setSnackbar: setSnackbar3 } = actions_default;
|
|
1528
1524
|
var { page: defaultPage3, perPage: defaultPerPage3 } = DEVICE_LIST_DEFAULTS;
|
|
1529
|
-
var cancelRequest =
|
|
1525
|
+
var cancelRequest = createAppAsyncThunk(`${sliceName5}/cancelRequest`, (reason, { dispatch, getState }) => {
|
|
1530
1526
|
const { id: tenantId } = getOrganization(getState());
|
|
1531
1527
|
return general_api_default.post(`${tenantadmApiUrlv2}/tenants/${tenantId}/cancel`, { reason }).then(
|
|
1532
1528
|
() => Promise.resolve(dispatch(setSnackbar3({ message: "Deactivation request was sent successfully", autoHideDuration: TIMEOUTS.fiveSeconds })))
|
|
@@ -1545,7 +1541,7 @@ var getTargetLocation = (key) => {
|
|
|
1545
1541
|
return `https://${window.location.hostname}`;
|
|
1546
1542
|
};
|
|
1547
1543
|
var devLocations = ["localhost", "docker.mender.io"];
|
|
1548
|
-
var createOrganizationTrial =
|
|
1544
|
+
var createOrganizationTrial = createAppAsyncThunk(`${sliceName5}/createOrganizationTrial`, (data, { dispatch }) => {
|
|
1549
1545
|
const { key } = locations[data.location];
|
|
1550
1546
|
const targetLocation = getTargetLocation(key);
|
|
1551
1547
|
const target = `${targetLocation}${tenantadmApiUrlv2}/tenants/trial`;
|
|
@@ -1567,36 +1563,46 @@ var createOrganizationTrial = createAsyncThunk4(`${sliceName5}/createOrganizatio
|
|
|
1567
1563
|
);
|
|
1568
1564
|
});
|
|
1569
1565
|
});
|
|
1570
|
-
var startCardUpdate =
|
|
1566
|
+
var startCardUpdate = createAppAsyncThunk(
|
|
1571
1567
|
`${sliceName5}/startCardUpdate`,
|
|
1572
1568
|
(_, { dispatch }) => general_api_default.post(`${tenantadmApiUrlv2}/billing/card`).then(({ data }) => {
|
|
1573
1569
|
dispatch(actions5.receiveSetupIntent(data.intent_id));
|
|
1574
1570
|
return Promise.resolve(data.secret);
|
|
1575
1571
|
}).catch((err) => commonErrorHandler(err, `Updating the card failed:`, dispatch))
|
|
1576
1572
|
);
|
|
1577
|
-
var confirmCardUpdate =
|
|
1573
|
+
var confirmCardUpdate = createAppAsyncThunk(
|
|
1578
1574
|
`${sliceName5}/confirmCardUpdate`,
|
|
1579
1575
|
(_, { 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))
|
|
1580
1576
|
);
|
|
1581
|
-
var getCurrentCard =
|
|
1577
|
+
var getCurrentCard = createAppAsyncThunk(
|
|
1582
1578
|
`${sliceName5}/getCurrentCard`,
|
|
1583
1579
|
(_, { dispatch }) => general_api_default.get(`${tenantadmApiUrlv2}/billing`).then((res) => {
|
|
1584
1580
|
const { last4, exp_month, exp_year, brand } = res.data.card || {};
|
|
1585
1581
|
return Promise.resolve(dispatch(actions5.receiveCurrentCard({ brand, last4, expiration: { month: exp_month, year: exp_year } })));
|
|
1586
1582
|
})
|
|
1587
1583
|
);
|
|
1588
|
-
var startUpgrade =
|
|
1584
|
+
var startUpgrade = createAppAsyncThunk(
|
|
1589
1585
|
`${sliceName5}/startUpgrade`,
|
|
1590
1586
|
(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))
|
|
1591
1587
|
);
|
|
1592
|
-
var cancelUpgrade =
|
|
1593
|
-
|
|
1588
|
+
var cancelUpgrade = createAppAsyncThunk(
|
|
1589
|
+
`${sliceName5}/cancelUpgrade`,
|
|
1590
|
+
(tenantId) => general_api_default.post(`${tenantadmApiUrlv2}/tenants/${tenantId}/upgrade/cancel`)
|
|
1591
|
+
);
|
|
1592
|
+
var completeUpgrade = createAppAsyncThunk(
|
|
1594
1593
|
`${sliceName5}/completeUpgrade`,
|
|
1595
1594
|
({ tenantId, plan, billing_profile }, { dispatch }) => general_api_default.post(`${tenantadmApiUrlv2}/tenants/${tenantId}/upgrade/complete`, { plan, billing_profile }).catch((err) => commonErrorHandler(err, `There was an error upgrading your account:`, dispatch)).then(() => Promise.all([dispatch(getDeviceLimit()), dispatch(getUserOrganization())]))
|
|
1596
1595
|
);
|
|
1597
|
-
var prepareAuditlogQuery = ({
|
|
1598
|
-
|
|
1599
|
-
|
|
1596
|
+
var prepareAuditlogQuery = ({
|
|
1597
|
+
startDate,
|
|
1598
|
+
endDate,
|
|
1599
|
+
user: userFilter,
|
|
1600
|
+
type,
|
|
1601
|
+
detail: detailFilter,
|
|
1602
|
+
sort = { direction: SORTING_OPTIONS.desc }
|
|
1603
|
+
}) => {
|
|
1604
|
+
const userId = typeof userFilter === "object" && userFilter ? userFilter.id : userFilter;
|
|
1605
|
+
const detail = typeof detailFilter === "object" && detailFilter ? detailFilter.id : detailFilter;
|
|
1600
1606
|
const { start: startUnix, end: endUnix } = dateRangeToUnix2(startDate, endDate);
|
|
1601
1607
|
const createdAfter = startDate ? `&created_after=${startUnix}` : "";
|
|
1602
1608
|
const createdBefore = endDate ? `&created_before=${endUnix}` : "";
|
|
@@ -1606,7 +1612,7 @@ var prepareAuditlogQuery = ({ startDate, endDate, user: userFilter, type, detail
|
|
|
1606
1612
|
const { direction = SORTING_OPTIONS.desc } = sort;
|
|
1607
1613
|
return `${createdAfter}${createdBefore}${userSearch}${typeSearch}${objectSearch}&sort=${direction}`;
|
|
1608
1614
|
};
|
|
1609
|
-
var getAuditLogs =
|
|
1615
|
+
var getAuditLogs = createAppAsyncThunk(`${sliceName5}/getAuditLogs`, (selectionState, { dispatch, getState }) => {
|
|
1610
1616
|
const { page, perPage } = selectionState;
|
|
1611
1617
|
const { hasAuditlogs } = getTenantCapabilities(getState());
|
|
1612
1618
|
if (!hasAuditlogs) {
|
|
@@ -1618,36 +1624,40 @@ var getAuditLogs = createAsyncThunk4(`${sliceName5}/getAuditLogs`, (selectionSta
|
|
|
1618
1624
|
return Promise.resolve(dispatch(actions5.receiveAuditLogs({ events: data, total })));
|
|
1619
1625
|
}).catch((err) => commonErrorHandler(err, `There was an error retrieving audit logs:`, dispatch));
|
|
1620
1626
|
});
|
|
1621
|
-
var getAuditLogsCsvLink =
|
|
1627
|
+
var getAuditLogsCsvLink = createAppAsyncThunk(
|
|
1622
1628
|
`${sliceName5}/getAuditLogsCsvLink`,
|
|
1623
1629
|
(_, { getState }) => Promise.resolve(`${window.location.origin}${auditLogsApiUrl}/logs/export?limit=20000${prepareAuditlogQuery(getAuditlogState(getState()))}`)
|
|
1624
1630
|
);
|
|
1625
|
-
var setAuditlogsState =
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1631
|
+
var setAuditlogsState = createAppAsyncThunk(
|
|
1632
|
+
`${sliceName5}/setAuditlogsState`,
|
|
1633
|
+
(selectionState, { dispatch, getState }) => {
|
|
1634
|
+
const currentState = getAuditlogState(getState());
|
|
1635
|
+
const nextState = {
|
|
1636
|
+
...currentState,
|
|
1637
|
+
...selectionState,
|
|
1638
|
+
sort: { ...currentState.sort, ...selectionState.sort }
|
|
1639
|
+
};
|
|
1640
|
+
const tasks = [];
|
|
1641
|
+
const { isLoading: currentLoading, selectedIssue: currentIssue, ...currentRequestState } = currentState;
|
|
1642
|
+
const { isLoading: selectionLoading, selectedIssue: selectionIssue, ...selectionRequestState } = nextState;
|
|
1643
|
+
if (!deepCompare3(currentRequestState, selectionRequestState)) {
|
|
1644
|
+
nextState.isLoading = true;
|
|
1645
|
+
tasks.push(dispatch(getAuditLogs(nextState)).finally(() => dispatch(actions5.setAuditLogState({ isLoading: false }))));
|
|
1646
|
+
}
|
|
1647
|
+
tasks.push(dispatch(actions5.setAuditLogState(nextState)));
|
|
1648
|
+
return Promise.all(tasks);
|
|
1638
1649
|
}
|
|
1639
|
-
|
|
1640
|
-
return Promise.all(tasks);
|
|
1641
|
-
});
|
|
1650
|
+
);
|
|
1642
1651
|
var tenantDataDivergedMessage = "The system detected there is a change in your plan or purchased add-ons. Please log out and log in again";
|
|
1643
|
-
var addTenant =
|
|
1644
|
-
|
|
1652
|
+
var addTenant = createAppAsyncThunk(
|
|
1653
|
+
`${sliceName5}/createTenant`,
|
|
1654
|
+
(selectionState, { dispatch }) => general_api_default.post(`${tenantadmApiUrlv2}/tenants`, selectionState).then(
|
|
1645
1655
|
() => Promise.all([
|
|
1646
1656
|
dispatch(setSnackbar3("Tenant was created successfully.")),
|
|
1647
1657
|
new Promise((resolve) => setTimeout(() => resolve(dispatch(getTenants())), TIMEOUTS.oneSecond))
|
|
1648
1658
|
])
|
|
1649
|
-
).catch((err) => commonErrorHandler(err, "There was an error creating tenant", dispatch, commonErrorFallback))
|
|
1650
|
-
|
|
1659
|
+
).catch((err) => commonErrorHandler(err, "There was an error creating tenant", dispatch, commonErrorFallback))
|
|
1660
|
+
);
|
|
1651
1661
|
var tenantListRetrieval = async (config) => {
|
|
1652
1662
|
const { page, perPage } = config;
|
|
1653
1663
|
const params = new URLSearchParams({ page, per_page: perPage }).toString();
|
|
@@ -1655,44 +1665,58 @@ var tenantListRetrieval = async (config) => {
|
|
|
1655
1665
|
const totalCount = tenantList.headers[headerNames.total] || TENANT_LIST_DEFAULT.perPage;
|
|
1656
1666
|
return [tenantList.data, Number(totalCount)];
|
|
1657
1667
|
};
|
|
1658
|
-
var getTenants =
|
|
1668
|
+
var getTenants = createAppAsyncThunk(`${sliceName5}/getTenants`, async (_, { dispatch, getState }) => {
|
|
1659
1669
|
const currentState = getTenantsList(getState());
|
|
1660
1670
|
const [tenants, pageCount] = await tenantListRetrieval(currentState);
|
|
1661
1671
|
dispatch(actions5.setTenantListState({ ...currentState, total: pageCount, tenants }));
|
|
1662
1672
|
});
|
|
1663
|
-
var setTenantsListState =
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1673
|
+
var setTenantsListState = createAppAsyncThunk(
|
|
1674
|
+
`${sliceName5}/setTenantsListState`,
|
|
1675
|
+
async (selectionState, { dispatch, getState }) => {
|
|
1676
|
+
const currentState = getTenantsList(getState());
|
|
1677
|
+
const nextState = {
|
|
1678
|
+
...currentState,
|
|
1679
|
+
...selectionState
|
|
1680
|
+
};
|
|
1681
|
+
if (!deepCompare3(currentState, selectionState)) {
|
|
1682
|
+
const [tenants, pageCount] = await tenantListRetrieval(nextState);
|
|
1683
|
+
return dispatch(actions5.setTenantListState({ ...nextState, tenants, total: pageCount }));
|
|
1684
|
+
}
|
|
1685
|
+
return dispatch(actions5.setTenantListState({ ...nextState }));
|
|
1672
1686
|
}
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1687
|
+
);
|
|
1688
|
+
var editTenantDeviceLimit = createAppAsyncThunk(
|
|
1689
|
+
`${sliceName5}/editDeviceLimit`,
|
|
1690
|
+
({ newLimit, id, name }, { dispatch }) => general_api_default.put(`${tenantadmApiUrlv2}/tenants/${id}/child`, { device_limit: newLimit, name }).catch((err) => commonErrorHandler(err, `Device Limit cannot be changed`, dispatch)).then(
|
|
1691
|
+
() => Promise.all([
|
|
1678
1692
|
dispatch(setSnackbar3("Device Limit was changed successfully")),
|
|
1679
1693
|
dispatch(getUserOrganization()),
|
|
1680
1694
|
new Promise((resolve) => setTimeout(() => resolve(dispatch(getTenants())), TIMEOUTS.oneSecond))
|
|
1681
|
-
])
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
var
|
|
1685
|
-
|
|
1695
|
+
])
|
|
1696
|
+
)
|
|
1697
|
+
);
|
|
1698
|
+
var editBillingProfile = createAppAsyncThunk(
|
|
1699
|
+
`${sliceName5}/editBillingProfileEmail`,
|
|
1700
|
+
({ billingProfile }, { dispatch }) => general_api_default.patch(`${tenantadmApiUrlv2}/billing/profile`, billingProfile).catch((err) => commonErrorHandler(err, `Failed to change billing profile`, dispatch)).then(() => Promise.all([dispatch(setSnackbar3("Billing Profile was changed successfully")), dispatch(getUserBilling())]))
|
|
1701
|
+
);
|
|
1702
|
+
var createBillingProfile = createAppAsyncThunk(
|
|
1703
|
+
`${sliceName5}/createBillingProfileEmail`,
|
|
1704
|
+
({ billingProfile }, { dispatch }) => general_api_default.post(`${tenantadmApiUrlv2}/billing/profile`, billingProfile).catch((err) => commonErrorHandler(err, `Failed to create billing profile`, dispatch)).then(() => Promise.all([dispatch(setSnackbar3("Billing Profile was created successfully")), dispatch(getUserBilling())]))
|
|
1705
|
+
);
|
|
1706
|
+
var removeTenant = createAppAsyncThunk(
|
|
1707
|
+
`${sliceName5}/editDeviceLimit`,
|
|
1708
|
+
({ id }, { dispatch }) => general_api_default.post(`${tenantadmApiUrlv2}/tenants/${id}/remove/start`).catch((err) => commonErrorHandler(err, `There was an error removing the tenant`, dispatch)).then(
|
|
1686
1709
|
() => Promise.all([
|
|
1687
1710
|
dispatch(setSnackbar3("The tenant was removed successfully")),
|
|
1688
1711
|
dispatch(getUserOrganization()),
|
|
1689
1712
|
new Promise((resolve) => setTimeout(() => resolve(dispatch(getTenants())), TIMEOUTS.oneSecond))
|
|
1690
1713
|
])
|
|
1691
|
-
)
|
|
1692
|
-
|
|
1693
|
-
var getUserOrganization =
|
|
1694
|
-
|
|
1695
|
-
|
|
1714
|
+
)
|
|
1715
|
+
);
|
|
1716
|
+
var getUserOrganization = createAppAsyncThunk(
|
|
1717
|
+
`${sliceName5}/getUserOrganization`,
|
|
1718
|
+
(_, { dispatch, getState }) => general_api_default.get(`${tenantadmApiUrlv1}/user/tenant`).then((res) => {
|
|
1719
|
+
const tasks = [dispatch(actions5.setOrganization(res.data))];
|
|
1696
1720
|
const { addons, plan, trial } = res.data;
|
|
1697
1721
|
const { token } = getCurrentSession(getState());
|
|
1698
1722
|
const jwt = jwtDecode(token);
|
|
@@ -1703,32 +1727,61 @@ var getUserOrganization = createAsyncThunk4(`${sliceName5}/getUserOrganization`,
|
|
|
1703
1727
|
tasks.push(dispatch(setAnnouncement(tenantDataDivergedMessage)));
|
|
1704
1728
|
}
|
|
1705
1729
|
return Promise.all(tasks);
|
|
1706
|
-
})
|
|
1730
|
+
})
|
|
1731
|
+
);
|
|
1732
|
+
var getUserBilling = createAppAsyncThunk(
|
|
1733
|
+
`${sliceName5}/getUserBilling`,
|
|
1734
|
+
(_, { dispatch }) => general_api_default.get(`${tenantadmApiUrlv2}/billing/profile`).then((res) => dispatch(actions5.setBillingProfile(res.data)))
|
|
1735
|
+
);
|
|
1736
|
+
var getUserSubscription = createAppAsyncThunk(`${sliceName5}/getUserSubscription`, (_, { dispatch }) => {
|
|
1737
|
+
const tasks = [dispatch(getBillingPreview({ preview_mode: PreviewRequestEnum.preview_mode.NEXT })).unwrap(), dispatch(getCurrentSubscription()).unwrap()];
|
|
1738
|
+
Promise.all(tasks).then(([currentPreview, currentSubscription]) => dispatch(actions5.setSubscription({ ...currentPreview, ...currentSubscription })));
|
|
1707
1739
|
});
|
|
1708
|
-
var
|
|
1740
|
+
var getBillingPreview = createAppAsyncThunk(
|
|
1741
|
+
`${sliceName5}/getBillingPreview`,
|
|
1742
|
+
(order) => general_api_default.post(`${tenantadmApiUrlv2}/billing/subscription/invoices/preview`, order).then(
|
|
1743
|
+
({ data }) => order.preview_mode === "recurring" ? { ...parseSubscriptionPreview(data.lines), total: data.total } : data
|
|
1744
|
+
)
|
|
1745
|
+
);
|
|
1746
|
+
var getCurrentSubscription = createAppAsyncThunk(
|
|
1747
|
+
`${sliceName5}/getCurrentSubscription`,
|
|
1748
|
+
() => general_api_default.get(`${tenantadmApiUrlv2}/billing/subscription`).then((res) => res.data)
|
|
1749
|
+
);
|
|
1750
|
+
var successMessage = (planId) => `Thank you! You have successfully subscribed to the ${PLANS[planId].name} plan. You can view and edit your billing details on the Organization and billing page.`;
|
|
1751
|
+
var requestPlanUpgrade = createAppAsyncThunk(
|
|
1752
|
+
`${sliceName5}/requestPlanUpgrade`,
|
|
1753
|
+
(order, { dispatch }) => general_api_default.post(`${tenantadmApiUrlv2}/billing/subscription`, order).catch((err) => commonErrorHandler(err, "There was an error sending your request", dispatch, commonErrorFallback)).then(
|
|
1754
|
+
() => Promise.all([
|
|
1755
|
+
dispatch(setSnackbar3(successMessage(order.plan))),
|
|
1756
|
+
setTimeout(() => dispatch(getDeviceLimit()), TIMEOUTS.threeSeconds),
|
|
1757
|
+
dispatch(getUserOrganization())
|
|
1758
|
+
])
|
|
1759
|
+
)
|
|
1760
|
+
);
|
|
1761
|
+
var sendSupportMessage = createAppAsyncThunk(
|
|
1709
1762
|
`${sliceName5}/sendSupportMessage`,
|
|
1710
1763
|
(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 }))))
|
|
1711
1764
|
);
|
|
1712
|
-
var requestPlanChange =
|
|
1765
|
+
var requestPlanChange = createAppAsyncThunk(
|
|
1713
1766
|
`${sliceName5}/requestPlanChange`,
|
|
1714
1767
|
({ content, tenantId }, { dispatch, rejectWithValue }) => general_api_default.post(`${tenantadmApiUrlv2}/tenants/${tenantId}/plan`, content).catch(async (err) => {
|
|
1715
1768
|
await commonErrorHandler(err, "There was an error sending your request", dispatch, commonErrorFallback);
|
|
1716
1769
|
rejectWithValue(err);
|
|
1717
1770
|
}).then(() => Promise.resolve(dispatch(setSnackbar3({ message: "Your request was sent successfully", autoHideDuration: TIMEOUTS.fiveSeconds }))))
|
|
1718
1771
|
);
|
|
1719
|
-
var downloadLicenseReport =
|
|
1772
|
+
var downloadLicenseReport = createAppAsyncThunk(
|
|
1720
1773
|
`${sliceName5}/downloadLicenseReport`,
|
|
1721
1774
|
(_, { 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)
|
|
1722
1775
|
);
|
|
1723
|
-
var createIntegration =
|
|
1776
|
+
var createIntegration = createAppAsyncThunk(
|
|
1724
1777
|
`${sliceName5}/createIntegration`,
|
|
1725
1778
|
({ id, ...integration }, { dispatch }) => 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())]))
|
|
1726
1779
|
);
|
|
1727
|
-
var changeIntegration =
|
|
1780
|
+
var changeIntegration = createAppAsyncThunk(
|
|
1728
1781
|
`${sliceName5}/changeIntegration`,
|
|
1729
1782
|
({ 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())]))
|
|
1730
1783
|
);
|
|
1731
|
-
var deleteIntegration =
|
|
1784
|
+
var deleteIntegration = createAppAsyncThunk(
|
|
1732
1785
|
`${sliceName5}/deleteIntegration`,
|
|
1733
1786
|
({ 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(() => {
|
|
1734
1787
|
const integrations = getState().organization.externalDeviceIntegrations.filter((item) => provider !== item.provider);
|
|
@@ -1738,7 +1791,7 @@ var deleteIntegration = createAsyncThunk4(
|
|
|
1738
1791
|
]);
|
|
1739
1792
|
})
|
|
1740
1793
|
);
|
|
1741
|
-
var getIntegrations =
|
|
1794
|
+
var getIntegrations = createAppAsyncThunk(
|
|
1742
1795
|
`${sliceName5}/getIntegrations`,
|
|
1743
1796
|
(_, { dispatch, getState }) => general_api_default.get(`${iotManagerBaseURL}/integrations`).catch((err) => commonErrorHandler(err, "There was an error retrieving the integration", dispatch, commonErrorFallback)).then(({ data }) => {
|
|
1744
1797
|
const existingIntegrations = getState().organization.externalDeviceIntegrations;
|
|
@@ -1751,10 +1804,10 @@ var getIntegrations = createAsyncThunk4(
|
|
|
1751
1804
|
return Promise.resolve(dispatch(actions5.receiveExternalDeviceIntegrations(integrations)));
|
|
1752
1805
|
})
|
|
1753
1806
|
);
|
|
1754
|
-
var getWebhookEvents =
|
|
1807
|
+
var getWebhookEvents = createAppAsyncThunk(`${sliceName5}/getWebhookEvents`, (config = {}, { dispatch, getState }) => {
|
|
1755
1808
|
const { isFollowUp, page = defaultPage3, perPage = defaultPerPage3 } = config;
|
|
1756
1809
|
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 }) => {
|
|
1757
|
-
|
|
1810
|
+
const tasks = [
|
|
1758
1811
|
dispatch(
|
|
1759
1812
|
actions5.receiveWebhookEvents({
|
|
1760
1813
|
value: isFollowUp ? getState().organization.webhooks.events : data,
|
|
@@ -1777,29 +1830,29 @@ var ssoConfigActions = {
|
|
|
1777
1830
|
};
|
|
1778
1831
|
var ssoConfigActionErrorHandler = (err, type) => (dispatch) => commonErrorHandler(err, `There was an error ${ssoConfigActions[type].error} the SSO configuration.`, dispatch, commonErrorFallback);
|
|
1779
1832
|
var ssoConfigActionSuccessHandler = (type) => (dispatch) => dispatch(setSnackbar3(`The SSO configuration was ${ssoConfigActions[type].success} successfully`));
|
|
1780
|
-
var storeSsoConfig =
|
|
1833
|
+
var storeSsoConfig = createAppAsyncThunk(
|
|
1781
1834
|
`${sliceName5}/storeSsoConfig`,
|
|
1782
1835
|
({ 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())]))
|
|
1783
1836
|
);
|
|
1784
|
-
var changeSsoConfig =
|
|
1837
|
+
var changeSsoConfig = createAppAsyncThunk(
|
|
1785
1838
|
`${sliceName5}/changeSsoConfig`,
|
|
1786
1839
|
({ 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())]))
|
|
1787
1840
|
);
|
|
1788
|
-
var deleteSsoConfig =
|
|
1841
|
+
var deleteSsoConfig = createAppAsyncThunk(
|
|
1789
1842
|
`${sliceName5}/deleteSsoConfig`,
|
|
1790
1843
|
({ id }, { dispatch, getState }) => general_api_default.delete(`${ssoIdpApiUrlv1}/${id}`).catch((err) => dispatch(ssoConfigActionErrorHandler(err, "remove"))).then(() => {
|
|
1791
1844
|
const configs = getState().organization.ssoConfigs.filter((item) => id !== item.id);
|
|
1792
1845
|
return Promise.all([dispatch(ssoConfigActionSuccessHandler("remove")), dispatch(actions5.receiveSsoConfigs(configs))]);
|
|
1793
1846
|
})
|
|
1794
1847
|
);
|
|
1795
|
-
var getSsoConfigById =
|
|
1848
|
+
var getSsoConfigById = createAppAsyncThunk(
|
|
1796
1849
|
`${sliceName5}/getSsoConfigById`,
|
|
1797
1850
|
(config, { dispatch }) => general_api_default.get(`${ssoIdpApiUrlv1}/${config.id}`).catch((err) => dispatch(ssoConfigActionErrorHandler(err, "read"))).then(({ data, headers }) => {
|
|
1798
1851
|
const sso = Object.values(SSO_TYPES).find(({ contentType }) => contentType === headers["content-type"]);
|
|
1799
1852
|
return sso ? Promise.resolve({ ...config, config: data, type: sso.id }) : Promise.reject("Unsupported SSO config content type.");
|
|
1800
1853
|
})
|
|
1801
1854
|
);
|
|
1802
|
-
var getSsoConfigs =
|
|
1855
|
+
var getSsoConfigs = createAppAsyncThunk(
|
|
1803
1856
|
`${sliceName5}/getSsoConfigs`,
|
|
1804
1857
|
(_, { dispatch }) => general_api_default.get(ssoIdpApiUrlv1).catch((err) => dispatch(ssoConfigActionErrorHandler(err, "readMultiple"))).then(
|
|
1805
1858
|
({ data }) => Promise.all(data.map((config) => dispatch(getSsoConfigById(config)).unwrap())).then((configs) => dispatch(actions5.receiveSsoConfigs(configs))).catch((err) => commonErrorHandler(err, err, dispatch, ""))
|
|
@@ -1807,15 +1860,13 @@ var getSsoConfigs = createAsyncThunk4(
|
|
|
1807
1860
|
);
|
|
1808
1861
|
|
|
1809
1862
|
// src/usersSlice/thunks.ts
|
|
1810
|
-
import {
|
|
1811
|
-
import { duplicateFilter, extractErrorMessage as extractErrorMessage2, isEmpty as isEmpty2, preformatWithRequestID } from "@northern.tech/utils/helpers";
|
|
1863
|
+
import { duplicateFilter, extractErrorMessage as extractErrorMessage2, isEmpty as isEmpty2 } from "@northern.tech/utils/helpers";
|
|
1812
1864
|
import { clearAllRetryTimers } from "@northern.tech/utils/retrytimer";
|
|
1813
|
-
import { createAsyncThunk as createAsyncThunk5 } from "@reduxjs/toolkit";
|
|
1814
1865
|
import hashString2 from "md5";
|
|
1815
1866
|
import Cookies3 from "universal-cookie";
|
|
1816
1867
|
var cookies3 = new Cookies3();
|
|
1817
1868
|
var { setAnnouncement: setAnnouncement2, setSnackbar: setSnackbar4 } = actions_default;
|
|
1818
|
-
var handleLoginError = (err, { token2fa: has2FA, password }, rejectWithValue) => (
|
|
1869
|
+
var handleLoginError = (err, { token2fa: has2FA, password }, rejectWithValue) => () => {
|
|
1819
1870
|
const errorText = extractErrorMessage2(err);
|
|
1820
1871
|
const is2FABackend = errorText.includes("2fa");
|
|
1821
1872
|
if (is2FABackend && !has2FA) {
|
|
@@ -1826,26 +1877,25 @@ var handleLoginError = (err, { token2fa: has2FA, password }, rejectWithValue) =>
|
|
|
1826
1877
|
}
|
|
1827
1878
|
const twoFAError = is2FABackend ? " and verification code" : "";
|
|
1828
1879
|
const errorMessage = `There was a problem logging in. Please check your email${twoFAError ? "," : " and"} password${twoFAError}. If you still have problems, contact an administrator.`;
|
|
1829
|
-
return
|
|
1880
|
+
return rejectWithValue({ error: errorMessage });
|
|
1830
1881
|
};
|
|
1831
|
-
var loginUser =
|
|
1882
|
+
var loginUser = createAppAsyncThunk(
|
|
1832
1883
|
`${sliceName6}/loginUser`,
|
|
1833
|
-
({ stayLoggedIn, ...userData }, { dispatch, rejectWithValue }) => users_api_default.postLogin(`${
|
|
1884
|
+
({ stayLoggedIn, ...userData }, { dispatch, rejectWithValue }) => users_api_default.postLogin(`${useradmApiUrl}/auth/login`, { ...userData, no_expiry: stayLoggedIn }).catch((err) => {
|
|
1834
1885
|
cleanUp();
|
|
1835
1886
|
return Promise.reject(dispatch(handleLoginError(err, userData, rejectWithValue)));
|
|
1836
|
-
}).then(({ text:
|
|
1887
|
+
}).then(({ text: token, contentType }) => {
|
|
1837
1888
|
if (contentType.includes(APPLICATION_JSON_CONTENT_TYPE)) {
|
|
1838
|
-
const { id, kind } =
|
|
1889
|
+
const { id, kind } = token;
|
|
1839
1890
|
const type = kind.split("/")[1];
|
|
1840
1891
|
const ssoLoginUrl = SSO_TYPES[type].getStartUrl(id);
|
|
1841
1892
|
window.location.replace(ssoLoginUrl);
|
|
1842
1893
|
return;
|
|
1843
1894
|
}
|
|
1844
|
-
const token = response;
|
|
1845
1895
|
if (contentType !== APPLICATION_JWT_CONTENT_TYPE || !token) {
|
|
1846
1896
|
return;
|
|
1847
1897
|
}
|
|
1848
|
-
|
|
1898
|
+
const now = /* @__PURE__ */ new Date();
|
|
1849
1899
|
now.setSeconds(now.getSeconds() + maxSessionAge);
|
|
1850
1900
|
const expiresAt = stayLoggedIn ? void 0 : now.toISOString();
|
|
1851
1901
|
setSessionInfo({ token, expiresAt });
|
|
@@ -1862,35 +1912,35 @@ var loginUser = createAsyncThunk5(
|
|
|
1862
1912
|
});
|
|
1863
1913
|
})
|
|
1864
1914
|
);
|
|
1865
|
-
var logoutUser =
|
|
1915
|
+
var logoutUser = createAppAsyncThunk(`${sliceName6}/logoutUser`, (_, { dispatch, getState }) => {
|
|
1866
1916
|
if (Object.keys(getState().app.uploadsById).length) {
|
|
1867
1917
|
return Promise.reject();
|
|
1868
1918
|
}
|
|
1869
|
-
return general_api_default.post(`${
|
|
1919
|
+
return general_api_default.post(`${useradmApiUrl}/auth/logout`).finally(() => {
|
|
1870
1920
|
cleanUp();
|
|
1871
1921
|
clearAllRetryTimers(setSnackbar4);
|
|
1872
1922
|
return Promise.resolve(dispatch({ type: USER_LOGOUT }));
|
|
1873
1923
|
});
|
|
1874
1924
|
});
|
|
1875
|
-
var switchUserOrganization =
|
|
1925
|
+
var switchUserOrganization = createAppAsyncThunk(`${sliceName6}/switchUserOrganization`, (tenantId, { getState }) => {
|
|
1876
1926
|
if (Object.keys(getState().app.uploadsById).length) {
|
|
1877
1927
|
return Promise.reject();
|
|
1878
1928
|
}
|
|
1879
|
-
return general_api_default.get(`${
|
|
1929
|
+
return general_api_default.get(`${useradmApiUrl}/users/tenants/${tenantId}/token`).then(({ data: token }) => {
|
|
1880
1930
|
window.sessionStorage.setItem("tenantChanged", "true");
|
|
1881
1931
|
setSessionInfo({ ...getSessionInfo(), token });
|
|
1882
1932
|
window.location.reload();
|
|
1883
1933
|
});
|
|
1884
1934
|
});
|
|
1885
|
-
var passwordResetStart =
|
|
1935
|
+
var passwordResetStart = createAppAsyncThunk(
|
|
1886
1936
|
`${sliceName6}/passwordResetStart`,
|
|
1887
|
-
(email, { dispatch }) => general_api_default.post(`${
|
|
1937
|
+
(email, { dispatch }) => general_api_default.post(`${useradmApiUrl}/auth/password-reset/start`, { email }).catch(
|
|
1888
1938
|
(err) => commonErrorHandler(err, `The password reset request cannot be processed:`, dispatch, void 0, true)
|
|
1889
1939
|
)
|
|
1890
1940
|
);
|
|
1891
|
-
var passwordResetComplete =
|
|
1941
|
+
var passwordResetComplete = createAppAsyncThunk(
|
|
1892
1942
|
`${sliceName6}/passwordResetComplete`,
|
|
1893
|
-
({ secretHash, newPassword }, { dispatch }) => general_api_default.post(`${
|
|
1943
|
+
({ secretHash, newPassword }, { dispatch }) => general_api_default.post(`${useradmApiUrl}/auth/password-reset/complete`, { secret_hash: secretHash, password: newPassword }).catch((err = {}) => {
|
|
1894
1944
|
const { error, response = {} } = err;
|
|
1895
1945
|
let errorMsg = "";
|
|
1896
1946
|
if (response.status == 400) {
|
|
@@ -1902,23 +1952,23 @@ var passwordResetComplete = createAsyncThunk5(
|
|
|
1902
1952
|
return Promise.reject(err);
|
|
1903
1953
|
})
|
|
1904
1954
|
);
|
|
1905
|
-
var verifyEmailStart =
|
|
1955
|
+
var verifyEmailStart = createAppAsyncThunk(
|
|
1906
1956
|
`${sliceName6}/verifyEmailStart`,
|
|
1907
|
-
(_, { dispatch, getState }) => general_api_default.post(`${
|
|
1957
|
+
(_, { dispatch, getState }) => general_api_default.post(`${useradmApiUrl}/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))))
|
|
1908
1958
|
);
|
|
1909
|
-
var verifyEmailComplete =
|
|
1959
|
+
var verifyEmailComplete = createAppAsyncThunk(
|
|
1910
1960
|
`${sliceName6}/verifyEmailComplete`,
|
|
1911
|
-
(secret_hash, { dispatch }) => general_api_default.post(`${
|
|
1961
|
+
(secret_hash, { dispatch }) => general_api_default.post(`${useradmApiUrl}/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))))
|
|
1912
1962
|
);
|
|
1913
|
-
var verify2FA =
|
|
1963
|
+
var verify2FA = createAppAsyncThunk(
|
|
1914
1964
|
`${sliceName6}/verify2FA`,
|
|
1915
|
-
(tfaData, { dispatch }) => users_api_default.putVerifyTFA(`${
|
|
1965
|
+
(tfaData, { dispatch }) => users_api_default.putVerifyTFA(`${useradmApiUrl}/2faverify`, tfaData).then(() => Promise.resolve(dispatch(getUser(OWN_USER_ID)))).catch(
|
|
1916
1966
|
(err) => commonErrorHandler(err, "An error occured validating the verification code: failed to verify token, please try again.", dispatch, void 0, true)
|
|
1917
1967
|
)
|
|
1918
1968
|
);
|
|
1919
|
-
var getUserList =
|
|
1969
|
+
var getUserList = createAppAsyncThunk(
|
|
1920
1970
|
`${sliceName6}/getUserList`,
|
|
1921
|
-
(_, { dispatch, getState }) => general_api_default.get(`${
|
|
1971
|
+
(_, { dispatch, getState }) => general_api_default.get(`${useradmApiUrl}/users`).then((res) => {
|
|
1922
1972
|
const currentUsersById = getUsersById(getState());
|
|
1923
1973
|
const users = res.data.reduce(
|
|
1924
1974
|
(accu, item) => {
|
|
@@ -1933,9 +1983,9 @@ var getUserList = createAsyncThunk5(
|
|
|
1933
1983
|
return dispatch(actions6.receivedUserList(users));
|
|
1934
1984
|
}).catch((err) => commonErrorHandler(err, `Users couldn't be loaded.`, dispatch, commonErrorFallback))
|
|
1935
1985
|
);
|
|
1936
|
-
var getUser =
|
|
1986
|
+
var getUser = createAppAsyncThunk(
|
|
1937
1987
|
`${sliceName6}/getUser`,
|
|
1938
|
-
(id, { dispatch, rejectWithValue }) => general_api_default.get(`${
|
|
1988
|
+
(id, { dispatch, rejectWithValue }) => general_api_default.get(`${useradmApiUrl}/users/${id}`).then(
|
|
1939
1989
|
({ data: user }) => Promise.all([
|
|
1940
1990
|
dispatch(actions6.receivedUser(user)),
|
|
1941
1991
|
dispatch(setHideAnnouncement({ shouldHide: false, userId: user.id })),
|
|
@@ -1944,22 +1994,25 @@ var getUser = createAsyncThunk5(
|
|
|
1944
1994
|
])
|
|
1945
1995
|
).catch((e) => rejectWithValue(e))
|
|
1946
1996
|
);
|
|
1947
|
-
var initializeSelf =
|
|
1948
|
-
var updateUserColumnSettings =
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1997
|
+
var initializeSelf = createAppAsyncThunk(`${sliceName6}/initializeSelf`, (_, { dispatch }) => dispatch(getUser(OWN_USER_ID)));
|
|
1998
|
+
var updateUserColumnSettings = createAppAsyncThunk(
|
|
1999
|
+
`${sliceName6}/updateUserColumnSettings`,
|
|
2000
|
+
({ columns, currentUserId }, { dispatch, getState }) => {
|
|
2001
|
+
const userId = currentUserId ?? getCurrentUser(getState()).id;
|
|
2002
|
+
const storageKey = `${userId}-column-widths`;
|
|
2003
|
+
let customColumns = [];
|
|
2004
|
+
if (!columns) {
|
|
2005
|
+
try {
|
|
2006
|
+
customColumns = JSON.parse(window.localStorage.getItem(storageKey) || "") || customColumns;
|
|
2007
|
+
} catch {
|
|
2008
|
+
}
|
|
2009
|
+
} else {
|
|
2010
|
+
customColumns = columns;
|
|
1956
2011
|
}
|
|
1957
|
-
|
|
1958
|
-
customColumns
|
|
2012
|
+
window.localStorage.setItem(storageKey, JSON.stringify(customColumns));
|
|
2013
|
+
return Promise.resolve(dispatch(actions6.setCustomColumns(customColumns)));
|
|
1959
2014
|
}
|
|
1960
|
-
|
|
1961
|
-
return Promise.resolve(dispatch(actions6.setCustomColumns(customColumns)));
|
|
1962
|
-
});
|
|
2015
|
+
);
|
|
1963
2016
|
var userActions = {
|
|
1964
2017
|
add: {
|
|
1965
2018
|
successMessage: "The user was added successfully.",
|
|
@@ -1979,34 +2032,34 @@ var userActions = {
|
|
|
1979
2032
|
}
|
|
1980
2033
|
};
|
|
1981
2034
|
var userActionErrorHandler = (err, type, dispatch) => commonErrorHandler(err, `There was an error ${userActions[type].errorMessage} the user.`, dispatch);
|
|
1982
|
-
var createUser =
|
|
2035
|
+
var createUser = createAppAsyncThunk(
|
|
1983
2036
|
`${sliceName6}/createUser`,
|
|
1984
|
-
({ shouldResetPassword, ...userData }, { dispatch }) => general_api_default.post(`${
|
|
2037
|
+
({ shouldResetPassword, ...userData }, { dispatch }) => general_api_default.post(`${useradmApiUrl}/users`, { ...userData, send_reset_password: shouldResetPassword }).then(() => Promise.all([dispatch(getUserList()), dispatch(setSnackbar4(userActions.create.successMessage))])).catch((err) => userActionErrorHandler(err, "create", dispatch))
|
|
1985
2038
|
);
|
|
1986
|
-
var removeUser =
|
|
2039
|
+
var removeUser = createAppAsyncThunk(
|
|
1987
2040
|
`${sliceName6}/removeUser`,
|
|
1988
|
-
(userId, { dispatch }) => general_api_default.delete(`${
|
|
2041
|
+
(userId, { dispatch }) => general_api_default.delete(`${useradmApiUrl}/users/${userId}`).then(() => Promise.all([dispatch(actions6.removedUser(userId)), dispatch(getUserList()), dispatch(setSnackbar4(userActions.remove.successMessage))])).catch((err) => userActionErrorHandler(err, "remove", dispatch))
|
|
1989
2042
|
);
|
|
1990
|
-
var editUser =
|
|
2043
|
+
var editUser = createAppAsyncThunk(
|
|
1991
2044
|
`${sliceName6}/editUser`,
|
|
1992
|
-
({ id, ...userData }, { dispatch, getState }) => general_api_default.put(`${
|
|
2045
|
+
({ id, ...userData }, { dispatch, getState }) => general_api_default.put(`${useradmApiUrl}/users/${id}`, userData).then(
|
|
1993
2046
|
() => Promise.all([
|
|
1994
2047
|
dispatch(actions6.updatedUser({ ...userData, id: id === OWN_USER_ID ? getCurrentUser(getState()).id : id })),
|
|
1995
2048
|
dispatch(setSnackbar4(userActions.edit.successMessage))
|
|
1996
2049
|
])
|
|
1997
|
-
)
|
|
2050
|
+
).catch((err) => userActionErrorHandler(err, "edit", dispatch))
|
|
1998
2051
|
);
|
|
1999
|
-
var addUserToCurrentTenant =
|
|
2052
|
+
var addUserToCurrentTenant = createAppAsyncThunk(`${sliceName6}/addUserToTenant`, (userId, { dispatch, getState }) => {
|
|
2000
2053
|
const { id } = getOrganization(getState());
|
|
2001
|
-
return general_api_default.post(`${
|
|
2054
|
+
return general_api_default.post(`${useradmApiUrl}/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())]));
|
|
2002
2055
|
});
|
|
2003
|
-
var enableUser2fa =
|
|
2056
|
+
var enableUser2fa = createAppAsyncThunk(
|
|
2004
2057
|
`${sliceName6}/enableUser2fa`,
|
|
2005
|
-
(userId = OWN_USER_ID, { dispatch }) => general_api_default.post(`${
|
|
2058
|
+
(userId = OWN_USER_ID, { dispatch }) => general_api_default.post(`${useradmApiUrl}/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))))
|
|
2006
2059
|
);
|
|
2007
|
-
var disableUser2fa =
|
|
2060
|
+
var disableUser2fa = createAppAsyncThunk(
|
|
2008
2061
|
`${sliceName6}/disableUser2fa`,
|
|
2009
|
-
(userId = OWN_USER_ID, { dispatch }) => general_api_default.post(`${
|
|
2062
|
+
(userId = OWN_USER_ID, { dispatch }) => general_api_default.post(`${useradmApiUrl}/users/${userId}/2fa/disable`).catch((err) => commonErrorHandler(err, `There was an error disabling Two Factor authentication for the user.`, dispatch)).then(() => Promise.all([dispatch(getUser(userId)), dispatch(actions6.receivedQrCode(null))]))
|
|
2010
2063
|
);
|
|
2011
2064
|
var mapHttpPermission = (permission) => Object.entries(uiPermissionsByArea).reduce(
|
|
2012
2065
|
(accu, [area, definition]) => {
|
|
@@ -2046,7 +2099,7 @@ var permissionActionTypes = {
|
|
|
2046
2099
|
} : {}
|
|
2047
2100
|
};
|
|
2048
2101
|
var combinePermissions = (existingPermissions, additionalPermissions = {}) => Object.entries(additionalPermissions).reduce((accu, [name, permissions]) => {
|
|
2049
|
-
|
|
2102
|
+
const maybeExistingPermissions = accu[name] || [];
|
|
2050
2103
|
accu[name] = [...permissions, ...maybeExistingPermissions].filter(duplicateFilter);
|
|
2051
2104
|
return accu;
|
|
2052
2105
|
}, existingPermissions);
|
|
@@ -2056,7 +2109,7 @@ var tryParseCustomPermission = (permission) => {
|
|
|
2056
2109
|
return { isCustom: true, permission, result };
|
|
2057
2110
|
};
|
|
2058
2111
|
var customPermissionHandler = (accu, permission) => {
|
|
2059
|
-
|
|
2112
|
+
const processor = tryParseCustomPermission(permission);
|
|
2060
2113
|
return {
|
|
2061
2114
|
...accu,
|
|
2062
2115
|
isCustom: accu.isCustom || processor.isCustom,
|
|
@@ -2064,7 +2117,7 @@ var customPermissionHandler = (accu, permission) => {
|
|
|
2064
2117
|
};
|
|
2065
2118
|
};
|
|
2066
2119
|
var mapPermissionSet = (permissionSetName, names, scope, existingGroupsPermissions = {}) => {
|
|
2067
|
-
const permission = Object.values(uiPermissionsById).find((permission2) => permission2.permissionSets[scope] === permissionSetName)
|
|
2120
|
+
const permission = Object.values(uiPermissionsById).find((permission2) => permission2.permissionSets[scope] === permissionSetName)?.value;
|
|
2068
2121
|
const scopedPermissions = names.reduce((accu, name) => combinePermissions(accu, { [name]: [permission] }), existingGroupsPermissions);
|
|
2069
2122
|
return Object.entries(scopedPermissions).reduce((accu, [key, permissions]) => ({ ...accu, [key]: deriveImpliedAreaPermissions(scope, permissions) }), {});
|
|
2070
2123
|
};
|
|
@@ -2077,16 +2130,21 @@ var isEmptyPermissionSet = (permissionSet) => !Object.values(permissionSet).redu
|
|
|
2077
2130
|
var parseRolePermissions = ({ permission_sets_with_scope = [], permissions = [] }, permissionSets) => {
|
|
2078
2131
|
const preliminaryResult = permission_sets_with_scope.reduce(
|
|
2079
2132
|
(accu, permissionSet) => {
|
|
2080
|
-
|
|
2133
|
+
const processor = permissionSets[permissionSet.name];
|
|
2081
2134
|
if (!processor) {
|
|
2082
2135
|
return accu;
|
|
2083
2136
|
}
|
|
2084
2137
|
const scope = Object.keys(scopedPermissionAreas).find((scope2) => uiPermissionsByArea[scope2].scope === permissionSet.scope?.type);
|
|
2085
2138
|
if (scope) {
|
|
2086
|
-
const result = mapPermissionSet(
|
|
2139
|
+
const result = mapPermissionSet(
|
|
2140
|
+
permissionSet.name,
|
|
2141
|
+
permissionSet.scope.value,
|
|
2142
|
+
scope,
|
|
2143
|
+
accu.uiPermissions[scope]
|
|
2144
|
+
);
|
|
2087
2145
|
return { ...accu, uiPermissions: { ...accu.uiPermissions, [scope]: result } };
|
|
2088
2146
|
} else if (isEmptyPermissionSet(processor.result)) {
|
|
2089
|
-
return processor.permissions
|
|
2147
|
+
return processor.permissions?.reduce(customPermissionHandler, accu);
|
|
2090
2148
|
}
|
|
2091
2149
|
return {
|
|
2092
2150
|
...accu,
|
|
@@ -2127,7 +2185,7 @@ var normalizeRbacRoles = (roles, rolesById2, permissionSets) => roles.reduce(
|
|
|
2127
2185
|
},
|
|
2128
2186
|
{ ...rolesById2 }
|
|
2129
2187
|
);
|
|
2130
|
-
var getPermissionSets =
|
|
2188
|
+
var getPermissionSets = createAppAsyncThunk(
|
|
2131
2189
|
`${sliceName6}/getPermissionSets`,
|
|
2132
2190
|
(_, { dispatch, getState }) => general_api_default.get(`${useradmApiUrlv2}/permission_sets?per_page=500`).then(({ data }) => {
|
|
2133
2191
|
const permissionSets = data.reduce(
|
|
@@ -2153,7 +2211,10 @@ var getPermissionSets = createAsyncThunk5(
|
|
|
2153
2211
|
return accu2;
|
|
2154
2212
|
}, []);
|
|
2155
2213
|
permissionSetObject = scopes.reduce((accu2, scope) => {
|
|
2156
|
-
accu2.result
|
|
2214
|
+
accu2.result = {
|
|
2215
|
+
...accu2.result,
|
|
2216
|
+
[scope]: mapPermissionSet(permissionSetObject.name, [scopedPermissionAreas[scope].excessiveAccessSelector], scope)
|
|
2217
|
+
};
|
|
2157
2218
|
return accu2;
|
|
2158
2219
|
}, permissionSetObject);
|
|
2159
2220
|
accu[permissionSet.name] = permissionSetObject;
|
|
@@ -2164,7 +2225,7 @@ var getPermissionSets = createAsyncThunk5(
|
|
|
2164
2225
|
return Promise.all([dispatch(actions6.receivedPermissionSets(permissionSets)), permissionSets]);
|
|
2165
2226
|
}).catch(() => console.log("Permission set retrieval failed - likely accessing a non-RBAC backend"))
|
|
2166
2227
|
);
|
|
2167
|
-
var getRoles =
|
|
2228
|
+
var getRoles = createAppAsyncThunk(
|
|
2168
2229
|
`${sliceName6}/getRoles`,
|
|
2169
2230
|
(_, { dispatch, getState }) => Promise.all([general_api_default.get(`${useradmApiUrlv2}/roles?per_page=500`), dispatch(getPermissionSets())]).then((results) => {
|
|
2170
2231
|
if (!results) {
|
|
@@ -2173,7 +2234,7 @@ var getRoles = createAsyncThunk5(
|
|
|
2173
2234
|
const [{ data: roles }, { payload: permissionSetTasks }] = results;
|
|
2174
2235
|
const rolesById2 = normalizeRbacRoles(roles, getRolesById(getState()), permissionSetTasks[permissionSetTasks.length - 1]);
|
|
2175
2236
|
return Promise.resolve(dispatch(actions6.receivedRoles(rolesById2)));
|
|
2176
|
-
}).catch(() => console.log("Role retrieval failed - likely accessing a non-RBAC backend"))
|
|
2237
|
+
}).catch(() => console.log("Role retrieval failed - likely accessing a non-RBAC backend")).finally(() => Promise.resolve(dispatch(actions6.finishedRoleInitialization(true))))
|
|
2177
2238
|
);
|
|
2178
2239
|
var deriveImpliedAreaPermissions = (area, areaPermissions, skipPermissions = []) => {
|
|
2179
2240
|
const highestAreaPermissionLevelSelected = areaPermissions.reduce(
|
|
@@ -2243,7 +2304,13 @@ var transformRoleDataToRole = (roleData, roleState = {}) => {
|
|
|
2243
2304
|
if (!uiPermissions[key]) {
|
|
2244
2305
|
return accu;
|
|
2245
2306
|
}
|
|
2246
|
-
accu.push(
|
|
2307
|
+
accu.push(
|
|
2308
|
+
...transformAreaRoleDataToScopedPermissionsSets(
|
|
2309
|
+
key,
|
|
2310
|
+
uiPermissions[key],
|
|
2311
|
+
excessiveAccessSelector
|
|
2312
|
+
)
|
|
2313
|
+
);
|
|
2247
2314
|
return accu;
|
|
2248
2315
|
}, []);
|
|
2249
2316
|
return {
|
|
@@ -2251,7 +2318,7 @@ var transformRoleDataToRole = (roleData, roleState = {}) => {
|
|
|
2251
2318
|
role: {
|
|
2252
2319
|
...emptyRole,
|
|
2253
2320
|
name,
|
|
2254
|
-
description: description ? description : roleState.description,
|
|
2321
|
+
description: description ? description : roleState.description || "",
|
|
2255
2322
|
uiPermissions: {
|
|
2256
2323
|
...emptyUiPermissions,
|
|
2257
2324
|
...roleUiPermissions,
|
|
@@ -2274,50 +2341,57 @@ var roleActions = {
|
|
|
2274
2341
|
errorMessage: "removing"
|
|
2275
2342
|
}
|
|
2276
2343
|
};
|
|
2277
|
-
var roleActionErrorHandler = (err, type, dispatch) =>
|
|
2278
|
-
|
|
2344
|
+
var roleActionErrorHandler = (err, type, dispatch, meta) => {
|
|
2345
|
+
let errorContext = `There was an error ${roleActions[type].errorMessage} the role.`;
|
|
2346
|
+
if (meta) {
|
|
2347
|
+
const { permissionSetsCreated, name } = meta;
|
|
2348
|
+
errorContext += ` Tried to ${type} role ${name} with ${permissionSetsCreated} permission sets.`;
|
|
2349
|
+
}
|
|
2350
|
+
return commonErrorHandler(err, errorContext, dispatch);
|
|
2351
|
+
};
|
|
2352
|
+
var createRole = createAppAsyncThunk(`${sliceName6}/createRole`, (roleData, { dispatch }) => {
|
|
2279
2353
|
const { permissionSetsWithScope, role } = transformRoleDataToRole(roleData);
|
|
2280
2354
|
return general_api_default.post(`${useradmApiUrlv2}/roles`, {
|
|
2281
2355
|
name: role.name,
|
|
2282
2356
|
description: role.description,
|
|
2283
2357
|
permission_sets_with_scope: permissionSetsWithScope
|
|
2284
|
-
}).then(() => Promise.all([dispatch(actions6.createdRole(role)), dispatch(getRoles()), dispatch(setSnackbar4(roleActions.create.successMessage))])).catch((err) => roleActionErrorHandler(err, "create", dispatch));
|
|
2358
|
+
}).then(() => Promise.all([dispatch(actions6.createdRole(role)), dispatch(getRoles()), dispatch(setSnackbar4(roleActions.create.successMessage))])).catch((err) => roleActionErrorHandler(err, "create", dispatch, { permissionSetsCreated: permissionSetsWithScope.length, name: role.name }));
|
|
2285
2359
|
});
|
|
2286
|
-
var editRole =
|
|
2360
|
+
var editRole = createAppAsyncThunk(`${sliceName6}/editRole`, (roleData, { dispatch, getState }) => {
|
|
2287
2361
|
const { permissionSetsWithScope, role } = transformRoleDataToRole(roleData, getRolesById(getState())[roleData.name]);
|
|
2288
2362
|
return general_api_default.put(`${useradmApiUrlv2}/roles/${role.name}`, {
|
|
2289
2363
|
description: role.description,
|
|
2290
2364
|
name: role.name,
|
|
2291
2365
|
permission_sets_with_scope: permissionSetsWithScope
|
|
2292
|
-
}).then(() => Promise.all([dispatch(actions6.createdRole(role)), dispatch(getRoles()), dispatch(setSnackbar4(roleActions.edit.successMessage))])).catch((err) => roleActionErrorHandler(err, "edit", dispatch));
|
|
2366
|
+
}).then(() => Promise.all([dispatch(actions6.createdRole(role)), dispatch(getRoles()), dispatch(setSnackbar4(roleActions.edit.successMessage))])).catch((err) => roleActionErrorHandler(err, "edit", dispatch, { permissionSetsCreated: permissionSetsWithScope.length, name: role.name }));
|
|
2293
2367
|
});
|
|
2294
|
-
var removeRole =
|
|
2368
|
+
var removeRole = createAppAsyncThunk(
|
|
2295
2369
|
`${sliceName6}/removeRole`,
|
|
2296
2370
|
(roleId, { dispatch }) => 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))
|
|
2297
2371
|
);
|
|
2298
|
-
var getGlobalSettings2 =
|
|
2372
|
+
var getGlobalSettings2 = createAppAsyncThunk(
|
|
2299
2373
|
`${sliceName6}/getGlobalSettings`,
|
|
2300
|
-
(_, { dispatch }) => general_api_default.get(`${
|
|
2301
|
-
window.sessionStorage.setItem(settingsKeys.initialized, true);
|
|
2374
|
+
(_, { dispatch }) => general_api_default.get(`${useradmApiUrl}/settings`).then(({ data: settings, headers: { etag } }) => {
|
|
2375
|
+
window.sessionStorage.setItem(settingsKeys.initialized, "true");
|
|
2302
2376
|
return Promise.all([dispatch(actions6.setGlobalSettings(settings)), dispatch(setOfflineThreshold()), etag]);
|
|
2303
2377
|
})
|
|
2304
2378
|
);
|
|
2305
|
-
var saveGlobalSettings =
|
|
2379
|
+
var saveGlobalSettings = createAppAsyncThunk(
|
|
2306
2380
|
`${sliceName6}/saveGlobalSettings`,
|
|
2307
2381
|
({ beOptimistic = false, notify = false, ...settings }, { dispatch, getState }) => {
|
|
2308
2382
|
if (!window.sessionStorage.getItem(settingsKeys.initialized) && !beOptimistic) {
|
|
2309
2383
|
return;
|
|
2310
2384
|
}
|
|
2311
2385
|
return dispatch(getGlobalSettings2()).unwrap().then((result) => {
|
|
2312
|
-
|
|
2386
|
+
const updatedSettings = { ...getState().users.globalSettings, ...settings };
|
|
2313
2387
|
if (getCurrentUser(getState()).verified) {
|
|
2314
2388
|
updatedSettings["2fa"] = twoFAStates.enabled;
|
|
2315
2389
|
} else {
|
|
2316
2390
|
delete updatedSettings["2fa"];
|
|
2317
2391
|
}
|
|
2318
|
-
|
|
2392
|
+
const tasks = [dispatch(actions6.setGlobalSettings(updatedSettings))];
|
|
2319
2393
|
const headers = result[result.length - 1] ? { "If-Match": result[result.length - 1] } : {};
|
|
2320
|
-
return general_api_default.post(`${
|
|
2394
|
+
return general_api_default.post(`${useradmApiUrl}/settings`, updatedSettings, { headers }).then(() => {
|
|
2321
2395
|
if (notify) {
|
|
2322
2396
|
tasks.push(dispatch(setSnackbar4("Settings saved successfully")));
|
|
2323
2397
|
}
|
|
@@ -2332,54 +2406,59 @@ var saveGlobalSettings = createAsyncThunk5(
|
|
|
2332
2406
|
});
|
|
2333
2407
|
}
|
|
2334
2408
|
);
|
|
2335
|
-
var getUserSettings2 =
|
|
2409
|
+
var getUserSettings2 = createAppAsyncThunk(
|
|
2336
2410
|
`${sliceName6}/getUserSettings`,
|
|
2337
|
-
(_, { dispatch }) => general_api_default.get(`${
|
|
2338
|
-
window.sessionStorage.setItem(settingsKeys.initialized, true);
|
|
2411
|
+
(_, { dispatch }) => general_api_default.get(`${useradmApiUrl}/settings/me`).then(({ data: settings, headers: { etag } }) => {
|
|
2412
|
+
window.sessionStorage.setItem(settingsKeys.initialized, "true");
|
|
2339
2413
|
return Promise.all([dispatch(actions6.setUserSettings(settings)), etag]);
|
|
2340
2414
|
})
|
|
2341
2415
|
);
|
|
2342
|
-
var saveUserSettings =
|
|
2343
|
-
|
|
2344
|
-
|
|
2416
|
+
var saveUserSettings = createAppAsyncThunk(
|
|
2417
|
+
`${sliceName6}/saveUserSettings`,
|
|
2418
|
+
(settings = { onboarding: {} }, { dispatch, getState }) => {
|
|
2419
|
+
if (!getCurrentUser(getState()).id) {
|
|
2420
|
+
return Promise.resolve();
|
|
2421
|
+
}
|
|
2422
|
+
return dispatch(getUserSettings2()).unwrap().then((result) => {
|
|
2423
|
+
const userSettings = getUserSettings(getState());
|
|
2424
|
+
const onboardingState = getOnboardingState(getState());
|
|
2425
|
+
const tooltipState = getTooltipsState(getState());
|
|
2426
|
+
const updatedSettings = {
|
|
2427
|
+
...userSettings,
|
|
2428
|
+
...settings,
|
|
2429
|
+
onboarding: {
|
|
2430
|
+
...onboardingState,
|
|
2431
|
+
...settings.onboarding
|
|
2432
|
+
},
|
|
2433
|
+
tooltips: tooltipState
|
|
2434
|
+
};
|
|
2435
|
+
const headers = result[result.length - 1] ? { "If-Match": result[result.length - 1] } : {};
|
|
2436
|
+
return Promise.all([
|
|
2437
|
+
Promise.resolve(dispatch(actions6.setUserSettings(updatedSettings))),
|
|
2438
|
+
general_api_default.post(`${useradmApiUrl}/settings/me`, updatedSettings, { headers })
|
|
2439
|
+
]).catch(() => dispatch(actions6.setUserSettings(userSettings)));
|
|
2440
|
+
});
|
|
2345
2441
|
}
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
const onboardingState = getOnboardingState(getState());
|
|
2349
|
-
const tooltipState = getTooltipsState(getState());
|
|
2350
|
-
const updatedSettings = {
|
|
2351
|
-
...userSettings,
|
|
2352
|
-
...settings,
|
|
2353
|
-
onboarding: {
|
|
2354
|
-
...onboardingState,
|
|
2355
|
-
...settings.onboarding
|
|
2356
|
-
},
|
|
2357
|
-
tooltips: tooltipState
|
|
2358
|
-
};
|
|
2359
|
-
const headers = result[result.length - 1] ? { "If-Match": result[result.length - 1] } : {};
|
|
2360
|
-
return Promise.all([
|
|
2361
|
-
Promise.resolve(dispatch(actions6.setUserSettings(updatedSettings))),
|
|
2362
|
-
general_api_default.post(`${useradmApiUrlv1}/settings/me`, updatedSettings, { headers })
|
|
2363
|
-
]).catch(() => dispatch(actions6.setUserSettings(userSettings)));
|
|
2364
|
-
});
|
|
2365
|
-
});
|
|
2366
|
-
var get2FAQRCode = createAsyncThunk5(
|
|
2442
|
+
);
|
|
2443
|
+
var get2FAQRCode = createAppAsyncThunk(
|
|
2367
2444
|
`${sliceName6}/get2FAQRCode`,
|
|
2368
|
-
(_, { dispatch }) => general_api_default.get(`${
|
|
2369
|
-
);
|
|
2370
|
-
var setHideAnnouncement =
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
cookies3.
|
|
2376
|
-
|
|
2445
|
+
(_, { dispatch }) => general_api_default.get(`${useradmApiUrl}/2faqr`).then((res) => dispatch(actions6.receivedQrCode(res.data.qr)))
|
|
2446
|
+
);
|
|
2447
|
+
var setHideAnnouncement = createAppAsyncThunk(
|
|
2448
|
+
`${sliceName6}/setHideAnnouncement`,
|
|
2449
|
+
({ shouldHide, userId }, { dispatch, getState }) => {
|
|
2450
|
+
const currentUserId = userId || getCurrentUser(getState()).id;
|
|
2451
|
+
const hash = getState().app.hostedAnnouncement ? hashString2(getState().app.hostedAnnouncement) : "";
|
|
2452
|
+
const announceCookie = cookies3.get(`${currentUserId}${hash}`);
|
|
2453
|
+
if (shouldHide || hash.length && typeof announceCookie !== "undefined") {
|
|
2454
|
+
cookies3.set(`${currentUserId}${hash}`, true, { maxAge: 604800 });
|
|
2455
|
+
dispatch(setAnnouncement2(""));
|
|
2456
|
+
}
|
|
2377
2457
|
}
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
var getTokens = createAsyncThunk5(
|
|
2458
|
+
);
|
|
2459
|
+
var getTokens = createAppAsyncThunk(
|
|
2381
2460
|
`${sliceName6}/getTokens`,
|
|
2382
|
-
(_, { dispatch, getState }) => general_api_default.get(`${
|
|
2461
|
+
(_, { dispatch, getState }) => general_api_default.get(`${useradmApiUrl}/settings/tokens`).then(({ data: tokens }) => {
|
|
2383
2462
|
const user = getCurrentUser(getState());
|
|
2384
2463
|
const updatedUser = {
|
|
2385
2464
|
...user,
|
|
@@ -2389,26 +2468,31 @@ var getTokens = createAsyncThunk5(
|
|
|
2389
2468
|
})
|
|
2390
2469
|
);
|
|
2391
2470
|
var ONE_YEAR = 31536e3;
|
|
2392
|
-
var generateToken =
|
|
2471
|
+
var generateToken = createAppAsyncThunk(
|
|
2393
2472
|
`${sliceName6}/generateToken`,
|
|
2394
|
-
({ expiresIn = ONE_YEAR, name }, { dispatch }) => general_api_default.post(`${
|
|
2473
|
+
({ expiresIn = ONE_YEAR, name }, { dispatch }) => general_api_default.post(`${useradmApiUrl}/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))
|
|
2395
2474
|
);
|
|
2396
|
-
var revokeToken =
|
|
2475
|
+
var revokeToken = createAppAsyncThunk(
|
|
2397
2476
|
`${sliceName6}/revokeToken`,
|
|
2398
|
-
(token, { dispatch }) => general_api_default.delete(`${
|
|
2477
|
+
(token, { dispatch }) => general_api_default.delete(`${useradmApiUrl}/settings/tokens/${token.id}`).then(() => Promise.resolve(dispatch(getTokens())))
|
|
2478
|
+
);
|
|
2479
|
+
var setTooltipReadState = createAppAsyncThunk(
|
|
2480
|
+
`${sliceName6}/setTooltipReadState`,
|
|
2481
|
+
async ({ persist, ...remainder }, { dispatch }) => {
|
|
2482
|
+
dispatch(actions6.setTooltipState(remainder));
|
|
2483
|
+
if (persist) {
|
|
2484
|
+
await dispatch(saveUserSettings());
|
|
2485
|
+
}
|
|
2486
|
+
}
|
|
2399
2487
|
);
|
|
2400
|
-
var
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2488
|
+
var setAllTooltipsReadState = createAppAsyncThunk(
|
|
2489
|
+
`${sliceName6}/toggleHelptips`,
|
|
2490
|
+
({ readState = READ_STATES.read, tooltipIds }, { dispatch }) => {
|
|
2491
|
+
const updatedTips = tooltipIds.reduce((accu, id) => ({ ...accu, [id]: { readState } }), {});
|
|
2492
|
+
return Promise.resolve(dispatch(actions6.setTooltipsState(updatedTips))).then(() => dispatch(saveUserSettings()));
|
|
2404
2493
|
}
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
var setAllTooltipsReadState = createAsyncThunk5(`${sliceName6}/toggleHelptips`, (readState = READ_STATES.read, { dispatch }) => {
|
|
2408
|
-
const updatedTips = Object.keys(HELPTOOLTIPS).reduce((accu, id) => ({ ...accu, [id]: { readState } }), {});
|
|
2409
|
-
return Promise.resolve(dispatch(actions6.setTooltipsState(updatedTips))).then(() => dispatch(saveUserSettings()));
|
|
2410
|
-
});
|
|
2411
|
-
var submitFeedback = createAsyncThunk5(
|
|
2494
|
+
);
|
|
2495
|
+
var submitFeedback = createAppAsyncThunk(
|
|
2412
2496
|
`${sliceName6}/submitFeedback`,
|
|
2413
2497
|
({ satisfaction, feedback, ...meta }, { dispatch }) => general_api_default.post(`${tenantadmApiUrlv2}/contact/support`, {
|
|
2414
2498
|
subject: "feedback submission",
|
|
@@ -2421,11 +2505,8 @@ var submitFeedback = createAsyncThunk5(
|
|
|
2421
2505
|
);
|
|
2422
2506
|
|
|
2423
2507
|
// src/appSlice/thunks.ts
|
|
2424
|
-
import { deepCompare as deepCompare4, extractErrorMessage as extractErrorMessage3 } from "@northern.tech/utils/helpers";
|
|
2425
|
-
import { createAsyncThunk as createAsyncThunk6 } from "@reduxjs/toolkit";
|
|
2426
|
-
import Cookies4 from "universal-cookie";
|
|
2427
2508
|
var cookies4 = new Cookies4();
|
|
2428
|
-
var setFirstLoginAfterSignup =
|
|
2509
|
+
var setFirstLoginAfterSignup = createAppAsyncThunk(`${sliceName}/setFirstLoginAfterSignup`, (firstLoginAfterSignup, { dispatch }) => {
|
|
2429
2510
|
cookies4.set("firstLoginAfterSignup", !!firstLoginAfterSignup, { maxAge: 60, path: "/", domain: ".mender.io", sameSite: false });
|
|
2430
2511
|
dispatch(actions.setFirstLoginAfterSignup(!!firstLoginAfterSignup));
|
|
2431
2512
|
});
|
|
@@ -2433,7 +2514,7 @@ var dateFunctionMap = {
|
|
|
2433
2514
|
getDays: "getDate",
|
|
2434
2515
|
setDays: "setDate"
|
|
2435
2516
|
};
|
|
2436
|
-
var setOfflineThreshold =
|
|
2517
|
+
var setOfflineThreshold = createAppAsyncThunk(`${sliceName}/setOfflineThreshold`, (_, { dispatch, getState }) => {
|
|
2437
2518
|
const { interval, intervalUnit } = getOfflineThresholdSettings(getState());
|
|
2438
2519
|
const today = /* @__PURE__ */ new Date();
|
|
2439
2520
|
const intervalName = `${intervalUnit.charAt(0).toUpperCase()}${intervalUnit.substring(1)}`;
|
|
@@ -2458,12 +2539,11 @@ var repoKeyMap = {
|
|
|
2458
2539
|
mender: "Mender-Client",
|
|
2459
2540
|
"mender-artifact": "Mender-Artifact"
|
|
2460
2541
|
};
|
|
2461
|
-
var deductSaasState = (latestRelease, guiTags
|
|
2542
|
+
var deductSaasState = (latestRelease, guiTags) => {
|
|
2462
2543
|
const latestGuiTag = guiTags.length ? guiTags[0].name : "";
|
|
2463
|
-
|
|
2464
|
-
return latestSaasRelease.date > latestRelease.release_date ? latestSaasRelease.tag : latestRelease.release;
|
|
2544
|
+
return latestGuiTag ? latestGuiTag : latestRelease.release;
|
|
2465
2545
|
};
|
|
2466
|
-
var getLatestReleaseInfo =
|
|
2546
|
+
var getLatestReleaseInfo = createAppAsyncThunk(`${sliceName}/getLatestReleaseInfo`, (_, { dispatch, getState }) => {
|
|
2467
2547
|
if (!getFeatures(getState()).isHosted) {
|
|
2468
2548
|
return Promise.resolve();
|
|
2469
2549
|
}
|
|
@@ -2474,7 +2554,7 @@ var getLatestReleaseInfo = createAsyncThunk6(`${sliceName}/getLatestReleaseInfo`
|
|
|
2474
2554
|
if (!guiTags.length) {
|
|
2475
2555
|
return Promise.resolve();
|
|
2476
2556
|
}
|
|
2477
|
-
const { releases
|
|
2557
|
+
const { releases } = data;
|
|
2478
2558
|
const latestRelease = getLatestRelease(getLatestRelease(releases));
|
|
2479
2559
|
const { latestRepos, latestVersions } = latestRelease.repos.reduce(
|
|
2480
2560
|
(accu, item) => {
|
|
@@ -2486,13 +2566,12 @@ var getLatestReleaseInfo = createAsyncThunk6(`${sliceName}/getLatestReleaseInfo`
|
|
|
2486
2566
|
},
|
|
2487
2567
|
{ latestVersions: { ...getState().app.versionInformation }, latestRepos: {} }
|
|
2488
2568
|
);
|
|
2489
|
-
const info = deductSaasState(latestRelease, guiTags
|
|
2569
|
+
const info = deductSaasState(latestRelease, guiTags);
|
|
2490
2570
|
return Promise.resolve(
|
|
2491
2571
|
dispatch(
|
|
2492
2572
|
actions.setVersionInformation({
|
|
2493
2573
|
...latestVersions,
|
|
2494
|
-
|
|
2495
|
-
GUI: info,
|
|
2574
|
+
Server: info,
|
|
2496
2575
|
latestRelease: {
|
|
2497
2576
|
releaseDate: latestRelease.release_date,
|
|
2498
2577
|
repos: latestRepos
|
|
@@ -2502,9 +2581,9 @@ var getLatestReleaseInfo = createAsyncThunk6(`${sliceName}/getLatestReleaseInfo`
|
|
|
2502
2581
|
);
|
|
2503
2582
|
});
|
|
2504
2583
|
});
|
|
2505
|
-
var setSearchState =
|
|
2584
|
+
var setSearchState = createAppAsyncThunk(`${sliceName}/setSearchState`, (searchState, { dispatch, getState }) => {
|
|
2506
2585
|
const currentState = getSearchState(getState());
|
|
2507
|
-
|
|
2586
|
+
const nextState = {
|
|
2508
2587
|
...currentState,
|
|
2509
2588
|
...searchState,
|
|
2510
2589
|
sort: {
|
|
@@ -2512,7 +2591,7 @@ var setSearchState = createAsyncThunk6(`${sliceName}/setSearchState`, (searchSta
|
|
|
2512
2591
|
...searchState.sort
|
|
2513
2592
|
}
|
|
2514
2593
|
};
|
|
2515
|
-
|
|
2594
|
+
const tasks = [];
|
|
2516
2595
|
const { isSearching: currentSearching, deviceIds: currentDevices, searchTotal: currentTotal, ...currentRequestState } = currentState;
|
|
2517
2596
|
const { isSearching: nextSearching, deviceIds: nextDevices, searchTotal: nextTotal, ...nextRequestState } = nextState;
|
|
2518
2597
|
if (nextRequestState.searchTerm && !deepCompare4(currentRequestState, nextRequestState)) {
|
|
@@ -2546,7 +2625,7 @@ export {
|
|
|
2546
2625
|
setDeploymentsState,
|
|
2547
2626
|
getDeploymentsConfig,
|
|
2548
2627
|
saveDeltaDeploymentsConfig,
|
|
2549
|
-
|
|
2628
|
+
getGroups,
|
|
2550
2629
|
addDevicesToGroup,
|
|
2551
2630
|
removeDevicesFromGroup,
|
|
2552
2631
|
addStaticGroup,
|
|
@@ -2561,7 +2640,6 @@ export {
|
|
|
2561
2640
|
getAllDynamicGroupDevices,
|
|
2562
2641
|
getDeviceById2 as getDeviceById,
|
|
2563
2642
|
getDeviceInfo,
|
|
2564
|
-
deriveInactiveDevices,
|
|
2565
2643
|
getDeviceCount,
|
|
2566
2644
|
getAllDeviceCounts,
|
|
2567
2645
|
getDeviceLimit,
|
|
@@ -2570,11 +2648,8 @@ export {
|
|
|
2570
2648
|
getAllDevicesByStatus,
|
|
2571
2649
|
searchDevices,
|
|
2572
2650
|
getDeviceAttributes,
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
getReportsData,
|
|
2576
|
-
deriveReportsData,
|
|
2577
|
-
getReportsDataWithoutBackendSupport,
|
|
2651
|
+
updateReportData,
|
|
2652
|
+
getReportDataWithoutBackendSupport,
|
|
2578
2653
|
getDeviceConnect,
|
|
2579
2654
|
triggerDeviceUpdate,
|
|
2580
2655
|
getSessionDetails,
|
|
@@ -2595,8 +2670,6 @@ export {
|
|
|
2595
2670
|
setDeviceTwin,
|
|
2596
2671
|
getSystemDevices,
|
|
2597
2672
|
getGatewayDevices,
|
|
2598
|
-
getDevicesInBounds,
|
|
2599
|
-
applyOnboardingFallbacks,
|
|
2600
2673
|
getOnboardingState2 as getOnboardingState,
|
|
2601
2674
|
setOnboardingDeviceType,
|
|
2602
2675
|
setOnboardingApproach,
|
|
@@ -2620,8 +2693,15 @@ export {
|
|
|
2620
2693
|
getTenants,
|
|
2621
2694
|
setTenantsListState,
|
|
2622
2695
|
editTenantDeviceLimit,
|
|
2696
|
+
editBillingProfile,
|
|
2697
|
+
createBillingProfile,
|
|
2623
2698
|
removeTenant,
|
|
2624
2699
|
getUserOrganization,
|
|
2700
|
+
getUserBilling,
|
|
2701
|
+
getUserSubscription,
|
|
2702
|
+
getBillingPreview,
|
|
2703
|
+
getCurrentSubscription,
|
|
2704
|
+
requestPlanUpgrade,
|
|
2625
2705
|
sendSupportMessage,
|
|
2626
2706
|
requestPlanChange,
|
|
2627
2707
|
downloadLicenseReport,
|
|
@@ -2672,4 +2752,4 @@ export {
|
|
|
2672
2752
|
setAllTooltipsReadState,
|
|
2673
2753
|
submitFeedback
|
|
2674
2754
|
};
|
|
2675
|
-
//# sourceMappingURL=chunk-
|
|
2755
|
+
//# sourceMappingURL=chunk-ZN5TB2NJ.js.map
|