import { environment } from "src/environments/environment"
import { TagModel } from "./tag.mmodel"
import { GroupModel } from "./group.mmodel"

export interface WidgetModel {
    widgetId: string
    widgetTname: string
    widgetEname: string
    thDesc: string
    engDesc: string
    chartType: string
    widgetHeight: number
    widgetWidth: number
    seriesColumn: string
    picture: string
    remark: string
    status: number
    link1: string
    dbSupport: string
    widgetObj: string
    fileType: string
    isPivot: number
    isDataGrid: number
    uploadBy: string
    uploadDate: string
    uploadTime: string
    group: GroupModel
    tags: TagModel[]
}

export class WidgetModel implements WidgetModel {
    widgetId: string
    widgetTname: string
    widgetEname: string
    thDesc: string
    engDesc: string
    chartType: string
    widgetHeight: number
    widgetWidth: number
    seriesColumn: string
    picture: string
    remark: string
    status: number
    link1: string
    dbSupport: string
    widgetObj: string
    fileType: string
    isPivot: number
    isDataGrid: number
    uploadBy: string
    uploadDate: string
    uploadTime: string
    group: GroupModel
    tags: TagModel[]
    constructor(data: Partial<any>) {
        this.widgetId = data.widgetId?data.widgetId:''
        this.widgetTname = data.widgetTname?data.widgetTname:''
        this.widgetEname = data.widgetEname?data.widgetEname:''
        this.thDesc = data.thDesc?data.thDesc:''
        this.engDesc = data.engDesc?data.engDesc:''
        this.chartType = data.chartType?data.chartType:''
        this.widgetHeight = data.widgetHeight?data.widgetHeight:0
        this.widgetWidth = data.widgetWidth?data.widgetWidth:0
        this.status = data.status?data.status:0
        this.seriesColumn = data.seriesColumn?data.seriesColumn:''
        this.picture = data.picture?data.picture:''
        this.remark = data.remark?data.remark:''
        this.link1 = data.link1?data.link1:''
        this.widgetObj = data.widgetObj?data.widgetObj:''
        this.dbSupport = data.dbSupport?data.dbSupport:''
        this.tags = data.tags?data.tags:[]
        this.fileType = data.fileType?data.fileType:''
        this.isPivot = data.isPivot?data.isPivot:0
        this.isDataGrid = data.isDataGrid?data.isDataGrid:0
        this.uploadBy = data.uploadBy?data.uploadBy:''
        this.uploadDate = data.uploadDate?data.uploadDate:''
        this.uploadTime = data.uploadTime?data.uploadTime:''
        this.group = data.group?new GroupModel(data.group):new GroupModel({})
   
    }
    getImage(){
        if(this.picture){
            return environment.url+"files/image/"+this.picture
        }else{
            return 'assets/images/big/auth-bg.jpg'
        }
    }
}