@northern.tech/store 0.30.0 → 0.30.2
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 +21 -1130
- package/dist/actions.cjs.map +1 -1
- package/dist/actions.d.cts +212 -221
- package/dist/actions.d.ts +212 -220
- package/dist/actions.js +21 -18
- package/dist/actions.js.map +1 -1
- package/dist/api/general-api.cjs +61 -459
- package/dist/api/general-api.cjs.map +1 -1
- package/dist/api/general-api.d.cts +15 -17
- package/dist/api/general-api.d.ts +15 -17
- package/dist/api/general-api.js +56 -15
- package/dist/api/general-api.js.map +1 -1
- package/dist/api/users-api.cjs +32 -469
- package/dist/api/users-api.cjs.map +1 -1
- package/dist/api/users-api.d.cts +19 -14
- package/dist/api/users-api.d.ts +19 -13
- package/dist/api/users-api.js +30 -12
- package/dist/api/users-api.js.map +1 -1
- package/dist/appSlice/constants.cjs +190 -144
- package/dist/appSlice/constants.cjs.map +1 -1
- package/dist/appSlice/constants.d.cts +2 -159
- package/dist/appSlice/constants.d.ts +2 -159
- package/dist/appSlice/constants.js +181 -29
- package/dist/appSlice/constants.js.map +1 -1
- package/dist/appSlice/index.cjs +147 -178
- package/dist/appSlice/index.cjs.map +1 -1
- package/dist/appSlice/index.d.cts +2 -148
- package/dist/appSlice/index.d.ts +2 -148
- package/dist/appSlice/index.js +142 -18
- package/dist/appSlice/index.js.map +1 -1
- package/dist/appSlice/mocks.cjs +17 -191
- package/dist/appSlice/mocks.cjs.map +1 -1
- package/dist/appSlice/mocks.d.cts +33 -36
- package/dist/appSlice/mocks.d.ts +33 -36
- package/dist/appSlice/mocks.js +17 -25
- package/dist/appSlice/mocks.js.map +1 -1
- package/dist/appSlice/selectors.cjs +49 -91
- package/dist/appSlice/selectors.cjs.map +1 -1
- package/dist/appSlice/selectors.d.cts +216 -230
- package/dist/appSlice/selectors.d.ts +216 -230
- package/dist/appSlice/selectors.js +29 -44
- package/dist/appSlice/selectors.js.map +1 -1
- package/dist/appSlice/thunks.cjs +6 -4636
- package/dist/appSlice/thunks.d.cts +59 -62
- package/dist/appSlice/thunks.d.ts +59 -62
- package/dist/appSlice/thunks.js +2 -45
- package/dist/auth.cjs +68 -433
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +14 -14
- package/dist/auth.d.ts +14 -14
- package/dist/auth.js +65 -18
- package/dist/auth.js.map +1 -1
- package/dist/chunk-CKQMccvm.cjs +28 -0
- package/dist/commonConstants.cjs +14 -393
- package/dist/commonConstants.d.cts +2 -83
- package/dist/commonConstants.d.ts +2 -83
- package/dist/commonConstants.js +2 -33
- package/dist/commonSelectors.cjs +284 -1269
- package/dist/commonSelectors.cjs.map +1 -1
- package/dist/commonSelectors.d.cts +1623 -1416
- package/dist/commonSelectors.d.ts +1623 -1416
- package/dist/commonSelectors.js +277 -51
- package/dist/commonSelectors.js.map +1 -1
- package/dist/constants-5cdwz1iH.d.ts +160 -0
- package/dist/constants-BWEsNG5c.d.ts +28 -0
- package/dist/constants-BciiayPt.d.ts +17 -0
- package/dist/constants-C5AU0mCY.d.ts +157 -0
- package/dist/constants-CIx3fnBv.d.cts +17 -0
- package/dist/constants-CNhpIMME.d.cts +93 -0
- package/dist/constants-Cpgyuy_r.d.ts +57 -0
- package/dist/constants-D41U_jbR.d.cts +160 -0
- package/dist/constants-DK7fI3Rh.d.cts +28 -0
- package/dist/constants-DPLHhjVN.d.cts +157 -0
- package/dist/constants-DrwXHsJ1.d.ts +120 -0
- package/dist/constants-G3wymKIl.d.cts +57 -0
- package/dist/constants-MPLfugsi.d.cts +120 -0
- package/dist/constants-y2XVLQWf.d.ts +93 -0
- package/dist/constants.cjs +784 -972
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts +8 -14
- package/dist/constants.d.ts +8 -14
- package/dist/constants.js +674 -232
- package/dist/constants.js.map +1 -1
- package/dist/deploymentsSlice/constants.cjs +15 -214
- package/dist/deploymentsSlice/constants.d.cts +2 -163
- package/dist/deploymentsSlice/constants.d.ts +2 -163
- package/dist/deploymentsSlice/constants.js +2 -35
- package/dist/deploymentsSlice/index.cjs +168 -302
- package/dist/deploymentsSlice/index.cjs.map +1 -1
- package/dist/deploymentsSlice/index.d.cts +2 -157
- package/dist/deploymentsSlice/index.d.ts +2 -157
- package/dist/deploymentsSlice/index.js +161 -18
- package/dist/deploymentsSlice/index.js.map +1 -1
- package/dist/deploymentsSlice/mocks.cjs +178 -433
- package/dist/deploymentsSlice/mocks.cjs.map +1 -1
- package/dist/deploymentsSlice/mocks.d.cts +176 -178
- package/dist/deploymentsSlice/mocks.d.ts +176 -178
- package/dist/deploymentsSlice/mocks.js +178 -144
- package/dist/deploymentsSlice/mocks.js.map +1 -1
- package/dist/deploymentsSlice/selectors.cjs +44 -223
- package/dist/deploymentsSlice/selectors.cjs.map +1 -1
- package/dist/deploymentsSlice/selectors.d.cts +73 -87
- package/dist/deploymentsSlice/selectors.d.ts +73 -87
- package/dist/deploymentsSlice/selectors.js +37 -25
- package/dist/deploymentsSlice/selectors.js.map +1 -1
- package/dist/deploymentsSlice/thunks.cjs +16 -4654
- package/dist/deploymentsSlice/thunks.d.cts +223 -236
- package/dist/deploymentsSlice/thunks.d.ts +223 -236
- package/dist/deploymentsSlice/thunks.js +2 -65
- package/dist/devicesSlice/constants.cjs +9 -68
- package/dist/devicesSlice/constants.d.cts +2 -37
- package/dist/devicesSlice/constants.d.ts +2 -37
- package/dist/devicesSlice/constants.js +2 -23
- package/dist/devicesSlice/index.cjs +215 -225
- package/dist/devicesSlice/index.cjs.map +1 -1
- package/dist/devicesSlice/index.d.cts +2 -202
- package/dist/devicesSlice/index.d.ts +2 -202
- package/dist/devicesSlice/index.js +209 -18
- package/dist/devicesSlice/index.js.map +1 -1
- package/dist/devicesSlice/mocks.cjs +146 -339
- package/dist/devicesSlice/mocks.cjs.map +1 -1
- package/dist/devicesSlice/mocks.d.cts +150 -148
- package/dist/devicesSlice/mocks.d.ts +150 -148
- package/dist/devicesSlice/mocks.js +145 -132
- package/dist/devicesSlice/mocks.js.map +1 -1
- package/dist/devicesSlice/selectors.cjs +145 -539
- package/dist/devicesSlice/selectors.cjs.map +1 -1
- package/dist/devicesSlice/selectors.d.cts +685 -699
- package/dist/devicesSlice/selectors.d.ts +685 -699
- package/dist/devicesSlice/selectors.js +123 -59
- package/dist/devicesSlice/selectors.js.map +1 -1
- package/dist/devicesSlice/thunks.cjs +48 -4718
- package/dist/devicesSlice/thunks.d.cts +800 -752
- package/dist/devicesSlice/thunks.d.ts +800 -752
- package/dist/devicesSlice/thunks.js +2 -129
- package/dist/index-4eaLEXy_.d.cts +152 -0
- package/dist/index-BEVkIiNa.d.cts +95 -0
- package/dist/index-BP0uAq36.d.cts +159 -0
- package/dist/index-Bwx9jEiL.d.cts +71 -0
- package/dist/index-CJkrL0oA.d.ts +64 -0
- package/dist/index-CO-py5d4.d.ts +95 -0
- package/dist/index-CTt-eIY8.d.cts +154 -0
- package/dist/index-CkwVnIqd.d.ts +159 -0
- package/dist/index-Cvkvcz4r.d.ts +115 -0
- package/dist/index-DJSlDPRX.d.ts +71 -0
- package/dist/index-DqyY6oZ3.d.ts +205 -0
- package/dist/index-DtePEQPT.d.ts +152 -0
- package/dist/index-Dv3Hfxk_.d.ts +154 -0
- package/dist/index-FyYBBeN-.d.cts +115 -0
- package/dist/index-Lz5JsJ6O.d.cts +205 -0
- package/dist/index-UPc3wvVd.d.cts +64 -0
- package/dist/liststatehook.cjs +83 -948
- package/dist/liststatehook.cjs.map +1 -1
- package/dist/liststatehook.d.cts +29 -239
- package/dist/liststatehook.d.ts +29 -239
- package/dist/liststatehook.js +77 -85
- package/dist/liststatehook.js.map +1 -1
- package/dist/locationutils.cjs +459 -916
- package/dist/locationutils.cjs.map +1 -1
- package/dist/locationutils.d.cts +244 -110
- package/dist/locationutils.d.ts +244 -110
- package/dist/locationutils.js +440 -44
- package/dist/locationutils.js.map +1 -1
- package/dist/monitorSlice/constants.cjs +0 -19
- package/dist/monitorSlice/constants.d.cts +2 -5
- package/dist/monitorSlice/constants.d.ts +2 -5
- package/dist/monitorSlice/constants.js +1 -2
- package/dist/monitorSlice/index.cjs +65 -82
- package/dist/monitorSlice/index.cjs.map +1 -1
- package/dist/monitorSlice/index.d.cts +2 -94
- package/dist/monitorSlice/index.d.ts +2 -94
- package/dist/monitorSlice/index.js +59 -18
- package/dist/monitorSlice/index.js.map +1 -1
- package/dist/monitorSlice/mocks.cjs +50 -126
- package/dist/monitorSlice/mocks.cjs.map +1 -1
- package/dist/monitorSlice/mocks.d.cts +49 -45
- package/dist/monitorSlice/mocks.d.ts +49 -45
- package/dist/monitorSlice/mocks.js +49 -62
- package/dist/monitorSlice/mocks.js.map +1 -1
- package/dist/monitorSlice/selectors.cjs +5 -29
- package/dist/monitorSlice/selectors.cjs.map +1 -1
- package/dist/monitorSlice/selectors.d.cts +10 -1
- package/dist/monitorSlice/selectors.d.ts +10 -1
- package/dist/monitorSlice/selectors.js +5 -6
- package/dist/monitorSlice/selectors.js.map +1 -1
- package/dist/monitorSlice/thunks.cjs +83 -1914
- package/dist/monitorSlice/thunks.cjs.map +1 -1
- package/dist/monitorSlice/thunks.d.cts +112 -120
- package/dist/monitorSlice/thunks.d.ts +112 -120
- package/dist/monitorSlice/thunks.js +78 -42
- package/dist/monitorSlice/thunks.js.map +1 -1
- package/dist/onboardingSlice/constants.cjs +44 -69
- package/dist/onboardingSlice/constants.cjs.map +1 -1
- package/dist/onboardingSlice/constants.d.cts +2 -26
- package/dist/onboardingSlice/constants.d.ts +2 -26
- package/dist/onboardingSlice/constants.js +43 -7
- package/dist/onboardingSlice/constants.js.map +1 -1
- package/dist/onboardingSlice/index.cjs +53 -73
- package/dist/onboardingSlice/index.cjs.map +1 -1
- package/dist/onboardingSlice/index.d.cts +2 -62
- package/dist/onboardingSlice/index.d.ts +2 -62
- package/dist/onboardingSlice/index.js +47 -13
- package/dist/onboardingSlice/index.js.map +1 -1
- package/dist/onboardingSlice/mocks.cjs +12 -81
- package/dist/onboardingSlice/mocks.cjs.map +1 -1
- package/dist/onboardingSlice/mocks.d.cts +14 -15
- package/dist/onboardingSlice/mocks.d.ts +14 -15
- package/dist/onboardingSlice/mocks.js +12 -15
- package/dist/onboardingSlice/mocks.js.map +1 -1
- package/dist/onboardingSlice/selectors.cjs +5 -29
- package/dist/onboardingSlice/selectors.cjs.map +1 -1
- package/dist/onboardingSlice/selectors.d.cts +6 -1
- package/dist/onboardingSlice/selectors.d.ts +6 -1
- package/dist/onboardingSlice/selectors.js +5 -6
- package/dist/onboardingSlice/selectors.js.map +1 -1
- package/dist/onboardingSlice/thunks.cjs +8 -4746
- package/dist/onboardingSlice/thunks.d.cts +124 -143
- package/dist/onboardingSlice/thunks.d.ts +124 -143
- package/dist/onboardingSlice/thunks.js +2 -49
- package/dist/organizationSlice/constants.cjs +11 -95
- package/dist/organizationSlice/constants.d.cts +2 -91
- package/dist/organizationSlice/constants.d.ts +2 -91
- package/dist/organizationSlice/constants.js +2 -27
- package/dist/organizationSlice/index.cjs +113 -152
- package/dist/organizationSlice/index.cjs.map +1 -1
- package/dist/organizationSlice/index.d.cts +2 -74
- package/dist/organizationSlice/index.d.ts +2 -74
- package/dist/organizationSlice/index.js +106 -18
- package/dist/organizationSlice/index.js.map +1 -1
- package/dist/organizationSlice/mocks.cjs +215 -406
- package/dist/organizationSlice/mocks.cjs.map +1 -1
- package/dist/organizationSlice/mocks.d.cts +209 -212
- package/dist/organizationSlice/mocks.d.ts +209 -212
- package/dist/organizationSlice/mocks.js +214 -184
- package/dist/organizationSlice/mocks.js.map +1 -1
- package/dist/organizationSlice/selectors.cjs +97 -474
- package/dist/organizationSlice/selectors.cjs.map +1 -1
- package/dist/organizationSlice/selectors.d.cts +381 -389
- package/dist/organizationSlice/selectors.d.ts +381 -389
- package/dist/organizationSlice/selectors.js +78 -50
- package/dist/organizationSlice/selectors.js.map +1 -1
- package/dist/organizationSlice/thunks.cjs +43 -5150
- package/dist/organizationSlice/thunks.d.cts +638 -649
- package/dist/organizationSlice/thunks.d.ts +638 -649
- package/dist/organizationSlice/thunks.js +2 -119
- package/dist/organizationSlice/types.cjs +0 -19
- package/dist/organizationSlice/types.d.cts +2 -88
- package/dist/organizationSlice/types.d.ts +2 -88
- package/dist/organizationSlice/types.js +1 -1
- package/dist/releasesSlice/constants.cjs +17 -41
- package/dist/releasesSlice/constants.cjs.map +1 -1
- package/dist/releasesSlice/constants.d.cts +2 -15
- package/dist/releasesSlice/constants.d.ts +2 -15
- package/dist/releasesSlice/constants.js +13 -14
- package/dist/releasesSlice/constants.js.map +1 -1
- package/dist/releasesSlice/index.cjs +106 -179
- package/dist/releasesSlice/index.cjs.map +1 -1
- package/dist/releasesSlice/index.d.cts +2 -113
- package/dist/releasesSlice/index.d.ts +2 -113
- package/dist/releasesSlice/index.js +100 -18
- package/dist/releasesSlice/index.js.map +1 -1
- package/dist/releasesSlice/mocks.cjs +44 -220
- package/dist/releasesSlice/mocks.cjs.map +1 -1
- package/dist/releasesSlice/mocks.d.cts +63 -61
- package/dist/releasesSlice/mocks.d.ts +63 -61
- package/dist/releasesSlice/mocks.js +43 -59
- package/dist/releasesSlice/mocks.js.map +1 -1
- package/dist/releasesSlice/selectors.cjs +44 -439
- package/dist/releasesSlice/selectors.cjs.map +1 -1
- package/dist/releasesSlice/selectors.d.cts +268 -280
- package/dist/releasesSlice/selectors.d.ts +268 -280
- package/dist/releasesSlice/selectors.js +31 -36
- package/dist/releasesSlice/selectors.js.map +1 -1
- package/dist/releasesSlice/thunks.cjs +422 -2175
- package/dist/releasesSlice/thunks.cjs.map +1 -1
- package/dist/releasesSlice/thunks.d.cts +305 -307
- package/dist/releasesSlice/thunks.d.ts +305 -307
- package/dist/releasesSlice/thunks.js +413 -65
- package/dist/releasesSlice/thunks.js.map +1 -1
- package/dist/selectors.cjs +136 -1530
- package/dist/selectors.d.cts +10 -36
- package/dist/selectors.d.ts +10 -36
- package/dist/selectors.js +10 -280
- package/dist/sockethook.cjs +140 -515
- package/dist/sockethook.cjs.map +1 -1
- package/dist/sockethook.d.cts +25 -9
- package/dist/sockethook.d.ts +25 -9
- package/dist/sockethook.js +134 -135
- package/dist/sockethook.js.map +1 -1
- package/dist/store-BQxOSRC1.d.ts +234 -0
- package/dist/store-BiIA0r0A.d.cts +234 -0
- package/dist/store.cjs +117 -1290
- package/dist/store.cjs.map +1 -1
- package/dist/store.d.cts +3 -206
- package/dist/store.d.ts +3 -206
- package/dist/store.js +110 -32
- package/dist/store.js.map +1 -1
- package/dist/storehooks.cjs +240 -5783
- package/dist/storehooks.cjs.map +1 -1
- package/dist/storehooks.d.cts +76 -4
- package/dist/storehooks.d.ts +76 -4
- package/dist/storehooks.js +229 -265
- package/dist/storehooks.js.map +1 -1
- package/dist/thunks.cjs +2656 -5918
- package/dist/thunks.cjs.map +1 -1
- package/dist/thunks.d.cts +9 -36
- package/dist/thunks.d.ts +9 -36
- package/dist/thunks.js +2481 -385
- package/dist/thunks.js.map +1 -1
- package/dist/types-B2NRQLFw.d.ts +88 -0
- package/dist/types-ClEfo0dK.d.cts +88 -0
- package/dist/useDeploymentDevice.cjs +26 -4650
- package/dist/useDeploymentDevice.cjs.map +1 -1
- package/dist/useDeploymentDevice.d.cts +4 -2
- package/dist/useDeploymentDevice.d.ts +4 -2
- package/dist/useDeploymentDevice.js +21 -60
- package/dist/useDeploymentDevice.js.map +1 -1
- package/dist/usersSlice/constants.cjs +8 -55
- package/dist/usersSlice/constants.d.cts +2 -52
- package/dist/usersSlice/constants.d.ts +2 -52
- package/dist/usersSlice/constants.js +2 -21
- package/dist/usersSlice/index.cjs +132 -172
- package/dist/usersSlice/index.cjs.map +1 -1
- package/dist/usersSlice/index.d.cts +2 -152
- package/dist/usersSlice/index.d.ts +2 -152
- package/dist/usersSlice/index.js +125 -18
- package/dist/usersSlice/index.js.map +1 -1
- package/dist/usersSlice/mocks.cjs +55 -196
- package/dist/usersSlice/mocks.cjs.map +1 -1
- package/dist/usersSlice/mocks.d.cts +68 -72
- package/dist/usersSlice/mocks.d.ts +68 -72
- package/dist/usersSlice/mocks.js +54 -46
- package/dist/usersSlice/mocks.js.map +1 -1
- package/dist/usersSlice/selectors.cjs +65 -567
- package/dist/usersSlice/selectors.cjs.map +1 -1
- package/dist/usersSlice/selectors.d.cts +364 -376
- package/dist/usersSlice/selectors.d.ts +364 -376
- package/dist/usersSlice/selectors.js +44 -50
- package/dist/usersSlice/selectors.js.map +1 -1
- package/dist/usersSlice/thunks.cjs +39 -4698
- package/dist/usersSlice/thunks.d.cts +820 -856
- package/dist/usersSlice/thunks.d.ts +820 -856
- package/dist/usersSlice/thunks.js +2 -111
- package/dist/utils-CO_CpGFP.d.ts +105 -0
- package/dist/utils-CpPfqW0Q.d.cts +105 -0
- package/dist/utils.cjs +231 -850
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +2 -80
- package/dist/utils.d.ts +2 -80
- package/dist/utils.js +211 -50
- package/dist/utils.js.map +1 -1
- package/package.json +11 -13
- package/dist/appSlice/thunks.cjs.map +0 -1
- package/dist/appSlice/thunks.js.map +0 -1
- package/dist/chunk-2DYA3X77.js +0 -15
- package/dist/chunk-2DYA3X77.js.map +0 -1
- package/dist/chunk-4BHM6WVX.js +0 -50
- package/dist/chunk-4BHM6WVX.js.map +0 -1
- package/dist/chunk-4UNLEL5A.js +0 -143
- package/dist/chunk-4UNLEL5A.js.map +0 -1
- package/dist/chunk-6V5IIIF7.js +0 -396
- package/dist/chunk-6V5IIIF7.js.map +0 -1
- package/dist/chunk-ARMI6SZS.js +0 -446
- package/dist/chunk-ARMI6SZS.js.map +0 -1
- package/dist/chunk-AZF4YY3P.js +0 -108
- package/dist/chunk-AZF4YY3P.js.map +0 -1
- package/dist/chunk-B5AI2YPV.js +0 -156
- package/dist/chunk-B5AI2YPV.js.map +0 -1
- package/dist/chunk-CQXDAXQF.js +0 -51
- package/dist/chunk-CQXDAXQF.js.map +0 -1
- package/dist/chunk-DBBE6D36.js +0 -115
- package/dist/chunk-DBBE6D36.js.map +0 -1
- package/dist/chunk-ECVQVQEL.js +0 -68
- package/dist/chunk-ECVQVQEL.js.map +0 -1
- package/dist/chunk-FAJ3I2UQ.js +0 -47
- package/dist/chunk-FAJ3I2UQ.js.map +0 -1
- package/dist/chunk-FCY7BUGK.js +0 -2876
- package/dist/chunk-FCY7BUGK.js.map +0 -1
- package/dist/chunk-FG37HJLC.js +0 -157
- package/dist/chunk-FG37HJLC.js.map +0 -1
- package/dist/chunk-FQAUVV6C.js +0 -246
- package/dist/chunk-FQAUVV6C.js.map +0 -1
- package/dist/chunk-HKN3RN2Z.js +0 -41
- package/dist/chunk-HKN3RN2Z.js.map +0 -1
- package/dist/chunk-HPKXWNEF.js +0 -100
- package/dist/chunk-HPKXWNEF.js.map +0 -1
- package/dist/chunk-JIS4PA3R.js +0 -7
- package/dist/chunk-JIS4PA3R.js.map +0 -1
- package/dist/chunk-JXBTIFMS.js +0 -82
- package/dist/chunk-JXBTIFMS.js.map +0 -1
- package/dist/chunk-JYPSCCT4.js +0 -58
- package/dist/chunk-JYPSCCT4.js.map +0 -1
- package/dist/chunk-L53CPHJU.js +0 -721
- package/dist/chunk-L53CPHJU.js.map +0 -1
- package/dist/chunk-MNJXEB7S.js +0 -304
- package/dist/chunk-MNJXEB7S.js.map +0 -1
- package/dist/chunk-NMAXZ3ZY.js +0 -1
- package/dist/chunk-NMAXZ3ZY.js.map +0 -1
- package/dist/chunk-NXLXPRYW.js +0 -142
- package/dist/chunk-NXLXPRYW.js.map +0 -1
- package/dist/chunk-O6VCSLNE.js +0 -59
- package/dist/chunk-O6VCSLNE.js.map +0 -1
- package/dist/chunk-PQADM3M3.js +0 -115
- package/dist/chunk-PQADM3M3.js.map +0 -1
- package/dist/chunk-SJ75YKOA.js +0 -44
- package/dist/chunk-SJ75YKOA.js.map +0 -1
- package/dist/chunk-TUPBZ6MQ.js +0 -162
- package/dist/chunk-TUPBZ6MQ.js.map +0 -1
- package/dist/chunk-XF3TZSZS.js +0 -25
- package/dist/chunk-XF3TZSZS.js.map +0 -1
- package/dist/chunk-YB3US6OT.js +0 -61
- package/dist/chunk-YB3US6OT.js.map +0 -1
- package/dist/chunk-YDDE5TIH.js +0 -204
- package/dist/chunk-YDDE5TIH.js.map +0 -1
- package/dist/chunk-YO22XLHI.js +0 -7
- package/dist/chunk-YO22XLHI.js.map +0 -1
- package/dist/chunk-Z2O6LYVP.js +0 -144
- package/dist/chunk-Z2O6LYVP.js.map +0 -1
- package/dist/chunk-ZKAH3APE.js +0 -1
- package/dist/chunk-ZKAH3APE.js.map +0 -1
- package/dist/commonConstants.cjs.map +0 -1
- package/dist/commonConstants.js.map +0 -1
- package/dist/deploymentsSlice/constants.cjs.map +0 -1
- package/dist/deploymentsSlice/constants.js.map +0 -1
- package/dist/deploymentsSlice/thunks.cjs.map +0 -1
- package/dist/deploymentsSlice/thunks.js.map +0 -1
- package/dist/devicesSlice/constants.cjs.map +0 -1
- package/dist/devicesSlice/constants.js.map +0 -1
- package/dist/devicesSlice/thunks.cjs.map +0 -1
- package/dist/devicesSlice/thunks.js.map +0 -1
- package/dist/monitorSlice/constants.cjs.map +0 -1
- package/dist/monitorSlice/constants.js.map +0 -1
- package/dist/onboardingSlice/thunks.cjs.map +0 -1
- package/dist/onboardingSlice/thunks.js.map +0 -1
- package/dist/organizationSlice/constants.cjs.map +0 -1
- package/dist/organizationSlice/constants.js.map +0 -1
- package/dist/organizationSlice/thunks.cjs.map +0 -1
- package/dist/organizationSlice/thunks.js.map +0 -1
- package/dist/organizationSlice/types.cjs.map +0 -1
- package/dist/organizationSlice/types.js.map +0 -1
- package/dist/selectors.cjs.map +0 -1
- package/dist/selectors.js.map +0 -1
- package/dist/usersSlice/constants.cjs.map +0 -1
- package/dist/usersSlice/constants.js.map +0 -1
- package/dist/usersSlice/thunks.cjs.map +0 -1
- package/dist/usersSlice/thunks.js.map +0 -1
|
@@ -1,4746 +1,8 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/onboardingSlice/thunks.ts
|
|
31
|
-
var thunks_exports = {};
|
|
32
|
-
__export(thunks_exports, {
|
|
33
|
-
advanceOnboarding: () => advanceOnboarding,
|
|
34
|
-
getOnboardingState: () => getOnboardingState2,
|
|
35
|
-
setOnboardingApproach: () => setOnboardingApproach,
|
|
36
|
-
setOnboardingCanceled: () => setOnboardingCanceled,
|
|
37
|
-
setOnboardingComplete: () => setOnboardingComplete,
|
|
38
|
-
setOnboardingDeviceType: () => setOnboardingDeviceType
|
|
39
|
-
});
|
|
40
|
-
module.exports = __toCommonJS(thunks_exports);
|
|
41
|
-
var import_helpers11 = require("@northern.tech/utils/helpers");
|
|
42
|
-
var import_tracking2 = __toESM(require("@northern.tech/utils/tracking"), 1);
|
|
43
|
-
var import_universal_cookie5 = __toESM(require("universal-cookie"), 1);
|
|
44
|
-
|
|
45
|
-
// src/onboardingSlice/index.ts
|
|
46
|
-
var import_toolkit = require("@reduxjs/toolkit");
|
|
47
|
-
var sliceName = "onboarding";
|
|
48
|
-
var initialState = {
|
|
49
|
-
approach: null,
|
|
50
|
-
complete: false,
|
|
51
|
-
deviceType: null,
|
|
52
|
-
demoArtifactPort: 85,
|
|
53
|
-
progress: null,
|
|
54
|
-
showTips: null,
|
|
55
|
-
showTipsDialog: false
|
|
56
|
-
};
|
|
57
|
-
var onboardingSlice = (0, import_toolkit.createSlice)({
|
|
58
|
-
name: sliceName,
|
|
59
|
-
initialState,
|
|
60
|
-
reducers: {
|
|
61
|
-
setOnboardingState: (state, action) => ({ ...state, ...action.payload }),
|
|
62
|
-
setDemoArtifactPort: (state, action) => {
|
|
63
|
-
state.demoArtifactPort = action.payload;
|
|
64
|
-
},
|
|
65
|
-
setShowOnboardingHelp: (state, action) => {
|
|
66
|
-
state.showTips = action.payload;
|
|
67
|
-
},
|
|
68
|
-
setShowDismissOnboardingTipsDialog: (state, action) => {
|
|
69
|
-
state.showTipsDialog = action.payload;
|
|
70
|
-
},
|
|
71
|
-
setOnboardingComplete: (state, action) => {
|
|
72
|
-
state.complete = action.payload;
|
|
73
|
-
},
|
|
74
|
-
setOnboardingProgress: (state, action) => {
|
|
75
|
-
state.progress = action.payload;
|
|
76
|
-
},
|
|
77
|
-
setOnboardingDeviceType: (state, action) => {
|
|
78
|
-
state.deviceType = action.payload;
|
|
79
|
-
},
|
|
80
|
-
setOnboardingApproach: (state, action) => {
|
|
81
|
-
state.approach = action.payload;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
var actions = onboardingSlice.actions;
|
|
86
|
-
var onboardingSlice_default = onboardingSlice.reducer;
|
|
87
|
-
|
|
88
|
-
// src/constants.ts
|
|
89
|
-
var import_constants5 = require("@northern.tech/utils/constants");
|
|
90
|
-
|
|
91
|
-
// src/appSlice/constants.ts
|
|
92
|
-
var import_icons_material = require("@mui/icons-material");
|
|
93
|
-
var import_utils = require("@northern.tech/utils");
|
|
94
|
-
var chartTypes = {
|
|
95
|
-
bar: { key: "bar", Icon: import_icons_material.BarChart },
|
|
96
|
-
pie: { key: "pie", Icon: import_icons_material.PieChartOutline }
|
|
97
|
-
};
|
|
98
|
-
var emptyChartSelection = { software: "", group: "", chartType: chartTypes.bar.key, attribute: "artifact_name" };
|
|
99
|
-
var defaultReportType = "distribution";
|
|
100
|
-
var defaultReports = [{ ...emptyChartSelection, group: null, attribute: "artifact_name", type: defaultReportType }];
|
|
101
|
-
var PLANS = {
|
|
102
|
-
os: {
|
|
103
|
-
id: "os",
|
|
104
|
-
name: "Basic",
|
|
105
|
-
description: "The core features of Mender. To continue using Enterprise Trial features\u2014like Delta updates, scheduled deployments, phased rollouts, device filtering, dynamic groups, RBAC, audit logs, and more\u2014please upgrade to a higher plan."
|
|
106
|
-
},
|
|
107
|
-
professional: {
|
|
108
|
-
id: "professional",
|
|
109
|
-
name: "Professional",
|
|
110
|
-
description: "Everything in Basic, plus enhanced update management and automation features."
|
|
111
|
-
},
|
|
112
|
-
enterprise: {
|
|
113
|
-
id: "enterprise",
|
|
114
|
-
name: "Enterprise",
|
|
115
|
-
description: "Every advanced feature of Mender, tailored for complex and large-scale deployments. Not available as a monthly subscription \u2014 ask us for a quote."
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
var ADDONS = {
|
|
119
|
-
configure: {
|
|
120
|
-
id: "configure",
|
|
121
|
-
title: "Configure",
|
|
122
|
-
description: "Seamlessly configure applications and devices remotely \u2013 configure each device to its environment.",
|
|
123
|
-
needs: ["hasDeviceConfig"],
|
|
124
|
-
eligible: ["os", "professional", "enterprise"]
|
|
125
|
-
},
|
|
126
|
-
monitor: {
|
|
127
|
-
id: "monitor",
|
|
128
|
-
title: "Monitor",
|
|
129
|
-
description: "Detect and analyze health issues of devices, services and applications. Set up alerts so you can act quickly.",
|
|
130
|
-
needs: ["hasMonitor"],
|
|
131
|
-
eligible: ["professional", "enterprise"]
|
|
132
|
-
},
|
|
133
|
-
troubleshoot: {
|
|
134
|
-
id: "troubleshoot",
|
|
135
|
-
title: "Troubleshoot",
|
|
136
|
-
description: "Secure, remote access to your devices \u2013 quickly diagnose and fix issues in real time.",
|
|
137
|
-
needs: ["hasDeviceConnect"],
|
|
138
|
-
eligible: ["os", "professional", "enterprise"]
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
var BENEFITS = {
|
|
142
|
-
auditlog: {
|
|
143
|
-
id: "auditlog",
|
|
144
|
-
benefit: "gain access to logs for important events such as changes to devices, deployments and user management, as well as remote terminal session replays",
|
|
145
|
-
requiredPlan: PLANS.enterprise.id
|
|
146
|
-
},
|
|
147
|
-
dashboard: { id: "dashboard", benefit: "actionable insights into the devices you are updating with Mender", requiredPlan: PLANS.enterprise.id },
|
|
148
|
-
deltaGeneration: {
|
|
149
|
-
id: "deltaGeneration",
|
|
150
|
-
benefit: "automatic delta artifacts generation to minimize data transfer and improve the update delivery",
|
|
151
|
-
requiredPlan: PLANS.enterprise.id
|
|
152
|
-
},
|
|
153
|
-
deviceConfiguration: { id: "deviceConfiguration", benefit: "device configuration features", requiredAddon: ADDONS.configure.id },
|
|
154
|
-
deviceMonitor: { id: "deviceMonitor", benefit: "device monitoring features", requiredAddon: ADDONS.monitor.id, requiredPlan: PLANS.professional.id },
|
|
155
|
-
deviceTroubleshoot: { id: "deviceTroubleshoot", benefit: "device troubleshooting features", requiredAddon: ADDONS.troubleshoot.id },
|
|
156
|
-
dynamicGroups: { id: "dynamicGroups", benefit: "create dynamic groups to ease device management", requiredPlan: PLANS.enterprise.id },
|
|
157
|
-
fullFiltering: { id: "fullFiltering", benefit: "filtering by multiple attributes to improve the device overview", requiredPlan: PLANS.professional.id },
|
|
158
|
-
gateway: { id: "gateway", benefit: "see devices connected to your gateway device for easy access", requiredPlans: PLANS.professional.id },
|
|
159
|
-
pausedDeployments: {
|
|
160
|
-
id: "pausedDeployments",
|
|
161
|
-
benefit: "granular control about update rollout to allow synchronization across your fleet",
|
|
162
|
-
requiredPlan: PLANS.enterprise.id
|
|
163
|
-
},
|
|
164
|
-
phasedDeployments: { id: "phasedDeployments", benefit: "choose to roll out deployments in multiple phases", requiredPlan: PLANS.enterprise.id },
|
|
165
|
-
rbac: { id: "rbac", benefit: "granular role based access control", requiredPlan: PLANS.enterprise.id },
|
|
166
|
-
retryDeployments: { id: "retryDeployments", benefit: "optional retries for failed rollout attempts", requiredPlan: PLANS.professional.id },
|
|
167
|
-
scheduledDeployments: {
|
|
168
|
-
id: "scheduledDeployments",
|
|
169
|
-
benefit: "scheduled deployments to steer the distribution of your updates.",
|
|
170
|
-
requiredPlan: PLANS.professional.id
|
|
171
|
-
},
|
|
172
|
-
webhookEvents: {
|
|
173
|
-
id: "webhookEvents",
|
|
174
|
-
benefit: "receive inventory events and select which type(s) of events the webhook will receive",
|
|
175
|
-
requiredPlan: PLANS.professional.id
|
|
176
|
-
},
|
|
177
|
-
default: { id: "default", benefit: "gain access to this feature", requiredPlan: PLANS.enterprise.id }
|
|
178
|
-
};
|
|
179
|
-
var DARK_MODE = "dark";
|
|
180
|
-
|
|
181
|
-
// src/commonConstants.tsx
|
|
182
|
-
var import_js = require("@mdi/js");
|
|
183
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
184
|
-
var timeUnits = {
|
|
185
|
-
days: "days",
|
|
186
|
-
minutes: "minutes",
|
|
187
|
-
hours: "hours"
|
|
188
|
-
};
|
|
189
|
-
var UNGROUPED_GROUP = { id: "*|=ungrouped=|*", name: "Unassigned" };
|
|
190
|
-
var DEVICE_LIST_MAXIMUM_LENGTH = 50;
|
|
191
|
-
var oneSecond = 1e3;
|
|
192
|
-
var TIMEOUTS = {
|
|
193
|
-
debounceDefault: 700,
|
|
194
|
-
debounceShort: 300,
|
|
195
|
-
halfASecond: 0.5 * oneSecond,
|
|
196
|
-
oneSecond,
|
|
197
|
-
twoSeconds: 2 * oneSecond,
|
|
198
|
-
threeSeconds: 3 * oneSecond,
|
|
199
|
-
fiveSeconds: 5 * oneSecond,
|
|
200
|
-
refreshDefault: 10 * oneSecond,
|
|
201
|
-
refreshLong: 60 * oneSecond
|
|
202
|
-
};
|
|
203
|
-
var DEVICE_ONLINE_CUTOFF = { interval: 1, intervalName: timeUnits.days };
|
|
204
|
-
var defaultIdAttribute = Object.freeze({ attribute: "id", scope: import_constants5.ATTRIBUTE_SCOPES.identity });
|
|
205
|
-
var productOrder = ["micro", "standard", "system"];
|
|
206
|
-
var credentialTypes = {
|
|
207
|
-
aws: "aws",
|
|
208
|
-
http: "http",
|
|
209
|
-
sas: "sas",
|
|
210
|
-
x509: "x509"
|
|
211
|
-
};
|
|
212
|
-
var EXTERNAL_PROVIDER = {
|
|
213
|
-
"iot-core": {
|
|
214
|
-
credentialsType: credentialTypes.aws,
|
|
215
|
-
icon: import_js.mdiAws,
|
|
216
|
-
title: "AWS IoT Core",
|
|
217
|
-
twinTitle: "Device Shadow",
|
|
218
|
-
provider: "iot-core",
|
|
219
|
-
enabled: true,
|
|
220
|
-
deviceTwin: true,
|
|
221
|
-
configHint: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: "For help finding your AWS IoT Core connection string, check the AWS IoT documentation." })
|
|
222
|
-
},
|
|
223
|
-
"iot-hub": {
|
|
224
|
-
credentialsType: credentialTypes.sas,
|
|
225
|
-
icon: import_js.mdiMicrosoftAzure,
|
|
226
|
-
title: "Azure IoT Hub",
|
|
227
|
-
twinTitle: "Device Twin",
|
|
228
|
-
provider: "iot-hub",
|
|
229
|
-
enabled: true,
|
|
230
|
-
deviceTwin: true,
|
|
231
|
-
configHint: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
|
|
232
|
-
"For help finding your Azure IoT Hub connection string, look under 'Shared access policies' in the Microsoft Azure UI as described",
|
|
233
|
-
" ",
|
|
234
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
235
|
-
"a",
|
|
236
|
-
{
|
|
237
|
-
href: "https://devblogs.microsoft.com/iotdev/understand-different-connection-strings-in-azure-iot-hub/#iothubconn",
|
|
238
|
-
target: "_blank",
|
|
239
|
-
rel: "noopener noreferrer",
|
|
240
|
-
children: "here"
|
|
241
|
-
}
|
|
242
|
-
),
|
|
243
|
-
"."
|
|
244
|
-
] })
|
|
245
|
-
},
|
|
246
|
-
webhook: {
|
|
247
|
-
credentialsType: credentialTypes.http,
|
|
248
|
-
deviceTwin: false,
|
|
249
|
-
twinTitle: "",
|
|
250
|
-
// disable the webhook provider here, since it is treated different than other integrations, with a custom configuration & management view, etc.
|
|
251
|
-
enabled: false,
|
|
252
|
-
provider: "webhook"
|
|
253
|
-
}
|
|
254
|
-
};
|
|
255
|
-
var emptyWebhook = {
|
|
256
|
-
description: "",
|
|
257
|
-
provider: "webhook",
|
|
258
|
-
credentials: {
|
|
259
|
-
type: EXTERNAL_PROVIDER.webhook.credentialsType,
|
|
260
|
-
[EXTERNAL_PROVIDER.webhook.credentialsType]: {
|
|
261
|
-
secret: "",
|
|
262
|
-
url: ""
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
};
|
|
266
|
-
var MAX_PAGE_SIZE = 500;
|
|
267
|
-
var regionNames = new Intl.DisplayNames(["en"], { type: "region" });
|
|
268
|
-
var countries = [
|
|
269
|
-
"AD",
|
|
270
|
-
"AE",
|
|
271
|
-
"AF",
|
|
272
|
-
"AG",
|
|
273
|
-
"AI",
|
|
274
|
-
"AL",
|
|
275
|
-
"AM",
|
|
276
|
-
"AO",
|
|
277
|
-
"AQ",
|
|
278
|
-
"AR",
|
|
279
|
-
"AS",
|
|
280
|
-
"AT",
|
|
281
|
-
"AU",
|
|
282
|
-
"AW",
|
|
283
|
-
"AX",
|
|
284
|
-
"AZ",
|
|
285
|
-
"BA",
|
|
286
|
-
"BB",
|
|
287
|
-
"BD",
|
|
288
|
-
"BE",
|
|
289
|
-
"BF",
|
|
290
|
-
"BG",
|
|
291
|
-
"BH",
|
|
292
|
-
"BI",
|
|
293
|
-
"BJ",
|
|
294
|
-
"BL",
|
|
295
|
-
"BM",
|
|
296
|
-
"BN",
|
|
297
|
-
"BO",
|
|
298
|
-
"BR",
|
|
299
|
-
"BS",
|
|
300
|
-
"BT",
|
|
301
|
-
"BV",
|
|
302
|
-
"BW",
|
|
303
|
-
"BY",
|
|
304
|
-
"BZ",
|
|
305
|
-
"CA",
|
|
306
|
-
"CC",
|
|
307
|
-
"CD",
|
|
308
|
-
"CF",
|
|
309
|
-
"CG",
|
|
310
|
-
"CH",
|
|
311
|
-
"CI",
|
|
312
|
-
"CK",
|
|
313
|
-
"CL",
|
|
314
|
-
"CM",
|
|
315
|
-
"CN",
|
|
316
|
-
"CO",
|
|
317
|
-
"CR",
|
|
318
|
-
"CU",
|
|
319
|
-
"CV",
|
|
320
|
-
"CW",
|
|
321
|
-
"CX",
|
|
322
|
-
"CY",
|
|
323
|
-
"CZ",
|
|
324
|
-
"DE",
|
|
325
|
-
"DJ",
|
|
326
|
-
"DK",
|
|
327
|
-
"DM",
|
|
328
|
-
"DO",
|
|
329
|
-
"DZ",
|
|
330
|
-
"EC",
|
|
331
|
-
"EE",
|
|
332
|
-
"EG",
|
|
333
|
-
"EH",
|
|
334
|
-
"ER",
|
|
335
|
-
"ES",
|
|
336
|
-
"ET",
|
|
337
|
-
"FI",
|
|
338
|
-
"FJ",
|
|
339
|
-
"FK",
|
|
340
|
-
"FM",
|
|
341
|
-
"FO",
|
|
342
|
-
"FR",
|
|
343
|
-
"GA",
|
|
344
|
-
"GB",
|
|
345
|
-
"GD",
|
|
346
|
-
"GE",
|
|
347
|
-
"GF",
|
|
348
|
-
"GG",
|
|
349
|
-
"GH",
|
|
350
|
-
"GI",
|
|
351
|
-
"GL",
|
|
352
|
-
"GM",
|
|
353
|
-
"GN",
|
|
354
|
-
"GP",
|
|
355
|
-
"GQ",
|
|
356
|
-
"GR",
|
|
357
|
-
"GS",
|
|
358
|
-
"GT",
|
|
359
|
-
"GU",
|
|
360
|
-
"GW",
|
|
361
|
-
"GY",
|
|
362
|
-
"HK",
|
|
363
|
-
"HM",
|
|
364
|
-
"HN",
|
|
365
|
-
"HR",
|
|
366
|
-
"HT",
|
|
367
|
-
"HU",
|
|
368
|
-
"ID",
|
|
369
|
-
"IE",
|
|
370
|
-
"IL",
|
|
371
|
-
"IM",
|
|
372
|
-
"IN",
|
|
373
|
-
"IO",
|
|
374
|
-
"IQ",
|
|
375
|
-
"IR",
|
|
376
|
-
"IS",
|
|
377
|
-
"IT",
|
|
378
|
-
"JE",
|
|
379
|
-
"JM",
|
|
380
|
-
"JO",
|
|
381
|
-
"JP",
|
|
382
|
-
"KE",
|
|
383
|
-
"KG",
|
|
384
|
-
"KH",
|
|
385
|
-
"KI",
|
|
386
|
-
"KM",
|
|
387
|
-
"KN",
|
|
388
|
-
"KP",
|
|
389
|
-
"KR",
|
|
390
|
-
"KW",
|
|
391
|
-
"KY",
|
|
392
|
-
"KZ",
|
|
393
|
-
"LA",
|
|
394
|
-
"LB",
|
|
395
|
-
"LC",
|
|
396
|
-
"LI",
|
|
397
|
-
"LK",
|
|
398
|
-
"LR",
|
|
399
|
-
"LS",
|
|
400
|
-
"LT",
|
|
401
|
-
"LU",
|
|
402
|
-
"LV",
|
|
403
|
-
"LY",
|
|
404
|
-
"MA",
|
|
405
|
-
"MC",
|
|
406
|
-
"MD",
|
|
407
|
-
"ME",
|
|
408
|
-
"MF",
|
|
409
|
-
"MG",
|
|
410
|
-
"MH",
|
|
411
|
-
"MK",
|
|
412
|
-
"ML",
|
|
413
|
-
"MM",
|
|
414
|
-
"MN",
|
|
415
|
-
"MO",
|
|
416
|
-
"MP",
|
|
417
|
-
"MQ",
|
|
418
|
-
"MR",
|
|
419
|
-
"MS",
|
|
420
|
-
"MT",
|
|
421
|
-
"MU",
|
|
422
|
-
"MV",
|
|
423
|
-
"MW",
|
|
424
|
-
"MX",
|
|
425
|
-
"MY",
|
|
426
|
-
"MZ",
|
|
427
|
-
"NA",
|
|
428
|
-
"NC",
|
|
429
|
-
"NE",
|
|
430
|
-
"NF",
|
|
431
|
-
"NG",
|
|
432
|
-
"NI",
|
|
433
|
-
"NL",
|
|
434
|
-
"NO",
|
|
435
|
-
"NP",
|
|
436
|
-
"NR",
|
|
437
|
-
"NU",
|
|
438
|
-
"NZ",
|
|
439
|
-
"OM",
|
|
440
|
-
"PA",
|
|
441
|
-
"PE",
|
|
442
|
-
"PF",
|
|
443
|
-
"PG",
|
|
444
|
-
"PH",
|
|
445
|
-
"PK",
|
|
446
|
-
"PL",
|
|
447
|
-
"PM",
|
|
448
|
-
"PN",
|
|
449
|
-
"PR",
|
|
450
|
-
"PS",
|
|
451
|
-
"PT",
|
|
452
|
-
"PW",
|
|
453
|
-
"PY",
|
|
454
|
-
"QA",
|
|
455
|
-
"RE",
|
|
456
|
-
"RO",
|
|
457
|
-
"RS",
|
|
458
|
-
"RU",
|
|
459
|
-
"RW",
|
|
460
|
-
"SA",
|
|
461
|
-
"SB",
|
|
462
|
-
"SC",
|
|
463
|
-
"SD",
|
|
464
|
-
"SE",
|
|
465
|
-
"SG",
|
|
466
|
-
"SH",
|
|
467
|
-
"SI",
|
|
468
|
-
"SJ",
|
|
469
|
-
"SK",
|
|
470
|
-
"SL",
|
|
471
|
-
"SM",
|
|
472
|
-
"SN",
|
|
473
|
-
"SO",
|
|
474
|
-
"SR",
|
|
475
|
-
"SS",
|
|
476
|
-
"ST",
|
|
477
|
-
"SV",
|
|
478
|
-
"SX",
|
|
479
|
-
"SY",
|
|
480
|
-
"SZ",
|
|
481
|
-
"TC",
|
|
482
|
-
"TD",
|
|
483
|
-
"TF",
|
|
484
|
-
"TG",
|
|
485
|
-
"TH",
|
|
486
|
-
"TJ",
|
|
487
|
-
"TK",
|
|
488
|
-
"TL",
|
|
489
|
-
"TM",
|
|
490
|
-
"TN",
|
|
491
|
-
"TO",
|
|
492
|
-
"TR",
|
|
493
|
-
"TT",
|
|
494
|
-
"TV",
|
|
495
|
-
"TW",
|
|
496
|
-
"TZ",
|
|
497
|
-
"UA",
|
|
498
|
-
"UG",
|
|
499
|
-
"US",
|
|
500
|
-
"UY",
|
|
501
|
-
"UZ",
|
|
502
|
-
"VA",
|
|
503
|
-
"VC",
|
|
504
|
-
"VE",
|
|
505
|
-
"VG",
|
|
506
|
-
"VI",
|
|
507
|
-
"VN",
|
|
508
|
-
"VU",
|
|
509
|
-
"WF",
|
|
510
|
-
"WS",
|
|
511
|
-
"XK",
|
|
512
|
-
"YE",
|
|
513
|
-
"YT",
|
|
514
|
-
"ZA",
|
|
515
|
-
"ZM",
|
|
516
|
-
"ZW"
|
|
517
|
-
].map((code) => ({ code, label: regionNames.of(code) })).sort((a, b) => a.label.localeCompare(b.label));
|
|
518
|
-
|
|
519
|
-
// src/deploymentsSlice/constants.ts
|
|
520
|
-
var alreadyInstalled = "already-installed";
|
|
521
|
-
var deploymentSubstates = {
|
|
522
|
-
aborted: "aborted",
|
|
523
|
-
alreadyInstalled,
|
|
524
|
-
decommissioned: "decommissioned",
|
|
525
|
-
downloading: "downloading",
|
|
526
|
-
failure: "failure",
|
|
527
|
-
installing: "installing",
|
|
528
|
-
noartifact: "noartifact",
|
|
529
|
-
artifact_too_big: "artifact_too_big",
|
|
530
|
-
pause_before_committing: "pause_before_committing",
|
|
531
|
-
pause_before_installing: "pause_before_installing",
|
|
532
|
-
pause_before_rebooting: "pause_before_rebooting",
|
|
533
|
-
pending: "pending",
|
|
534
|
-
rebooting: "rebooting",
|
|
535
|
-
success: "success"
|
|
536
|
-
};
|
|
537
|
-
var deploymentStatesToSubstates = {
|
|
538
|
-
failures: [deploymentSubstates.failure, deploymentSubstates.aborted, deploymentSubstates.decommissioned],
|
|
539
|
-
inprogress: [deploymentSubstates.downloading, deploymentSubstates.installing, deploymentSubstates.rebooting],
|
|
540
|
-
paused: [deploymentSubstates.pause_before_installing, deploymentSubstates.pause_before_rebooting, deploymentSubstates.pause_before_committing],
|
|
541
|
-
pending: [deploymentSubstates.pending],
|
|
542
|
-
successes: [deploymentSubstates.success, deploymentSubstates.alreadyInstalled, deploymentSubstates.noartifact, deploymentSubstates.artifact_too_big]
|
|
543
|
-
};
|
|
544
|
-
var deploymentStatesToSubstatesWithSkipped = {
|
|
545
|
-
...deploymentStatesToSubstates,
|
|
546
|
-
failures: [deploymentSubstates.failure],
|
|
547
|
-
skipped: [
|
|
548
|
-
deploymentSubstates.aborted,
|
|
549
|
-
deploymentSubstates.noartifact,
|
|
550
|
-
deploymentSubstates.artifact_too_big,
|
|
551
|
-
deploymentSubstates.alreadyInstalled,
|
|
552
|
-
deploymentSubstates.decommissioned
|
|
553
|
-
],
|
|
554
|
-
successes: [deploymentSubstates.success]
|
|
555
|
-
};
|
|
556
|
-
var installationSubstatesMap = {
|
|
557
|
-
download: {
|
|
558
|
-
title: "download",
|
|
559
|
-
done: "downloaded",
|
|
560
|
-
successIndicators: [deploymentSubstates.installing, deploymentSubstates.rebooting, ...deploymentStatesToSubstates.paused, deploymentSubstates.success],
|
|
561
|
-
failureIndicators: deploymentStatesToSubstates.failures,
|
|
562
|
-
pauseConfigurationIndicator: "ArtifactInstall_Enter"
|
|
563
|
-
},
|
|
564
|
-
install: {
|
|
565
|
-
title: "install",
|
|
566
|
-
done: "installed",
|
|
567
|
-
successIndicators: [
|
|
568
|
-
deploymentSubstates.rebooting,
|
|
569
|
-
deploymentSubstates.pause_before_rebooting,
|
|
570
|
-
deploymentSubstates.pause_before_committing,
|
|
571
|
-
deploymentSubstates.success
|
|
572
|
-
],
|
|
573
|
-
failureIndicators: deploymentStatesToSubstates.failures,
|
|
574
|
-
pauseConfigurationIndicator: "ArtifactReboot_Enter"
|
|
575
|
-
},
|
|
576
|
-
reboot: {
|
|
577
|
-
title: "reboot",
|
|
578
|
-
done: "rebooted",
|
|
579
|
-
successIndicators: [deploymentSubstates.pause_before_committing, deploymentSubstates.success],
|
|
580
|
-
failureIndicators: deploymentStatesToSubstates.failures,
|
|
581
|
-
pauseConfigurationIndicator: "ArtifactCommit_Enter"
|
|
582
|
-
},
|
|
583
|
-
commit: {
|
|
584
|
-
title: "commit",
|
|
585
|
-
done: "committed",
|
|
586
|
-
successIndicators: deploymentStatesToSubstates.successes,
|
|
587
|
-
failureIndicators: deploymentStatesToSubstates.failures,
|
|
588
|
-
pauseConfigurationIndicator: void 0
|
|
589
|
-
}
|
|
590
|
-
};
|
|
591
|
-
var DEPLOYMENT_STATES = {
|
|
592
|
-
finished: "finished",
|
|
593
|
-
inprogress: "inprogress",
|
|
594
|
-
pending: "pending",
|
|
595
|
-
scheduled: "scheduled"
|
|
596
|
-
};
|
|
597
|
-
var listDefaultsByState = {
|
|
598
|
-
[DEPLOYMENT_STATES.inprogress]: { page: 1, perPage: 10 },
|
|
599
|
-
[DEPLOYMENT_STATES.pending]: { page: 1, perPage: 10 },
|
|
600
|
-
[DEPLOYMENT_STATES.scheduled]: { ...import_constants5.DEVICE_LIST_DEFAULTS },
|
|
601
|
-
[DEPLOYMENT_STATES.finished]: { ...import_constants5.DEVICE_LIST_DEFAULTS },
|
|
602
|
-
sort: { direction: import_constants5.SORTING_OPTIONS.desc }
|
|
603
|
-
};
|
|
604
|
-
var DEFAULT_PENDING_INPROGRESS_COUNT = 10;
|
|
605
|
-
var DEPLOYMENT_ROUTES = {
|
|
606
|
-
active: {
|
|
607
|
-
key: "active",
|
|
608
|
-
route: "/deployments/active",
|
|
609
|
-
states: [DEPLOYMENT_STATES.pending, DEPLOYMENT_STATES.inprogress],
|
|
610
|
-
title: "Active"
|
|
611
|
-
},
|
|
612
|
-
finished: {
|
|
613
|
-
key: "finished",
|
|
614
|
-
route: "/deployments/finished",
|
|
615
|
-
states: [DEPLOYMENT_STATES.finished],
|
|
616
|
-
title: "Finished"
|
|
617
|
-
},
|
|
618
|
-
scheduled: {
|
|
619
|
-
key: "scheduled",
|
|
620
|
-
route: "/deployments/scheduled",
|
|
621
|
-
states: [DEPLOYMENT_STATES.scheduled],
|
|
622
|
-
title: "Scheduled"
|
|
623
|
-
}
|
|
624
|
-
};
|
|
625
|
-
var DEPLOYMENT_TYPES = {
|
|
626
|
-
software: "software",
|
|
627
|
-
configuration: "configuration"
|
|
628
|
-
};
|
|
629
|
-
var defaultStats = {
|
|
630
|
-
[deploymentSubstates.aborted]: 0,
|
|
631
|
-
[deploymentSubstates.alreadyInstalled]: 0,
|
|
632
|
-
[deploymentSubstates.decommissioned]: 0,
|
|
633
|
-
[deploymentSubstates.downloading]: 0,
|
|
634
|
-
[deploymentSubstates.failure]: 0,
|
|
635
|
-
[deploymentSubstates.installing]: 0,
|
|
636
|
-
[deploymentSubstates.noartifact]: 0,
|
|
637
|
-
[deploymentSubstates.pause_before_committing]: 0,
|
|
638
|
-
[deploymentSubstates.pause_before_installing]: 0,
|
|
639
|
-
[deploymentSubstates.pause_before_rebooting]: 0,
|
|
640
|
-
[deploymentSubstates.pending]: 0,
|
|
641
|
-
[deploymentSubstates.rebooting]: 0,
|
|
642
|
-
[deploymentSubstates.success]: 0
|
|
643
|
-
};
|
|
644
|
-
var deploymentPrototype = {
|
|
645
|
-
devices: {},
|
|
646
|
-
name: void 0,
|
|
647
|
-
statistics: { status: {} }
|
|
648
|
-
};
|
|
649
|
-
var pauseMap = {
|
|
650
|
-
[deploymentSubstates.pause_before_installing]: {
|
|
651
|
-
title: installationSubstatesMap.download.done,
|
|
652
|
-
followUp: installationSubstatesMap.download.pauseConfigurationIndicator
|
|
653
|
-
},
|
|
654
|
-
[deploymentSubstates.pause_before_rebooting]: {
|
|
655
|
-
title: installationSubstatesMap.install.done,
|
|
656
|
-
followUp: installationSubstatesMap.install.pauseConfigurationIndicator
|
|
657
|
-
},
|
|
658
|
-
[deploymentSubstates.pause_before_committing]: {
|
|
659
|
-
title: installationSubstatesMap.reboot.done,
|
|
660
|
-
followUp: installationSubstatesMap.reboot.pauseConfigurationIndicator
|
|
661
|
-
}
|
|
662
|
-
};
|
|
663
|
-
|
|
664
|
-
// src/devicesSlice/constants.ts
|
|
665
|
-
var emptyFilter = { key: null, value: "", operator: import_constants5.DEVICE_FILTERING_OPTIONS.$eq.key, scope: "inventory" };
|
|
666
|
-
var geoAttributes = ["geo-lat", "geo-lon"].map((attribute) => ({ attribute, scope: "inventory" }));
|
|
667
|
-
|
|
668
|
-
// src/onboardingSlice/constants.ts
|
|
669
|
-
var onboardingSteps = {
|
|
670
|
-
ONBOARDING_START: "onboarding-start",
|
|
671
|
-
DEVICES_PENDING_ONBOARDING_START: "devices-pending-onboarding-start",
|
|
672
|
-
DASHBOARD_ONBOARDING_START: "dashboard-onboarding-start",
|
|
673
|
-
DASHBOARD_ONBOARDING_PENDINGS: "dashboard-onboarding-pendings",
|
|
674
|
-
DEVICES_DELAYED_ONBOARDING: "devices-delayed-onboarding",
|
|
675
|
-
DEVICES_PENDING_ONBOARDING: "devices-pending-onboarding",
|
|
676
|
-
DEVICES_ACCEPTED_ONBOARDING: "devices-accepted-onboarding",
|
|
677
|
-
DEVICES_PENDING_ACCEPTING_ONBOARDING: "devices-pending-accepting-onboarding",
|
|
678
|
-
DEVICES_DEPLOY_RELEASE_ONBOARDING: "devices-deploy-release-onboarding",
|
|
679
|
-
SCHEDULING_ARTIFACT_SELECTION: "scheduling-artifact-selection",
|
|
680
|
-
SCHEDULING_ALL_DEVICES_SELECTION: "scheduling-all-devices-selection",
|
|
681
|
-
SCHEDULING_GROUP_SELECTION: "scheduling-group-selection",
|
|
682
|
-
SCHEDULING_RELEASE_TO_DEVICES: "scheduling-release-to-devices",
|
|
683
|
-
DEPLOYMENTS_INPROGRESS: "deployments-inprogress",
|
|
684
|
-
DEPLOYMENTS_COMPLETED: "deployments-completed",
|
|
685
|
-
DEPLOYMENTS_PAST: "deployments-past",
|
|
686
|
-
DEPLOYMENTS_PAST_COMPLETED: "deployments-past-completed",
|
|
687
|
-
DEPLOYMENTS_PAST_COMPLETED_FAILURE: "deployments-past-completed-failure",
|
|
688
|
-
ONBOARDING_CANCELED: "onboarding-canceled"
|
|
689
|
-
};
|
|
690
|
-
var orderedOnboardingSteps = [
|
|
691
|
-
onboardingSteps.DASHBOARD_ONBOARDING_START,
|
|
692
|
-
onboardingSteps.DEVICES_PENDING_ONBOARDING_START,
|
|
693
|
-
onboardingSteps.DEVICES_DELAYED_ONBOARDING,
|
|
694
|
-
onboardingSteps.DEVICES_PENDING_ONBOARDING,
|
|
695
|
-
onboardingSteps.DEVICES_PENDING_ACCEPTING_ONBOARDING,
|
|
696
|
-
onboardingSteps.DASHBOARD_ONBOARDING_PENDINGS,
|
|
697
|
-
onboardingSteps.DEVICES_ACCEPTED_ONBOARDING,
|
|
698
|
-
onboardingSteps.DEVICES_DEPLOY_RELEASE_ONBOARDING,
|
|
699
|
-
onboardingSteps.SCHEDULING_ALL_DEVICES_SELECTION,
|
|
700
|
-
onboardingSteps.SCHEDULING_GROUP_SELECTION,
|
|
701
|
-
onboardingSteps.SCHEDULING_ARTIFACT_SELECTION,
|
|
702
|
-
onboardingSteps.SCHEDULING_RELEASE_TO_DEVICES,
|
|
703
|
-
onboardingSteps.DEPLOYMENTS_INPROGRESS,
|
|
704
|
-
onboardingSteps.DEPLOYMENTS_PAST,
|
|
705
|
-
onboardingSteps.DEPLOYMENTS_PAST_COMPLETED,
|
|
706
|
-
onboardingSteps.DEPLOYMENTS_PAST_COMPLETED_FAILURE,
|
|
707
|
-
onboardingSteps.ONBOARDING_CANCELED
|
|
708
|
-
];
|
|
709
|
-
|
|
710
|
-
// src/organizationSlice/constants.ts
|
|
711
|
-
var XML_METADATA_FORMAT = "xml";
|
|
712
|
-
var JSON_METADATA_FORMAT = "json";
|
|
713
|
-
var getSamlStartUrl = (id) => `${window.location.origin}${import_constants5.useradmApiUrl}/auth/sso/${id}/login`;
|
|
714
|
-
var getOidcStartUrl = (id) => `${window.location.origin}${import_constants5.useradmApiUrl}/oidc/${id}/start`;
|
|
715
|
-
var SSO_TYPES = {
|
|
716
|
-
saml: {
|
|
717
|
-
id: "saml",
|
|
718
|
-
type: "saml",
|
|
719
|
-
title: "SAML",
|
|
720
|
-
metadataFormat: XML_METADATA_FORMAT,
|
|
721
|
-
editorLanguage: XML_METADATA_FORMAT,
|
|
722
|
-
contentType: "application/samlmetadata+xml",
|
|
723
|
-
getStartUrl: getSamlStartUrl,
|
|
724
|
-
configDetails: [
|
|
725
|
-
{ key: "entityID", label: "Entity ID", getValue: (id) => `${window.location.origin}${import_constants5.useradmApiUrl}/sso/sp/metadata/${id}` },
|
|
726
|
-
{ key: "acs", label: "ACS URL", getValue: (id) => `${window.location.origin}${import_constants5.useradmApiUrl}/auth/sso/${id}/acs` },
|
|
727
|
-
{ key: "startURL", label: "Start URL", getValue: getSamlStartUrl }
|
|
728
|
-
]
|
|
729
|
-
},
|
|
730
|
-
oidc: {
|
|
731
|
-
id: "oidc",
|
|
732
|
-
type: "oidc",
|
|
733
|
-
title: "OpenID Connect",
|
|
734
|
-
metadataFormat: JSON_METADATA_FORMAT,
|
|
735
|
-
editorLanguage: JSON_METADATA_FORMAT,
|
|
736
|
-
contentType: "application/json",
|
|
737
|
-
getStartUrl: getOidcStartUrl,
|
|
738
|
-
configDetails: [{ key: "startURL", label: "Start Url", getValue: getOidcStartUrl }]
|
|
739
|
-
}
|
|
740
|
-
};
|
|
741
|
-
var auditlogTypes = {
|
|
742
|
-
artifact: { title: "Artifact", queryParameter: "object_type", value: "artifact" },
|
|
743
|
-
deployment: { title: "Deployment", queryParameter: "object_deployment_name", value: "deployment" },
|
|
744
|
-
device: { title: "Device", queryParameter: "object_id", value: "device" },
|
|
745
|
-
user_access_token: { title: "Personal Access Token", queryParameter: "user_access_token", value: "user_access_token" },
|
|
746
|
-
user: { title: "User", queryParameter: "object_id", value: "user" },
|
|
747
|
-
tenant: { title: "Tenant", queryParameter: "object_id", value: "tenant" }
|
|
748
|
-
};
|
|
749
|
-
var AUDIT_LOGS_TYPES = [auditlogTypes.artifact, auditlogTypes.deployment, auditlogTypes.device, auditlogTypes.user_access_token, auditlogTypes.user];
|
|
750
|
-
var SP_AUDIT_LOGS_TYPES = [auditlogTypes.user, auditlogTypes.tenant];
|
|
751
|
-
var TENANT_LIST_DEFAULT = {
|
|
752
|
-
page: 1,
|
|
753
|
-
perPage: 20
|
|
754
|
-
};
|
|
755
|
-
|
|
756
|
-
// src/releasesSlice/constants.ts
|
|
757
|
-
var rootfsImageVersion = "rootfs-image.version";
|
|
758
|
-
var softwareTitleMap = { [rootfsImageVersion]: { title: "Root filesystem", priority: 0, key: rootfsImageVersion } };
|
|
759
|
-
|
|
760
|
-
// src/usersSlice/constants.ts
|
|
761
|
-
var itemUiPermissionsReducer = (accu, { item, uiPermissions }) => item ? { ...accu, [item]: uiPermissions } : accu;
|
|
762
|
-
var USER_LOGOUT = "USER_LOGOUT";
|
|
763
|
-
var OWN_USER_ID = "me";
|
|
764
|
-
var settingsKeys = { initialized: "settings-initialized" };
|
|
765
|
-
var READ_STATES = {
|
|
766
|
-
read: "read",
|
|
767
|
-
seen: "seen",
|
|
768
|
-
unread: "unread"
|
|
769
|
-
};
|
|
770
|
-
|
|
771
|
-
// src/appSlice/selectors.ts
|
|
772
|
-
var import_helpers = require("@northern.tech/utils/helpers");
|
|
773
|
-
var import_toolkit2 = require("@reduxjs/toolkit");
|
|
774
|
-
var getFeatures = (state) => state.app.features;
|
|
775
|
-
var getFullVersionInformation = (state) => state.app.versionInformation;
|
|
776
|
-
var getSearchState = (state) => state.app.searchState;
|
|
777
|
-
var getUploads = (state) => state.app.uploadsById;
|
|
778
|
-
var getHostedAnnouncement = (state) => state.app.hostedAnnouncement;
|
|
779
|
-
var getIsUploading = (0, import_toolkit2.createSelector)([getUploads], (uploadsById) => !!Object.keys(uploadsById).length);
|
|
780
|
-
var getSearchedDevices = (0, import_toolkit2.createSelector)([getSearchState], ({ deviceIds }) => deviceIds);
|
|
781
|
-
var getVersionInformation = (0, import_toolkit2.createSelector)(
|
|
782
|
-
[getFullVersionInformation, getFeatures],
|
|
783
|
-
({ Integration, ...remainder }, { isHosted }) => isHosted && Integration !== "next" ? remainder : { ...remainder, Integration }
|
|
784
|
-
);
|
|
785
|
-
var getIsPreview = (0, import_toolkit2.createSelector)([getFullVersionInformation], ({ Integration }) => (0, import_helpers.versionCompare)(Integration, "next") > -1);
|
|
786
|
-
|
|
787
|
-
// src/commonSelectors.ts
|
|
788
|
-
var import_helpers4 = require("@northern.tech/utils/helpers");
|
|
789
|
-
var import_toolkit8 = require("@reduxjs/toolkit");
|
|
790
|
-
var import_dayjs = __toESM(require("dayjs"), 1);
|
|
791
|
-
|
|
792
|
-
// src/deploymentsSlice/selectors.ts
|
|
793
|
-
var import_toolkit3 = require("@reduxjs/toolkit");
|
|
794
|
-
var getDeploymentsById = (state) => state.deployments.byId;
|
|
795
|
-
var getDeploymentsByStatus = (state) => state.deployments.byStatus;
|
|
796
|
-
var getSelectedDeploymentDeviceIds = (state) => state.deployments.selectedDeviceIds;
|
|
797
|
-
var getDeploymentsSelectionState = (state) => state.deployments.selectionState;
|
|
798
|
-
var getDeploymentById = (0, import_toolkit3.createSelector)(
|
|
799
|
-
[getDeploymentsById, (_, deploymentId) => deploymentId],
|
|
800
|
-
(deploymentsById, deploymentId = "") => deploymentsById[deploymentId]
|
|
801
|
-
);
|
|
802
|
-
var getMappedDeploymentSelection = (0, import_toolkit3.createSelector)(
|
|
803
|
-
[getDeploymentsSelectionState, (_, deploymentsState) => deploymentsState, getDeploymentsById],
|
|
804
|
-
(selectionState, deploymentsState, deploymentsById) => {
|
|
805
|
-
const { selection = [] } = selectionState[deploymentsState] ?? {};
|
|
806
|
-
return selection.reduce((accu, id) => {
|
|
807
|
-
if (deploymentsById[id]) {
|
|
808
|
-
accu.push(deploymentsById[id]);
|
|
809
|
-
}
|
|
810
|
-
return accu;
|
|
811
|
-
}, []);
|
|
812
|
-
}
|
|
813
|
-
);
|
|
814
|
-
var relevantDeploymentStates = [DEPLOYMENT_STATES.pending, DEPLOYMENT_STATES.inprogress, DEPLOYMENT_STATES.finished];
|
|
815
|
-
var DEPLOYMENT_CUTOFF = 3;
|
|
816
|
-
var getRecentDeployments = (0, import_toolkit3.createSelector)(
|
|
817
|
-
[getDeploymentsById, getDeploymentsByStatus],
|
|
818
|
-
(deploymentsById, deploymentsByStatus) => Object.entries(deploymentsByStatus).reduce(
|
|
819
|
-
(accu, [state, byStatus]) => {
|
|
820
|
-
if (!relevantDeploymentStates.includes(state) || !byStatus.deploymentIds.length) {
|
|
821
|
-
return accu;
|
|
822
|
-
}
|
|
823
|
-
accu[state] = byStatus.deploymentIds.reduce((accu2, id) => {
|
|
824
|
-
if (deploymentsById[id]) {
|
|
825
|
-
accu2.push(deploymentsById[id]);
|
|
826
|
-
}
|
|
827
|
-
return accu2;
|
|
828
|
-
}, []).slice(0, DEPLOYMENT_CUTOFF);
|
|
829
|
-
accu.total += byStatus.total;
|
|
830
|
-
return accu;
|
|
831
|
-
},
|
|
832
|
-
{ total: 0 }
|
|
833
|
-
)
|
|
834
|
-
);
|
|
835
|
-
|
|
836
|
-
// src/devicesSlice/selectors.ts
|
|
837
|
-
var import_helpers2 = require("@northern.tech/utils/helpers");
|
|
838
|
-
var import_toolkit4 = require("@reduxjs/toolkit");
|
|
839
|
-
var getAcceptedDevices = (state) => state.devices.byStatus.accepted;
|
|
840
|
-
var getDevicesByStatus = (state) => state.devices.byStatus;
|
|
841
|
-
var getDevicesById = (state) => state.devices.byId;
|
|
842
|
-
var getDeviceReports = (state) => state.devices.reports;
|
|
843
|
-
var getGroupsById = (state) => state.devices.groups.byId;
|
|
844
|
-
var getSelectedGroup = (state) => state.devices.groups.selectedGroup;
|
|
845
|
-
var getDeviceListState = (state) => state.devices.deviceList;
|
|
846
|
-
var getListedDevices = (state) => state.devices.deviceList.deviceIds;
|
|
847
|
-
var getFilteringAttributes = (state) => state.devices.filteringAttributes;
|
|
848
|
-
var getDeviceFilters = (state) => state.devices.filters || [];
|
|
849
|
-
var getFilteringAttributesFromConfig = (state) => state.devices.filteringAttributesConfig.attributes;
|
|
850
|
-
var getSortedFilteringAttributes = (0, import_toolkit4.createSelector)([getFilteringAttributes], (filteringAttributes) => ({
|
|
851
|
-
...filteringAttributes,
|
|
852
|
-
identityAttributes: [...filteringAttributes.identityAttributes, "id"]
|
|
853
|
-
}));
|
|
854
|
-
var getDeviceLimits = (state) => state.devices.limits;
|
|
855
|
-
var getFilteringAttributesLimit = (state) => state.devices.filteringAttributesLimit;
|
|
856
|
-
var getDeviceIdentityAttributes = (0, import_toolkit4.createSelector)(
|
|
857
|
-
[getFilteringAttributes, getFilteringAttributesLimit],
|
|
858
|
-
({ identityAttributes }, filteringAttributesLimit) => {
|
|
859
|
-
const attributes = identityAttributes.slice(0, filteringAttributesLimit);
|
|
860
|
-
return attributes.reduce(
|
|
861
|
-
(accu, value) => {
|
|
862
|
-
accu.push({ value, label: value, scope: "identity" });
|
|
863
|
-
return accu;
|
|
864
|
-
},
|
|
865
|
-
[
|
|
866
|
-
{ value: "name", label: "Name", scope: "tags" },
|
|
867
|
-
{ value: "id", label: "Device ID", scope: "identity" }
|
|
868
|
-
]
|
|
869
|
-
);
|
|
870
|
-
}
|
|
871
|
-
);
|
|
872
|
-
var getDeviceCountsByStatus = (0, import_toolkit4.createSelector)(
|
|
873
|
-
[getDevicesByStatus],
|
|
874
|
-
(byStatus) => Object.values(import_constants5.DEVICE_STATES).reduce(
|
|
875
|
-
(accu, deviceState) => {
|
|
876
|
-
const { counts } = byStatus[deviceState];
|
|
877
|
-
const { total, ...tieredCounts } = counts;
|
|
878
|
-
const count = Object.values(tieredCounts).reduce((accu2, countPerTier) => accu2 + countPerTier, 0);
|
|
879
|
-
accu[deviceState] = count;
|
|
880
|
-
accu.total = accu.total + count;
|
|
881
|
-
return accu;
|
|
882
|
-
},
|
|
883
|
-
{ total: 0 }
|
|
884
|
-
)
|
|
885
|
-
);
|
|
886
|
-
var getDeviceById = (0, import_toolkit4.createSelector)([getDevicesById, (_, deviceId) => deviceId], (devicesById, deviceId = "") => devicesById[deviceId] ?? {});
|
|
887
|
-
var getSelectedGroupInfo = (0, import_toolkit4.createSelector)(
|
|
888
|
-
[getDeviceCountsByStatus, getGroupsById, getSelectedGroup],
|
|
889
|
-
({ accepted: acceptedDeviceTotal }, groupsById, selectedGroup) => {
|
|
890
|
-
let groupCount = acceptedDeviceTotal;
|
|
891
|
-
let groupFilters = [];
|
|
892
|
-
if (selectedGroup && groupsById[selectedGroup]) {
|
|
893
|
-
groupCount = groupsById[selectedGroup].total || 0;
|
|
894
|
-
groupFilters = groupsById[selectedGroup].filters || [];
|
|
895
|
-
}
|
|
896
|
-
return { groupCount, selectedGroup, groupFilters };
|
|
897
|
-
}
|
|
898
|
-
);
|
|
899
|
-
var getCombinedLimit = (0, import_toolkit4.createSelector)(
|
|
900
|
-
[getDeviceLimits],
|
|
901
|
-
(deviceLimits) => Object.values(deviceLimits).reduce((accu, limit) => accu + Math.max(limit ?? 0, 0), 0)
|
|
902
|
-
// limit might be -1 for unlimited devices
|
|
903
|
-
);
|
|
904
|
-
var getLimitMaxed = (0, import_toolkit4.createSelector)(
|
|
905
|
-
[getDeviceCountsByStatus, getCombinedLimit],
|
|
906
|
-
({ accepted: acceptedDevices }, combinedLimit) => !!combinedLimit && combinedLimit <= acceptedDevices
|
|
907
|
-
);
|
|
908
|
-
var getGroupsByIdWithoutUngrouped = (0, import_toolkit4.createSelector)([getGroupsById], ({ [UNGROUPED_GROUP.id]: ungrouped, ...groups }) => groups);
|
|
909
|
-
var getGroupData = (0, import_toolkit4.createSelector)([getGroupsByIdWithoutUngrouped], (groups) => {
|
|
910
|
-
const createdGroup = Object.keys(groups).length ? Object.keys(groups)[0] : void 0;
|
|
911
|
-
const hasDynamicGroups = Object.values(groups).some((group) => !!group.id);
|
|
912
|
-
return { createdGroup, hasDynamicGroups, groups };
|
|
913
|
-
});
|
|
914
|
-
var getGroups = (0, import_toolkit4.createSelector)([getGroupsById], (groupsById) => {
|
|
915
|
-
const groupNames = Object.keys(groupsById).sort();
|
|
916
|
-
const groupedGroups = Object.entries(groupsById).sort((a, b) => a[0].localeCompare(b[0])).reduce(
|
|
917
|
-
(accu, [groupname, group]) => {
|
|
918
|
-
const name = groupname === UNGROUPED_GROUP.id ? UNGROUPED_GROUP.name : groupname;
|
|
919
|
-
const groupItem = { ...group, groupId: name, name: groupname };
|
|
920
|
-
if ((group.filters ?? []).length > 0) {
|
|
921
|
-
if (groupname !== UNGROUPED_GROUP.id) {
|
|
922
|
-
accu.dynamic.push(groupItem);
|
|
923
|
-
} else {
|
|
924
|
-
accu.ungrouped.push(groupItem);
|
|
925
|
-
}
|
|
926
|
-
} else {
|
|
927
|
-
accu.static.push(groupItem);
|
|
928
|
-
}
|
|
929
|
-
return accu;
|
|
930
|
-
},
|
|
931
|
-
{ dynamic: [], static: [], ungrouped: [] }
|
|
932
|
-
);
|
|
933
|
-
return { groupNames, ...groupedGroups };
|
|
934
|
-
});
|
|
935
|
-
var getAttributesList = (0, import_toolkit4.createSelector)(
|
|
936
|
-
[getFilteringAttributes, getFilteringAttributesFromConfig],
|
|
937
|
-
({ identityAttributes = [], inventoryAttributes = [] }, { identity = [], inventory = [] }) => [...identityAttributes, ...inventoryAttributes, ...identity, ...inventory].filter(import_helpers2.duplicateFilter)
|
|
938
|
-
);
|
|
939
|
-
var getEnabledTierLimits = (0, import_toolkit4.createSelector)([getDeviceLimits], (limits) => Object.entries(limits).filter(([, limit]) => limit !== 0));
|
|
940
|
-
var getEnabledTiers = (0, import_toolkit4.createSelector)([getEnabledTierLimits], (enabledTierLimits) => enabledTierLimits.map(([type]) => type));
|
|
941
|
-
var getDeviceLimitStats = (0, import_toolkit4.createSelector)([getEnabledTierLimits, getAcceptedDevices], (enabledTierLimits, accepted) => {
|
|
942
|
-
const { counts } = accepted;
|
|
943
|
-
return enabledTierLimits.map(([type, limit]) => ({
|
|
944
|
-
type,
|
|
945
|
-
limit,
|
|
946
|
-
total: counts[type] || 0
|
|
947
|
-
}));
|
|
948
|
-
});
|
|
949
|
-
var getDeviceTypes = (0, import_toolkit4.createSelector)(
|
|
950
|
-
[getAcceptedDevices, getDevicesById],
|
|
951
|
-
({ deviceIds = [] }, devicesById) => Object.keys(
|
|
952
|
-
deviceIds.slice(0, 200).reduce((accu, item) => {
|
|
953
|
-
const { device_type: deviceTypes = [] } = devicesById[item] ? devicesById[item].attributes : {};
|
|
954
|
-
accu = deviceTypes.reduce((deviceTypeAccu, deviceType) => {
|
|
955
|
-
if (deviceType.length > 1) {
|
|
956
|
-
deviceTypeAccu[deviceType] = deviceTypeAccu[deviceType] ? deviceTypeAccu[deviceType] + 1 : 1;
|
|
957
|
-
}
|
|
958
|
-
return deviceTypeAccu;
|
|
959
|
-
}, accu);
|
|
960
|
-
return accu;
|
|
961
|
-
}, {})
|
|
962
|
-
)
|
|
963
|
-
);
|
|
964
|
-
|
|
965
|
-
// src/monitorSlice/selectors.ts
|
|
966
|
-
var getIssueCountsByType = (state) => state.monitor.issueCounts.byType;
|
|
967
|
-
|
|
968
|
-
// src/onboardingSlice/selectors.ts
|
|
969
|
-
var getOnboarding = (state) => state.onboarding;
|
|
970
|
-
|
|
971
|
-
// src/organizationSlice/selectors.ts
|
|
972
|
-
var import_toolkit5 = require("@reduxjs/toolkit");
|
|
973
|
-
var getOrganization = (state) => state.organization.organization;
|
|
974
|
-
var getExternalIntegrations = (state) => state.organization.externalDeviceIntegrations;
|
|
975
|
-
var getAuditLog = (state) => state.organization.auditlog.events;
|
|
976
|
-
var getAuditLogSelectionState = (state) => state.organization.auditlog.selectionState;
|
|
977
|
-
var getTenantsList = (state) => state.organization.tenantList;
|
|
978
|
-
var getWebhookEvents = (state) => state.organization.webhooks.events;
|
|
979
|
-
var getWebhookEventTotal = (state) => state.organization.webhooks.eventsTotal;
|
|
980
|
-
var getDeviceTwinIntegrations = (0, import_toolkit5.createSelector)(
|
|
981
|
-
[getExternalIntegrations],
|
|
982
|
-
(integrations) => integrations.filter((integration) => integration.id && EXTERNAL_PROVIDER[integration.provider]?.deviceTwin)
|
|
983
|
-
);
|
|
984
|
-
var getIsServiceProvider = (state) => state.organization.organization.service_provider;
|
|
985
|
-
var getWebhooks = (0, import_toolkit5.createSelector)(
|
|
986
|
-
[getExternalIntegrations],
|
|
987
|
-
(integrations) => integrations.filter((integration) => integration.id && integration.provider === EXTERNAL_PROVIDER.webhook.provider)
|
|
988
|
-
);
|
|
989
|
-
var getWebhookEventInfo = (0, import_toolkit5.createSelector)(
|
|
990
|
-
[getWebhooks, getWebhookEvents, getWebhookEventTotal],
|
|
991
|
-
(webhooks, events, eventTotal) => webhooks.length ? { events, eventTotal } : { events: [], eventTotal: 0 }
|
|
992
|
-
);
|
|
993
|
-
var getAuditLogEntry = (0, import_toolkit5.createSelector)([getAuditLog, getAuditLogSelectionState], (events, { selectedId }) => {
|
|
994
|
-
if (!selectedId) {
|
|
995
|
-
return;
|
|
996
|
-
}
|
|
997
|
-
const [eventAction, eventTime] = atob(selectedId).split("|");
|
|
998
|
-
return events.find((item) => item.action === eventAction && item.time === eventTime);
|
|
999
|
-
});
|
|
1000
|
-
var toTierName = (key) => key.replace(/max_|_?devices/g, "") || "standard";
|
|
1001
|
-
var processDeviceLimits = (deviceLimits, skipFilter = false) => {
|
|
1002
|
-
const result = { limits: {}, disabled: [] };
|
|
1003
|
-
if (!deviceLimits) return result;
|
|
1004
|
-
const tiersByName = Object.fromEntries(Object.entries(deviceLimits).map(([key, limit]) => [toTierName(key), { key, limit }]));
|
|
1005
|
-
return productOrder.reduce((accu, tierName) => {
|
|
1006
|
-
const entry = tiersByName[tierName];
|
|
1007
|
-
if (!entry) return accu;
|
|
1008
|
-
const { key, limit } = entry;
|
|
1009
|
-
if (limit.value === 0) {
|
|
1010
|
-
accu.disabled.push(tierName);
|
|
1011
|
-
if (!skipFilter) return accu;
|
|
1012
|
-
}
|
|
1013
|
-
accu.limits[tierName] = {
|
|
1014
|
-
id: tierName,
|
|
1015
|
-
backendId: key,
|
|
1016
|
-
limit: limit.value,
|
|
1017
|
-
current: limit.current_value,
|
|
1018
|
-
name: tierName,
|
|
1019
|
-
quotaLeft: Math.max(limit.value - limit.current_value, 0),
|
|
1020
|
-
limitReached: limit.value !== -1 && limit.value <= limit.current_value
|
|
1021
|
-
};
|
|
1022
|
-
return accu;
|
|
1023
|
-
}, result);
|
|
1024
|
-
};
|
|
1025
|
-
var getDeviceLimitsInfo = (0, import_toolkit5.createSelector)([getOrganization], ({ device_limits }) => processDeviceLimits(device_limits));
|
|
1026
|
-
var getDisabledTiers = (0, import_toolkit5.createSelector)([getDeviceLimitsInfo], ({ disabled }) => disabled);
|
|
1027
|
-
var getSpLimits = (0, import_toolkit5.createSelector)([getDeviceLimitsInfo], ({ limits }) => limits);
|
|
1028
|
-
var getTenantListWithLimits = (0, import_toolkit5.createSelector)([getTenantsList], (tenantList) => ({
|
|
1029
|
-
...tenantList,
|
|
1030
|
-
tenants: tenantList.tenants.map((tenant) => ({
|
|
1031
|
-
...tenant,
|
|
1032
|
-
device_limits: processDeviceLimits(tenant.device_limits, true).limits
|
|
1033
|
-
}))
|
|
1034
|
-
}));
|
|
1035
|
-
|
|
1036
|
-
// src/releasesSlice/selectors.ts
|
|
1037
|
-
var import_toolkit6 = require("@reduxjs/toolkit");
|
|
1038
|
-
|
|
1039
|
-
// src/utils.ts
|
|
1040
|
-
var import_helpers3 = require("@northern.tech/utils/helpers");
|
|
1041
|
-
var filterProcessors = {
|
|
1042
|
-
[import_constants5.DEVICE_FILTERING_OPTIONS.$gt.key]: (val) => Number(val) || val,
|
|
1043
|
-
[import_constants5.DEVICE_FILTERING_OPTIONS.$gte.key]: (val) => Number(val) || val,
|
|
1044
|
-
[import_constants5.DEVICE_FILTERING_OPTIONS.$lt.key]: (val) => Number(val) || val,
|
|
1045
|
-
[import_constants5.DEVICE_FILTERING_OPTIONS.$lte.key]: (val) => Number(val) || val,
|
|
1046
|
-
[import_constants5.DEVICE_FILTERING_OPTIONS.$ltne.key]: (val) => Number(val) || val,
|
|
1047
|
-
[import_constants5.DEVICE_FILTERING_OPTIONS.$in.key]: (val) => ("" + val).split(",").map((i) => i.trim()),
|
|
1048
|
-
[import_constants5.DEVICE_FILTERING_OPTIONS.$nin.key]: (val) => ("" + val).split(",").map((i) => i.trim()),
|
|
1049
|
-
[import_constants5.DEVICE_FILTERING_OPTIONS.$exists.key]: import_helpers3.yes,
|
|
1050
|
-
[import_constants5.DEVICE_FILTERING_OPTIONS.$nexists.key]: () => false
|
|
1051
|
-
};
|
|
1052
|
-
var filterAliases = {
|
|
1053
|
-
$nexists: { alias: import_constants5.DEVICE_FILTERING_OPTIONS.$exists.key, value: false }
|
|
1054
|
-
};
|
|
1055
|
-
var mapFiltersToTerms = (filters) => filters.map((filter) => ({
|
|
1056
|
-
scope: filter.scope,
|
|
1057
|
-
attribute: filter.key,
|
|
1058
|
-
type: filterAliases[filter.operator]?.alias || filter.operator,
|
|
1059
|
-
value: filterProcessors.hasOwnProperty(filter.operator) ? filterProcessors[filter.operator](filter.value) : filter.value
|
|
1060
|
-
}));
|
|
1061
|
-
var mapTermsToFilters = (terms) => terms.map((term) => {
|
|
1062
|
-
const aliasedFilter = Object.entries(filterAliases).find(
|
|
1063
|
-
(aliasDefinition) => aliasDefinition[1].alias === term.type && aliasDefinition[1].value === term.value
|
|
1064
|
-
);
|
|
1065
|
-
const operator = aliasedFilter ? aliasedFilter[0] : term.type;
|
|
1066
|
-
return { scope: term.scope, key: term.attribute, operator, value: term.value };
|
|
1067
|
-
});
|
|
1068
|
-
var convertIssueOptionsToFilters = (issuesSelection, filtersState = {}) => issuesSelection.map((item) => {
|
|
1069
|
-
if (typeof import_constants5.DEVICE_ISSUE_OPTIONS[item].filterRule.value === "function") {
|
|
1070
|
-
return { ...import_constants5.DEVICE_ISSUE_OPTIONS[item].filterRule, value: import_constants5.DEVICE_ISSUE_OPTIONS[item].filterRule.value(filtersState) };
|
|
1071
|
-
}
|
|
1072
|
-
return import_constants5.DEVICE_ISSUE_OPTIONS[item].filterRule;
|
|
1073
|
-
});
|
|
1074
|
-
var convertDeviceListStateToFilters = ({
|
|
1075
|
-
filters = [],
|
|
1076
|
-
group,
|
|
1077
|
-
groups = { byId: {} },
|
|
1078
|
-
offlineThreshold,
|
|
1079
|
-
selectedIssues = [],
|
|
1080
|
-
status
|
|
1081
|
-
}) => {
|
|
1082
|
-
let applicableFilters = [...filters];
|
|
1083
|
-
if (typeof group === "string" && !(groups.byId[group]?.filters || applicableFilters).length) {
|
|
1084
|
-
applicableFilters.push({ key: "group", value: group, operator: import_constants5.DEVICE_FILTERING_OPTIONS.$eq.key, scope: "system" });
|
|
1085
|
-
}
|
|
1086
|
-
const nonMonitorFilters = applicableFilters.filter(
|
|
1087
|
-
(filter) => !Object.values(import_constants5.DEVICE_ISSUE_OPTIONS).some(
|
|
1088
|
-
({ filterRule }) => filter.scope !== "inventory" && filterRule.scope === filter.scope && filterRule.key === filter.key
|
|
1089
|
-
)
|
|
1090
|
-
);
|
|
1091
|
-
const deviceIssueFilters = convertIssueOptionsToFilters(selectedIssues, { offlineThreshold });
|
|
1092
|
-
applicableFilters = [...nonMonitorFilters, ...deviceIssueFilters];
|
|
1093
|
-
const effectiveFilters = status ? [...applicableFilters, { key: "status", value: status, operator: import_constants5.DEVICE_FILTERING_OPTIONS.$eq.key, scope: "identity" }] : applicableFilters;
|
|
1094
|
-
return { applicableFilters: nonMonitorFilters, filterTerms: mapFiltersToTerms(effectiveFilters) };
|
|
1095
|
-
};
|
|
1096
|
-
var filterCompare = (filter, item) => Object.keys(emptyFilter).every((key) => item[key]?.toString() === filter[key]?.toString());
|
|
1097
|
-
var filtersFilter = (item, index, array) => {
|
|
1098
|
-
const firstIndex = array.findIndex((filter) => filterCompare(filter, item));
|
|
1099
|
-
return firstIndex === index;
|
|
1100
|
-
};
|
|
1101
|
-
var listItemMapper = (byId, ids, { cutOffSize = DEVICE_LIST_MAXIMUM_LENGTH, defaultObject = {} }) => ids.slice(0, cutOffSize).reduce((accu, id) => {
|
|
1102
|
-
if (id && byId[id]) {
|
|
1103
|
-
accu.push({ ...defaultObject, ...byId[id] });
|
|
1104
|
-
}
|
|
1105
|
-
return accu;
|
|
1106
|
-
}, []);
|
|
1107
|
-
var mergePermissions = (existingPermissions = { ...import_constants5.emptyUiPermissions }, addedPermissions) => Object.entries(existingPermissions).reduce(
|
|
1108
|
-
(accu, [key, value]) => {
|
|
1109
|
-
let values;
|
|
1110
|
-
if (!accu[key]) {
|
|
1111
|
-
accu[key] = value;
|
|
1112
|
-
return accu;
|
|
1113
|
-
}
|
|
1114
|
-
if (Array.isArray(value)) {
|
|
1115
|
-
values = [...value, ...accu[key]].filter(import_helpers3.duplicateFilter);
|
|
1116
|
-
} else {
|
|
1117
|
-
values = mergePermissions(accu[key], { ...value });
|
|
1118
|
-
}
|
|
1119
|
-
accu[key] = values;
|
|
1120
|
-
return accu;
|
|
1121
|
-
},
|
|
1122
|
-
{ ...addedPermissions }
|
|
1123
|
-
);
|
|
1124
|
-
var mapUserRolesToUiPermissions = (userRoles, roles) => userRoles.reduce(
|
|
1125
|
-
(accu, roleId) => {
|
|
1126
|
-
if (!(roleId && roles[roleId])) {
|
|
1127
|
-
return accu;
|
|
1128
|
-
}
|
|
1129
|
-
return mergePermissions(accu, roles[roleId].uiPermissions);
|
|
1130
|
-
},
|
|
1131
|
-
{ ...import_constants5.emptyUiPermissions }
|
|
1132
|
-
);
|
|
1133
|
-
var progress = ({ loaded, total }) => {
|
|
1134
|
-
let uploadProgress3 = loaded / total * 100;
|
|
1135
|
-
return uploadProgress3 = uploadProgress3 < 50 ? Math.ceil(uploadProgress3) : Math.round(uploadProgress3);
|
|
1136
|
-
};
|
|
1137
|
-
var extractErrorMessage = (err, fallback = "") => err.response?.data?.error?.message || err.response?.data?.error || err.error || err.message || fallback;
|
|
1138
|
-
var getComparisonCompatibleVersion = (version) => isNaN(version.charAt(0)) && version !== "next" ? "master" : version;
|
|
1139
|
-
var mapDeviceAttributes = (attributes = []) => attributes.reduce(
|
|
1140
|
-
(accu, attribute) => {
|
|
1141
|
-
if (!(attribute.value && attribute.name) && attribute.scope === import_constants5.ATTRIBUTE_SCOPES.inventory) {
|
|
1142
|
-
return accu;
|
|
1143
|
-
}
|
|
1144
|
-
accu[attribute.scope || import_constants5.ATTRIBUTE_SCOPES.inventory] = {
|
|
1145
|
-
...accu[attribute.scope || import_constants5.ATTRIBUTE_SCOPES.inventory],
|
|
1146
|
-
[attribute.name]: attribute.value
|
|
1147
|
-
};
|
|
1148
|
-
if (attribute.name === "device_type" && attribute.scope === import_constants5.ATTRIBUTE_SCOPES.inventory) {
|
|
1149
|
-
accu.inventory.device_type = [].concat(attribute.value);
|
|
1150
|
-
}
|
|
1151
|
-
return accu;
|
|
1152
|
-
},
|
|
1153
|
-
{ inventory: { device_type: [], artifact_name: "" }, identity: {}, monitor: {}, system: {}, tags: {} }
|
|
1154
|
-
);
|
|
1155
|
-
var isDarkMode = (mode) => mode === DARK_MODE;
|
|
1156
|
-
|
|
1157
|
-
// src/releasesSlice/selectors.ts
|
|
1158
|
-
var getSelectedReleaseId = (state) => state.releases.selectedRelease;
|
|
1159
|
-
var getReleasesById = (state) => state.releases.byId;
|
|
1160
|
-
var getReleaseTags = (state) => state.releases.tags;
|
|
1161
|
-
var getReleaseListState = (state) => state.releases.releasesList;
|
|
1162
|
-
var getListedReleases = (state) => state.releases.releasesList.releaseIds;
|
|
1163
|
-
var releaseDefaults = {};
|
|
1164
|
-
var getReleaseMappingDefaults = () => releaseDefaults;
|
|
1165
|
-
var getReleasesList = (0, import_toolkit6.createSelector)([getReleasesById, getListedReleases, getReleaseMappingDefaults], listItemMapper);
|
|
1166
|
-
var getReleaseTagsById = (0, import_toolkit6.createSelector)([getReleaseTags], (releaseTags) => releaseTags.reduce((accu, key) => ({ ...accu, [key]: key }), {}));
|
|
1167
|
-
var getHasReleases = (0, import_toolkit6.createSelector)(
|
|
1168
|
-
[getReleaseListState, getReleasesById],
|
|
1169
|
-
({ searchTotal, total }, byId) => !!(Object.keys(byId).length || total || searchTotal)
|
|
1170
|
-
);
|
|
1171
|
-
var getSelectedRelease = (0, import_toolkit6.createSelector)([getReleasesById, getSelectedReleaseId], (byId, id) => byId[id || ""] ?? {});
|
|
1172
|
-
var getSelectedReleases = (0, import_toolkit6.createSelector)([getReleaseListState, getReleasesList], ({ selection }, releases) => selection.map((index) => releases[index]));
|
|
1173
|
-
var getDeltaJobsById = (state) => state.releases.deltaJobs;
|
|
1174
|
-
var getDeltaJobById = (0, import_toolkit6.createSelector)([getDeltaJobsById, (_, jobId) => jobId], (byId, jobId) => byId[jobId]);
|
|
1175
|
-
var getSelectedJobId = (state) => state.releases.selectedJob;
|
|
1176
|
-
var getSelectedJob = (0, import_toolkit6.createSelector)([getDeltaJobsById, getSelectedJobId], (byId, jobId) => byId[jobId || ""]);
|
|
1177
|
-
|
|
1178
|
-
// src/usersSlice/selectors.ts
|
|
1179
|
-
var import_toolkit7 = require("@reduxjs/toolkit");
|
|
1180
|
-
var emptyObject = {};
|
|
1181
|
-
var getRolesById = (state) => state.users.rolesById;
|
|
1182
|
-
var getTooltipsById = (state) => state.users.tooltips.byId;
|
|
1183
|
-
var getGlobalSettings = (state) => state.users.globalSettings;
|
|
1184
|
-
var getUserSettingsInitialized = (state) => state.users.userSettingsInitialized;
|
|
1185
|
-
var getCurrentUserId = (state) => state.users.currentUser;
|
|
1186
|
-
var getUsersById = (state) => state.users.byId;
|
|
1187
|
-
var getUsersList = (0, import_toolkit7.createSelector)([getUsersById], (usersById) => Object.values(usersById));
|
|
1188
|
-
var getCurrentUser = (0, import_toolkit7.createSelector)(
|
|
1189
|
-
[getUsersById, getCurrentUserId],
|
|
1190
|
-
(usersById, userId) => userId ? usersById[userId] ?? emptyObject : emptyObject
|
|
1191
|
-
);
|
|
1192
|
-
var getUserSettings = (state) => state.users.userSettings;
|
|
1193
|
-
var getSelectedDeviceAttribute = (0, import_toolkit7.createSelector)(
|
|
1194
|
-
[getUserSettings],
|
|
1195
|
-
({ columnSelection }) => columnSelection.map((attribute) => ({ attribute: attribute.key, scope: attribute.scope }))
|
|
1196
|
-
);
|
|
1197
|
-
var getIsDarkMode = (0, import_toolkit7.createSelector)([getUserSettings], ({ mode }) => isDarkMode(mode));
|
|
1198
|
-
var getReadAllHelptips = (0, import_toolkit7.createSelector)(
|
|
1199
|
-
[getTooltipsById],
|
|
1200
|
-
(tooltips) => Object.values(tooltips).every(({ readState }) => readState === READ_STATES.read)
|
|
1201
|
-
);
|
|
1202
|
-
var getTooltipsState = (0, import_toolkit7.createSelector)(
|
|
1203
|
-
[getTooltipsById, getUserSettings],
|
|
1204
|
-
(byId, { tooltips = {} }) => Object.entries(byId).reduce(
|
|
1205
|
-
(accu, [id, value]) => {
|
|
1206
|
-
accu[id] = { ...accu[id], ...value };
|
|
1207
|
-
return accu;
|
|
1208
|
-
},
|
|
1209
|
-
{ ...tooltips }
|
|
1210
|
-
)
|
|
1211
|
-
);
|
|
1212
|
-
var getHas2FA = (0, import_toolkit7.createSelector)(
|
|
1213
|
-
[getCurrentUser],
|
|
1214
|
-
(currentUser) => currentUser.hasOwnProperty("tfa_status") && currentUser.tfa_status === import_constants5.twoFAStates.enabled
|
|
1215
|
-
);
|
|
1216
|
-
var getIdAttribute = (0, import_toolkit7.createSelector)([getGlobalSettings], ({ id_attribute = { ...defaultIdAttribute } }) => id_attribute);
|
|
1217
|
-
var getOfflineThresholdSettings = (0, import_toolkit7.createSelector)([getGlobalSettings], ({ offlineThreshold }) => ({
|
|
1218
|
-
interval: offlineThreshold?.interval || DEVICE_ONLINE_CUTOFF.interval,
|
|
1219
|
-
intervalUnit: offlineThreshold?.intervalUnit || DEVICE_ONLINE_CUTOFF.intervalName
|
|
1220
|
-
}));
|
|
1221
|
-
var getRolesList = (0, import_toolkit7.createSelector)([getRolesById], (rolesById2) => Object.entries(rolesById2).map(([value, role]) => ({ value, ...role })));
|
|
1222
|
-
var getSecurityAlertDismissedTimestamp = (state) => state.users.userSettings.securityAlertDismissedTimestamp;
|
|
1223
|
-
|
|
1224
|
-
// src/commonSelectors.ts
|
|
1225
|
-
var getIsEnterprise = (0, import_toolkit8.createSelector)(
|
|
1226
|
-
[getOrganization, getFeatures],
|
|
1227
|
-
({ plan = PLANS.os.id }, { isEnterprise, isHosted }) => isEnterprise || isHosted && plan === PLANS.enterprise.id
|
|
1228
|
-
);
|
|
1229
|
-
var getUserRoles = (0, import_toolkit8.createSelector)([getCurrentUser, getRolesById, getIsEnterprise], (currentUser, rolesById2, isEnterprise) => {
|
|
1230
|
-
const isAdmin = currentUser.roles?.length ? currentUser.roles.some((role) => role === import_constants5.rolesByName.admin) : !isEnterprise;
|
|
1231
|
-
const uiPermissions = isAdmin ? mapUserRolesToUiPermissions([import_constants5.rolesByName.admin], rolesById2) : mapUserRolesToUiPermissions(currentUser.roles || [], rolesById2);
|
|
1232
|
-
return { isAdmin, uiPermissions };
|
|
1233
|
-
});
|
|
1234
|
-
var hasPermission = (thing, permission) => Object.values(thing).some((permissions) => permissions.includes(permission));
|
|
1235
|
-
var getUserCapabilities = (0, import_toolkit8.createSelector)([getUserRoles, getIsServiceProvider], ({ uiPermissions }, isServiceProvider) => {
|
|
1236
|
-
const canManageReleases = hasPermission(uiPermissions.releases, import_constants5.uiPermissionsById.manage.value);
|
|
1237
|
-
const canReadReleases = canManageReleases || hasPermission(uiPermissions.releases, import_constants5.uiPermissionsById.read.value);
|
|
1238
|
-
const canUploadReleases = canManageReleases || hasPermission(uiPermissions.releases, import_constants5.uiPermissionsById.upload.value);
|
|
1239
|
-
const canAuditlog = uiPermissions.auditlog.includes(import_constants5.uiPermissionsById.read.value);
|
|
1240
|
-
const canReadUsers = uiPermissions.userManagement.includes(import_constants5.uiPermissionsById.read.value);
|
|
1241
|
-
const canManageUsers = uiPermissions.userManagement.includes(import_constants5.uiPermissionsById.manage.value);
|
|
1242
|
-
const canReadDevices = hasPermission(uiPermissions.groups, import_constants5.uiPermissionsById.read.value);
|
|
1243
|
-
const canWriteDevices = Object.values(uiPermissions.groups).some(
|
|
1244
|
-
(groupPermissions) => groupPermissions.includes(import_constants5.uiPermissionsById.read.value) && groupPermissions.length > 1
|
|
1245
|
-
);
|
|
1246
|
-
const canTroubleshoot = hasPermission(uiPermissions.groups, import_constants5.uiPermissionsById.connect.value);
|
|
1247
|
-
const canManageDevices = hasPermission(uiPermissions.groups, import_constants5.uiPermissionsById.manage.value);
|
|
1248
|
-
const canConfigure = hasPermission(uiPermissions.groups, import_constants5.uiPermissionsById.configure.value);
|
|
1249
|
-
const canDeploy = uiPermissions.deployments.includes(import_constants5.uiPermissionsById.deploy.value) || hasPermission(uiPermissions.groups, import_constants5.uiPermissionsById.deploy.value);
|
|
1250
|
-
const canReadDeployments = uiPermissions.deployments.includes(import_constants5.uiPermissionsById.read.value);
|
|
1251
|
-
return {
|
|
1252
|
-
canAuditlog,
|
|
1253
|
-
canConfigure,
|
|
1254
|
-
canDeploy,
|
|
1255
|
-
canManageDevices,
|
|
1256
|
-
canManageReleases,
|
|
1257
|
-
canManageUsers,
|
|
1258
|
-
canReadDeployments,
|
|
1259
|
-
canReadDevices,
|
|
1260
|
-
canReadReleases,
|
|
1261
|
-
canReadUsers,
|
|
1262
|
-
canTroubleshoot,
|
|
1263
|
-
canUploadReleases,
|
|
1264
|
-
canWriteDevices,
|
|
1265
|
-
groupsPermissions: uiPermissions.groups,
|
|
1266
|
-
releasesPermissions: uiPermissions.releases,
|
|
1267
|
-
SPTenant: isServiceProvider
|
|
1268
|
-
};
|
|
1269
|
-
});
|
|
1270
|
-
var getTenantCapabilities = (0, import_toolkit8.createSelector)(
|
|
1271
|
-
[getFeatures, getOrganization, getIsEnterprise],
|
|
1272
|
-
({
|
|
1273
|
-
hasAuditlogs: isAuditlogEnabled,
|
|
1274
|
-
hasDeviceConfig: isDeviceConfigEnabled,
|
|
1275
|
-
hasDeviceConnect: isDeviceConnectEnabled,
|
|
1276
|
-
hasMonitor: isMonitorEnabled,
|
|
1277
|
-
isHosted
|
|
1278
|
-
}, { addons = [], plan = PLANS.os.id }, isEnterprise) => {
|
|
1279
|
-
const canDelta = isEnterprise || plan === PLANS.professional.id;
|
|
1280
|
-
const hasAuditlogs = isAuditlogEnabled && isEnterprise;
|
|
1281
|
-
const hasDeviceConfig = addons.some((addon) => addon.name === ADDONS.configure.id && addon.enabled) || isDeviceConfigEnabled && !isHosted;
|
|
1282
|
-
const hasDeviceConnect = addons.some((addon) => addon.name === ADDONS.troubleshoot.id && addon.enabled) || isDeviceConnectEnabled && !isHosted;
|
|
1283
|
-
const hasMonitor = isMonitorEnabled && addons.some((addon) => addon.name === ADDONS.monitor.id && addon.enabled);
|
|
1284
|
-
return {
|
|
1285
|
-
canDelta,
|
|
1286
|
-
canRetry: canDelta,
|
|
1287
|
-
canSchedule: canDelta,
|
|
1288
|
-
hasAuditlogs,
|
|
1289
|
-
hasDeviceConfig,
|
|
1290
|
-
hasDeviceConnect,
|
|
1291
|
-
hasFullFiltering: canDelta,
|
|
1292
|
-
hasMonitor,
|
|
1293
|
-
isEnterprise,
|
|
1294
|
-
plan
|
|
1295
|
-
};
|
|
1296
|
-
}
|
|
1297
|
-
);
|
|
1298
|
-
var getFilterAttributes = (0, import_toolkit8.createSelector)(
|
|
1299
|
-
[getGlobalSettings, getFilteringAttributes],
|
|
1300
|
-
({ previousFilters }, { identityAttributes, inventoryAttributes, systemAttributes, tagAttributes }) => {
|
|
1301
|
-
const deviceNameAttribute = { key: "name", value: "Name", scope: import_constants5.ATTRIBUTE_SCOPES.tags, category: import_constants5.ATTRIBUTE_SCOPES.tags, priority: 1 };
|
|
1302
|
-
const deviceIdAttribute = { key: "id", value: "Device ID", scope: import_constants5.ATTRIBUTE_SCOPES.identity, category: import_constants5.ATTRIBUTE_SCOPES.identity, priority: 1 };
|
|
1303
|
-
const checkInAttribute = { key: "check_in_time", value: "Latest activity", scope: import_constants5.ATTRIBUTE_SCOPES.system, category: import_constants5.ATTRIBUTE_SCOPES.system, priority: 4 };
|
|
1304
|
-
const updateAttribute = { ...checkInAttribute, key: "updated_ts", value: "Last inventory update" };
|
|
1305
|
-
const firstRequestAttribute = { key: "created_ts", value: "First request", scope: import_constants5.ATTRIBUTE_SCOPES.system, category: import_constants5.ATTRIBUTE_SCOPES.system, priority: 4 };
|
|
1306
|
-
const attributes = [
|
|
1307
|
-
...previousFilters.map((item) => ({
|
|
1308
|
-
...item,
|
|
1309
|
-
value: deviceIdAttribute.key === item.key ? deviceIdAttribute.value : item.key,
|
|
1310
|
-
category: "recently used",
|
|
1311
|
-
priority: 0
|
|
1312
|
-
})),
|
|
1313
|
-
deviceNameAttribute,
|
|
1314
|
-
deviceIdAttribute,
|
|
1315
|
-
...identityAttributes.map((item) => ({ key: item, value: item, scope: import_constants5.ATTRIBUTE_SCOPES.identity, category: import_constants5.ATTRIBUTE_SCOPES.identity, priority: 1 })),
|
|
1316
|
-
...inventoryAttributes.map((item) => ({ key: item, value: item, scope: import_constants5.ATTRIBUTE_SCOPES.inventory, category: import_constants5.ATTRIBUTE_SCOPES.inventory, priority: 2 })),
|
|
1317
|
-
...tagAttributes.map((item) => ({ key: item, value: item, scope: import_constants5.ATTRIBUTE_SCOPES.tags, category: import_constants5.ATTRIBUTE_SCOPES.tags, priority: 3 })),
|
|
1318
|
-
checkInAttribute,
|
|
1319
|
-
updateAttribute,
|
|
1320
|
-
firstRequestAttribute,
|
|
1321
|
-
...systemAttributes.map((item) => ({ key: item, value: item, scope: import_constants5.ATTRIBUTE_SCOPES.system, category: import_constants5.ATTRIBUTE_SCOPES.system, priority: 4 }))
|
|
1322
|
-
];
|
|
1323
|
-
return (0, import_helpers4.attributeDuplicateFilter)(attributes, "key");
|
|
1324
|
-
}
|
|
1325
|
-
);
|
|
1326
|
-
var getOnboardingState = (0, import_toolkit8.createSelector)([getOnboarding, getUserSettings], ({ complete, progress: progress2, showTips, ...remainder }, { onboarding = {} }) => ({
|
|
1327
|
-
...remainder,
|
|
1328
|
-
...onboarding,
|
|
1329
|
-
complete: onboarding.complete || complete,
|
|
1330
|
-
progress: Object.keys(onboardingSteps).findIndex((step) => step === progress2) > Object.keys(onboardingSteps).findIndex((step) => step === onboarding.progress) ? progress2 : onboarding.progress,
|
|
1331
|
-
showTips: !onboarding.showTips ? onboarding.showTips : showTips
|
|
1332
|
-
}));
|
|
1333
|
-
var getDemoDeviceAddress = (0, import_toolkit8.createSelector)([getDevicesById, getOnboarding], (devicesById, { approach, demoArtifactPort }) => {
|
|
1334
|
-
const demoDeviceAddress = `http://${(0, import_helpers4.getDemoDeviceAddress)(Object.values(devicesById), approach)}`;
|
|
1335
|
-
return demoArtifactPort ? `${demoDeviceAddress}:${demoArtifactPort}` : demoDeviceAddress;
|
|
1336
|
-
});
|
|
1337
|
-
var getDeviceConfigDeployment = (0, import_toolkit8.createSelector)([getDeviceById, getDeploymentsById], (device, deploymentsById) => {
|
|
1338
|
-
const { config = {} } = device;
|
|
1339
|
-
const { deployment_id: configDeploymentId } = config;
|
|
1340
|
-
const deviceConfigDeployment = deploymentsById[configDeploymentId] || {};
|
|
1341
|
-
return { device, deviceConfigDeployment };
|
|
1342
|
-
});
|
|
1343
|
-
var getDeploymentRelease = (0, import_toolkit8.createSelector)(
|
|
1344
|
-
[getDeploymentsById, getDeploymentsSelectionState, getReleasesById],
|
|
1345
|
-
(deploymentsById, { selectedId }, releasesById) => {
|
|
1346
|
-
const deployment = deploymentsById[selectedId] || {};
|
|
1347
|
-
return deployment.artifact_name && releasesById[deployment.artifact_name] ? releasesById[deployment.artifact_name] : { device_types_compatible: [] };
|
|
1348
|
-
}
|
|
1349
|
-
);
|
|
1350
|
-
var getSelectedDeploymentData = (0, import_toolkit8.createSelector)(
|
|
1351
|
-
[getDeploymentsById, getDeploymentsSelectionState, getDevicesById, getSelectedDeploymentDeviceIds],
|
|
1352
|
-
(deploymentsById, { selectedId }, devicesById, selectedDeviceIds) => {
|
|
1353
|
-
const deployment = deploymentsById[selectedId] ?? {};
|
|
1354
|
-
const { devices = {} } = deployment;
|
|
1355
|
-
return {
|
|
1356
|
-
deployment,
|
|
1357
|
-
selectedDevices: selectedDeviceIds.map((deviceId) => ({ ...devicesById[deviceId], ...devices[deviceId] }))
|
|
1358
|
-
};
|
|
1359
|
-
}
|
|
1360
|
-
);
|
|
1361
|
-
var getAvailableIssueOptionsByType = (0, import_toolkit8.createSelector)(
|
|
1362
|
-
[getTenantCapabilities, getIssueCountsByType],
|
|
1363
|
-
({ hasFullFiltering, hasMonitor }, issueCounts) => Object.values(import_constants5.DEVICE_ISSUE_OPTIONS).reduce((accu, { isCategory, key, needsFullFiltering, needsMonitor, title }) => {
|
|
1364
|
-
if (isCategory || needsFullFiltering && !hasFullFiltering || needsMonitor && !hasMonitor) {
|
|
1365
|
-
return accu;
|
|
1366
|
-
}
|
|
1367
|
-
accu[key] = { count: issueCounts[key].filtered, key, title };
|
|
1368
|
-
return accu;
|
|
1369
|
-
}, {})
|
|
1370
|
-
);
|
|
1371
|
-
var getGroupNames = (0, import_toolkit8.createSelector)([getGroupsById, getUserRoles], (groupsById, { uiPermissions }) => {
|
|
1372
|
-
const { [UNGROUPED_GROUP.id]: ungrouped, ...groups } = groupsById;
|
|
1373
|
-
return Object.keys(
|
|
1374
|
-
Object.entries(groups).reduce((accu, [groupName, group]) => {
|
|
1375
|
-
if (group.filterId || uiPermissions.groups[import_constants5.ALL_DEVICES]) {
|
|
1376
|
-
accu[groupName] = group;
|
|
1377
|
-
}
|
|
1378
|
-
return accu;
|
|
1379
|
-
}, uiPermissions.groups)
|
|
1380
|
-
).sort();
|
|
1381
|
-
});
|
|
1382
|
-
var getDeviceReportsForUser = (0, import_toolkit8.createSelector)(
|
|
1383
|
-
[getUserSettings, getCurrentUser, getGlobalSettings, getDevicesById],
|
|
1384
|
-
({ reports }, { id: currentUserId }, globalSettings, devicesById) => reports || globalSettings[`${currentUserId}-reports`] || (Object.keys(devicesById).length ? defaultReports : [])
|
|
1385
|
-
);
|
|
1386
|
-
var listTypeDeviceIdMap = {
|
|
1387
|
-
deviceList: getListedDevices,
|
|
1388
|
-
search: getSearchedDevices
|
|
1389
|
-
};
|
|
1390
|
-
var deviceMapDefault = { defaultObject: { auth_sets: [] }, cutOffSize: DEVICE_LIST_MAXIMUM_LENGTH };
|
|
1391
|
-
var getDeviceMappingDefaults = () => deviceMapDefault;
|
|
1392
|
-
var getMappedDevicesList = (0, import_toolkit8.createSelector)(
|
|
1393
|
-
[getDevicesById, (state, listType) => listTypeDeviceIdMap[listType](state), getDeviceMappingDefaults],
|
|
1394
|
-
listItemMapper
|
|
1395
|
-
);
|
|
1396
|
-
var getAuditlogDevice = (0, import_toolkit8.createSelector)([getAuditLogEntry, getDevicesById], (auditlogEvent, devicesById) => {
|
|
1397
|
-
let auditlogDevice = {};
|
|
1398
|
-
if (auditlogEvent) {
|
|
1399
|
-
const { object = {} } = auditlogEvent;
|
|
1400
|
-
const { device = {}, id, type } = object;
|
|
1401
|
-
auditlogDevice = type === "device" ? { id, ...device } : auditlogDevice;
|
|
1402
|
-
}
|
|
1403
|
-
return { ...auditlogDevice, ...devicesById[auditlogDevice.id] };
|
|
1404
|
-
});
|
|
1405
|
-
var getRelevantRoles = (0, import_toolkit8.createSelector)([getOrganization, getRolesList], ({ service_provider }, roles) => {
|
|
1406
|
-
if (service_provider) {
|
|
1407
|
-
return roles.reduce((accu, role) => {
|
|
1408
|
-
if (import_constants5.rolesById[role.value]) {
|
|
1409
|
-
return accu;
|
|
1410
|
-
}
|
|
1411
|
-
accu.push(role);
|
|
1412
|
-
return accu;
|
|
1413
|
-
}, Object.values(import_constants5.serviceProviderRolesById));
|
|
1414
|
-
}
|
|
1415
|
-
return Object.keys(import_constants5.rolesById).reverse().reduce((accu, key) => {
|
|
1416
|
-
const index = accu.findIndex(({ value }) => value === key);
|
|
1417
|
-
accu = [accu[index], ...accu.filter((item, itemIndex) => index !== itemIndex)];
|
|
1418
|
-
return accu;
|
|
1419
|
-
}, roles);
|
|
1420
|
-
});
|
|
1421
|
-
var getShowSecurityAlert = (0, import_toolkit8.createSelector)(
|
|
1422
|
-
[getCurrentUser, getHas2FA, getFeatures, getIsEnterprise, getUserSettingsInitialized, getSecurityAlertDismissedTimestamp],
|
|
1423
|
-
(currentUser, has2FA, features, isEnterprise, settingsInitialized, dismissedTimestamp) => {
|
|
1424
|
-
const isOAuth2 = !!currentUser?.sso?.length;
|
|
1425
|
-
const userVerified = !!currentUser.verified;
|
|
1426
|
-
const isHosted = features?.isHosted;
|
|
1427
|
-
const canHave2FA = isEnterprise || isHosted;
|
|
1428
|
-
const secureOAuthUser = isOAuth2 && userVerified;
|
|
1429
|
-
if (!currentUser || !settingsInitialized || has2FA || !canHave2FA || secureOAuthUser) {
|
|
1430
|
-
return false;
|
|
1431
|
-
}
|
|
1432
|
-
if (dismissedTimestamp === null) {
|
|
1433
|
-
return true;
|
|
1434
|
-
}
|
|
1435
|
-
const today = (0, import_dayjs.default)();
|
|
1436
|
-
const dismissedMonthAgo = today.diff(dismissedTimestamp, "months");
|
|
1437
|
-
return dismissedMonthAgo > 0;
|
|
1438
|
-
}
|
|
1439
|
-
);
|
|
1440
|
-
|
|
1441
|
-
// src/store.ts
|
|
1442
|
-
var import_react_redux = require("react-redux");
|
|
1443
|
-
var import_helpers6 = require("@northern.tech/utils/helpers");
|
|
1444
|
-
var import_toolkit16 = require("@reduxjs/toolkit");
|
|
1445
|
-
var import_react = require("@sentry/react");
|
|
1446
|
-
|
|
1447
|
-
// src/appSlice/index.ts
|
|
1448
|
-
var import_toolkit9 = require("@reduxjs/toolkit");
|
|
1449
|
-
var sliceName2 = "app";
|
|
1450
|
-
var getYesterday = () => {
|
|
1451
|
-
const today = /* @__PURE__ */ new Date();
|
|
1452
|
-
today.setDate(today.getDate() - 1);
|
|
1453
|
-
return today.toISOString();
|
|
1454
|
-
};
|
|
1455
|
-
var initialState2 = {
|
|
1456
|
-
appInitDone: false,
|
|
1457
|
-
cancelSource: void 0,
|
|
1458
|
-
commit: "",
|
|
1459
|
-
demoArtifactLink: "https://dgsbl4vditpls.cloudfront.net/mender-demo-artifact.mender",
|
|
1460
|
-
hostAddress: null,
|
|
1461
|
-
snackbar: {
|
|
1462
|
-
action: void 0,
|
|
1463
|
-
autoHideDuration: void 0,
|
|
1464
|
-
message: "",
|
|
1465
|
-
open: false,
|
|
1466
|
-
preventClickToCopy: false
|
|
1467
|
-
},
|
|
1468
|
-
// return boolean rather than organization details
|
|
1469
|
-
features: {
|
|
1470
|
-
hasAiEnabled: false,
|
|
1471
|
-
hasAuditlogs: false,
|
|
1472
|
-
hasDeltaProgress: false,
|
|
1473
|
-
hasMultitenancy: false,
|
|
1474
|
-
hasDeviceConfig: false,
|
|
1475
|
-
hasDeviceConnect: false,
|
|
1476
|
-
hasFeedbackEnabled: false,
|
|
1477
|
-
hasManifestsEnabled: false,
|
|
1478
|
-
hasMonitor: false,
|
|
1479
|
-
hasMCUEnabled: false,
|
|
1480
|
-
isHosted: true,
|
|
1481
|
-
isEnterprise: false
|
|
1482
|
-
},
|
|
1483
|
-
feedbackProbability: 0.3,
|
|
1484
|
-
firstLoginAfterSignup: false,
|
|
1485
|
-
hostedAnnouncement: "",
|
|
1486
|
-
docsVersion: "",
|
|
1487
|
-
recaptchaSiteKey: "",
|
|
1488
|
-
searchState: {
|
|
1489
|
-
deviceIds: [],
|
|
1490
|
-
searchTerm: "",
|
|
1491
|
-
searchTotal: 0,
|
|
1492
|
-
isSearching: false,
|
|
1493
|
-
sort: {
|
|
1494
|
-
direction: import_constants5.SORTING_OPTIONS.desc
|
|
1495
|
-
// key: null,
|
|
1496
|
-
// scope: null
|
|
1497
|
-
}
|
|
1498
|
-
},
|
|
1499
|
-
sentry: {
|
|
1500
|
-
location: "",
|
|
1501
|
-
replaysSessionSampleRate: 0.1,
|
|
1502
|
-
tracesSampleRate: 1
|
|
1503
|
-
},
|
|
1504
|
-
stripeAPIKey: "",
|
|
1505
|
-
trackerCode: "",
|
|
1506
|
-
uploadsById: {
|
|
1507
|
-
// id: { progress: 0, cancelSource: undefined }
|
|
1508
|
-
},
|
|
1509
|
-
newThreshold: getYesterday(),
|
|
1510
|
-
offlineThreshold: getYesterday(),
|
|
1511
|
-
versionInformation: {
|
|
1512
|
-
Integration: "",
|
|
1513
|
-
"Mender-Artifact": "",
|
|
1514
|
-
"Meta-Mender": ""
|
|
1515
|
-
},
|
|
1516
|
-
yesterday: void 0
|
|
1517
|
-
};
|
|
1518
|
-
var appSlice = (0, import_toolkit9.createSlice)({
|
|
1519
|
-
name: sliceName2,
|
|
1520
|
-
initialState: initialState2,
|
|
1521
|
-
reducers: {
|
|
1522
|
-
setFeatures: (state, action) => {
|
|
1523
|
-
state.features = {
|
|
1524
|
-
...state.features,
|
|
1525
|
-
...action.payload
|
|
1526
|
-
};
|
|
1527
|
-
},
|
|
1528
|
-
setSnackbar: (state, { payload }) => {
|
|
1529
|
-
if (typeof payload === "string" || payload instanceof String) {
|
|
1530
|
-
state.snackbar = {
|
|
1531
|
-
...initialState2.snackbar,
|
|
1532
|
-
message: payload,
|
|
1533
|
-
open: !!payload
|
|
1534
|
-
};
|
|
1535
|
-
return;
|
|
1536
|
-
}
|
|
1537
|
-
const { message, autoHideDuration, action, preventClickToCopy = false } = payload;
|
|
1538
|
-
state.snackbar = {
|
|
1539
|
-
message,
|
|
1540
|
-
autoHideDuration,
|
|
1541
|
-
action,
|
|
1542
|
-
preventClickToCopy,
|
|
1543
|
-
open: !!message
|
|
1544
|
-
};
|
|
1545
|
-
},
|
|
1546
|
-
setFirstLoginAfterSignup: (state, action) => {
|
|
1547
|
-
state.firstLoginAfterSignup = action.payload;
|
|
1548
|
-
},
|
|
1549
|
-
setAnnouncement: (state, action) => {
|
|
1550
|
-
state.hostedAnnouncement = action.payload;
|
|
1551
|
-
},
|
|
1552
|
-
setSearchState: (state, action) => {
|
|
1553
|
-
state.searchState = {
|
|
1554
|
-
...state.searchState,
|
|
1555
|
-
...action.payload
|
|
1556
|
-
};
|
|
1557
|
-
},
|
|
1558
|
-
setOfflineThreshold: (state, action) => {
|
|
1559
|
-
state.offlineThreshold = action.payload;
|
|
1560
|
-
},
|
|
1561
|
-
initUpload: (state, action) => {
|
|
1562
|
-
const { id, upload } = action.payload;
|
|
1563
|
-
state.uploadsById[id] = upload;
|
|
1564
|
-
},
|
|
1565
|
-
uploadProgress: (state, action) => {
|
|
1566
|
-
const { id, progress: progress2 } = action.payload;
|
|
1567
|
-
state.uploadsById[id] = {
|
|
1568
|
-
...state.uploadsById[id],
|
|
1569
|
-
progress: progress2
|
|
1570
|
-
};
|
|
1571
|
-
},
|
|
1572
|
-
cleanUpUpload: (state, action) => {
|
|
1573
|
-
const { [action.payload]: current, ...remainder } = state.uploadsById;
|
|
1574
|
-
state.uploadsById = remainder;
|
|
1575
|
-
},
|
|
1576
|
-
setVersionInformation: (state, action) => {
|
|
1577
|
-
state.versionInformation = {
|
|
1578
|
-
...state.versionInformation,
|
|
1579
|
-
...action.payload
|
|
1580
|
-
};
|
|
1581
|
-
},
|
|
1582
|
-
setEnvironmentData: (state, action) => ({ ...state, ...action.payload }),
|
|
1583
|
-
setAppInitDone: (state) => {
|
|
1584
|
-
state.appInitDone = true;
|
|
1585
|
-
}
|
|
1586
|
-
}
|
|
1587
|
-
});
|
|
1588
|
-
var actions2 = appSlice.actions;
|
|
1589
|
-
var appSlice_default = appSlice.reducer;
|
|
1590
|
-
|
|
1591
|
-
// src/deploymentsSlice/index.ts
|
|
1592
|
-
var import_toolkit10 = require("@reduxjs/toolkit");
|
|
1593
|
-
var sliceName3 = "deployments";
|
|
1594
|
-
var initialState3 = {
|
|
1595
|
-
byId: {
|
|
1596
|
-
// [id]: { statistics: { status: {}, total_size }, devices: { [deploymentId]: { id, log } }, totalDeviceCount }
|
|
1597
|
-
},
|
|
1598
|
-
byStatus: {
|
|
1599
|
-
finished: { deploymentIds: [], total: 0 },
|
|
1600
|
-
inprogress: { deploymentIds: [], total: 0 },
|
|
1601
|
-
pending: { deploymentIds: [], total: 0 },
|
|
1602
|
-
scheduled: { deploymentIds: [], total: 0 }
|
|
1603
|
-
},
|
|
1604
|
-
config: {
|
|
1605
|
-
binaryDelta: {
|
|
1606
|
-
timeout: -1,
|
|
1607
|
-
duplicatesWindow: -1,
|
|
1608
|
-
compressionLevel: -1,
|
|
1609
|
-
disableChecksum: false,
|
|
1610
|
-
disableDecompression: false,
|
|
1611
|
-
inputWindow: -1,
|
|
1612
|
-
instructionBuffer: -1,
|
|
1613
|
-
sourceWindow: -1
|
|
1614
|
-
},
|
|
1615
|
-
binaryDeltaLimits: {
|
|
1616
|
-
timeout: { ...import_constants5.limitDefault, default: 60, max: 3600, min: 60 },
|
|
1617
|
-
sourceWindow: import_constants5.limitDefault,
|
|
1618
|
-
inputWindow: import_constants5.limitDefault,
|
|
1619
|
-
duplicatesWindow: import_constants5.limitDefault,
|
|
1620
|
-
instructionBuffer: import_constants5.limitDefault
|
|
1621
|
-
}
|
|
1622
|
-
},
|
|
1623
|
-
deploymentDeviceLimit: 5e3,
|
|
1624
|
-
selectedDeviceIds: [],
|
|
1625
|
-
selectionState: {
|
|
1626
|
-
finished: { ...import_constants5.DEVICE_LIST_DEFAULTS, endDate: void 0, search: "", selection: [], startDate: void 0, total: 0, type: "" },
|
|
1627
|
-
inprogress: { ...import_constants5.DEVICE_LIST_DEFAULTS, perPage: DEFAULT_PENDING_INPROGRESS_COUNT, selection: [] },
|
|
1628
|
-
pending: { ...import_constants5.DEVICE_LIST_DEFAULTS, perPage: DEFAULT_PENDING_INPROGRESS_COUNT, selection: [] },
|
|
1629
|
-
scheduled: { ...import_constants5.DEVICE_LIST_DEFAULTS, selection: [] },
|
|
1630
|
-
general: {
|
|
1631
|
-
state: DEPLOYMENT_ROUTES.active.key,
|
|
1632
|
-
showCreationDialog: false,
|
|
1633
|
-
showReportDialog: false,
|
|
1634
|
-
reportType: null
|
|
1635
|
-
// DeploymentConstants.DEPLOYMENT_TYPES.configuration|DeploymentConstants.DEPLOYMENT_TYPES.software
|
|
1636
|
-
},
|
|
1637
|
-
selectedId: void 0
|
|
1638
|
-
}
|
|
1639
|
-
};
|
|
1640
|
-
var deploymentsSlice = (0, import_toolkit10.createSlice)({
|
|
1641
|
-
name: sliceName3,
|
|
1642
|
-
initialState: initialState3,
|
|
1643
|
-
reducers: {
|
|
1644
|
-
createdDeployment: (state, action) => {
|
|
1645
|
-
state.byId[action.payload.id] = {
|
|
1646
|
-
...deploymentPrototype,
|
|
1647
|
-
...action.payload
|
|
1648
|
-
};
|
|
1649
|
-
state.byStatus[DEPLOYMENT_STATES.pending].total = state.byStatus[DEPLOYMENT_STATES.pending].total + 1;
|
|
1650
|
-
state.byStatus[DEPLOYMENT_STATES.pending].deploymentIds = [...state.byStatus.pending.deploymentIds, action.payload.id];
|
|
1651
|
-
state.selectionState[DEPLOYMENT_STATES.pending].selection = [action.payload.id, ...state.selectionState[DEPLOYMENT_STATES.pending].selection];
|
|
1652
|
-
state.selectionState[DEPLOYMENT_STATES.pending].total = (state.selectionState[DEPLOYMENT_STATES.pending].total || 0) + 1;
|
|
1653
|
-
},
|
|
1654
|
-
removedDeployment: (state, action) => {
|
|
1655
|
-
const { [action.payload]: removedDeployment, ...remainder } = state.byId;
|
|
1656
|
-
state.byId = remainder;
|
|
1657
|
-
},
|
|
1658
|
-
receivedDeployment: (state, action) => {
|
|
1659
|
-
state.byId[action.payload.id] = {
|
|
1660
|
-
...state.byId[action.payload.id] || {},
|
|
1661
|
-
...action.payload
|
|
1662
|
-
};
|
|
1663
|
-
},
|
|
1664
|
-
receivedDeploymentDeviceLog: (state, action) => {
|
|
1665
|
-
const { id, deviceId, log } = action.payload;
|
|
1666
|
-
const deployment = {
|
|
1667
|
-
...deploymentPrototype,
|
|
1668
|
-
...state.byId[id]
|
|
1669
|
-
};
|
|
1670
|
-
state.byId[id] = {
|
|
1671
|
-
...deployment,
|
|
1672
|
-
devices: {
|
|
1673
|
-
...deployment.devices,
|
|
1674
|
-
[deviceId]: {
|
|
1675
|
-
...deployment.devices[deviceId],
|
|
1676
|
-
log
|
|
1677
|
-
}
|
|
1678
|
-
}
|
|
1679
|
-
};
|
|
1680
|
-
},
|
|
1681
|
-
receivedDeploymentDevices: (state, action) => {
|
|
1682
|
-
const { id, devices, selectedDeviceIds, totalDeviceCount } = action.payload;
|
|
1683
|
-
state.byId[id] = {
|
|
1684
|
-
...state.byId[id],
|
|
1685
|
-
devices,
|
|
1686
|
-
totalDeviceCount
|
|
1687
|
-
};
|
|
1688
|
-
state.selectedDeviceIds = selectedDeviceIds;
|
|
1689
|
-
},
|
|
1690
|
-
receivedDeployments: (state, action) => {
|
|
1691
|
-
state.byId = {
|
|
1692
|
-
...state.byId,
|
|
1693
|
-
...action.payload
|
|
1694
|
-
};
|
|
1695
|
-
},
|
|
1696
|
-
receivedDeploymentsForStatus: (state, action) => {
|
|
1697
|
-
const { status, deploymentIds, total } = action.payload;
|
|
1698
|
-
state.byStatus[status].deploymentIds = deploymentIds;
|
|
1699
|
-
state.byStatus[status].total = total;
|
|
1700
|
-
},
|
|
1701
|
-
selectDeploymentsForStatus: (state, action) => {
|
|
1702
|
-
const { status, deploymentIds, total } = action.payload;
|
|
1703
|
-
state.selectionState[status].selection = deploymentIds;
|
|
1704
|
-
state.selectionState[status].total = total;
|
|
1705
|
-
},
|
|
1706
|
-
setDeploymentsState: (state, action) => {
|
|
1707
|
-
state.selectionState = action.payload;
|
|
1708
|
-
},
|
|
1709
|
-
setDeploymentsConfig: (state, action) => {
|
|
1710
|
-
state.config = action.payload;
|
|
1711
|
-
}
|
|
1712
|
-
}
|
|
1713
|
-
});
|
|
1714
|
-
var actions3 = deploymentsSlice.actions;
|
|
1715
|
-
var deploymentsSlice_default = deploymentsSlice.reducer;
|
|
1716
|
-
|
|
1717
|
-
// src/devicesSlice/index.ts
|
|
1718
|
-
var import_helpers5 = require("@northern.tech/utils/helpers");
|
|
1719
|
-
var import_toolkit11 = require("@reduxjs/toolkit");
|
|
1720
|
-
var sliceName4 = "devices";
|
|
1721
|
-
var initialState4 = {
|
|
1722
|
-
byId: {
|
|
1723
|
-
// [deviceId]: {
|
|
1724
|
-
// ...,
|
|
1725
|
-
// twinsByIntegration: { [external.provider.id]: twinData }
|
|
1726
|
-
// }
|
|
1727
|
-
},
|
|
1728
|
-
byStatus: {
|
|
1729
|
-
[import_constants5.DEVICE_STATES.accepted]: { deviceIds: [], counts: { standard: 0, micro: 0, system: 0, total: 0 } },
|
|
1730
|
-
[import_constants5.DEVICE_STATES.pending]: { deviceIds: [], counts: { standard: 0, micro: 0, system: 0, total: 0 } },
|
|
1731
|
-
[import_constants5.DEVICE_STATES.preauth]: { deviceIds: [], counts: { standard: 0, micro: 0, system: 0, total: 0 } },
|
|
1732
|
-
[import_constants5.DEVICE_STATES.rejected]: { deviceIds: [], counts: { standard: 0, micro: 0, system: 0, total: 0 } }
|
|
1733
|
-
},
|
|
1734
|
-
deviceList: {
|
|
1735
|
-
deviceIds: [],
|
|
1736
|
-
...import_constants5.DEVICE_LIST_DEFAULTS,
|
|
1737
|
-
selectedAttributes: [],
|
|
1738
|
-
selectedIssues: [],
|
|
1739
|
-
selection: [],
|
|
1740
|
-
sort: {
|
|
1741
|
-
direction: import_constants5.SORTING_OPTIONS.desc
|
|
1742
|
-
// key: null,
|
|
1743
|
-
// scope: null
|
|
1744
|
-
},
|
|
1745
|
-
state: import_constants5.DEVICE_STATES.accepted,
|
|
1746
|
-
total: 0,
|
|
1747
|
-
refreshTrigger: false,
|
|
1748
|
-
isLoading: false,
|
|
1749
|
-
detailsTab: "",
|
|
1750
|
-
open: false
|
|
1751
|
-
},
|
|
1752
|
-
filters: [
|
|
1753
|
-
// { key: 'device_type', value: 'raspberry', operator: '$eq', scope: 'inventory' }
|
|
1754
|
-
],
|
|
1755
|
-
filteringAttributes: { identityAttributes: [], inventoryAttributes: [], systemAttributes: [], tagAttributes: [] },
|
|
1756
|
-
filteringAttributesLimit: 10,
|
|
1757
|
-
filteringAttributesConfig: {
|
|
1758
|
-
attributes: {
|
|
1759
|
-
// inventory: ['some_attribute']
|
|
1760
|
-
},
|
|
1761
|
-
count: 0,
|
|
1762
|
-
limit: 100
|
|
1763
|
-
},
|
|
1764
|
-
reports: [
|
|
1765
|
-
// { items: [{ key: "someKey", count: 42 }], otherCount: 123, total: <otherCount + itemsCount> }
|
|
1766
|
-
],
|
|
1767
|
-
total: 0,
|
|
1768
|
-
limits: {
|
|
1769
|
-
standard: 0,
|
|
1770
|
-
micro: 0,
|
|
1771
|
-
system: 0
|
|
1772
|
-
},
|
|
1773
|
-
groups: {
|
|
1774
|
-
byId: {
|
|
1775
|
-
// groupName: { deviceIds: [], total: 0, filters: [] },
|
|
1776
|
-
// dynamo: { deviceIds: [], total: 3, filters: [{ a: 1 }] }
|
|
1777
|
-
},
|
|
1778
|
-
selectedGroup: void 0
|
|
1779
|
-
}
|
|
1780
|
-
};
|
|
1781
|
-
var devicesSlice = (0, import_toolkit11.createSlice)({
|
|
1782
|
-
name: sliceName4,
|
|
1783
|
-
initialState: initialState4,
|
|
1784
|
-
reducers: {
|
|
1785
|
-
receivedGroups: (state, action) => {
|
|
1786
|
-
state.groups.byId = action.payload;
|
|
1787
|
-
},
|
|
1788
|
-
addToGroup: (state, action) => {
|
|
1789
|
-
const { group, deviceIds } = action.payload;
|
|
1790
|
-
const maybeExistingGroup = {
|
|
1791
|
-
filters: [],
|
|
1792
|
-
deviceIds: [],
|
|
1793
|
-
...state.groups.byId[group]
|
|
1794
|
-
};
|
|
1795
|
-
state.groups.byId[group] = {
|
|
1796
|
-
...maybeExistingGroup,
|
|
1797
|
-
deviceIds: [...maybeExistingGroup.deviceIds, ...deviceIds].filter(import_helpers5.duplicateFilter),
|
|
1798
|
-
total: (maybeExistingGroup.total || 0) + 1
|
|
1799
|
-
};
|
|
1800
|
-
},
|
|
1801
|
-
removeFromGroup: (state, action) => {
|
|
1802
|
-
const { group, deviceIds: removedIds } = action.payload;
|
|
1803
|
-
const { deviceIds = [], total = 0, ...maybeExistingGroup } = state.groups.byId[group] || {};
|
|
1804
|
-
const changedGroup = {
|
|
1805
|
-
...maybeExistingGroup,
|
|
1806
|
-
deviceIds: deviceIds.filter((id) => !removedIds.includes(id)),
|
|
1807
|
-
total: Math.max(total - removedIds.length, 0)
|
|
1808
|
-
};
|
|
1809
|
-
if (changedGroup.total || changedGroup.deviceIds.length) {
|
|
1810
|
-
state.groups.byId[group] = changedGroup;
|
|
1811
|
-
return;
|
|
1812
|
-
} else if (state.groups.selectedGroup === group) {
|
|
1813
|
-
state.groups.selectedGroup = void 0;
|
|
1814
|
-
}
|
|
1815
|
-
const { [group]: removal, ...remainingById } = state.groups.byId;
|
|
1816
|
-
state.groups.byId = remainingById;
|
|
1817
|
-
},
|
|
1818
|
-
addGroup: (state, action) => {
|
|
1819
|
-
const { groupName, group } = action.payload;
|
|
1820
|
-
state.groups.byId[groupName] = {
|
|
1821
|
-
...state.groups.byId[groupName],
|
|
1822
|
-
...group
|
|
1823
|
-
};
|
|
1824
|
-
},
|
|
1825
|
-
selectGroup: (state, { payload: group }) => {
|
|
1826
|
-
state.deviceList.deviceIds = group && state.groups.byId[group] && state.groups.byId[group].deviceIds && state.groups.byId[group].deviceIds.length > 0 ? state.groups.byId[group].deviceIds : [];
|
|
1827
|
-
state.groups.selectedGroup = group;
|
|
1828
|
-
},
|
|
1829
|
-
removeGroup: (state, action) => {
|
|
1830
|
-
const { [action.payload]: removal, ...remainingById } = state.groups.byId;
|
|
1831
|
-
state.groups.byId = remainingById;
|
|
1832
|
-
state.groups.selectedGroup = state.groups.selectedGroup === action.payload ? void 0 : state.groups.selectedGroup;
|
|
1833
|
-
},
|
|
1834
|
-
setDeviceListState: (state, action) => {
|
|
1835
|
-
state.deviceList = {
|
|
1836
|
-
...state.deviceList,
|
|
1837
|
-
...action.payload,
|
|
1838
|
-
sort: {
|
|
1839
|
-
...state.deviceList.sort,
|
|
1840
|
-
...action.payload.sort
|
|
1841
|
-
}
|
|
1842
|
-
};
|
|
1843
|
-
},
|
|
1844
|
-
setFilterAttributes: (state, action) => {
|
|
1845
|
-
state.filteringAttributes = action.payload;
|
|
1846
|
-
},
|
|
1847
|
-
setFilterablesConfig: (state, action) => {
|
|
1848
|
-
state.filteringAttributesConfig = action.payload;
|
|
1849
|
-
},
|
|
1850
|
-
receivedDevices: (state, action) => {
|
|
1851
|
-
state.byId = {
|
|
1852
|
-
...state.byId,
|
|
1853
|
-
...action.payload
|
|
1854
|
-
};
|
|
1855
|
-
},
|
|
1856
|
-
setDeviceFilters: (state, action) => {
|
|
1857
|
-
if ((0, import_helpers5.deepCompare)(action.payload, state.filters)) {
|
|
1858
|
-
return;
|
|
1859
|
-
}
|
|
1860
|
-
state.filters = action.payload.filter((filter) => filter.key && filter.operator && filter.scope && typeof filter.value !== "undefined");
|
|
1861
|
-
},
|
|
1862
|
-
setDeviceReports: (state, action) => {
|
|
1863
|
-
state.reports = action.payload;
|
|
1864
|
-
},
|
|
1865
|
-
setDevicesByStatus: (state, action) => {
|
|
1866
|
-
const { status, total, deviceIds } = action.payload;
|
|
1867
|
-
if (total) {
|
|
1868
|
-
state.byStatus[status].deviceIds = deviceIds;
|
|
1869
|
-
state.byStatus[status].counts.total = total;
|
|
1870
|
-
}
|
|
1871
|
-
},
|
|
1872
|
-
setDevicesCountByStatus: (state, action) => {
|
|
1873
|
-
const { countsPerTier, status } = action.payload;
|
|
1874
|
-
state.byStatus[status].counts = { ...countsPerTier, total: Object.values(countsPerTier).reduce((accu, tieredCount) => accu += tieredCount, 0) };
|
|
1875
|
-
},
|
|
1876
|
-
setDeviceLimits: (state, action) => {
|
|
1877
|
-
state.limits = action.payload;
|
|
1878
|
-
},
|
|
1879
|
-
receivedDevice: (state, action) => {
|
|
1880
|
-
state.byId[action.payload.id] = {
|
|
1881
|
-
...state.byId[action.payload.id],
|
|
1882
|
-
...action.payload
|
|
1883
|
-
};
|
|
1884
|
-
},
|
|
1885
|
-
maybeUpdateDevicesByStatus: (state, action) => {
|
|
1886
|
-
const { deviceId, authId } = action.payload;
|
|
1887
|
-
const device = state.byId[deviceId];
|
|
1888
|
-
const hasMultipleAuthSets = authId && device.auth_sets ? device.auth_sets.filter((authset) => authset.id !== authId).length > 0 : false;
|
|
1889
|
-
if (!hasMultipleAuthSets && Object.values(import_constants5.DEVICE_STATES).includes(device.status)) {
|
|
1890
|
-
const deviceIds = state.byStatus[device.status].deviceIds.filter((id) => id !== deviceId);
|
|
1891
|
-
const deviceTier = device.attributes.tier || "standard";
|
|
1892
|
-
state.byStatus[device.status] = {
|
|
1893
|
-
deviceIds,
|
|
1894
|
-
counts: {
|
|
1895
|
-
...state.byStatus[device.status].counts,
|
|
1896
|
-
[deviceTier]: Math.max(0, state.byStatus[device.status].counts[deviceTier] - 1),
|
|
1897
|
-
total: Math.max(0, state.byStatus[device.status].counts.total - 1)
|
|
1898
|
-
}
|
|
1899
|
-
};
|
|
1900
|
-
}
|
|
1901
|
-
}
|
|
1902
|
-
}
|
|
1903
|
-
});
|
|
1904
|
-
var actions4 = devicesSlice.actions;
|
|
1905
|
-
var devicesSlice_default = devicesSlice.reducer;
|
|
1906
|
-
|
|
1907
|
-
// src/monitorSlice/index.ts
|
|
1908
|
-
var import_toolkit12 = require("@reduxjs/toolkit");
|
|
1909
|
-
var sliceName5 = "monitor";
|
|
1910
|
-
var initialState5 = {
|
|
1911
|
-
alerts: {
|
|
1912
|
-
alertList: { ...import_constants5.DEVICE_LIST_DEFAULTS, total: 0 },
|
|
1913
|
-
byDeviceId: {}
|
|
1914
|
-
},
|
|
1915
|
-
issueCounts: {
|
|
1916
|
-
byType: Object.keys(import_constants5.DEVICE_ISSUE_OPTIONS).reduce((accu, key) => ({ ...accu, [key]: { filtered: 0, total: 0 } }), {})
|
|
1917
|
-
},
|
|
1918
|
-
settings: {
|
|
1919
|
-
global: {
|
|
1920
|
-
channels: {
|
|
1921
|
-
...Object.keys(import_constants5.alertChannels).reduce((accu, item) => ({ ...accu, [item]: { enabled: true } }), {})
|
|
1922
|
-
}
|
|
1923
|
-
}
|
|
1924
|
-
}
|
|
1925
|
-
};
|
|
1926
|
-
var monitorSlice = (0, import_toolkit12.createSlice)({
|
|
1927
|
-
name: sliceName5,
|
|
1928
|
-
initialState: initialState5,
|
|
1929
|
-
reducers: {
|
|
1930
|
-
changeAlertChannel: (state, action) => {
|
|
1931
|
-
const { channel, enabled } = action.payload;
|
|
1932
|
-
state.settings.global.channels[channel] = { enabled };
|
|
1933
|
-
},
|
|
1934
|
-
receiveDeviceAlerts: (state, action) => {
|
|
1935
|
-
const { deviceId, alerts } = action.payload;
|
|
1936
|
-
state.alerts.byDeviceId[deviceId] = { alerts };
|
|
1937
|
-
},
|
|
1938
|
-
receiveLatestDeviceAlerts: (state, action) => {
|
|
1939
|
-
const { deviceId, alerts } = action.payload;
|
|
1940
|
-
state.alerts.byDeviceId[deviceId] = { ...state.alerts.byDeviceId[deviceId], latest: alerts };
|
|
1941
|
-
},
|
|
1942
|
-
receiveDeviceIssueCounts: (state, action) => {
|
|
1943
|
-
const { issueType, counts } = action.payload;
|
|
1944
|
-
state.issueCounts.byType[issueType] = counts;
|
|
1945
|
-
},
|
|
1946
|
-
setAlertListState: (state, action) => {
|
|
1947
|
-
state.alerts.alertList = { ...state.alerts.alertList, ...action.payload };
|
|
1948
|
-
}
|
|
1949
|
-
}
|
|
1950
|
-
});
|
|
1951
|
-
var actions5 = monitorSlice.actions;
|
|
1952
|
-
var monitorSlice_default = monitorSlice.reducer;
|
|
1953
|
-
|
|
1954
|
-
// src/organizationSlice/index.ts
|
|
1955
|
-
var import_toolkit13 = require("@reduxjs/toolkit");
|
|
1956
|
-
var sliceName6 = "organization";
|
|
1957
|
-
var initialState6 = {
|
|
1958
|
-
card: {
|
|
1959
|
-
last4: "",
|
|
1960
|
-
expiration: { month: 1, year: 2020 },
|
|
1961
|
-
brand: ""
|
|
1962
|
-
},
|
|
1963
|
-
intentId: null,
|
|
1964
|
-
tenantList: {
|
|
1965
|
-
...TENANT_LIST_DEFAULT,
|
|
1966
|
-
total: 0,
|
|
1967
|
-
tenants: [],
|
|
1968
|
-
selectedTenant: null,
|
|
1969
|
-
sort: {
|
|
1970
|
-
direction: import_constants5.SORTING_OPTIONS.desc,
|
|
1971
|
-
key: "name"
|
|
1972
|
-
}
|
|
1973
|
-
},
|
|
1974
|
-
organization: {
|
|
1975
|
-
// id, name, status, tenant_token, plan
|
|
1976
|
-
},
|
|
1977
|
-
auditlog: {
|
|
1978
|
-
events: [],
|
|
1979
|
-
selectionState: {
|
|
1980
|
-
...import_constants5.DEVICE_LIST_DEFAULTS,
|
|
1981
|
-
detail: void 0,
|
|
1982
|
-
endDate: void 0,
|
|
1983
|
-
selectedIssue: void 0,
|
|
1984
|
-
sort: { direction: import_constants5.SORTING_OPTIONS.desc },
|
|
1985
|
-
startDate: void 0,
|
|
1986
|
-
total: 0,
|
|
1987
|
-
type: void 0,
|
|
1988
|
-
user: void 0,
|
|
1989
|
-
isLoading: false
|
|
1990
|
-
}
|
|
1991
|
-
},
|
|
1992
|
-
externalDeviceIntegrations: [
|
|
1993
|
-
// { <connection_string|x509|...>, id, provider }
|
|
1994
|
-
],
|
|
1995
|
-
ssoConfigs: [],
|
|
1996
|
-
webhooks: {
|
|
1997
|
-
// [id]: { events: [] }
|
|
1998
|
-
// for now:
|
|
1999
|
-
events: [],
|
|
2000
|
-
eventsTotal: 0
|
|
2001
|
-
}
|
|
2002
|
-
};
|
|
2003
|
-
var organizationSlice = (0, import_toolkit13.createSlice)({
|
|
2004
|
-
name: sliceName6,
|
|
2005
|
-
initialState: initialState6,
|
|
2006
|
-
reducers: {
|
|
2007
|
-
receiveAuditLogs: (state, action) => {
|
|
2008
|
-
const { events, total } = action.payload;
|
|
2009
|
-
state.auditlog.events = events;
|
|
2010
|
-
state.auditlog.selectionState.total = total;
|
|
2011
|
-
},
|
|
2012
|
-
setAuditLogState: (state, action) => {
|
|
2013
|
-
state.auditlog.selectionState = {
|
|
2014
|
-
...state.auditlog.selectionState,
|
|
2015
|
-
...action.payload
|
|
2016
|
-
};
|
|
2017
|
-
},
|
|
2018
|
-
receiveCurrentCard: (state, action) => {
|
|
2019
|
-
state.card = action.payload;
|
|
2020
|
-
},
|
|
2021
|
-
receiveSetupIntent: (state, action) => {
|
|
2022
|
-
state.intentId = action.payload;
|
|
2023
|
-
},
|
|
2024
|
-
setOrganization: (state, action) => {
|
|
2025
|
-
state.organization = { ...state.organization, ...action.payload };
|
|
2026
|
-
},
|
|
2027
|
-
setSubscription: (state, action) => {
|
|
2028
|
-
state.organization.subscription = { ...state.organization.subscription, ...action.payload };
|
|
2029
|
-
},
|
|
2030
|
-
setProducts: (state, action) => {
|
|
2031
|
-
state.products = action.payload;
|
|
2032
|
-
},
|
|
2033
|
-
setBillingProfile: (state, action) => {
|
|
2034
|
-
state.organization.billing_profile = action.payload;
|
|
2035
|
-
},
|
|
2036
|
-
setTenantListState: (state, action) => {
|
|
2037
|
-
state.tenantList = action.payload;
|
|
2038
|
-
},
|
|
2039
|
-
receiveExternalDeviceIntegrations: (state, action) => {
|
|
2040
|
-
state.externalDeviceIntegrations = action.payload;
|
|
2041
|
-
},
|
|
2042
|
-
receiveSsoConfigs: (state, action) => {
|
|
2043
|
-
state.ssoConfigs = action.payload;
|
|
2044
|
-
},
|
|
2045
|
-
receiveWebhookEvents: (state, action) => {
|
|
2046
|
-
const { value, total } = action.payload;
|
|
2047
|
-
state.webhooks.events = value;
|
|
2048
|
-
state.webhooks.eventsTotal = total;
|
|
2049
|
-
}
|
|
2050
|
-
}
|
|
2051
|
-
});
|
|
2052
|
-
var actions6 = organizationSlice.actions;
|
|
2053
|
-
var organizationSlice_default = organizationSlice.reducer;
|
|
2054
|
-
|
|
2055
|
-
// src/releasesSlice/index.ts
|
|
2056
|
-
var import_toolkit14 = require("@reduxjs/toolkit");
|
|
2057
|
-
var sliceName7 = "releases";
|
|
2058
|
-
var initialState7 = {
|
|
2059
|
-
/*
|
|
2060
|
-
* Return list of saved artifacts objects
|
|
2061
|
-
*/
|
|
2062
|
-
/*
|
|
2063
|
-
* return list of artifacts where duplicate names are collated with device compatibility lists combined
|
|
2064
|
-
*/
|
|
2065
|
-
// artifacts: AppStore.getCollatedArtifacts(AppStore.getArtifactsRepo()),
|
|
2066
|
-
artifacts: [],
|
|
2067
|
-
/*
|
|
2068
|
-
* Return list of saved release objects
|
|
2069
|
-
*/
|
|
2070
|
-
byId: {
|
|
2071
|
-
/*
|
|
2072
|
-
[releaseName]: {
|
|
2073
|
-
artifacts: [
|
|
2074
|
-
{
|
|
2075
|
-
id: '',
|
|
2076
|
-
name: '',
|
|
2077
|
-
description: '',
|
|
2078
|
-
device_types_compatible: [],
|
|
2079
|
-
...
|
|
2080
|
-
updates: [{
|
|
2081
|
-
files: [
|
|
2082
|
-
{ size: 123, name: '' }
|
|
2083
|
-
],
|
|
2084
|
-
type_info: { type: '' }
|
|
2085
|
-
}],
|
|
2086
|
-
url: '' // optional
|
|
2087
|
-
}
|
|
2088
|
-
],
|
|
2089
|
-
modified: ''
|
|
2090
|
-
device_types_compatible,
|
|
2091
|
-
name: '',
|
|
2092
|
-
tags: ['something'],
|
|
2093
|
-
notes: ''
|
|
2094
|
-
}
|
|
2095
|
-
*/
|
|
2096
|
-
},
|
|
2097
|
-
deltaJobs: {
|
|
2098
|
-
/*
|
|
2099
|
-
[jobId]: {
|
|
2100
|
-
id: '',
|
|
2101
|
-
...
|
|
2102
|
-
}
|
|
2103
|
-
*/
|
|
2104
|
-
},
|
|
2105
|
-
deltaJobsList: {
|
|
2106
|
-
...import_constants5.DEVICE_LIST_DEFAULTS,
|
|
2107
|
-
jobIds: [],
|
|
2108
|
-
total: 0,
|
|
2109
|
-
sort: {
|
|
2110
|
-
direction: import_constants5.SORTING_OPTIONS.desc,
|
|
2111
|
-
key: "started"
|
|
2112
|
-
}
|
|
2113
|
-
},
|
|
2114
|
-
releasesList: {
|
|
2115
|
-
...import_constants5.DEVICE_LIST_DEFAULTS,
|
|
2116
|
-
searchedIds: [],
|
|
2117
|
-
releaseIds: [],
|
|
2118
|
-
selection: [],
|
|
2119
|
-
sort: {
|
|
2120
|
-
direction: import_constants5.SORTING_OPTIONS.desc,
|
|
2121
|
-
key: "modified"
|
|
2122
|
-
},
|
|
2123
|
-
isLoading: void 0,
|
|
2124
|
-
searchTerm: "",
|
|
2125
|
-
searchTotal: 0,
|
|
2126
|
-
selectedTags: [],
|
|
2127
|
-
total: 0,
|
|
2128
|
-
type: ""
|
|
2129
|
-
},
|
|
2130
|
-
tags: [],
|
|
2131
|
-
updateTypes: [],
|
|
2132
|
-
selectedJob: null,
|
|
2133
|
-
/*
|
|
2134
|
-
* Return single release with corresponding Artifacts
|
|
2135
|
-
*/
|
|
2136
|
-
selectedRelease: null
|
|
2137
|
-
};
|
|
2138
|
-
var releaseSlice = (0, import_toolkit14.createSlice)({
|
|
2139
|
-
name: sliceName7,
|
|
2140
|
-
initialState: initialState7,
|
|
2141
|
-
reducers: {
|
|
2142
|
-
receiveRelease: (state, action) => {
|
|
2143
|
-
const { name } = action.payload;
|
|
2144
|
-
state.byId[name] = action.payload;
|
|
2145
|
-
},
|
|
2146
|
-
receiveReleases: (state, action) => {
|
|
2147
|
-
state.byId = action.payload;
|
|
2148
|
-
},
|
|
2149
|
-
receiveReleaseTags: (state, action) => {
|
|
2150
|
-
state.tags = action.payload;
|
|
2151
|
-
},
|
|
2152
|
-
receiveReleaseTypes: (state, action) => {
|
|
2153
|
-
state.updateTypes = action.payload;
|
|
2154
|
-
},
|
|
2155
|
-
removeRelease: (state, action) => {
|
|
2156
|
-
const { [action.payload]: toBeRemoved, ...byId } = state.byId;
|
|
2157
|
-
state.byId = byId;
|
|
2158
|
-
state.selectedRelease = action.payload === state.selectedRelease ? null : state.selectedRelease;
|
|
2159
|
-
},
|
|
2160
|
-
selectedRelease: (state, action) => {
|
|
2161
|
-
state.selectedRelease = action.payload;
|
|
2162
|
-
},
|
|
2163
|
-
setReleaseListState: (state, action) => {
|
|
2164
|
-
state.releasesList = action.payload;
|
|
2165
|
-
},
|
|
2166
|
-
receivedDeltaJobs: (state, action) => {
|
|
2167
|
-
const { jobs, total } = action.payload;
|
|
2168
|
-
state.deltaJobs = jobs.reduce(
|
|
2169
|
-
(accu, job) => {
|
|
2170
|
-
accu[job.id] = {
|
|
2171
|
-
...accu[job.id],
|
|
2172
|
-
...job
|
|
2173
|
-
};
|
|
2174
|
-
return accu;
|
|
2175
|
-
},
|
|
2176
|
-
{ ...state.deltaJobs }
|
|
2177
|
-
);
|
|
2178
|
-
state.deltaJobsList.jobIds = jobs.map((job) => job.id);
|
|
2179
|
-
state.deltaJobsList.total = total;
|
|
2180
|
-
},
|
|
2181
|
-
receivedDeltaJobDetails: (state, action) => {
|
|
2182
|
-
const job = action.payload;
|
|
2183
|
-
state.deltaJobs[job.id] = {
|
|
2184
|
-
...state.deltaJobs[job.id],
|
|
2185
|
-
...job
|
|
2186
|
-
};
|
|
2187
|
-
},
|
|
2188
|
-
setDeltaJobsListState: (state, action) => {
|
|
2189
|
-
state.deltaJobsList = { ...state.deltaJobsList, ...action.payload };
|
|
2190
|
-
},
|
|
2191
|
-
setSelectedJob: (state, action) => {
|
|
2192
|
-
state.selectedJob = action.payload;
|
|
2193
|
-
}
|
|
2194
|
-
}
|
|
2195
|
-
});
|
|
2196
|
-
var actions7 = releaseSlice.actions;
|
|
2197
|
-
var releasesSlice_default = releaseSlice.reducer;
|
|
2198
|
-
|
|
2199
|
-
// src/usersSlice/index.ts
|
|
2200
|
-
var import_toolkit15 = require("@reduxjs/toolkit");
|
|
2201
|
-
var sliceName8 = "users";
|
|
2202
|
-
var initialState8 = {
|
|
2203
|
-
byId: {},
|
|
2204
|
-
currentUser: null,
|
|
2205
|
-
currentSession: {
|
|
2206
|
-
// { token: window.localStorage.getItem('JWT'), expiresAt: '2023-01-01T00:15:00.000Z' | undefined }, // expiresAt depending on the stay logged in setting
|
|
2207
|
-
},
|
|
2208
|
-
customColumns: [],
|
|
2209
|
-
qrCode: null,
|
|
2210
|
-
globalSettings: {
|
|
2211
|
-
id_attribute: void 0,
|
|
2212
|
-
previousFilters: [],
|
|
2213
|
-
previousPhases: [],
|
|
2214
|
-
retries: 0
|
|
2215
|
-
},
|
|
2216
|
-
permissionSetsById: {
|
|
2217
|
-
...import_constants5.defaultPermissionSets
|
|
2218
|
-
},
|
|
2219
|
-
rolesById: {
|
|
2220
|
-
...import_constants5.rolesById
|
|
2221
|
-
},
|
|
2222
|
-
rolesInitialized: false,
|
|
2223
|
-
settingsInitialized: false,
|
|
2224
|
-
showConnectDeviceDialog: false,
|
|
2225
|
-
showFeedbackDialog: false,
|
|
2226
|
-
showStartupNotification: false,
|
|
2227
|
-
tooltips: {
|
|
2228
|
-
byId: {
|
|
2229
|
-
// <id>: { readState: <read|unread> } // this object is getting enhanced by the tooltip texts in the app constants
|
|
2230
|
-
}
|
|
2231
|
-
},
|
|
2232
|
-
userSettings: {
|
|
2233
|
-
columnSelection: [],
|
|
2234
|
-
onboarding: {},
|
|
2235
|
-
firstLoginTimestamp: null,
|
|
2236
|
-
securityAlertDismissedTimestamp: null
|
|
2237
|
-
},
|
|
2238
|
-
userSettingsInitialized: false
|
|
2239
|
-
};
|
|
2240
|
-
var usersSlice = (0, import_toolkit15.createSlice)({
|
|
2241
|
-
name: sliceName8,
|
|
2242
|
-
initialState: initialState8,
|
|
2243
|
-
reducers: {
|
|
2244
|
-
receivedQrCode: (state, action) => {
|
|
2245
|
-
state.qrCode = action.payload;
|
|
2246
|
-
},
|
|
2247
|
-
successfullyLoggedIn: (state, action) => {
|
|
2248
|
-
state.currentSession = action.payload;
|
|
2249
|
-
},
|
|
2250
|
-
receivedUserList: (state, action) => {
|
|
2251
|
-
state.byId = action.payload;
|
|
2252
|
-
},
|
|
2253
|
-
receivedUser: (state, action) => {
|
|
2254
|
-
state.byId[action.payload.id] = action.payload;
|
|
2255
|
-
state.currentUser = action.payload.id;
|
|
2256
|
-
},
|
|
2257
|
-
removedUser: (state, action) => {
|
|
2258
|
-
const { [action.payload]: removedUser, ...byId } = state.byId;
|
|
2259
|
-
state.byId = byId;
|
|
2260
|
-
state.currentUser = state.currentUser === action.payload ? null : state.currentUser;
|
|
2261
|
-
},
|
|
2262
|
-
updatedUser: (state, action) => {
|
|
2263
|
-
state.byId[action.payload.id] = {
|
|
2264
|
-
...state.byId[action.payload.id],
|
|
2265
|
-
...action.payload
|
|
2266
|
-
};
|
|
2267
|
-
},
|
|
2268
|
-
receivedPermissionSets: (state, action) => {
|
|
2269
|
-
state.permissionSetsById = action.payload;
|
|
2270
|
-
},
|
|
2271
|
-
receivedRoles: (state, action) => {
|
|
2272
|
-
state.rolesById = action.payload;
|
|
2273
|
-
state.rolesInitialized = true;
|
|
2274
|
-
},
|
|
2275
|
-
finishedRoleInitialization: (state, action) => {
|
|
2276
|
-
state.rolesInitialized = action.payload;
|
|
2277
|
-
},
|
|
2278
|
-
createdRole: (state, action) => {
|
|
2279
|
-
state.rolesById[action.payload.name] = {
|
|
2280
|
-
...state.rolesById[action.payload.name],
|
|
2281
|
-
...action.payload
|
|
2282
|
-
};
|
|
2283
|
-
},
|
|
2284
|
-
removedRole: (state, action) => {
|
|
2285
|
-
const { [action.payload]: toBeRemoved, ...rolesById2 } = state.rolesById;
|
|
2286
|
-
state.rolesById = rolesById2;
|
|
2287
|
-
},
|
|
2288
|
-
setCustomColumns: (state, action) => {
|
|
2289
|
-
state.customColumns = action.payload;
|
|
2290
|
-
},
|
|
2291
|
-
setGlobalSettings: (state, action) => {
|
|
2292
|
-
state.settingsInitialized = true;
|
|
2293
|
-
state.globalSettings = {
|
|
2294
|
-
...state.globalSettings,
|
|
2295
|
-
...action.payload
|
|
2296
|
-
};
|
|
2297
|
-
},
|
|
2298
|
-
setUserSettings: (state, action) => {
|
|
2299
|
-
state.userSettingsInitialized = true;
|
|
2300
|
-
state.userSettings = {
|
|
2301
|
-
...state.userSettings,
|
|
2302
|
-
...action.payload
|
|
2303
|
-
};
|
|
2304
|
-
},
|
|
2305
|
-
setTooltipState: (state, action) => {
|
|
2306
|
-
const { id, readState = READ_STATES.read } = action.payload;
|
|
2307
|
-
state.tooltips.byId[id] = { ...state.tooltips.byId[id], readState };
|
|
2308
|
-
},
|
|
2309
|
-
setTooltipsState: (state, action) => {
|
|
2310
|
-
state.tooltips.byId = {
|
|
2311
|
-
...state.tooltips.byId,
|
|
2312
|
-
...action.payload
|
|
2313
|
-
};
|
|
2314
|
-
},
|
|
2315
|
-
setShowFeedbackDialog: (state, action) => {
|
|
2316
|
-
state.showFeedbackDialog = action.payload;
|
|
2317
|
-
},
|
|
2318
|
-
setShowConnectingDialog: (state, action) => {
|
|
2319
|
-
state.showConnectDeviceDialog = action.payload;
|
|
2320
|
-
},
|
|
2321
|
-
setShowStartupNotification: (state, action) => {
|
|
2322
|
-
state.showStartupNotification = action.payload;
|
|
2323
|
-
}
|
|
2324
|
-
}
|
|
2325
|
-
});
|
|
2326
|
-
var actions8 = usersSlice.actions;
|
|
2327
|
-
var usersSlice_default = usersSlice.reducer;
|
|
2328
|
-
|
|
2329
|
-
// src/actions.ts
|
|
2330
|
-
var actions_default = {
|
|
2331
|
-
...actions2,
|
|
2332
|
-
...actions3,
|
|
2333
|
-
...actions4,
|
|
2334
|
-
...actions5,
|
|
2335
|
-
...actions,
|
|
2336
|
-
...actions6,
|
|
2337
|
-
...actions7,
|
|
2338
|
-
...actions8
|
|
2339
|
-
};
|
|
2340
|
-
|
|
2341
|
-
// src/auth.ts
|
|
2342
|
-
var import_universal_cookie = __toESM(require("universal-cookie"), 1);
|
|
2343
|
-
var cookies = new import_universal_cookie.default();
|
|
2344
|
-
var emptySession = Object.freeze({ token: "", expiresAt: void 0 });
|
|
2345
|
-
var tokenCache = "";
|
|
2346
|
-
var getSessionInfo = () => {
|
|
2347
|
-
let sessionInfo = { ...emptySession };
|
|
2348
|
-
try {
|
|
2349
|
-
sessionInfo = JSON.parse(window.localStorage.getItem("JWT") ?? "");
|
|
2350
|
-
} catch {
|
|
2351
|
-
}
|
|
2352
|
-
const jwtTokenFromCookie = cookies.get("JWT", { doNotParse: true }) ?? "";
|
|
2353
|
-
if (jwtTokenFromCookie) {
|
|
2354
|
-
setSessionInfo({ token: jwtTokenFromCookie });
|
|
2355
|
-
cookies.remove("JWT");
|
|
2356
|
-
cookies.remove("JWT", { path: "/" });
|
|
2357
|
-
return { token: jwtTokenFromCookie, expiresAt: void 0 };
|
|
2358
|
-
}
|
|
2359
|
-
if (sessionInfo.expiresAt && new Date(sessionInfo.expiresAt) < /* @__PURE__ */ new Date()) {
|
|
2360
|
-
cleanUp();
|
|
2361
|
-
return { ...emptySession };
|
|
2362
|
-
}
|
|
2363
|
-
sessionInfo.token = sessionInfo.token || "";
|
|
2364
|
-
tokenCache = sessionInfo.token;
|
|
2365
|
-
return sessionInfo;
|
|
2366
|
-
};
|
|
2367
|
-
var getToken = () => tokenCache ? tokenCache : getSessionInfo().token;
|
|
2368
|
-
var setSessionInfo = ({ token, expiresAt }) => {
|
|
2369
|
-
tokenCache = token;
|
|
2370
|
-
window.localStorage.setItem("JWT", JSON.stringify({ token, expiresAt }));
|
|
2371
|
-
};
|
|
2372
|
-
var cleanUp = () => {
|
|
2373
|
-
tokenCache = "";
|
|
2374
|
-
cookies.remove("JWT");
|
|
2375
|
-
cookies.remove("JWT", { path: "/" });
|
|
2376
|
-
window.localStorage.removeItem("JWT");
|
|
2377
|
-
window.localStorage.removeItem("oauth");
|
|
2378
|
-
};
|
|
2379
|
-
|
|
2380
|
-
// src/store.ts
|
|
2381
|
-
var { setSnackbar, uploadProgress } = actions_default;
|
|
2382
|
-
var keys = ["sessionDeploymentChecker", settingsKeys.initialized];
|
|
2383
|
-
var resetEnvironment = () => keys.forEach((key) => window.sessionStorage.removeItem(key));
|
|
2384
|
-
resetEnvironment();
|
|
2385
|
-
var commonErrorFallback = "Please check your connection.";
|
|
2386
|
-
var commonErrorHandler = (err, errorContext, dispatch, fallback, mightBeAuthRelated = false) => {
|
|
2387
|
-
const errMsg = (0, import_helpers6.extractErrorMessage)(err, fallback);
|
|
2388
|
-
if (mightBeAuthRelated || getToken()) {
|
|
2389
|
-
dispatch(setSnackbar({ message: (0, import_helpers6.preformatWithRequestID)(err.response, `${errorContext} ${errMsg}`), action: "Copy to clipboard" }));
|
|
2390
|
-
}
|
|
2391
|
-
return Promise.reject(err);
|
|
2392
|
-
};
|
|
2393
|
-
var rootReducer = (0, import_toolkit16.combineReducers)({
|
|
2394
|
-
app: appSlice_default,
|
|
2395
|
-
devices: devicesSlice_default,
|
|
2396
|
-
deployments: deploymentsSlice_default,
|
|
2397
|
-
monitor: monitorSlice_default,
|
|
2398
|
-
onboarding: onboardingSlice_default,
|
|
2399
|
-
organization: organizationSlice_default,
|
|
2400
|
-
releases: releasesSlice_default,
|
|
2401
|
-
users: usersSlice_default
|
|
2402
|
-
});
|
|
2403
|
-
var sessionReducer = (state, action) => {
|
|
2404
|
-
if (action.type === USER_LOGOUT) {
|
|
2405
|
-
state = void 0;
|
|
2406
|
-
}
|
|
2407
|
-
return rootReducer(state, action);
|
|
2408
|
-
};
|
|
2409
|
-
var rejectionLoggerMiddleware = () => (next) => (action) => {
|
|
2410
|
-
if (action.type.endsWith("/rejected")) {
|
|
2411
|
-
const { error } = action;
|
|
2412
|
-
console.error("Rejection in action:", action);
|
|
2413
|
-
console.error(error.stack);
|
|
2414
|
-
}
|
|
2415
|
-
return next(action);
|
|
2416
|
-
};
|
|
2417
|
-
var tracingActionIgnoreList = [actions8.successfullyLoggedIn.type, "users/loginUser/pending", "users/loginUser/fulfilled", "users/loginUser/rejected"];
|
|
2418
|
-
var sentryReduxEnhancer = (0, import_react.createReduxEnhancer)({
|
|
2419
|
-
actionTransformer: (action) => {
|
|
2420
|
-
if (tracingActionIgnoreList.includes(action.type)) {
|
|
2421
|
-
return null;
|
|
2422
|
-
}
|
|
2423
|
-
return action;
|
|
2424
|
-
},
|
|
2425
|
-
// Transform the state to remove sensitive information
|
|
2426
|
-
stateTransformer: (state) => {
|
|
2427
|
-
const transformedState = {
|
|
2428
|
-
...state,
|
|
2429
|
-
users: { ...state.users, currentSession: null },
|
|
2430
|
-
organization: {
|
|
2431
|
-
...state.organization,
|
|
2432
|
-
organization: {
|
|
2433
|
-
...state.organization.organization,
|
|
2434
|
-
tenant_token: null
|
|
2435
|
-
}
|
|
2436
|
-
}
|
|
2437
|
-
};
|
|
2438
|
-
return transformedState;
|
|
2439
|
-
}
|
|
2440
|
-
});
|
|
2441
|
-
var getConfiguredStore = (options = {}) => {
|
|
2442
|
-
const { preloadedState = {}, ...config } = options;
|
|
2443
|
-
return (0, import_toolkit16.configureStore)({
|
|
2444
|
-
...config,
|
|
2445
|
-
preloadedState,
|
|
2446
|
-
enhancers: (getDefaultEnhancers) => {
|
|
2447
|
-
if (window.mender_environment?.sentry?.isReduxEnabled) {
|
|
2448
|
-
return getDefaultEnhancers().concat(sentryReduxEnhancer);
|
|
2449
|
-
}
|
|
2450
|
-
return getDefaultEnhancers();
|
|
2451
|
-
},
|
|
2452
|
-
reducer: sessionReducer,
|
|
2453
|
-
middleware: (getDefaultMiddleware) => getDefaultMiddleware({
|
|
2454
|
-
immutableCheck: {
|
|
2455
|
-
ignoredPaths: ["app.uploadsById"]
|
|
2456
|
-
},
|
|
2457
|
-
serializableCheck: {
|
|
2458
|
-
ignoredActions: [actions6.receiveExternalDeviceIntegrations.name, uploadProgress.name],
|
|
2459
|
-
ignoredActionPaths: ["uploads", /payload\..*$/, "meta.arg.file", "meta.arg.integration.configHint"],
|
|
2460
|
-
ignoredPaths: ["app.uploadsById", "organization.externalDeviceIntegrations"]
|
|
2461
|
-
}
|
|
2462
|
-
}).concat(rejectionLoggerMiddleware)
|
|
2463
|
-
});
|
|
2464
|
-
};
|
|
2465
|
-
var store = getConfiguredStore({
|
|
2466
|
-
preloadedState: {}
|
|
2467
|
-
});
|
|
2468
|
-
var createAppAsyncThunk = import_toolkit16.createAsyncThunk.withTypes();
|
|
2469
|
-
|
|
2470
|
-
// src/appSlice/thunks.ts
|
|
2471
|
-
var import_helpers7 = require("@northern.tech/utils/helpers");
|
|
2472
|
-
var import_universal_cookie3 = __toESM(require("universal-cookie"), 1);
|
|
2473
|
-
|
|
2474
|
-
// src/api/general-api.ts
|
|
2475
|
-
var import_axios = __toESM(require("axios"), 1);
|
|
2476
|
-
var import_universal_cookie2 = __toESM(require("universal-cookie"), 1);
|
|
2477
|
-
var cookies2 = new import_universal_cookie2.default();
|
|
2478
|
-
var unauthorizedRedirect = (error) => {
|
|
2479
|
-
if (!(0, import_axios.isCancel)(error) && error.response?.status === 401 && getToken() && !window.location.pathname.endsWith("/subscription")) {
|
|
2480
|
-
if (cookies2.get("JWT", { doNotParse: true })) {
|
|
2481
|
-
window.location.reload();
|
|
2482
|
-
return Promise.reject(error);
|
|
2483
|
-
}
|
|
2484
|
-
cleanUp();
|
|
2485
|
-
window.location.replace("/ui/");
|
|
2486
|
-
}
|
|
2487
|
-
return Promise.reject(error);
|
|
2488
|
-
};
|
|
2489
|
-
var commonRequestConfig = { timeout: TIMEOUTS.refreshDefault, headers: { "Content-Type": "application/json" } };
|
|
2490
|
-
var authenticatedRequest = import_axios.default.create(commonRequestConfig);
|
|
2491
|
-
authenticatedRequest.interceptors.response.use((res) => res, unauthorizedRedirect);
|
|
2492
|
-
authenticatedRequest.interceptors.request.use(
|
|
2493
|
-
(config) => ({ ...config, headers: { ...config.headers, Authorization: `Bearer ${getToken()}` } }),
|
|
2494
|
-
(error) => Promise.reject(error)
|
|
2495
|
-
);
|
|
2496
|
-
var Api = {
|
|
2497
|
-
get: authenticatedRequest.get,
|
|
2498
|
-
delete: (url, data) => authenticatedRequest.request({ method: "delete", url, data }),
|
|
2499
|
-
patch: authenticatedRequest.patch,
|
|
2500
|
-
post: authenticatedRequest.post,
|
|
2501
|
-
postUnauthorized: (url, data, config = {}) => import_axios.default.post(url, data, { ...commonRequestConfig, ...config }),
|
|
2502
|
-
put: authenticatedRequest.put,
|
|
2503
|
-
upload: (url, formData, progress2, cancelSignal) => authenticatedRequest.post(url, formData, {
|
|
2504
|
-
headers: { "Content-Type": "multipart/form-data" },
|
|
2505
|
-
onUploadProgress: progress2,
|
|
2506
|
-
timeout: 0,
|
|
2507
|
-
signal: cancelSignal
|
|
2508
|
-
}),
|
|
2509
|
-
uploadPut: (url, formData, progress2, cancelSignal) => authenticatedRequest.put(url, formData, {
|
|
2510
|
-
headers: { "Content-Type": "multipart/form-data" },
|
|
2511
|
-
onUploadProgress: progress2,
|
|
2512
|
-
timeout: 0,
|
|
2513
|
-
signal: cancelSignal
|
|
2514
|
-
})
|
|
2515
|
-
};
|
|
2516
|
-
var general_api_default = Api;
|
|
2517
|
-
|
|
2518
|
-
// src/appSlice/thunks.ts
|
|
2519
|
-
var cookies3 = new import_universal_cookie3.default();
|
|
2520
|
-
var setFirstLoginAfterSignup = createAppAsyncThunk(`${sliceName2}/setFirstLoginAfterSignup`, (firstLoginAfterSignup, { dispatch }) => {
|
|
2521
|
-
cookies3.set("firstLoginAfterSignup", !!firstLoginAfterSignup, { maxAge: 60, path: "/", domain: ".mender.io", sameSite: false });
|
|
2522
|
-
dispatch(actions2.setFirstLoginAfterSignup(!!firstLoginAfterSignup));
|
|
2523
|
-
});
|
|
2524
|
-
var dateFunctionMap = {
|
|
2525
|
-
getDays: "getDate",
|
|
2526
|
-
setDays: "setDate"
|
|
2527
|
-
};
|
|
2528
|
-
var setOfflineThreshold = createAppAsyncThunk(`${sliceName2}/setOfflineThreshold`, (_, { dispatch, getState }) => {
|
|
2529
|
-
const { interval, intervalUnit } = getOfflineThresholdSettings(getState());
|
|
2530
|
-
const today = /* @__PURE__ */ new Date();
|
|
2531
|
-
const intervalName = `${intervalUnit.charAt(0).toUpperCase()}${intervalUnit.substring(1)}`;
|
|
2532
|
-
const setter = dateFunctionMap[`set${intervalName}`] ?? `set${intervalName}`;
|
|
2533
|
-
const getter = dateFunctionMap[`get${intervalName}`] ?? `get${intervalName}`;
|
|
2534
|
-
today[setter](today[getter]() - interval);
|
|
2535
|
-
let value;
|
|
2536
|
-
try {
|
|
2537
|
-
value = today.toISOString();
|
|
2538
|
-
} catch {
|
|
2539
|
-
return Promise.resolve(dispatch(actions2.setSnackbar("There was an error saving the offline threshold, please check your settings.")));
|
|
2540
|
-
}
|
|
2541
|
-
return Promise.resolve(dispatch(actions2.setOfflineThreshold(value)));
|
|
2542
|
-
});
|
|
2543
|
-
var versionRegex = new RegExp(/\d+\.\d+/);
|
|
2544
|
-
var getLatestRelease = (thing) => {
|
|
2545
|
-
const latestKey = Object.keys(thing).filter((key) => versionRegex.test(key)).sort().reverse()[0];
|
|
2546
|
-
return thing[latestKey];
|
|
2547
|
-
};
|
|
2548
|
-
var repoKeyMap = {
|
|
2549
|
-
integration: "Integration",
|
|
2550
|
-
"mender-artifact": "Mender-Artifact"
|
|
2551
|
-
};
|
|
2552
|
-
var deductSaasState = (latestRelease, guiTags) => {
|
|
2553
|
-
const latestGuiTag = guiTags.length ? guiTags[0].name : "";
|
|
2554
|
-
return latestGuiTag ? latestGuiTag : latestRelease.release;
|
|
2555
|
-
};
|
|
2556
|
-
var getLatestReleaseInfo = createAppAsyncThunk(`${sliceName2}/getLatestReleaseInfo`, (_, { dispatch, getState }) => {
|
|
2557
|
-
if (!getFeatures(getState()).isHosted) {
|
|
2558
|
-
return Promise.resolve();
|
|
2559
|
-
}
|
|
2560
|
-
return Promise.all([general_api_default.get("/versions.json"), general_api_default.get("/tags.json")]).catch((err) => {
|
|
2561
|
-
console.log("init error:", (0, import_helpers7.extractErrorMessage)(err));
|
|
2562
|
-
return Promise.resolve([{ data: {} }, { data: [] }]);
|
|
2563
|
-
}).then(([{ data }, { data: guiTags }]) => {
|
|
2564
|
-
if (!guiTags.length) {
|
|
2565
|
-
return Promise.resolve();
|
|
2566
|
-
}
|
|
2567
|
-
const { releases } = data;
|
|
2568
|
-
const latestRelease = getLatestRelease(getLatestRelease(releases));
|
|
2569
|
-
const { latestRepos, latestVersions } = latestRelease.repos.reduce(
|
|
2570
|
-
(accu, item) => {
|
|
2571
|
-
if (repoKeyMap[item.name]) {
|
|
2572
|
-
accu.latestVersions[repoKeyMap[item.name]] = getComparisonCompatibleVersion(item.version);
|
|
2573
|
-
}
|
|
2574
|
-
accu.latestRepos[item.name] = getComparisonCompatibleVersion(item.version);
|
|
2575
|
-
return accu;
|
|
2576
|
-
},
|
|
2577
|
-
{ latestVersions: { ...getState().app.versionInformation }, latestRepos: {} }
|
|
2578
|
-
);
|
|
2579
|
-
const info = deductSaasState(latestRelease, guiTags);
|
|
2580
|
-
return Promise.resolve(
|
|
2581
|
-
dispatch(
|
|
2582
|
-
actions2.setVersionInformation({
|
|
2583
|
-
...latestVersions,
|
|
2584
|
-
Server: info,
|
|
2585
|
-
latestRelease: {
|
|
2586
|
-
releaseDate: latestRelease.release_date,
|
|
2587
|
-
repos: latestRepos
|
|
2588
|
-
}
|
|
2589
|
-
})
|
|
2590
|
-
)
|
|
2591
|
-
);
|
|
2592
|
-
});
|
|
2593
|
-
});
|
|
2594
|
-
var setSearchState = createAppAsyncThunk(`${sliceName2}/setSearchState`, (searchState, { dispatch, getState }) => {
|
|
2595
|
-
const currentState = getSearchState(getState());
|
|
2596
|
-
const nextState = {
|
|
2597
|
-
...currentState,
|
|
2598
|
-
...searchState,
|
|
2599
|
-
sort: {
|
|
2600
|
-
...currentState.sort,
|
|
2601
|
-
...searchState.sort
|
|
2602
|
-
}
|
|
2603
|
-
};
|
|
2604
|
-
const tasks = [];
|
|
2605
|
-
const { isSearching: currentSearching, deviceIds: currentDevices, searchTotal: currentTotal, ...currentRequestState } = currentState;
|
|
2606
|
-
const { isSearching: nextSearching, deviceIds: nextDevices, searchTotal: nextTotal, ...nextRequestState } = nextState;
|
|
2607
|
-
if (nextRequestState.searchTerm && !(0, import_helpers7.deepCompare)(currentRequestState, nextRequestState)) {
|
|
2608
|
-
nextState.isSearching = true;
|
|
2609
|
-
tasks.push(
|
|
2610
|
-
dispatch(searchDevices(nextState)).unwrap().then((results) => {
|
|
2611
|
-
const searchResult = results[results.length - 1];
|
|
2612
|
-
return dispatch(actions2.setSearchState({ ...searchResult, isSearching: false }));
|
|
2613
|
-
}).catch(() => dispatch(actions2.setSearchState({ isSearching: false, searchTotal: 0 })))
|
|
2614
|
-
);
|
|
2615
|
-
}
|
|
2616
|
-
tasks.push(dispatch(actions2.setSearchState(nextState)));
|
|
2617
|
-
return Promise.all(tasks);
|
|
2618
|
-
});
|
|
2619
|
-
|
|
2620
|
-
// src/deploymentsSlice/thunks.ts
|
|
2621
|
-
var import_helpers8 = require("@northern.tech/utils/helpers");
|
|
2622
|
-
var import_tracking = __toESM(require("@northern.tech/utils/tracking"), 1);
|
|
2623
|
-
var import_validator = __toESM(require("validator"), 1);
|
|
2624
|
-
var { isUUID } = import_validator.default;
|
|
2625
|
-
var { receivedDevice, setSnackbar: setSnackbar2 } = actions_default;
|
|
2626
|
-
var { page: defaultPage, perPage: defaultPerPage } = import_constants5.DEVICE_LIST_DEFAULTS;
|
|
2627
|
-
var deriveDeploymentGroup = ({ filter, group, groups = [], name }) => group || groups.length === 1 && !isUUID(name) ? groups[0] : filter?.name;
|
|
2628
|
-
var transformDeployments = (deployments, deploymentsById) => deployments.sort((0, import_helpers8.customSort)(true, "created")).reduce(
|
|
2629
|
-
(accu, item) => {
|
|
2630
|
-
const filter = item.filter;
|
|
2631
|
-
let deployment = {
|
|
2632
|
-
...deploymentPrototype,
|
|
2633
|
-
...deploymentsById[item.id],
|
|
2634
|
-
...item,
|
|
2635
|
-
// TODO: explicitly set filter term types to address scope type mismatch in deployment specs
|
|
2636
|
-
// @ts-expect-error: type misalignment in filter terms type
|
|
2637
|
-
filter: filter ? { ...filter, name: filter.name ?? filter.id, filters: mapTermsToFilters(filter.terms) } : void 0,
|
|
2638
|
-
name: decodeURIComponent(item.name)
|
|
2639
|
-
};
|
|
2640
|
-
deployment = { ...deployment, group: deriveDeploymentGroup(deployment) };
|
|
2641
|
-
accu.deployments[item.id] = deployment;
|
|
2642
|
-
accu.deploymentIds.push(item.id);
|
|
2643
|
-
return accu;
|
|
2644
|
-
},
|
|
2645
|
-
{ deployments: {}, deploymentIds: [] }
|
|
2646
|
-
);
|
|
2647
|
-
var getDeploymentsByStatus2 = createAppAsyncThunk(
|
|
2648
|
-
`${sliceName3}/getDeploymentsByStatus`,
|
|
2649
|
-
(options, { dispatch, getState }) => {
|
|
2650
|
-
const { status, page = defaultPage, perPage = defaultPerPage, startDate, endDate, group, type, shouldSelect = true, sort = import_constants5.SORTING_OPTIONS.desc } = options;
|
|
2651
|
-
const created_after = startDate ? `&created_after=${startDate}` : "";
|
|
2652
|
-
const created_before = endDate ? `&created_before=${endDate}` : "";
|
|
2653
|
-
const { attribute, scope } = getIdAttribute(getState());
|
|
2654
|
-
const attributeHint = `&id_attribute=${attribute}&id_scope=${scope}`;
|
|
2655
|
-
const search = group ? `&name=${group}${attributeHint}` : "";
|
|
2656
|
-
const typeFilter = type ? `&type=${type}` : "";
|
|
2657
|
-
return general_api_default.get(
|
|
2658
|
-
`${import_constants5.deploymentsApiUrlV2}/deployments?status=${status}&per_page=${perPage}&page=${page}${created_after}${created_before}${search}${typeFilter}&sort=${sort}`
|
|
2659
|
-
).then((res) => {
|
|
2660
|
-
const { deployments, deploymentIds } = transformDeployments(res.data, getState().deployments.byId);
|
|
2661
|
-
const total = Number(res.headers[import_constants5.headerNames.total]);
|
|
2662
|
-
let tasks = [
|
|
2663
|
-
dispatch(actions3.receivedDeployments(deployments)),
|
|
2664
|
-
dispatch(
|
|
2665
|
-
actions3.receivedDeploymentsForStatus({
|
|
2666
|
-
deploymentIds,
|
|
2667
|
-
status,
|
|
2668
|
-
total: !(startDate || endDate || group || type) ? total : getState().deployments.byStatus[status].total
|
|
2669
|
-
})
|
|
2670
|
-
)
|
|
2671
|
-
];
|
|
2672
|
-
tasks = deploymentIds.reduce((accu, deploymentId) => {
|
|
2673
|
-
if (deployments[deploymentId].type === DEPLOYMENT_TYPES.configuration) {
|
|
2674
|
-
accu.push(dispatch(getSingleDeployment(deploymentId)));
|
|
2675
|
-
}
|
|
2676
|
-
return accu;
|
|
2677
|
-
}, tasks);
|
|
2678
|
-
if (shouldSelect) {
|
|
2679
|
-
tasks.push(dispatch(actions3.selectDeploymentsForStatus({ deploymentIds, status, total })));
|
|
2680
|
-
}
|
|
2681
|
-
tasks.push({ deploymentIds, total });
|
|
2682
|
-
return Promise.all(tasks);
|
|
2683
|
-
});
|
|
2684
|
-
}
|
|
2685
|
-
);
|
|
2686
|
-
var isWithinFirstMonth = (expirationDate) => {
|
|
2687
|
-
if (!expirationDate) {
|
|
2688
|
-
return false;
|
|
2689
|
-
}
|
|
2690
|
-
const endOfFirstMonth = new Date(expirationDate);
|
|
2691
|
-
endOfFirstMonth.setMonth(endOfFirstMonth.getMonth() - 11);
|
|
2692
|
-
return endOfFirstMonth > /* @__PURE__ */ new Date();
|
|
2693
|
-
};
|
|
2694
|
-
var trackDeploymentCreation = (totalDeploymentCount, hasDeployments, trial_expiration) => {
|
|
2695
|
-
import_tracking.default.event({ category: "deployments", action: "create" });
|
|
2696
|
-
if (!totalDeploymentCount) {
|
|
2697
|
-
if (!hasDeployments) {
|
|
2698
|
-
import_tracking.default.event({ category: "deployments", action: "create_initial_deployment" });
|
|
2699
|
-
if (isWithinFirstMonth(trial_expiration)) {
|
|
2700
|
-
import_tracking.default.event({ category: "deployments", action: "create_initial_deployment_first_month" });
|
|
2701
|
-
}
|
|
2702
|
-
}
|
|
2703
|
-
import_tracking.default.event({ category: "deployments", action: "create_initial_deployment_user" });
|
|
2704
|
-
}
|
|
2705
|
-
};
|
|
2706
|
-
var MAX_PREVIOUS_PHASES_COUNT = 5;
|
|
2707
|
-
var createDeployment = createAppAsyncThunk(
|
|
2708
|
-
`${sliceName3}/createDeployment`,
|
|
2709
|
-
({
|
|
2710
|
-
newDeployment,
|
|
2711
|
-
hasNewRetryDefault = false
|
|
2712
|
-
}, { dispatch, getState }) => {
|
|
2713
|
-
let request;
|
|
2714
|
-
if ("filter_id" in newDeployment && newDeployment.filter_id) {
|
|
2715
|
-
request = general_api_default.post(`${import_constants5.deploymentsApiUrlV2}/deployments`, newDeployment);
|
|
2716
|
-
} else if ("group" in newDeployment && newDeployment.group) {
|
|
2717
|
-
request = general_api_default.post(`${import_constants5.deploymentsApiUrl}/deployments/group/${newDeployment.group}`, newDeployment);
|
|
2718
|
-
} else {
|
|
2719
|
-
request = general_api_default.post(`${import_constants5.deploymentsApiUrl}/deployments`, newDeployment);
|
|
2720
|
-
}
|
|
2721
|
-
const totalDeploymentCount = Object.values(getDeploymentsByStatus(getState())).reduce(
|
|
2722
|
-
(accu, item) => accu + item.total,
|
|
2723
|
-
0
|
|
2724
|
-
);
|
|
2725
|
-
const { hasDeployments } = getGlobalSettings(getState());
|
|
2726
|
-
const { trial_expiration } = getOrganization(getState());
|
|
2727
|
-
return request.catch((err) => commonErrorHandler(err, "Error creating deployment.", dispatch)).then((data) => {
|
|
2728
|
-
const lastslashindex = data.headers.location.lastIndexOf("/");
|
|
2729
|
-
const deploymentId = data.headers.location.substring(lastslashindex + 1);
|
|
2730
|
-
const deployment = {
|
|
2731
|
-
...newDeployment,
|
|
2732
|
-
id: deploymentId,
|
|
2733
|
-
devices: "devices" in newDeployment && newDeployment.devices ? newDeployment.devices.map((id) => ({ id, status: "pending" })) : [],
|
|
2734
|
-
statistics: { status: {} }
|
|
2735
|
-
};
|
|
2736
|
-
const tasks = [
|
|
2737
|
-
dispatch(actions3.createdDeployment(deployment)),
|
|
2738
|
-
dispatch(getSingleDeployment(deploymentId)),
|
|
2739
|
-
dispatch(setSnackbar2({ message: "Deployment created successfully", autoHideDuration: TIMEOUTS.fiveSeconds }))
|
|
2740
|
-
];
|
|
2741
|
-
trackDeploymentCreation(totalDeploymentCount, hasDeployments, trial_expiration);
|
|
2742
|
-
const { canManageUsers } = getUserCapabilities(getState());
|
|
2743
|
-
if (canManageUsers) {
|
|
2744
|
-
const { phases, retries } = newDeployment;
|
|
2745
|
-
const { previousPhases = [], retries: previousRetries = 0 } = getGlobalSettings(getState());
|
|
2746
|
-
const newSettings = { retries: hasNewRetryDefault ? retries : previousRetries, hasDeployments: true };
|
|
2747
|
-
if (phases) {
|
|
2748
|
-
const standardPhases = (0, import_helpers8.standardizePhases)(phases);
|
|
2749
|
-
const prevPhases = previousPhases.map(import_helpers8.standardizePhases);
|
|
2750
|
-
if (!prevPhases.find((previousPhaseList) => previousPhaseList.every((oldPhase) => standardPhases.find((phase) => (0, import_helpers8.deepCompare)(phase, oldPhase))))) {
|
|
2751
|
-
prevPhases.push(standardPhases);
|
|
2752
|
-
}
|
|
2753
|
-
newSettings.previousPhases = prevPhases.slice(-1 * MAX_PREVIOUS_PHASES_COUNT);
|
|
2754
|
-
}
|
|
2755
|
-
tasks.push(dispatch(saveGlobalSettings(newSettings)));
|
|
2756
|
-
}
|
|
2757
|
-
return Promise.all(tasks);
|
|
2758
|
-
});
|
|
2759
|
-
}
|
|
2760
|
-
);
|
|
2761
|
-
var getDeploymentDevices = createAppAsyncThunk(
|
|
2762
|
-
`${sliceName3}/getDeploymentDevices`,
|
|
2763
|
-
(options, { dispatch, getState }) => {
|
|
2764
|
-
const { id, page = defaultPage, perPage = defaultPerPage } = options;
|
|
2765
|
-
return general_api_default.get(`${import_constants5.deploymentsApiUrl}/deployments/${id}/devices/list?&page=${page}&per_page=${perPage}`).then((response) => {
|
|
2766
|
-
const { devices: deploymentDevices = {} } = getState().deployments.byId[id] || {};
|
|
2767
|
-
const devices = response.data.reduce((accu, item) => {
|
|
2768
|
-
accu[item.id] = item;
|
|
2769
|
-
const log = (deploymentDevices[item.id] || {}).log;
|
|
2770
|
-
if (log) {
|
|
2771
|
-
accu[item.id].log = log;
|
|
2772
|
-
}
|
|
2773
|
-
return accu;
|
|
2774
|
-
}, {});
|
|
2775
|
-
const selectedDeviceIds = Object.keys(devices);
|
|
2776
|
-
let tasks = [
|
|
2777
|
-
dispatch(
|
|
2778
|
-
actions3.receivedDeploymentDevices({
|
|
2779
|
-
id,
|
|
2780
|
-
devices,
|
|
2781
|
-
selectedDeviceIds,
|
|
2782
|
-
totalDeviceCount: Number(response.headers[import_constants5.headerNames.total])
|
|
2783
|
-
})
|
|
2784
|
-
)
|
|
2785
|
-
];
|
|
2786
|
-
const devicesById = getDevicesById(getState());
|
|
2787
|
-
const lackingData = selectedDeviceIds.reduce((accu, deviceId) => {
|
|
2788
|
-
const device = devicesById[deviceId];
|
|
2789
|
-
if (!device || !device.identity_data || !device.attributes || Object.keys(device.attributes).length === 0) {
|
|
2790
|
-
accu.push(deviceId);
|
|
2791
|
-
}
|
|
2792
|
-
return accu;
|
|
2793
|
-
}, []);
|
|
2794
|
-
tasks = lackingData.reduce((accu, deviceId) => [...accu, dispatch(getDeviceById2(deviceId)), dispatch(getDeviceAuth(deviceId))], tasks);
|
|
2795
|
-
return Promise.all(tasks);
|
|
2796
|
-
});
|
|
2797
|
-
}
|
|
2798
|
-
);
|
|
2799
|
-
var parseDeviceDeployment = ({
|
|
2800
|
-
deployment: { id, artifact_name: release, status: deploymentStatus },
|
|
2801
|
-
device: { created, deleted, id: deviceId, finished, status, log }
|
|
2802
|
-
}) => ({
|
|
2803
|
-
id,
|
|
2804
|
-
release,
|
|
2805
|
-
created,
|
|
2806
|
-
deleted,
|
|
2807
|
-
deviceId,
|
|
2808
|
-
finished,
|
|
2809
|
-
status,
|
|
2810
|
-
log,
|
|
2811
|
-
route: Object.values(DEPLOYMENT_ROUTES).reduce((accu, { key, states }) => {
|
|
2812
|
-
if (!accu) {
|
|
2813
|
-
return states.includes(deploymentStatus) ? key : accu;
|
|
2814
|
-
}
|
|
2815
|
-
return accu;
|
|
2816
|
-
}, "")
|
|
2817
|
-
});
|
|
2818
|
-
var getDeviceDeployments = createAppAsyncThunk(`${sliceName3}/getDeviceDeployments`, (options, { dispatch }) => {
|
|
2819
|
-
const { deviceId, filterSelection = [], page = defaultPage, perPage = defaultPerPage } = options;
|
|
2820
|
-
const filters = filterSelection.map((item) => `&status=${item}`).join("");
|
|
2821
|
-
return general_api_default.get(`${import_constants5.deploymentsApiUrl}/deployments/devices/${deviceId}?page=${page}&per_page=${perPage}${filters}`).then(
|
|
2822
|
-
({ data, headers }) => Promise.resolve(
|
|
2823
|
-
dispatch(
|
|
2824
|
-
receivedDevice({
|
|
2825
|
-
id: deviceId,
|
|
2826
|
-
deviceDeployments: data.map(parseDeviceDeployment),
|
|
2827
|
-
deploymentsCount: Number(headers[import_constants5.headerNames.total])
|
|
2828
|
-
})
|
|
2829
|
-
)
|
|
2830
|
-
)
|
|
2831
|
-
).catch((err) => commonErrorHandler(err, "There was an error retrieving the device deployment history:", dispatch));
|
|
2832
|
-
});
|
|
2833
|
-
var resetDeviceDeployments = createAppAsyncThunk(
|
|
2834
|
-
`${sliceName3}/resetDeviceDeployments`,
|
|
2835
|
-
(deviceId, { dispatch }) => general_api_default.delete(`${import_constants5.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))
|
|
2836
|
-
);
|
|
2837
|
-
var getSingleDeployment = createAppAsyncThunk(
|
|
2838
|
-
`${sliceName3}/getSingleDeployment`,
|
|
2839
|
-
(id, { dispatch, getState }) => general_api_default.get(`${import_constants5.deploymentsApiUrl}/deployments/${id}`).then(({ data }) => {
|
|
2840
|
-
const { deployments } = transformDeployments([data], getState().deployments.byId);
|
|
2841
|
-
return Promise.resolve(dispatch(actions3.receivedDeployment(deployments[id])));
|
|
2842
|
-
})
|
|
2843
|
-
);
|
|
2844
|
-
var getDeviceLog = createAppAsyncThunk(
|
|
2845
|
-
`${sliceName3}/getDeviceLog`,
|
|
2846
|
-
({ deploymentId, deviceId }, { dispatch }) => general_api_default.get(`${import_constants5.deploymentsApiUrl}/deployments/${deploymentId}/devices/${deviceId}/log`).catch((e) => {
|
|
2847
|
-
console.log("no log here", e);
|
|
2848
|
-
return Promise.reject();
|
|
2849
|
-
}).then(
|
|
2850
|
-
({ data: log }) => Promise.all([Promise.resolve(dispatch(actions3.receivedDeploymentDeviceLog({ id: deploymentId, deviceId, log }))), Promise.resolve(log)])
|
|
2851
|
-
)
|
|
2852
|
-
);
|
|
2853
|
-
var abortDeployment = createAppAsyncThunk(
|
|
2854
|
-
`${sliceName3}/abortDeployment`,
|
|
2855
|
-
(deploymentId, { dispatch, getState }) => general_api_default.put(`${import_constants5.deploymentsApiUrl}/deployments/${deploymentId}/status`, { status: "aborted" }).then(() => {
|
|
2856
|
-
const deploymentsByStatus = getDeploymentsByStatus(getState());
|
|
2857
|
-
let status = DEPLOYMENT_STATES.pending;
|
|
2858
|
-
let index = deploymentsByStatus.pending.deploymentIds.findIndex((id) => id === deploymentId);
|
|
2859
|
-
if (index < 0) {
|
|
2860
|
-
status = DEPLOYMENT_STATES.inprogress;
|
|
2861
|
-
index = deploymentsByStatus.inprogress.deploymentIds.findIndex((id) => id === deploymentId);
|
|
2862
|
-
}
|
|
2863
|
-
const deploymentIds = [...deploymentsByStatus[status].deploymentIds.slice(0, index), ...deploymentsByStatus[status].deploymentIds.slice(index + 1)];
|
|
2864
|
-
const deploymentsById = getDeploymentsById(getState());
|
|
2865
|
-
const deployments = deploymentIds.reduce((accu, id) => {
|
|
2866
|
-
accu[id] = deploymentsById[id];
|
|
2867
|
-
return accu;
|
|
2868
|
-
}, {});
|
|
2869
|
-
const total = Math.max(deploymentsByStatus[status].total - 1, 0);
|
|
2870
|
-
return Promise.all([
|
|
2871
|
-
dispatch(actions3.receivedDeployments(deployments)),
|
|
2872
|
-
dispatch(actions3.receivedDeploymentsForStatus({ deploymentIds, status, total })),
|
|
2873
|
-
dispatch(actions3.removedDeployment(deploymentId)),
|
|
2874
|
-
dispatch(setSnackbar2("The deployment was successfully aborted"))
|
|
2875
|
-
]);
|
|
2876
|
-
}).catch((err) => commonErrorHandler(err, "There was an error while aborting the deployment:", dispatch))
|
|
2877
|
-
);
|
|
2878
|
-
var updateDeploymentControlMap = createAppAsyncThunk(
|
|
2879
|
-
`${sliceName3}/updateDeploymentControlMap`,
|
|
2880
|
-
({ deploymentId, updateControlMap }, { dispatch }) => general_api_default.patch(`${import_constants5.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))))
|
|
2881
|
-
);
|
|
2882
|
-
var setDeploymentsState = createAppAsyncThunk(`${sliceName3}/setDeploymentsState`, (selection, { dispatch, getState }) => {
|
|
2883
|
-
const { page, perPage, ...selectionState } = selection;
|
|
2884
|
-
const currentState = getState().deployments.selectionState;
|
|
2885
|
-
const nextState = {
|
|
2886
|
-
...currentState,
|
|
2887
|
-
...selectionState,
|
|
2888
|
-
...Object.keys(DEPLOYMENT_STATES).reduce((accu, item) => {
|
|
2889
|
-
accu[item] = {
|
|
2890
|
-
...currentState[item],
|
|
2891
|
-
...selectionState[item]
|
|
2892
|
-
};
|
|
2893
|
-
return accu;
|
|
2894
|
-
}, {}),
|
|
2895
|
-
general: {
|
|
2896
|
-
...currentState.general,
|
|
2897
|
-
...selectionState.general
|
|
2898
|
-
}
|
|
2899
|
-
};
|
|
2900
|
-
const tasks = [dispatch(actions3.setDeploymentsState(nextState))];
|
|
2901
|
-
if (nextState.selectedId && currentState.selectedId !== nextState.selectedId) {
|
|
2902
|
-
tasks.push(dispatch(getSingleDeployment(nextState.selectedId)));
|
|
2903
|
-
}
|
|
2904
|
-
return Promise.all(tasks);
|
|
2905
|
-
});
|
|
2906
|
-
var deltaAttributeMappings = [
|
|
2907
|
-
{ here: "compressionLevel", there: "compression_level" },
|
|
2908
|
-
{ here: "disableChecksum", there: "disable_checksum" },
|
|
2909
|
-
{ here: "disableDecompression", there: "disable_external_decompression" },
|
|
2910
|
-
{ here: "sourceWindow", there: "source_window_size" },
|
|
2911
|
-
{ here: "inputWindow", there: "input_window_size" },
|
|
2912
|
-
{ here: "duplicatesWindow", there: "compression_duplicates_window" },
|
|
2913
|
-
{ here: "instructionBuffer", there: "instruction_buffer_size" }
|
|
2914
|
-
];
|
|
2915
|
-
var mapExternalDeltaConfig = (config = {}) => deltaAttributeMappings.reduce((accu, { here, there }) => {
|
|
2916
|
-
if (config[there] !== void 0) {
|
|
2917
|
-
accu[here] = config[there];
|
|
2918
|
-
}
|
|
2919
|
-
return accu;
|
|
2920
|
-
}, {});
|
|
2921
|
-
var getDeploymentsConfig = createAppAsyncThunk(
|
|
2922
|
-
`${sliceName3}/getDeploymentsConfig`,
|
|
2923
|
-
(_, { dispatch, getState }) => general_api_default.get(`${import_constants5.deploymentsApiUrl}/config`).then(({ data }) => {
|
|
2924
|
-
const oldConfig = getState().deployments.config;
|
|
2925
|
-
const { delta = {} } = data;
|
|
2926
|
-
const { binary_delta = {}, binary_delta_limits = {} } = delta;
|
|
2927
|
-
const { xdelta_args = {} } = binary_delta;
|
|
2928
|
-
const { xdelta_args_limits = {} } = binary_delta_limits;
|
|
2929
|
-
const config = {
|
|
2930
|
-
...oldConfig,
|
|
2931
|
-
hasDelta: Boolean(delta.enabled),
|
|
2932
|
-
binaryDelta: {
|
|
2933
|
-
...oldConfig.binaryDelta,
|
|
2934
|
-
...mapExternalDeltaConfig(xdelta_args)
|
|
2935
|
-
},
|
|
2936
|
-
binaryDeltaLimits: {
|
|
2937
|
-
...oldConfig.binaryDeltaLimits,
|
|
2938
|
-
...mapExternalDeltaConfig(xdelta_args_limits)
|
|
2939
|
-
}
|
|
2940
|
-
};
|
|
2941
|
-
return Promise.resolve(dispatch(actions3.setDeploymentsConfig(config)));
|
|
2942
|
-
})
|
|
2943
|
-
);
|
|
2944
|
-
var deepClean = (source) => Object.entries(source).reduce((accu, [key, value]) => {
|
|
2945
|
-
if (value !== void 0) {
|
|
2946
|
-
const cleanedValue = typeof value === "object" ? deepClean(value) : value;
|
|
2947
|
-
if (cleanedValue === void 0 || typeof cleanedValue === "object" && (0, import_helpers8.isEmpty)(cleanedValue)) {
|
|
2948
|
-
return accu;
|
|
2949
|
-
}
|
|
2950
|
-
accu = { ...accu ?? {}, [key]: cleanedValue };
|
|
2951
|
-
}
|
|
2952
|
-
return accu;
|
|
2953
|
-
}, void 0);
|
|
2954
|
-
var saveDeltaDeploymentsConfig = createAppAsyncThunk(
|
|
2955
|
-
`${sliceName3}/saveDeltaDeploymentsConfig`,
|
|
2956
|
-
(config, { dispatch, getState }) => {
|
|
2957
|
-
const configChange = {
|
|
2958
|
-
xdelta_args: deltaAttributeMappings.reduce((accu, { here, there }) => {
|
|
2959
|
-
if (config[here] !== void 0) {
|
|
2960
|
-
accu[there] = config[here];
|
|
2961
|
-
}
|
|
2962
|
-
return accu;
|
|
2963
|
-
}, {})
|
|
2964
|
-
};
|
|
2965
|
-
const result = deepClean(configChange);
|
|
2966
|
-
if (!result) {
|
|
2967
|
-
return Promise.resolve();
|
|
2968
|
-
}
|
|
2969
|
-
return general_api_default.put(`${import_constants5.deploymentsApiUrl}/config/binary_delta`, result).catch((err) => commonErrorHandler(err, "There was a problem storing your delta artifact generation configuration.", dispatch)).then(() => {
|
|
2970
|
-
const oldConfig = getState().deployments.config;
|
|
2971
|
-
const newConfig = {
|
|
2972
|
-
...oldConfig,
|
|
2973
|
-
binaryDelta: {
|
|
2974
|
-
...oldConfig.binaryDelta,
|
|
2975
|
-
...config
|
|
2976
|
-
}
|
|
2977
|
-
};
|
|
2978
|
-
return Promise.all([dispatch(actions3.setDeploymentsConfig(newConfig)), dispatch(setSnackbar2("Settings saved successfully"))]);
|
|
2979
|
-
});
|
|
2980
|
-
}
|
|
2981
|
-
);
|
|
2982
|
-
var generateDeploymentLogAnalysis = createAppAsyncThunk(
|
|
2983
|
-
`${sliceName3}/generateDeploymentLogAnalysis`,
|
|
2984
|
-
({ deploymentId, deviceId }, { dispatch, rejectWithValue }) => general_api_default.get(`${import_constants5.apiRoot}/v1alpha1/deployments/deployments/${deploymentId}/devices/${deviceId}/log/explain`, { timeout: 60 * TIMEOUTS.oneSecond }).then(({ data: result }) => Promise.resolve(result)).catch((err) => {
|
|
2985
|
-
if (err.response.status === 429) {
|
|
2986
|
-
return rejectWithValue(err.response);
|
|
2987
|
-
}
|
|
2988
|
-
commonErrorHandler(err, "There was an error analysing the deployment log:", dispatch);
|
|
2989
|
-
})
|
|
2990
|
-
);
|
|
2991
|
-
|
|
2992
|
-
// src/devicesSlice/thunks.tsx
|
|
2993
|
-
var import_react_router_dom = require("react-router-dom");
|
|
2994
|
-
var import_helpers9 = require("@northern.tech/utils/helpers");
|
|
2995
|
-
var import_axios2 = require("axios");
|
|
2996
|
-
var import_pluralize = __toESM(require("pluralize"), 1);
|
|
2997
|
-
var import_uuid = require("uuid");
|
|
2998
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
2999
|
-
var { cleanUpUpload, initUpload, setSnackbar: setSnackbar3, uploadProgress: uploadProgress2 } = actions_default;
|
|
3000
|
-
var { page: defaultPage2, perPage: defaultPerPage2 } = import_constants5.DEVICE_LIST_DEFAULTS;
|
|
3001
|
-
var defaultAttributes = [
|
|
3002
|
-
{ scope: "identity", attribute: "status" },
|
|
3003
|
-
{ scope: "inventory", attribute: "artifact_name" },
|
|
3004
|
-
{ scope: "inventory", attribute: "device_type" },
|
|
3005
|
-
{ scope: "inventory", attribute: "mender_is_gateway" },
|
|
3006
|
-
{ scope: "inventory", attribute: "mender_gateway_system_id" },
|
|
3007
|
-
{ scope: "inventory", attribute: rootfsImageVersion },
|
|
3008
|
-
{ scope: "monitor", attribute: "alerts" },
|
|
3009
|
-
{ scope: "system", attribute: "created_ts" },
|
|
3010
|
-
{ scope: "system", attribute: "updated_ts" },
|
|
3011
|
-
{ scope: "system", attribute: "check_in_time" },
|
|
3012
|
-
{ scope: "system", attribute: "group" },
|
|
3013
|
-
{ scope: "tags", attribute: "name" }
|
|
3014
|
-
];
|
|
3015
|
-
var getGroups2 = createAppAsyncThunk(
|
|
3016
|
-
`${sliceName4}/getGroups`,
|
|
3017
|
-
(_, { dispatch, getState }) => general_api_default.get(`${import_constants5.inventoryApiUrl}/groups`).then((res) => {
|
|
3018
|
-
const state = getGroupsById(getState());
|
|
3019
|
-
const dynamicGroups = Object.entries(state).reduce((accu, [id, group]) => {
|
|
3020
|
-
if (group.id || group.filters?.length && id !== UNGROUPED_GROUP.id) {
|
|
3021
|
-
accu[id] = group;
|
|
3022
|
-
}
|
|
3023
|
-
return accu;
|
|
3024
|
-
}, {});
|
|
3025
|
-
const groups = res.data.reduce((accu, group) => {
|
|
3026
|
-
accu[group] = { deviceIds: [], filters: [], total: 0, ...state[group] };
|
|
3027
|
-
return accu;
|
|
3028
|
-
}, dynamicGroups);
|
|
3029
|
-
const filters = [{ key: "group", value: res.data, operator: import_constants5.DEVICE_FILTERING_OPTIONS.$nin.key, scope: "system" }];
|
|
3030
|
-
return Promise.all([
|
|
3031
|
-
dispatch(actions4.receivedGroups(groups)),
|
|
3032
|
-
dispatch(getDevicesByStatus2({ filterSelection: filters, group: "", page: 1, perPage: 1, status: void 0 }))
|
|
3033
|
-
]).then((promises) => {
|
|
3034
|
-
const devicesRetrieval = promises[promises.length - 1] || [];
|
|
3035
|
-
const { payload } = devicesRetrieval || {};
|
|
3036
|
-
const result = payload[payload.length - 1] || {};
|
|
3037
|
-
if (!result.total) {
|
|
3038
|
-
return Promise.resolve();
|
|
3039
|
-
}
|
|
3040
|
-
return Promise.resolve(
|
|
3041
|
-
dispatch(
|
|
3042
|
-
actions4.addGroup({
|
|
3043
|
-
groupName: UNGROUPED_GROUP.id,
|
|
3044
|
-
group: { filters: [{ key: "group", value: res.data, operator: import_constants5.DEVICE_FILTERING_OPTIONS.$nin.key, scope: "system" }] }
|
|
3045
|
-
})
|
|
3046
|
-
)
|
|
3047
|
-
);
|
|
3048
|
-
});
|
|
3049
|
-
})
|
|
3050
|
-
);
|
|
3051
|
-
var addDevicesToGroup = createAppAsyncThunk(
|
|
3052
|
-
`${sliceName4}/addDevicesToGroup`,
|
|
3053
|
-
({ group, deviceIds, isCreation }, { dispatch }) => general_api_default.patch(`${import_constants5.inventoryApiUrl}/groups/${group}/devices`, deviceIds).then(() => dispatch(actions4.addToGroup({ group, deviceIds }))).finally(() => isCreation ? Promise.resolve(dispatch(getGroups2())) : {})
|
|
3054
|
-
);
|
|
3055
|
-
var removeDevicesFromGroup = createAppAsyncThunk(
|
|
3056
|
-
`${sliceName4}/removeDevicesFromGroup`,
|
|
3057
|
-
({ group, deviceIds }, { dispatch }) => general_api_default.delete(`${import_constants5.inventoryApiUrl}/groups/${group}/devices`, deviceIds).then(
|
|
3058
|
-
() => Promise.all([
|
|
3059
|
-
dispatch(actions4.removeFromGroup({ group, deviceIds })),
|
|
3060
|
-
dispatch(
|
|
3061
|
-
setSnackbar3({
|
|
3062
|
-
message: `The ${(0, import_pluralize.default)("devices", deviceIds.length)} ${(0, import_pluralize.default)("were", deviceIds.length)} removed from the group`,
|
|
3063
|
-
autoHideDuration: TIMEOUTS.fiveSeconds
|
|
3064
|
-
})
|
|
3065
|
-
)
|
|
3066
|
-
])
|
|
3067
|
-
)
|
|
3068
|
-
);
|
|
3069
|
-
var getGroupNotification = (newGroup, selectedGroup) => {
|
|
3070
|
-
const successMessage = "The group was updated successfully";
|
|
3071
|
-
if (newGroup === selectedGroup) {
|
|
3072
|
-
return { message: successMessage, autoHideDuration: TIMEOUTS.fiveSeconds };
|
|
3073
|
-
}
|
|
3074
|
-
return {
|
|
3075
|
-
action: "",
|
|
3076
|
-
autoHideDuration: TIMEOUTS.fiveSeconds,
|
|
3077
|
-
message: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
3078
|
-
successMessage,
|
|
3079
|
-
" - ",
|
|
3080
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_router_dom.Link, { to: `/devices?inventory=group:eq:${newGroup}`, children: "click here" }),
|
|
3081
|
-
" to see it."
|
|
3082
|
-
] }),
|
|
3083
|
-
preventClickToCopy: true
|
|
3084
|
-
};
|
|
3085
|
-
};
|
|
3086
|
-
var addStaticGroup = createAppAsyncThunk(
|
|
3087
|
-
`${sliceName4}/addStaticGroup`,
|
|
3088
|
-
({ group, devices }, { dispatch, getState }) => Promise.resolve(dispatch(addDevicesToGroup({ group, deviceIds: devices.map(({ id }) => id), isCreation: true }))).then(
|
|
3089
|
-
() => Promise.resolve(
|
|
3090
|
-
dispatch(
|
|
3091
|
-
actions4.addGroup({
|
|
3092
|
-
group: { deviceIds: [], total: 0, filters: [], ...getState().devices.groups.byId[group] },
|
|
3093
|
-
groupName: group
|
|
3094
|
-
})
|
|
3095
|
-
)
|
|
3096
|
-
).then(
|
|
3097
|
-
() => Promise.all([
|
|
3098
|
-
dispatch(setDeviceListState({ setOnly: true })),
|
|
3099
|
-
dispatch(getGroups2()),
|
|
3100
|
-
dispatch(setSnackbar3(getGroupNotification(group, getState().devices.groups.selectedGroup)))
|
|
3101
|
-
])
|
|
3102
|
-
)
|
|
3103
|
-
).catch((err) => commonErrorHandler(err, `Group could not be updated:`, dispatch))
|
|
3104
|
-
);
|
|
3105
|
-
var removeReportsByGroupName = createAppAsyncThunk(`${sliceName4}/removeReportsByGroupName`, (groupName, { dispatch, getState }) => {
|
|
3106
|
-
if (!groupName) return Promise.resolve();
|
|
3107
|
-
const reports = getDeviceReportsForUser(getState());
|
|
3108
|
-
const filteredReports = reports.filter((report) => report.group !== groupName);
|
|
3109
|
-
dispatch(saveUserSettings({ reports: filteredReports }));
|
|
3110
|
-
});
|
|
3111
|
-
var removeStaticGroup = createAppAsyncThunk(
|
|
3112
|
-
`${sliceName4}/removeStaticGroup`,
|
|
3113
|
-
(groupName, { dispatch }) => general_api_default.delete(`${import_constants5.inventoryApiUrl}/groups/${groupName}`).then(
|
|
3114
|
-
() => Promise.all([
|
|
3115
|
-
dispatch(actions4.removeGroup(groupName)),
|
|
3116
|
-
dispatch(removeReportsByGroupName(groupName)),
|
|
3117
|
-
dispatch(getGroups2()),
|
|
3118
|
-
dispatch(setSnackbar3({ message: "Group was removed successfully", autoHideDuration: TIMEOUTS.fiveSeconds }))
|
|
3119
|
-
])
|
|
3120
|
-
)
|
|
3121
|
-
);
|
|
3122
|
-
var getDynamicGroup = createAppAsyncThunk(
|
|
3123
|
-
`${sliceName4}/getDynamicGroupById`,
|
|
3124
|
-
(id, { dispatch }) => general_api_default.get(`${import_constants5.inventoryApiUrlV2}/filters/${id}`).catch((err) => {
|
|
3125
|
-
if (err.response && err.response.status === 404) {
|
|
3126
|
-
throw new Error("Request failed with status code 404");
|
|
3127
|
-
}
|
|
3128
|
-
return commonErrorHandler(err, `Error retrieving the group: `, dispatch, commonErrorFallback);
|
|
3129
|
-
})
|
|
3130
|
-
);
|
|
3131
|
-
var getDynamicGroups = createAppAsyncThunk(
|
|
3132
|
-
`${sliceName4}/getDynamicGroups`,
|
|
3133
|
-
(_, { dispatch, getState }) => general_api_default.get(`${import_constants5.inventoryApiUrlV2}/filters?per_page=${MAX_PAGE_SIZE}`).then(({ data: filters }) => {
|
|
3134
|
-
const state = getGroupsById(getState());
|
|
3135
|
-
const staticGroups = Object.entries(state).reduce((accu, [id, group]) => {
|
|
3136
|
-
if (!(group.id || group.filters?.length)) {
|
|
3137
|
-
accu[id] = group;
|
|
3138
|
-
}
|
|
3139
|
-
return accu;
|
|
3140
|
-
}, {});
|
|
3141
|
-
const groups = (filters || []).reduce((accu, filter) => {
|
|
3142
|
-
accu[filter.name] = {
|
|
3143
|
-
deviceIds: [],
|
|
3144
|
-
total: 0,
|
|
3145
|
-
...state[filter.name],
|
|
3146
|
-
id: filter.id,
|
|
3147
|
-
filters: mapTermsToFilters(filter.terms)
|
|
3148
|
-
};
|
|
3149
|
-
return accu;
|
|
3150
|
-
}, staticGroups);
|
|
3151
|
-
return Promise.resolve(dispatch(actions4.receivedGroups(groups)));
|
|
3152
|
-
}).catch(() => console.log("Dynamic group retrieval failed - likely accessing a non-enterprise backend"))
|
|
3153
|
-
);
|
|
3154
|
-
var addDynamicGroup = createAppAsyncThunk(
|
|
3155
|
-
`${sliceName4}/addDynamicGroup`,
|
|
3156
|
-
({ groupName, filterPredicates }, { dispatch, getState }) => general_api_default.post(`${import_constants5.inventoryApiUrlV2}/filters`, { name: groupName, terms: mapFiltersToTerms(filterPredicates) }).then(
|
|
3157
|
-
(res) => Promise.resolve(
|
|
3158
|
-
dispatch(
|
|
3159
|
-
actions4.addGroup({
|
|
3160
|
-
groupName,
|
|
3161
|
-
group: {
|
|
3162
|
-
id: res.headers[import_constants5.headerNames.location].substring(res.headers[import_constants5.headerNames.location].lastIndexOf("/") + 1),
|
|
3163
|
-
filters: filterPredicates
|
|
3164
|
-
}
|
|
3165
|
-
})
|
|
3166
|
-
)
|
|
3167
|
-
).then(() => {
|
|
3168
|
-
const { cleanedFilters } = getGroupFilters(groupName, getState().devices.groups);
|
|
3169
|
-
return Promise.all([
|
|
3170
|
-
dispatch(actions4.setDeviceFilters(cleanedFilters)),
|
|
3171
|
-
dispatch(setSnackbar3(getGroupNotification(groupName, getState().devices.groups.selectedGroup))),
|
|
3172
|
-
dispatch(getDynamicGroups())
|
|
3173
|
-
]);
|
|
3174
|
-
})
|
|
3175
|
-
).catch((err) => commonErrorHandler(err, `Group could not be updated:`, dispatch))
|
|
3176
|
-
);
|
|
3177
|
-
var updateDynamicGroup = createAppAsyncThunk(
|
|
3178
|
-
`${sliceName4}/updateDynamicGroup`,
|
|
3179
|
-
({ groupName, filterPredicates }, { dispatch, getState }) => {
|
|
3180
|
-
const filterId = getState().devices.groups.byId[groupName].id;
|
|
3181
|
-
return general_api_default.delete(`${import_constants5.inventoryApiUrlV2}/filters/${filterId}`).then(
|
|
3182
|
-
() => Promise.resolve(dispatch(addDynamicGroup({ groupName, filterPredicates })))
|
|
3183
|
-
);
|
|
3184
|
-
}
|
|
3185
|
-
);
|
|
3186
|
-
var removeDynamicGroup = createAppAsyncThunk(`${sliceName4}/removeDynamicGroup`, (groupName, { dispatch, getState }) => {
|
|
3187
|
-
const filterId = getState().devices.groups.byId[groupName].id;
|
|
3188
|
-
return general_api_default.delete(`${import_constants5.inventoryApiUrlV2}/filters/${filterId}`).then(
|
|
3189
|
-
() => Promise.all([
|
|
3190
|
-
dispatch(actions4.removeGroup(groupName)),
|
|
3191
|
-
dispatch(removeReportsByGroupName(groupName)),
|
|
3192
|
-
dispatch(setSnackbar3({ message: "Group was removed successfully", autoHideDuration: TIMEOUTS.fiveSeconds }))
|
|
3193
|
-
])
|
|
3194
|
-
);
|
|
3195
|
-
});
|
|
3196
|
-
var getGroupFilters = (group, groupsState, filters = []) => {
|
|
3197
|
-
const groupName = group === UNGROUPED_GROUP.id || group === UNGROUPED_GROUP.name ? UNGROUPED_GROUP.id : group;
|
|
3198
|
-
const selectedGroup = groupsState.byId[groupName];
|
|
3199
|
-
const groupFilterLength = selectedGroup?.filters?.length || 0;
|
|
3200
|
-
const cleanedFilters = groupFilterLength ? [...filters, ...selectedGroup.filters || []].filter(filtersFilter) : filters;
|
|
3201
|
-
return { cleanedFilters, groupName, selectedGroup, groupFilterLength };
|
|
3202
|
-
};
|
|
3203
|
-
var selectGroup = createAppAsyncThunk(
|
|
3204
|
-
`${sliceName4}/selectGroup`,
|
|
3205
|
-
({ group, filters = [] }, { dispatch, getState }) => {
|
|
3206
|
-
const { cleanedFilters, groupName, selectedGroup, groupFilterLength } = getGroupFilters(group, getState().devices.groups, filters);
|
|
3207
|
-
if (getSelectedGroup(getState()) === groupName && (filters.length === 0 && !groupFilterLength || filters.length === cleanedFilters.length)) {
|
|
3208
|
-
return Promise.resolve();
|
|
3209
|
-
}
|
|
3210
|
-
const tasks = [];
|
|
3211
|
-
if (groupFilterLength) {
|
|
3212
|
-
tasks.push(dispatch(actions4.setDeviceFilters(cleanedFilters)));
|
|
3213
|
-
} else {
|
|
3214
|
-
tasks.push(dispatch(actions4.setDeviceFilters(filters)));
|
|
3215
|
-
tasks.push(dispatch(getGroupDevices({ group: groupName, perPage: 1, shouldIncludeAllStates: true })));
|
|
3216
|
-
}
|
|
3217
|
-
const selectedGroupName = selectedGroup || !Object.keys(getGroupsById(getState())).length ? groupName : void 0;
|
|
3218
|
-
tasks.push(dispatch(actions4.selectGroup(selectedGroupName)));
|
|
3219
|
-
return Promise.all(tasks);
|
|
3220
|
-
}
|
|
3221
|
-
);
|
|
3222
|
-
var getEarliestTs = (dateA = "", dateB = "") => !dateA || !dateB ? dateA || dateB : dateA < dateB ? dateA : dateB;
|
|
3223
|
-
var reduceReceivedDevices = (devices, ids, state, status) => devices.reduce(
|
|
3224
|
-
(accu, device) => {
|
|
3225
|
-
const stateDevice = getDeviceById(state, device.id);
|
|
3226
|
-
const {
|
|
3227
|
-
attributes: storedAttributes = {},
|
|
3228
|
-
identity_data: storedIdentity = {},
|
|
3229
|
-
monitor: storedMonitor = {},
|
|
3230
|
-
tags: storedTags = {},
|
|
3231
|
-
group: storedGroup
|
|
3232
|
-
} = stateDevice;
|
|
3233
|
-
const { identity, inventory, monitor, system = {}, tags } = mapDeviceAttributes(device.attributes);
|
|
3234
|
-
device.tags = { ...storedTags, ...tags };
|
|
3235
|
-
device.group = system.group ?? storedGroup;
|
|
3236
|
-
device.monitor = { ...storedMonitor, ...monitor };
|
|
3237
|
-
device.identity_data = { ...storedIdentity, ...identity, ...device.identity_data ? device.identity_data : {} };
|
|
3238
|
-
device.status = status ? status : device.status || identity.status;
|
|
3239
|
-
device.check_in_time_rounded = system.check_in_time ?? stateDevice.check_in_time_rounded;
|
|
3240
|
-
device.check_in_time_exact = device.check_in_time ?? stateDevice.check_in_time_exact;
|
|
3241
|
-
device.created_ts = getEarliestTs(getEarliestTs(system.created_ts, device.created_ts), stateDevice.created_ts);
|
|
3242
|
-
device.updated_ts = device.attributes ? device.updated_ts : stateDevice.updated_ts;
|
|
3243
|
-
device.isNew = new Date(device.created_ts) > new Date(state.app.newThreshold);
|
|
3244
|
-
device.isOffline = new Date(device.check_in_time_rounded) < new Date(state.app.offlineThreshold) || device.check_in_time_rounded === void 0;
|
|
3245
|
-
device.attributes = device.attributes ? { ...storedAttributes, ...inventory } : storedAttributes;
|
|
3246
|
-
accu.devicesById[device.id] = { ...stateDevice, ...device };
|
|
3247
|
-
accu.ids.push(device.id);
|
|
3248
|
-
return accu;
|
|
3249
|
-
},
|
|
3250
|
-
{ ids, devicesById: {} }
|
|
3251
|
-
);
|
|
3252
|
-
var getGroupDevices = createAppAsyncThunk(`${sliceName4}/getGroupDevices`, (options, { dispatch, getState }) => {
|
|
3253
|
-
const { group, shouldIncludeAllStates, ...remainder } = options;
|
|
3254
|
-
const { cleanedFilters: filterSelection } = getGroupFilters(group, getState().devices.groups);
|
|
3255
|
-
return dispatch(
|
|
3256
|
-
getDevicesByStatus2({
|
|
3257
|
-
...remainder,
|
|
3258
|
-
filterSelection,
|
|
3259
|
-
group,
|
|
3260
|
-
status: shouldIncludeAllStates ? void 0 : import_constants5.DEVICE_STATES.accepted
|
|
3261
|
-
})
|
|
3262
|
-
).unwrap().then((results) => {
|
|
3263
|
-
if (!group) {
|
|
3264
|
-
return Promise.resolve();
|
|
3265
|
-
}
|
|
3266
|
-
const { deviceAccu, total } = results[results.length - 1];
|
|
3267
|
-
const stateGroup = getState().devices.groups.byId[group];
|
|
3268
|
-
if (!stateGroup && !total && !deviceAccu.ids.length) {
|
|
3269
|
-
return Promise.resolve();
|
|
3270
|
-
}
|
|
3271
|
-
return Promise.resolve(
|
|
3272
|
-
dispatch(
|
|
3273
|
-
actions4.addGroup({
|
|
3274
|
-
group: {
|
|
3275
|
-
deviceIds: deviceAccu.ids.length === total || stateGroup && stateGroup.deviceIds && deviceAccu.ids.length > stateGroup.deviceIds ? deviceAccu.ids : stateGroup.deviceIds,
|
|
3276
|
-
total
|
|
3277
|
-
},
|
|
3278
|
-
groupName: group
|
|
3279
|
-
})
|
|
3280
|
-
)
|
|
3281
|
-
);
|
|
3282
|
-
});
|
|
3283
|
-
});
|
|
3284
|
-
var getAllGroupDevices = createAppAsyncThunk(
|
|
3285
|
-
`${sliceName4}/getAllGroupDevices`,
|
|
3286
|
-
({ group, attribute }, { dispatch, getState }) => {
|
|
3287
|
-
if (!group || !!group && (!getGroupsById(getState())[group] || getGroupsById(getState())[group].filters.length)) {
|
|
3288
|
-
return Promise.resolve();
|
|
3289
|
-
}
|
|
3290
|
-
const { attributes, filterTerms } = prepareSearchArguments({
|
|
3291
|
-
filters: [],
|
|
3292
|
-
group,
|
|
3293
|
-
state: getState(),
|
|
3294
|
-
status: import_constants5.DEVICE_STATES.accepted
|
|
3295
|
-
});
|
|
3296
|
-
const getAllDevices = (perPage = MAX_PAGE_SIZE, page = defaultPage2, devices = []) => general_api_default.post(`${import_constants5.inventoryApiUrlV2}/filters/search`, {
|
|
3297
|
-
page,
|
|
3298
|
-
per_page: perPage,
|
|
3299
|
-
filters: filterTerms,
|
|
3300
|
-
attributes: [...attributes, { scope: "inventory", attribute }]
|
|
3301
|
-
}).then((res) => {
|
|
3302
|
-
const state = getState();
|
|
3303
|
-
const deviceAccu = reduceReceivedDevices(res.data, devices, state);
|
|
3304
|
-
dispatch(actions4.receivedDevices(deviceAccu.devicesById));
|
|
3305
|
-
const total = Number(res.headers[import_constants5.headerNames.total]);
|
|
3306
|
-
if (total > perPage * page) {
|
|
3307
|
-
return getAllDevices(perPage, page + 1, deviceAccu.ids);
|
|
3308
|
-
}
|
|
3309
|
-
return Promise.resolve(dispatch(actions4.addGroup({ group: { deviceIds: deviceAccu.ids, total: deviceAccu.ids.length }, groupName: group })));
|
|
3310
|
-
});
|
|
3311
|
-
return getAllDevices();
|
|
3312
|
-
}
|
|
3313
|
-
);
|
|
3314
|
-
var getAllDynamicGroupDevices = createAppAsyncThunk(
|
|
3315
|
-
`${sliceName4}/getAllDynamicGroupDevices`,
|
|
3316
|
-
({ group, attribute }, { dispatch, getState }) => {
|
|
3317
|
-
if (!!group && (!getGroupsById(getState())[group] || !getGroupsById(getState())[group].filters.length)) {
|
|
3318
|
-
return Promise.resolve();
|
|
3319
|
-
}
|
|
3320
|
-
const { attributes, filterTerms: filters } = prepareSearchArguments({
|
|
3321
|
-
filters: getState().devices.groups.byId[group].filters,
|
|
3322
|
-
state: getState(),
|
|
3323
|
-
status: import_constants5.DEVICE_STATES.accepted
|
|
3324
|
-
});
|
|
3325
|
-
const getAllDevices = (perPage = MAX_PAGE_SIZE, page = defaultPage2, devices = []) => general_api_default.post(`${import_constants5.inventoryApiUrlV2}/filters/search`, {
|
|
3326
|
-
page,
|
|
3327
|
-
per_page: perPage,
|
|
3328
|
-
filters,
|
|
3329
|
-
attributes: [...attributes, { scope: "inventory", attribute }]
|
|
3330
|
-
}).then((res) => {
|
|
3331
|
-
const state = getState();
|
|
3332
|
-
const deviceAccu = reduceReceivedDevices(res.data, devices, state);
|
|
3333
|
-
dispatch(actions4.receivedDevices(deviceAccu.devicesById));
|
|
3334
|
-
const total = Number(res.headers[import_constants5.headerNames.total]);
|
|
3335
|
-
if (total > deviceAccu.ids.length) {
|
|
3336
|
-
return getAllDevices(perPage, page + 1, deviceAccu.ids);
|
|
3337
|
-
}
|
|
3338
|
-
return Promise.resolve(dispatch(actions4.addGroup({ group: { deviceIds: deviceAccu.ids, total }, groupName: group })));
|
|
3339
|
-
});
|
|
3340
|
-
return getAllDevices();
|
|
3341
|
-
}
|
|
3342
|
-
);
|
|
3343
|
-
var getDeviceById2 = createAppAsyncThunk(
|
|
3344
|
-
`${sliceName4}/getDeviceById`,
|
|
3345
|
-
(id, { dispatch, getState }) => general_api_default.get(`${import_constants5.inventoryApiUrl}/devices/${id}`).then((res) => {
|
|
3346
|
-
const device = reduceReceivedDevices([res.data], [], getState()).devicesById[id];
|
|
3347
|
-
device.etag = res.headers.etag;
|
|
3348
|
-
dispatch(actions4.receivedDevice(device));
|
|
3349
|
-
return Promise.resolve(device);
|
|
3350
|
-
}).catch((err) => {
|
|
3351
|
-
const errMsg = extractErrorMessage(err);
|
|
3352
|
-
if (errMsg.includes("Not Found")) {
|
|
3353
|
-
console.log(`${id} does not have any inventory information`);
|
|
3354
|
-
const device = reduceReceivedDevices(
|
|
3355
|
-
[
|
|
3356
|
-
{
|
|
3357
|
-
id,
|
|
3358
|
-
attributes: [
|
|
3359
|
-
{ name: "status", value: "decomissioned", scope: "identity" },
|
|
3360
|
-
{ name: "decomissioned", value: "true", scope: "inventory" }
|
|
3361
|
-
],
|
|
3362
|
-
log: false
|
|
3363
|
-
}
|
|
3364
|
-
],
|
|
3365
|
-
[],
|
|
3366
|
-
getState()
|
|
3367
|
-
).devicesById[id];
|
|
3368
|
-
dispatch(actions4.receivedDevice(device));
|
|
3369
|
-
}
|
|
3370
|
-
})
|
|
3371
|
-
);
|
|
3372
|
-
var getDeviceInfo = createAppAsyncThunk(`${sliceName4}/getDeviceInfo`, (deviceId, { dispatch, getState }) => {
|
|
3373
|
-
const device = getDeviceById(getState(), deviceId);
|
|
3374
|
-
const { hasDeviceConfig, hasDeviceConnect, hasMonitor } = getTenantCapabilities(getState());
|
|
3375
|
-
const { canConfigure } = getUserCapabilities(getState());
|
|
3376
|
-
const integrations = getDeviceTwinIntegrations(getState());
|
|
3377
|
-
const tasks = [
|
|
3378
|
-
dispatch(getDeviceAuth(deviceId)),
|
|
3379
|
-
dispatch(getDeviceById2(deviceId)),
|
|
3380
|
-
...integrations.map((integration) => dispatch(getDeviceTwin({ deviceId, integration })))
|
|
3381
|
-
];
|
|
3382
|
-
if (hasDeviceConfig && canConfigure && (device.status === import_constants5.DEVICE_STATES.accepted || device.status === import_constants5.DEVICE_STATES.preauth)) {
|
|
3383
|
-
tasks.push(dispatch(getDeviceConfig(deviceId)));
|
|
3384
|
-
}
|
|
3385
|
-
if (device.status === import_constants5.DEVICE_STATES.accepted) {
|
|
3386
|
-
if (hasDeviceConnect) {
|
|
3387
|
-
tasks.push(dispatch(getDeviceConnect(deviceId)));
|
|
3388
|
-
}
|
|
3389
|
-
if (hasMonitor) {
|
|
3390
|
-
tasks.push(dispatch(getLatestDeviceAlerts({ id: deviceId })));
|
|
3391
|
-
tasks.push(dispatch(getDeviceMonitorConfig(deviceId)));
|
|
3392
|
-
}
|
|
3393
|
-
}
|
|
3394
|
-
return Promise.all(tasks);
|
|
3395
|
-
});
|
|
3396
|
-
var getAllDeviceCounts = createAppAsyncThunk(
|
|
3397
|
-
`${sliceName4}/getAllDeviceCounts`,
|
|
3398
|
-
(_, { dispatch }) => general_api_default.get(`${import_constants5.inventoryApiUrlV2}/statistics`).then(({ data }) => {
|
|
3399
|
-
const { devices_by_status } = data;
|
|
3400
|
-
Object.entries(devices_by_status).map(([status, countsPerTier]) => dispatch(actions4.setDevicesCountByStatus({ countsPerTier, status })));
|
|
3401
|
-
return;
|
|
3402
|
-
})
|
|
3403
|
-
);
|
|
3404
|
-
var getDeviceLimits2 = createAppAsyncThunk(
|
|
3405
|
-
`${sliceName4}/getDeviceLimit`,
|
|
3406
|
-
(_, { dispatch }) => general_api_default.get(`${import_constants5.deviceAuthV2}/limits/devices`).then((res) => dispatch(actions4.setDeviceLimits(res.data)))
|
|
3407
|
-
);
|
|
3408
|
-
var setDeviceListState = createAppAsyncThunk(
|
|
3409
|
-
`${sliceName4}/setDeviceListState`,
|
|
3410
|
-
({ shouldSelectDevices = true, forceRefresh, fetchAuth = true, ...selectionState }, { dispatch, getState }) => {
|
|
3411
|
-
const currentState = getDeviceListState(getState());
|
|
3412
|
-
const refreshTrigger = forceRefresh ? !currentState.refreshTrigger : selectionState.refreshTrigger;
|
|
3413
|
-
const nextState = {
|
|
3414
|
-
...currentState,
|
|
3415
|
-
setOnly: false,
|
|
3416
|
-
refreshTrigger,
|
|
3417
|
-
...selectionState,
|
|
3418
|
-
sort: { ...currentState.sort, ...selectionState.sort }
|
|
3419
|
-
};
|
|
3420
|
-
const tasks = [];
|
|
3421
|
-
const { isLoading: currentLoading, deviceIds: currentDevices, selection: currentSelection, ...currentRequestState } = currentState;
|
|
3422
|
-
const { isLoading: nextLoading, deviceIds: nextDevices, selection: nextSelection, ...nextRequestState } = nextState;
|
|
3423
|
-
if (!nextState.setOnly && !(0, import_helpers9.deepCompare)(currentRequestState, nextRequestState)) {
|
|
3424
|
-
const { direction: sortDown = import_constants5.SORTING_OPTIONS.desc, key: sortCol, scope: sortScope = "" } = nextState.sort ?? {};
|
|
3425
|
-
const sortBy = sortCol ? [{ attribute: sortCol, order: sortDown, scope: sortScope }] : void 0;
|
|
3426
|
-
const applicableSelectedState = nextState.state === import_constants5.ALL_DEVICE_STATES ? void 0 : nextState.state;
|
|
3427
|
-
nextState.isLoading = true;
|
|
3428
|
-
tasks.push(
|
|
3429
|
-
dispatch(getDevicesByStatus2({ ...nextState, status: applicableSelectedState, sortOptions: sortBy, fetchAuth })).unwrap().then((results) => {
|
|
3430
|
-
const { deviceAccu, total } = results[results.length - 1];
|
|
3431
|
-
const devicesState = shouldSelectDevices ? { deviceIds: deviceAccu.ids, total, isLoading: false } : { isLoading: false };
|
|
3432
|
-
return Promise.resolve(dispatch(actions4.setDeviceListState(devicesState)));
|
|
3433
|
-
}).catch(() => Promise.resolve({ isLoading: false }))
|
|
3434
|
-
);
|
|
3435
|
-
}
|
|
3436
|
-
if (currentState.page !== nextState.page || currentState.perPage > nextState.perPage || currentState.state !== nextState.state || !(0, import_helpers9.deepCompare)(currentState.sort, nextState.sort)) {
|
|
3437
|
-
nextState.selection = [];
|
|
3438
|
-
}
|
|
3439
|
-
tasks.push(dispatch(actions4.setDeviceListState(nextState)));
|
|
3440
|
-
return Promise.all(tasks);
|
|
3441
|
-
}
|
|
3442
|
-
);
|
|
3443
|
-
var getDevicesByStatus2 = createAppAsyncThunk(
|
|
3444
|
-
`${sliceName4}/getDevicesByStatus`,
|
|
3445
|
-
(options, { dispatch, getState }) => {
|
|
3446
|
-
const {
|
|
3447
|
-
status,
|
|
3448
|
-
fetchAuth = true,
|
|
3449
|
-
filterSelection,
|
|
3450
|
-
group,
|
|
3451
|
-
selectedIssues = [],
|
|
3452
|
-
page = defaultPage2,
|
|
3453
|
-
perPage = defaultPerPage2,
|
|
3454
|
-
sortOptions = [],
|
|
3455
|
-
selectedAttributes = getSelectedDeviceAttribute(getState())
|
|
3456
|
-
} = options;
|
|
3457
|
-
const state = getState();
|
|
3458
|
-
const { applicableFilters, filterTerms } = convertDeviceListStateToFilters({
|
|
3459
|
-
filters: filterSelection ?? getDeviceFilters(state),
|
|
3460
|
-
group: group ?? getSelectedGroup(state),
|
|
3461
|
-
groups: state.devices.groups,
|
|
3462
|
-
offlineThreshold: state.app.offlineThreshold,
|
|
3463
|
-
selectedIssues,
|
|
3464
|
-
status
|
|
3465
|
-
});
|
|
3466
|
-
const attributes = [...defaultAttributes, getIdAttribute(getState()), ...selectedAttributes];
|
|
3467
|
-
return general_api_default.post(`${import_constants5.inventoryApiUrlV2}/filters/search`, {
|
|
3468
|
-
page,
|
|
3469
|
-
per_page: perPage,
|
|
3470
|
-
filters: filterTerms,
|
|
3471
|
-
sort: sortOptions,
|
|
3472
|
-
attributes
|
|
3473
|
-
}).then((response) => {
|
|
3474
|
-
const state2 = getState();
|
|
3475
|
-
const deviceAccu = reduceReceivedDevices(response.data, [], state2, status);
|
|
3476
|
-
let total = !applicableFilters.length ? Number(response.headers[import_constants5.headerNames.total]) : 0;
|
|
3477
|
-
if (status && state2.devices.byStatus[status].counts.total === deviceAccu.ids.length) {
|
|
3478
|
-
total = deviceAccu.ids.length;
|
|
3479
|
-
}
|
|
3480
|
-
const tasks = [dispatch(actions4.receivedDevices(deviceAccu.devicesById))];
|
|
3481
|
-
if (status) {
|
|
3482
|
-
tasks.push(dispatch(actions4.setDevicesByStatus({ deviceIds: deviceAccu.ids, status, total })));
|
|
3483
|
-
}
|
|
3484
|
-
const receivedDevices = Object.values(deviceAccu.devicesById);
|
|
3485
|
-
if (receivedDevices.length && fetchAuth) {
|
|
3486
|
-
tasks.push(dispatch(getDevicesWithAuth(receivedDevices)));
|
|
3487
|
-
}
|
|
3488
|
-
tasks.push(Promise.resolve({ deviceAccu, total: Number(response.headers[import_constants5.headerNames.total]) }));
|
|
3489
|
-
return Promise.all(tasks);
|
|
3490
|
-
}).catch((err) => commonErrorHandler(err, `${status} devices couldn't be loaded.`, dispatch, commonErrorFallback));
|
|
3491
|
-
}
|
|
3492
|
-
);
|
|
3493
|
-
var getAllDevicesByStatus = createAppAsyncThunk(
|
|
3494
|
-
`${sliceName4}/getAllDevicesByStatus`,
|
|
3495
|
-
({ status, attribute }, { dispatch, getState }) => {
|
|
3496
|
-
const attributes = [...defaultAttributes, getIdAttribute(getState())];
|
|
3497
|
-
const getAllDevices = (perPage = MAX_PAGE_SIZE, page = 1, devices = []) => general_api_default.post(`${import_constants5.inventoryApiUrlV2}/filters/search`, {
|
|
3498
|
-
page,
|
|
3499
|
-
per_page: perPage,
|
|
3500
|
-
filters: mapFiltersToTerms([{ key: "status", value: status, operator: import_constants5.DEVICE_FILTERING_OPTIONS.$eq.key, scope: "identity" }]),
|
|
3501
|
-
attributes: [...attributes, { scope: "inventory", attribute }]
|
|
3502
|
-
}).then((res) => {
|
|
3503
|
-
const state = getState();
|
|
3504
|
-
const deviceAccu = reduceReceivedDevices(res.data, devices, state, status);
|
|
3505
|
-
dispatch(actions4.receivedDevices(deviceAccu.devicesById));
|
|
3506
|
-
const total = Number(res.headers[import_constants5.headerNames.total]);
|
|
3507
|
-
if (total > state.deployments.deploymentDeviceLimit) {
|
|
3508
|
-
return Promise.resolve();
|
|
3509
|
-
}
|
|
3510
|
-
if (total > perPage * page) {
|
|
3511
|
-
return getAllDevices(perPage, page + 1, deviceAccu.ids);
|
|
3512
|
-
}
|
|
3513
|
-
return Promise.resolve();
|
|
3514
|
-
});
|
|
3515
|
-
return getAllDevices();
|
|
3516
|
-
}
|
|
3517
|
-
);
|
|
3518
|
-
var searchDevices = createAppAsyncThunk(`${sliceName4}/searchDevices`, (passedOptions = {}, { dispatch, getState }) => {
|
|
3519
|
-
const state = getState();
|
|
3520
|
-
const options = { ...state.app.searchState, ...passedOptions };
|
|
3521
|
-
const { page = defaultPage2, searchTerm, sortOptions = [] } = options;
|
|
3522
|
-
const { columnSelection = [] } = getUserSettings(state);
|
|
3523
|
-
const selectedAttributes = columnSelection.map((column) => ({ attribute: column.key, scope: column.scope }));
|
|
3524
|
-
const attributes = (0, import_helpers9.attributeDuplicateFilter)([...defaultAttributes, getIdAttribute(state), ...selectedAttributes], "attribute");
|
|
3525
|
-
return general_api_default.post(`${import_constants5.inventoryApiUrlV2}/filters/search`, {
|
|
3526
|
-
page,
|
|
3527
|
-
per_page: 10,
|
|
3528
|
-
filters: [],
|
|
3529
|
-
sort: sortOptions,
|
|
3530
|
-
text: searchTerm,
|
|
3531
|
-
attributes
|
|
3532
|
-
}).then((response) => {
|
|
3533
|
-
const deviceAccu = reduceReceivedDevices(response.data, [], getState());
|
|
3534
|
-
return Promise.all([
|
|
3535
|
-
dispatch(actions4.receivedDevices(deviceAccu.devicesById)),
|
|
3536
|
-
Promise.resolve({ deviceIds: deviceAccu.ids, searchTotal: Number(response.headers[import_constants5.headerNames.total]) })
|
|
3537
|
-
]);
|
|
3538
|
-
}).catch((err) => commonErrorHandler(err, `devices couldn't be searched.`, dispatch, commonErrorFallback));
|
|
3539
|
-
});
|
|
3540
|
-
var ATTRIBUTE_LIST_CUTOFF = 100;
|
|
3541
|
-
var attributeReducer = (attributes = []) => attributes.slice(0, ATTRIBUTE_LIST_CUTOFF).reduce(
|
|
3542
|
-
(accu, { name, scope }) => {
|
|
3543
|
-
if (!accu[scope]) {
|
|
3544
|
-
accu[scope] = [];
|
|
3545
|
-
}
|
|
3546
|
-
accu[scope].push(name);
|
|
3547
|
-
return accu;
|
|
3548
|
-
},
|
|
3549
|
-
{ identity: [], inventory: [], system: [], tags: [] }
|
|
3550
|
-
);
|
|
3551
|
-
var getDeviceAttributes = createAppAsyncThunk(
|
|
3552
|
-
`${sliceName4}/getDeviceAttributes`,
|
|
3553
|
-
(_, { dispatch }) => general_api_default.get(`${import_constants5.inventoryApiUrlV2}/filters/attributes`).then(({ data }) => {
|
|
3554
|
-
const { identity: identityAttributes, inventory: inventoryAttributes, system: systemAttributes, tags: tagAttributes } = attributeReducer(data || []);
|
|
3555
|
-
return dispatch(actions4.setFilterAttributes({ identityAttributes, inventoryAttributes, systemAttributes, tagAttributes }));
|
|
3556
|
-
})
|
|
3557
|
-
);
|
|
3558
|
-
var initializeDistributionData = (report, groups, devices, totalDeviceCount) => {
|
|
3559
|
-
const { attribute, group = "", software = "" } = report;
|
|
3560
|
-
const effectiveAttribute = software ? software : attribute;
|
|
3561
|
-
const { deviceIds, total = 0 } = groups[group] || {};
|
|
3562
|
-
const relevantDevices = deviceIds ? deviceIds.map((id) => devices[id]) : Object.values(devices);
|
|
3563
|
-
const distributionByAttribute = relevantDevices.reduce((accu, item) => {
|
|
3564
|
-
if (!item.attributes || item.status !== import_constants5.DEVICE_STATES.accepted) return accu;
|
|
3565
|
-
const attributeValue = item.attributes[effectiveAttribute];
|
|
3566
|
-
if (!accu[attributeValue]) {
|
|
3567
|
-
accu[attributeValue] = 0;
|
|
3568
|
-
}
|
|
3569
|
-
accu[attributeValue] = accu[attributeValue] + 1;
|
|
3570
|
-
return accu;
|
|
3571
|
-
}, {});
|
|
3572
|
-
const distributionByAttributeSorted = Object.entries(distributionByAttribute).sort((pairA, pairB) => pairB[1] - pairA[1]);
|
|
3573
|
-
const items = distributionByAttributeSorted.map(([key, count]) => ({ key, count }));
|
|
3574
|
-
const dataCount = items.reduce((accu, item) => accu + item.count, 0);
|
|
3575
|
-
const otherCount = (groups[group] ? total : totalDeviceCount) - dataCount;
|
|
3576
|
-
return { items, otherCount, total: otherCount + dataCount };
|
|
3577
|
-
};
|
|
3578
|
-
var updateReportData = createAppAsyncThunk(`${sliceName4}/updateReportData`, (reportIndex, { dispatch, getState }) => {
|
|
3579
|
-
const reports = getDeviceReportsForUser(getState());
|
|
3580
|
-
const report = reports[reportIndex];
|
|
3581
|
-
const { group = "" } = report;
|
|
3582
|
-
const devicesById = getDevicesById(getState());
|
|
3583
|
-
const groups = getGroupsById(getState());
|
|
3584
|
-
const { accepted: acceptedDevicesCount } = getDeviceCountsByStatus(getState());
|
|
3585
|
-
const totalDeviceCount = groups[group] ? groups[group].total : acceptedDevicesCount;
|
|
3586
|
-
const reportsData = getDeviceReports(getState());
|
|
3587
|
-
const newReports = [...reportsData];
|
|
3588
|
-
newReports[reportIndex] = initializeDistributionData(report, groups, devicesById, totalDeviceCount);
|
|
3589
|
-
return Promise.resolve(dispatch(actions4.setDeviceReports(newReports)));
|
|
3590
|
-
});
|
|
3591
|
-
var getReportDataWithoutBackendSupport = createAppAsyncThunk(
|
|
3592
|
-
`${sliceName4}/getReportDataWithoutBackendSupport`,
|
|
3593
|
-
(reportIndex, { dispatch, getState }) => {
|
|
3594
|
-
const reports = getDeviceReportsForUser(getState());
|
|
3595
|
-
const report = reports[reportIndex];
|
|
3596
|
-
if (!report) {
|
|
3597
|
-
return;
|
|
3598
|
-
}
|
|
3599
|
-
const { attribute, group = "", software = "" } = report;
|
|
3600
|
-
const effectiveAttribute = software ? software : attribute;
|
|
3601
|
-
const devicesById = getDevicesById(getState());
|
|
3602
|
-
const acceptedDevices = getAcceptedDevices(getState());
|
|
3603
|
-
const { accepted: acceptedDevicesCount } = getDeviceCountsByStatus(getState());
|
|
3604
|
-
const groups = getGroupsById(getState());
|
|
3605
|
-
const { deviceIds = [], filters = [], total = 0 } = groups[group] || {};
|
|
3606
|
-
let groupDevicesRequest = Promise.resolve({
|
|
3607
|
-
payload: { groupName: "", group: { deviceIds: Object.keys(devicesById), total: Object.keys(devicesById).length } }
|
|
3608
|
-
});
|
|
3609
|
-
if (group && (!(deviceIds.length && total) || deviceIds.length !== total || !deviceIds.every((id) => !!devicesById[id]))) {
|
|
3610
|
-
groupDevicesRequest = filters.length ? dispatch(getAllDynamicGroupDevices({ group, attribute: effectiveAttribute })).unwrap() : dispatch(getAllGroupDevices({ group, attribute: effectiveAttribute })).unwrap();
|
|
3611
|
-
} else if (!group && (acceptedDevices.deviceIds.length !== acceptedDevicesCount || !acceptedDevices.deviceIds.every((id) => !!devicesById[id]))) {
|
|
3612
|
-
groupDevicesRequest = dispatch(getAllDevicesByStatus({ status: import_constants5.DEVICE_STATES.accepted, attribute: effectiveAttribute })).unwrap();
|
|
3613
|
-
}
|
|
3614
|
-
return groupDevicesRequest.then(() => dispatch(updateReportData(reportIndex)));
|
|
3615
|
-
}
|
|
3616
|
-
);
|
|
3617
|
-
var getDeviceConnect = createAppAsyncThunk(
|
|
3618
|
-
`${sliceName4}/getDeviceConnect`,
|
|
3619
|
-
(id, { dispatch }) => general_api_default.get(`${import_constants5.deviceConnect}/devices/${id}`).then(
|
|
3620
|
-
({ data }) => Promise.all([dispatch(actions4.receivedDevice({ connect_status: data.status, connect_updated_ts: data.updated_ts, id })), Promise.resolve(data)])
|
|
3621
|
-
)
|
|
3622
|
-
);
|
|
3623
|
-
var updateTypeMap = { deploymentUpdate: "check-update", inventoryUpdate: "send-inventory" };
|
|
3624
|
-
var triggerDeviceUpdate = createAppAsyncThunk(
|
|
3625
|
-
`${sliceName4}/triggerDeviceUpdate`,
|
|
3626
|
-
({ id, type }, { dispatch }) => general_api_default.post(`${import_constants5.deviceConnect}/devices/${id}/${updateTypeMap[type] ?? updateTypeMap.deploymentUpdate}`).catch((err) => commonErrorHandler(err, `The request couldn\u2019t be sent.`, dispatch)).then(() => {
|
|
3627
|
-
dispatch(setSnackbar3("Request has been sent."));
|
|
3628
|
-
return new Promise((resolve) => setTimeout(() => resolve(dispatch(getDeviceById2(id))), TIMEOUTS.threeSeconds));
|
|
3629
|
-
})
|
|
3630
|
-
);
|
|
3631
|
-
var getSessionDetails = createAppAsyncThunk(
|
|
3632
|
-
`${sliceName4}/getSessionDetails`,
|
|
3633
|
-
({ sessionId, deviceId, userId, startDate, endDate }) => {
|
|
3634
|
-
const { start: startUnix, end: endUnix } = (0, import_helpers9.dateRangeToUnix)(startDate, endDate);
|
|
3635
|
-
const createdAfter = startDate ? `&created_after=${startUnix}` : "";
|
|
3636
|
-
const createdBefore = endDate ? `&created_before=${endUnix}` : "";
|
|
3637
|
-
const objectSearch = `&object_id=${deviceId}`;
|
|
3638
|
-
return general_api_default.get(`${import_constants5.auditLogsApiUrl}/logs?per_page=500${createdAfter}${createdBefore}&actor_id=${userId}${objectSearch}`).then(
|
|
3639
|
-
({ data: auditLogEntries }) => {
|
|
3640
|
-
const { start, end } = auditLogEntries.reduce(
|
|
3641
|
-
(accu, item) => {
|
|
3642
|
-
if (item.meta?.session_id?.includes(sessionId)) {
|
|
3643
|
-
accu.start = new Date(item.action.startsWith("open") ? item.time : accu.start);
|
|
3644
|
-
accu.end = new Date(item.action.startsWith("close") ? item.time : accu.end);
|
|
3645
|
-
}
|
|
3646
|
-
return accu;
|
|
3647
|
-
},
|
|
3648
|
-
{ start: startDate || endDate, end: endDate || startDate }
|
|
3649
|
-
);
|
|
3650
|
-
return Promise.resolve({ start, end });
|
|
3651
|
-
}
|
|
3652
|
-
);
|
|
3653
|
-
}
|
|
3654
|
-
);
|
|
3655
|
-
var getDeviceFileDownloadLink = createAppAsyncThunk(
|
|
3656
|
-
`${sliceName4}/getDeviceFileDownloadLink`,
|
|
3657
|
-
({ deviceId, path }) => Promise.resolve(`${window.location.origin}${import_constants5.deviceConnect}/devices/${deviceId}/download?path=${encodeURIComponent(path)}`)
|
|
3658
|
-
);
|
|
3659
|
-
var deviceFileUpload = createAppAsyncThunk(
|
|
3660
|
-
`${sliceName4}/deviceFileUpload`,
|
|
3661
|
-
({ deviceId, path, file }, { dispatch }) => {
|
|
3662
|
-
const formData = new FormData();
|
|
3663
|
-
formData.append("path", path);
|
|
3664
|
-
formData.append("file", file);
|
|
3665
|
-
const uploadId = (0, import_uuid.v4)();
|
|
3666
|
-
const cancelSource = new AbortController();
|
|
3667
|
-
return Promise.all([
|
|
3668
|
-
dispatch(setSnackbar3("Uploading file")),
|
|
3669
|
-
dispatch(initUpload({ id: uploadId, upload: { progress: 0, cancelSource } })),
|
|
3670
|
-
general_api_default.uploadPut(
|
|
3671
|
-
`${import_constants5.deviceConnect}/devices/${deviceId}/upload`,
|
|
3672
|
-
formData,
|
|
3673
|
-
(e) => dispatch(uploadProgress2({ id: uploadId, progress: progress(e) })),
|
|
3674
|
-
cancelSource.signal
|
|
3675
|
-
)
|
|
3676
|
-
]).then(() => Promise.resolve(dispatch(setSnackbar3({ message: "Upload successful", autoHideDuration: TIMEOUTS.fiveSeconds })))).catch((err) => {
|
|
3677
|
-
if ((0, import_axios2.isCancel)(err)) {
|
|
3678
|
-
return dispatch(setSnackbar3({ message: "The upload has been cancelled", autoHideDuration: TIMEOUTS.fiveSeconds }));
|
|
3679
|
-
}
|
|
3680
|
-
return commonErrorHandler(err, `Error uploading file to device.`, dispatch);
|
|
3681
|
-
}).finally(() => dispatch(cleanUpUpload(uploadId)));
|
|
3682
|
-
}
|
|
3683
|
-
);
|
|
3684
|
-
var getDeviceAuth = createAppAsyncThunk(
|
|
3685
|
-
`${sliceName4}/getDeviceAuth`,
|
|
3686
|
-
(id, { dispatch }) => dispatch(getDevicesWithAuth([{ id }])).unwrap().then((results) => {
|
|
3687
|
-
if (results[results.length - 1]) {
|
|
3688
|
-
return Promise.resolve(results[results.length - 1][0]);
|
|
3689
|
-
}
|
|
3690
|
-
return Promise.resolve();
|
|
3691
|
-
})
|
|
3692
|
-
);
|
|
3693
|
-
var getDevicesWithAuth = createAppAsyncThunk(
|
|
3694
|
-
`${sliceName4}/getDevicesWithAuth`,
|
|
3695
|
-
(devices, { dispatch, getState }) => devices.length ? general_api_default.get(`${import_constants5.deviceAuthV2}/devices?id=${devices.map((device) => device.id).join("&id=")}`).then(({ data: receivedDevices }) => {
|
|
3696
|
-
const { devicesById } = reduceReceivedDevices(receivedDevices, [], getState());
|
|
3697
|
-
return Promise.all([dispatch(actions4.receivedDevices(devicesById)), Promise.resolve(receivedDevices)]);
|
|
3698
|
-
}).catch((err) => commonErrorHandler(err, `Error: ${err}`, dispatch)) : Promise.resolve([[], []])
|
|
3699
|
-
);
|
|
3700
|
-
var updateDeviceAuth = createAppAsyncThunk(
|
|
3701
|
-
`${sliceName4}/updateDeviceAuth`,
|
|
3702
|
-
({ deviceId, authId, status }, { dispatch, getState }) => general_api_default.put(`${import_constants5.deviceAuthV2}/devices/${deviceId}/auth/${authId}/status`, { status }).then(() => Promise.all([dispatch(getDeviceAuth(deviceId)), dispatch(setSnackbar3("Device authorization status was updated successfully"))])).catch((err) => commonErrorHandler(err, "There was a problem updating the device authorization status:", dispatch)).then(() => Promise.resolve(dispatch(actions4.maybeUpdateDevicesByStatus({ deviceId, authId })))).finally(() => dispatch(setDeviceListState({ refreshTrigger: !getDeviceListState(getState()).refreshTrigger })))
|
|
3703
|
-
);
|
|
3704
|
-
var updateDevicesAuth = createAppAsyncThunk(
|
|
3705
|
-
`${sliceName4}/updateDevicesAuth`,
|
|
3706
|
-
({ deviceIds, status }, { dispatch, getState }) => {
|
|
3707
|
-
let devices = getDevicesById(getState());
|
|
3708
|
-
const deviceIdsWithoutAuth = deviceIds.reduce((accu, id) => devices[id].auth_sets ? accu : [...accu, { id }], []);
|
|
3709
|
-
return dispatch(getDevicesWithAuth(deviceIdsWithoutAuth)).then(() => {
|
|
3710
|
-
devices = getDevicesById(getState());
|
|
3711
|
-
const deviceAuthUpdates = deviceIds.map((id) => {
|
|
3712
|
-
const device = devices[id];
|
|
3713
|
-
if (device.auth_sets && device.auth_sets.length !== 1) {
|
|
3714
|
-
return Promise.reject();
|
|
3715
|
-
}
|
|
3716
|
-
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));
|
|
3717
|
-
});
|
|
3718
|
-
return Promise.allSettled(deviceAuthUpdates).then((results) => {
|
|
3719
|
-
const { skipped, count } = results.reduce(
|
|
3720
|
-
(accu, item) => {
|
|
3721
|
-
if (item.status === "rejected") {
|
|
3722
|
-
accu.skipped = accu.skipped + 1;
|
|
3723
|
-
} else {
|
|
3724
|
-
accu.count = accu.count + 1;
|
|
3725
|
-
}
|
|
3726
|
-
return accu;
|
|
3727
|
-
},
|
|
3728
|
-
{ skipped: 0, count: 0 }
|
|
3729
|
-
);
|
|
3730
|
-
const message = (0, import_helpers9.getSnackbarMessage)(skipped, count);
|
|
3731
|
-
return dispatch(setSnackbar3(message));
|
|
3732
|
-
});
|
|
3733
|
-
});
|
|
3734
|
-
}
|
|
3735
|
-
);
|
|
3736
|
-
var deleteAuthset = createAppAsyncThunk(
|
|
3737
|
-
`${sliceName4}/deleteAuthset`,
|
|
3738
|
-
({ deviceId, authId }, { dispatch, getState }) => general_api_default.delete(`${import_constants5.deviceAuthV2}/devices/${deviceId}/auth/${authId}`).then(() => Promise.all([dispatch(setSnackbar3("Device authorization status was updated successfully"))])).catch((err) => commonErrorHandler(err, "There was a problem updating the device authorization status:", dispatch)).then(() => Promise.resolve(dispatch(actions4.maybeUpdateDevicesByStatus({ deviceId, authId })))).finally(() => dispatch(setDeviceListState({ refreshTrigger: !getState().devices.deviceList.refreshTrigger })))
|
|
3739
|
-
);
|
|
3740
|
-
var preauthDevice = createAppAsyncThunk(
|
|
3741
|
-
`${sliceName4}/preauthDevice`,
|
|
3742
|
-
(authset, { dispatch, rejectWithValue }) => general_api_default.post(`${import_constants5.deviceAuthV2}/devices`, authset).then(
|
|
3743
|
-
() => Promise.resolve(dispatch(setSnackbar3({ message: "Device was successfully added to the preauthorization list", autoHideDuration: TIMEOUTS.fiveSeconds })))
|
|
3744
|
-
).catch((err) => {
|
|
3745
|
-
if (err.response.status === 409) {
|
|
3746
|
-
return rejectWithValue("A device with a matching identity data set already exists");
|
|
3747
|
-
}
|
|
3748
|
-
return commonErrorHandler(err, "The device could not be added:", dispatch);
|
|
3749
|
-
})
|
|
3750
|
-
);
|
|
3751
|
-
var decommissionDevice = createAppAsyncThunk(
|
|
3752
|
-
`${sliceName4}/decommissionDevice`,
|
|
3753
|
-
({ deviceId, authId }, { dispatch, getState }) => general_api_default.delete(`${import_constants5.deviceAuthV2}/devices/${deviceId}`).then(() => Promise.resolve(dispatch(setSnackbar3("Device was decommissioned successfully")))).catch((err) => commonErrorHandler(err, "There was a problem decommissioning the device:", dispatch)).then(() => Promise.resolve(dispatch(actions4.maybeUpdateDevicesByStatus({ deviceId, authId })))).finally(() => dispatch(setDeviceListState({ refreshTrigger: !getState().devices.deviceList.refreshTrigger })))
|
|
3754
|
-
);
|
|
3755
|
-
var getDeviceConfig = createAppAsyncThunk(
|
|
3756
|
-
`${sliceName4}/getDeviceConfig`,
|
|
3757
|
-
(deviceId, { dispatch }) => general_api_default.get(`${import_constants5.deviceConfig}/${deviceId}`).then(({ data }) => Promise.all([dispatch(actions4.receivedDevice({ id: deviceId, config: data })), Promise.resolve(data)])).catch((err) => {
|
|
3758
|
-
if (err.response?.data?.error.status_code !== 404) {
|
|
3759
|
-
return commonErrorHandler(err, `There was an error retrieving the configuration for device ${deviceId}.`, dispatch, commonErrorFallback);
|
|
3760
|
-
}
|
|
3761
|
-
})
|
|
3762
|
-
);
|
|
3763
|
-
var setDeviceConfig = createAppAsyncThunk(
|
|
3764
|
-
`${sliceName4}/setDeviceConfig`,
|
|
3765
|
-
({ deviceId, config }, { dispatch }) => general_api_default.put(`${import_constants5.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))))
|
|
3766
|
-
);
|
|
3767
|
-
var applyDeviceConfig = createAppAsyncThunk(
|
|
3768
|
-
`${sliceName4}/applyDeviceConfig`,
|
|
3769
|
-
({ deviceId, configDeploymentConfiguration, isDefault, config }, { dispatch, getState }) => general_api_default.post(`${import_constants5.deviceConfig}/${deviceId}/deploy`, configDeploymentConfiguration).catch((err) => commonErrorHandler(err, `There was an error deploying the configuration to device ${deviceId}.`, dispatch, commonErrorFallback)).then(({ data }) => {
|
|
3770
|
-
const device = getDeviceById(getState(), deviceId);
|
|
3771
|
-
const { canManageUsers } = getUserCapabilities(getState());
|
|
3772
|
-
const tasks = [
|
|
3773
|
-
dispatch(actions4.receivedDevice({ ...device, config: { ...device.config, deployment_id: data.deployment_id } })),
|
|
3774
|
-
new Promise((resolve) => setTimeout(() => resolve(dispatch(getSingleDeployment(data.deployment_id))), TIMEOUTS.oneSecond))
|
|
3775
|
-
];
|
|
3776
|
-
if (isDefault && canManageUsers) {
|
|
3777
|
-
const { previous } = getGlobalSettings(getState()).defaultDeviceConfig ?? {};
|
|
3778
|
-
tasks.push(dispatch(saveGlobalSettings({ defaultDeviceConfig: { current: config, previous } })));
|
|
3779
|
-
}
|
|
3780
|
-
return Promise.all(tasks);
|
|
3781
|
-
})
|
|
3782
|
-
);
|
|
3783
|
-
var setDeviceTags = createAppAsyncThunk(
|
|
3784
|
-
`${sliceName4}/setDeviceTags`,
|
|
3785
|
-
({ deviceId, tags }, { dispatch }) => (
|
|
3786
|
-
// to prevent tag set failures, retrieve the device & use the freshest etag we can get
|
|
3787
|
-
dispatch(getDeviceById2(deviceId)).unwrap().then((device) => {
|
|
3788
|
-
const headers = device.etag ? { "If-Match": device.etag } : {};
|
|
3789
|
-
const tagList = Object.entries(tags).map(([name, value]) => ({ name, value }));
|
|
3790
|
-
const isNameChange = tagList.some(({ name }) => name === "name");
|
|
3791
|
-
return general_api_default.put(`${import_constants5.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(
|
|
3792
|
-
() => Promise.all([
|
|
3793
|
-
dispatch(actions4.receivedDevice({ ...device, id: deviceId, tags })),
|
|
3794
|
-
dispatch(setSnackbar3(`Device ${tagList.length === 1 && isNameChange ? "name" : "tags"} changed`))
|
|
3795
|
-
])
|
|
3796
|
-
);
|
|
3797
|
-
})
|
|
3798
|
-
)
|
|
3799
|
-
);
|
|
3800
|
-
var getDeviceTwin = createAppAsyncThunk(`${sliceName4}/getDeviceTwin`, ({ deviceId, integration }, { dispatch, getState }) => {
|
|
3801
|
-
let providerResult = {};
|
|
3802
|
-
return general_api_default.get(`${import_constants5.iotManagerBaseURL}/devices/${deviceId}/state`).then(({ data }) => {
|
|
3803
|
-
providerResult = { ...data, twinError: "" };
|
|
3804
|
-
}).catch((err) => {
|
|
3805
|
-
providerResult = {
|
|
3806
|
-
twinError: `There was an error getting the ${EXTERNAL_PROVIDER[integration.provider].twinTitle.toLowerCase()} for device ${deviceId}. ${err}`
|
|
3807
|
-
};
|
|
3808
|
-
}).finally(() => {
|
|
3809
|
-
const device = getDeviceById(getState(), deviceId);
|
|
3810
|
-
Promise.resolve(dispatch(actions4.receivedDevice({ ...device, twinsByIntegration: { ...device.twinsByIntegration, ...providerResult } })));
|
|
3811
|
-
});
|
|
3812
|
-
});
|
|
3813
|
-
var setDeviceTwin = createAppAsyncThunk(
|
|
3814
|
-
`${sliceName4}/setDeviceTwin`,
|
|
3815
|
-
({ deviceId, integration, settings }, { dispatch, getState }) => general_api_default.put(`${import_constants5.iotManagerBaseURL}/devices/${deviceId}/state/${integration.id}`, { desired: settings }).catch(
|
|
3816
|
-
(err) => commonErrorHandler(
|
|
3817
|
-
err,
|
|
3818
|
-
`There was an error updating the ${EXTERNAL_PROVIDER[integration.provider].twinTitle.toLowerCase()} for device ${deviceId}.`,
|
|
3819
|
-
dispatch
|
|
3820
|
-
)
|
|
3821
|
-
).then(() => {
|
|
3822
|
-
const device = getDeviceById(getState(), deviceId);
|
|
3823
|
-
const { twinsByIntegration = {} } = device;
|
|
3824
|
-
const { [integration.id]: currentState = {} } = twinsByIntegration;
|
|
3825
|
-
return Promise.resolve(
|
|
3826
|
-
dispatch(
|
|
3827
|
-
actions4.receivedDevice({ ...device, twinsByIntegration: { ...twinsByIntegration, [integration.id]: { ...currentState, desired: settings } } })
|
|
3828
|
-
)
|
|
3829
|
-
);
|
|
3830
|
-
})
|
|
3831
|
-
);
|
|
3832
|
-
var prepareSearchArguments = ({ filters, group, state, status }) => {
|
|
3833
|
-
const { filterTerms } = convertDeviceListStateToFilters({ filters, group, offlineThreshold: state.app.offlineThreshold, selectedIssues: [], status });
|
|
3834
|
-
const { columnSelection = [] } = getUserSettings(state);
|
|
3835
|
-
const selectedAttributes = columnSelection.map((column) => ({ attribute: column.key, scope: column.scope }));
|
|
3836
|
-
const attributes = [...defaultAttributes, getIdAttribute(state), ...selectedAttributes];
|
|
3837
|
-
return { attributes, filterTerms };
|
|
3838
|
-
};
|
|
3839
|
-
var getSystemDevices = createAppAsyncThunk(`${sliceName4}/getSystemDevices`, (options, { dispatch, getState }) => {
|
|
3840
|
-
const { id, page = defaultPage2, perPage = defaultPerPage2, sortOptions = [] } = options;
|
|
3841
|
-
const state = getState();
|
|
3842
|
-
const { hasFullFiltering } = getTenantCapabilities(state);
|
|
3843
|
-
if (!hasFullFiltering) {
|
|
3844
|
-
return Promise.resolve();
|
|
3845
|
-
}
|
|
3846
|
-
const { attributes: deviceAttributes = {} } = getDeviceById(state, id);
|
|
3847
|
-
const { mender_gateway_system_id = "" } = deviceAttributes;
|
|
3848
|
-
const filters = [
|
|
3849
|
-
{ ...emptyFilter, key: "mender_is_gateway", operator: import_constants5.DEVICE_FILTERING_OPTIONS.$ne.key, value: "true", scope: "inventory" },
|
|
3850
|
-
{ ...emptyFilter, key: "mender_gateway_system_id", value: mender_gateway_system_id, scope: "inventory" }
|
|
3851
|
-
];
|
|
3852
|
-
const { attributes, filterTerms } = prepareSearchArguments({ filters, state });
|
|
3853
|
-
return general_api_default.post(`${import_constants5.inventoryApiUrlV2}/filters/search`, {
|
|
3854
|
-
page,
|
|
3855
|
-
per_page: perPage,
|
|
3856
|
-
filters: filterTerms,
|
|
3857
|
-
sort: sortOptions,
|
|
3858
|
-
attributes
|
|
3859
|
-
}).catch((err) => commonErrorHandler(err, `There was an error getting system devices device ${id}.`, dispatch, "Please check your connection.")).then(({ data, headers }) => {
|
|
3860
|
-
const state2 = getState();
|
|
3861
|
-
const { devicesById, ids } = reduceReceivedDevices(data, [], state2);
|
|
3862
|
-
const device = {
|
|
3863
|
-
...getDeviceById(state2, id),
|
|
3864
|
-
systemDeviceIds: ids,
|
|
3865
|
-
systemDeviceTotal: Number(headers[import_constants5.headerNames.total])
|
|
3866
|
-
};
|
|
3867
|
-
return Promise.resolve(dispatch(actions4.receivedDevices({ ...devicesById, [id]: device })));
|
|
3868
|
-
});
|
|
3869
|
-
});
|
|
3870
|
-
var getGatewayDevices = createAppAsyncThunk(`${sliceName4}/getGatewayDevices`, (deviceId, { dispatch, getState }) => {
|
|
3871
|
-
const state = getState();
|
|
3872
|
-
const { attributes = {} } = getDeviceById(state, deviceId);
|
|
3873
|
-
const { mender_gateway_system_id = "" } = attributes;
|
|
3874
|
-
const filters = [
|
|
3875
|
-
{ ...emptyFilter, key: "id", operator: import_constants5.DEVICE_FILTERING_OPTIONS.$ne.key, value: deviceId, scope: "identity" },
|
|
3876
|
-
{ ...emptyFilter, key: "mender_is_gateway", value: "true", scope: "inventory" },
|
|
3877
|
-
{ ...emptyFilter, key: "mender_gateway_system_id", value: mender_gateway_system_id, scope: "inventory" }
|
|
3878
|
-
];
|
|
3879
|
-
const { attributes: attributeSelection, filterTerms } = prepareSearchArguments({ filters, state });
|
|
3880
|
-
return general_api_default.post(`${import_constants5.inventoryApiUrlV2}/filters/search`, {
|
|
3881
|
-
page: 1,
|
|
3882
|
-
per_page: MAX_PAGE_SIZE,
|
|
3883
|
-
filters: filterTerms,
|
|
3884
|
-
attributes: attributeSelection
|
|
3885
|
-
}).then(({ data }) => {
|
|
3886
|
-
const { ids } = reduceReceivedDevices(data, [], getState());
|
|
3887
|
-
const tasks = ids.map((deviceId2) => dispatch(getDeviceInfo(deviceId2)));
|
|
3888
|
-
tasks.push(dispatch(actions4.receivedDevice({ id: deviceId, gatewayIds: ids })));
|
|
3889
|
-
return Promise.all(tasks);
|
|
3890
|
-
});
|
|
3891
|
-
});
|
|
3892
|
-
|
|
3893
|
-
// src/monitorSlice/thunks.ts
|
|
3894
|
-
var { page: defaultPage3, perPage: defaultPerPage3 } = import_constants5.DEVICE_LIST_DEFAULTS;
|
|
3895
|
-
var cutoffLength = 75;
|
|
3896
|
-
var ellipsis = "...";
|
|
3897
|
-
var longTextTrimmer = (text) => text.length >= cutoffLength + ellipsis.length ? `${text.substring(0, cutoffLength + ellipsis.length)}${ellipsis}` : text;
|
|
3898
|
-
var sanitizeDeviceAlerts = (alerts) => alerts.map((alert) => ({ ...alert, fullName: alert.name, name: longTextTrimmer(alert.name || "") }));
|
|
3899
|
-
var getDeviceAlerts = createAppAsyncThunk(`${sliceName5}/getDeviceAlerts`, ({ id, config = {} }, { dispatch }) => {
|
|
3900
|
-
const { page = defaultPage3, perPage = defaultPerPage3, issuedBefore, issuedAfter, sortAscending = false } = config;
|
|
3901
|
-
const issued_after = issuedAfter ? `&issued_after=${issuedAfter}` : "";
|
|
3902
|
-
const issued_before = issuedBefore ? `&issued_before=${issuedBefore}` : "";
|
|
3903
|
-
return general_api_default.get(
|
|
3904
|
-
`${import_constants5.monitorApiUrlv1}/devices/${id}/alerts?page=${page}&per_page=${perPage}${issued_after}${issued_before}&sort_ascending=${sortAscending}`
|
|
3905
|
-
).catch((err) => commonErrorHandler(err, `Retrieving device alerts for device ${id} failed:`, dispatch)).then(
|
|
3906
|
-
(res) => Promise.all([
|
|
3907
|
-
dispatch(actions5.receiveDeviceAlerts({ deviceId: id, alerts: sanitizeDeviceAlerts(res.data) })),
|
|
3908
|
-
dispatch(actions5.setAlertListState({ total: Number(res.headers[import_constants5.headerNames.total]) }))
|
|
3909
|
-
])
|
|
3910
|
-
);
|
|
3911
|
-
});
|
|
3912
|
-
var getLatestDeviceAlerts = createAppAsyncThunk(
|
|
3913
|
-
`${sliceName5}/getLatestDeviceAlerts`,
|
|
3914
|
-
({ id, config = {} }, { dispatch }) => {
|
|
3915
|
-
const { page = defaultPage3, perPage = 10 } = config;
|
|
3916
|
-
return general_api_default.get(`${import_constants5.monitorApiUrlv1}/devices/${id}/alerts/latest?page=${page}&per_page=${perPage}`).catch((err) => commonErrorHandler(err, `Retrieving device alerts for device ${id} failed:`, dispatch)).then((res) => Promise.resolve(dispatch(actions5.receiveLatestDeviceAlerts({ deviceId: id, alerts: sanitizeDeviceAlerts(res.data) }))));
|
|
3917
|
-
}
|
|
3918
|
-
);
|
|
3919
|
-
var getIssueCountsByType2 = createAppAsyncThunk(
|
|
3920
|
-
`${sliceName5}/getIssueCountsByType`,
|
|
3921
|
-
({ type, options = {} }, { dispatch, getState }) => {
|
|
3922
|
-
const state = getState();
|
|
3923
|
-
const { filters = getDeviceFilters(state), group, status, ...remainder } = options;
|
|
3924
|
-
const { applicableFilters: nonMonitorFilters, filterTerms } = convertDeviceListStateToFilters({
|
|
3925
|
-
...remainder,
|
|
3926
|
-
filters,
|
|
3927
|
-
group,
|
|
3928
|
-
offlineThreshold: state.app.offlineThreshold,
|
|
3929
|
-
selectedIssues: [type],
|
|
3930
|
-
status
|
|
3931
|
-
});
|
|
3932
|
-
return general_api_default.post(`${import_constants5.inventoryApiUrlV2}/filters/search`, {
|
|
3933
|
-
page: 1,
|
|
3934
|
-
per_page: 1,
|
|
3935
|
-
filters: filterTerms,
|
|
3936
|
-
attributes: [{ scope: "identity", attribute: "status" }]
|
|
3937
|
-
}).catch((err) => commonErrorHandler(err, `Retrieving issue counts failed:`, dispatch, commonErrorFallback)).then((res) => {
|
|
3938
|
-
const total = nonMonitorFilters.length ? state.monitor.issueCounts.byType[type].total : Number(res.headers[import_constants5.headerNames.total]);
|
|
3939
|
-
const filtered = nonMonitorFilters.length ? Number(res.headers[import_constants5.headerNames.total]) : total;
|
|
3940
|
-
if (total === state.monitor.issueCounts.byType[type].total && filtered === state.monitor.issueCounts.byType[type].filtered) {
|
|
3941
|
-
return Promise.resolve();
|
|
3942
|
-
}
|
|
3943
|
-
return Promise.resolve(dispatch(actions5.receiveDeviceIssueCounts({ counts: { filtered, total }, issueType: type })));
|
|
3944
|
-
});
|
|
3945
|
-
}
|
|
3946
|
-
);
|
|
3947
|
-
var getDeviceMonitorConfig = createAppAsyncThunk(
|
|
3948
|
-
`${sliceName5}/getDeviceMonitorConfig`,
|
|
3949
|
-
(id, { dispatch }) => general_api_default.get(`${import_constants5.monitorApiUrlv1}/devices/${id}/config`).catch((err) => commonErrorHandler(err, `Retrieving device monitor config for device ${id} failed:`, dispatch)).then(({ data }) => Promise.all([dispatch(actions_default.receivedDevice({ id, monitors: data }), Promise.resolve(data))]))
|
|
3950
|
-
);
|
|
3951
|
-
var changeNotificationSetting = createAppAsyncThunk(
|
|
3952
|
-
`${sliceName5}/changeNotificationSetting`,
|
|
3953
|
-
({ enabled, channel = import_constants5.alertChannels.email }, { dispatch }) => general_api_default.put(`${import_constants5.monitorApiUrlv1}/settings/global/channel/alerts/${channel}/status`, { enabled }).catch((err) => commonErrorHandler(err, `${enabled ? "En" : "Dis"}abling ${channel} alerts failed:`, dispatch)).then(
|
|
3954
|
-
() => Promise.all([
|
|
3955
|
-
dispatch(actions5.changeAlertChannel({ channel, enabled })),
|
|
3956
|
-
dispatch(
|
|
3957
|
-
actions_default.setSnackbar({ message: `Successfully ${enabled ? "en" : "dis"}abled ${channel} alerts`, autoHideDuration: TIMEOUTS.fiveSeconds })
|
|
3958
|
-
)
|
|
3959
|
-
])
|
|
3960
|
-
)
|
|
3961
|
-
);
|
|
3962
|
-
|
|
3963
|
-
// src/usersSlice/thunks.ts
|
|
3964
|
-
var import_helpers10 = require("@northern.tech/utils/helpers");
|
|
3965
|
-
var import_retrytimer = require("@northern.tech/utils/retrytimer");
|
|
3966
|
-
var import_dayjs2 = __toESM(require("dayjs"), 1);
|
|
3967
|
-
var import_md5 = __toESM(require("md5"), 1);
|
|
3968
|
-
var import_universal_cookie4 = __toESM(require("universal-cookie"), 1);
|
|
3969
|
-
|
|
3970
|
-
// src/api/users-api.ts
|
|
3971
|
-
var import_axios3 = __toESM(require("axios"), 1);
|
|
3972
|
-
var Api2 = {
|
|
3973
|
-
postLogin: (url, { email: username, password, ...body }) => import_axios3.default.post(url, body, { ...commonRequestConfig, auth: { username, password } }).then((res) => ({ text: res.data, code: res.status, contentType: res.headers?.["content-type"] })),
|
|
3974
|
-
putVerifyTFA: (url, userData) => {
|
|
3975
|
-
let body = {};
|
|
3976
|
-
if (userData.hasOwnProperty("token2fa")) {
|
|
3977
|
-
body = { token2fa: userData.token2fa };
|
|
3978
|
-
}
|
|
3979
|
-
return import_axios3.default.put(url, body, { ...commonRequestConfig, headers: { ...commonRequestConfig.headers, Authorization: `Bearer ${getToken()}` } });
|
|
3980
|
-
}
|
|
3981
|
-
};
|
|
3982
|
-
var users_api_default = Api2;
|
|
3983
|
-
|
|
3984
|
-
// src/usersSlice/thunks.ts
|
|
3985
|
-
var cookies4 = new import_universal_cookie4.default();
|
|
3986
|
-
var { setAnnouncement, setSnackbar: setSnackbar4 } = actions_default;
|
|
3987
|
-
var handleLoginError = (err, { token2fa: has2FA, password }, rejectWithValue) => () => {
|
|
3988
|
-
const errorText = (0, import_helpers10.extractErrorMessage)(err);
|
|
3989
|
-
const is2FABackend = errorText.includes("2fa");
|
|
3990
|
-
if (is2FABackend && !has2FA) {
|
|
3991
|
-
return rejectWithValue({ error: "2fa code missing" });
|
|
3992
|
-
}
|
|
3993
|
-
if (password === void 0) {
|
|
3994
|
-
return Promise.reject();
|
|
3995
|
-
}
|
|
3996
|
-
const twoFAError = is2FABackend ? " and verification code" : "";
|
|
3997
|
-
const errorMessage = `There was a problem logging in. Please check your email${twoFAError ? "," : " and"} password${twoFAError}. If you still have problems, contact an administrator.`;
|
|
3998
|
-
return rejectWithValue({ error: errorMessage });
|
|
3999
|
-
};
|
|
4000
|
-
var loginUser = createAppAsyncThunk(
|
|
4001
|
-
`${sliceName8}/loginUser`,
|
|
4002
|
-
({ stayLoggedIn, ...userData }, { dispatch, rejectWithValue }) => users_api_default.postLogin(`${import_constants5.useradmApiUrl}/auth/login`, { ...userData, no_expiry: stayLoggedIn }).catch((err) => {
|
|
4003
|
-
cleanUp();
|
|
4004
|
-
return Promise.reject(dispatch(handleLoginError(err, userData, rejectWithValue)));
|
|
4005
|
-
}).then(({ text: token, contentType }) => {
|
|
4006
|
-
if (contentType.includes(import_constants5.APPLICATION_JSON_CONTENT_TYPE)) {
|
|
4007
|
-
const { id, kind } = token;
|
|
4008
|
-
const type = kind.split("/")[1];
|
|
4009
|
-
const ssoLoginUrl = SSO_TYPES[type].getStartUrl(id);
|
|
4010
|
-
window.location.replace(ssoLoginUrl);
|
|
4011
|
-
return;
|
|
4012
|
-
}
|
|
4013
|
-
if (contentType !== import_constants5.APPLICATION_JWT_CONTENT_TYPE || !token) {
|
|
4014
|
-
return;
|
|
4015
|
-
}
|
|
4016
|
-
const now = /* @__PURE__ */ new Date();
|
|
4017
|
-
now.setSeconds(now.getSeconds() + import_constants5.maxSessionAge);
|
|
4018
|
-
const expiresAt = stayLoggedIn ? void 0 : now.toISOString();
|
|
4019
|
-
setSessionInfo({ token, expiresAt });
|
|
4020
|
-
cookies4.remove("JWT", { path: "/" });
|
|
4021
|
-
return dispatch(getUser(OWN_USER_ID)).unwrap().catch((e) => {
|
|
4022
|
-
cleanUp();
|
|
4023
|
-
return Promise.reject(dispatch(setSnackbar4((0, import_helpers10.extractErrorMessage)(e))));
|
|
4024
|
-
}).then(() => {
|
|
4025
|
-
window.sessionStorage.removeItem("pendings-redirect");
|
|
4026
|
-
if (window.location.pathname !== "/ui/") {
|
|
4027
|
-
window.location.replace("/ui/");
|
|
4028
|
-
}
|
|
4029
|
-
return Promise.resolve(dispatch(actions8.successfullyLoggedIn({ expiresAt, token })));
|
|
4030
|
-
});
|
|
4031
|
-
})
|
|
4032
|
-
);
|
|
4033
|
-
var logoutUser = createAppAsyncThunk(`${sliceName8}/logoutUser`, (_, { dispatch, getState }) => {
|
|
4034
|
-
if (Object.keys(getState().app.uploadsById).length) {
|
|
4035
|
-
return Promise.reject();
|
|
4036
|
-
}
|
|
4037
|
-
return general_api_default.post(`${import_constants5.useradmApiUrl}/auth/logout`).finally(() => {
|
|
4038
|
-
cleanUp();
|
|
4039
|
-
(0, import_retrytimer.clearAllRetryTimers)(setSnackbar4);
|
|
4040
|
-
return Promise.resolve(dispatch({ type: USER_LOGOUT }));
|
|
4041
|
-
});
|
|
4042
|
-
});
|
|
4043
|
-
var switchUserOrganization = createAppAsyncThunk(`${sliceName8}/switchUserOrganization`, (tenantId, { getState }) => {
|
|
4044
|
-
if (Object.keys(getState().app.uploadsById).length) {
|
|
4045
|
-
return Promise.reject();
|
|
4046
|
-
}
|
|
4047
|
-
return general_api_default.get(`${import_constants5.useradmApiUrl}/users/tenants/${tenantId}/token`).then(({ data: token }) => {
|
|
4048
|
-
window.sessionStorage.setItem("tenantChanged", "true");
|
|
4049
|
-
setSessionInfo({ ...getSessionInfo(), token });
|
|
4050
|
-
window.location.reload();
|
|
4051
|
-
});
|
|
4052
|
-
});
|
|
4053
|
-
var passwordResetStart = createAppAsyncThunk(
|
|
4054
|
-
`${sliceName8}/passwordResetStart`,
|
|
4055
|
-
(email, { dispatch }) => general_api_default.post(`${import_constants5.useradmApiUrl}/auth/password-reset/start`, { email }).catch(
|
|
4056
|
-
(err) => commonErrorHandler(err, `The password reset request cannot be processed:`, dispatch, void 0, true)
|
|
4057
|
-
)
|
|
4058
|
-
);
|
|
4059
|
-
var passwordResetComplete = createAppAsyncThunk(
|
|
4060
|
-
`${sliceName8}/passwordResetComplete`,
|
|
4061
|
-
({ secretHash, newPassword }, { dispatch }) => general_api_default.post(`${import_constants5.useradmApiUrl}/auth/password-reset/complete`, { secret_hash: secretHash, password: newPassword }).catch((err = {}) => {
|
|
4062
|
-
const { error, response = {} } = err;
|
|
4063
|
-
let errorMsg = "";
|
|
4064
|
-
if (response.status == 400) {
|
|
4065
|
-
errorMsg = "the link you are using expired or the request is not valid, please try again.";
|
|
4066
|
-
} else {
|
|
4067
|
-
errorMsg = error;
|
|
4068
|
-
}
|
|
4069
|
-
dispatch(setSnackbar4("The password reset request cannot be processed: " + errorMsg));
|
|
4070
|
-
return Promise.reject(err);
|
|
4071
|
-
})
|
|
4072
|
-
);
|
|
4073
|
-
var verifyEmailStart = createAppAsyncThunk(
|
|
4074
|
-
`${sliceName8}/verifyEmailStart`,
|
|
4075
|
-
(_, { dispatch, getState }) => general_api_default.post(`${import_constants5.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))))
|
|
4076
|
-
);
|
|
4077
|
-
var verifyEmailComplete = createAppAsyncThunk(
|
|
4078
|
-
`${sliceName8}/verifyEmailComplete`,
|
|
4079
|
-
(secret_hash, { dispatch, rejectWithValue }) => general_api_default.post(`${import_constants5.useradmApiUrl}/auth/verify-email/complete`, { secret_hash }).catch((err) => rejectWithValue({ status: err.response?.status, data: err.response?.data })).finally(() => Promise.resolve(dispatch(getUser(OWN_USER_ID))))
|
|
4080
|
-
);
|
|
4081
|
-
var verify2FA = createAppAsyncThunk(
|
|
4082
|
-
`${sliceName8}/verify2FA`,
|
|
4083
|
-
(tfaData, { dispatch }) => users_api_default.putVerifyTFA(`${import_constants5.useradmApiUrl}/2faverify`, tfaData).then(() => Promise.resolve(dispatch(getUser(OWN_USER_ID)))).catch(
|
|
4084
|
-
(err) => commonErrorHandler(err, "An error occured validating the verification code: failed to verify token, please try again.", dispatch, void 0, true)
|
|
4085
|
-
)
|
|
4086
|
-
);
|
|
4087
|
-
var getUserList = createAppAsyncThunk(
|
|
4088
|
-
`${sliceName8}/getUserList`,
|
|
4089
|
-
(_, { dispatch, getState }) => general_api_default.get(`${import_constants5.useradmApiUrl}/users`).then((res) => {
|
|
4090
|
-
const currentUsersById = getUsersById(getState());
|
|
4091
|
-
const users = res.data.reduce(
|
|
4092
|
-
(accu, item) => {
|
|
4093
|
-
accu[item.id] = {
|
|
4094
|
-
...accu[item.id],
|
|
4095
|
-
...item
|
|
4096
|
-
};
|
|
4097
|
-
return accu;
|
|
4098
|
-
},
|
|
4099
|
-
{ ...currentUsersById }
|
|
4100
|
-
);
|
|
4101
|
-
return dispatch(actions8.receivedUserList(users));
|
|
4102
|
-
}).catch((err) => commonErrorHandler(err, `Users couldn't be loaded.`, dispatch, commonErrorFallback))
|
|
4103
|
-
);
|
|
4104
|
-
var getUser = createAppAsyncThunk(
|
|
4105
|
-
`${sliceName8}/getUser`,
|
|
4106
|
-
(id, { dispatch, rejectWithValue }) => general_api_default.get(`${import_constants5.useradmApiUrl}/users/${id}`).then(
|
|
4107
|
-
({ data: user }) => Promise.all([
|
|
4108
|
-
dispatch(actions8.receivedUser(user)),
|
|
4109
|
-
dispatch(setHideAnnouncement({ shouldHide: false, userId: user.id })),
|
|
4110
|
-
dispatch(updateUserColumnSettings({ currentUserId: user.id })),
|
|
4111
|
-
user
|
|
4112
|
-
])
|
|
4113
|
-
).catch((e) => rejectWithValue(e))
|
|
4114
|
-
);
|
|
4115
|
-
var initializeSelf = createAppAsyncThunk(`${sliceName8}/initializeSelf`, (_, { dispatch }) => dispatch(getUser(OWN_USER_ID)));
|
|
4116
|
-
var updateUserColumnSettings = createAppAsyncThunk(
|
|
4117
|
-
`${sliceName8}/updateUserColumnSettings`,
|
|
4118
|
-
({ columns, currentUserId }, { dispatch, getState }) => {
|
|
4119
|
-
const userId = currentUserId ?? getCurrentUser(getState()).id;
|
|
4120
|
-
const storageKey = `${userId}-column-widths`;
|
|
4121
|
-
let customColumns = [];
|
|
4122
|
-
if (!columns) {
|
|
4123
|
-
try {
|
|
4124
|
-
customColumns = JSON.parse(window.localStorage.getItem(storageKey) || "") || customColumns;
|
|
4125
|
-
} catch {
|
|
4126
|
-
}
|
|
4127
|
-
} else {
|
|
4128
|
-
customColumns = columns;
|
|
4129
|
-
}
|
|
4130
|
-
window.localStorage.setItem(storageKey, JSON.stringify(customColumns));
|
|
4131
|
-
return Promise.resolve(dispatch(actions8.setCustomColumns(customColumns)));
|
|
4132
|
-
}
|
|
4133
|
-
);
|
|
4134
|
-
var userActions = {
|
|
4135
|
-
add: {
|
|
4136
|
-
successMessage: "The user was added successfully.",
|
|
4137
|
-
errorMessage: "adding"
|
|
4138
|
-
},
|
|
4139
|
-
create: {
|
|
4140
|
-
successMessage: "The user was created successfully.",
|
|
4141
|
-
errorMessage: "creating"
|
|
4142
|
-
},
|
|
4143
|
-
edit: {
|
|
4144
|
-
successMessage: "The user has been updated.",
|
|
4145
|
-
errorMessage: "editing"
|
|
4146
|
-
},
|
|
4147
|
-
remove: {
|
|
4148
|
-
successMessage: "The user was removed from the system.",
|
|
4149
|
-
errorMessage: "removing"
|
|
4150
|
-
}
|
|
4151
|
-
};
|
|
4152
|
-
var userActionErrorHandler = (err, type, dispatch) => commonErrorHandler(err, `There was an error ${userActions[type].errorMessage} the user.`, dispatch);
|
|
4153
|
-
var createUser = createAppAsyncThunk(
|
|
4154
|
-
`${sliceName8}/createUser`,
|
|
4155
|
-
({ shouldResetPassword, ...userData }, { dispatch }) => general_api_default.post(`${import_constants5.useradmApiUrl}/users`, { ...userData, send_reset_password: shouldResetPassword }).then(() => Promise.all([dispatch(getUserList()), dispatch(setSnackbar4(userActions.create.successMessage))])).catch((err) => userActionErrorHandler(err, "create", dispatch))
|
|
4156
|
-
);
|
|
4157
|
-
var removeUser = createAppAsyncThunk(
|
|
4158
|
-
`${sliceName8}/removeUser`,
|
|
4159
|
-
(userId, { dispatch }) => general_api_default.delete(`${import_constants5.useradmApiUrl}/users/${userId}`).then(() => Promise.all([dispatch(actions8.removedUser(userId)), dispatch(getUserList()), dispatch(setSnackbar4(userActions.remove.successMessage))])).catch((err) => userActionErrorHandler(err, "remove", dispatch))
|
|
4160
|
-
);
|
|
4161
|
-
var editUser = createAppAsyncThunk(
|
|
4162
|
-
`${sliceName8}/editUser`,
|
|
4163
|
-
({ id, ...userData }, { dispatch, getState }) => general_api_default.put(`${import_constants5.useradmApiUrl}/users/${id}`, userData).then(
|
|
4164
|
-
() => Promise.all([
|
|
4165
|
-
dispatch(actions8.updatedUser({ ...userData, id: id === OWN_USER_ID ? getCurrentUser(getState()).id : id })),
|
|
4166
|
-
dispatch(setSnackbar4(userActions.edit.successMessage))
|
|
4167
|
-
])
|
|
4168
|
-
).catch((err) => userActionErrorHandler(err, "edit", dispatch))
|
|
4169
|
-
);
|
|
4170
|
-
var checkEmailExists = createAppAsyncThunk(`${sliceName8}/checkEmailExists`, async (email) => {
|
|
4171
|
-
const response = await general_api_default.get(`${import_constants5.useradmApiUrl}/users/exists?email=${encodeURIComponent(email)}`);
|
|
4172
|
-
return response.data.exists;
|
|
4173
|
-
});
|
|
4174
|
-
var addUserToCurrentTenant = createAppAsyncThunk(`${sliceName8}/addUserToTenant`, (userId, { dispatch, getState }) => {
|
|
4175
|
-
const { id } = getOrganization(getState());
|
|
4176
|
-
return general_api_default.post(`${import_constants5.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())]));
|
|
4177
|
-
});
|
|
4178
|
-
var enableUser2fa = createAppAsyncThunk(
|
|
4179
|
-
`${sliceName8}/enableUser2fa`,
|
|
4180
|
-
(userId = OWN_USER_ID, { dispatch }) => general_api_default.post(`${import_constants5.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))))
|
|
4181
|
-
);
|
|
4182
|
-
var disableUser2fa = createAppAsyncThunk(
|
|
4183
|
-
`${sliceName8}/disableUser2fa`,
|
|
4184
|
-
(userId = OWN_USER_ID, { dispatch }) => general_api_default.post(`${import_constants5.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(actions8.receivedQrCode(null))]))
|
|
4185
|
-
);
|
|
4186
|
-
var mapHttpPermission = (permission) => Object.entries(import_constants5.uiPermissionsByArea).reduce(
|
|
4187
|
-
(accu, [area, definition]) => {
|
|
4188
|
-
const endpointMatches = definition.endpoints.filter(
|
|
4189
|
-
(endpoint) => endpoint.path.test(permission.value) && (endpoint.types.includes(permission.type) || permission.type === import_constants5.PermissionTypes.Any)
|
|
4190
|
-
);
|
|
4191
|
-
if (permission.value === import_constants5.PermissionTypes.Any || permission.value.includes(import_constants5.apiRoot) && endpointMatches.length) {
|
|
4192
|
-
const endpointUiPermission = endpointMatches.reduce((endpointAccu, endpoint) => [...endpointAccu, ...endpoint.uiPermissions], []);
|
|
4193
|
-
const collector = (endpointUiPermission || definition.uiPermissions).reduce((permissionsAccu, uiPermission) => {
|
|
4194
|
-
if (permission.type === import_constants5.PermissionTypes.Any || !endpointMatches.length && uiPermission.verbs.some((verb) => verb === permission.type)) {
|
|
4195
|
-
permissionsAccu.push(uiPermission.value);
|
|
4196
|
-
}
|
|
4197
|
-
return permissionsAccu;
|
|
4198
|
-
}, []).filter(import_helpers10.duplicateFilter);
|
|
4199
|
-
if (Array.isArray(accu[area])) {
|
|
4200
|
-
accu[area] = [...accu[area], ...collector].filter(import_helpers10.duplicateFilter);
|
|
4201
|
-
} else {
|
|
4202
|
-
accu[area] = mergePermissions(accu[area], { [import_constants5.scopedPermissionAreas[area].excessiveAccessSelector]: collector });
|
|
4203
|
-
}
|
|
4204
|
-
}
|
|
4205
|
-
return accu;
|
|
4206
|
-
},
|
|
4207
|
-
{ ...import_constants5.emptyUiPermissions }
|
|
4208
|
-
);
|
|
4209
|
-
var permissionActionTypes = {
|
|
4210
|
-
any: mapHttpPermission,
|
|
4211
|
-
CREATE_DEPLOYMENT: (permission) => permission.type === import_constants5.PermissionTypes.DeviceGroup ? {
|
|
4212
|
-
deployments: [import_constants5.uiPermissionsById.deploy.value],
|
|
4213
|
-
groups: { [permission.value]: [import_constants5.uiPermissionsById.deploy.value] }
|
|
4214
|
-
} : {},
|
|
4215
|
-
http: mapHttpPermission,
|
|
4216
|
-
REMOTE_TERMINAL: (permission) => permission.type === import_constants5.PermissionTypes.DeviceGroup ? {
|
|
4217
|
-
groups: { [permission.value]: [import_constants5.uiPermissionsById.connect.value] }
|
|
4218
|
-
} : {},
|
|
4219
|
-
VIEW_DEVICE: (permission) => permission.type === import_constants5.PermissionTypes.DeviceGroup ? {
|
|
4220
|
-
groups: { [permission.value]: [import_constants5.uiPermissionsById.read.value] }
|
|
4221
|
-
} : {}
|
|
4222
|
-
};
|
|
4223
|
-
var combinePermissions = (existingPermissions, additionalPermissions = {}) => Object.entries(additionalPermissions).reduce((accu, [name, permissions]) => {
|
|
4224
|
-
const maybeExistingPermissions = accu[name] || [];
|
|
4225
|
-
accu[name] = [...permissions, ...maybeExistingPermissions].filter(import_helpers10.duplicateFilter);
|
|
4226
|
-
return accu;
|
|
4227
|
-
}, existingPermissions);
|
|
4228
|
-
var tryParseCustomPermission = (permission) => {
|
|
4229
|
-
const uiPermissions = permissionActionTypes[permission.action](permission.object);
|
|
4230
|
-
const result = mergePermissions({ ...import_constants5.emptyUiPermissions }, uiPermissions);
|
|
4231
|
-
return { isCustom: true, permission, result };
|
|
4232
|
-
};
|
|
4233
|
-
var customPermissionHandler = (accu, permission) => {
|
|
4234
|
-
const processor = tryParseCustomPermission(permission);
|
|
4235
|
-
return {
|
|
4236
|
-
...accu,
|
|
4237
|
-
isCustom: accu.isCustom || processor.isCustom,
|
|
4238
|
-
uiPermissions: mergePermissions(accu.uiPermissions, processor.result)
|
|
4239
|
-
};
|
|
4240
|
-
};
|
|
4241
|
-
var mapPermissionSet = (permissionSetName, names, scope, existingGroupsPermissions = {}) => {
|
|
4242
|
-
const permission = Object.values(import_constants5.uiPermissionsById).find((permission2) => permission2.permissionSets[scope] === permissionSetName)?.value;
|
|
4243
|
-
const scopedPermissions = names.reduce((accu, name) => combinePermissions(accu, { [name]: [permission] }), existingGroupsPermissions);
|
|
4244
|
-
return Object.entries(scopedPermissions).reduce((accu, [key, permissions]) => ({ ...accu, [key]: deriveImpliedAreaPermissions(scope, permissions) }), {});
|
|
4245
|
-
};
|
|
4246
|
-
var isEmptyPermissionSet = (permissionSet) => !Object.values(permissionSet).reduce((accu, permissions) => {
|
|
4247
|
-
if (Array.isArray(permissions)) {
|
|
4248
|
-
return accu || !!permissions.length;
|
|
4249
|
-
}
|
|
4250
|
-
return accu || !(0, import_helpers10.isEmpty)(permissions);
|
|
4251
|
-
}, false);
|
|
4252
|
-
var parseRolePermissions = ({ permission_sets_with_scope = [], permissions = [] }, permissionSets) => {
|
|
4253
|
-
const preliminaryResult = permission_sets_with_scope.reduce(
|
|
4254
|
-
(accu, permissionSet) => {
|
|
4255
|
-
if (!permissionSet.name) {
|
|
4256
|
-
return accu;
|
|
4257
|
-
}
|
|
4258
|
-
const processor = permissionSets[permissionSet.name];
|
|
4259
|
-
if (!processor) {
|
|
4260
|
-
return accu;
|
|
4261
|
-
}
|
|
4262
|
-
const scope = Object.keys(import_constants5.scopedPermissionAreas).find((scope2) => import_constants5.uiPermissionsByArea[scope2].scope === permissionSet.scope?.type);
|
|
4263
|
-
if (scope) {
|
|
4264
|
-
const result = mapPermissionSet(
|
|
4265
|
-
permissionSet.name,
|
|
4266
|
-
permissionSet.scope?.value ?? [],
|
|
4267
|
-
scope,
|
|
4268
|
-
accu.uiPermissions[scope]
|
|
4269
|
-
);
|
|
4270
|
-
return { ...accu, uiPermissions: { ...accu.uiPermissions, [scope]: result } };
|
|
4271
|
-
} else if (isEmptyPermissionSet(processor.result)) {
|
|
4272
|
-
return processor.permissions?.reduce(customPermissionHandler, accu);
|
|
4273
|
-
}
|
|
4274
|
-
return {
|
|
4275
|
-
...accu,
|
|
4276
|
-
isCustom: accu.isCustom || processor.isCustom,
|
|
4277
|
-
uiPermissions: mergePermissions(accu.uiPermissions, processor.result)
|
|
4278
|
-
};
|
|
4279
|
-
},
|
|
4280
|
-
{ isCustom: false, uiPermissions: { ...import_constants5.emptyUiPermissions, groups: {}, releases: {} } }
|
|
4281
|
-
);
|
|
4282
|
-
return permissions.reduce(customPermissionHandler, preliminaryResult);
|
|
4283
|
-
};
|
|
4284
|
-
var normalizeRbacRoles = (roles, rolesById2, permissionSets) => roles.reduce(
|
|
4285
|
-
(accu, role) => {
|
|
4286
|
-
let normalizedPermissions;
|
|
4287
|
-
let isCustom = false;
|
|
4288
|
-
if (rolesById2[role.name]) {
|
|
4289
|
-
normalizedPermissions = {
|
|
4290
|
-
...rolesById2[role.name].uiPermissions,
|
|
4291
|
-
groups: { ...rolesById2[role.name].uiPermissions.groups },
|
|
4292
|
-
releases: { ...rolesById2[role.name].uiPermissions.releases }
|
|
4293
|
-
};
|
|
4294
|
-
} else {
|
|
4295
|
-
const result = parseRolePermissions(role, permissionSets);
|
|
4296
|
-
normalizedPermissions = result.uiPermissions;
|
|
4297
|
-
isCustom = result.isCustom;
|
|
4298
|
-
}
|
|
4299
|
-
const roleState = accu[role.name] ?? { ...import_constants5.emptyRole };
|
|
4300
|
-
accu[role.name] = {
|
|
4301
|
-
...roleState,
|
|
4302
|
-
...role,
|
|
4303
|
-
description: roleState.description ? roleState.description : role.description,
|
|
4304
|
-
editable: !import_constants5.rolesById[role.name] && !isCustom && (typeof roleState.editable !== "undefined" ? roleState.editable : true),
|
|
4305
|
-
isCustom,
|
|
4306
|
-
name: roleState.name ? roleState.name : role.name,
|
|
4307
|
-
uiPermissions: normalizedPermissions
|
|
4308
|
-
};
|
|
4309
|
-
return accu;
|
|
4310
|
-
},
|
|
4311
|
-
{ ...rolesById2 }
|
|
4312
|
-
);
|
|
4313
|
-
var getPermissionSets = createAppAsyncThunk(
|
|
4314
|
-
`${sliceName8}/getPermissionSets`,
|
|
4315
|
-
(_, { dispatch, getState }) => general_api_default.get(`${import_constants5.useradmApiUrlv2}/permission_sets?per_page=500`).then(({ data }) => {
|
|
4316
|
-
const permissionSets = data.reduce(
|
|
4317
|
-
(accu, permissionSet) => {
|
|
4318
|
-
const permissionSetState = accu[permissionSet.name] ?? {};
|
|
4319
|
-
let permissionSetObject = { ...permissionSetState, ...permissionSet };
|
|
4320
|
-
permissionSetObject.result = Object.values(import_constants5.uiPermissionsById).reduce(
|
|
4321
|
-
(accu2, item) => Object.entries(item.permissionSets).reduce((collector, [area, permissionSet2]) => {
|
|
4322
|
-
if (import_constants5.scopedPermissionAreas[area]) {
|
|
4323
|
-
return collector;
|
|
4324
|
-
}
|
|
4325
|
-
if (permissionSet2 === permissionSetObject.name) {
|
|
4326
|
-
collector[area] = [...collector[area], item.value].filter(import_helpers10.duplicateFilter);
|
|
4327
|
-
}
|
|
4328
|
-
return collector;
|
|
4329
|
-
}, accu2),
|
|
4330
|
-
{ ...import_constants5.emptyUiPermissions, ...permissionSetObject.result ?? {} }
|
|
4331
|
-
);
|
|
4332
|
-
const scopes = Object.values(import_constants5.scopedPermissionAreas).reduce((accu2, { key, scopeType }) => {
|
|
4333
|
-
if (permissionSetObject.supported_scope_types?.includes(key) || permissionSetObject.supported_scope_types?.includes(scopeType)) {
|
|
4334
|
-
accu2.push(key);
|
|
4335
|
-
}
|
|
4336
|
-
return accu2;
|
|
4337
|
-
}, []);
|
|
4338
|
-
permissionSetObject = scopes.reduce((accu2, scope) => {
|
|
4339
|
-
accu2.result = {
|
|
4340
|
-
...accu2.result,
|
|
4341
|
-
[scope]: mapPermissionSet(permissionSetObject.name, [import_constants5.scopedPermissionAreas[scope].excessiveAccessSelector], scope)
|
|
4342
|
-
};
|
|
4343
|
-
return accu2;
|
|
4344
|
-
}, permissionSetObject);
|
|
4345
|
-
accu[permissionSet.name] = permissionSetObject;
|
|
4346
|
-
return accu;
|
|
4347
|
-
},
|
|
4348
|
-
{ ...getState().users.permissionSetsById }
|
|
4349
|
-
);
|
|
4350
|
-
return Promise.all([dispatch(actions8.receivedPermissionSets(permissionSets)), permissionSets]);
|
|
4351
|
-
}).catch(() => console.log("Permission set retrieval failed - likely accessing a non-RBAC backend"))
|
|
4352
|
-
);
|
|
4353
|
-
var getRoles = createAppAsyncThunk(
|
|
4354
|
-
`${sliceName8}/getRoles`,
|
|
4355
|
-
(_, { dispatch, getState }) => Promise.all([general_api_default.get(`${import_constants5.useradmApiUrlv2}/roles?per_page=500`), dispatch(getPermissionSets())]).then((results) => {
|
|
4356
|
-
if (!results) {
|
|
4357
|
-
return Promise.resolve();
|
|
4358
|
-
}
|
|
4359
|
-
const [{ data: roles }, { payload: permissionSetTasks }] = results;
|
|
4360
|
-
const rolesById2 = normalizeRbacRoles(roles, getRolesById(getState()), permissionSetTasks[permissionSetTasks.length - 1]);
|
|
4361
|
-
return Promise.resolve(dispatch(actions8.receivedRoles(rolesById2)));
|
|
4362
|
-
}).catch(() => console.log("Role retrieval failed - likely accessing a non-RBAC backend")).finally(() => Promise.resolve(dispatch(actions8.finishedRoleInitialization(true))))
|
|
4363
|
-
);
|
|
4364
|
-
var deriveImpliedAreaPermissions = (area, areaPermissions, skipPermissions = []) => {
|
|
4365
|
-
const highestAreaPermissionLevelSelected = areaPermissions.reduce(
|
|
4366
|
-
(highest, current) => import_constants5.uiPermissionsById[current].permissionLevel > highest ? import_constants5.uiPermissionsById[current].permissionLevel : highest,
|
|
4367
|
-
1
|
|
4368
|
-
);
|
|
4369
|
-
return import_constants5.uiPermissionsByArea[area].uiPermissions.reduce((permissions, current) => {
|
|
4370
|
-
if ((current.permissionLevel < highestAreaPermissionLevelSelected || areaPermissions.includes(current.value)) && !skipPermissions.includes(current.value)) {
|
|
4371
|
-
permissions.push(current.value);
|
|
4372
|
-
}
|
|
4373
|
-
return permissions;
|
|
4374
|
-
}, []);
|
|
4375
|
-
};
|
|
4376
|
-
var transformAreaRoleDataToScopedPermissionsSets = (area, areaPermissions, excessiveAccessSelector) => {
|
|
4377
|
-
const permissionSetObject = areaPermissions.reduce((accu, { item, uiPermissions }) => {
|
|
4378
|
-
const skipPermissions = import_constants5.scopedPermissionAreas.releases.key === area && item !== import_constants5.ALL_RELEASES ? [import_constants5.uiPermissionsById.upload.value] : [];
|
|
4379
|
-
const impliedPermissions = deriveImpliedAreaPermissions(area, uiPermissions, skipPermissions);
|
|
4380
|
-
accu = impliedPermissions.reduce((itemPermissionAccu, impliedPermission) => {
|
|
4381
|
-
const permissionSetState = itemPermissionAccu[import_constants5.uiPermissionsById[impliedPermission].permissionSets[area]] ?? {
|
|
4382
|
-
type: import_constants5.uiPermissionsByArea[area].scope,
|
|
4383
|
-
value: []
|
|
4384
|
-
};
|
|
4385
|
-
itemPermissionAccu[import_constants5.uiPermissionsById[impliedPermission].permissionSets[area]] = {
|
|
4386
|
-
...permissionSetState,
|
|
4387
|
-
value: [...permissionSetState.value, item]
|
|
4388
|
-
};
|
|
4389
|
-
return itemPermissionAccu;
|
|
4390
|
-
}, accu);
|
|
4391
|
-
return accu;
|
|
4392
|
-
}, {});
|
|
4393
|
-
return Object.entries(permissionSetObject).map(([name, { value, ...scope }]) => {
|
|
4394
|
-
if (value.includes(excessiveAccessSelector)) {
|
|
4395
|
-
return { name };
|
|
4396
|
-
}
|
|
4397
|
-
return { name, scope: { ...scope, value: value.filter(import_helpers10.duplicateFilter) } };
|
|
4398
|
-
});
|
|
4399
|
-
};
|
|
4400
|
-
var transformRoleDataToRole = (roleData, roleState = {}) => {
|
|
4401
|
-
const role = { ...roleState, ...roleData };
|
|
4402
|
-
const { description = "", name, uiPermissions = import_constants5.emptyUiPermissions } = role;
|
|
4403
|
-
const { maybeUiPermissions, remainderKeys } = Object.entries(import_constants5.emptyUiPermissions).reduce(
|
|
4404
|
-
(accu, [key, emptyPermissions]) => {
|
|
4405
|
-
if (!import_constants5.scopedPermissionAreas[key]) {
|
|
4406
|
-
accu.remainderKeys.push(key);
|
|
4407
|
-
} else if (uiPermissions[key]) {
|
|
4408
|
-
accu.maybeUiPermissions[key] = uiPermissions[key].reduce(itemUiPermissionsReducer, emptyPermissions);
|
|
4409
|
-
}
|
|
4410
|
-
return accu;
|
|
4411
|
-
},
|
|
4412
|
-
{ maybeUiPermissions: {}, remainderKeys: [] }
|
|
4413
|
-
);
|
|
4414
|
-
const { permissionSetsWithScope, roleUiPermissions } = remainderKeys.reduce(
|
|
4415
|
-
(accu, area) => {
|
|
4416
|
-
const areaPermissions = role.uiPermissions[area];
|
|
4417
|
-
if (!Array.isArray(areaPermissions)) {
|
|
4418
|
-
return accu;
|
|
4419
|
-
}
|
|
4420
|
-
const impliedPermissions = deriveImpliedAreaPermissions(area, areaPermissions);
|
|
4421
|
-
accu.roleUiPermissions[area] = impliedPermissions;
|
|
4422
|
-
const mappedPermissions = impliedPermissions.map((uiPermission) => ({ name: import_constants5.uiPermissionsById[uiPermission].permissionSets[area] }));
|
|
4423
|
-
accu.permissionSetsWithScope.push(...mappedPermissions);
|
|
4424
|
-
return accu;
|
|
4425
|
-
},
|
|
4426
|
-
{ permissionSetsWithScope: [{ name: import_constants5.defaultPermissionSets.Basic.name }], roleUiPermissions: {} }
|
|
4427
|
-
);
|
|
4428
|
-
const scopedPermissionSets = Object.values(import_constants5.scopedPermissionAreas).reduce((accu, { key, excessiveAccessSelector }) => {
|
|
4429
|
-
if (!uiPermissions[key]) {
|
|
4430
|
-
return accu;
|
|
4431
|
-
}
|
|
4432
|
-
accu.push(
|
|
4433
|
-
...transformAreaRoleDataToScopedPermissionsSets(
|
|
4434
|
-
key,
|
|
4435
|
-
uiPermissions[key],
|
|
4436
|
-
excessiveAccessSelector
|
|
4437
|
-
)
|
|
4438
|
-
);
|
|
4439
|
-
return accu;
|
|
4440
|
-
}, []);
|
|
4441
|
-
return {
|
|
4442
|
-
permissionSetsWithScope: [...permissionSetsWithScope, ...scopedPermissionSets],
|
|
4443
|
-
role: {
|
|
4444
|
-
...import_constants5.emptyRole,
|
|
4445
|
-
name,
|
|
4446
|
-
description: description ? description : roleState.description || "",
|
|
4447
|
-
uiPermissions: {
|
|
4448
|
-
...import_constants5.emptyUiPermissions,
|
|
4449
|
-
...roleUiPermissions,
|
|
4450
|
-
...maybeUiPermissions
|
|
4451
|
-
}
|
|
4452
|
-
}
|
|
4453
|
-
};
|
|
4454
|
-
};
|
|
4455
|
-
var roleActions = {
|
|
4456
|
-
create: {
|
|
4457
|
-
successMessage: "The role was created successfully.",
|
|
4458
|
-
errorMessage: "creating"
|
|
4459
|
-
},
|
|
4460
|
-
edit: {
|
|
4461
|
-
successMessage: "The role has been updated.",
|
|
4462
|
-
errorMessage: "editing"
|
|
4463
|
-
},
|
|
4464
|
-
remove: {
|
|
4465
|
-
successMessage: "The role was deleted successfully.",
|
|
4466
|
-
errorMessage: "removing"
|
|
4467
|
-
}
|
|
4468
|
-
};
|
|
4469
|
-
var roleActionErrorHandler = (err, type, dispatch, meta) => {
|
|
4470
|
-
let errorContext = `There was an error ${roleActions[type].errorMessage} the role.`;
|
|
4471
|
-
if (meta) {
|
|
4472
|
-
const { permissionSetsCreated, name } = meta;
|
|
4473
|
-
errorContext += ` Tried to ${type} role ${name} with ${permissionSetsCreated} permission sets.`;
|
|
4474
|
-
}
|
|
4475
|
-
return commonErrorHandler(err, errorContext, dispatch);
|
|
4476
|
-
};
|
|
4477
|
-
var createRole = createAppAsyncThunk(`${sliceName8}/createRole`, (roleData, { dispatch }) => {
|
|
4478
|
-
const { permissionSetsWithScope, role } = transformRoleDataToRole(roleData);
|
|
4479
|
-
return general_api_default.post(`${import_constants5.useradmApiUrlv2}/roles`, {
|
|
4480
|
-
name: role.name,
|
|
4481
|
-
description: role.description,
|
|
4482
|
-
permission_sets_with_scope: permissionSetsWithScope
|
|
4483
|
-
}).then(() => Promise.all([dispatch(actions8.createdRole(role)), dispatch(getRoles()), dispatch(setSnackbar4(roleActions.create.successMessage))])).catch((err) => roleActionErrorHandler(err, "create", dispatch, { permissionSetsCreated: permissionSetsWithScope.length, name: role.name }));
|
|
4484
|
-
});
|
|
4485
|
-
var editRole = createAppAsyncThunk(`${sliceName8}/editRole`, (roleData, { dispatch, getState }) => {
|
|
4486
|
-
const { permissionSetsWithScope, role } = transformRoleDataToRole(roleData, getRolesById(getState())[roleData.name]);
|
|
4487
|
-
return general_api_default.put(`${import_constants5.useradmApiUrlv2}/roles/${role.name}`, {
|
|
4488
|
-
description: role.description,
|
|
4489
|
-
name: role.name,
|
|
4490
|
-
permission_sets_with_scope: permissionSetsWithScope
|
|
4491
|
-
}).then(() => Promise.all([dispatch(actions8.createdRole(role)), dispatch(getRoles()), dispatch(setSnackbar4(roleActions.edit.successMessage))])).catch((err) => roleActionErrorHandler(err, "edit", dispatch, { permissionSetsCreated: permissionSetsWithScope.length, name: role.name }));
|
|
4492
|
-
});
|
|
4493
|
-
var removeRole = createAppAsyncThunk(
|
|
4494
|
-
`${sliceName8}/removeRole`,
|
|
4495
|
-
(roleId, { dispatch }) => general_api_default.delete(`${import_constants5.useradmApiUrlv2}/roles/${roleId}`).then(() => Promise.all([dispatch(actions8.removedRole(roleId)), dispatch(getRoles()), dispatch(setSnackbar4(roleActions.remove.successMessage))])).catch((err) => roleActionErrorHandler(err, "remove", dispatch))
|
|
4496
|
-
);
|
|
4497
|
-
var getGlobalSettings2 = createAppAsyncThunk(
|
|
4498
|
-
`${sliceName8}/getGlobalSettings`,
|
|
4499
|
-
(_, { dispatch }) => general_api_default.get(`${import_constants5.useradmApiUrl}/settings`).then(({ data: settings, headers: { etag } }) => {
|
|
4500
|
-
window.sessionStorage.setItem(settingsKeys.initialized, "true");
|
|
4501
|
-
return Promise.all([dispatch(actions8.setGlobalSettings(settings)), dispatch(setOfflineThreshold()), etag]);
|
|
4502
|
-
})
|
|
4503
|
-
);
|
|
4504
|
-
var saveGlobalSettings = createAppAsyncThunk(
|
|
4505
|
-
`${sliceName8}/saveGlobalSettings`,
|
|
4506
|
-
({ beOptimistic = false, notify = false, ...settings }, { dispatch, getState }) => {
|
|
4507
|
-
if (!window.sessionStorage.getItem(settingsKeys.initialized) && !beOptimistic) {
|
|
4508
|
-
return;
|
|
4509
|
-
}
|
|
4510
|
-
return dispatch(getGlobalSettings2()).unwrap().then((result) => {
|
|
4511
|
-
const updatedSettings = { ...getState().users.globalSettings, ...settings };
|
|
4512
|
-
if (getCurrentUser(getState()).verified) {
|
|
4513
|
-
updatedSettings["2fa"] = import_constants5.twoFAStates.enabled;
|
|
4514
|
-
} else {
|
|
4515
|
-
delete updatedSettings["2fa"];
|
|
4516
|
-
}
|
|
4517
|
-
const tasks = [dispatch(actions8.setGlobalSettings(updatedSettings))];
|
|
4518
|
-
const headers = result[result.length - 1] ? { "If-Match": result[result.length - 1] } : {};
|
|
4519
|
-
return general_api_default.post(`${import_constants5.useradmApiUrl}/settings`, updatedSettings, { headers }).then(() => {
|
|
4520
|
-
if (notify) {
|
|
4521
|
-
tasks.push(dispatch(setSnackbar4("Settings saved successfully")));
|
|
4522
|
-
}
|
|
4523
|
-
return Promise.all(tasks);
|
|
4524
|
-
}).catch((err) => {
|
|
4525
|
-
if (beOptimistic) {
|
|
4526
|
-
return Promise.all([tasks]);
|
|
4527
|
-
}
|
|
4528
|
-
console.log(err);
|
|
4529
|
-
return commonErrorHandler(err, `The settings couldn't be saved.`, dispatch);
|
|
4530
|
-
});
|
|
4531
|
-
});
|
|
4532
|
-
}
|
|
4533
|
-
);
|
|
4534
|
-
var getUserSettings2 = createAppAsyncThunk(
|
|
4535
|
-
`${sliceName8}/getUserSettings`,
|
|
4536
|
-
(_, { dispatch }) => general_api_default.get(`${import_constants5.useradmApiUrl}/settings/me`).then(({ data: settings, headers: { etag } }) => {
|
|
4537
|
-
window.sessionStorage.setItem(settingsKeys.initialized, "true");
|
|
4538
|
-
return Promise.all([dispatch(actions8.setUserSettings(settings)), etag]);
|
|
4539
|
-
})
|
|
4540
|
-
);
|
|
4541
|
-
var saveUserSettings = createAppAsyncThunk(
|
|
4542
|
-
`${sliceName8}/saveUserSettings`,
|
|
4543
|
-
(settings = { onboarding: {} }, { dispatch, getState }) => {
|
|
4544
|
-
if (!getCurrentUser(getState()).id) {
|
|
4545
|
-
return Promise.resolve();
|
|
4546
|
-
}
|
|
4547
|
-
return dispatch(getUserSettings2()).unwrap().then((result) => {
|
|
4548
|
-
const userSettings = getUserSettings(getState());
|
|
4549
|
-
const onboardingState = getOnboardingState(getState());
|
|
4550
|
-
const tooltipState = getTooltipsState(getState());
|
|
4551
|
-
const updatedSettings = {
|
|
4552
|
-
...userSettings,
|
|
4553
|
-
...settings,
|
|
4554
|
-
firstLoginTimestamp: userSettings.firstLoginTimestamp ?? (0, import_dayjs2.default)().format(),
|
|
4555
|
-
onboarding: {
|
|
4556
|
-
...onboardingState,
|
|
4557
|
-
...settings.onboarding
|
|
4558
|
-
},
|
|
4559
|
-
tooltips: tooltipState
|
|
4560
|
-
};
|
|
4561
|
-
const headers = result[result.length - 1] ? { "If-Match": result[result.length - 1] } : {};
|
|
4562
|
-
return Promise.all([
|
|
4563
|
-
Promise.resolve(dispatch(actions8.setUserSettings(updatedSettings))),
|
|
4564
|
-
general_api_default.post(`${import_constants5.useradmApiUrl}/settings/me`, updatedSettings, { headers })
|
|
4565
|
-
]).catch(() => dispatch(actions8.setUserSettings(userSettings)));
|
|
4566
|
-
});
|
|
4567
|
-
}
|
|
4568
|
-
);
|
|
4569
|
-
var get2FAQRCode = createAppAsyncThunk(
|
|
4570
|
-
`${sliceName8}/get2FAQRCode`,
|
|
4571
|
-
(_, { dispatch }) => general_api_default.get(`${import_constants5.useradmApiUrl}/2faqr`).then((res) => dispatch(actions8.receivedQrCode(res.data.qr)))
|
|
4572
|
-
);
|
|
4573
|
-
var setHideAnnouncement = createAppAsyncThunk(
|
|
4574
|
-
`${sliceName8}/setHideAnnouncement`,
|
|
4575
|
-
({ shouldHide, userId }, { dispatch, getState }) => {
|
|
4576
|
-
const currentUserId = userId || getCurrentUser(getState()).id;
|
|
4577
|
-
const announcement = getHostedAnnouncement(getState());
|
|
4578
|
-
const hash = announcement ? (0, import_md5.default)(announcement) : "";
|
|
4579
|
-
const announceCookie = cookies4.get(`${currentUserId}${hash}`);
|
|
4580
|
-
if (shouldHide || hash.length && typeof announceCookie !== "undefined") {
|
|
4581
|
-
cookies4.set(`${currentUserId}${hash}`, true, { maxAge: 604800 });
|
|
4582
|
-
dispatch(setAnnouncement(""));
|
|
4583
|
-
}
|
|
4584
|
-
}
|
|
4585
|
-
);
|
|
4586
|
-
var getTokens = createAppAsyncThunk(
|
|
4587
|
-
`${sliceName8}/getTokens`,
|
|
4588
|
-
(_, { dispatch, getState }) => general_api_default.get(`${import_constants5.useradmApiUrl}/settings/tokens`).then(({ data: tokens }) => {
|
|
4589
|
-
const user = getCurrentUser(getState());
|
|
4590
|
-
const updatedUser = {
|
|
4591
|
-
...user,
|
|
4592
|
-
tokens
|
|
4593
|
-
};
|
|
4594
|
-
return Promise.resolve(dispatch(actions8.updatedUser(updatedUser)));
|
|
4595
|
-
})
|
|
4596
|
-
);
|
|
4597
|
-
var ONE_YEAR = 31536e3;
|
|
4598
|
-
var generateToken = createAppAsyncThunk(
|
|
4599
|
-
`${sliceName8}/generateToken`,
|
|
4600
|
-
({ expiresIn = ONE_YEAR, name }, { dispatch }) => general_api_default.post(`${import_constants5.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))
|
|
4601
|
-
);
|
|
4602
|
-
var revokeToken = createAppAsyncThunk(
|
|
4603
|
-
`${sliceName8}/revokeToken`,
|
|
4604
|
-
(token, { dispatch }) => general_api_default.delete(`${import_constants5.useradmApiUrl}/settings/tokens/${token.id}`).then(() => Promise.resolve(dispatch(getTokens())))
|
|
4605
|
-
);
|
|
4606
|
-
var setTooltipReadState = createAppAsyncThunk(
|
|
4607
|
-
`${sliceName8}/setTooltipReadState`,
|
|
4608
|
-
async ({ persist, ...remainder }, { dispatch }) => {
|
|
4609
|
-
dispatch(actions8.setTooltipState(remainder));
|
|
4610
|
-
if (persist) {
|
|
4611
|
-
await dispatch(saveUserSettings());
|
|
4612
|
-
}
|
|
4613
|
-
}
|
|
4614
|
-
);
|
|
4615
|
-
var setAllTooltipsReadState = createAppAsyncThunk(
|
|
4616
|
-
`${sliceName8}/toggleHelptips`,
|
|
4617
|
-
({ readState = READ_STATES.read, tooltipIds }, { dispatch }) => {
|
|
4618
|
-
const updatedTips = tooltipIds.reduce((accu, id) => ({ ...accu, [id]: { readState } }), {});
|
|
4619
|
-
return Promise.resolve(dispatch(actions8.setTooltipsState(updatedTips))).then(() => dispatch(saveUserSettings()));
|
|
4620
|
-
}
|
|
4621
|
-
);
|
|
4622
|
-
var submitUserFeedback = createAppAsyncThunk(
|
|
4623
|
-
`${sliceName8}/submitFeedback`,
|
|
4624
|
-
({ formId, feedback }, { dispatch }) => general_api_default.post(`${import_constants5.useradmApiUrlv2}/support/feedback/${formId}`, feedback).then(() => {
|
|
4625
|
-
if (formId === "product") {
|
|
4626
|
-
const today = /* @__PURE__ */ new Date();
|
|
4627
|
-
dispatch(saveUserSettings({ feedbackCollectedAt: today.toISOString().split("T")[0] }));
|
|
4628
|
-
setTimeout(() => dispatch(actions8.setShowFeedbackDialog(false)), TIMEOUTS.threeSeconds);
|
|
4629
|
-
}
|
|
4630
|
-
})
|
|
4631
|
-
);
|
|
4632
|
-
|
|
4633
|
-
// src/onboardingSlice/thunks.ts
|
|
4634
|
-
var cookies5 = new import_universal_cookie5.default();
|
|
4635
|
-
var applyOnboardingFallbacks = (progress2) => {
|
|
4636
|
-
const step = orderedOnboardingSteps[progress2];
|
|
4637
|
-
if (step && step.fallbackStep) {
|
|
4638
|
-
return step.fallbackStep;
|
|
4639
|
-
}
|
|
4640
|
-
return progress2;
|
|
4641
|
-
};
|
|
4642
|
-
var determineProgress = (acceptedDevices, pendingDevices, releases, pastDeployments) => {
|
|
4643
|
-
const steps = orderedOnboardingSteps;
|
|
4644
|
-
let progress2 = -1;
|
|
4645
|
-
progress2 = pendingDevices.length > 1 ? steps.findIndex((step) => step === onboardingSteps.DEVICES_PENDING_ACCEPTING_ONBOARDING) : progress2;
|
|
4646
|
-
progress2 = acceptedDevices.length >= 1 ? steps.findIndex((step) => step === onboardingSteps.DEVICES_ACCEPTED_ONBOARDING) : progress2;
|
|
4647
|
-
progress2 = acceptedDevices.length > 1 && releases.length > 1 && pastDeployments.length > 1 ? steps.findIndex((step) => step === onboardingSteps.DEPLOYMENTS_PAST_COMPLETED) : progress2;
|
|
4648
|
-
return steps[progress2];
|
|
4649
|
-
};
|
|
4650
|
-
var deductOnboardingState = ({ devicesById, devicesByStatus, onboardingState, pastDeployments, releases, userCapabilities, userId }) => {
|
|
4651
|
-
const { canDeploy, canManageDevices, canReadDeployments, canReadDevices, canReadReleases, canUploadReleases } = userCapabilities;
|
|
4652
|
-
const userCookie = cookies5.get(`${userId}-onboarded`);
|
|
4653
|
-
const acceptedDevices = devicesByStatus[import_constants5.DEVICE_STATES.accepted].deviceIds;
|
|
4654
|
-
const pendingDevices = devicesByStatus[import_constants5.DEVICE_STATES.pending].deviceIds;
|
|
4655
|
-
let deviceType = onboardingState.deviceType ?? [];
|
|
4656
|
-
deviceType = !deviceType.length && acceptedDevices.length && devicesById[acceptedDevices[0]].hasOwnProperty("attributes") ? devicesById[acceptedDevices[0]].attributes.device_type : deviceType;
|
|
4657
|
-
const deviceTier = acceptedDevices.length && devicesById[acceptedDevices[0]].tier;
|
|
4658
|
-
let approach = null;
|
|
4659
|
-
if (deviceType.some((type) => type.startsWith("qemu"))) {
|
|
4660
|
-
approach = "virtual";
|
|
4661
|
-
} else if (deviceType.some((type) => type.startsWith("esp32")) || deviceTier === "micro") {
|
|
4662
|
-
approach = "mcu";
|
|
4663
|
-
} else if (deviceType.length) {
|
|
4664
|
-
approach = "physical";
|
|
4665
|
-
}
|
|
4666
|
-
const progress2 = applyOnboardingFallbacks(onboardingState.progress || determineProgress(acceptedDevices, pendingDevices, releases, pastDeployments));
|
|
4667
|
-
return {
|
|
4668
|
-
...onboardingState,
|
|
4669
|
-
complete: !!(Boolean(userCookie) || onboardingState.complete || acceptedDevices.length > 1 && pendingDevices.length > 0 && releases.length > 1 && pastDeployments.length > 1 || acceptedDevices.length >= 1 && releases.length >= 2 && pastDeployments.length > 2 || acceptedDevices.length >= 1 && pendingDevices.length > 0 && releases.length >= 2 && pastDeployments.length >= 2 || orderedOnboardingSteps.findIndex((step) => step === progress2) >= orderedOnboardingSteps.length - 1 || onboardingState.disable || ![canDeploy, canManageDevices, canReadDeployments, canReadDevices, canReadReleases, canUploadReleases].every((i) => i)),
|
|
4670
|
-
showTips: onboardingState.showTips != null ? onboardingState.showTips : true,
|
|
4671
|
-
deviceType,
|
|
4672
|
-
approach: onboardingState.approach || approach,
|
|
4673
|
-
progress: progress2
|
|
4674
|
-
};
|
|
4675
|
-
};
|
|
4676
|
-
var getOnboardingState2 = createAppAsyncThunk(`${sliceName}/getOnboardingState`, (_, { dispatch, getState }) => {
|
|
4677
|
-
const state = getState();
|
|
4678
|
-
let onboardingState = getOnboardingState(state);
|
|
4679
|
-
if (!onboardingState.complete) {
|
|
4680
|
-
const userId = state.users.currentUser;
|
|
4681
|
-
onboardingState = deductOnboardingState({
|
|
4682
|
-
devicesById: state.devices.byId,
|
|
4683
|
-
devicesByStatus: state.devices.byStatus,
|
|
4684
|
-
onboardingState,
|
|
4685
|
-
pastDeployments: state.deployments.byStatus.finished.deploymentIds,
|
|
4686
|
-
releases: Object.values(state.releases.byId),
|
|
4687
|
-
userCapabilities: getUserCapabilities(state),
|
|
4688
|
-
userId
|
|
4689
|
-
});
|
|
4690
|
-
}
|
|
4691
|
-
onboardingState.progress = onboardingState.progress || onboardingSteps.DASHBOARD_ONBOARDING_START;
|
|
4692
|
-
const demoDeviceAddress = `http://${(0, import_helpers11.getDemoDeviceAddress)(Object.values(state.devices.byId), onboardingState.approach)}`;
|
|
4693
|
-
onboardingState.address = state.onboarding.demoArtifactPort ? `${demoDeviceAddress}:${state.onboarding.demoArtifactPort}` : demoDeviceAddress;
|
|
4694
|
-
return Promise.all([
|
|
4695
|
-
dispatch(actions.setOnboardingComplete(onboardingState.complete)),
|
|
4696
|
-
dispatch(actions.setOnboardingState(onboardingState)),
|
|
4697
|
-
dispatch(saveUserSettings({ onboarding: onboardingState }))
|
|
4698
|
-
]);
|
|
4699
|
-
});
|
|
4700
|
-
var setOnboardingDeviceType = createAppAsyncThunk(
|
|
4701
|
-
`${sliceName}/setOnboardingDeviceType`,
|
|
4702
|
-
(value, { dispatch }) => Promise.all([dispatch(actions.setOnboardingDeviceType(value)), dispatch(saveUserSettings({ onboarding: { deviceType: value } }))])
|
|
4703
|
-
);
|
|
4704
|
-
var setOnboardingApproach = createAppAsyncThunk(
|
|
4705
|
-
`${sliceName}/setOnboardingApproach`,
|
|
4706
|
-
(value, { dispatch }) => Promise.all([dispatch(actions.setOnboardingApproach(value)), dispatch(saveUserSettings({ onboarding: { approach: value } }))])
|
|
4707
|
-
);
|
|
4708
|
-
var setOnboardingComplete = createAppAsyncThunk(`${sliceName}/setOnboardingComplete`, (value, { dispatch }) => {
|
|
4709
|
-
const tasks = [Promise.resolve(dispatch(actions.setOnboardingComplete(value)))];
|
|
4710
|
-
if (value) {
|
|
4711
|
-
tasks.push(Promise.resolve(dispatch(actions.setShowOnboardingHelp(false))));
|
|
4712
|
-
tasks.push(Promise.resolve(dispatch(advanceOnboarding(onboardingSteps.DEPLOYMENTS_PAST_COMPLETED))));
|
|
4713
|
-
}
|
|
4714
|
-
return Promise.all(tasks);
|
|
4715
|
-
});
|
|
4716
|
-
var setOnboardingCanceled = createAppAsyncThunk(
|
|
4717
|
-
`${sliceName}/setOnboardingCanceled`,
|
|
4718
|
-
(_, { dispatch }) => Promise.all([
|
|
4719
|
-
Promise.resolve(dispatch(actions.setShowOnboardingHelp(false))),
|
|
4720
|
-
Promise.resolve(dispatch(actions.setShowDismissOnboardingTipsDialog(false))),
|
|
4721
|
-
Promise.resolve(dispatch(actions.setOnboardingComplete(true)))
|
|
4722
|
-
]).then(() => dispatch(advanceOnboarding(onboardingSteps.DEPLOYMENTS_PAST_COMPLETED_FAILURE))).then(() => import_tracking2.default.event({ category: "onboarding", action: onboardingSteps.ONBOARDING_CANCELED }))
|
|
4723
|
-
);
|
|
4724
|
-
var advanceOnboarding = createAppAsyncThunk(`${sliceName}/advanceOnboarding`, (stepId, { dispatch, getState }) => {
|
|
4725
|
-
const steps = orderedOnboardingSteps;
|
|
4726
|
-
const progress2 = steps.findIndex((step) => step === getState().onboarding.progress);
|
|
4727
|
-
const stepIndex = steps.findIndex((step) => step === stepId);
|
|
4728
|
-
if (progress2 > stepIndex || getState().onboarding.progress === null) {
|
|
4729
|
-
return;
|
|
4730
|
-
}
|
|
4731
|
-
const madeProgress = steps[stepIndex + 1];
|
|
4732
|
-
const state = { ...getOnboardingState(getState()), progress: madeProgress };
|
|
4733
|
-
state.complete = stepIndex + 1 >= orderedOnboardingSteps.findIndex((step) => step === onboardingSteps.DEPLOYMENTS_PAST_COMPLETED_FAILURE) ? true : state.complete;
|
|
4734
|
-
import_tracking2.default.event({ category: "onboarding", action: stepId });
|
|
4735
|
-
return Promise.all([dispatch(actions.setOnboardingProgress(madeProgress)), dispatch(saveUserSettings({ onboarding: state }))]);
|
|
4736
|
-
});
|
|
4737
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
4738
|
-
0 && (module.exports = {
|
|
4739
|
-
advanceOnboarding,
|
|
4740
|
-
getOnboardingState,
|
|
4741
|
-
setOnboardingApproach,
|
|
4742
|
-
setOnboardingCanceled,
|
|
4743
|
-
setOnboardingComplete,
|
|
4744
|
-
setOnboardingDeviceType
|
|
4745
|
-
});
|
|
4746
|
-
//# sourceMappingURL=thunks.cjs.map
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_thunks = require("../thunks.cjs");
|
|
3
|
+
exports.advanceOnboarding = require_thunks.advanceOnboarding;
|
|
4
|
+
exports.getOnboardingState = require_thunks.getOnboardingState;
|
|
5
|
+
exports.setOnboardingApproach = require_thunks.setOnboardingApproach;
|
|
6
|
+
exports.setOnboardingCanceled = require_thunks.setOnboardingCanceled;
|
|
7
|
+
exports.setOnboardingComplete = require_thunks.setOnboardingComplete;
|
|
8
|
+
exports.setOnboardingDeviceType = require_thunks.setOnboardingDeviceType;
|