@northern.tech/store 0.30.2 → 0.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions.d.cts +16 -7
- package/dist/actions.d.ts +16 -7
- package/dist/api/general-api.cjs +2 -2
- package/dist/api/general-api.cjs.map +1 -1
- package/dist/api/general-api.js.map +1 -1
- package/dist/api/users-api.cjs +1 -1
- package/dist/api/users-api.cjs.map +1 -1
- package/dist/api/users-api.js.map +1 -1
- package/dist/appSlice/constants.cjs +6 -1
- package/dist/appSlice/constants.cjs.map +1 -1
- package/dist/appSlice/constants.d.cts +1 -1
- package/dist/appSlice/constants.d.ts +1 -1
- package/dist/appSlice/constants.js +7 -2
- package/dist/appSlice/constants.js.map +1 -1
- package/dist/appSlice/index.cjs.map +1 -1
- package/dist/appSlice/index.d.cts +1 -1
- package/dist/appSlice/index.d.ts +1 -1
- package/dist/appSlice/index.js.map +1 -1
- package/dist/appSlice/mocks.d.cts +1 -1
- package/dist/appSlice/mocks.d.ts +1 -1
- package/dist/appSlice/selectors.d.cts +7 -7
- package/dist/appSlice/selectors.d.ts +7 -7
- package/dist/appSlice/thunks.d.cts +2 -2
- package/dist/appSlice/thunks.d.ts +2 -2
- package/dist/auth.cjs +1 -1
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +1 -1
- package/dist/auth.d.ts +1 -1
- package/dist/auth.js.map +1 -1
- package/dist/commonConstants.d.cts +1 -1
- package/dist/commonConstants.d.ts +1 -1
- package/dist/commonSelectors.cjs +1 -1
- package/dist/commonSelectors.cjs.map +1 -1
- package/dist/commonSelectors.d.cts +10 -10
- package/dist/commonSelectors.d.ts +10 -10
- package/dist/commonSelectors.js.map +1 -1
- package/dist/{constants-DPLHhjVN.d.cts → constants-BFTS6mge.d.cts} +6 -1
- package/dist/{constants-C5AU0mCY.d.ts → constants-BIIEMVoG.d.ts} +6 -1
- package/dist/{constants-MPLfugsi.d.cts → constants-BrGIx40B.d.cts} +3 -3
- package/dist/{constants-DrwXHsJ1.d.ts → constants-CjO3_FOH.d.ts} +3 -3
- package/dist/constants.cjs +1 -0
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts +3 -3
- package/dist/constants.d.ts +3 -3
- package/dist/constants.js +2 -2
- package/dist/constants.js.map +1 -1
- package/dist/deploymentsSlice/index.cjs.map +1 -1
- package/dist/deploymentsSlice/index.js.map +1 -1
- package/dist/deploymentsSlice/selectors.cjs.map +1 -1
- package/dist/deploymentsSlice/selectors.d.cts +7 -7
- package/dist/deploymentsSlice/selectors.d.ts +7 -7
- package/dist/deploymentsSlice/selectors.js.map +1 -1
- package/dist/deploymentsSlice/thunks.d.cts +4 -4
- package/dist/deploymentsSlice/thunks.d.ts +4 -4
- package/dist/devicesSlice/constants.d.cts +1 -1
- package/dist/devicesSlice/constants.d.ts +1 -1
- package/dist/devicesSlice/index.cjs.map +1 -1
- package/dist/devicesSlice/index.d.cts +1 -1
- package/dist/devicesSlice/index.d.ts +1 -1
- package/dist/devicesSlice/index.js.map +1 -1
- package/dist/devicesSlice/selectors.cjs.map +1 -1
- package/dist/devicesSlice/selectors.d.cts +7 -7
- package/dist/devicesSlice/selectors.d.ts +7 -7
- package/dist/devicesSlice/selectors.js.map +1 -1
- package/dist/devicesSlice/thunks.d.cts +4 -4
- package/dist/devicesSlice/thunks.d.ts +4 -4
- package/dist/{index-Lz5JsJ6O.d.cts → index-B64X5ozM.d.cts} +2 -2
- package/dist/{index-4eaLEXy_.d.cts → index-BFlHWzjv.d.cts} +2 -2
- package/dist/{index-DqyY6oZ3.d.ts → index-BI9O8JWe.d.ts} +2 -2
- package/dist/{index-Bwx9jEiL.d.cts → index-BbaS7MzW.d.cts} +2 -2
- package/dist/{index-Dv3Hfxk_.d.ts → index-Bp1WpATs.d.ts} +2 -2
- package/dist/{index-FyYBBeN-.d.cts → index-C-q632wO.d.cts} +41 -8
- package/dist/{index-DJSlDPRX.d.ts → index-C6wNUfiV.d.ts} +2 -2
- package/dist/{index-BEVkIiNa.d.cts → index-CT5hgXm9.d.cts} +2 -2
- package/dist/{index-Cvkvcz4r.d.ts → index-CyokFK2e.d.ts} +41 -8
- package/dist/{index-CO-py5d4.d.ts → index-DUvrw_Ed.d.ts} +2 -2
- package/dist/{index-CTt-eIY8.d.cts → index-DwACbyUg.d.cts} +2 -2
- package/dist/{index-DtePEQPT.d.ts → index-ez3oxfRo.d.ts} +2 -2
- package/dist/liststatehook.cjs +5 -3
- package/dist/liststatehook.cjs.map +1 -1
- package/dist/liststatehook.js +5 -3
- package/dist/liststatehook.js.map +1 -1
- package/dist/locationutils.cjs +3 -0
- package/dist/locationutils.cjs.map +1 -1
- package/dist/locationutils.d.cts +3 -2
- package/dist/locationutils.d.ts +3 -2
- package/dist/locationutils.js +3 -0
- package/dist/locationutils.js.map +1 -1
- package/dist/monitorSlice/constants.d.cts +1 -1
- package/dist/monitorSlice/constants.d.ts +1 -1
- package/dist/monitorSlice/index.cjs.map +1 -1
- package/dist/monitorSlice/index.d.cts +1 -1
- package/dist/monitorSlice/index.d.ts +1 -1
- package/dist/monitorSlice/index.js.map +1 -1
- package/dist/monitorSlice/mocks.cjs.map +1 -1
- package/dist/monitorSlice/mocks.d.cts +1 -1
- package/dist/monitorSlice/mocks.d.ts +1 -1
- package/dist/monitorSlice/mocks.js.map +1 -1
- package/dist/monitorSlice/selectors.d.cts +1 -1
- package/dist/monitorSlice/selectors.d.ts +1 -1
- package/dist/monitorSlice/thunks.cjs.map +1 -1
- package/dist/monitorSlice/thunks.d.cts +4 -4
- package/dist/monitorSlice/thunks.d.ts +4 -4
- package/dist/monitorSlice/thunks.js.map +1 -1
- package/dist/onboardingSlice/index.cjs.map +1 -1
- package/dist/onboardingSlice/index.js.map +1 -1
- package/dist/onboardingSlice/mocks.cjs.map +1 -1
- package/dist/onboardingSlice/selectors.d.cts +1 -1
- package/dist/onboardingSlice/selectors.d.ts +1 -1
- package/dist/onboardingSlice/thunks.d.cts +2 -2
- package/dist/onboardingSlice/thunks.d.ts +2 -2
- package/dist/organizationSlice/index.cjs.map +1 -1
- package/dist/organizationSlice/index.d.cts +1 -1
- package/dist/organizationSlice/index.d.ts +1 -1
- package/dist/organizationSlice/index.js.map +1 -1
- package/dist/organizationSlice/mocks.d.cts +2 -2
- package/dist/organizationSlice/mocks.d.ts +2 -2
- package/dist/organizationSlice/selectors.cjs.map +1 -1
- package/dist/organizationSlice/selectors.d.cts +8 -8
- package/dist/organizationSlice/selectors.d.ts +8 -8
- package/dist/organizationSlice/selectors.js.map +1 -1
- package/dist/organizationSlice/thunks.d.cts +5 -5
- package/dist/organizationSlice/thunks.d.ts +5 -5
- package/dist/organizationSlice/types.d.cts +1 -1
- package/dist/organizationSlice/types.d.ts +1 -1
- package/dist/releasesSlice/index.cjs +63 -2
- package/dist/releasesSlice/index.cjs.map +1 -1
- package/dist/releasesSlice/index.d.cts +2 -2
- package/dist/releasesSlice/index.d.ts +2 -2
- package/dist/releasesSlice/index.js +63 -2
- package/dist/releasesSlice/index.js.map +1 -1
- package/dist/releasesSlice/mocks.cjs +34 -0
- package/dist/releasesSlice/mocks.cjs.map +1 -1
- package/dist/releasesSlice/mocks.d.cts +44 -1
- package/dist/releasesSlice/mocks.d.ts +44 -1
- package/dist/releasesSlice/mocks.js +34 -0
- package/dist/releasesSlice/mocks.js.map +1 -1
- package/dist/releasesSlice/selectors.cjs +37 -5
- package/dist/releasesSlice/selectors.cjs.map +1 -1
- package/dist/releasesSlice/selectors.d.cts +403 -15
- package/dist/releasesSlice/selectors.d.ts +403 -15
- package/dist/releasesSlice/selectors.js +27 -6
- package/dist/releasesSlice/selectors.js.map +1 -1
- package/dist/releasesSlice/thunks.cjs +210 -2
- package/dist/releasesSlice/thunks.cjs.map +1 -1
- package/dist/releasesSlice/thunks.d.cts +144 -10
- package/dist/releasesSlice/thunks.d.ts +144 -10
- package/dist/releasesSlice/thunks.js +201 -4
- package/dist/releasesSlice/thunks.js.map +1 -1
- package/dist/selectors.cjs +11 -0
- package/dist/selectors.d.cts +2 -2
- package/dist/selectors.d.ts +2 -2
- package/dist/selectors.js +2 -2
- package/dist/sockethook.cjs +2 -2
- package/dist/sockethook.cjs.map +1 -1
- package/dist/sockethook.js.map +1 -1
- package/dist/{store-BQxOSRC1.d.ts → store-D-xvZXiY.d.ts} +7 -7
- package/dist/{store-BiIA0r0A.d.cts → store-b5cF2WB5.d.cts} +7 -7
- package/dist/store.cjs.map +1 -1
- package/dist/store.d.cts +2 -2
- package/dist/store.d.ts +2 -2
- package/dist/store.js.map +1 -1
- package/dist/storehooks.cjs +3 -3
- package/dist/storehooks.cjs.map +1 -1
- package/dist/storehooks.d.cts +2 -2
- package/dist/storehooks.d.ts +2 -2
- package/dist/storehooks.js.map +1 -1
- package/dist/thunks.cjs +22 -10
- package/dist/thunks.cjs.map +1 -1
- package/dist/thunks.d.cts +2 -2
- package/dist/thunks.d.ts +2 -2
- package/dist/thunks.js +8 -6
- package/dist/thunks.js.map +1 -1
- package/dist/{types-B2NRQLFw.d.ts → types-BPyM8Inu.d.ts} +3 -3
- package/dist/{types-ClEfo0dK.d.cts → types-COdPU2QQ.d.cts} +3 -3
- package/dist/useDeploymentDevice.cjs +1 -1
- package/dist/useDeploymentDevice.cjs.map +1 -1
- package/dist/useDeploymentDevice.js.map +1 -1
- package/dist/usersSlice/index.cjs.map +1 -1
- package/dist/usersSlice/index.d.cts +1 -1
- package/dist/usersSlice/index.d.ts +1 -1
- package/dist/usersSlice/index.js.map +1 -1
- package/dist/usersSlice/mocks.d.cts +1 -1
- package/dist/usersSlice/mocks.d.ts +1 -1
- package/dist/usersSlice/selectors.cjs.map +1 -1
- package/dist/usersSlice/selectors.d.cts +7 -7
- package/dist/usersSlice/selectors.d.ts +7 -7
- package/dist/usersSlice/selectors.js.map +1 -1
- package/dist/usersSlice/thunks.d.cts +4 -4
- package/dist/usersSlice/thunks.d.ts +4 -4
- package/dist/{utils-CO_CpGFP.d.ts → utils-CHBWS_tH.d.ts} +4 -4
- package/dist/{utils-CpPfqW0Q.d.cts → utils-Do9z5TL1.d.cts} +4 -4
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js.map +1 -1
- package/package.json +7 -7
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { o as UserSliceType } from "../index-
|
|
2
|
-
import {
|
|
1
|
+
import { o as UserSliceType } from "../index-ez3oxfRo.js";
|
|
2
|
+
import { i as ReleaseSliceType } from "../index-CyokFK2e.js";
|
|
3
3
|
import { n as OnboardingSliceType } from "../index-CJkrL0oA.js";
|
|
4
4
|
import { l as SelectionState, n as DeploymentByStatus, o as DeploymentsSliceType, t as Deployment } from "../index-CkwVnIqd.js";
|
|
5
|
-
import { s as DeviceSliceType } from "../index-
|
|
6
|
-
import { t as AppSliceType } from "../index-
|
|
7
|
-
import { t as MonitorSliceType } from "../index-
|
|
8
|
-
import { t as OrganizationSliceType } from "../index-
|
|
9
|
-
import { r as RootState } from "../store-
|
|
5
|
+
import { s as DeviceSliceType } from "../index-BI9O8JWe.js";
|
|
6
|
+
import { t as AppSliceType } from "../index-Bp1WpATs.js";
|
|
7
|
+
import { t as MonitorSliceType } from "../index-DUvrw_Ed.js";
|
|
8
|
+
import { t as OrganizationSliceType } from "../index-C6wNUfiV.js";
|
|
9
|
+
import { r as RootState } from "../store-D-xvZXiY.js";
|
|
10
10
|
import * as _$reselect from "reselect";
|
|
11
11
|
|
|
12
12
|
//#region src/deploymentsSlice/selectors.d.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectors.js","names":[],"sources":["../../src/deploymentsSlice/selectors.ts"],"sourcesContent":["// Copyright 2023 Northern.tech AS\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { createSelector } from '@reduxjs/toolkit';\n\nimport type { Deployment } from '.';\nimport type { RootState } from '../store';\nimport { DEPLOYMENT_STATES } from './constants';\n\nexport const getDeploymentsById = (state: RootState) => state.deployments.byId;\nexport const getDeploymentsByStatus = (state: RootState) => state.deployments.byStatus;\nexport const getSelectedDeploymentDeviceIds = (state: RootState) => state.deployments.selectedDeviceIds;\nexport const getDeploymentsSelectionState = (state: RootState) => state.deployments.selectionState;\n\nexport const getDeploymentById = createSelector(\n [getDeploymentsById, (_, deploymentId) => deploymentId],\n (deploymentsById, deploymentId = '') => deploymentsById[deploymentId]\n);\n\nexport const getMappedDeploymentSelection = createSelector(\n [getDeploymentsSelectionState, (_, deploymentsState) => deploymentsState, getDeploymentsById],\n (selectionState, deploymentsState, deploymentsById) => {\n const { selection = [] } = selectionState[deploymentsState] ?? {};\n return selection.reduce((accu, id) => {\n if (deploymentsById[id]) {\n accu.push(deploymentsById[id]);\n }\n return accu;\n }, []);\n }\n);\n\nconst relevantDeploymentStates = [DEPLOYMENT_STATES.pending, DEPLOYMENT_STATES.inprogress, DEPLOYMENT_STATES.finished] as const;\nexport const DEPLOYMENT_CUTOFF = 3;\nexport const getRecentDeployments = createSelector([getDeploymentsById, getDeploymentsByStatus], (deploymentsById, deploymentsByStatus) =>\n Object.entries(deploymentsByStatus).reduce(\n (accu, [state, byStatus]) => {\n if (!relevantDeploymentStates.includes(state as (typeof relevantDeploymentStates)[number]) || !byStatus.deploymentIds.length) {\n return accu;\n }\n accu[state] = byStatus.deploymentIds\n .reduce<Deployment[]>((accu, id) => {\n if (deploymentsById[id]) {\n accu.push(deploymentsById[id]);\n }\n return accu;\n }, [])\n .slice(0, DEPLOYMENT_CUTOFF);\n accu.total += byStatus.total;\n return accu;\n },\n { total: 0 }\n )\n);\n"],"mappings":";;;AAmBA,MAAa,sBAAsB,UAAqB,MAAM,YAAY;AAC1E,MAAa,0BAA0B,UAAqB,MAAM,YAAY;AAC9E,MAAa,kCAAkC,UAAqB,MAAM,YAAY;AACtF,MAAa,gCAAgC,UAAqB,MAAM,YAAY;AAEpF,MAAa,oBAAoB,eAC/B,CAAC,qBAAqB,GAAG,iBAAiB,aAAa,GACtD,iBAAiB,eAAe,OAAO,gBAAgB,cACzD;AAED,MAAa,+BAA+B,eAC1C;CAAC;EAA+B,GAAG,qBAAqB;CAAkB;CAAmB,GAC5F,gBAAgB,kBAAkB,oBAAoB;CACrD,MAAM,EAAE,YAAY,EAAE,KAAK,eAAe,qBAAqB,EAAE;
|
|
1
|
+
{"version":3,"file":"selectors.js","names":[],"sources":["../../src/deploymentsSlice/selectors.ts"],"sourcesContent":["// Copyright 2023 Northern.tech AS\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { createSelector } from '@reduxjs/toolkit';\n\nimport type { Deployment } from '.';\nimport type { RootState } from '../store';\nimport { DEPLOYMENT_STATES } from './constants';\n\nexport const getDeploymentsById = (state: RootState) => state.deployments.byId;\nexport const getDeploymentsByStatus = (state: RootState) => state.deployments.byStatus;\nexport const getSelectedDeploymentDeviceIds = (state: RootState) => state.deployments.selectedDeviceIds;\nexport const getDeploymentsSelectionState = (state: RootState) => state.deployments.selectionState;\n\nexport const getDeploymentById = createSelector(\n [getDeploymentsById, (_, deploymentId) => deploymentId],\n (deploymentsById, deploymentId = '') => deploymentsById[deploymentId]\n);\n\nexport const getMappedDeploymentSelection = createSelector(\n [getDeploymentsSelectionState, (_, deploymentsState) => deploymentsState, getDeploymentsById],\n (selectionState, deploymentsState, deploymentsById) => {\n const { selection = [] } = selectionState[deploymentsState] ?? {};\n return selection.reduce((accu, id) => {\n if (deploymentsById[id]) {\n accu.push(deploymentsById[id]);\n }\n return accu;\n }, []);\n }\n);\n\nconst relevantDeploymentStates = [DEPLOYMENT_STATES.pending, DEPLOYMENT_STATES.inprogress, DEPLOYMENT_STATES.finished] as const;\nexport const DEPLOYMENT_CUTOFF = 3;\nexport const getRecentDeployments = createSelector([getDeploymentsById, getDeploymentsByStatus], (deploymentsById, deploymentsByStatus) =>\n Object.entries(deploymentsByStatus).reduce(\n (accu, [state, byStatus]) => {\n if (!relevantDeploymentStates.includes(state as (typeof relevantDeploymentStates)[number]) || !byStatus.deploymentIds.length) {\n return accu;\n }\n accu[state] = byStatus.deploymentIds\n .reduce<Deployment[]>((accu, id) => {\n if (deploymentsById[id]) {\n accu.push(deploymentsById[id]);\n }\n return accu;\n }, [])\n .slice(0, DEPLOYMENT_CUTOFF);\n accu.total += byStatus.total;\n return accu;\n },\n { total: 0 }\n )\n);\n"],"mappings":";;;AAmBA,MAAa,sBAAsB,UAAqB,MAAM,YAAY;AAC1E,MAAa,0BAA0B,UAAqB,MAAM,YAAY;AAC9E,MAAa,kCAAkC,UAAqB,MAAM,YAAY;AACtF,MAAa,gCAAgC,UAAqB,MAAM,YAAY;AAEpF,MAAa,oBAAoB,eAC/B,CAAC,qBAAqB,GAAG,iBAAiB,aAAa,GACtD,iBAAiB,eAAe,OAAO,gBAAgB,cACzD;AAED,MAAa,+BAA+B,eAC1C;CAAC;EAA+B,GAAG,qBAAqB;CAAkB;CAAmB,GAC5F,gBAAgB,kBAAkB,oBAAoB;CACrD,MAAM,EAAE,YAAY,EAAE,KAAK,eAAe,qBAAqB,EAAE;CACjE,OAAO,UAAU,QAAQ,MAAM,OAAO;EACpC,IAAI,gBAAgB,KAClB,KAAK,KAAK,gBAAgB,IAAI;EAEhC,OAAO;IACN,EAAE,CAAC;EAET;AAED,MAAM,2BAA2B;CAAC,kBAAkB;CAAS,kBAAkB;CAAY,kBAAkB;CAAS;AACtH,MAAa,oBAAoB;AACjC,MAAa,uBAAuB,eAAe,CAAC,oBAAoB,uBAAuB,GAAG,iBAAiB,wBACjH,OAAO,QAAQ,oBAAoB,CAAC,QACjC,MAAM,CAAC,OAAO,cAAc;CAC3B,IAAI,CAAC,yBAAyB,SAAS,MAAmD,IAAI,CAAC,SAAS,cAAc,QACpH,OAAO;CAET,KAAK,SAAS,SAAS,cACpB,QAAsB,MAAM,OAAO;EAClC,IAAI,gBAAgB,KAClB,KAAK,KAAK,gBAAgB,IAAI;EAEhC,OAAO;IACN,EAAE,CAAC,CACL,MAAM,GAAA,EAAqB;CAC9B,KAAK,SAAS,SAAS;CACvB,OAAO;GAET,EAAE,OAAO,GAAG,CACb,CACF"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { T as SortOptions } from "../constants-
|
|
1
|
+
import { T as SortOptions } from "../constants-BrGIx40B.cjs";
|
|
2
2
|
import { c as SelectionListState, i as DeploymentConfig, l as SelectionState, r as DeploymentByStatusKey, t as Deployment } from "../index-BP0uAq36.cjs";
|
|
3
|
-
import { t as Device$1 } from "../index-
|
|
4
|
-
import { s as SnackbarContent } from "../index-
|
|
5
|
-
import { r as RootState, t as AppDispatch } from "../store-
|
|
3
|
+
import { t as Device$1 } from "../index-B64X5ozM.cjs";
|
|
4
|
+
import { s as SnackbarContent } from "../index-DwACbyUg.cjs";
|
|
5
|
+
import { r as RootState, t as AppDispatch } from "../store-b5cF2WB5.cjs";
|
|
6
6
|
import * as _$_reduxjs_toolkit0 from "@reduxjs/toolkit";
|
|
7
7
|
import { DeploymentV1, NewDeploymentForGroup, NewDeploymentTypeManagement, NewDeploymentV2TypeManagement } from "@northern.tech/types/MenderTypes";
|
|
8
8
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { T as SortOptions } from "../constants-
|
|
1
|
+
import { T as SortOptions } from "../constants-CjO3_FOH.js";
|
|
2
2
|
import { c as SelectionListState, i as DeploymentConfig, l as SelectionState, r as DeploymentByStatusKey, t as Deployment } from "../index-CkwVnIqd.js";
|
|
3
|
-
import { t as Device$1 } from "../index-
|
|
4
|
-
import { s as SnackbarContent } from "../index-
|
|
5
|
-
import { r as RootState, t as AppDispatch } from "../store-
|
|
3
|
+
import { t as Device$1 } from "../index-BI9O8JWe.js";
|
|
4
|
+
import { s as SnackbarContent } from "../index-Bp1WpATs.js";
|
|
5
|
+
import { r as RootState, t as AppDispatch } from "../store-D-xvZXiY.js";
|
|
6
6
|
import * as _$_reduxjs_toolkit0 from "@reduxjs/toolkit";
|
|
7
7
|
import { DeploymentV1, NewDeploymentForGroup, NewDeploymentTypeManagement, NewDeploymentV2TypeManagement } from "@northern.tech/types/MenderTypes";
|
|
8
8
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _t as geoAttributes, dt as DEVICE_DISMISSAL_STATE, ft as DEVICE_MESSAGE_PROTOCOLS, gt as emptyFilter, ht as REPORT_CHART_SIZE_LIMIT, mt as DeviceAuthState, pt as DEVICE_MESSAGE_TYPES, ut as DEVICE_CONNECT_STATES } from "../constants-BrGIx40B.cjs";
|
|
2
2
|
export { DEVICE_CONNECT_STATES, DEVICE_DISMISSAL_STATE, DEVICE_MESSAGE_PROTOCOLS, DEVICE_MESSAGE_TYPES, DeviceAuthState, REPORT_CHART_SIZE_LIMIT, emptyFilter, geoAttributes };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _t as geoAttributes, dt as DEVICE_DISMISSAL_STATE, ft as DEVICE_MESSAGE_PROTOCOLS, gt as emptyFilter, ht as REPORT_CHART_SIZE_LIMIT, mt as DeviceAuthState, pt as DEVICE_MESSAGE_TYPES, ut as DEVICE_CONNECT_STATES } from "../constants-CjO3_FOH.js";
|
|
2
2
|
export { DEVICE_CONNECT_STATES, DEVICE_DISMISSAL_STATE, DEVICE_MESSAGE_PROTOCOLS, DEVICE_MESSAGE_TYPES, DeviceAuthState, REPORT_CHART_SIZE_LIMIT, emptyFilter, geoAttributes };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["DEVICE_STATES","DEVICE_LIST_DEFAULTS","SORTING_OPTIONS","duplicateFilter"],"sources":["../../src/devicesSlice/index.ts"],"sourcesContent":["// Copyright 2023 Northern.tech AS\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport type {\n Device as BackendDeviceAuth,\n ConnectionState,\n DeviceConfiguration,\n DeviceState,\n DeviceTierLimits,\n MonitorConfiguration,\n Scope,\n SortCriteria,\n Status\n} from '@northern.tech/types/MenderTypes';\n// @ts-nocheck\nimport { deepCompare, duplicateFilter } from '@northern.tech/utils/helpers';\nimport type { PayloadAction } from '@reduxjs/toolkit';\nimport { createSlice } from '@reduxjs/toolkit';\n\nimport type { ALL_DEVICE_STATES, DeviceIssueOptionKey, FilterOperator, SortOptions } from '../constants';\nimport { DEVICE_LIST_DEFAULTS, DEVICE_STATES, SORTING_OPTIONS } from '../constants';\nimport type { DeviceDeployment } from '../deploymentsSlice';\nimport type { DeviceAuthState } from './constants';\n\nexport const sliceName = 'devices';\nexport type DeviceSelectedAttribute = { attribute: string; scope: string };\nexport type DeviceListState = {\n detailsTab: string;\n deviceIds: string[];\n isLoading: boolean;\n open?: boolean;\n page: number;\n perPage: number;\n refreshTrigger: boolean;\n selectedAttributes: DeviceSelectedAttribute[];\n selectedId?: string;\n selectedIssues: DeviceIssueOptionKey[];\n selection: number[];\n setOnly?: boolean;\n sort: SortOptions & Partial<SortCriteria>;\n state?: DeviceAuthState | typeof ALL_DEVICE_STATES;\n total: number;\n};\ntype DeviceReport = {\n items: { count: number; key: string }[];\n otherCount: number;\n total: number;\n};\nexport type DeviceGroup = { deviceIds?: string[]; filters?: DeviceFilter[]; id?: string; total?: number };\nexport type InventoryAttributes = {\n [key: string]: string | string[];\n artifact_name: string;\n device_type: string[];\n};\n\n// based on the api docs the Record values might be even: \"Supported types: number, string, array of numbers, array of strings\" - but I guess \"string\" or \"string | sting[]\" should be good enough\ntype UiDeviceAttributes = {\n attributes: InventoryAttributes;\n identity?: Record<string, string>;\n monitor?: Record<string, string>;\n system: Record<string, string>;\n tags?: Record<string, string>;\n};\n\nexport type Device = BackendDeviceAuth &\n UiDeviceAttributes & {\n check_in_time_exact?: string;\n check_in_time_rounded?: string;\n config?: DeviceConfiguration;\n connect_status?: ConnectionState['status'];\n connect_updated_ts?: string;\n deploymentsCount?: number;\n deviceDeployments?: DeviceDeployment;\n etag?: string;\n gatewayIds?: string[];\n group?: string;\n id: string;\n isNew?: boolean;\n isOffline?: boolean;\n monitors?: MonitorConfiguration[];\n status: Status;\n twinsByIntegration?: Record<string, DeviceState & { twinError?: string }>;\n };\nexport type DeviceFilter = {\n key: string;\n operator: FilterOperator;\n scope: Scope;\n value: string | string[];\n};\ntype FilteringAttributes = {\n identityAttributes: string[];\n inventoryAttributes: string[];\n systemAttributes: string[];\n tagAttributes: string[];\n};\ntype FilteringAttributesConfig = {\n attributes: Record<string, string[]>;\n count: number;\n limit: number;\n};\n\nexport type DeviceGroups = {\n byId: Record<string, DeviceGroup>;\n selectedGroup?: string;\n};\nexport type DeviceSliceType = {\n byId: Record<string, Device>;\n byStatus: Record<DeviceAuthState, { counts: DeviceTierLimits & { total: number }; deviceIds: string[] }>;\n deviceList: DeviceListState;\n filteringAttributes: FilteringAttributes;\n filteringAttributesConfig: FilteringAttributesConfig;\n filteringAttributesLimit: number;\n filters: DeviceFilter[];\n groups: DeviceGroups;\n limits: DeviceTierLimits;\n reports: DeviceReport[];\n total: number;\n};\nexport const initialState: DeviceSliceType = {\n byId: {\n // [deviceId]: {\n // ...,\n // twinsByIntegration: { [external.provider.id]: twinData }\n // }\n },\n byStatus: {\n [DEVICE_STATES.accepted]: { deviceIds: [], counts: { standard: 0, micro: 0, system: 0, total: 0 } },\n [DEVICE_STATES.pending]: { deviceIds: [], counts: { standard: 0, micro: 0, system: 0, total: 0 } },\n [DEVICE_STATES.preauth]: { deviceIds: [], counts: { standard: 0, micro: 0, system: 0, total: 0 } },\n [DEVICE_STATES.rejected]: { deviceIds: [], counts: { standard: 0, micro: 0, system: 0, total: 0 } }\n },\n deviceList: {\n deviceIds: [],\n ...DEVICE_LIST_DEFAULTS,\n selectedAttributes: [],\n selectedIssues: [],\n selection: [],\n sort: {\n direction: SORTING_OPTIONS.desc\n // key: null,\n // scope: null\n },\n state: DEVICE_STATES.accepted,\n total: 0,\n refreshTrigger: false,\n isLoading: false,\n detailsTab: '',\n open: false\n },\n filters: [\n // { key: 'device_type', value: 'raspberry', operator: '$eq', scope: 'inventory' }\n ],\n filteringAttributes: { identityAttributes: [], inventoryAttributes: [], systemAttributes: [], tagAttributes: [] },\n filteringAttributesLimit: 10,\n filteringAttributesConfig: {\n attributes: {\n // inventory: ['some_attribute']\n },\n count: 0,\n limit: 100\n },\n reports: [\n // { items: [{ key: \"someKey\", count: 42 }], otherCount: 123, total: <otherCount + itemsCount> }\n ],\n total: 0,\n limits: {\n standard: 0,\n micro: 0,\n system: 0\n },\n groups: {\n byId: {\n // groupName: { deviceIds: [], total: 0, filters: [] },\n // dynamo: { deviceIds: [], total: 3, filters: [{ a: 1 }] }\n },\n selectedGroup: undefined\n }\n};\n\nexport const devicesSlice = createSlice({\n name: sliceName,\n initialState,\n reducers: {\n receivedGroups: (state, action: PayloadAction<Record<string, DeviceGroup>>) => {\n state.groups.byId = action.payload;\n },\n addToGroup: (state, action: PayloadAction<{ deviceIds: string[]; group: string }>) => {\n const { group, deviceIds } = action.payload;\n const maybeExistingGroup = {\n filters: [],\n deviceIds: [],\n ...state.groups.byId[group]\n };\n state.groups.byId[group] = {\n ...maybeExistingGroup,\n deviceIds: [...maybeExistingGroup.deviceIds, ...deviceIds].filter(duplicateFilter),\n total: (maybeExistingGroup.total || 0) + 1\n };\n },\n removeFromGroup: (state, action: PayloadAction<{ deviceIds: string[]; group: string }>) => {\n const { group, deviceIds: removedIds } = action.payload;\n const { deviceIds = [], total = 0, ...maybeExistingGroup } = state.groups.byId[group] || {};\n const changedGroup = {\n ...maybeExistingGroup,\n deviceIds: deviceIds.filter(id => !removedIds.includes(id)),\n total: Math.max(total - removedIds.length, 0)\n };\n if (changedGroup.total || changedGroup.deviceIds.length) {\n state.groups.byId[group] = changedGroup;\n return;\n } else if (state.groups.selectedGroup === group) {\n state.groups.selectedGroup = undefined;\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { [group]: removal, ...remainingById } = state.groups.byId;\n state.groups.byId = remainingById;\n },\n addGroup: (state, action: PayloadAction<{ group: DeviceGroup; groupName: string }>) => {\n const { groupName, group } = action.payload;\n state.groups.byId[groupName] = {\n ...state.groups.byId[groupName],\n ...group\n };\n },\n selectGroup: (state, { payload: group }: PayloadAction<string | undefined>) => {\n state.deviceList.deviceIds =\n group && state.groups.byId[group] && state.groups.byId[group].deviceIds && state.groups.byId[group].deviceIds.length > 0\n ? state.groups.byId[group].deviceIds\n : [];\n state.groups.selectedGroup = group;\n },\n removeGroup: (state, action: PayloadAction<string>) => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { [action.payload]: removal, ...remainingById } = state.groups.byId;\n state.groups.byId = remainingById;\n state.groups.selectedGroup = state.groups.selectedGroup === action.payload ? undefined : state.groups.selectedGroup;\n },\n setDeviceListState: (state, action: PayloadAction<Partial<DeviceListState>>) => {\n state.deviceList = {\n ...state.deviceList,\n ...action.payload,\n sort: {\n ...state.deviceList.sort,\n ...action.payload.sort\n }\n };\n },\n setFilterAttributes: (state, action: PayloadAction<FilteringAttributes>) => {\n state.filteringAttributes = action.payload;\n },\n setFilterablesConfig: (state, action: PayloadAction<FilteringAttributesConfig>) => {\n state.filteringAttributesConfig = action.payload;\n },\n receivedDevices: (state, action: PayloadAction<Record<string, Device>>) => {\n state.byId = {\n ...state.byId,\n ...action.payload\n };\n },\n setDeviceFilters: (state, action: PayloadAction<DeviceFilter[]>) => {\n if (deepCompare(action.payload, state.filters)) {\n return;\n }\n state.filters = action.payload.filter(filter => filter.key && filter.operator && filter.scope && typeof filter.value !== 'undefined');\n },\n setDeviceReports: (state, action: PayloadAction<DeviceReport[]>) => {\n state.reports = action.payload;\n },\n setDevicesByStatus: (state, action: PayloadAction<{ deviceIds: string[]; status: DeviceAuthState; total: number }>) => {\n const { status, total, deviceIds } = action.payload;\n if (total) {\n state.byStatus[status].deviceIds = deviceIds;\n state.byStatus[status].counts.total = total;\n }\n },\n setDevicesCountByStatus: (state, action: PayloadAction<{ countsPerTier: DeviceTierLimits; status: DeviceAuthState }>) => {\n const { countsPerTier, status } = action.payload;\n state.byStatus[status].counts = { ...countsPerTier, total: Object.values(countsPerTier).reduce((accu, tieredCount) => (accu += tieredCount), 0) };\n },\n setDeviceLimits: (state, action: PayloadAction<DeviceTierLimits>) => {\n state.limits = action.payload;\n },\n receivedDevice: (state, action: PayloadAction<{ id: string } & Partial<Device>>) => {\n state.byId[action.payload.id] = {\n ...state.byId[action.payload.id],\n ...action.payload\n };\n },\n maybeUpdateDevicesByStatus: (state, action: PayloadAction<{ authId?: string; deviceId: string }>) => {\n const { deviceId, authId } = action.payload;\n const device = state.byId[deviceId];\n const hasMultipleAuthSets = authId && device.auth_sets ? device.auth_sets.filter(authset => authset.id !== authId).length > 0 : false;\n if (!hasMultipleAuthSets && (Object.values(DEVICE_STATES) as string[]).includes(device.status)) {\n const deviceIds = state.byStatus[device.status].deviceIds.filter(id => id !== deviceId);\n const deviceTier = (device.attributes.tier as string) || 'standard';\n state.byStatus[device.status] = {\n deviceIds,\n counts: {\n ...state.byStatus[device.status].counts,\n [deviceTier]: Math.max(0, state.byStatus[device.status].counts[deviceTier] - 1),\n total: Math.max(0, state.byStatus[device.status].counts.total - 1)\n }\n };\n }\n }\n }\n});\n\nexport const actions = devicesSlice.actions;\nexport default devicesSlice.reducer;\n"],"mappings":";;;;;;;;;AAkCA,MAAa,YAAY;AA8FzB,MAAa,eAAgC;CAC3C,MAAM,EAKL;CACD,UAAU;GACPA,+BAAAA,cAAc,WAAW;GAAE,WAAW,EAAE;GAAE,QAAQ;IAAE,UAAU;IAAG,OAAO;IAAG,QAAQ;IAAG,OAAO;IAAG;GAAE;GAClGA,+BAAAA,cAAc,UAAU;GAAE,WAAW,EAAE;GAAE,QAAQ;IAAE,UAAU;IAAG,OAAO;IAAG,QAAQ;IAAG,OAAO;IAAG;GAAE;GACjGA,+BAAAA,cAAc,UAAU;GAAE,WAAW,EAAE;GAAE,QAAQ;IAAE,UAAU;IAAG,OAAO;IAAG,QAAQ;IAAG,OAAO;IAAG;GAAE;GACjGA,+BAAAA,cAAc,WAAW;GAAE,WAAW,EAAE;GAAE,QAAQ;IAAE,UAAU;IAAG,OAAO;IAAG,QAAQ;IAAG,OAAO;IAAG;GAAE;EACpG;CACD,YAAY;EACV,WAAW,EAAE;EACb,GAAGC,+BAAAA;EACH,oBAAoB,EAAE;EACtB,gBAAgB,EAAE;EAClB,WAAW,EAAE;EACb,MAAM,EACJ,WAAWC,+BAAAA,gBAAgB,MAG5B;EACD,OAAOF,+BAAAA,cAAc;EACrB,OAAO;EACP,gBAAgB;EAChB,WAAW;EACX,YAAY;EACZ,MAAM;EACP;CACD,SAAS,EAER;CACD,qBAAqB;EAAE,oBAAoB,EAAE;EAAE,qBAAqB,EAAE;EAAE,kBAAkB,EAAE;EAAE,eAAe,EAAE;EAAE;CACjH,0BAA0B;CAC1B,2BAA2B;EACzB,YAAY,EAEX;EACD,OAAO;EACP,OAAO;EACR;CACD,SAAS,EAER;CACD,OAAO;CACP,QAAQ;EACN,UAAU;EACV,OAAO;EACP,QAAQ;EACT;CACD,QAAQ;EACN,MA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O,OAAO,OAAO,cAAc,CAAC,QAAQ,MAAM,gBAAiB,QAAQ,aAAc,EAAE;IAAE;;EAEnJ,kBAAkB,OAAO,WAA4C;AACnE,SAAM,SAAS,OAAO;;EAExB,iBAAiB,OAAO,WAA4D;AAClF,SAAM,KAAK,OAAO,QAAQ,MAAM;IAC9B,GAAG,MAAM,KAAK,OAAO,QAAQ;IAC7B,GAAG,OAAO;IACX;;EAEH,6BAA6B,OAAO,WAAiE;GACnG,MAAM,EAAE,UAAU,WAAW,OAAO;GACpC,MAAM,SAAS,MAAM,KAAK;AAE1B,OAAI,EADwB,UAAU,OAAO,YAAY,OAAO,UAAU,QAAO,YAAW,QAAQ,OAAO,OAAO,CAAC,SAAS,IAAI,UACnG,OAAO,OAAOH,+BAAAA,cAAc,CAAc,SAAS,OAAO,OAAO,EAAE;IAC9F,MAAM,YAAY,MAAM,SAAS,OAAO,QAAQ,UAAU,QAAO,OAAM,OAAO,SAAS;IACvF,MAAM,aAAc,OAAO,WAAW,QAAmB;AACzD,UAAM,SAAS,OAAO,UAAU;KAC9B;KACA,QAAQ;MACN,GAAG,MAAM,SAAS,OAAO,QAAQ;OAChC,aAAa,KAAK,IAAI,GAAG,MAAM,SAAS,OAAO,QAAQ,OAAO,cAAc,EAAE;MAC/E,OAAO,KAAK,IAAI,GAAG,MAAM,SAAS,OAAO,QAAQ,OAAO,QAAQ,EAAE;MACnE;KACF;;;EAGN;CACF,CAAC;AAEF,MAAa,UAAU,aAAa;AACpC,IAAA,uBAAe,aAAa"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["DEVICE_STATES","DEVICE_LIST_DEFAULTS","SORTING_OPTIONS","duplicateFilter"],"sources":["../../src/devicesSlice/index.ts"],"sourcesContent":["// Copyright 2023 Northern.tech AS\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport type {\n Device as BackendDeviceAuth,\n ConnectionState,\n DeviceConfiguration,\n DeviceState,\n DeviceTierLimits,\n MonitorConfiguration,\n Scope,\n SortCriteria,\n Status\n} from '@northern.tech/types/MenderTypes';\n// @ts-nocheck\nimport { deepCompare, duplicateFilter } from '@northern.tech/utils/helpers';\nimport type { PayloadAction } from '@reduxjs/toolkit';\nimport { createSlice } from '@reduxjs/toolkit';\n\nimport type { ALL_DEVICE_STATES, DeviceIssueOptionKey, FilterOperator, SortOptions } from '../constants';\nimport { DEVICE_LIST_DEFAULTS, DEVICE_STATES, SORTING_OPTIONS } from '../constants';\nimport type { DeviceDeployment } from '../deploymentsSlice';\nimport type { DeviceAuthState } from './constants';\n\nexport const sliceName = 'devices';\nexport type DeviceSelectedAttribute = { attribute: string; scope: string };\nexport type DeviceListState = {\n detailsTab: string;\n deviceIds: string[];\n isLoading: boolean;\n open?: boolean;\n page: number;\n perPage: number;\n refreshTrigger: boolean;\n selectedAttributes: DeviceSelectedAttribute[];\n selectedId?: string;\n selectedIssues: DeviceIssueOptionKey[];\n selection: number[];\n setOnly?: boolean;\n sort: SortOptions & Partial<SortCriteria>;\n state?: DeviceAuthState | typeof ALL_DEVICE_STATES;\n total: number;\n};\ntype DeviceReport = {\n items: { count: number; key: string }[];\n otherCount: number;\n total: number;\n};\nexport type DeviceGroup = { deviceIds?: string[]; filters?: DeviceFilter[]; id?: string; total?: number };\nexport type InventoryAttributes = {\n [key: string]: string | string[];\n artifact_name: string;\n device_type: string[];\n};\n\n// based on the api docs the Record values might be even: \"Supported types: number, string, array of numbers, array of strings\" - but I guess \"string\" or \"string | sting[]\" should be good enough\ntype UiDeviceAttributes = {\n attributes: InventoryAttributes;\n identity?: Record<string, string>;\n monitor?: Record<string, string>;\n system: Record<string, string>;\n tags?: Record<string, string>;\n};\n\nexport type Device = BackendDeviceAuth &\n UiDeviceAttributes & {\n check_in_time_exact?: string;\n check_in_time_rounded?: string;\n config?: DeviceConfiguration;\n connect_status?: ConnectionState['status'];\n connect_updated_ts?: string;\n deploymentsCount?: number;\n deviceDeployments?: DeviceDeployment;\n etag?: string;\n gatewayIds?: string[];\n group?: string;\n id: string;\n isNew?: boolean;\n isOffline?: boolean;\n monitors?: MonitorConfiguration[];\n status: Status;\n twinsByIntegration?: Record<string, DeviceState & { twinError?: string }>;\n };\nexport type DeviceFilter = {\n key: string;\n operator: FilterOperator;\n scope: Scope;\n value: string | string[];\n};\ntype FilteringAttributes = {\n identityAttributes: string[];\n inventoryAttributes: string[];\n systemAttributes: string[];\n tagAttributes: string[];\n};\ntype FilteringAttributesConfig = {\n attributes: Record<string, string[]>;\n count: number;\n limit: number;\n};\n\nexport type DeviceGroups = {\n byId: Record<string, DeviceGroup>;\n selectedGroup?: string;\n};\nexport type DeviceSliceType = {\n byId: Record<string, Device>;\n byStatus: Record<DeviceAuthState, { counts: DeviceTierLimits & { total: number }; deviceIds: string[] }>;\n deviceList: DeviceListState;\n filteringAttributes: FilteringAttributes;\n filteringAttributesConfig: FilteringAttributesConfig;\n filteringAttributesLimit: number;\n filters: DeviceFilter[];\n groups: DeviceGroups;\n limits: DeviceTierLimits;\n reports: DeviceReport[];\n total: number;\n};\nexport const initialState: DeviceSliceType = {\n byId: {\n // [deviceId]: {\n // ...,\n // twinsByIntegration: { [external.provider.id]: twinData }\n // }\n },\n byStatus: {\n [DEVICE_STATES.accepted]: { deviceIds: [], counts: { standard: 0, micro: 0, system: 0, total: 0 } },\n [DEVICE_STATES.pending]: { deviceIds: [], counts: { standard: 0, micro: 0, system: 0, total: 0 } },\n [DEVICE_STATES.preauth]: { deviceIds: [], counts: { standard: 0, micro: 0, system: 0, total: 0 } },\n [DEVICE_STATES.rejected]: { deviceIds: [], counts: { standard: 0, micro: 0, system: 0, total: 0 } }\n },\n deviceList: {\n deviceIds: [],\n ...DEVICE_LIST_DEFAULTS,\n selectedAttributes: [],\n selectedIssues: [],\n selection: [],\n sort: {\n direction: SORTING_OPTIONS.desc\n // key: null,\n // scope: null\n },\n state: DEVICE_STATES.accepted,\n total: 0,\n refreshTrigger: false,\n isLoading: false,\n detailsTab: '',\n open: false\n },\n filters: [\n // { key: 'device_type', value: 'raspberry', operator: '$eq', scope: 'inventory' }\n ],\n filteringAttributes: { identityAttributes: [], inventoryAttributes: [], systemAttributes: [], tagAttributes: [] },\n filteringAttributesLimit: 10,\n filteringAttributesConfig: {\n attributes: {\n // inventory: ['some_attribute']\n },\n count: 0,\n limit: 100\n },\n reports: [\n // { items: [{ key: \"someKey\", count: 42 }], otherCount: 123, total: <otherCount + itemsCount> }\n ],\n total: 0,\n limits: {\n standard: 0,\n micro: 0,\n system: 0\n },\n groups: {\n byId: {\n // groupName: { deviceIds: [], total: 0, filters: [] },\n // dynamo: { deviceIds: [], total: 3, filters: [{ a: 1 }] }\n },\n selectedGroup: undefined\n }\n};\n\nexport const devicesSlice = createSlice({\n name: sliceName,\n initialState,\n reducers: {\n receivedGroups: (state, action: PayloadAction<Record<string, DeviceGroup>>) => {\n state.groups.byId = action.payload;\n },\n addToGroup: (state, action: PayloadAction<{ deviceIds: string[]; group: string }>) => {\n const { group, deviceIds } = action.payload;\n const maybeExistingGroup = {\n filters: [],\n deviceIds: [],\n ...state.groups.byId[group]\n };\n state.groups.byId[group] = {\n ...maybeExistingGroup,\n deviceIds: [...maybeExistingGroup.deviceIds, ...deviceIds].filter(duplicateFilter),\n total: (maybeExistingGroup.total || 0) + 1\n };\n },\n removeFromGroup: (state, action: PayloadAction<{ deviceIds: string[]; group: string }>) => {\n const { group, deviceIds: removedIds } = action.payload;\n const { deviceIds = [], total = 0, ...maybeExistingGroup } = state.groups.byId[group] || {};\n const changedGroup = {\n ...maybeExistingGroup,\n deviceIds: deviceIds.filter(id => !removedIds.includes(id)),\n total: Math.max(total - removedIds.length, 0)\n };\n if (changedGroup.total || changedGroup.deviceIds.length) {\n state.groups.byId[group] = changedGroup;\n return;\n } else if (state.groups.selectedGroup === group) {\n state.groups.selectedGroup = undefined;\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { [group]: removal, ...remainingById } = state.groups.byId;\n state.groups.byId = remainingById;\n },\n addGroup: (state, action: PayloadAction<{ group: DeviceGroup; groupName: string }>) => {\n const { groupName, group } = action.payload;\n state.groups.byId[groupName] = {\n ...state.groups.byId[groupName],\n ...group\n };\n },\n selectGroup: (state, { payload: group }: PayloadAction<string | undefined>) => {\n state.deviceList.deviceIds =\n group && state.groups.byId[group] && state.groups.byId[group].deviceIds && state.groups.byId[group].deviceIds.length > 0\n ? state.groups.byId[group].deviceIds\n : [];\n state.groups.selectedGroup = group;\n },\n removeGroup: (state, action: PayloadAction<string>) => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { [action.payload]: removal, ...remainingById } = state.groups.byId;\n state.groups.byId = remainingById;\n state.groups.selectedGroup = state.groups.selectedGroup === action.payload ? undefined : state.groups.selectedGroup;\n },\n setDeviceListState: (state, action: PayloadAction<Partial<DeviceListState>>) => {\n state.deviceList = {\n ...state.deviceList,\n ...action.payload,\n sort: {\n ...state.deviceList.sort,\n ...action.payload.sort\n }\n };\n },\n setFilterAttributes: (state, action: PayloadAction<FilteringAttributes>) => {\n state.filteringAttributes = action.payload;\n },\n setFilterablesConfig: (state, action: PayloadAction<FilteringAttributesConfig>) => {\n state.filteringAttributesConfig = action.payload;\n },\n receivedDevices: (state, action: PayloadAction<Record<string, Device>>) => {\n state.byId = {\n ...state.byId,\n ...action.payload\n };\n },\n setDeviceFilters: (state, action: PayloadAction<DeviceFilter[]>) => {\n if (deepCompare(action.payload, state.filters)) {\n return;\n }\n state.filters = action.payload.filter(filter => filter.key && filter.operator && filter.scope && typeof filter.value !== 'undefined');\n },\n setDeviceReports: (state, action: PayloadAction<DeviceReport[]>) => {\n state.reports = action.payload;\n },\n setDevicesByStatus: (state, action: PayloadAction<{ deviceIds: string[]; status: DeviceAuthState; total: number }>) => {\n const { status, total, deviceIds } = action.payload;\n if (total) {\n state.byStatus[status].deviceIds = deviceIds;\n state.byStatus[status].counts.total = total;\n }\n },\n setDevicesCountByStatus: (state, action: PayloadAction<{ countsPerTier: DeviceTierLimits; status: DeviceAuthState }>) => {\n const { countsPerTier, status } = action.payload;\n state.byStatus[status].counts = { ...countsPerTier, total: Object.values(countsPerTier).reduce((accu, tieredCount) => (accu += tieredCount), 0) };\n },\n setDeviceLimits: (state, action: PayloadAction<DeviceTierLimits>) => {\n state.limits = action.payload;\n },\n receivedDevice: (state, action: PayloadAction<{ id: string } & Partial<Device>>) => {\n state.byId[action.payload.id] = {\n ...state.byId[action.payload.id],\n ...action.payload\n };\n },\n maybeUpdateDevicesByStatus: (state, action: PayloadAction<{ authId?: string; deviceId: string }>) => {\n const { deviceId, authId } = action.payload;\n const device = state.byId[deviceId];\n const hasMultipleAuthSets = authId && device.auth_sets ? device.auth_sets.filter(authset => authset.id !== authId).length > 0 : false;\n if (!hasMultipleAuthSets && (Object.values(DEVICE_STATES) as string[]).includes(device.status)) {\n const deviceIds = state.byStatus[device.status].deviceIds.filter(id => id !== deviceId);\n const deviceTier = (device.attributes.tier as string) || 'standard';\n state.byStatus[device.status] = {\n deviceIds,\n counts: {\n ...state.byStatus[device.status].counts,\n [deviceTier]: Math.max(0, state.byStatus[device.status].counts[deviceTier] - 1),\n total: Math.max(0, state.byStatus[device.status].counts.total - 1)\n }\n };\n }\n }\n }\n});\n\nexport const actions = devicesSlice.actions;\nexport default devicesSlice.reducer;\n"],"mappings":";;;;;;;;;AAkCA,MAAa,YAAY;AA8FzB,MAAa,eAAgC;CAC3C,MAAM,EAKL;CACD,UAAU;GACPA,+BAAAA,cAAc,WAAW;GAAE,WAAW,EAAE;GAAE,QAAQ;IAAE,UAAU;IAAG,OAAO;IAAG,QAAQ;IAAG,OAAO;IAAG;GAAE;GAClGA,+BAAAA,cAAc,UAAU;GAA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IAAI,EADwB,UAAU,OAAO,YAAY,OAAO,UAAU,QAAO,YAAW,QAAQ,OAAO,OAAO,CAAC,SAAS,IAAI,UACnG,OAAO,OAAOH,+BAAAA,cAAc,CAAc,SAAS,OAAO,OAAO,EAAE;IAC9F,MAAM,YAAY,MAAM,SAAS,OAAO,QAAQ,UAAU,QAAO,OAAM,OAAO,SAAS;IACvF,MAAM,aAAc,OAAO,WAAW,QAAmB;IACzD,MAAM,SAAS,OAAO,UAAU;KAC9B;KACA,QAAQ;MACN,GAAG,MAAM,SAAS,OAAO,QAAQ;OAChC,aAAa,KAAK,IAAI,GAAG,MAAM,SAAS,OAAO,QAAQ,OAAO,cAAc,EAAE;MAC/E,OAAO,KAAK,IAAI,GAAG,MAAM,SAAS,OAAO,QAAQ,OAAO,QAAQ,EAAE;MACnE;KACF;;;EAGN;CACF,CAAC;AAEF,MAAa,UAAU,aAAa;AACpC,IAAA,uBAAe,aAAa"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as DeviceListState, c as InventoryAttributes, d as devicesSlice, f as initialState, i as DeviceGroups, l as _default, n as DeviceFilter, o as DeviceSelectedAttribute, p as sliceName, r as DeviceGroup, s as DeviceSliceType, t as Device, u as actions } from "../index-
|
|
1
|
+
import { a as DeviceListState, c as InventoryAttributes, d as devicesSlice, f as initialState, i as DeviceGroups, l as _default, n as DeviceFilter, o as DeviceSelectedAttribute, p as sliceName, r as DeviceGroup, s as DeviceSliceType, t as Device, u as actions } from "../index-B64X5ozM.cjs";
|
|
2
2
|
export { Device, DeviceFilter, DeviceGroup, DeviceGroups, DeviceListState, DeviceSelectedAttribute, DeviceSliceType, InventoryAttributes, actions, _default as default, devicesSlice, initialState, sliceName };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as DeviceListState, c as InventoryAttributes, d as devicesSlice, f as initialState, i as DeviceGroups, l as _default, n as DeviceFilter, o as DeviceSelectedAttribute, p as sliceName, r as DeviceGroup, s as DeviceSliceType, t as Device, u as actions } from "../index-
|
|
1
|
+
import { a as DeviceListState, c as InventoryAttributes, d as devicesSlice, f as initialState, i as DeviceGroups, l as _default, n as DeviceFilter, o as DeviceSelectedAttribute, p as sliceName, r as DeviceGroup, s as DeviceSliceType, t as Device, u as actions } from "../index-BI9O8JWe.js";
|
|
2
2
|
export { Device, DeviceFilter, DeviceGroup, DeviceGroups, DeviceListState, DeviceSelectedAttribute, DeviceSliceType, InventoryAttributes, actions, _default as default, devicesSlice, initialState, sliceName };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/devicesSlice/index.ts"],"sourcesContent":["// Copyright 2023 Northern.tech AS\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport type {\n Device as BackendDeviceAuth,\n ConnectionState,\n DeviceConfiguration,\n DeviceState,\n DeviceTierLimits,\n MonitorConfiguration,\n Scope,\n SortCriteria,\n Status\n} from '@northern.tech/types/MenderTypes';\n// @ts-nocheck\nimport { deepCompare, duplicateFilter } from '@northern.tech/utils/helpers';\nimport type { PayloadAction } from '@reduxjs/toolkit';\nimport { createSlice } from '@reduxjs/toolkit';\n\nimport type { ALL_DEVICE_STATES, DeviceIssueOptionKey, FilterOperator, SortOptions } from '../constants';\nimport { DEVICE_LIST_DEFAULTS, DEVICE_STATES, SORTING_OPTIONS } from '../constants';\nimport type { DeviceDeployment } from '../deploymentsSlice';\nimport type { DeviceAuthState } from './constants';\n\nexport const sliceName = 'devices';\nexport type DeviceSelectedAttribute = { attribute: string; scope: string };\nexport type DeviceListState = {\n detailsTab: string;\n deviceIds: string[];\n isLoading: boolean;\n open?: boolean;\n page: number;\n perPage: number;\n refreshTrigger: boolean;\n selectedAttributes: DeviceSelectedAttribute[];\n selectedId?: string;\n selectedIssues: DeviceIssueOptionKey[];\n selection: number[];\n setOnly?: boolean;\n sort: SortOptions & Partial<SortCriteria>;\n state?: DeviceAuthState | typeof ALL_DEVICE_STATES;\n total: number;\n};\ntype DeviceReport = {\n items: { count: number; key: string }[];\n otherCount: number;\n total: number;\n};\nexport type DeviceGroup = { deviceIds?: string[]; filters?: DeviceFilter[]; id?: string; total?: number };\nexport type InventoryAttributes = {\n [key: string]: string | string[];\n artifact_name: string;\n device_type: string[];\n};\n\n// based on the api docs the Record values might be even: \"Supported types: number, string, array of numbers, array of strings\" - but I guess \"string\" or \"string | sting[]\" should be good enough\ntype UiDeviceAttributes = {\n attributes: InventoryAttributes;\n identity?: Record<string, string>;\n monitor?: Record<string, string>;\n system: Record<string, string>;\n tags?: Record<string, string>;\n};\n\nexport type Device = BackendDeviceAuth &\n UiDeviceAttributes & {\n check_in_time_exact?: string;\n check_in_time_rounded?: string;\n config?: DeviceConfiguration;\n connect_status?: ConnectionState['status'];\n connect_updated_ts?: string;\n deploymentsCount?: number;\n deviceDeployments?: DeviceDeployment;\n etag?: string;\n gatewayIds?: string[];\n group?: string;\n id: string;\n isNew?: boolean;\n isOffline?: boolean;\n monitors?: MonitorConfiguration[];\n status: Status;\n twinsByIntegration?: Record<string, DeviceState & { twinError?: string }>;\n };\nexport type DeviceFilter = {\n key: string;\n operator: FilterOperator;\n scope: Scope;\n value: string | string[];\n};\ntype FilteringAttributes = {\n identityAttributes: string[];\n inventoryAttributes: string[];\n systemAttributes: string[];\n tagAttributes: string[];\n};\ntype FilteringAttributesConfig = {\n attributes: Record<string, string[]>;\n count: number;\n limit: number;\n};\n\nexport type DeviceGroups = {\n byId: Record<string, DeviceGroup>;\n selectedGroup?: string;\n};\nexport type DeviceSliceType = {\n byId: Record<string, Device>;\n byStatus: Record<DeviceAuthState, { counts: DeviceTierLimits & { total: number }; deviceIds: string[] }>;\n deviceList: DeviceListState;\n filteringAttributes: FilteringAttributes;\n filteringAttributesConfig: FilteringAttributesConfig;\n filteringAttributesLimit: number;\n filters: DeviceFilter[];\n groups: DeviceGroups;\n limits: DeviceTierLimits;\n reports: DeviceReport[];\n total: number;\n};\nexport const initialState: DeviceSliceType = {\n byId: {\n // [deviceId]: {\n // ...,\n // twinsByIntegration: { [external.provider.id]: twinData }\n // }\n },\n byStatus: {\n [DEVICE_STATES.accepted]: { deviceIds: [], counts: { standard: 0, micro: 0, system: 0, total: 0 } },\n [DEVICE_STATES.pending]: { deviceIds: [], counts: { standard: 0, micro: 0, system: 0, total: 0 } },\n [DEVICE_STATES.preauth]: { deviceIds: [], counts: { standard: 0, micro: 0, system: 0, total: 0 } },\n [DEVICE_STATES.rejected]: { deviceIds: [], counts: { standard: 0, micro: 0, system: 0, total: 0 } }\n },\n deviceList: {\n deviceIds: [],\n ...DEVICE_LIST_DEFAULTS,\n selectedAttributes: [],\n selectedIssues: [],\n selection: [],\n sort: {\n direction: SORTING_OPTIONS.desc\n // key: null,\n // scope: null\n },\n state: DEVICE_STATES.accepted,\n total: 0,\n refreshTrigger: false,\n isLoading: false,\n detailsTab: '',\n open: false\n },\n filters: [\n // { key: 'device_type', value: 'raspberry', operator: '$eq', scope: 'inventory' }\n ],\n filteringAttributes: { identityAttributes: [], inventoryAttributes: [], systemAttributes: [], tagAttributes: [] },\n filteringAttributesLimit: 10,\n filteringAttributesConfig: {\n attributes: {\n // inventory: ['some_attribute']\n },\n count: 0,\n limit: 100\n },\n reports: [\n // { items: [{ key: \"someKey\", count: 42 }], otherCount: 123, total: <otherCount + itemsCount> }\n ],\n total: 0,\n limits: {\n standard: 0,\n micro: 0,\n system: 0\n },\n groups: {\n byId: {\n // groupName: { deviceIds: [], total: 0, filters: [] },\n // dynamo: { deviceIds: [], total: 3, filters: [{ a: 1 }] }\n },\n selectedGroup: undefined\n }\n};\n\nexport const devicesSlice = createSlice({\n name: sliceName,\n initialState,\n reducers: {\n receivedGroups: (state, action: PayloadAction<Record<string, DeviceGroup>>) => {\n state.groups.byId = action.payload;\n },\n addToGroup: (state, action: PayloadAction<{ deviceIds: string[]; group: string }>) => {\n const { group, deviceIds } = action.payload;\n const maybeExistingGroup = {\n filters: [],\n deviceIds: [],\n ...state.groups.byId[group]\n };\n state.groups.byId[group] = {\n ...maybeExistingGroup,\n deviceIds: [...maybeExistingGroup.deviceIds, ...deviceIds].filter(duplicateFilter),\n total: (maybeExistingGroup.total || 0) + 1\n };\n },\n removeFromGroup: (state, action: PayloadAction<{ deviceIds: string[]; group: string }>) => {\n const { group, deviceIds: removedIds } = action.payload;\n const { deviceIds = [], total = 0, ...maybeExistingGroup } = state.groups.byId[group] || {};\n const changedGroup = {\n ...maybeExistingGroup,\n deviceIds: deviceIds.filter(id => !removedIds.includes(id)),\n total: Math.max(total - removedIds.length, 0)\n };\n if (changedGroup.total || changedGroup.deviceIds.length) {\n state.groups.byId[group] = changedGroup;\n return;\n } else if (state.groups.selectedGroup === group) {\n state.groups.selectedGroup = undefined;\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { [group]: removal, ...remainingById } = state.groups.byId;\n state.groups.byId = remainingById;\n },\n addGroup: (state, action: PayloadAction<{ group: DeviceGroup; groupName: string }>) => {\n const { groupName, group } = action.payload;\n state.groups.byId[groupName] = {\n ...state.groups.byId[groupName],\n ...group\n };\n },\n selectGroup: (state, { payload: group }: PayloadAction<string | undefined>) => {\n state.deviceList.deviceIds =\n group && state.groups.byId[group] && state.groups.byId[group].deviceIds && state.groups.byId[group].deviceIds.length > 0\n ? state.groups.byId[group].deviceIds\n : [];\n state.groups.selectedGroup = group;\n },\n removeGroup: (state, action: PayloadAction<string>) => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { [action.payload]: removal, ...remainingById } = state.groups.byId;\n state.groups.byId = remainingById;\n state.groups.selectedGroup = state.groups.selectedGroup === action.payload ? undefined : state.groups.selectedGroup;\n },\n setDeviceListState: (state, action: PayloadAction<Partial<DeviceListState>>) => {\n state.deviceList = {\n ...state.deviceList,\n ...action.payload,\n sort: {\n ...state.deviceList.sort,\n ...action.payload.sort\n }\n };\n },\n setFilterAttributes: (state, action: PayloadAction<FilteringAttributes>) => {\n state.filteringAttributes = action.payload;\n },\n setFilterablesConfig: (state, action: PayloadAction<FilteringAttributesConfig>) => {\n state.filteringAttributesConfig = action.payload;\n },\n receivedDevices: (state, action: PayloadAction<Record<string, Device>>) => {\n state.byId = {\n ...state.byId,\n ...action.payload\n };\n },\n setDeviceFilters: (state, action: PayloadAction<DeviceFilter[]>) => {\n if (deepCompare(action.payload, state.filters)) {\n return;\n }\n state.filters = action.payload.filter(filter => filter.key && filter.operator && filter.scope && typeof filter.value !== 'undefined');\n },\n setDeviceReports: (state, action: PayloadAction<DeviceReport[]>) => {\n state.reports = action.payload;\n },\n setDevicesByStatus: (state, action: PayloadAction<{ deviceIds: string[]; status: DeviceAuthState; total: number }>) => {\n const { status, total, deviceIds } = action.payload;\n if (total) {\n state.byStatus[status].deviceIds = deviceIds;\n state.byStatus[status].counts.total = total;\n }\n },\n setDevicesCountByStatus: (state, action: PayloadAction<{ countsPerTier: DeviceTierLimits; status: DeviceAuthState }>) => {\n const { countsPerTier, status } = action.payload;\n state.byStatus[status].counts = { ...countsPerTier, total: Object.values(countsPerTier).reduce((accu, tieredCount) => (accu += tieredCount), 0) };\n },\n setDeviceLimits: (state, action: PayloadAction<DeviceTierLimits>) => {\n state.limits = action.payload;\n },\n receivedDevice: (state, action: PayloadAction<{ id: string } & Partial<Device>>) => {\n state.byId[action.payload.id] = {\n ...state.byId[action.payload.id],\n ...action.payload\n };\n },\n maybeUpdateDevicesByStatus: (state, action: PayloadAction<{ authId?: string; deviceId: string }>) => {\n const { deviceId, authId } = action.payload;\n const device = state.byId[deviceId];\n const hasMultipleAuthSets = authId && device.auth_sets ? device.auth_sets.filter(authset => authset.id !== authId).length > 0 : false;\n if (!hasMultipleAuthSets && (Object.values(DEVICE_STATES) as string[]).includes(device.status)) {\n const deviceIds = state.byStatus[device.status].deviceIds.filter(id => id !== deviceId);\n const deviceTier = (device.attributes.tier as string) || 'standard';\n state.byStatus[device.status] = {\n deviceIds,\n counts: {\n ...state.byStatus[device.status].counts,\n [deviceTier]: Math.max(0, state.byStatus[device.status].counts[deviceTier] - 1),\n total: Math.max(0, state.byStatus[device.status].counts.total - 1)\n }\n };\n }\n }\n }\n});\n\nexport const actions = devicesSlice.actions;\nexport default devicesSlice.reducer;\n"],"mappings":";;;;AAkCA,MAAa,YAAY;AA8FzB,MAAa,eAAgC;CAC3C,MAAM,EAKL;CACD,UAAU;GACP,cAAc,WAAW;GAAE,WAAW,EAAE;GAAE,QAAQ;IAAE,UAAU;IAAG,OAAO;IAAG,QAAQ;IAAG,OAAO;IAAG;GAAE;GAClG,cAAc,UAAU;GAAE,WAAW,EAAE;GAAE,QAAQ;IAAE,UAAU;IAAG,OAAO;IAAG,QAAQ;IAAG,OAAO;IAAG;GAAE;GACjG,cAAc,UAAU;GAAE,WAAW,EAAE;GAAE,QAAQ;IAAE,UAAU;IAAG,OAAO;IAAG,QAAQ;IAAG,OAAO;IAAG;GAAE;GACjG,cAAc,WAAW;GAAE,WAAW,EAAE;GAAE,QAAQ;IAAE,UAAU;IAAG,OAAO;IAAG,QAAQ;IAAG,OAAO;IAAG;GAAE;EACpG;CACD,YAAY;EACV,WAAW,EAAE;EACb,GAAG;EACH,oBAAoB,EAAE;EACtB,gBAAgB,EAAE;EAClB,WAAW,EAAE;EACb,MAAM,EACJ,WAAW,gBAAgB,MAG5B;EACD,OAAO,cAAc;EACrB,OAAO;EACP,gBAAgB;EAChB,WAAW;EACX,YAAY;EACZ,MAAM;EACP;CACD,SAAS,EAER;CACD,qBAAqB;EAAE,oBAAoB,EAAE;EAAE,qBAAqB,EAAE;EAAE,kBAAkB,EAAE;EAAE,eAAe,EAAE;EAAE;CACjH,0BAA0B;CAC1B,2BAA2B;EACzB,YAAY,EAEX;EACD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M,EAAE,eAAe,WAAW,OAAO;AACzC,SAAM,SAAS,QAAQ,SAAS;IAAE,GAAG;IAAe,OAAO,OAAO,OAAO,cAAc,CAAC,QAAQ,MAAM,gBAAiB,QAAQ,aAAc,EAAE;IAAE;;EAEnJ,kBAAkB,OAAO,WAA4C;AACnE,SAAM,SAAS,OAAO;;EAExB,iBAAiB,OAAO,WAA4D;AAClF,SAAM,KAAK,OAAO,QAAQ,MAAM;IAC9B,GAAG,MAAM,KAAK,OAAO,QAAQ;IAC7B,GAAG,OAAO;IACX;;EAEH,6BAA6B,OAAO,WAAiE;GACnG,MAAM,EAAE,UAAU,WAAW,OAAO;GACpC,MAAM,SAAS,MAAM,KAAK;AAE1B,OAAI,EADwB,UAAU,OAAO,YAAY,OAAO,UAAU,QAAO,YAAW,QAAQ,OAAO,OAAO,CAAC,SAAS,IAAI,UACnG,OAAO,OAAO,cAAc,CAAc,SAAS,OAAO,OAAO,EAAE;IAC9F,MAAM,YAAY,MAAM,SAAS,OAAO,QAAQ,UAAU,QAAO,OAAM,OAAO,SAAS;IACvF,MAAM,aAAc,OAAO,WAAW,QAAmB;AACzD,UAAM,SAAS,OAAO,UAAU;KAC9B;KACA,QAAQ;MACN,GAAG,MAAM,SAAS,OAAO,QAAQ;OAChC,aAAa,KAAK,IAAI,GAAG,MAAM,SAAS,OAAO,QAAQ,OAAO,cAAc,EAAE;MAC/E,OAAO,KAAK,IAAI,GAAG,MAAM,SAAS,OAAO,QAAQ,OAAO,QAAQ,EAAE;MACnE;KACF;;;EAGN;CACF,CAAC;AAEF,MAAa,UAAU,aAAa;AACpC,IAAA,uBAAe,aAAa"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/devicesSlice/index.ts"],"sourcesContent":["// Copyright 2023 Northern.tech AS\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport type {\n Device as BackendDeviceAuth,\n ConnectionState,\n DeviceConfiguration,\n DeviceState,\n DeviceTierLimits,\n MonitorConfiguration,\n Scope,\n SortCriteria,\n Status\n} from '@northern.tech/types/MenderTypes';\n// @ts-nocheck\nimport { deepCompare, duplicateFilter } from '@northern.tech/utils/helpers';\nimport type { PayloadAction } from '@reduxjs/toolkit';\nimport { createSlice } from '@reduxjs/toolkit';\n\nimport type { ALL_DEVICE_STATES, DeviceIssueOptionKey, FilterOperator, SortOptions } from '../constants';\nimport { DEVICE_LIST_DEFAULTS, DEVICE_STATES, SORTING_OPTIONS } from '../constants';\nimport type { DeviceDeployment } from '../deploymentsSlice';\nimport type { DeviceAuthState } from './constants';\n\nexport const sliceName = 'devices';\nexport type DeviceSelectedAttribute = { attribute: string; scope: string };\nexport type DeviceListState = {\n detailsTab: string;\n deviceIds: string[];\n isLoading: boolean;\n open?: boolean;\n page: number;\n perPage: number;\n refreshTrigger: boolean;\n selectedAttributes: DeviceSelectedAttribute[];\n selectedId?: string;\n selectedIssues: DeviceIssueOptionKey[];\n selection: number[];\n setOnly?: boolean;\n sort: SortOptions & Partial<SortCriteria>;\n state?: DeviceAuthState | typeof ALL_DEVICE_STATES;\n total: number;\n};\ntype DeviceReport = {\n items: { count: number; key: string }[];\n otherCount: number;\n total: number;\n};\nexport type DeviceGroup = { deviceIds?: string[]; filters?: DeviceFilter[]; id?: string; total?: number };\nexport type InventoryAttributes = {\n [key: string]: string | string[];\n artifact_name: string;\n device_type: string[];\n};\n\n// based on the api docs the Record values might be even: \"Supported types: number, string, array of numbers, array of strings\" - but I guess \"string\" or \"string | sting[]\" should be good enough\ntype UiDeviceAttributes = {\n attributes: InventoryAttributes;\n identity?: Record<string, string>;\n monitor?: Record<string, string>;\n system: Record<string, string>;\n tags?: Record<string, string>;\n};\n\nexport type Device = BackendDeviceAuth &\n UiDeviceAttributes & {\n check_in_time_exact?: string;\n check_in_time_rounded?: string;\n config?: DeviceConfiguration;\n connect_status?: ConnectionState['status'];\n connect_updated_ts?: string;\n deploymentsCount?: number;\n deviceDeployments?: DeviceDeployment;\n etag?: string;\n gatewayIds?: string[];\n group?: string;\n id: string;\n isNew?: boolean;\n isOffline?: boolean;\n monitors?: MonitorConfiguration[];\n status: Status;\n twinsByIntegration?: Record<string, DeviceState & { twinError?: string }>;\n };\nexport type DeviceFilter = {\n key: string;\n operator: FilterOperator;\n scope: Scope;\n value: string | string[];\n};\ntype FilteringAttributes = {\n identityAttributes: string[];\n inventoryAttributes: string[];\n systemAttributes: string[];\n tagAttributes: string[];\n};\ntype FilteringAttributesConfig = {\n attributes: Record<string, string[]>;\n count: number;\n limit: number;\n};\n\nexport type DeviceGroups = {\n byId: Record<string, DeviceGroup>;\n selectedGroup?: string;\n};\nexport type DeviceSliceType = {\n byId: Record<string, Device>;\n byStatus: Record<DeviceAuthState, { counts: DeviceTierLimits & { total: number }; deviceIds: string[] }>;\n deviceList: DeviceListState;\n filteringAttributes: FilteringAttributes;\n filteringAttributesConfig: FilteringAttributesConfig;\n filteringAttributesLimit: number;\n filters: DeviceFilter[];\n groups: DeviceGroups;\n limits: DeviceTierLimits;\n reports: DeviceReport[];\n total: number;\n};\nexport const initialState: DeviceSliceType = {\n byId: {\n // [deviceId]: {\n // ...,\n // twinsByIntegration: { [external.provider.id]: twinData }\n // }\n },\n byStatus: {\n [DEVICE_STATES.accepted]: { deviceIds: [], counts: { standard: 0, micro: 0, system: 0, total: 0 } },\n [DEVICE_STATES.pending]: { deviceIds: [], counts: { standard: 0, micro: 0, system: 0, total: 0 } },\n [DEVICE_STATES.preauth]: { deviceIds: [], counts: { standard: 0, micro: 0, system: 0, total: 0 } },\n [DEVICE_STATES.rejected]: { deviceIds: [], counts: { standard: 0, micro: 0, system: 0, total: 0 } }\n },\n deviceList: {\n deviceIds: [],\n ...DEVICE_LIST_DEFAULTS,\n selectedAttributes: [],\n selectedIssues: [],\n selection: [],\n sort: {\n direction: SORTING_OPTIONS.desc\n // key: null,\n // scope: null\n },\n state: DEVICE_STATES.accepted,\n total: 0,\n refreshTrigger: false,\n isLoading: false,\n detailsTab: '',\n open: false\n },\n filters: [\n // { key: 'device_type', value: 'raspberry', operator: '$eq', scope: 'inventory' }\n ],\n filteringAttributes: { identityAttributes: [], inventoryAttributes: [], systemAttributes: [], tagAttributes: [] },\n filteringAttributesLimit: 10,\n filteringAttributesConfig: {\n attributes: {\n // inventory: ['some_attribute']\n },\n count: 0,\n limit: 100\n },\n reports: [\n // { items: [{ key: \"someKey\", count: 42 }], otherCount: 123, total: <otherCount + itemsCount> }\n ],\n total: 0,\n limits: {\n standard: 0,\n micro: 0,\n system: 0\n },\n groups: {\n byId: {\n // groupName: { deviceIds: [], total: 0, filters: [] },\n // dynamo: { deviceIds: [], total: 3, filters: [{ a: 1 }] }\n },\n selectedGroup: undefined\n }\n};\n\nexport const devicesSlice = createSlice({\n name: sliceName,\n initialState,\n reducers: {\n receivedGroups: (state, action: PayloadAction<Record<string, DeviceGroup>>) => {\n state.groups.byId = action.payload;\n },\n addToGroup: (state, action: PayloadAction<{ deviceIds: string[]; group: string }>) => {\n const { group, deviceIds } = action.payload;\n const maybeExistingGroup = {\n filters: [],\n deviceIds: [],\n ...state.groups.byId[group]\n };\n state.groups.byId[group] = {\n ...maybeExistingGroup,\n deviceIds: [...maybeExistingGroup.deviceIds, ...deviceIds].filter(duplicateFilter),\n total: (maybeExistingGroup.total || 0) + 1\n };\n },\n removeFromGroup: (state, action: PayloadAction<{ deviceIds: string[]; group: string }>) => {\n const { group, deviceIds: removedIds } = action.payload;\n const { deviceIds = [], total = 0, ...maybeExistingGroup } = state.groups.byId[group] || {};\n const changedGroup = {\n ...maybeExistingGroup,\n deviceIds: deviceIds.filter(id => !removedIds.includes(id)),\n total: Math.max(total - removedIds.length, 0)\n };\n if (changedGroup.total || changedGroup.deviceIds.length) {\n state.groups.byId[group] = changedGroup;\n return;\n } else if (state.groups.selectedGroup === group) {\n state.groups.selectedGroup = undefined;\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { [group]: removal, ...remainingById } = state.groups.byId;\n state.groups.byId = remainingById;\n },\n addGroup: (state, action: PayloadAction<{ group: DeviceGroup; groupName: string }>) => {\n const { groupName, group } = action.payload;\n state.groups.byId[groupName] = {\n ...state.groups.byId[groupName],\n ...group\n };\n },\n selectGroup: (state, { payload: group }: PayloadAction<string | undefined>) => {\n state.deviceList.deviceIds =\n group && state.groups.byId[group] && state.groups.byId[group].deviceIds && state.groups.byId[group].deviceIds.length > 0\n ? state.groups.byId[group].deviceIds\n : [];\n state.groups.selectedGroup = group;\n },\n removeGroup: (state, action: PayloadAction<string>) => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { [action.payload]: removal, ...remainingById } = state.groups.byId;\n state.groups.byId = remainingById;\n state.groups.selectedGroup = state.groups.selectedGroup === action.payload ? undefined : state.groups.selectedGroup;\n },\n setDeviceListState: (state, action: PayloadAction<Partial<DeviceListState>>) => {\n state.deviceList = {\n ...state.deviceList,\n ...action.payload,\n sort: {\n ...state.deviceList.sort,\n ...action.payload.sort\n }\n };\n },\n setFilterAttributes: (state, action: PayloadAction<FilteringAttributes>) => {\n state.filteringAttributes = action.payload;\n },\n setFilterablesConfig: (state, action: PayloadAction<FilteringAttributesConfig>) => {\n state.filteringAttributesConfig = action.payload;\n },\n receivedDevices: (state, action: PayloadAction<Record<string, Device>>) => {\n state.byId = {\n ...state.byId,\n ...action.payload\n };\n },\n setDeviceFilters: (state, action: PayloadAction<DeviceFilter[]>) => {\n if (deepCompare(action.payload, state.filters)) {\n return;\n }\n state.filters = action.payload.filter(filter => filter.key && filter.operator && filter.scope && typeof filter.value !== 'undefined');\n },\n setDeviceReports: (state, action: PayloadAction<DeviceReport[]>) => {\n state.reports = action.payload;\n },\n setDevicesByStatus: (state, action: PayloadAction<{ deviceIds: string[]; status: DeviceAuthState; total: number }>) => {\n const { status, total, deviceIds } = action.payload;\n if (total) {\n state.byStatus[status].deviceIds = deviceIds;\n state.byStatus[status].counts.total = total;\n }\n },\n setDevicesCountByStatus: (state, action: PayloadAction<{ countsPerTier: DeviceTierLimits; status: DeviceAuthState }>) => {\n const { countsPerTier, status } = action.payload;\n state.byStatus[status].counts = { ...countsPerTier, total: Object.values(countsPerTier).reduce((accu, tieredCount) => (accu += tieredCount), 0) };\n },\n setDeviceLimits: (state, action: PayloadAction<DeviceTierLimits>) => {\n state.limits = action.payload;\n },\n receivedDevice: (state, action: PayloadAction<{ id: string } & Partial<Device>>) => {\n state.byId[action.payload.id] = {\n ...state.byId[action.payload.id],\n ...action.payload\n };\n },\n maybeUpdateDevicesByStatus: (state, action: PayloadAction<{ authId?: string; deviceId: string }>) => {\n const { deviceId, authId } = action.payload;\n const device = state.byId[deviceId];\n const hasMultipleAuthSets = authId && device.auth_sets ? device.auth_sets.filter(authset => authset.id !== authId).length > 0 : false;\n if (!hasMultipleAuthSets && (Object.values(DEVICE_STATES) as string[]).includes(device.status)) {\n const deviceIds = state.byStatus[device.status].deviceIds.filter(id => id !== deviceId);\n const deviceTier = (device.attributes.tier as string) || 'standard';\n state.byStatus[device.status] = {\n deviceIds,\n counts: {\n ...state.byStatus[device.status].counts,\n [deviceTier]: Math.max(0, state.byStatus[device.status].counts[deviceTier] - 1),\n total: Math.max(0, state.byStatus[device.status].counts.total - 1)\n }\n };\n }\n }\n }\n});\n\nexport const actions = devicesSlice.actions;\nexport default devicesSlice.reducer;\n"],"mappings":";;;;AAkCA,MAAa,YAAY;AA8FzB,MAAa,eAAgC;CAC3C,MAAM,EAKL;CACD,UAAU;GACP,cAAc,WAAW;GAAE,WAAW,EAAE;GAAE,QAAQ;IAAE,UAAU;IAAG,OAAO;IAAG,QAAQ;IAAG,OAAO;IAAG;GAAE;GAClG,cAAc,UAAU;GAAE,WAAW,EAAE;G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OAAO,cAAc,CAAc,SAAS,OAAO,OAAO,EAAE;IAC9F,MAAM,YAAY,MAAM,SAAS,OAAO,QAAQ,UAAU,QAAO,OAAM,OAAO,SAAS;IACvF,MAAM,aAAc,OAAO,WAAW,QAAmB;IACzD,MAAM,SAAS,OAAO,UAAU;KAC9B;KACA,QAAQ;MACN,GAAG,MAAM,SAAS,OAAO,QAAQ;OAChC,aAAa,KAAK,IAAI,GAAG,MAAM,SAAS,OAAO,QAAQ,OAAO,cAAc,EAAE;MAC/E,OAAO,KAAK,IAAI,GAAG,MAAM,SAAS,OAAO,QAAQ,OAAO,QAAQ,EAAE;MACnE;KACF;;;EAGN;CACF,CAAC;AAEF,MAAa,UAAU,aAAa;AACpC,IAAA,uBAAe,aAAa"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectors.cjs","names":["DEVICE_STATES","UNGROUPED_GROUP","duplicateFilter"],"sources":["../../src/devicesSlice/selectors.ts"],"sourcesContent":["// Copyright 2023 Northern.tech AS\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { duplicateFilter } from '@northern.tech/utils/helpers';\nimport { createSelector } from '@reduxjs/toolkit';\n\nimport type { DeviceFilter, DeviceGroup } from '.';\nimport type { DeviceAuthState } from '../constants';\nimport { DEVICE_STATES, UNGROUPED_GROUP } from '../constants';\nimport type { RootState } from '../store';\n\nexport const getAcceptedDevices = (state: RootState) => state.devices.byStatus.accepted;\nexport const getDevicesByStatus = (state: RootState) => state.devices.byStatus;\nexport const getDevicesById = (state: RootState) => state.devices.byId;\nexport const getDeviceReports = (state: RootState) => state.devices.reports;\nexport const getGroupsById = (state: RootState) => state.devices.groups.byId;\nexport const getSelectedGroup = (state: RootState) => state.devices.groups.selectedGroup;\n\nexport const getDeviceListState = (state: RootState) => state.devices.deviceList;\nexport const getListedDevices = (state: RootState) => state.devices.deviceList.deviceIds;\nexport const getFilteringAttributes = (state: RootState) => state.devices.filteringAttributes;\nexport const getDeviceFilters = (state: RootState) => state.devices.filters || [];\nconst getFilteringAttributesFromConfig = (state: RootState) => state.devices.filteringAttributesConfig.attributes;\nexport const getSortedFilteringAttributes = createSelector([getFilteringAttributes], filteringAttributes => ({\n ...filteringAttributes,\n identityAttributes: [...filteringAttributes.identityAttributes, 'id']\n}));\nexport const getDeviceLimits = (state: RootState) => state.devices.limits;\nconst getFilteringAttributesLimit = (state: RootState) => state.devices.filteringAttributesLimit;\n\nexport const getDeviceIdentityAttributes = createSelector(\n [getFilteringAttributes, getFilteringAttributesLimit],\n ({ identityAttributes }, filteringAttributesLimit) => {\n // limit the selection of the available attribute to AVAILABLE_ATTRIBUTE_LIMIT\n const attributes = identityAttributes.slice(0, filteringAttributesLimit);\n return attributes.reduce(\n (accu, value) => {\n accu.push({ value, label: value, scope: 'identity' });\n return accu;\n },\n [\n { value: 'name', label: 'Name', scope: 'tags' },\n { value: 'id', label: 'Device ID', scope: 'identity' }\n ]\n );\n }\n);\n\nexport const getDeviceCountsByStatus = createSelector([getDevicesByStatus], byStatus =>\n Object.values(DEVICE_STATES).reduce<Record<DeviceAuthState, number>>(\n (accu, deviceState) => {\n const { counts } = byStatus[deviceState];\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { total, ...tieredCounts } = counts;\n const count = Object.values(tieredCounts).reduce((accu, countPerTier) => accu + countPerTier, 0);\n accu[deviceState] = count;\n accu.total = accu.total + count;\n return accu;\n },\n { total: 0 }\n )\n);\n\nexport const getDeviceById = createSelector([getDevicesById, (_, deviceId) => deviceId], (devicesById, deviceId = '') => devicesById[deviceId] ?? {});\n\nexport const getSelectedGroupInfo = createSelector(\n [getDeviceCountsByStatus, getGroupsById, getSelectedGroup],\n ({ accepted: acceptedDeviceTotal }, groupsById, selectedGroup) => {\n let groupCount = acceptedDeviceTotal;\n let groupFilters: DeviceFilter[] = [];\n if (selectedGroup && groupsById[selectedGroup]) {\n groupCount = groupsById[selectedGroup].total || 0;\n groupFilters = groupsById[selectedGroup].filters || [];\n }\n return { groupCount, selectedGroup, groupFilters };\n }\n);\n\nexport const getCombinedLimit = createSelector(\n [getDeviceLimits],\n deviceLimits => Object.values(deviceLimits).reduce((accu, limit) => accu + Math.max(limit ?? 0, 0), 0) // limit might be -1 for unlimited devices\n);\n\nexport const getLimitMaxed = createSelector(\n [getDeviceCountsByStatus, getCombinedLimit],\n ({ accepted: acceptedDevices }, combinedLimit) => !!combinedLimit && combinedLimit <= acceptedDevices\n);\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport const getGroupsByIdWithoutUngrouped = createSelector([getGroupsById], ({ [UNGROUPED_GROUP.id]: ungrouped, ...groups }) => groups);\n\nexport const getGroupData = createSelector([getGroupsByIdWithoutUngrouped], groups => {\n const createdGroup = Object.keys(groups).length ? Object.keys(groups)[0] : undefined;\n const hasDynamicGroups = Object.values(groups).some(group => !!group.id);\n return { createdGroup, hasDynamicGroups, groups };\n});\n\ntype SelectorGroup = DeviceGroup & { groupId: string };\ntype SelectorGroups = { dynamic: SelectorGroup[]; static: SelectorGroup[]; ungrouped: SelectorGroup[] };\n\nexport const getGroups = createSelector([getGroupsById], groupsById => {\n const groupNames = Object.keys(groupsById).sort();\n const groupedGroups = Object.entries(groupsById)\n .sort((a, b) => a[0].localeCompare(b[0]))\n .reduce<SelectorGroups>(\n (accu, [groupname, group]) => {\n const name = groupname === UNGROUPED_GROUP.id ? UNGROUPED_GROUP.name : groupname;\n const groupItem = { ...group, groupId: name, name: groupname };\n if ((group.filters ?? []).length > 0) {\n if (groupname !== UNGROUPED_GROUP.id) {\n accu.dynamic.push(groupItem);\n } else {\n accu.ungrouped.push(groupItem);\n }\n } else {\n accu.static.push(groupItem);\n }\n return accu;\n },\n { dynamic: [], static: [], ungrouped: [] }\n );\n return { groupNames, ...groupedGroups };\n});\nexport const getAttributesList = createSelector(\n [getFilteringAttributes, getFilteringAttributesFromConfig],\n ({ identityAttributes = [], inventoryAttributes = [] }, { identity = [], inventory = [] }) =>\n [...identityAttributes, ...inventoryAttributes, ...identity, ...inventory].filter(duplicateFilter)\n);\nconst getEnabledTierLimits = createSelector([getDeviceLimits], limits => Object.entries(limits).filter(([, limit]) => limit !== 0));\n\nexport const getEnabledTiers = createSelector([getEnabledTierLimits], enabledTierLimits => enabledTierLimits.map(([type]) => type));\n\nexport const getDeviceLimitStats = createSelector([getEnabledTierLimits, getAcceptedDevices], (enabledTierLimits, accepted) => {\n const { counts } = accepted;\n return enabledTierLimits.map(([type, limit]) => ({\n type,\n limit,\n total: counts[type] || 0\n }));\n});\n\nexport const getDeviceTypes = createSelector([getAcceptedDevices, getDevicesById], ({ deviceIds = [] }, devicesById) =>\n Object.keys(\n deviceIds.slice(0, 200).reduce((accu, item) => {\n const { device_type: deviceTypes = [] } = devicesById[item] ? devicesById[item].attributes : {};\n accu = deviceTypes.reduce((deviceTypeAccu, deviceType) => {\n if (deviceType.length > 1) {\n deviceTypeAccu[deviceType] = deviceTypeAccu[deviceType] ? deviceTypeAccu[deviceType] + 1 : 1;\n }\n return deviceTypeAccu;\n }, accu);\n return accu;\n }, {})\n )\n);\n"],"mappings":";;;;;;;AAqBA,MAAa,sBAAsB,UAAqB,MAAM,QAAQ,SAAS;AAC/E,MAAa,sBAAsB,UAAqB,MAAM,QAAQ;AACtE,MAAa,kBAAkB,UAAqB,MAAM,QAAQ;AAClE,MAAa,oBAAoB,UAAqB,MAAM,QAAQ;AACpE,MAAa,iBAAiB,UAAqB,MAAM,QAAQ,OAAO;AACxE,MAAa,oBAAoB,UAAqB,MAAM,QAAQ,OAAO;AAE3E,MAAa,sBAAsB,UAAqB,MAAM,QAAQ;AACtE,MAAa,oBAAoB,UAAqB,M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CAC7C,MAAM,EAAE,aAAa,cAAc,EAAE,KAAK,YAAY,QAAQ,YAAY,MAAM,aAAa,EAAE;AAC/F,QAAO,YAAY,QAAQ,gBAAgB,eAAe;AACxD,MAAI,WAAW,SAAS,EACtB,gBAAe,cAAc,eAAe,cAAc,eAAe,cAAc,IAAI;AAE7F,SAAO;IACN,KAAK;AACR,QAAO;GACN,EAAE,CAAC,CACP,CACF"}
|
|
1
|
+
{"version":3,"file":"selectors.cjs","names":["DEVICE_STATES","UNGROUPED_GROUP","duplicateFilter"],"sources":["../../src/devicesSlice/selectors.ts"],"sourcesContent":["// Copyright 2023 Northern.tech AS\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { duplicateFilter } from '@northern.tech/utils/helpers';\nimport { createSelector } from '@reduxjs/toolkit';\n\nimport type { DeviceFilter, DeviceGroup } from '.';\nimport type { DeviceAuthState } from '../constants';\nimport { DEVICE_STATES, UNGROUPED_GROUP } from '../constants';\nimport type { RootState } from '../store';\n\nexport const getAcceptedDevices = (state: RootState) => state.devices.byStatus.accepted;\nexport const getDevicesByStatus = (state: RootState) => state.devices.byStatus;\nexport const getDevicesById = (state: RootState) => state.devices.byId;\nexport const getDeviceReports = (state: RootState) => state.devices.reports;\nexport const getGroupsById = (state: RootState) => state.devices.groups.byId;\nexport const getSelectedGroup = (state: RootState) => state.devices.groups.selectedGroup;\n\nexport const getDeviceListState = (state: RootState) => state.devices.deviceList;\nexport const getListedDevices = (state: RootState) => state.devices.deviceList.deviceIds;\nexport const getFilteringAttributes = (state: RootState) => state.devices.filteringAttributes;\nexport const getDeviceFilters = (state: RootState) => state.devices.filters || [];\nconst getFilteringAttributesFromConfig = (state: RootState) => state.devices.filteringAttributesConfig.attributes;\nexport const getSortedFilteringAttributes = createSelector([getFilteringAttributes], filteringAttributes => ({\n ...filteringAttributes,\n identityAttributes: [...filteringAttributes.identityAttributes, 'id']\n}));\nexport const getDeviceLimits = (state: RootState) => state.devices.limits;\nconst getFilteringAttributesLimit = (state: RootState) => state.devices.filteringAttributesLimit;\n\nexport const getDeviceIdentityAttributes = createSelector(\n [getFilteringAttributes, getFilteringAttributesLimit],\n ({ identityAttributes }, filteringAttributesLimit) => {\n // limit the selection of the available attribute to AVAILABLE_ATTRIBUTE_LIMIT\n const attributes = identityAttributes.slice(0, filteringAttributesLimit);\n return attributes.reduce(\n (accu, value) => {\n accu.push({ value, label: value, scope: 'identity' });\n return accu;\n },\n [\n { value: 'name', label: 'Name', scope: 'tags' },\n { value: 'id', label: 'Device ID', scope: 'identity' }\n ]\n );\n }\n);\n\nexport const getDeviceCountsByStatus = createSelector([getDevicesByStatus], byStatus =>\n Object.values(DEVICE_STATES).reduce<Record<DeviceAuthState, number>>(\n (accu, deviceState) => {\n const { counts } = byStatus[deviceState];\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { total, ...tieredCounts } = counts;\n const count = Object.values(tieredCounts).reduce((accu, countPerTier) => accu + countPerTier, 0);\n accu[deviceState] = count;\n accu.total = accu.total + count;\n return accu;\n },\n { total: 0 }\n )\n);\n\nexport const getDeviceById = createSelector([getDevicesById, (_, deviceId) => deviceId], (devicesById, deviceId = '') => devicesById[deviceId] ?? {});\n\nexport const getSelectedGroupInfo = createSelector(\n [getDeviceCountsByStatus, getGroupsById, getSelectedGroup],\n ({ accepted: acceptedDeviceTotal }, groupsById, selectedGroup) => {\n let groupCount = acceptedDeviceTotal;\n let groupFilters: DeviceFilter[] = [];\n if (selectedGroup && groupsById[selectedGroup]) {\n groupCount = groupsById[selectedGroup].total || 0;\n groupFilters = groupsById[selectedGroup].filters || [];\n }\n return { groupCount, selectedGroup, groupFilters };\n }\n);\n\nexport const getCombinedLimit = createSelector(\n [getDeviceLimits],\n deviceLimits => Object.values(deviceLimits).reduce((accu, limit) => accu + Math.max(limit ?? 0, 0), 0) // limit might be -1 for unlimited devices\n);\n\nexport const getLimitMaxed = createSelector(\n [getDeviceCountsByStatus, getCombinedLimit],\n ({ accepted: acceptedDevices }, combinedLimit) => !!combinedLimit && combinedLimit <= acceptedDevices\n);\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport const getGroupsByIdWithoutUngrouped = createSelector([getGroupsById], ({ [UNGROUPED_GROUP.id]: ungrouped, ...groups }) => groups);\n\nexport const getGroupData = createSelector([getGroupsByIdWithoutUngrouped], groups => {\n const createdGroup = Object.keys(groups).length ? Object.keys(groups)[0] : undefined;\n const hasDynamicGroups = Object.values(groups).some(group => !!group.id);\n return { createdGroup, hasDynamicGroups, groups };\n});\n\ntype SelectorGroup = DeviceGroup & { groupId: string };\ntype SelectorGroups = { dynamic: SelectorGroup[]; static: SelectorGroup[]; ungrouped: SelectorGroup[] };\n\nexport const getGroups = createSelector([getGroupsById], groupsById => {\n const groupNames = Object.keys(groupsById).sort();\n const groupedGroups = Object.entries(groupsById)\n .sort((a, b) => a[0].localeCompare(b[0]))\n .reduce<SelectorGroups>(\n (accu, [groupname, group]) => {\n const name = groupname === UNGROUPED_GROUP.id ? UNGROUPED_GROUP.name : groupname;\n const groupItem = { ...group, groupId: name, name: groupname };\n if ((group.filters ?? []).length > 0) {\n if (groupname !== UNGROUPED_GROUP.id) {\n accu.dynamic.push(groupItem);\n } else {\n accu.ungrouped.push(groupItem);\n }\n } else {\n accu.static.push(groupItem);\n }\n return accu;\n },\n { dynamic: [], static: [], ungrouped: [] }\n );\n return { groupNames, ...groupedGroups };\n});\nexport const getAttributesList = createSelector(\n [getFilteringAttributes, getFilteringAttributesFromConfig],\n ({ identityAttributes = [], inventoryAttributes = [] }, { identity = [], inventory = [] }) =>\n [...identityAttributes, ...inventoryAttributes, ...identity, ...inventory].filter(duplicateFilter)\n);\nconst getEnabledTierLimits = createSelector([getDeviceLimits], limits => Object.entries(limits).filter(([, limit]) => limit !== 0));\n\nexport const getEnabledTiers = createSelector([getEnabledTierLimits], enabledTierLimits => enabledTierLimits.map(([type]) => type));\n\nexport const getDeviceLimitStats = createSelector([getEnabledTierLimits, getAcceptedDevices], (enabledTierLimits, accepted) => {\n const { counts } = accepted;\n return enabledTierLimits.map(([type, limit]) => ({\n type,\n limit,\n total: counts[type] || 0\n }));\n});\n\nexport const getDeviceTypes = createSelector([getAcceptedDevices, getDevicesById], ({ deviceIds = [] }, devicesById) =>\n Object.keys(\n deviceIds.slice(0, 200).reduce((accu, item) => {\n const { device_type: deviceTypes = [] } = devicesById[item] ? devicesById[item].attributes : {};\n accu = deviceTypes.reduce((deviceTypeAccu, deviceType) => {\n if (deviceType.length > 1) {\n deviceTypeAccu[deviceType] = deviceTypeAccu[deviceType] ? deviceTypeAccu[deviceType] + 1 : 1;\n }\n return deviceTypeAccu;\n }, accu);\n return accu;\n }, {})\n )\n);\n"],"mappings":";;;;;;;AAqBA,MAAa,sBAAsB,UAAqB,MAAM,QAAQ,SAAS;AAC/E,MAAa,sBAAsB,UAAqB,MAAM,QAAQ;AACtE,MAAa,kBAAkB,UAAqB,MAAM,QAAQ;AAClE,MAAa,oBAAoB,UAAqB,MAAM,QAAQ;AACpE,MAAa,iBAAiB,UAAqB,MAAM,QAAQ,OAAO;AACxE,MAAa,oBAAoB,UAAqB,MAAM,QAAQ,OAAO;AAE3E,MAAa,sBAAsB,UAAqB,MAAM,QAAQ;AACtE,MAAa,oBAAoB,UAAqB,MAAM,QAAQ,WAAW;AAC/E,MAAa,0BAA0B,UAAqB,MAAM,QAAQ;AAC1E,MAAa,oBAAoB,UAAqB,MAAM,QAAQ,WAAW,EAAE;AACjF,MAAM,oCAAoC,UAAqB,MAAM,QAAQ,0BAA0B;AACvG,MAAa,gCAAA,GAAA,iBAAA,gBAA8C,CAAC,uBAAuB,GAAE,yBAAwB;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E,CAAC,CACP,CACF"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { o as UserSliceType } from "../index-
|
|
2
|
-
import {
|
|
1
|
+
import { o as UserSliceType } from "../index-BFlHWzjv.cjs";
|
|
2
|
+
import { i as ReleaseSliceType } from "../index-C-q632wO.cjs";
|
|
3
3
|
import { n as OnboardingSliceType } from "../index-UPc3wvVd.cjs";
|
|
4
4
|
import { o as DeploymentsSliceType } from "../index-BP0uAq36.cjs";
|
|
5
|
-
import { a as DeviceListState, n as DeviceFilter, r as DeviceGroup, s as DeviceSliceType, t as Device } from "../index-
|
|
6
|
-
import { t as AppSliceType } from "../index-
|
|
7
|
-
import { t as MonitorSliceType } from "../index-
|
|
8
|
-
import { t as OrganizationSliceType } from "../index-
|
|
9
|
-
import { r as RootState } from "../store-
|
|
5
|
+
import { a as DeviceListState, n as DeviceFilter, r as DeviceGroup, s as DeviceSliceType, t as Device } from "../index-B64X5ozM.cjs";
|
|
6
|
+
import { t as AppSliceType } from "../index-DwACbyUg.cjs";
|
|
7
|
+
import { t as MonitorSliceType } from "../index-CT5hgXm9.cjs";
|
|
8
|
+
import { t as OrganizationSliceType } from "../index-BbaS7MzW.cjs";
|
|
9
|
+
import { r as RootState } from "../store-b5cF2WB5.cjs";
|
|
10
10
|
import * as _$_northern_tech_types_types_gen0 from "@northern.tech/types/types.gen";
|
|
11
11
|
import * as _$reselect from "reselect";
|
|
12
12
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { o as UserSliceType } from "../index-
|
|
2
|
-
import {
|
|
1
|
+
import { o as UserSliceType } from "../index-ez3oxfRo.js";
|
|
2
|
+
import { i as ReleaseSliceType } from "../index-CyokFK2e.js";
|
|
3
3
|
import { n as OnboardingSliceType } from "../index-CJkrL0oA.js";
|
|
4
4
|
import { o as DeploymentsSliceType } from "../index-CkwVnIqd.js";
|
|
5
|
-
import { a as DeviceListState, n as DeviceFilter, r as DeviceGroup, s as DeviceSliceType, t as Device } from "../index-
|
|
6
|
-
import { t as AppSliceType } from "../index-
|
|
7
|
-
import { t as MonitorSliceType } from "../index-
|
|
8
|
-
import { t as OrganizationSliceType } from "../index-
|
|
9
|
-
import { r as RootState } from "../store-
|
|
5
|
+
import { a as DeviceListState, n as DeviceFilter, r as DeviceGroup, s as DeviceSliceType, t as Device } from "../index-BI9O8JWe.js";
|
|
6
|
+
import { t as AppSliceType } from "../index-Bp1WpATs.js";
|
|
7
|
+
import { t as MonitorSliceType } from "../index-DUvrw_Ed.js";
|
|
8
|
+
import { t as OrganizationSliceType } from "../index-C6wNUfiV.js";
|
|
9
|
+
import { r as RootState } from "../store-D-xvZXiY.js";
|
|
10
10
|
import * as _$_northern_tech_types_types_gen0 from "@northern.tech/types/types.gen";
|
|
11
11
|
import * as _$reselect from "reselect";
|
|
12
12
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectors.js","names":[],"sources":["../../src/devicesSlice/selectors.ts"],"sourcesContent":["// Copyright 2023 Northern.tech AS\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { duplicateFilter } from '@northern.tech/utils/helpers';\nimport { createSelector } from '@reduxjs/toolkit';\n\nimport type { DeviceFilter, DeviceGroup } from '.';\nimport type { DeviceAuthState } from '../constants';\nimport { DEVICE_STATES, UNGROUPED_GROUP } from '../constants';\nimport type { RootState } from '../store';\n\nexport const getAcceptedDevices = (state: RootState) => state.devices.byStatus.accepted;\nexport const getDevicesByStatus = (state: RootState) => state.devices.byStatus;\nexport const getDevicesById = (state: RootState) => state.devices.byId;\nexport const getDeviceReports = (state: RootState) => state.devices.reports;\nexport const getGroupsById = (state: RootState) => state.devices.groups.byId;\nexport const getSelectedGroup = (state: RootState) => state.devices.groups.selectedGroup;\n\nexport const getDeviceListState = (state: RootState) => state.devices.deviceList;\nexport const getListedDevices = (state: RootState) => state.devices.deviceList.deviceIds;\nexport const getFilteringAttributes = (state: RootState) => state.devices.filteringAttributes;\nexport const getDeviceFilters = (state: RootState) => state.devices.filters || [];\nconst getFilteringAttributesFromConfig = (state: RootState) => state.devices.filteringAttributesConfig.attributes;\nexport const getSortedFilteringAttributes = createSelector([getFilteringAttributes], filteringAttributes => ({\n ...filteringAttributes,\n identityAttributes: [...filteringAttributes.identityAttributes, 'id']\n}));\nexport const getDeviceLimits = (state: RootState) => state.devices.limits;\nconst getFilteringAttributesLimit = (state: RootState) => state.devices.filteringAttributesLimit;\n\nexport const getDeviceIdentityAttributes = createSelector(\n [getFilteringAttributes, getFilteringAttributesLimit],\n ({ identityAttributes }, filteringAttributesLimit) => {\n // limit the selection of the available attribute to AVAILABLE_ATTRIBUTE_LIMIT\n const attributes = identityAttributes.slice(0, filteringAttributesLimit);\n return attributes.reduce(\n (accu, value) => {\n accu.push({ value, label: value, scope: 'identity' });\n return accu;\n },\n [\n { value: 'name', label: 'Name', scope: 'tags' },\n { value: 'id', label: 'Device ID', scope: 'identity' }\n ]\n );\n }\n);\n\nexport const getDeviceCountsByStatus = createSelector([getDevicesByStatus], byStatus =>\n Object.values(DEVICE_STATES).reduce<Record<DeviceAuthState, number>>(\n (accu, deviceState) => {\n const { counts } = byStatus[deviceState];\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { total, ...tieredCounts } = counts;\n const count = Object.values(tieredCounts).reduce((accu, countPerTier) => accu + countPerTier, 0);\n accu[deviceState] = count;\n accu.total = accu.total + count;\n return accu;\n },\n { total: 0 }\n )\n);\n\nexport const getDeviceById = createSelector([getDevicesById, (_, deviceId) => deviceId], (devicesById, deviceId = '') => devicesById[deviceId] ?? {});\n\nexport const getSelectedGroupInfo = createSelector(\n [getDeviceCountsByStatus, getGroupsById, getSelectedGroup],\n ({ accepted: acceptedDeviceTotal }, groupsById, selectedGroup) => {\n let groupCount = acceptedDeviceTotal;\n let groupFilters: DeviceFilter[] = [];\n if (selectedGroup && groupsById[selectedGroup]) {\n groupCount = groupsById[selectedGroup].total || 0;\n groupFilters = groupsById[selectedGroup].filters || [];\n }\n return { groupCount, selectedGroup, groupFilters };\n }\n);\n\nexport const getCombinedLimit = createSelector(\n [getDeviceLimits],\n deviceLimits => Object.values(deviceLimits).reduce((accu, limit) => accu + Math.max(limit ?? 0, 0), 0) // limit might be -1 for unlimited devices\n);\n\nexport const getLimitMaxed = createSelector(\n [getDeviceCountsByStatus, getCombinedLimit],\n ({ accepted: acceptedDevices }, combinedLimit) => !!combinedLimit && combinedLimit <= acceptedDevices\n);\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport const getGroupsByIdWithoutUngrouped = createSelector([getGroupsById], ({ [UNGROUPED_GROUP.id]: ungrouped, ...groups }) => groups);\n\nexport const getGroupData = createSelector([getGroupsByIdWithoutUngrouped], groups => {\n const createdGroup = Object.keys(groups).length ? Object.keys(groups)[0] : undefined;\n const hasDynamicGroups = Object.values(groups).some(group => !!group.id);\n return { createdGroup, hasDynamicGroups, groups };\n});\n\ntype SelectorGroup = DeviceGroup & { groupId: string };\ntype SelectorGroups = { dynamic: SelectorGroup[]; static: SelectorGroup[]; ungrouped: SelectorGroup[] };\n\nexport const getGroups = createSelector([getGroupsById], groupsById => {\n const groupNames = Object.keys(groupsById).sort();\n const groupedGroups = Object.entries(groupsById)\n .sort((a, b) => a[0].localeCompare(b[0]))\n .reduce<SelectorGroups>(\n (accu, [groupname, group]) => {\n const name = groupname === UNGROUPED_GROUP.id ? UNGROUPED_GROUP.name : groupname;\n const groupItem = { ...group, groupId: name, name: groupname };\n if ((group.filters ?? []).length > 0) {\n if (groupname !== UNGROUPED_GROUP.id) {\n accu.dynamic.push(groupItem);\n } else {\n accu.ungrouped.push(groupItem);\n }\n } else {\n accu.static.push(groupItem);\n }\n return accu;\n },\n { dynamic: [], static: [], ungrouped: [] }\n );\n return { groupNames, ...groupedGroups };\n});\nexport const getAttributesList = createSelector(\n [getFilteringAttributes, getFilteringAttributesFromConfig],\n ({ identityAttributes = [], inventoryAttributes = [] }, { identity = [], inventory = [] }) =>\n [...identityAttributes, ...inventoryAttributes, ...identity, ...inventory].filter(duplicateFilter)\n);\nconst getEnabledTierLimits = createSelector([getDeviceLimits], limits => Object.entries(limits).filter(([, limit]) => limit !== 0));\n\nexport const getEnabledTiers = createSelector([getEnabledTierLimits], enabledTierLimits => enabledTierLimits.map(([type]) => type));\n\nexport const getDeviceLimitStats = createSelector([getEnabledTierLimits, getAcceptedDevices], (enabledTierLimits, accepted) => {\n const { counts } = accepted;\n return enabledTierLimits.map(([type, limit]) => ({\n type,\n limit,\n total: counts[type] || 0\n }));\n});\n\nexport const getDeviceTypes = createSelector([getAcceptedDevices, getDevicesById], ({ deviceIds = [] }, devicesById) =>\n Object.keys(\n deviceIds.slice(0, 200).reduce((accu, item) => {\n const { device_type: deviceTypes = [] } = devicesById[item] ? devicesById[item].attributes : {};\n accu = deviceTypes.reduce((deviceTypeAccu, deviceType) => {\n if (deviceType.length > 1) {\n deviceTypeAccu[deviceType] = deviceTypeAccu[deviceType] ? deviceTypeAccu[deviceType] + 1 : 1;\n }\n return deviceTypeAccu;\n }, accu);\n return accu;\n }, {})\n )\n);\n"],"mappings":";;;;AAqBA,MAAa,sBAAsB,UAAqB,MAAM,QAAQ,SAAS;AAC/E,MAAa,sBAAsB,UAAqB,MAAM,QAAQ;AACtE,MAAa,kBAAkB,UAAqB,MAAM,QAAQ;AAClE,MAAa,oBAAoB,UAAqB,MAAM,QAAQ;AACpE,MAAa,iBAAiB,UAAqB,MAAM,QAAQ,OAAO;AACxE,MAAa,oBAAoB,UAAqB,MAAM,QAAQ,OAAO;AAE3E,MAAa,sBAAsB,UAAqB,MAAM,QAAQ;AACtE,MAAa,oBAAoB,UAAqB,MAAM,QAA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{"version":3,"file":"selectors.js","names":[],"sources":["../../src/devicesSlice/selectors.ts"],"sourcesContent":["// Copyright 2023 Northern.tech AS\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { duplicateFilter } from '@northern.tech/utils/helpers';\nimport { createSelector } from '@reduxjs/toolkit';\n\nimport type { DeviceFilter, DeviceGroup } from '.';\nimport type { DeviceAuthState } from '../constants';\nimport { DEVICE_STATES, UNGROUPED_GROUP } from '../constants';\nimport type { RootState } from '../store';\n\nexport const getAcceptedDevices = (state: RootState) => state.devices.byStatus.accepted;\nexport const getDevicesByStatus = (state: RootState) => state.devices.byStatus;\nexport const getDevicesById = (state: RootState) => state.devices.byId;\nexport const getDeviceReports = (state: RootState) => state.devices.reports;\nexport const getGroupsById = (state: RootState) => state.devices.groups.byId;\nexport const getSelectedGroup = (state: RootState) => state.devices.groups.selectedGroup;\n\nexport const getDeviceListState = (state: RootState) => state.devices.deviceList;\nexport const getListedDevices = (state: RootState) => state.devices.deviceList.deviceIds;\nexport const getFilteringAttributes = (state: RootState) => state.devices.filteringAttributes;\nexport const getDeviceFilters = (state: RootState) => state.devices.filters || [];\nconst getFilteringAttributesFromConfig = (state: RootState) => state.devices.filteringAttributesConfig.attributes;\nexport const getSortedFilteringAttributes = createSelector([getFilteringAttributes], filteringAttributes => ({\n ...filteringAttributes,\n identityAttributes: [...filteringAttributes.identityAttributes, 'id']\n}));\nexport const getDeviceLimits = (state: RootState) => state.devices.limits;\nconst getFilteringAttributesLimit = (state: RootState) => state.devices.filteringAttributesLimit;\n\nexport const getDeviceIdentityAttributes = createSelector(\n [getFilteringAttributes, getFilteringAttributesLimit],\n ({ identityAttributes }, filteringAttributesLimit) => {\n // limit the selection of the available attribute to AVAILABLE_ATTRIBUTE_LIMIT\n const attributes = identityAttributes.slice(0, filteringAttributesLimit);\n return attributes.reduce(\n (accu, value) => {\n accu.push({ value, label: value, scope: 'identity' });\n return accu;\n },\n [\n { value: 'name', label: 'Name', scope: 'tags' },\n { value: 'id', label: 'Device ID', scope: 'identity' }\n ]\n );\n }\n);\n\nexport const getDeviceCountsByStatus = createSelector([getDevicesByStatus], byStatus =>\n Object.values(DEVICE_STATES).reduce<Record<DeviceAuthState, number>>(\n (accu, deviceState) => {\n const { counts } = byStatus[deviceState];\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { total, ...tieredCounts } = counts;\n const count = Object.values(tieredCounts).reduce((accu, countPerTier) => accu + countPerTier, 0);\n accu[deviceState] = count;\n accu.total = accu.total + count;\n return accu;\n },\n { total: 0 }\n )\n);\n\nexport const getDeviceById = createSelector([getDevicesById, (_, deviceId) => deviceId], (devicesById, deviceId = '') => devicesById[deviceId] ?? {});\n\nexport const getSelectedGroupInfo = createSelector(\n [getDeviceCountsByStatus, getGroupsById, getSelectedGroup],\n ({ accepted: acceptedDeviceTotal }, groupsById, selectedGroup) => {\n let groupCount = acceptedDeviceTotal;\n let groupFilters: DeviceFilter[] = [];\n if (selectedGroup && groupsById[selectedGroup]) {\n groupCount = groupsById[selectedGroup].total || 0;\n groupFilters = groupsById[selectedGroup].filters || [];\n }\n return { groupCount, selectedGroup, groupFilters };\n }\n);\n\nexport const getCombinedLimit = createSelector(\n [getDeviceLimits],\n deviceLimits => Object.values(deviceLimits).reduce((accu, limit) => accu + Math.max(limit ?? 0, 0), 0) // limit might be -1 for unlimited devices\n);\n\nexport const getLimitMaxed = createSelector(\n [getDeviceCountsByStatus, getCombinedLimit],\n ({ accepted: acceptedDevices }, combinedLimit) => !!combinedLimit && combinedLimit <= acceptedDevices\n);\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport const getGroupsByIdWithoutUngrouped = createSelector([getGroupsById], ({ [UNGROUPED_GROUP.id]: ungrouped, ...groups }) => groups);\n\nexport const getGroupData = createSelector([getGroupsByIdWithoutUngrouped], groups => {\n const createdGroup = Object.keys(groups).length ? Object.keys(groups)[0] : undefined;\n const hasDynamicGroups = Object.values(groups).some(group => !!group.id);\n return { createdGroup, hasDynamicGroups, groups };\n});\n\ntype SelectorGroup = DeviceGroup & { groupId: string };\ntype SelectorGroups = { dynamic: SelectorGroup[]; static: SelectorGroup[]; ungrouped: SelectorGroup[] };\n\nexport const getGroups = createSelector([getGroupsById], groupsById => {\n const groupNames = Object.keys(groupsById).sort();\n const groupedGroups = Object.entries(groupsById)\n .sort((a, b) => a[0].localeCompare(b[0]))\n .reduce<SelectorGroups>(\n (accu, [groupname, group]) => {\n const name = groupname === UNGROUPED_GROUP.id ? UNGROUPED_GROUP.name : groupname;\n const groupItem = { ...group, groupId: name, name: groupname };\n if ((group.filters ?? []).length > 0) {\n if (groupname !== UNGROUPED_GROUP.id) {\n accu.dynamic.push(groupItem);\n } else {\n accu.ungrouped.push(groupItem);\n }\n } else {\n accu.static.push(groupItem);\n }\n return accu;\n },\n { dynamic: [], static: [], ungrouped: [] }\n );\n return { groupNames, ...groupedGroups };\n});\nexport const getAttributesList = createSelector(\n [getFilteringAttributes, getFilteringAttributesFromConfig],\n ({ identityAttributes = [], inventoryAttributes = [] }, { identity = [], inventory = [] }) =>\n [...identityAttributes, ...inventoryAttributes, ...identity, ...inventory].filter(duplicateFilter)\n);\nconst getEnabledTierLimits = createSelector([getDeviceLimits], limits => Object.entries(limits).filter(([, limit]) => limit !== 0));\n\nexport const getEnabledTiers = createSelector([getEnabledTierLimits], enabledTierLimits => enabledTierLimits.map(([type]) => type));\n\nexport const getDeviceLimitStats = createSelector([getEnabledTierLimits, getAcceptedDevices], (enabledTierLimits, accepted) => {\n const { counts } = accepted;\n return enabledTierLimits.map(([type, limit]) => ({\n type,\n limit,\n total: counts[type] || 0\n }));\n});\n\nexport const getDeviceTypes = createSelector([getAcceptedDevices, getDevicesById], ({ deviceIds = [] }, devicesById) =>\n Object.keys(\n deviceIds.slice(0, 200).reduce((accu, item) => {\n const { device_type: deviceTypes = [] } = devicesById[item] ? devicesById[item].attributes : {};\n accu = deviceTypes.reduce((deviceTypeAccu, deviceType) => {\n if (deviceType.length > 1) {\n deviceTypeAccu[deviceType] = deviceTypeAccu[deviceType] ? deviceTypeAccu[deviceType] + 1 : 1;\n }\n return deviceTypeAccu;\n }, accu);\n return accu;\n }, {})\n )\n);\n"],"mappings":";;;;AAqBA,MAAa,sBAAsB,UAAqB,MAAM,QAAQ,SAAS;AAC/E,MAAa,sBAAsB,UAAqB,MAAM,QAAQ;AACtE,MAAa,kBAAkB,UAAqB,MAAM,QAAQ;AAClE,MAAa,oBAAoB,UAAqB,MAAM,QAAQ;AACpE,MAAa,iBAAiB,UAAqB,MAAM,QAAQ,OAAO;AACxE,MAAa,oBAAoB,UAAqB,MAAM,QAAQ,OAAO;AAE3E,MAAa,sBAAsB,UAAqB,MAAM,QAAQ;AACtE,MAAa,oBAAoB,UAAqB,MAAM,QAAQ,WAAW;AAC/E,MAAa,0BAA0B,UAAqB,MAAM,QAAQ;AAC1E,MAAa,oBAAoB,UAAqB,MAAM,QAAQ,WAAW,EAAE;AACjF,MAAM,oCAAoC,UAAqB,MAAM,QAAQ,0BAA0B;AACvG,MAAa,+BAA+B,eAAe,CAAC,uBAAuB,GAAE,yBAAwB;CAC3G,GAAG;CACH,oBAAoB,CAAC,GAAG,oBAAoB,oBAAoB,KAAK;CACtE,EAAE;AACH,MAAa,mBAAmB,UAAqB,MAAM,QAAQ;AACnE,MAAM,+BAA+B,UAAqB,MAAM,QAAQ;AAExE,MAAa,8BAA8B,eACzC,CAAC,wBAAwB,4BAA4B,GACpD,EAAE,sBAAsB,6BAA6B;CAGpD,OADmB,mBAAmB,MAAM,GAAG,yBAC9B,CAAC,QACf,MAAM,UAAU;EACf,KAAK,KAAK;GAAE;GAAO,OA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kBAAkB,eAAe,CAAC,qBAAqB,GAAE,sBAAqB,kBAAkB,KAAK,CAAC,UAAU,KAAK,CAAC;AAEnI,MAAa,sBAAsB,eAAe,CAAC,sBAAsB,mBAAmB,GAAG,mBAAmB,aAAa;CAC7H,MAAM,EAAE,WAAW;CACnB,OAAO,kBAAkB,KAAK,CAAC,MAAM,YAAY;EAC/C;EACA;EACA,OAAO,OAAO,SAAS;EACxB,EAAE;EACH;AAEF,MAAa,iBAAiB,eAAe,CAAC,oBAAoB,eAAe,GAAG,EAAE,YAAY,EAAE,IAAI,gBACtG,OAAO,KACL,UAAU,MAAM,GAAG,IAAI,CAAC,QAAQ,MAAM,SAAS;CAC7C,MAAM,EAAE,aAAa,cAAc,EAAE,KAAK,YAAY,QAAQ,YAAY,MAAM,aAAa,EAAE;CAC/F,OAAO,YAAY,QAAQ,gBAAgB,eAAe;EACxD,IAAI,WAAW,SAAS,GACtB,eAAe,cAAc,eAAe,cAAc,eAAe,cAAc,IAAI;EAE7F,OAAO;IACN,KAAK;CACR,OAAO;GACN,EAAE,CAAC,CACP,CACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { m as DeviceIssueOptionKey,
|
|
2
|
-
import { a as DeviceListState, n as DeviceFilter, o as DeviceSelectedAttribute, r as DeviceGroup, t as Device$1 } from "../index-
|
|
3
|
-
import { a as SearchState, s as SnackbarContent } from "../index-
|
|
4
|
-
import { r as RootState, t as AppDispatch } from "../store-
|
|
1
|
+
import { m as DeviceIssueOptionKey, mt as DeviceAuthState } from "../constants-BrGIx40B.cjs";
|
|
2
|
+
import { a as DeviceListState, n as DeviceFilter, o as DeviceSelectedAttribute, r as DeviceGroup, t as Device$1 } from "../index-B64X5ozM.cjs";
|
|
3
|
+
import { a as SearchState, s as SnackbarContent } from "../index-DwACbyUg.cjs";
|
|
4
|
+
import { r as RootState, t as AppDispatch } from "../store-b5cF2WB5.cjs";
|
|
5
5
|
import * as _$_reduxjs_toolkit0 from "@reduxjs/toolkit";
|
|
6
6
|
import { ConnectionState, Device, DeviceConfiguration, DeviceInventory, DeviceTierLimits, DeviceWithImage, Filter, Integration, ManagementApiConfiguration, NewConfigurationDeployment, PreAuthSet, SortCriteria, Status } from "@northern.tech/types/MenderTypes";
|
|
7
7
|
import * as _$axios from "axios";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { m as DeviceIssueOptionKey,
|
|
2
|
-
import { a as DeviceListState, n as DeviceFilter, o as DeviceSelectedAttribute, r as DeviceGroup, t as Device$1 } from "../index-
|
|
3
|
-
import { a as SearchState, s as SnackbarContent } from "../index-
|
|
4
|
-
import { r as RootState, t as AppDispatch } from "../store-
|
|
1
|
+
import { m as DeviceIssueOptionKey, mt as DeviceAuthState } from "../constants-CjO3_FOH.js";
|
|
2
|
+
import { a as DeviceListState, n as DeviceFilter, o as DeviceSelectedAttribute, r as DeviceGroup, t as Device$1 } from "../index-BI9O8JWe.js";
|
|
3
|
+
import { a as SearchState, s as SnackbarContent } from "../index-Bp1WpATs.js";
|
|
4
|
+
import { r as RootState, t as AppDispatch } from "../store-D-xvZXiY.js";
|
|
5
5
|
import * as _$_reduxjs_toolkit0 from "@reduxjs/toolkit";
|
|
6
6
|
import * as _$axios from "axios";
|
|
7
7
|
import { ConnectionState, Device, DeviceConfiguration, DeviceInventory, DeviceTierLimits, DeviceWithImage, Filter, Integration, ManagementApiConfiguration, NewConfigurationDeployment, PreAuthSet, SortCriteria, Status } from "@northern.tech/types/MenderTypes";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { T as SortOptions,
|
|
1
|
+
import { T as SortOptions, m as DeviceIssueOptionKey, mt as DeviceAuthState, n as ALL_DEVICE_STATES, xt as FilterOperator } from "./constants-BrGIx40B.cjs";
|
|
2
2
|
import { s as DeviceDeployment } from "./index-BP0uAq36.cjs";
|
|
3
3
|
import * as _$_reduxjs_toolkit0 from "@reduxjs/toolkit";
|
|
4
4
|
import { PayloadAction } from "@reduxjs/toolkit";
|
|
@@ -202,4 +202,4 @@ declare const actions: _$_reduxjs_toolkit0.CaseReducerActions<{
|
|
|
202
202
|
declare const _default: _$redux.Reducer<DeviceSliceType>;
|
|
203
203
|
//#endregion
|
|
204
204
|
export { DeviceListState as a, InventoryAttributes as c, devicesSlice as d, initialState as f, DeviceGroups as i, _default as l, DeviceFilter as n, DeviceSelectedAttribute as o, sliceName as p, DeviceGroup as r, DeviceSliceType as s, Device$1 as t, actions as u };
|
|
205
|
-
//# sourceMappingURL=index-
|
|
205
|
+
//# sourceMappingURL=index-B64X5ozM.d.cts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as Role,
|
|
1
|
+
import { S as Role, v as PermissionSet, xt as FilterOperator } from "./constants-BrGIx40B.cjs";
|
|
2
2
|
import { i as ReadState } from "./constants-G3wymKIl.cjs";
|
|
3
3
|
import * as _$_reduxjs_toolkit0 from "@reduxjs/toolkit";
|
|
4
4
|
import { PayloadAction } from "@reduxjs/toolkit";
|
|
@@ -149,4 +149,4 @@ declare const actions: _$_reduxjs_toolkit0.CaseReducerActions<{
|
|
|
149
149
|
declare const _default: _$redux.Reducer<UserSliceType>;
|
|
150
150
|
//#endregion
|
|
151
151
|
export { UserSettings as a, actions as c, usersSlice as d, UserSession as i, initialState as l, GlobalSettings as n, UserSliceType as o, User$1 as r, _default as s, CustomColumn as t, sliceName as u };
|
|
152
|
-
//# sourceMappingURL=index-
|
|
152
|
+
//# sourceMappingURL=index-BFlHWzjv.d.cts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { T as SortOptions,
|
|
1
|
+
import { T as SortOptions, m as DeviceIssueOptionKey, mt as DeviceAuthState, n as ALL_DEVICE_STATES, xt as FilterOperator } from "./constants-CjO3_FOH.js";
|
|
2
2
|
import { s as DeviceDeployment } from "./index-CkwVnIqd.js";
|
|
3
3
|
import * as _$_reduxjs_toolkit0 from "@reduxjs/toolkit";
|
|
4
4
|
import { PayloadAction } from "@reduxjs/toolkit";
|
|
@@ -202,4 +202,4 @@ declare const actions: _$_reduxjs_toolkit0.CaseReducerActions<{
|
|
|
202
202
|
declare const _default: _$redux.Reducer<DeviceSliceType>;
|
|
203
203
|
//#endregion
|
|
204
204
|
export { DeviceListState as a, InventoryAttributes as c, devicesSlice as d, initialState as f, DeviceGroups as i, _default as l, DeviceFilter as n, DeviceSelectedAttribute as o, sliceName as p, DeviceGroup as r, DeviceSliceType as s, Device$1 as t, actions as u };
|
|
205
|
-
//# sourceMappingURL=index-
|
|
205
|
+
//# sourceMappingURL=index-BI9O8JWe.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as TenantList, f as Webhook, i as Organization, l as SSOConfig, n as AuditLogSelectionState, o as ProductConfig, r as Card, t as AuditLog$1 } from "./types-
|
|
1
|
+
import { d as TenantList, f as Webhook, i as Organization, l as SSOConfig, n as AuditLogSelectionState, o as ProductConfig, r as Card, t as AuditLog$1 } from "./types-COdPU2QQ.cjs";
|
|
2
2
|
import * as _$_reduxjs_toolkit0 from "@reduxjs/toolkit";
|
|
3
3
|
import { PayloadAction } from "@reduxjs/toolkit";
|
|
4
4
|
import * as _$immer from "immer";
|
|
@@ -68,4 +68,4 @@ declare const actions: _$_reduxjs_toolkit0.CaseReducerActions<{
|
|
|
68
68
|
declare const _default: _$redux.Reducer<OrganizationSliceType>;
|
|
69
69
|
//#endregion
|
|
70
70
|
export { organizationSlice as a, initialState as i, _default as n, sliceName as o, actions as r, OrganizationSliceType as t };
|
|
71
|
-
//# sourceMappingURL=index-
|
|
71
|
+
//# sourceMappingURL=index-BbaS7MzW.d.cts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { T as SortOptions } from "./constants-
|
|
1
|
+
import { T as SortOptions } from "./constants-CjO3_FOH.js";
|
|
2
2
|
import * as _$_reduxjs_toolkit0 from "@reduxjs/toolkit";
|
|
3
3
|
import { PayloadAction } from "@reduxjs/toolkit";
|
|
4
4
|
import * as _$immer from "immer";
|
|
@@ -151,4 +151,4 @@ declare const actions: _$_reduxjs_toolkit0.CaseReducerActions<{
|
|
|
151
151
|
declare const _default: _$redux.Reducer<AppSliceType>;
|
|
152
152
|
//#endregion
|
|
153
153
|
export { SearchState as a, TagData as c, _default as d, actions as f, sliceName as h, SaasVersion as i, Upload as l, initialState as m, ReleaseData as n, SentryConfig as o, appSlice as p, Repository as r, SnackbarContent as s, AppSliceType as t, VersionRelease as u };
|
|
154
|
-
//# sourceMappingURL=index-
|
|
154
|
+
//# sourceMappingURL=index-Bp1WpATs.d.ts.map
|