extract plot detail view into its own component
This commit is contained in:
38
pdb-js/src/app/utils.service.ts
Normal file
38
pdb-js/src/app/utils.service.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class UtilService {
|
||||
|
||||
constructor() {
|
||||
}
|
||||
|
||||
formatMs(valueInMs):string {
|
||||
const ms = Math.floor(valueInMs % 1000);
|
||||
const s = Math.floor((valueInMs / 1000) % 60);
|
||||
const m = Math.floor((valueInMs / (60*1000)) % 60);
|
||||
const h = Math.floor(valueInMs / (3600*1000));
|
||||
|
||||
var result = "";
|
||||
if (h != 0) {
|
||||
result += h+"h ";
|
||||
}
|
||||
if (h!= 0 || m != 0) {
|
||||
result += m+"m ";
|
||||
}
|
||||
if (h!= 0 || m != 0 || s != 0) {
|
||||
result += s+"s ";
|
||||
result += ms+"ms";
|
||||
} else {
|
||||
result += ms+"ms";
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
toPercent(percentage: number) : string{
|
||||
return (Math.round(percentage * 10000) / 100)+"%";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user