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