@esfaenza/admin-module 15.2.12 → 15.2.14

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.
@@ -31,8 +31,8 @@ import * as i3 from '@esfaenza/preferences';
31
31
  import * as i4 from '@esfaenza/httpservice';
32
32
  import { HttpParams } from '@angular/common/http';
33
33
  import { __decorate } from 'tslib';
34
- import { catchError } from 'rxjs/operators';
35
- import { of } from 'rxjs';
34
+ import { takeUntil, catchError } from 'rxjs/operators';
35
+ import { ReplaySubject, interval, of } from 'rxjs';
36
36
 
37
37
  class AuditsView extends AppSearch {
38
38
  constructor() {
@@ -715,6 +715,8 @@ class AdmTopActivitiesComponent {
715
715
  this.searchView = new TopActivitiesDataView();
716
716
  this.autoUpdate = false;
717
717
  this.seconds = "5";
718
+ this.rtWindow = null;
719
+ this.destroyed$ = new ReplaySubject(1);
718
720
  this.seriesPropertiesMapping = {};
719
721
  this.propertiesSeriesMapping = {
720
722
  ["cputime"]: "CPU",
@@ -729,10 +731,31 @@ class AdmTopActivitiesComponent {
729
731
  this.intercom.send(InboundMessageTypes.Navigation, { sub: false, routeTitle: this.lc.loc(this.route.snapshot.data["title"]) });
730
732
  }
731
733
  ngOnInit() {
734
+ // Ogni minuto calcolo qual è la finestra del realTime
735
+ interval(60 * 1000).pipe(takeUntil(this.destroyed$)).subscribe(_ => {
736
+ this.updateRealTimeWindow();
737
+ });
732
738
  this.storageSub = this.route.queryParams.subscribe(params => {
733
739
  this.Init(params["ignoreStorage"]);
734
740
  });
735
741
  }
742
+ async updateRealTimeWindow() {
743
+ let data = new TopActivitiesDataView();
744
+ data = await this.http.post(Repository.POST_Director_GetTopActivities, data).toPromise();
745
+ let reference = data.items[0];
746
+ for (let i = 0; i < reference.actsessions.length; i++) {
747
+ let itemref = reference.actsessions[i];
748
+ let theD = this.dateExts.getDateConvertion(itemref.sampletime);
749
+ if (!this.rtWindow)
750
+ this.rtWindow = { from: theD, to: theD };
751
+ else {
752
+ if (theD.isBefore(this.rtWindow.from))
753
+ this.rtWindow.from = theD;
754
+ if (theD.isAfter(this.rtWindow.to))
755
+ this.rtWindow.to = theD;
756
+ }
757
+ }
758
+ }
736
759
  Init(ignoreStore) {
737
760
  this.doInit(ignoreStore);
738
761
  }
@@ -759,14 +782,20 @@ class AdmTopActivitiesComponent {
759
782
  }
760
783
  }
761
784
  ngOnDestroy() {
785
+ this.destroyed$.next(true);
786
+ this.destroyed$.complete();
762
787
  if (this.storageSub)
763
788
  this.storageSub.unsubscribe();
764
789
  }
765
- sendSearch(resetPage = true, update = false, searchViewOverride = null) {
766
- this.searchView.searchinprogress = true;
767
- if (resetPage)
768
- this.searchView.page = 1;
769
- this.POSTGetItems(Repository.POST_Director_GetTopActivities, searchViewOverride ?? this.searchView, update);
790
+ async sendSearch(resetPage = true, update = false, searchViewOverride = null) {
791
+ let sv = searchViewOverride ?? this.searchView;
792
+ if ((sv.filterfrom || sv.filterto) && !this.rtWindow)
793
+ await this.updateRealTimeWindow();
794
+ let dateRequestOnRealtimeWindow = sv.filterfrom && this.dateExts.getDateConvertion(sv.filterfrom).isAfter(this.rtWindow.from) &&
795
+ sv.filterto && this.dateExts.getDateConvertion(sv.filterto).isBefore(this.rtWindow.to);
796
+ sv.filterrealtime = dateRequestOnRealtimeWindow;
797
+ sv.searchinprogress = true;
798
+ this.POSTGetItems(Repository.POST_Director_GetTopActivities, sv, update);
770
799
  }
771
800
  POSTGetItems(url, data, update) {
772
801
  this.http.post(url, data).subscribe(async (t) => {
@@ -1064,7 +1093,7 @@ class AdmMetricsComponent {
1064
1093
  this.metricsToShow = [];
1065
1094
  this.searchView = t;
1066
1095
  this.searchView.items.forEach(m => {
1067
- if (!this.Instances.find(t => t.id == m.instance))
1096
+ if (!this.Instances.find(t => t.id == m.instance) && m.instance)
1068
1097
  this.Instances.push(new KeyValue(m.instance, m.instance));
1069
1098
  });
1070
1099
  this.instanceRequired = this.Instances.length > 1;
@@ -1072,6 +1101,8 @@ class AdmMetricsComponent {
1072
1101
  this.selectedInstance = this.Instances[0].id;
1073
1102
  this.instanceSelected();
1074
1103
  }
1104
+ else
1105
+ this.instanceSelected(true);
1075
1106
  this.localStorage.setItem("HotSearchMetrics", this.searchView).subscribe();
1076
1107
  }
1077
1108
  else {
@@ -1092,10 +1123,10 @@ class AdmMetricsComponent {
1092
1123
  this.searchView.searchinprogress = false;
1093
1124
  });
1094
1125
  }
1095
- instanceSelected() {
1096
- if (!this.selectedInstance)
1126
+ instanceSelected(allowNull = false) {
1127
+ if (!this.selectedInstance && !allowNull)
1097
1128
  return;
1098
- this.metricsToShow = this.searchView.items.filter(t => t.instance == this.selectedInstance);
1129
+ this.metricsToShow = this.searchView.items.filter(t => !this.selectedInstance || (t.instance == this.selectedInstance));
1099
1130
  }
1100
1131
  linkChartToMetric(metric, metricChart, chartComp) {
1101
1132
  this.MetricsChartCache[this.metricKey(metric, metricChart)] = { chart: chartComp, lastTs: metricChart.series.map(t => dayjs.max(t.values.map(v => this.dateExts.getDateConvertion(v.d))))[0] };