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