@webx-ui/module-auth 0.5.3 → 0.6.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/AdminsPage.d.ts +5 -1
- package/dist/ProfileDialog.d.ts +20 -0
- package/dist/UserMenu.d.ts +13 -0
- package/dist/index.d.ts +9 -1
- package/dist/index.js +656 -484
- package/dist/index.js.map +1 -1
- package/dist/session.d.ts +26 -2
- package/dist/style.css +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,36 +1,43 @@
|
|
|
1
|
-
import { inject as
|
|
2
|
-
import { useTranslate as I, HttpError as
|
|
3
|
-
import { useModal as
|
|
4
|
-
const
|
|
5
|
-
function
|
|
6
|
-
const a =
|
|
1
|
+
import { inject as te, defineComponent as R, computed as P, ref as g, useTemplateRef as oe, onBeforeUnmount as ze, resolveComponent as B, openBlock as L, createBlock as S, withCtx as l, createVNode as t, withModifiers as Be, createCommentVNode as T, createElementVNode as N, createTextVNode as F, toDisplayString as $, watch as Z, unref as e, isRef as se, createElementBlock as O, resolveDynamicComponent as ge, createSlots as ne, Fragment as le, renderList as _e, h as xe, normalizeClass as Te } from "vue";
|
|
2
|
+
import { useTranslate as I, HttpError as Me, useAdmin as q, useI18n as ke, useErrorText as re, WxDate as Ne, WxRowMenu as he, WxListScreen as Ee } from "@webx-ui/module-admin";
|
|
3
|
+
import { useModal as ie, WxDialog as ue, WxFormItem as M, WxInput as E, WxSelect as X, WxSpace as Y, WxCheckbox as be, WxText as de, WxButton as D, toast as j, WxTable as Oe, WxBadge as ae, WxAvatar as De, createModal as ce, confirm as Re } from "@webx-ui/core";
|
|
4
|
+
const Ve = /* @__PURE__ */ Symbol("webx-auth");
|
|
5
|
+
function me() {
|
|
6
|
+
const a = te(Ve, null);
|
|
7
7
|
if (a === null)
|
|
8
8
|
throw new Error("useAuth() was called outside a panel that installed the auth plugin.");
|
|
9
9
|
return a;
|
|
10
10
|
}
|
|
11
|
-
function
|
|
11
|
+
function Ie(a) {
|
|
12
12
|
const i = `${a.apiPath}/auth`;
|
|
13
13
|
return {
|
|
14
14
|
async me() {
|
|
15
15
|
try {
|
|
16
16
|
return (await a.http.get(`${i}/me`)).data;
|
|
17
17
|
} catch (s) {
|
|
18
|
-
if (
|
|
18
|
+
if (Ye(s))
|
|
19
19
|
return null;
|
|
20
20
|
throw s;
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
23
|
async login(s) {
|
|
24
|
-
const
|
|
24
|
+
const o = await a.http.post(`${i}/login`, {
|
|
25
25
|
email: s.email,
|
|
26
26
|
password: s.password,
|
|
27
27
|
remember: s.remember ?? !1
|
|
28
28
|
});
|
|
29
|
-
return a.setUser(
|
|
29
|
+
return a.setUser(o.data), await a.reload(), o.data;
|
|
30
30
|
},
|
|
31
31
|
async setLocale(s) {
|
|
32
|
-
const
|
|
33
|
-
a.setUser(
|
|
32
|
+
const o = await a.http.put(`${i}/locale`, { locale: s });
|
|
33
|
+
a.setUser(o.data), await a.setLocale(s);
|
|
34
|
+
},
|
|
35
|
+
async updateProfile(s) {
|
|
36
|
+
const o = await a.http.put(
|
|
37
|
+
`${i}/me`,
|
|
38
|
+
s
|
|
39
|
+
);
|
|
40
|
+
return a.setUser(o.data), o.data;
|
|
34
41
|
},
|
|
35
42
|
async logout() {
|
|
36
43
|
try {
|
|
@@ -41,14 +48,14 @@ function Ee(a) {
|
|
|
41
48
|
}
|
|
42
49
|
};
|
|
43
50
|
}
|
|
44
|
-
const
|
|
45
|
-
function
|
|
46
|
-
a.provide(
|
|
51
|
+
const Ae = /* @__PURE__ */ Symbol("webx-auth-avatar"), Le = /* @__PURE__ */ Symbol("webx-auth-avatar-field");
|
|
52
|
+
function Ke(a, i, s = null, o = null) {
|
|
53
|
+
a.provide(Ve, i), a.provide(Ae, s), a.provide(Le, o);
|
|
47
54
|
}
|
|
48
|
-
function
|
|
55
|
+
function Ye(a) {
|
|
49
56
|
return typeof a == "object" && a !== null && "status" in a && a.status === 401;
|
|
50
57
|
}
|
|
51
|
-
const
|
|
58
|
+
const je = ["title", "aria-label", "aria-pressed"], qe = /* @__PURE__ */ R({
|
|
52
59
|
__name: "LoginCard",
|
|
53
60
|
props: {
|
|
54
61
|
emailLabel: { default: void 0 },
|
|
@@ -64,170 +71,170 @@ const De = ["title", "aria-label", "aria-pressed"], Ke = /* @__PURE__ */ R({
|
|
|
64
71
|
},
|
|
65
72
|
emits: ["success"],
|
|
66
73
|
setup(a, { expose: i, emit: s }) {
|
|
67
|
-
const
|
|
68
|
-
email:
|
|
69
|
-
password:
|
|
70
|
-
remember:
|
|
71
|
-
submit:
|
|
72
|
-
capsLock:
|
|
73
|
-
reveal:
|
|
74
|
-
hide:
|
|
75
|
-
})),
|
|
76
|
-
let
|
|
77
|
-
|
|
78
|
-
const
|
|
79
|
-
() =>
|
|
74
|
+
const o = a, u = s, k = me(), m = I("webx-auth"), n = P(() => ({
|
|
75
|
+
email: o.emailLabel ?? m("card.email"),
|
|
76
|
+
password: o.passwordLabel ?? m("card.password"),
|
|
77
|
+
remember: o.rememberLabel ?? m("card.remember"),
|
|
78
|
+
submit: o.submitLabel ?? m("card.submit"),
|
|
79
|
+
capsLock: o.capsLockWarning ?? m("card.caps-lock"),
|
|
80
|
+
reveal: o.revealLabel ?? m("card.reveal"),
|
|
81
|
+
hide: o.hideLabel ?? m("card.hide")
|
|
82
|
+
})), p = g(""), C = g(""), V = g(!1), d = g(!1), w = g(!1), r = g(!1), b = g(""), _ = g({}), f = g(0), U = oe("emailField");
|
|
83
|
+
let W = null;
|
|
84
|
+
ze(H);
|
|
85
|
+
const z = P(() => f.value > 0), h = P(
|
|
86
|
+
() => o.throttleMessage === void 0 ? m("card.throttled", { seconds: f.value }) : o.throttleMessage.replace(":seconds", String(f.value))
|
|
80
87
|
);
|
|
81
|
-
async function
|
|
82
|
-
if (!(d.value ||
|
|
83
|
-
d.value = !0,
|
|
88
|
+
async function c() {
|
|
89
|
+
if (!(d.value || z.value)) {
|
|
90
|
+
d.value = !0, b.value = "", _.value = {};
|
|
84
91
|
try {
|
|
85
|
-
await
|
|
86
|
-
email:
|
|
87
|
-
password:
|
|
88
|
-
remember:
|
|
89
|
-
}),
|
|
90
|
-
} catch (
|
|
91
|
-
|
|
92
|
+
await k.login({
|
|
93
|
+
email: p.value,
|
|
94
|
+
password: C.value,
|
|
95
|
+
remember: V.value
|
|
96
|
+
}), C.value = "", u("success");
|
|
97
|
+
} catch (y) {
|
|
98
|
+
x(y);
|
|
92
99
|
} finally {
|
|
93
100
|
d.value = !1;
|
|
94
101
|
}
|
|
95
102
|
}
|
|
96
103
|
}
|
|
97
|
-
function
|
|
98
|
-
if (!(
|
|
99
|
-
|
|
104
|
+
function x(y) {
|
|
105
|
+
if (!(y instanceof Me)) {
|
|
106
|
+
b.value = y instanceof Error ? y.message : String(y);
|
|
100
107
|
return;
|
|
101
108
|
}
|
|
102
|
-
if (
|
|
103
|
-
|
|
109
|
+
if (y.isValidation) {
|
|
110
|
+
_.value = y.errors;
|
|
104
111
|
return;
|
|
105
112
|
}
|
|
106
|
-
if (
|
|
107
|
-
|
|
113
|
+
if (y.isThrottled) {
|
|
114
|
+
Q(y.retryAfter ?? 60);
|
|
108
115
|
return;
|
|
109
116
|
}
|
|
110
|
-
|
|
117
|
+
b.value = y.message;
|
|
111
118
|
}
|
|
112
|
-
function
|
|
113
|
-
|
|
114
|
-
|
|
119
|
+
function Q(y) {
|
|
120
|
+
H(), f.value = y, W = setInterval(() => {
|
|
121
|
+
f.value -= 1, f.value <= 0 && H();
|
|
115
122
|
}, 1e3);
|
|
116
123
|
}
|
|
117
|
-
function
|
|
118
|
-
|
|
124
|
+
function H() {
|
|
125
|
+
W !== null && (clearInterval(W), W = null), f.value = 0;
|
|
119
126
|
}
|
|
120
|
-
function
|
|
121
|
-
|
|
127
|
+
function A(y) {
|
|
128
|
+
r.value = y.getModifierState("CapsLock");
|
|
122
129
|
}
|
|
123
|
-
return i({ focus: () =>
|
|
124
|
-
const
|
|
125
|
-
return
|
|
130
|
+
return i({ focus: () => U.value?.focus() }), (y, v) => {
|
|
131
|
+
const G = B("wx-alert"), ee = B("wx-icon"), fe = B("wx-input"), we = B("wx-form-item"), Fe = B("wx-checkbox"), Se = B("wx-button"), We = B("wx-form"), Pe = B("wx-card");
|
|
132
|
+
return L(), S(Pe, {
|
|
126
133
|
class: "wx-login",
|
|
127
134
|
padding: 24
|
|
128
135
|
}, {
|
|
129
136
|
default: l(() => [
|
|
130
|
-
|
|
131
|
-
errors:
|
|
137
|
+
t(We, {
|
|
138
|
+
errors: _.value,
|
|
132
139
|
disabled: d.value,
|
|
133
140
|
gap: "md",
|
|
134
|
-
onSubmit:
|
|
141
|
+
onSubmit: Be(c, ["prevent"])
|
|
135
142
|
}, {
|
|
136
143
|
default: l(() => [
|
|
137
|
-
|
|
144
|
+
b.value !== "" ? (L(), S(G, {
|
|
138
145
|
key: 0,
|
|
139
146
|
type: "danger",
|
|
140
147
|
variant: "soft",
|
|
141
148
|
live: "",
|
|
142
|
-
description:
|
|
149
|
+
description: b.value,
|
|
143
150
|
class: "wx-login__message"
|
|
144
|
-
}, null, 8, ["description"])) :
|
|
151
|
+
}, null, 8, ["description"])) : z.value ? (L(), S(G, {
|
|
145
152
|
key: 1,
|
|
146
153
|
type: "warning",
|
|
147
154
|
variant: "soft",
|
|
148
155
|
live: "",
|
|
149
|
-
description:
|
|
156
|
+
description: h.value,
|
|
150
157
|
class: "wx-login__message"
|
|
151
|
-
}, null, 8, ["description"])) :
|
|
152
|
-
|
|
158
|
+
}, null, 8, ["description"])) : T("", !0),
|
|
159
|
+
t(we, { name: "email" }, {
|
|
153
160
|
default: l(() => [
|
|
154
|
-
|
|
161
|
+
t(fe, {
|
|
155
162
|
ref_key: "emailField",
|
|
156
|
-
ref:
|
|
157
|
-
modelValue:
|
|
158
|
-
"onUpdate:modelValue":
|
|
163
|
+
ref: U,
|
|
164
|
+
modelValue: p.value,
|
|
165
|
+
"onUpdate:modelValue": v[0] || (v[0] = (K) => p.value = K),
|
|
159
166
|
type: "email",
|
|
160
|
-
placeholder:
|
|
161
|
-
"aria-label":
|
|
167
|
+
placeholder: n.value.email,
|
|
168
|
+
"aria-label": n.value.email,
|
|
162
169
|
autocomplete: "username",
|
|
163
170
|
autofocus: a.autofocus,
|
|
164
171
|
inputmode: "email",
|
|
165
172
|
size: "lg"
|
|
166
173
|
}, {
|
|
167
174
|
prefix: l(() => [
|
|
168
|
-
|
|
175
|
+
t(ee, { name: "mail" })
|
|
169
176
|
]),
|
|
170
177
|
_: 1
|
|
171
178
|
}, 8, ["modelValue", "placeholder", "aria-label", "autofocus"])
|
|
172
179
|
]),
|
|
173
180
|
_: 1
|
|
174
181
|
}),
|
|
175
|
-
|
|
182
|
+
t(we, {
|
|
176
183
|
name: "password",
|
|
177
|
-
help:
|
|
184
|
+
help: r.value ? n.value.capsLock : void 0
|
|
178
185
|
}, {
|
|
179
186
|
default: l(() => [
|
|
180
|
-
|
|
181
|
-
modelValue:
|
|
182
|
-
"onUpdate:modelValue":
|
|
183
|
-
type:
|
|
184
|
-
placeholder:
|
|
185
|
-
"aria-label":
|
|
187
|
+
t(fe, {
|
|
188
|
+
modelValue: C.value,
|
|
189
|
+
"onUpdate:modelValue": v[2] || (v[2] = (K) => C.value = K),
|
|
190
|
+
type: w.value ? "text" : "password",
|
|
191
|
+
placeholder: n.value.password,
|
|
192
|
+
"aria-label": n.value.password,
|
|
186
193
|
autocomplete: "current-password",
|
|
187
194
|
size: "lg",
|
|
188
|
-
onKeydown:
|
|
189
|
-
onKeyup:
|
|
195
|
+
onKeydown: A,
|
|
196
|
+
onKeyup: A
|
|
190
197
|
}, {
|
|
191
198
|
prefix: l(() => [
|
|
192
|
-
|
|
199
|
+
t(ee, { name: "lock" })
|
|
193
200
|
]),
|
|
194
201
|
suffix: l(() => [
|
|
195
|
-
|
|
202
|
+
N("button", {
|
|
196
203
|
type: "button",
|
|
197
204
|
class: "wx-login__reveal",
|
|
198
|
-
title:
|
|
199
|
-
"aria-label":
|
|
200
|
-
"aria-pressed":
|
|
205
|
+
title: w.value ? n.value.hide : n.value.reveal,
|
|
206
|
+
"aria-label": w.value ? n.value.hide : n.value.reveal,
|
|
207
|
+
"aria-pressed": w.value,
|
|
201
208
|
tabindex: "-1",
|
|
202
|
-
onClick:
|
|
209
|
+
onClick: v[1] || (v[1] = (K) => w.value = !w.value)
|
|
203
210
|
}, [
|
|
204
|
-
|
|
205
|
-
name:
|
|
211
|
+
t(ee, {
|
|
212
|
+
name: w.value ? "eye-off" : "eye"
|
|
206
213
|
}, null, 8, ["name"])
|
|
207
|
-
], 8,
|
|
214
|
+
], 8, je)
|
|
208
215
|
]),
|
|
209
216
|
_: 1
|
|
210
217
|
}, 8, ["modelValue", "type", "placeholder", "aria-label"])
|
|
211
218
|
]),
|
|
212
219
|
_: 1
|
|
213
220
|
}, 8, ["help"]),
|
|
214
|
-
a.remember ? (
|
|
221
|
+
a.remember ? (L(), S(Fe, {
|
|
215
222
|
key: 2,
|
|
216
|
-
modelValue:
|
|
217
|
-
"onUpdate:modelValue":
|
|
218
|
-
label:
|
|
223
|
+
modelValue: V.value,
|
|
224
|
+
"onUpdate:modelValue": v[3] || (v[3] = (K) => V.value = K),
|
|
225
|
+
label: n.value.remember,
|
|
219
226
|
class: "wx-login__remember"
|
|
220
|
-
}, null, 8, ["modelValue", "label"])) :
|
|
221
|
-
|
|
227
|
+
}, null, 8, ["modelValue", "label"])) : T("", !0),
|
|
228
|
+
t(Se, {
|
|
222
229
|
type: "primary",
|
|
223
230
|
"native-type": "submit",
|
|
224
231
|
size: "lg",
|
|
225
232
|
block: "",
|
|
226
233
|
loading: d.value,
|
|
227
|
-
disabled:
|
|
234
|
+
disabled: z.value
|
|
228
235
|
}, {
|
|
229
236
|
default: l(() => [
|
|
230
|
-
|
|
237
|
+
F($(n.value.submit), 1)
|
|
231
238
|
]),
|
|
232
239
|
_: 1
|
|
233
240
|
}, 8, ["loading", "disabled"])
|
|
@@ -239,12 +246,12 @@ const De = ["title", "aria-label", "aria-pressed"], Ke = /* @__PURE__ */ R({
|
|
|
239
246
|
});
|
|
240
247
|
};
|
|
241
248
|
}
|
|
242
|
-
}),
|
|
249
|
+
}), ve = (a, i) => {
|
|
243
250
|
const s = a.__vccOpts || a;
|
|
244
|
-
for (const [
|
|
245
|
-
s[
|
|
251
|
+
for (const [o, u] of i)
|
|
252
|
+
s[o] = u;
|
|
246
253
|
return s;
|
|
247
|
-
},
|
|
254
|
+
}, He = /* @__PURE__ */ ve(qe, [["__scopeId", "data-v-3c206e31"]]), $e = {
|
|
248
255
|
card: {
|
|
249
256
|
email: "Email",
|
|
250
257
|
password: "Password",
|
|
@@ -278,7 +285,6 @@ const De = ["title", "aria-label", "aria-pressed"], Ke = /* @__PURE__ */ R({
|
|
|
278
285
|
locale: "Panel language",
|
|
279
286
|
"locale-auto": "Follow the browser",
|
|
280
287
|
"last-login": "Last signed in",
|
|
281
|
-
never: "Never",
|
|
282
288
|
save: "Save",
|
|
283
289
|
cancel: "Cancel",
|
|
284
290
|
delete: "Delete",
|
|
@@ -303,52 +309,67 @@ const De = ["title", "aria-label", "aria-pressed"], Ke = /* @__PURE__ */ R({
|
|
|
303
309
|
"not-yourself": "You cannot do that to your own account.",
|
|
304
310
|
"last-super": "There has to be one super administrator left."
|
|
305
311
|
},
|
|
312
|
+
// Somebody editing themselves, which is a shorter list than an administrator editing them.
|
|
313
|
+
profile: {
|
|
314
|
+
title: "Your profile",
|
|
315
|
+
menu: "Edit your profile",
|
|
316
|
+
name: "Name",
|
|
317
|
+
avatar: "Photo",
|
|
318
|
+
password: "New password",
|
|
319
|
+
"password-hint": "At least 12 characters. Leave blank to keep the current one.",
|
|
320
|
+
"current-password": "Current password",
|
|
321
|
+
"current-password-hint": "Asked for before the password is changed.",
|
|
322
|
+
"wrong-password": "That is not the current password.",
|
|
323
|
+
saved: "Your profile is saved.",
|
|
324
|
+
save: "Save",
|
|
325
|
+
cancel: "Cancel"
|
|
326
|
+
},
|
|
306
327
|
menu: {
|
|
307
328
|
"sign-out": "Sign out",
|
|
308
329
|
language: "Interface language"
|
|
309
330
|
}
|
|
310
331
|
};
|
|
311
|
-
function
|
|
312
|
-
const i = `${a.apiPath}/auth`, s = (
|
|
332
|
+
function pe(a) {
|
|
333
|
+
const i = `${a.apiPath}/auth`, s = (o) => o.data;
|
|
313
334
|
return {
|
|
314
|
-
list: (
|
|
335
|
+
list: (o = {}) => a.http.get(`${i}/admins`, {
|
|
315
336
|
query: {
|
|
316
|
-
q:
|
|
317
|
-
role:
|
|
318
|
-
active:
|
|
319
|
-
sort:
|
|
320
|
-
page:
|
|
321
|
-
per_page:
|
|
337
|
+
q: o.q || void 0,
|
|
338
|
+
role: o.role ?? void 0,
|
|
339
|
+
active: o.active ?? void 0,
|
|
340
|
+
sort: o.sort,
|
|
341
|
+
page: o.page,
|
|
342
|
+
per_page: o.per_page
|
|
322
343
|
}
|
|
323
|
-
}).then((
|
|
324
|
-
get: (
|
|
325
|
-
create: (
|
|
326
|
-
update: (
|
|
327
|
-
remove: (
|
|
344
|
+
}).then((u) => ({ ...u.meta, data: u.data })),
|
|
345
|
+
get: (o) => a.http.get(`${i}/admins/${o}`).then(s),
|
|
346
|
+
create: (o) => a.http.post(`${i}/admins`, o).then(s),
|
|
347
|
+
update: (o, u) => a.http.patch(`${i}/admins/${o}`, u).then(s),
|
|
348
|
+
remove: (o) => a.http.delete(`${i}/admins/${o}`),
|
|
328
349
|
roles: () => a.http.get(`${i}/roles`).then(s)
|
|
329
350
|
};
|
|
330
351
|
}
|
|
331
|
-
const
|
|
332
|
-
function
|
|
352
|
+
const ye = /* @__PURE__ */ new WeakSet();
|
|
353
|
+
function J() {
|
|
333
354
|
try {
|
|
334
355
|
const { i18n: a } = q();
|
|
335
|
-
|
|
356
|
+
ye.has(a) || (a.defaults("webx-auth", $e), ye.add(a));
|
|
336
357
|
} catch {
|
|
337
358
|
}
|
|
338
359
|
}
|
|
339
|
-
const
|
|
360
|
+
const Ge = { class: "wx-admin-form" }, Je = { class: "wx-admin-form__grid" }, Qe = {
|
|
340
361
|
key: 0,
|
|
341
362
|
class: "wx-admin-form__aside"
|
|
342
|
-
},
|
|
363
|
+
}, Xe = { class: "wx-admin-form__fields" }, Ze = /* @__PURE__ */ R({
|
|
343
364
|
__name: "AdminDialog",
|
|
344
365
|
props: {
|
|
345
366
|
admin: { default: null },
|
|
346
367
|
avatarField: { default: void 0 }
|
|
347
368
|
},
|
|
348
369
|
setup(a) {
|
|
349
|
-
const i = a, { resolve: s, dismiss:
|
|
350
|
-
|
|
351
|
-
const
|
|
370
|
+
const i = a, { resolve: s, dismiss: o, open: u } = ie(), k = q(), m = pe(k), n = ke();
|
|
371
|
+
J();
|
|
372
|
+
const p = I("webx-auth"), C = re(), V = g([]), d = g(!1), w = g({}), r = g({
|
|
352
373
|
name: "",
|
|
353
374
|
email: "",
|
|
354
375
|
password: "",
|
|
@@ -357,81 +378,81 @@ const qe = { class: "wx-admin-form" }, He = { class: "wx-admin-form__grid" }, Ye
|
|
|
357
378
|
is_super: !1,
|
|
358
379
|
locale: null,
|
|
359
380
|
roles: []
|
|
360
|
-
}),
|
|
361
|
-
get: () =>
|
|
362
|
-
set: (
|
|
363
|
-
|
|
381
|
+
}), b = P({
|
|
382
|
+
get: () => r.value.avatar ? { path: r.value.avatar } : null,
|
|
383
|
+
set: (h) => {
|
|
384
|
+
r.value.avatar = h?.path ?? null;
|
|
364
385
|
}
|
|
365
|
-
}),
|
|
366
|
-
{ value: "auto", label:
|
|
367
|
-
...
|
|
386
|
+
}), _ = P(() => i.admin !== null), f = P(() => V.value.map((h) => ({ value: h.id, label: h.name }))), U = P(() => [
|
|
387
|
+
{ value: "auto", label: p("admins.locale-auto") },
|
|
388
|
+
...n.state.panelLocales.map((h) => ({ value: h.code, label: h.nativeName }))
|
|
368
389
|
]);
|
|
369
|
-
|
|
390
|
+
m.roles().then((h) => V.value = h), Z(
|
|
370
391
|
() => i.admin,
|
|
371
|
-
(
|
|
372
|
-
|
|
373
|
-
name:
|
|
374
|
-
email:
|
|
392
|
+
(h) => {
|
|
393
|
+
r.value = {
|
|
394
|
+
name: h?.name ?? "",
|
|
395
|
+
email: h?.email ?? "",
|
|
375
396
|
password: "",
|
|
376
|
-
avatar:
|
|
377
|
-
is_active:
|
|
378
|
-
is_super:
|
|
379
|
-
locale:
|
|
380
|
-
roles:
|
|
381
|
-
},
|
|
397
|
+
avatar: h?.avatar ?? null,
|
|
398
|
+
is_active: h?.is_active ?? !0,
|
|
399
|
+
is_super: h?.is_super ?? !1,
|
|
400
|
+
locale: h?.locale ?? "auto",
|
|
401
|
+
roles: h?.roles.map((c) => c.id) ?? []
|
|
402
|
+
}, w.value = {};
|
|
382
403
|
},
|
|
383
404
|
{ immediate: !0 }
|
|
384
405
|
);
|
|
385
|
-
function
|
|
386
|
-
return
|
|
406
|
+
function W(h) {
|
|
407
|
+
return w.value[h]?.[0];
|
|
387
408
|
}
|
|
388
409
|
async function z() {
|
|
389
|
-
|
|
390
|
-
const
|
|
391
|
-
name:
|
|
392
|
-
email:
|
|
393
|
-
avatar:
|
|
394
|
-
is_active:
|
|
395
|
-
is_super:
|
|
396
|
-
locale:
|
|
397
|
-
roles:
|
|
410
|
+
d.value = !0, w.value = {};
|
|
411
|
+
const h = {
|
|
412
|
+
name: r.value.name,
|
|
413
|
+
email: r.value.email,
|
|
414
|
+
avatar: r.value.avatar,
|
|
415
|
+
is_active: r.value.is_active,
|
|
416
|
+
is_super: r.value.is_super,
|
|
417
|
+
locale: r.value.locale === "auto" ? null : r.value.locale,
|
|
418
|
+
roles: r.value.roles ?? []
|
|
398
419
|
};
|
|
399
|
-
|
|
420
|
+
r.value.password && (h.password = r.value.password);
|
|
400
421
|
try {
|
|
401
|
-
const
|
|
402
|
-
|
|
403
|
-
} catch (
|
|
404
|
-
const
|
|
405
|
-
|
|
422
|
+
const c = i.admin ? await m.update(i.admin.id, h) : await m.create(h);
|
|
423
|
+
j.success(p(_.value ? "admins.updated" : "admins.created")), s(c);
|
|
424
|
+
} catch (c) {
|
|
425
|
+
const x = c.body;
|
|
426
|
+
x?.errors ? w.value = x.errors : j.danger(C(c));
|
|
406
427
|
} finally {
|
|
407
|
-
|
|
428
|
+
d.value = !1;
|
|
408
429
|
}
|
|
409
430
|
}
|
|
410
|
-
return (
|
|
411
|
-
open: e(
|
|
412
|
-
"onUpdate:open":
|
|
413
|
-
title:
|
|
431
|
+
return (h, c) => (L(), S(e(ue), {
|
|
432
|
+
open: e(u),
|
|
433
|
+
"onUpdate:open": c[9] || (c[9] = (x) => se(u) ? u.value = x : null),
|
|
434
|
+
title: _.value ? e(p)("admins.edit-short") : e(p)("admins.new-short"),
|
|
414
435
|
width: 720
|
|
415
436
|
}, {
|
|
416
437
|
footer: l(() => [
|
|
417
|
-
|
|
438
|
+
t(e(Y), { size: "sm" }, {
|
|
418
439
|
default: l(() => [
|
|
419
|
-
|
|
440
|
+
t(e(D), {
|
|
420
441
|
variant: "outline",
|
|
421
|
-
onClick:
|
|
442
|
+
onClick: c[8] || (c[8] = (x) => e(o)())
|
|
422
443
|
}, {
|
|
423
444
|
default: l(() => [
|
|
424
|
-
|
|
445
|
+
F($(e(p)("admins.cancel")), 1)
|
|
425
446
|
]),
|
|
426
447
|
_: 1
|
|
427
448
|
}),
|
|
428
|
-
|
|
449
|
+
t(e(D), {
|
|
429
450
|
type: "primary",
|
|
430
|
-
loading:
|
|
451
|
+
loading: d.value,
|
|
431
452
|
onClick: z
|
|
432
453
|
}, {
|
|
433
454
|
default: l(() => [
|
|
434
|
-
|
|
455
|
+
F($(e(p)("admins.save")), 1)
|
|
435
456
|
]),
|
|
436
457
|
_: 1
|
|
437
458
|
}, 8, ["loading"])
|
|
@@ -440,39 +461,39 @@ const qe = { class: "wx-admin-form" }, He = { class: "wx-admin-form__grid" }, Ye
|
|
|
440
461
|
})
|
|
441
462
|
]),
|
|
442
463
|
default: l(() => [
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
a.avatarField ? (
|
|
446
|
-
(
|
|
447
|
-
modelValue:
|
|
448
|
-
"onUpdate:modelValue":
|
|
449
|
-
label: e(
|
|
464
|
+
N("div", Ge, [
|
|
465
|
+
N("div", Je, [
|
|
466
|
+
a.avatarField ? (L(), O("div", Qe, [
|
|
467
|
+
(L(), S(ge(a.avatarField), {
|
|
468
|
+
modelValue: b.value,
|
|
469
|
+
"onUpdate:modelValue": c[0] || (c[0] = (x) => b.value = x),
|
|
470
|
+
label: e(p)("admins.avatar"),
|
|
450
471
|
aspect: "1/1",
|
|
451
472
|
captions: !1
|
|
452
473
|
}, null, 8, ["modelValue", "label"]))
|
|
453
|
-
])) :
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
label: e(
|
|
457
|
-
error:
|
|
474
|
+
])) : T("", !0),
|
|
475
|
+
N("div", Xe, [
|
|
476
|
+
t(e(M), {
|
|
477
|
+
label: e(p)("admins.name"),
|
|
478
|
+
error: W("name")
|
|
458
479
|
}, {
|
|
459
480
|
default: l(() => [
|
|
460
|
-
|
|
461
|
-
modelValue:
|
|
462
|
-
"onUpdate:modelValue":
|
|
481
|
+
t(e(E), {
|
|
482
|
+
modelValue: r.value.name,
|
|
483
|
+
"onUpdate:modelValue": c[1] || (c[1] = (x) => r.value.name = x),
|
|
463
484
|
name: "name"
|
|
464
485
|
}, null, 8, ["modelValue"])
|
|
465
486
|
]),
|
|
466
487
|
_: 1
|
|
467
488
|
}, 8, ["label", "error"]),
|
|
468
|
-
|
|
469
|
-
label: e(
|
|
470
|
-
error:
|
|
489
|
+
t(e(M), {
|
|
490
|
+
label: e(p)("admins.email"),
|
|
491
|
+
error: W("email")
|
|
471
492
|
}, {
|
|
472
493
|
default: l(() => [
|
|
473
|
-
|
|
474
|
-
modelValue:
|
|
475
|
-
"onUpdate:modelValue":
|
|
494
|
+
t(e(E), {
|
|
495
|
+
modelValue: r.value.email,
|
|
496
|
+
"onUpdate:modelValue": c[2] || (c[2] = (x) => r.value.email = x),
|
|
476
497
|
type: "email",
|
|
477
498
|
name: "email",
|
|
478
499
|
autocomplete: "off"
|
|
@@ -480,15 +501,15 @@ const qe = { class: "wx-admin-form" }, He = { class: "wx-admin-form__grid" }, Ye
|
|
|
480
501
|
]),
|
|
481
502
|
_: 1
|
|
482
503
|
}, 8, ["label", "error"]),
|
|
483
|
-
|
|
484
|
-
label: e(
|
|
485
|
-
error:
|
|
486
|
-
help:
|
|
504
|
+
t(e(M), {
|
|
505
|
+
label: e(p)("admins.password"),
|
|
506
|
+
error: W("password"),
|
|
507
|
+
help: _.value ? e(p)("admins.password-keep") : e(p)("admins.password-hint")
|
|
487
508
|
}, {
|
|
488
509
|
default: l(() => [
|
|
489
|
-
|
|
490
|
-
modelValue:
|
|
491
|
-
"onUpdate:modelValue":
|
|
510
|
+
t(e(E), {
|
|
511
|
+
modelValue: r.value.password,
|
|
512
|
+
"onUpdate:modelValue": c[3] || (c[3] = (x) => r.value.password = x),
|
|
492
513
|
type: "password",
|
|
493
514
|
name: "password",
|
|
494
515
|
autocomplete: "new-password"
|
|
@@ -496,53 +517,53 @@ const qe = { class: "wx-admin-form" }, He = { class: "wx-admin-form__grid" }, Ye
|
|
|
496
517
|
]),
|
|
497
518
|
_: 1
|
|
498
519
|
}, 8, ["label", "error", "help"]),
|
|
499
|
-
|
|
500
|
-
label: e(
|
|
501
|
-
error:
|
|
520
|
+
t(e(M), {
|
|
521
|
+
label: e(p)("admins.roles"),
|
|
522
|
+
error: W("roles")
|
|
502
523
|
}, {
|
|
503
524
|
default: l(() => [
|
|
504
|
-
|
|
505
|
-
modelValue:
|
|
506
|
-
"onUpdate:modelValue":
|
|
507
|
-
options:
|
|
525
|
+
t(e(X), {
|
|
526
|
+
modelValue: r.value.roles,
|
|
527
|
+
"onUpdate:modelValue": c[4] || (c[4] = (x) => r.value.roles = x),
|
|
528
|
+
options: f.value,
|
|
508
529
|
multiple: ""
|
|
509
530
|
}, null, 8, ["modelValue", "options"])
|
|
510
531
|
]),
|
|
511
532
|
_: 1
|
|
512
533
|
}, 8, ["label", "error"]),
|
|
513
|
-
|
|
514
|
-
label: e(
|
|
534
|
+
t(e(M), {
|
|
535
|
+
label: e(p)("admins.locale")
|
|
515
536
|
}, {
|
|
516
537
|
default: l(() => [
|
|
517
|
-
|
|
518
|
-
modelValue:
|
|
519
|
-
"onUpdate:modelValue":
|
|
520
|
-
options:
|
|
538
|
+
t(e(X), {
|
|
539
|
+
modelValue: r.value.locale,
|
|
540
|
+
"onUpdate:modelValue": c[5] || (c[5] = (x) => r.value.locale = x),
|
|
541
|
+
options: U.value
|
|
521
542
|
}, null, 8, ["modelValue", "options"])
|
|
522
543
|
]),
|
|
523
544
|
_: 1
|
|
524
545
|
}, 8, ["label"]),
|
|
525
|
-
|
|
546
|
+
t(e(Y), { size: "md" }, {
|
|
526
547
|
default: l(() => [
|
|
527
|
-
|
|
528
|
-
modelValue:
|
|
529
|
-
"onUpdate:modelValue":
|
|
530
|
-
label: e(
|
|
548
|
+
t(e(be), {
|
|
549
|
+
modelValue: r.value.is_active,
|
|
550
|
+
"onUpdate:modelValue": c[6] || (c[6] = (x) => r.value.is_active = x),
|
|
551
|
+
label: e(p)("admins.active")
|
|
531
552
|
}, null, 8, ["modelValue", "label"]),
|
|
532
|
-
|
|
533
|
-
modelValue:
|
|
534
|
-
"onUpdate:modelValue":
|
|
535
|
-
label: e(
|
|
553
|
+
t(e(be), {
|
|
554
|
+
modelValue: r.value.is_super,
|
|
555
|
+
"onUpdate:modelValue": c[7] || (c[7] = (x) => r.value.is_super = x),
|
|
556
|
+
label: e(p)("admins.super")
|
|
536
557
|
}, null, 8, ["modelValue", "label"])
|
|
537
558
|
]),
|
|
538
559
|
_: 1
|
|
539
560
|
}),
|
|
540
|
-
|
|
561
|
+
t(e(de), {
|
|
541
562
|
size: "sm",
|
|
542
563
|
tone: "muted"
|
|
543
564
|
}, {
|
|
544
565
|
default: l(() => [
|
|
545
|
-
|
|
566
|
+
F($(e(p)("admins.super-hint")), 1)
|
|
546
567
|
]),
|
|
547
568
|
_: 1
|
|
548
569
|
})
|
|
@@ -553,7 +574,7 @@ const qe = { class: "wx-admin-form" }, He = { class: "wx-admin-form__grid" }, Ye
|
|
|
553
574
|
_: 1
|
|
554
575
|
}, 8, ["open", "title"]));
|
|
555
576
|
}
|
|
556
|
-
}),
|
|
577
|
+
}), ea = { class: "wx-admin-list" }, Ce = /* @__PURE__ */ R({
|
|
557
578
|
__name: "AdminList",
|
|
558
579
|
props: {
|
|
559
580
|
picking: { type: Boolean, default: !1 },
|
|
@@ -564,25 +585,25 @@ const qe = { class: "wx-admin-form" }, He = { class: "wx-admin-form__grid" }, Ye
|
|
|
564
585
|
},
|
|
565
586
|
emits: ["open", "chosen", "selection", "remove"],
|
|
566
587
|
setup(a, { expose: i, emit: s }) {
|
|
567
|
-
const
|
|
568
|
-
|
|
569
|
-
const
|
|
570
|
-
let
|
|
571
|
-
const
|
|
572
|
-
{ value: "all", label:
|
|
573
|
-
...
|
|
574
|
-
]),
|
|
575
|
-
{ value: "any", label:
|
|
576
|
-
{ value: "yes", label:
|
|
577
|
-
{ value: "no", label:
|
|
578
|
-
]),
|
|
579
|
-
{ key: "name", label:
|
|
580
|
-
{ key: "email", label:
|
|
581
|
-
{ key: "roles", label:
|
|
582
|
-
{ key: "is_active", label:
|
|
588
|
+
const o = a, u = s, k = q(), m = pe(k);
|
|
589
|
+
J();
|
|
590
|
+
const n = I("webx-auth"), p = g(null), C = g([]), V = g(!1), d = g("all"), w = g("any"), r = g([]), b = g({});
|
|
591
|
+
let _ = { page: 1, perPage: 20, sort: null, search: "" };
|
|
592
|
+
const f = P(() => [
|
|
593
|
+
{ value: "all", label: n("admins.all-roles") },
|
|
594
|
+
...C.value.map((A) => ({ value: A.slug, label: A.name }))
|
|
595
|
+
]), U = P(() => [
|
|
596
|
+
{ value: "any", label: n("admins.any-state") },
|
|
597
|
+
{ value: "yes", label: n("admins.only-active") },
|
|
598
|
+
{ value: "no", label: n("admins.only-inactive") }
|
|
599
|
+
]), W = P(() => [
|
|
600
|
+
{ key: "name", label: n("admins.name"), sortable: !0 },
|
|
601
|
+
{ key: "email", label: n("admins.email"), sortable: !0, hideBelow: 560 },
|
|
602
|
+
{ key: "roles", label: n("admins.roles"), hideBelow: 760 },
|
|
603
|
+
{ key: "is_active", label: n("admins.active"), align: "center", hideBelow: 660 },
|
|
583
604
|
{
|
|
584
605
|
key: "last_login_at",
|
|
585
|
-
label:
|
|
606
|
+
label: n("admins.last-login"),
|
|
586
607
|
sortable: !0,
|
|
587
608
|
hideBelow: 900,
|
|
588
609
|
// The first thing to go when a row becomes a card: it is a date somebody scans down a
|
|
@@ -594,188 +615,176 @@ const qe = { class: "wx-admin-form" }, He = { class: "wx-admin-form__grid" }, Ye
|
|
|
594
615
|
label: "",
|
|
595
616
|
width: 56,
|
|
596
617
|
align: "right",
|
|
597
|
-
hidden: !
|
|
618
|
+
hidden: !o.removable,
|
|
598
619
|
// A card puts them along its top instead, through the `card-actions` slot.
|
|
599
620
|
hideOnCards: !0
|
|
600
621
|
}
|
|
601
622
|
]);
|
|
602
|
-
|
|
603
|
-
async function
|
|
604
|
-
|
|
623
|
+
m.roles().then((A) => C.value = A), Z([d, w], () => z(_));
|
|
624
|
+
async function z(A) {
|
|
625
|
+
_ = A, V.value = !0;
|
|
605
626
|
try {
|
|
606
|
-
|
|
607
|
-
q:
|
|
627
|
+
p.value = await m.list({
|
|
628
|
+
q: A.search,
|
|
608
629
|
role: d.value === "all" ? null : d.value,
|
|
609
|
-
active:
|
|
610
|
-
sort:
|
|
611
|
-
page:
|
|
612
|
-
per_page:
|
|
613
|
-
}),
|
|
630
|
+
active: w.value === "any" ? null : w.value,
|
|
631
|
+
sort: A.sort ? `${A.sort.order === "desc" ? "-" : ""}${A.sort.key}` : "name",
|
|
632
|
+
page: A.page,
|
|
633
|
+
per_page: A.perPage
|
|
634
|
+
}), h();
|
|
614
635
|
} finally {
|
|
615
|
-
|
|
636
|
+
V.value = !1;
|
|
616
637
|
}
|
|
617
638
|
}
|
|
618
|
-
async function
|
|
619
|
-
const
|
|
620
|
-
if (
|
|
621
|
-
for (const
|
|
622
|
-
if (!
|
|
623
|
-
const
|
|
624
|
-
|
|
639
|
+
async function h() {
|
|
640
|
+
const A = o.resolveAvatar;
|
|
641
|
+
if (A)
|
|
642
|
+
for (const y of p.value?.data ?? []) {
|
|
643
|
+
if (!y.avatar || b.value[y.avatar]) continue;
|
|
644
|
+
const v = await A(y.avatar);
|
|
645
|
+
v && (b.value = { ...b.value, [y.avatar]: v });
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
function c(A) {
|
|
649
|
+
return [
|
|
650
|
+
{
|
|
651
|
+
key: "delete",
|
|
652
|
+
icon: "trash",
|
|
653
|
+
label: n("admins.delete"),
|
|
654
|
+
danger: !0,
|
|
655
|
+
run: () => u("remove", A)
|
|
625
656
|
}
|
|
657
|
+
];
|
|
626
658
|
}
|
|
627
|
-
function
|
|
628
|
-
if (
|
|
629
|
-
|
|
659
|
+
function x(A) {
|
|
660
|
+
if (o.picking) {
|
|
661
|
+
u("chosen", [A]);
|
|
630
662
|
return;
|
|
631
663
|
}
|
|
632
|
-
|
|
664
|
+
u("open", A);
|
|
633
665
|
}
|
|
634
|
-
|
|
635
|
-
|
|
666
|
+
const Q = P(() => !(o.picking && o.multiple));
|
|
667
|
+
function H(A, y) {
|
|
668
|
+
r.value = y, u("selection", y);
|
|
636
669
|
}
|
|
637
|
-
return i({ reload: () =>
|
|
638
|
-
|
|
639
|
-
data:
|
|
640
|
-
columns:
|
|
670
|
+
return i({ reload: () => z(_), chosen: () => r.value }), (A, y) => (L(), O("div", ea, [
|
|
671
|
+
t(e(Oe), {
|
|
672
|
+
data: p.value,
|
|
673
|
+
columns: W.value,
|
|
641
674
|
"row-key": "id",
|
|
642
675
|
searchable: "",
|
|
643
|
-
|
|
676
|
+
clickable: Q.value,
|
|
677
|
+
hover: Q.value,
|
|
644
678
|
flush: "",
|
|
645
|
-
loading:
|
|
646
|
-
"search-placeholder": e(
|
|
647
|
-
"empty-text": e(
|
|
679
|
+
loading: V.value,
|
|
680
|
+
"search-placeholder": e(n)("admins.search"),
|
|
681
|
+
"empty-text": e(n)("admins.empty"),
|
|
648
682
|
selectable: a.picking && a.multiple,
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
onSelectionChange:
|
|
683
|
+
onRowClick: x,
|
|
684
|
+
onStateChange: z,
|
|
685
|
+
onSelectionChange: H
|
|
652
686
|
}, ne({
|
|
653
|
-
"cell-name": l(({ row:
|
|
654
|
-
|
|
687
|
+
"cell-name": l(({ row: v }) => [
|
|
688
|
+
t(e(Y), {
|
|
655
689
|
size: "sm",
|
|
656
690
|
align: "center"
|
|
657
691
|
}, {
|
|
658
692
|
default: l(() => [
|
|
659
|
-
|
|
660
|
-
name:
|
|
661
|
-
src:
|
|
693
|
+
t(e(De), {
|
|
694
|
+
name: v.name,
|
|
695
|
+
src: v.avatar ? b.value[v.avatar] : void 0,
|
|
662
696
|
size: "sm"
|
|
663
697
|
}, null, 8, ["name", "src"]),
|
|
664
|
-
|
|
665
|
-
|
|
698
|
+
N("span", null, $(v.name), 1),
|
|
699
|
+
v.is_super ? (L(), S(e(ae), {
|
|
666
700
|
key: 0,
|
|
667
701
|
type: "warning"
|
|
668
702
|
}, {
|
|
669
703
|
default: l(() => [
|
|
670
|
-
|
|
704
|
+
F($(e(n)("admins.super")), 1)
|
|
671
705
|
]),
|
|
672
706
|
_: 1
|
|
673
|
-
})) :
|
|
707
|
+
})) : T("", !0)
|
|
674
708
|
]),
|
|
675
709
|
_: 2
|
|
676
710
|
}, 1024)
|
|
677
711
|
]),
|
|
678
|
-
"cell-roles": l(({ row:
|
|
679
|
-
|
|
712
|
+
"cell-roles": l(({ row: v }) => [
|
|
713
|
+
v.roles.length > 0 ? (L(), S(e(Y), {
|
|
680
714
|
key: 0,
|
|
681
715
|
size: "xs",
|
|
682
716
|
wrap: ""
|
|
683
717
|
}, {
|
|
684
718
|
default: l(() => [
|
|
685
|
-
(
|
|
686
|
-
key:
|
|
719
|
+
(L(!0), O(le, null, _e(v.roles, (G) => (L(), S(e(ae), {
|
|
720
|
+
key: G.id
|
|
687
721
|
}, {
|
|
688
722
|
default: l(() => [
|
|
689
|
-
|
|
723
|
+
F($(G.name), 1)
|
|
690
724
|
]),
|
|
691
725
|
_: 2
|
|
692
726
|
}, 1024))), 128))
|
|
693
727
|
]),
|
|
694
728
|
_: 2
|
|
695
|
-
}, 1024)) : (
|
|
729
|
+
}, 1024)) : (L(), S(e(de), {
|
|
696
730
|
key: 1,
|
|
697
731
|
size: "sm",
|
|
698
732
|
tone: "muted"
|
|
699
733
|
}, {
|
|
700
734
|
default: l(() => [
|
|
701
|
-
|
|
735
|
+
F($(e(n)("admins.no-roles")), 1)
|
|
702
736
|
]),
|
|
703
737
|
_: 1
|
|
704
738
|
}))
|
|
705
739
|
]),
|
|
706
|
-
"cell-is_active": l(({ row:
|
|
707
|
-
|
|
708
|
-
type:
|
|
740
|
+
"cell-is_active": l(({ row: v }) => [
|
|
741
|
+
t(e(ae), {
|
|
742
|
+
type: v.is_active ? "success" : "default",
|
|
709
743
|
dot: ""
|
|
710
744
|
}, {
|
|
711
745
|
default: l(() => [
|
|
712
|
-
|
|
746
|
+
F($(v.is_active ? e(n)("admins.active") : e(n)("admins.only-inactive")), 1)
|
|
713
747
|
]),
|
|
714
748
|
_: 2
|
|
715
749
|
}, 1032, ["type"])
|
|
716
750
|
]),
|
|
717
|
-
"card-actions": l(({ row:
|
|
718
|
-
a.removable ? (
|
|
751
|
+
"card-actions": l(({ row: v }) => [
|
|
752
|
+
a.removable ? (L(), S(e(he), {
|
|
719
753
|
key: 0,
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
}, {
|
|
724
|
-
default: l(() => [
|
|
725
|
-
o(e(me), {
|
|
726
|
-
type: "remove",
|
|
727
|
-
title: e(u)("admins.delete"),
|
|
728
|
-
onClick: (g) => r("remove", f)
|
|
729
|
-
}, null, 8, ["title", "onClick"])
|
|
730
|
-
]),
|
|
731
|
-
_: 2
|
|
732
|
-
}, 1024)) : P("", !0)
|
|
754
|
+
actions: c(v),
|
|
755
|
+
label: v.name
|
|
756
|
+
}, null, 8, ["actions", "label"])) : T("", !0)
|
|
733
757
|
]),
|
|
734
|
-
"cell-actions": l(({ row:
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
}, {
|
|
740
|
-
default: l(() => [
|
|
741
|
-
o(e(me), {
|
|
742
|
-
type: "remove",
|
|
743
|
-
title: e(u)("admins.delete"),
|
|
744
|
-
onClick: (g) => r("remove", f)
|
|
745
|
-
}, null, 8, ["title", "onClick"])
|
|
746
|
-
]),
|
|
747
|
-
_: 2
|
|
748
|
-
}, 1024)
|
|
758
|
+
"cell-actions": l(({ row: v }) => [
|
|
759
|
+
t(e(he), {
|
|
760
|
+
actions: c(v),
|
|
761
|
+
label: v.name
|
|
762
|
+
}, null, 8, ["actions", "label"])
|
|
749
763
|
]),
|
|
750
|
-
"cell-last_login_at": l(({ row:
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
tone:
|
|
754
|
-
},
|
|
755
|
-
default: l(() => [
|
|
756
|
-
L(C(f.last_login_at ? new Date(f.last_login_at).toLocaleString() : e(u)("admins.never")), 1)
|
|
757
|
-
]),
|
|
758
|
-
_: 2
|
|
759
|
-
}, 1032, ["tone"])
|
|
764
|
+
"cell-last_login_at": l(({ row: v }) => [
|
|
765
|
+
t(e(Ne), {
|
|
766
|
+
value: v.last_login_at,
|
|
767
|
+
tone: v.last_login_at ? "default" : "muted"
|
|
768
|
+
}, null, 8, ["value", "tone"])
|
|
760
769
|
]),
|
|
761
770
|
_: 2
|
|
762
771
|
}, [
|
|
763
772
|
a.filters ? {
|
|
764
773
|
name: "actions",
|
|
765
774
|
fn: l(() => [
|
|
766
|
-
|
|
775
|
+
t(e(Y), { size: "sm" }, {
|
|
767
776
|
default: l(() => [
|
|
768
|
-
|
|
777
|
+
t(e(X), {
|
|
769
778
|
modelValue: d.value,
|
|
770
|
-
"onUpdate:modelValue":
|
|
771
|
-
options:
|
|
779
|
+
"onUpdate:modelValue": y[0] || (y[0] = (v) => d.value = v),
|
|
780
|
+
options: f.value,
|
|
772
781
|
size: "sm",
|
|
773
782
|
style: { width: "180px" }
|
|
774
783
|
}, null, 8, ["modelValue", "options"]),
|
|
775
|
-
|
|
776
|
-
modelValue:
|
|
777
|
-
"onUpdate:modelValue":
|
|
778
|
-
options:
|
|
784
|
+
t(e(X), {
|
|
785
|
+
modelValue: w.value,
|
|
786
|
+
"onUpdate:modelValue": y[1] || (y[1] = (v) => w.value = v),
|
|
787
|
+
options: U.value,
|
|
779
788
|
size: "sm",
|
|
780
789
|
style: { width: "180px" }
|
|
781
790
|
}, null, 8, ["modelValue", "options"])
|
|
@@ -785,73 +794,71 @@ const qe = { class: "wx-admin-form" }, He = { class: "wx-admin-form__grid" }, Ye
|
|
|
785
794
|
]),
|
|
786
795
|
key: "0"
|
|
787
796
|
} : void 0
|
|
788
|
-
]), 1032, ["data", "columns", "loading", "search-placeholder", "empty-text", "selectable"])
|
|
797
|
+
]), 1032, ["data", "columns", "clickable", "hover", "loading", "search-placeholder", "empty-text", "selectable"])
|
|
789
798
|
]));
|
|
790
799
|
}
|
|
791
|
-
}),
|
|
800
|
+
}), aa = /* @__PURE__ */ R({
|
|
792
801
|
__name: "AdminsPage",
|
|
793
802
|
props: {
|
|
794
803
|
avatarField: { default: void 0 },
|
|
795
804
|
resolveAvatar: { type: Function, default: void 0 }
|
|
796
805
|
},
|
|
797
806
|
setup(a) {
|
|
798
|
-
const i = a, s = q(),
|
|
799
|
-
|
|
800
|
-
const
|
|
801
|
-
|
|
802
|
-
|
|
807
|
+
const i = a, s = q(), o = pe(s);
|
|
808
|
+
J();
|
|
809
|
+
const u = I("webx-auth"), k = re(), m = oe("list"), n = g(null), p = ce(Ze), C = s.can("admins.manage"), V = P(
|
|
810
|
+
() => s.state.manifest?.modules.find((r) => r.id === "admins")?.title ?? u("admins.title")
|
|
811
|
+
);
|
|
812
|
+
async function d(r) {
|
|
813
|
+
n.value = r, await p({ admin: r, avatarField: i.avatarField }) && m.value?.reload();
|
|
803
814
|
}
|
|
804
|
-
async function
|
|
805
|
-
if (await
|
|
806
|
-
title:
|
|
807
|
-
message:
|
|
808
|
-
confirmText:
|
|
809
|
-
cancelText:
|
|
815
|
+
async function w(r) {
|
|
816
|
+
if (await Re({
|
|
817
|
+
title: u("admins.delete-title", { name: r.name }),
|
|
818
|
+
message: u("admins.delete-text"),
|
|
819
|
+
confirmText: u("admins.delete"),
|
|
820
|
+
cancelText: u("admins.cancel"),
|
|
810
821
|
tone: "danger"
|
|
811
822
|
}))
|
|
812
823
|
try {
|
|
813
|
-
await
|
|
814
|
-
} catch (
|
|
815
|
-
|
|
816
|
-
G.danger(A?.message ?? r("errors.forbidden"));
|
|
824
|
+
await o.remove(r.id), j.success(u("admins.deleted")), m.value?.reload();
|
|
825
|
+
} catch (_) {
|
|
826
|
+
j.danger(k(_));
|
|
817
827
|
}
|
|
818
828
|
}
|
|
819
|
-
return (
|
|
820
|
-
header: l(() => [
|
|
821
|
-
L(C(e(r)("admins.title")), 1)
|
|
822
|
-
]),
|
|
829
|
+
return (r, b) => (L(), S(e(Ee), { title: V.value }, ne({
|
|
823
830
|
default: l(() => [
|
|
824
|
-
|
|
831
|
+
t(Ce, {
|
|
825
832
|
ref_key: "list",
|
|
826
|
-
ref:
|
|
827
|
-
removable: e(
|
|
833
|
+
ref: m,
|
|
834
|
+
removable: e(C),
|
|
828
835
|
"resolve-avatar": i.resolveAvatar,
|
|
829
|
-
onOpen:
|
|
830
|
-
onRemove:
|
|
836
|
+
onOpen: d,
|
|
837
|
+
onRemove: w
|
|
831
838
|
}, null, 8, ["removable", "resolve-avatar"])
|
|
832
839
|
]),
|
|
833
840
|
_: 2
|
|
834
841
|
}, [
|
|
835
|
-
e(
|
|
836
|
-
name: "
|
|
842
|
+
e(C) ? {
|
|
843
|
+
name: "actions",
|
|
837
844
|
fn: l(() => [
|
|
838
|
-
|
|
845
|
+
t(e(D), {
|
|
839
846
|
type: "primary",
|
|
840
847
|
icon: "add",
|
|
841
|
-
onClick:
|
|
848
|
+
onClick: b[0] || (b[0] = (_) => d(null))
|
|
842
849
|
}, {
|
|
843
850
|
default: l(() => [
|
|
844
|
-
|
|
851
|
+
F($(e(u)("admins.new-short")), 1)
|
|
845
852
|
]),
|
|
846
853
|
_: 1
|
|
847
854
|
})
|
|
848
855
|
]),
|
|
849
856
|
key: "0"
|
|
850
857
|
} : void 0
|
|
851
|
-
]),
|
|
858
|
+
]), 1032, ["title"]));
|
|
852
859
|
}
|
|
853
860
|
});
|
|
854
|
-
function
|
|
861
|
+
function fa(a = {}) {
|
|
855
862
|
const i = a.path ?? "/admins";
|
|
856
863
|
return {
|
|
857
864
|
id: "admins",
|
|
@@ -861,7 +868,7 @@ function na(a = {}) {
|
|
|
861
868
|
path: i,
|
|
862
869
|
name: "webx.admins",
|
|
863
870
|
component: {
|
|
864
|
-
render: () =>
|
|
871
|
+
render: () => xe(aa, {
|
|
865
872
|
avatarField: a.avatarField,
|
|
866
873
|
resolveAvatar: a.resolveAvatar
|
|
867
874
|
})
|
|
@@ -870,7 +877,7 @@ function na(a = {}) {
|
|
|
870
877
|
]
|
|
871
878
|
};
|
|
872
879
|
}
|
|
873
|
-
const
|
|
880
|
+
const ta = /* @__PURE__ */ R({
|
|
874
881
|
__name: "AdminPicker",
|
|
875
882
|
props: {
|
|
876
883
|
multiple: { type: Boolean, default: !1 },
|
|
@@ -878,30 +885,30 @@ const Ze = /* @__PURE__ */ R({
|
|
|
878
885
|
resolveAvatar: { type: Function, default: void 0 }
|
|
879
886
|
},
|
|
880
887
|
setup(a) {
|
|
881
|
-
const i = a, { open: s, resolve:
|
|
882
|
-
|
|
883
|
-
const
|
|
884
|
-
function
|
|
885
|
-
|
|
888
|
+
const i = a, { open: s, resolve: o, dismiss: u } = ie();
|
|
889
|
+
J();
|
|
890
|
+
const k = I("webx-auth"), m = oe("list"), n = g(0);
|
|
891
|
+
function p(V) {
|
|
892
|
+
o(V);
|
|
886
893
|
}
|
|
887
|
-
function V
|
|
888
|
-
|
|
894
|
+
function C(V) {
|
|
895
|
+
n.value = V.length;
|
|
889
896
|
}
|
|
890
|
-
return (
|
|
897
|
+
return (V, d) => (L(), S(e(ue), {
|
|
891
898
|
open: e(s),
|
|
892
|
-
"onUpdate:open": d[2] || (d[2] = (
|
|
893
|
-
title: a.title ?? e(
|
|
899
|
+
"onUpdate:open": d[2] || (d[2] = (w) => se(s) ? s.value = w : null),
|
|
900
|
+
title: a.title ?? e(k)(a.multiple ? "admins.select-many" : "admins.select-one"),
|
|
894
901
|
width: 880
|
|
895
902
|
}, ne({
|
|
896
903
|
default: l(() => [
|
|
897
|
-
|
|
904
|
+
t(Ce, {
|
|
898
905
|
ref_key: "list",
|
|
899
|
-
ref:
|
|
906
|
+
ref: m,
|
|
900
907
|
picking: "",
|
|
901
908
|
multiple: a.multiple,
|
|
902
909
|
"resolve-avatar": i.resolveAvatar,
|
|
903
|
-
onChosen:
|
|
904
|
-
onSelection:
|
|
910
|
+
onChosen: p,
|
|
911
|
+
onSelection: C
|
|
905
912
|
}, null, 8, ["multiple", "resolve-avatar"])
|
|
906
913
|
]),
|
|
907
914
|
_: 2
|
|
@@ -909,36 +916,36 @@ const Ze = /* @__PURE__ */ R({
|
|
|
909
916
|
a.multiple ? {
|
|
910
917
|
name: "footer",
|
|
911
918
|
fn: l(() => [
|
|
912
|
-
|
|
919
|
+
t(e(Y), {
|
|
913
920
|
size: "sm",
|
|
914
921
|
align: "center"
|
|
915
922
|
}, {
|
|
916
923
|
default: l(() => [
|
|
917
|
-
|
|
924
|
+
t(e(de), {
|
|
918
925
|
size: "sm",
|
|
919
926
|
tone: "muted"
|
|
920
927
|
}, {
|
|
921
928
|
default: l(() => [
|
|
922
|
-
|
|
929
|
+
F($(e(k)("admins.chosen", { count: n.value })), 1)
|
|
923
930
|
]),
|
|
924
931
|
_: 1
|
|
925
932
|
}),
|
|
926
|
-
|
|
933
|
+
t(e(D), {
|
|
927
934
|
variant: "outline",
|
|
928
|
-
onClick: d[0] || (d[0] = (
|
|
935
|
+
onClick: d[0] || (d[0] = (w) => e(u)())
|
|
929
936
|
}, {
|
|
930
937
|
default: l(() => [
|
|
931
|
-
|
|
938
|
+
F($(e(k)("admins.cancel")), 1)
|
|
932
939
|
]),
|
|
933
940
|
_: 1
|
|
934
941
|
}),
|
|
935
|
-
|
|
942
|
+
t(e(D), {
|
|
936
943
|
type: "primary",
|
|
937
|
-
disabled:
|
|
938
|
-
onClick: d[1] || (d[1] = (
|
|
944
|
+
disabled: n.value === 0,
|
|
945
|
+
onClick: d[1] || (d[1] = (w) => e(o)(m.value?.chosen() ?? []))
|
|
939
946
|
}, {
|
|
940
947
|
default: l(() => [
|
|
941
|
-
|
|
948
|
+
F($(e(k)("admins.save")), 1)
|
|
942
949
|
]),
|
|
943
950
|
_: 1
|
|
944
951
|
}, 8, ["disabled"])
|
|
@@ -950,131 +957,294 @@ const Ze = /* @__PURE__ */ R({
|
|
|
950
957
|
} : void 0
|
|
951
958
|
]), 1032, ["open", "title"]));
|
|
952
959
|
}
|
|
953
|
-
}),
|
|
954
|
-
async function
|
|
955
|
-
return (await
|
|
960
|
+
}), Ue = ce(ta);
|
|
961
|
+
async function wa(a = {}) {
|
|
962
|
+
return (await Ue({ ...a, multiple: !1 }))?.[0];
|
|
956
963
|
}
|
|
957
|
-
function
|
|
958
|
-
return
|
|
964
|
+
function ha(a = {}) {
|
|
965
|
+
return Ue({ ...a, multiple: !0 });
|
|
959
966
|
}
|
|
960
|
-
const
|
|
967
|
+
const la = { class: "wx-profile-host" }, oa = { class: "wx-profile" }, sa = {
|
|
968
|
+
key: 0,
|
|
969
|
+
class: "wx-profile__aside"
|
|
970
|
+
}, na = { class: "wx-profile__fields" }, ra = /* @__PURE__ */ R({
|
|
971
|
+
__name: "ProfileDialog",
|
|
972
|
+
props: {
|
|
973
|
+
avatarField: { default: void 0 }
|
|
974
|
+
},
|
|
975
|
+
setup(a) {
|
|
976
|
+
const i = a, { resolve: s, dismiss: o, open: u } = ie(), k = q(), m = me();
|
|
977
|
+
J();
|
|
978
|
+
const n = I("webx-auth"), p = re(), C = g(!1), V = g({}), d = g({
|
|
979
|
+
name: k.state.user?.name ?? "",
|
|
980
|
+
avatar: k.state.user?.avatar ?? null,
|
|
981
|
+
password: "",
|
|
982
|
+
current_password: ""
|
|
983
|
+
}), w = g(d.value.avatar ? { path: d.value.avatar } : null);
|
|
984
|
+
function r(_) {
|
|
985
|
+
return V.value[_]?.[0];
|
|
986
|
+
}
|
|
987
|
+
async function b() {
|
|
988
|
+
C.value = !0, V.value = {};
|
|
989
|
+
try {
|
|
990
|
+
await m.updateProfile({
|
|
991
|
+
name: d.value.name,
|
|
992
|
+
avatar: w.value?.path ?? null,
|
|
993
|
+
// Blank is left out entirely rather than sent as an empty string: the server reads a
|
|
994
|
+
// filled password as "change it", and an empty one would be a change to nothing.
|
|
995
|
+
...d.value.password ? { password: d.value.password, current_password: d.value.current_password } : {}
|
|
996
|
+
}), j.success(n("profile.saved")), s(!0);
|
|
997
|
+
} catch (_) {
|
|
998
|
+
const f = _.body;
|
|
999
|
+
f?.errors ? V.value = f.errors : j.danger(p(_));
|
|
1000
|
+
} finally {
|
|
1001
|
+
C.value = !1;
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
return (_, f) => (L(), S(e(ue), {
|
|
1005
|
+
open: e(u),
|
|
1006
|
+
"onUpdate:open": f[5] || (f[5] = (U) => se(u) ? u.value = U : null),
|
|
1007
|
+
title: e(n)("profile.title"),
|
|
1008
|
+
width: 560
|
|
1009
|
+
}, {
|
|
1010
|
+
footer: l(() => [
|
|
1011
|
+
t(e(D), {
|
|
1012
|
+
onClick: f[4] || (f[4] = (U) => e(o)())
|
|
1013
|
+
}, {
|
|
1014
|
+
default: l(() => [
|
|
1015
|
+
F($(e(n)("profile.cancel")), 1)
|
|
1016
|
+
]),
|
|
1017
|
+
_: 1
|
|
1018
|
+
}),
|
|
1019
|
+
t(e(D), {
|
|
1020
|
+
type: "primary",
|
|
1021
|
+
loading: C.value,
|
|
1022
|
+
onClick: b
|
|
1023
|
+
}, {
|
|
1024
|
+
default: l(() => [
|
|
1025
|
+
F($(e(n)("profile.save")), 1)
|
|
1026
|
+
]),
|
|
1027
|
+
_: 1
|
|
1028
|
+
}, 8, ["loading"])
|
|
1029
|
+
]),
|
|
1030
|
+
default: l(() => [
|
|
1031
|
+
N("div", la, [
|
|
1032
|
+
N("div", oa, [
|
|
1033
|
+
i.avatarField ? (L(), O("div", sa, [
|
|
1034
|
+
(L(), S(ge(i.avatarField), {
|
|
1035
|
+
modelValue: w.value,
|
|
1036
|
+
"onUpdate:modelValue": f[0] || (f[0] = (U) => w.value = U),
|
|
1037
|
+
label: e(n)("profile.avatar"),
|
|
1038
|
+
aspect: "1/1",
|
|
1039
|
+
captions: !1
|
|
1040
|
+
}, null, 8, ["modelValue", "label"]))
|
|
1041
|
+
])) : T("", !0),
|
|
1042
|
+
N("div", na, [
|
|
1043
|
+
t(e(M), {
|
|
1044
|
+
label: e(n)("profile.name"),
|
|
1045
|
+
error: r("name")
|
|
1046
|
+
}, {
|
|
1047
|
+
default: l(() => [
|
|
1048
|
+
t(e(E), {
|
|
1049
|
+
modelValue: d.value.name,
|
|
1050
|
+
"onUpdate:modelValue": f[1] || (f[1] = (U) => d.value.name = U),
|
|
1051
|
+
name: "name"
|
|
1052
|
+
}, null, 8, ["modelValue"])
|
|
1053
|
+
]),
|
|
1054
|
+
_: 1
|
|
1055
|
+
}, 8, ["label", "error"]),
|
|
1056
|
+
t(e(M), {
|
|
1057
|
+
label: e(n)("admins.email")
|
|
1058
|
+
}, {
|
|
1059
|
+
default: l(() => [
|
|
1060
|
+
t(e(E), {
|
|
1061
|
+
"model-value": e(k).state.user?.email ?? "",
|
|
1062
|
+
readonly: ""
|
|
1063
|
+
}, null, 8, ["model-value"])
|
|
1064
|
+
]),
|
|
1065
|
+
_: 1
|
|
1066
|
+
}, 8, ["label"]),
|
|
1067
|
+
t(e(M), {
|
|
1068
|
+
label: e(n)("profile.password"),
|
|
1069
|
+
help: e(n)("profile.password-hint"),
|
|
1070
|
+
error: r("password")
|
|
1071
|
+
}, {
|
|
1072
|
+
default: l(() => [
|
|
1073
|
+
t(e(E), {
|
|
1074
|
+
modelValue: d.value.password,
|
|
1075
|
+
"onUpdate:modelValue": f[2] || (f[2] = (U) => d.value.password = U),
|
|
1076
|
+
type: "password",
|
|
1077
|
+
autocomplete: "new-password"
|
|
1078
|
+
}, null, 8, ["modelValue"])
|
|
1079
|
+
]),
|
|
1080
|
+
_: 1
|
|
1081
|
+
}, 8, ["label", "help", "error"]),
|
|
1082
|
+
d.value.password ? (L(), S(e(M), {
|
|
1083
|
+
key: 0,
|
|
1084
|
+
label: e(n)("profile.current-password"),
|
|
1085
|
+
help: e(n)("profile.current-password-hint"),
|
|
1086
|
+
error: r("current_password")
|
|
1087
|
+
}, {
|
|
1088
|
+
default: l(() => [
|
|
1089
|
+
t(e(E), {
|
|
1090
|
+
modelValue: d.value.current_password,
|
|
1091
|
+
"onUpdate:modelValue": f[3] || (f[3] = (U) => d.value.current_password = U),
|
|
1092
|
+
type: "password",
|
|
1093
|
+
autocomplete: "current-password"
|
|
1094
|
+
}, null, 8, ["modelValue"])
|
|
1095
|
+
]),
|
|
1096
|
+
_: 1
|
|
1097
|
+
}, 8, ["label", "help", "error"])) : T("", !0)
|
|
1098
|
+
])
|
|
1099
|
+
])
|
|
1100
|
+
])
|
|
1101
|
+
]),
|
|
1102
|
+
_: 1
|
|
1103
|
+
}, 8, ["open", "title"]));
|
|
1104
|
+
}
|
|
1105
|
+
}), ia = /* @__PURE__ */ ve(ra, [["__scopeId", "data-v-9583a67a"]]), ua = ["title"], da = {
|
|
1106
|
+
key: 0,
|
|
1107
|
+
class: "wx-user-menu__name"
|
|
1108
|
+
}, ca = /* @__PURE__ */ R({
|
|
961
1109
|
__name: "UserMenu",
|
|
962
1110
|
props: {
|
|
963
1111
|
signOutLabel: { default: void 0 },
|
|
964
|
-
resolveAvatar: { type: Function, default: void 0 }
|
|
1112
|
+
resolveAvatar: { type: Function, default: void 0 },
|
|
1113
|
+
avatarField: { default: void 0 },
|
|
1114
|
+
expanded: { type: Boolean, default: !1 }
|
|
965
1115
|
},
|
|
966
1116
|
setup(a) {
|
|
967
|
-
const i = a, s = q(),
|
|
968
|
-
() =>
|
|
969
|
-
),
|
|
970
|
-
|
|
971
|
-
() => typeof
|
|
972
|
-
async (
|
|
973
|
-
const
|
|
974
|
-
if (
|
|
1117
|
+
const i = a, s = q(), o = me(), u = ke(), k = I("webx-auth"), m = P(() => s.state.user), n = P(
|
|
1118
|
+
() => u.state.panelLocales.length > 1 ? u.state.panelLocales : []
|
|
1119
|
+
), p = te(Ae, null), C = te(Le, null), V = g(void 0);
|
|
1120
|
+
Z(
|
|
1121
|
+
() => typeof m.value?.avatar == "string" ? m.value.avatar : null,
|
|
1122
|
+
async (b) => {
|
|
1123
|
+
const _ = i.resolveAvatar ?? p;
|
|
1124
|
+
if (b === null || b === "" || _ === null) {
|
|
975
1125
|
V.value = void 0;
|
|
976
1126
|
return;
|
|
977
1127
|
}
|
|
978
|
-
const
|
|
979
|
-
|
|
1128
|
+
const f = await _(b);
|
|
1129
|
+
m.value?.avatar === b && (V.value = f ?? void 0);
|
|
980
1130
|
},
|
|
981
1131
|
{ immediate: !0 }
|
|
982
1132
|
);
|
|
983
|
-
|
|
984
|
-
|
|
1133
|
+
const d = ce(ia);
|
|
1134
|
+
function w() {
|
|
1135
|
+
setTimeout(
|
|
1136
|
+
() => {
|
|
1137
|
+
d({ avatarField: i.avatarField ?? C ?? void 0 });
|
|
1138
|
+
},
|
|
1139
|
+
0
|
|
1140
|
+
);
|
|
985
1141
|
}
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
1142
|
+
async function r(b) {
|
|
1143
|
+
b !== u.state.locale && await o.setLocale(b);
|
|
1144
|
+
}
|
|
1145
|
+
return (b, _) => {
|
|
1146
|
+
const f = B("wx-avatar"), U = B("wx-text"), W = B("wx-dropdown-item"), z = B("wx-divider"), h = B("wx-dropdown");
|
|
1147
|
+
return m.value !== null ? (L(), S(h, { key: 0 }, {
|
|
989
1148
|
trigger: l(() => [
|
|
990
|
-
|
|
1149
|
+
N("button", {
|
|
991
1150
|
type: "button",
|
|
992
|
-
class: "wx-user-menu__trigger",
|
|
993
|
-
title:
|
|
1151
|
+
class: Te(["wx-user-menu__trigger", { "wx-user-menu__trigger--named": a.expanded }]),
|
|
1152
|
+
title: m.value.name
|
|
994
1153
|
}, [
|
|
995
|
-
|
|
996
|
-
name:
|
|
1154
|
+
t(f, {
|
|
1155
|
+
name: m.value.name,
|
|
997
1156
|
src: V.value,
|
|
998
1157
|
size: "lg"
|
|
999
|
-
}, null, 8, ["name", "src"])
|
|
1000
|
-
|
|
1158
|
+
}, null, 8, ["name", "src"]),
|
|
1159
|
+
a.expanded ? (L(), O("span", da, $(m.value.name), 1)) : T("", !0)
|
|
1160
|
+
], 10, ua)
|
|
1001
1161
|
]),
|
|
1002
1162
|
default: l(() => [
|
|
1003
|
-
|
|
1163
|
+
t(W, { disabled: "" }, {
|
|
1004
1164
|
default: l(() => [
|
|
1005
|
-
|
|
1165
|
+
t(U, { size: "sm" }, {
|
|
1006
1166
|
default: l(() => [
|
|
1007
|
-
|
|
1167
|
+
F($(m.value.email), 1)
|
|
1008
1168
|
]),
|
|
1009
1169
|
_: 1
|
|
1010
1170
|
})
|
|
1011
1171
|
]),
|
|
1012
1172
|
_: 1
|
|
1013
1173
|
}),
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1174
|
+
t(z, { spacing: "sm" }),
|
|
1175
|
+
t(W, {
|
|
1176
|
+
icon: "user",
|
|
1177
|
+
onClick: w
|
|
1178
|
+
}, {
|
|
1179
|
+
default: l(() => [
|
|
1180
|
+
F($(e(k)("profile.menu")), 1)
|
|
1181
|
+
]),
|
|
1182
|
+
_: 1
|
|
1183
|
+
}),
|
|
1184
|
+
n.value.length > 0 ? (L(), O(le, { key: 0 }, [
|
|
1185
|
+
t(z, { spacing: "sm" }),
|
|
1186
|
+
t(W, { disabled: "" }, {
|
|
1017
1187
|
default: l(() => [
|
|
1018
|
-
|
|
1188
|
+
t(U, {
|
|
1019
1189
|
size: "sm",
|
|
1020
1190
|
tone: "muted"
|
|
1021
1191
|
}, {
|
|
1022
1192
|
default: l(() => [
|
|
1023
|
-
|
|
1193
|
+
F($(e(k)("menu.language")), 1)
|
|
1024
1194
|
]),
|
|
1025
1195
|
_: 1
|
|
1026
1196
|
})
|
|
1027
1197
|
]),
|
|
1028
1198
|
_: 1
|
|
1029
1199
|
}),
|
|
1030
|
-
(
|
|
1031
|
-
key:
|
|
1032
|
-
icon:
|
|
1033
|
-
onClick: (
|
|
1200
|
+
(L(!0), O(le, null, _e(n.value, (c) => (L(), S(W, {
|
|
1201
|
+
key: c.code,
|
|
1202
|
+
icon: c.code === e(u).state.locale ? "check" : void 0,
|
|
1203
|
+
onClick: (x) => r(c.code)
|
|
1034
1204
|
}, {
|
|
1035
1205
|
default: l(() => [
|
|
1036
|
-
|
|
1206
|
+
F($(c.nativeName), 1)
|
|
1037
1207
|
]),
|
|
1038
1208
|
_: 2
|
|
1039
1209
|
}, 1032, ["icon", "onClick"]))), 128)),
|
|
1040
|
-
|
|
1041
|
-
], 64)) :
|
|
1042
|
-
|
|
1210
|
+
t(z, { spacing: "sm" })
|
|
1211
|
+
], 64)) : T("", !0),
|
|
1212
|
+
t(W, {
|
|
1043
1213
|
icon: "logout",
|
|
1044
|
-
onClick:
|
|
1214
|
+
onClick: _[0] || (_[0] = (c) => e(o).logout())
|
|
1045
1215
|
}, {
|
|
1046
1216
|
default: l(() => [
|
|
1047
|
-
|
|
1217
|
+
F($(a.signOutLabel ?? e(k)("menu.sign-out")), 1)
|
|
1048
1218
|
]),
|
|
1049
1219
|
_: 1
|
|
1050
1220
|
})
|
|
1051
1221
|
]),
|
|
1052
1222
|
_: 1
|
|
1053
|
-
})) :
|
|
1223
|
+
})) : T("", !0);
|
|
1054
1224
|
};
|
|
1055
1225
|
}
|
|
1056
|
-
}),
|
|
1057
|
-
function
|
|
1226
|
+
}), ba = /* @__PURE__ */ ve(ca, [["__scopeId", "data-v-d51d13e4"]]);
|
|
1227
|
+
function ya(a = {}) {
|
|
1058
1228
|
const i = a.path ?? "/login";
|
|
1059
1229
|
return {
|
|
1060
1230
|
install(s) {
|
|
1061
|
-
const
|
|
1062
|
-
s.i18n.defaults("webx-auth",
|
|
1231
|
+
const o = Ie(s.context);
|
|
1232
|
+
s.i18n.defaults("webx-auth", $e), Ke(s.app, o, a.resolveAvatar ?? null, a.avatarField ?? null), s.context.useSessionLoader(() => o.me()), s.router.addRoute({
|
|
1063
1233
|
path: i,
|
|
1064
1234
|
name: "webx.login",
|
|
1065
1235
|
meta: { public: !0 },
|
|
1066
|
-
component: { render: () =>
|
|
1067
|
-
}), s.router.beforeEach((
|
|
1236
|
+
component: { render: () => xe(He, { ...a.card }) }
|
|
1237
|
+
}), s.router.beforeEach((u) => u.meta.public === !0 || s.context.state.status !== "unauthenticated" ? !0 : { path: i, query: u.fullPath === "/" ? {} : { next: u.fullPath } }), Z(
|
|
1068
1238
|
() => s.context.state.status,
|
|
1069
|
-
(
|
|
1070
|
-
const
|
|
1071
|
-
if (
|
|
1072
|
-
s.router.replace({ path: i, query: { next:
|
|
1239
|
+
(u) => {
|
|
1240
|
+
const k = s.router.currentRoute.value;
|
|
1241
|
+
if (u === "unauthenticated" && k.path !== i) {
|
|
1242
|
+
s.router.replace({ path: i, query: { next: k.fullPath } });
|
|
1073
1243
|
return;
|
|
1074
1244
|
}
|
|
1075
|
-
if (
|
|
1076
|
-
const
|
|
1077
|
-
s.router.replace(typeof
|
|
1245
|
+
if (u === "ready" && k.path === i) {
|
|
1246
|
+
const m = k.query.next;
|
|
1247
|
+
s.router.replace(typeof m == "string" ? m : "/");
|
|
1078
1248
|
}
|
|
1079
1249
|
}
|
|
1080
1250
|
);
|
|
@@ -1082,20 +1252,22 @@ function ua(a = {}) {
|
|
|
1082
1252
|
};
|
|
1083
1253
|
}
|
|
1084
1254
|
export {
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1255
|
+
Ce as WxAdminList,
|
|
1256
|
+
aa as WxAdminsPage,
|
|
1257
|
+
He as WxLoginCard,
|
|
1258
|
+
ia as WxProfileDialog,
|
|
1259
|
+
ba as WxUserMenu,
|
|
1260
|
+
fa as admins,
|
|
1261
|
+
ya as auth,
|
|
1262
|
+
Ve as authKey,
|
|
1263
|
+
$e as authMessages,
|
|
1264
|
+
Le as avatarFieldKey,
|
|
1265
|
+
Ae as avatarResolverKey,
|
|
1266
|
+
pe as createAdminsApi,
|
|
1267
|
+
Ie as createAuthSession,
|
|
1268
|
+
Ke as provideAuth,
|
|
1269
|
+
wa as selectAdmin,
|
|
1270
|
+
ha as selectAdmins,
|
|
1271
|
+
me as useAuth
|
|
1100
1272
|
};
|
|
1101
1273
|
//# sourceMappingURL=index.js.map
|