@cleavelandprice/ngx-lib 3.0.4 → 3.0.8

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.
Files changed (44) hide show
  1. package/active-directory/public_api.d.ts +3 -0
  2. package/authentication/public_api.d.ts +1 -0
  3. package/esm2020/active-directory/public_api.mjs +4 -1
  4. package/esm2020/active-directory/services/active-directory.service.mjs +13 -4
  5. package/esm2020/authentication/public_api.mjs +2 -2
  6. package/esm2020/authentication/services/authentication.service.mjs +5 -2
  7. package/esm2020/lib/services/app-path-config.service.mjs +5 -2
  8. package/esm2020/sharepoint/public_api.mjs +2 -2
  9. package/esm2020/sharepoint/services/sharepoint.service.mjs +5 -2
  10. package/esm2020/upload/components/upload/upload.component.mjs +5 -4
  11. package/esm2020/upload/components/upload-dialog/upload-dialog.component.mjs +10 -13
  12. package/esm2020/upload/model/default-config.mjs +14 -0
  13. package/esm2020/upload/model/service-config.mjs +14 -1
  14. package/esm2020/upload/public_api.mjs +2 -1
  15. package/esm2020/upload/services/upload.service.mjs +28 -30
  16. package/esm2020/upload/upload.module.mjs +5 -1
  17. package/fesm2015/cleavelandprice-ngx-lib-active-directory.mjs +7 -8
  18. package/fesm2015/cleavelandprice-ngx-lib-active-directory.mjs.map +1 -1
  19. package/fesm2015/cleavelandprice-ngx-lib-authentication.mjs +5 -6
  20. package/fesm2015/cleavelandprice-ngx-lib-authentication.mjs.map +1 -1
  21. package/fesm2015/cleavelandprice-ngx-lib-sharepoint.mjs +5 -6
  22. package/fesm2015/cleavelandprice-ngx-lib-sharepoint.mjs.map +1 -1
  23. package/fesm2015/cleavelandprice-ngx-lib-upload.mjs +68 -48
  24. package/fesm2015/cleavelandprice-ngx-lib-upload.mjs.map +1 -1
  25. package/fesm2015/cleavelandprice-ngx-lib.mjs +1 -2
  26. package/fesm2015/cleavelandprice-ngx-lib.mjs.map +1 -1
  27. package/fesm2020/cleavelandprice-ngx-lib-active-directory.mjs +16 -7
  28. package/fesm2020/cleavelandprice-ngx-lib-active-directory.mjs.map +1 -1
  29. package/fesm2020/cleavelandprice-ngx-lib-authentication.mjs +8 -5
  30. package/fesm2020/cleavelandprice-ngx-lib-authentication.mjs.map +1 -1
  31. package/fesm2020/cleavelandprice-ngx-lib-sharepoint.mjs +8 -5
  32. package/fesm2020/cleavelandprice-ngx-lib-sharepoint.mjs.map +1 -1
  33. package/fesm2020/cleavelandprice-ngx-lib-upload.mjs +71 -46
  34. package/fesm2020/cleavelandprice-ngx-lib-upload.mjs.map +1 -1
  35. package/fesm2020/cleavelandprice-ngx-lib.mjs +4 -1
  36. package/fesm2020/cleavelandprice-ngx-lib.mjs.map +1 -1
  37. package/package.json +1 -1
  38. package/sharepoint/public_api.d.ts +1 -0
  39. package/upload/components/upload-dialog/upload-dialog.component.d.ts +1 -6
  40. package/upload/model/default-config.d.ts +2 -0
  41. package/upload/model/service-config.d.ts +10 -10
  42. package/upload/public_api.d.ts +1 -0
  43. package/upload/services/upload.service.d.ts +1 -11
  44. package/upload/upload.module.d.ts +5 -4
@@ -4,35 +4,53 @@ import { Subject, forkJoin } from 'rxjs';
4
4
  import * as i1$1 from '@angular/material/dialog';
5
5
  import { MatDialogModule } from '@angular/material/dialog';
6
6
  import * as i1 from '@angular/common/http';
7
- import { HttpRequest, HttpHeaders, HttpEventType, HttpResponse } from '@angular/common/http';
7
+ import { HttpHeaders, HttpRequest, HttpEventType, HttpResponse } from '@angular/common/http';
8
8
  import * as i3 from '@angular/common';
9
9
  import { CommonModule } from '@angular/common';
10
- import * as i4 from '@angular/material/list';
10
+ import * as i4 from '@angular/material/button';
11
+ import { MatButtonModule } from '@angular/material/button';
12
+ import * as i5 from '@angular/material/list';
11
13
  import { MatListModule } from '@angular/material/list';
12
- import * as i5 from '@angular/material/core';
13
- import * as i6 from '@angular/material/progress-bar';
14
+ import * as i6 from '@angular/material/core';
15
+ import * as i7 from '@angular/material/progress-bar';
14
16
  import { MatProgressBarModule } from '@angular/material/progress-bar';
15
17
 
18
+ const defaultConfig = {
19
+ apiUrl: 'http://utilityapi/upload/database',
20
+ uploadDialogTitle: 'Upload Files',
21
+ uploadPath: null,
22
+ comment: null,
23
+ dbAppId: null,
24
+ externalReferenceId: null,
25
+ uploadButtonText: 'Upload',
26
+ uploadDialogCancelButtonText: 'Cancel',
27
+ uploadDialogFinishButtonText: 'Finish',
28
+ uploadDialogUploadButtonText: 'Upload',
29
+ uploadDialogAddFilesButtonText: 'Add Files'
30
+ };
31
+
16
32
  class ServiceConfig {
33
+ constructor() {
34
+ this.uploadPath = null;
35
+ this.dbAppId = null;
36
+ this.externalReferenceId = null;
37
+ this.comment = null;
38
+ // UI configuration
39
+ this.uploadButtonText = null;
40
+ this.uploadDialogTitle = null;
41
+ this.uploadDialogAddFilesButtonText = null;
42
+ this.uploadDialogCancelButtonText = null;
43
+ this.uploadDialogUploadButtonText = null;
44
+ this.uploadDialogFinishButtonText = null;
45
+ }
17
46
  }
18
47
 
19
48
  // https://malcoded.com/posts/angular-file-upload-component-with-express
20
49
  class UploadService {
21
50
  constructor(http, config) {
22
- var _a, _b, _c, _d, _e, _f;
23
51
  this.http = http;
24
- this.uploadApiUrl = config.apiUrl;
25
- this.uploadPath = config.uploadPath || '';
26
- this.dbAppId = config.dbAppId || '';
27
- this.externalReferenceId = config.externalReferenceId || '';
28
- this.comment = config.comment || '';
29
- // UI configuration
30
- this.uploadButtonText = (_a = config.uploadButtonText) !== null && _a !== void 0 ? _a : '';
31
- this.uploadDialogTitle = (_b = config.uploadDialogTitle) !== null && _b !== void 0 ? _b : '';
32
- this.uploadDialogAddFilesButtonText = (_c = config.uploadDialogAddFilesButtonText) !== null && _c !== void 0 ? _c : '';
33
- this.uploadDialogCancelButtonText = (_d = config.uploadDialogCancelButtonText) !== null && _d !== void 0 ? _d : '';
34
- this.uploadDialogUploadButtonText = (_e = config.uploadDialogUploadButtonText) !== null && _e !== void 0 ? _e : '';
35
- this.uploadDialogFinishButtonText = (_f = config.uploadDialogFinishButtonText) !== null && _f !== void 0 ? _f : '';
52
+ this.config = config;
53
+ this.config = Object.assign(Object.assign({}, defaultConfig), this.config);
36
54
  }
37
55
  upload(files) {
38
56
  // this will be the our resulting map
@@ -45,19 +63,23 @@ class UploadService {
45
63
  // tell it to report the upload progress
46
64
  // A 'Destination' header is used to optionally configure the file upload destination (filesystem)
47
65
  // A 'DbAppId' header is used to configure the unique identifier of database uploads
48
- const req = new HttpRequest('POST', this.uploadApiUrl, formData, {
66
+ const headers = new HttpHeaders();
67
+ if (this.config.uploadPath) {
68
+ headers.append('Destination', this.config.uploadPath);
69
+ }
70
+ if (this.config.dbAppId) {
71
+ headers.append('DbAppId', this.config.dbAppId);
72
+ }
73
+ if (this.config.externalReferenceId) {
74
+ headers.append('ExternalReferenceId', this.config.externalReferenceId);
75
+ }
76
+ if (this.config.comment) {
77
+ headers.append('Comment', this.config.comment);
78
+ }
79
+ const req = new HttpRequest('POST', this.config.apiUrl, formData, {
49
80
  reportProgress: true,
50
81
  responseType: 'blob',
51
- headers: new HttpHeaders()
52
- .set('Destination', this.uploadPath)
53
- .set('DbAppId', this.dbAppId)
54
- .set('ExternalReferenceId', this.externalReferenceId)
55
- .set('Comment', this.comment)
56
- /*headers: this.uploadPath ?
57
- new HttpHeaders({ 'Destination': this.uploadPath }) :
58
- this.dbAppId ?
59
- new HttpHeaders({ 'DbAppId': this.dbAppId }) :
60
- null*/
82
+ headers
61
83
  });
62
84
  // create a new progress-subject for every file
63
85
  const progress = new Subject();
@@ -85,16 +107,16 @@ class UploadService {
85
107
  return status;
86
108
  }
87
109
  exists(fileName) {
88
- const query = this.uploadApiUrl.toLowerCase().indexOf('filesystem') === -1 ?
89
- { name: fileName, dbAppId: this.dbAppId } :
90
- { name: fileName, destination: this.uploadPath };
91
- return this.http.post(`${this.uploadApiUrl}/exists`, query);
110
+ const query = this.config.apiUrl.toLowerCase().indexOf('filesystem') === -1 ?
111
+ { name: fileName, dbAppId: this.config.dbAppId } :
112
+ { name: fileName, destination: this.config.uploadPath };
113
+ return this.http.post(`${this.config.apiUrl}/exists`, query);
92
114
  }
93
115
  download(request) {
94
- return this.http.post(`${this.uploadApiUrl}/stream`, request, { responseType: 'blob' });
116
+ return this.http.post(`${this.config.apiUrl}/stream`, request, { responseType: 'blob' });
95
117
  }
96
118
  getUploadInfo(request) {
97
- return this.http.post(`${this.uploadApiUrl}/info`, request);
119
+ return this.http.post(`${this.config.apiUrl}/info`, request);
98
120
  }
99
121
  }
100
122
  UploadService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.0", ngImport: i0, type: UploadService, deps: [{ token: i1.HttpClient }, { token: ServiceConfig, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
@@ -114,18 +136,13 @@ class UploadDialogComponent {
114
136
  this.files = new Set();
115
137
  this.existingFileConflict = null;
116
138
  this.canBeClosed = true;
139
+ this.primaryButtonText = null;
117
140
  this.showCancelButton = true;
118
141
  this.uploading = false;
119
142
  this.uploadSuccessful = false;
120
143
  }
121
144
  ngOnInit() {
122
- var _a, _b, _c, _d, _e;
123
- this.uploadDialogTitle = (_a = this.uploadService.uploadDialogTitle) !== null && _a !== void 0 ? _a : 'Upload Files';
124
- this.uploadDialogAddFilesButtonText = (_b = this.uploadService.uploadDialogAddFilesButtonText) !== null && _b !== void 0 ? _b : 'Add Files';
125
- this.uploadDialogCancelButtonText = (_c = this.uploadService.uploadDialogCancelButtonText) !== null && _c !== void 0 ? _c : 'Cancel';
126
- this.uploadDialogUploadButtonText = (_d = this.uploadService.uploadDialogUploadButtonText) !== null && _d !== void 0 ? _d : 'Upload';
127
- this.uploadDialogFinishButtonText = (_e = this.uploadService.uploadDialogFinishButtonText) !== null && _e !== void 0 ? _e : 'Finish';
128
- this.primaryButtonText = this.uploadDialogUploadButtonText;
145
+ this.primaryButtonText = this.uploadService.config.uploadDialogUploadButtonText;
129
146
  }
130
147
  addFiles() {
131
148
  this.file.nativeElement.click();
@@ -163,7 +180,7 @@ class UploadDialogComponent {
163
180
  }
164
181
  // Adjust the state variables
165
182
  // The OK-button should have the text "Finish" now
166
- this.primaryButtonText = this.uploadDialogFinishButtonText;
183
+ this.primaryButtonText = this.uploadService.config.uploadDialogFinishButtonText;
167
184
  // The dialog should not be closed while uploading
168
185
  this.canBeClosed = false;
169
186
  this.dialogRef.disableClose = true;
@@ -182,10 +199,10 @@ class UploadDialogComponent {
182
199
  }
183
200
  }
184
201
  UploadDialogComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.0", ngImport: i0, type: UploadDialogComponent, deps: [{ token: i1$1.MatDialogRef }, { token: UploadService }], target: i0.ɵɵFactoryTarget.Component });
185
- UploadDialogComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.0", type: UploadDialogComponent, selector: "cp-upload-dialog", viewQueries: [{ propertyName: "file", first: true, predicate: ["file"], descendants: true, static: true }], ngImport: i0, template: "<input type=\"file\" #file style=\"display: none\" (change)=\"onFilesAdded()\" multiple />\n\n<div mat-dialog-title id=\"title\">\n <div>{{ uploadDialogTitle }}</div>\n <button [disabled]=\"uploading || uploadSuccessful\" mat-raised-button color=\"primary\" class=\"add-files-btn\" (click)=\"addFiles()\">\n {{ uploadDialogAddFilesButtonText }}\n </button>\n</div>\n\n<div id=\"conflict\" *ngIf=\"existingFileConflict\">\n {{ existingFileConflict }} already exists on the server and cannot be overwritten\n</div>\n\n<mat-dialog-content>\n <mat-list>\n <mat-list-item *ngFor=\"let file of files\">\n <h4 mat-line>{{file.name}}</h4>\n <mat-progress-bar *ngIf=\"progress\" mode=\"determinate\" [value]=\"progress[file.name].progress | async\"></mat-progress-bar>\n </mat-list-item>\n </mat-list>\n</mat-dialog-content>\n\n<mat-dialog-actions id=\"actions\">\n <button *ngIf=\"showCancelButton\" mat-button mat-dialog-close>{{ uploadDialogCancelButtonText }}</button>\n <button *ngIf=\"files.size > 0\" mat-raised-button color=\"primary\" [disabled]=\"!canBeClosed\" (click)=\"closeDialog()\">{{ primaryButtonText }}</button>\n</mat-dialog-actions>\n", styles: ["#title{display:flex;justify-content:space-between}#actions{display:flex;justify-content:flex-end}#conflict{font-size:.8em;color:red;margin-top:.5em}\n"], dependencies: [{ kind: "directive", type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1$1.MatDialogClose, selector: "[mat-dialog-close], [matDialogClose]", inputs: ["aria-label", "type", "mat-dialog-close", "matDialogClose"], exportAs: ["matDialogClose"] }, { kind: "directive", type: i1$1.MatDialogTitle, selector: "[mat-dialog-title], [matDialogTitle]", inputs: ["id"], exportAs: ["matDialogTitle"] }, { kind: "directive", type: i1$1.MatDialogContent, selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]" }, { kind: "directive", type: i1$1.MatDialogActions, selector: "[mat-dialog-actions], mat-dialog-actions, [matDialogActions]", inputs: ["align"] }, { kind: "component", type: i4.MatList, selector: "mat-list, mat-action-list", inputs: ["disableRipple", "disabled"], exportAs: ["matList"] }, { kind: "component", type: i4.MatListItem, selector: "mat-list-item, a[mat-list-item], button[mat-list-item]", inputs: ["disableRipple", "disabled"], exportAs: ["matListItem"] }, { kind: "directive", type: i5.MatLine, selector: "[mat-line], [matLine]" }, { kind: "component", type: i6.MatProgressBar, selector: "mat-progress-bar", inputs: ["color", "value", "bufferValue", "mode"], outputs: ["animationEnd"], exportAs: ["matProgressBar"] }, { kind: "pipe", type: i3.AsyncPipe, name: "async" }] });
202
+ UploadDialogComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.0", type: UploadDialogComponent, selector: "cp-upload-dialog", viewQueries: [{ propertyName: "file", first: true, predicate: ["file"], descendants: true, static: true }], ngImport: i0, template: "<input type=\"file\" #file style=\"display: none\" (change)=\"onFilesAdded()\" multiple />\n\n<div mat-dialog-title id=\"title\">\n <div>{{ uploadService.config.uploadDialogTitle }}</div>\n <button [disabled]=\"uploading || uploadSuccessful\" mat-raised-button color=\"primary\" class=\"add-files-btn\" (click)=\"addFiles()\">\n {{ uploadService.config.uploadDialogAddFilesButtonText }}\n </button>\n</div>\n\n<div id=\"conflict\" *ngIf=\"existingFileConflict\">\n {{ existingFileConflict }} already exists on the server and cannot be overwritten\n</div>\n\n<mat-dialog-content>\n <mat-list>\n <mat-list-item *ngFor=\"let file of files\">\n <h4 mat-line>{{file.name}}</h4>\n <mat-progress-bar *ngIf=\"progress\" mode=\"determinate\" [value]=\"progress[file.name].progress | async\"></mat-progress-bar>\n </mat-list-item>\n </mat-list>\n</mat-dialog-content>\n\n<mat-dialog-actions id=\"actions\">\n <button *ngIf=\"showCancelButton\" mat-button mat-dialog-close>{{ uploadService.config.uploadDialogCancelButtonText }}</button>\n <button *ngIf=\"files.size > 0\" mat-raised-button color=\"primary\" [disabled]=\"!canBeClosed\" (click)=\"closeDialog()\">{{ primaryButtonText }}</button>\n</mat-dialog-actions>\n", styles: ["#title{display:flex;justify-content:space-between}#actions{display:flex;justify-content:flex-end}#conflict{font-size:.8em;color:red;margin-top:.5em}\n"], dependencies: [{ kind: "directive", type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i4.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "directive", type: i1$1.MatDialogClose, selector: "[mat-dialog-close], [matDialogClose]", inputs: ["aria-label", "type", "mat-dialog-close", "matDialogClose"], exportAs: ["matDialogClose"] }, { kind: "directive", type: i1$1.MatDialogTitle, selector: "[mat-dialog-title], [matDialogTitle]", inputs: ["id"], exportAs: ["matDialogTitle"] }, { kind: "directive", type: i1$1.MatDialogContent, selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]" }, { kind: "directive", type: i1$1.MatDialogActions, selector: "[mat-dialog-actions], mat-dialog-actions, [matDialogActions]", inputs: ["align"] }, { kind: "component", type: i5.MatList, selector: "mat-list, mat-action-list", inputs: ["disableRipple", "disabled"], exportAs: ["matList"] }, { kind: "component", type: i5.MatListItem, selector: "mat-list-item, a[mat-list-item], button[mat-list-item]", inputs: ["disableRipple", "disabled"], exportAs: ["matListItem"] }, { kind: "directive", type: i6.MatLine, selector: "[mat-line], [matLine]" }, { kind: "component", type: i7.MatProgressBar, selector: "mat-progress-bar", inputs: ["color", "value", "bufferValue", "mode"], outputs: ["animationEnd"], exportAs: ["matProgressBar"] }, { kind: "pipe", type: i3.AsyncPipe, name: "async" }] });
186
203
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.0", ngImport: i0, type: UploadDialogComponent, decorators: [{
187
204
  type: Component,
188
- args: [{ selector: 'cp-upload-dialog', template: "<input type=\"file\" #file style=\"display: none\" (change)=\"onFilesAdded()\" multiple />\n\n<div mat-dialog-title id=\"title\">\n <div>{{ uploadDialogTitle }}</div>\n <button [disabled]=\"uploading || uploadSuccessful\" mat-raised-button color=\"primary\" class=\"add-files-btn\" (click)=\"addFiles()\">\n {{ uploadDialogAddFilesButtonText }}\n </button>\n</div>\n\n<div id=\"conflict\" *ngIf=\"existingFileConflict\">\n {{ existingFileConflict }} already exists on the server and cannot be overwritten\n</div>\n\n<mat-dialog-content>\n <mat-list>\n <mat-list-item *ngFor=\"let file of files\">\n <h4 mat-line>{{file.name}}</h4>\n <mat-progress-bar *ngIf=\"progress\" mode=\"determinate\" [value]=\"progress[file.name].progress | async\"></mat-progress-bar>\n </mat-list-item>\n </mat-list>\n</mat-dialog-content>\n\n<mat-dialog-actions id=\"actions\">\n <button *ngIf=\"showCancelButton\" mat-button mat-dialog-close>{{ uploadDialogCancelButtonText }}</button>\n <button *ngIf=\"files.size > 0\" mat-raised-button color=\"primary\" [disabled]=\"!canBeClosed\" (click)=\"closeDialog()\">{{ primaryButtonText }}</button>\n</mat-dialog-actions>\n", styles: ["#title{display:flex;justify-content:space-between}#actions{display:flex;justify-content:flex-end}#conflict{font-size:.8em;color:red;margin-top:.5em}\n"] }]
205
+ args: [{ selector: 'cp-upload-dialog', template: "<input type=\"file\" #file style=\"display: none\" (change)=\"onFilesAdded()\" multiple />\n\n<div mat-dialog-title id=\"title\">\n <div>{{ uploadService.config.uploadDialogTitle }}</div>\n <button [disabled]=\"uploading || uploadSuccessful\" mat-raised-button color=\"primary\" class=\"add-files-btn\" (click)=\"addFiles()\">\n {{ uploadService.config.uploadDialogAddFilesButtonText }}\n </button>\n</div>\n\n<div id=\"conflict\" *ngIf=\"existingFileConflict\">\n {{ existingFileConflict }} already exists on the server and cannot be overwritten\n</div>\n\n<mat-dialog-content>\n <mat-list>\n <mat-list-item *ngFor=\"let file of files\">\n <h4 mat-line>{{file.name}}</h4>\n <mat-progress-bar *ngIf=\"progress\" mode=\"determinate\" [value]=\"progress[file.name].progress | async\"></mat-progress-bar>\n </mat-list-item>\n </mat-list>\n</mat-dialog-content>\n\n<mat-dialog-actions id=\"actions\">\n <button *ngIf=\"showCancelButton\" mat-button mat-dialog-close>{{ uploadService.config.uploadDialogCancelButtonText }}</button>\n <button *ngIf=\"files.size > 0\" mat-raised-button color=\"primary\" [disabled]=\"!canBeClosed\" (click)=\"closeDialog()\">{{ primaryButtonText }}</button>\n</mat-dialog-actions>\n", styles: ["#title{display:flex;justify-content:space-between}#actions{display:flex;justify-content:flex-end}#conflict{font-size:.8em;color:red;margin-top:.5em}\n"] }]
189
206
  }], ctorParameters: function () { return [{ type: i1$1.MatDialogRef }, { type: UploadService }]; }, propDecorators: { file: [{
190
207
  type: ViewChild,
191
208
  args: ['file', { static: true }]
@@ -198,8 +215,8 @@ class UploadComponent {
198
215
  this.dialogClosed = new EventEmitter();
199
216
  }
200
217
  ngOnInit() {
201
- this.uploadButtonText = this.uploadService.uploadButtonText ?
202
- this.uploadService.uploadButtonText :
218
+ this.uploadButtonText = this.uploadService.config.uploadButtonText ?
219
+ this.uploadService.config.uploadButtonText :
203
220
  'Upload';
204
221
  }
205
222
  openUploadDialog() {
@@ -208,7 +225,7 @@ class UploadComponent {
208
225
  }
209
226
  }
210
227
  UploadComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.0", ngImport: i0, type: UploadComponent, deps: [{ token: i1$1.MatDialog }, { token: UploadService }], target: i0.ɵɵFactoryTarget.Component });
211
- UploadComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.0", type: UploadComponent, selector: "cp-upload", outputs: { dialogClosed: "dialogClosed" }, ngImport: i0, template: '<button mat-raised-button (click)="openUploadDialog()">{{ uploadButtonText }}</button>', isInline: true });
228
+ UploadComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.0", type: UploadComponent, selector: "cp-upload", outputs: { dialogClosed: "dialogClosed" }, ngImport: i0, template: '<button mat-raised-button (click)="openUploadDialog()">{{ uploadButtonText }}</button>', isInline: true, dependencies: [{ kind: "component", type: i4.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }] });
212
229
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.0", ngImport: i0, type: UploadComponent, decorators: [{
213
230
  type: Component,
214
231
  args: [{
@@ -238,11 +255,13 @@ class UploadModule {
238
255
  UploadModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.0", ngImport: i0, type: UploadModule, deps: [{ token: UploadModule, optional: true, skipSelf: true }], target: i0.ɵɵFactoryTarget.NgModule });
239
256
  UploadModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.0", ngImport: i0, type: UploadModule, declarations: [UploadComponent,
240
257
  UploadDialogComponent], imports: [CommonModule,
258
+ MatButtonModule,
241
259
  MatDialogModule,
242
260
  MatListModule,
243
261
  MatProgressBarModule], exports: [UploadComponent,
244
262
  UploadDialogComponent] });
245
263
  UploadModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.0", ngImport: i0, type: UploadModule, imports: [CommonModule,
264
+ MatButtonModule,
246
265
  MatDialogModule,
247
266
  MatListModule,
248
267
  MatProgressBarModule] });
@@ -255,6 +274,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.0", ngImpor
255
274
  ],
256
275
  imports: [
257
276
  CommonModule,
277
+ MatButtonModule,
258
278
  MatDialogModule,
259
279
  MatListModule,
260
280
  MatProgressBarModule
@@ -276,5 +296,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.0", ngImpor
276
296
  * Generated bundle index. Do not edit.
277
297
  */
278
298
 
279
- export { ServiceConfig, UploadComponent, UploadDialogComponent, UploadModule, UploadService };
299
+ export { ServiceConfig, UploadComponent, UploadDialogComponent, UploadModule, UploadService, defaultConfig };
280
300
  //# sourceMappingURL=cleavelandprice-ngx-lib-upload.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"cleavelandprice-ngx-lib-upload.mjs","sources":["../../../../projects/cleavelandprice/ngx-lib/upload/src/model/service-config.ts","../../../../projects/cleavelandprice/ngx-lib/upload/src/services/upload.service.ts","../../../../projects/cleavelandprice/ngx-lib/upload/src/components/upload-dialog/upload-dialog.component.ts","../../../../projects/cleavelandprice/ngx-lib/upload/src/components/upload-dialog/upload-dialog.component.html","../../../../projects/cleavelandprice/ngx-lib/upload/src/components/upload/upload.component.ts","../../../../projects/cleavelandprice/ngx-lib/upload/src/upload.module.ts","../../../../projects/cleavelandprice/ngx-lib/upload/src/cleavelandprice-ngx-lib-upload.ts"],"sourcesContent":["export class ServiceConfig {\r\n apiUrl!: string;\r\n uploadPath?: string;\r\n dbAppId?: string;\r\n externalReferenceId?: string;\r\n comment?: string;\r\n\r\n // UI configuration\r\n uploadButtonText?: string;\r\n uploadDialogTitle?: string;\r\n uploadDialogAddFilesButtonText?: string;\r\n uploadDialogCancelButtonText?: string;\r\n uploadDialogUploadButtonText?: string;\r\n uploadDialogFinishButtonText?: string;\r\n}\r\n","import { Injectable, Optional } from '@angular/core';\nimport { HttpClient, HttpRequest, HttpEventType, HttpResponse, HttpHeaders } from '@angular/common/http';\nimport { Subject , Observable } from 'rxjs';\nimport { ServiceConfig } from '../model/service-config';\nimport { FileUploadRequest } from '../model/file-upload-request';\nimport { DatabaseFileInfo } from '../model/database-file-info';\nimport { FilesystemFileInfo } from '../model/filesystem-file-info';\n\n// https://malcoded.com/posts/angular-file-upload-component-with-express\n\n@Injectable()\nexport class UploadService {\n public uploadApiUrl: string;\n public uploadPath: string;\n public dbAppId: string;\n public externalReferenceId: string;\n public comment: string;\n\n // UI configuration\n public uploadButtonText: string;\n public uploadDialogTitle: string;\n public uploadDialogAddFilesButtonText: string;\n public uploadDialogCancelButtonText: string;\n public uploadDialogUploadButtonText: string;\n public uploadDialogFinishButtonText: string;\n\n constructor(private http: HttpClient,\n @Optional() config: ServiceConfig) {\n this.uploadApiUrl = config.apiUrl;\n this.uploadPath = config.uploadPath || '';\n this.dbAppId = config.dbAppId || '';\n this.externalReferenceId = config.externalReferenceId || '';\n this.comment = config.comment || '';\n\n // UI configuration\n this.uploadButtonText = config.uploadButtonText ?? '';\n this.uploadDialogTitle = config.uploadDialogTitle ?? '';\n this.uploadDialogAddFilesButtonText = config.uploadDialogAddFilesButtonText ?? '';\n this.uploadDialogCancelButtonText = config.uploadDialogCancelButtonText ?? '';\n this.uploadDialogUploadButtonText = config.uploadDialogUploadButtonText ?? '';\n this.uploadDialogFinishButtonText = config.uploadDialogFinishButtonText ?? '';\n }\n\n public upload(files: Set<File>): any { // {[key: string]: Observable<number>} {\n // this will be the our resulting map\n const status: {[key: string]: {progress: Observable<number>}} = {};\n\n files.forEach(file => {\n // create a new multipart-form for every file\n const formData: FormData = new FormData();\n formData.append('file', file, file.name);\n\n // create a http-post request and pass the form\n // tell it to report the upload progress\n\n // A 'Destination' header is used to optionally configure the file upload destination (filesystem)\n // A 'DbAppId' header is used to configure the unique identifier of database uploads\n const req = new HttpRequest('POST', this.uploadApiUrl, formData, {\n reportProgress: true,\n responseType: 'blob',\n headers: new HttpHeaders()\n .set('Destination', this.uploadPath)\n .set('DbAppId', this.dbAppId)\n .set('ExternalReferenceId', this.externalReferenceId)\n .set('Comment', this.comment)\n /*headers: this.uploadPath ?\n new HttpHeaders({ 'Destination': this.uploadPath }) :\n this.dbAppId ?\n new HttpHeaders({ 'DbAppId': this.dbAppId }) :\n null*/\n });\n\n // create a new progress-subject for every file\n const progress = new Subject<number>();\n\n // send the http-request and subscribe for progress-updates\n this.http.request(req).subscribe(event => {\n if (event.type === HttpEventType.UploadProgress) {\n\n // calculate the progress percentage\n const percentDone = Math.round(100 * event.loaded / (event.total ?? 1));\n\n // pass the percentage into the progress-stream\n progress.next(percentDone);\n } else if (event instanceof HttpResponse) {\n\n // Close the progress-stream if we get an answer form the API\n // The upload is complete\n progress.complete();\n }\n });\n\n // Save every progress-observable in a map of all observables\n status[file.name] = {\n progress: progress.asObservable()\n };\n });\n\n // return the map of progress.observables\n return status;\n }\n\n public exists(fileName: string): Observable<boolean> {\n const query = this.uploadApiUrl.toLowerCase().indexOf('filesystem') === -1 ?\n { name: fileName, dbAppId: this.dbAppId } :\n { name: fileName, destination: this.uploadPath };\n\n return this.http.post<boolean>(`${this.uploadApiUrl}/exists`, query);\n }\n\n public download(request: FileUploadRequest): Observable<Blob> {\n return this.http.post(`${this.uploadApiUrl}/stream`, request, { responseType: 'blob' });\n }\n\n public getUploadInfo(request: FileUploadRequest):\n Observable<DatabaseFileInfo | DatabaseFileInfo[] | FilesystemFileInfo | FilesystemFileInfo[]> {\n return this.http.post<DatabaseFileInfo | DatabaseFileInfo[] | FilesystemFileInfo | FilesystemFileInfo[]>\n (`${this.uploadApiUrl}/info`, request);\n }\n}\n","import { Component, ElementRef, OnInit, ViewChild } from '@angular/core';\nimport { MatDialogRef } from '@angular/material/dialog';\nimport { UploadService } from './../../services/upload.service';\nimport { forkJoin } from 'rxjs';\n\n@Component({\n selector: 'cp-upload-dialog',\n templateUrl: './upload-dialog.component.html',\n styleUrls: ['./upload-dialog.component.css']\n})\nexport class UploadDialogComponent implements OnInit {\n @ViewChild('file', { static: true }) file!: ElementRef;\n public files: Set<File> = new Set();\n existingFileConflict: string | null = null;\n\n // State\n progress: any;\n canBeClosed = true;\n primaryButtonText!: string;\n showCancelButton = true;\n uploading = false;\n uploadSuccessful = false;\n\n // UI configuration\n uploadDialogTitle!: string;\n uploadDialogAddFilesButtonText!: string;\n uploadDialogCancelButtonText!: string;\n uploadDialogUploadButtonText!: string;\n uploadDialogFinishButtonText!: string;\n\n constructor(public dialogRef: MatDialogRef<UploadDialogComponent>, public uploadService: UploadService) { }\n\n ngOnInit() {\n this.uploadDialogTitle = this.uploadService.uploadDialogTitle ?? 'Upload Files';\n\n this.uploadDialogAddFilesButtonText = this.uploadService.uploadDialogAddFilesButtonText ?? 'Add Files';\n\n this.uploadDialogCancelButtonText = this.uploadService.uploadDialogCancelButtonText ?? 'Cancel';\n\n this.uploadDialogUploadButtonText = this.uploadService.uploadDialogUploadButtonText ?? 'Upload';\n\n this.uploadDialogFinishButtonText = this.uploadService.uploadDialogFinishButtonText ?? 'Finish';\n\n this.primaryButtonText = this.uploadDialogUploadButtonText;\n }\n\n addFiles() {\n this.file.nativeElement.click();\n }\n\n onFilesAdded() {\n const files: { [key: string]: File } = this.file.nativeElement.files;\n for (const key in files) {\n if (!isNaN(parseInt(key))) {\n // See if the file already exists\n this.uploadService.exists(files[key].name)\n .subscribe(exists => {\n if (exists) {\n this.existingFileConflict = files[key].name;\n }\n\n if (!exists) {\n this.files.add(files[key]);\n }\n });\n }\n }\n }\n\n closeDialog() {\n // if everything was uploaded already, just close the dialog\n if (this.uploadSuccessful) {\n return this.dialogRef.close();\n }\n\n // set the component state to \"uploading\"\n this.uploading = true;\n\n // start the upload and save the progress map\n this.progress = this.uploadService.upload(this.files);\n\n // convert the progress map into an array\n const allProgressObservables = [];\n\n for (let key in this.progress) {\n allProgressObservables.push(this.progress[key].progress);\n }\n\n // Adjust the state variables\n\n // The OK-button should have the text \"Finish\" now\n this.primaryButtonText = this.uploadDialogFinishButtonText;\n\n // The dialog should not be closed while uploading\n this.canBeClosed = false;\n this.dialogRef.disableClose = true;\n\n // Hide the cancel-button\n this.showCancelButton = false;\n\n // When all progress-observables are completed...\n forkJoin(allProgressObservables).subscribe(end => {\n // ... the dialog can be closed again...\n this.canBeClosed = true;\n this.dialogRef.disableClose = false;\n\n // ... the upload was successful...\n this.uploadSuccessful = true;\n\n // ... and the component is no longer uploading\n this.uploading = false;\n });\n }\n}\n","<input type=\"file\" #file style=\"display: none\" (change)=\"onFilesAdded()\" multiple />\n\n<div mat-dialog-title id=\"title\">\n <div>{{ uploadDialogTitle }}</div>\n <button [disabled]=\"uploading || uploadSuccessful\" mat-raised-button color=\"primary\" class=\"add-files-btn\" (click)=\"addFiles()\">\n {{ uploadDialogAddFilesButtonText }}\n </button>\n</div>\n\n<div id=\"conflict\" *ngIf=\"existingFileConflict\">\n {{ existingFileConflict }} already exists on the server and cannot be overwritten\n</div>\n\n<mat-dialog-content>\n <mat-list>\n <mat-list-item *ngFor=\"let file of files\">\n <h4 mat-line>{{file.name}}</h4>\n <mat-progress-bar *ngIf=\"progress\" mode=\"determinate\" [value]=\"progress[file.name].progress | async\"></mat-progress-bar>\n </mat-list-item>\n </mat-list>\n</mat-dialog-content>\n\n<mat-dialog-actions id=\"actions\">\n <button *ngIf=\"showCancelButton\" mat-button mat-dialog-close>{{ uploadDialogCancelButtonText }}</button>\n <button *ngIf=\"files.size > 0\" mat-raised-button color=\"primary\" [disabled]=\"!canBeClosed\" (click)=\"closeDialog()\">{{ primaryButtonText }}</button>\n</mat-dialog-actions>\n","import { Component, OnInit, Output, EventEmitter } from '@angular/core';\nimport { MatDialog } from '@angular/material/dialog';\nimport { UploadDialogComponent } from './../upload-dialog/upload-dialog.component';\nimport { UploadService } from './../../services/upload.service';\n\n@Component({\n selector: 'cp-upload',\n template: '<button mat-raised-button (click)=\"openUploadDialog()\">{{ uploadButtonText }}</button>'\n})\nexport class UploadComponent implements OnInit {\n @Output() dialogClosed = new EventEmitter();\n uploadButtonText!: string;\n\n constructor(public dialog: MatDialog, public uploadService: UploadService) { }\n\n ngOnInit(): void {\n this.uploadButtonText = this.uploadService.uploadButtonText ?\n this.uploadService.uploadButtonText :\n 'Upload';\n }\n\n public openUploadDialog() {\n this.dialog.open(UploadDialogComponent, { width: '50%' })\n .afterClosed().subscribe(() => this.dialogClosed.emit());\n }\n}\n","import { ModuleWithProviders, NgModule, Optional, SkipSelf } from '@angular/core';\nimport { CommonModule } from '@angular/common';\n\nimport { MatDialogModule } from '@angular/material/dialog';\nimport { MatListModule } from '@angular/material/list';\nimport { MatProgressBarModule } from '@angular/material/progress-bar';\n\nimport { UploadComponent } from './components/upload/upload.component';\nimport { UploadDialogComponent } from './components/upload-dialog/upload-dialog.component';\nimport { ServiceConfig } from './model/service-config';\nimport { UploadService } from './services/upload.service';\n\n@NgModule({\n declarations: [\n UploadComponent,\n UploadDialogComponent\n ],\n imports: [\n CommonModule,\n MatDialogModule,\n MatListModule,\n MatProgressBarModule\n ],\n exports: [\n UploadComponent,\n UploadDialogComponent\n ]\n})\nexport class UploadModule {\n static forRoot(uploadConfig: ServiceConfig): ModuleWithProviders<UploadModule> {\n return {\n ngModule: UploadModule,\n providers: [\n UploadService,\n { provide: ServiceConfig, useValue: uploadConfig }\n ]\n };\n }\n\n constructor(@Optional() @SkipSelf() parentModule: UploadModule) {\n if (parentModule) {\n throw new Error(\n 'UploadModule is already loaded. Import it in the AppModule only');\n }\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":["i2.ServiceConfig","i1","i2.UploadService"],"mappings":";;;;;;;;;;;;;;;MAAa,aAAa,CAAA;AAczB;;ACND;MAGa,aAAa,CAAA;IAexB,WAAoB,CAAA,IAAgB,EACtB,MAAqB,EAAA;;AADf,QAAA,IAAI,CAAA,IAAA,GAAJ,IAAI,CAAY;AAEhC,QAAA,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC;QAClC,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,IAAI,EAAE,CAAC;QAC1C,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC;QACpC,IAAI,CAAC,mBAAmB,GAAG,MAAM,CAAC,mBAAmB,IAAI,EAAE,CAAC;QAC5D,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC;;QAGpC,IAAI,CAAC,gBAAgB,GAAG,CAAA,EAAA,GAAA,MAAM,CAAC,gBAAgB,MAAI,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAA,EAAE,CAAC;QACtD,IAAI,CAAC,iBAAiB,GAAG,CAAA,EAAA,GAAA,MAAM,CAAC,iBAAiB,MAAI,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAA,EAAE,CAAC;QACxD,IAAI,CAAC,8BAA8B,GAAG,CAAA,EAAA,GAAA,MAAM,CAAC,8BAA8B,MAAI,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAA,EAAE,CAAC;QAClF,IAAI,CAAC,4BAA4B,GAAG,CAAA,EAAA,GAAA,MAAM,CAAC,4BAA4B,MAAI,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAA,EAAE,CAAC;QAC9E,IAAI,CAAC,4BAA4B,GAAG,CAAA,EAA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O,EAAE;wBACP,eAAe;wBACf,qBAAqB;AACtB,qBAAA;iBACF,CAAA;;wBAYqD,YAAY,EAAA,UAAA,EAAA,CAAA;8BAAjD,QAAQ;;8BAAI,QAAQ;;;;ACvCrC;;AAEG;;;;"}
1
+ {"version":3,"file":"cleavelandprice-ngx-lib-upload.mjs","sources":["../../../../projects/cleavelandprice/ngx-lib/upload/src/model/default-config.ts","../../../../projects/cleavelandprice/ngx-lib/upload/src/model/service-config.ts","../../../../projects/cleavelandprice/ngx-lib/upload/src/services/upload.service.ts","../../../../projects/cleavelandprice/ngx-lib/upload/src/components/upload-dialog/upload-dialog.component.ts","../../../../projects/cleavelandprice/ngx-lib/upload/src/components/upload-dialog/upload-dialog.component.html","../../../../projects/cleavelandprice/ngx-lib/upload/src/components/upload/upload.component.ts","../../../../projects/cleavelandprice/ngx-lib/upload/src/upload.module.ts","../../../../projects/cleavelandprice/ngx-lib/upload/src/cleavelandprice-ngx-lib-upload.ts"],"sourcesContent":["import { ServiceConfig } from \"./service-config\";\r\n\r\nexport const defaultConfig: ServiceConfig = {\r\n apiUrl: 'http://utilityapi/upload/database',\r\n uploadDialogTitle: 'Upload Files',\r\n uploadPath: null,\r\n comment: null,\r\n dbAppId: null,\r\n externalReferenceId: null,\r\n \r\n uploadButtonText: 'Upload',\r\n uploadDialogCancelButtonText: 'Cancel',\r\n uploadDialogFinishButtonText: 'Finish',\r\n uploadDialogUploadButtonText: 'Upload',\r\n uploadDialogAddFilesButtonText: 'Add Files'\r\n}","export class ServiceConfig {\r\n apiUrl!: string;\r\n uploadPath: string | null = null;\r\n dbAppId: string | null = null;\r\n externalReferenceId: string | null = null;\r\n comment: string | null = null;\r\n\r\n // UI configuration\r\n uploadButtonText: string | null = null;\r\n uploadDialogTitle: string | null = null;\r\n uploadDialogAddFilesButtonText: string | null = null;\r\n uploadDialogCancelButtonText: string | null = null;\r\n uploadDialogUploadButtonText: string | null = null;\r\n uploadDialogFinishButtonText: string | null = null;\r\n}\r\n","import { Injectable, Optional } from '@angular/core';\nimport { HttpClient, HttpRequest, HttpEventType, HttpResponse, HttpHeaders } from '@angular/common/http';\nimport { Subject , Observable } from 'rxjs';\nimport { ServiceConfig } from '../model/service-config';\nimport { FileUploadRequest } from '../model/file-upload-request';\nimport { DatabaseFileInfo } from '../model/database-file-info';\nimport { FilesystemFileInfo } from '../model/filesystem-file-info';\nimport { defaultConfig } from '../model/default-config';\n\n// https://malcoded.com/posts/angular-file-upload-component-with-express\n\n@Injectable()\nexport class UploadService {\n constructor(private http: HttpClient,\n @Optional() public config: ServiceConfig) {\n this.config = {\n ...defaultConfig,\n ...this.config\n };\n }\n\n public upload(files: Set<File>): any { // {[key: string]: Observable<number>} {\n // this will be the our resulting map\n const status: {[key: string]: {progress: Observable<number>}} = {};\n\n files.forEach(file => {\n // create a new multipart-form for every file\n const formData: FormData = new FormData();\n formData.append('file', file, file.name);\n\n // create a http-post request and pass the form\n // tell it to report the upload progress\n\n // A 'Destination' header is used to optionally configure the file upload destination (filesystem)\n // A 'DbAppId' header is used to configure the unique identifier of database uploads\n \n const headers = new HttpHeaders();\n if (this.config.uploadPath) {\n headers.append('Destination', this.config.uploadPath);\n }\n if (this.config.dbAppId) {\n headers.append('DbAppId', this.config.dbAppId);\n }\n if (this.config.externalReferenceId) {\n headers.append('ExternalReferenceId', this.config.externalReferenceId);\n }\n if (this.config.comment) {\n headers.append('Comment', this.config.comment);\n }\n const req = new HttpRequest('POST', this.config.apiUrl, formData, {\n reportProgress: true,\n responseType: 'blob',\n headers\n });\n\n // create a new progress-subject for every file\n const progress = new Subject<number>();\n\n // send the http-request and subscribe for progress-updates\n this.http.request(req).subscribe(event => {\n if (event.type === HttpEventType.UploadProgress) {\n\n // calculate the progress percentage\n const percentDone = Math.round(100 * event.loaded / (event.total ?? 1));\n\n // pass the percentage into the progress-stream\n progress.next(percentDone);\n } else if (event instanceof HttpResponse) {\n\n // Close the progress-stream if we get an answer form the API\n // The upload is complete\n progress.complete();\n }\n });\n\n // Save every progress-observable in a map of all observables\n status[file.name] = {\n progress: progress.asObservable()\n };\n });\n\n // return the map of progress.observables\n return status;\n }\n\n public exists(fileName: string): Observable<boolean> {\n const query = this.config.apiUrl.toLowerCase().indexOf('filesystem') === -1 ?\n { name: fileName, dbAppId: this.config.dbAppId } :\n { name: fileName, destination: this.config.uploadPath };\n\n return this.http.post<boolean>(`${this.config.apiUrl}/exists`, query);\n }\n\n public download(request: FileUploadRequest): Observable<Blob> {\n return this.http.post(`${this.config.apiUrl}/stream`, request, { responseType: 'blob' });\n }\n\n public getUploadInfo(request: FileUploadRequest):\n Observable<DatabaseFileInfo | DatabaseFileInfo[] | FilesystemFileInfo | FilesystemFileInfo[]> {\n return this.http.post<DatabaseFileInfo | DatabaseFileInfo[] | FilesystemFileInfo | FilesystemFileInfo[]>\n (`${this.config.apiUrl}/info`, request);\n }\n}\n","import { Component, ElementRef, OnInit, ViewChild } from '@angular/core';\nimport { MatDialogRef } from '@angular/material/dialog';\nimport { UploadService } from './../../services/upload.service';\nimport { forkJoin } from 'rxjs';\n\n@Component({\n selector: 'cp-upload-dialog',\n templateUrl: './upload-dialog.component.html',\n styleUrls: ['./upload-dialog.component.css']\n})\nexport class UploadDialogComponent implements OnInit {\n @ViewChild('file', { static: true }) file!: ElementRef;\n public files: Set<File> = new Set();\n existingFileConflict: string | null = null;\n\n // State\n progress: any;\n canBeClosed = true;\n primaryButtonText: string | null = null;\n showCancelButton = true;\n uploading = false;\n uploadSuccessful = false;\n \n constructor(public dialogRef: MatDialogRef<UploadDialogComponent>, public uploadService: UploadService) { }\n\n ngOnInit() {\n this.primaryButtonText = this.uploadService.config.uploadDialogUploadButtonText;\n }\n\n addFiles() {\n this.file.nativeElement.click();\n }\n\n onFilesAdded() {\n const files: { [key: string]: File } = this.file.nativeElement.files;\n for (const key in files) {\n if (!isNaN(parseInt(key))) {\n // See if the file already exists\n this.uploadService.exists(files[key].name)\n .subscribe(exists => {\n if (exists) {\n this.existingFileConflict = files[key].name;\n }\n\n if (!exists) {\n this.files.add(files[key]);\n }\n });\n }\n }\n }\n\n closeDialog() {\n // if everything was uploaded already, just close the dialog\n if (this.uploadSuccessful) {\n return this.dialogRef.close();\n }\n\n // set the component state to \"uploading\"\n this.uploading = true;\n\n // start the upload and save the progress map\n this.progress = this.uploadService.upload(this.files);\n\n // convert the progress map into an array\n const allProgressObservables = [];\n\n for (let key in this.progress) {\n allProgressObservables.push(this.progress[key].progress);\n }\n\n // Adjust the state variables\n\n // The OK-button should have the text \"Finish\" now\n this.primaryButtonText = this.uploadService.config.uploadDialogFinishButtonText;\n\n // The dialog should not be closed while uploading\n this.canBeClosed = false;\n this.dialogRef.disableClose = true;\n\n // Hide the cancel-button\n this.showCancelButton = false;\n\n // When all progress-observables are completed...\n forkJoin(allProgressObservables).subscribe(end => {\n // ... the dialog can be closed again...\n this.canBeClosed = true;\n this.dialogRef.disableClose = false;\n\n // ... the upload was successful...\n this.uploadSuccessful = true;\n\n // ... and the component is no longer uploading\n this.uploading = false;\n });\n }\n}\n","<input type=\"file\" #file style=\"display: none\" (change)=\"onFilesAdded()\" multiple />\n\n<div mat-dialog-title id=\"title\">\n <div>{{ uploadService.config.uploadDialogTitle }}</div>\n <button [disabled]=\"uploading || uploadSuccessful\" mat-raised-button color=\"primary\" class=\"add-files-btn\" (click)=\"addFiles()\">\n {{ uploadService.config.uploadDialogAddFilesButtonText }}\n </button>\n</div>\n\n<div id=\"conflict\" *ngIf=\"existingFileConflict\">\n {{ existingFileConflict }} already exists on the server and cannot be overwritten\n</div>\n\n<mat-dialog-content>\n <mat-list>\n <mat-list-item *ngFor=\"let file of files\">\n <h4 mat-line>{{file.name}}</h4>\n <mat-progress-bar *ngIf=\"progress\" mode=\"determinate\" [value]=\"progress[file.name].progress | async\"></mat-progress-bar>\n </mat-list-item>\n </mat-list>\n</mat-dialog-content>\n\n<mat-dialog-actions id=\"actions\">\n <button *ngIf=\"showCancelButton\" mat-button mat-dialog-close>{{ uploadService.config.uploadDialogCancelButtonText }}</button>\n <button *ngIf=\"files.size > 0\" mat-raised-button color=\"primary\" [disabled]=\"!canBeClosed\" (click)=\"closeDialog()\">{{ primaryButtonText }}</button>\n</mat-dialog-actions>\n","import { Component, OnInit, Output, EventEmitter } from '@angular/core';\nimport { MatDialog } from '@angular/material/dialog';\nimport { UploadDialogComponent } from './../upload-dialog/upload-dialog.component';\nimport { UploadService } from './../../services/upload.service';\n\n@Component({\n selector: 'cp-upload',\n template: '<button mat-raised-button (click)=\"openUploadDialog()\">{{ uploadButtonText }}</button>'\n})\nexport class UploadComponent implements OnInit {\n @Output() dialogClosed = new EventEmitter();\n uploadButtonText!: string;\n\n constructor(public dialog: MatDialog, public uploadService: UploadService) { }\n\n ngOnInit(): void {\n this.uploadButtonText = this.uploadService.config.uploadButtonText ?\n this.uploadService.config.uploadButtonText :\n 'Upload';\n }\n\n public openUploadDialog() {\n this.dialog.open(UploadDialogComponent, { width: '50%' })\n .afterClosed().subscribe(() => this.dialogClosed.emit());\n }\n}\n","import { ModuleWithProviders, NgModule, Optional, SkipSelf } from '@angular/core';\nimport { CommonModule } from '@angular/common';\n\nimport { MatButtonModule } from '@angular/material/button';\nimport { MatDialogModule } from '@angular/material/dialog';\nimport { MatListModule } from '@angular/material/list';\nimport { MatProgressBarModule } from '@angular/material/progress-bar';\n\nimport { UploadComponent } from './components/upload/upload.component';\nimport { UploadDialogComponent } from './components/upload-dialog/upload-dialog.component';\nimport { ServiceConfig } from './model/service-config';\nimport { UploadService } from './services/upload.service';\n\n@NgModule({\n declarations: [\n UploadComponent,\n UploadDialogComponent\n ],\n imports: [\n CommonModule,\n MatButtonModule,\n MatDialogModule,\n MatListModule,\n MatProgressBarModule\n ],\n exports: [\n UploadComponent,\n UploadDialogComponent\n ]\n})\nexport class UploadModule {\n static forRoot(uploadConfig: ServiceConfig): ModuleWithProviders<UploadModule> {\n return {\n ngModule: UploadModule,\n providers: [\n UploadService,\n { provide: ServiceConfig, useValue: uploadConfig }\n ]\n };\n }\n\n constructor(@Optional() @SkipSelf() parentModule: UploadModule) {\n if (parentModule) {\n throw new Error(\n 'UploadModule is already loaded. Import it in the AppModule only');\n }\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":["i2.ServiceConfig","i1","i2.UploadService","i3"],"mappings":";;;;;;;;;;;;;;;;;AAEa,MAAA,aAAa,GAAkB;AACxC,IAAA,MAAM,EAAE,mCAAmC;AAC3C,IAAA,iBAAiB,EAAE,cAAc;AACjC,IAAA,UAAU,EAAE,IAAI;AAChB,IAAA,OAAO,EAAE,IAAI;AACb,IAAA,OAAO,EAAE,IAAI;AACb,IAAA,mBAAmB,EAAE,IAAI;AAEzB,IAAA,gBAAgB,EAAE,QAAQ;AAC1B,IAAA,4BAA4B,EAAE,QAAQ;AACtC,IAAA,4BAA4B,EAAE,QAAQ;AACtC,IAAA,4BAA4B,EAAE,QAAQ;AACtC,IAAA,8BAA8B,EAAE,WAAW;;;MCdlC,aAAa,CAAA;AAA1B,IAAA,WAAA,GAAA;AAEI,QAAA,IAAU,CAAA,UAAA,GAAkB,IAAI,CAAC;AACjC,QAAA,IAAO,CAAA,OAAA,GAAkB,IAAI,CAAC;AAC9B,QAAA,IAAmB,CAAA,mBAAA,GAAkB,IAAI,CAAC;AAC1C,QAAA,IAAO,CAAA,OAAA,GAAkB,IAAI,CAAC;;AAG9B,QAAA,IAAgB,CAAA,gBAAA,GAAkB,IAAI,CAAC;AACvC,QAAA,IAAiB,CAAA,iBAAA,GAAkB,IAAI,CAAC;AACxC,QAAA,IAA8B,CAAA,8BAAA,GAAkB,IAAI,CAAC;AACrD,QAAA,IAA4B,CAAA,4BAAA,GAAkB,IAAI,CAAC;AACnD,QAAA,IAA4B,CAAA,4BAAA,GAAkB,IAAI,CAAC;AACnD,QAAA,IAA4B,CAAA,4BAAA,GAAkB,IAAI,CAAC;KACtD;AAAA;;ACLD;MAGa,aAAa,CAAA;IACxB,WAAoB,CAAA,IAAgB,EACf,MAAqB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;kBAjBxB,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,YAAY,EAAE;wBACZ,eAAe;wBACf,qBAAqB;AACtB,qBAAA;AACD,oBAAA,OAAO,EAAE;wBACP,YAAY;wBACZ,eAAe;wBACf,eAAe;wBACf,aAAa;wBACb,oBAAoB;AACrB,qBAAA;AACD,oBAAA,OAAO,EAAE;wBACP,eAAe;wBACf,qBAAqB;AACtB,qBAAA;iBACF,CAAA;;wBAYqD,YAAY,EAAA,UAAA,EAAA,CAAA;8BAAjD,QAAQ;;8BAAI,QAAQ;;;;ACzCrC;;AAEG;;;;"}
@@ -11,10 +11,9 @@ const defaultConfig = {
11
11
 
12
12
  class AppPathConfigService {
13
13
  constructor(config, http) {
14
- var _a;
15
14
  this.config = config;
16
15
  this.http = http;
17
- this.config = (_a = this.config) !== null && _a !== void 0 ? _a : defaultConfig;
16
+ this.config = Object.assign(Object.assign({}, defaultConfig), this.config);
18
17
  this.url = `${this.config.apiUrl}/apppathconfigs`;
19
18
  }
20
19
  getAll() {
@@ -1 +1 @@
1
- {"version":3,"file":"cleavelandprice-ngx-lib.mjs","sources":["../../../../projects/cleavelandprice/ngx-lib/src/lib/model/service-config.ts","../../../../projects/cleavelandprice/ngx-lib/src/lib/model/default-config.ts","../../../../projects/cleavelandprice/ngx-lib/src/lib/services/app-path-config.service.ts","../../../../projects/cleavelandprice/ngx-lib/src/lib/ngx-lib.module.ts","../../../../projects/cleavelandprice/ngx-lib/src/public_api.ts","../../../../projects/cleavelandprice/ngx-lib/src/cleavelandprice-ngx-lib.ts"],"sourcesContent":["export class ServiceConfig {\r\n apiUrl!: string;\r\n}","import { ServiceConfig } from \"./service-config\";\r\n\r\nexport const defaultConfig: ServiceConfig = {\r\n apiUrl: 'http://utilityapi'\r\n}","import { HttpClient } from '@angular/common/http';\nimport { Injectable, Optional } from '@angular/core';\nimport { Observable } from 'rxjs';\nimport { AppPathConfig } from '../model/app-path-config';\n\nimport { defaultConfig } from '../model/default-config';\nimport { ServiceConfig } from '../model/service-config';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class AppPathConfigService {\n url!: string;\n\n constructor(@Optional() private config: ServiceConfig,\n private http: HttpClient) {\n\n this.config = this.config ?? defaultConfig;\n this.url = `${this.config.apiUrl}/apppathconfigs`\n }\n\n getAll(): Observable<AppPathConfig[]> {\n return this.http.get<AppPathConfig[]>(this.url);\n }\n\n getById(id: number): Observable<AppPathConfig> {\n return this.http.get<AppPathConfig>(`${this.url}/${id}`);\n }\n\n getByAppId(id: number): Observable<AppPathConfig[]> {\n return this.http.get<AppPathConfig[]>(`${this.url}/appid/${id}`);\n }\n\n getByApp(name: string): Observable<AppPathConfig[]> {\n return this.http.get<AppPathConfig[]>(`${this.url}/app/${name}`);\n }\n\n getByAppTypeId(id: number): Observable<AppPathConfig[]> {\n return this.http.get<AppPathConfig[]>(`${this.url}/apptypeid/${id}`);\n }\n\n getByAppType(name: string): Observable<AppPathConfig[]> {\n return this.http.get<AppPathConfig[]>(`${this.url}/apptype/${name}`);\n }\n\n getByAppFunction(name: string): Observable<AppPathConfig[]> {\n return this.http.get<AppPathConfig[]>(`${this.url}/function/${name}`);\n }\n}\n","import { ModuleWithProviders, NgModule, Optional, SkipSelf } from '@angular/core';\nimport { AppPathConfigService } from '../public_api';\nimport { ServiceConfig } from './model/service-config';\n\n@NgModule({\n declarations: [\n ],\n imports: [\n ],\n exports: [\n ]\n})\nexport class NgxLibModule {\n static forRoot(config: ServiceConfig): ModuleWithProviders<NgxLibModule> {\n return {\n ngModule: NgxLibModule,\n providers: [\n AppPathConfigService,\n { provide: ServiceConfig, useValue: config }\n ]\n };\n }\n\n constructor( @Optional() @SkipSelf() parentModule: NgxLibModule) {\n if (parentModule) {\n throw new Error(\n 'NgxLibModule is already loaded. Import it in the AppModule only');\n }\n }\n}","/*\n * Public API Surface of ngx-lib\n */\n\nexport * from './lib/model/app';\nexport * from './lib/model/app-path-config';\nexport * from './lib/model/app-type';\nexport * from './lib/model/service-config';\n\nexport * from './lib/services/app-path-config.service';\n\nexport * from './lib/ngx-lib.module';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":["i1.ServiceConfig"],"mappings":";;;;MAAa,aAAa,CAAA;AAEzB;;ACAM,MAAM,aAAa,GAAkB;AACxC,IAAA,MAAM,EAAE,mBAAmB;CAC9B;;MCOY,oBAAoB,CAAA;IAG/B,WAAgC,CAAA,MAAqB,EACjC,IAAgB,EAAA;;AADJ,QAAA,IAAM,CAAA,MAAA,GAAN,MAAM,CAAe;AACjC,QAAA,IAAI,CAAA,IAAA,GAAJ,IAAI,CAAY;QAEtB,IAAI,CAAC,MAAM,GAAG,CAAA,EAAA,GAAA,IAAI,CAAC,MAAM,MAAI,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAA,aAAa,CAAC;QAC3C,IAAI,CAAC,GAAG,GAAG,CAAG,EAAA,IAAI,CAAC,MAAM,CAAC,MAAM,CAAA,eAAA,CAAiB,CAAA;KAC9D;IAED,MAAM,GAAA;QACJ,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAkB,IAAI,CAAC,GAAG,CAAC,CAAC;KACjD;AAED,IAAA,OAAO,CAAC,EAAU,EAAA;AAChB,QAAA,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAgB,CAAA,EAAG,IAAI,CAAC,GAAG,CAAA,CAAA,EAAI,EAAE,CAAA,CAAE,CAAC,CAAC;KAC1D;AAED,IAAA,UAAU,CAAC,EAAU,EAAA;AACnB,QAAA,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAkB,CAAA,EAAG,IAAI,CAAC,GAAG,CAAA,OAAA,EAAU,EAAE,CAAA,CAAE,CAAC,CAAC;KAClE;AAED,IAAA,QAAQ,CAAC,IAAY,EAAA;AACnB,QAAA,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAkB,CAAA,EAAG,IAAI,CAAC,GAAG,CAAA,KAAA,EAA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AAK,CACb,iEAAiE,CAAC,CAAC;AACtE,SAAA;KACF;IAfD,OAAO,OAAO,CAAC,MAAqB,EAAA;QAClC,OAAO;AACL,YAAA,QAAQ,EAAE,YAAY;AACtB,YAAA,SAAS,EAAE;gBACT,oBAAoB;AACpB,gBAAA,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAE;AAC7C,aAAA;SACF,CAAC;KACH;;AATU,YAAA,CAAA,IAAA,GAAA,EAAA,CAAA,kBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,YAAY,kBAW4B,YAAY,EAAA,QAAA,EAAA,IAAA,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;0GAXpD,YAAY,EAAA,CAAA,CAAA;0GAAZ,YAAY,EAAA,CAAA,CAAA;2FAAZ,YAAY,EAAA,UAAA,EAAA,CAAA;kBARxB,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,YAAY,EAAE,EACb;AACD,oBAAA,OAAO,EAAE,EACR;AACD,oBAAA,OAAO,EAAE,EACR;iBACF,CAAA;;wBAYoD,YAAY,EAAA,UAAA,EAAA,CAAA;8BAAjD,QAAQ;;8BAAI,QAAQ;;;;ACvBpC;;AAEG;;ACFH;;AAEG;;;;"}
1
+ {"version":3,"file":"cleavelandprice-ngx-lib.mjs","sources":["../../../../projects/cleavelandprice/ngx-lib/src/lib/model/service-config.ts","../../../../projects/cleavelandprice/ngx-lib/src/lib/model/default-config.ts","../../../../projects/cleavelandprice/ngx-lib/src/lib/services/app-path-config.service.ts","../../../../projects/cleavelandprice/ngx-lib/src/lib/ngx-lib.module.ts","../../../../projects/cleavelandprice/ngx-lib/src/public_api.ts","../../../../projects/cleavelandprice/ngx-lib/src/cleavelandprice-ngx-lib.ts"],"sourcesContent":["export class ServiceConfig {\r\n apiUrl!: string;\r\n}","import { ServiceConfig } from \"./service-config\";\r\n\r\nexport const defaultConfig: ServiceConfig = {\r\n apiUrl: 'http://utilityapi'\r\n}","import { HttpClient } from '@angular/common/http';\nimport { Injectable, Optional } from '@angular/core';\nimport { Observable } from 'rxjs';\nimport { AppPathConfig } from '../model/app-path-config';\n\nimport { defaultConfig } from '../model/default-config';\nimport { ServiceConfig } from '../model/service-config';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class AppPathConfigService {\n url!: string;\n\n constructor(@Optional() private config: ServiceConfig,\n private http: HttpClient) {\n\n this.config = {\n ...defaultConfig,\n ...this.config\n };\n \n this.url = `${this.config.apiUrl}/apppathconfigs`\n }\n\n getAll(): Observable<AppPathConfig[]> {\n return this.http.get<AppPathConfig[]>(this.url);\n }\n\n getById(id: number): Observable<AppPathConfig> {\n return this.http.get<AppPathConfig>(`${this.url}/${id}`);\n }\n\n getByAppId(id: number): Observable<AppPathConfig[]> {\n return this.http.get<AppPathConfig[]>(`${this.url}/appid/${id}`);\n }\n\n getByApp(name: string): Observable<AppPathConfig[]> {\n return this.http.get<AppPathConfig[]>(`${this.url}/app/${name}`);\n }\n\n getByAppTypeId(id: number): Observable<AppPathConfig[]> {\n return this.http.get<AppPathConfig[]>(`${this.url}/apptypeid/${id}`);\n }\n\n getByAppType(name: string): Observable<AppPathConfig[]> {\n return this.http.get<AppPathConfig[]>(`${this.url}/apptype/${name}`);\n }\n\n getByAppFunction(name: string): Observable<AppPathConfig[]> {\n return this.http.get<AppPathConfig[]>(`${this.url}/function/${name}`);\n }\n}\n","import { ModuleWithProviders, NgModule, Optional, SkipSelf } from '@angular/core';\nimport { AppPathConfigService } from '../public_api';\nimport { ServiceConfig } from './model/service-config';\n\n@NgModule({\n declarations: [\n ],\n imports: [\n ],\n exports: [\n ]\n})\nexport class NgxLibModule {\n static forRoot(config: ServiceConfig): ModuleWithProviders<NgxLibModule> {\n return {\n ngModule: NgxLibModule,\n providers: [\n AppPathConfigService,\n { provide: ServiceConfig, useValue: config }\n ]\n };\n }\n\n constructor( @Optional() @SkipSelf() parentModule: NgxLibModule) {\n if (parentModule) {\n throw new Error(\n 'NgxLibModule is already loaded. Import it in the AppModule only');\n }\n }\n}","/*\n * Public API Surface of ngx-lib\n */\n\nexport * from './lib/model/app';\nexport * from './lib/model/app-path-config';\nexport * from './lib/model/app-type';\nexport * from './lib/model/service-config';\n\nexport * from './lib/services/app-path-config.service';\n\nexport * from './lib/ngx-lib.module';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":["i1.ServiceConfig"],"mappings":";;;;MAAa,aAAa,CAAA;AAEzB;;ACAM,MAAM,aAAa,GAAkB;AACxC,IAAA,MAAM,EAAE,mBAAmB;CAC9B;;MCOY,oBAAoB,CAAA;IAG/B,WAAgC,CAAA,MAAqB,EACjC,IAAgB,EAAA;AADJ,QAAA,IAAM,CAAA,MAAA,GAAN,MAAM,CAAe;AACjC,QAAA,IAAI,CAAA,IAAA,GAAJ,IAAI,CAAY;QAEtB,IAAI,CAAC,MAAM,GACN,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAA,aAAa,GACb,IAAI,CAAC,MAAM,CACf,CAAC;QAEF,IAAI,CAAC,GAAG,GAAG,CAAG,EAAA,IAAI,CAAC,MAAM,CAAC,MAAM,CAAA,eAAA,CAAiB,CAAA;KAC9D;IAED,MAAM,GAAA;QACJ,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAkB,IAAI,CAAC,GAAG,CAAC,CAAC;KACjD;AAED,IAAA,OAAO,CAAC,EAAU,EAAA;AAChB,QAAA,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAgB,CAAA,EAAG,IAAI,CAAC,GAAG,CAAA,CAAA,EAAI,EAAE,CAAA,CAAE,CAAC,CAAC;KAC1D;AAED,IAAA,UAAU,CAAC,EAAU,EAAA;AACnB,QAAA,OAAO,IAAI,CA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ommonModule } from '@angular/common';
7
7
 
8
- class ServiceConfig {
9
- }
10
-
11
8
  const defaultCachingConfig = {
12
9
  enabled: false,
13
10
  lifeMinutes: 720
@@ -26,6 +23,9 @@ const defaultConfig = {
26
23
  logging: defaultLoggingConfig
27
24
  };
28
25
 
26
+ class ServiceConfig {
27
+ }
28
+
29
29
  //#region Imports
30
30
  //#endregion
31
31
  class ActiveDirectoryService {
@@ -37,9 +37,18 @@ class ActiveDirectoryService {
37
37
  this.http = http;
38
38
  this.cache = null;
39
39
  this.defaultCacheLifeMinutes = 720;
40
- this.config = this.config ?? defaultConfig;
41
- this.config.caching = this.config.caching ?? defaultCachingConfig;
42
- this.config.logging = this.config.logging ?? defaultLoggingConfig;
40
+ this.config = {
41
+ ...defaultConfig,
42
+ ...this.config
43
+ };
44
+ this.config.caching = {
45
+ ...defaultCachingConfig,
46
+ ...this.config.caching
47
+ };
48
+ this.config.logging = {
49
+ ...defaultLoggingConfig,
50
+ ...this.config.logging
51
+ };
43
52
  }
44
53
  //#region Properties
45
54
  get cacheExpired() {
@@ -143,5 +152,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.0", ngImpor
143
152
  * Generated bundle index. Do not edit.
144
153
  */
145
154
 
146
- export { ActiveDirectoryModule, ActiveDirectoryService, ServiceConfig };
155
+ export { ActiveDirectoryModule, ActiveDirectoryService, ServiceConfig, defaultCachingConfig, defaultConfig, defaultLoggingConfig };
147
156
  //# sourceMappingURL=cleavelandprice-ngx-lib-active-directory.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"cleavelandprice-ngx-lib-active-directory.mjs","sources":["../../../../projects/cleavelandprice/ngx-lib/active-directory/src/model/service-config.ts","../../../../projects/cleavelandprice/ngx-lib/active-directory/src/model/default-caching-config.ts","../../../../projects/cleavelandprice/ngx-lib/active-directory/src/model/default-logging-config.ts","../../../../projects/cleavelandprice/ngx-lib/active-directory/src/model/default-config.ts","../../../../projects/cleavelandprice/ngx-lib/active-directory/src/services/active-directory.service.ts","../../../../projects/cleavelandprice/ngx-lib/active-directory/src/active-directory.module.ts","../../../../projects/cleavelandprice/ngx-lib/active-directory/src/cleavelandprice-ngx-lib-active-directory.ts"],"sourcesContent":["import { CachingConfig } from './caching-config';\r\nimport { LoggingConfig } from './logging-config';\r\n\r\nexport class ServiceConfig {\r\n apiUrl!: string;\r\n caching?: CachingConfig;\r\n logging?: LoggingConfig;\r\n}\r\n","import { CachingConfig } from \"./caching-config\";\r\n\r\nexport const defaultCachingConfig: CachingConfig = {\r\n enabled: false,\r\n lifeMinutes: 720\r\n}","import { LoggingConfig } from \"./logging-config\";\r\n\r\nexport const defaultLoggingConfig: LoggingConfig = {\r\n dataCached: false,\r\n cachedDataReturned: false,\r\n freshDataReturned: false,\r\n cacheCleared: false\r\n}","import { ServiceConfig } from \"./service-config\";\r\nimport { defaultCachingConfig } from './default-caching-config';\r\nimport { defaultLoggingConfig } from \"./default-logging-config\";\r\n\r\nexport const defaultConfig: ServiceConfig = {\r\n apiUrl: 'http://utilityapi/users',\r\n caching: defaultCachingConfig,\r\n logging: defaultLoggingConfig\r\n}","//#region Imports\nimport { Injectable, Optional } from '@angular/core';\nimport { HttpClient } from '@angular/common/http';\nimport { Observable, of } from 'rxjs';\n\nimport { defaultConfig } from '../model/default-config';\nimport { defaultCachingConfig } from '../model/default-caching-config';\nimport { defaultLoggingConfig } from '../model/default-logging-config';\n\nimport { CacheObject } from '../model/cache-object';\nimport { ServiceConfig } from '../model/service-config';\nimport { User } from '../model/user';\n\nimport moment from 'moment';\n//#endregion\n\n@Injectable({\n providedIn: 'root'\n})\nexport class ActiveDirectoryService {\n private cache: CacheObject<User> | null = null;\n private defaultCacheLifeMinutes = 720;\n\n //#region Properties\n private get cacheExpired(): boolean {\n if (!this.cache) {\n return true;\n }\n\n const lifeMinutes = this.config.caching?.lifeMinutes ?? this.defaultCacheLifeMinutes;\n const expiration = moment(this.cache.lastUpdate)\n .add(lifeMinutes, 'minutes');\n\n return moment().isAfter(expiration);\n }\n //#endregion\n\n //#region Initialization\n // If a ServiceConfig object is not provided when the module is imported, then default values are pulled in from default-config.ts.\n constructor(@Optional() private config: ServiceConfig,\n private http: HttpClient) {\n\n this.config = this.config ?? defaultConfig;\n this.config.caching = this.config.caching ?? defaultCachingConfig;\n this.config.logging = this.config.logging ?? defaultLoggingConfig;\n }\n //#endregion\n\n getUsers(includePhoto = false, includeDisabled = false, parentOU?: string): Observable<User[]> {\n // If caching is enabled, there will be two calls to the API if the cache is null/expired\n // One call is to update the cache and the other is to return the data that the user requested\n // Subsequent calls will bypass the API and returned cached data until it expires\n\n const observable$ = this.http.get<User[]>(`${this.config.apiUrl}/${includePhoto}/${includeDisabled}/${parentOU ?? ''}`);\n\n if (this.config.caching?.enabled) {\n if (this.cacheExpired) {\n // Get the data and cache it\n observable$.subscribe(data => {\n this.cache = {\n data,\n lastUpdate: moment()\n };\n\n if (this.config.logging?.dataCached) {\n const lifeMinutes = this.config.caching?.lifeMinutes ?? this.defaultCacheLifeMinutes;\n console.log(`Data cached for ${lifeMinutes} minutes`);\n }\n });\n } else {\n // Cache exists and hasn't expired yet\n if (this.config.logging?.cachedDataReturned) {\n console.log('Returning cached users');\n }\n\n return of(this.cache!.data);\n }\n }\n\n // Cache is either disabled or expired, return data from API\n if (this.config.logging?.freshDataReturned) {\n console.log('Returning fresh users');\n }\n\n return observable$;\n }\n\n getUser(accountName: string, includePhoto = false): Observable<User> {\n return this.http.get<User>(`${this.config.apiUrl}/name/${accountName}/${includePhoto}`);\n }\n\n clearCache(): void {\n this.cache = null;\n\n if (this.config.logging?.cacheCleared) {\n console.log('Cache cleared');\n }\n }\n}\n","import { ModuleWithProviders, NgModule, Optional, SkipSelf } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { ServiceConfig } from './model/service-config';\nimport { ActiveDirectoryService } from './services/active-directory.service';\n\n@NgModule({\n declarations: [],\n imports: [\n CommonModule\n ]\n})\nexport class ActiveDirectoryModule {\n static forRoot(config: ServiceConfig): ModuleWithProviders<ActiveDirectoryModule> {\n return {\n ngModule: ActiveDirectoryModule,\n providers: [\n ActiveDirectoryService,\n { provide: ServiceConfig, useValue: config }\n ]\n };\n }\n\n constructor( @Optional() @SkipSelf() parentModule: ActiveDirectoryModule) {\n if (parentModule) {\n throw new Error(\n 'ActiveDirectoryModule is already loaded. Import it in the AppModule only');\n }\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":["i1.ServiceConfig"],"mappings":";;;;;;;MAGa,aAAa,CAAA;AAIzB;;ACLM,MAAM,oBAAoB,GAAkB;AAC/C,IAAA,OAAO,EAAE,KAAK;AACd,IAAA,WAAW,EAAE,GAAG;CACnB;;ACHM,MAAM,oBAAoB,GAAkB;AAC/C,IAAA,UAAU,EAAE,KAAK;AACjB,IAAA,kBAAkB,EAAE,KAAK;AACzB,IAAA,iBAAiB,EAAE,KAAK;AACxB,IAAA,YAAY,EAAE,KAAK;CACtB;;ACHM,MAAM,aAAa,GAAkB;AACxC,IAAA,MAAM,EAAE,yBAAyB;AACjC,IAAA,OAAO,EAAE,oBAAoB;AAC7B,IAAA,OAAO,EAAE,oBAAoB;CAChC;;ACRD;AAcA;MAKa,sBAAsB,CAAA;;;;IAoBjC,WAAgC,CAAA,MAAqB,EACjC,IAAgB,EAAA;QADJ,IAAM,CAAA,MAAA,GAAN,MAAM,CAAe;QACjC,IAAI,CAAA,IAAA,GAAJ,IAAI,CAAY;QApB5B,IAAK,CAAA,KAAA,GAA6B,IAAI,CAAC;QACvC,IAAuB,CAAA,uBAAA,GAAG,GAAG,CAAC;QAqBxB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,aAAa,CAAC;AAC3C,QAAA,IAAI,CAAC,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,oBAAoB,CAAC;AAClE,QAAA,IAAI,CAAC,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,MAAM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AAA,EAAA,EAAA,EAAA,IAAA,EAAA,qBAAqB,YAH9B,YAAY,CAAA,EAAA,CAAA,CAAA;2FAGH,qBAAqB,EAAA,UAAA,EAAA,CAAA;kBANjC,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,YAAY,EAAE,EAAE;AAChB,oBAAA,OAAO,EAAE;wBACP,YAAY;AACb,qBAAA;AACF,iBAAA,CAAA;0DAYoD,qBAAqB,EAAA,UAAA,EAAA,CAAA;0BAA1D,QAAQ;;0BAAI,QAAQ;;;ACtBpC;;AAEG;;;;"}
1
+ {"version":3,"file":"cleavelandprice-ngx-lib-active-directory.mjs","sources":["../../../../projects/cleavelandprice/ngx-lib/active-directory/src/model/default-caching-config.ts","../../../../projects/cleavelandprice/ngx-lib/active-directory/src/model/default-logging-config.ts","../../../../projects/cleavelandprice/ngx-lib/active-directory/src/model/default-config.ts","../../../../projects/cleavelandprice/ngx-lib/active-directory/src/model/service-config.ts","../../../../projects/cleavelandprice/ngx-lib/active-directory/src/services/active-directory.service.ts","../../../../projects/cleavelandprice/ngx-lib/active-directory/src/active-directory.module.ts","../../../../projects/cleavelandprice/ngx-lib/active-directory/src/cleavelandprice-ngx-lib-active-directory.ts"],"sourcesContent":["import { CachingConfig } from \"./caching-config\";\r\n\r\nexport const defaultCachingConfig: CachingConfig = {\r\n enabled: false,\r\n lifeMinutes: 720\r\n}","import { LoggingConfig } from \"./logging-config\";\r\n\r\nexport const defaultLoggingConfig: LoggingConfig = {\r\n dataCached: false,\r\n cachedDataReturned: false,\r\n freshDataReturned: false,\r\n cacheCleared: false\r\n}","import { ServiceConfig } from \"./service-config\";\r\nimport { defaultCachingConfig } from './default-caching-config';\r\nimport { defaultLoggingConfig } from \"./default-logging-config\";\r\n\r\nexport const defaultConfig: ServiceConfig = {\r\n apiUrl: 'http://utilityapi/users',\r\n caching: defaultCachingConfig,\r\n logging: defaultLoggingConfig\r\n}","import { CachingConfig } from './caching-config';\r\nimport { LoggingConfig } from './logging-config';\r\n\r\nexport class ServiceConfig {\r\n apiUrl!: string;\r\n caching?: CachingConfig;\r\n logging?: LoggingConfig;\r\n}\r\n","//#region Imports\nimport { Injectable, Optional } from '@angular/core';\nimport { HttpClient } from '@angular/common/http';\nimport { Observable, of } from 'rxjs';\n\nimport { defaultConfig } from '../model/default-config';\nimport { defaultCachingConfig } from '../model/default-caching-config';\nimport { defaultLoggingConfig } from '../model/default-logging-config';\n\nimport { CacheObject } from '../model/cache-object';\nimport { ServiceConfig } from '../model/service-config';\nimport { User } from '../model/user';\n\nimport moment from 'moment';\n//#endregion\n\n@Injectable({\n providedIn: 'root'\n})\nexport class ActiveDirectoryService {\n private cache: CacheObject<User> | null = null;\n private defaultCacheLifeMinutes = 720;\n\n //#region Properties\n private get cacheExpired(): boolean {\n if (!this.cache) {\n return true;\n }\n\n const lifeMinutes = this.config.caching?.lifeMinutes ?? this.defaultCacheLifeMinutes;\n const expiration = moment(this.cache.lastUpdate)\n .add(lifeMinutes, 'minutes');\n\n return moment().isAfter(expiration);\n }\n //#endregion\n\n //#region Initialization\n // If a ServiceConfig object is not provided when the module is imported, then default values are pulled in from default-config.ts.\n constructor(@Optional() private config: ServiceConfig,\n private http: HttpClient) {\n\n this.config = {\n ...defaultConfig,\n ...this.config\n };\n\n this.config.caching = {\n ...defaultCachingConfig,\n ...this.config.caching\n };\n\n this.config.logging = {\n ...defaultLoggingConfig,\n ...this.config.logging\n };\n }\n //#endregion\n\n getUsers(includePhoto = false, includeDisabled = false, parentOU?: string): Observable<User[]> {\n // If caching is enabled, there will be two calls to the API if the cache is null/expired\n // One call is to update the cache and the other is to return the data that the user requested\n // Subsequent calls will bypass the API and returned cached data until it expires\n\n const observable$ = this.http.get<User[]>(`${this.config.apiUrl}/${includePhoto}/${includeDisabled}/${parentOU ?? ''}`);\n\n if (this.config.caching?.enabled) {\n if (this.cacheExpired) {\n // Get the data and cache it\n observable$.subscribe(data => {\n this.cache = {\n data,\n lastUpdate: moment()\n };\n\n if (this.config.logging?.dataCached) {\n const lifeMinutes = this.config.caching?.lifeMinutes ?? this.defaultCacheLifeMinutes;\n console.log(`Data cached for ${lifeMinutes} minutes`);\n }\n });\n } else {\n // Cache exists and hasn't expired yet\n if (this.config.logging?.cachedDataReturned) {\n console.log('Returning cached users');\n }\n\n return of(this.cache!.data);\n }\n }\n\n // Cache is either disabled or expired, return data from API\n if (this.config.logging?.freshDataReturned) {\n console.log('Returning fresh users');\n }\n\n return observable$;\n }\n\n getUser(accountName: string, includePhoto = false): Observable<User> {\n return this.http.get<User>(`${this.config.apiUrl}/name/${accountName}/${includePhoto}`);\n }\n\n clearCache(): void {\n this.cache = null;\n\n if (this.config.logging?.cacheCleared) {\n console.log('Cache cleared');\n }\n }\n}\n","import { ModuleWithProviders, NgModule, Optional, SkipSelf } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { ServiceConfig } from './model/service-config';\nimport { ActiveDirectoryService } from './services/active-directory.service';\n\n@NgModule({\n declarations: [],\n imports: [\n CommonModule\n ]\n})\nexport class ActiveDirectoryModule {\n static forRoot(config: ServiceConfig): ModuleWithProviders<ActiveDirectoryModule> {\n return {\n ngModule: ActiveDirectoryModule,\n providers: [\n ActiveDirectoryService,\n { provide: ServiceConfig, useValue: config }\n ]\n };\n }\n\n constructor( @Optional() @SkipSelf() parentModule: ActiveDirectoryModule) {\n if (parentModule) {\n throw new Error(\n 'ActiveDirectoryModule is already loaded. Import it in the AppModule only');\n }\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":["i1.ServiceConfig"],"mappings":";;;;;;;AAEa,MAAA,oBAAoB,GAAkB;AAC/C,IAAA,OAAO,EAAE,KAAK;AACd,IAAA,WAAW,EAAE,GAAG;;;ACFP,MAAA,oBAAoB,GAAkB;AAC/C,IAAA,UAAU,EAAE,KAAK;AACjB,IAAA,kBAAkB,EAAE,KAAK;AACzB,IAAA,iBAAiB,EAAE,KAAK;AACxB,IAAA,YAAY,EAAE,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AAE,qBAAqB;AAC/B,YAAA,SAAS,EAAE;gBACT,sBAAsB;AACtB,gBAAA,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAE;AAC7C,aAAA;SACF,CAAC;KACH;;AATU,qBAAA,CAAA,IAAA,GAAA,EAAA,CAAA,kBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,qBAAqB,kBAWmB,qBAAqB,EAAA,QAAA,EAAA,IAAA,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;AAX7D,qBAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,qBAAqB,YAH9B,YAAY,CAAA,EAAA,CAAA,CAAA;AAGH,qBAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,qBAAqB,YAH9B,YAAY,CAAA,EAAA,CAAA,CAAA;2FAGH,qBAAqB,EAAA,UAAA,EAAA,CAAA;kBANjC,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,YAAY,EAAE,EAAE;AAChB,oBAAA,OAAO,EAAE;wBACP,YAAY;AACb,qBAAA;AACF,iBAAA,CAAA;0DAYoD,qBAAqB,EAAA,UAAA,EAAA,CAAA;0BAA1D,QAAQ;;0BAAI,QAAQ;;;ACtBpC;;AAEG;;;;"}
@@ -21,13 +21,13 @@ import { MatInputModule } from '@angular/material/input';
21
21
  import * as i9 from '@angular/material/progress-spinner';
22
22
  import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
23
23
 
24
- class ServiceConfig {
25
- }
26
-
27
24
  const defaultConfig = {
28
25
  apiUrl: 'http://utilityapi/authenticate/token'
29
26
  };
30
27
 
28
+ class ServiceConfig {
29
+ }
30
+
31
31
  //#region Imports
32
32
  //#endregion
33
33
  class AuthenticationService {
@@ -46,7 +46,10 @@ class AuthenticationService {
46
46
  this.authenticating = false;
47
47
  //Flag set to true when the user is successfully authenticated
48
48
  this.authenticated = false;
49
- this.config = this.config ?? defaultConfig;
49
+ this.config = {
50
+ ...defaultConfig,
51
+ ...this.config
52
+ };
50
53
  this.checkForExistingToken();
51
54
  }
52
55
  //#endregion
@@ -289,5 +292,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.0", ngImpor
289
292
  * Generated bundle index. Do not edit.
290
293
  */
291
294
 
292
- export { AuthenticationModule, AuthenticationService, LoginComponent, LoginFormComponent, ServiceConfig };
295
+ export { AuthenticationModule, AuthenticationService, LoginComponent, LoginFormComponent, ServiceConfig, defaultConfig };
293
296
  //# sourceMappingURL=cleavelandprice-ngx-lib-authentication.mjs.map