@wawjs/ngx-bos 22.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/AGENTS.md +23 -0
- package/README.md +105 -0
- package/RELEASES.md +21 -0
- package/ai/architecture.md +40 -0
- package/ai/code-style.md +33 -0
- package/ai/decisions/2026-06-02-browser-only-bos-spa.md +16 -0
- package/ai/decisions/2026-06-02-package-boundary.md +22 -0
- package/ai/decisions/2026-06-02-version-start.md +12 -0
- package/ai/decisions/index.md +7 -0
- package/ai/onboarding.md +19 -0
- package/ai/task-execution.md +35 -0
- package/ai/tooling.md +33 -0
- package/fesm2022/wawjs-ngx-bos.mjs +2287 -0
- package/fesm2022/wawjs-ngx-bos.mjs.map +1 -0
- package/package.json +38 -0
- package/src/feature/file/file.component.html +123 -0
- package/src/feature/file/file.component.scss +209 -0
- package/src/feature/file/file.component.ts +220 -0
- package/src/feature/file/file.const.ts +20 -0
- package/src/feature/file/file.interface.ts +12 -0
- package/src/feature/file/file.service.ts +34 -0
- package/src/feature/file/file.util.ts +72 -0
- package/src/feature/file/index.ts +9 -0
- package/src/feature/file/pages/files/files.component.html +12 -0
- package/src/feature/file/pages/files/files.component.ts +117 -0
- package/src/feature/file/pages/files/files.routes.ts +9 -0
- package/src/feature/file/selectors/file/file-selector.component.html +11 -0
- package/src/feature/file/selectors/file/file-selector.component.ts +27 -0
- package/src/feature/user/LICENSE +21 -0
- package/src/feature/user/README.md +1 -0
- package/src/feature/user/components/user-preview/user-preview.component.html +7 -0
- package/src/feature/user/components/user-preview/user-preview.component.scss +27 -0
- package/src/feature/user/components/user-preview/user-preview.component.ts +16 -0
- package/src/feature/user/guards/admins.guard.ts +22 -0
- package/src/feature/user/guards/authenticated.guard.ts +14 -0
- package/src/feature/user/guards/guest.guard.ts +14 -0
- package/src/feature/user/module.json +1 -0
- package/src/feature/user/pages/clients/clients.component.html +8 -0
- package/src/feature/user/pages/clients/clients.component.scss +0 -0
- package/src/feature/user/pages/clients/clients.component.ts +45 -0
- package/src/feature/user/pages/clients/clients.routes.ts +9 -0
- package/src/feature/user/pages/users/users.component.html +18 -0
- package/src/feature/user/pages/users/users.component.ts +57 -0
- package/src/feature/user/pages/users/users.routes.ts +9 -0
- package/src/feature/user/selectors/user/user-selector.component.html +6 -0
- package/src/feature/user/selectors/user/user-selector.component.scss +0 -0
- package/src/feature/user/selectors/user/user-selector.component.ts +17 -0
- package/src/feature/user/user.const.ts +13 -0
- package/src/feature/user/user.form.ts +54 -0
- package/src/feature/user/user.interface.ts +12 -0
- package/src/feature/user/user.service.ts +176 -0
- package/src/form-components/ace/ace.component.html +14 -0
- package/src/form-components/ace/ace.component.scss +22 -0
- package/src/form-components/ace/ace.component.ts +210 -0
- package/src/form-components/ace/ace.form.ts +184 -0
- package/src/form-components/button/button.component.html +15 -0
- package/src/form-components/button/button.component.ts +31 -0
- package/src/form-components/button/button.form.ts +74 -0
- package/src/form-components/file/file.component.html +73 -0
- package/src/form-components/file/file.component.ts +91 -0
- package/src/form-components/file/file.form.ts +112 -0
- package/src/form-components/form-bridge.interface.ts +27 -0
- package/src/form-components/index.ts +85 -0
- package/src/form-components/input/input.component.html +16 -0
- package/src/form-components/input/input.component.ts +31 -0
- package/src/form-components/input/input.form.ts +117 -0
- package/src/form-components/select/select.component.html +24 -0
- package/src/form-components/select/select.component.ts +31 -0
- package/src/form-components/select/select.form.ts +88 -0
- package/src/form-components/tinymce/tinymce.component.html +13 -0
- package/src/form-components/tinymce/tinymce.component.scss +19 -0
- package/src/form-components/tinymce/tinymce.component.ts +221 -0
- package/src/form-components/tinymce/tinymce.form.ts +191 -0
- package/src/icons/spider/LICENSE +21 -0
- package/src/icons/spider/README.md +127 -0
- package/src/icons/spider/index.ts +1 -0
- package/src/icons/spider/module.json +4 -0
- package/src/icons/spider/spider.component.html +115 -0
- package/src/icons/spider/spider.component.scss +20 -0
- package/src/icons/spider/spider.component.ts +20 -0
- package/src/ngx-bos.config.ts +55 -0
- package/src/pages/form/form.component.html +9 -0
- package/src/pages/form/form.component.ts +86 -0
- package/src/pages/form/form.routes.ts +9 -0
- package/src/pages/forms/forms.component.html +9 -0
- package/src/pages/forms/forms.component.ts +77 -0
- package/src/pages/forms/forms.routes.ts +9 -0
- package/src/pipes/phone.pipe.ts +17 -0
- package/src/public-api.ts +36 -0
- package/types/wawjs-ngx-bos.d.ts +332 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Component,
|
|
3
|
+
inject,
|
|
4
|
+
input,
|
|
5
|
+
output,
|
|
6
|
+
Signal,
|
|
7
|
+
signal,
|
|
8
|
+
} from '@angular/core';
|
|
9
|
+
import { SelectComponent } from '@wawjs/ngx-ui';
|
|
10
|
+
import { TranslateService } from '@wawjs/ngx-translate';
|
|
11
|
+
import { File, FileService } from '../..';
|
|
12
|
+
|
|
13
|
+
@Component({
|
|
14
|
+
selector: 'file-selector',
|
|
15
|
+
imports: [SelectComponent],
|
|
16
|
+
templateUrl: './file-selector.component.html',
|
|
17
|
+
})
|
|
18
|
+
export class FileSelectorComponent {
|
|
19
|
+
private _files = inject(FileService);
|
|
20
|
+
private _translate = inject(TranslateService);
|
|
21
|
+
readonly wModel = input<string | null>(null, { alias: 'wModel' });
|
|
22
|
+
readonly wChange = output<string | null>();
|
|
23
|
+
|
|
24
|
+
readonly items: Signal<File[]> = signal(this._files.documents());
|
|
25
|
+
|
|
26
|
+
readonly placeholder = this._translate.translate('Select file...');
|
|
27
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Web Art Work
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# ngx-user
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
.space {
|
|
2
|
+
&__header {
|
|
3
|
+
&-avatar {
|
|
4
|
+
margin-inline-start: var(--sp-3);
|
|
5
|
+
inline-size: 32px;
|
|
6
|
+
block-size: 32px;
|
|
7
|
+
border-radius: 999px;
|
|
8
|
+
overflow: hidden;
|
|
9
|
+
display: inline-flex;
|
|
10
|
+
cursor: pointer;
|
|
11
|
+
text-decoration: none;
|
|
12
|
+
|
|
13
|
+
&:focus-visible {
|
|
14
|
+
outline: none;
|
|
15
|
+
box-shadow: var(--focus-ring);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
img {
|
|
19
|
+
inline-size: 100%;
|
|
20
|
+
block-size: 100%;
|
|
21
|
+
object-fit: cover;
|
|
22
|
+
border-radius: inherit;
|
|
23
|
+
display: block;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Component, inject } from '@angular/core';
|
|
2
|
+
import { RouterLink } from '@angular/router';
|
|
3
|
+
import { NGX_BOS_CONFIG } from '../../../../ngx-bos.config';
|
|
4
|
+
import { UserService } from '../../user.service';
|
|
5
|
+
|
|
6
|
+
@Component({
|
|
7
|
+
selector: 'user-preview',
|
|
8
|
+
imports: [RouterLink],
|
|
9
|
+
templateUrl: './user-preview.component.html',
|
|
10
|
+
styleUrl: './user-preview.component.scss',
|
|
11
|
+
})
|
|
12
|
+
export class UserPreviewComponent {
|
|
13
|
+
userService = inject(UserService);
|
|
14
|
+
|
|
15
|
+
protected readonly bosConfig = inject(NGX_BOS_CONFIG);
|
|
16
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { inject } from '@angular/core';
|
|
2
|
+
import { CanActivateFn, Router } from '@angular/router';
|
|
3
|
+
import { NGX_BOS_CONFIG } from '../../../ngx-bos.config';
|
|
4
|
+
|
|
5
|
+
export const adminsGuard: CanActivateFn = () => {
|
|
6
|
+
const router = inject(Router);
|
|
7
|
+
const config = inject(NGX_BOS_CONFIG);
|
|
8
|
+
|
|
9
|
+
const stored = localStorage.getItem('waw_user');
|
|
10
|
+
|
|
11
|
+
if (!stored) {
|
|
12
|
+
return router.parseUrl(config.signPath);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const user = JSON.parse(stored);
|
|
16
|
+
|
|
17
|
+
if (user.is && user.is.admin) {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return router.parseUrl(config.profilePath);
|
|
22
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { inject } from '@angular/core';
|
|
2
|
+
import { CanActivateFn, Router } from '@angular/router';
|
|
3
|
+
import { NGX_BOS_CONFIG } from '../../../ngx-bos.config';
|
|
4
|
+
|
|
5
|
+
export const authenticatedGuard: CanActivateFn = () => {
|
|
6
|
+
const router = inject(Router);
|
|
7
|
+
const config = inject(NGX_BOS_CONFIG);
|
|
8
|
+
|
|
9
|
+
if (localStorage.getItem('waw_user')) {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return router.parseUrl(config.signPath);
|
|
14
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { inject } from '@angular/core';
|
|
2
|
+
import { CanActivateFn, Router } from '@angular/router';
|
|
3
|
+
import { NGX_BOS_CONFIG } from '../../../ngx-bos.config';
|
|
4
|
+
|
|
5
|
+
export const guestGuard: CanActivateFn = () => {
|
|
6
|
+
const router = inject(Router);
|
|
7
|
+
const config = inject(NGX_BOS_CONFIG);
|
|
8
|
+
|
|
9
|
+
if (localStorage.getItem('waw_user')) {
|
|
10
|
+
return router.parseUrl(config.profilePath);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return true;
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "repo": "https://github.com/WebArtWork/ngx-user.git" }
|
|
File without changes
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Component, inject } from '@angular/core';
|
|
2
|
+
import { FormInterface, FormService } from '@wawjs/ngx-form';
|
|
3
|
+
import { TableComponent } from '@wawjs/ngx-ui';
|
|
4
|
+
import { CrudComponent } from '@wawjs/ngx-crud';
|
|
5
|
+
import { userFormComponentsFactory } from '../../user.form';
|
|
6
|
+
import { User } from '../../user.interface';
|
|
7
|
+
import { UserService } from '../../user.service';
|
|
8
|
+
|
|
9
|
+
@Component({
|
|
10
|
+
imports: [TableComponent],
|
|
11
|
+
templateUrl: './clients.component.html',
|
|
12
|
+
styleUrl: './clients.component.scss',
|
|
13
|
+
})
|
|
14
|
+
export class ClientsComponent extends CrudComponent<
|
|
15
|
+
UserService,
|
|
16
|
+
User,
|
|
17
|
+
FormInterface
|
|
18
|
+
> {
|
|
19
|
+
/** Use server-side pagination for clients */
|
|
20
|
+
protected override configType: 'server' | 'local' = 'server';
|
|
21
|
+
|
|
22
|
+
/** Basic columns for clients table */
|
|
23
|
+
columns = ['name', 'email'];
|
|
24
|
+
|
|
25
|
+
/** wtable config built by CrudComponent, aware of server mode */
|
|
26
|
+
config = this.getConfig();
|
|
27
|
+
|
|
28
|
+
protected override allowUrl(): boolean {
|
|
29
|
+
// no URL-driven filters for now, same as UsersComponent
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
constructor() {
|
|
34
|
+
// 'user' docType reuses existing user form components
|
|
35
|
+
super(
|
|
36
|
+
userFormComponentsFactory(),
|
|
37
|
+
inject(FormService),
|
|
38
|
+
inject(UserService),
|
|
39
|
+
'user',
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
// fetch first page from server using CrudComponent logic
|
|
43
|
+
this.setDocuments();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<!--==== Table Module ====-->
|
|
2
|
+
<wtable
|
|
3
|
+
[rows]="documents()"
|
|
4
|
+
[columns]="columns"
|
|
5
|
+
[config]="config"
|
|
6
|
+
title="Users"
|
|
7
|
+
>
|
|
8
|
+
@for (role of roles; track role) {
|
|
9
|
+
<ng-template [cell]="role" let-user>
|
|
10
|
+
<winput
|
|
11
|
+
(wChange)="user.is[role] = $event; update(user)"
|
|
12
|
+
[wModel]="user.is[role]"
|
|
13
|
+
type="checkbox"
|
|
14
|
+
/>
|
|
15
|
+
</ng-template>
|
|
16
|
+
}
|
|
17
|
+
</wtable>
|
|
18
|
+
<!-- ==================== -->
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Component, inject } from '@angular/core';
|
|
2
|
+
import { Router } from '@angular/router';
|
|
3
|
+
import { FormInterface, FormService } from '@wawjs/ngx-form';
|
|
4
|
+
import { CrudComponent } from '@wawjs/ngx-crud';
|
|
5
|
+
import { CellDirective, InputComponent, TableComponent } from '@wawjs/ngx-ui';
|
|
6
|
+
import { userFormComponentsFactory } from '../../user.form';
|
|
7
|
+
import { User } from '../../user.interface';
|
|
8
|
+
import { UserService } from '../../user.service';
|
|
9
|
+
|
|
10
|
+
@Component({
|
|
11
|
+
imports: [TableComponent, CellDirective, InputComponent],
|
|
12
|
+
templateUrl: './users.component.html',
|
|
13
|
+
})
|
|
14
|
+
export class UsersComponent extends CrudComponent<
|
|
15
|
+
UserService,
|
|
16
|
+
User,
|
|
17
|
+
FormInterface
|
|
18
|
+
> {
|
|
19
|
+
protected override configType: 'server' | 'local' = 'local';
|
|
20
|
+
|
|
21
|
+
protected override allowUrl(): boolean {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
protected override async delete(doc: User) {
|
|
26
|
+
this.userService.deleteAdmin(doc).subscribe(() => {
|
|
27
|
+
this.setDocuments();
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
private _router = inject(Router);
|
|
32
|
+
|
|
33
|
+
userService = inject(UserService);
|
|
34
|
+
|
|
35
|
+
readonly roles = this._router.url.includes('admin')
|
|
36
|
+
? this.userService.roles
|
|
37
|
+
: this.userService.employees;
|
|
38
|
+
|
|
39
|
+
columns = ['name', 'email'];
|
|
40
|
+
|
|
41
|
+
config = this.getConfig();
|
|
42
|
+
|
|
43
|
+
constructor() {
|
|
44
|
+
super(
|
|
45
|
+
userFormComponentsFactory(),
|
|
46
|
+
inject(FormService),
|
|
47
|
+
inject(UserService),
|
|
48
|
+
'user',
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
this.setDocuments();
|
|
52
|
+
|
|
53
|
+
for (const role of this.userService.roles) {
|
|
54
|
+
this.columns.push(role);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Component, inject, input, output } from '@angular/core';
|
|
2
|
+
import { SelectComponent, SelectValue } from '@wawjs/ngx-ui';
|
|
3
|
+
import { UserService } from '../../user.service';
|
|
4
|
+
|
|
5
|
+
@Component({
|
|
6
|
+
imports: [SelectComponent],
|
|
7
|
+
selector: 'user-selector',
|
|
8
|
+
templateUrl: './user-selector.component.html',
|
|
9
|
+
styleUrl: './user-selector.component.scss',
|
|
10
|
+
})
|
|
11
|
+
export class UserSelectorComponent {
|
|
12
|
+
userService = inject(UserService);
|
|
13
|
+
|
|
14
|
+
value = input('');
|
|
15
|
+
|
|
16
|
+
onChange = output<SelectValue>();
|
|
17
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { inject } from '@angular/core';
|
|
2
|
+
import { FormComponentInterface } from '@wawjs/ngx-form';
|
|
3
|
+
import { NGX_BOS_CONFIG } from '../../ngx-bos.config';
|
|
4
|
+
|
|
5
|
+
export const createUserFormComponents = (
|
|
6
|
+
userForm: FormComponentInterface[] = [],
|
|
7
|
+
) => ({
|
|
8
|
+
formId: 'user',
|
|
9
|
+
title: 'Profile Settings',
|
|
10
|
+
components: [
|
|
11
|
+
{
|
|
12
|
+
name: 'Input',
|
|
13
|
+
key: 'name',
|
|
14
|
+
focused: true,
|
|
15
|
+
props: {
|
|
16
|
+
placeholder: 'Enter name...',
|
|
17
|
+
label: 'Name',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: 'Input',
|
|
22
|
+
key: 'email',
|
|
23
|
+
props: {
|
|
24
|
+
placeholder: 'Enter email...',
|
|
25
|
+
label: 'Email',
|
|
26
|
+
type: 'email',
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: 'Input',
|
|
31
|
+
key: 'phone',
|
|
32
|
+
props: {
|
|
33
|
+
placeholder: 'Enter phone...',
|
|
34
|
+
label: 'Phone',
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: 'Input',
|
|
39
|
+
key: 'bio',
|
|
40
|
+
props: {
|
|
41
|
+
placeholder: 'Enter bio...',
|
|
42
|
+
label: 'Biography',
|
|
43
|
+
type: 'textarea',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
...userForm,
|
|
47
|
+
],
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
export const userFormComponentsFactory = () => {
|
|
51
|
+
const config = inject(NGX_BOS_CONFIG);
|
|
52
|
+
|
|
53
|
+
return createUserFormComponents(config.userForm);
|
|
54
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CrudDocument } from '@wawjs/ngx-crud';
|
|
2
|
+
|
|
3
|
+
export interface User extends CrudDocument<User> {
|
|
4
|
+
data: Record<string, unknown>;
|
|
5
|
+
is: Record<string, boolean>;
|
|
6
|
+
roles: string[];
|
|
7
|
+
name: string;
|
|
8
|
+
phone: string;
|
|
9
|
+
bio: string;
|
|
10
|
+
email: string;
|
|
11
|
+
thumb: string;
|
|
12
|
+
}
|
|
@@ -0,0 +1,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
|
+
users = signal<User[]>(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
|
+
: this.url + thumb;
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
role(role: string): boolean {
|
|
44
|
+
return !!(this.user().is || {})[role];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
readonly usersByRole = computed<Record<string, User[]>>(() => {
|
|
48
|
+
const splitted: Record<string, User[]> = {};
|
|
49
|
+
|
|
50
|
+
for (const user of this.documents()) {
|
|
51
|
+
for (const role of user.roles || []) {
|
|
52
|
+
if (role === undefined || role === null) continue;
|
|
53
|
+
(splitted[String(role)] ??= []).push(user);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return splitted;
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
constructor() {
|
|
61
|
+
super({
|
|
62
|
+
name: 'user',
|
|
63
|
+
replace: (user) => {
|
|
64
|
+
user.roles = [];
|
|
65
|
+
user.data = user.data || {};
|
|
66
|
+
user.is = user.is || {};
|
|
67
|
+
|
|
68
|
+
for (const field of this._bosConfig.userFields) {
|
|
69
|
+
user.data[field] = user.data[field] || {};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
for (const role of this.roles) {
|
|
73
|
+
if (user.is[role]) {
|
|
74
|
+
user.roles.push(role);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return user;
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
if (localStorage.getItem('waw_user')) {
|
|
83
|
+
this.fetch({}, { name: 'me' }).subscribe((user: User) => {
|
|
84
|
+
if (user) {
|
|
85
|
+
if (
|
|
86
|
+
!localStorage.getItem('waw_user') &&
|
|
87
|
+
this._router.url === this._bosConfig.signPath
|
|
88
|
+
) {
|
|
89
|
+
this._router.navigateByUrl(this._bosConfig.profilePath);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
this.setUser(user);
|
|
93
|
+
} else if (localStorage.getItem('waw_user')) {
|
|
94
|
+
this.logout();
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
this.get({
|
|
99
|
+
query: this._bosConfig.appId ? 'appId=' + this._bosConfig.appId : '',
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
setUser(user: User) {
|
|
105
|
+
this.user.set(user);
|
|
106
|
+
|
|
107
|
+
localStorage.setItem('waw_user', JSON.stringify(user));
|
|
108
|
+
|
|
109
|
+
this._emitterService.complete('us.user');
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
updateMe() {
|
|
113
|
+
this.setUser(this.user());
|
|
114
|
+
|
|
115
|
+
return this.update(this.user()).subscribe(() => {
|
|
116
|
+
this._alertService.info({
|
|
117
|
+
text: 'Profile information has been updated',
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
updateMeAfterWhile() {
|
|
123
|
+
this.setUser(this.user());
|
|
124
|
+
|
|
125
|
+
this.updateAfterWhile(this.user());
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
changePassword(oldPass: string, newPass: string) {
|
|
129
|
+
return this._userHttpService.post(
|
|
130
|
+
'/api/user/changePassword',
|
|
131
|
+
{
|
|
132
|
+
newPass: newPass,
|
|
133
|
+
oldPass: oldPass,
|
|
134
|
+
},
|
|
135
|
+
(resp: boolean) => {
|
|
136
|
+
if (resp) {
|
|
137
|
+
this._alertService.info({
|
|
138
|
+
text: 'Successfully changed password',
|
|
139
|
+
});
|
|
140
|
+
} else {
|
|
141
|
+
this._alertService.error({
|
|
142
|
+
text: 'Incorrect current password',
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
logout() {
|
|
150
|
+
this.user.set(this.prepareDocument()());
|
|
151
|
+
|
|
152
|
+
localStorage.removeItem('waw_user');
|
|
153
|
+
|
|
154
|
+
this._userHttpService.remove('token');
|
|
155
|
+
|
|
156
|
+
this._userHttpService.get('/api/user/logout');
|
|
157
|
+
|
|
158
|
+
this._router.navigateByUrl(this._bosConfig.signPath);
|
|
159
|
+
|
|
160
|
+
setTimeout(() => {
|
|
161
|
+
location.reload();
|
|
162
|
+
}, 100);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
updateAdmin(user: User) {
|
|
166
|
+
return this.update(user, {
|
|
167
|
+
name: 'admin',
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
deleteAdmin(user: User) {
|
|
172
|
+
return this.delete(user, {
|
|
173
|
+
name: 'admin',
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<ng-template #templateRef let-data>
|
|
2
|
+
<div class="w-ace" [class]="data.component?.class">
|
|
3
|
+
<ace
|
|
4
|
+
class="w-ace__editor"
|
|
5
|
+
(valueChange)="onValueChange(data, $event)"
|
|
6
|
+
[value]="getValue(data)"
|
|
7
|
+
[config]="getConfig(data)"
|
|
8
|
+
[mode]="$any(getMode(data))"
|
|
9
|
+
[theme]="$any(getTheme(data))"
|
|
10
|
+
[disabled]="isDisabled(data)"
|
|
11
|
+
[useAceClass]="getUseAceClass(data)"
|
|
12
|
+
></ace>
|
|
13
|
+
</div>
|
|
14
|
+
</ng-template>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
.w-ace {
|
|
2
|
+
width: 100%;
|
|
3
|
+
background: var(--c-bg-secondary);
|
|
4
|
+
color: var(--c-text-primary);
|
|
5
|
+
border: 1px solid var(--c-border);
|
|
6
|
+
border-radius: var(--radius-card);
|
|
7
|
+
box-shadow: var(--shadow-sm);
|
|
8
|
+
overflow: hidden;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/*
|
|
12
|
+
* Editor height:
|
|
13
|
+
* - at least 240px so it’s usable,
|
|
14
|
+
* - ideally ~60% of viewport height,
|
|
15
|
+
* - capped at 720px so it doesn’t explode on huge screens.
|
|
16
|
+
* Works nicely inside a modal of ~80–90vh (leaves room for header/footer/buttons).
|
|
17
|
+
*/
|
|
18
|
+
.w-ace__editor {
|
|
19
|
+
display: block;
|
|
20
|
+
width: 100%;
|
|
21
|
+
height: clamp(240px, 60vh, 720px);
|
|
22
|
+
}
|