@wawjs/ngx-bos 22.0.0 → 22.0.2
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/AGENTS.md +23 -23
- package/README.md +105 -105
- package/RELEASES.md +41 -15
- package/ai/architecture.md +40 -40
- package/ai/code-style.md +33 -33
- package/ai/decisions/2026-06-02-browser-only-bos-spa.md +16 -16
- package/ai/decisions/2026-06-02-package-boundary.md +22 -22
- package/ai/decisions/2026-06-02-version-start.md +12 -12
- package/ai/decisions/index.md +7 -7
- package/ai/onboarding.md +19 -19
- package/ai/task-execution.md +35 -35
- package/ai/tooling.md +33 -33
- package/fesm2022/wawjs-ngx-bos.mjs +138 -98
- package/fesm2022/wawjs-ngx-bos.mjs.map +1 -1
- package/package.json +1 -1
- package/src/feature/file/file.component.html +1 -1
- package/src/feature/file/file.component.ts +236 -220
- package/src/feature/file/file.interface.ts +12 -12
- package/src/feature/file/file.service.ts +35 -34
- package/src/feature/file/pages/files/files.component.html +2 -2
- package/src/feature/file/pages/files/files.component.ts +117 -117
- package/src/feature/file/pages/files/files.routes.ts +9 -9
- package/src/feature/file/selectors/file/file-selector.component.html +2 -5
- package/src/feature/file/selectors/file/file-selector.component.ts +24 -27
- package/src/feature/user/guards/admins.guard.ts +22 -22
- package/src/feature/user/guards/authenticated.guard.ts +14 -14
- package/src/feature/user/guards/guest.guard.ts +14 -14
- package/src/feature/user/pages/clients/clients.component.ts +45 -45
- package/src/feature/user/pages/clients/clients.routes.ts +1 -1
- package/src/feature/user/pages/users/users.component.html +3 -2
- package/src/feature/user/pages/users/users.component.scss +12 -0
- package/src/feature/user/pages/users/users.component.ts +78 -45
- package/src/feature/user/pages/users/users.routes.ts +1 -1
- package/src/feature/user/selectors/user/user-selector.component.ts +17 -17
- package/src/feature/user/user.const.ts +3 -3
- package/src/feature/user/user.form.ts +54 -54
- package/src/feature/user/user.interface.ts +12 -12
- package/src/feature/user/user.service.ts +178 -176
- package/src/form-components/ace/ace.component.ts +210 -210
- package/src/form-components/button/button.component.ts +31 -31
- package/src/form-components/file/file.component.ts +91 -91
- package/src/form-components/form-bridge.interface.ts +27 -27
- package/src/form-components/index.ts +85 -85
- package/src/form-components/input/input.component.html +1 -0
- package/src/form-components/input/input.component.ts +31 -31
- package/src/form-components/select/select.component.html +2 -2
- package/src/form-components/select/select.component.ts +31 -31
- package/src/form-components/tinymce/tinymce.component.ts +221 -221
- package/src/ngx-bos.config.ts +55 -55
- package/src/pages/form/form.component.ts +86 -86
- package/src/pages/form/form.routes.ts +1 -1
- package/src/pages/forms/forms.component.ts +15 -15
- package/src/pages/forms/forms.routes.ts +1 -1
- package/src/pipes/phone.pipe.ts +17 -17
- package/src/public-api.ts +36 -36
- package/types/wawjs-ngx-bos.d.ts +13 -9
|
@@ -1,176 +1,178 @@
|
|
|
1
|
-
import { Service, computed, inject, signal } from '@angular/core';
|
|
2
|
-
import { Router } from '@angular/router';
|
|
3
|
-
import { AlertService } from '@wawjs/ngx-ui';
|
|
4
|
-
import { CrudService } from '@wawjs/ngx-crud';
|
|
5
|
-
import { EmitterService } from '@wawjs/ngx-core';
|
|
6
|
-
import { HttpService } from '@wawjs/ngx-http';
|
|
7
|
-
import { NGX_BOS_CONFIG } from '../../ngx-bos.config';
|
|
8
|
-
import { User } from './user.interface';
|
|
9
|
-
@Service()
|
|
10
|
-
export class UserService extends CrudService<User> {
|
|
11
|
-
private readonly _userHttpService = inject(HttpService);
|
|
12
|
-
|
|
13
|
-
private readonly _alertService = inject(AlertService);
|
|
14
|
-
|
|
15
|
-
private readonly _router = inject(Router);
|
|
16
|
-
|
|
17
|
-
private readonly _emitterService = inject(EmitterService);
|
|
18
|
-
|
|
19
|
-
private readonly _bosConfig = inject(NGX_BOS_CONFIG);
|
|
20
|
-
|
|
21
|
-
readonly url = this._bosConfig.url;
|
|
22
|
-
|
|
23
|
-
roles = this._bosConfig.roles.concat(['admin']);
|
|
24
|
-
|
|
25
|
-
employees = this._bosConfig.roles;
|
|
26
|
-
|
|
27
|
-
users =
|
|
28
|
-
|
|
29
|
-
user = signal<User>(
|
|
30
|
-
localStorage.getItem('waw_user')
|
|
31
|
-
? JSON.parse(localStorage.getItem('waw_user') as string)
|
|
32
|
-
: this.prepareDocument()(),
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
thumb = computed(() => {
|
|
36
|
-
const thumb = this.user().thumb;
|
|
37
|
-
|
|
38
|
-
return !thumb || thumb.includes(this._bosConfig.defaultUserThumb)
|
|
39
|
-
? this._bosConfig.defaultUserThumb
|
|
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
|
-
user.
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
this._router.
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
this.
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
this.
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
this._userHttpService.
|
|
157
|
-
|
|
158
|
-
this.
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
1
|
+
import { Service, computed, inject, signal } from '@angular/core';
|
|
2
|
+
import { Router } from '@angular/router';
|
|
3
|
+
import { AlertService } from '@wawjs/ngx-ui';
|
|
4
|
+
import { CrudService } from '@wawjs/ngx-crud';
|
|
5
|
+
import { EmitterService } from '@wawjs/ngx-core';
|
|
6
|
+
import { HttpService } from '@wawjs/ngx-http';
|
|
7
|
+
import { NGX_BOS_CONFIG } from '../../ngx-bos.config';
|
|
8
|
+
import { User } from './user.interface';
|
|
9
|
+
@Service()
|
|
10
|
+
export class UserService extends CrudService<User> {
|
|
11
|
+
private readonly _userHttpService = inject(HttpService);
|
|
12
|
+
|
|
13
|
+
private readonly _alertService = inject(AlertService);
|
|
14
|
+
|
|
15
|
+
private readonly _router = inject(Router);
|
|
16
|
+
|
|
17
|
+
private readonly _emitterService = inject(EmitterService);
|
|
18
|
+
|
|
19
|
+
private readonly _bosConfig = inject(NGX_BOS_CONFIG);
|
|
20
|
+
|
|
21
|
+
readonly url = this._bosConfig.url;
|
|
22
|
+
|
|
23
|
+
roles = this._bosConfig.roles.concat(['admin']);
|
|
24
|
+
|
|
25
|
+
employees = this._bosConfig.roles;
|
|
26
|
+
|
|
27
|
+
readonly users = this.documents;
|
|
28
|
+
|
|
29
|
+
user = signal<User>(
|
|
30
|
+
localStorage.getItem('waw_user')
|
|
31
|
+
? JSON.parse(localStorage.getItem('waw_user') as string)
|
|
32
|
+
: this.prepareDocument()(),
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
thumb = computed(() => {
|
|
36
|
+
const thumb = this.user().thumb;
|
|
37
|
+
|
|
38
|
+
return !thumb || thumb.includes(this._bosConfig.defaultUserThumb)
|
|
39
|
+
? this._bosConfig.defaultUserThumb
|
|
40
|
+
: /^https?:\/\//i.test(thumb)
|
|
41
|
+
? thumb
|
|
42
|
+
: this.url + thumb;
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
role(role: string): boolean {
|
|
46
|
+
return !!(this.user().is || {})[role];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
readonly usersByRole = computed<Record<string, User[]>>(() => {
|
|
50
|
+
const splitted: Record<string, User[]> = {};
|
|
51
|
+
|
|
52
|
+
for (const user of this.documents()) {
|
|
53
|
+
for (const role of user.roles || []) {
|
|
54
|
+
if (role === undefined || role === null) continue;
|
|
55
|
+
(splitted[String(role)] ??= []).push(user);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return splitted;
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
constructor() {
|
|
63
|
+
super({
|
|
64
|
+
name: 'user',
|
|
65
|
+
replace: (user) => {
|
|
66
|
+
user.roles = [];
|
|
67
|
+
user.data = user.data || {};
|
|
68
|
+
user.is = user.is || {};
|
|
69
|
+
|
|
70
|
+
for (const field of this._bosConfig.userFields) {
|
|
71
|
+
user.data[field] = user.data[field] || {};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
for (const role of this.roles) {
|
|
75
|
+
if (user.is[role]) {
|
|
76
|
+
user.roles.push(role);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return user;
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
if (localStorage.getItem('waw_user')) {
|
|
85
|
+
this.fetch({}, { name: 'me' }).subscribe((user: User) => {
|
|
86
|
+
if (user) {
|
|
87
|
+
if (
|
|
88
|
+
!localStorage.getItem('waw_user') &&
|
|
89
|
+
this._router.url === this._bosConfig.signPath
|
|
90
|
+
) {
|
|
91
|
+
this._router.navigateByUrl(this._bosConfig.profilePath);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
this.setUser(user);
|
|
95
|
+
} else if (localStorage.getItem('waw_user')) {
|
|
96
|
+
this.logout();
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
this.get({
|
|
101
|
+
query: this._bosConfig.appId ? 'appId=' + this._bosConfig.appId : '',
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
setUser(user: User) {
|
|
107
|
+
this.user.set(user);
|
|
108
|
+
|
|
109
|
+
localStorage.setItem('waw_user', JSON.stringify(user));
|
|
110
|
+
|
|
111
|
+
this._emitterService.complete('us.user');
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
updateMe() {
|
|
115
|
+
this.setUser(this.user());
|
|
116
|
+
|
|
117
|
+
return this.update(this.user()).subscribe(() => {
|
|
118
|
+
this._alertService.info({
|
|
119
|
+
text: 'Profile information has been updated',
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
updateMeAfterWhile() {
|
|
125
|
+
this.setUser(this.user());
|
|
126
|
+
|
|
127
|
+
this.updateAfterWhile(this.user());
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
changePassword(oldPass: string, newPass: string) {
|
|
131
|
+
return this._userHttpService.post(
|
|
132
|
+
'/api/user/changePassword',
|
|
133
|
+
{
|
|
134
|
+
newPass: newPass,
|
|
135
|
+
oldPass: oldPass,
|
|
136
|
+
},
|
|
137
|
+
(resp: boolean) => {
|
|
138
|
+
if (resp) {
|
|
139
|
+
this._alertService.info({
|
|
140
|
+
text: 'Successfully changed password',
|
|
141
|
+
});
|
|
142
|
+
} else {
|
|
143
|
+
this._alertService.error({
|
|
144
|
+
text: 'Incorrect current password',
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
logout() {
|
|
152
|
+
this.user.set(this.prepareDocument()());
|
|
153
|
+
|
|
154
|
+
localStorage.removeItem('waw_user');
|
|
155
|
+
|
|
156
|
+
this._userHttpService.remove('token');
|
|
157
|
+
|
|
158
|
+
this._userHttpService.get('/api/user/logout');
|
|
159
|
+
|
|
160
|
+
this._router.navigateByUrl(this._bosConfig.signPath);
|
|
161
|
+
|
|
162
|
+
setTimeout(() => {
|
|
163
|
+
location.reload();
|
|
164
|
+
}, 100);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
updateAdmin(user: User) {
|
|
168
|
+
return this.update(user, {
|
|
169
|
+
name: 'admin',
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
deleteAdmin(user: User) {
|
|
174
|
+
return this.delete(user, {
|
|
175
|
+
name: 'admin',
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
}
|