aril 1.2.47 → 1.2.48
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/esm2022/theme/layout/service/interfaces/interfaces.mjs +1 -1
- package/esm2022/theme/layout/service/selection-group.service.mjs +72 -6
- package/fesm2022/aril-theme-layout.mjs +71 -5
- package/fesm2022/aril-theme-layout.mjs.map +1 -1
- package/package.json +131 -131
- package/theme/layout/service/interfaces/interfaces.d.ts +7 -0
- package/theme/layout/service/interfaces/interfaces.ts +8 -0
- package/theme/layout/service/selection-group.service.d.ts +12 -0
- package/theme/layout/service/selection-group.service.ts +144 -73
- package/ui/table/src/table.component.d.ts +1 -1
|
@@ -1,73 +1,144 @@
|
|
|
1
|
-
import { HttpClient } from '@angular/common/http';
|
|
2
|
-
import { Injectable, effect, signal } from '@angular/core';
|
|
3
|
-
|
|
4
|
-
import { take } from 'rxjs';
|
|
5
|
-
|
|
6
|
-
import { API_CONFIGS } from 'aril/boot/config/api';
|
|
7
|
-
|
|
8
|
-
import { SelectionGroupDTO, SelectionRequestDTO } from './interfaces/interfaces';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
1
|
+
import { HttpClient } from '@angular/common/http';
|
|
2
|
+
import { Injectable, effect, signal } from '@angular/core';
|
|
3
|
+
|
|
4
|
+
import { take } from 'rxjs';
|
|
5
|
+
|
|
6
|
+
import { API_CONFIGS } from 'aril/boot/config/api';
|
|
7
|
+
|
|
8
|
+
import { SelectionGroupDTO, SelectionGroupVersionDTO, SelectionRequestDTO } from './interfaces/interfaces';
|
|
9
|
+
|
|
10
|
+
const STORAGE_KEY = 'selection-groups';
|
|
11
|
+
|
|
12
|
+
@Injectable({
|
|
13
|
+
providedIn: 'root'
|
|
14
|
+
})
|
|
15
|
+
export class SelectionGroupService {
|
|
16
|
+
selectionGroups = signal<{ [key: string]: SelectionGroupDTO | null }>({});
|
|
17
|
+
|
|
18
|
+
private loading = new Map<string, boolean>();
|
|
19
|
+
private loaded = new Map<string, boolean>();
|
|
20
|
+
|
|
21
|
+
constructor(private http: HttpClient) {
|
|
22
|
+
this.loadStatesFromLocalStorage();
|
|
23
|
+
this.revalidateCachedGroups();
|
|
24
|
+
|
|
25
|
+
effect(() => {
|
|
26
|
+
try {
|
|
27
|
+
const encodedData = btoa(encodeURI(JSON.stringify(this.selectionGroups())));
|
|
28
|
+
localStorage.setItem(STORAGE_KEY, encodedData);
|
|
29
|
+
} catch (e) {
|
|
30
|
+
// Kota dolduysa ya da depolama kapalıysa yalnızca önbellek kaybolur; gruplar sunucudan çekilmeye devam eder.
|
|
31
|
+
console.warn('Selection groups could not be cached', e);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
private async loadStatesFromLocalStorage() {
|
|
37
|
+
const selectionGroups = localStorage.getItem(STORAGE_KEY);
|
|
38
|
+
|
|
39
|
+
if (selectionGroups) {
|
|
40
|
+
try {
|
|
41
|
+
const decodedData = decodeURI(atob(selectionGroups));
|
|
42
|
+
this.selectionGroups.set(JSON.parse(decodedData));
|
|
43
|
+
} catch (e) {
|
|
44
|
+
console.error(e);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Önbellek kendi başına bayatlar: bir grubun etiketi sunucuda değiştiğinde localStorage'daki
|
|
51
|
+
* kopya güncellenmez ve kullanıcı eski etiketi süresiz görür. Bu yüzden açılışta grup sürümleri
|
|
52
|
+
* okunur ve yalnız değişenler düşürülür; düşen grubu bileşenlerin mevcut "grup yoksa fetchEnum"
|
|
53
|
+
* yolu yeniden çeker.
|
|
54
|
+
*
|
|
55
|
+
* Sürüm listesi alınamazsa önbelleğe DOKUNULMAZ: davranış bu durumda bugünküne eşitlenir,
|
|
56
|
+
* yani tazelik kaybedilir ama hiçbir etiket kaybolmaz.
|
|
57
|
+
*/
|
|
58
|
+
private revalidateCachedGroups() {
|
|
59
|
+
if (!Object.keys(this.selectionGroups()).length) return;
|
|
60
|
+
|
|
61
|
+
this.http
|
|
62
|
+
.get<SelectionGroupVersionDTO[]>(this.hostApi() + '/selection-group/versions')
|
|
63
|
+
.pipe(take(1))
|
|
64
|
+
.subscribe({
|
|
65
|
+
next: (versions) => {
|
|
66
|
+
// Gövdesiz/biçimsiz yanıt "sürüm bilinmiyor" demektir; hata yolundaki gibi önbellek korunur.
|
|
67
|
+
if (!Array.isArray(versions)) return;
|
|
68
|
+
this.dropStaleGroups(versions);
|
|
69
|
+
},
|
|
70
|
+
error: () => {
|
|
71
|
+
console.debug('Selection group versions unavailable; cached groups are kept as is.');
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
private dropStaleGroups(versions: SelectionGroupVersionDTO[]) {
|
|
77
|
+
const serverVersions = new Map(versions.map((version) => [version.groupName, version.version]));
|
|
78
|
+
|
|
79
|
+
this.selectionGroups.update((groups) => {
|
|
80
|
+
const next = { ...groups };
|
|
81
|
+
let dropped = false;
|
|
82
|
+
|
|
83
|
+
for (const key of Object.keys(next)) {
|
|
84
|
+
const group = next[key];
|
|
85
|
+
if (!group) continue;
|
|
86
|
+
|
|
87
|
+
// Yalnız localStorage'dan gelen girdiler doğrulanır. Bu oturumda istenmiş bir grup zaten
|
|
88
|
+
// tazedir ve düşürülmemelidir: tüketiciler kendi "istedim" kaydını tuttuğu için (bkz.
|
|
89
|
+
// TableComponent.requestedEnumKeys) düşen grubu yeniden istemezler ve seçenekleri
|
|
90
|
+
// kalıcı olarak boş kalır. `has`, süren istekleri de kapsar: fetchEnum başlarken false,
|
|
91
|
+
// biterken true yazar.
|
|
92
|
+
if (this.loaded.has(key)) continue;
|
|
93
|
+
|
|
94
|
+
// Anahtar `groupName~parentSelectionKey` biçimindedir: aynı grubun her parent varyantı
|
|
95
|
+
// ayrı bir girdidir ve grup değiştiğinde hepsi birlikte düşmelidir.
|
|
96
|
+
const serverVersion = serverVersions.get(key.split('~')[0]);
|
|
97
|
+
|
|
98
|
+
// Sunucu yalnız Fixed grupların sürümünü döndürür. Sürümü gelmeyen grup ya Dynamic'tir
|
|
99
|
+
// (içeriği sorgudan üretilir, doğrulanamaz) ya da silinmiştir; ikisinde de tutulmaz.
|
|
100
|
+
if (serverVersion !== undefined && serverVersion === group.version) continue;
|
|
101
|
+
|
|
102
|
+
delete next[key];
|
|
103
|
+
dropped = true;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return dropped ? next : groups;
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
fetchEnum(groupName: string, parentSelectionKey: string = 'ALL') {
|
|
111
|
+
const key = groupName + '~' + parentSelectionKey;
|
|
112
|
+
|
|
113
|
+
if (this.loaded.get(key) || this.loading.get(key)) return;
|
|
114
|
+
|
|
115
|
+
const payload: SelectionRequestDTO = {
|
|
116
|
+
groupName,
|
|
117
|
+
parentSelectionKey
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
this.loading.set(key, true);
|
|
121
|
+
this.loaded.set(key, false);
|
|
122
|
+
|
|
123
|
+
this.http
|
|
124
|
+
.post<SelectionGroupDTO>(this.hostApi() + '/selection-group/load', payload)
|
|
125
|
+
.pipe(take(1))
|
|
126
|
+
.subscribe((selectionGroup) => {
|
|
127
|
+
this.loading.set(key, false);
|
|
128
|
+
this.loaded.set(key, true);
|
|
129
|
+
|
|
130
|
+
this.selectionGroups.update((groups) => ({
|
|
131
|
+
...groups,
|
|
132
|
+
[key]: selectionGroup
|
|
133
|
+
}));
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
private hostApi(): string {
|
|
138
|
+
return API_CONFIGS.api.replace(/\/[^\/]+\/v1$/, `/host/v1`);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
isLoading(groupName: string): boolean {
|
|
142
|
+
return this.loading.get(groupName) ?? false;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
@@ -24,7 +24,7 @@ export declare class TableComponent {
|
|
|
24
24
|
checkboxSelection: import("@angular/core").InputSignal<boolean | undefined, boolean | undefined>;
|
|
25
25
|
radioButtonSelection: import("@angular/core").InputSignal<boolean | undefined, boolean | undefined>;
|
|
26
26
|
headerCheckboxSelection: import("@angular/core").InputSignal<boolean | undefined, boolean | undefined>;
|
|
27
|
-
pageSize: import("@angular/core").InputSignal<5 | 10 |
|
|
27
|
+
pageSize: import("@angular/core").InputSignal<5 | 10 | 1000 | 500 | 20 | 50 | 100, 5 | 10 | 1000 | 500 | 20 | 50 | 100>;
|
|
28
28
|
proxy: import("@angular/core").InputSignal<ProxyTypes, ProxyTypes>;
|
|
29
29
|
showFooter: import("@angular/core").InputSignal<boolean, boolean>;
|
|
30
30
|
tAlign: import("@angular/core").InputSignal<AlignTypes, AlignTypes>;
|