@wawjs/ngx-bos 22.0.6 → 22.0.7

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.
Files changed (30) hide show
  1. package/README.md +1 -1
  2. package/RELEASES.md +38 -0
  3. package/fesm2022/file.service-C8Erkqrm.mjs +48 -0
  4. package/fesm2022/file.service-C8Erkqrm.mjs.map +1 -0
  5. package/fesm2022/{wawjs-ngx-bos-ngx-bos.config-B6tWU_X3.mjs → ngx-bos.config-DjtgUjR8.mjs} +3 -5
  6. package/fesm2022/ngx-bos.config-DjtgUjR8.mjs.map +1 -0
  7. package/fesm2022/{wawjs-ngx-bos-user.service-DFgHcvNR.mjs → user-crud.component-B1_SlIDS.mjs} +146 -16
  8. package/fesm2022/user-crud.component-B1_SlIDS.mjs.map +1 -0
  9. package/fesm2022/wawjs-ngx-bos.mjs +201 -184
  10. package/fesm2022/wawjs-ngx-bos.mjs.map +1 -1
  11. package/package.json +11 -9
  12. package/src/feature/file/file.component.html +1 -0
  13. package/src/feature/file/file.component.ts +34 -8
  14. package/src/feature/user/pages/clients/clients.component.ts +19 -45
  15. package/src/feature/user/pages/user-crud.component.ts +119 -0
  16. package/src/feature/user/pages/users/users.component.ts +33 -86
  17. package/src/feature/user/user.service.ts +102 -15
  18. package/src/form-components/ace/ace.component.ts +15 -1
  19. package/src/form-components/file/file.component.html +2 -2
  20. package/src/form-components/form-config-cache.ts +70 -0
  21. package/src/form-components/input/input.form.ts +1 -1
  22. package/src/form-components/select/select.component.html +24 -24
  23. package/src/form-components/tinymce/tinymce.component.ts +12 -0
  24. package/src/ngx-bos.config.ts +6 -4
  25. package/src/pages/form/form.component.ts +44 -7
  26. package/src/pages/forms/forms.component.ts +14 -2
  27. package/src/public-api.ts +1 -1
  28. package/types/wawjs-ngx-bos.d.ts +52 -15
  29. package/fesm2022/wawjs-ngx-bos-ngx-bos.config-B6tWU_X3.mjs.map +0 -1
  30. package/fesm2022/wawjs-ngx-bos-user.service-DFgHcvNR.mjs.map +0 -1
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Reusable Angular 22 contracts, services, guards, selectors, pages, and AI guidance for Ngx BOS CRM and business operating system applications.
4
4
 
5
- Current package line: `22.0.2`.
5
+ Current package line: `22.0.6`.
6
6
 
7
7
  ## App Contract
8
8
 
package/RELEASES.md CHANGED
@@ -1,5 +1,43 @@
1
1
  # Releases
2
2
 
3
+ ## 22.0.7
4
+
5
+ Bump `projects/ngx-bos/package.json`, the root `package.json` and `NGX_BOS_VERSION` together when
6
+ publishing.
7
+
8
+ - Built with the Angular `@angular/build:library` builder instead of `ng-packagr`; the published files and
9
+ `exports` are unchanged and `tslib` stays a dependency.
10
+ - Companion package line updated to Angular 22.3.0 and `@wawjs/*` 22.0.16.
11
+ - The user delete confirmation reads "Delete this user?" (it was "Are we sure to delete this user ?").
12
+ - Users and Clients share `UserCrudComponent`: edit and delete use the `admin` backend routes
13
+ (the unnamed update always targeted the signed-in user), delete asks for confirmation, the edit
14
+ form leaves out Email (not an updatable key), bulk edit is removed, and both tables follow the
15
+ live user list. Clients reads the shared list instead of replacing it with one page.
16
+ - `UserService`: logs out when the `me` check fails (except offline or 502 to 504), clears the
17
+ cached CRUD data on logout and when another user signs in, reports `updateMe()` errors, and
18
+ loads the user list only for users with a role (`hasAnyRole()`, `loadUsers()`).
19
+ - Form modals start from the document being opened instead of the previous one; `inputForm` has
20
+ its own `formId`; the form page offers the registered component names and guards the settings
21
+ button.
22
+ - TinyMCE keeps one config object per props, so the editor is no longer re-created while typing.
23
+ - File picker: multi-file fields accept an empty value, closing the crop modal no longer hangs the
24
+ picker, uploads keep a file extension, and the thumb-only clear button no longer opens the picker.
25
+
26
+ ### Migration notes
27
+
28
+ - The backend user list (`/api/user/get`, `/api/user/fetch`) now requires at least one role.
29
+ Apps that read it for plain accounts must stop doing so.
30
+ - Apps that provide `NGX_FORM_CONFIG` with their own factory must pass `modalFormComponent` and
31
+ `modalUniqueComponent` (only `provideNgxForm()` adds them).
32
+
33
+ ## 22.0.6
34
+
35
+ Bug-fix release.
36
+
37
+ - Logout waits for the server to clear the session cookie before reloading (at most 3 seconds).
38
+ - Image resize keeps PNG and WebP (transparency) and passes through files the browser cannot decode
39
+ instead of waiting forever.
40
+
3
41
  ## 22.0.5
4
42
 
5
43
  Bug-fix release on the `@wawjs/*` 22.0.12 line.
@@ -0,0 +1,48 @@
1
+ import * as i0 from "@angular/core";
2
+ import { Service, inject } from "@angular/core";
3
+ import { CrudService } from "@wawjs/ngx-crud";
4
+ import { HttpService } from "@wawjs/ngx-http";
5
+ var FileService = class FileService extends CrudService {
6
+ constructor() {
7
+ super({ name: "file" });
8
+ this._http = inject(HttpService);
9
+ }
10
+ async uploadBase64(dataUrl, container = "general", name = "") {
11
+ return await new Promise((resolve, reject) => {
12
+ this._http.post("/api/cloudflare/upload-base64", {
13
+ container,
14
+ name,
15
+ dataUrl
16
+ }, (resp) => resolve(resp?.publicUrl || ""), { err: (error) => reject(error) });
17
+ });
18
+ }
19
+ static {
20
+ this.ɵfac = i0.ɵɵngDeclareFactory({
21
+ minVersion: "12.0.0",
22
+ version: "22.3.0",
23
+ ngImport: i0,
24
+ type: FileService,
25
+ deps: [],
26
+ target: i0.ɵɵFactoryTarget.Service
27
+ });
28
+ }
29
+ static {
30
+ this.ɵprov = i0.ɵɵngDeclareService({
31
+ minVersion: "22.0.0",
32
+ version: "22.3.0",
33
+ ngImport: i0,
34
+ type: FileService
35
+ });
36
+ }
37
+ };
38
+ i0.ɵɵngDeclareClassMetadata({
39
+ minVersion: "12.0.0",
40
+ version: "22.3.0",
41
+ ngImport: i0,
42
+ type: FileService,
43
+ decorators: [{ type: Service }],
44
+ ctorParameters: () => []
45
+ });
46
+ export { FileService as t };
47
+
48
+ //# sourceMappingURL=file.service-C8Erkqrm.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file.service-C8Erkqrm.mjs","names":[],"sources":["../../../projects/ngx-bos/src/feature/file/file.service.ts"],"sourcesContent":["import { Service, inject } from '@angular/core';\r\nimport { CrudService } from '@wawjs/ngx-crud';\r\nimport { HttpService } from '@wawjs/ngx-http';\r\nimport { File } from './file.interface';\r\n\r\ninterface UploadBase64Response {\r\n\tpublicUrl?: string;\r\n}\r\n\r\n@Service()\r\nexport class FileService extends CrudService<File> {\r\n\tprivate readonly _http = inject(HttpService);\r\n\r\n\tconstructor() {\r\n\t\tsuper({ name: 'file' });\r\n\t}\r\n\r\n\t/**\r\n\t * Upload base64 (data URL) to backend with optional container/name.\r\n\t * Returns a URL string from the API; rejects when the request fails.\r\n\t */\r\n\tasync uploadBase64(\r\n\t\tdataUrl: string,\r\n\t\tcontainer = 'general',\r\n\t\tname = '',\r\n\t): Promise<string> {\r\n\t\treturn await new Promise<string>((resolve, reject) => {\r\n\t\t\tthis._http.post(\r\n\t\t\t\t'/api/cloudflare/upload-base64',\r\n\t\t\t\t{ container, name, dataUrl },\r\n\t\t\t\t(resp: UploadBase64Response) => resolve(resp?.publicUrl || ''),\r\n\t\t\t\t{ err: (error: unknown) => reject(error) },\r\n\t\t\t);\r\n\t\t});\r\n\t}\r\n}\r\n"],"mappings":";;;;AAUA,IAAa,cAAb,MAAa,oBAAoB,YAAiB;CAGjD,cAAA;EACC,MAAM,EAAE,MAAM,OAAM,CAAE;EAHN,KAAA,QAAQ,OAAO,WAAW;CAI3C;CAMA,MAAM,aACL,SACA,YAAY,WACZ,OAAO,IAAE;EAET,OAAO,MAAM,IAAI,SAAiB,SAAS,WAAU;GACpD,KAAK,MAAM,KACV,iCACA;IAAE;IAAW;IAAM;GAAO,IACzB,SAA+B,QAAQ,MAAM,aAAa,EAAE,GAC7D,EAAE,MAAM,UAAmB,OAAO,KAAK,EAAC,CAAE;EAE5C,CAAC;CACF;CAxBY;EAAA,KAAA,OAAA,GAAA,mBAAA;GAAA,YAAA;GAAA,SAAA;GAAA,UAAA;GAAA,MAAA;GAAW,MAAA,CAAA;GAAA,QAAA,GAAA,gBAAA;EAAA,CAAA;CAAA;CAAX;EAAA,KAAA,QAAA,GAAA,mBAAA;GAAA,YAAA;GAAA,SAAA;GAAA,UAAA;GAAA,MAAA;EAAW,CAAA;CAAA;;AAAX,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAW,YAAA,CAAA,EADvB,MAAA,Q"}
@@ -12,18 +12,16 @@ const DEFAULT_NGX_BOS_CONFIG = {
12
12
  };
13
13
  const NGX_BOS_CONFIG = new InjectionToken("NGX_BOS_CONFIG", { factory: () => DEFAULT_NGX_BOS_CONFIG });
14
14
  function ngxBosProvide(config = {}) {
15
+ const defined = Object.fromEntries(Object.entries(config).filter(([, value]) => value !== void 0));
15
16
  return makeEnvironmentProviders([{
16
17
  provide: NGX_BOS_CONFIG,
17
18
  useValue: {
18
19
  ...DEFAULT_NGX_BOS_CONFIG,
19
- ...config,
20
- roles: config.roles ?? DEFAULT_NGX_BOS_CONFIG.roles,
21
- userFields: config.userFields ?? DEFAULT_NGX_BOS_CONFIG.userFields,
22
- userForm: config.userForm ?? DEFAULT_NGX_BOS_CONFIG.userForm
20
+ ...defined
23
21
  }
24
22
  }]);
25
23
  }
26
24
  const provideNgxBos = ngxBosProvide;
27
25
  export { provideNgxBos as i, NGX_BOS_CONFIG as n, ngxBosProvide as r, DEFAULT_NGX_BOS_CONFIG as t };
28
26
 
29
- //# sourceMappingURL=wawjs-ngx-bos-ngx-bos.config-B6tWU_X3.mjs.map
27
+ //# sourceMappingURL=ngx-bos.config-DjtgUjR8.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ngx-bos.config-DjtgUjR8.mjs","names":[],"sources":["../../../projects/ngx-bos/src/ngx-bos.config.ts"],"sourcesContent":["import {\r\n\tEnvironmentProviders,\r\n\tInjectionToken,\r\n\tProvider,\r\n\tmakeEnvironmentProviders,\r\n} from '@angular/core';\r\nimport { FormComponentInterface } from '@wawjs/ngx-form';\r\n\r\nexport interface NgxBosConfig {\r\n\tappId?: string;\r\n\turl?: string;\r\n\tcdnUrl?: string;\r\n\troles?: string[];\r\n\tuserFields?: string[];\r\n\tuserForm?: FormComponentInterface[];\r\n\tsignPath?: string;\r\n\tprofilePath?: string;\r\n\tdefaultUserThumb?: string;\r\n}\r\n\r\nexport const DEFAULT_NGX_BOS_CONFIG: Required<NgxBosConfig> = {\r\n\tappId: '',\r\n\turl: '',\r\n\tcdnUrl: 'https://cdn.webart.work',\r\n\troles: [],\r\n\tuserFields: [],\r\n\tuserForm: [],\r\n\tsignPath: '/sign',\r\n\tprofilePath: '/profile',\r\n\tdefaultUserThumb: 'default.png',\r\n};\r\n\r\nexport const NGX_BOS_CONFIG = new InjectionToken<Required<NgxBosConfig>>(\r\n\t'NGX_BOS_CONFIG',\r\n\t{\r\n\t\tfactory: () => DEFAULT_NGX_BOS_CONFIG,\r\n\t},\r\n);\r\n\r\nexport function ngxBosProvide(config: NgxBosConfig = {}): EnvironmentProviders {\r\n\t// An explicit `undefined` (for example an unset environment value) must not replace a default.\r\n\tconst defined = Object.fromEntries(\r\n\t\tObject.entries(config).filter(([, value]) => value !== undefined),\r\n\t) as NgxBosConfig;\r\n\r\n\treturn makeEnvironmentProviders([\r\n\t\t{\r\n\t\t\tprovide: NGX_BOS_CONFIG,\r\n\t\t\tuseValue: {\r\n\t\t\t\t...DEFAULT_NGX_BOS_CONFIG,\r\n\t\t\t\t...defined,\r\n\t\t\t},\r\n\t\t} satisfies Provider,\r\n\t]);\r\n}\r\n\r\nexport const provideNgxBos = ngxBosProvide;\r\n"],"mappings":";AAoBA,MAAa,yBAAiD;CAC7D,OAAO;CACP,KAAK;CACL,QAAQ;CACR,OAAO,CAAA;CACP,YAAY,CAAA;CACZ,UAAU,CAAA;CACV,UAAU;CACV,aAAa;CACb,kBAAkB;AAClB;AAED,MAAa,iBAAiB,IAAI,eACjC,kBACA,EACC,eAAe,uBACf,CAAA;AAGF,SAAgB,cAAc,SAAuB,CAAA,GAAE;CAEtD,MAAM,UAAU,OAAO,YACtB,OAAO,QAAQ,MAAM,CAAC,CAAC,QAAQ,GAAG,WAAW,UAAU,MAAS,CAAC;CAGlE,OAAO,yBAAyB,CAC/B;EACC,SAAS;EACT,UAAU;GACT,GAAG;GACH,GAAG;EACH;CACkB,CACpB,CAAA;AACF;AAEA,MAAa,gBAAgB"}
@@ -1,11 +1,24 @@
1
- import { n as NGX_BOS_CONFIG } from "./wawjs-ngx-bos-ngx-bos.config-B6tWU_X3.mjs";
1
+ import { n as NGX_BOS_CONFIG } from "./ngx-bos.config-DjtgUjR8.mjs";
2
+ import { t as FileService } from "./file.service-C8Erkqrm.mjs";
2
3
  import * as i0 from "@angular/core";
3
- import { Service, computed, inject, signal } from "@angular/core";
4
+ import { Service, computed, effect, inject, signal, untracked } from "@angular/core";
4
5
  import { AlertService } from "@wawjs/ngx-ui";
5
- import { CrudService } from "@wawjs/ngx-crud";
6
+ import { CrudComponent, CrudService } from "@wawjs/ngx-crud";
6
7
  import { HttpService } from "@wawjs/ngx-http";
8
+ import { FormService, FormcomponentService } from "@wawjs/ngx-form";
7
9
  import { EmitterService } from "@wawjs/ngx-core";
8
10
  import { Router } from "@angular/router";
11
+ const NEW_USER = {
12
+ _id: "",
13
+ data: {},
14
+ is: {},
15
+ roles: [],
16
+ name: "",
17
+ phone: "",
18
+ bio: "",
19
+ email: "",
20
+ thumb: ""
21
+ };
9
22
  const createUserFormComponents = (userForm = []) => ({
10
23
  formId: "user",
11
24
  title: "Profile Settings",
@@ -63,10 +76,29 @@ function readStoredUser() {
63
76
  localStorage.removeItem(USER_STORAGE_KEY);
64
77
  return null;
65
78
  }
79
+ function guestUser() {
80
+ return {
81
+ ...NEW_USER,
82
+ data: {},
83
+ is: {},
84
+ roles: []
85
+ };
86
+ }
66
87
  var UserService = class UserService extends CrudService {
67
88
  role(role) {
68
89
  return !!(this.user().is || {})[role];
69
90
  }
91
+ hasAnyRole(user = this.user()) {
92
+ const is = user.is || {};
93
+ return Object.keys(is).some((role) => !!is[role]);
94
+ }
95
+ loadUsers() {
96
+ if (this._usersRequested || !this.hasAnyRole()) return;
97
+ this._usersRequested = true;
98
+ this.get({ query: this._bosConfig.appId ? "appId=" + this._bosConfig.appId : "" }).subscribe({ error: () => {
99
+ this._usersRequested = false;
100
+ } });
101
+ }
70
102
  constructor() {
71
103
  super({
72
104
  name: "user",
@@ -84,15 +116,21 @@ var UserService = class UserService extends CrudService {
84
116
  this._router = inject(Router);
85
117
  this._emitterService = inject(EmitterService);
86
118
  this._bosConfig = inject(NGX_BOS_CONFIG);
119
+ this._userScopedServices = [
120
+ inject(FileService),
121
+ inject(FormService),
122
+ inject(FormcomponentService)
123
+ ];
87
124
  this.url = this._bosConfig.url;
88
125
  this.roles = this._bosConfig.roles.concat(["admin"]);
89
126
  this.employees = this._bosConfig.roles;
90
127
  this.users = this.documents;
91
- this.user = signal(readStoredUser() ?? this.prepareDocument()(), ...ngDevMode ? [{ debugName: "user" }] : /* istanbul ignore next */ []);
128
+ this.user = signal(readStoredUser() ?? guestUser(), ...ngDevMode ? [{ debugName: "user" }] : /* istanbul ignore next */ []);
92
129
  this.thumb = computed(() => {
93
130
  const thumb = this.user().thumb;
94
131
  return !thumb || thumb.includes(this._bosConfig.defaultUserThumb) ? this._bosConfig.defaultUserThumb : /^https?:\/\//i.test(thumb) ? thumb : this.url + thumb;
95
132
  }, ...ngDevMode ? [{ debugName: "thumb" }] : /* istanbul ignore next */ []);
133
+ this._usersRequested = false;
96
134
  this.usersByRole = computed(() => {
97
135
  const splitted = {};
98
136
  for (const user of this.documents()) for (const role of user.roles || []) {
@@ -102,22 +140,43 @@ var UserService = class UserService extends CrudService {
102
140
  return splitted;
103
141
  }, ...ngDevMode ? [{ debugName: "usersByRole" }] : /* istanbul ignore next */ []);
104
142
  if (localStorage.getItem("waw_user")) {
105
- this.fetch({}, { name: "me" }).subscribe((user) => {
106
- if (user) this.setUser(user);
107
- else if (localStorage.getItem("waw_user")) this.logout();
143
+ this.fetch({}, { name: "me" }).subscribe({
144
+ next: (user) => {
145
+ if (user) {
146
+ this.setUser(user);
147
+ this.loadUsers();
148
+ } else if (localStorage.getItem("waw_user")) this.logout();
149
+ },
150
+ error: (error) => {
151
+ const status = error?.status;
152
+ if (status === 0 || status === 502 || status === 503 || status === 504) {
153
+ this._emitterService.complete("us.user");
154
+ return;
155
+ }
156
+ if (localStorage.getItem("waw_user")) this.logout();
157
+ }
108
158
  });
109
- this.get({ query: this._bosConfig.appId ? "appId=" + this._bosConfig.appId : "" });
159
+ this.loadUsers();
110
160
  }
111
161
  }
112
162
  setUser(user) {
113
163
  this.user.set(user);
164
+ if (user._id) {
165
+ this.checkUser(user._id);
166
+ for (const service of this._userScopedServices) service.checkUser(user._id);
167
+ }
114
168
  localStorage.setItem(USER_STORAGE_KEY, JSON.stringify(user));
115
169
  this._emitterService.complete("us.user");
116
170
  }
117
171
  updateMe() {
118
172
  this.setUser(this.user());
119
- return this.update(this.user()).subscribe(() => {
120
- this._alertService.info({ text: "Profile information has been updated" });
173
+ return this.update(this.user()).subscribe({
174
+ next: () => {
175
+ this._alertService.info({ text: "Profile information has been updated" });
176
+ },
177
+ error: () => {
178
+ this._alertService.error({ text: "Something went wrong" });
179
+ }
121
180
  });
122
181
  }
123
182
  updateMeAfterWhile() {
@@ -134,8 +193,10 @@ var UserService = class UserService extends CrudService {
134
193
  });
135
194
  }
136
195
  logout() {
137
- this.user.set(this.prepareDocument()());
196
+ this.user.set(guestUser());
138
197
  localStorage.removeItem(USER_STORAGE_KEY);
198
+ this.clearDocs();
199
+ for (const service of this._userScopedServices) service.clearDocs();
139
200
  let finished = false;
140
201
  const finish = () => {
141
202
  if (finished) return;
@@ -158,7 +219,7 @@ var UserService = class UserService extends CrudService {
158
219
  static {
159
220
  this.ɵfac = i0.ɵɵngDeclareFactory({
160
221
  minVersion: "12.0.0",
161
- version: "22.2.5",
222
+ version: "22.3.0",
162
223
  ngImport: i0,
163
224
  type: UserService,
164
225
  deps: [],
@@ -168,7 +229,7 @@ var UserService = class UserService extends CrudService {
168
229
  static {
169
230
  this.ɵprov = i0.ɵɵngDeclareService({
170
231
  minVersion: "22.0.0",
171
- version: "22.2.5",
232
+ version: "22.3.0",
172
233
  ngImport: i0,
173
234
  type: UserService
174
235
  });
@@ -176,12 +237,81 @@ var UserService = class UserService extends CrudService {
176
237
  };
177
238
  i0.ɵɵngDeclareClassMetadata({
178
239
  minVersion: "12.0.0",
179
- version: "22.2.5",
240
+ version: "22.3.0",
180
241
  ngImport: i0,
181
242
  type: UserService,
182
243
  decorators: [{ type: Service }],
183
244
  ctorParameters: () => []
184
245
  });
185
- export { userFormComponentsFactory as i, readStoredUser as n, createUserFormComponents as r, UserService as t };
246
+ var UserCrudComponent = class extends CrudComponent {
247
+ constructor() {
248
+ super(userFormComponentsFactory(), inject(FormService), inject(UserService), "user");
249
+ this.userService = inject(UserService);
250
+ this._userFormService = inject(FormService);
251
+ this._userAlertService = inject(AlertService);
252
+ this._createForm = userFormComponentsFactory();
253
+ this._editForm = {
254
+ ...this._createForm,
255
+ formId: "user-edit",
256
+ components: this._createForm.components.filter((component) => component.key !== "email")
257
+ };
258
+ this.configType = "local";
259
+ effect(() => {
260
+ this.userService.documents();
261
+ if (this.userService.isLoaded()) untracked(() => void this.setDocuments());
262
+ });
263
+ }
264
+ allowUrl() {
265
+ return false;
266
+ }
267
+ withoutBulkEdit(config) {
268
+ return {
269
+ ...config,
270
+ headerButtons: (config.headerButtons || []).filter((button) => button.class !== "edit")
271
+ };
272
+ }
273
+ create() {
274
+ if (this._createForm.formId) this._userFormService.reset(this._createForm.formId, this.createObject());
275
+ super.create();
276
+ }
277
+ update(doc) {
278
+ this._userFormService.reset(this._editForm.formId, doc);
279
+ this._userFormService.modal(this._editForm, {
280
+ label: "Update",
281
+ click: (updated, close) => {
282
+ close();
283
+ const { email: _email, ...changes } = updated;
284
+ const next = {
285
+ ...doc,
286
+ ...changes
287
+ };
288
+ this.userService.updateAdmin(next).subscribe({
289
+ next: () => {
290
+ this.setDocuments();
291
+ },
292
+ error: () => {
293
+ this.setDocuments();
294
+ }
295
+ });
296
+ }
297
+ }, doc);
298
+ }
299
+ async delete(doc) {
300
+ this._userAlertService.question({
301
+ text: "Delete this user?",
302
+ timeout: 0,
303
+ progress: false,
304
+ buttons: [{
305
+ text: "Delete",
306
+ callback: () => {
307
+ this.userService.deleteAdmin(doc).subscribe(() => {
308
+ this.setDocuments();
309
+ });
310
+ }
311
+ }, { text: "Cancel" }]
312
+ });
313
+ }
314
+ };
315
+ export { userFormComponentsFactory as a, createUserFormComponents as i, UserService as n, NEW_USER as o, readStoredUser as r, UserCrudComponent as t };
186
316
 
187
- //# sourceMappingURL=wawjs-ngx-bos-user.service-DFgHcvNR.mjs.map
317
+ //# sourceMappingURL=user-crud.component-B1_SlIDS.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-crud.component-B1_SlIDS.mjs","names":[],"sources":["../../../projects/ngx-bos/src/feature/user/user.const.ts","../../../projects/ngx-bos/src/feature/user/user.form.ts","../../../projects/ngx-bos/src/feature/user/user.storage.ts","../../../projects/ngx-bos/src/feature/user/user.service.ts","../../../projects/ngx-bos/src/feature/user/pages/user-crud.component.ts"],"sourcesContent":["import { User } from './user.interface';\r\n\r\nexport const NEW_USER: User = {\r\n\t_id: '',\r\n\tdata: {},\r\n\tis: {},\r\n\troles: [],\r\n\tname: '',\r\n\tphone: '',\r\n\tbio: '',\r\n\temail: '',\r\n\tthumb: '',\r\n};\r\n","import { inject } from '@angular/core';\r\nimport { FormComponentInterface } from '@wawjs/ngx-form';\r\nimport { NGX_BOS_CONFIG } from '../../ngx-bos.config';\r\n\r\nexport const createUserFormComponents = (\r\n\tuserForm: FormComponentInterface[] = [],\r\n) => ({\r\n\tformId: 'user',\r\n\ttitle: 'Profile Settings',\r\n\tcomponents: [\r\n\t\t{\r\n\t\t\tname: 'Input',\r\n\t\t\tkey: 'name',\r\n\t\t\tfocused: true,\r\n\t\t\tprops: {\r\n\t\t\t\tplaceholder: 'Enter name...',\r\n\t\t\t\tlabel: 'Name',\r\n\t\t\t},\r\n\t\t},\r\n\t\t{\r\n\t\t\tname: 'Input',\r\n\t\t\tkey: 'email',\r\n\t\t\tprops: {\r\n\t\t\t\tplaceholder: 'Enter email...',\r\n\t\t\t\tlabel: 'Email',\r\n\t\t\t\ttype: 'email',\r\n\t\t\t},\r\n\t\t},\r\n\t\t{\r\n\t\t\tname: 'Input',\r\n\t\t\tkey: 'phone',\r\n\t\t\tprops: {\r\n\t\t\t\tplaceholder: 'Enter phone...',\r\n\t\t\t\tlabel: 'Phone',\r\n\t\t\t},\r\n\t\t},\r\n\t\t{\r\n\t\t\tname: 'Input',\r\n\t\t\tkey: 'bio',\r\n\t\t\tprops: {\r\n\t\t\t\tplaceholder: 'Enter bio...',\r\n\t\t\t\tlabel: 'Biography',\r\n\t\t\t\ttype: 'textarea',\r\n\t\t\t},\r\n\t\t},\r\n\t\t...userForm,\r\n\t],\r\n});\r\n\r\nexport const userFormComponentsFactory = () => {\r\n\tconst config = inject(NGX_BOS_CONFIG);\r\n\r\n\treturn createUserFormComponents(config.userForm);\r\n};\r\n","import { User } from './user.interface';\r\n\r\n/** localStorage key holding the signed-in user snapshot. */\r\nexport const USER_STORAGE_KEY = 'waw_user';\r\n\r\n/**\r\n * Reads the stored user snapshot. Returns `null` when nothing is stored or when the\r\n * stored value is corrupted; a corrupted value is removed so it cannot break guards\r\n * or service initialization again.\r\n */\r\nexport function readStoredUser(): User | null {\r\n\tconst stored = localStorage.getItem(USER_STORAGE_KEY);\r\n\r\n\tif (!stored) {\r\n\t\treturn null;\r\n\t}\r\n\r\n\ttry {\r\n\t\tconst user = JSON.parse(stored) as User | null;\r\n\r\n\t\tif (user && typeof user === 'object') {\r\n\t\t\treturn user;\r\n\t\t}\r\n\t} catch {\r\n\t\t// fall through to cleanup\r\n\t}\r\n\r\n\tlocalStorage.removeItem(USER_STORAGE_KEY);\r\n\r\n\treturn null;\r\n}\r\n","import { Service, computed, inject, signal } from '@angular/core';\r\nimport { Router } from '@angular/router';\r\nimport { AlertService } from '@wawjs/ngx-ui';\r\nimport { CrudService } from '@wawjs/ngx-crud';\r\nimport { EmitterService } from '@wawjs/ngx-core';\r\nimport { FormcomponentService, FormService } from '@wawjs/ngx-form';\r\nimport { HttpService } from '@wawjs/ngx-http';\r\nimport { NGX_BOS_CONFIG } from '../../ngx-bos.config';\r\nimport { FileService } from '../file/file.service';\r\nimport { NEW_USER } from './user.const';\r\nimport { User } from './user.interface';\r\nimport { readStoredUser, USER_STORAGE_KEY } from './user.storage';\r\n\r\n/** Signed-out user: no `_id`, no roles. A fresh copy so nested objects are never shared. */\r\nfunction guestUser(): User {\r\n\treturn { ...NEW_USER, data: {}, is: {}, roles: [] };\r\n}\r\n\r\n@Service()\r\nexport class UserService extends CrudService<User> {\r\n\tprivate readonly _userHttpService = inject(HttpService);\r\n\r\n\tprivate readonly _alertService = inject(AlertService);\r\n\r\n\tprivate readonly _router = inject(Router);\r\n\r\n\tprivate readonly _emitterService = inject(EmitterService);\r\n\r\n\tprivate readonly _bosConfig = inject(NGX_BOS_CONFIG);\r\n\r\n\t/** Other CRUD collections whose cached documents and queued mutations belong to one user. */\r\n\tprivate readonly _userScopedServices: Pick<CrudService<User>, 'checkUser' | 'clearDocs'>[] = [\r\n\t\tinject(FileService),\r\n\t\tinject(FormService),\r\n\t\tinject(FormcomponentService),\r\n\t];\r\n\r\n\treadonly url = this._bosConfig.url;\r\n\r\n\troles = this._bosConfig.roles.concat(['admin']);\r\n\r\n\temployees = this._bosConfig.roles;\r\n\r\n\treadonly users = this.documents;\r\n\r\n\tuser = signal<User>(readStoredUser() ?? guestUser());\r\n\r\n\tthumb = computed(() => {\r\n\t\tconst thumb = this.user().thumb;\r\n\r\n\t\treturn !thumb || thumb.includes(this._bosConfig.defaultUserThumb)\r\n\t\t\t? this._bosConfig.defaultUserThumb\r\n\t\t\t: /^https?:\\/\\//i.test(thumb)\r\n\t\t\t\t? thumb\r\n\t\t\t\t: this.url + thumb;\r\n\t});\r\n\r\n\trole(role: string): boolean {\r\n\t\treturn !!(this.user().is || {})[role];\r\n\t}\r\n\r\n\t/** True when the user has at least one role (admin or any configured staff role). */\r\n\thasAnyRole(user: User = this.user()): boolean {\r\n\t\tconst is = user.is || {};\r\n\r\n\t\treturn Object.keys(is).some((role) => !!is[role]);\r\n\t}\r\n\r\n\tprivate _usersRequested = false;\r\n\r\n\t/**\r\n\t * Loads the user list once. The backend only gives it to users with a role (it holds emails\r\n\t * and phones, and anyone can register), so plain accounts do not request it at all.\r\n\t */\r\n\tloadUsers(): void {\r\n\t\tif (this._usersRequested || !this.hasAnyRole()) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tthis._usersRequested = true;\r\n\r\n\t\tthis.get({\r\n\t\t\tquery: this._bosConfig.appId ? 'appId=' + this._bosConfig.appId : '',\r\n\t\t}).subscribe({\r\n\t\t\terror: () => {\r\n\t\t\t\t// Allow a retry, for example after the session or the roles are refreshed.\r\n\t\t\t\tthis._usersRequested = false;\r\n\t\t\t},\r\n\t\t});\r\n\t}\r\n\r\n\treadonly usersByRole = computed<Record<string, User[]>>(() => {\r\n\t\tconst splitted: Record<string, User[]> = {};\r\n\r\n\t\tfor (const user of this.documents()) {\r\n\t\t\tfor (const role of user.roles || []) {\r\n\t\t\t\tif (role === undefined || role === null) continue;\r\n\t\t\t\t(splitted[String(role)] ??= []).push(user);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn splitted;\r\n\t});\r\n\r\n\tconstructor() {\r\n\t\tsuper({\r\n\t\t\tname: 'user',\r\n\t\t\treplace: (user) => {\r\n\t\t\t\tuser.roles = [];\r\n\t\t\t\tuser.data = user.data || {};\r\n\t\t\t\tuser.is = user.is || {};\r\n\r\n\t\t\t\tfor (const field of this._bosConfig.userFields) {\r\n\t\t\t\t\tuser.data[field] = user.data[field] || {};\r\n\t\t\t\t}\r\n\r\n\t\t\t\tfor (const role of this.roles) {\r\n\t\t\t\t\tif (user.is[role]) {\r\n\t\t\t\t\t\tuser.roles.push(role);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\treturn user;\r\n\t\t\t},\r\n\t\t});\r\n\r\n\t\tif (localStorage.getItem(USER_STORAGE_KEY)) {\r\n\t\t\tthis.fetch({}, { name: 'me' }).subscribe({\r\n\t\t\t\tnext: (user: User) => {\r\n\t\t\t\t\tif (user) {\r\n\t\t\t\t\t\tthis.setUser(user);\r\n\t\t\t\t\t\t// The stored roles may be stale; a role granted since the last visit counts.\r\n\t\t\t\t\t\tthis.loadUsers();\r\n\t\t\t\t\t} else if (localStorage.getItem(USER_STORAGE_KEY)) {\r\n\t\t\t\t\t\tthis.logout();\r\n\t\t\t\t\t}\r\n\t\t\t\t},\r\n\t\t\t\terror: (error: unknown) => {\r\n\t\t\t\t\t// Keep the saved user while offline or while the API is down; any other error\r\n\t\t\t\t\t// means the session is no longer valid.\r\n\t\t\t\t\tconst status = (error as { status?: number } | null)?.status;\r\n\r\n\t\t\t\t\tif (status === 0 || status === 502 || status === 503 || status === 504) {\r\n\t\t\t\t\t\tthis._emitterService.complete('us.user');\r\n\r\n\t\t\t\t\t\treturn;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif (localStorage.getItem(USER_STORAGE_KEY)) {\r\n\t\t\t\t\t\tthis.logout();\r\n\t\t\t\t\t}\r\n\t\t\t\t},\r\n\t\t\t});\r\n\r\n\t\t\tthis.loadUsers();\r\n\t\t}\r\n\t}\r\n\r\n\tsetUser(user: User) {\r\n\t\tthis.user.set(user);\r\n\r\n\t\t// Cached CRUD documents and queued mutations belong to the previous user on this browser:\r\n\t\t// each collection drops them when the stored owner differs from this user.\r\n\t\tif (user._id) {\r\n\t\t\tvoid this.checkUser(user._id);\r\n\r\n\t\t\tfor (const service of this._userScopedServices) {\r\n\t\t\t\tvoid service.checkUser(user._id);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tlocalStorage.setItem(USER_STORAGE_KEY, JSON.stringify(user));\r\n\r\n\t\tthis._emitterService.complete('us.user');\r\n\t}\r\n\r\n\tupdateMe() {\r\n\t\tthis.setUser(this.user());\r\n\r\n\t\treturn this.update(this.user()).subscribe({\r\n\t\t\tnext: () => {\r\n\t\t\t\tthis._alertService.info({\r\n\t\t\t\t\ttext: 'Profile information has been updated',\r\n\t\t\t\t});\r\n\t\t\t},\r\n\t\t\terror: () => {\r\n\t\t\t\tthis._alertService.error({\r\n\t\t\t\t\ttext: 'Something went wrong',\r\n\t\t\t\t});\r\n\t\t\t},\r\n\t\t});\r\n\t}\r\n\r\n\tupdateMeAfterWhile() {\r\n\t\tthis.setUser(this.user());\r\n\r\n\t\tthis.updateAfterWhile(this.user());\r\n\t}\r\n\r\n\tchangePassword(oldPass: string, newPass: string) {\r\n\t\treturn this._userHttpService.post(\r\n\t\t\t'/api/user/changePassword',\r\n\t\t\t{\r\n\t\t\t\tnewPass: newPass,\r\n\t\t\t\toldPass: oldPass,\r\n\t\t\t},\r\n\t\t\t(resp: boolean) => {\r\n\t\t\t\tif (resp) {\r\n\t\t\t\t\tthis._alertService.info({\r\n\t\t\t\t\t\ttext: 'Successfully changed password',\r\n\t\t\t\t\t});\r\n\t\t\t\t} else {\r\n\t\t\t\t\tthis._alertService.error({\r\n\t\t\t\t\t\ttext: 'Incorrect current password',\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t);\r\n\t}\r\n\r\n\tlogout() {\r\n\t\tthis.user.set(guestUser());\r\n\r\n\t\tlocalStorage.removeItem(USER_STORAGE_KEY);\r\n\r\n\t\t// Do not leave this user's cached documents and queued mutations to the next person.\r\n\t\tthis.clearDocs();\r\n\r\n\t\tfor (const service of this._userScopedServices) {\r\n\t\t\tservice.clearDocs();\r\n\t\t}\r\n\r\n\t\t// Reload only after the server has cleared the session cookie: reloading right away can\r\n\t\t// cancel the request and leave the session alive. Do not wait longer than 3s if the API is down.\r\n\t\tlet finished = false;\r\n\r\n\t\tconst finish = () => {\r\n\t\t\tif (finished) return;\r\n\r\n\t\t\tfinished = true;\r\n\r\n\t\t\tthis._router.navigateByUrl(this._bosConfig.signPath);\r\n\r\n\t\t\tsetTimeout(() => {\r\n\t\t\t\tlocation.reload();\r\n\t\t\t}, 100);\r\n\t\t};\r\n\r\n\t\tthis._userHttpService.get('/api/user/logout', finish, { err: finish });\r\n\r\n\t\tthis._userHttpService.remove('token');\r\n\r\n\t\tsetTimeout(finish, 3000);\r\n\t}\r\n\r\n\tupdateAdmin(user: User) {\r\n\t\treturn this.update(user, {\r\n\t\t\tname: 'admin',\r\n\t\t});\r\n\t}\r\n\r\n\tdeleteAdmin(user: User) {\r\n\t\treturn this.delete(user, {\r\n\t\t\tname: 'admin',\r\n\t\t});\r\n\t}\r\n}\r\n","import { effect, inject, untracked } from '@angular/core';\r\nimport { CrudComponent, TableConfig } from '@wawjs/ngx-crud';\r\nimport { FormInterface, FormService } from '@wawjs/ngx-form';\r\nimport { AlertService } from '@wawjs/ngx-ui';\r\nimport { userFormComponentsFactory } from '../user.form';\r\nimport { User } from '../user.interface';\r\nimport { UserService } from '../user.service';\r\n\r\n/**\r\n * Shared admin behavior for the Users and Clients tables.\r\n *\r\n * The backend's unnamed `/api/user/update` always targets the signed-in user, and user delete only\r\n * exists as the `admin` variant, so every mutation here goes through `updateAdmin` / `deleteAdmin`.\r\n * Email is not an updatable key on the backend, so the edit form leaves it out.\r\n */\r\nexport abstract class UserCrudComponent extends CrudComponent<UserService, User, FormInterface> {\r\n\tprotected readonly userService = inject(UserService);\r\n\r\n\tprivate readonly _userFormService = inject(FormService);\r\n\r\n\tprivate readonly _userAlertService = inject(AlertService);\r\n\r\n\tprivate readonly _createForm = userFormComponentsFactory();\r\n\r\n\tprivate readonly _editForm: FormInterface = {\r\n\t\t...this._createForm,\r\n\t\tformId: 'user-edit',\r\n\t\tcomponents: this._createForm.components.filter((component) => component.key !== 'email'),\r\n\t};\r\n\r\n\tprotected override configType: 'server' | 'local' = 'local';\r\n\r\n\tconstructor() {\r\n\t\tsuper(userFormComponentsFactory(), inject(FormService), inject(UserService), 'user');\r\n\r\n\t\t// The user list arrives after startup; keep the table in sync with it. setDocuments() reads\r\n\t\t// and writes document signals, so it runs untracked to keep the effect from re-dirtying itself.\r\n\t\teffect(() => {\r\n\t\t\tthis.userService.documents();\r\n\r\n\t\t\tif (this.userService.isLoaded()) {\r\n\t\t\t\tuntracked(() => void this.setDocuments());\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\tprotected override allowUrl(): boolean {\r\n\t\treturn false;\r\n\t}\r\n\r\n\t/** Bulk edit would post every row through the self-update route, so only bulk create stays. */\r\n\tprotected withoutBulkEdit(config: TableConfig<User>): TableConfig<User> {\r\n\t\treturn {\r\n\t\t\t...config,\r\n\t\t\theaderButtons: (config.headerButtons || []).filter((button) => button.class !== 'edit'),\r\n\t\t};\r\n\t}\r\n\r\n\tprotected override create(): void {\r\n\t\tif (this._createForm.formId) {\r\n\t\t\tthis._userFormService.reset(this._createForm.formId, this.createObject());\r\n\t\t}\r\n\r\n\t\tsuper.create();\r\n\t}\r\n\r\n\tprotected override update(doc: User): void {\r\n\t\tthis._userFormService.reset(\r\n\t\t\tthis._editForm.formId as string,\r\n\t\t\tdoc as unknown as Record<string, unknown>,\r\n\t\t);\r\n\r\n\t\tthis._userFormService.modal(\r\n\t\t\tthis._editForm,\r\n\t\t\t{\r\n\t\t\t\tlabel: 'Update',\r\n\t\t\t\tclick: (updated: unknown, close: () => void) => {\r\n\t\t\t\t\tclose();\r\n\r\n\t\t\t\t\tconst { email: _email, ...changes } = updated as User;\r\n\r\n\t\t\t\t\t// Send a copy; mutating the row would also change the cached document on failure.\r\n\t\t\t\t\tconst next: User = { ...doc, ...changes };\r\n\r\n\t\t\t\t\tthis.userService.updateAdmin(next).subscribe({\r\n\t\t\t\t\t\tnext: () => {\r\n\t\t\t\t\t\t\tvoid this.setDocuments();\r\n\t\t\t\t\t\t},\r\n\t\t\t\t\t\terror: () => {\r\n\t\t\t\t\t\t\tvoid this.setDocuments();\r\n\t\t\t\t\t\t},\r\n\t\t\t\t\t});\r\n\t\t\t\t},\r\n\t\t\t},\r\n\t\t\tdoc,\r\n\t\t);\r\n\t}\r\n\r\n\tprotected override async delete(doc: User): Promise<void> {\r\n\t\tthis._userAlertService.question({\r\n\t\t\ttext: 'Delete this user?',\r\n\t\t\ttimeout: 0,\r\n\t\t\tprogress: false,\r\n\t\t\tbuttons: [\r\n\t\t\t\t{\r\n\t\t\t\t\ttext: 'Delete',\r\n\t\t\t\t\tcallback: () => {\r\n\t\t\t\t\t\tthis.userService.deleteAdmin(doc).subscribe(() => {\r\n\t\t\t\t\t\t\tvoid this.setDocuments();\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t},\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\ttext: 'Cancel',\r\n\t\t\t\t},\r\n\t\t\t],\r\n\t\t});\r\n\t}\r\n}\r\n"],"mappings":";;;;;;;;;;AAEA,MAAa,WAAiB;CAC7B,KAAK;CACL,MAAM,CAAA;CACN,IAAI,CAAA;CACJ,OAAO,CAAA;CACP,MAAM;CACN,OAAO;CACP,KAAK;CACL,OAAO;CACP,OAAO;AACP;ACRD,MAAa,4BACZ,WAAqC,CAAA,OAChC;CACL,QAAQ;CACR,OAAO;CACP,YAAY;EACX;GACC,MAAM;GACN,KAAK;GACL,SAAS;GACT,OAAO;IACN,aAAa;IACb,OAAO;GACP;EACD;EACD;GACC,MAAM;GACN,KAAK;GACL,OAAO;IACN,aAAa;IACb,OAAO;IACP,MAAM;GACN;EACD;EACD;GACC,MAAM;GACN,KAAK;GACL,OAAO;IACN,aAAa;IACb,OAAO;GACP;EACD;EACD;GACC,MAAM;GACN,KAAK;GACL,OAAO;IACN,aAAa;IACb,OAAO;IACP,MAAM;GACN;EACD;EACD,GAAG;CACH;AACD;AAED,MAAa,kCAAiC;CAC7C,MAAM,SAAS,OAAO,cAAc;CAEpC,OAAO,yBAAyB,OAAO,QAAQ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