@seniorsistemas/yms-integration 1.10.6 → 1.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/seniorsistemas-yms-integration.umd.js +96 -18
- package/bundles/seniorsistemas-yms-integration.umd.js.map +1 -1
- package/bundles/seniorsistemas-yms-integration.umd.min.js +1 -1
- package/bundles/seniorsistemas-yms-integration.umd.min.js.map +1 -1
- package/esm2015/src/devices/cancelas/cancelas.service.js +5 -1
- package/esm2015/src/devices/cancelas/controlador-cancela/controlador-cancela.component.js +91 -21
- package/esm2015/src/devices/cancelas/gate.js +1 -1
- package/esm5/src/devices/cancelas/cancelas.service.js +5 -1
- package/esm5/src/devices/cancelas/controlador-cancela/controlador-cancela.component.js +94 -21
- package/esm5/src/devices/cancelas/gate.js +1 -1
- package/fesm2015/seniorsistemas-yms-integration.js +95 -20
- package/fesm2015/seniorsistemas-yms-integration.js.map +1 -1
- package/fesm5/seniorsistemas-yms-integration.js +98 -20
- package/fesm5/seniorsistemas-yms-integration.js.map +1 -1
- package/package.json +1 -1
- package/seniorsistemas-yms-integration.metadata.json +1 -1
- package/src/devices/cancelas/cancelas.service.d.ts +1 -0
- package/src/devices/cancelas/controlador-cancela/controlador-cancela.component.d.ts +12 -8
- package/src/devices/cancelas/gate.d.ts +2 -0
|
@@ -188,6 +188,10 @@
|
|
|
188
188
|
ControladorCancelasService.prototype.closeGate = function (ip) {
|
|
189
189
|
return this.http.post(this.url + "actions/closeGate", { ip: ip }).pipe(this.defaultCatch());
|
|
190
190
|
};
|
|
191
|
+
ControladorCancelasService.prototype.checkAccess = function (resources) {
|
|
192
|
+
var acess = { includeFilters: false, permissions: resources };
|
|
193
|
+
return this.http.post("platform/authorization/queries/checkAccess", acess).pipe(this.defaultCatch());
|
|
194
|
+
};
|
|
191
195
|
ControladorCancelasService = __decorate([
|
|
192
196
|
core.Injectable(),
|
|
193
197
|
__metadata("design:paramtypes", [http.HttpClient, api.MessageService])
|
|
@@ -212,35 +216,90 @@
|
|
|
212
216
|
}());
|
|
213
217
|
var ControladorCancelaComponent = /** @class */ (function (_super) {
|
|
214
218
|
__extends(ControladorCancelaComponent, _super);
|
|
215
|
-
function ControladorCancelaComponent(service, translate
|
|
219
|
+
function ControladorCancelaComponent(service, translate) {
|
|
216
220
|
var _this = _super.call(this) || this;
|
|
217
221
|
_this.service = service;
|
|
218
222
|
_this.translate = translate;
|
|
219
|
-
_this.permissionsService = permissionsService;
|
|
220
223
|
_this.successState = 'default';
|
|
221
|
-
_this.
|
|
222
|
-
_this.
|
|
224
|
+
_this.permissionOpenGate = false;
|
|
225
|
+
_this.permissionCloseGate = false;
|
|
226
|
+
_this.uriGateDefault = "res://senior.com.br/yms/devices/gate";
|
|
223
227
|
_this.unsubscribe$ = new rxjs.Subject();
|
|
224
228
|
_this.gates$ = new rxjs.Subject();
|
|
225
229
|
return _this;
|
|
226
230
|
}
|
|
227
231
|
ControladorCancelaComponent.prototype.ngOnInit = function () {
|
|
232
|
+
this.checkPermissionsGates();
|
|
233
|
+
};
|
|
234
|
+
ControladorCancelaComponent.prototype.checkPermissionsGates = function () {
|
|
228
235
|
var _this = this;
|
|
229
236
|
this.service
|
|
230
237
|
.listGateByArea(this.sequenciaCircuito.area.id)
|
|
231
238
|
.pipe(operators.takeUntil(this.unsubscribe$))
|
|
232
|
-
.subscribe(function (res) {
|
|
233
|
-
|
|
234
|
-
.
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
_this.canOpenGate = true;
|
|
239
|
+
.subscribe(function (res) {
|
|
240
|
+
var gates = res.contents;
|
|
241
|
+
var resourcesUri = _this.buildResourceGateAndAction(gates);
|
|
242
|
+
if (resourcesUri.length <= 0) {
|
|
243
|
+
return;
|
|
238
244
|
}
|
|
239
|
-
|
|
240
|
-
|
|
245
|
+
_this.checkAcessPermissionGate(resourcesUri, gates);
|
|
246
|
+
});
|
|
247
|
+
};
|
|
248
|
+
ControladorCancelaComponent.prototype.buildResourceGateAndAction = function (gates) {
|
|
249
|
+
var resourcesUri = [];
|
|
250
|
+
resourcesUri.push({ resource: this.uriGateDefault, action: "Close" });
|
|
251
|
+
resourcesUri.push({ resource: this.uriGateDefault, action: "Open" });
|
|
252
|
+
gates.filter(function (gate) {
|
|
253
|
+
if (gate.resourceUri !== undefined) {
|
|
254
|
+
resourcesUri.push({ resource: gate.resourceUri, action: "Close" });
|
|
255
|
+
resourcesUri.push({ resource: gate.resourceUri, action: "Open" });
|
|
241
256
|
}
|
|
242
|
-
})
|
|
243
|
-
|
|
257
|
+
});
|
|
258
|
+
return resourcesUri;
|
|
259
|
+
};
|
|
260
|
+
ControladorCancelaComponent.prototype.checkAcessPermissionGate = function (resourcesUri, gates) {
|
|
261
|
+
var _this = this;
|
|
262
|
+
this.service.checkAccess(resourcesUri)
|
|
263
|
+
.pipe(operators.takeUntil(this.unsubscribe$), operators.finalize(function () { return _this.loading = undefined; }))
|
|
264
|
+
.subscribe(function (_a) {
|
|
265
|
+
var permissions = _a.permissions;
|
|
266
|
+
_this.gates$.next(_this.buildGateWithActionsAndPermissions(permissions, gates));
|
|
267
|
+
});
|
|
268
|
+
};
|
|
269
|
+
ControladorCancelaComponent.prototype.buildGateWithActionsAndPermissions = function (permissions, gates) {
|
|
270
|
+
var _this = this;
|
|
271
|
+
var gateActions = [];
|
|
272
|
+
gates.filter(function (gate) {
|
|
273
|
+
gate.isActionButton = false;
|
|
274
|
+
gate.actions = [];
|
|
275
|
+
if (_this.permissionCloseGate && _this.permissionOpenGate) {
|
|
276
|
+
gate.isActionButton = true;
|
|
277
|
+
gateActions.push(gate);
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
permissions.filter(function (permission) {
|
|
281
|
+
gate.isActionButton = gate.isActionButton ? true : _this.checkDefaultGatePermission(permission, gate);
|
|
282
|
+
if (gate.resourceUri === permission.resource) {
|
|
283
|
+
gate.actions.push({ action: permission.action, authorized: permission.authorized });
|
|
284
|
+
gate.isActionButton = gate.isActionButton ? true : permission.authorized;
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
gateActions.push(gate);
|
|
288
|
+
});
|
|
289
|
+
return gateActions;
|
|
290
|
+
};
|
|
291
|
+
ControladorCancelaComponent.prototype.checkDefaultGatePermission = function (permission, gate) {
|
|
292
|
+
if (this.uriGateDefault === permission.resource) {
|
|
293
|
+
if (permission.action === "Open") {
|
|
294
|
+
this.permissionOpenGate = permission.authorized;
|
|
295
|
+
return permission.authorized;
|
|
296
|
+
}
|
|
297
|
+
if (permission.action === "Close") {
|
|
298
|
+
this.permissionCloseGate = permission.authorized;
|
|
299
|
+
return permission.authorized;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
return false;
|
|
244
303
|
};
|
|
245
304
|
ControladorCancelaComponent.prototype.ngOnDestroy = function () {
|
|
246
305
|
this.unsubscribe$.next();
|
|
@@ -248,15 +307,33 @@
|
|
|
248
307
|
};
|
|
249
308
|
ControladorCancelaComponent.prototype.model = function (gate) {
|
|
250
309
|
var _this = this;
|
|
310
|
+
var canOpenGate = false;
|
|
311
|
+
var canCloseGate = false;
|
|
312
|
+
if (!(this.permissionCloseGate && this.permissionOpenGate)) {
|
|
313
|
+
gate.actions.filter(function (action) {
|
|
314
|
+
if (action.action === "Open") {
|
|
315
|
+
canOpenGate = action.authorized;
|
|
316
|
+
}
|
|
317
|
+
if (action.action === "Close") {
|
|
318
|
+
canCloseGate = action.authorized;
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
if (this.permissionOpenGate === true) {
|
|
323
|
+
canOpenGate = this.permissionOpenGate;
|
|
324
|
+
}
|
|
325
|
+
if (this.permissionCloseGate === true) {
|
|
326
|
+
canCloseGate = this.permissionCloseGate;
|
|
327
|
+
}
|
|
251
328
|
return [
|
|
252
329
|
{
|
|
253
330
|
label: this.translate.instant('yms.integration.open_gate'),
|
|
254
|
-
visible:
|
|
331
|
+
visible: canOpenGate,
|
|
255
332
|
command: function () { return _this.openGate(gate); }
|
|
256
333
|
},
|
|
257
334
|
{
|
|
258
335
|
label: this.translate.instant('yms.integration.close_gate'),
|
|
259
|
-
visible:
|
|
336
|
+
visible: canCloseGate,
|
|
260
337
|
command: function () { return _this.closeGate(gate); }
|
|
261
338
|
}
|
|
262
339
|
];
|
|
@@ -282,7 +359,7 @@
|
|
|
282
359
|
ControladorCancelaComponent = __decorate([
|
|
283
360
|
core.Component({
|
|
284
361
|
selector: 'controlador-cancela-component',
|
|
285
|
-
template: "<div>\n <p-table [value]=\"gates$ | async\">\n <ng-template pTemplate=\"header\">\n <tr>\n <th>{{'yms.integration.gate_ip' | translate}}</th>\n <th>{{'yms.integration.gate_type' | translate}}</th>\n <th></th>\n </tr>\n </ng-template>\n <ng-template pTemplate=\"body\" let-rowData>\n <tr \n [@success]=\"successState === rowData.id ? successState : 'default'\" \n (@success.done)=\"successState = 'default'\"\n >\n <td>{{rowData.ip}}</td>\n <td>{{rowData.type | translate}}</td>\n <td>\n <span *sLoadingState=\"loading === rowData.id\">\n
|
|
362
|
+
template: "<div>\n <p-table [value]=\"gates$ | async\">\n <ng-template pTemplate=\"header\">\n <tr>\n <th>{{'yms.integration.gate_ip' | translate}}</th>\n <th>{{'yms.integration.gate_type' | translate}}</th>\n <th></th>\n </tr>\n </ng-template>\n <ng-template pTemplate=\"body\" let-rowData>\n <tr \n [@success]=\"successState === rowData.id ? successState : 'default'\" \n (@success.done)=\"successState = 'default'\"\n >\n <td>{{rowData.ip}}</td>\n <td>{{rowData.type | translate}}</td>\n <td>\n <div *ngIf=\"rowData.isActionButton\">\n <span *sLoadingState=\"loading === rowData.id\" >\n <s-button priority=\"default\" [auxiliary]=\"true\" label=\"A\u00E7\u00F5es\" [model]=\"model(rowData)\" >\n </s-button>\n </span>\n </div>\n </td>\n </tr>\n </ng-template>\n </p-table>\n</div>",
|
|
286
363
|
animations: [
|
|
287
364
|
animations.trigger('success', [
|
|
288
365
|
animations.state('*', animations.style({
|
|
@@ -298,7 +375,8 @@
|
|
|
298
375
|
])
|
|
299
376
|
]
|
|
300
377
|
}),
|
|
301
|
-
__metadata("design:paramtypes", [ControladorCancelasService,
|
|
378
|
+
__metadata("design:paramtypes", [ControladorCancelasService,
|
|
379
|
+
core$1.TranslateService])
|
|
302
380
|
], ControladorCancelaComponent);
|
|
303
381
|
return ControladorCancelaComponent;
|
|
304
382
|
}(ControladorCancelaDescritor));
|