@wawjs/ngx-bos 22.0.0 → 22.0.1
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 +19 -19
- 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 +2 -2
- package/fesm2022/wawjs-ngx-bos.mjs.map +1 -1
- package/package.json +1 -1
- package/src/feature/file/file.component.ts +220 -220
- package/src/feature/file/file.interface.ts +12 -12
- package/src/feature/file/file.service.ts +34 -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.ts +27 -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.ts +57 -57
- 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 +176 -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.ts +31 -31
- 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/package.json
CHANGED
|
@@ -1,220 +1,220 @@
|
|
|
1
|
-
import { NgTemplateOutlet } from '@angular/common';
|
|
2
|
-
import {
|
|
3
|
-
Component,
|
|
4
|
-
TemplateRef,
|
|
5
|
-
computed,
|
|
6
|
-
inject,
|
|
7
|
-
input,
|
|
8
|
-
model,
|
|
9
|
-
} from '@angular/core';
|
|
10
|
-
import { ButtonComponent, ModalService } from '@wawjs/ngx-ui';
|
|
11
|
-
import { fileToDataUrl } from './file.util';
|
|
12
|
-
import { TranslateDirective } from '@wawjs/ngx-translate';
|
|
13
|
-
import type { FabricCropResult } from '@wawjs/ngx-fabric';
|
|
14
|
-
import { fileDefaults } from './file.const';
|
|
15
|
-
import { FileService } from './file.service';
|
|
16
|
-
|
|
17
|
-
export type FileMode =
|
|
18
|
-
| 'single-image'
|
|
19
|
-
| 'single-file'
|
|
20
|
-
| 'multi-image'
|
|
21
|
-
| 'multi-file';
|
|
22
|
-
|
|
23
|
-
export type FileView = 'dropzone' | 'list' | 'thumb-only';
|
|
24
|
-
|
|
25
|
-
@Component({
|
|
26
|
-
selector: 'ngx-file',
|
|
27
|
-
imports: [NgTemplateOutlet, TranslateDirective, ButtonComponent],
|
|
28
|
-
templateUrl: './file.component.html',
|
|
29
|
-
styleUrl: './file.component.scss',
|
|
30
|
-
})
|
|
31
|
-
export class FileComponent {
|
|
32
|
-
/** UI props */
|
|
33
|
-
readonly label = input<string>(fileDefaults.label);
|
|
34
|
-
readonly placeholder = input<string>(fileDefaults.placeholder);
|
|
35
|
-
readonly disabled = input<boolean>(fileDefaults.disabled);
|
|
36
|
-
readonly clearable = input<boolean>(fileDefaults.clearable);
|
|
37
|
-
readonly accept = input<string>(fileDefaults.accept);
|
|
38
|
-
readonly preview = input<boolean>(fileDefaults.preview);
|
|
39
|
-
|
|
40
|
-
/** Behaviour */
|
|
41
|
-
readonly mode = input<FileMode>(fileDefaults.mode as FileMode);
|
|
42
|
-
readonly view = input<FileView>(fileDefaults.view as FileView);
|
|
43
|
-
|
|
44
|
-
/** Optional crop box (for image modes) */
|
|
45
|
-
readonly cropWidth = input<number | null>(fileDefaults.cropWidth);
|
|
46
|
-
readonly cropHeight = input<number | null>(fileDefaults.cropHeight);
|
|
47
|
-
|
|
48
|
-
/** Custom templates */
|
|
49
|
-
readonly t_item = input<TemplateRef<unknown>>();
|
|
50
|
-
readonly t_empty = input<TemplateRef<unknown>>();
|
|
51
|
-
|
|
52
|
-
/** Back-end routing */
|
|
53
|
-
readonly container = input<string>(fileDefaults.container);
|
|
54
|
-
readonly name = input<string>(fileDefaults.name);
|
|
55
|
-
|
|
56
|
-
/** Separate models for each mode */
|
|
57
|
-
readonly wImage = model<string | null>(null, { alias: 'wImage' });
|
|
58
|
-
readonly wFile = model<string | null>(null, { alias: 'wFile' });
|
|
59
|
-
readonly wImages = model<string[]>([], { alias: 'wImages' });
|
|
60
|
-
readonly wFiles = model<string[]>([], { alias: 'wFiles' });
|
|
61
|
-
|
|
62
|
-
private readonly _modal = inject(ModalService);
|
|
63
|
-
private readonly _fs = inject(FileService);
|
|
64
|
-
|
|
65
|
-
readonly isDisabled = computed(() => this.disabled());
|
|
66
|
-
readonly isMultiple = computed(() => this.mode().startsWith('multi-'));
|
|
67
|
-
readonly isImageMode = computed(() => this.mode().includes('image'));
|
|
68
|
-
|
|
69
|
-
/** Normalized list of URLs for rendering */
|
|
70
|
-
readonly files = computed<string[]>(() => {
|
|
71
|
-
const mode = this.mode();
|
|
72
|
-
switch (mode) {
|
|
73
|
-
case 'single-image':
|
|
74
|
-
return this.wImage() ? [this.wImage() as string] : [];
|
|
75
|
-
case 'single-file':
|
|
76
|
-
return this.wFile() ? [this.wFile() as string] : [];
|
|
77
|
-
case 'multi-image':
|
|
78
|
-
return this.wImages();
|
|
79
|
-
case 'multi-file':
|
|
80
|
-
return this.wFiles();
|
|
81
|
-
default:
|
|
82
|
-
return [];
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
triggerPick(input: HTMLInputElement): void {
|
|
87
|
-
if (!this.isDisabled()) {
|
|
88
|
-
input.click();
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
isImage(src: string): boolean {
|
|
93
|
-
return /\.(png|jpe?g|webp|gif)(\?|$)/i.test(src ?? '');
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
async onPicked(input: HTMLInputElement): Promise<void> {
|
|
97
|
-
const list = input.files;
|
|
98
|
-
if (!list || !list.length) return;
|
|
99
|
-
|
|
100
|
-
const doCrop =
|
|
101
|
-
this.isImageMode() && !!this.cropWidth() && !!this.cropHeight();
|
|
102
|
-
const urls: string[] = [];
|
|
103
|
-
const container = this.container();
|
|
104
|
-
const name = this.name();
|
|
105
|
-
|
|
106
|
-
for (let i = 0; i < list.length; i++) {
|
|
107
|
-
const f = list.item(i)!;
|
|
108
|
-
|
|
109
|
-
// Always read file as data URL
|
|
110
|
-
const dataUrl = await fileToDataUrl(f);
|
|
111
|
-
|
|
112
|
-
if (doCrop) {
|
|
113
|
-
// Lazy-load fabric crop modal only when actually cropping
|
|
114
|
-
const { FabricCropModalComponent } = await import(
|
|
115
|
-
'@wawjs/ngx-fabric'
|
|
116
|
-
);
|
|
117
|
-
await new Promise<void>((resolve) => {
|
|
118
|
-
this._modal.show({
|
|
119
|
-
component: FabricCropModalComponent,
|
|
120
|
-
size: 'big',
|
|
121
|
-
image: dataUrl,
|
|
122
|
-
width: this.cropWidth()!,
|
|
123
|
-
height: this.cropHeight()!,
|
|
124
|
-
aspectRatio: this.cropWidth()! / this.cropHeight()!,
|
|
125
|
-
outputWidth: this.cropWidth()!,
|
|
126
|
-
outputHeight: this.cropHeight()!,
|
|
127
|
-
onCrop: (result: FabricCropResult) => {
|
|
128
|
-
this._fs
|
|
129
|
-
.uploadBase64(result.base64, container, name)
|
|
130
|
-
.then((url) => {
|
|
131
|
-
urls.push(url);
|
|
132
|
-
resolve();
|
|
133
|
-
});
|
|
134
|
-
},
|
|
135
|
-
onCancel: () => resolve(),
|
|
136
|
-
});
|
|
137
|
-
});
|
|
138
|
-
} else {
|
|
139
|
-
const url = await this._fs.uploadBase64(
|
|
140
|
-
dataUrl,
|
|
141
|
-
container,
|
|
142
|
-
name,
|
|
143
|
-
);
|
|
144
|
-
urls.push(url);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// If single mode, ignore extra files after first
|
|
148
|
-
if (!this.isMultiple()) {
|
|
149
|
-
break;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
this._applyNewUrls(urls);
|
|
154
|
-
input.value = '';
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
removeAt(index: number): void {
|
|
158
|
-
const mode = this.mode();
|
|
159
|
-
|
|
160
|
-
if (mode === 'single-image') {
|
|
161
|
-
this.wImage.set(null);
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
if (mode === 'single-file') {
|
|
166
|
-
this.wFile.set(null);
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// Multi modes
|
|
171
|
-
const current = [...this.files()];
|
|
172
|
-
current.splice(index, 1);
|
|
173
|
-
|
|
174
|
-
if (mode === 'multi-image') {
|
|
175
|
-
this.wImages.set(current);
|
|
176
|
-
} else if (mode === 'multi-file') {
|
|
177
|
-
this.wFiles.set(current);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
clear(): void {
|
|
182
|
-
const mode = this.mode();
|
|
183
|
-
if (mode === 'single-image') {
|
|
184
|
-
this.wImage.set(null);
|
|
185
|
-
} else if (mode === 'single-file') {
|
|
186
|
-
this.wFile.set(null);
|
|
187
|
-
} else if (mode === 'multi-image') {
|
|
188
|
-
this.wImages.set([]);
|
|
189
|
-
} else if (mode === 'multi-file') {
|
|
190
|
-
this.wFiles.set([]);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
private _applyNewUrls(urls: string[]): void {
|
|
195
|
-
const mode = this.mode();
|
|
196
|
-
|
|
197
|
-
if (!urls.length) {
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
if (mode === 'single-image') {
|
|
202
|
-
this.wImage.set(urls[0] ?? null);
|
|
203
|
-
return;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
if (mode === 'single-file') {
|
|
207
|
-
this.wFile.set(urls[0] ?? null);
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
if (mode === 'multi-image') {
|
|
212
|
-
this.wImages.set([...this.wImages(), ...urls]);
|
|
213
|
-
return;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
if (mode === 'multi-file') {
|
|
217
|
-
this.wFiles.set([...this.wFiles(), ...urls]);
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
}
|
|
1
|
+
import { NgTemplateOutlet } from '@angular/common';
|
|
2
|
+
import {
|
|
3
|
+
Component,
|
|
4
|
+
TemplateRef,
|
|
5
|
+
computed,
|
|
6
|
+
inject,
|
|
7
|
+
input,
|
|
8
|
+
model,
|
|
9
|
+
} from '@angular/core';
|
|
10
|
+
import { ButtonComponent, ModalService } from '@wawjs/ngx-ui';
|
|
11
|
+
import { fileToDataUrl } from './file.util';
|
|
12
|
+
import { TranslateDirective } from '@wawjs/ngx-translate';
|
|
13
|
+
import type { FabricCropResult } from '@wawjs/ngx-fabric';
|
|
14
|
+
import { fileDefaults } from './file.const';
|
|
15
|
+
import { FileService } from './file.service';
|
|
16
|
+
|
|
17
|
+
export type FileMode =
|
|
18
|
+
| 'single-image'
|
|
19
|
+
| 'single-file'
|
|
20
|
+
| 'multi-image'
|
|
21
|
+
| 'multi-file';
|
|
22
|
+
|
|
23
|
+
export type FileView = 'dropzone' | 'list' | 'thumb-only';
|
|
24
|
+
|
|
25
|
+
@Component({
|
|
26
|
+
selector: 'ngx-file',
|
|
27
|
+
imports: [NgTemplateOutlet, TranslateDirective, ButtonComponent],
|
|
28
|
+
templateUrl: './file.component.html',
|
|
29
|
+
styleUrl: './file.component.scss',
|
|
30
|
+
})
|
|
31
|
+
export class FileComponent {
|
|
32
|
+
/** UI props */
|
|
33
|
+
readonly label = input<string>(fileDefaults.label);
|
|
34
|
+
readonly placeholder = input<string>(fileDefaults.placeholder);
|
|
35
|
+
readonly disabled = input<boolean>(fileDefaults.disabled);
|
|
36
|
+
readonly clearable = input<boolean>(fileDefaults.clearable);
|
|
37
|
+
readonly accept = input<string>(fileDefaults.accept);
|
|
38
|
+
readonly preview = input<boolean>(fileDefaults.preview);
|
|
39
|
+
|
|
40
|
+
/** Behaviour */
|
|
41
|
+
readonly mode = input<FileMode>(fileDefaults.mode as FileMode);
|
|
42
|
+
readonly view = input<FileView>(fileDefaults.view as FileView);
|
|
43
|
+
|
|
44
|
+
/** Optional crop box (for image modes) */
|
|
45
|
+
readonly cropWidth = input<number | null>(fileDefaults.cropWidth);
|
|
46
|
+
readonly cropHeight = input<number | null>(fileDefaults.cropHeight);
|
|
47
|
+
|
|
48
|
+
/** Custom templates */
|
|
49
|
+
readonly t_item = input<TemplateRef<unknown>>();
|
|
50
|
+
readonly t_empty = input<TemplateRef<unknown>>();
|
|
51
|
+
|
|
52
|
+
/** Back-end routing */
|
|
53
|
+
readonly container = input<string>(fileDefaults.container);
|
|
54
|
+
readonly name = input<string>(fileDefaults.name);
|
|
55
|
+
|
|
56
|
+
/** Separate models for each mode */
|
|
57
|
+
readonly wImage = model<string | null>(null, { alias: 'wImage' });
|
|
58
|
+
readonly wFile = model<string | null>(null, { alias: 'wFile' });
|
|
59
|
+
readonly wImages = model<string[]>([], { alias: 'wImages' });
|
|
60
|
+
readonly wFiles = model<string[]>([], { alias: 'wFiles' });
|
|
61
|
+
|
|
62
|
+
private readonly _modal = inject(ModalService);
|
|
63
|
+
private readonly _fs = inject(FileService);
|
|
64
|
+
|
|
65
|
+
readonly isDisabled = computed(() => this.disabled());
|
|
66
|
+
readonly isMultiple = computed(() => this.mode().startsWith('multi-'));
|
|
67
|
+
readonly isImageMode = computed(() => this.mode().includes('image'));
|
|
68
|
+
|
|
69
|
+
/** Normalized list of URLs for rendering */
|
|
70
|
+
readonly files = computed<string[]>(() => {
|
|
71
|
+
const mode = this.mode();
|
|
72
|
+
switch (mode) {
|
|
73
|
+
case 'single-image':
|
|
74
|
+
return this.wImage() ? [this.wImage() as string] : [];
|
|
75
|
+
case 'single-file':
|
|
76
|
+
return this.wFile() ? [this.wFile() as string] : [];
|
|
77
|
+
case 'multi-image':
|
|
78
|
+
return this.wImages();
|
|
79
|
+
case 'multi-file':
|
|
80
|
+
return this.wFiles();
|
|
81
|
+
default:
|
|
82
|
+
return [];
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
triggerPick(input: HTMLInputElement): void {
|
|
87
|
+
if (!this.isDisabled()) {
|
|
88
|
+
input.click();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
isImage(src: string): boolean {
|
|
93
|
+
return /\.(png|jpe?g|webp|gif)(\?|$)/i.test(src ?? '');
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
async onPicked(input: HTMLInputElement): Promise<void> {
|
|
97
|
+
const list = input.files;
|
|
98
|
+
if (!list || !list.length) return;
|
|
99
|
+
|
|
100
|
+
const doCrop =
|
|
101
|
+
this.isImageMode() && !!this.cropWidth() && !!this.cropHeight();
|
|
102
|
+
const urls: string[] = [];
|
|
103
|
+
const container = this.container();
|
|
104
|
+
const name = this.name();
|
|
105
|
+
|
|
106
|
+
for (let i = 0; i < list.length; i++) {
|
|
107
|
+
const f = list.item(i)!;
|
|
108
|
+
|
|
109
|
+
// Always read file as data URL
|
|
110
|
+
const dataUrl = await fileToDataUrl(f);
|
|
111
|
+
|
|
112
|
+
if (doCrop) {
|
|
113
|
+
// Lazy-load fabric crop modal only when actually cropping
|
|
114
|
+
const { FabricCropModalComponent } = await import(
|
|
115
|
+
'@wawjs/ngx-fabric'
|
|
116
|
+
);
|
|
117
|
+
await new Promise<void>((resolve) => {
|
|
118
|
+
this._modal.show({
|
|
119
|
+
component: FabricCropModalComponent,
|
|
120
|
+
size: 'big',
|
|
121
|
+
image: dataUrl,
|
|
122
|
+
width: this.cropWidth()!,
|
|
123
|
+
height: this.cropHeight()!,
|
|
124
|
+
aspectRatio: this.cropWidth()! / this.cropHeight()!,
|
|
125
|
+
outputWidth: this.cropWidth()!,
|
|
126
|
+
outputHeight: this.cropHeight()!,
|
|
127
|
+
onCrop: (result: FabricCropResult) => {
|
|
128
|
+
this._fs
|
|
129
|
+
.uploadBase64(result.base64, container, name)
|
|
130
|
+
.then((url) => {
|
|
131
|
+
urls.push(url);
|
|
132
|
+
resolve();
|
|
133
|
+
});
|
|
134
|
+
},
|
|
135
|
+
onCancel: () => resolve(),
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
} else {
|
|
139
|
+
const url = await this._fs.uploadBase64(
|
|
140
|
+
dataUrl,
|
|
141
|
+
container,
|
|
142
|
+
name,
|
|
143
|
+
);
|
|
144
|
+
urls.push(url);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// If single mode, ignore extra files after first
|
|
148
|
+
if (!this.isMultiple()) {
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
this._applyNewUrls(urls);
|
|
154
|
+
input.value = '';
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
removeAt(index: number): void {
|
|
158
|
+
const mode = this.mode();
|
|
159
|
+
|
|
160
|
+
if (mode === 'single-image') {
|
|
161
|
+
this.wImage.set(null);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (mode === 'single-file') {
|
|
166
|
+
this.wFile.set(null);
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// Multi modes
|
|
171
|
+
const current = [...this.files()];
|
|
172
|
+
current.splice(index, 1);
|
|
173
|
+
|
|
174
|
+
if (mode === 'multi-image') {
|
|
175
|
+
this.wImages.set(current);
|
|
176
|
+
} else if (mode === 'multi-file') {
|
|
177
|
+
this.wFiles.set(current);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
clear(): void {
|
|
182
|
+
const mode = this.mode();
|
|
183
|
+
if (mode === 'single-image') {
|
|
184
|
+
this.wImage.set(null);
|
|
185
|
+
} else if (mode === 'single-file') {
|
|
186
|
+
this.wFile.set(null);
|
|
187
|
+
} else if (mode === 'multi-image') {
|
|
188
|
+
this.wImages.set([]);
|
|
189
|
+
} else if (mode === 'multi-file') {
|
|
190
|
+
this.wFiles.set([]);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
private _applyNewUrls(urls: string[]): void {
|
|
195
|
+
const mode = this.mode();
|
|
196
|
+
|
|
197
|
+
if (!urls.length) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if (mode === 'single-image') {
|
|
202
|
+
this.wImage.set(urls[0] ?? null);
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
if (mode === 'single-file') {
|
|
207
|
+
this.wFile.set(urls[0] ?? null);
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (mode === 'multi-image') {
|
|
212
|
+
this.wImages.set([...this.wImages(), ...urls]);
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
if (mode === 'multi-file') {
|
|
217
|
+
this.wFiles.set([...this.wFiles(), ...urls]);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { CrudDocument } from '@wawjs/ngx-crud';
|
|
2
|
-
|
|
3
|
-
export interface File extends CrudDocument<File> {
|
|
4
|
-
name: string;
|
|
5
|
-
description: string;
|
|
6
|
-
url?: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface ImageResizeBounds {
|
|
10
|
-
width: number;
|
|
11
|
-
height: number;
|
|
12
|
-
}
|
|
1
|
+
import { CrudDocument } from '@wawjs/ngx-crud';
|
|
2
|
+
|
|
3
|
+
export interface File extends CrudDocument<File> {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
url?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface ImageResizeBounds {
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
}
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import { Injectable, inject } from '@angular/core';
|
|
2
|
-
import { CrudService } from '@wawjs/ngx-crud';
|
|
3
|
-
import { HttpService } from '@wawjs/ngx-http';
|
|
4
|
-
import { NGX_BOS_CONFIG } from '../../ngx-bos.config';
|
|
5
|
-
import { File } from './file.interface';
|
|
6
|
-
|
|
7
|
-
@Injectable({ providedIn: 'root' })
|
|
8
|
-
export class FileService extends CrudService<File> {
|
|
9
|
-
private readonly _http = inject(HttpService);
|
|
10
|
-
private readonly _bosConfig = inject(NGX_BOS_CONFIG);
|
|
11
|
-
|
|
12
|
-
constructor() {
|
|
13
|
-
super({ name: 'file' });
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Upload base64 (data URL) to backend with optional container/name.
|
|
18
|
-
* Returns a URL string from the API.
|
|
19
|
-
*/
|
|
20
|
-
async uploadBase64(
|
|
21
|
-
dataUrl: string,
|
|
22
|
-
container = 'general',
|
|
23
|
-
name = '',
|
|
24
|
-
): Promise<string> {
|
|
25
|
-
return await new Promise<string>((resolve) => {
|
|
26
|
-
this._http.post(
|
|
27
|
-
'/api/cloudflare/upload-base64',
|
|
28
|
-
{ container, name, dataUrl },
|
|
29
|
-
(resp: { key: string }) =>
|
|
30
|
-
resolve(this._bosConfig.cdnUrl + '/' + resp.key),
|
|
31
|
-
);
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
}
|
|
1
|
+
import { Injectable, inject } from '@angular/core';
|
|
2
|
+
import { CrudService } from '@wawjs/ngx-crud';
|
|
3
|
+
import { HttpService } from '@wawjs/ngx-http';
|
|
4
|
+
import { NGX_BOS_CONFIG } from '../../ngx-bos.config';
|
|
5
|
+
import { File } from './file.interface';
|
|
6
|
+
|
|
7
|
+
@Injectable({ providedIn: 'root' })
|
|
8
|
+
export class FileService extends CrudService<File> {
|
|
9
|
+
private readonly _http = inject(HttpService);
|
|
10
|
+
private readonly _bosConfig = inject(NGX_BOS_CONFIG);
|
|
11
|
+
|
|
12
|
+
constructor() {
|
|
13
|
+
super({ name: 'file' });
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Upload base64 (data URL) to backend with optional container/name.
|
|
18
|
+
* Returns a URL string from the API.
|
|
19
|
+
*/
|
|
20
|
+
async uploadBase64(
|
|
21
|
+
dataUrl: string,
|
|
22
|
+
container = 'general',
|
|
23
|
+
name = '',
|
|
24
|
+
): Promise<string> {
|
|
25
|
+
return await new Promise<string>((resolve) => {
|
|
26
|
+
this._http.post(
|
|
27
|
+
'/api/cloudflare/upload-base64',
|
|
28
|
+
{ container, name, dataUrl },
|
|
29
|
+
(resp: { key: string }) =>
|
|
30
|
+
resolve(this._bosConfig.cdnUrl + '/' + resp.key),
|
|
31
|
+
);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
<wtable title="Files" [columns]="columns" [config]="config" [rows]="rows">
|
|
2
2
|
<ng-template cell="img" let-element>
|
|
3
3
|
<img
|
|
4
|
-
[src]="element.url || ''"
|
|
4
|
+
[src]="element.url || ''"
|
|
5
5
|
(click)="copy(element.url)"
|
|
6
6
|
style="height: 100px"
|
|
7
7
|
/>
|
|
8
8
|
</ng-template>
|
|
9
9
|
<ng-template cell="url" let-element>
|
|
10
|
-
<span (click)="copy(element.url || '')">{{ element.url }}</span>
|
|
10
|
+
<span (click)="copy(element.url || '')">{{ element.url }}</span>
|
|
11
11
|
</ng-template>
|
|
12
12
|
</wtable>
|