@yelon/acl 12.0.6 → 12.0.10
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/LICENSE +21 -21
- package/acl.d.ts +4 -4
- package/bundles/acl.umd.js +785 -787
- package/bundles/acl.umd.js.map +1 -1
- package/esm2015/acl.js +4 -4
- package/esm2015/index.js +7 -7
- package/esm2015/src/acl-guard.js +54 -54
- package/esm2015/src/acl-if.directive.js +77 -77
- package/esm2015/src/acl.config.js +3 -3
- package/esm2015/src/acl.directive.js +46 -46
- package/esm2015/src/acl.module.js +21 -21
- package/esm2015/src/acl.service.js +194 -194
- package/esm2015/src/acl.type.js +6 -6
- package/fesm2015/acl.js +372 -372
- package/index.d.ts +7 -7
- package/package.json +2 -2
- package/src/acl-guard.d.ts +23 -23
- package/src/acl-if.directive.d.ts +23 -23
- package/src/acl.config.d.ts +2 -2
- package/src/acl.directive.d.ts +15 -15
- package/src/acl.module.d.ts +4 -4
- package/src/acl.service.d.ts +75 -75
- package/src/acl.type.d.ts +28 -28
package/bundles/acl.umd.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license ng-yunzai(devcui@outlook.com) v12.0.
|
|
3
|
-
* (c) 2020 devcui https://github.com/hbyunzai/yelon/
|
|
4
|
-
* License: MIT
|
|
5
|
-
*/
|
|
1
|
+
/**
|
|
2
|
+
* @license ng-yunzai(devcui@outlook.com) v12.0.10
|
|
3
|
+
* (c) 2020 devcui https://github.com/hbyunzai/yelon/
|
|
4
|
+
* License: MIT
|
|
5
|
+
*/
|
|
6
6
|
(function (global, factory) {
|
|
7
7
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('@yelon/util/config'), require('rxjs/operators'), require('@angular/router'), require('@angular/common')) :
|
|
8
8
|
typeof define === 'function' && define.amd ? define('@yelon/acl', ['exports', '@angular/core', 'rxjs', '@yelon/util/config', 'rxjs/operators', '@angular/router', '@angular/common'], factory) :
|
|
9
9
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.yelon = global.yelon || {}, global.yelon.acl = {}), global.ng.core, global.rxjs, global.config, global.rxjs.operators, global.ng.router, global.ng.common));
|
|
10
|
-
}(this, (function (exports, i0, rxjs, config, operators, i2, common) { 'use strict';
|
|
10
|
+
})(this, (function (exports, i0, rxjs, config, operators, i2, common) { 'use strict';
|
|
11
11
|
|
|
12
12
|
function _interopNamespace(e) {
|
|
13
13
|
if (e && e.__esModule) return e;
|
|
@@ -18,810 +18,808 @@
|
|
|
18
18
|
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
19
19
|
Object.defineProperty(n, k, d.get ? d : {
|
|
20
20
|
enumerable: true,
|
|
21
|
-
get: function () {
|
|
22
|
-
return e[k];
|
|
23
|
-
}
|
|
21
|
+
get: function () { return e[k]; }
|
|
24
22
|
});
|
|
25
23
|
}
|
|
26
24
|
});
|
|
27
25
|
}
|
|
28
|
-
n[
|
|
26
|
+
n["default"] = e;
|
|
29
27
|
return Object.freeze(n);
|
|
30
28
|
}
|
|
31
29
|
|
|
32
30
|
var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
|
|
33
31
|
var i2__namespace = /*#__PURE__*/_interopNamespace(i2);
|
|
34
32
|
|
|
35
|
-
/*! *****************************************************************************
|
|
36
|
-
Copyright (c) Microsoft Corporation.
|
|
37
|
-
|
|
38
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
39
|
-
purpose with or without fee is hereby granted.
|
|
40
|
-
|
|
41
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
42
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
43
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
44
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
45
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
46
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
47
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
48
|
-
***************************************************************************** */
|
|
49
|
-
/* global Reflect, Promise */
|
|
50
|
-
var extendStatics = function (d, b) {
|
|
51
|
-
extendStatics = Object.setPrototypeOf ||
|
|
52
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
53
|
-
function (d, b) { for (var p in b)
|
|
54
|
-
if (Object.prototype.hasOwnProperty.call(b, p))
|
|
55
|
-
d[p] = b[p]; };
|
|
56
|
-
return extendStatics(d, b);
|
|
57
|
-
};
|
|
58
|
-
function __extends(d, b) {
|
|
59
|
-
if (typeof b !== "function" && b !== null)
|
|
60
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
61
|
-
extendStatics(d, b);
|
|
62
|
-
function __() { this.constructor = d; }
|
|
63
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
64
|
-
}
|
|
65
|
-
var __assign = function () {
|
|
66
|
-
__assign = Object.assign || function __assign(t) {
|
|
67
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
68
|
-
s = arguments[i];
|
|
69
|
-
for (var p in s)
|
|
70
|
-
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
71
|
-
t[p] = s[p];
|
|
72
|
-
}
|
|
73
|
-
return t;
|
|
74
|
-
};
|
|
75
|
-
return __assign.apply(this, arguments);
|
|
76
|
-
};
|
|
77
|
-
function __rest(s, e) {
|
|
78
|
-
var t = {};
|
|
79
|
-
for (var p in s)
|
|
80
|
-
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
81
|
-
t[p] = s[p];
|
|
82
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
83
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
84
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
85
|
-
t[p[i]] = s[p[i]];
|
|
86
|
-
}
|
|
87
|
-
return t;
|
|
88
|
-
}
|
|
89
|
-
function __decorate(decorators, target, key, desc) {
|
|
90
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
91
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
92
|
-
r = Reflect.decorate(decorators, target, key, desc);
|
|
93
|
-
else
|
|
94
|
-
for (var i = decorators.length - 1; i >= 0; i--)
|
|
95
|
-
if (d = decorators[i])
|
|
96
|
-
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
97
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
98
|
-
}
|
|
99
|
-
function __param(paramIndex, decorator) {
|
|
100
|
-
return function (target, key) { decorator(target, key, paramIndex); };
|
|
101
|
-
}
|
|
102
|
-
function __metadata(metadataKey, metadataValue) {
|
|
103
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
104
|
-
return Reflect.metadata(metadataKey, metadataValue);
|
|
105
|
-
}
|
|
106
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
107
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
108
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
109
|
-
function fulfilled(value) { try {
|
|
110
|
-
step(generator.next(value));
|
|
111
|
-
}
|
|
112
|
-
catch (e) {
|
|
113
|
-
reject(e);
|
|
114
|
-
} }
|
|
115
|
-
function rejected(value) { try {
|
|
116
|
-
step(generator["throw"](value));
|
|
117
|
-
}
|
|
118
|
-
catch (e) {
|
|
119
|
-
reject(e);
|
|
120
|
-
} }
|
|
121
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
122
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
function __generator(thisArg, body) {
|
|
126
|
-
var _ = { label: 0, sent: function () { if (t[0] & 1)
|
|
127
|
-
throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
128
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
|
|
129
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
130
|
-
function step(op) {
|
|
131
|
-
if (f)
|
|
132
|
-
throw new TypeError("Generator is already executing.");
|
|
133
|
-
while (_)
|
|
134
|
-
try {
|
|
135
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
|
|
136
|
-
return t;
|
|
137
|
-
if (y = 0, t)
|
|
138
|
-
op = [op[0] & 2, t.value];
|
|
139
|
-
switch (op[0]) {
|
|
140
|
-
case 0:
|
|
141
|
-
case 1:
|
|
142
|
-
t = op;
|
|
143
|
-
break;
|
|
144
|
-
case 4:
|
|
145
|
-
_.label++;
|
|
146
|
-
return { value: op[1], done: false };
|
|
147
|
-
case 5:
|
|
148
|
-
_.label++;
|
|
149
|
-
y = op[1];
|
|
150
|
-
op = [0];
|
|
151
|
-
continue;
|
|
152
|
-
case 7:
|
|
153
|
-
op = _.ops.pop();
|
|
154
|
-
_.trys.pop();
|
|
155
|
-
continue;
|
|
156
|
-
default:
|
|
157
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
158
|
-
_ = 0;
|
|
159
|
-
continue;
|
|
160
|
-
}
|
|
161
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
|
|
162
|
-
_.label = op[1];
|
|
163
|
-
break;
|
|
164
|
-
}
|
|
165
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
166
|
-
_.label = t[1];
|
|
167
|
-
t = op;
|
|
168
|
-
break;
|
|
169
|
-
}
|
|
170
|
-
if (t && _.label < t[2]) {
|
|
171
|
-
_.label = t[2];
|
|
172
|
-
_.ops.push(op);
|
|
173
|
-
break;
|
|
174
|
-
}
|
|
175
|
-
if (t[2])
|
|
176
|
-
_.ops.pop();
|
|
177
|
-
_.trys.pop();
|
|
178
|
-
continue;
|
|
179
|
-
}
|
|
180
|
-
op = body.call(thisArg, _);
|
|
181
|
-
}
|
|
182
|
-
catch (e) {
|
|
183
|
-
op = [6, e];
|
|
184
|
-
y = 0;
|
|
185
|
-
}
|
|
186
|
-
finally {
|
|
187
|
-
f = t = 0;
|
|
188
|
-
}
|
|
189
|
-
if (op[0] & 5)
|
|
190
|
-
throw op[1];
|
|
191
|
-
return { value: op[0] ? op[1] : void 0, done: true };
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
var __createBinding = Object.create ? (function (o, m, k, k2) {
|
|
195
|
-
if (k2 === undefined)
|
|
196
|
-
k2 = k;
|
|
197
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
|
|
198
|
-
}) : (function (o, m, k, k2) {
|
|
199
|
-
if (k2 === undefined)
|
|
200
|
-
k2 = k;
|
|
201
|
-
o[k2] = m[k];
|
|
202
|
-
});
|
|
203
|
-
function __exportStar(m, o) {
|
|
204
|
-
for (var p in m)
|
|
205
|
-
if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
|
|
206
|
-
__createBinding(o, m, p);
|
|
207
|
-
}
|
|
208
|
-
function __values(o) {
|
|
209
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
210
|
-
if (m)
|
|
211
|
-
return m.call(o);
|
|
212
|
-
if (o && typeof o.length === "number")
|
|
213
|
-
return {
|
|
214
|
-
next: function () {
|
|
215
|
-
if (o && i >= o.length)
|
|
216
|
-
o = void 0;
|
|
217
|
-
return { value: o && o[i++], done: !o };
|
|
218
|
-
}
|
|
219
|
-
};
|
|
220
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
221
|
-
}
|
|
222
|
-
function __read(o, n) {
|
|
223
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
224
|
-
if (!m)
|
|
225
|
-
return o;
|
|
226
|
-
var i = m.call(o), r, ar = [], e;
|
|
227
|
-
try {
|
|
228
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
|
|
229
|
-
ar.push(r.value);
|
|
230
|
-
}
|
|
231
|
-
catch (error) {
|
|
232
|
-
e = { error: error };
|
|
233
|
-
}
|
|
234
|
-
finally {
|
|
235
|
-
try {
|
|
236
|
-
if (r && !r.done && (m = i["return"]))
|
|
237
|
-
m.call(i);
|
|
238
|
-
}
|
|
239
|
-
finally {
|
|
240
|
-
if (e)
|
|
241
|
-
throw e.error;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
return ar;
|
|
245
|
-
}
|
|
246
|
-
/** @deprecated */
|
|
247
|
-
function __spread() {
|
|
248
|
-
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
249
|
-
ar = ar.concat(__read(arguments[i]));
|
|
250
|
-
return ar;
|
|
251
|
-
}
|
|
252
|
-
/** @deprecated */
|
|
253
|
-
function __spreadArrays() {
|
|
254
|
-
for (var s = 0, i = 0, il = arguments.length; i < il; i++)
|
|
255
|
-
s += arguments[i].length;
|
|
256
|
-
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
257
|
-
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
258
|
-
r[k] = a[j];
|
|
259
|
-
return r;
|
|
260
|
-
}
|
|
261
|
-
function __spreadArray(to, from, pack) {
|
|
262
|
-
if (pack || arguments.length === 2)
|
|
263
|
-
for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
264
|
-
if (ar || !(i in from)) {
|
|
265
|
-
if (!ar)
|
|
266
|
-
ar = Array.prototype.slice.call(from, 0, i);
|
|
267
|
-
ar[i] = from[i];
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
271
|
-
}
|
|
272
|
-
function __await(v) {
|
|
273
|
-
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
274
|
-
}
|
|
275
|
-
function __asyncGenerator(thisArg, _arguments, generator) {
|
|
276
|
-
if (!Symbol.asyncIterator)
|
|
277
|
-
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
278
|
-
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
279
|
-
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
280
|
-
function verb(n) { if (g[n])
|
|
281
|
-
i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
|
282
|
-
function resume(n, v) { try {
|
|
283
|
-
step(g[n](v));
|
|
284
|
-
}
|
|
285
|
-
catch (e) {
|
|
286
|
-
settle(q[0][3], e);
|
|
287
|
-
} }
|
|
288
|
-
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
289
|
-
function fulfill(value) { resume("next", value); }
|
|
290
|
-
function reject(value) { resume("throw", value); }
|
|
291
|
-
function settle(f, v) { if (f(v), q.shift(), q.length)
|
|
292
|
-
resume(q[0][0], q[0][1]); }
|
|
293
|
-
}
|
|
294
|
-
function __asyncDelegator(o) {
|
|
295
|
-
var i, p;
|
|
296
|
-
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
|
297
|
-
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
|
|
298
|
-
}
|
|
299
|
-
function __asyncValues(o) {
|
|
300
|
-
if (!Symbol.asyncIterator)
|
|
301
|
-
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
302
|
-
var m = o[Symbol.asyncIterator], i;
|
|
303
|
-
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
304
|
-
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
305
|
-
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
|
|
306
|
-
}
|
|
307
|
-
function __makeTemplateObject(cooked, raw) {
|
|
308
|
-
if (Object.defineProperty) {
|
|
309
|
-
Object.defineProperty(cooked, "raw", { value: raw });
|
|
310
|
-
}
|
|
311
|
-
else {
|
|
312
|
-
cooked.raw = raw;
|
|
313
|
-
}
|
|
314
|
-
return cooked;
|
|
315
|
-
}
|
|
316
|
-
;
|
|
317
|
-
var __setModuleDefault = Object.create ? (function (o, v) {
|
|
318
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
319
|
-
}) : function (o, v) {
|
|
320
|
-
o["default"] = v;
|
|
321
|
-
};
|
|
322
|
-
function __importStar(mod) {
|
|
323
|
-
if (mod && mod.__esModule)
|
|
324
|
-
return mod;
|
|
325
|
-
var result = {};
|
|
326
|
-
if (mod != null)
|
|
327
|
-
for (var k in mod)
|
|
328
|
-
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
|
|
329
|
-
__createBinding(result, mod, k);
|
|
330
|
-
__setModuleDefault(result, mod);
|
|
331
|
-
return result;
|
|
332
|
-
}
|
|
333
|
-
function __importDefault(mod) {
|
|
334
|
-
return (mod && mod.__esModule) ? mod : { default: mod };
|
|
335
|
-
}
|
|
336
|
-
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
337
|
-
if (kind === "a" && !f)
|
|
338
|
-
throw new TypeError("Private accessor was defined without a getter");
|
|
339
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
340
|
-
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
341
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
342
|
-
}
|
|
343
|
-
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
344
|
-
if (kind === "m")
|
|
345
|
-
throw new TypeError("Private method is not writable");
|
|
346
|
-
if (kind === "a" && !f)
|
|
347
|
-
throw new TypeError("Private accessor was defined without a setter");
|
|
348
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
349
|
-
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
350
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
33
|
+
/*! *****************************************************************************
|
|
34
|
+
Copyright (c) Microsoft Corporation.
|
|
35
|
+
|
|
36
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
37
|
+
purpose with or without fee is hereby granted.
|
|
38
|
+
|
|
39
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
40
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
41
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
42
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
43
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
44
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
45
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
46
|
+
***************************************************************************** */
|
|
47
|
+
/* global Reflect, Promise */
|
|
48
|
+
var extendStatics = function (d, b) {
|
|
49
|
+
extendStatics = Object.setPrototypeOf ||
|
|
50
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
51
|
+
function (d, b) { for (var p in b)
|
|
52
|
+
if (Object.prototype.hasOwnProperty.call(b, p))
|
|
53
|
+
d[p] = b[p]; };
|
|
54
|
+
return extendStatics(d, b);
|
|
55
|
+
};
|
|
56
|
+
function __extends(d, b) {
|
|
57
|
+
if (typeof b !== "function" && b !== null)
|
|
58
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
59
|
+
extendStatics(d, b);
|
|
60
|
+
function __() { this.constructor = d; }
|
|
61
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
62
|
+
}
|
|
63
|
+
var __assign = function () {
|
|
64
|
+
__assign = Object.assign || function __assign(t) {
|
|
65
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
66
|
+
s = arguments[i];
|
|
67
|
+
for (var p in s)
|
|
68
|
+
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
69
|
+
t[p] = s[p];
|
|
70
|
+
}
|
|
71
|
+
return t;
|
|
72
|
+
};
|
|
73
|
+
return __assign.apply(this, arguments);
|
|
74
|
+
};
|
|
75
|
+
function __rest(s, e) {
|
|
76
|
+
var t = {};
|
|
77
|
+
for (var p in s)
|
|
78
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
79
|
+
t[p] = s[p];
|
|
80
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
81
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
82
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
83
|
+
t[p[i]] = s[p[i]];
|
|
84
|
+
}
|
|
85
|
+
return t;
|
|
86
|
+
}
|
|
87
|
+
function __decorate(decorators, target, key, desc) {
|
|
88
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
89
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
90
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
91
|
+
else
|
|
92
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
93
|
+
if (d = decorators[i])
|
|
94
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
95
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
96
|
+
}
|
|
97
|
+
function __param(paramIndex, decorator) {
|
|
98
|
+
return function (target, key) { decorator(target, key, paramIndex); };
|
|
99
|
+
}
|
|
100
|
+
function __metadata(metadataKey, metadataValue) {
|
|
101
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
102
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
103
|
+
}
|
|
104
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
105
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
106
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
107
|
+
function fulfilled(value) { try {
|
|
108
|
+
step(generator.next(value));
|
|
109
|
+
}
|
|
110
|
+
catch (e) {
|
|
111
|
+
reject(e);
|
|
112
|
+
} }
|
|
113
|
+
function rejected(value) { try {
|
|
114
|
+
step(generator["throw"](value));
|
|
115
|
+
}
|
|
116
|
+
catch (e) {
|
|
117
|
+
reject(e);
|
|
118
|
+
} }
|
|
119
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
120
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
function __generator(thisArg, body) {
|
|
124
|
+
var _ = { label: 0, sent: function () { if (t[0] & 1)
|
|
125
|
+
throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
126
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
|
|
127
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
128
|
+
function step(op) {
|
|
129
|
+
if (f)
|
|
130
|
+
throw new TypeError("Generator is already executing.");
|
|
131
|
+
while (_)
|
|
132
|
+
try {
|
|
133
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
|
|
134
|
+
return t;
|
|
135
|
+
if (y = 0, t)
|
|
136
|
+
op = [op[0] & 2, t.value];
|
|
137
|
+
switch (op[0]) {
|
|
138
|
+
case 0:
|
|
139
|
+
case 1:
|
|
140
|
+
t = op;
|
|
141
|
+
break;
|
|
142
|
+
case 4:
|
|
143
|
+
_.label++;
|
|
144
|
+
return { value: op[1], done: false };
|
|
145
|
+
case 5:
|
|
146
|
+
_.label++;
|
|
147
|
+
y = op[1];
|
|
148
|
+
op = [0];
|
|
149
|
+
continue;
|
|
150
|
+
case 7:
|
|
151
|
+
op = _.ops.pop();
|
|
152
|
+
_.trys.pop();
|
|
153
|
+
continue;
|
|
154
|
+
default:
|
|
155
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
156
|
+
_ = 0;
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
|
|
160
|
+
_.label = op[1];
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
164
|
+
_.label = t[1];
|
|
165
|
+
t = op;
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
if (t && _.label < t[2]) {
|
|
169
|
+
_.label = t[2];
|
|
170
|
+
_.ops.push(op);
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
if (t[2])
|
|
174
|
+
_.ops.pop();
|
|
175
|
+
_.trys.pop();
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
op = body.call(thisArg, _);
|
|
179
|
+
}
|
|
180
|
+
catch (e) {
|
|
181
|
+
op = [6, e];
|
|
182
|
+
y = 0;
|
|
183
|
+
}
|
|
184
|
+
finally {
|
|
185
|
+
f = t = 0;
|
|
186
|
+
}
|
|
187
|
+
if (op[0] & 5)
|
|
188
|
+
throw op[1];
|
|
189
|
+
return { value: op[0] ? op[1] : void 0, done: true };
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
var __createBinding = Object.create ? (function (o, m, k, k2) {
|
|
193
|
+
if (k2 === undefined)
|
|
194
|
+
k2 = k;
|
|
195
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
|
|
196
|
+
}) : (function (o, m, k, k2) {
|
|
197
|
+
if (k2 === undefined)
|
|
198
|
+
k2 = k;
|
|
199
|
+
o[k2] = m[k];
|
|
200
|
+
});
|
|
201
|
+
function __exportStar(m, o) {
|
|
202
|
+
for (var p in m)
|
|
203
|
+
if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
|
|
204
|
+
__createBinding(o, m, p);
|
|
205
|
+
}
|
|
206
|
+
function __values(o) {
|
|
207
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
208
|
+
if (m)
|
|
209
|
+
return m.call(o);
|
|
210
|
+
if (o && typeof o.length === "number")
|
|
211
|
+
return {
|
|
212
|
+
next: function () {
|
|
213
|
+
if (o && i >= o.length)
|
|
214
|
+
o = void 0;
|
|
215
|
+
return { value: o && o[i++], done: !o };
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
219
|
+
}
|
|
220
|
+
function __read(o, n) {
|
|
221
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
222
|
+
if (!m)
|
|
223
|
+
return o;
|
|
224
|
+
var i = m.call(o), r, ar = [], e;
|
|
225
|
+
try {
|
|
226
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
|
|
227
|
+
ar.push(r.value);
|
|
228
|
+
}
|
|
229
|
+
catch (error) {
|
|
230
|
+
e = { error: error };
|
|
231
|
+
}
|
|
232
|
+
finally {
|
|
233
|
+
try {
|
|
234
|
+
if (r && !r.done && (m = i["return"]))
|
|
235
|
+
m.call(i);
|
|
236
|
+
}
|
|
237
|
+
finally {
|
|
238
|
+
if (e)
|
|
239
|
+
throw e.error;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
return ar;
|
|
243
|
+
}
|
|
244
|
+
/** @deprecated */
|
|
245
|
+
function __spread() {
|
|
246
|
+
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
247
|
+
ar = ar.concat(__read(arguments[i]));
|
|
248
|
+
return ar;
|
|
249
|
+
}
|
|
250
|
+
/** @deprecated */
|
|
251
|
+
function __spreadArrays() {
|
|
252
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++)
|
|
253
|
+
s += arguments[i].length;
|
|
254
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
255
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
256
|
+
r[k] = a[j];
|
|
257
|
+
return r;
|
|
258
|
+
}
|
|
259
|
+
function __spreadArray(to, from, pack) {
|
|
260
|
+
if (pack || arguments.length === 2)
|
|
261
|
+
for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
262
|
+
if (ar || !(i in from)) {
|
|
263
|
+
if (!ar)
|
|
264
|
+
ar = Array.prototype.slice.call(from, 0, i);
|
|
265
|
+
ar[i] = from[i];
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
269
|
+
}
|
|
270
|
+
function __await(v) {
|
|
271
|
+
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
272
|
+
}
|
|
273
|
+
function __asyncGenerator(thisArg, _arguments, generator) {
|
|
274
|
+
if (!Symbol.asyncIterator)
|
|
275
|
+
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
276
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
277
|
+
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
278
|
+
function verb(n) { if (g[n])
|
|
279
|
+
i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
|
280
|
+
function resume(n, v) { try {
|
|
281
|
+
step(g[n](v));
|
|
282
|
+
}
|
|
283
|
+
catch (e) {
|
|
284
|
+
settle(q[0][3], e);
|
|
285
|
+
} }
|
|
286
|
+
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
287
|
+
function fulfill(value) { resume("next", value); }
|
|
288
|
+
function reject(value) { resume("throw", value); }
|
|
289
|
+
function settle(f, v) { if (f(v), q.shift(), q.length)
|
|
290
|
+
resume(q[0][0], q[0][1]); }
|
|
291
|
+
}
|
|
292
|
+
function __asyncDelegator(o) {
|
|
293
|
+
var i, p;
|
|
294
|
+
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
|
295
|
+
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
|
|
296
|
+
}
|
|
297
|
+
function __asyncValues(o) {
|
|
298
|
+
if (!Symbol.asyncIterator)
|
|
299
|
+
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
300
|
+
var m = o[Symbol.asyncIterator], i;
|
|
301
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
302
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
303
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
|
|
304
|
+
}
|
|
305
|
+
function __makeTemplateObject(cooked, raw) {
|
|
306
|
+
if (Object.defineProperty) {
|
|
307
|
+
Object.defineProperty(cooked, "raw", { value: raw });
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
cooked.raw = raw;
|
|
311
|
+
}
|
|
312
|
+
return cooked;
|
|
313
|
+
}
|
|
314
|
+
;
|
|
315
|
+
var __setModuleDefault = Object.create ? (function (o, v) {
|
|
316
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
317
|
+
}) : function (o, v) {
|
|
318
|
+
o["default"] = v;
|
|
319
|
+
};
|
|
320
|
+
function __importStar(mod) {
|
|
321
|
+
if (mod && mod.__esModule)
|
|
322
|
+
return mod;
|
|
323
|
+
var result = {};
|
|
324
|
+
if (mod != null)
|
|
325
|
+
for (var k in mod)
|
|
326
|
+
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
|
|
327
|
+
__createBinding(result, mod, k);
|
|
328
|
+
__setModuleDefault(result, mod);
|
|
329
|
+
return result;
|
|
330
|
+
}
|
|
331
|
+
function __importDefault(mod) {
|
|
332
|
+
return (mod && mod.__esModule) ? mod : { default: mod };
|
|
333
|
+
}
|
|
334
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
335
|
+
if (kind === "a" && !f)
|
|
336
|
+
throw new TypeError("Private accessor was defined without a getter");
|
|
337
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
338
|
+
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
339
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
340
|
+
}
|
|
341
|
+
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
342
|
+
if (kind === "m")
|
|
343
|
+
throw new TypeError("Private method is not writable");
|
|
344
|
+
if (kind === "a" && !f)
|
|
345
|
+
throw new TypeError("Private accessor was defined without a setter");
|
|
346
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
347
|
+
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
348
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
351
349
|
}
|
|
352
350
|
|
|
353
|
-
var ACL_DEFAULT_CONFIG = {
|
|
354
|
-
guard_url: "/403"
|
|
351
|
+
var ACL_DEFAULT_CONFIG = {
|
|
352
|
+
guard_url: "/403"
|
|
355
353
|
};
|
|
356
354
|
|
|
357
|
-
/**
|
|
358
|
-
* ACL 控制服务,[在线文档](https://ng.yunzainfo.com/acl)
|
|
359
|
-
*
|
|
360
|
-
* 务必在根目录注册 `YelonACLModule.forRoot()` 才能使用服务
|
|
361
|
-
*/
|
|
362
|
-
var ACLService = /** @class */ (function () {
|
|
363
|
-
function ACLService(configSrv) {
|
|
364
|
-
this.roles = [];
|
|
365
|
-
this.abilities = [];
|
|
366
|
-
this.full = false;
|
|
367
|
-
this.aclChange = new rxjs.BehaviorSubject(null);
|
|
368
|
-
this.options = configSrv.merge('acl', ACL_DEFAULT_CONFIG);
|
|
369
|
-
}
|
|
370
|
-
Object.defineProperty(ACLService.prototype, "change", {
|
|
371
|
-
/** ACL变更通知 */
|
|
372
|
-
get: function () {
|
|
373
|
-
return this.aclChange.asObservable();
|
|
374
|
-
},
|
|
375
|
-
enumerable: false,
|
|
376
|
-
configurable: true
|
|
377
|
-
});
|
|
378
|
-
Object.defineProperty(ACLService.prototype, "data", {
|
|
379
|
-
/** 获取所有数据 */
|
|
380
|
-
get: function () {
|
|
381
|
-
return {
|
|
382
|
-
full: this.full,
|
|
383
|
-
roles: this.roles,
|
|
384
|
-
abilities: this.abilities
|
|
385
|
-
};
|
|
386
|
-
},
|
|
387
|
-
enumerable: false,
|
|
388
|
-
configurable: true
|
|
389
|
-
});
|
|
390
|
-
Object.defineProperty(ACLService.prototype, "guard_url", {
|
|
391
|
-
get: function () {
|
|
392
|
-
return this.options.guard_url;
|
|
393
|
-
},
|
|
394
|
-
enumerable: false,
|
|
395
|
-
configurable: true
|
|
396
|
-
});
|
|
397
|
-
ACLService.prototype.parseACLType = function (val) {
|
|
398
|
-
var t;
|
|
399
|
-
if (typeof val === 'number') {
|
|
400
|
-
t = { ability: [val] };
|
|
401
|
-
}
|
|
402
|
-
else if (Array.isArray(val) && val.length > 0 && typeof val[0] === 'number') {
|
|
403
|
-
t = { ability: val };
|
|
404
|
-
}
|
|
405
|
-
else if (typeof val === 'object' && !Array.isArray(val)) {
|
|
406
|
-
t = Object.assign({}, val);
|
|
407
|
-
}
|
|
408
|
-
else if (Array.isArray(val)) {
|
|
409
|
-
t = { role: val };
|
|
410
|
-
}
|
|
411
|
-
else {
|
|
412
|
-
t = { role: val == null ? [] : [val] };
|
|
413
|
-
}
|
|
414
|
-
return Object.assign({ except: false }, t);
|
|
415
|
-
};
|
|
416
|
-
/**
|
|
417
|
-
* 设置当前用户角色或权限能力(会先清除所有)
|
|
418
|
-
*/
|
|
419
|
-
ACLService.prototype.set = function (value) {
|
|
420
|
-
this.full = false;
|
|
421
|
-
this.abilities = [];
|
|
422
|
-
this.roles = [];
|
|
423
|
-
this.add(value);
|
|
424
|
-
this.aclChange.next(value);
|
|
425
|
-
};
|
|
426
|
-
/**
|
|
427
|
-
* 标识当前用户为全量,即不受限
|
|
428
|
-
*/
|
|
429
|
-
ACLService.prototype.setFull = function (val) {
|
|
430
|
-
this.full = val;
|
|
431
|
-
this.aclChange.next(val);
|
|
432
|
-
};
|
|
433
|
-
/**
|
|
434
|
-
* 设置当前用户权限能力(会先清除所有)
|
|
435
|
-
*/
|
|
436
|
-
ACLService.prototype.setAbility = function (abilities) {
|
|
437
|
-
this.set({ ability: abilities });
|
|
438
|
-
};
|
|
439
|
-
/**
|
|
440
|
-
* 设置当前用户角色(会先清除所有)
|
|
441
|
-
*/
|
|
442
|
-
ACLService.prototype.setRole = function (roles) {
|
|
443
|
-
this.set({ role: roles });
|
|
444
|
-
};
|
|
445
|
-
/**
|
|
446
|
-
* 为当前用户增加角色或权限能力
|
|
447
|
-
*/
|
|
448
|
-
ACLService.prototype.add = function (value) {
|
|
449
|
-
var _a, _b;
|
|
450
|
-
if (value.role && value.role.length > 0) {
|
|
451
|
-
(_a = this.roles).push.apply(_a, __spreadArray([], __read(value.role)));
|
|
452
|
-
}
|
|
453
|
-
if (value.ability && value.ability.length > 0) {
|
|
454
|
-
(_b = this.abilities).push.apply(_b, __spreadArray([], __read(value.ability)));
|
|
455
|
-
}
|
|
456
|
-
};
|
|
457
|
-
/**
|
|
458
|
-
* 为当前用户附加角色
|
|
459
|
-
*/
|
|
460
|
-
ACLService.prototype.attachRole = function (roles) {
|
|
461
|
-
var e_1, _a;
|
|
462
|
-
try {
|
|
463
|
-
for (var roles_1 = __values(roles), roles_1_1 = roles_1.next(); !roles_1_1.done; roles_1_1 = roles_1.next()) {
|
|
464
|
-
var val = roles_1_1.value;
|
|
465
|
-
if (!this.roles.includes(val)) {
|
|
466
|
-
this.roles.push(val);
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
471
|
-
finally {
|
|
472
|
-
try {
|
|
473
|
-
if (roles_1_1 && !roles_1_1.done && (_a = roles_1.return)) _a.call(roles_1);
|
|
474
|
-
}
|
|
475
|
-
finally { if (e_1) throw e_1.error; }
|
|
476
|
-
}
|
|
477
|
-
this.aclChange.next(this.data);
|
|
478
|
-
};
|
|
479
|
-
/**
|
|
480
|
-
* 为当前用户附加权限
|
|
481
|
-
*/
|
|
482
|
-
ACLService.prototype.attachAbility = function (abilities) {
|
|
483
|
-
var e_2, _a;
|
|
484
|
-
try {
|
|
485
|
-
for (var abilities_1 = __values(abilities), abilities_1_1 = abilities_1.next(); !abilities_1_1.done; abilities_1_1 = abilities_1.next()) {
|
|
486
|
-
var val = abilities_1_1.value;
|
|
487
|
-
if (!this.abilities.includes(val)) {
|
|
488
|
-
this.abilities.push(val);
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
493
|
-
finally {
|
|
494
|
-
try {
|
|
495
|
-
if (abilities_1_1 && !abilities_1_1.done && (_a = abilities_1.return)) _a.call(abilities_1);
|
|
496
|
-
}
|
|
497
|
-
finally { if (e_2) throw e_2.error; }
|
|
498
|
-
}
|
|
499
|
-
this.aclChange.next(this.data);
|
|
500
|
-
};
|
|
501
|
-
/**
|
|
502
|
-
* 为当前用户移除角色
|
|
503
|
-
*/
|
|
504
|
-
ACLService.prototype.removeRole = function (roles) {
|
|
505
|
-
var e_3, _a;
|
|
506
|
-
try {
|
|
507
|
-
for (var roles_2 = __values(roles), roles_2_1 = roles_2.next(); !roles_2_1.done; roles_2_1 = roles_2.next()) {
|
|
508
|
-
var val = roles_2_1.value;
|
|
509
|
-
var idx = this.roles.indexOf(val);
|
|
510
|
-
if (idx !== -1) {
|
|
511
|
-
this.roles.splice(idx, 1);
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
516
|
-
finally {
|
|
517
|
-
try {
|
|
518
|
-
if (roles_2_1 && !roles_2_1.done && (_a = roles_2.return)) _a.call(roles_2);
|
|
519
|
-
}
|
|
520
|
-
finally { if (e_3) throw e_3.error; }
|
|
521
|
-
}
|
|
522
|
-
this.aclChange.next(this.data);
|
|
523
|
-
};
|
|
524
|
-
/**
|
|
525
|
-
* 为当前用户移除权限
|
|
526
|
-
*/
|
|
527
|
-
ACLService.prototype.removeAbility = function (abilities) {
|
|
528
|
-
var e_4, _a;
|
|
529
|
-
try {
|
|
530
|
-
for (var abilities_2 = __values(abilities), abilities_2_1 = abilities_2.next(); !abilities_2_1.done; abilities_2_1 = abilities_2.next()) {
|
|
531
|
-
var val = abilities_2_1.value;
|
|
532
|
-
var idx = this.abilities.indexOf(val);
|
|
533
|
-
if (idx !== -1) {
|
|
534
|
-
this.abilities.splice(idx, 1);
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
539
|
-
finally {
|
|
540
|
-
try {
|
|
541
|
-
if (abilities_2_1 && !abilities_2_1.done && (_a = abilities_2.return)) _a.call(abilities_2);
|
|
542
|
-
}
|
|
543
|
-
finally { if (e_4) throw e_4.error; }
|
|
544
|
-
}
|
|
545
|
-
this.aclChange.next(this.data);
|
|
546
|
-
};
|
|
547
|
-
/**
|
|
548
|
-
* 当前用户是否有对应角色,其实 `number` 表示Ability
|
|
549
|
-
*
|
|
550
|
-
* - 当 `full: true` 或参数 `null` 时返回 `true`
|
|
551
|
-
* - 若使用 `ACLType` 参数,可以指定 `mode` 校验模式
|
|
552
|
-
*/
|
|
553
|
-
ACLService.prototype.can = function (roleOrAbility) {
|
|
554
|
-
var _this = this;
|
|
555
|
-
var preCan = this.options.preCan;
|
|
556
|
-
if (preCan) {
|
|
557
|
-
roleOrAbility = preCan(roleOrAbility);
|
|
558
|
-
}
|
|
559
|
-
var t = this.parseACLType(roleOrAbility);
|
|
560
|
-
var result = false;
|
|
561
|
-
if (this.full === true || !roleOrAbility) {
|
|
562
|
-
result = true;
|
|
563
|
-
}
|
|
564
|
-
else {
|
|
565
|
-
if (t.role && t.role.length > 0) {
|
|
566
|
-
if (t.mode === 'allOf') {
|
|
567
|
-
result = t.role.every(function (v) { return _this.roles.includes(v); });
|
|
568
|
-
}
|
|
569
|
-
else {
|
|
570
|
-
result = t.role.some(function (v) { return _this.roles.includes(v); });
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
if (t.ability && t.ability.length > 0) {
|
|
574
|
-
if (t.mode === 'allOf') {
|
|
575
|
-
result = t.ability.every(function (v) { return _this.abilities.includes(v); });
|
|
576
|
-
}
|
|
577
|
-
else {
|
|
578
|
-
result = t.ability.some(function (v) { return _this.abilities.includes(v); });
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
return t.except === true ? !result : result;
|
|
583
|
-
};
|
|
584
|
-
/** @inner */
|
|
585
|
-
ACLService.prototype.parseAbility = function (value) {
|
|
586
|
-
if (typeof value === 'number' || typeof value === 'string' || Array.isArray(value)) {
|
|
587
|
-
value = { ability: Array.isArray(value) ? value : [value] };
|
|
588
|
-
}
|
|
589
|
-
delete value.role;
|
|
590
|
-
return value;
|
|
591
|
-
};
|
|
592
|
-
/**
|
|
593
|
-
* 当前用户是否有对应权限点
|
|
594
|
-
*/
|
|
595
|
-
ACLService.prototype.canAbility = function (value) {
|
|
596
|
-
return this.can(this.parseAbility(value));
|
|
597
|
-
};
|
|
598
|
-
return ACLService;
|
|
599
|
-
}());
|
|
600
|
-
ACLService.decorators = [
|
|
601
|
-
{ type: i0.Injectable }
|
|
602
|
-
];
|
|
603
|
-
ACLService.ctorParameters = function () { return [
|
|
604
|
-
{ type: config.YunzaiConfigService }
|
|
355
|
+
/**
|
|
356
|
+
* ACL 控制服务,[在线文档](https://ng.yunzainfo.com/acl)
|
|
357
|
+
*
|
|
358
|
+
* 务必在根目录注册 `YelonACLModule.forRoot()` 才能使用服务
|
|
359
|
+
*/
|
|
360
|
+
var ACLService = /** @class */ (function () {
|
|
361
|
+
function ACLService(configSrv) {
|
|
362
|
+
this.roles = [];
|
|
363
|
+
this.abilities = [];
|
|
364
|
+
this.full = false;
|
|
365
|
+
this.aclChange = new rxjs.BehaviorSubject(null);
|
|
366
|
+
this.options = configSrv.merge('acl', ACL_DEFAULT_CONFIG);
|
|
367
|
+
}
|
|
368
|
+
Object.defineProperty(ACLService.prototype, "change", {
|
|
369
|
+
/** ACL变更通知 */
|
|
370
|
+
get: function () {
|
|
371
|
+
return this.aclChange.asObservable();
|
|
372
|
+
},
|
|
373
|
+
enumerable: false,
|
|
374
|
+
configurable: true
|
|
375
|
+
});
|
|
376
|
+
Object.defineProperty(ACLService.prototype, "data", {
|
|
377
|
+
/** 获取所有数据 */
|
|
378
|
+
get: function () {
|
|
379
|
+
return {
|
|
380
|
+
full: this.full,
|
|
381
|
+
roles: this.roles,
|
|
382
|
+
abilities: this.abilities
|
|
383
|
+
};
|
|
384
|
+
},
|
|
385
|
+
enumerable: false,
|
|
386
|
+
configurable: true
|
|
387
|
+
});
|
|
388
|
+
Object.defineProperty(ACLService.prototype, "guard_url", {
|
|
389
|
+
get: function () {
|
|
390
|
+
return this.options.guard_url;
|
|
391
|
+
},
|
|
392
|
+
enumerable: false,
|
|
393
|
+
configurable: true
|
|
394
|
+
});
|
|
395
|
+
ACLService.prototype.parseACLType = function (val) {
|
|
396
|
+
var t;
|
|
397
|
+
if (typeof val === 'number') {
|
|
398
|
+
t = { ability: [val] };
|
|
399
|
+
}
|
|
400
|
+
else if (Array.isArray(val) && val.length > 0 && typeof val[0] === 'number') {
|
|
401
|
+
t = { ability: val };
|
|
402
|
+
}
|
|
403
|
+
else if (typeof val === 'object' && !Array.isArray(val)) {
|
|
404
|
+
t = Object.assign({}, val);
|
|
405
|
+
}
|
|
406
|
+
else if (Array.isArray(val)) {
|
|
407
|
+
t = { role: val };
|
|
408
|
+
}
|
|
409
|
+
else {
|
|
410
|
+
t = { role: val == null ? [] : [val] };
|
|
411
|
+
}
|
|
412
|
+
return Object.assign({ except: false }, t);
|
|
413
|
+
};
|
|
414
|
+
/**
|
|
415
|
+
* 设置当前用户角色或权限能力(会先清除所有)
|
|
416
|
+
*/
|
|
417
|
+
ACLService.prototype.set = function (value) {
|
|
418
|
+
this.full = false;
|
|
419
|
+
this.abilities = [];
|
|
420
|
+
this.roles = [];
|
|
421
|
+
this.add(value);
|
|
422
|
+
this.aclChange.next(value);
|
|
423
|
+
};
|
|
424
|
+
/**
|
|
425
|
+
* 标识当前用户为全量,即不受限
|
|
426
|
+
*/
|
|
427
|
+
ACLService.prototype.setFull = function (val) {
|
|
428
|
+
this.full = val;
|
|
429
|
+
this.aclChange.next(val);
|
|
430
|
+
};
|
|
431
|
+
/**
|
|
432
|
+
* 设置当前用户权限能力(会先清除所有)
|
|
433
|
+
*/
|
|
434
|
+
ACLService.prototype.setAbility = function (abilities) {
|
|
435
|
+
this.set({ ability: abilities });
|
|
436
|
+
};
|
|
437
|
+
/**
|
|
438
|
+
* 设置当前用户角色(会先清除所有)
|
|
439
|
+
*/
|
|
440
|
+
ACLService.prototype.setRole = function (roles) {
|
|
441
|
+
this.set({ role: roles });
|
|
442
|
+
};
|
|
443
|
+
/**
|
|
444
|
+
* 为当前用户增加角色或权限能力
|
|
445
|
+
*/
|
|
446
|
+
ACLService.prototype.add = function (value) {
|
|
447
|
+
var _a, _b;
|
|
448
|
+
if (value.role && value.role.length > 0) {
|
|
449
|
+
(_a = this.roles).push.apply(_a, __spreadArray([], __read(value.role)));
|
|
450
|
+
}
|
|
451
|
+
if (value.ability && value.ability.length > 0) {
|
|
452
|
+
(_b = this.abilities).push.apply(_b, __spreadArray([], __read(value.ability)));
|
|
453
|
+
}
|
|
454
|
+
};
|
|
455
|
+
/**
|
|
456
|
+
* 为当前用户附加角色
|
|
457
|
+
*/
|
|
458
|
+
ACLService.prototype.attachRole = function (roles) {
|
|
459
|
+
var e_1, _a;
|
|
460
|
+
try {
|
|
461
|
+
for (var roles_1 = __values(roles), roles_1_1 = roles_1.next(); !roles_1_1.done; roles_1_1 = roles_1.next()) {
|
|
462
|
+
var val = roles_1_1.value;
|
|
463
|
+
if (!this.roles.includes(val)) {
|
|
464
|
+
this.roles.push(val);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
469
|
+
finally {
|
|
470
|
+
try {
|
|
471
|
+
if (roles_1_1 && !roles_1_1.done && (_a = roles_1.return)) _a.call(roles_1);
|
|
472
|
+
}
|
|
473
|
+
finally { if (e_1) throw e_1.error; }
|
|
474
|
+
}
|
|
475
|
+
this.aclChange.next(this.data);
|
|
476
|
+
};
|
|
477
|
+
/**
|
|
478
|
+
* 为当前用户附加权限
|
|
479
|
+
*/
|
|
480
|
+
ACLService.prototype.attachAbility = function (abilities) {
|
|
481
|
+
var e_2, _a;
|
|
482
|
+
try {
|
|
483
|
+
for (var abilities_1 = __values(abilities), abilities_1_1 = abilities_1.next(); !abilities_1_1.done; abilities_1_1 = abilities_1.next()) {
|
|
484
|
+
var val = abilities_1_1.value;
|
|
485
|
+
if (!this.abilities.includes(val)) {
|
|
486
|
+
this.abilities.push(val);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
491
|
+
finally {
|
|
492
|
+
try {
|
|
493
|
+
if (abilities_1_1 && !abilities_1_1.done && (_a = abilities_1.return)) _a.call(abilities_1);
|
|
494
|
+
}
|
|
495
|
+
finally { if (e_2) throw e_2.error; }
|
|
496
|
+
}
|
|
497
|
+
this.aclChange.next(this.data);
|
|
498
|
+
};
|
|
499
|
+
/**
|
|
500
|
+
* 为当前用户移除角色
|
|
501
|
+
*/
|
|
502
|
+
ACLService.prototype.removeRole = function (roles) {
|
|
503
|
+
var e_3, _a;
|
|
504
|
+
try {
|
|
505
|
+
for (var roles_2 = __values(roles), roles_2_1 = roles_2.next(); !roles_2_1.done; roles_2_1 = roles_2.next()) {
|
|
506
|
+
var val = roles_2_1.value;
|
|
507
|
+
var idx = this.roles.indexOf(val);
|
|
508
|
+
if (idx !== -1) {
|
|
509
|
+
this.roles.splice(idx, 1);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
514
|
+
finally {
|
|
515
|
+
try {
|
|
516
|
+
if (roles_2_1 && !roles_2_1.done && (_a = roles_2.return)) _a.call(roles_2);
|
|
517
|
+
}
|
|
518
|
+
finally { if (e_3) throw e_3.error; }
|
|
519
|
+
}
|
|
520
|
+
this.aclChange.next(this.data);
|
|
521
|
+
};
|
|
522
|
+
/**
|
|
523
|
+
* 为当前用户移除权限
|
|
524
|
+
*/
|
|
525
|
+
ACLService.prototype.removeAbility = function (abilities) {
|
|
526
|
+
var e_4, _a;
|
|
527
|
+
try {
|
|
528
|
+
for (var abilities_2 = __values(abilities), abilities_2_1 = abilities_2.next(); !abilities_2_1.done; abilities_2_1 = abilities_2.next()) {
|
|
529
|
+
var val = abilities_2_1.value;
|
|
530
|
+
var idx = this.abilities.indexOf(val);
|
|
531
|
+
if (idx !== -1) {
|
|
532
|
+
this.abilities.splice(idx, 1);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
537
|
+
finally {
|
|
538
|
+
try {
|
|
539
|
+
if (abilities_2_1 && !abilities_2_1.done && (_a = abilities_2.return)) _a.call(abilities_2);
|
|
540
|
+
}
|
|
541
|
+
finally { if (e_4) throw e_4.error; }
|
|
542
|
+
}
|
|
543
|
+
this.aclChange.next(this.data);
|
|
544
|
+
};
|
|
545
|
+
/**
|
|
546
|
+
* 当前用户是否有对应角色,其实 `number` 表示Ability
|
|
547
|
+
*
|
|
548
|
+
* - 当 `full: true` 或参数 `null` 时返回 `true`
|
|
549
|
+
* - 若使用 `ACLType` 参数,可以指定 `mode` 校验模式
|
|
550
|
+
*/
|
|
551
|
+
ACLService.prototype.can = function (roleOrAbility) {
|
|
552
|
+
var _this = this;
|
|
553
|
+
var preCan = this.options.preCan;
|
|
554
|
+
if (preCan) {
|
|
555
|
+
roleOrAbility = preCan(roleOrAbility);
|
|
556
|
+
}
|
|
557
|
+
var t = this.parseACLType(roleOrAbility);
|
|
558
|
+
var result = false;
|
|
559
|
+
if (this.full === true || !roleOrAbility) {
|
|
560
|
+
result = true;
|
|
561
|
+
}
|
|
562
|
+
else {
|
|
563
|
+
if (t.role && t.role.length > 0) {
|
|
564
|
+
if (t.mode === 'allOf') {
|
|
565
|
+
result = t.role.every(function (v) { return _this.roles.includes(v); });
|
|
566
|
+
}
|
|
567
|
+
else {
|
|
568
|
+
result = t.role.some(function (v) { return _this.roles.includes(v); });
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
if (t.ability && t.ability.length > 0) {
|
|
572
|
+
if (t.mode === 'allOf') {
|
|
573
|
+
result = t.ability.every(function (v) { return _this.abilities.includes(v); });
|
|
574
|
+
}
|
|
575
|
+
else {
|
|
576
|
+
result = t.ability.some(function (v) { return _this.abilities.includes(v); });
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
return t.except === true ? !result : result;
|
|
581
|
+
};
|
|
582
|
+
/** @inner */
|
|
583
|
+
ACLService.prototype.parseAbility = function (value) {
|
|
584
|
+
if (typeof value === 'number' || typeof value === 'string' || Array.isArray(value)) {
|
|
585
|
+
value = { ability: Array.isArray(value) ? value : [value] };
|
|
586
|
+
}
|
|
587
|
+
delete value.role;
|
|
588
|
+
return value;
|
|
589
|
+
};
|
|
590
|
+
/**
|
|
591
|
+
* 当前用户是否有对应权限点
|
|
592
|
+
*/
|
|
593
|
+
ACLService.prototype.canAbility = function (value) {
|
|
594
|
+
return this.can(this.parseAbility(value));
|
|
595
|
+
};
|
|
596
|
+
return ACLService;
|
|
597
|
+
}());
|
|
598
|
+
ACLService.decorators = [
|
|
599
|
+
{ type: i0.Injectable }
|
|
600
|
+
];
|
|
601
|
+
ACLService.ctorParameters = function () { return [
|
|
602
|
+
{ type: config.YunzaiConfigService }
|
|
605
603
|
]; };
|
|
606
604
|
|
|
607
|
-
var ACLIfDirective = /** @class */ (function () {
|
|
608
|
-
function ACLIfDirective(templateRef, srv, _viewContainer) {
|
|
609
|
-
var _this = this;
|
|
610
|
-
this.srv = srv;
|
|
611
|
-
this._viewContainer = _viewContainer;
|
|
612
|
-
this._thenTemplateRef = null;
|
|
613
|
-
this._elseTemplateRef = null;
|
|
614
|
-
this._thenViewRef = null;
|
|
615
|
-
this._elseViewRef = null;
|
|
616
|
-
this._except = false;
|
|
617
|
-
this._change$ = this.srv.change.pipe(operators.filter(function (r) { return r != null; })).subscribe(function () { return _this._updateView(); });
|
|
618
|
-
this._thenTemplateRef = templateRef;
|
|
619
|
-
}
|
|
620
|
-
Object.defineProperty(ACLIfDirective.prototype, "aclIf", {
|
|
621
|
-
set: function (value) {
|
|
622
|
-
this._value = value;
|
|
623
|
-
this._updateView();
|
|
624
|
-
},
|
|
625
|
-
enumerable: false,
|
|
626
|
-
configurable: true
|
|
627
|
-
});
|
|
628
|
-
Object.defineProperty(ACLIfDirective.prototype, "aclIfThen", {
|
|
629
|
-
set: function (templateRef) {
|
|
630
|
-
this._thenTemplateRef = templateRef;
|
|
631
|
-
this._thenViewRef = null;
|
|
632
|
-
this._updateView();
|
|
633
|
-
},
|
|
634
|
-
enumerable: false,
|
|
635
|
-
configurable: true
|
|
636
|
-
});
|
|
637
|
-
Object.defineProperty(ACLIfDirective.prototype, "aclIfElse", {
|
|
638
|
-
set: function (templateRef) {
|
|
639
|
-
this._elseTemplateRef = templateRef;
|
|
640
|
-
this._elseViewRef = null;
|
|
641
|
-
this._updateView();
|
|
642
|
-
},
|
|
643
|
-
enumerable: false,
|
|
644
|
-
configurable: true
|
|
645
|
-
});
|
|
646
|
-
Object.defineProperty(ACLIfDirective.prototype, "except", {
|
|
647
|
-
get: function () {
|
|
648
|
-
return this._except;
|
|
649
|
-
},
|
|
650
|
-
set: function (value) {
|
|
651
|
-
this._except = value != null && "" + value !== 'false';
|
|
652
|
-
},
|
|
653
|
-
enumerable: false,
|
|
654
|
-
configurable: true
|
|
655
|
-
});
|
|
656
|
-
ACLIfDirective.prototype._updateView = function () {
|
|
657
|
-
var res = this.srv.can(this._value);
|
|
658
|
-
if ((res && !this.except) || (!res && this.except)) {
|
|
659
|
-
if (!this._thenViewRef) {
|
|
660
|
-
this._viewContainer.clear();
|
|
661
|
-
this._elseViewRef = null;
|
|
662
|
-
if (this._thenTemplateRef) {
|
|
663
|
-
this._thenViewRef = this._viewContainer.createEmbeddedView(this._thenTemplateRef);
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
}
|
|
667
|
-
else {
|
|
668
|
-
if (!this._elseViewRef) {
|
|
669
|
-
this._viewContainer.clear();
|
|
670
|
-
this._thenViewRef = null;
|
|
671
|
-
if (this._elseTemplateRef) {
|
|
672
|
-
this._elseViewRef = this._viewContainer.createEmbeddedView(this._elseTemplateRef);
|
|
673
|
-
}
|
|
674
|
-
}
|
|
675
|
-
}
|
|
676
|
-
};
|
|
677
|
-
ACLIfDirective.prototype.ngOnDestroy = function () {
|
|
678
|
-
this._change$.unsubscribe();
|
|
679
|
-
};
|
|
680
|
-
return ACLIfDirective;
|
|
681
|
-
}());
|
|
682
|
-
ACLIfDirective.decorators = [
|
|
683
|
-
{ type: i0.Directive, args: [{
|
|
684
|
-
selector: '[aclIf]',
|
|
685
|
-
exportAs: 'aclIf'
|
|
686
|
-
},] }
|
|
687
|
-
];
|
|
688
|
-
ACLIfDirective.ctorParameters = function () { return [
|
|
689
|
-
{ type: i0.TemplateRef },
|
|
690
|
-
{ type: ACLService },
|
|
691
|
-
{ type: i0.ViewContainerRef }
|
|
692
|
-
]; };
|
|
693
|
-
ACLIfDirective.propDecorators = {
|
|
694
|
-
aclIf: [{ type: i0.Input }],
|
|
695
|
-
aclIfThen: [{ type: i0.Input }],
|
|
696
|
-
aclIfElse: [{ type: i0.Input }],
|
|
697
|
-
except: [{ type: i0.Input }]
|
|
605
|
+
var ACLIfDirective = /** @class */ (function () {
|
|
606
|
+
function ACLIfDirective(templateRef, srv, _viewContainer) {
|
|
607
|
+
var _this = this;
|
|
608
|
+
this.srv = srv;
|
|
609
|
+
this._viewContainer = _viewContainer;
|
|
610
|
+
this._thenTemplateRef = null;
|
|
611
|
+
this._elseTemplateRef = null;
|
|
612
|
+
this._thenViewRef = null;
|
|
613
|
+
this._elseViewRef = null;
|
|
614
|
+
this._except = false;
|
|
615
|
+
this._change$ = this.srv.change.pipe(operators.filter(function (r) { return r != null; })).subscribe(function () { return _this._updateView(); });
|
|
616
|
+
this._thenTemplateRef = templateRef;
|
|
617
|
+
}
|
|
618
|
+
Object.defineProperty(ACLIfDirective.prototype, "aclIf", {
|
|
619
|
+
set: function (value) {
|
|
620
|
+
this._value = value;
|
|
621
|
+
this._updateView();
|
|
622
|
+
},
|
|
623
|
+
enumerable: false,
|
|
624
|
+
configurable: true
|
|
625
|
+
});
|
|
626
|
+
Object.defineProperty(ACLIfDirective.prototype, "aclIfThen", {
|
|
627
|
+
set: function (templateRef) {
|
|
628
|
+
this._thenTemplateRef = templateRef;
|
|
629
|
+
this._thenViewRef = null;
|
|
630
|
+
this._updateView();
|
|
631
|
+
},
|
|
632
|
+
enumerable: false,
|
|
633
|
+
configurable: true
|
|
634
|
+
});
|
|
635
|
+
Object.defineProperty(ACLIfDirective.prototype, "aclIfElse", {
|
|
636
|
+
set: function (templateRef) {
|
|
637
|
+
this._elseTemplateRef = templateRef;
|
|
638
|
+
this._elseViewRef = null;
|
|
639
|
+
this._updateView();
|
|
640
|
+
},
|
|
641
|
+
enumerable: false,
|
|
642
|
+
configurable: true
|
|
643
|
+
});
|
|
644
|
+
Object.defineProperty(ACLIfDirective.prototype, "except", {
|
|
645
|
+
get: function () {
|
|
646
|
+
return this._except;
|
|
647
|
+
},
|
|
648
|
+
set: function (value) {
|
|
649
|
+
this._except = value != null && "" + value !== 'false';
|
|
650
|
+
},
|
|
651
|
+
enumerable: false,
|
|
652
|
+
configurable: true
|
|
653
|
+
});
|
|
654
|
+
ACLIfDirective.prototype._updateView = function () {
|
|
655
|
+
var res = this.srv.can(this._value);
|
|
656
|
+
if ((res && !this.except) || (!res && this.except)) {
|
|
657
|
+
if (!this._thenViewRef) {
|
|
658
|
+
this._viewContainer.clear();
|
|
659
|
+
this._elseViewRef = null;
|
|
660
|
+
if (this._thenTemplateRef) {
|
|
661
|
+
this._thenViewRef = this._viewContainer.createEmbeddedView(this._thenTemplateRef);
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
else {
|
|
666
|
+
if (!this._elseViewRef) {
|
|
667
|
+
this._viewContainer.clear();
|
|
668
|
+
this._thenViewRef = null;
|
|
669
|
+
if (this._elseTemplateRef) {
|
|
670
|
+
this._elseViewRef = this._viewContainer.createEmbeddedView(this._elseTemplateRef);
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
};
|
|
675
|
+
ACLIfDirective.prototype.ngOnDestroy = function () {
|
|
676
|
+
this._change$.unsubscribe();
|
|
677
|
+
};
|
|
678
|
+
return ACLIfDirective;
|
|
679
|
+
}());
|
|
680
|
+
ACLIfDirective.decorators = [
|
|
681
|
+
{ type: i0.Directive, args: [{
|
|
682
|
+
selector: '[aclIf]',
|
|
683
|
+
exportAs: 'aclIf'
|
|
684
|
+
},] }
|
|
685
|
+
];
|
|
686
|
+
ACLIfDirective.ctorParameters = function () { return [
|
|
687
|
+
{ type: i0.TemplateRef },
|
|
688
|
+
{ type: ACLService },
|
|
689
|
+
{ type: i0.ViewContainerRef }
|
|
690
|
+
]; };
|
|
691
|
+
ACLIfDirective.propDecorators = {
|
|
692
|
+
aclIf: [{ type: i0.Input }],
|
|
693
|
+
aclIfThen: [{ type: i0.Input }],
|
|
694
|
+
aclIfElse: [{ type: i0.Input }],
|
|
695
|
+
except: [{ type: i0.Input }]
|
|
698
696
|
};
|
|
699
697
|
|
|
700
|
-
var ACLDirective = /** @class */ (function () {
|
|
701
|
-
function ACLDirective(el, renderer, srv) {
|
|
702
|
-
var _this = this;
|
|
703
|
-
this.el = el;
|
|
704
|
-
this.renderer = renderer;
|
|
705
|
-
this.srv = srv;
|
|
706
|
-
this.change$ = this.srv.change.pipe(operators.filter(function (r) { return r != null; })).subscribe(function () { return _this.set(_this._value); });
|
|
707
|
-
}
|
|
708
|
-
Object.defineProperty(ACLDirective.prototype, "acl", {
|
|
709
|
-
set: function (value) {
|
|
710
|
-
this.set(value);
|
|
711
|
-
},
|
|
712
|
-
enumerable: false,
|
|
713
|
-
configurable: true
|
|
714
|
-
});
|
|
715
|
-
Object.defineProperty(ACLDirective.prototype, "ability", {
|
|
716
|
-
set: function (value) {
|
|
717
|
-
this.set(this.srv.parseAbility(value));
|
|
718
|
-
},
|
|
719
|
-
enumerable: false,
|
|
720
|
-
configurable: true
|
|
721
|
-
});
|
|
722
|
-
ACLDirective.prototype.set = function (value) {
|
|
723
|
-
this._value = value;
|
|
724
|
-
var CLS = 'acl__hide';
|
|
725
|
-
var el = this.el.nativeElement;
|
|
726
|
-
if (this.srv.can(this._value)) {
|
|
727
|
-
this.renderer.removeClass(el, CLS);
|
|
728
|
-
}
|
|
729
|
-
else {
|
|
730
|
-
this.renderer.addClass(el, CLS);
|
|
731
|
-
}
|
|
732
|
-
};
|
|
733
|
-
ACLDirective.prototype.ngOnDestroy = function () {
|
|
734
|
-
this.change$.unsubscribe();
|
|
735
|
-
};
|
|
736
|
-
return ACLDirective;
|
|
737
|
-
}());
|
|
738
|
-
ACLDirective.decorators = [
|
|
739
|
-
{ type: i0.Directive, args: [{
|
|
740
|
-
selector: '[acl]',
|
|
741
|
-
exportAs: 'acl'
|
|
742
|
-
},] }
|
|
743
|
-
];
|
|
744
|
-
ACLDirective.ctorParameters = function () { return [
|
|
745
|
-
{ type: i0.ElementRef },
|
|
746
|
-
{ type: i0.Renderer2 },
|
|
747
|
-
{ type: ACLService }
|
|
748
|
-
]; };
|
|
749
|
-
ACLDirective.propDecorators = {
|
|
750
|
-
acl: [{ type: i0.Input, args: ['acl',] }],
|
|
751
|
-
ability: [{ type: i0.Input, args: ['acl-ability',] }]
|
|
698
|
+
var ACLDirective = /** @class */ (function () {
|
|
699
|
+
function ACLDirective(el, renderer, srv) {
|
|
700
|
+
var _this = this;
|
|
701
|
+
this.el = el;
|
|
702
|
+
this.renderer = renderer;
|
|
703
|
+
this.srv = srv;
|
|
704
|
+
this.change$ = this.srv.change.pipe(operators.filter(function (r) { return r != null; })).subscribe(function () { return _this.set(_this._value); });
|
|
705
|
+
}
|
|
706
|
+
Object.defineProperty(ACLDirective.prototype, "acl", {
|
|
707
|
+
set: function (value) {
|
|
708
|
+
this.set(value);
|
|
709
|
+
},
|
|
710
|
+
enumerable: false,
|
|
711
|
+
configurable: true
|
|
712
|
+
});
|
|
713
|
+
Object.defineProperty(ACLDirective.prototype, "ability", {
|
|
714
|
+
set: function (value) {
|
|
715
|
+
this.set(this.srv.parseAbility(value));
|
|
716
|
+
},
|
|
717
|
+
enumerable: false,
|
|
718
|
+
configurable: true
|
|
719
|
+
});
|
|
720
|
+
ACLDirective.prototype.set = function (value) {
|
|
721
|
+
this._value = value;
|
|
722
|
+
var CLS = 'acl__hide';
|
|
723
|
+
var el = this.el.nativeElement;
|
|
724
|
+
if (this.srv.can(this._value)) {
|
|
725
|
+
this.renderer.removeClass(el, CLS);
|
|
726
|
+
}
|
|
727
|
+
else {
|
|
728
|
+
this.renderer.addClass(el, CLS);
|
|
729
|
+
}
|
|
730
|
+
};
|
|
731
|
+
ACLDirective.prototype.ngOnDestroy = function () {
|
|
732
|
+
this.change$.unsubscribe();
|
|
733
|
+
};
|
|
734
|
+
return ACLDirective;
|
|
735
|
+
}());
|
|
736
|
+
ACLDirective.decorators = [
|
|
737
|
+
{ type: i0.Directive, args: [{
|
|
738
|
+
selector: '[acl]',
|
|
739
|
+
exportAs: 'acl'
|
|
740
|
+
},] }
|
|
741
|
+
];
|
|
742
|
+
ACLDirective.ctorParameters = function () { return [
|
|
743
|
+
{ type: i0.ElementRef },
|
|
744
|
+
{ type: i0.Renderer2 },
|
|
745
|
+
{ type: ACLService }
|
|
746
|
+
]; };
|
|
747
|
+
ACLDirective.propDecorators = {
|
|
748
|
+
acl: [{ type: i0.Input, args: ['acl',] }],
|
|
749
|
+
ability: [{ type: i0.Input, args: ['acl-ability',] }]
|
|
752
750
|
};
|
|
753
751
|
|
|
754
|
-
/**
|
|
755
|
-
* Routing guard prevent unauthorized users visit the page, [ACL Document](https://ng.yunzainfo.com/acl).
|
|
756
|
-
*
|
|
757
|
-
* ```ts
|
|
758
|
-
* data: {
|
|
759
|
-
* path: 'home',
|
|
760
|
-
* canActivate: [ ACLGuard ],
|
|
761
|
-
* data: { guard: 'user1' }
|
|
762
|
-
* }
|
|
763
|
-
* ```
|
|
764
|
-
*/
|
|
765
|
-
var ACLGuard = /** @class */ (function () {
|
|
766
|
-
function ACLGuard(srv, router) {
|
|
767
|
-
this.srv = srv;
|
|
768
|
-
this.router = router;
|
|
769
|
-
}
|
|
770
|
-
ACLGuard.prototype.process = function (data) {
|
|
771
|
-
var _this = this;
|
|
772
|
-
data = Object.assign({ guard: null, guard_url: this.srv.guard_url }, data);
|
|
773
|
-
var guard = data.guard;
|
|
774
|
-
return (guard && guard instanceof rxjs.Observable ? guard : rxjs.of(guard != null ? guard : null)).pipe(operators.map(function (v) { return _this.srv.can(v); }), operators.tap(function (v) {
|
|
775
|
-
if (v)
|
|
776
|
-
return;
|
|
777
|
-
_this.router.navigateByUrl(data.guard_url);
|
|
778
|
-
}));
|
|
779
|
-
};
|
|
780
|
-
// lazy loading
|
|
781
|
-
ACLGuard.prototype.canLoad = function (route) {
|
|
782
|
-
return this.process(route.data);
|
|
783
|
-
};
|
|
784
|
-
// all children route
|
|
785
|
-
ACLGuard.prototype.canActivateChild = function (childRoute, state) {
|
|
786
|
-
return this.canActivate(childRoute, state);
|
|
787
|
-
};
|
|
788
|
-
// route
|
|
789
|
-
ACLGuard.prototype.canActivate = function (route, _state) {
|
|
790
|
-
return this.process(route.data);
|
|
791
|
-
};
|
|
792
|
-
return ACLGuard;
|
|
793
|
-
}());
|
|
794
|
-
ACLGuard.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function ACLGuard_Factory() { return new ACLGuard(i0__namespace.ɵɵinject(ACLService), i0__namespace.ɵɵinject(i2__namespace.Router)); }, token: ACLGuard, providedIn: "root" });
|
|
795
|
-
ACLGuard.decorators = [
|
|
796
|
-
{ type: i0.Injectable, args: [{ providedIn: 'root' },] }
|
|
797
|
-
];
|
|
798
|
-
ACLGuard.ctorParameters = function () { return [
|
|
799
|
-
{ type: ACLService },
|
|
800
|
-
{ type: i2.Router }
|
|
752
|
+
/**
|
|
753
|
+
* Routing guard prevent unauthorized users visit the page, [ACL Document](https://ng.yunzainfo.com/acl).
|
|
754
|
+
*
|
|
755
|
+
* ```ts
|
|
756
|
+
* data: {
|
|
757
|
+
* path: 'home',
|
|
758
|
+
* canActivate: [ ACLGuard ],
|
|
759
|
+
* data: { guard: 'user1' }
|
|
760
|
+
* }
|
|
761
|
+
* ```
|
|
762
|
+
*/
|
|
763
|
+
var ACLGuard = /** @class */ (function () {
|
|
764
|
+
function ACLGuard(srv, router) {
|
|
765
|
+
this.srv = srv;
|
|
766
|
+
this.router = router;
|
|
767
|
+
}
|
|
768
|
+
ACLGuard.prototype.process = function (data) {
|
|
769
|
+
var _this = this;
|
|
770
|
+
data = Object.assign({ guard: null, guard_url: this.srv.guard_url }, data);
|
|
771
|
+
var guard = data.guard;
|
|
772
|
+
return (guard && guard instanceof rxjs.Observable ? guard : rxjs.of(guard != null ? guard : null)).pipe(operators.map(function (v) { return _this.srv.can(v); }), operators.tap(function (v) {
|
|
773
|
+
if (v)
|
|
774
|
+
return;
|
|
775
|
+
_this.router.navigateByUrl(data.guard_url);
|
|
776
|
+
}));
|
|
777
|
+
};
|
|
778
|
+
// lazy loading
|
|
779
|
+
ACLGuard.prototype.canLoad = function (route) {
|
|
780
|
+
return this.process(route.data);
|
|
781
|
+
};
|
|
782
|
+
// all children route
|
|
783
|
+
ACLGuard.prototype.canActivateChild = function (childRoute, state) {
|
|
784
|
+
return this.canActivate(childRoute, state);
|
|
785
|
+
};
|
|
786
|
+
// route
|
|
787
|
+
ACLGuard.prototype.canActivate = function (route, _state) {
|
|
788
|
+
return this.process(route.data);
|
|
789
|
+
};
|
|
790
|
+
return ACLGuard;
|
|
791
|
+
}());
|
|
792
|
+
ACLGuard.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function ACLGuard_Factory() { return new ACLGuard(i0__namespace.ɵɵinject(ACLService), i0__namespace.ɵɵinject(i2__namespace.Router)); }, token: ACLGuard, providedIn: "root" });
|
|
793
|
+
ACLGuard.decorators = [
|
|
794
|
+
{ type: i0.Injectable, args: [{ providedIn: 'root' },] }
|
|
795
|
+
];
|
|
796
|
+
ACLGuard.ctorParameters = function () { return [
|
|
797
|
+
{ type: ACLService },
|
|
798
|
+
{ type: i2.Router }
|
|
801
799
|
]; };
|
|
802
800
|
|
|
803
|
-
var COMPONENTS = [ACLDirective, ACLIfDirective];
|
|
804
|
-
var YelonACLModule = /** @class */ (function () {
|
|
805
|
-
function YelonACLModule() {
|
|
806
|
-
}
|
|
807
|
-
YelonACLModule.forRoot = function () {
|
|
808
|
-
return {
|
|
809
|
-
ngModule: YelonACLModule,
|
|
810
|
-
providers: [ACLService]
|
|
811
|
-
};
|
|
812
|
-
};
|
|
813
|
-
return YelonACLModule;
|
|
814
|
-
}());
|
|
815
|
-
YelonACLModule.decorators = [
|
|
816
|
-
{ type: i0.NgModule, args: [{
|
|
817
|
-
imports: [common.CommonModule],
|
|
818
|
-
declarations: COMPONENTS,
|
|
819
|
-
exports: COMPONENTS
|
|
820
|
-
},] }
|
|
801
|
+
var COMPONENTS = [ACLDirective, ACLIfDirective];
|
|
802
|
+
var YelonACLModule = /** @class */ (function () {
|
|
803
|
+
function YelonACLModule() {
|
|
804
|
+
}
|
|
805
|
+
YelonACLModule.forRoot = function () {
|
|
806
|
+
return {
|
|
807
|
+
ngModule: YelonACLModule,
|
|
808
|
+
providers: [ACLService]
|
|
809
|
+
};
|
|
810
|
+
};
|
|
811
|
+
return YelonACLModule;
|
|
812
|
+
}());
|
|
813
|
+
YelonACLModule.decorators = [
|
|
814
|
+
{ type: i0.NgModule, args: [{
|
|
815
|
+
imports: [common.CommonModule],
|
|
816
|
+
declarations: COMPONENTS,
|
|
817
|
+
exports: COMPONENTS
|
|
818
|
+
},] }
|
|
821
819
|
];
|
|
822
820
|
|
|
823
|
-
/**
|
|
824
|
-
* Generated bundle index. Do not edit.
|
|
821
|
+
/**
|
|
822
|
+
* Generated bundle index. Do not edit.
|
|
825
823
|
*/
|
|
826
824
|
|
|
827
825
|
exports.ACLDirective = ACLDirective;
|
|
@@ -833,5 +831,5 @@
|
|
|
833
831
|
|
|
834
832
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
835
833
|
|
|
836
|
-
}))
|
|
834
|
+
}));
|
|
837
835
|
//# sourceMappingURL=acl.umd.js.map
|