X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=src%2Fservices%2FSharedService.ts;h=bc4e71a834cc79f17db2dfd5b26ed788e0439839;hb=208bef2cea31da5427861ac81817790e98851fe2;hp=3a138e585a54563823330fee8bb660e3f60d05bd;hpb=c4970aef0a1aba9dda11327f33f4862aaa3552b0;p=osm%2FNG-UI.git diff --git a/src/services/SharedService.ts b/src/services/SharedService.ts index 3a138e5..bc4e71a 100644 --- a/src/services/SharedService.ts +++ b/src/services/SharedService.ts @@ -88,6 +88,9 @@ export class SharedService { /** Service holds the router information @private */ private router: Router; + /** Random color string generator length @private */ + private colorStringLength: number = 256; + /** Check for the root directory @private */ private directoryCount: number = 2; @@ -274,6 +277,13 @@ export class SharedService { this.restService.handleError(error, 'get'); }); } + /** 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); + return 'rgb(' + x + ',' + y + ',' + z + ')'; + } /** Method to validate file extension and size @private */ private vaildataFileInfo(fileInfo: File, fileType: string): boolean { const extension: string = fileInfo.name.substring(fileInfo.name.lastIndexOf('.') + 1);