@ldw-framework/material-media 0.3.0 → 0.4.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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CommonModule } from '@angular/common';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
|
-
import { inject, ChangeDetectorRef, Component, InjectionToken, Injectable } from '@angular/core';
|
|
3
|
+
import { inject, ChangeDetectorRef, Component, InjectionToken, Injectable, Input, NgModule } from '@angular/core';
|
|
4
4
|
import * as i1 from '@angular/material/button';
|
|
5
5
|
import { MatButtonModule } from '@angular/material/button';
|
|
6
6
|
import * as i3 from '@angular/material/dialog';
|
|
@@ -8,6 +8,13 @@ import { MatDialogRef, MAT_DIALOG_DATA, MatDialogModule, MatDialog } from '@angu
|
|
|
8
8
|
import * as i2 from '@angular/material/icon';
|
|
9
9
|
import { MatIconModule } from '@angular/material/icon';
|
|
10
10
|
import { LDuAnguBootTranslationPipe } from '@ldu-anguboot/i18n';
|
|
11
|
+
import { coerceBooleanProperty } from '@angular/cdk/coercion';
|
|
12
|
+
import * as i1$1 from '@angular/forms';
|
|
13
|
+
import { FormGroup, FormControl, FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
14
|
+
import * as i3$1 from '@angular/material/form-field';
|
|
15
|
+
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
16
|
+
import * as i4 from '@angular/material/input';
|
|
17
|
+
import { MatInputModule } from '@angular/material/input';
|
|
11
18
|
import { LDuAnguBootApiService } from '@ldu-anguboot/http';
|
|
12
19
|
import { firstValueFrom } from 'rxjs';
|
|
13
20
|
|
|
@@ -120,8 +127,8 @@ const LDW_MAT_MEDIA_API = new InjectionToken('LDW_MAT_MEDIA_API');
|
|
|
120
127
|
|
|
121
128
|
class LDwMaterialMediaService {
|
|
122
129
|
MEDIA_API$ = inject(LDW_MAT_MEDIA_API);
|
|
123
|
-
lduApiService = inject(LDuAnguBootApiService);
|
|
124
|
-
matDialog = inject(MatDialog);
|
|
130
|
+
lduApiService$ = inject(LDuAnguBootApiService);
|
|
131
|
+
matDialog$ = inject(MatDialog);
|
|
125
132
|
async uploadImage(uploadUrl, type = 'jpg', data) {
|
|
126
133
|
const media = await firstValueFrom(this.matDialog.open(LDwMaterialImageUploadDialogComponent, {
|
|
127
134
|
height: 'calc(100% - 1rem)',
|
|
@@ -134,13 +141,13 @@ class LDwMaterialMediaService {
|
|
|
134
141
|
},
|
|
135
142
|
}).afterClosed());
|
|
136
143
|
if (media?.imgBase64) {
|
|
137
|
-
const response = await firstValueFrom(this.
|
|
144
|
+
const response = await firstValueFrom(this.apiService.PUT(uploadUrl, media));
|
|
138
145
|
if (response?.id) {
|
|
139
146
|
switch (type) {
|
|
140
147
|
case 'jpg':
|
|
141
|
-
return this.
|
|
148
|
+
return this.apiService.url(`${this.ENV.url}/${response.id}.jpg?t=${Date.now()}`);
|
|
142
149
|
case 'png':
|
|
143
|
-
return this.
|
|
150
|
+
return this.apiService.url(`${this.ENV.url}/${response.id}.png?t=${Date.now()}`);
|
|
144
151
|
default:
|
|
145
152
|
break;
|
|
146
153
|
}
|
|
@@ -149,9 +156,11 @@ class LDwMaterialMediaService {
|
|
|
149
156
|
return null;
|
|
150
157
|
}
|
|
151
158
|
async clearImage(api) {
|
|
152
|
-
return firstValueFrom(this.
|
|
159
|
+
return firstValueFrom(this.apiService.DELETE(`${api}`));
|
|
153
160
|
}
|
|
154
161
|
get ENV() { return this.MEDIA_API$; }
|
|
162
|
+
get apiService() { return this.lduApiService$; }
|
|
163
|
+
get matDialog() { return this.matDialog$; }
|
|
155
164
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: LDwMaterialMediaService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
156
165
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: LDwMaterialMediaService, providedIn: 'root' });
|
|
157
166
|
}
|
|
@@ -160,9 +169,187 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImpor
|
|
|
160
169
|
args: [{ providedIn: 'root' }]
|
|
161
170
|
}] });
|
|
162
171
|
|
|
172
|
+
class LDwMaterialImageUploaderComponent {
|
|
173
|
+
service = inject(LDwMaterialMediaService);
|
|
174
|
+
readonly$ = false;
|
|
175
|
+
required$ = false;
|
|
176
|
+
formParent = new FormGroup({
|
|
177
|
+
value: new FormControl(null, [])
|
|
178
|
+
});
|
|
179
|
+
formParentControlName = 'value';
|
|
180
|
+
label = 'Value';
|
|
181
|
+
appearance = 'outline';
|
|
182
|
+
name = 'value';
|
|
183
|
+
type = 'jpg';
|
|
184
|
+
dimensions;
|
|
185
|
+
api;
|
|
186
|
+
set readonly(v) { this.readonly$ = coerceBooleanProperty(v); }
|
|
187
|
+
set required(v) { this.required$ = coerceBooleanProperty(v); }
|
|
188
|
+
async onUploadClick() {
|
|
189
|
+
if (this.api) {
|
|
190
|
+
const mediaUrl = await this.service.uploadImage(`${this.api}`);
|
|
191
|
+
if (mediaUrl) {
|
|
192
|
+
this.control.setValue(mediaUrl);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
async onDeleteClick() {
|
|
197
|
+
if (this.api) {
|
|
198
|
+
await this.service.clearImage(this.api);
|
|
199
|
+
}
|
|
200
|
+
this.control.setValue(null);
|
|
201
|
+
}
|
|
202
|
+
get readonly() { return this.readonly$; }
|
|
203
|
+
;
|
|
204
|
+
get required() { return this.required$; }
|
|
205
|
+
;
|
|
206
|
+
get control() {
|
|
207
|
+
return this.formParent?.get(this.formParentControlName);
|
|
208
|
+
}
|
|
209
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: LDwMaterialImageUploaderComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
210
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.0", type: LDwMaterialImageUploaderComponent, isStandalone: true, selector: "ldw-mat-image-uploader", inputs: { formParent: "formParent", formParentControlName: "formParentControlName", label: "label", appearance: "appearance", name: "name", type: "type", dimensions: "dimensions", api: "api", readonly: "readonly", required: "required" }, host: { classAttribute: "ldw-mat-image-uploader" }, ngImport: i0, template: `
|
|
211
|
+
<form
|
|
212
|
+
[formGroup]="formParent"
|
|
213
|
+
novalidate
|
|
214
|
+
><mat-form-field
|
|
215
|
+
[appearance]="appearance"
|
|
216
|
+
><mat-label
|
|
217
|
+
[innerHTML]="label" />
|
|
218
|
+
<input matInput
|
|
219
|
+
[name]="name"
|
|
220
|
+
[formControlName]="formParentControlName"
|
|
221
|
+
[readonly]="readonly"
|
|
222
|
+
[required]="required"
|
|
223
|
+
/>
|
|
224
|
+
@if (dimensions)
|
|
225
|
+
{
|
|
226
|
+
<mat-hint>{{ dimensions }}.{{ type }}</mat-hint>
|
|
227
|
+
}
|
|
228
|
+
<div matSuffix>
|
|
229
|
+
@if (control.value)
|
|
230
|
+
{
|
|
231
|
+
<a matIconButton
|
|
232
|
+
[href]="control.value"
|
|
233
|
+
target="_blank"
|
|
234
|
+
><mat-icon>visibility</mat-icon>
|
|
235
|
+
</a>
|
|
236
|
+
}
|
|
237
|
+
<button matIconButton
|
|
238
|
+
(click)="onUploadClick()"
|
|
239
|
+
><mat-icon>add_photo_alternate</mat-icon>
|
|
240
|
+
</button>
|
|
241
|
+
<button matIconButton
|
|
242
|
+
(click)="onDeleteClick()"
|
|
243
|
+
><mat-icon>delete</mat-icon>
|
|
244
|
+
</button>
|
|
245
|
+
</div>
|
|
246
|
+
<ng-content/>
|
|
247
|
+
</mat-form-field>
|
|
248
|
+
</form>
|
|
249
|
+
`, isInline: true, dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1$1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1$1.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1$1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i1.MatIconButton, selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]", exportAs: ["matButton", "matAnchor"] }, { kind: "ngmodule", type: MatFormFieldModule }, { kind: "component", type: i3$1.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i3$1.MatLabel, selector: "mat-label" }, { kind: "directive", type: i3$1.MatHint, selector: "mat-hint", inputs: ["align", "id"] }, { kind: "directive", type: i3$1.MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }, { kind: "ngmodule", type: MatInputModule }, { kind: "directive", type: i4.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly", "disabledInteractive"], exportAs: ["matInput"] }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i2.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }] });
|
|
250
|
+
}
|
|
251
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: LDwMaterialImageUploaderComponent, decorators: [{
|
|
252
|
+
type: Component,
|
|
253
|
+
args: [{
|
|
254
|
+
selector: 'ldw-mat-image-uploader',
|
|
255
|
+
host: { class: 'ldw-mat-image-uploader' },
|
|
256
|
+
imports: [
|
|
257
|
+
CommonModule,
|
|
258
|
+
FormsModule,
|
|
259
|
+
ReactiveFormsModule,
|
|
260
|
+
MatButtonModule,
|
|
261
|
+
MatFormFieldModule,
|
|
262
|
+
MatInputModule,
|
|
263
|
+
MatIconModule,
|
|
264
|
+
],
|
|
265
|
+
template: `
|
|
266
|
+
<form
|
|
267
|
+
[formGroup]="formParent"
|
|
268
|
+
novalidate
|
|
269
|
+
><mat-form-field
|
|
270
|
+
[appearance]="appearance"
|
|
271
|
+
><mat-label
|
|
272
|
+
[innerHTML]="label" />
|
|
273
|
+
<input matInput
|
|
274
|
+
[name]="name"
|
|
275
|
+
[formControlName]="formParentControlName"
|
|
276
|
+
[readonly]="readonly"
|
|
277
|
+
[required]="required"
|
|
278
|
+
/>
|
|
279
|
+
@if (dimensions)
|
|
280
|
+
{
|
|
281
|
+
<mat-hint>{{ dimensions }}.{{ type }}</mat-hint>
|
|
282
|
+
}
|
|
283
|
+
<div matSuffix>
|
|
284
|
+
@if (control.value)
|
|
285
|
+
{
|
|
286
|
+
<a matIconButton
|
|
287
|
+
[href]="control.value"
|
|
288
|
+
target="_blank"
|
|
289
|
+
><mat-icon>visibility</mat-icon>
|
|
290
|
+
</a>
|
|
291
|
+
}
|
|
292
|
+
<button matIconButton
|
|
293
|
+
(click)="onUploadClick()"
|
|
294
|
+
><mat-icon>add_photo_alternate</mat-icon>
|
|
295
|
+
</button>
|
|
296
|
+
<button matIconButton
|
|
297
|
+
(click)="onDeleteClick()"
|
|
298
|
+
><mat-icon>delete</mat-icon>
|
|
299
|
+
</button>
|
|
300
|
+
</div>
|
|
301
|
+
<ng-content/>
|
|
302
|
+
</mat-form-field>
|
|
303
|
+
</form>
|
|
304
|
+
`
|
|
305
|
+
}]
|
|
306
|
+
}], propDecorators: { formParent: [{
|
|
307
|
+
type: Input,
|
|
308
|
+
args: [{ required: true }]
|
|
309
|
+
}], formParentControlName: [{
|
|
310
|
+
type: Input,
|
|
311
|
+
args: [{ required: true }]
|
|
312
|
+
}], label: [{
|
|
313
|
+
type: Input,
|
|
314
|
+
args: [{ required: true }]
|
|
315
|
+
}], appearance: [{
|
|
316
|
+
type: Input
|
|
317
|
+
}], name: [{
|
|
318
|
+
type: Input
|
|
319
|
+
}], type: [{
|
|
320
|
+
type: Input
|
|
321
|
+
}], dimensions: [{
|
|
322
|
+
type: Input
|
|
323
|
+
}], api: [{
|
|
324
|
+
type: Input
|
|
325
|
+
}], readonly: [{
|
|
326
|
+
type: Input
|
|
327
|
+
}], required: [{
|
|
328
|
+
type: Input
|
|
329
|
+
}] } });
|
|
330
|
+
|
|
331
|
+
const components = [
|
|
332
|
+
LDwMaterialImageUploadDialogComponent,
|
|
333
|
+
LDwMaterialImageUploaderComponent,
|
|
334
|
+
];
|
|
335
|
+
class LDwMaterialImageUploaderModule {
|
|
336
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: LDwMaterialImageUploaderModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
337
|
+
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.2.0", ngImport: i0, type: LDwMaterialImageUploaderModule, imports: [LDwMaterialImageUploadDialogComponent,
|
|
338
|
+
LDwMaterialImageUploaderComponent], exports: [LDwMaterialImageUploadDialogComponent,
|
|
339
|
+
LDwMaterialImageUploaderComponent] });
|
|
340
|
+
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: LDwMaterialImageUploaderModule, imports: [components] });
|
|
341
|
+
}
|
|
342
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: LDwMaterialImageUploaderModule, decorators: [{
|
|
343
|
+
type: NgModule,
|
|
344
|
+
args: [{
|
|
345
|
+
imports: [...components],
|
|
346
|
+
exports: [...components]
|
|
347
|
+
}]
|
|
348
|
+
}] });
|
|
349
|
+
|
|
163
350
|
/**
|
|
164
351
|
* Generated bundle index. Do not edit.
|
|
165
352
|
*/
|
|
166
353
|
|
|
167
|
-
export { LDW_MAT_MEDIA_API, LDwMaterialImageUploadDialogComponent, LDwMaterialMediaService };
|
|
354
|
+
export { LDW_MAT_MEDIA_API, LDwMaterialImageUploadDialogComponent, LDwMaterialImageUploaderComponent, LDwMaterialImageUploaderModule, LDwMaterialMediaService };
|
|
168
355
|
//# sourceMappingURL=ldw-framework-material-media.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ldw-framework-material-media.mjs","sources":["../../../lib/src/components/ldw-mat-image-upload-dialog.component.ts","../../../lib/src/config/ldw-mat-media.config.ts","../../../lib/src/services/ldw-mat-media.service.ts","../../../lib/src/ldw-framework-material-media.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport { ChangeDetectorRef, Component, inject } from '@angular/core';\nimport { MatButtonModule } from '@angular/material/button';\nimport { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material/dialog';\nimport { MatIconModule } from '@angular/material/icon';\nimport { LDuAnguBootTranslationPipe } from '@ldu-anguboot/i18n';\nimport { LDwMaterialMediaModel } from '../models/ldw-mat-media.model';\n\n@Component({\n selector: 'ldw-mat-image-upload-dialog',\n host: { class: 'ldw-mat-image-upload-dialog' },\n imports: [\n CommonModule,\n MatButtonModule,\n MatIconModule,\n MatDialogModule,\n LDuAnguBootTranslationPipe,\n ],\n template: `\n <mat-dialog-actions>\n <h2>{{ 'LDU_ANGUBOOT_IMG_UPLOAD_DIALOG.title' | i18n }}</h2>\n <button class=\"ldw-mat-image-uploader-save\"\n matButton\n cdkFocusInitial\n (click)=\"onSaveClick()\"\n >{{ 'LDU_ANGUBOOT_IMG_UPLOAD_DIALOG.btnSave' | i18n }}</button>\n <button class=\"ldw-mat-image-uploader-cancel\"\n matButton\n (click)=\"onCancelClick()\"\n >{{ 'LDU_ANGUBOOT_IMG_UPLOAD_DIALOG.btnCancel' | i18n }}</button>\n </mat-dialog-actions>\n <mat-dialog-content>\n <input class=\"ldw-mat-image-uploader-hidden-input\"\n #uploader type=\"file\"\n [style.display]=\"'none'\"\n (change)=\"onChange($event)\"\n />\n <div class=\"ldw-mat-image-uploader--instance\"\n [style.backgroundImage]=\"$backgroundImage\"\n (keypress)=\"uploader.click()\"\n (click)=\"uploader.click()\"\n >@if ($noData) { <mat-icon>image</mat-icon> }\n </div>\n </mat-dialog-content>\n`})\nexport class LDwMaterialImageUploadDialogComponent {\n\n readonly dialogRef = inject(MatDialogRef<LDwMaterialImageUploadDialogComponent>);\n\n readonly data = inject<LDwMaterialMediaModel>(MAT_DIALOG_DATA);\n\n readonly cdr = inject(ChangeDetectorRef);\n\n onSaveClick() {\n this.dialogRef.close(this.data);\n }\n\n onCancelClick() {\n this.dialogRef.close(false);\n }\n\n onChange($event: any) {\n const files = $event?.target?.files;\n if (files?.[0]) {\n const picture = files[0];\n const reader = new FileReader();\n reader.readAsDataURL(picture);\n reader.onload = () => {\n this.data.imgBase64 = (reader.result as string).toString();\n this.cdr.detectChanges();\n };\n }\n }\n\n get $backgroundImage() {\n if (this.data.imgBase64) {\n return 'url(' + this.data.imgBase64 + ')';\n }\n if (this.data.imgSrc) {\n return 'url(' + this.data.imgSrc + ')';\n }\n return '';\n }\n\n get $noData() {\n return !this.data?.imgBase64 && !this.data?.imgSrc;\n }\n}\n","import { InjectionToken } from '@angular/core';\n\nexport const LDW_MAT_MEDIA_API = new InjectionToken<{\n url: string;\n}>('LDW_MAT_MEDIA_API');\n","import { inject, Injectable } from '@angular/core';\nimport { MatDialog } from '@angular/material/dialog';\nimport { LDuAnguBootApiService } from '@ldu-anguboot/http';\nimport { firstValueFrom } from 'rxjs';\nimport { LDwMaterialImageUploadDialogComponent } from '../components/ldw-mat-image-upload-dialog.component';\nimport { LDW_MAT_MEDIA_API } from '../config/ldw-mat-media.config';\nimport { LDwMaterialMediaModel } from '../models/ldw-mat-media.model';\n\n@Injectable({ providedIn: 'root' })\nexport class LDwMaterialMediaService {\n\n private readonly MEDIA_API$ = inject(LDW_MAT_MEDIA_API);\n\n private readonly lduApiService = inject(LDuAnguBootApiService);\n\n private readonly matDialog = inject(MatDialog);\n\n async uploadImage(uploadUrl: string, type: 'jpg' | 'png' = 'jpg', data?: LDwMaterialMediaModel) {\n const media = await firstValueFrom(this.matDialog.open(LDwMaterialImageUploadDialogComponent, {\n height: 'calc(100% - 1rem)',\n width: 'calc(100% - 1rem)',\n maxHeight: '100%',\n maxWidth: '100%',\n data: {\n imgSrc: data?.imgSrc,\n imgBase64: data?.imgBase64,\n },\n }).afterClosed());\n if (media?.imgBase64) {\n const response = await firstValueFrom(this.lduApiService.PUT<LDwMaterialMediaModel>(uploadUrl, media));\n if (response?.id) {\n switch (type) {\n case 'jpg':\n return this.lduApiService.url(`${this.ENV.url}/${response.id}.jpg?t=${Date.now()}`);\n case 'png':\n return this.lduApiService.url(`${this.ENV.url}/${response.id}.png?t=${Date.now()}`);\n default:\n break;\n }\n }\n }\n return null;\n }\n\n async clearImage(api: string) {\n return firstValueFrom(this.lduApiService.DELETE(`${api}`));\n }\n\n get ENV() { return this.MEDIA_API$; }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;;;;MA6Ca,qCAAqC,CAAA;AAErC,IAAA,SAAS,GAA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,EAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAA,CAAA,EAAI,QAAQ,CAAC,EAAE,CAAA,OAAA,EAAU,IAAI,CAAC,GAAG,EAAE,CAAA,CAAE,CAAC;AACvF,oBAAA,KAAK,KAAK;wBACN,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAA,EAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAA,CAAA,EAAI,QAAQ,CAAC,EAAE,CAAA,OAAA,EAAU,IAAI,CAAC,GAAG,EAAE,CAAA,CAAE,CAAC;AACvF,oBAAA;wBACI;;YAEZ;QACJ;AACA,QAAA,OAAO,IAAI;IACf;IAEA,MAAM,UAAU,CAAC,GAAW,EAAA;AACxB,QAAA,OAAO,cAAc,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAA,EAAG,GAAG,CAAA,CAAE,CAAC,CAAC;IAC9D;IAEA,IAAI,GAAG,KAAK,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC;uGAvC3B,uBAAuB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;AAAvB,IAAA,OAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,uBAAuB,cADV,MAAM,EAAA,CAAA;;2FACnB,uBAAuB,EAAA,UAAA,EAAA,CAAA;kBADnC,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;ACRlC;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ldw-framework-material-media.mjs","sources":["../../../lib/src/components/ldw-mat-image-upload-dialog.component.ts","../../../lib/src/config/ldw-mat-media.config.ts","../../../lib/src/services/ldw-mat-media.service.ts","../../../lib/src/components/ldw-mat-image-uploader.component.ts","../../../lib/src/modules/ldw-mat-image-uploader.module.ts","../../../lib/src/ldw-framework-material-media.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport { ChangeDetectorRef, Component, inject } from '@angular/core';\nimport { MatButtonModule } from '@angular/material/button';\nimport { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material/dialog';\nimport { MatIconModule } from '@angular/material/icon';\nimport { LDuAnguBootTranslationPipe } from '@ldu-anguboot/i18n';\nimport { LDwMaterialMediaModel } from '../models/ldw-mat-media.model';\n\n@Component({\n selector: 'ldw-mat-image-upload-dialog',\n host: { class: 'ldw-mat-image-upload-dialog' },\n imports: [\n CommonModule,\n MatButtonModule,\n MatIconModule,\n MatDialogModule,\n LDuAnguBootTranslationPipe,\n ],\n template: `\n <mat-dialog-actions>\n <h2>{{ 'LDU_ANGUBOOT_IMG_UPLOAD_DIALOG.title' | i18n }}</h2>\n <button class=\"ldw-mat-image-uploader-save\"\n matButton\n cdkFocusInitial\n (click)=\"onSaveClick()\"\n >{{ 'LDU_ANGUBOOT_IMG_UPLOAD_DIALOG.btnSave' | i18n }}</button>\n <button class=\"ldw-mat-image-uploader-cancel\"\n matButton\n (click)=\"onCancelClick()\"\n >{{ 'LDU_ANGUBOOT_IMG_UPLOAD_DIALOG.btnCancel' | i18n }}</button>\n </mat-dialog-actions>\n <mat-dialog-content>\n <input class=\"ldw-mat-image-uploader-hidden-input\"\n #uploader type=\"file\"\n [style.display]=\"'none'\"\n (change)=\"onChange($event)\"\n />\n <div class=\"ldw-mat-image-uploader--instance\"\n [style.backgroundImage]=\"$backgroundImage\"\n (keypress)=\"uploader.click()\"\n (click)=\"uploader.click()\"\n >@if ($noData) { <mat-icon>image</mat-icon> }\n </div>\n </mat-dialog-content>\n`})\nexport class LDwMaterialImageUploadDialogComponent {\n\n readonly dialogRef = inject(MatDialogRef<LDwMaterialImageUploadDialogComponent>);\n\n readonly data = inject<LDwMaterialMediaModel>(MAT_DIALOG_DATA);\n\n readonly cdr = inject(ChangeDetectorRef);\n\n onSaveClick() {\n this.dialogRef.close(this.data);\n }\n\n onCancelClick() {\n this.dialogRef.close(false);\n }\n\n onChange($event: any) {\n const files = $event?.target?.files;\n if (files?.[0]) {\n const picture = files[0];\n const reader = new FileReader();\n reader.readAsDataURL(picture);\n reader.onload = () => {\n this.data.imgBase64 = (reader.result as string).toString();\n this.cdr.detectChanges();\n };\n }\n }\n\n get $backgroundImage() {\n if (this.data.imgBase64) {\n return 'url(' + this.data.imgBase64 + ')';\n }\n if (this.data.imgSrc) {\n return 'url(' + this.data.imgSrc + ')';\n }\n return '';\n }\n\n get $noData() {\n return !this.data?.imgBase64 && !this.data?.imgSrc;\n }\n}\n","import { InjectionToken } from '@angular/core';\n\nexport const LDW_MAT_MEDIA_API = new InjectionToken<{\n url: string;\n}>('LDW_MAT_MEDIA_API');\n","import { inject, Injectable } from '@angular/core';\nimport { MatDialog } from '@angular/material/dialog';\nimport { LDuAnguBootApiService } from '@ldu-anguboot/http';\nimport { firstValueFrom } from 'rxjs';\nimport { LDwMaterialImageUploadDialogComponent } from '../components/ldw-mat-image-upload-dialog.component';\nimport { LDW_MAT_MEDIA_API } from '../config/ldw-mat-media.config';\nimport { LDwMaterialMediaModel } from '../models/ldw-mat-media.model';\n\n@Injectable({ providedIn: 'root' })\nexport class LDwMaterialMediaService {\n\n private readonly MEDIA_API$ = inject(LDW_MAT_MEDIA_API);\n\n private readonly lduApiService$ = inject(LDuAnguBootApiService);\n\n private readonly matDialog$ = inject(MatDialog);\n\n async uploadImage(uploadUrl: string, type: 'jpg' | 'png' = 'jpg', data?: LDwMaterialMediaModel) {\n const media = await firstValueFrom(this.matDialog.open(LDwMaterialImageUploadDialogComponent, {\n height: 'calc(100% - 1rem)',\n width: 'calc(100% - 1rem)',\n maxHeight: '100%',\n maxWidth: '100%',\n data: {\n imgSrc: data?.imgSrc,\n imgBase64: data?.imgBase64,\n },\n }).afterClosed());\n if (media?.imgBase64) {\n const response = await firstValueFrom(this.apiService.PUT<LDwMaterialMediaModel>(uploadUrl, media));\n if (response?.id) {\n switch (type) {\n case 'jpg':\n return this.apiService.url(`${this.ENV.url}/${response.id}.jpg?t=${Date.now()}`);\n case 'png':\n return this.apiService.url(`${this.ENV.url}/${response.id}.png?t=${Date.now()}`);\n default:\n break;\n }\n }\n }\n return null;\n }\n\n async clearImage(api: string) {\n return firstValueFrom(this.apiService.DELETE(`${api}`));\n }\n\n get ENV() { return this.MEDIA_API$; }\n\n get apiService() { return this.lduApiService$; }\n\n get matDialog() { return this.matDialog$; }\n}\n","import { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { CommonModule } from '@angular/common';\nimport { Component, inject, Input } from '@angular/core';\nimport { FormControl, FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms';\nimport { MatButtonModule } from '@angular/material/button';\nimport { MatFormFieldModule } from '@angular/material/form-field';\nimport { MatIconModule } from '@angular/material/icon';\nimport { MatInputModule } from '@angular/material/input';\nimport { LDwMaterialMediaService } from '../services/ldw-mat-media.service';\n\n@Component({\n selector: 'ldw-mat-image-uploader',\n host: { class: 'ldw-mat-image-uploader' },\n imports: [\n CommonModule,\n FormsModule,\n ReactiveFormsModule,\n MatButtonModule,\n MatFormFieldModule,\n MatInputModule,\n MatIconModule,\n ],\n template: `\n <form\n [formGroup]=\"formParent\"\n novalidate\n ><mat-form-field\n [appearance]=\"appearance\"\n ><mat-label\n [innerHTML]=\"label\" />\n <input matInput\n [name]=\"name\"\n [formControlName]=\"formParentControlName\"\n [readonly]=\"readonly\"\n [required]=\"required\"\n />\n @if (dimensions)\n {\n <mat-hint>{{ dimensions }}.{{ type }}</mat-hint>\n }\n <div matSuffix>\n @if (control.value)\n {\n <a matIconButton\n [href]=\"control.value\"\n target=\"_blank\"\n ><mat-icon>visibility</mat-icon>\n </a>\n }\n <button matIconButton\n (click)=\"onUploadClick()\"\n ><mat-icon>add_photo_alternate</mat-icon>\n </button>\n <button matIconButton\n (click)=\"onDeleteClick()\"\n ><mat-icon>delete</mat-icon>\n </button>\n </div>\n <ng-content/>\n </mat-form-field>\n </form>\n`})\nexport class LDwMaterialImageUploaderComponent {\n\n protected readonly service = inject(LDwMaterialMediaService);\n\n protected readonly$: string | boolean = false;\n\n protected required$: string | boolean = false;\n\n @Input({ required: true })\n formParent: FormGroup = new FormGroup({\n value: new FormControl<string | null | undefined>(null, [])\n });\n\n @Input({ required: true })\n formParentControlName = 'value';\n\n @Input({ required: true })\n label = 'Value';\n\n @Input()\n appearance: 'fill' | 'outline' = 'outline';\n\n @Input()\n name = 'value';\n\n @Input()\n type: 'jpg' | 'png' = 'jpg';\n\n @Input()\n dimensions: string | null | undefined;\n\n @Input()\n api: string | null | undefined;\n\n @Input()\n set readonly(v) { this.readonly$ = coerceBooleanProperty(v); }\n\n @Input()\n set required(v) { this.required$ = coerceBooleanProperty(v); }\n\n async onUploadClick() {\n if (this.api) {\n const mediaUrl = await this.service.uploadImage(`${this.api}`);\n if (mediaUrl) {\n this.control.setValue(mediaUrl);\n }\n }\n }\n\n async onDeleteClick() {\n if (this.api) {\n await this.service.clearImage(this.api);\n }\n this.control.setValue(null);\n }\n\n get readonly() { return this.readonly$; };\n\n get required() { return this.required$; };\n\n get control() {\n return this.formParent?.get(this.formParentControlName) as FormControl<string | null | undefined>;\n }\n}\n","import { NgModule } from '@angular/core';\nimport { LDwMaterialImageUploadDialogComponent } from '../components/ldw-mat-image-upload-dialog.component';\nimport { LDwMaterialImageUploaderComponent } from '../components/ldw-mat-image-uploader.component';\n\nconst components = [\n LDwMaterialImageUploadDialogComponent,\n LDwMaterialImageUploaderComponent,\n];\n\n@NgModule({\n imports: [...components],\n exports: [...components]\n})\nexport class LDwMaterialImageUploaderModule { }\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i1","i2","i3","i5"],"mappings":";;;;;;;;;;;;;;;;;;;;MA6Ca,qCAAqC,CAAA;AAErC,IAAA,SAAS,GAAG,MAAM,EAAC,YAAmD,EAAC;AAEvE,IAAA,IAAI,GAAG,MAAM,CAAwB,eAAe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
|
4
4
|
"peerDependencies": {
|
|
5
|
+
"@angular/cdk": "^21.0.0",
|
|
5
6
|
"@angular/common": "^21.0.0",
|
|
6
7
|
"@angular/core": "^21.0.0",
|
|
8
|
+
"@angular/forms": "^21.0.0",
|
|
7
9
|
"@angular/material": "^21.0.0",
|
|
8
10
|
"@ldu-anguboot/http": "latest",
|
|
9
11
|
"@ldu-anguboot/i18n": "latest",
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { ChangeDetectorRef, InjectionToken } from '@angular/core';
|
|
3
|
-
import { MatDialogRef } from '@angular/material/dialog';
|
|
3
|
+
import { MatDialogRef, MatDialog } from '@angular/material/dialog';
|
|
4
|
+
import { FormGroup, FormControl } from '@angular/forms';
|
|
5
|
+
import { LDuAnguBootApiService } from '@ldu-anguboot/http';
|
|
4
6
|
|
|
5
7
|
interface LDwMaterialMediaModel {
|
|
6
8
|
id?: number;
|
|
@@ -21,22 +23,53 @@ declare class LDwMaterialImageUploadDialogComponent {
|
|
|
21
23
|
static ɵcmp: i0.ɵɵComponentDeclaration<LDwMaterialImageUploadDialogComponent, "ldw-mat-image-upload-dialog", never, {}, {}, never, never, true, never>;
|
|
22
24
|
}
|
|
23
25
|
|
|
24
|
-
declare const LDW_MAT_MEDIA_API: InjectionToken<{
|
|
25
|
-
url: string;
|
|
26
|
-
}>;
|
|
27
|
-
|
|
28
26
|
declare class LDwMaterialMediaService {
|
|
29
27
|
private readonly MEDIA_API$;
|
|
30
|
-
private readonly lduApiService
|
|
31
|
-
private readonly matDialog
|
|
28
|
+
private readonly lduApiService$;
|
|
29
|
+
private readonly matDialog$;
|
|
32
30
|
uploadImage(uploadUrl: string, type?: 'jpg' | 'png', data?: LDwMaterialMediaModel): Promise<string | null>;
|
|
33
31
|
clearImage(api: string): Promise<unknown>;
|
|
34
32
|
get ENV(): {
|
|
35
33
|
url: string;
|
|
36
34
|
};
|
|
35
|
+
get apiService(): LDuAnguBootApiService;
|
|
36
|
+
get matDialog(): MatDialog;
|
|
37
37
|
static ɵfac: i0.ɵɵFactoryDeclaration<LDwMaterialMediaService, never>;
|
|
38
38
|
static ɵprov: i0.ɵɵInjectableDeclaration<LDwMaterialMediaService>;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
declare class LDwMaterialImageUploaderComponent {
|
|
42
|
+
protected readonly service: LDwMaterialMediaService;
|
|
43
|
+
protected readonly$: string | boolean;
|
|
44
|
+
protected required$: string | boolean;
|
|
45
|
+
formParent: FormGroup;
|
|
46
|
+
formParentControlName: string;
|
|
47
|
+
label: string;
|
|
48
|
+
appearance: 'fill' | 'outline';
|
|
49
|
+
name: string;
|
|
50
|
+
type: 'jpg' | 'png';
|
|
51
|
+
dimensions: string | null | undefined;
|
|
52
|
+
api: string | null | undefined;
|
|
53
|
+
set readonly(v: string | boolean);
|
|
54
|
+
set required(v: string | boolean);
|
|
55
|
+
onUploadClick(): Promise<void>;
|
|
56
|
+
onDeleteClick(): Promise<void>;
|
|
57
|
+
get readonly(): string | boolean;
|
|
58
|
+
get required(): string | boolean;
|
|
59
|
+
get control(): FormControl<string | null | undefined>;
|
|
60
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<LDwMaterialImageUploaderComponent, never>;
|
|
61
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<LDwMaterialImageUploaderComponent, "ldw-mat-image-uploader", never, { "formParent": { "alias": "formParent"; "required": true; }; "formParentControlName": { "alias": "formParentControlName"; "required": true; }; "label": { "alias": "label"; "required": true; }; "appearance": { "alias": "appearance"; "required": false; }; "name": { "alias": "name"; "required": false; }; "type": { "alias": "type"; "required": false; }; "dimensions": { "alias": "dimensions"; "required": false; }; "api": { "alias": "api"; "required": false; }; "readonly": { "alias": "readonly"; "required": false; }; "required": { "alias": "required"; "required": false; }; }, {}, never, ["*"], true, never>;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
declare const LDW_MAT_MEDIA_API: InjectionToken<{
|
|
65
|
+
url: string;
|
|
66
|
+
}>;
|
|
67
|
+
|
|
68
|
+
declare class LDwMaterialImageUploaderModule {
|
|
69
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<LDwMaterialImageUploaderModule, never>;
|
|
70
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<LDwMaterialImageUploaderModule, never, [typeof LDwMaterialImageUploadDialogComponent, typeof LDwMaterialImageUploaderComponent], [typeof LDwMaterialImageUploadDialogComponent, typeof LDwMaterialImageUploaderComponent]>;
|
|
71
|
+
static ɵinj: i0.ɵɵInjectorDeclaration<LDwMaterialImageUploaderModule>;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export { LDW_MAT_MEDIA_API, LDwMaterialImageUploadDialogComponent, LDwMaterialImageUploaderComponent, LDwMaterialImageUploaderModule, LDwMaterialMediaService };
|
|
42
75
|
export type { LDwMaterialMediaModel };
|