UI: Fix pageLink without pagination. Minor fixes
This commit is contained in:
		
							parent
							
								
									2ca2b1b1f2
								
							
						
					
					
						commit
						4f3e29b433
					
				
							
								
								
									
										4
									
								
								ui-ngx/package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										4
									
								
								ui-ngx/package-lock.json
									
									
									
										generated
									
									
									
								
							@ -8997,10 +8997,10 @@
 | 
			
		||||
      "integrity": "sha512-4O3GWAYJaauMCILm07weko2rHA8a4kjn7+8Lg4s1d7SxwS/3IpkVD/GljbRrIJ1c1W/XGJ3GbuK7RyYZEJChhw=="
 | 
			
		||||
    },
 | 
			
		||||
    "ngx-flowchart": {
 | 
			
		||||
      "version": "git://github.com/thingsboard/ngx-flowchart.git#a4157b0eef2eb3646ef920447c7b06b39d54f87f",
 | 
			
		||||
      "version": "git://github.com/thingsboard/ngx-flowchart.git#7a02f4748b5e7821a883c903107af5f20415d026",
 | 
			
		||||
      "from": "git://github.com/thingsboard/ngx-flowchart.git#master",
 | 
			
		||||
      "requires": {
 | 
			
		||||
        "tslib": "^1.10.0"
 | 
			
		||||
        "tslib": "^1.13.0"
 | 
			
		||||
      },
 | 
			
		||||
      "dependencies": {
 | 
			
		||||
        "tslib": {
 | 
			
		||||
 | 
			
		||||
@ -337,6 +337,7 @@ export class WidgetSubscription implements IWidgetSubscription {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private initDataSubscription(): Observable<any> {
 | 
			
		||||
    this.notifyDataLoading();
 | 
			
		||||
    const initDataSubscriptionSubject = new ReplaySubject(1);
 | 
			
		||||
    this.loadStDiff().subscribe(() => {
 | 
			
		||||
      if (!this.ctx.aliasController) {
 | 
			
		||||
@ -431,6 +432,7 @@ export class WidgetSubscription implements IWidgetSubscription {
 | 
			
		||||
        });
 | 
			
		||||
        this.configureLoadedData();
 | 
			
		||||
        this.hasResolvedData = this.datasources.length > 0;
 | 
			
		||||
        this.updateDataTimewindow();
 | 
			
		||||
        this.notifyDataLoaded();
 | 
			
		||||
        this.onDataUpdated(true);
 | 
			
		||||
      })
 | 
			
		||||
@ -731,6 +733,7 @@ export class WidgetSubscription implements IWidgetSubscription {
 | 
			
		||||
      if (this.type === widgetType.alarm) {
 | 
			
		||||
        this.updateAlarmDataSubscription();
 | 
			
		||||
      } else {
 | 
			
		||||
        this.notifyDataLoading();
 | 
			
		||||
        this.dataSubscribe();
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
@ -831,13 +834,21 @@ export class WidgetSubscription implements IWidgetSubscription {
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private dataSubscribe() {
 | 
			
		||||
  private updateDataTimewindow() {
 | 
			
		||||
    if (!this.hasDataPageLink) {
 | 
			
		||||
      if (this.type === widgetType.timeseries && this.timeWindowConfig) {
 | 
			
		||||
        this.updateRealtimeSubscription();
 | 
			
		||||
        if (this.comparisonEnabled) {
 | 
			
		||||
          this.updateSubscriptionForComparison();
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private dataSubscribe() {
 | 
			
		||||
    if (!this.hasDataPageLink) {
 | 
			
		||||
      if (this.type === widgetType.timeseries && this.timeWindowConfig) {
 | 
			
		||||
        this.updateDataTimewindow();
 | 
			
		||||
        if (this.subscriptionTimewindow.fixedWindow) {
 | 
			
		||||
          this.onDataUpdated();
 | 
			
		||||
        }
 | 
			
		||||
@ -1025,6 +1036,11 @@ export class WidgetSubscription implements IWidgetSubscription {
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private notifyDataLoading() {
 | 
			
		||||
    this.loadingData = true;
 | 
			
		||||
    this.callbacks.dataLoading(this);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private notifyDataLoaded() {
 | 
			
		||||
    this.loadingData = false;
 | 
			
		||||
    this.callbacks.dataLoading(this);
 | 
			
		||||
@ -1268,6 +1284,7 @@ export class WidgetSubscription implements IWidgetSubscription {
 | 
			
		||||
      if (this.caulculateLegendData) {
 | 
			
		||||
        this.updateLegend(index, data.data, detectChanges);
 | 
			
		||||
      }
 | 
			
		||||
      this.notifyDataLoaded();
 | 
			
		||||
      this.onDataUpdated(detectChanges);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@ -330,7 +330,7 @@ export class AlarmsTableWidgetComponent extends PageComponent implements OnInit,
 | 
			
		||||
      this.defaultPageSize = pageSize;
 | 
			
		||||
    }
 | 
			
		||||
    this.pageSizeOptions = [this.defaultPageSize, this.defaultPageSize * 2, this.defaultPageSize * 3];
 | 
			
		||||
    this.pageLink.pageSize = this.displayPagination ? this.defaultPageSize : Number.POSITIVE_INFINITY;
 | 
			
		||||
    this.pageLink.pageSize = this.displayPagination ? this.defaultPageSize : 1024;
 | 
			
		||||
 | 
			
		||||
    this.pageLink.searchPropagatedAlarms = isDefined(this.widgetConfig.searchPropagatedAlarms)
 | 
			
		||||
      ? this.widgetConfig.searchPropagatedAlarms : true;
 | 
			
		||||
@ -535,10 +535,15 @@ export class AlarmsTableWidgetComponent extends PageComponent implements OnInit,
 | 
			
		||||
    } else {
 | 
			
		||||
      this.pageLink.page = 0;
 | 
			
		||||
    }
 | 
			
		||||
    const key = findEntityKeyByColumnDef(this.sort.active, this.columns);
 | 
			
		||||
    if (key) {
 | 
			
		||||
      this.pageLink.sortOrder = {
 | 
			
		||||
      key: findEntityKeyByColumnDef(this.sort.active, this.columns),
 | 
			
		||||
        key,
 | 
			
		||||
        direction: Direction[this.sort.direction.toUpperCase()]
 | 
			
		||||
      };
 | 
			
		||||
    } else {
 | 
			
		||||
      this.pageLink.sortOrder = null;
 | 
			
		||||
    }
 | 
			
		||||
    const sortOrderLabel = fromEntityColumnDef(this.sort.active, this.columns);
 | 
			
		||||
    const keyFilters: KeyFilter[] = null; // TODO:
 | 
			
		||||
    this.alarmsDatasource.loadAlarms(this.pageLink, sortOrderLabel, keyFilters);
 | 
			
		||||
 | 
			
		||||
@ -240,7 +240,7 @@ export class EntitiesTableWidgetComponent extends PageComponent implements OnIni
 | 
			
		||||
      this.defaultPageSize = pageSize;
 | 
			
		||||
    }
 | 
			
		||||
    this.pageSizeOptions = [this.defaultPageSize, this.defaultPageSize * 2, this.defaultPageSize * 3];
 | 
			
		||||
    this.pageLink.pageSize = this.displayPagination ? this.defaultPageSize : Number.POSITIVE_INFINITY;
 | 
			
		||||
    this.pageLink.pageSize = this.displayPagination ? this.defaultPageSize : 1024;
 | 
			
		||||
 | 
			
		||||
    const cssString = constructTableCssString(this.widgetConfig);
 | 
			
		||||
    const cssParser = new cssjs();
 | 
			
		||||
@ -460,10 +460,15 @@ export class EntitiesTableWidgetComponent extends PageComponent implements OnIni
 | 
			
		||||
    } else {
 | 
			
		||||
      this.pageLink.page = 0;
 | 
			
		||||
    }
 | 
			
		||||
    const key = findEntityKeyByColumnDef(this.sort.active, this.columns);
 | 
			
		||||
    if (key) {
 | 
			
		||||
      this.pageLink.sortOrder = {
 | 
			
		||||
      key: findEntityKeyByColumnDef(this.sort.active, this.columns),
 | 
			
		||||
        key,
 | 
			
		||||
        direction: Direction[this.sort.direction.toUpperCase()]
 | 
			
		||||
      };
 | 
			
		||||
    } else {
 | 
			
		||||
      this.pageLink.sortOrder = null;
 | 
			
		||||
    }
 | 
			
		||||
    const sortOrderLabel = fromEntityColumnDef(this.sort.active, this.columns);
 | 
			
		||||
    const keyFilters: KeyFilter[] = null; // TODO:
 | 
			
		||||
    this.entityDatasource.loadEntities(this.pageLink, sortOrderLabel, keyFilters);
 | 
			
		||||
 | 
			
		||||
@ -159,7 +159,7 @@ function parseTemplate(template: string, data: { $datasource?: Datasource, [key:
 | 
			
		||||
    }
 | 
			
		||||
    template = createLabelFromDatasource(data.$datasource, template);
 | 
			
		||||
 | 
			
		||||
    let match = varsRegex.exec(template);
 | 
			
		||||
    let match = /\${([^}]*)}/g.exec(template);
 | 
			
		||||
    while (match !== null) {
 | 
			
		||||
      const variable = match[0];
 | 
			
		||||
      let label = match[1];
 | 
			
		||||
@ -186,7 +186,7 @@ function parseTemplate(template: string, data: { $datasource?: Datasource, [key:
 | 
			
		||||
        textValue = value;
 | 
			
		||||
      }
 | 
			
		||||
      template = template.split(variable).join(textValue);
 | 
			
		||||
      match = varsRegex.exec(template);
 | 
			
		||||
      match = /\${([^}]*)}/g.exec(template);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    let actionTags: string;
 | 
			
		||||
 | 
			
		||||
@ -96,7 +96,10 @@ export function entityDataSortOrderFromString(strSortOrder: string, columns: Ent
 | 
			
		||||
  if (!property && !property.length) {
 | 
			
		||||
    return null;
 | 
			
		||||
  }
 | 
			
		||||
  const column = findColumnByLabel(property, columns);
 | 
			
		||||
  let column = findColumnByLabel(property, columns);
 | 
			
		||||
  if (!column) {
 | 
			
		||||
    column = findColumnByName(property, columns);
 | 
			
		||||
  }
 | 
			
		||||
  if (column && column.entityKey) {
 | 
			
		||||
    return {key: column.entityKey, direction};
 | 
			
		||||
  }
 | 
			
		||||
@ -113,13 +116,22 @@ export function findColumnByEntityKey(key: EntityKey, columns: EntityColumn[]):
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function findEntityKeyByColumnDef(def: string, columns: EntityColumn[]): EntityKey {
 | 
			
		||||
  return findColumnByDef(def, columns).entityKey;
 | 
			
		||||
  if (def) {
 | 
			
		||||
    const column = findColumnByDef(def, columns);
 | 
			
		||||
    return column ? column.entityKey : null;
 | 
			
		||||
  } else {
 | 
			
		||||
    return null;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function findColumn(searchProperty: string, searchValue: string, columns: EntityColumn[]): EntityColumn {
 | 
			
		||||
  return columns.find(theColumn => theColumn[searchProperty] === searchValue);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function findColumnByName(name: string, columns: EntityColumn[]): EntityColumn {
 | 
			
		||||
  return findColumn('name', name, columns);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function findColumnByLabel(label: string, columns: EntityColumn[]): EntityColumn {
 | 
			
		||||
  let column: EntityColumn;
 | 
			
		||||
  const alarmColumns = columns.filter(c => c.type === DataKeyType.alarm);
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user