/* Copyright CloudLinux Zug GmbH 2010-2017 All Rights Reserved
 *
 * Licensed under CLOUD LINUX LICENSE AGREEMENT
 * http://cloudlinux.com/docs/LICENSE.TXT
 */

import {Result} from './result';
import {User} from "./user";
import {Row} from "../utils/row";

export interface StatResult extends Result{
    users: Stat[];
    resellers: Stat[];
    mySqlGov: CustomBoolean;
}

export type CustomBoolean = 'enabled' | 'disabled';

export class Stat extends Row {
    id: number;
    username: string;
    name: string;
    reseller: string;
    resellerStatus?: boolean; // Is it activated reseller? Which have enabled limits.
    userType: string;
    userTypeTooltip: string;
    isReseller: boolean;
    domain: string;
    usage: Limits;
    limits: Limits;
    faults: Limits;
    user?: User;

    usage_cpu_lve: Cell;
    limits_cpu_lve: Cell;
    usage_cpu_mysql: Cell;
    limits_cpu_mysql: Cell;
    faults_cpu_lve: Cell;
    usage_pmem_lve: Cell;
    limits_pmem_lve: Cell;
    faults_pmem_lve: Cell;
    usage_vmem_lve: Cell;
    limits_vmem_lve: Cell;
    faults_vmem_lve: Cell;
    usage_io_lve: Cell;
    limits_io_lve: Cell;
    usage_io_mysql: Cell;
    limits_io_mysql: Cell;
    faults_io_lve: Cell;
    usage_ep_lve: Cell;
    limits_ep_lve: Cell;
    faults_ep_lve: Cell;
    usage_nproc_lve: Cell;
    limits_nproc_lve: Cell;
    faults_nproc_lve: Cell;
    usage_iops_lve: Cell;
    limits_iops_lve: Cell;
    faults_iops_lve: Cell;


    hasEdit: boolean = true;
    hasStat: boolean = true;

    get loadingStage(): boolean {
        if (this.user) {
            return this.user.loadingStage;
        }
        return false;
    }

}

export interface Limits {
    pmem:  'string' | Param;
    vmem:  'string' | Param;
    iops:  'string' | Param;
    nproc: 'string' | Param;
    ep:    'string' | Param;
    cpu:   'string' | Param;
    io:    'string' | Param;
    mysql: 'string' | Param;
}

interface Param {
    lve: number;
    mysql: number;
}

interface Cell {
    value: any;
    warning: boolean;
}
