list dns entries after add/delete action handling so the table of entries always shows the current state withouth reloading the page; fixes #887
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -19,7 +19,6 @@ if (! defined('AREA')) {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Froxlor\Database\Database;
|
|
||||||
use Froxlor\Api\Commands\DomainZones as DomainZones;
|
use Froxlor\Api\Commands\DomainZones as DomainZones;
|
||||||
|
|
||||||
// This file is being included in admin_domains and customer_domains
|
// This file is being included in admin_domains and customer_domains
|
||||||
@@ -36,18 +35,6 @@ $ttl = isset($_POST['record']['ttl']) ? (int) $_POST['record']['ttl'] : 18000;
|
|||||||
// get domain-name
|
// get domain-name
|
||||||
$domain = \Froxlor\Dns\Dns::getAllowedDomainEntry($domain_id, AREA, $userinfo);
|
$domain = \Froxlor\Dns\Dns::getAllowedDomainEntry($domain_id, AREA, $userinfo);
|
||||||
|
|
||||||
// select all entries
|
|
||||||
try {
|
|
||||||
// get list
|
|
||||||
$json_result = DomainZones::getLocal($userinfo, [
|
|
||||||
'id' => $domain_id
|
|
||||||
])->listing();
|
|
||||||
} catch (Exception $e) {
|
|
||||||
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
|
||||||
}
|
|
||||||
$result = json_decode($json_result, true)['data'];
|
|
||||||
$dom_entries = $result['list'];
|
|
||||||
|
|
||||||
$errors = "";
|
$errors = "";
|
||||||
$success_message = "";
|
$success_message = "";
|
||||||
|
|
||||||
@@ -63,8 +50,9 @@ if ($action == 'add_record' && ! empty($_POST)) {
|
|||||||
'ttl' => $ttl
|
'ttl' => $ttl
|
||||||
))->add();
|
))->add();
|
||||||
$success_message = $lng['success']['dns_record_added'];
|
$success_message = $lng['success']['dns_record_added'];
|
||||||
|
$record = $prio = $content = "";
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
$errors = str_replace("\n", "<br>", $e->getMessage());
|
||||||
}
|
}
|
||||||
} elseif ($action == 'delete') {
|
} elseif ($action == 'delete') {
|
||||||
// remove entry
|
// remove entry
|
||||||
@@ -75,26 +63,26 @@ if ($action == 'add_record' && ! empty($_POST)) {
|
|||||||
'entry_id' => $entry_id,
|
'entry_id' => $entry_id,
|
||||||
'id' => $domain_id
|
'id' => $domain_id
|
||||||
))->delete();
|
))->delete();
|
||||||
|
// success message (inline)
|
||||||
|
$success_message = $lng['success']['dns_record_deleted'];
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$errors = str_replace("\n", "<br>", $e->getMessage());
|
$errors = str_replace("\n", "<br>", $e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($errors)) {
|
|
||||||
// remove deleted entry from internal data array (no reread of DB necessary)
|
|
||||||
$_t = $dom_entries;
|
|
||||||
foreach ($_t as $idx => $entry) {
|
|
||||||
if ($entry['id'] == $entry_id) {
|
|
||||||
unset($dom_entries[$idx]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
unset($_t);
|
|
||||||
// success message (inline)
|
|
||||||
$success_message = $lng['success']['dns_record_deleted'];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// select all entries
|
||||||
|
try {
|
||||||
|
// get list
|
||||||
|
$json_result = DomainZones::getLocal($userinfo, [
|
||||||
|
'id' => $domain_id
|
||||||
|
])->listing();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
||||||
|
}
|
||||||
|
$result = json_decode($json_result, true)['data'];
|
||||||
|
$dom_entries = $result['list'];
|
||||||
|
|
||||||
// show editor
|
// show editor
|
||||||
$record_list = "";
|
$record_list = "";
|
||||||
$existing_entries = "";
|
$existing_entries = "";
|
||||||
|
|||||||
Reference in New Issue
Block a user