@trismegisto/spine 2.0.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/LICENSE +56 -0
- package/README.md +207 -0
- package/fesm2022/trismegisto-spine-audit.mjs +1299 -0
- package/fesm2022/trismegisto-spine-audit.mjs.map +1 -0
- package/fesm2022/trismegisto-spine-auto-service-auto-service-audit.component-CCiz-q8o.mjs +37 -0
- package/fesm2022/trismegisto-spine-auto-service-auto-service-audit.component-CCiz-q8o.mjs.map +1 -0
- package/fesm2022/trismegisto-spine-auto-service-auto-service-client-picker.component-Z0wCANF6.mjs +51 -0
- package/fesm2022/trismegisto-spine-auto-service-auto-service-client-picker.component-Z0wCANF6.mjs.map +1 -0
- package/fesm2022/trismegisto-spine-auto-service-auto-service-client.component-BYkUOwWL.mjs +595 -0
- package/fesm2022/trismegisto-spine-auto-service-auto-service-client.component-BYkUOwWL.mjs.map +1 -0
- package/fesm2022/trismegisto-spine-auto-service-auto-service-groups.component-CqIVe2LU.mjs +357 -0
- package/fesm2022/trismegisto-spine-auto-service-auto-service-groups.component-CqIVe2LU.mjs.map +1 -0
- package/fesm2022/trismegisto-spine-auto-service-auto-service.component-B5tyJ2zY.mjs +477 -0
- package/fesm2022/trismegisto-spine-auto-service-auto-service.component-B5tyJ2zY.mjs.map +1 -0
- package/fesm2022/trismegisto-spine-auto-service-home.component-vl3BPFnk.mjs +238 -0
- package/fesm2022/trismegisto-spine-auto-service-home.component-vl3BPFnk.mjs.map +1 -0
- package/fesm2022/trismegisto-spine-auto-service.mjs +154 -0
- package/fesm2022/trismegisto-spine-auto-service.mjs.map +1 -0
- package/fesm2022/trismegisto-spine-graphql.mjs +347 -0
- package/fesm2022/trismegisto-spine-graphql.mjs.map +1 -0
- package/fesm2022/trismegisto-spine-layout.mjs +2848 -0
- package/fesm2022/trismegisto-spine-layout.mjs.map +1 -0
- package/fesm2022/trismegisto-spine-modal.mjs +141 -0
- package/fesm2022/trismegisto-spine-modal.mjs.map +1 -0
- package/fesm2022/trismegisto-spine-notification.mjs +122 -0
- package/fesm2022/trismegisto-spine-notification.mjs.map +1 -0
- package/fesm2022/trismegisto-spine-routing.mjs +398 -0
- package/fesm2022/trismegisto-spine-routing.mjs.map +1 -0
- package/fesm2022/trismegisto-spine-shell.mjs +409 -0
- package/fesm2022/trismegisto-spine-shell.mjs.map +1 -0
- package/fesm2022/trismegisto-spine-side-panel.mjs +142 -0
- package/fesm2022/trismegisto-spine-side-panel.mjs.map +1 -0
- package/fesm2022/trismegisto-spine.mjs +2574 -0
- package/fesm2022/trismegisto-spine.mjs.map +1 -0
- package/package.json +94 -0
- package/types/trismegisto-spine-audit.d.ts +948 -0
- package/types/trismegisto-spine-audit.d.ts.map +1 -0
- package/types/trismegisto-spine-auto-service.d.ts +110 -0
- package/types/trismegisto-spine-auto-service.d.ts.map +1 -0
- package/types/trismegisto-spine-graphql.d.ts +72 -0
- package/types/trismegisto-spine-graphql.d.ts.map +1 -0
- package/types/trismegisto-spine-layout.d.ts +1054 -0
- package/types/trismegisto-spine-layout.d.ts.map +1 -0
- package/types/trismegisto-spine-modal.d.ts +68 -0
- package/types/trismegisto-spine-modal.d.ts.map +1 -0
- package/types/trismegisto-spine-notification.d.ts +62 -0
- package/types/trismegisto-spine-notification.d.ts.map +1 -0
- package/types/trismegisto-spine-routing.d.ts +205 -0
- package/types/trismegisto-spine-routing.d.ts.map +1 -0
- package/types/trismegisto-spine-shell.d.ts +143 -0
- package/types/trismegisto-spine-shell.d.ts.map +1 -0
- package/types/trismegisto-spine-side-panel.d.ts +66 -0
- package/types/trismegisto-spine-side-panel.d.ts.map +1 -0
- package/types/trismegisto-spine.d.ts +1161 -0
- package/types/trismegisto-spine.d.ts.map +1 -0
|
@@ -0,0 +1,595 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { inject, ChangeDetectorRef, computed, Input, ChangeDetectionStrategy, Component, EventEmitter, Output } from '@angular/core';
|
|
3
|
+
import * as i2 from '@angular/common';
|
|
4
|
+
import { CommonModule } from '@angular/common';
|
|
5
|
+
import { ButtonComponent, CheckboxComponent, IconComponent, InputComponent, TextareaComponent, ModalComponent, DataGridComponent, DataGridCellDirective, TagComponent, ComboboxComponent, DividerComponent, DrawerComponent, TabsComponent, TabComponent, TabContentDirective } from '@trismegisto/angular';
|
|
6
|
+
import { A as AutoServiceClientPickerComponent } from './trismegisto-spine-auto-service-auto-service-client-picker.component-Z0wCANF6.mjs';
|
|
7
|
+
import * as i3 from '@angular/forms';
|
|
8
|
+
import { FormControl, ReactiveFormsModule, FormsModule } from '@angular/forms';
|
|
9
|
+
import { SPINE_MESSAGES } from '@trismegisto/spine';
|
|
10
|
+
import { AutoServiceService } from './trismegisto-spine-auto-service.mjs';
|
|
11
|
+
import { formatMessage } from '@trismegisto/primitives';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Caminho de UMA rota = um trecho só do endereço (`dashboard`, `ordens-servico`). O `/` entre níveis
|
|
15
|
+
* é o roteador que monta, juntando o caminho de cada rota da composição (header→…→page). Um `/`
|
|
16
|
+
* dentro do caminho (ex.: `laboratorio/dashboard` numa rota só) desalinha a cadeia que o `ViewGuard`
|
|
17
|
+
* resolve por nível e a tela cai no fallback (volta para o início) — achado real, 2026-10-07.
|
|
18
|
+
*
|
|
19
|
+
* Só letras minúsculas e hífen, sem hífen no início/fim nem dois seguidos. Mesma regra do admin-server
|
|
20
|
+
* do Argos (`route-path.ts`), que é quem de fato recusa — aqui é só para avisar antes de enviar.
|
|
21
|
+
*/
|
|
22
|
+
const ROUTE_PATH_PATTERN = /^[a-z]+(?:-[a-z]+)*$/;
|
|
23
|
+
/** Vazio passa (rota "pasta", só agrupa o menu); preenchido precisa casar com `ROUTE_PATH_PATTERN`. */
|
|
24
|
+
function routePathValidator(control) {
|
|
25
|
+
const value = control.value ?? '';
|
|
26
|
+
return value === '' || ROUTE_PATH_PATTERN.test(value) ? null : { routePath: true };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
class AutoServiceRoutesComponent {
|
|
30
|
+
constructor(service) {
|
|
31
|
+
this.service = service;
|
|
32
|
+
this.text = inject(SPINE_MESSAGES).autoService;
|
|
33
|
+
/** Telas com estado em campo comum, preenchido depois de `await`: marca a view ao terminar (app sem zone.js). */
|
|
34
|
+
this.cdr = inject(ChangeDetectorRef);
|
|
35
|
+
this.clientId = '';
|
|
36
|
+
this.routes = [];
|
|
37
|
+
this.loading = false;
|
|
38
|
+
this.showRouteModal = false;
|
|
39
|
+
this.editingRouteId = '';
|
|
40
|
+
this.name = new FormControl('', { nonNullable: true });
|
|
41
|
+
this.displayName = new FormControl('', { nonNullable: true });
|
|
42
|
+
this.icon = new FormControl('', { nonNullable: true });
|
|
43
|
+
this.path = new FormControl('', { nonNullable: true, validators: [routePathValidator] });
|
|
44
|
+
this.info = new FormControl('', { nonNullable: true });
|
|
45
|
+
/** Rota protegida (`excludable: false`) é travada aqui: o auto-serviço não libera a exclusão — o
|
|
46
|
+
* admin-server também recusa (403), isto só evita oferecer o que vai ser negado. */
|
|
47
|
+
this.excludable = new FormControl(true, { nonNullable: true });
|
|
48
|
+
/** Mensagem do erro `routePath` no `hm-input` (chave do validador → texto). */
|
|
49
|
+
this.pathMessages = computed(() => ({ routePath: this.text.pathInvalid }), ...(ngDevMode ? [{ debugName: "pathMessages" }] : /* istanbul ignore next */ []));
|
|
50
|
+
this.rowId = (r) => r.id;
|
|
51
|
+
this.columns = computed(() => [
|
|
52
|
+
{ key: 'name', title: this.text.colName, value: (r) => r.name, sortable: true },
|
|
53
|
+
{ key: 'display_name', title: this.text.colDisplay, value: (r) => r.display_name || '—', sortable: true },
|
|
54
|
+
{ key: 'icon', title: this.text.colIcon, value: (r) => r.icon || '—' },
|
|
55
|
+
{ key: 'path', title: this.text.colPath, value: (r) => r.path || '—', sortable: true },
|
|
56
|
+
{
|
|
57
|
+
key: 'excludable', title: this.text.colExcludable, sortable: true,
|
|
58
|
+
value: (r) => (r.excludable ? this.text.excludableYes : this.text.excludableNo),
|
|
59
|
+
},
|
|
60
|
+
], ...(ngDevMode ? [{ debugName: "columns" }] : /* istanbul ignore next */ []));
|
|
61
|
+
// Rota de template não se edita nem se exclui aqui (403 no admin-server); excluir, além disso, só em rota
|
|
62
|
+
// excluível (409). Linha sem ação nenhuma fica sem o kebab.
|
|
63
|
+
this.rowActions = computed(() => [
|
|
64
|
+
{ id: 'edit', icon: 'pencil', label: this.text.edit, available: (r) => !r.templated },
|
|
65
|
+
{
|
|
66
|
+
id: 'delete', icon: 'trash', label: this.text.delete, danger: true, separatorAbove: true,
|
|
67
|
+
available: (r) => !r.templated && r.excludable,
|
|
68
|
+
},
|
|
69
|
+
], ...(ngDevMode ? [{ debugName: "rowActions" }] : /* istanbul ignore next */ []));
|
|
70
|
+
}
|
|
71
|
+
ngOnChanges(changes) { if (changes['clientId'])
|
|
72
|
+
this.load(); }
|
|
73
|
+
async load() {
|
|
74
|
+
if (!this.clientId) {
|
|
75
|
+
this.routes = [];
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
this.loading = true;
|
|
79
|
+
try {
|
|
80
|
+
const res = await this.service.getWebRoutes(this.clientId);
|
|
81
|
+
this.routes = res.routes;
|
|
82
|
+
}
|
|
83
|
+
finally {
|
|
84
|
+
this.loading = false;
|
|
85
|
+
this.cdr.markForCheck();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
resetForm(r) {
|
|
89
|
+
this.name.setValue(r?.name ?? '');
|
|
90
|
+
this.displayName.setValue(r?.display_name ?? '');
|
|
91
|
+
this.icon.setValue(r?.icon ?? '');
|
|
92
|
+
this.path.setValue(r?.path ?? '');
|
|
93
|
+
this.info.setValue(r?.info ?? '');
|
|
94
|
+
this.excludable.setValue(r?.excludable ?? true);
|
|
95
|
+
// Protegida só destrava no Argos central. Nova rota (sem `r`) sempre pode escolher.
|
|
96
|
+
if (r && !r.excludable)
|
|
97
|
+
this.excludable.disable();
|
|
98
|
+
else
|
|
99
|
+
this.excludable.enable();
|
|
100
|
+
// Sem isso, abrir o modal de novo mostraria o erro do caminho da vez anterior antes de digitar.
|
|
101
|
+
this.path.markAsPristine();
|
|
102
|
+
this.path.markAsUntouched();
|
|
103
|
+
}
|
|
104
|
+
/** Editando rota protegida — mostra por que o "Excluível" está travado. */
|
|
105
|
+
get excludableLocked() {
|
|
106
|
+
return this.excludable.disabled;
|
|
107
|
+
}
|
|
108
|
+
openCreateRoute() {
|
|
109
|
+
this.editingRouteId = '';
|
|
110
|
+
this.resetForm();
|
|
111
|
+
this.showRouteModal = true;
|
|
112
|
+
}
|
|
113
|
+
openEditRoute(r) {
|
|
114
|
+
if (r.templated)
|
|
115
|
+
return;
|
|
116
|
+
this.editingRouteId = r.id;
|
|
117
|
+
this.resetForm(r);
|
|
118
|
+
this.showRouteModal = true;
|
|
119
|
+
}
|
|
120
|
+
async saveRoute() {
|
|
121
|
+
// O botão já fica desabilitado; a guarda cobre chamadas diretas (ex.: Enter no form).
|
|
122
|
+
if (!this.name.value || this.path.invalid)
|
|
123
|
+
return;
|
|
124
|
+
const body = {
|
|
125
|
+
name: this.name.value, display_name: this.displayName.value, icon: this.icon.value,
|
|
126
|
+
path: this.path.value, info: this.info.value, excludable: this.excludable.value,
|
|
127
|
+
};
|
|
128
|
+
if (this.editingRouteId) {
|
|
129
|
+
await this.service.updateWebRoute(this.clientId, this.editingRouteId, body);
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
await this.service.createWebRoute(this.clientId, body);
|
|
133
|
+
}
|
|
134
|
+
this.showRouteModal = false;
|
|
135
|
+
await this.load();
|
|
136
|
+
}
|
|
137
|
+
async deleteRoute(r) {
|
|
138
|
+
if (r.templated || !r.excludable)
|
|
139
|
+
return;
|
|
140
|
+
await this.service.deleteWebRoute(this.clientId, r.id);
|
|
141
|
+
await this.load();
|
|
142
|
+
}
|
|
143
|
+
onAction(e) {
|
|
144
|
+
if (e.action === 'edit')
|
|
145
|
+
this.openEditRoute(e.row);
|
|
146
|
+
if (e.action === 'delete')
|
|
147
|
+
void this.deleteRoute(e.row);
|
|
148
|
+
}
|
|
149
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.24", ngImport: i0, type: AutoServiceRoutesComponent, deps: [{ token: AutoServiceService }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
150
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.24", type: AutoServiceRoutesComponent, isStandalone: true, selector: "spine-auto-service-routes", inputs: { clientId: "clientId" }, usesOnChanges: true, ngImport: i0, template: "<hm-data-grid\n [columns]=\"columns()\"\n [rows]=\"routes\"\n [rowId]=\"rowId\"\n [caption]=\"text.routesCaption\"\n [loading]=\"loading\"\n [rowActions]=\"rowActions()\"\n (actionTriggered)=\"onAction($event)\"\n [emptyMessage]=\"text.noRoutes\"\n>\n <hm-button dataGridActions icon=\"plus\" (clicked)=\"openCreateRoute()\">{{ text.newRoute }}</hm-button>\n <ng-template hmCell=\"name\" let-r>\n <span class=\"name-cell\">\n {{ r.name }}\n <hm-tag *ngIf=\"r.templated\" [name]=\"text.templateTag\" color=\"info\" [title]=\"text.templateLocked\" />\n </span>\n </ng-template>\n <ng-template hmCell=\"icon\" let-r>\n <span class=\"icon-cell\">\n <hm-icon *ngIf=\"r.icon\" [shape]=\"r.icon\"></hm-icon>\n {{ r.icon || '\u2014' }}\n </span>\n </ng-template>\n <ng-template hmCell=\"path\" let-r>\n <code *ngIf=\"r.path\">{{ r.path }}</code>\n <ng-container *ngIf=\"!r.path\">\u2014</ng-container>\n </ng-template>\n</hm-data-grid>\n\n<!-- Modal: criar/editar rota -->\n<hm-modal [open]=\"showRouteModal\" (openChange)=\"showRouteModal = $event\" [heading]=\"editingRouteId ? text.editRoute : text.newRoute\" (closed)=\"showRouteModal = false\">\n <div class=\"form-stack\">\n <hm-input [formControl]=\"name\" [label]=\"text.internalName\" />\n <hm-input [formControl]=\"displayName\" [label]=\"text.displayName\" />\n <hm-input [formControl]=\"icon\" [label]=\"text.icon\" [placeholder]=\"text.iconPlaceholder\" />\n <hm-input [formControl]=\"path\" [label]=\"text.path\" [placeholder]=\"text.pathPlaceholder\" [hint]=\"text.pathHint\" [messages]=\"pathMessages()\" />\n <hm-textarea [formControl]=\"info\" [label]=\"text.info\" />\n <hm-checkbox [formControl]=\"excludable\" [label]=\"text.excludable\" />\n <p *ngIf=\"excludableLocked\" class=\"field-note\">{{ text.excludableLocked }}</p>\n </div>\n\n <ng-container footer>\n <hm-button emphasis=\"medium\" (clicked)=\"showRouteModal = false\">{{ text.cancel }}</hm-button>\n <hm-button [disabled]=\"!name.value || path.invalid\" (clicked)=\"saveRoute()\">\n {{ editingRouteId ? text.save : text.create }}\n </hm-button>\n </ng-container>\n</hm-modal>\n", styles: [".as-stack{display:flex;flex-direction:column;gap:var(--hm-space-md);min-inline-size:0}.as-actions{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:var(--hm-space-xs)}.as-field-row{display:flex;flex-wrap:wrap;align-items:flex-end;gap:var(--hm-space-sm)}.as-field-row>:first-child{flex:1 1 20rem;min-inline-size:0}.as-summary{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-sm)}.as-summary__info{display:flex;flex:1 1 16rem;flex-direction:column;gap:var(--hm-space-micro);min-inline-size:0}.as-summary__title{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-xs);margin:0;color:var(--hm-text);font-size:var(--hm-font-size-md);font-weight:var(--hm-font-weight-semibold)}.as-summary__detail{margin:0;color:var(--hm-muted);font-size:var(--hm-font-size-sm)}.muted{color:var(--hm-muted)}:host{display:block}.form-stack{display:flex;flex-direction:column;gap:var(--hm-space-sm)}.field-note{margin:0;color:var(--hm-muted);font-size:var(--hm-font-size-sm)}.name-cell{display:inline-flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-xs)}.icon-cell{display:inline-flex;align-items:center;gap:var(--hm-space-micro)}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i3.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: ButtonComponent, selector: "hm-button", inputs: ["emphasis", "intent", "size", "type", "icon", "iconDirection", "iconEnd", "disabled", "loading", "busy", "loadingState", "block", "link", "newTab", "caret", "inMenu", "toggle", "pressed"], outputs: ["loadingStateChange", "pressedChange", "clicked"] }, { kind: "component", type: CheckboxComponent, selector: "hm-checkbox", inputs: ["label", "labelHidden", "checked", "indeterminate"], outputs: ["checkedChange"] }, { kind: "component", type: IconComponent, selector: "hm-icon", inputs: ["shape", "direction", "size", "solid", "badge", "status", "flip", "inverse", "label"] }, { kind: "component", type: InputComponent, selector: "hm-input", inputs: ["value", "label", "type", "placeholder", "icon", "labelHidden", "hint", "prefix", "suffix", "prefixIcon", "mask", "maskValue", "min", "max", "step", "stepButtons", "maxLength", "autocomplete", "inputMode"], outputs: ["valueChange"] }, { kind: "component", type: TextareaComponent, selector: "hm-textarea", inputs: ["value", "label", "hint", "help", "placeholder", "maxLength", "rows", "autoGrow", "labelHidden", "loading", "maxRows", "submitKey"], outputs: ["valueChange", "submitted"] }, { kind: "component", type: ModalComponent, selector: "hm-modal", inputs: ["open", "heading", "size", "closeLabel", "closable", "beforeClose"], outputs: ["openChange", "closed"] }, { kind: "component", type: DataGridComponent, selector: "hm-data-grid", inputs: ["columns", "rows", "rowId", "caption", "rowActions", "loading", "error", "emptyMessage", "noResultsMessage", "filterable", "paginated", "pageState", "pagination", "totalItems", "sort", "selectable", "selectionMode", "selection", "rowSelectable", "rowSelectableReason", "rowDetailDisabled", "rowDetailHidden", "virtual", "rowHeight", "pinnedColumns", "columnState", "pageSizes", "fillHeight", "maxHeight", "bordered", "rowState", "rowClickable", "remoteSearch", "remoteSort", "itemsLabel", "pageSizeLabel", "exportable", "exportFileName", "groupBy", "aggregates", "aggregateFormatter", "persistKey", "persistStorage", "advancedFilter", "filterQuery", "columnManager", "columnOrder", "searchTerm"], outputs: ["pageStateChange", "sortChange", "selectionChange", "pinnedColumnsChange", "columnStateChange", "actionTriggered", "detailToggled", "rowClicked", "clearFiltersRequested", "filteredChange", "searchTermChanged", "groupByChange", "filterQueryChange", "columnOrderChange", "searchTermChange", "detailPaneToggled"] }, { kind: "directive", type: DataGridCellDirective, selector: "ng-template[hmCell]", inputs: ["hmCell"] }, { kind: "component", type: TagComponent, selector: "hm-tag", inputs: ["name", "color", "compact"] }], changeDetection: i0.ChangeDetectionStrategy.Eager }); }
|
|
151
|
+
}
|
|
152
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.24", ngImport: i0, type: AutoServiceRoutesComponent, decorators: [{
|
|
153
|
+
type: Component,
|
|
154
|
+
args: [{ selector: 'spine-auto-service-routes', standalone: true, imports: [
|
|
155
|
+
CommonModule, ReactiveFormsModule, ButtonComponent, CheckboxComponent, IconComponent, InputComponent, TextareaComponent,
|
|
156
|
+
ModalComponent, DataGridComponent, DataGridCellDirective, TagComponent,
|
|
157
|
+
], changeDetection: ChangeDetectionStrategy.Eager, template: "<hm-data-grid\n [columns]=\"columns()\"\n [rows]=\"routes\"\n [rowId]=\"rowId\"\n [caption]=\"text.routesCaption\"\n [loading]=\"loading\"\n [rowActions]=\"rowActions()\"\n (actionTriggered)=\"onAction($event)\"\n [emptyMessage]=\"text.noRoutes\"\n>\n <hm-button dataGridActions icon=\"plus\" (clicked)=\"openCreateRoute()\">{{ text.newRoute }}</hm-button>\n <ng-template hmCell=\"name\" let-r>\n <span class=\"name-cell\">\n {{ r.name }}\n <hm-tag *ngIf=\"r.templated\" [name]=\"text.templateTag\" color=\"info\" [title]=\"text.templateLocked\" />\n </span>\n </ng-template>\n <ng-template hmCell=\"icon\" let-r>\n <span class=\"icon-cell\">\n <hm-icon *ngIf=\"r.icon\" [shape]=\"r.icon\"></hm-icon>\n {{ r.icon || '\u2014' }}\n </span>\n </ng-template>\n <ng-template hmCell=\"path\" let-r>\n <code *ngIf=\"r.path\">{{ r.path }}</code>\n <ng-container *ngIf=\"!r.path\">\u2014</ng-container>\n </ng-template>\n</hm-data-grid>\n\n<!-- Modal: criar/editar rota -->\n<hm-modal [open]=\"showRouteModal\" (openChange)=\"showRouteModal = $event\" [heading]=\"editingRouteId ? text.editRoute : text.newRoute\" (closed)=\"showRouteModal = false\">\n <div class=\"form-stack\">\n <hm-input [formControl]=\"name\" [label]=\"text.internalName\" />\n <hm-input [formControl]=\"displayName\" [label]=\"text.displayName\" />\n <hm-input [formControl]=\"icon\" [label]=\"text.icon\" [placeholder]=\"text.iconPlaceholder\" />\n <hm-input [formControl]=\"path\" [label]=\"text.path\" [placeholder]=\"text.pathPlaceholder\" [hint]=\"text.pathHint\" [messages]=\"pathMessages()\" />\n <hm-textarea [formControl]=\"info\" [label]=\"text.info\" />\n <hm-checkbox [formControl]=\"excludable\" [label]=\"text.excludable\" />\n <p *ngIf=\"excludableLocked\" class=\"field-note\">{{ text.excludableLocked }}</p>\n </div>\n\n <ng-container footer>\n <hm-button emphasis=\"medium\" (clicked)=\"showRouteModal = false\">{{ text.cancel }}</hm-button>\n <hm-button [disabled]=\"!name.value || path.invalid\" (clicked)=\"saveRoute()\">\n {{ editingRouteId ? text.save : text.create }}\n </hm-button>\n </ng-container>\n</hm-modal>\n", styles: [".as-stack{display:flex;flex-direction:column;gap:var(--hm-space-md);min-inline-size:0}.as-actions{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:var(--hm-space-xs)}.as-field-row{display:flex;flex-wrap:wrap;align-items:flex-end;gap:var(--hm-space-sm)}.as-field-row>:first-child{flex:1 1 20rem;min-inline-size:0}.as-summary{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-sm)}.as-summary__info{display:flex;flex:1 1 16rem;flex-direction:column;gap:var(--hm-space-micro);min-inline-size:0}.as-summary__title{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-xs);margin:0;color:var(--hm-text);font-size:var(--hm-font-size-md);font-weight:var(--hm-font-weight-semibold)}.as-summary__detail{margin:0;color:var(--hm-muted);font-size:var(--hm-font-size-sm)}.muted{color:var(--hm-muted)}:host{display:block}.form-stack{display:flex;flex-direction:column;gap:var(--hm-space-sm)}.field-note{margin:0;color:var(--hm-muted);font-size:var(--hm-font-size-sm)}.name-cell{display:inline-flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-xs)}.icon-cell{display:inline-flex;align-items:center;gap:var(--hm-space-micro)}\n"] }]
|
|
158
|
+
}], ctorParameters: () => [{ type: AutoServiceService }], propDecorators: { clientId: [{
|
|
159
|
+
type: Input
|
|
160
|
+
}] } });
|
|
161
|
+
|
|
162
|
+
class AutoServiceRoutersComponent {
|
|
163
|
+
constructor(service) {
|
|
164
|
+
this.service = service;
|
|
165
|
+
this.text = inject(SPINE_MESSAGES).autoService;
|
|
166
|
+
/** Telas com estado em campo comum, preenchido depois de `await`: marca a view ao terminar (app sem zone.js). */
|
|
167
|
+
this.cdr = inject(ChangeDetectorRef);
|
|
168
|
+
this.clientId = '';
|
|
169
|
+
this.routes = [];
|
|
170
|
+
this.routers = [];
|
|
171
|
+
this.loading = false;
|
|
172
|
+
this.showRouterModal = false;
|
|
173
|
+
this.editingRouterId = '';
|
|
174
|
+
this.routerForm = { page_id: '', header_id: '', navigation_id: '', menu_id: '', item_id: '', submenu_id: '', is_private: true, description: '' };
|
|
175
|
+
this.rowId = (r) => r.id;
|
|
176
|
+
this.columns = computed(() => [
|
|
177
|
+
{ key: 'page', title: this.text.colPage, value: (r) => this.routeName(r.page_id), sortable: true },
|
|
178
|
+
{ key: 'built_path', title: this.text.colBuiltPath, value: (r) => r.built_path },
|
|
179
|
+
{ key: 'description', title: this.text.colDescription, value: (r) => r.description ?? '' },
|
|
180
|
+
{ key: 'is_private', title: this.text.colVisibility, value: (r) => (r.is_private ? this.text.private : this.text.public), sortable: true },
|
|
181
|
+
], ...(ngDevMode ? [{ debugName: "columns" }] : /* istanbul ignore next */ []));
|
|
182
|
+
// Router de template não se edita nem se exclui aqui (403 no admin-server): a linha fica sem o kebab.
|
|
183
|
+
this.rowActions = computed(() => [
|
|
184
|
+
{ id: 'edit', icon: 'pencil', label: this.text.edit, available: (r) => !r.templated },
|
|
185
|
+
{ id: 'delete', icon: 'trash', label: this.text.delete, danger: true, separatorAbove: true, available: (r) => !r.templated },
|
|
186
|
+
], ...(ngDevMode ? [{ debugName: "rowActions" }] : /* istanbul ignore next */ []));
|
|
187
|
+
this.pathLevels = ['header_id', 'navigation_id', 'menu_id', 'item_id', 'submenu_id', 'page_id'];
|
|
188
|
+
}
|
|
189
|
+
get routeOptions() {
|
|
190
|
+
return this.routes.map((r) => ({ value: r.id, label: r.display_name || r.name }));
|
|
191
|
+
}
|
|
192
|
+
ngOnChanges(changes) { if (changes['clientId'])
|
|
193
|
+
this.load(); }
|
|
194
|
+
async load() {
|
|
195
|
+
if (!this.clientId) {
|
|
196
|
+
this.routes = [];
|
|
197
|
+
this.routers = [];
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
this.loading = true;
|
|
201
|
+
try {
|
|
202
|
+
const [routesRes, routersRes] = await Promise.all([this.service.getWebRoutes(this.clientId), this.service.getRouters(this.clientId)]);
|
|
203
|
+
this.routes = routesRes.routes;
|
|
204
|
+
this.routers = routersRes.routers.map((r) => ({ ...r, built_path: this.builtPath(r) }));
|
|
205
|
+
}
|
|
206
|
+
finally {
|
|
207
|
+
this.loading = false;
|
|
208
|
+
this.cdr.markForCheck();
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
routeName(id) { if (!id)
|
|
212
|
+
return '—'; return this.routes.find(r => r.id === id)?.name ?? id; }
|
|
213
|
+
builtPath(r) {
|
|
214
|
+
const segments = this.pathLevels
|
|
215
|
+
.map(level => this.routes.find(x => x.id === r[level])?.path)
|
|
216
|
+
.filter((p) => !!p)
|
|
217
|
+
.map(p => p.replace(/^\/+|\/+$/g, ''));
|
|
218
|
+
return segments.length ? '/' + segments.join('/') : '—';
|
|
219
|
+
}
|
|
220
|
+
openCreateRouter() {
|
|
221
|
+
this.editingRouterId = '';
|
|
222
|
+
this.routerForm = { page_id: '', header_id: '', navigation_id: '', menu_id: '', item_id: '', submenu_id: '', is_private: true, description: '' };
|
|
223
|
+
this.showRouterModal = true;
|
|
224
|
+
}
|
|
225
|
+
openEditRouter(r) {
|
|
226
|
+
this.editingRouterId = r.id;
|
|
227
|
+
this.routerForm = {
|
|
228
|
+
page_id: r.page_id, header_id: r.header_id ?? '', navigation_id: r.navigation_id ?? '',
|
|
229
|
+
menu_id: r.menu_id ?? '', item_id: r.item_id ?? '', submenu_id: r.submenu_id ?? '', is_private: r.is_private ?? true,
|
|
230
|
+
description: r.description ?? '',
|
|
231
|
+
};
|
|
232
|
+
this.showRouterModal = true;
|
|
233
|
+
}
|
|
234
|
+
async saveRouter() {
|
|
235
|
+
const body = {
|
|
236
|
+
page_id: this.routerForm.page_id,
|
|
237
|
+
header_id: this.routerForm.header_id || null,
|
|
238
|
+
navigation_id: this.routerForm.navigation_id || null,
|
|
239
|
+
menu_id: this.routerForm.menu_id || null,
|
|
240
|
+
item_id: this.routerForm.item_id || null,
|
|
241
|
+
submenu_id: this.routerForm.submenu_id || null,
|
|
242
|
+
is_private: this.routerForm.is_private,
|
|
243
|
+
description: this.routerForm.description.trim() || null,
|
|
244
|
+
};
|
|
245
|
+
if (this.editingRouterId) {
|
|
246
|
+
await this.service.updateRouter(this.clientId, this.editingRouterId, body);
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
await this.service.createRouter(this.clientId, body);
|
|
250
|
+
}
|
|
251
|
+
this.showRouterModal = false;
|
|
252
|
+
await this.load();
|
|
253
|
+
}
|
|
254
|
+
async deleteRouter(routerId) { await this.service.deleteRouter(this.clientId, routerId); await this.load(); }
|
|
255
|
+
onAction(e) {
|
|
256
|
+
if (e.row.templated)
|
|
257
|
+
return;
|
|
258
|
+
if (e.action === 'edit')
|
|
259
|
+
this.openEditRouter(e.row);
|
|
260
|
+
if (e.action === 'delete')
|
|
261
|
+
void this.deleteRouter(e.row.id);
|
|
262
|
+
}
|
|
263
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.24", ngImport: i0, type: AutoServiceRoutersComponent, deps: [{ token: AutoServiceService }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
264
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.24", type: AutoServiceRoutersComponent, isStandalone: true, selector: "spine-auto-service-routers", inputs: { clientId: "clientId" }, usesOnChanges: true, ngImport: i0, template: "<hm-data-grid\n [columns]=\"columns()\"\n [rows]=\"routers\"\n [rowId]=\"rowId\"\n [caption]=\"text.routersCaption\"\n [loading]=\"loading\"\n [rowActions]=\"rowActions()\"\n (actionTriggered)=\"onAction($event)\"\n [emptyMessage]=\"text.noRouters\"\n>\n <hm-button dataGridActions icon=\"plus\" [disabled]=\"!routes.length\" (clicked)=\"openCreateRouter()\">{{ text.newRouter }}</hm-button>\n <ng-template hmCell=\"page\" let-r>\n <span class=\"name-cell\">\n {{ routeName(r.page_id) }}\n <hm-tag *ngIf=\"r.templated\" [name]=\"text.templateTag\" color=\"info\" [title]=\"text.templateLocked\" />\n </span>\n </ng-template>\n <ng-template hmCell=\"is_private\" let-r>\n <hm-tag [name]=\"r.is_private ? text.private : text.public\" [color]=\"r.is_private ? 'warning' : 'success'\" />\n </ng-template>\n <ng-template hmCell=\"built_path\" let-r>\n <code>{{ r.built_path }}</code>\n </ng-template>\n</hm-data-grid>\n\n<!-- Modal: criar/editar roteador -->\n<hm-modal [open]=\"showRouterModal\" (openChange)=\"showRouterModal = $event\" [heading]=\"editingRouterId ? text.editRouter : text.newRouter\" size=\"large\" (closed)=\"showRouterModal = false\">\n <div class=\"form-stack\">\n <hm-combobox [label]=\"text.page\" [options]=\"routeOptions\" [value]=\"routerForm.page_id\" (valueChange)=\"routerForm.page_id = $event\"></hm-combobox>\n <hm-textarea [label]=\"text.routerDescription\" [rows]=\"2\" [hint]=\"text.routerDescriptionHint\" [(ngModel)]=\"routerForm.description\" />\n\n <hm-divider [label]=\"text.hierarchy\" />\n\n <hm-combobox [label]=\"text.levelHeader\" [options]=\"routeOptions\" [clearable]=\"true\" [value]=\"routerForm.header_id\" (valueChange)=\"routerForm.header_id = $event\"></hm-combobox>\n <hm-combobox [label]=\"text.levelNavigation\" [options]=\"routeOptions\" [clearable]=\"true\" [value]=\"routerForm.navigation_id\" (valueChange)=\"routerForm.navigation_id = $event\"></hm-combobox>\n <hm-combobox [label]=\"text.levelMenu\" [options]=\"routeOptions\" [clearable]=\"true\" [value]=\"routerForm.menu_id\" (valueChange)=\"routerForm.menu_id = $event\"></hm-combobox>\n <hm-combobox [label]=\"text.levelItem\" [options]=\"routeOptions\" [clearable]=\"true\" [value]=\"routerForm.item_id\" (valueChange)=\"routerForm.item_id = $event\"></hm-combobox>\n <hm-combobox [label]=\"text.levelSubmenu\" [options]=\"routeOptions\" [clearable]=\"true\" [value]=\"routerForm.submenu_id\" (valueChange)=\"routerForm.submenu_id = $event\"></hm-combobox>\n\n <hm-divider />\n <hm-checkbox [(ngModel)]=\"routerForm.is_private\" [label]=\"text.privateHint\" />\n </div>\n\n <ng-container footer>\n <hm-button emphasis=\"medium\" (clicked)=\"showRouterModal = false\">{{ text.cancel }}</hm-button>\n <hm-button [disabled]=\"!routerForm.page_id\" (clicked)=\"saveRouter()\">\n {{ editingRouterId ? text.save : text.create }}\n </hm-button>\n </ng-container>\n</hm-modal>\n", styles: [".as-stack{display:flex;flex-direction:column;gap:var(--hm-space-md);min-inline-size:0}.as-actions{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:var(--hm-space-xs)}.as-field-row{display:flex;flex-wrap:wrap;align-items:flex-end;gap:var(--hm-space-sm)}.as-field-row>:first-child{flex:1 1 20rem;min-inline-size:0}.as-summary{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-sm)}.as-summary__info{display:flex;flex:1 1 16rem;flex-direction:column;gap:var(--hm-space-micro);min-inline-size:0}.as-summary__title{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-xs);margin:0;color:var(--hm-text);font-size:var(--hm-font-size-md);font-weight:var(--hm-font-weight-semibold)}.as-summary__detail{margin:0;color:var(--hm-muted);font-size:var(--hm-font-size-sm)}.muted{color:var(--hm-muted)}:host{display:block}.name-cell{display:inline-flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-xs)}.form-stack{display:flex;flex-direction:column;gap:var(--hm-space-sm)}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i3.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: ButtonComponent, selector: "hm-button", inputs: ["emphasis", "intent", "size", "type", "icon", "iconDirection", "iconEnd", "disabled", "loading", "busy", "loadingState", "block", "link", "newTab", "caret", "inMenu", "toggle", "pressed"], outputs: ["loadingStateChange", "pressedChange", "clicked"] }, { kind: "component", type: CheckboxComponent, selector: "hm-checkbox", inputs: ["label", "labelHidden", "checked", "indeterminate"], outputs: ["checkedChange"] }, { kind: "component", type: ComboboxComponent, selector: "hm-combobox", inputs: ["label", "options", "value", "placeholder", "icon", "hint", "help", "size", "labelHidden", "clearable", "requiredManual", "loading", "allowCustomValue"], outputs: ["valueChange"] }, { kind: "component", type: DividerComponent, selector: "hm-divider", inputs: ["orientation", "label", "labelAlign", "emphasis", "thickness", "spacing", "decorative"] }, { kind: "component", type: ModalComponent, selector: "hm-modal", inputs: ["open", "heading", "size", "closeLabel", "closable", "beforeClose"], outputs: ["openChange", "closed"] }, { kind: "component", type: DataGridComponent, selector: "hm-data-grid", inputs: ["columns", "rows", "rowId", "caption", "rowActions", "loading", "error", "emptyMessage", "noResultsMessage", "filterable", "paginated", "pageState", "pagination", "totalItems", "sort", "selectable", "selectionMode", "selection", "rowSelectable", "rowSelectableReason", "rowDetailDisabled", "rowDetailHidden", "virtual", "rowHeight", "pinnedColumns", "columnState", "pageSizes", "fillHeight", "maxHeight", "bordered", "rowState", "rowClickable", "remoteSearch", "remoteSort", "itemsLabel", "pageSizeLabel", "exportable", "exportFileName", "groupBy", "aggregates", "aggregateFormatter", "persistKey", "persistStorage", "advancedFilter", "filterQuery", "columnManager", "columnOrder", "searchTerm"], outputs: ["pageStateChange", "sortChange", "selectionChange", "pinnedColumnsChange", "columnStateChange", "actionTriggered", "detailToggled", "rowClicked", "clearFiltersRequested", "filteredChange", "searchTermChanged", "groupByChange", "filterQueryChange", "columnOrderChange", "searchTermChange", "detailPaneToggled"] }, { kind: "directive", type: DataGridCellDirective, selector: "ng-template[hmCell]", inputs: ["hmCell"] }, { kind: "component", type: TagComponent, selector: "hm-tag", inputs: ["name", "color", "compact"] }, { kind: "component", type: TextareaComponent, selector: "hm-textarea", inputs: ["value", "label", "hint", "help", "placeholder", "maxLength", "rows", "autoGrow", "labelHidden", "loading", "maxRows", "submitKey"], outputs: ["valueChange", "submitted"] }], changeDetection: i0.ChangeDetectionStrategy.Eager }); }
|
|
265
|
+
}
|
|
266
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.24", ngImport: i0, type: AutoServiceRoutersComponent, decorators: [{
|
|
267
|
+
type: Component,
|
|
268
|
+
args: [{ selector: 'spine-auto-service-routers', standalone: true, imports: [
|
|
269
|
+
CommonModule, FormsModule, ButtonComponent, CheckboxComponent, ComboboxComponent, DividerComponent, ModalComponent,
|
|
270
|
+
DataGridComponent, DataGridCellDirective, TagComponent, TextareaComponent,
|
|
271
|
+
], changeDetection: ChangeDetectionStrategy.Eager, template: "<hm-data-grid\n [columns]=\"columns()\"\n [rows]=\"routers\"\n [rowId]=\"rowId\"\n [caption]=\"text.routersCaption\"\n [loading]=\"loading\"\n [rowActions]=\"rowActions()\"\n (actionTriggered)=\"onAction($event)\"\n [emptyMessage]=\"text.noRouters\"\n>\n <hm-button dataGridActions icon=\"plus\" [disabled]=\"!routes.length\" (clicked)=\"openCreateRouter()\">{{ text.newRouter }}</hm-button>\n <ng-template hmCell=\"page\" let-r>\n <span class=\"name-cell\">\n {{ routeName(r.page_id) }}\n <hm-tag *ngIf=\"r.templated\" [name]=\"text.templateTag\" color=\"info\" [title]=\"text.templateLocked\" />\n </span>\n </ng-template>\n <ng-template hmCell=\"is_private\" let-r>\n <hm-tag [name]=\"r.is_private ? text.private : text.public\" [color]=\"r.is_private ? 'warning' : 'success'\" />\n </ng-template>\n <ng-template hmCell=\"built_path\" let-r>\n <code>{{ r.built_path }}</code>\n </ng-template>\n</hm-data-grid>\n\n<!-- Modal: criar/editar roteador -->\n<hm-modal [open]=\"showRouterModal\" (openChange)=\"showRouterModal = $event\" [heading]=\"editingRouterId ? text.editRouter : text.newRouter\" size=\"large\" (closed)=\"showRouterModal = false\">\n <div class=\"form-stack\">\n <hm-combobox [label]=\"text.page\" [options]=\"routeOptions\" [value]=\"routerForm.page_id\" (valueChange)=\"routerForm.page_id = $event\"></hm-combobox>\n <hm-textarea [label]=\"text.routerDescription\" [rows]=\"2\" [hint]=\"text.routerDescriptionHint\" [(ngModel)]=\"routerForm.description\" />\n\n <hm-divider [label]=\"text.hierarchy\" />\n\n <hm-combobox [label]=\"text.levelHeader\" [options]=\"routeOptions\" [clearable]=\"true\" [value]=\"routerForm.header_id\" (valueChange)=\"routerForm.header_id = $event\"></hm-combobox>\n <hm-combobox [label]=\"text.levelNavigation\" [options]=\"routeOptions\" [clearable]=\"true\" [value]=\"routerForm.navigation_id\" (valueChange)=\"routerForm.navigation_id = $event\"></hm-combobox>\n <hm-combobox [label]=\"text.levelMenu\" [options]=\"routeOptions\" [clearable]=\"true\" [value]=\"routerForm.menu_id\" (valueChange)=\"routerForm.menu_id = $event\"></hm-combobox>\n <hm-combobox [label]=\"text.levelItem\" [options]=\"routeOptions\" [clearable]=\"true\" [value]=\"routerForm.item_id\" (valueChange)=\"routerForm.item_id = $event\"></hm-combobox>\n <hm-combobox [label]=\"text.levelSubmenu\" [options]=\"routeOptions\" [clearable]=\"true\" [value]=\"routerForm.submenu_id\" (valueChange)=\"routerForm.submenu_id = $event\"></hm-combobox>\n\n <hm-divider />\n <hm-checkbox [(ngModel)]=\"routerForm.is_private\" [label]=\"text.privateHint\" />\n </div>\n\n <ng-container footer>\n <hm-button emphasis=\"medium\" (clicked)=\"showRouterModal = false\">{{ text.cancel }}</hm-button>\n <hm-button [disabled]=\"!routerForm.page_id\" (clicked)=\"saveRouter()\">\n {{ editingRouterId ? text.save : text.create }}\n </hm-button>\n </ng-container>\n</hm-modal>\n", styles: [".as-stack{display:flex;flex-direction:column;gap:var(--hm-space-md);min-inline-size:0}.as-actions{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:var(--hm-space-xs)}.as-field-row{display:flex;flex-wrap:wrap;align-items:flex-end;gap:var(--hm-space-sm)}.as-field-row>:first-child{flex:1 1 20rem;min-inline-size:0}.as-summary{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-sm)}.as-summary__info{display:flex;flex:1 1 16rem;flex-direction:column;gap:var(--hm-space-micro);min-inline-size:0}.as-summary__title{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-xs);margin:0;color:var(--hm-text);font-size:var(--hm-font-size-md);font-weight:var(--hm-font-weight-semibold)}.as-summary__detail{margin:0;color:var(--hm-muted);font-size:var(--hm-font-size-sm)}.muted{color:var(--hm-muted)}:host{display:block}.name-cell{display:inline-flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-xs)}.form-stack{display:flex;flex-direction:column;gap:var(--hm-space-sm)}\n"] }]
|
|
272
|
+
}], ctorParameters: () => [{ type: AutoServiceService }], propDecorators: { clientId: [{
|
|
273
|
+
type: Input
|
|
274
|
+
}] } });
|
|
275
|
+
|
|
276
|
+
class AutoServiceAccessCreateComponent {
|
|
277
|
+
constructor(service) {
|
|
278
|
+
this.service = service;
|
|
279
|
+
this.text = inject(SPINE_MESSAGES).autoService;
|
|
280
|
+
/** Telas com estado em campo comum, preenchido depois de `await`: marca a view ao terminar (app sem zone.js). */
|
|
281
|
+
this.cdr = inject(ChangeDetectorRef);
|
|
282
|
+
this.clientId = '';
|
|
283
|
+
this.availableGroups = [];
|
|
284
|
+
this.open = false;
|
|
285
|
+
this.openChange = new EventEmitter();
|
|
286
|
+
this.created = new EventEmitter();
|
|
287
|
+
this.groupId = '';
|
|
288
|
+
this.saving = false;
|
|
289
|
+
}
|
|
290
|
+
get groupOptions() {
|
|
291
|
+
return this.availableGroups.map((g) => ({ value: g.id, label: g.type ? `${g.name} (${g.type.name})` : g.name }));
|
|
292
|
+
}
|
|
293
|
+
ngOnChanges(changes) { if (changes['open'] && this.open) {
|
|
294
|
+
this.groupId = '';
|
|
295
|
+
} }
|
|
296
|
+
onModalOpenChange(value) { this.open = value; this.openChange.emit(value); }
|
|
297
|
+
close() { this.onModalOpenChange(false); }
|
|
298
|
+
async save() {
|
|
299
|
+
if (!this.groupId)
|
|
300
|
+
return;
|
|
301
|
+
this.saving = true;
|
|
302
|
+
try {
|
|
303
|
+
await this.service.createAccess(this.clientId, this.groupId);
|
|
304
|
+
this.created.emit();
|
|
305
|
+
this.close();
|
|
306
|
+
}
|
|
307
|
+
finally {
|
|
308
|
+
this.saving = false;
|
|
309
|
+
this.cdr.markForCheck();
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.24", ngImport: i0, type: AutoServiceAccessCreateComponent, deps: [{ token: AutoServiceService }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
313
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.24", type: AutoServiceAccessCreateComponent, isStandalone: true, selector: "spine-auto-service-access-create", inputs: { clientId: "clientId", availableGroups: "availableGroups", open: "open" }, outputs: { openChange: "openChange", created: "created" }, usesOnChanges: true, ngImport: i0, template: "<hm-modal [open]=\"open\" (openChange)=\"onModalOpenChange($event)\" [heading]=\"text.newAccessHeading\" (closed)=\"close()\">\n <hm-combobox [label]=\"text.group\" [options]=\"groupOptions\" [value]=\"groupId\" (valueChange)=\"groupId = $event\"></hm-combobox>\n\n <ng-container footer>\n <hm-button emphasis=\"medium\" (clicked)=\"close()\">{{ text.cancel }}</hm-button>\n <hm-button [disabled]=\"!groupId\" [loading]=\"saving\" (clicked)=\"save()\">{{ text.create }}</hm-button>\n </ng-container>\n</hm-modal>\n", styles: [""], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "component", type: ButtonComponent, selector: "hm-button", inputs: ["emphasis", "intent", "size", "type", "icon", "iconDirection", "iconEnd", "disabled", "loading", "busy", "loadingState", "block", "link", "newTab", "caret", "inMenu", "toggle", "pressed"], outputs: ["loadingStateChange", "pressedChange", "clicked"] }, { kind: "component", type: ComboboxComponent, selector: "hm-combobox", inputs: ["label", "options", "value", "placeholder", "icon", "hint", "help", "size", "labelHidden", "clearable", "requiredManual", "loading", "allowCustomValue"], outputs: ["valueChange"] }, { kind: "component", type: ModalComponent, selector: "hm-modal", inputs: ["open", "heading", "size", "closeLabel", "closable", "beforeClose"], outputs: ["openChange", "closed"] }], changeDetection: i0.ChangeDetectionStrategy.Eager }); }
|
|
314
|
+
}
|
|
315
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.24", ngImport: i0, type: AutoServiceAccessCreateComponent, decorators: [{
|
|
316
|
+
type: Component,
|
|
317
|
+
args: [{ selector: 'spine-auto-service-access-create', standalone: true, imports: [CommonModule, ButtonComponent, ComboboxComponent, ModalComponent], changeDetection: ChangeDetectionStrategy.Eager, template: "<hm-modal [open]=\"open\" (openChange)=\"onModalOpenChange($event)\" [heading]=\"text.newAccessHeading\" (closed)=\"close()\">\n <hm-combobox [label]=\"text.group\" [options]=\"groupOptions\" [value]=\"groupId\" (valueChange)=\"groupId = $event\"></hm-combobox>\n\n <ng-container footer>\n <hm-button emphasis=\"medium\" (clicked)=\"close()\">{{ text.cancel }}</hm-button>\n <hm-button [disabled]=\"!groupId\" [loading]=\"saving\" (clicked)=\"save()\">{{ text.create }}</hm-button>\n </ng-container>\n</hm-modal>\n" }]
|
|
318
|
+
}], ctorParameters: () => [{ type: AutoServiceService }], propDecorators: { clientId: [{
|
|
319
|
+
type: Input
|
|
320
|
+
}], availableGroups: [{
|
|
321
|
+
type: Input
|
|
322
|
+
}], open: [{
|
|
323
|
+
type: Input
|
|
324
|
+
}], openChange: [{
|
|
325
|
+
type: Output
|
|
326
|
+
}], created: [{
|
|
327
|
+
type: Output
|
|
328
|
+
}] } });
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Um nível da árvore de rotas — se referencia (`imports: [RouteTreeNodeComponent]`) pra
|
|
332
|
+
* desenhar os filhos, já que não existe nenhum componente de árvore no DS novo (o antigo
|
|
333
|
+
* usava `hermes-tree`/`*hermesRecursiveFor`, sem equivalente). Folha = checkbox (marca/
|
|
334
|
+
* desmarca um guard); pasta = só rótulo, sem estado próprio.
|
|
335
|
+
*/
|
|
336
|
+
class RouteTreeNodeComponent {
|
|
337
|
+
constructor() {
|
|
338
|
+
this.selectedChange = new EventEmitter();
|
|
339
|
+
}
|
|
340
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.24", ngImport: i0, type: RouteTreeNodeComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
341
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.24", type: RouteTreeNodeComponent, isStandalone: true, selector: "spine-route-tree-node", inputs: { node: "node" }, outputs: { selectedChange: "selectedChange" }, ngImport: i0, template: `
|
|
342
|
+
<li class="tree-node" [class.tree-node--folder]="node.isFolder">
|
|
343
|
+
<label *ngIf="!node.isFolder" class="tree-node__leaf">
|
|
344
|
+
<input type="checkbox" class="hm-check" [(ngModel)]="node.selected" (ngModelChange)="selectedChange.emit()" />
|
|
345
|
+
<hm-icon shape="router" class="tree-node__icon"></hm-icon>
|
|
346
|
+
<span>{{ node.name }}</span>
|
|
347
|
+
</label>
|
|
348
|
+
|
|
349
|
+
<div *ngIf="node.isFolder" class="tree-node__folder">
|
|
350
|
+
<hm-icon shape="filter-grid" class="tree-node__icon"></hm-icon>
|
|
351
|
+
<span>{{ node.name }}</span>
|
|
352
|
+
</div>
|
|
353
|
+
|
|
354
|
+
<ul class="tree-node__children" *ngIf="node.children.length">
|
|
355
|
+
<spine-route-tree-node *ngFor="let child of node.children" [node]="child" (selectedChange)="selectedChange.emit()"></spine-route-tree-node>
|
|
356
|
+
</ul>
|
|
357
|
+
</li>
|
|
358
|
+
`, isInline: true, styles: [".tree-node{list-style:none}.tree-node__children{list-style:none;margin:0;padding-inline-start:var(--hm-space-lg)}.tree-node__leaf,.tree-node__folder{display:flex;align-items:center;gap:var(--hm-space-xs);padding:var(--hm-space-micro) 0;font-size:var(--hm-font-size-sm)}.tree-node__leaf{cursor:pointer}.tree-node__folder{font-weight:var(--hm-font-weight-semibold);color:var(--hm-muted)}.tree-node__icon{flex:0 0 auto;color:var(--hm-action)}\n"], dependencies: [{ kind: "component", type: RouteTreeNodeComponent, selector: "spine-route-tree-node", inputs: ["node"], outputs: ["selectedChange"] }, { kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i3.CheckboxControlValueAccessor, selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]" }, { kind: "directive", type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i3.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: IconComponent, selector: "hm-icon", inputs: ["shape", "direction", "size", "solid", "badge", "status", "flip", "inverse", "label"] }], changeDetection: i0.ChangeDetectionStrategy.Eager }); }
|
|
359
|
+
}
|
|
360
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.24", ngImport: i0, type: RouteTreeNodeComponent, decorators: [{
|
|
361
|
+
type: Component,
|
|
362
|
+
args: [{ selector: 'spine-route-tree-node', standalone: true, imports: [CommonModule, FormsModule, IconComponent, RouteTreeNodeComponent], changeDetection: ChangeDetectionStrategy.Eager, template: `
|
|
363
|
+
<li class="tree-node" [class.tree-node--folder]="node.isFolder">
|
|
364
|
+
<label *ngIf="!node.isFolder" class="tree-node__leaf">
|
|
365
|
+
<input type="checkbox" class="hm-check" [(ngModel)]="node.selected" (ngModelChange)="selectedChange.emit()" />
|
|
366
|
+
<hm-icon shape="router" class="tree-node__icon"></hm-icon>
|
|
367
|
+
<span>{{ node.name }}</span>
|
|
368
|
+
</label>
|
|
369
|
+
|
|
370
|
+
<div *ngIf="node.isFolder" class="tree-node__folder">
|
|
371
|
+
<hm-icon shape="filter-grid" class="tree-node__icon"></hm-icon>
|
|
372
|
+
<span>{{ node.name }}</span>
|
|
373
|
+
</div>
|
|
374
|
+
|
|
375
|
+
<ul class="tree-node__children" *ngIf="node.children.length">
|
|
376
|
+
<spine-route-tree-node *ngFor="let child of node.children" [node]="child" (selectedChange)="selectedChange.emit()"></spine-route-tree-node>
|
|
377
|
+
</ul>
|
|
378
|
+
</li>
|
|
379
|
+
`, styles: [".tree-node{list-style:none}.tree-node__children{list-style:none;margin:0;padding-inline-start:var(--hm-space-lg)}.tree-node__leaf,.tree-node__folder{display:flex;align-items:center;gap:var(--hm-space-xs);padding:var(--hm-space-micro) 0;font-size:var(--hm-font-size-sm)}.tree-node__leaf{cursor:pointer}.tree-node__folder{font-weight:var(--hm-font-weight-semibold);color:var(--hm-muted)}.tree-node__icon{flex:0 0 auto;color:var(--hm-action)}\n"] }]
|
|
380
|
+
}], propDecorators: { node: [{
|
|
381
|
+
type: Input,
|
|
382
|
+
args: [{ required: true }]
|
|
383
|
+
}], selectedChange: [{
|
|
384
|
+
type: Output
|
|
385
|
+
}] } });
|
|
386
|
+
|
|
387
|
+
class AutoServiceAccessGuardsComponent {
|
|
388
|
+
constructor(service) {
|
|
389
|
+
this.service = service;
|
|
390
|
+
this.text = inject(SPINE_MESSAGES).autoService;
|
|
391
|
+
/** Telas com estado em campo comum, preenchido depois de `await`: marca a view ao terminar (app sem zone.js). */
|
|
392
|
+
this.cdr = inject(ChangeDetectorRef);
|
|
393
|
+
this.fmt = formatMessage;
|
|
394
|
+
this.clientId = '';
|
|
395
|
+
this.access = null;
|
|
396
|
+
this.open = false;
|
|
397
|
+
this.openChange = new EventEmitter();
|
|
398
|
+
this.availableRouters = [];
|
|
399
|
+
this.availableRoutes = [];
|
|
400
|
+
this.clientPrivateRouters = [];
|
|
401
|
+
this.guards = [];
|
|
402
|
+
this.tree = [];
|
|
403
|
+
this.loading = false;
|
|
404
|
+
this.saving = false;
|
|
405
|
+
this.levels = ['header_id', 'navigation_id', 'menu_id', 'item_id', 'submenu_id'];
|
|
406
|
+
}
|
|
407
|
+
ngOnChanges(changes) { if (changes['open'] && this.open) {
|
|
408
|
+
this.reset();
|
|
409
|
+
} }
|
|
410
|
+
close() { this.open = false; this.openChange.emit(false); }
|
|
411
|
+
async reset() {
|
|
412
|
+
this.loading = true;
|
|
413
|
+
try {
|
|
414
|
+
const [routersRes, routesRes] = await Promise.all([this.service.getRouters(this.clientId), this.service.getWebRoutes(this.clientId)]);
|
|
415
|
+
this.availableRouters = routersRes.routers;
|
|
416
|
+
this.availableRoutes = routesRes.routes;
|
|
417
|
+
this.clientPrivateRouters = this.availableRouters.filter((r) => r.is_private && (!r.allowed_type_ids?.length || r.allowed_type_ids.includes(this.access.group_type_id)));
|
|
418
|
+
await this.loadGuards();
|
|
419
|
+
this.buildTree();
|
|
420
|
+
}
|
|
421
|
+
finally {
|
|
422
|
+
this.loading = false;
|
|
423
|
+
this.cdr.markForCheck();
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
async loadGuards() { const res = await this.service.getGuards(this.clientId, this.access.access_id); this.guards = res.guards; }
|
|
427
|
+
routeName(id) {
|
|
428
|
+
if (!id)
|
|
429
|
+
return '—';
|
|
430
|
+
return this.availableRoutes.find((r) => r.id === id)?.name ?? id;
|
|
431
|
+
}
|
|
432
|
+
buildTree() {
|
|
433
|
+
const root = [];
|
|
434
|
+
for (const router of this.clientPrivateRouters) {
|
|
435
|
+
let currentLevel = root;
|
|
436
|
+
for (const level of this.levels) {
|
|
437
|
+
const id = router[level];
|
|
438
|
+
if (!id)
|
|
439
|
+
continue;
|
|
440
|
+
const key = `${level}:${id}`;
|
|
441
|
+
let node = currentLevel.find(n => n.key === key);
|
|
442
|
+
if (!node) {
|
|
443
|
+
node = { key, name: this.routeName(id), isFolder: true, children: [] };
|
|
444
|
+
currentLevel.push(node);
|
|
445
|
+
}
|
|
446
|
+
currentLevel = node.children;
|
|
447
|
+
}
|
|
448
|
+
const guard = this.guards.find((g) => g.router_id === router.id);
|
|
449
|
+
currentLevel.push({
|
|
450
|
+
key: `page:${router.id}`, name: router.page_name || this.routeName(router.page_id), isFolder: false,
|
|
451
|
+
routerId: router.id, guardId: guard?.guard_id, selected: !!guard, children: [],
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
this.tree = root;
|
|
455
|
+
}
|
|
456
|
+
collectLeaves(node) {
|
|
457
|
+
if (!node.isFolder)
|
|
458
|
+
return [node];
|
|
459
|
+
return node.children.flatMap(child => this.collectLeaves(child));
|
|
460
|
+
}
|
|
461
|
+
get allLeaves() { return this.tree.flatMap(node => this.collectLeaves(node)); }
|
|
462
|
+
get hasChanges() { return this.allLeaves.some(leaf => !!leaf.selected !== !!leaf.guardId); }
|
|
463
|
+
async confirm() {
|
|
464
|
+
const leaves = this.allLeaves;
|
|
465
|
+
const toAdd = leaves.filter(l => l.selected && !l.guardId);
|
|
466
|
+
const toRemove = leaves.filter(l => !l.selected && l.guardId);
|
|
467
|
+
if (toAdd.length === 0 && toRemove.length === 0) {
|
|
468
|
+
this.close();
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
471
|
+
this.saving = true;
|
|
472
|
+
try {
|
|
473
|
+
for (const l of toAdd) {
|
|
474
|
+
await this.service.addGuard(this.clientId, this.access.access_id, l.routerId);
|
|
475
|
+
}
|
|
476
|
+
for (const l of toRemove) {
|
|
477
|
+
await this.service.removeGuard(this.clientId, this.access.access_id, l.guardId);
|
|
478
|
+
}
|
|
479
|
+
this.close();
|
|
480
|
+
}
|
|
481
|
+
finally {
|
|
482
|
+
this.saving = false;
|
|
483
|
+
this.cdr.markForCheck();
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.24", ngImport: i0, type: AutoServiceAccessGuardsComponent, deps: [{ token: AutoServiceService }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
487
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.24", type: AutoServiceAccessGuardsComponent, isStandalone: true, selector: "spine-auto-service-access-guards", inputs: { clientId: "clientId", access: "access", open: "open" }, outputs: { openChange: "openChange" }, usesOnChanges: true, ngImport: i0, template: "<hm-drawer [open]=\"open\" (openChange)=\"open = $event\" [heading]=\"fmt(text.routesOf, { group: access?.group_name ?? '' })\" (closed)=\"close()\">\n <p class=\"muted\" *ngIf=\"!loading\" [innerHTML]=\"fmt(text.guardsHint, { badge: access?.group_type_name ?? '' })\"></p>\n\n <div *ngIf=\"loading\" class=\"loading-row\">\n <span>{{ text.loading }}</span>\n </div>\n\n <ul class=\"route-tree\" *ngIf=\"!loading\">\n <spine-route-tree-node *ngFor=\"let node of tree\" [node]=\"node\"></spine-route-tree-node>\n </ul>\n\n <div class=\"empty-state\" *ngIf=\"!loading && tree.length === 0\">\n <hm-icon shape=\"filter-grid\" size=\"xl\"></hm-icon>\n <p>{{ text.noPrivateRoutes }}</p>\n </div>\n\n <ng-container footer>\n <hm-button emphasis=\"medium\" (clicked)=\"close()\">{{ text.cancel }}</hm-button>\n <hm-button [disabled]=\"!hasChanges\" [loading]=\"saving\" (clicked)=\"confirm()\">{{ text.confirmChanges }}</hm-button>\n </ng-container>\n</hm-drawer>\n", styles: [".as-stack{display:flex;flex-direction:column;gap:var(--hm-space-md);min-inline-size:0}.as-actions{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:var(--hm-space-xs)}.as-field-row{display:flex;flex-wrap:wrap;align-items:flex-end;gap:var(--hm-space-sm)}.as-field-row>:first-child{flex:1 1 20rem;min-inline-size:0}.as-summary{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-sm)}.as-summary__info{display:flex;flex:1 1 16rem;flex-direction:column;gap:var(--hm-space-micro);min-inline-size:0}.as-summary__title{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-xs);margin:0;color:var(--hm-text);font-size:var(--hm-font-size-md);font-weight:var(--hm-font-weight-semibold)}.as-summary__detail{margin:0;color:var(--hm-muted);font-size:var(--hm-font-size-sm)}.muted{color:var(--hm-muted)}.loading-row{display:flex;justify-content:center;padding:var(--hm-space-xl);color:var(--hm-muted)}.route-tree{list-style:none;margin:0;padding:0}.empty-state{display:flex;flex-direction:column;align-items:center;gap:var(--hm-space-xs);padding:var(--hm-space-xl);color:var(--hm-muted);text-align:center}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: ButtonComponent, selector: "hm-button", inputs: ["emphasis", "intent", "size", "type", "icon", "iconDirection", "iconEnd", "disabled", "loading", "busy", "loadingState", "block", "link", "newTab", "caret", "inMenu", "toggle", "pressed"], outputs: ["loadingStateChange", "pressedChange", "clicked"] }, { kind: "component", type: IconComponent, selector: "hm-icon", inputs: ["shape", "direction", "size", "solid", "badge", "status", "flip", "inverse", "label"] }, { kind: "component", type: DrawerComponent, selector: "hm-drawer", inputs: ["open", "heading", "size", "position", "pinned", "closeLabel", "closable", "beforeClose"], outputs: ["openChange", "closed"] }, { kind: "component", type: RouteTreeNodeComponent, selector: "spine-route-tree-node", inputs: ["node"], outputs: ["selectedChange"] }], changeDetection: i0.ChangeDetectionStrategy.Eager }); }
|
|
488
|
+
}
|
|
489
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.24", ngImport: i0, type: AutoServiceAccessGuardsComponent, decorators: [{
|
|
490
|
+
type: Component,
|
|
491
|
+
args: [{ selector: 'spine-auto-service-access-guards', standalone: true, imports: [CommonModule, ButtonComponent, IconComponent, DrawerComponent, RouteTreeNodeComponent], changeDetection: ChangeDetectionStrategy.Eager, template: "<hm-drawer [open]=\"open\" (openChange)=\"open = $event\" [heading]=\"fmt(text.routesOf, { group: access?.group_name ?? '' })\" (closed)=\"close()\">\n <p class=\"muted\" *ngIf=\"!loading\" [innerHTML]=\"fmt(text.guardsHint, { badge: access?.group_type_name ?? '' })\"></p>\n\n <div *ngIf=\"loading\" class=\"loading-row\">\n <span>{{ text.loading }}</span>\n </div>\n\n <ul class=\"route-tree\" *ngIf=\"!loading\">\n <spine-route-tree-node *ngFor=\"let node of tree\" [node]=\"node\"></spine-route-tree-node>\n </ul>\n\n <div class=\"empty-state\" *ngIf=\"!loading && tree.length === 0\">\n <hm-icon shape=\"filter-grid\" size=\"xl\"></hm-icon>\n <p>{{ text.noPrivateRoutes }}</p>\n </div>\n\n <ng-container footer>\n <hm-button emphasis=\"medium\" (clicked)=\"close()\">{{ text.cancel }}</hm-button>\n <hm-button [disabled]=\"!hasChanges\" [loading]=\"saving\" (clicked)=\"confirm()\">{{ text.confirmChanges }}</hm-button>\n </ng-container>\n</hm-drawer>\n", styles: [".as-stack{display:flex;flex-direction:column;gap:var(--hm-space-md);min-inline-size:0}.as-actions{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:var(--hm-space-xs)}.as-field-row{display:flex;flex-wrap:wrap;align-items:flex-end;gap:var(--hm-space-sm)}.as-field-row>:first-child{flex:1 1 20rem;min-inline-size:0}.as-summary{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-sm)}.as-summary__info{display:flex;flex:1 1 16rem;flex-direction:column;gap:var(--hm-space-micro);min-inline-size:0}.as-summary__title{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-xs);margin:0;color:var(--hm-text);font-size:var(--hm-font-size-md);font-weight:var(--hm-font-weight-semibold)}.as-summary__detail{margin:0;color:var(--hm-muted);font-size:var(--hm-font-size-sm)}.muted{color:var(--hm-muted)}.loading-row{display:flex;justify-content:center;padding:var(--hm-space-xl);color:var(--hm-muted)}.route-tree{list-style:none;margin:0;padding:0}.empty-state{display:flex;flex-direction:column;align-items:center;gap:var(--hm-space-xs);padding:var(--hm-space-xl);color:var(--hm-muted);text-align:center}\n"] }]
|
|
492
|
+
}], ctorParameters: () => [{ type: AutoServiceService }], propDecorators: { clientId: [{
|
|
493
|
+
type: Input
|
|
494
|
+
}], access: [{
|
|
495
|
+
type: Input
|
|
496
|
+
}], open: [{
|
|
497
|
+
type: Input
|
|
498
|
+
}], openChange: [{
|
|
499
|
+
type: Output
|
|
500
|
+
}] } });
|
|
501
|
+
|
|
502
|
+
class AutoServiceAccessComponent {
|
|
503
|
+
constructor(service) {
|
|
504
|
+
this.service = service;
|
|
505
|
+
this.text = inject(SPINE_MESSAGES).autoService;
|
|
506
|
+
/** Telas com estado em campo comum, preenchido depois de `await`: marca a view ao terminar (app sem zone.js). */
|
|
507
|
+
this.cdr = inject(ChangeDetectorRef);
|
|
508
|
+
this.clientId = '';
|
|
509
|
+
this.entries = [];
|
|
510
|
+
this.availableGroups = [];
|
|
511
|
+
this.loading = false;
|
|
512
|
+
this.showCreate = false;
|
|
513
|
+
this.showGuards = false;
|
|
514
|
+
this.activeAccess = null;
|
|
515
|
+
this.rowId = (a) => a.access_id;
|
|
516
|
+
this.columns = computed(() => [
|
|
517
|
+
{ key: 'group_name', title: this.text.colGroup, value: (a) => a.group_name, sortable: true },
|
|
518
|
+
{ key: 'group_type_name', title: this.text.colBadge, value: (a) => a.group_type_name, sortable: true },
|
|
519
|
+
], ...(ngDevMode ? [{ debugName: "columns" }] : /* istanbul ignore next */ []));
|
|
520
|
+
this.rowActions = computed(() => [
|
|
521
|
+
{ id: 'guards', icon: 'shield', label: this.text.manageRoutes },
|
|
522
|
+
{ id: 'delete', icon: 'trash', label: this.text.remove, danger: true, separatorAbove: true },
|
|
523
|
+
], ...(ngDevMode ? [{ debugName: "rowActions" }] : /* istanbul ignore next */ []));
|
|
524
|
+
}
|
|
525
|
+
ngOnChanges(changes) {
|
|
526
|
+
if (changes['clientId']) {
|
|
527
|
+
this.load();
|
|
528
|
+
this.loadGroups();
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
async load() {
|
|
532
|
+
if (!this.clientId) {
|
|
533
|
+
this.entries = [];
|
|
534
|
+
return;
|
|
535
|
+
}
|
|
536
|
+
this.loading = true;
|
|
537
|
+
try {
|
|
538
|
+
const res = await this.service.getAccess(this.clientId);
|
|
539
|
+
this.entries = res.access;
|
|
540
|
+
}
|
|
541
|
+
finally {
|
|
542
|
+
this.loading = false;
|
|
543
|
+
this.cdr.markForCheck();
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
async loadGroups() {
|
|
547
|
+
if (!this.clientId) {
|
|
548
|
+
this.availableGroups = [];
|
|
549
|
+
return;
|
|
550
|
+
}
|
|
551
|
+
const res = await this.service.getGroups(this.clientId);
|
|
552
|
+
this.availableGroups = res.groups;
|
|
553
|
+
this.cdr.markForCheck();
|
|
554
|
+
}
|
|
555
|
+
openCreate() { this.showCreate = true; }
|
|
556
|
+
async onCreated() { await this.load(); }
|
|
557
|
+
async deleteAccess(accessId) { await this.service.deleteAccess(this.clientId, accessId); await this.load(); }
|
|
558
|
+
openGuards(access) { this.activeAccess = access; this.showGuards = true; }
|
|
559
|
+
onAction(e) {
|
|
560
|
+
if (e.action === 'guards')
|
|
561
|
+
this.openGuards(e.row);
|
|
562
|
+
if (e.action === 'delete')
|
|
563
|
+
void this.deleteAccess(e.row.access_id);
|
|
564
|
+
}
|
|
565
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.24", ngImport: i0, type: AutoServiceAccessComponent, deps: [{ token: AutoServiceService }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
566
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.24", type: AutoServiceAccessComponent, isStandalone: true, selector: "spine-auto-service-access", inputs: { clientId: "clientId" }, usesOnChanges: true, ngImport: i0, template: "<hm-data-grid\n [columns]=\"columns()\"\n [rows]=\"entries\"\n [rowId]=\"rowId\"\n [caption]=\"text.accessCaption\"\n [loading]=\"loading\"\n [rowActions]=\"rowActions()\"\n (actionTriggered)=\"onAction($event)\"\n [emptyMessage]=\"text.noAccess\"\n>\n <hm-button dataGridActions icon=\"plus\" (clicked)=\"openCreate()\">{{ text.newAccess }}</hm-button>\n</hm-data-grid>\n\n<spine-auto-service-access-create\n [clientId]=\"clientId\"\n [availableGroups]=\"availableGroups\"\n [open]=\"showCreate\"\n (openChange)=\"showCreate = $event\"\n (created)=\"onCreated()\">\n</spine-auto-service-access-create>\n\n<spine-auto-service-access-guards\n *ngIf=\"activeAccess\"\n [clientId]=\"clientId\"\n [access]=\"activeAccess\"\n [open]=\"showGuards\"\n (openChange)=\"showGuards = $event\">\n</spine-auto-service-access-guards>\n", styles: [".as-stack{display:flex;flex-direction:column;gap:var(--hm-space-md);min-inline-size:0}.as-actions{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:var(--hm-space-xs)}.as-field-row{display:flex;flex-wrap:wrap;align-items:flex-end;gap:var(--hm-space-sm)}.as-field-row>:first-child{flex:1 1 20rem;min-inline-size:0}.as-summary{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-sm)}.as-summary__info{display:flex;flex:1 1 16rem;flex-direction:column;gap:var(--hm-space-micro);min-inline-size:0}.as-summary__title{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-xs);margin:0;color:var(--hm-text);font-size:var(--hm-font-size-md);font-weight:var(--hm-font-weight-semibold)}.as-summary__detail{margin:0;color:var(--hm-muted);font-size:var(--hm-font-size-sm)}.muted{color:var(--hm-muted)}:host{display:block}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: ButtonComponent, selector: "hm-button", inputs: ["emphasis", "intent", "size", "type", "icon", "iconDirection", "iconEnd", "disabled", "loading", "busy", "loadingState", "block", "link", "newTab", "caret", "inMenu", "toggle", "pressed"], outputs: ["loadingStateChange", "pressedChange", "clicked"] }, { kind: "component", type: DataGridComponent, selector: "hm-data-grid", inputs: ["columns", "rows", "rowId", "caption", "rowActions", "loading", "error", "emptyMessage", "noResultsMessage", "filterable", "paginated", "pageState", "pagination", "totalItems", "sort", "selectable", "selectionMode", "selection", "rowSelectable", "rowSelectableReason", "rowDetailDisabled", "rowDetailHidden", "virtual", "rowHeight", "pinnedColumns", "columnState", "pageSizes", "fillHeight", "maxHeight", "bordered", "rowState", "rowClickable", "remoteSearch", "remoteSort", "itemsLabel", "pageSizeLabel", "exportable", "exportFileName", "groupBy", "aggregates", "aggregateFormatter", "persistKey", "persistStorage", "advancedFilter", "filterQuery", "columnManager", "columnOrder", "searchTerm"], outputs: ["pageStateChange", "sortChange", "selectionChange", "pinnedColumnsChange", "columnStateChange", "actionTriggered", "detailToggled", "rowClicked", "clearFiltersRequested", "filteredChange", "searchTermChanged", "groupByChange", "filterQueryChange", "columnOrderChange", "searchTermChange", "detailPaneToggled"] }, { kind: "component", type: AutoServiceAccessCreateComponent, selector: "spine-auto-service-access-create", inputs: ["clientId", "availableGroups", "open"], outputs: ["openChange", "created"] }, { kind: "component", type: AutoServiceAccessGuardsComponent, selector: "spine-auto-service-access-guards", inputs: ["clientId", "access", "open"], outputs: ["openChange"] }], changeDetection: i0.ChangeDetectionStrategy.Eager }); }
|
|
567
|
+
}
|
|
568
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.24", ngImport: i0, type: AutoServiceAccessComponent, decorators: [{
|
|
569
|
+
type: Component,
|
|
570
|
+
args: [{ selector: 'spine-auto-service-access', standalone: true, imports: [CommonModule, ButtonComponent, IconComponent, DataGridComponent, AutoServiceAccessCreateComponent, AutoServiceAccessGuardsComponent], changeDetection: ChangeDetectionStrategy.Eager, template: "<hm-data-grid\n [columns]=\"columns()\"\n [rows]=\"entries\"\n [rowId]=\"rowId\"\n [caption]=\"text.accessCaption\"\n [loading]=\"loading\"\n [rowActions]=\"rowActions()\"\n (actionTriggered)=\"onAction($event)\"\n [emptyMessage]=\"text.noAccess\"\n>\n <hm-button dataGridActions icon=\"plus\" (clicked)=\"openCreate()\">{{ text.newAccess }}</hm-button>\n</hm-data-grid>\n\n<spine-auto-service-access-create\n [clientId]=\"clientId\"\n [availableGroups]=\"availableGroups\"\n [open]=\"showCreate\"\n (openChange)=\"showCreate = $event\"\n (created)=\"onCreated()\">\n</spine-auto-service-access-create>\n\n<spine-auto-service-access-guards\n *ngIf=\"activeAccess\"\n [clientId]=\"clientId\"\n [access]=\"activeAccess\"\n [open]=\"showGuards\"\n (openChange)=\"showGuards = $event\">\n</spine-auto-service-access-guards>\n", styles: [".as-stack{display:flex;flex-direction:column;gap:var(--hm-space-md);min-inline-size:0}.as-actions{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:var(--hm-space-xs)}.as-field-row{display:flex;flex-wrap:wrap;align-items:flex-end;gap:var(--hm-space-sm)}.as-field-row>:first-child{flex:1 1 20rem;min-inline-size:0}.as-summary{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-sm)}.as-summary__info{display:flex;flex:1 1 16rem;flex-direction:column;gap:var(--hm-space-micro);min-inline-size:0}.as-summary__title{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-xs);margin:0;color:var(--hm-text);font-size:var(--hm-font-size-md);font-weight:var(--hm-font-weight-semibold)}.as-summary__detail{margin:0;color:var(--hm-muted);font-size:var(--hm-font-size-sm)}.muted{color:var(--hm-muted)}:host{display:block}\n"] }]
|
|
571
|
+
}], ctorParameters: () => [{ type: AutoServiceService }], propDecorators: { clientId: [{
|
|
572
|
+
type: Input
|
|
573
|
+
}] } });
|
|
574
|
+
|
|
575
|
+
class AutoServiceClientComponent {
|
|
576
|
+
constructor() {
|
|
577
|
+
this.text = inject(SPINE_MESSAGES).autoService;
|
|
578
|
+
this.client = null;
|
|
579
|
+
this.activeTab = 'routes';
|
|
580
|
+
}
|
|
581
|
+
onClientChange(c) { this.client = c; }
|
|
582
|
+
setTab(tab) { this.activeTab = tab; }
|
|
583
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.24", ngImport: i0, type: AutoServiceClientComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
584
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.24", type: AutoServiceClientComponent, isStandalone: true, selector: "spine-auto-service-client", ngImport: i0, template: "<!-- T\u00EDtulo e descri\u00E7\u00E3o da tela v\u00EAm da barra da p\u00E1gina (nome + description do router). -->\n<div class=\"as-stack\">\n <spine-auto-service-client-picker (clientChange)=\"onClientChange($event)\"></spine-auto-service-client-picker>\n\n <!-- Conte\u00FAdo de cada aba \u00E9 pregui\u00E7oso (*hmTabContent): s\u00F3 busca na API quando a aba \u00E9 aberta. -->\n <hm-tabs *ngIf=\"client as c\" [label]=\"text.clientSections\" [active]=\"activeTab\" (activeChange)=\"setTab($any($event))\">\n <hm-tab id=\"routes\" [label]=\"text.tabRoutes\">\n <spine-auto-service-routes *hmTabContent [clientId]=\"c.id\"></spine-auto-service-routes>\n </hm-tab>\n <hm-tab id=\"routers\" [label]=\"text.tabRouters\">\n <spine-auto-service-routers *hmTabContent [clientId]=\"c.id\"></spine-auto-service-routers>\n </hm-tab>\n <hm-tab id=\"access\" [label]=\"text.tabAccess\">\n <spine-auto-service-access *hmTabContent [clientId]=\"c.id\"></spine-auto-service-access>\n </hm-tab>\n </hm-tabs>\n</div>\n", styles: [".as-stack{display:flex;flex-direction:column;gap:var(--hm-space-md);min-inline-size:0}.as-actions{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:var(--hm-space-xs)}.as-field-row{display:flex;flex-wrap:wrap;align-items:flex-end;gap:var(--hm-space-sm)}.as-field-row>:first-child{flex:1 1 20rem;min-inline-size:0}.as-summary{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-sm)}.as-summary__info{display:flex;flex:1 1 16rem;flex-direction:column;gap:var(--hm-space-micro);min-inline-size:0}.as-summary__title{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-xs);margin:0;color:var(--hm-text);font-size:var(--hm-font-size-md);font-weight:var(--hm-font-weight-semibold)}.as-summary__detail{margin:0;color:var(--hm-muted);font-size:var(--hm-font-size-sm)}.muted{color:var(--hm-muted)}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: TabsComponent, selector: "hm-tabs", inputs: ["label", "active", "orientation", "mode", "overflow", "fillHeight", "noPanelGap"], outputs: ["activeChange"] }, { kind: "component", type: TabComponent, selector: "hm-tab", inputs: ["id", "label", "disabled", "count", "route", "exact", "destroyOnHide"] }, { kind: "directive", type: TabContentDirective, selector: "ng-template[hmTabContent]" }, { kind: "component", type: AutoServiceClientPickerComponent, selector: "spine-auto-service-client-picker", outputs: ["clientChange"] }, { kind: "component", type: AutoServiceRoutesComponent, selector: "spine-auto-service-routes", inputs: ["clientId"] }, { kind: "component", type: AutoServiceRoutersComponent, selector: "spine-auto-service-routers", inputs: ["clientId"] }, { kind: "component", type: AutoServiceAccessComponent, selector: "spine-auto-service-access", inputs: ["clientId"] }], changeDetection: i0.ChangeDetectionStrategy.Eager }); }
|
|
585
|
+
}
|
|
586
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.24", ngImport: i0, type: AutoServiceClientComponent, decorators: [{
|
|
587
|
+
type: Component,
|
|
588
|
+
args: [{ selector: 'spine-auto-service-client', standalone: true, imports: [
|
|
589
|
+
CommonModule, TabsComponent, TabComponent, TabContentDirective,
|
|
590
|
+
AutoServiceClientPickerComponent, AutoServiceRoutesComponent, AutoServiceRoutersComponent, AutoServiceAccessComponent,
|
|
591
|
+
], changeDetection: ChangeDetectionStrategy.Eager, template: "<!-- T\u00EDtulo e descri\u00E7\u00E3o da tela v\u00EAm da barra da p\u00E1gina (nome + description do router). -->\n<div class=\"as-stack\">\n <spine-auto-service-client-picker (clientChange)=\"onClientChange($event)\"></spine-auto-service-client-picker>\n\n <!-- Conte\u00FAdo de cada aba \u00E9 pregui\u00E7oso (*hmTabContent): s\u00F3 busca na API quando a aba \u00E9 aberta. -->\n <hm-tabs *ngIf=\"client as c\" [label]=\"text.clientSections\" [active]=\"activeTab\" (activeChange)=\"setTab($any($event))\">\n <hm-tab id=\"routes\" [label]=\"text.tabRoutes\">\n <spine-auto-service-routes *hmTabContent [clientId]=\"c.id\"></spine-auto-service-routes>\n </hm-tab>\n <hm-tab id=\"routers\" [label]=\"text.tabRouters\">\n <spine-auto-service-routers *hmTabContent [clientId]=\"c.id\"></spine-auto-service-routers>\n </hm-tab>\n <hm-tab id=\"access\" [label]=\"text.tabAccess\">\n <spine-auto-service-access *hmTabContent [clientId]=\"c.id\"></spine-auto-service-access>\n </hm-tab>\n </hm-tabs>\n</div>\n", styles: [".as-stack{display:flex;flex-direction:column;gap:var(--hm-space-md);min-inline-size:0}.as-actions{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:var(--hm-space-xs)}.as-field-row{display:flex;flex-wrap:wrap;align-items:flex-end;gap:var(--hm-space-sm)}.as-field-row>:first-child{flex:1 1 20rem;min-inline-size:0}.as-summary{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-sm)}.as-summary__info{display:flex;flex:1 1 16rem;flex-direction:column;gap:var(--hm-space-micro);min-inline-size:0}.as-summary__title{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-xs);margin:0;color:var(--hm-text);font-size:var(--hm-font-size-md);font-weight:var(--hm-font-weight-semibold)}.as-summary__detail{margin:0;color:var(--hm-muted);font-size:var(--hm-font-size-sm)}.muted{color:var(--hm-muted)}\n"] }]
|
|
592
|
+
}] });
|
|
593
|
+
|
|
594
|
+
export { AutoServiceClientComponent };
|
|
595
|
+
//# sourceMappingURL=trismegisto-spine-auto-service-auto-service-client.component-BYkUOwWL.mjs.map
|