@provoly/dashboard 0.12.1 → 0.12.2

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 (29) hide show
  1. package/README.md +1 -1
  2. package/esm2022/dataset/components/dataset-detail/dataset-detail.component.mjs +3 -3
  3. package/esm2022/lib/dashboard/store/dashboard.selectors.mjs +4 -1
  4. package/esm2022/lib/dashboard/store/manifest.service.mjs +1 -1
  5. package/esm2022/notification/components/notification/content/notification-content.component.mjs +1 -1
  6. package/esm2022/notification/style/css.component.mjs +2 -2
  7. package/esm2022/toolbox/components/automate-refresh/automate-refresh.component.mjs +10 -11
  8. package/esm2022/toolbox/components/clear-view/clear-view.component.mjs +2 -1
  9. package/esm2022/toolbox/components/filter-settings/filter-settings.component.mjs +2 -1
  10. package/esm2022/toolbox/components/launch-tab/launch-tab.component.mjs +2 -1
  11. package/esm2022/toolbox/components/refresh-datasets/refresh-datasets.component.mjs +3 -2
  12. package/esm2022/toolbox/components/save-view/save-view.component.mjs +2 -1
  13. package/esm2022/toolbox/components/select-grid-layout/select-grid-layout.component.mjs +2 -1
  14. package/esm2022/toolbox/components/toolbox-action/toolbox-action.component.mjs +4 -1
  15. package/fesm2022/provoly-dashboard-dataset.mjs +2 -2
  16. package/fesm2022/provoly-dashboard-dataset.mjs.map +1 -1
  17. package/fesm2022/provoly-dashboard-notification.mjs +2 -2
  18. package/fesm2022/provoly-dashboard-notification.mjs.map +1 -1
  19. package/fesm2022/provoly-dashboard-toolbox.mjs +14 -6
  20. package/fesm2022/provoly-dashboard-toolbox.mjs.map +1 -1
  21. package/fesm2022/provoly-dashboard.mjs +92 -90
  22. package/fesm2022/provoly-dashboard.mjs.map +1 -1
  23. package/lib/dashboard/store/dashboard.selectors.d.ts +8 -0
  24. package/lib/dashboard/store/manifest.service.d.ts +1 -1
  25. package/notification/style/_m-notifications.scss +1 -1
  26. package/package.json +1 -1
  27. package/toolbox/components/automate-refresh/automate-refresh.component.d.ts +3 -2
  28. package/toolbox/components/refresh-datasets/refresh-datasets.component.d.ts +1 -1
  29. package/toolbox/components/toolbox-action/toolbox-action.component.d.ts +1 -0
@@ -20,6 +20,7 @@ import { ComponentPortal, TemplatePortal } from '@angular/cdk/portal';
20
20
  import equal from 'fast-deep-equal/es6';
21
21
  import { distinctUntilChanged, filter as filter$1, debounceTime as debounceTime$1, mergeMap as mergeMap$1, map as map$1, catchError, withLatestFrom, tap, delay } from 'rxjs/operators';
22
22
  import { animation, style, animate, trigger, transition, useAnimation } from '@angular/animations';
23
+ import { v4 } from 'uuid';
23
24
  import { GeoJSON } from 'ol/format';
24
25
  import { fromLonLat } from 'ol/proj';
25
26
  import * as i2$2 from '@angular/forms';
@@ -27,7 +28,6 @@ import { NG_VALUE_ACCESSOR, FormsModule } from '@angular/forms';
27
28
  import * as i2$3 from '@ng-select/ng-select';
28
29
  import { NgSelectModule } from '@ng-select/ng-select';
29
30
  import { webSocket } from 'rxjs/webSocket';
30
- import { v4 } from 'uuid';
31
31
  import * as i8 from '@provoly/dashboard/components/checkbox';
32
32
  import { PryCheckboxModule } from '@provoly/dashboard/components/checkbox';
33
33
 
@@ -3624,6 +3624,95 @@ var DashboardGridLayout;
3624
3624
  DashboardGridLayout["MANUAL"] = "0";
3625
3625
  })(DashboardGridLayout || (DashboardGridLayout = {}));
3626
3626
 
3627
+ class ManifestService {
3628
+ constructor(httpClient, store, snackBar, translateService) {
3629
+ this.httpClient = httpClient;
3630
+ this.store = store;
3631
+ this.snackBar = snackBar;
3632
+ this.translateService = translateService;
3633
+ }
3634
+ list() {
3635
+ return this.store.select(ConfigSelectors.refUrl).pipe(mergeMap((url) => this.httpClient.get(encodeURI(`${url}/users/me/dashboards`))), catchError((error) => {
3636
+ if (error.error instanceof Error) {
3637
+ // A client-side or network error occurred
3638
+ console.error('A frontend error occurred:', error.error.message);
3639
+ this.snackBar.open({
3640
+ type: 'error',
3641
+ message: this.translateService.instant('@pry.manifest.get.errorFront', { msg: error.error.message })
3642
+ });
3643
+ }
3644
+ else {
3645
+ // The backend returned an unsuccessful response code.
3646
+ if (error.code !== 200) {
3647
+ console.error(`Backend returned code ${error.status}, body was: ${JSON.stringify(error.error)}`);
3648
+ }
3649
+ if (error.code >= 400) {
3650
+ this.snackBar.open({
3651
+ type: 'error',
3652
+ message: this.translateService.instant('@pry.manifest.get.errorBack', {
3653
+ code: error.status
3654
+ })
3655
+ });
3656
+ }
3657
+ }
3658
+ return of([]);
3659
+ }));
3660
+ }
3661
+ get(id) {
3662
+ return this.store
3663
+ .select(ConfigSelectors.refUrl)
3664
+ .pipe(mergeMap((url) => this.httpClient.get(encodeURI(`${url}/users/me/dashboards/id/${id}/manifest`))));
3665
+ }
3666
+ save(name, manifest, visibility, id, description, image, cover) {
3667
+ return this.store.select(ConfigSelectors.refUrl).pipe(mergeMap((url) => this.httpClient.post(encodeURI(`${url}/users/me/dashboards`), {
3668
+ id: id === undefined || id.length === 0 ? v4() : id,
3669
+ name,
3670
+ description,
3671
+ manifest,
3672
+ image,
3673
+ visibility,
3674
+ cover,
3675
+ datasource: ManifestService.getDatasourcesUsedByManifest(manifest)
3676
+ })));
3677
+ }
3678
+ delete(id) {
3679
+ return this.store
3680
+ .select(ConfigSelectors.refUrl)
3681
+ .pipe(mergeMap((url) => this.httpClient.delete(encodeURI(`${url}/users/me/dashboards/id/${id}`))));
3682
+ }
3683
+ default(id) {
3684
+ return this.store.select(ConfigSelectors.refUrl).pipe(withLatestFrom(this.store.select(DashboardSelectors.manifestsList)), mergeMap(([url, manifests]) => {
3685
+ const actual = manifests.find((manifest) => manifest.id === id);
3686
+ if (!!actual && !actual.default) {
3687
+ return this.httpClient
3688
+ .put(encodeURI(`${url}/users/me/dashboards/id/${id}/default`), {})
3689
+ .pipe(map$1(() => true));
3690
+ }
3691
+ else {
3692
+ return this.httpClient
3693
+ .delete(encodeURI(`${url}/users/me/dashboards/default`), {})
3694
+ .pipe(map$1(() => false));
3695
+ }
3696
+ }));
3697
+ }
3698
+ static getDatasourcesUsedByManifest(manifest) {
3699
+ return [
3700
+ ...new Set(manifest.windows
3701
+ .map((window) => window.widgets.map((widget) => widget.datasource))
3702
+ .flat(3)
3703
+ .filter((dataset) => !!dataset))
3704
+ ];
3705
+ }
3706
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.6", ngImport: i0, type: ManifestService, deps: [{ token: i1$2.HttpClient }, { token: i1.Store }, { token: PrySnackbarService }, { token: PryI18nService }], target: i0.ɵɵFactoryTarget.Injectable }); }
3707
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.6", ngImport: i0, type: ManifestService, providedIn: 'root' }); }
3708
+ }
3709
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.6", ngImport: i0, type: ManifestService, decorators: [{
3710
+ type: Injectable,
3711
+ args: [{
3712
+ providedIn: 'root'
3713
+ }]
3714
+ }], ctorParameters: function () { return [{ type: i1$2.HttpClient }, { type: i1.Store }, { type: PrySnackbarService }, { type: PryI18nService }]; } });
3715
+
3627
3716
  const NEW_WINDOW_TARGET = -1;
3628
3717
  const feature$4 = createFeatureSelector('@pry/dashboard');
3629
3718
  const manifests = createSelector(feature$4, (state) => state?.manifests);
@@ -3632,6 +3721,7 @@ const currentManifestId = createSelector(manifests, (manifests) => manifests.cur
3632
3721
  const globalManifest = createSelector(manifests,
3633
3722
  // @ts-ignore
3634
3723
  (manifests) => ({ windows: [], ...manifests?.manifest } ?? { windows: [] }));
3724
+ const manifestDatasources = createSelector(globalManifest, (manifest) => ManifestService.getDatasourcesUsedByManifest(manifest));
3635
3725
  const staticManifest = createSelector(manifests,
3636
3726
  // @ts-ignore
3637
3727
  (manifests) => ({ windows: [], ...manifests?.staticManifest } ?? { windows: [] }));
@@ -3707,6 +3797,7 @@ const DashboardSelectors = {
3707
3797
  rank,
3708
3798
  currentManifestId,
3709
3799
  globalManifest,
3800
+ manifestDatasources,
3710
3801
  refreshRates,
3711
3802
  windowManifest,
3712
3803
  widgetManifest,
@@ -9185,95 +9276,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.6", ngImpor
9185
9276
  args: ['filters', { read: ViewContainerRef }]
9186
9277
  }] } });
9187
9278
 
9188
- class ManifestService {
9189
- constructor(httpClient, store, snackBar, translateService) {
9190
- this.httpClient = httpClient;
9191
- this.store = store;
9192
- this.snackBar = snackBar;
9193
- this.translateService = translateService;
9194
- }
9195
- list() {
9196
- return this.store.select(ConfigSelectors.refUrl).pipe(mergeMap((url) => this.httpClient.get(encodeURI(`${url}/users/me/dashboards`))), catchError((error) => {
9197
- if (error.error instanceof Error) {
9198
- // A client-side or network error occurred
9199
- console.error('A frontend error occurred:', error.error.message);
9200
- this.snackBar.open({
9201
- type: 'error',
9202
- message: this.translateService.instant('@pry.manifest.get.errorFront', { msg: error.error.message })
9203
- });
9204
- }
9205
- else {
9206
- // The backend returned an unsuccessful response code.
9207
- if (error.code !== 200) {
9208
- console.error(`Backend returned code ${error.status}, body was: ${JSON.stringify(error.error)}`);
9209
- }
9210
- if (error.code >= 400) {
9211
- this.snackBar.open({
9212
- type: 'error',
9213
- message: this.translateService.instant('@pry.manifest.get.errorBack', {
9214
- code: error.status
9215
- })
9216
- });
9217
- }
9218
- }
9219
- return of([]);
9220
- }));
9221
- }
9222
- get(id) {
9223
- return this.store
9224
- .select(ConfigSelectors.refUrl)
9225
- .pipe(mergeMap((url) => this.httpClient.get(encodeURI(`${url}/users/me/dashboards/id/${id}/manifest`))));
9226
- }
9227
- save(name, manifest, visibility, id, description, image, cover) {
9228
- return this.store.select(ConfigSelectors.refUrl).pipe(mergeMap((url) => this.httpClient.post(encodeURI(`${url}/users/me/dashboards`), {
9229
- id: id === undefined || id.length === 0 ? v4() : id,
9230
- name,
9231
- description,
9232
- manifest,
9233
- image,
9234
- visibility,
9235
- cover,
9236
- datasource: ManifestService.getDatasourcesUsedByManifest(manifest)
9237
- })));
9238
- }
9239
- delete(id) {
9240
- return this.store
9241
- .select(ConfigSelectors.refUrl)
9242
- .pipe(mergeMap((url) => this.httpClient.delete(encodeURI(`${url}/users/me/dashboards/id/${id}`))));
9243
- }
9244
- default(id) {
9245
- return this.store.select(ConfigSelectors.refUrl).pipe(withLatestFrom(this.store.select(DashboardSelectors.manifestsList)), mergeMap(([url, manifests]) => {
9246
- const actual = manifests.find((manifest) => manifest.id === id);
9247
- if (!!actual && !actual.default) {
9248
- return this.httpClient
9249
- .put(encodeURI(`${url}/users/me/dashboards/id/${id}/default`), {})
9250
- .pipe(map$1(() => true));
9251
- }
9252
- else {
9253
- return this.httpClient
9254
- .delete(encodeURI(`${url}/users/me/dashboards/default`), {})
9255
- .pipe(map$1(() => false));
9256
- }
9257
- }));
9258
- }
9259
- static getDatasourcesUsedByManifest(manifest) {
9260
- return [
9261
- ...new Set(manifest.windows
9262
- .map((window) => window.widgets.map((widget) => widget.datasource))
9263
- .flat(3)
9264
- .filter((dataset) => !!dataset))
9265
- ];
9266
- }
9267
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.6", ngImport: i0, type: ManifestService, deps: [{ token: i1$2.HttpClient }, { token: i1.Store }, { token: PrySnackbarService }, { token: PryI18nService }], target: i0.ɵɵFactoryTarget.Injectable }); }
9268
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.6", ngImport: i0, type: ManifestService, providedIn: 'root' }); }
9269
- }
9270
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.6", ngImport: i0, type: ManifestService, decorators: [{
9271
- type: Injectable,
9272
- args: [{
9273
- providedIn: 'root'
9274
- }]
9275
- }], ctorParameters: function () { return [{ type: i1$2.HttpClient }, { type: i1.Store }, { type: PrySnackbarService }, { type: PryI18nService }]; } });
9276
-
9277
9279
  class DefaultViewGuard {
9278
9280
  constructor(manifestService, router, store) {
9279
9281
  this.manifestService = manifestService;