@7365admin1/layer-common 3.2.4 → 3.2.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.
- package/CHANGELOG.md +204 -0
- package/components/BuildingUnitFormAdd.vue +5 -1
- package/components/CameraWall.vue +1034 -0
- package/components/CameraWallTile.vue +818 -0
- package/components/QrTemplate/CreditCardLandscape.vue +19 -12
- package/components/QrTemplate/PrintDialog.vue +209 -196
- package/components/VisitorManagement.vue +1 -1
- package/composables/useLocalAuth.ts +9 -36
- package/composables/useOrg.ts +1 -1
- package/composables/useSiteSettings.ts +50 -0
- package/package.json +2 -1
- package/types/org.d.ts +2 -0
- package/utils/camera-wall.test.ts +571 -0
- package/utils/camera-wall.ts +926 -0
- package/middleware/member.ts +0 -4
|
@@ -1,36 +1,7 @@
|
|
|
1
1
|
export default function useLocalAuth() {
|
|
2
2
|
const { cookieConfig } = useRuntimeConfig().public;
|
|
3
3
|
|
|
4
|
-
const
|
|
5
|
-
country: "",
|
|
6
|
-
address1: "",
|
|
7
|
-
address2: "",
|
|
8
|
-
city: "",
|
|
9
|
-
province: "",
|
|
10
|
-
postalCode: "",
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const user = {
|
|
14
|
-
_id: "",
|
|
15
|
-
givenName: "",
|
|
16
|
-
middleName: "",
|
|
17
|
-
surname: "",
|
|
18
|
-
address: _address,
|
|
19
|
-
email: "",
|
|
20
|
-
password: "",
|
|
21
|
-
type: "",
|
|
22
|
-
createdAt: "",
|
|
23
|
-
organization: "",
|
|
24
|
-
role: "",
|
|
25
|
-
primaryPhone: "",
|
|
26
|
-
mobilePhone: "",
|
|
27
|
-
serviceProviders: [],
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const currentUser = useState(
|
|
31
|
-
"currentUser",
|
|
32
|
-
(): TUser | null => JSON.parse(JSON.stringify(user))
|
|
33
|
-
);
|
|
4
|
+
const currentUser = useState<TUser | null>("currentUser", () => null);
|
|
34
5
|
|
|
35
6
|
async function authenticate() {
|
|
36
7
|
const user = useCookie("user", cookieConfig).value;
|
|
@@ -41,9 +12,7 @@ export default function useLocalAuth() {
|
|
|
41
12
|
);
|
|
42
13
|
|
|
43
14
|
watchEffect(() => {
|
|
44
|
-
|
|
45
|
-
currentUser.value = getCurrentUserReq.value as TUser;
|
|
46
|
-
}
|
|
15
|
+
currentUser.value = (getCurrentUserReq.value as TUser | null) ?? null;
|
|
47
16
|
});
|
|
48
17
|
|
|
49
18
|
watchEffect(() => {
|
|
@@ -70,6 +39,7 @@ export default function useLocalAuth() {
|
|
|
70
39
|
useCookie("sid", cookieConfig).value = null;
|
|
71
40
|
useCookie("user", cookieConfig).value = null;
|
|
72
41
|
useCookie("organization", cookieConfig).value = null;
|
|
42
|
+
currentUser.value = null;
|
|
73
43
|
}
|
|
74
44
|
|
|
75
45
|
async function logout() {
|
|
@@ -79,17 +49,20 @@ export default function useLocalAuth() {
|
|
|
79
49
|
await useNuxtApp().$api(`/api/auth/${sid}`, {
|
|
80
50
|
method: "DELETE",
|
|
81
51
|
});
|
|
82
|
-
|
|
83
|
-
clearCookies();
|
|
84
52
|
} catch (error) {
|
|
85
53
|
console.error("Logout failed:", error);
|
|
86
54
|
}
|
|
55
|
+
|
|
56
|
+
clearCookies();
|
|
87
57
|
}
|
|
88
58
|
}
|
|
89
59
|
|
|
90
60
|
async function getCurrentUser() {
|
|
91
61
|
const user = useCookie("user", cookieConfig).value;
|
|
92
|
-
if (!user)
|
|
62
|
+
if (!user) {
|
|
63
|
+
currentUser.value = null;
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
93
66
|
const _user = await useNuxtApp().$api<TUser>(`/api/users/id/${user}`, {
|
|
94
67
|
method: "GET",
|
|
95
68
|
});
|
package/composables/useOrg.ts
CHANGED
|
@@ -170,7 +170,7 @@ export default function useOrg() {
|
|
|
170
170
|
|
|
171
171
|
function updateOrg(
|
|
172
172
|
id: string,
|
|
173
|
-
value: Partial<Pick<TOrg, "name" | "type" | "email" | "nature" | "contact">>
|
|
173
|
+
value: Partial<Pick<TOrg, "name" | "type" | "email" | "nature" | "contact" | "terms" | "policies">>
|
|
174
174
|
) {
|
|
175
175
|
return useNuxtApp()
|
|
176
176
|
.$api<Record<string, any>>(`/api/organizations/${id}`, {
|
|
@@ -99,6 +99,54 @@ export default function () {
|
|
|
99
99
|
});
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
+
/**
|
|
103
|
+
* The monitoring wall for one site.
|
|
104
|
+
*
|
|
105
|
+
* A different endpoint from `getAllSiteCameras`, and the difference is the
|
|
106
|
+
* point. That one is the Settings panel's paginated CRUD list; this one is
|
|
107
|
+
* purpose-built for a wall and is what the React Native app already uses:
|
|
108
|
+
*
|
|
109
|
+
* - it is **site-scoped and authorised server-side** — the caller must be a
|
|
110
|
+
* member of the site, of its owning organisation, or work for an
|
|
111
|
+
* organisation engaged to serve it;
|
|
112
|
+
* - it returns `type: "ip"` cameras only, so an ANPR unit can never land on a
|
|
113
|
+
* monitoring wall;
|
|
114
|
+
* - it returns each camera's **capability descriptor** and the server's own
|
|
115
|
+
* `unavailableReason`, so a tile explains itself instead of showing a black
|
|
116
|
+
* rectangle;
|
|
117
|
+
* - it never returns a credential, and it contacts no device.
|
|
118
|
+
*
|
|
119
|
+
* Unpaginated by design: a wall shows a site's cameras, and paging them was
|
|
120
|
+
* an artefact of borrowing the CRUD list.
|
|
121
|
+
*/
|
|
122
|
+
async function getSiteWall(siteId: string) {
|
|
123
|
+
return await useNuxtApp().$api<Record<string, any>>(
|
|
124
|
+
`/api/site-cameras/site/${siteId}/wall`,
|
|
125
|
+
{ method: "GET" }
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Health for the cameras currently on screen.
|
|
131
|
+
*
|
|
132
|
+
* Same site scoping as the wall, and the ids are narrowed to the visible
|
|
133
|
+
* tiles on purpose: this is the one camera call that can reach a device, and
|
|
134
|
+
* asking about cameras nobody is looking at spends a real budget for nothing.
|
|
135
|
+
*
|
|
136
|
+
* **Reachability is answered per RECORDER and cached there**, so a wall of
|
|
137
|
+
* twelve channels on one device is one connect rather than twelve, and
|
|
138
|
+
* several supervisors watching the same wall is still one. That is what makes
|
|
139
|
+
* it safe to ask on a timer at all — but only a slow one: the server caches
|
|
140
|
+
* for `healthCacheSeconds`, and asking faster than the cache buys nothing and
|
|
141
|
+
* costs round trips.
|
|
142
|
+
*/
|
|
143
|
+
async function getSiteHealth(siteId: string, cameraIds: string[]) {
|
|
144
|
+
return await useNuxtApp().$api<Record<string, any>>(
|
|
145
|
+
`/api/site-cameras/site/${siteId}/health`,
|
|
146
|
+
{ method: "GET", query: { ids: cameraIds.join(",") } }
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
|
|
102
150
|
async function updateSiteInformation(
|
|
103
151
|
siteId: string,
|
|
104
152
|
payload: { bgImage: string; description: string; docs: { id: string; name: string }[] }
|
|
@@ -175,6 +223,8 @@ export default function () {
|
|
|
175
223
|
updateSite,
|
|
176
224
|
addCamera,
|
|
177
225
|
getAllSiteCameras,
|
|
226
|
+
getSiteWall,
|
|
227
|
+
getSiteHealth,
|
|
178
228
|
setSiteGuardPosts,
|
|
179
229
|
updateSiteCamera,
|
|
180
230
|
deleteSiteCameraById,
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@7365admin1/layer-common",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "3.2.
|
|
5
|
+
"version": "3.2.6",
|
|
6
6
|
"author": "7365admin1",
|
|
7
7
|
"main": "./nuxt.config.ts",
|
|
8
8
|
"publishConfig": {
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"preview": "nuxt preview .playground",
|
|
17
17
|
"test": "esbuild composables/useVisitorSocket.ts --format=esm --outfile=test/.build/useVisitorSocket.mjs --log-level=error && node --test \"test/*.test.mjs\"",
|
|
18
18
|
"test:theme": "node --test \"utils/theme.test.ts\"",
|
|
19
|
+
"test:camera-wall": "node --test \"utils/camera-wall.test.ts\"",
|
|
19
20
|
"release": "yarn run build && changeset publish"
|
|
20
21
|
},
|
|
21
22
|
"devDependencies": {
|