@northern.tech/store 0.3.4 → 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 +78 -827
- 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 +102 -112
- package/dist/appSlice/constants.d.ts +102 -112
- package/dist/appSlice/constants.js +1 -11
- package/dist/appSlice/index.cjs +24 -239
- 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 +1552 -1769
- 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 +31 -31
- 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-JO33IORF.js → chunk-4TUJPE6G.js} +19 -4
- package/dist/chunk-4TUJPE6G.js.map +1 -0
- package/dist/{chunk-AFICTIVU.js → chunk-6KGTHJKC.js} +22 -24
- 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-X3GZILYD.js → chunk-ABJLRDCO.js} +10 -11
- package/dist/chunk-ABJLRDCO.js.map +1 -0
- package/dist/{chunk-PAIB5V27.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-FVCYB5OP.js → chunk-IQG5I7AM.js} +32 -40
- 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-ZWOAFHAR.js → chunk-JXQUFKID.js} +2 -2
- package/dist/chunk-JXQUFKID.js.map +1 -0
- package/dist/{chunk-K4MMUDYT.js → chunk-KC7SKI3U.js} +9 -11
- package/dist/chunk-KC7SKI3U.js.map +1 -0
- package/dist/{chunk-L3SY3J5M.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-FRSA2YB5.js → chunk-MZNANSS2.js} +12 -7
- package/dist/chunk-MZNANSS2.js.map +1 -0
- package/dist/{chunk-EYCORLYU.js → chunk-N2KLYPS5.js} +128 -87
- package/dist/chunk-N2KLYPS5.js.map +1 -0
- package/dist/{chunk-Y575RZHR.js → chunk-OHF3YUXX.js} +25 -40
- package/dist/chunk-OHF3YUXX.js.map +1 -0
- package/dist/{chunk-NOQR3TE7.js → chunk-OOICURFL.js} +2 -2
- package/dist/chunk-OOICURFL.js.map +1 -0
- package/dist/{chunk-AVX7VVOK.js → chunk-PGFVHKP5.js} +5 -7
- package/dist/chunk-PGFVHKP5.js.map +1 -0
- package/dist/{chunk-NCSKCF2S.js → chunk-QHK7GGV4.js} +3 -3
- package/dist/chunk-QHK7GGV4.js.map +1 -0
- package/dist/{chunk-AUBJUUP3.js → chunk-RS37Y2PQ.js} +3 -3
- package/dist/chunk-RS37Y2PQ.js.map +1 -0
- package/dist/{chunk-7YZCUAXZ.js → chunk-UGSLGUS6.js} +8 -6
- package/dist/chunk-UGSLGUS6.js.map +1 -0
- package/dist/{chunk-ZZMFXRQK.js → chunk-URNS6A5T.js} +14 -14
- package/dist/{chunk-RX32WLVJ.js → chunk-VANBSJS5.js} +1 -1
- package/dist/chunk-VANBSJS5.js.map +1 -0
- package/dist/{chunk-DGQKXSRI.js → chunk-VUFRP6P3.js} +5 -6
- package/dist/chunk-VUFRP6P3.js.map +1 -0
- package/dist/{chunk-DCEKU6UV.js → chunk-X4GUACQO.js} +8 -5
- package/dist/chunk-X4GUACQO.js.map +1 -0
- package/dist/{chunk-GWJIY56H.js → chunk-XWYJACQC.js} +40 -15
- package/dist/chunk-XWYJACQC.js.map +1 -0
- package/dist/{chunk-GAI4VYRZ.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-EQLHIPPR.js → chunk-ZN5TB2NJ.js} +919 -842
- package/dist/chunk-ZN5TB2NJ.js.map +1 -0
- package/dist/{chunk-FQDSV3NK.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 +507 -768
- package/dist/commonSelectors.cjs.map +1 -1
- package/dist/commonSelectors.d.cts +4307 -280
- package/dist/commonSelectors.d.ts +4307 -280
- package/dist/commonSelectors.js +14 -14
- 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 +1518 -1735
- 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 +31 -31
- 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 -1926
- 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 +37 -47
- package/dist/liststatehook.cjs +289 -325
- package/dist/liststatehook.cjs.map +1 -1
- package/dist/liststatehook.d.cts +4 -16
- package/dist/liststatehook.d.ts +4 -16
- package/dist/liststatehook.js +9 -9
- package/dist/liststatehook.js.map +1 -1
- package/dist/locationutils.cjs +286 -322
- package/dist/locationutils.cjs.map +1 -1
- package/dist/locationutils.d.cts +8 -7
- package/dist/locationutils.d.ts +8 -7
- package/dist/locationutils.js +6 -6
- 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 +623 -860
- 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 +27 -27
- 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.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 +1771 -1991
- package/dist/onboardingSlice/thunks.cjs.map +1 -1
- package/dist/onboardingSlice/thunks.d.cts +62 -34
- package/dist/onboardingSlice/thunks.d.ts +62 -34
- package/dist/onboardingSlice/thunks.js +31 -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 -74
- package/dist/organizationSlice/index.d.ts +45 -74
- 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 -52
- package/dist/organizationSlice/selectors.d.ts +888 -52
- package/dist/organizationSlice/selectors.js +14 -6
- package/dist/organizationSlice/thunks.cjs +2593 -2730
- package/dist/organizationSlice/thunks.cjs.map +1 -1
- package/dist/organizationSlice/thunks.d.cts +318 -127
- package/dist/organizationSlice/thunks.d.ts +318 -127
- package/dist/organizationSlice/thunks.js +45 -31
- package/dist/organizationSlice/types.cjs.map +1 -1
- package/dist/organizationSlice/types.d.cts +95 -3
- package/dist/organizationSlice/types.d.ts +95 -3
- 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 +288 -158
- 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 +787 -982
- 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 +34 -28
- package/dist/selectors.cjs +559 -770
- package/dist/selectors.cjs.map +1 -1
- package/dist/selectors.d.cts +37 -9
- package/dist/selectors.d.ts +37 -9
- package/dist/selectors.js +77 -41
- package/dist/sockethook.cjs +271 -281
- package/dist/sockethook.cjs.map +1 -1
- package/dist/sockethook.js +7 -9
- package/dist/sockethook.js.map +1 -1
- package/dist/store.cjs +119 -834
- package/dist/store.cjs.map +1 -1
- package/dist/store.d.cts +698 -1963
- package/dist/store.d.ts +698 -1963
- package/dist/store.js +18 -16
- package/dist/storehooks.cjs +1797 -1907
- package/dist/storehooks.cjs.map +1 -1
- package/dist/storehooks.js +43 -49
- package/dist/storehooks.js.map +1 -1
- package/dist/thunks.cjs +2132 -2229
- package/dist/thunks.cjs.map +1 -1
- package/dist/thunks.d.cts +24 -6
- package/dist/thunks.d.ts +24 -6
- package/dist/thunks.js +55 -45
- package/dist/{deploymentdevicehook.cjs → useDeploymentDevice.cjs} +1757 -1976
- 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 +11 -769
- package/dist/usersSlice/constants.d.ts +11 -769
- 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 +1655 -1872
- 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 +31 -31
- package/dist/utils.cjs +423 -285
- 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 +20 -11
- package/dist/BillingProfile-ChP2_Sqw.d.cts +0 -45
- package/dist/BillingProfile-ChP2_Sqw.d.ts +0 -45
- 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-4RWZR3BN.js +0 -104
- package/dist/chunk-4RWZR3BN.js.map +0 -1
- package/dist/chunk-7YZCUAXZ.js.map +0 -1
- package/dist/chunk-AFICTIVU.js.map +0 -1
- package/dist/chunk-AUBJUUP3.js.map +0 -1
- package/dist/chunk-AVX7VVOK.js.map +0 -1
- package/dist/chunk-BSN2TOQC.js +0 -245
- package/dist/chunk-BSN2TOQC.js.map +0 -1
- package/dist/chunk-DCEKU6UV.js.map +0 -1
- package/dist/chunk-DGQKXSRI.js.map +0 -1
- package/dist/chunk-EQLHIPPR.js.map +0 -1
- package/dist/chunk-EYCORLYU.js.map +0 -1
- package/dist/chunk-FQDSV3NK.js.map +0 -1
- package/dist/chunk-FRSA2YB5.js.map +0 -1
- package/dist/chunk-FVCYB5OP.js.map +0 -1
- package/dist/chunk-GAI4VYRZ.js.map +0 -1
- package/dist/chunk-GWJIY56H.js.map +0 -1
- package/dist/chunk-JO33IORF.js.map +0 -1
- package/dist/chunk-K4MMUDYT.js.map +0 -1
- package/dist/chunk-L3SY3J5M.js.map +0 -1
- package/dist/chunk-LIJIIRON.js +0 -28
- package/dist/chunk-LIJIIRON.js.map +0 -1
- package/dist/chunk-MRCFLG45.js.map +0 -1
- package/dist/chunk-NCSKCF2S.js.map +0 -1
- package/dist/chunk-NOQR3TE7.js.map +0 -1
- package/dist/chunk-OEP2D6QL.js +0 -727
- package/dist/chunk-OEP2D6QL.js.map +0 -1
- package/dist/chunk-PAIB5V27.js.map +0 -1
- package/dist/chunk-RX32WLVJ.js.map +0 -1
- package/dist/chunk-X3GZILYD.js.map +0 -1
- package/dist/chunk-Y575RZHR.js.map +0 -1
- package/dist/chunk-ZWOAFHAR.js.map +0 -1
- package/dist/deploymentdevicehook.cjs.map +0 -1
- package/dist/deploymentdevicehook.js +0 -63
- package/dist/deploymentdevicehook.js.map +0 -1
- package/dist/types-DBj17FZO.d.cts +0 -135
- package/dist/types-DnfZa6xd.d.ts +0 -135
- /package/dist/{chunk-ZZMFXRQK.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,61 +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-
|
|
11
|
-
import {
|
|
12
|
-
commonErrorFallback,
|
|
13
|
-
commonErrorHandler
|
|
14
|
-
} from "./chunk-PAIB5V27.js";
|
|
15
|
+
} from "./chunk-RS37Y2PQ.js";
|
|
15
16
|
import {
|
|
16
17
|
actions_default
|
|
17
|
-
} from "./chunk-
|
|
18
|
-
import {
|
|
19
|
-
actions as actions2,
|
|
20
|
-
sliceName as sliceName2
|
|
21
|
-
} from "./chunk-DGQKXSRI.js";
|
|
18
|
+
} from "./chunk-URNS6A5T.js";
|
|
22
19
|
import {
|
|
23
20
|
actions as actions6,
|
|
24
21
|
sliceName as sliceName6
|
|
25
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-UGSLGUS6.js";
|
|
26
23
|
import {
|
|
27
24
|
actions as actions5,
|
|
28
25
|
sliceName as sliceName5
|
|
29
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-MZNANSS2.js";
|
|
30
27
|
import {
|
|
31
28
|
actions as actions4,
|
|
32
29
|
sliceName as sliceName4
|
|
33
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-VANBSJS5.js";
|
|
34
31
|
import {
|
|
35
|
-
actions as
|
|
36
|
-
sliceName as
|
|
37
|
-
} from "./chunk-
|
|
32
|
+
actions as actions2,
|
|
33
|
+
sliceName as sliceName2
|
|
34
|
+
} from "./chunk-VUFRP6P3.js";
|
|
38
35
|
import {
|
|
39
36
|
actions,
|
|
40
37
|
sliceName
|
|
41
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-6KGTHJKC.js";
|
|
39
|
+
import {
|
|
40
|
+
actions as actions3,
|
|
41
|
+
sliceName as sliceName3
|
|
42
|
+
} from "./chunk-ABJLRDCO.js";
|
|
42
43
|
import {
|
|
43
44
|
cleanUp,
|
|
44
45
|
getSessionInfo,
|
|
45
|
-
maxSessionAge,
|
|
46
46
|
setSessionInfo
|
|
47
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-ZJW3QIPM.js";
|
|
48
48
|
import {
|
|
49
49
|
getAttrsEndpoint,
|
|
50
|
+
getDeviceReportsForUser,
|
|
50
51
|
getOnboardingState,
|
|
51
52
|
getSearchEndpoint,
|
|
52
53
|
getTenantCapabilities,
|
|
53
54
|
getUserCapabilities
|
|
54
|
-
} from "./chunk-
|
|
55
|
-
import {
|
|
56
|
-
getDeploymentsById,
|
|
57
|
-
getDeploymentsByStatus
|
|
58
|
-
} from "./chunk-ZWOAFHAR.js";
|
|
55
|
+
} from "./chunk-IQG5I7AM.js";
|
|
59
56
|
import {
|
|
60
57
|
getCurrentSession,
|
|
61
58
|
getCurrentUser,
|
|
@@ -67,49 +64,66 @@ import {
|
|
|
67
64
|
getTooltipsState,
|
|
68
65
|
getUserSettings,
|
|
69
66
|
getUsersById
|
|
70
|
-
} from "./chunk-
|
|
67
|
+
} from "./chunk-ZRSYBSSY.js";
|
|
71
68
|
import {
|
|
72
69
|
getAuditlogState,
|
|
73
70
|
getDeviceTwinIntegrations,
|
|
74
71
|
getOrganization,
|
|
75
72
|
getTenantsList
|
|
76
|
-
} from "./chunk-
|
|
73
|
+
} from "./chunk-4TUJPE6G.js";
|
|
77
74
|
import {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
} from "./chunk-
|
|
75
|
+
getDeploymentsById,
|
|
76
|
+
getDeploymentsByStatus
|
|
77
|
+
} from "./chunk-JXQUFKID.js";
|
|
81
78
|
import {
|
|
79
|
+
getAcceptedDevices,
|
|
82
80
|
getDeviceById,
|
|
83
81
|
getDeviceFilters,
|
|
84
82
|
getDeviceListState,
|
|
83
|
+
getDeviceReports,
|
|
85
84
|
getDevicesById,
|
|
86
|
-
getGroups,
|
|
87
85
|
getGroupsById,
|
|
88
86
|
getSelectedGroup
|
|
89
|
-
} from "./chunk-
|
|
87
|
+
} from "./chunk-KJNNEDRV.js";
|
|
88
|
+
import {
|
|
89
|
+
getFeatures,
|
|
90
|
+
getSearchState
|
|
91
|
+
} from "./chunk-MBKAZVE3.js";
|
|
90
92
|
import {
|
|
91
93
|
convertDeviceListStateToFilters,
|
|
94
|
+
extractErrorMessage,
|
|
92
95
|
filtersFilter,
|
|
93
96
|
getComparisonCompatibleVersion,
|
|
94
97
|
mapDeviceAttributes,
|
|
95
98
|
mapFiltersToTerms,
|
|
96
99
|
mapTermsToFilters,
|
|
97
100
|
mergePermissions,
|
|
101
|
+
parseSubscriptionPreview,
|
|
98
102
|
progress
|
|
99
|
-
} from "./chunk-
|
|
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,54 +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
160
|
onboardingSteps,
|
|
145
161
|
orderedOnboardingSteps
|
|
146
|
-
} from "./chunk-
|
|
162
|
+
} from "./chunk-FAJ3I2UQ.js";
|
|
147
163
|
import {
|
|
148
|
-
|
|
149
|
-
APPLICATION_JWT_CONTENT_TYPE,
|
|
150
|
-
apiRoot,
|
|
151
|
-
defaultReports,
|
|
152
|
-
headerNames,
|
|
164
|
+
PLANS,
|
|
153
165
|
locations
|
|
154
|
-
} from "./chunk-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
DEVICE_LIST_DEFAULTS,
|
|
160
|
-
EXTERNAL_PROVIDER,
|
|
161
|
-
MAX_PAGE_SIZE,
|
|
162
|
-
SORTING_OPTIONS,
|
|
163
|
-
TIMEOUTS,
|
|
164
|
-
UNGROUPED_GROUP,
|
|
165
|
-
emptyRole,
|
|
166
|
-
emptyUiPermissions
|
|
167
|
-
} from "./chunk-BSN2TOQC.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";
|
|
168
171
|
|
|
169
172
|
// src/deploymentsSlice/thunks.ts
|
|
170
173
|
import { customSort, deepCompare, isEmpty, standardizePhases } from "@northern.tech/utils/helpers";
|
|
171
174
|
import Tracking from "@northern.tech/utils/tracking";
|
|
172
|
-
import
|
|
173
|
-
import { isUUID } from "validator";
|
|
175
|
+
import isUUID from "validator/lib/isUUID";
|
|
174
176
|
var { receivedDevice, setSnackbar } = actions_default;
|
|
175
177
|
var { page: defaultPage, perPage: defaultPerPage } = DEVICE_LIST_DEFAULTS;
|
|
176
|
-
var deriveDeploymentGroup = ({ filter
|
|
178
|
+
var deriveDeploymentGroup = ({ filter, group, groups = [], name }) => group || groups.length === 1 && !isUUID(name) ? groups[0] : filter?.name;
|
|
177
179
|
var transformDeployments = (deployments, deploymentsById) => deployments.sort(customSort(true, "created")).reduce(
|
|
178
180
|
(accu, item) => {
|
|
179
|
-
const filter = item.filter
|
|
181
|
+
const filter = item.filter;
|
|
180
182
|
let deployment = {
|
|
181
183
|
...deploymentPrototype,
|
|
182
184
|
...deploymentsById[item.id],
|
|
183
185
|
...item,
|
|
184
|
-
filter:
|
|
186
|
+
filter: filter ? { ...filter, name: filter.name ?? filter.id, filters: mapTermsToFilters(filter.terms) } : void 0,
|
|
185
187
|
name: decodeURIComponent(item.name)
|
|
186
188
|
};
|
|
187
189
|
deployment = { ...deployment, group: deriveDeploymentGroup(deployment) };
|
|
@@ -191,40 +193,43 @@ var transformDeployments = (deployments, deploymentsById) => deployments.sort(cu
|
|
|
191
193
|
},
|
|
192
194
|
{ deployments: {}, deploymentIds: [] }
|
|
193
195
|
);
|
|
194
|
-
var getDeploymentsByStatus2 =
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
actions2.
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
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 })));
|
|
218
227
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
tasks.push({ deploymentIds, total });
|
|
225
|
-
return Promise.all(tasks);
|
|
226
|
-
});
|
|
227
|
-
});
|
|
228
|
+
tasks.push({ deploymentIds, total });
|
|
229
|
+
return Promise.all(tasks);
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
);
|
|
228
233
|
var isWithinFirstMonth = (expirationDate) => {
|
|
229
234
|
if (!expirationDate) {
|
|
230
235
|
return false;
|
|
@@ -246,86 +251,98 @@ var trackDeploymentCreation = (totalDeploymentCount, hasDeployments, trial_expir
|
|
|
246
251
|
}
|
|
247
252
|
};
|
|
248
253
|
var MAX_PREVIOUS_PHASES_COUNT = 5;
|
|
249
|
-
var createDeployment =
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
const lastslashindex = data.headers.location.lastIndexOf("/");
|
|
263
|
-
const deploymentId = data.headers.location.substring(lastslashindex + 1);
|
|
264
|
-
const deployment = {
|
|
265
|
-
...newDeployment,
|
|
266
|
-
id: deploymentId,
|
|
267
|
-
devices: newDeployment.devices ? newDeployment.devices.map((id) => ({ id, status: "pending" })) : [],
|
|
268
|
-
statistics: { status: {} }
|
|
269
|
-
};
|
|
270
|
-
let tasks = [
|
|
271
|
-
dispatch(actions2.createdDeployment(deployment)),
|
|
272
|
-
dispatch(getSingleDeployment(deploymentId)),
|
|
273
|
-
dispatch(setSnackbar("Deployment created successfully", TIMEOUTS.fiveSeconds))
|
|
274
|
-
];
|
|
275
|
-
trackDeploymentCreation(totalDeploymentCount, hasDeployments, trial_expiration);
|
|
276
|
-
const { canManageUsers } = getUserCapabilities(getState());
|
|
277
|
-
if (canManageUsers) {
|
|
278
|
-
const { phases, retries } = newDeployment;
|
|
279
|
-
const { previousPhases = [], retries: previousRetries = 0 } = getGlobalSettings(getState());
|
|
280
|
-
let newSettings = { retries: hasNewRetryDefault ? retries : previousRetries, hasDeployments: true };
|
|
281
|
-
if (phases) {
|
|
282
|
-
const standardPhases = standardizePhases(phases);
|
|
283
|
-
let prevPhases = previousPhases.map(standardizePhases);
|
|
284
|
-
if (!prevPhases.find((previousPhaseList) => previousPhaseList.every((oldPhase) => standardPhases.find((phase) => deepCompare(phase, oldPhase))))) {
|
|
285
|
-
prevPhases.push(standardPhases);
|
|
286
|
-
}
|
|
287
|
-
newSettings.previousPhases = prevPhases.slice(-1 * MAX_PREVIOUS_PHASES_COUNT);
|
|
288
|
-
}
|
|
289
|
-
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);
|
|
290
267
|
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
const
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
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)));
|
|
322
303
|
}
|
|
323
|
-
return
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
}
|
|
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
|
+
);
|
|
329
346
|
var parseDeviceDeployment = ({
|
|
330
347
|
deployment: { id, artifact_name: release, status: deploymentStatus },
|
|
331
348
|
device: { created, deleted, id: deviceId, finished, status, log }
|
|
@@ -345,7 +362,7 @@ var parseDeviceDeployment = ({
|
|
|
345
362
|
return accu;
|
|
346
363
|
}, "")
|
|
347
364
|
});
|
|
348
|
-
var getDeviceDeployments =
|
|
365
|
+
var getDeviceDeployments = createAppAsyncThunk(`${sliceName2}/getDeviceDeployments`, (options, { dispatch }) => {
|
|
349
366
|
const { deviceId, filterSelection = [], page = defaultPage, perPage = defaultPerPage } = options;
|
|
350
367
|
const filters = filterSelection.map((item) => `&status=${item}`).join("");
|
|
351
368
|
return general_api_default.get(`${deploymentsApiUrl}/deployments/devices/${deviceId}?page=${page}&per_page=${perPage}${filters}`).then(
|
|
@@ -360,18 +377,18 @@ var getDeviceDeployments = createAsyncThunk(`${sliceName2}/getDeviceDeployments`
|
|
|
360
377
|
)
|
|
361
378
|
).catch((err) => commonErrorHandler(err, "There was an error retrieving the device deployment history:", dispatch));
|
|
362
379
|
});
|
|
363
|
-
var resetDeviceDeployments =
|
|
380
|
+
var resetDeviceDeployments = createAppAsyncThunk(
|
|
364
381
|
`${sliceName2}/resetDeviceDeployments`,
|
|
365
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))
|
|
366
383
|
);
|
|
367
|
-
var getSingleDeployment =
|
|
384
|
+
var getSingleDeployment = createAppAsyncThunk(
|
|
368
385
|
`${sliceName2}/getSingleDeployment`,
|
|
369
386
|
(id, { dispatch, getState }) => general_api_default.get(`${deploymentsApiUrl}/deployments/${id}`).then(({ data }) => {
|
|
370
387
|
const { deployments } = transformDeployments([data], getState().deployments.byId);
|
|
371
388
|
return Promise.resolve(dispatch(actions2.receivedDeployment(deployments[id])));
|
|
372
389
|
})
|
|
373
390
|
);
|
|
374
|
-
var getDeviceLog =
|
|
391
|
+
var getDeviceLog = createAppAsyncThunk(
|
|
375
392
|
`${sliceName2}/getDeviceLog`,
|
|
376
393
|
({ deploymentId, deviceId }, { dispatch }) => general_api_default.get(`${deploymentsApiUrl}/deployments/${deploymentId}/devices/${deviceId}/log`).catch((e) => {
|
|
377
394
|
console.log("no log here", e);
|
|
@@ -380,7 +397,7 @@ var getDeviceLog = createAsyncThunk(
|
|
|
380
397
|
({ data: log }) => Promise.all([Promise.resolve(dispatch(actions2.receivedDeploymentDeviceLog({ id: deploymentId, deviceId, log }))), Promise.resolve(log)])
|
|
381
398
|
)
|
|
382
399
|
);
|
|
383
|
-
var abortDeployment =
|
|
400
|
+
var abortDeployment = createAppAsyncThunk(
|
|
384
401
|
`${sliceName2}/abortDeployment`,
|
|
385
402
|
(deploymentId, { dispatch, getState }) => general_api_default.put(`${deploymentsApiUrl}/deployments/${deploymentId}/status`, { status: "aborted" }).then(() => {
|
|
386
403
|
const deploymentsByStatus = getDeploymentsByStatus(getState());
|
|
@@ -405,14 +422,14 @@ var abortDeployment = createAsyncThunk(
|
|
|
405
422
|
]);
|
|
406
423
|
}).catch((err) => commonErrorHandler(err, "There was an error while aborting the deployment:", dispatch))
|
|
407
424
|
);
|
|
408
|
-
var updateDeploymentControlMap =
|
|
425
|
+
var updateDeploymentControlMap = createAppAsyncThunk(
|
|
409
426
|
`${sliceName2}/updateDeploymentControlMap`,
|
|
410
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))))
|
|
411
428
|
);
|
|
412
|
-
var setDeploymentsState =
|
|
429
|
+
var setDeploymentsState = createAppAsyncThunk(`${sliceName2}/setDeploymentsState`, (selection, { dispatch, getState }) => {
|
|
413
430
|
const { page, perPage, ...selectionState } = selection;
|
|
414
431
|
const currentState = getState().deployments.selectionState;
|
|
415
|
-
|
|
432
|
+
const nextState = {
|
|
416
433
|
...currentState,
|
|
417
434
|
...selectionState,
|
|
418
435
|
...Object.keys(DEPLOYMENT_STATES).reduce((accu, item) => {
|
|
@@ -427,7 +444,7 @@ var setDeploymentsState = createAsyncThunk(`${sliceName2}/setDeploymentsState`,
|
|
|
427
444
|
...selectionState.general
|
|
428
445
|
}
|
|
429
446
|
};
|
|
430
|
-
|
|
447
|
+
const tasks = [dispatch(actions2.setDeploymentsState(nextState))];
|
|
431
448
|
if (nextState.selectedId && currentState.selectedId !== nextState.selectedId) {
|
|
432
449
|
tasks.push(dispatch(getSingleDeployment(nextState.selectedId)));
|
|
433
450
|
}
|
|
@@ -448,25 +465,23 @@ var mapExternalDeltaConfig = (config = {}) => deltaAttributeMappings.reduce((acc
|
|
|
448
465
|
}
|
|
449
466
|
return accu;
|
|
450
467
|
}, {});
|
|
451
|
-
var getDeploymentsConfig =
|
|
468
|
+
var getDeploymentsConfig = createAppAsyncThunk(
|
|
452
469
|
`${sliceName2}/getDeploymentsConfig`,
|
|
453
470
|
(_, { dispatch, getState }) => general_api_default.get(`${deploymentsApiUrl}/config`).then(({ data }) => {
|
|
454
471
|
const oldConfig = getState().deployments.config;
|
|
455
472
|
const { delta = {} } = data;
|
|
456
473
|
const { binary_delta = {}, binary_delta_limits = {} } = delta;
|
|
457
|
-
const { xdelta_args = {}
|
|
458
|
-
const { xdelta_args_limits = {}
|
|
474
|
+
const { xdelta_args = {} } = binary_delta;
|
|
475
|
+
const { xdelta_args_limits = {} } = binary_delta_limits;
|
|
459
476
|
const config = {
|
|
460
477
|
...oldConfig,
|
|
461
478
|
hasDelta: Boolean(delta.enabled),
|
|
462
479
|
binaryDelta: {
|
|
463
480
|
...oldConfig.binaryDelta,
|
|
464
|
-
timeout: timeoutConfig,
|
|
465
481
|
...mapExternalDeltaConfig(xdelta_args)
|
|
466
482
|
},
|
|
467
483
|
binaryDeltaLimits: {
|
|
468
484
|
...oldConfig.binaryDeltaLimits,
|
|
469
|
-
timeout: timeoutLimit,
|
|
470
485
|
...mapExternalDeltaConfig(xdelta_args_limits)
|
|
471
486
|
}
|
|
472
487
|
};
|
|
@@ -475,7 +490,7 @@ var getDeploymentsConfig = createAsyncThunk(
|
|
|
475
490
|
);
|
|
476
491
|
var deepClean = (source) => Object.entries(source).reduce((accu, [key, value]) => {
|
|
477
492
|
if (value !== void 0) {
|
|
478
|
-
|
|
493
|
+
const cleanedValue = typeof value === "object" ? deepClean(value) : value;
|
|
479
494
|
if (cleanedValue === void 0 || typeof cleanedValue === "object" && isEmpty(cleanedValue)) {
|
|
480
495
|
return accu;
|
|
481
496
|
}
|
|
@@ -483,37 +498,38 @@ var deepClean = (source) => Object.entries(source).reduce((accu, [key, value]) =
|
|
|
483
498
|
}
|
|
484
499
|
return accu;
|
|
485
500
|
}, void 0);
|
|
486
|
-
var saveDeltaDeploymentsConfig =
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
const result = deepClean(configChange);
|
|
497
|
-
if (!result) {
|
|
498
|
-
return Promise.resolve();
|
|
499
|
-
}
|
|
500
|
-
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(() => {
|
|
501
|
-
const oldConfig = getState().deployments.config;
|
|
502
|
-
const newConfig = {
|
|
503
|
-
...oldConfig,
|
|
504
|
-
binaryDelta: {
|
|
505
|
-
...oldConfig.binaryDelta,
|
|
506
|
-
...config
|
|
507
|
-
}
|
|
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
|
+
}, {})
|
|
508
511
|
};
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
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
|
+
);
|
|
512
529
|
|
|
513
530
|
// src/devicesSlice/thunks.tsx
|
|
514
531
|
import { Link } from "react-router-dom";
|
|
515
|
-
import { attributeDuplicateFilter, dateRangeToUnix, deepCompare as deepCompare2,
|
|
516
|
-
import { createAsyncThunk as createAsyncThunk2 } from "@reduxjs/toolkit";
|
|
532
|
+
import { attributeDuplicateFilter, dateRangeToUnix, deepCompare as deepCompare2, getSnackbarMessage } from "@northern.tech/utils/helpers";
|
|
517
533
|
import { isCancel } from "axios";
|
|
518
534
|
import pluralize from "pluralize";
|
|
519
535
|
import { v4 as uuid } from "uuid";
|
|
@@ -534,7 +550,7 @@ var defaultAttributes = [
|
|
|
534
550
|
{ scope: "system", attribute: "group" },
|
|
535
551
|
{ scope: "tags", attribute: "name" }
|
|
536
552
|
];
|
|
537
|
-
var
|
|
553
|
+
var getGroups = createAppAsyncThunk(
|
|
538
554
|
`${sliceName3}/getGroups`,
|
|
539
555
|
(_, { dispatch, getState }) => general_api_default.get(`${inventoryApiUrl}/groups`).then((res) => {
|
|
540
556
|
const state = getGroupsById(getState());
|
|
@@ -551,7 +567,7 @@ var getGroups2 = createAsyncThunk2(
|
|
|
551
567
|
const filters = [{ key: "group", value: res.data, operator: DEVICE_FILTERING_OPTIONS.$nin.key, scope: "system" }];
|
|
552
568
|
return Promise.all([
|
|
553
569
|
dispatch(actions3.receivedGroups(groups)),
|
|
554
|
-
dispatch(getDevicesByStatus({ filterSelection: filters, group:
|
|
570
|
+
dispatch(getDevicesByStatus({ filterSelection: filters, group: "", page: 1, perPage: 1, status: void 0 }))
|
|
555
571
|
]).then((promises) => {
|
|
556
572
|
const devicesRetrieval = promises[promises.length - 1] || [];
|
|
557
573
|
const { payload } = devicesRetrieval || {};
|
|
@@ -570,39 +586,42 @@ var getGroups2 = createAsyncThunk2(
|
|
|
570
586
|
});
|
|
571
587
|
})
|
|
572
588
|
);
|
|
573
|
-
var addDevicesToGroup =
|
|
589
|
+
var addDevicesToGroup = createAppAsyncThunk(
|
|
574
590
|
`${sliceName3}/addDevicesToGroup`,
|
|
575
|
-
({ 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())) : {})
|
|
576
592
|
);
|
|
577
|
-
var removeDevicesFromGroup =
|
|
593
|
+
var removeDevicesFromGroup = createAppAsyncThunk(
|
|
578
594
|
`${sliceName3}/removeDevicesFromGroup`,
|
|
579
595
|
({ group, deviceIds }, { dispatch }) => general_api_default.delete(`${inventoryApiUrl}/groups/${group}/devices`, deviceIds).then(
|
|
580
596
|
() => Promise.all([
|
|
581
597
|
dispatch(actions3.removeFromGroup({ group, deviceIds })),
|
|
582
|
-
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
|
+
)
|
|
583
604
|
])
|
|
584
605
|
)
|
|
585
606
|
);
|
|
586
607
|
var getGroupNotification = (newGroup, selectedGroup) => {
|
|
587
|
-
const
|
|
608
|
+
const successMessage2 = "The group was updated successfully";
|
|
588
609
|
if (newGroup === selectedGroup) {
|
|
589
|
-
return
|
|
610
|
+
return { message: successMessage2, autoHideDuration: TIMEOUTS.fiveSeconds };
|
|
590
611
|
}
|
|
591
|
-
return
|
|
592
|
-
|
|
593
|
-
|
|
612
|
+
return {
|
|
613
|
+
action: "",
|
|
614
|
+
autoHideDuration: TIMEOUTS.fiveSeconds,
|
|
615
|
+
message: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
616
|
+
successMessage2,
|
|
594
617
|
" - ",
|
|
595
618
|
/* @__PURE__ */ jsx(Link, { to: `/devices?inventory=group:eq:${newGroup}`, children: "click here" }),
|
|
596
619
|
" to see it."
|
|
597
620
|
] }),
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
void 0,
|
|
601
|
-
() => {
|
|
602
|
-
}
|
|
603
|
-
];
|
|
621
|
+
preventClickToCopy: true
|
|
622
|
+
};
|
|
604
623
|
};
|
|
605
|
-
var addStaticGroup =
|
|
624
|
+
var addStaticGroup = createAppAsyncThunk(
|
|
606
625
|
`${sliceName3}/addStaticGroup`,
|
|
607
626
|
({ group, devices }, { dispatch, getState }) => Promise.resolve(dispatch(addDevicesToGroup({ group, deviceIds: devices.map(({ id }) => id), isCreation: true }))).then(
|
|
608
627
|
() => Promise.resolve(
|
|
@@ -615,23 +634,23 @@ var addStaticGroup = createAsyncThunk2(
|
|
|
615
634
|
).then(
|
|
616
635
|
() => Promise.all([
|
|
617
636
|
dispatch(setDeviceListState({ setOnly: true })),
|
|
618
|
-
dispatch(
|
|
619
|
-
dispatch(setSnackbar2(
|
|
637
|
+
dispatch(getGroups()),
|
|
638
|
+
dispatch(setSnackbar2(getGroupNotification(group, getState().devices.groups.selectedGroup)))
|
|
620
639
|
])
|
|
621
640
|
)
|
|
622
641
|
).catch((err) => commonErrorHandler(err, `Group could not be updated:`, dispatch))
|
|
623
642
|
);
|
|
624
|
-
var removeStaticGroup =
|
|
643
|
+
var removeStaticGroup = createAppAsyncThunk(
|
|
625
644
|
`${sliceName3}/removeStaticGroup`,
|
|
626
645
|
(groupName, { dispatch }) => general_api_default.delete(`${inventoryApiUrl}/groups/${groupName}`).then(
|
|
627
646
|
() => Promise.all([
|
|
628
647
|
dispatch(actions3.removeGroup(groupName)),
|
|
629
|
-
dispatch(
|
|
630
|
-
dispatch(setSnackbar2("Group was removed successfully", TIMEOUTS.fiveSeconds))
|
|
648
|
+
dispatch(getGroups()),
|
|
649
|
+
dispatch(setSnackbar2({ message: "Group was removed successfully", autoHideDuration: TIMEOUTS.fiveSeconds }))
|
|
631
650
|
])
|
|
632
651
|
)
|
|
633
652
|
);
|
|
634
|
-
var getDynamicGroups =
|
|
653
|
+
var getDynamicGroups = createAppAsyncThunk(
|
|
635
654
|
`${sliceName3}/getDynamicGroups`,
|
|
636
655
|
(_, { dispatch, getState }) => general_api_default.get(`${inventoryApiUrlV2}/filters?per_page=${MAX_PAGE_SIZE}`).then(({ data: filters }) => {
|
|
637
656
|
const state = getGroupsById(getState());
|
|
@@ -654,7 +673,7 @@ var getDynamicGroups = createAsyncThunk2(
|
|
|
654
673
|
return Promise.resolve(dispatch(actions3.receivedGroups(groups)));
|
|
655
674
|
}).catch(() => console.log("Dynamic group retrieval failed - likely accessing a non-enterprise backend"))
|
|
656
675
|
);
|
|
657
|
-
var addDynamicGroup =
|
|
676
|
+
var addDynamicGroup = createAppAsyncThunk(
|
|
658
677
|
`${sliceName3}/addDynamicGroup`,
|
|
659
678
|
({ groupName, filterPredicates }, { dispatch, getState }) => general_api_default.post(`${inventoryApiUrlV2}/filters`, { name: groupName, terms: mapFiltersToTerms(filterPredicates) }).then(
|
|
660
679
|
(res) => Promise.resolve(
|
|
@@ -671,45 +690,56 @@ var addDynamicGroup = createAsyncThunk2(
|
|
|
671
690
|
const { cleanedFilters } = getGroupFilters(groupName, getState().devices.groups);
|
|
672
691
|
return Promise.all([
|
|
673
692
|
dispatch(actions3.setDeviceFilters(cleanedFilters)),
|
|
674
|
-
dispatch(setSnackbar2(
|
|
693
|
+
dispatch(setSnackbar2(getGroupNotification(groupName, getState().devices.groups.selectedGroup))),
|
|
675
694
|
dispatch(getDynamicGroups())
|
|
676
695
|
]);
|
|
677
696
|
})
|
|
678
697
|
).catch((err) => commonErrorHandler(err, `Group could not be updated:`, dispatch))
|
|
679
698
|
);
|
|
680
|
-
var updateDynamicGroup =
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
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 }) => {
|
|
685
709
|
const filterId = getState().devices.groups.byId[groupName].id;
|
|
686
710
|
return general_api_default.delete(`${inventoryApiUrlV2}/filters/${filterId}`).then(
|
|
687
|
-
() => Promise.all([
|
|
711
|
+
() => Promise.all([
|
|
712
|
+
dispatch(actions3.removeGroup(groupName)),
|
|
713
|
+
dispatch(setSnackbar2({ message: "Group was removed successfully", autoHideDuration: TIMEOUTS.fiveSeconds }))
|
|
714
|
+
])
|
|
688
715
|
);
|
|
689
716
|
});
|
|
690
717
|
var getGroupFilters = (group, groupsState, filters = []) => {
|
|
691
718
|
const groupName = group === UNGROUPED_GROUP.id || group === UNGROUPED_GROUP.name ? UNGROUPED_GROUP.id : group;
|
|
692
719
|
const selectedGroup = groupsState.byId[groupName];
|
|
693
720
|
const groupFilterLength = selectedGroup?.filters?.length || 0;
|
|
694
|
-
const cleanedFilters = groupFilterLength ? [...filters, ...selectedGroup.filters].filter(filtersFilter) : filters;
|
|
721
|
+
const cleanedFilters = groupFilterLength ? [...filters, ...selectedGroup.filters || []].filter(filtersFilter) : filters;
|
|
695
722
|
return { cleanedFilters, groupName, selectedGroup, groupFilterLength };
|
|
696
723
|
};
|
|
697
|
-
var selectGroup =
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
tasks
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
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);
|
|
708
741
|
}
|
|
709
|
-
|
|
710
|
-
tasks.push(dispatch(actions3.selectGroup(selectedGroupName)));
|
|
711
|
-
return Promise.all(tasks);
|
|
712
|
-
});
|
|
742
|
+
);
|
|
713
743
|
var getEarliestTs = (dateA = "", dateB = "") => !dateA || !dateB ? dateA || dateB : dateA < dateB ? dateA : dateB;
|
|
714
744
|
var reduceReceivedDevices = (devices, ids, state, status) => devices.reduce(
|
|
715
745
|
(accu, device) => {
|
|
@@ -740,11 +770,16 @@ var reduceReceivedDevices = (devices, ids, state, status) => devices.reduce(
|
|
|
740
770
|
},
|
|
741
771
|
{ ids, devicesById: {} }
|
|
742
772
|
);
|
|
743
|
-
var getGroupDevices =
|
|
773
|
+
var getGroupDevices = createAppAsyncThunk(`${sliceName3}/getGroupDevices`, (options, { dispatch, getState }) => {
|
|
744
774
|
const { group, shouldIncludeAllStates, ...remainder } = options;
|
|
745
775
|
const { cleanedFilters: filterSelection } = getGroupFilters(group, getState().devices.groups);
|
|
746
|
-
return
|
|
747
|
-
|
|
776
|
+
return dispatch(
|
|
777
|
+
getDevicesByStatus({
|
|
778
|
+
...remainder,
|
|
779
|
+
filterSelection,
|
|
780
|
+
group,
|
|
781
|
+
status: shouldIncludeAllStates ? void 0 : DEVICE_STATES.accepted
|
|
782
|
+
})
|
|
748
783
|
).unwrap().then((results) => {
|
|
749
784
|
if (!group) {
|
|
750
785
|
return Promise.resolve();
|
|
@@ -758,7 +793,7 @@ var getGroupDevices = createAsyncThunk2(`${sliceName3}/getGroupDevices`, (option
|
|
|
758
793
|
dispatch(
|
|
759
794
|
actions3.addGroup({
|
|
760
795
|
group: {
|
|
761
|
-
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,
|
|
762
797
|
total
|
|
763
798
|
},
|
|
764
799
|
groupName: group
|
|
@@ -767,55 +802,63 @@ var getGroupDevices = createAsyncThunk2(`${sliceName3}/getGroupDevices`, (option
|
|
|
767
802
|
);
|
|
768
803
|
});
|
|
769
804
|
});
|
|
770
|
-
var getAllGroupDevices =
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
filters: [],
|
|
776
|
-
group,
|
|
777
|
-
state: getState(),
|
|
778
|
-
status: DEVICE_STATES.accepted
|
|
779
|
-
});
|
|
780
|
-
const getAllDevices = (perPage = MAX_PAGE_SIZE, page = defaultPage2, devices = []) => general_api_default.post(getSearchEndpoint(getState()), {
|
|
781
|
-
page,
|
|
782
|
-
per_page: perPage,
|
|
783
|
-
filters: filterTerms,
|
|
784
|
-
attributes
|
|
785
|
-
}).then((res) => {
|
|
786
|
-
const state = getState();
|
|
787
|
-
const deviceAccu = reduceReceivedDevices(res.data, devices, state);
|
|
788
|
-
dispatch(actions3.receivedDevices(deviceAccu.devicesById));
|
|
789
|
-
const total = Number(res.headers[headerNames.total]);
|
|
790
|
-
if (total > perPage * page) {
|
|
791
|
-
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();
|
|
792
810
|
}
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
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();
|
|
800
833
|
}
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
const state = getState();
|
|
808
|
-
const deviceAccu = reduceReceivedDevices(res.data, devices, state);
|
|
809
|
-
dispatch(actions3.receivedDevices(deviceAccu.devicesById));
|
|
810
|
-
const total = Number(res.headers[headerNames.total]);
|
|
811
|
-
if (total > deviceAccu.ids.length) {
|
|
812
|
-
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();
|
|
813
840
|
}
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
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(
|
|
819
862
|
`${sliceName3}/getDeviceById`,
|
|
820
863
|
(id, { dispatch, getState }) => general_api_default.get(`${inventoryApiUrl}/devices/${id}`).then((res) => {
|
|
821
864
|
const device = reduceReceivedDevices([res.data], [], getState()).devicesById[id];
|
|
@@ -833,7 +876,8 @@ var getDeviceById2 = createAsyncThunk2(
|
|
|
833
876
|
attributes: [
|
|
834
877
|
{ name: "status", value: "decomissioned", scope: "identity" },
|
|
835
878
|
{ name: "decomissioned", value: "true", scope: "inventory" }
|
|
836
|
-
]
|
|
879
|
+
],
|
|
880
|
+
log: false
|
|
837
881
|
}
|
|
838
882
|
],
|
|
839
883
|
[],
|
|
@@ -843,17 +887,20 @@ var getDeviceById2 = createAsyncThunk2(
|
|
|
843
887
|
}
|
|
844
888
|
})
|
|
845
889
|
);
|
|
846
|
-
var getDeviceInfo =
|
|
890
|
+
var getDeviceInfo = createAppAsyncThunk(`${sliceName3}/getDeviceInfo`, (deviceId, { dispatch, getState }) => {
|
|
847
891
|
const device = getDeviceById(getState(), deviceId);
|
|
848
892
|
const { hasDeviceConfig, hasDeviceConnect, hasMonitor } = getTenantCapabilities(getState());
|
|
849
893
|
const { canConfigure } = getUserCapabilities(getState());
|
|
850
894
|
const integrations = getDeviceTwinIntegrations(getState());
|
|
851
|
-
|
|
852
|
-
|
|
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)) {
|
|
853
901
|
tasks.push(dispatch(getDeviceConfig(deviceId)));
|
|
854
902
|
}
|
|
855
903
|
if (device.status === DEVICE_STATES.accepted) {
|
|
856
|
-
tasks.push(dispatch(getDeviceById2(deviceId)));
|
|
857
904
|
if (hasDeviceConnect) {
|
|
858
905
|
tasks.push(dispatch(getDeviceConnect(deviceId)));
|
|
859
906
|
}
|
|
@@ -864,25 +911,7 @@ var getDeviceInfo = createAsyncThunk2(`${sliceName3}/getDeviceInfo`, (deviceId,
|
|
|
864
911
|
}
|
|
865
912
|
return Promise.all(tasks);
|
|
866
913
|
});
|
|
867
|
-
var
|
|
868
|
-
const yesterday = /* @__PURE__ */ new Date();
|
|
869
|
-
yesterday.setDate(yesterday.getDate() - 1);
|
|
870
|
-
const yesterdaysIsoString = yesterday.toISOString();
|
|
871
|
-
const devices = deviceIds.reduce(
|
|
872
|
-
(accu, id) => {
|
|
873
|
-
const device = getDeviceById(getState(), id);
|
|
874
|
-
if (device && device.updated_ts > yesterdaysIsoString) {
|
|
875
|
-
accu.active.push(id);
|
|
876
|
-
} else {
|
|
877
|
-
accu.inactive.push(id);
|
|
878
|
-
}
|
|
879
|
-
return accu;
|
|
880
|
-
},
|
|
881
|
-
{ active: [], inactive: [] }
|
|
882
|
-
);
|
|
883
|
-
return dispatch(actions3.setInactiveDevices({ activeDeviceTotal: devices.active.length, inactiveDeviceTotal: devices.inactive.length }));
|
|
884
|
-
});
|
|
885
|
-
var getDeviceCount = createAsyncThunk2(
|
|
914
|
+
var getDeviceCount = createAppAsyncThunk(
|
|
886
915
|
`${sliceName3}/getDeviceCount`,
|
|
887
916
|
(status, { dispatch, getState }) => general_api_default.post(getSearchEndpoint(getState()), {
|
|
888
917
|
page: 1,
|
|
@@ -891,37 +920,34 @@ var getDeviceCount = createAsyncThunk2(
|
|
|
891
920
|
attributes: defaultAttributes
|
|
892
921
|
}).then((response) => {
|
|
893
922
|
const count = Number(response.headers[headerNames.total]);
|
|
894
|
-
|
|
895
|
-
return dispatch(actions3.setDevicesCountByStatus({ count, status }));
|
|
896
|
-
}
|
|
897
|
-
return dispatch(actions3.setTotalDevices(count));
|
|
923
|
+
return dispatch(actions3.setDevicesCountByStatus({ count, status }));
|
|
898
924
|
})
|
|
899
925
|
);
|
|
900
|
-
var getAllDeviceCounts =
|
|
926
|
+
var getAllDeviceCounts = createAppAsyncThunk(
|
|
901
927
|
`${sliceName3}/getAllDeviceCounts`,
|
|
902
928
|
(_, { dispatch }) => Promise.all([DEVICE_STATES.accepted, DEVICE_STATES.pending].map((status) => dispatch(getDeviceCount(status))))
|
|
903
929
|
);
|
|
904
|
-
var getDeviceLimit =
|
|
930
|
+
var getDeviceLimit = createAppAsyncThunk(
|
|
905
931
|
`${sliceName3}/getDeviceLimit`,
|
|
906
932
|
(_, { dispatch }) => general_api_default.get(`${deviceAuthV2}/limits/max_devices`).then((res) => dispatch(actions3.setDeviceLimit(res.data.limit)))
|
|
907
933
|
);
|
|
908
|
-
var setDeviceListState =
|
|
934
|
+
var setDeviceListState = createAppAsyncThunk(
|
|
909
935
|
`${sliceName3}/setDeviceListState`,
|
|
910
936
|
({ shouldSelectDevices = true, forceRefresh, fetchAuth = true, ...selectionState }, { dispatch, getState }) => {
|
|
911
937
|
const currentState = getDeviceListState(getState());
|
|
912
938
|
const refreshTrigger = forceRefresh ? !currentState.refreshTrigger : selectionState.refreshTrigger;
|
|
913
|
-
|
|
939
|
+
const nextState = {
|
|
914
940
|
...currentState,
|
|
915
941
|
setOnly: false,
|
|
916
942
|
refreshTrigger,
|
|
917
943
|
...selectionState,
|
|
918
944
|
sort: { ...currentState.sort, ...selectionState.sort }
|
|
919
945
|
};
|
|
920
|
-
|
|
946
|
+
const tasks = [];
|
|
921
947
|
const { isLoading: currentLoading, deviceIds: currentDevices, selection: currentSelection, ...currentRequestState } = currentState;
|
|
922
948
|
const { isLoading: nextLoading, deviceIds: nextDevices, selection: nextSelection, ...nextRequestState } = nextState;
|
|
923
949
|
if (!nextState.setOnly && !deepCompare2(currentRequestState, nextRequestState)) {
|
|
924
|
-
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 ?? {};
|
|
925
951
|
const sortBy = sortCol ? [{ attribute: sortCol, order: sortDown, scope: sortScope }] : void 0;
|
|
926
952
|
const applicableSelectedState = nextState.state === ALL_DEVICE_STATES ? void 0 : nextState.state;
|
|
927
953
|
nextState.isLoading = true;
|
|
@@ -937,83 +963,84 @@ var setDeviceListState = createAsyncThunk2(
|
|
|
937
963
|
return Promise.all(tasks);
|
|
938
964
|
}
|
|
939
965
|
);
|
|
940
|
-
var getDevicesByStatus =
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
filters: filterSelection ?? getDeviceFilters(state),
|
|
955
|
-
group: group ?? getSelectedGroup(state),
|
|
956
|
-
groups: state.devices.groups,
|
|
957
|
-
offlineThreshold: state.app.offlineThreshold,
|
|
958
|
-
selectedIssues,
|
|
959
|
-
status
|
|
960
|
-
});
|
|
961
|
-
const attributes = [...defaultAttributes, getIdAttribute(getState()), ...selectedAttributes];
|
|
962
|
-
return general_api_default.post(getSearchEndpoint(getState()), {
|
|
963
|
-
page,
|
|
964
|
-
per_page: perPage,
|
|
965
|
-
filters: filterTerms,
|
|
966
|
-
sort: sortOptions,
|
|
967
|
-
attributes
|
|
968
|
-
}).then((response) => {
|
|
969
|
-
const state2 = getState();
|
|
970
|
-
const deviceAccu = reduceReceivedDevices(response.data, [], state2, status);
|
|
971
|
-
let total = !applicableFilters.length ? Number(response.headers[headerNames.total]) : null;
|
|
972
|
-
if (status && state2.devices.byStatus[status].total === deviceAccu.ids.length) {
|
|
973
|
-
total = deviceAccu.ids.length;
|
|
974
|
-
}
|
|
975
|
-
let tasks = [dispatch(actions3.receivedDevices(deviceAccu.devicesById))];
|
|
976
|
-
if (status) {
|
|
977
|
-
tasks.push(dispatch(actions3.setDevicesByStatus({ deviceIds: deviceAccu.ids, status, total })));
|
|
978
|
-
}
|
|
979
|
-
const receivedDevices = Object.values(deviceAccu.devicesById);
|
|
980
|
-
if (receivedDevices.length && fetchAuth) {
|
|
981
|
-
tasks.push(dispatch(getDevicesWithAuth(receivedDevices)));
|
|
982
|
-
}
|
|
983
|
-
tasks.push(Promise.resolve({ deviceAccu, total: Number(response.headers[headerNames.total]) }));
|
|
984
|
-
return Promise.all(tasks);
|
|
985
|
-
}).catch((err) => commonErrorHandler(err, `${status} devices couldn't be loaded.`, dispatch, commonErrorFallback));
|
|
986
|
-
});
|
|
987
|
-
var getAllDevicesByStatus = createAsyncThunk2(`${sliceName3}/getAllDevicesByStatus`, (status, { dispatch, getState }) => {
|
|
988
|
-
const attributes = [...defaultAttributes, getIdAttribute(getState())];
|
|
989
|
-
const getAllDevices = (perPage = MAX_PAGE_SIZE, page = 1, devices = []) => general_api_default.post(getSearchEndpoint(getState()), {
|
|
990
|
-
page,
|
|
991
|
-
per_page: perPage,
|
|
992
|
-
filters: mapFiltersToTerms([{ key: "status", value: status, operator: DEVICE_FILTERING_OPTIONS.$eq.key, scope: "identity" }]),
|
|
993
|
-
attributes
|
|
994
|
-
}).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;
|
|
995
980
|
const state = getState();
|
|
996
|
-
const
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
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
|
+
}
|
|
1000
1036
|
return Promise.resolve();
|
|
1001
|
-
}
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
if (status === DEVICE_STATES.accepted && deviceAccu.ids.length === total) {
|
|
1007
|
-
tasks.push(dispatch(deriveInactiveDevices(deviceAccu.ids)));
|
|
1008
|
-
tasks.push(dispatch(deriveReportsData()));
|
|
1009
|
-
}
|
|
1010
|
-
return Promise.all(tasks);
|
|
1011
|
-
});
|
|
1012
|
-
return getAllDevices();
|
|
1013
|
-
});
|
|
1014
|
-
var searchDevices = createAsyncThunk2(`${sliceName3}/searchDevices`, (passedOptions = {}, { dispatch, getState }) => {
|
|
1037
|
+
});
|
|
1038
|
+
return getAllDevices();
|
|
1039
|
+
}
|
|
1040
|
+
);
|
|
1041
|
+
var searchDevices = createAppAsyncThunk(`${sliceName3}/searchDevices`, (passedOptions = {}, { dispatch, getState }) => {
|
|
1015
1042
|
const state = getState();
|
|
1016
|
-
|
|
1043
|
+
const options = { ...state.app.searchState, ...passedOptions };
|
|
1017
1044
|
const { page = defaultPage2, searchTerm, sortOptions = [] } = options;
|
|
1018
1045
|
const { columnSelection = [] } = getUserSettings(state);
|
|
1019
1046
|
const selectedAttributes = columnSelection.map((column) => ({ attribute: column.key, scope: column.scope }));
|
|
@@ -1044,64 +1071,25 @@ var attributeReducer = (attributes = []) => attributes.slice(0, ATTRIBUTE_LIST_C
|
|
|
1044
1071
|
},
|
|
1045
1072
|
{ identity: [], inventory: [], system: [], tags: [] }
|
|
1046
1073
|
);
|
|
1047
|
-
var getDeviceAttributes =
|
|
1074
|
+
var getDeviceAttributes = createAppAsyncThunk(
|
|
1048
1075
|
`${sliceName3}/getDeviceAttributes`,
|
|
1049
1076
|
(_, { dispatch, getState }) => general_api_default.get(getAttrsEndpoint(getState())).then(({ data }) => {
|
|
1050
1077
|
const { identity: identityAttributes, inventory: inventoryAttributes, system: systemAttributes, tags: tagAttributes } = attributeReducer(data || []);
|
|
1051
1078
|
return dispatch(actions3.setFilterAttributes({ identityAttributes, inventoryAttributes, systemAttributes, tagAttributes }));
|
|
1052
1079
|
})
|
|
1053
1080
|
);
|
|
1054
|
-
var getReportingLimits = createAsyncThunk2(
|
|
1055
|
-
`${sliceName3}/getReportingLimits`,
|
|
1056
|
-
(_, { dispatch }) => general_api_default.get(`${reportingApiUrl}/devices/attributes`).catch((err) => commonErrorHandler(err, `filterable attributes limit & usage could not be retrieved.`, dispatch, commonErrorFallback)).then(({ data }) => {
|
|
1057
|
-
const { attributes, count, limit } = data;
|
|
1058
|
-
const groupedAttributes = attributeReducer(attributes);
|
|
1059
|
-
return Promise.resolve(dispatch(actions3.setFilterablesConfig({ count, limit, attributes: groupedAttributes })));
|
|
1060
|
-
})
|
|
1061
|
-
);
|
|
1062
|
-
var ensureVersionString = (software, fallback) => software.length && software !== "artifact_name" ? software.endsWith(".version") ? software : `${software}.version` : fallback;
|
|
1063
|
-
var getSingleReportData = (reportConfig, groups) => {
|
|
1064
|
-
const { attribute, group, software = "" } = reportConfig;
|
|
1065
|
-
const filters = [{ key: "status", scope: "identity", operator: DEVICE_FILTERING_OPTIONS.$eq.key, value: "accepted" }];
|
|
1066
|
-
if (group) {
|
|
1067
|
-
const staticGroupFilter = { key: "group", scope: "system", operator: DEVICE_FILTERING_OPTIONS.$eq.key, value: group };
|
|
1068
|
-
const { cleanedFilters: groupFilters } = getGroupFilters(group, groups);
|
|
1069
|
-
filters.push(...groupFilters.length ? groupFilters : [staticGroupFilter]);
|
|
1070
|
-
}
|
|
1071
|
-
const aggregationAttribute = ensureVersionString(software, attribute);
|
|
1072
|
-
return general_api_default.post(`${reportingApiUrl}/devices/aggregate`, {
|
|
1073
|
-
aggregations: [{ attribute: aggregationAttribute, name: "*", scope: "inventory", size: REPORT_CHART_SIZE_LIMIT }],
|
|
1074
|
-
filters: mapFiltersToTerms(filters)
|
|
1075
|
-
}).then(({ data }) => ({ data, reportConfig }));
|
|
1076
|
-
};
|
|
1077
|
-
var getReportsData = createAsyncThunk2(`${sliceName3}/getReportsData`, (_, { dispatch, getState }) => {
|
|
1078
|
-
const state = getState();
|
|
1079
|
-
const currentUserId = getCurrentUser(state).id;
|
|
1080
|
-
const reports = getUserSettings(state).reports || getGlobalSettings(state)[`${currentUserId}-reports`] || (Object.keys(getDevicesById(state)).length ? defaultReports : []);
|
|
1081
|
-
return Promise.all(reports.map((report) => getSingleReportData(report, getState().devices.groups))).then((results) => {
|
|
1082
|
-
const devicesState = getState().devices;
|
|
1083
|
-
const totalDeviceCount = devicesState.byStatus.accepted.total;
|
|
1084
|
-
const newReports = results.map(({ data, reportConfig }) => {
|
|
1085
|
-
let { items, other_count } = data[0];
|
|
1086
|
-
const { attribute, group, software = "" } = reportConfig;
|
|
1087
|
-
const dataCount = items.reduce((accu, item) => accu + item.count, 0);
|
|
1088
|
-
const otherCount = !group && (software === rootfsImageVersion || attribute === "artifact_name") ? totalDeviceCount - dataCount : other_count;
|
|
1089
|
-
return { items, otherCount, total: otherCount + dataCount };
|
|
1090
|
-
});
|
|
1091
|
-
return Promise.resolve(dispatch(actions3.setDeviceReports(newReports)));
|
|
1092
|
-
});
|
|
1093
|
-
});
|
|
1094
1081
|
var initializeDistributionData = (report, groups, devices, totalDeviceCount) => {
|
|
1095
1082
|
const { attribute, group = "", software = "" } = report;
|
|
1096
1083
|
const effectiveAttribute = software ? software : attribute;
|
|
1097
1084
|
const { deviceIds, total = 0 } = groups[group] || {};
|
|
1098
|
-
const relevantDevices =
|
|
1085
|
+
const relevantDevices = deviceIds ? deviceIds.map((id) => devices[id]) : Object.values(devices);
|
|
1099
1086
|
const distributionByAttribute = relevantDevices.reduce((accu, item) => {
|
|
1100
1087
|
if (!item.attributes || item.status !== DEVICE_STATES.accepted) return accu;
|
|
1101
|
-
|
|
1102
|
-
|
|
1088
|
+
const attributeValue = item.attributes[effectiveAttribute];
|
|
1089
|
+
if (!accu[attributeValue]) {
|
|
1090
|
+
accu[attributeValue] = 0;
|
|
1103
1091
|
}
|
|
1104
|
-
accu[
|
|
1092
|
+
accu[attributeValue] = accu[attributeValue] + 1;
|
|
1105
1093
|
return accu;
|
|
1106
1094
|
}, {});
|
|
1107
1095
|
const distributionByAttributeSorted = Object.entries(distributionByAttribute).sort((pairA, pairB) => pairB[1] - pairA[1]);
|
|
@@ -1110,90 +1098,111 @@ var initializeDistributionData = (report, groups, devices, totalDeviceCount) =>
|
|
|
1110
1098
|
const otherCount = (groups[group] ? total : totalDeviceCount) - dataCount;
|
|
1111
1099
|
return { items, otherCount, total: otherCount + dataCount };
|
|
1112
1100
|
};
|
|
1113
|
-
var
|
|
1114
|
-
const
|
|
1115
|
-
const
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
const
|
|
1123
|
-
|
|
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);
|
|
1124
1112
|
return Promise.resolve(dispatch(actions3.setDeviceReports(newReports)));
|
|
1125
1113
|
});
|
|
1126
|
-
var
|
|
1127
|
-
`${sliceName3}/
|
|
1128
|
-
(
|
|
1129
|
-
const
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
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
|
+
}
|
|
1135
1138
|
);
|
|
1136
|
-
var getDeviceConnect =
|
|
1139
|
+
var getDeviceConnect = createAppAsyncThunk(
|
|
1137
1140
|
`${sliceName3}/getDeviceConnect`,
|
|
1138
1141
|
(id, { dispatch }) => general_api_default.get(`${deviceConnect}/devices/${id}`).then(
|
|
1139
1142
|
({ data }) => Promise.all([dispatch(actions3.receivedDevice({ connect_status: data.status, connect_updated_ts: data.updated_ts, id })), Promise.resolve(data)])
|
|
1140
1143
|
)
|
|
1141
1144
|
);
|
|
1142
1145
|
var updateTypeMap = { deploymentUpdate: "check-update", inventoryUpdate: "send-inventory" };
|
|
1143
|
-
var triggerDeviceUpdate =
|
|
1146
|
+
var triggerDeviceUpdate = createAppAsyncThunk(
|
|
1144
1147
|
`${sliceName3}/triggerDeviceUpdate`,
|
|
1145
1148
|
({ id, type }, { dispatch }) => general_api_default.post(`${deviceConnect}/devices/${id}/${updateTypeMap[type] ?? updateTypeMap.deploymentUpdate}`).then(
|
|
1146
1149
|
() => new Promise((resolve) => setTimeout(() => resolve(dispatch(getDeviceById2(id))), TIMEOUTS.threeSeconds))
|
|
1147
1150
|
)
|
|
1148
1151
|
);
|
|
1149
|
-
var getSessionDetails =
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
}
|
|
1170
|
-
|
|
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(
|
|
1171
1177
|
`${sliceName3}/getDeviceFileDownloadLink`,
|
|
1172
1178
|
({ deviceId, path }) => Promise.resolve(`${window.location.origin}${deviceConnect}/devices/${deviceId}/download?path=${encodeURIComponent(path)}`)
|
|
1173
1179
|
);
|
|
1174
|
-
var deviceFileUpload =
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
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(
|
|
1197
1206
|
`${sliceName3}/getDeviceAuth`,
|
|
1198
1207
|
(id, { dispatch }) => dispatch(getDevicesWithAuth([{ id }])).unwrap().then((results) => {
|
|
1199
1208
|
if (results[results.length - 1]) {
|
|
@@ -1202,64 +1211,69 @@ var getDeviceAuth = createAsyncThunk2(
|
|
|
1202
1211
|
return Promise.resolve();
|
|
1203
1212
|
})
|
|
1204
1213
|
);
|
|
1205
|
-
var getDevicesWithAuth =
|
|
1214
|
+
var getDevicesWithAuth = createAppAsyncThunk(
|
|
1206
1215
|
`${sliceName3}/getDevicesWithAuth`,
|
|
1207
1216
|
(devices, { dispatch, getState }) => devices.length ? general_api_default.get(`${deviceAuthV2}/devices?id=${devices.map((device) => device.id).join("&id=")}`).then(({ data: receivedDevices }) => {
|
|
1208
1217
|
const { devicesById } = reduceReceivedDevices(receivedDevices, [], getState());
|
|
1209
1218
|
return Promise.all([dispatch(actions3.receivedDevices(devicesById)), Promise.resolve(receivedDevices)]);
|
|
1210
1219
|
}).catch((err) => commonErrorHandler(err, `Error: ${err}`, dispatch)) : Promise.resolve([[], []])
|
|
1211
1220
|
);
|
|
1212
|
-
var updateDeviceAuth =
|
|
1221
|
+
var updateDeviceAuth = createAppAsyncThunk(
|
|
1213
1222
|
`${sliceName3}/updateDeviceAuth`,
|
|
1214
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 })))
|
|
1215
1224
|
);
|
|
1216
|
-
var updateDevicesAuth =
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
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
|
+
});
|
|
1242
1254
|
});
|
|
1243
|
-
}
|
|
1244
|
-
|
|
1245
|
-
var deleteAuthset =
|
|
1255
|
+
}
|
|
1256
|
+
);
|
|
1257
|
+
var deleteAuthset = createAppAsyncThunk(
|
|
1246
1258
|
`${sliceName3}/deleteAuthset`,
|
|
1247
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 })))
|
|
1248
1260
|
);
|
|
1249
|
-
var preauthDevice =
|
|
1261
|
+
var preauthDevice = createAppAsyncThunk(
|
|
1250
1262
|
`${sliceName3}/preauthDevice`,
|
|
1251
|
-
(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) => {
|
|
1252
1266
|
if (err.response.status === 409) {
|
|
1253
1267
|
return rejectWithValue("A device with a matching identity data set already exists");
|
|
1254
1268
|
}
|
|
1255
1269
|
return commonErrorHandler(err, "The device could not be added:", dispatch);
|
|
1256
1270
|
})
|
|
1257
1271
|
);
|
|
1258
|
-
var decommissionDevice =
|
|
1272
|
+
var decommissionDevice = createAppAsyncThunk(
|
|
1259
1273
|
`${sliceName3}/decommissionDevice`,
|
|
1260
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 })))
|
|
1261
1275
|
);
|
|
1262
|
-
var getDeviceConfig =
|
|
1276
|
+
var getDeviceConfig = createAppAsyncThunk(
|
|
1263
1277
|
`${sliceName3}/getDeviceConfig`,
|
|
1264
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) => {
|
|
1265
1279
|
if (err.response?.data?.error.status_code !== 404) {
|
|
@@ -1267,16 +1281,16 @@ var getDeviceConfig = createAsyncThunk2(
|
|
|
1267
1281
|
}
|
|
1268
1282
|
})
|
|
1269
1283
|
);
|
|
1270
|
-
var setDeviceConfig =
|
|
1284
|
+
var setDeviceConfig = createAppAsyncThunk(
|
|
1271
1285
|
`${sliceName3}/setDeviceConfig`,
|
|
1272
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))))
|
|
1273
1287
|
);
|
|
1274
|
-
var applyDeviceConfig =
|
|
1288
|
+
var applyDeviceConfig = createAppAsyncThunk(
|
|
1275
1289
|
`${sliceName3}/applyDeviceConfig`,
|
|
1276
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 }) => {
|
|
1277
1291
|
const device = getDeviceById(getState(), deviceId);
|
|
1278
1292
|
const { canManageUsers } = getUserCapabilities(getState());
|
|
1279
|
-
|
|
1293
|
+
const tasks = [
|
|
1280
1294
|
dispatch(actions3.receivedDevice({ ...device, config: { ...device.config, deployment_id: data.deployment_id } })),
|
|
1281
1295
|
new Promise((resolve) => setTimeout(() => resolve(dispatch(getSingleDeployment(data.deployment_id))), TIMEOUTS.oneSecond))
|
|
1282
1296
|
];
|
|
@@ -1287,21 +1301,24 @@ var applyDeviceConfig = createAsyncThunk2(
|
|
|
1287
1301
|
return Promise.all(tasks);
|
|
1288
1302
|
})
|
|
1289
1303
|
);
|
|
1290
|
-
var setDeviceTags =
|
|
1304
|
+
var setDeviceTags = createAppAsyncThunk(
|
|
1291
1305
|
`${sliceName3}/setDeviceTags`,
|
|
1292
1306
|
({ deviceId, tags }, { dispatch }) => (
|
|
1293
1307
|
// to prevent tag set failures, retrieve the device & use the freshest etag we can get
|
|
1294
|
-
|
|
1308
|
+
dispatch(getDeviceById2(deviceId)).unwrap().then((device) => {
|
|
1295
1309
|
const headers = device.etag ? { "If-Match": device.etag } : {};
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
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
|
+
);
|
|
1301
1318
|
})
|
|
1302
1319
|
)
|
|
1303
1320
|
);
|
|
1304
|
-
var getDeviceTwin =
|
|
1321
|
+
var getDeviceTwin = createAppAsyncThunk(`${sliceName3}/getDeviceTwin`, ({ deviceId, integration }, { dispatch, getState }) => {
|
|
1305
1322
|
let providerResult = {};
|
|
1306
1323
|
return general_api_default.get(`${iotManagerBaseURL}/devices/${deviceId}/state`).then(({ data }) => {
|
|
1307
1324
|
providerResult = { ...data, twinError: "" };
|
|
@@ -1314,7 +1331,7 @@ var getDeviceTwin = createAsyncThunk2(`${sliceName3}/getDeviceTwin`, ({ deviceId
|
|
|
1314
1331
|
Promise.resolve(dispatch(actions3.receivedDevice({ ...device, twinsByIntegration: { ...device.twinsByIntegration, ...providerResult } })));
|
|
1315
1332
|
});
|
|
1316
1333
|
});
|
|
1317
|
-
var setDeviceTwin =
|
|
1334
|
+
var setDeviceTwin = createAppAsyncThunk(
|
|
1318
1335
|
`${sliceName3}/setDeviceTwin`,
|
|
1319
1336
|
({ deviceId, integration, settings }, { dispatch, getState }) => general_api_default.put(`${iotManagerBaseURL}/devices/${deviceId}/state/${integration.id}`, { desired: settings }).catch(
|
|
1320
1337
|
(err) => commonErrorHandler(
|
|
@@ -1327,7 +1344,9 @@ var setDeviceTwin = createAsyncThunk2(
|
|
|
1327
1344
|
const { twinsByIntegration = {} } = device;
|
|
1328
1345
|
const { [integration.id]: currentState = {} } = twinsByIntegration;
|
|
1329
1346
|
return Promise.resolve(
|
|
1330
|
-
dispatch(
|
|
1347
|
+
dispatch(
|
|
1348
|
+
actions3.receivedDevice({ ...device, twinsByIntegration: { ...twinsByIntegration, [integration.id]: { ...currentState, desired: settings } } })
|
|
1349
|
+
)
|
|
1331
1350
|
);
|
|
1332
1351
|
})
|
|
1333
1352
|
);
|
|
@@ -1338,7 +1357,7 @@ var prepareSearchArguments = ({ filters, group, state, status }) => {
|
|
|
1338
1357
|
const attributes = [...defaultAttributes, getIdAttribute(state), ...selectedAttributes];
|
|
1339
1358
|
return { attributes, filterTerms };
|
|
1340
1359
|
};
|
|
1341
|
-
var getSystemDevices =
|
|
1360
|
+
var getSystemDevices = createAppAsyncThunk(`${sliceName3}/getSystemDevices`, (options, { dispatch, getState }) => {
|
|
1342
1361
|
const { id, page = defaultPage2, perPage = defaultPerPage2, sortOptions = [] } = options;
|
|
1343
1362
|
const state = getState();
|
|
1344
1363
|
const { hasFullFiltering } = getTenantCapabilities(state);
|
|
@@ -1369,7 +1388,7 @@ var getSystemDevices = createAsyncThunk2(`${sliceName3}/getSystemDevices`, (opti
|
|
|
1369
1388
|
return Promise.resolve(dispatch(actions3.receivedDevices({ ...devicesById, [id]: device })));
|
|
1370
1389
|
});
|
|
1371
1390
|
});
|
|
1372
|
-
var getGatewayDevices =
|
|
1391
|
+
var getGatewayDevices = createAppAsyncThunk(`${sliceName3}/getGatewayDevices`, (deviceId, { dispatch, getState }) => {
|
|
1373
1392
|
const state = getState();
|
|
1374
1393
|
const { attributes = {} } = getDeviceById(state, deviceId);
|
|
1375
1394
|
const { mender_gateway_system_id = "" } = attributes;
|
|
@@ -1386,41 +1405,15 @@ var getGatewayDevices = createAsyncThunk2(`${sliceName3}/getGatewayDevices`, (de
|
|
|
1386
1405
|
attributes: attributeSelection
|
|
1387
1406
|
}).then(({ data }) => {
|
|
1388
1407
|
const { ids } = reduceReceivedDevices(data, [], getState());
|
|
1389
|
-
|
|
1408
|
+
const tasks = ids.map((deviceId2) => dispatch(getDeviceInfo(deviceId2)));
|
|
1390
1409
|
tasks.push(dispatch(actions3.receivedDevice({ id: deviceId, gatewayIds: ids })));
|
|
1391
1410
|
return Promise.all(tasks);
|
|
1392
1411
|
});
|
|
1393
1412
|
});
|
|
1394
|
-
var getDevicesInBounds = createAsyncThunk2(`${sliceName3}/getDevicesInBounds`, ({ bounds, group }, { dispatch, getState }) => {
|
|
1395
|
-
const state = getState();
|
|
1396
|
-
const { filterTerms } = convertDeviceListStateToFilters({
|
|
1397
|
-
group: group === ALL_DEVICES ? void 0 : group,
|
|
1398
|
-
groups: state.devices.groups,
|
|
1399
|
-
status: DEVICE_STATES.accepted
|
|
1400
|
-
});
|
|
1401
|
-
return general_api_default.post(getSearchEndpoint(getState()), {
|
|
1402
|
-
page: 1,
|
|
1403
|
-
per_page: MAX_PAGE_SIZE,
|
|
1404
|
-
filters: filterTerms,
|
|
1405
|
-
attributes: geoAttributes,
|
|
1406
|
-
geo_bounding_box_filter: {
|
|
1407
|
-
geo_bounding_box: {
|
|
1408
|
-
location: {
|
|
1409
|
-
top_left: { lat: bounds._northEast.lat, lon: bounds._southWest.lng },
|
|
1410
|
-
bottom_right: { lat: bounds._southWest.lat, lon: bounds._northEast.lng }
|
|
1411
|
-
}
|
|
1412
|
-
}
|
|
1413
|
-
}
|
|
1414
|
-
}).then(({ data }) => {
|
|
1415
|
-
const { devicesById } = reduceReceivedDevices(data, [], getState());
|
|
1416
|
-
return Promise.resolve(dispatch(actions3.receivedDevices(devicesById)));
|
|
1417
|
-
});
|
|
1418
|
-
});
|
|
1419
1413
|
|
|
1420
1414
|
// src/onboardingSlice/thunks.ts
|
|
1421
1415
|
import { getDemoDeviceAddress } from "@northern.tech/utils/helpers";
|
|
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) => {
|
|
@@ -1455,7 +1448,7 @@ var deductOnboardingState = ({ devicesById, devicesByStatus, onboardingState, pa
|
|
|
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,23 +1472,23 @@ 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))),
|
|
@@ -1503,7 +1496,7 @@ var setOnboardingCanceled = createAsyncThunk3(
|
|
|
1503
1496
|
Promise.resolve(dispatch(actions4.setOnboardingComplete(true)))
|
|
1504
1497
|
]).then(() => dispatch(advanceOnboarding(onboardingSteps.DEPLOYMENTS_PAST_COMPLETED_FAILURE))).then(() => Tracking2.event({ category: "onboarding", action: onboardingSteps.ONBOARDING_CANCELED }))
|
|
1505
1498
|
);
|
|
1506
|
-
var advanceOnboarding =
|
|
1499
|
+
var advanceOnboarding = createAppAsyncThunk(`${sliceName4}/advanceOnboarding`, (stepId, { dispatch, getState }) => {
|
|
1507
1500
|
const steps = orderedOnboardingSteps;
|
|
1508
1501
|
const progress2 = steps.findIndex((step) => step === getState().onboarding.progress);
|
|
1509
1502
|
const stepIndex = steps.findIndex((step) => step === stepId);
|
|
@@ -1518,15 +1511,18 @@ var advanceOnboarding = createAsyncThunk3(`${sliceName4}/advanceOnboarding`, (st
|
|
|
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,29 +1624,32 @@ 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 =
|
|
1652
|
+
var addTenant = createAppAsyncThunk(
|
|
1644
1653
|
`${sliceName5}/createTenant`,
|
|
1645
1654
|
(selectionState, { dispatch }) => general_api_default.post(`${tenantadmApiUrlv2}/tenants`, selectionState).then(
|
|
1646
1655
|
() => Promise.all([
|
|
@@ -1656,24 +1665,27 @@ var tenantListRetrieval = async (config) => {
|
|
|
1656
1665
|
const totalCount = tenantList.headers[headerNames.total] || TENANT_LIST_DEFAULT.perPage;
|
|
1657
1666
|
return [tenantList.data, Number(totalCount)];
|
|
1658
1667
|
};
|
|
1659
|
-
var getTenants =
|
|
1668
|
+
var getTenants = createAppAsyncThunk(`${sliceName5}/getTenants`, async (_, { dispatch, getState }) => {
|
|
1660
1669
|
const currentState = getTenantsList(getState());
|
|
1661
1670
|
const [tenants, pageCount] = await tenantListRetrieval(currentState);
|
|
1662
1671
|
dispatch(actions5.setTenantListState({ ...currentState, total: pageCount, tenants }));
|
|
1663
1672
|
});
|
|
1664
|
-
var setTenantsListState =
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
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 }));
|
|
1673
1686
|
}
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
var editTenantDeviceLimit = createAsyncThunk4(
|
|
1687
|
+
);
|
|
1688
|
+
var editTenantDeviceLimit = createAppAsyncThunk(
|
|
1677
1689
|
`${sliceName5}/editDeviceLimit`,
|
|
1678
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(
|
|
1679
1691
|
() => Promise.all([
|
|
@@ -1683,7 +1695,15 @@ var editTenantDeviceLimit = createAsyncThunk4(
|
|
|
1683
1695
|
])
|
|
1684
1696
|
)
|
|
1685
1697
|
);
|
|
1686
|
-
var
|
|
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(
|
|
1687
1707
|
`${sliceName5}/editDeviceLimit`,
|
|
1688
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(
|
|
1689
1709
|
() => Promise.all([
|
|
@@ -1693,10 +1713,10 @@ var removeTenant = createAsyncThunk4(
|
|
|
1693
1713
|
])
|
|
1694
1714
|
)
|
|
1695
1715
|
);
|
|
1696
|
-
var getUserOrganization =
|
|
1716
|
+
var getUserOrganization = createAppAsyncThunk(
|
|
1697
1717
|
`${sliceName5}/getUserOrganization`,
|
|
1698
1718
|
(_, { dispatch, getState }) => general_api_default.get(`${tenantadmApiUrlv1}/user/tenant`).then((res) => {
|
|
1699
|
-
|
|
1719
|
+
const tasks = [dispatch(actions5.setOrganization(res.data))];
|
|
1700
1720
|
const { addons, plan, trial } = res.data;
|
|
1701
1721
|
const { token } = getCurrentSession(getState());
|
|
1702
1722
|
const jwt = jwtDecode(token);
|
|
@@ -1709,30 +1729,59 @@ var getUserOrganization = createAsyncThunk4(
|
|
|
1709
1729
|
return Promise.all(tasks);
|
|
1710
1730
|
})
|
|
1711
1731
|
);
|
|
1712
|
-
var
|
|
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 })));
|
|
1739
|
+
});
|
|
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(
|
|
1713
1762
|
`${sliceName5}/sendSupportMessage`,
|
|
1714
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 }))))
|
|
1715
1764
|
);
|
|
1716
|
-
var requestPlanChange =
|
|
1765
|
+
var requestPlanChange = createAppAsyncThunk(
|
|
1717
1766
|
`${sliceName5}/requestPlanChange`,
|
|
1718
1767
|
({ content, tenantId }, { dispatch, rejectWithValue }) => general_api_default.post(`${tenantadmApiUrlv2}/tenants/${tenantId}/plan`, content).catch(async (err) => {
|
|
1719
1768
|
await commonErrorHandler(err, "There was an error sending your request", dispatch, commonErrorFallback);
|
|
1720
1769
|
rejectWithValue(err);
|
|
1721
1770
|
}).then(() => Promise.resolve(dispatch(setSnackbar3({ message: "Your request was sent successfully", autoHideDuration: TIMEOUTS.fiveSeconds }))))
|
|
1722
1771
|
);
|
|
1723
|
-
var downloadLicenseReport =
|
|
1772
|
+
var downloadLicenseReport = createAppAsyncThunk(
|
|
1724
1773
|
`${sliceName5}/downloadLicenseReport`,
|
|
1725
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)
|
|
1726
1775
|
);
|
|
1727
|
-
var createIntegration =
|
|
1776
|
+
var createIntegration = createAppAsyncThunk(
|
|
1728
1777
|
`${sliceName5}/createIntegration`,
|
|
1729
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())]))
|
|
1730
1779
|
);
|
|
1731
|
-
var changeIntegration =
|
|
1780
|
+
var changeIntegration = createAppAsyncThunk(
|
|
1732
1781
|
`${sliceName5}/changeIntegration`,
|
|
1733
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())]))
|
|
1734
1783
|
);
|
|
1735
|
-
var deleteIntegration =
|
|
1784
|
+
var deleteIntegration = createAppAsyncThunk(
|
|
1736
1785
|
`${sliceName5}/deleteIntegration`,
|
|
1737
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(() => {
|
|
1738
1787
|
const integrations = getState().organization.externalDeviceIntegrations.filter((item) => provider !== item.provider);
|
|
@@ -1742,7 +1791,7 @@ var deleteIntegration = createAsyncThunk4(
|
|
|
1742
1791
|
]);
|
|
1743
1792
|
})
|
|
1744
1793
|
);
|
|
1745
|
-
var getIntegrations =
|
|
1794
|
+
var getIntegrations = createAppAsyncThunk(
|
|
1746
1795
|
`${sliceName5}/getIntegrations`,
|
|
1747
1796
|
(_, { dispatch, getState }) => general_api_default.get(`${iotManagerBaseURL}/integrations`).catch((err) => commonErrorHandler(err, "There was an error retrieving the integration", dispatch, commonErrorFallback)).then(({ data }) => {
|
|
1748
1797
|
const existingIntegrations = getState().organization.externalDeviceIntegrations;
|
|
@@ -1755,10 +1804,10 @@ var getIntegrations = createAsyncThunk4(
|
|
|
1755
1804
|
return Promise.resolve(dispatch(actions5.receiveExternalDeviceIntegrations(integrations)));
|
|
1756
1805
|
})
|
|
1757
1806
|
);
|
|
1758
|
-
var getWebhookEvents =
|
|
1807
|
+
var getWebhookEvents = createAppAsyncThunk(`${sliceName5}/getWebhookEvents`, (config = {}, { dispatch, getState }) => {
|
|
1759
1808
|
const { isFollowUp, page = defaultPage3, perPage = defaultPerPage3 } = config;
|
|
1760
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 }) => {
|
|
1761
|
-
|
|
1810
|
+
const tasks = [
|
|
1762
1811
|
dispatch(
|
|
1763
1812
|
actions5.receiveWebhookEvents({
|
|
1764
1813
|
value: isFollowUp ? getState().organization.webhooks.events : data,
|
|
@@ -1781,29 +1830,29 @@ var ssoConfigActions = {
|
|
|
1781
1830
|
};
|
|
1782
1831
|
var ssoConfigActionErrorHandler = (err, type) => (dispatch) => commonErrorHandler(err, `There was an error ${ssoConfigActions[type].error} the SSO configuration.`, dispatch, commonErrorFallback);
|
|
1783
1832
|
var ssoConfigActionSuccessHandler = (type) => (dispatch) => dispatch(setSnackbar3(`The SSO configuration was ${ssoConfigActions[type].success} successfully`));
|
|
1784
|
-
var storeSsoConfig =
|
|
1833
|
+
var storeSsoConfig = createAppAsyncThunk(
|
|
1785
1834
|
`${sliceName5}/storeSsoConfig`,
|
|
1786
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())]))
|
|
1787
1836
|
);
|
|
1788
|
-
var changeSsoConfig =
|
|
1837
|
+
var changeSsoConfig = createAppAsyncThunk(
|
|
1789
1838
|
`${sliceName5}/changeSsoConfig`,
|
|
1790
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())]))
|
|
1791
1840
|
);
|
|
1792
|
-
var deleteSsoConfig =
|
|
1841
|
+
var deleteSsoConfig = createAppAsyncThunk(
|
|
1793
1842
|
`${sliceName5}/deleteSsoConfig`,
|
|
1794
1843
|
({ id }, { dispatch, getState }) => general_api_default.delete(`${ssoIdpApiUrlv1}/${id}`).catch((err) => dispatch(ssoConfigActionErrorHandler(err, "remove"))).then(() => {
|
|
1795
1844
|
const configs = getState().organization.ssoConfigs.filter((item) => id !== item.id);
|
|
1796
1845
|
return Promise.all([dispatch(ssoConfigActionSuccessHandler("remove")), dispatch(actions5.receiveSsoConfigs(configs))]);
|
|
1797
1846
|
})
|
|
1798
1847
|
);
|
|
1799
|
-
var getSsoConfigById =
|
|
1848
|
+
var getSsoConfigById = createAppAsyncThunk(
|
|
1800
1849
|
`${sliceName5}/getSsoConfigById`,
|
|
1801
1850
|
(config, { dispatch }) => general_api_default.get(`${ssoIdpApiUrlv1}/${config.id}`).catch((err) => dispatch(ssoConfigActionErrorHandler(err, "read"))).then(({ data, headers }) => {
|
|
1802
1851
|
const sso = Object.values(SSO_TYPES).find(({ contentType }) => contentType === headers["content-type"]);
|
|
1803
1852
|
return sso ? Promise.resolve({ ...config, config: data, type: sso.id }) : Promise.reject("Unsupported SSO config content type.");
|
|
1804
1853
|
})
|
|
1805
1854
|
);
|
|
1806
|
-
var getSsoConfigs =
|
|
1855
|
+
var getSsoConfigs = createAppAsyncThunk(
|
|
1807
1856
|
`${sliceName5}/getSsoConfigs`,
|
|
1808
1857
|
(_, { dispatch }) => general_api_default.get(ssoIdpApiUrlv1).catch((err) => dispatch(ssoConfigActionErrorHandler(err, "readMultiple"))).then(
|
|
1809
1858
|
({ data }) => Promise.all(data.map((config) => dispatch(getSsoConfigById(config)).unwrap())).then((configs) => dispatch(actions5.receiveSsoConfigs(configs))).catch((err) => commonErrorHandler(err, err, dispatch, ""))
|
|
@@ -1811,15 +1860,13 @@ var getSsoConfigs = createAsyncThunk4(
|
|
|
1811
1860
|
);
|
|
1812
1861
|
|
|
1813
1862
|
// src/usersSlice/thunks.ts
|
|
1814
|
-
import {
|
|
1815
|
-
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";
|
|
1816
1864
|
import { clearAllRetryTimers } from "@northern.tech/utils/retrytimer";
|
|
1817
|
-
import { createAsyncThunk as createAsyncThunk5 } from "@reduxjs/toolkit";
|
|
1818
1865
|
import hashString2 from "md5";
|
|
1819
1866
|
import Cookies3 from "universal-cookie";
|
|
1820
1867
|
var cookies3 = new Cookies3();
|
|
1821
1868
|
var { setAnnouncement: setAnnouncement2, setSnackbar: setSnackbar4 } = actions_default;
|
|
1822
|
-
var handleLoginError = (err, { token2fa: has2FA, password }, rejectWithValue) => (
|
|
1869
|
+
var handleLoginError = (err, { token2fa: has2FA, password }, rejectWithValue) => () => {
|
|
1823
1870
|
const errorText = extractErrorMessage2(err);
|
|
1824
1871
|
const is2FABackend = errorText.includes("2fa");
|
|
1825
1872
|
if (is2FABackend && !has2FA) {
|
|
@@ -1830,26 +1877,25 @@ var handleLoginError = (err, { token2fa: has2FA, password }, rejectWithValue) =>
|
|
|
1830
1877
|
}
|
|
1831
1878
|
const twoFAError = is2FABackend ? " and verification code" : "";
|
|
1832
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.`;
|
|
1833
|
-
return
|
|
1880
|
+
return rejectWithValue({ error: errorMessage });
|
|
1834
1881
|
};
|
|
1835
|
-
var loginUser =
|
|
1882
|
+
var loginUser = createAppAsyncThunk(
|
|
1836
1883
|
`${sliceName6}/loginUser`,
|
|
1837
|
-
({ 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) => {
|
|
1838
1885
|
cleanUp();
|
|
1839
1886
|
return Promise.reject(dispatch(handleLoginError(err, userData, rejectWithValue)));
|
|
1840
|
-
}).then(({ text:
|
|
1887
|
+
}).then(({ text: token, contentType }) => {
|
|
1841
1888
|
if (contentType.includes(APPLICATION_JSON_CONTENT_TYPE)) {
|
|
1842
|
-
const { id, kind } =
|
|
1889
|
+
const { id, kind } = token;
|
|
1843
1890
|
const type = kind.split("/")[1];
|
|
1844
1891
|
const ssoLoginUrl = SSO_TYPES[type].getStartUrl(id);
|
|
1845
1892
|
window.location.replace(ssoLoginUrl);
|
|
1846
1893
|
return;
|
|
1847
1894
|
}
|
|
1848
|
-
const token = response;
|
|
1849
1895
|
if (contentType !== APPLICATION_JWT_CONTENT_TYPE || !token) {
|
|
1850
1896
|
return;
|
|
1851
1897
|
}
|
|
1852
|
-
|
|
1898
|
+
const now = /* @__PURE__ */ new Date();
|
|
1853
1899
|
now.setSeconds(now.getSeconds() + maxSessionAge);
|
|
1854
1900
|
const expiresAt = stayLoggedIn ? void 0 : now.toISOString();
|
|
1855
1901
|
setSessionInfo({ token, expiresAt });
|
|
@@ -1866,35 +1912,35 @@ var loginUser = createAsyncThunk5(
|
|
|
1866
1912
|
});
|
|
1867
1913
|
})
|
|
1868
1914
|
);
|
|
1869
|
-
var logoutUser =
|
|
1915
|
+
var logoutUser = createAppAsyncThunk(`${sliceName6}/logoutUser`, (_, { dispatch, getState }) => {
|
|
1870
1916
|
if (Object.keys(getState().app.uploadsById).length) {
|
|
1871
1917
|
return Promise.reject();
|
|
1872
1918
|
}
|
|
1873
|
-
return general_api_default.post(`${
|
|
1919
|
+
return general_api_default.post(`${useradmApiUrl}/auth/logout`).finally(() => {
|
|
1874
1920
|
cleanUp();
|
|
1875
1921
|
clearAllRetryTimers(setSnackbar4);
|
|
1876
1922
|
return Promise.resolve(dispatch({ type: USER_LOGOUT }));
|
|
1877
1923
|
});
|
|
1878
1924
|
});
|
|
1879
|
-
var switchUserOrganization =
|
|
1925
|
+
var switchUserOrganization = createAppAsyncThunk(`${sliceName6}/switchUserOrganization`, (tenantId, { getState }) => {
|
|
1880
1926
|
if (Object.keys(getState().app.uploadsById).length) {
|
|
1881
1927
|
return Promise.reject();
|
|
1882
1928
|
}
|
|
1883
|
-
return general_api_default.get(`${
|
|
1929
|
+
return general_api_default.get(`${useradmApiUrl}/users/tenants/${tenantId}/token`).then(({ data: token }) => {
|
|
1884
1930
|
window.sessionStorage.setItem("tenantChanged", "true");
|
|
1885
1931
|
setSessionInfo({ ...getSessionInfo(), token });
|
|
1886
1932
|
window.location.reload();
|
|
1887
1933
|
});
|
|
1888
1934
|
});
|
|
1889
|
-
var passwordResetStart =
|
|
1935
|
+
var passwordResetStart = createAppAsyncThunk(
|
|
1890
1936
|
`${sliceName6}/passwordResetStart`,
|
|
1891
|
-
(email, { dispatch }) => general_api_default.post(`${
|
|
1937
|
+
(email, { dispatch }) => general_api_default.post(`${useradmApiUrl}/auth/password-reset/start`, { email }).catch(
|
|
1892
1938
|
(err) => commonErrorHandler(err, `The password reset request cannot be processed:`, dispatch, void 0, true)
|
|
1893
1939
|
)
|
|
1894
1940
|
);
|
|
1895
|
-
var passwordResetComplete =
|
|
1941
|
+
var passwordResetComplete = createAppAsyncThunk(
|
|
1896
1942
|
`${sliceName6}/passwordResetComplete`,
|
|
1897
|
-
({ 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 = {}) => {
|
|
1898
1944
|
const { error, response = {} } = err;
|
|
1899
1945
|
let errorMsg = "";
|
|
1900
1946
|
if (response.status == 400) {
|
|
@@ -1906,23 +1952,23 @@ var passwordResetComplete = createAsyncThunk5(
|
|
|
1906
1952
|
return Promise.reject(err);
|
|
1907
1953
|
})
|
|
1908
1954
|
);
|
|
1909
|
-
var verifyEmailStart =
|
|
1955
|
+
var verifyEmailStart = createAppAsyncThunk(
|
|
1910
1956
|
`${sliceName6}/verifyEmailStart`,
|
|
1911
|
-
(_, { 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))))
|
|
1912
1958
|
);
|
|
1913
|
-
var verifyEmailComplete =
|
|
1959
|
+
var verifyEmailComplete = createAppAsyncThunk(
|
|
1914
1960
|
`${sliceName6}/verifyEmailComplete`,
|
|
1915
|
-
(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))))
|
|
1916
1962
|
);
|
|
1917
|
-
var verify2FA =
|
|
1963
|
+
var verify2FA = createAppAsyncThunk(
|
|
1918
1964
|
`${sliceName6}/verify2FA`,
|
|
1919
|
-
(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(
|
|
1920
1966
|
(err) => commonErrorHandler(err, "An error occured validating the verification code: failed to verify token, please try again.", dispatch, void 0, true)
|
|
1921
1967
|
)
|
|
1922
1968
|
);
|
|
1923
|
-
var getUserList =
|
|
1969
|
+
var getUserList = createAppAsyncThunk(
|
|
1924
1970
|
`${sliceName6}/getUserList`,
|
|
1925
|
-
(_, { dispatch, getState }) => general_api_default.get(`${
|
|
1971
|
+
(_, { dispatch, getState }) => general_api_default.get(`${useradmApiUrl}/users`).then((res) => {
|
|
1926
1972
|
const currentUsersById = getUsersById(getState());
|
|
1927
1973
|
const users = res.data.reduce(
|
|
1928
1974
|
(accu, item) => {
|
|
@@ -1937,9 +1983,9 @@ var getUserList = createAsyncThunk5(
|
|
|
1937
1983
|
return dispatch(actions6.receivedUserList(users));
|
|
1938
1984
|
}).catch((err) => commonErrorHandler(err, `Users couldn't be loaded.`, dispatch, commonErrorFallback))
|
|
1939
1985
|
);
|
|
1940
|
-
var getUser =
|
|
1986
|
+
var getUser = createAppAsyncThunk(
|
|
1941
1987
|
`${sliceName6}/getUser`,
|
|
1942
|
-
(id, { dispatch, rejectWithValue }) => general_api_default.get(`${
|
|
1988
|
+
(id, { dispatch, rejectWithValue }) => general_api_default.get(`${useradmApiUrl}/users/${id}`).then(
|
|
1943
1989
|
({ data: user }) => Promise.all([
|
|
1944
1990
|
dispatch(actions6.receivedUser(user)),
|
|
1945
1991
|
dispatch(setHideAnnouncement({ shouldHide: false, userId: user.id })),
|
|
@@ -1948,22 +1994,25 @@ var getUser = createAsyncThunk5(
|
|
|
1948
1994
|
])
|
|
1949
1995
|
).catch((e) => rejectWithValue(e))
|
|
1950
1996
|
);
|
|
1951
|
-
var initializeSelf =
|
|
1952
|
-
var updateUserColumnSettings =
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
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;
|
|
1960
2011
|
}
|
|
1961
|
-
|
|
1962
|
-
customColumns
|
|
2012
|
+
window.localStorage.setItem(storageKey, JSON.stringify(customColumns));
|
|
2013
|
+
return Promise.resolve(dispatch(actions6.setCustomColumns(customColumns)));
|
|
1963
2014
|
}
|
|
1964
|
-
|
|
1965
|
-
return Promise.resolve(dispatch(actions6.setCustomColumns(customColumns)));
|
|
1966
|
-
});
|
|
2015
|
+
);
|
|
1967
2016
|
var userActions = {
|
|
1968
2017
|
add: {
|
|
1969
2018
|
successMessage: "The user was added successfully.",
|
|
@@ -1983,34 +2032,34 @@ var userActions = {
|
|
|
1983
2032
|
}
|
|
1984
2033
|
};
|
|
1985
2034
|
var userActionErrorHandler = (err, type, dispatch) => commonErrorHandler(err, `There was an error ${userActions[type].errorMessage} the user.`, dispatch);
|
|
1986
|
-
var createUser =
|
|
2035
|
+
var createUser = createAppAsyncThunk(
|
|
1987
2036
|
`${sliceName6}/createUser`,
|
|
1988
|
-
({ 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))
|
|
1989
2038
|
);
|
|
1990
|
-
var removeUser =
|
|
2039
|
+
var removeUser = createAppAsyncThunk(
|
|
1991
2040
|
`${sliceName6}/removeUser`,
|
|
1992
|
-
(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))
|
|
1993
2042
|
);
|
|
1994
|
-
var editUser =
|
|
2043
|
+
var editUser = createAppAsyncThunk(
|
|
1995
2044
|
`${sliceName6}/editUser`,
|
|
1996
|
-
({ id, ...userData }, { dispatch, getState }) => general_api_default.put(`${
|
|
2045
|
+
({ id, ...userData }, { dispatch, getState }) => general_api_default.put(`${useradmApiUrl}/users/${id}`, userData).then(
|
|
1997
2046
|
() => Promise.all([
|
|
1998
2047
|
dispatch(actions6.updatedUser({ ...userData, id: id === OWN_USER_ID ? getCurrentUser(getState()).id : id })),
|
|
1999
2048
|
dispatch(setSnackbar4(userActions.edit.successMessage))
|
|
2000
2049
|
])
|
|
2001
|
-
)
|
|
2050
|
+
).catch((err) => userActionErrorHandler(err, "edit", dispatch))
|
|
2002
2051
|
);
|
|
2003
|
-
var addUserToCurrentTenant =
|
|
2052
|
+
var addUserToCurrentTenant = createAppAsyncThunk(`${sliceName6}/addUserToTenant`, (userId, { dispatch, getState }) => {
|
|
2004
2053
|
const { id } = getOrganization(getState());
|
|
2005
|
-
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())]));
|
|
2006
2055
|
});
|
|
2007
|
-
var enableUser2fa =
|
|
2056
|
+
var enableUser2fa = createAppAsyncThunk(
|
|
2008
2057
|
`${sliceName6}/enableUser2fa`,
|
|
2009
|
-
(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))))
|
|
2010
2059
|
);
|
|
2011
|
-
var disableUser2fa =
|
|
2060
|
+
var disableUser2fa = createAppAsyncThunk(
|
|
2012
2061
|
`${sliceName6}/disableUser2fa`,
|
|
2013
|
-
(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))]))
|
|
2014
2063
|
);
|
|
2015
2064
|
var mapHttpPermission = (permission) => Object.entries(uiPermissionsByArea).reduce(
|
|
2016
2065
|
(accu, [area, definition]) => {
|
|
@@ -2050,7 +2099,7 @@ var permissionActionTypes = {
|
|
|
2050
2099
|
} : {}
|
|
2051
2100
|
};
|
|
2052
2101
|
var combinePermissions = (existingPermissions, additionalPermissions = {}) => Object.entries(additionalPermissions).reduce((accu, [name, permissions]) => {
|
|
2053
|
-
|
|
2102
|
+
const maybeExistingPermissions = accu[name] || [];
|
|
2054
2103
|
accu[name] = [...permissions, ...maybeExistingPermissions].filter(duplicateFilter);
|
|
2055
2104
|
return accu;
|
|
2056
2105
|
}, existingPermissions);
|
|
@@ -2060,7 +2109,7 @@ var tryParseCustomPermission = (permission) => {
|
|
|
2060
2109
|
return { isCustom: true, permission, result };
|
|
2061
2110
|
};
|
|
2062
2111
|
var customPermissionHandler = (accu, permission) => {
|
|
2063
|
-
|
|
2112
|
+
const processor = tryParseCustomPermission(permission);
|
|
2064
2113
|
return {
|
|
2065
2114
|
...accu,
|
|
2066
2115
|
isCustom: accu.isCustom || processor.isCustom,
|
|
@@ -2068,7 +2117,7 @@ var customPermissionHandler = (accu, permission) => {
|
|
|
2068
2117
|
};
|
|
2069
2118
|
};
|
|
2070
2119
|
var mapPermissionSet = (permissionSetName, names, scope, existingGroupsPermissions = {}) => {
|
|
2071
|
-
const permission = Object.values(uiPermissionsById).find((permission2) => permission2.permissionSets[scope] === permissionSetName)
|
|
2120
|
+
const permission = Object.values(uiPermissionsById).find((permission2) => permission2.permissionSets[scope] === permissionSetName)?.value;
|
|
2072
2121
|
const scopedPermissions = names.reduce((accu, name) => combinePermissions(accu, { [name]: [permission] }), existingGroupsPermissions);
|
|
2073
2122
|
return Object.entries(scopedPermissions).reduce((accu, [key, permissions]) => ({ ...accu, [key]: deriveImpliedAreaPermissions(scope, permissions) }), {});
|
|
2074
2123
|
};
|
|
@@ -2081,16 +2130,21 @@ var isEmptyPermissionSet = (permissionSet) => !Object.values(permissionSet).redu
|
|
|
2081
2130
|
var parseRolePermissions = ({ permission_sets_with_scope = [], permissions = [] }, permissionSets) => {
|
|
2082
2131
|
const preliminaryResult = permission_sets_with_scope.reduce(
|
|
2083
2132
|
(accu, permissionSet) => {
|
|
2084
|
-
|
|
2133
|
+
const processor = permissionSets[permissionSet.name];
|
|
2085
2134
|
if (!processor) {
|
|
2086
2135
|
return accu;
|
|
2087
2136
|
}
|
|
2088
2137
|
const scope = Object.keys(scopedPermissionAreas).find((scope2) => uiPermissionsByArea[scope2].scope === permissionSet.scope?.type);
|
|
2089
2138
|
if (scope) {
|
|
2090
|
-
const result = mapPermissionSet(
|
|
2139
|
+
const result = mapPermissionSet(
|
|
2140
|
+
permissionSet.name,
|
|
2141
|
+
permissionSet.scope.value,
|
|
2142
|
+
scope,
|
|
2143
|
+
accu.uiPermissions[scope]
|
|
2144
|
+
);
|
|
2091
2145
|
return { ...accu, uiPermissions: { ...accu.uiPermissions, [scope]: result } };
|
|
2092
2146
|
} else if (isEmptyPermissionSet(processor.result)) {
|
|
2093
|
-
return processor.permissions
|
|
2147
|
+
return processor.permissions?.reduce(customPermissionHandler, accu);
|
|
2094
2148
|
}
|
|
2095
2149
|
return {
|
|
2096
2150
|
...accu,
|
|
@@ -2131,7 +2185,7 @@ var normalizeRbacRoles = (roles, rolesById2, permissionSets) => roles.reduce(
|
|
|
2131
2185
|
},
|
|
2132
2186
|
{ ...rolesById2 }
|
|
2133
2187
|
);
|
|
2134
|
-
var getPermissionSets =
|
|
2188
|
+
var getPermissionSets = createAppAsyncThunk(
|
|
2135
2189
|
`${sliceName6}/getPermissionSets`,
|
|
2136
2190
|
(_, { dispatch, getState }) => general_api_default.get(`${useradmApiUrlv2}/permission_sets?per_page=500`).then(({ data }) => {
|
|
2137
2191
|
const permissionSets = data.reduce(
|
|
@@ -2157,7 +2211,10 @@ var getPermissionSets = createAsyncThunk5(
|
|
|
2157
2211
|
return accu2;
|
|
2158
2212
|
}, []);
|
|
2159
2213
|
permissionSetObject = scopes.reduce((accu2, scope) => {
|
|
2160
|
-
accu2.result
|
|
2214
|
+
accu2.result = {
|
|
2215
|
+
...accu2.result,
|
|
2216
|
+
[scope]: mapPermissionSet(permissionSetObject.name, [scopedPermissionAreas[scope].excessiveAccessSelector], scope)
|
|
2217
|
+
};
|
|
2161
2218
|
return accu2;
|
|
2162
2219
|
}, permissionSetObject);
|
|
2163
2220
|
accu[permissionSet.name] = permissionSetObject;
|
|
@@ -2168,7 +2225,7 @@ var getPermissionSets = createAsyncThunk5(
|
|
|
2168
2225
|
return Promise.all([dispatch(actions6.receivedPermissionSets(permissionSets)), permissionSets]);
|
|
2169
2226
|
}).catch(() => console.log("Permission set retrieval failed - likely accessing a non-RBAC backend"))
|
|
2170
2227
|
);
|
|
2171
|
-
var getRoles =
|
|
2228
|
+
var getRoles = createAppAsyncThunk(
|
|
2172
2229
|
`${sliceName6}/getRoles`,
|
|
2173
2230
|
(_, { dispatch, getState }) => Promise.all([general_api_default.get(`${useradmApiUrlv2}/roles?per_page=500`), dispatch(getPermissionSets())]).then((results) => {
|
|
2174
2231
|
if (!results) {
|
|
@@ -2177,7 +2234,7 @@ var getRoles = createAsyncThunk5(
|
|
|
2177
2234
|
const [{ data: roles }, { payload: permissionSetTasks }] = results;
|
|
2178
2235
|
const rolesById2 = normalizeRbacRoles(roles, getRolesById(getState()), permissionSetTasks[permissionSetTasks.length - 1]);
|
|
2179
2236
|
return Promise.resolve(dispatch(actions6.receivedRoles(rolesById2)));
|
|
2180
|
-
}).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))))
|
|
2181
2238
|
);
|
|
2182
2239
|
var deriveImpliedAreaPermissions = (area, areaPermissions, skipPermissions = []) => {
|
|
2183
2240
|
const highestAreaPermissionLevelSelected = areaPermissions.reduce(
|
|
@@ -2247,7 +2304,13 @@ var transformRoleDataToRole = (roleData, roleState = {}) => {
|
|
|
2247
2304
|
if (!uiPermissions[key]) {
|
|
2248
2305
|
return accu;
|
|
2249
2306
|
}
|
|
2250
|
-
accu.push(
|
|
2307
|
+
accu.push(
|
|
2308
|
+
...transformAreaRoleDataToScopedPermissionsSets(
|
|
2309
|
+
key,
|
|
2310
|
+
uiPermissions[key],
|
|
2311
|
+
excessiveAccessSelector
|
|
2312
|
+
)
|
|
2313
|
+
);
|
|
2251
2314
|
return accu;
|
|
2252
2315
|
}, []);
|
|
2253
2316
|
return {
|
|
@@ -2255,7 +2318,7 @@ var transformRoleDataToRole = (roleData, roleState = {}) => {
|
|
|
2255
2318
|
role: {
|
|
2256
2319
|
...emptyRole,
|
|
2257
2320
|
name,
|
|
2258
|
-
description: description ? description : roleState.description,
|
|
2321
|
+
description: description ? description : roleState.description || "",
|
|
2259
2322
|
uiPermissions: {
|
|
2260
2323
|
...emptyUiPermissions,
|
|
2261
2324
|
...roleUiPermissions,
|
|
@@ -2278,50 +2341,57 @@ var roleActions = {
|
|
|
2278
2341
|
errorMessage: "removing"
|
|
2279
2342
|
}
|
|
2280
2343
|
};
|
|
2281
|
-
var roleActionErrorHandler = (err, type, dispatch) =>
|
|
2282
|
-
|
|
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 }) => {
|
|
2283
2353
|
const { permissionSetsWithScope, role } = transformRoleDataToRole(roleData);
|
|
2284
2354
|
return general_api_default.post(`${useradmApiUrlv2}/roles`, {
|
|
2285
2355
|
name: role.name,
|
|
2286
2356
|
description: role.description,
|
|
2287
2357
|
permission_sets_with_scope: permissionSetsWithScope
|
|
2288
|
-
}).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 }));
|
|
2289
2359
|
});
|
|
2290
|
-
var editRole =
|
|
2360
|
+
var editRole = createAppAsyncThunk(`${sliceName6}/editRole`, (roleData, { dispatch, getState }) => {
|
|
2291
2361
|
const { permissionSetsWithScope, role } = transformRoleDataToRole(roleData, getRolesById(getState())[roleData.name]);
|
|
2292
2362
|
return general_api_default.put(`${useradmApiUrlv2}/roles/${role.name}`, {
|
|
2293
2363
|
description: role.description,
|
|
2294
2364
|
name: role.name,
|
|
2295
2365
|
permission_sets_with_scope: permissionSetsWithScope
|
|
2296
|
-
}).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 }));
|
|
2297
2367
|
});
|
|
2298
|
-
var removeRole =
|
|
2368
|
+
var removeRole = createAppAsyncThunk(
|
|
2299
2369
|
`${sliceName6}/removeRole`,
|
|
2300
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))
|
|
2301
2371
|
);
|
|
2302
|
-
var getGlobalSettings2 =
|
|
2372
|
+
var getGlobalSettings2 = createAppAsyncThunk(
|
|
2303
2373
|
`${sliceName6}/getGlobalSettings`,
|
|
2304
|
-
(_, { dispatch }) => general_api_default.get(`${
|
|
2305
|
-
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");
|
|
2306
2376
|
return Promise.all([dispatch(actions6.setGlobalSettings(settings)), dispatch(setOfflineThreshold()), etag]);
|
|
2307
2377
|
})
|
|
2308
2378
|
);
|
|
2309
|
-
var saveGlobalSettings =
|
|
2379
|
+
var saveGlobalSettings = createAppAsyncThunk(
|
|
2310
2380
|
`${sliceName6}/saveGlobalSettings`,
|
|
2311
2381
|
({ beOptimistic = false, notify = false, ...settings }, { dispatch, getState }) => {
|
|
2312
2382
|
if (!window.sessionStorage.getItem(settingsKeys.initialized) && !beOptimistic) {
|
|
2313
2383
|
return;
|
|
2314
2384
|
}
|
|
2315
2385
|
return dispatch(getGlobalSettings2()).unwrap().then((result) => {
|
|
2316
|
-
|
|
2386
|
+
const updatedSettings = { ...getState().users.globalSettings, ...settings };
|
|
2317
2387
|
if (getCurrentUser(getState()).verified) {
|
|
2318
2388
|
updatedSettings["2fa"] = twoFAStates.enabled;
|
|
2319
2389
|
} else {
|
|
2320
2390
|
delete updatedSettings["2fa"];
|
|
2321
2391
|
}
|
|
2322
|
-
|
|
2392
|
+
const tasks = [dispatch(actions6.setGlobalSettings(updatedSettings))];
|
|
2323
2393
|
const headers = result[result.length - 1] ? { "If-Match": result[result.length - 1] } : {};
|
|
2324
|
-
return general_api_default.post(`${
|
|
2394
|
+
return general_api_default.post(`${useradmApiUrl}/settings`, updatedSettings, { headers }).then(() => {
|
|
2325
2395
|
if (notify) {
|
|
2326
2396
|
tasks.push(dispatch(setSnackbar4("Settings saved successfully")));
|
|
2327
2397
|
}
|
|
@@ -2336,54 +2406,59 @@ var saveGlobalSettings = createAsyncThunk5(
|
|
|
2336
2406
|
});
|
|
2337
2407
|
}
|
|
2338
2408
|
);
|
|
2339
|
-
var getUserSettings2 =
|
|
2409
|
+
var getUserSettings2 = createAppAsyncThunk(
|
|
2340
2410
|
`${sliceName6}/getUserSettings`,
|
|
2341
|
-
(_, { dispatch }) => general_api_default.get(`${
|
|
2342
|
-
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");
|
|
2343
2413
|
return Promise.all([dispatch(actions6.setUserSettings(settings)), etag]);
|
|
2344
2414
|
})
|
|
2345
2415
|
);
|
|
2346
|
-
var saveUserSettings =
|
|
2347
|
-
|
|
2348
|
-
|
|
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
|
+
});
|
|
2349
2441
|
}
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
const onboardingState = getOnboardingState(getState());
|
|
2353
|
-
const tooltipState = getTooltipsState(getState());
|
|
2354
|
-
const updatedSettings = {
|
|
2355
|
-
...userSettings,
|
|
2356
|
-
...settings,
|
|
2357
|
-
onboarding: {
|
|
2358
|
-
...onboardingState,
|
|
2359
|
-
...settings.onboarding
|
|
2360
|
-
},
|
|
2361
|
-
tooltips: tooltipState
|
|
2362
|
-
};
|
|
2363
|
-
const headers = result[result.length - 1] ? { "If-Match": result[result.length - 1] } : {};
|
|
2364
|
-
return Promise.all([
|
|
2365
|
-
Promise.resolve(dispatch(actions6.setUserSettings(updatedSettings))),
|
|
2366
|
-
general_api_default.post(`${useradmApiUrlv1}/settings/me`, updatedSettings, { headers })
|
|
2367
|
-
]).catch(() => dispatch(actions6.setUserSettings(userSettings)));
|
|
2368
|
-
});
|
|
2369
|
-
});
|
|
2370
|
-
var get2FAQRCode = createAsyncThunk5(
|
|
2442
|
+
);
|
|
2443
|
+
var get2FAQRCode = createAppAsyncThunk(
|
|
2371
2444
|
`${sliceName6}/get2FAQRCode`,
|
|
2372
|
-
(_, { dispatch }) => general_api_default.get(`${
|
|
2373
|
-
);
|
|
2374
|
-
var setHideAnnouncement =
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
cookies3.
|
|
2380
|
-
|
|
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
|
+
}
|
|
2381
2457
|
}
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
var getTokens = createAsyncThunk5(
|
|
2458
|
+
);
|
|
2459
|
+
var getTokens = createAppAsyncThunk(
|
|
2385
2460
|
`${sliceName6}/getTokens`,
|
|
2386
|
-
(_, { dispatch, getState }) => general_api_default.get(`${
|
|
2461
|
+
(_, { dispatch, getState }) => general_api_default.get(`${useradmApiUrl}/settings/tokens`).then(({ data: tokens }) => {
|
|
2387
2462
|
const user = getCurrentUser(getState());
|
|
2388
2463
|
const updatedUser = {
|
|
2389
2464
|
...user,
|
|
@@ -2393,26 +2468,31 @@ var getTokens = createAsyncThunk5(
|
|
|
2393
2468
|
})
|
|
2394
2469
|
);
|
|
2395
2470
|
var ONE_YEAR = 31536e3;
|
|
2396
|
-
var generateToken =
|
|
2471
|
+
var generateToken = createAppAsyncThunk(
|
|
2397
2472
|
`${sliceName6}/generateToken`,
|
|
2398
|
-
({ 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))
|
|
2399
2474
|
);
|
|
2400
|
-
var revokeToken =
|
|
2475
|
+
var revokeToken = createAppAsyncThunk(
|
|
2401
2476
|
`${sliceName6}/revokeToken`,
|
|
2402
|
-
(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
|
+
}
|
|
2403
2487
|
);
|
|
2404
|
-
var
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
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()));
|
|
2408
2493
|
}
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
var setAllTooltipsReadState = createAsyncThunk5(`${sliceName6}/toggleHelptips`, (readState = READ_STATES.read, { dispatch }) => {
|
|
2412
|
-
const updatedTips = Object.keys(HELPTOOLTIPS).reduce((accu, id) => ({ ...accu, [id]: { readState } }), {});
|
|
2413
|
-
return Promise.resolve(dispatch(actions6.setTooltipsState(updatedTips))).then(() => dispatch(saveUserSettings()));
|
|
2414
|
-
});
|
|
2415
|
-
var submitFeedback = createAsyncThunk5(
|
|
2494
|
+
);
|
|
2495
|
+
var submitFeedback = createAppAsyncThunk(
|
|
2416
2496
|
`${sliceName6}/submitFeedback`,
|
|
2417
2497
|
({ satisfaction, feedback, ...meta }, { dispatch }) => general_api_default.post(`${tenantadmApiUrlv2}/contact/support`, {
|
|
2418
2498
|
subject: "feedback submission",
|
|
@@ -2425,11 +2505,8 @@ var submitFeedback = createAsyncThunk5(
|
|
|
2425
2505
|
);
|
|
2426
2506
|
|
|
2427
2507
|
// src/appSlice/thunks.ts
|
|
2428
|
-
import { deepCompare as deepCompare4, extractErrorMessage as extractErrorMessage3 } from "@northern.tech/utils/helpers";
|
|
2429
|
-
import { createAsyncThunk as createAsyncThunk6 } from "@reduxjs/toolkit";
|
|
2430
|
-
import Cookies4 from "universal-cookie";
|
|
2431
2508
|
var cookies4 = new Cookies4();
|
|
2432
|
-
var setFirstLoginAfterSignup =
|
|
2509
|
+
var setFirstLoginAfterSignup = createAppAsyncThunk(`${sliceName}/setFirstLoginAfterSignup`, (firstLoginAfterSignup, { dispatch }) => {
|
|
2433
2510
|
cookies4.set("firstLoginAfterSignup", !!firstLoginAfterSignup, { maxAge: 60, path: "/", domain: ".mender.io", sameSite: false });
|
|
2434
2511
|
dispatch(actions.setFirstLoginAfterSignup(!!firstLoginAfterSignup));
|
|
2435
2512
|
});
|
|
@@ -2437,7 +2514,7 @@ var dateFunctionMap = {
|
|
|
2437
2514
|
getDays: "getDate",
|
|
2438
2515
|
setDays: "setDate"
|
|
2439
2516
|
};
|
|
2440
|
-
var setOfflineThreshold =
|
|
2517
|
+
var setOfflineThreshold = createAppAsyncThunk(`${sliceName}/setOfflineThreshold`, (_, { dispatch, getState }) => {
|
|
2441
2518
|
const { interval, intervalUnit } = getOfflineThresholdSettings(getState());
|
|
2442
2519
|
const today = /* @__PURE__ */ new Date();
|
|
2443
2520
|
const intervalName = `${intervalUnit.charAt(0).toUpperCase()}${intervalUnit.substring(1)}`;
|
|
@@ -2462,12 +2539,11 @@ var repoKeyMap = {
|
|
|
2462
2539
|
mender: "Mender-Client",
|
|
2463
2540
|
"mender-artifact": "Mender-Artifact"
|
|
2464
2541
|
};
|
|
2465
|
-
var deductSaasState = (latestRelease, guiTags
|
|
2542
|
+
var deductSaasState = (latestRelease, guiTags) => {
|
|
2466
2543
|
const latestGuiTag = guiTags.length ? guiTags[0].name : "";
|
|
2467
|
-
|
|
2468
|
-
return latestSaasRelease.date > latestRelease.release_date ? latestSaasRelease.tag : latestRelease.release;
|
|
2544
|
+
return latestGuiTag ? latestGuiTag : latestRelease.release;
|
|
2469
2545
|
};
|
|
2470
|
-
var getLatestReleaseInfo =
|
|
2546
|
+
var getLatestReleaseInfo = createAppAsyncThunk(`${sliceName}/getLatestReleaseInfo`, (_, { dispatch, getState }) => {
|
|
2471
2547
|
if (!getFeatures(getState()).isHosted) {
|
|
2472
2548
|
return Promise.resolve();
|
|
2473
2549
|
}
|
|
@@ -2478,7 +2554,7 @@ var getLatestReleaseInfo = createAsyncThunk6(`${sliceName}/getLatestReleaseInfo`
|
|
|
2478
2554
|
if (!guiTags.length) {
|
|
2479
2555
|
return Promise.resolve();
|
|
2480
2556
|
}
|
|
2481
|
-
const { releases
|
|
2557
|
+
const { releases } = data;
|
|
2482
2558
|
const latestRelease = getLatestRelease(getLatestRelease(releases));
|
|
2483
2559
|
const { latestRepos, latestVersions } = latestRelease.repos.reduce(
|
|
2484
2560
|
(accu, item) => {
|
|
@@ -2490,13 +2566,12 @@ var getLatestReleaseInfo = createAsyncThunk6(`${sliceName}/getLatestReleaseInfo`
|
|
|
2490
2566
|
},
|
|
2491
2567
|
{ latestVersions: { ...getState().app.versionInformation }, latestRepos: {} }
|
|
2492
2568
|
);
|
|
2493
|
-
const info = deductSaasState(latestRelease, guiTags
|
|
2569
|
+
const info = deductSaasState(latestRelease, guiTags);
|
|
2494
2570
|
return Promise.resolve(
|
|
2495
2571
|
dispatch(
|
|
2496
2572
|
actions.setVersionInformation({
|
|
2497
2573
|
...latestVersions,
|
|
2498
|
-
|
|
2499
|
-
GUI: info,
|
|
2574
|
+
Server: info,
|
|
2500
2575
|
latestRelease: {
|
|
2501
2576
|
releaseDate: latestRelease.release_date,
|
|
2502
2577
|
repos: latestRepos
|
|
@@ -2506,9 +2581,9 @@ var getLatestReleaseInfo = createAsyncThunk6(`${sliceName}/getLatestReleaseInfo`
|
|
|
2506
2581
|
);
|
|
2507
2582
|
});
|
|
2508
2583
|
});
|
|
2509
|
-
var setSearchState =
|
|
2584
|
+
var setSearchState = createAppAsyncThunk(`${sliceName}/setSearchState`, (searchState, { dispatch, getState }) => {
|
|
2510
2585
|
const currentState = getSearchState(getState());
|
|
2511
|
-
|
|
2586
|
+
const nextState = {
|
|
2512
2587
|
...currentState,
|
|
2513
2588
|
...searchState,
|
|
2514
2589
|
sort: {
|
|
@@ -2516,7 +2591,7 @@ var setSearchState = createAsyncThunk6(`${sliceName}/setSearchState`, (searchSta
|
|
|
2516
2591
|
...searchState.sort
|
|
2517
2592
|
}
|
|
2518
2593
|
};
|
|
2519
|
-
|
|
2594
|
+
const tasks = [];
|
|
2520
2595
|
const { isSearching: currentSearching, deviceIds: currentDevices, searchTotal: currentTotal, ...currentRequestState } = currentState;
|
|
2521
2596
|
const { isSearching: nextSearching, deviceIds: nextDevices, searchTotal: nextTotal, ...nextRequestState } = nextState;
|
|
2522
2597
|
if (nextRequestState.searchTerm && !deepCompare4(currentRequestState, nextRequestState)) {
|
|
@@ -2550,7 +2625,7 @@ export {
|
|
|
2550
2625
|
setDeploymentsState,
|
|
2551
2626
|
getDeploymentsConfig,
|
|
2552
2627
|
saveDeltaDeploymentsConfig,
|
|
2553
|
-
|
|
2628
|
+
getGroups,
|
|
2554
2629
|
addDevicesToGroup,
|
|
2555
2630
|
removeDevicesFromGroup,
|
|
2556
2631
|
addStaticGroup,
|
|
@@ -2565,7 +2640,6 @@ export {
|
|
|
2565
2640
|
getAllDynamicGroupDevices,
|
|
2566
2641
|
getDeviceById2 as getDeviceById,
|
|
2567
2642
|
getDeviceInfo,
|
|
2568
|
-
deriveInactiveDevices,
|
|
2569
2643
|
getDeviceCount,
|
|
2570
2644
|
getAllDeviceCounts,
|
|
2571
2645
|
getDeviceLimit,
|
|
@@ -2574,11 +2648,8 @@ export {
|
|
|
2574
2648
|
getAllDevicesByStatus,
|
|
2575
2649
|
searchDevices,
|
|
2576
2650
|
getDeviceAttributes,
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
getReportsData,
|
|
2580
|
-
deriveReportsData,
|
|
2581
|
-
getReportsDataWithoutBackendSupport,
|
|
2651
|
+
updateReportData,
|
|
2652
|
+
getReportDataWithoutBackendSupport,
|
|
2582
2653
|
getDeviceConnect,
|
|
2583
2654
|
triggerDeviceUpdate,
|
|
2584
2655
|
getSessionDetails,
|
|
@@ -2599,7 +2670,6 @@ export {
|
|
|
2599
2670
|
setDeviceTwin,
|
|
2600
2671
|
getSystemDevices,
|
|
2601
2672
|
getGatewayDevices,
|
|
2602
|
-
getDevicesInBounds,
|
|
2603
2673
|
getOnboardingState2 as getOnboardingState,
|
|
2604
2674
|
setOnboardingDeviceType,
|
|
2605
2675
|
setOnboardingApproach,
|
|
@@ -2623,8 +2693,15 @@ export {
|
|
|
2623
2693
|
getTenants,
|
|
2624
2694
|
setTenantsListState,
|
|
2625
2695
|
editTenantDeviceLimit,
|
|
2696
|
+
editBillingProfile,
|
|
2697
|
+
createBillingProfile,
|
|
2626
2698
|
removeTenant,
|
|
2627
2699
|
getUserOrganization,
|
|
2700
|
+
getUserBilling,
|
|
2701
|
+
getUserSubscription,
|
|
2702
|
+
getBillingPreview,
|
|
2703
|
+
getCurrentSubscription,
|
|
2704
|
+
requestPlanUpgrade,
|
|
2628
2705
|
sendSupportMessage,
|
|
2629
2706
|
requestPlanChange,
|
|
2630
2707
|
downloadLicenseReport,
|
|
@@ -2675,4 +2752,4 @@ export {
|
|
|
2675
2752
|
setAllTooltipsReadState,
|
|
2676
2753
|
submitFeedback
|
|
2677
2754
|
};
|
|
2678
|
-
//# sourceMappingURL=chunk-
|
|
2755
|
+
//# sourceMappingURL=chunk-ZN5TB2NJ.js.map
|