migrate customer::backups
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -291,15 +291,12 @@ if ($page == 'overview' || $page == 'htpasswds') {
|
||||
|
||||
// check whether there is a backup-job for this customer
|
||||
try {
|
||||
$json_result = CustomerBackups::getLocal($userinfo)->listing();
|
||||
$backup_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/customer/tablelisting.backups.php';
|
||||
$collection = (new \Froxlor\UI\Collection(\Froxlor\Api\Commands\CustomerBackups::class, $userinfo))
|
||||
->withPagination($backup_list_data['backup_list']['columns']);
|
||||
} catch (Exception $e) {
|
||||
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
||||
}
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
$existing_backupJob = null;
|
||||
if ($result['count'] > 0) {
|
||||
$existing_backupJob = array_shift($result['list']);
|
||||
}
|
||||
|
||||
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
||||
try {
|
||||
@@ -309,26 +306,13 @@ if ($page == 'overview' || $page == 'htpasswds') {
|
||||
}
|
||||
\Froxlor\UI\Response::standard_success('backupscheduled');
|
||||
} else {
|
||||
|
||||
if (!empty($existing_backupJob)) {
|
||||
$action = "abort";
|
||||
$row = $existing_backupJob['data'];
|
||||
|
||||
$row['path'] = \Froxlor\FileDir::makeCorrectDir(str_replace($userinfo['documentroot'], "/", $row['destdir']));
|
||||
$row['backup_web'] = ($row['backup_web'] == '1') ? $lng['panel']['yes'] : $lng['panel']['no'];
|
||||
$row['backup_mail'] = ($row['backup_mail'] == '1') ? $lng['panel']['yes'] : $lng['panel']['no'];
|
||||
$row['backup_dbs'] = ($row['backup_dbs'] == '1') ? $lng['panel']['yes'] : $lng['panel']['no'];
|
||||
|
||||
// overwrite backup_form after we took everything from it we needed
|
||||
eval("\$backup_form = \"" . \Froxlor\UI\Template::getTemplate("extras/backup_listexisting") . "\";");
|
||||
}
|
||||
|
||||
$pathSelect = \Froxlor\FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']);
|
||||
$backup_data = include_once dirname(__FILE__) . '/lib/formfields/customer/extras/formfield.backup.php';
|
||||
|
||||
UI::view('user/form.html.twig', [
|
||||
UI::view('user/form-datatable.html.twig', [
|
||||
'formaction' => $linker->getLink(array('section' => 'extras')),
|
||||
'formdata' => $backup_data['backup']
|
||||
'formdata' => $backup_data['backup'],
|
||||
'tabledata' => \Froxlor\UI\Listing::format($collection, $backup_list_data['backup_list']),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
68
lib/tablelisting/customer/tablelisting.backups.php
Normal file
68
lib/tablelisting/customer/tablelisting.backups.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Froxlor project.
|
||||
* Copyright (c) 2010 the Froxlor Team (see authors).
|
||||
*
|
||||
* For the full copyright and license information, please view the COPYING
|
||||
* file that was distributed with this source code. You can also view the
|
||||
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
|
||||
*
|
||||
* @copyright (c) the authors
|
||||
* @author Froxlor team <team@froxlor.org> (2010-)
|
||||
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||
* @package Tabellisting
|
||||
*
|
||||
*/
|
||||
|
||||
use Froxlor\UI\Callbacks\Ftp;
|
||||
use Froxlor\UI\Callbacks\Text;
|
||||
use Froxlor\UI\Listing;
|
||||
|
||||
return [
|
||||
'backup_list' => [
|
||||
'title' => $lng['error']['customerhasongoingbackupjob'],
|
||||
'icon' => 'fa-solid fa-server',
|
||||
'columns' => [
|
||||
'destdir' => [
|
||||
'label' => $lng['panel']['path'],
|
||||
'field' => 'data.destdir',
|
||||
'callback' => [Ftp::class, 'pathRelative']
|
||||
],
|
||||
'backup_web' => [
|
||||
'label' => $lng['extras']['backup_web'],
|
||||
'field' => 'data.backup_web',
|
||||
'callback' => [Text::class, 'boolean'],
|
||||
],
|
||||
'backup_mail' => [
|
||||
'label' => $lng['extras']['backup_mail'],
|
||||
'field' => 'data.backup_mail',
|
||||
'callback' => [Text::class, 'boolean'],
|
||||
],
|
||||
'backup_dbs' => [
|
||||
'label' => $lng['extras']['backup_dbs'],
|
||||
'field' => 'data.backup_dbs',
|
||||
'callback' => [Text::class, 'boolean'],
|
||||
]
|
||||
],
|
||||
'visible_columns' => Listing::getVisibleColumnsForListing('backup_list', [
|
||||
'destdir',
|
||||
'backup_web',
|
||||
'backup_mail',
|
||||
'backup_dbs'
|
||||
]),
|
||||
'actions' => [
|
||||
'delete' => [
|
||||
'icon' => 'fa fa-trash',
|
||||
'title' => $lng['panel']['abort'],
|
||||
'class' => 'btn-warning',
|
||||
'href' => [
|
||||
'section' => 'extras',
|
||||
'page' => 'backup',
|
||||
'action' => 'abort',
|
||||
'id' => ':id'
|
||||
],
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
16
templates/Froxlor/user/form-datatable.html.twig
Normal file
16
templates/Froxlor/user/form-datatable.html.twig
Normal file
@@ -0,0 +1,16 @@
|
||||
{% extends "Froxlor/user/form.html.twig" %}
|
||||
|
||||
{% block content %}
|
||||
{% if tabledata is not empty and tabledata is iterable %}
|
||||
<div class="row mb-2">
|
||||
{% set type = 'warning' %}
|
||||
{% set alert_msg = lng('error.customerhasongoingbackupjob') %}
|
||||
{% include 'Froxlor/misc/alertbox.html.twig' %}
|
||||
</div>
|
||||
{% import "Froxlor/table/table.html.twig" as table %}
|
||||
{{ table.table(tabledata) }}
|
||||
{% endif %}
|
||||
|
||||
{{ parent() }}
|
||||
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user