Add baseUrl method
This commit is contained in:
		
							parent
							
								
									c428b58720
								
							
						
					
					
						commit
						119cd91fa3
					
				@ -21,6 +21,7 @@ import { Inject, Injectable, NgZone } from '@angular/core';
 | 
			
		||||
import { WINDOW } from '@core/services/window.service';
 | 
			
		||||
import { ExceptionData } from '@app/shared/models/error.models';
 | 
			
		||||
import {
 | 
			
		||||
  baseUrl,
 | 
			
		||||
  createLabelFromDatasource,
 | 
			
		||||
  deepClone,
 | 
			
		||||
  deleteNullProperties,
 | 
			
		||||
@ -409,7 +410,7 @@ export class UtilsService {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public updateQueryParam(name: string, value: string | null) {
 | 
			
		||||
    const baseUrl = [this.window.location.protocol, '//', this.window.location.host, this.window.location.pathname].join('');
 | 
			
		||||
    const baseUrlPart = [baseUrl(), this.window.location.pathname].join('');
 | 
			
		||||
    const urlQueryString = this.window.location.search;
 | 
			
		||||
    let newParam = '';
 | 
			
		||||
    let params = '';
 | 
			
		||||
@ -429,7 +430,11 @@ export class UtilsService {
 | 
			
		||||
    } else if (newParam) {
 | 
			
		||||
      params = '?' + newParam;
 | 
			
		||||
    }
 | 
			
		||||
    this.window.history.replaceState({}, '', baseUrl + params);
 | 
			
		||||
    this.window.history.replaceState({}, '', baseUrlPart + params);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public baseUrl(): string {
 | 
			
		||||
    return baseUrl();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public deepClone<T>(target: T, ignoreFields?: string[]): T {
 | 
			
		||||
 | 
			
		||||
@ -385,6 +385,15 @@ export function padValue(val: any, dec: number): string {
 | 
			
		||||
  return strVal;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function baseUrl(): string {
 | 
			
		||||
  let url = window.location.protocol + '//' + window.location.hostname;
 | 
			
		||||
  const port = window.location.port;
 | 
			
		||||
  if (port && port.length > 0 && port !== '80' && port !== '443') {
 | 
			
		||||
    url += ':' + port;
 | 
			
		||||
  }
 | 
			
		||||
  return url;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function sortObjectKeys<T>(obj: T): T {
 | 
			
		||||
  return Object.keys(obj).sort().reduce((acc, key) => {
 | 
			
		||||
    acc[key] = obj[key];
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user