From d75f9fa26ff2d37cf12fbeaf2fed5be2f8e8733d Mon Sep 17 00:00:00 2001 From: Luca Haid Date: Tue, 30 Jul 2024 17:52:04 +0000 Subject: [PATCH] Feature/improve domain --- application/Domain/DomainController.php | 1 + application/Domain/DomainModel.php | 17 +++++++++++++++- public/js/pages/Domain/Domain.js | 26 +++++++++++++++++-------- 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/application/Domain/DomainController.php b/application/Domain/DomainController.php index fb660f364..a98208ecf 100644 --- a/application/Domain/DomainController.php +++ b/application/Domain/DomainController.php @@ -27,6 +27,7 @@ class DomainController extends mfBaseController { protected function indexAction(): void { $JSGlobals = ["BASE_URL" => self::getUrl("Domain"), + "CONTRACT_URL" => self::getUrl("Contract"), "DASHBOARD_URL" => self::getUrl("Dashboard"), "MFAPPNAME" => MFAPPNAME_SLUG, "PAGE_TITLE" => "Domains", diff --git a/application/Domain/DomainModel.php b/application/Domain/DomainModel.php index 51fe5bfbe..29209091a 100644 --- a/application/Domain/DomainModel.php +++ b/application/Domain/DomainModel.php @@ -106,7 +106,22 @@ class DomainModel { $rows[] = new DomainModel($row); } - return $rows; + $newRows = []; + // convert domain contracts to array + $domainContracts = array_map(function ($contract) { + return $contract->toArray(); + }, ContractModel::search(['product_id' => 170])); + + // search for $domain->domain in $domainContracts['matchcode'] + foreach ($rows as $row) { + $contract = array_filter($domainContracts, function ($contract) use ($row) { + return $contract['matchcode'] === $row->domain; + }); + $row->contractId = count($contract) > 0 ? array_values($contract)[0]['id'] : null; + $newRows[] = $row; + } + + return $newRows; } public static function countDomains($filters) { diff --git a/public/js/pages/Domain/Domain.js b/public/js/pages/Domain/Domain.js index 8b99c0926..b217b3342 100644 --- a/public/js/pages/Domain/Domain.js +++ b/public/js/pages/Domain/Domain.js @@ -33,13 +33,15 @@ Vue.component('Domain', { @@ -155,7 +157,7 @@ Vue.component('Domain', { key: "tech", sortable: false }, {text: "Billing ID", key: "billing", sortable: false}, {text: "Name Servers", key: "ns"}, - {text: "DNS", key: "inwxRoId", filter: false, sortable: false, priority: 1}], + {text: "Actions", key: "inwxRoId", filter: false, sortable: false, priority: 1}], tableHeader: 'Domains', key: 'Domain' } @@ -178,6 +180,14 @@ Vue.component('Domain', { return base } }, methods: { + async showContract(contractId) { + if (!contractId) return + const contractUrl= window['TT_CONFIG']['CONTRACT_URL'] + '/view/?contract_id=' + contractId + //redirect to contractUrl in new tab + + const win = window.open(contractUrl, '_blank') + win.focus() + }, async showDnsRecordsModal(domain) { this.dnsRecordsModalLoading = domain this.dnsRecordsModal = {