projects
/
osm
/
NG-UI.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Feature 11009 Ns Config Template as first class citizens in OSM
[osm/NG-UI.git]
/
src
/
services
/
SharedService.ts
diff --git
a/src/services/SharedService.ts
b/src/services/SharedService.ts
index
e8eac94
..
61c3367
100644
(file)
--- a/
src/services/SharedService.ts
+++ b/
src/services/SharedService.ts
@@
-18,7
+18,6
@@
/**
* @file Provider for Shared Service
*/
/**
* @file Provider for Shared Service
*/
-import { isNullOrUndefined } from 'util';
import { HttpErrorResponse, HttpHeaders } from '@angular/common/http';
import { EventEmitter, Injectable, Output } from '@angular/core';
import { FormArray, FormGroup } from '@angular/forms';
import { HttpErrorResponse, HttpHeaders } from '@angular/common/http';
import { EventEmitter, Injectable, Output } from '@angular/core';
import { FormArray, FormGroup } from '@angular/forms';
@@
-82,6
+81,9
@@
export class SharedService {
/** Variables to hold regexp pattern for Longitude */
public REGX_LONG_PATTERN: RegExp = new RegExp(/^(\+|-)?(?:180(?:(?:\.0{1,6})?)|(?:[0-9]|[1-9][0-9]|1[0-7][0-9])(?:(?:\.[0-9]{1,15})?))$/);
/** Variables to hold regexp pattern for Longitude */
public REGX_LONG_PATTERN: RegExp = new RegExp(/^(\+|-)?(?:180(?:(?:\.0{1,6})?)|(?:[0-9]|[1-9][0-9]|1[0-7][0-9])(?:(?:\.[0-9]{1,15})?))$/);
+ /** Variable to hold regexp pattern for EMAIL */
+ public REGX_EMAIL_PATTERN: RegExp = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
+
/** Variables to hold maxlength for the description @public */
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
public MAX_LENGTH_DESCRIPTION: number = 500;
/** Variables to hold maxlength for the description @public */
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
public MAX_LENGTH_DESCRIPTION: number = 500;
@@
-128,9
+130,13
@@
export class SharedService {
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
private randomStringLength: number = 4;
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
private randomStringLength: number = 4;
- /** Max length of Uint8Array */
+ /** express number for rgb manipulation */
+ // eslint-disable-next-line @typescript-eslint/no-magic-numbers
+ private colourHour: number = 10;
+
+ /** express number for rgb manipulation*/
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
- private
unit8Array: number = 25
5;
+ private
colourMin: number =
5;
/** Instance of the rest service @private */
private restService: RestService;
/** Instance of the rest service @private */
private restService: RestService;
@@
-138,10
+144,6
@@
export class SharedService {
/** Service holds the router information @private */
private router: Router;
/** Service holds the router information @private */
private router: Router;
- /** Random color string generator length @private */
- // eslint-disable-next-line @typescript-eslint/no-magic-numbers
- private colorStringLength: number = 256;
-
/** Check for the root directory @private */
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
private directoryCount: number = 2;
/** Check for the root directory @private */
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
private directoryCount: number = 2;
@@
-260,10
+262,9
@@
export class SharedService {
/** Generate random string @public */
public randomString(): string {
/** Generate random string @public */
public randomString(): string {
- const chars: string = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
let result: string = '';
for (let randomStringRef: number = this.randomStringLength; randomStringRef > 0; --randomStringRef) {
let result: string = '';
for (let randomStringRef: number = this.randomStringLength; randomStringRef > 0; --randomStringRef) {
- result +=
chars[Math.floor(Math.random() * chars.length)]
;
+ result +=
new Date().getSeconds()
;
}
return result;
}
}
return result;
}
@@
-414,6
+415,7
@@
export class SharedService {
const version: string[] = res.version.split('+');
if (!isNullOrUndefined(version[0])) {
this.osmVersion = version[0];
const version: string[] = res.version.split('+');
if (!isNullOrUndefined(version[0])) {
this.osmVersion = version[0];
+ sessionStorage.setItem('version', version[0]);
} else {
this.osmVersion = null;
}
} else {
this.osmVersion = null;
}
@@
-425,9
+427,9
@@
export class SharedService {
/** Random RGB color code generator @public */
public generateColor(): string {
/** Random RGB color code generator @public */
public generateColor(): string {
- const x: number = Math.floor(
Math.random() * this.colorStringLength
);
- const y: number = Math.floor(
Math.random() * this.colorStringLength
);
- const z: number = Math.floor(
Math.random() * this.colorStringLength
);
+ const x: number = Math.floor(
(new Date().getHours()) * this.colourHour
);
+ const y: number = Math.floor(
(new Date().getMinutes()) * this.colourMin
);
+ const z: number = Math.floor(
(new Date().getSeconds()) * this.colourMin
);
return 'rgb(' + x + ',' + y + ',' + z + ')';
}
return 'rgb(' + x + ',' + y + ',' + z + ')';
}
@@
-514,3
+516,8
@@
export class SharedService {
};
}
}
};
}
}
+
+/** Method to handle null or undefined @public */
+// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
+export const isNullOrUndefined = (data: any): boolean => data === null || data === undefined;
+