diff --git a/module/instance/config/dtable.php b/module/instance/config/dtable.php new file mode 100644 index 0000000000..767904b810 --- /dev/null +++ b/module/instance/config/dtable.php @@ -0,0 +1,58 @@ +backup = new stdClass(); +$config->backup->dtable = new stdclass(); +$config->backup->dtable->fieldList['create_time']['name'] = 'create_time'; +$config->backup->dtable->fieldList['create_time']['title'] = $lang->instance->backup->date; +$config->backup->dtable->fieldList['create_time']['type'] = 'desc'; +$config->backup->dtable->fieldList['create_time']['sortType'] = false; +$config->backup->dtable->fieldList['create_time']['hint'] = true; +$config->backup->dtable->fieldList['create_time']['formatDate'] = 'YYYY-MM-dd hh:mm:ss'; +$config->backup->dtable->fieldList['create_time']['width'] = '120'; + +$config->backup->dtable->fieldList['operator']['name'] = 'operator'; +$config->backup->dtable->fieldList['operator']['title'] = $lang->instance->backup->operator; +$config->backup->dtable->fieldList['operator']['type'] = 'desc'; +$config->backup->dtable->fieldList['operator']['sortType'] = false; +$config->backup->dtable->fieldList['operator']['hint'] = true; +$config->backup->dtable->fieldList['operator']['width'] = '100'; + +$config->backup->dtable->fieldList['dbStatus']['name'] = 'status'; +$config->backup->dtable->fieldList['dbStatus']['title'] = $lang->instance->backup->dbStatus; +$config->backup->dtable->fieldList['dbStatus']['type'] = 'desc'; +$config->backup->dtable->fieldList['dbStatus']['sortType'] = false; +$config->backup->dtable->fieldList['dbStatus']['hint'] = true; +$config->backup->dtable->fieldList['dbStatus']['width'] = '80'; + +$config->backup->dtable->fieldList['backupSize']['name'] = 'backupSize'; +$config->backup->dtable->fieldList['backupSize']['title'] = $lang->instance->backup->backupSize; +$config->backup->dtable->fieldList['backupSize']['type'] = 'desc'; +$config->backup->dtable->fieldList['backupSize']['sortType'] = false; +$config->backup->dtable->fieldList['backupSize']['hint'] = true; +$config->backup->dtable->fieldList['backupSize']['width'] = '100'; + +$config->backup->dtable->fieldList['restoreDate']['name'] = 'latestRestoreTime'; +$config->backup->dtable->fieldList['restoreDate']['title'] = $lang->instance->backup->restoreDate; +$config->backup->dtable->fieldList['restoreDate']['type'] = 'desc'; +$config->backup->dtable->fieldList['restoreDate']['sortType'] = false; +$config->backup->dtable->fieldList['restoreDate']['hint'] = true; +$config->backup->dtable->fieldList['restoreDate']['width'] = '120'; + +$config->backup->dtable->fieldList['restoreStatus']['name'] = 'latestRestoreStatus'; +$config->backup->dtable->fieldList['restoreStatus']['title'] = $lang->instance->backup->restoreStatus; +$config->backup->dtable->fieldList['restoreStatus']['type'] = 'desc'; +$config->backup->dtable->fieldList['restoreStatus']['sortType'] = false; +$config->backup->dtable->fieldList['restoreStatus']['hint'] = true; +$config->backup->dtable->fieldList['restoreStatus']['width'] = '80'; + +$config->backup->dtable->fieldList['actions']['name'] = 'actions'; +$config->backup->dtable->fieldList['actions']['title'] = $lang->instance->backup->action; +$config->backup->dtable->fieldList['actions']['type'] = 'actions'; +$config->backup->dtable->fieldList['actions']['hint'] = true; +$config->backup->dtable->fieldList['actions']['menu'] = array('restore'); + +$config->backup->dtable->fieldList['actions']['list']['restore']['icon'] = 'icon-restart'; +$config->backup->dtable->fieldList['actions']['list']['restore']['hint'] = $lang->instance->restore->common; +$config->backup->dtable->fieldList['actions']['list']['restore']['url'] = helper::createLink('instance', 'ajaxRestore', 'instanceID={instanceId}&backupName={name}'); +$config->backup->dtable->fieldList['actions']['list']['restore']['className'] = 'ajax-submit'; \ No newline at end of file diff --git a/module/instance/ui/backuplist.html.php b/module/instance/ui/backuplist.html.php new file mode 100644 index 0000000000..c2f6c1c636 --- /dev/null +++ b/module/instance/ui/backuplist.html.php @@ -0,0 +1,52 @@ + + * @package repo + * @link https://www.zentao.net + */ +namespace zin; + +$backups = initTableData($backupList, $config->backup->dtable->fieldList, $this->instance); +$hasRestoreLog = false; +foreach($backupList as &$backup) +{ + /* Initialization calculation and assignment. */ + $status = $backup->status; + $restoreStatus = ''; + $backupSize = isset($backup->backup_details->db[0]) ? intval(zget($backup->backup_details->db[0], 'size', 0)) : 0; + $backupSize += isset($backup->backup_details->volume[0]) ? intval(zget($backup->backup_details->volume[0], 'doneBytes', 0)) : 0; + + $backup->instanceId = $instance->id; + $backup->operator = zget($lang->instance->backup->operators, $backup->username, $backup->username); + $backup->status = zget($lang->instance->backup->statusList, strtolower($backup->status)); + $backup->backupSize = helper::formatKB($backupSize); + + /* Mark recently restored information. */ + $backup->latestRestoreTime = 0; + $backup->latestRestoreStatus = ''; + foreach($backup->restores as $restore) + { + $hasRestoreLog = true; + if($restore->create_time > $backup->latestRestoreTime) + { + $backup->latestRestoreTime = $restore->create_time; + $restoreStatus = $restore->status; + $backup->latestRestoreStatus = zget($lang->instance->restore->statusList, $restore->status, $restore->status); + } + } + $backup->latestRestoreTime = $backup->latestRestoreTime == 0 ? '' : date('Y-m-d H:i:s', $backup->latestRestoreTime); + $backup->restoreTime = zget($lang->instance->backup->operators, $backup->username, $backup->username); + + if(in_array($status, array('processing', 'inprogress')) || in_array($restoreStatus, array('pending', 'inprogress'))) $backup->actions[0]['disabled'] = true; +} +dtable +( + set::cols($config->backup->dtable->fieldList), + set::data($backups), + set::sortLink(createLink('instance', 'backuplist', "id={$instance->id}&orderBy={name}_{sortType}&recTotal={$pager->recTotal}&pageID={$pager->pageID}")), + set::footPager(usePager()) +);