@lenne.tech/ng-base 14.11.1 → 14.12.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/base-components/components/model-form/model-form.component.d.ts +12 -2
- package/base-components/components/model-form-sub/model-form-sub.component.d.ts +5 -1
- package/base-components/components/model-table/model-table.component.d.ts +1 -1
- package/base-components/components/upload-image/upload-image.component.d.ts +18 -7
- package/esm2020/base-components/components/model-form/model-form.component.mjs +48 -8
- package/esm2020/base-components/components/model-form-sub/model-form-sub.component.mjs +6 -3
- package/esm2020/base-components/components/model-table/model-table.component.mjs +3 -3
- package/esm2020/base-components/components/refence-input/refence-input.component.mjs +4 -3
- package/esm2020/base-components/components/tags/tags.component.mjs +3 -3
- package/esm2020/base-components/components/upload-image/upload-image.component.mjs +74 -33
- package/esm2020/shared/interfaces/compress-options.interface.mjs +2 -0
- package/esm2020/shared/public-api.mjs +3 -1
- package/esm2020/shared/services/file.service.mjs +89 -0
- package/fesm2015/lenne.tech-ng-base-base-components.mjs +137 -48
- package/fesm2015/lenne.tech-ng-base-base-components.mjs.map +1 -1
- package/fesm2015/lenne.tech-ng-base-shared.mjs +83 -1
- package/fesm2015/lenne.tech-ng-base-shared.mjs.map +1 -1
- package/fesm2020/lenne.tech-ng-base-base-components.mjs +130 -46
- package/fesm2020/lenne.tech-ng-base-base-components.mjs.map +1 -1
- package/fesm2020/lenne.tech-ng-base-shared.mjs +87 -1
- package/fesm2020/lenne.tech-ng-base-shared.mjs.map +1 -1
- package/package.json +3 -2
- package/shared/interfaces/compress-options.interface.d.ts +15 -0
- package/shared/public-api.d.ts +2 -0
- package/shared/services/file.service.d.ts +22 -0
|
@@ -11,6 +11,9 @@ import * as i2 from '@angular/common';
|
|
|
11
11
|
import { DOCUMENT } from '@angular/common';
|
|
12
12
|
import * as i1$1 from '@angular/router';
|
|
13
13
|
import { NavigationEnd } from '@angular/router';
|
|
14
|
+
import Compressor from 'compressorjs';
|
|
15
|
+
import * as i2$1 from '@angular/common/http';
|
|
16
|
+
import { HttpHeaders } from '@angular/common/http';
|
|
14
17
|
import { createClient } from 'graphql-ws';
|
|
15
18
|
|
|
16
19
|
/**
|
|
@@ -2394,6 +2397,89 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0", ngImpor
|
|
|
2394
2397
|
}]
|
|
2395
2398
|
}], ctorParameters: function () { return [{ type: GraphQLService }]; } });
|
|
2396
2399
|
|
|
2400
|
+
class FileService {
|
|
2401
|
+
constructor(authService, httpClient) {
|
|
2402
|
+
this.authService = authService;
|
|
2403
|
+
this.httpClient = httpClient;
|
|
2404
|
+
}
|
|
2405
|
+
/**
|
|
2406
|
+
* Compress file with options and return file
|
|
2407
|
+
*/
|
|
2408
|
+
compress(file, options) {
|
|
2409
|
+
const config = {
|
|
2410
|
+
...{
|
|
2411
|
+
quality: 0.6,
|
|
2412
|
+
checkOrientation: false,
|
|
2413
|
+
},
|
|
2414
|
+
...options,
|
|
2415
|
+
};
|
|
2416
|
+
return new Promise((resolve, reject) => {
|
|
2417
|
+
new Compressor(file, {
|
|
2418
|
+
...config,
|
|
2419
|
+
...{
|
|
2420
|
+
success(result) {
|
|
2421
|
+
// Check if result is blob for convert to file
|
|
2422
|
+
if (result instanceof Blob) {
|
|
2423
|
+
resolve(new File([result], result.name));
|
|
2424
|
+
}
|
|
2425
|
+
else {
|
|
2426
|
+
resolve(result);
|
|
2427
|
+
}
|
|
2428
|
+
},
|
|
2429
|
+
error(err) {
|
|
2430
|
+
reject(err.message);
|
|
2431
|
+
},
|
|
2432
|
+
},
|
|
2433
|
+
});
|
|
2434
|
+
});
|
|
2435
|
+
}
|
|
2436
|
+
/**
|
|
2437
|
+
* Upload file to server
|
|
2438
|
+
*/
|
|
2439
|
+
async upload(url, path, file, compressOptions) {
|
|
2440
|
+
return new Promise(async (resolve, reject) => {
|
|
2441
|
+
console.log(url, path, compressOptions, file);
|
|
2442
|
+
if (compressOptions) {
|
|
2443
|
+
file = await this.compress(file, compressOptions);
|
|
2444
|
+
}
|
|
2445
|
+
const data = new FormData();
|
|
2446
|
+
data.append('file', file);
|
|
2447
|
+
const httpOptions = {
|
|
2448
|
+
headers: new HttpHeaders({
|
|
2449
|
+
Authorization: 'Bearer ' + this.authService.token,
|
|
2450
|
+
}),
|
|
2451
|
+
};
|
|
2452
|
+
this.httpClient.post(url + path, data, httpOptions).subscribe((result) => {
|
|
2453
|
+
resolve(result);
|
|
2454
|
+
}, (err) => {
|
|
2455
|
+
reject(err);
|
|
2456
|
+
});
|
|
2457
|
+
});
|
|
2458
|
+
}
|
|
2459
|
+
delete(url, path, id) {
|
|
2460
|
+
return new Promise(async (resolve, reject) => {
|
|
2461
|
+
const httpOptions = {
|
|
2462
|
+
headers: new HttpHeaders({
|
|
2463
|
+
Authorization: 'Bearer ' + this.authService.token,
|
|
2464
|
+
}),
|
|
2465
|
+
};
|
|
2466
|
+
this.httpClient.delete(url + path + id, httpOptions).subscribe((result) => {
|
|
2467
|
+
resolve(result);
|
|
2468
|
+
}, (err) => {
|
|
2469
|
+
reject(err);
|
|
2470
|
+
});
|
|
2471
|
+
});
|
|
2472
|
+
}
|
|
2473
|
+
}
|
|
2474
|
+
FileService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: FileService, deps: [{ token: AuthService }, { token: i2$1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2475
|
+
FileService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: FileService, providedIn: 'root' });
|
|
2476
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: FileService, decorators: [{
|
|
2477
|
+
type: Injectable,
|
|
2478
|
+
args: [{
|
|
2479
|
+
providedIn: 'root',
|
|
2480
|
+
}]
|
|
2481
|
+
}], ctorParameters: function () { return [{ type: AuthService }, { type: i2$1.HttpClient }]; } });
|
|
2482
|
+
|
|
2397
2483
|
/**
|
|
2398
2484
|
* Comparison operator enum
|
|
2399
2485
|
*/
|
|
@@ -2516,5 +2602,5 @@ function createRestartableClient(options) {
|
|
|
2516
2602
|
* Generated bundle index. Do not edit.
|
|
2517
2603
|
*/
|
|
2518
2604
|
|
|
2519
|
-
export { Auth, AuthService, BASE_MODULE_CONFIG, BasicUser, BreadcrumbService, CmsService, ComparisonOperatorEnum, FormsService, GraphQLEnum, GraphQLMeta, GraphQLMetaService, GraphQLPlusService, GraphQLRequestType, GraphQLService, GraphQLType, Helper, ImageService, LoaderService, LogicalOperatorEnum, NavigationService, ScrollService, SkeletonType, Sort, SortOrderEnum, Standard, StorageService, ToastService, ToastType, UserService, Validation, WsService, createRestartableClient, debounce, fullEmail };
|
|
2605
|
+
export { Auth, AuthService, BASE_MODULE_CONFIG, BasicUser, BreadcrumbService, CmsService, ComparisonOperatorEnum, FileService, FormsService, GraphQLEnum, GraphQLMeta, GraphQLMetaService, GraphQLPlusService, GraphQLRequestType, GraphQLService, GraphQLType, Helper, ImageService, LoaderService, LogicalOperatorEnum, NavigationService, ScrollService, SkeletonType, Sort, SortOrderEnum, Standard, StorageService, ToastService, ToastType, UserService, Validation, WsService, createRestartableClient, debounce, fullEmail };
|
|
2520
2606
|
//# sourceMappingURL=lenne.tech-ng-base-shared.mjs.map
|