Merge branch 'monitor-production' into develop
This commit is contained in:
commit
4c328efa3a
|
@ -1,5 +1,5 @@
|
|||
export enum Level {
|
||||
NONE,
|
||||
ALL,
|
||||
K,
|
||||
M,
|
||||
B
|
||||
|
@ -14,7 +14,8 @@ export interface NumberSize {
|
|||
|
||||
export class NumberUtils {
|
||||
|
||||
public static roundNumber(num: number, level: Level = Level.NONE, decimal = 0): any {
|
||||
public static roundNumber(num: number | string, level: Level = Level.ALL, decimal = 0): any {
|
||||
num = Number.parseFloat(num.toString());
|
||||
let roundNum: NumberSize;
|
||||
let initialNum = num;
|
||||
let variance = Math.pow(10, decimal);
|
||||
|
@ -30,11 +31,6 @@ export class NumberUtils {
|
|||
num = num / 1000;
|
||||
num = Math.round(num * variance) / variance;
|
||||
roundNum = {number: num, size: "K", count: initialNum};
|
||||
} else if (num >= 100) {
|
||||
num = num / 100;
|
||||
num = Math.round(num * variance) / variance;
|
||||
num = num * 100;
|
||||
roundNum = {number: num, size: "", count: initialNum};
|
||||
} else {
|
||||
roundNum = {number: num, size: "", count: initialNum};
|
||||
}
|
||||
|
|
|
@ -6,10 +6,15 @@ import {DecimalPipe} from "@angular/common";
|
|||
export class NumberRoundPipe implements PipeTransform {
|
||||
decimalPipe: DecimalPipe = new DecimalPipe("en");
|
||||
|
||||
constructor() {}
|
||||
constructor() {
|
||||
}
|
||||
|
||||
transform(value: number, ...args: any[]): any {
|
||||
let level = Level.NONE;
|
||||
/**
|
||||
* Args: Level: 0 (default): ALL, 1: K, 2: M, 3:B
|
||||
* Decimal: how many decimals should be shown (e.g 1 -> 62.1)
|
||||
* */
|
||||
transform(value: number | string, ...args: any[]): any {
|
||||
let level = Level.ALL;
|
||||
let decimal = 0;
|
||||
if (args[0]) {
|
||||
level = args[0];
|
||||
|
|
Loading…
Reference in New Issue