dt-common-device 5.1.4 → 5.1.6
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.
|
@@ -94,47 +94,45 @@ let AdminRepository = (() => {
|
|
|
94
94
|
INNER JOIN "dt_zones" "z" ON "zc"."zoneId" = "z"."id"
|
|
95
95
|
WHERE "zc"."collectionId" = ANY($1)`, [accessGroupIds]);
|
|
96
96
|
const response = result.rows;
|
|
97
|
-
const _zones = (nestedZones,
|
|
97
|
+
const _zones = (nestedZones, allZones = []) => {
|
|
98
98
|
nestedZones.forEach((z) => {
|
|
99
99
|
const onlyZone = { ...z };
|
|
100
100
|
delete onlyZone.childZones;
|
|
101
|
-
|
|
101
|
+
allZones.push(onlyZone);
|
|
102
102
|
if (!Array.isArray(z.childZones)) {
|
|
103
103
|
if (z.childZones.id)
|
|
104
104
|
z.childZones = [z.childZones];
|
|
105
105
|
}
|
|
106
106
|
if (z.childZones.length) {
|
|
107
|
-
_zones(z.childZones,
|
|
107
|
+
_zones(z.childZones, allZones);
|
|
108
108
|
}
|
|
109
109
|
});
|
|
110
|
-
return
|
|
110
|
+
return allZones.map((e) => e.id);
|
|
111
111
|
};
|
|
112
|
-
// const zones = _zones(response);
|
|
113
|
-
const zoneIds = response.map((el) => el.id);
|
|
114
112
|
const collectionZone = [];
|
|
115
|
-
for (let
|
|
113
|
+
for (let zone of response) {
|
|
116
114
|
let zoneIds = [];
|
|
117
|
-
const zones = await this.axiosInstance.get(`/zones/child?zoneId=${
|
|
118
|
-
zoneIds.push(
|
|
115
|
+
const zones = (await this.axiosInstance.get(`/zones/child?zoneId=${zone.zoneId}`))?.data?.data;
|
|
116
|
+
zoneIds.push(zone.zoneId);
|
|
119
117
|
if (zones.childZones?.length > 0) {
|
|
120
118
|
const nestedZoneIds = new Set(_zones(zones.childZones));
|
|
121
119
|
zoneIds = [...zoneIds, ...nestedZoneIds];
|
|
122
120
|
}
|
|
123
121
|
if (collectionZone.length == 0) {
|
|
124
122
|
const obj = {
|
|
125
|
-
collectionId:
|
|
123
|
+
collectionId: zone.collectionId,
|
|
126
124
|
zoneIds,
|
|
127
125
|
};
|
|
128
126
|
collectionZone.push(obj);
|
|
129
127
|
}
|
|
130
128
|
else {
|
|
131
|
-
const obj = collectionZone.find((e) => e.collectionId ==
|
|
129
|
+
const obj = collectionZone.find((e) => e.collectionId == zone.collectionId);
|
|
132
130
|
if (obj) {
|
|
133
131
|
obj.zoneIds = [...obj.zoneIds, ...zoneIds];
|
|
134
132
|
}
|
|
135
133
|
else {
|
|
136
134
|
collectionZone.push({
|
|
137
|
-
collectionId:
|
|
135
|
+
collectionId: zone.collectionId,
|
|
138
136
|
zoneIds,
|
|
139
137
|
});
|
|
140
138
|
}
|
|
@@ -145,7 +143,7 @@ let AdminRepository = (() => {
|
|
|
145
143
|
});
|
|
146
144
|
if (_zoneIds.length === 0)
|
|
147
145
|
return [];
|
|
148
|
-
const
|
|
146
|
+
const deviceDetails = await this.deviceRepository.queryDevices({
|
|
149
147
|
zoneIds: _zoneIds,
|
|
150
148
|
excludeDeviceType: interfaces_1.DeviceType.HUB,
|
|
151
149
|
});
|
|
@@ -153,7 +151,7 @@ let AdminRepository = (() => {
|
|
|
153
151
|
const zones = e.zoneIds;
|
|
154
152
|
let devices = [];
|
|
155
153
|
zones.forEach((element) => {
|
|
156
|
-
const device =
|
|
154
|
+
const device = deviceDetails.filter((d) => d.zoneId == element);
|
|
157
155
|
// Add collectionId to each device
|
|
158
156
|
device.forEach((dev) => {
|
|
159
157
|
dev.collectionId = e.collectionId;
|
|
@@ -11,7 +11,12 @@ class AdminService {
|
|
|
11
11
|
this.adminRepository = typedi_1.default.get(Admin_repository_1.AdminRepository);
|
|
12
12
|
}
|
|
13
13
|
async getZonesByAccessGroupIds(accessGroupIds) {
|
|
14
|
-
|
|
14
|
+
try {
|
|
15
|
+
return await this.adminRepository.getZonesByAccessGroupIds(accessGroupIds);
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
console.log(error);
|
|
19
|
+
}
|
|
15
20
|
}
|
|
16
21
|
}
|
|
17
22
|
exports.AdminService = AdminService;
|