ngx-techlify-core 11.3.3 → 11.3.7

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 (39) hide show
  1. package/bundles/ngx-techlify-core.umd.js +709 -181
  2. package/bundles/ngx-techlify-core.umd.js.map +1 -1
  3. package/bundles/ngx-techlify-core.umd.min.js +2 -2
  4. package/bundles/ngx-techlify-core.umd.min.js.map +1 -1
  5. package/esm2015/lib/note/comment-form/comment-form.component.js +73 -0
  6. package/esm2015/lib/note/index.js +2 -1
  7. package/esm2015/lib/note/note-list/note-list.component.js +33 -3
  8. package/esm2015/lib/note/note.module.js +7 -3
  9. package/esm2015/lib/read-more/read-more.component.js +43 -0
  10. package/esm2015/lib/read-more/read-more.module.js +21 -0
  11. package/esm2015/lib/techlify-feature/on-off-switch/on-off-switch.component.js +27 -0
  12. package/esm2015/lib/techlify-feature/techlify-feature-enabled.directive.js +77 -0
  13. package/esm2015/lib/techlify-feature/techlify-feature-listing.component.js +174 -0
  14. package/esm2015/lib/techlify-feature/techlify-feature.module.js +30 -0
  15. package/esm2015/lib/techlify-feature/techlify-feature.routing.js +12 -0
  16. package/esm2015/lib/techlify-feature/techlify-feature.service.js +28 -0
  17. package/esm2015/lib/techlify-update/techlify-update-history/techlify-update-history.module.js +2 -2
  18. package/esm2015/lib/techlify-update/techlify-update.module.js +2 -2
  19. package/esm2015/ngx-techlify-core.js +33 -31
  20. package/esm2015/public-api.js +7 -1
  21. package/fesm2015/ngx-techlify-core.js +479 -63
  22. package/fesm2015/ngx-techlify-core.js.map +1 -1
  23. package/lib/note/comment-form/comment-form.component.d.ts +22 -0
  24. package/lib/note/index.d.ts +1 -0
  25. package/lib/note/note-list/note-list.component.d.ts +4 -0
  26. package/lib/{techlify-update/read-more → read-more}/read-more.component.d.ts +0 -0
  27. package/lib/{techlify-update/read-more → read-more}/read-more.module.d.ts +0 -0
  28. package/lib/techlify-feature/on-off-switch/on-off-switch.component.d.ts +9 -0
  29. package/lib/techlify-feature/techlify-feature-enabled.directive.d.ts +16 -0
  30. package/lib/techlify-feature/techlify-feature-listing.component.d.ts +34 -0
  31. package/lib/techlify-feature/techlify-feature.module.d.ts +2 -0
  32. package/lib/techlify-feature/techlify-feature.routing.d.ts +2 -0
  33. package/lib/techlify-feature/techlify-feature.service.d.ts +8 -0
  34. package/ngx-techlify-core.d.ts +32 -30
  35. package/ngx-techlify-core.metadata.json +1 -1
  36. package/package.json +1 -1
  37. package/public-api.d.ts +6 -0
  38. package/esm2015/lib/techlify-update/read-more/read-more.component.js +0 -43
  39. package/esm2015/lib/techlify-update/read-more/read-more.module.js +0 -21
@@ -38,6 +38,7 @@ import { diff, formatters } from 'jsondiffpatch';
38
38
  import { ENTER, COMMA } from '@angular/cdk/keycodes';
39
39
  import { MatAutocompleteModule } from '@angular/material/autocomplete';
40
40
  import { MatButtonToggleModule } from '@angular/material/button-toggle';
41
+ import { MatSlideToggleModule } from '@angular/material/slide-toggle';
41
42
 
42
43
  class ActionPopup {
43
44
  }
@@ -1602,6 +1603,7 @@ class NoteListComponent {
1602
1603
  this.dialog = dialog;
1603
1604
  this.readonly = false;
1604
1605
  this.labelText = 'Note';
1606
+ this.commentsView = false;
1605
1607
  this.notes = [];
1606
1608
  this.displayedColumns = [
1607
1609
  'index',
@@ -1692,11 +1694,39 @@ class NoteListComponent {
1692
1694
  this.loadData();
1693
1695
  }
1694
1696
  }
1697
+ commentAction(event) {
1698
+ if (event.type === "save") {
1699
+ if (event.value.id) {
1700
+ this.editComment(event.value);
1701
+ return;
1702
+ }
1703
+ this.addComment(event.value);
1704
+ return;
1705
+ }
1706
+ this.deleteNote(event.value);
1707
+ }
1708
+ editComment(comment) {
1709
+ return __awaiter(this, void 0, void 0, function* () {
1710
+ const result = yield this.noteService.editNote(comment);
1711
+ let index = this.notes.findIndex((x) => x.id === comment.id);
1712
+ if (index !== -1) {
1713
+ this.notes[index] = result.item;
1714
+ }
1715
+ });
1716
+ }
1717
+ addComment(comment) {
1718
+ return __awaiter(this, void 0, void 0, function* () {
1719
+ comment.related_model_id = this.relatedModelId;
1720
+ comment.model_type = this.modelType;
1721
+ const result = yield this.noteService.addNote(comment);
1722
+ this.notes.push(result.item);
1723
+ });
1724
+ }
1695
1725
  }
1696
1726
  NoteListComponent.decorators = [
1697
1727
  { type: Component, args: [{
1698
1728
  selector: 'app-note-list',
1699
- template: "<div fxLayout=\"column\" fxLayoutGap=\"1.5rem\" class=\"m-4\">\n\n <div fxLayout fxLayoutAlign=\"center center\" fxLayoutGap=\"1rem\">\n <h3 class=\"m-0 font-weight-bold mr-3\">{{labelText}}s</h3>\n <button class=\"d-print-none\" *ngIf=\"!readonly\" mat-raised-button color=\"primary\" type=\"button\"\n (click)=\"addNote()\">+ Add</button>\n </div>\n\n <div class=\"w-00 scroll-container\" infiniteScroll [infiniteScrollDistance]=\"1\" [infiniteScrollThrottle]=\"50\"\n (scrolled)=\"onScroll()\" [scrollWindow]=\"false\">\n <table mat-table [dataSource]=\"notes\" class=\"w-100\" multiTemplateDataRows>\n\n <!-- Index Column -->\n <ng-container matColumnDef=\"index\">\n <th mat-header-cell *matHeaderCellDef> # </th>\n <td mat-cell *matCellDef=\"let note; let i = dataIndex\"> {{ i+1 }} </td>\n </ng-container>\n\n\n <ng-container matColumnDef=\"note\">\n <th mat-header-cell *matHeaderCellDef> {{labelText}} </th>\n <td mat-cell *matCellDef=\"let note\">\n {{note?.note}}\n </td>\n </ng-container>\n\n <ng-container matColumnDef=\"actions\">\n <th mat-header-cell *matHeaderCellDef class=\"d-print-none\"> Actions </th>\n <td mat-cell *matCellDef=\"let note\" class=\"d-print-none\">\n <button type=\"button\" mat-icon-button (click)=\"editNote(note)\">\n <mat-icon>edit</mat-icon>\n </button>\n <button type=\"button\" mat-icon-button (click)=\"deleteNote(note)\">\n <mat-icon>delete</mat-icon>\n </button>\n </td>\n </ng-container>\n <tr mat-header-row *matHeaderRowDef=\"displayedColumns\"></tr>\n <tr mat-row *matRowDef=\"let row; columns: displayedColumns;\"></tr>\n </table>\n </div>\n\n</div>",
1729
+ template: "<div fxLayout=\"column\" fxLayoutGap=\"1.5rem\" class=\"m-4\" *ngIf=\"!commentsView\">\n\n <div fxLayout fxLayoutAlign=\"center center\" fxLayoutGap=\"1rem\">\n <h3 class=\"m-0 font-weight-bold mr-3\">{{labelText}}s</h3>\n <button class=\"d-print-none\" *ngIf=\"!readonly\" mat-raised-button color=\"primary\" type=\"button\" (click)=\"addNote()\">+\n Add</button>\n </div>\n\n <div class=\"w-100 scroll-container\" infiniteScroll [infiniteScrollDistance]=\"1\" [infiniteScrollThrottle]=\"50\"\n (scrolled)=\"onScroll()\" [scrollWindow]=\"false\">\n <table mat-table [dataSource]=\"notes\" class=\"w-100\" multiTemplateDataRows>\n\n <!-- Index Column -->\n <ng-container matColumnDef=\"index\">\n <th mat-header-cell *matHeaderCellDef> # </th>\n <td mat-cell *matCellDef=\"let note; let i = dataIndex\"> {{ i+1 }} </td>\n </ng-container>\n\n\n <ng-container matColumnDef=\"note\">\n <th mat-header-cell *matHeaderCellDef> {{labelText}} </th>\n <td mat-cell *matCellDef=\"let note\">\n {{note?.note}}\n </td>\n </ng-container>\n\n <ng-container matColumnDef=\"actions\">\n <th mat-header-cell *matHeaderCellDef class=\"d-print-none\"> Actions </th>\n <td mat-cell *matCellDef=\"let note\" class=\"d-print-none\">\n <button type=\"button\" mat-icon-button (click)=\"editNote(note)\">\n <mat-icon>edit</mat-icon>\n </button>\n <button type=\"button\" mat-icon-button (click)=\"deleteNote(note)\">\n <mat-icon>delete</mat-icon>\n </button>\n </td>\n </ng-container>\n <tr mat-header-row *matHeaderRowDef=\"displayedColumns\"></tr>\n <tr mat-row *matRowDef=\"let row; columns: displayedColumns;\"></tr>\n </table>\n </div>\n\n</div>\n\n<div fxLayout=\"column\" fxLayoutGap=\"1.5rem\" *ngIf=\"commentsView\">\n <div fxLayout fxLayoutAlign=\"center center\" fxLayoutGap=\"1rem\">\n <h3 class=\"m-0 font-weight-bold mr-3\">{{labelText}}s</h3>\n </div>\n\n <div fxLayout=\"column\" fxLayoutAlign=\"start\" fxFlex=\"100%\">\n <div class=\"w-100 scroll-container jumbotron\" infiniteScroll [infiniteScrollDistance]=\"1\"\n [infiniteScrollThrottle]=\"50\" (scrolled)=\"onScroll()\" [scrollWindow]=\"false\">\n <app-comment-form [commentData]=\"comment\" (action)=\"commentAction($event)\" *ngFor=\"let comment of notes\">\n </app-comment-form>\n <app-comment-form (action)=\"commentAction($event)\"></app-comment-form>\n </div>\n </div>\n</div>\n",
1700
1730
  styles: [".scroll-container{max-height:400px;overflow-y:auto}"]
1701
1731
  },] }
1702
1732
  ];
@@ -1708,7 +1738,78 @@ NoteListComponent.propDecorators = {
1708
1738
  relatedModelId: [{ type: Input }],
1709
1739
  modelType: [{ type: Input }],
1710
1740
  readonly: [{ type: Input }],
1711
- labelText: [{ type: Input }]
1741
+ labelText: [{ type: Input }],
1742
+ commentsView: [{ type: Input }]
1743
+ };
1744
+
1745
+ class CommentFormComponent {
1746
+ constructor(fb, credentialService) {
1747
+ this.fb = fb;
1748
+ this.credentialService = credentialService;
1749
+ this.action = new EventEmitter();
1750
+ this.createForm();
1751
+ }
1752
+ set commentData(data) {
1753
+ this.view = !!data;
1754
+ this._commentData = data;
1755
+ this.commentFormGroup.patchValue(data);
1756
+ }
1757
+ ngOnInit() { }
1758
+ get isLoggedIn() {
1759
+ return this.credentialService.isAuthenticated;
1760
+ }
1761
+ get currentUser() {
1762
+ return this.credentialService.credentials.user;
1763
+ }
1764
+ createForm() {
1765
+ //TODO: Finialize and add more validations.
1766
+ this.commentFormGroup = this.fb.group({
1767
+ id: [""],
1768
+ note: [""],
1769
+ model_type: [""],
1770
+ related_model_id: [""],
1771
+ });
1772
+ }
1773
+ submit() {
1774
+ if (this.commentFormGroup.get("note").value) {
1775
+ if (this._commentData) {
1776
+ this.view = !this.view;
1777
+ }
1778
+ this.action.emit({ type: "save", value: this.commentFormGroup.value });
1779
+ this.commentFormGroup.reset();
1780
+ }
1781
+ else if (this.commentFormGroup.get("id").value) {
1782
+ this.deleteComment();
1783
+ }
1784
+ }
1785
+ hideEdit() {
1786
+ if (this.commentFormGroup.get("id").value) {
1787
+ this.view = !this.view;
1788
+ }
1789
+ }
1790
+ editComment() {
1791
+ this.view = !this.view;
1792
+ this.commentFormGroup.patchValue(this._commentData);
1793
+ }
1794
+ deleteComment() {
1795
+ this.action.emit({ type: "delete", value: this.commentFormGroup.value });
1796
+ }
1797
+ ngOnDestroy() { }
1798
+ }
1799
+ CommentFormComponent.decorators = [
1800
+ { type: Component, args: [{
1801
+ selector: "app-comment-form",
1802
+ template: "<form (ngSubmit)=\"submit()\" [formGroup]=\"commentFormGroup\">\n <div fxLayout=\"column\" class=\"my-2\" [ngClass]=\"{ 'border border-primary shadow rounded ': view}\">\n <div *ngIf=\"!view\" fxLayout=\"column\">\n <mat-form-field appearance=\"outline\" style=\"background-color:white;\">\n <mat-label>Comment</mat-label>\n <textarea matInput rows=\"5\" placeholder=\"Add a comment...\" formControlName=\"note\" autocomplete=\"off\"></textarea>\n </mat-form-field>\n\n <div fxLayout fxLayoutGap=\"1rem\" class=\"mt-2\">\n <span fxFlex></span>\n <button *ngIf=\"_commentData\" mat-button type=\"button\" (click)=\"view = !view\">\n Cancel\n </button>\n <button mat-raised-button color=\"primary\" type=\"submit\">\n {{ _commentData ? \"Update\" : \"Post comment\" }}\n </button>\n </div>\n </div>\n\n <div fxLayout=\"column\" *ngIf=\"view\" class=\"p-2 m-2\">\n <div fxLayout=\"row wrap\" fxLayoutGap=\".5rem\">\n <div fxFlex=\"20%\" fxLayoutAlign=\"start\">\n <button mat-icon-button type=\"button\" style=\"color:grey\">\n <mat-icon style=\"font-size:60px\">account_circle</mat-icon>\n </button>\n </div>\n <div fxFlex=\"75%\">\n <div fxLayout=\"column\" fxLayoutGap=\".5rem\">\n <div class=\"font-weight-bold\">{{ _commentData?.creator?.name }}</div>\n <div class=\"text-muted\">{{ _commentData.updated_at | date:'medium' }}</div>\n </div>\n </div>\n </div>\n <app-read-more class=\"mt-2\" [text]=\"_commentData.note\"></app-read-more>\n <div fxLayout class=\"mt-1\" fxLayoutGap=\"1rem\" *ngIf=\"isLoggedIn && currentUser.id === _commentData.creator_id\">\n <a href=\"javascript:;\" (click)=\"editComment()\">\n Edit\n </a>\n <a href=\"javascript:;\" (click)=\"deleteComment()\">\n Delete\n </a>\n </div>\n </div>\n </div>\n</form>",
1803
+ styles: [":host ::ng-deep .mat-form-field-wrapper{margin:0!important;padding-bottom:0!important}"]
1804
+ },] }
1805
+ ];
1806
+ CommentFormComponent.ctorParameters = () => [
1807
+ { type: FormBuilder },
1808
+ { type: CredentialsService }
1809
+ ];
1810
+ CommentFormComponent.propDecorators = {
1811
+ commentData: [{ type: Input }],
1812
+ action: [{ type: Output }]
1712
1813
  };
1713
1814
 
1714
1815
  var SearchableSelectorComponent_1;
@@ -2812,13 +2913,72 @@ EntityFilesViewAllModule.decorators = [
2812
2913
  },] }
2813
2914
  ];
2814
2915
 
2916
+ class ReadMoreComponent {
2917
+ constructor() {
2918
+ this.maxLength = 100;
2919
+ this.hideToggle = true;
2920
+ this.isCollapsed = true;
2921
+ }
2922
+ ngOnInit() {
2923
+ this.determineView();
2924
+ }
2925
+ toggleView() {
2926
+ this.isCollapsed = !this.isCollapsed;
2927
+ this.determineView();
2928
+ }
2929
+ determineView() {
2930
+ if (!this.text || this.text.length <= this.maxLength) {
2931
+ this.currentText = this.text;
2932
+ this.isCollapsed = false;
2933
+ this.hideToggle = true;
2934
+ return;
2935
+ }
2936
+ this.hideToggle = false;
2937
+ if (this.isCollapsed == true) {
2938
+ this.currentText = this.text.substring(0, this.maxLength) + "...";
2939
+ }
2940
+ else if (this.isCollapsed == false) {
2941
+ this.currentText = this.text;
2942
+ }
2943
+ }
2944
+ }
2945
+ ReadMoreComponent.decorators = [
2946
+ { type: Component, args: [{
2947
+ selector: "app-read-more",
2948
+ template: "<div [innerHTML]=\"currentText\"></div>\n<a href=\"javascript:;\" *ngIf=\"!hideToggle\" class=\"primary-color hoverable\" (click)=\"toggleView()\">Read\n {{ isCollapsed ? \"more\" : \"less\" }}</a>",
2949
+ styles: ["div.collapsed{height:250px;overflow:hidden}.primary-color{color:#009fdd!important}"]
2950
+ },] }
2951
+ ];
2952
+ ReadMoreComponent.ctorParameters = () => [];
2953
+ ReadMoreComponent.propDecorators = {
2954
+ text: [{ type: Input }],
2955
+ maxLength: [{ type: Input }]
2956
+ };
2957
+
2958
+ class ReadMoreModule {
2959
+ }
2960
+ ReadMoreModule.decorators = [
2961
+ { type: NgModule, args: [{
2962
+ declarations: [ReadMoreComponent],
2963
+ imports: [
2964
+ CommonModule,
2965
+ MaterialModule,
2966
+ FlexLayoutModule
2967
+ ],
2968
+ exports: [
2969
+ ReadMoreComponent
2970
+ ]
2971
+ },] }
2972
+ ];
2973
+
2815
2974
  class NoteModule {
2816
2975
  }
2817
2976
  NoteModule.decorators = [
2818
2977
  { type: NgModule, args: [{
2819
2978
  declarations: [
2820
2979
  NoteListComponent,
2821
- NoteFormComponent
2980
+ NoteFormComponent,
2981
+ CommentFormComponent,
2822
2982
  ],
2823
2983
  imports: [
2824
2984
  CommonModule,
@@ -2826,7 +2986,8 @@ NoteModule.decorators = [
2826
2986
  InfiniteScrollModule,
2827
2987
  FlexLayoutModule,
2828
2988
  ActionPopupModule,
2829
- MaterialModule
2989
+ MaterialModule,
2990
+ ReadMoreModule
2830
2991
  ],
2831
2992
  exports: [
2832
2993
  NoteListComponent
@@ -3763,64 +3924,6 @@ EmailSubscriptionForUserModule.decorators = [
3763
3924
  },] }
3764
3925
  ];
3765
3926
 
3766
- class ReadMoreComponent {
3767
- constructor() {
3768
- this.maxLength = 100;
3769
- this.hideToggle = true;
3770
- this.isCollapsed = true;
3771
- }
3772
- ngOnInit() {
3773
- this.determineView();
3774
- }
3775
- toggleView() {
3776
- this.isCollapsed = !this.isCollapsed;
3777
- this.determineView();
3778
- }
3779
- determineView() {
3780
- if (!this.text || this.text.length <= this.maxLength) {
3781
- this.currentText = this.text;
3782
- this.isCollapsed = false;
3783
- this.hideToggle = true;
3784
- return;
3785
- }
3786
- this.hideToggle = false;
3787
- if (this.isCollapsed == true) {
3788
- this.currentText = this.text.substring(0, this.maxLength) + "...";
3789
- }
3790
- else if (this.isCollapsed == false) {
3791
- this.currentText = this.text;
3792
- }
3793
- }
3794
- }
3795
- ReadMoreComponent.decorators = [
3796
- { type: Component, args: [{
3797
- selector: "app-read-more",
3798
- template: "<div [innerHTML]=\"currentText\"></div>\n<a href=\"javascript:;\" *ngIf=\"!hideToggle\" class=\"primary-color hoverable\" (click)=\"toggleView()\">Read\n {{ isCollapsed ? \"more\" : \"less\" }}</a>",
3799
- styles: ["div.collapsed{height:250px;overflow:hidden}"]
3800
- },] }
3801
- ];
3802
- ReadMoreComponent.ctorParameters = () => [];
3803
- ReadMoreComponent.propDecorators = {
3804
- text: [{ type: Input }],
3805
- maxLength: [{ type: Input }]
3806
- };
3807
-
3808
- class ReadMoreModule {
3809
- }
3810
- ReadMoreModule.decorators = [
3811
- { type: NgModule, args: [{
3812
- declarations: [ReadMoreComponent],
3813
- imports: [
3814
- CommonModule,
3815
- MaterialModule,
3816
- FlexLayoutModule
3817
- ],
3818
- exports: [
3819
- ReadMoreComponent
3820
- ]
3821
- },] }
3822
- ];
3823
-
3824
3927
  class TechlifyUpdateService {
3825
3928
  constructor(http) {
3826
3929
  this.http = http;
@@ -6064,6 +6167,319 @@ TechlifyTaggerTagSelectorModule.decorators = [
6064
6167
  },] }
6065
6168
  ];
6066
6169
 
6170
+ class TechlifyFeatureService {
6171
+ constructor(dataManager) {
6172
+ this.dataManager = dataManager;
6173
+ }
6174
+ getFeatures() {
6175
+ return this.dataManager.GET(`api/features`);
6176
+ }
6177
+ disableFeature(id) {
6178
+ return this.dataManager.GET(`api/feature/${id}/disable`);
6179
+ }
6180
+ enableFeature(id) {
6181
+ return this.dataManager.GET(`api/feature/${id}/enable`);
6182
+ }
6183
+ }
6184
+ TechlifyFeatureService.ɵprov = ɵɵdefineInjectable({ factory: function TechlifyFeatureService_Factory() { return new TechlifyFeatureService(ɵɵinject(DataManager)); }, token: TechlifyFeatureService, providedIn: "root" });
6185
+ TechlifyFeatureService.decorators = [
6186
+ { type: Injectable, args: [{
6187
+ providedIn: 'root'
6188
+ },] }
6189
+ ];
6190
+ TechlifyFeatureService.ctorParameters = () => [
6191
+ { type: DataManager }
6192
+ ];
6193
+
6194
+ let TechlifyFeatureListingComponent = class TechlifyFeatureListingComponent {
6195
+ constructor(dataManager, errorHandler, fb, alertService, dialog, storage, featureService) {
6196
+ this.dataManager = dataManager;
6197
+ this.errorHandler = errorHandler;
6198
+ this.fb = fb;
6199
+ this.alertService = alertService;
6200
+ this.dialog = dialog;
6201
+ this.storage = storage;
6202
+ this.featureService = featureService;
6203
+ this.features = [];
6204
+ this.displayedColumns = [
6205
+ 'index',
6206
+ 'feature',
6207
+ 'description',
6208
+ 'actions',
6209
+ ];
6210
+ this.dataSource = new MatTableDataSource();
6211
+ this.page = 1;
6212
+ this.perPage = 25;
6213
+ this.isWorking = false;
6214
+ this.filterFormGroup = this.fb.group({
6215
+ num_items: [""]
6216
+ });
6217
+ }
6218
+ ngOnInit() {
6219
+ this.loadData();
6220
+ this.listenForChanges();
6221
+ }
6222
+ listenForChanges() {
6223
+ this.filterFormGroup.valueChanges
6224
+ .pipe(debounceTime(500), untilDestroyed(this))
6225
+ .subscribe((changes) => {
6226
+ this.reload();
6227
+ });
6228
+ }
6229
+ loadData() {
6230
+ return __awaiter(this, void 0, void 0, function* () {
6231
+ let result;
6232
+ try {
6233
+ this.isWorking = true;
6234
+ var filter = this.filterFormGroup.value;
6235
+ filter.page = this.page;
6236
+ filter.perPage = this.perPage;
6237
+ result = yield this.dataManager.GET(`api/features`, filter);
6238
+ this.features = this.features.concat(result.data);
6239
+ this.dataSource = new MatTableDataSource(this.features);
6240
+ if (!this.storage.getItem('features')) {
6241
+ this.setStorage(this.features);
6242
+ }
6243
+ this.isWorking = false;
6244
+ }
6245
+ catch (error) {
6246
+ this.errorHandler.handleError(error);
6247
+ }
6248
+ finally {
6249
+ this.isWorking = false;
6250
+ }
6251
+ });
6252
+ }
6253
+ toggeleFeature(element, feature) {
6254
+ return __awaiter(this, void 0, void 0, function* () {
6255
+ let status = element ? 'Off' : "On";
6256
+ let data;
6257
+ const dialogRef = this.dialog.open(ActionPopupComponent, {
6258
+ width: "400px",
6259
+ data: {
6260
+ title: `Turn this feature ${status}?`,
6261
+ message: `Would you like to turn ${feature.title} feature ${status}`
6262
+ }
6263
+ });
6264
+ dialogRef.afterClosed().subscribe((result) => __awaiter(this, void 0, void 0, function* () {
6265
+ if (result) {
6266
+ try {
6267
+ data = element
6268
+ ? yield this.featureService.disableFeature(feature.id)
6269
+ : yield this.featureService.enableFeature(feature.id);
6270
+ }
6271
+ catch (error) {
6272
+ this.errorHandler.handleError(error);
6273
+ }
6274
+ finally {
6275
+ this.alertService.addAlert(`You have just turned ${status} the feature ${feature.title}`, 'success');
6276
+ this.reload();
6277
+ this.storage.removeItem('features');
6278
+ this.setStorage(this.features);
6279
+ this.isWorking = false;
6280
+ }
6281
+ }
6282
+ else {
6283
+ this.reload();
6284
+ }
6285
+ }));
6286
+ });
6287
+ }
6288
+ setStorage(features) {
6289
+ let localFeatures = [];
6290
+ for (let feature of features) {
6291
+ if (!feature.client_feature) {
6292
+ if (feature.is_enabled_default) {
6293
+ localFeatures.push(feature.code);
6294
+ }
6295
+ }
6296
+ else {
6297
+ if (feature.client_feature.is_enabled) {
6298
+ localFeatures.push(feature.code);
6299
+ }
6300
+ }
6301
+ }
6302
+ this.storage.setItem("features", localFeatures);
6303
+ }
6304
+ reload() {
6305
+ this.features = [];
6306
+ this.page = 1;
6307
+ if (!this.isWorking) {
6308
+ this.loadData();
6309
+ }
6310
+ }
6311
+ onScroll() {
6312
+ if (!this.isWorking && this.page < this.lastPage) {
6313
+ this.page += 1;
6314
+ this.loadData();
6315
+ }
6316
+ }
6317
+ sortColumn(event) {
6318
+ var direction = event.direction.toString().toUpperCase();
6319
+ this.assignFilter(event.active, direction);
6320
+ this.reload();
6321
+ }
6322
+ assignFilter(column, direction) {
6323
+ switch (column) {
6324
+ case 'name': {
6325
+ return this.filterFormGroup
6326
+ .get('sort_by')
6327
+ .setValue('first_name|' + direction);
6328
+ }
6329
+ case 'added_on': {
6330
+ return this.filterFormGroup
6331
+ .get('sort_by')
6332
+ .setValue('created_at|' + direction);
6333
+ }
6334
+ }
6335
+ }
6336
+ };
6337
+ TechlifyFeatureListingComponent.decorators = [
6338
+ { type: Component, args: [{
6339
+ selector: 'app-techlify-listing-feature',
6340
+ template: "<div fxLayout=\"column\" fxLayoutGap=\"3rem\" class=\"p-3\">\n <div fxLayout=\"column\" fxLayoutAlign=\"center center\" class=\"primary-color mt-3\">\n <h3>Features Configuration</h3>\n <mat-hint>\n <i> Here you can specify which optional features you'd like to have available to your team </i>\n </mat-hint>\n </div>\n\n\n <div>\n <mat-card>\n <mat-card-content fxlayout=\"column\" style=\"overflow: auto; height: 700px\" class=\"classifications-card\">\n <table mat-table [dataSource]=\"dataSource\" class=\"mat-elevation-z8 w-100\" matSort multiTemplateDataRows\n (matSortChange)=\"sortColumn($event)\" infiniteScroll [infiniteScrollDistance]=\"2\" [infiniteScrollThrottle]=\"50\"\n (scrolled)=\"onScroll()\" [fromRoot]=\"true\" [infiniteScrollContainer]=\"'.classifications-card'\">\n <!-- Index Column -->\n <ng-container matColumnDef=\"index\">\n <th mat-header-cell *matHeaderCellDef>#</th>\n <td mat-cell *matCellDef=\"let element; let i = dataIndex\">\n {{ i + 1 }}\n </td>\n </ng-container>\n\n <!-- Title Column -->\n <ng-container matColumnDef=\"feature\">\n <th mat-header-cell *matHeaderCellDef mat-sort-header disableClear>\n Feature\n </th>\n <td mat-cell *matCellDef=\"let element\">{{ element?.title }}</td>\n </ng-container>\n\n <!-- Description Column -->\n <ng-container matColumnDef=\"description\">\n <th mat-header-cell *matHeaderCellDef mat-sort-header disableClear>\n Descriptions\n </th>\n <td mat-cell *matCellDef=\"let element\">\n {{ element?.description }}\n </td>\n </ng-container>\n\n <!-- Actions Column -->\n <ng-container matColumnDef=\"actions\">\n <th mat-header-cell *matHeaderCellDef mat-sort-header disableClear>\n Actions\n </th>\n <td mat-cell *matCellDef=\"let element\">\n <div *ngIf=\"!element?.client_feature\">\n <app-on-off-switch [value]=\"element?.is_enabled_default\"\n (click)=\"toggeleFeature(element?.is_enabled_default, element)\"></app-on-off-switch>\n </div>\n <div *ngIf=\"element?.client_feature\">\n <app-on-off-switch [value]=\"element?.client_feature?.is_enabled\"\n (click)=\"toggeleFeature(element?.client_feature?.is_enabled, element)\"></app-on-off-switch>\n </div>\n </td>\n </ng-container>\n\n <tr mat-header-row *matHeaderRowDef=\"displayedColumns\"></tr>\n <tr mat-row *matRowDef=\"let row; columns: displayedColumns\"></tr>\n </table>\n </mat-card-content>\n </mat-card>\n </div>\n</div>\n",
6341
+ styles: [""]
6342
+ },] }
6343
+ ];
6344
+ TechlifyFeatureListingComponent.ctorParameters = () => [
6345
+ { type: DataManager },
6346
+ { type: ErrorHandlerService },
6347
+ { type: FormBuilder },
6348
+ { type: AlertService },
6349
+ { type: MatDialog },
6350
+ { type: StorageService },
6351
+ { type: TechlifyFeatureService }
6352
+ ];
6353
+ TechlifyFeatureListingComponent = __decorate([
6354
+ UntilDestroy()
6355
+ ], TechlifyFeatureListingComponent);
6356
+
6357
+ const routes$n = [
6358
+ {
6359
+ path: '',
6360
+ component: TechlifyFeatureListingComponent,
6361
+ canActivate: [AuthenticationGuard]
6362
+ },
6363
+ ];
6364
+ const TechlifyFeatureRoutes = RouterModule.forChild(routes$n);
6365
+
6366
+ class OnOffSwitchComponent {
6367
+ constructor(fb) {
6368
+ this.fb = fb;
6369
+ this.slideToggle = this.fb.group({
6370
+ toggle: [""]
6371
+ });
6372
+ }
6373
+ ngOnInit() {
6374
+ this.slideToggle.get('toggle').setValue(this.value);
6375
+ }
6376
+ }
6377
+ OnOffSwitchComponent.decorators = [
6378
+ { type: Component, args: [{
6379
+ selector: 'app-on-off-switch',
6380
+ template: "<form [formGroup]=\"slideToggle\">\n <mat-slide-toggle formControlName=\"toggle\">On / Off\n </mat-slide-toggle>\n</form>\n",
6381
+ styles: [""]
6382
+ },] }
6383
+ ];
6384
+ OnOffSwitchComponent.ctorParameters = () => [
6385
+ { type: FormBuilder }
6386
+ ];
6387
+ OnOffSwitchComponent.propDecorators = {
6388
+ value: [{ type: Input }]
6389
+ };
6390
+
6391
+ class TechlifyFeatureEnabledDirective {
6392
+ constructor(el, featureService, errorHandler, storage) {
6393
+ this.el = el;
6394
+ this.featureService = featureService;
6395
+ this.errorHandler = errorHandler;
6396
+ this.storage = storage;
6397
+ this.localFeatures = [];
6398
+ }
6399
+ ngOnInit() {
6400
+ if (!this.storage.getItem('features')) {
6401
+ this.getFeatures();
6402
+ }
6403
+ else {
6404
+ this.checkForFeatureEnabled();
6405
+ }
6406
+ }
6407
+ getFeatures() {
6408
+ return __awaiter(this, void 0, void 0, function* () {
6409
+ try {
6410
+ let features = yield this.featureService.getFeatures();
6411
+ for (let feature of features.data) {
6412
+ if (!feature.client_feature) {
6413
+ if (feature.is_enabled_default) {
6414
+ this.localFeatures.push(feature.code);
6415
+ }
6416
+ }
6417
+ else {
6418
+ if (feature.client_feature.is_enabled) {
6419
+ this.localFeatures.push(feature.code);
6420
+ }
6421
+ }
6422
+ }
6423
+ this.storage.setItem("features", this.localFeatures);
6424
+ }
6425
+ catch (error) {
6426
+ this.errorHandler.handleError(error);
6427
+ }
6428
+ finally {
6429
+ this.checkForFeatureEnabled();
6430
+ }
6431
+ });
6432
+ }
6433
+ checkForFeatureEnabled() {
6434
+ try {
6435
+ let features = this.storage.getItem('features');
6436
+ let features_split = features.split(',');
6437
+ if (features_split.includes(this.enabledFeature)) {
6438
+ this.el.nativeElement.style.display = "show";
6439
+ }
6440
+ else {
6441
+ this.el.nativeElement.remove();
6442
+ }
6443
+ }
6444
+ catch (error) {
6445
+ this.errorHandler.handleError(error);
6446
+ }
6447
+ }
6448
+ }
6449
+ TechlifyFeatureEnabledDirective.decorators = [
6450
+ { type: Directive, args: [{
6451
+ selector: '[techlifyFeatureEnabled]'
6452
+ },] }
6453
+ ];
6454
+ TechlifyFeatureEnabledDirective.ctorParameters = () => [
6455
+ { type: ElementRef },
6456
+ { type: TechlifyFeatureService },
6457
+ { type: ErrorHandlerService },
6458
+ { type: StorageService }
6459
+ ];
6460
+ TechlifyFeatureEnabledDirective.propDecorators = {
6461
+ enabledFeature: [{ type: Input, args: ['techlifyFeatureEnabled',] }]
6462
+ };
6463
+
6464
+ class TechlifyFeatureModule {
6465
+ }
6466
+ TechlifyFeatureModule.decorators = [
6467
+ { type: NgModule, args: [{
6468
+ imports: [
6469
+ CommonModule,
6470
+ MaterialModule,
6471
+ FlexLayoutModule,
6472
+ TechlifyFeatureRoutes,
6473
+ MatSlideToggleModule,
6474
+ FormsModule,
6475
+ ReactiveFormsModule,
6476
+ InfiniteScrollModule
6477
+ ],
6478
+ declarations: [TechlifyFeatureListingComponent, OnOffSwitchComponent, TechlifyFeatureEnabledDirective],
6479
+ exports: [TechlifyFeatureListingComponent, TechlifyFeatureEnabledDirective]
6480
+ },] }
6481
+ ];
6482
+
6067
6483
  /*
6068
6484
  * Public API Surface of ngx-techlify-core
6069
6485
  */
@@ -6072,5 +6488,5 @@ TechlifyTaggerTagSelectorModule.decorators = [
6072
6488
  * Generated bundle index. Do not edit.
6073
6489
  */
6074
6490
 
6075
- export { ActionPopup, ActionPopupComponent, ActionPopupModule, AlertService, ApiPrefixInterceptor, AuditLogForModelComponent, AuditLogForModelModule, AuditLogForModelRoutingModule, AuditLogListComponent, AuditLogListFilterComponent, AuditLogListFilterModule, AuditLogListFilterRoutingModule, AuditLogListModule, AuditLogListRoutingModule, AuditLogModule, AuditLogRoutingModule, AuditLogViewComponent, AuditLogViewModelComponent, AuditLogViewModelModule, AuditLogViewModelRoutingModule, AuditLogViewModule, AuditLogViewRoutingModule, AuditLogsViewModelComponent, AuditLogsViewModelModule, AuditLogsViewModelRoutingModule, AuthenticationGuard, AuthenticationService, CacheInterceptor, ConfigService, CoreModule, CredentialsService, DataManager, DataTable, DataTableComponent, DataTableModule, DateUtils, DateValidator, DocumentViewerComponent, DocumentViewerModule, EmailSubscriptionForUserComponent, EmailSubscriptionForUserModule, EmailSubscriptionForUserRoutingModule, EmailSubscriptionModule, EmailSubscriptionRoutingModule, EmailSubscriptionTypeFormComponent, EmailSubscriptionTypeFormModule, EmailSubscriptionTypeFormRoutingModule, EmailSubscriptionTypeListComponent, EmailSubscriptionTypeListModule, EmailSubscriptionTypeListRoutingModule, EmailSubscriptionTypeModule, EmailSubscriptionTypeRoutingModule, EmailSubscriptionUserFormComponent, EmailSubscriptionUserFormModule, EmailSubscriptionUserFormRoutingModule, EmailSubscriptionUserListComponent, EmailSubscriptionUserListFilterComponent, EmailSubscriptionUserListFilterModule, EmailSubscriptionUserListFilterRoutingModule, EmailSubscriptionUserListModule, EmailSubscriptionUserListRoutingModule, EmailSubscriptionUserModule, EmailSubscriptionUserRoutingModule, EntityFileFormComponent, EntityFilesViewAllComponent, EntityFilesViewAllModule, ErrorHandlerInterceptor, ErrorHandlerService, ErrorSnackComponent, ExportExcelButtonComponent, ExportExcelModule, FailedItemsComponent, FailedItemsModule, FailedItemsRoutingModule, FileDropperComponent, FileDropperConfig, FileDropperModule, FormValidatorService, HTTP_DYNAMIC_INTERCEPTORS, HttpCacheService, HttpService, ImportConfig, ImportCsvComponent, ImportCsvModule, ImportCsvRoutingModule, ImportItemsComponent, ImportItemsModule, ImportItemsRoutingModule, LoaderComponent, LoaderModule, LogLevel, Logger, LoginHistoryForUserComponent, LoginHistoryForUserModule, LoginHistoryForUserRoutingModule, MatSelectInfiniteScrollDirective, MaterialModule, NoteFormComponent, NoteListComponent, NoteModule, NumItemsSelector, NumberSelector, PageEvent, RouteReusableStrategy, SearchableSelectorComponent, SearchableSelectorModule, SnackModule, StorageService, SuccessSnackComponent, TechlifyConfig, TechlifyTaggerTagFormConfigModel, TechlifyTaggerTagFormFieldComponent, TechlifyTaggerTagFormFieldModule, TechlifyTaggerTagSelectorComponent, TechlifyTaggerTagSelectorModule, TechlifyUpdateHistoryModule, TechlifyUpdateModule, Timeline, TimelineFilterComponent, TimelineFilterModule, TokenInterceptor, UpdateNotifierComponent, UpdateNotifierModule, UtilityModule, ViewerConfig, calculateTimeline, esfur, estlr, esulr, SnackModule as ɵa, SuccessSnackComponent as ɵb, EmailSubscriptionUserFormComponent as ɵba, EmailSubscriptionUserListComponent as ɵbb, AuthenticationGuard as ɵbc, CredentialsService as ɵbd, ConfigService as ɵbe, TechlifyConfig as ɵbf, EmailSubscriptionUserListFilterComponent as ɵbg, EmailSubscriptionTypeFormComponent as ɵbh, EmailSubscriptionTypeListComponent as ɵbi, EmailSubscriptionForUserComponent as ɵbj, TechlifyUpdatesListComponent as ɵbk, TechlifyUpdateService as ɵbl, TechlifyUpdateRoutingModule as ɵbm, TechlifyUpdateFormModule as ɵbn, TechlifyUpdateFormComponent as ɵbo, ReadMoreModule as ɵbp, ReadMoreComponent as ɵbq, TechlifyUpdateHistoryRoutingModule as ɵbr, TechlifyUpdateHistoryComponent as ɵbs, UpdateNotifierSnackComponent as ɵbt, UpdateViewModule as ɵbu, UpdateViewComponent as ɵbv, DataManager as ɵbw, ErrorSnackComponent as ɵc, HTTP_DYNAMIC_INTERCEPTORS as ɵd, HttpService as ɵe, RouteReusableStrategy as ɵf, ActionPopupComponent as ɵg, ActionPopup as ɵh, DataTableComponent as ɵi, DocumentViewerComponent as ɵj, EntityFileFormComponent as ɵk, FormValidatorService as ɵl, EntityFileService as ɵm, AlertService as ɵn, EntityFilesViewAllComponent as ɵo, FileDropperComponent as ɵp, NoteListComponent as ɵq, NoteService as ɵr, NoteFormComponent as ɵs, SearchableSelectorComponent as ɵt, MatSelectInfiniteScrollDirective as ɵu, NumItemsSelector as ɵv, NumberSelector as ɵw, TimelineFilterComponent as ɵx, TimelineFilterRoutingModule as ɵy, LoaderComponent as ɵz };
6491
+ export { ActionPopup, ActionPopupComponent, ActionPopupModule, AlertService, ApiPrefixInterceptor, AuditLogForModelComponent, AuditLogForModelModule, AuditLogForModelRoutingModule, AuditLogListComponent, AuditLogListFilterComponent, AuditLogListFilterModule, AuditLogListFilterRoutingModule, AuditLogListModule, AuditLogListRoutingModule, AuditLogModule, AuditLogRoutingModule, AuditLogViewComponent, AuditLogViewModelComponent, AuditLogViewModelModule, AuditLogViewModelRoutingModule, AuditLogViewModule, AuditLogViewRoutingModule, AuditLogsViewModelComponent, AuditLogsViewModelModule, AuditLogsViewModelRoutingModule, AuthenticationGuard, AuthenticationService, CacheInterceptor, CommentFormComponent, ConfigService, CoreModule, CredentialsService, DataManager, DataTable, DataTableComponent, DataTableModule, DateUtils, DateValidator, DocumentViewerComponent, DocumentViewerModule, EmailSubscriptionForUserComponent, EmailSubscriptionForUserModule, EmailSubscriptionForUserRoutingModule, EmailSubscriptionModule, EmailSubscriptionRoutingModule, EmailSubscriptionTypeFormComponent, EmailSubscriptionTypeFormModule, EmailSubscriptionTypeFormRoutingModule, EmailSubscriptionTypeListComponent, EmailSubscriptionTypeListModule, EmailSubscriptionTypeListRoutingModule, EmailSubscriptionTypeModule, EmailSubscriptionTypeRoutingModule, EmailSubscriptionUserFormComponent, EmailSubscriptionUserFormModule, EmailSubscriptionUserFormRoutingModule, EmailSubscriptionUserListComponent, EmailSubscriptionUserListFilterComponent, EmailSubscriptionUserListFilterModule, EmailSubscriptionUserListFilterRoutingModule, EmailSubscriptionUserListModule, EmailSubscriptionUserListRoutingModule, EmailSubscriptionUserModule, EmailSubscriptionUserRoutingModule, EntityFileFormComponent, EntityFilesViewAllComponent, EntityFilesViewAllModule, ErrorHandlerInterceptor, ErrorHandlerService, ErrorSnackComponent, ExportExcelButtonComponent, ExportExcelModule, FailedItemsComponent, FailedItemsModule, FailedItemsRoutingModule, FileDropperComponent, FileDropperConfig, FileDropperModule, FormValidatorService, HTTP_DYNAMIC_INTERCEPTORS, HttpCacheService, HttpService, ImportConfig, ImportCsvComponent, ImportCsvModule, ImportCsvRoutingModule, ImportItemsComponent, ImportItemsModule, ImportItemsRoutingModule, LoaderComponent, LoaderModule, LogLevel, Logger, LoginHistoryForUserComponent, LoginHistoryForUserModule, LoginHistoryForUserRoutingModule, MatSelectInfiniteScrollDirective, MaterialModule, NoteFormComponent, NoteListComponent, NoteModule, NumItemsSelector, NumberSelector, PageEvent, ReadMoreComponent, ReadMoreModule, RouteReusableStrategy, SearchableSelectorComponent, SearchableSelectorModule, SnackModule, StorageService, SuccessSnackComponent, TechlifyConfig, TechlifyFeatureEnabledDirective, TechlifyFeatureListingComponent, TechlifyFeatureModule, TechlifyFeatureRoutes, TechlifyTaggerTagFormConfigModel, TechlifyTaggerTagFormFieldComponent, TechlifyTaggerTagFormFieldModule, TechlifyTaggerTagSelectorComponent, TechlifyTaggerTagSelectorModule, TechlifyUpdateHistoryModule, TechlifyUpdateModule, Timeline, TimelineFilterComponent, TimelineFilterModule, TokenInterceptor, UpdateNotifierComponent, UpdateNotifierModule, UtilityModule, ViewerConfig, calculateTimeline, esfur, estlr, esulr, SnackModule as ɵa, SuccessSnackComponent as ɵb, NumberSelector as ɵba, TimelineFilterComponent as ɵbb, TimelineFilterRoutingModule as ɵbc, LoaderComponent as ɵbd, EmailSubscriptionUserFormComponent as ɵbe, EmailSubscriptionUserListComponent as ɵbf, AuthenticationGuard as ɵbg, EmailSubscriptionUserListFilterComponent as ɵbh, EmailSubscriptionTypeFormComponent as ɵbi, EmailSubscriptionTypeListComponent as ɵbj, EmailSubscriptionForUserComponent as ɵbk, TechlifyUpdatesListComponent as ɵbl, TechlifyUpdateService as ɵbm, TechlifyUpdateRoutingModule as ɵbn, TechlifyUpdateFormModule as ɵbo, TechlifyUpdateFormComponent as ɵbp, TechlifyUpdateHistoryRoutingModule as ɵbq, TechlifyUpdateHistoryComponent as ɵbr, UpdateNotifierSnackComponent as ɵbs, UpdateViewModule as ɵbt, UpdateViewComponent as ɵbu, DataManager as ɵbv, DataManager as ɵbw, ErrorHandlerService as ɵbx, AlertService as ɵby, StorageService as ɵbz, ErrorSnackComponent as ɵc, TechlifyFeatureService as ɵca, AuthenticationGuard as ɵcb, OnOffSwitchComponent as ɵcc, HTTP_DYNAMIC_INTERCEPTORS as ɵd, HttpService as ɵe, RouteReusableStrategy as ɵf, ActionPopupComponent as ɵg, ActionPopup as ɵh, DataTableComponent as ɵi, DocumentViewerComponent as ɵj, EntityFileFormComponent as ɵk, FormValidatorService as ɵl, EntityFileService as ɵm, AlertService as ɵn, EntityFilesViewAllComponent as ɵo, FileDropperComponent as ɵp, NoteListComponent as ɵq, NoteService as ɵr, NoteFormComponent as ɵs, CommentFormComponent as ɵt, CredentialsService as ɵu, ConfigService as ɵv, TechlifyConfig as ɵw, SearchableSelectorComponent as ɵx, MatSelectInfiniteScrollDirective as ɵy, NumItemsSelector as ɵz };
6076
6492
  //# sourceMappingURL=ngx-techlify-core.js.map