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