function time(field) {
    return {
        type: 'tpl',
        tpl: `\${IF(${field}, DATETOSTR(${field}, 'YYYY-MM-DD HH:mm:ss'), undefined)}`
    }
}

function cloudCrud(title, path) {
    return {
        type: 'crud',
        title: title,
        api: `\${base}${path}`,
        ...crudCommonOptions(),
        interval: 2000,
        headerToolbar: ['reload'],
        loadDataOnce: true,
        perPage: 100,
        columns: [
            {name: 'name', label: '名称'},
            {
                name: 'status',
                label: '状态',
                align: 'center',
                width: 60,
            },
            {
                name: 'serviceUpTime',
                label: '启动时间',
                ...time('serviceUpTime'),
                align: 'center',
                width: 160,
            },
            {name: 'url', label: '地址', width: 200},
            {name: 'serviceId', label: '服务', width: 200, fixed: 'right'},
        ]
    }
}

function cloudTab() {
    return {
        title: 'Cloud',
        icon: 'fa fa-cloud',
        tab: [
            /*{
                type: 'service',
                silentPolling: true,
                schemaApi: 'get:${base}/cloud/deploy_plan',
            },*/
            cloudCrud('服务列表', '/cloud/list'),
            cloudCrud('服务列表 (IP)', '/cloud/list_ip'),
        ],
    }
}