From 69d6922ff30e864fe772385a7042b15828693370 Mon Sep 17 00:00:00 2001 From: cp6 Date: Sat, 30 Jan 2021 10:04:13 +1100 Subject: [PATCH 01/12] Added KB/s to MB/s conversion --- class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/class.php b/class.php index 302fb62..5c775e3 100644 --- a/class.php +++ b/class.php @@ -523,9 +523,11 @@ class helperFunctions extends elementHelpers } protected function diskSpeedAsMbps(string $type, string $value) - {//If value type GB/s convert to MB/s + {//If value type GB/s convert to MB/s, KB/s to MB/s if ($type == "GB/s") { return $this->GBpstoMBps($value); + } elseif ($type == "KB/s") { + return ($value / 1000); } else { return $value; } From 3de0b0956cfd9801869fa879186cd07b4643a4fd Mon Sep 17 00:00:00 2001 From: cp6 Date: Sat, 30 Jan 2021 10:10:27 +1100 Subject: [PATCH 02/12] Fixed domain and shared hosting deletion Fixed domain and shared hosting deletion --- calls.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/calls.php b/calls.php index 78afc3e..5afe94a 100644 --- a/calls.php +++ b/calls.php @@ -64,7 +64,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { } } elseif (isset($_POST['action']) && $_POST['action'] == 'update') { $update = new itemUpdate($_POST); - if (isset($_POST['me_delete'])) {//Delete object + if (isset($_POST['me_delete']) || isset($_POST['sh_me_delete']) || isset($_POST['d_me_delete'])) {//Delete object $update->deleteObjectData(); } elseif ($_POST['type'] == 'server_modal_edit') {//Update the server info $update->updateServerFromModal(); From c882d4702656cd5568b379f93c591b9252539e9d Mon Sep 17 00:00:00 2001 From: cp6 Date: Sat, 30 Jan 2021 11:19:05 +1100 Subject: [PATCH 03/12] Added a constant to set view as Cards or Table Added a constant to set view as Cards or Table. "CARDS", "TABLE" this means on page load that default view will be showing. --- assets/js/scripts.min.js | 70 ++++++++++++++++++++++++++-------------- calls.php | 3 ++ class.php | 30 +++++++++++++---- 3 files changed, 72 insertions(+), 31 deletions(-) diff --git a/assets/js/scripts.min.js b/assets/js/scripts.min.js index c5a0bcd..fe1b934 100644 --- a/assets/js/scripts.min.js +++ b/assets/js/scripts.min.js @@ -149,8 +149,36 @@ $(document).ready(function () { $('.next-dd').val(one_month_on); + + if ($("#cardsViewDiv").hasClass("active")) { + loadCards(); + } else if ($("#tableViewDiv").hasClass("active")){ + loadTable(); + } }); +function loadCards(){ + $.ajax({ + type: "GET", + url: "calls.php", + data: {"type": "object_cards"}, + success: function (result) { + $("#cardsViewDiv").append(result); + } + }); +} + +function loadTable(){ + $.ajax({ + type: "GET", + url: "calls.php", + data: {"type": "object_tables"}, + success: function (result) { + $("#tableViewDiv").append(result); + } + }); +} + $(function () { $(".location-input").autocomplete({ source: function (request, response) { @@ -175,7 +203,6 @@ $(function () { }); }); - $(document).on("click", "#viewMoreServer", function () { var serverId = this.getAttribute("value"); $("#viewMoreModalBody").empty(); @@ -315,34 +342,27 @@ $(document).on("click", "#checkUpStatus", function () { $(document).on("click", "#viewSwitcherIcon", function () { var icon = $(this).children().first(); - if ($("#serversTable").children().length == 0){ - $.ajax({ - type: "GET", - url: "calls.php", - data: {"type": "object_tables"}, - success: function (result) { - $("#tableViewDiv").append(result); - } - }); + if (icon.hasClass("fa-table")) { + if ($("#serversTable").children().length == 0) { + loadTable(); + } icon.removeClass("fa-table"); icon.addClass("fa-th"); - $("#cardsViewDiv" ).hide(); - $("#tableViewDiv" ).show(); + $("#cardsViewDiv").hide(); + $("#tableViewDiv").show(); $('#viewSwitchIcon').prop('title', 'Switch to cards'); - } else { - if (icon.hasClass("fa-table")) { - icon.removeClass("fa-table"); - icon.addClass("fa-th"); - $( "#cardsViewDiv" ).hide(); - $( "#tableViewDiv" ).show(); - $('#viewSwitchIcon').prop('title', 'Switch to cards'); - } else if (icon.hasClass("fa-th")) { - icon.removeClass("fa-th"); - icon.addClass("fa-table"); - $( "#tableViewDiv" ).hide(); - $( "#cardsViewDiv" ).show(); - $('#viewSwitchIcon').prop('title', 'Switch to table'); + + } else if (icon.hasClass("fa-th")) { + if ($("#cardsViewDiv").children().length == 0) { + loadCards(); } + icon.removeClass("fa-th"); + icon.addClass("fa-table"); + $("#cardsViewDiv").addClass("active"); + $("#tableViewDiv").removeClass("active"); + $("#tableViewDiv").hide(); + $("#cardsViewDiv").show(); + $('#viewSwitchIcon').prop('title', 'Switch to table'); } }); diff --git a/calls.php b/calls.php index 5afe94a..6e6c01f 100644 --- a/calls.php +++ b/calls.php @@ -40,6 +40,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { $idle->getIpForDomain($_GET['hostname'], $_GET['dns_type']); } elseif ($_GET['type'] == 'check_up') { echo $idle->checkIsUp($_GET['host']); + } elseif ($_GET['type'] == 'object_cards') { + header('Content-Type: text/html; charset=utf-8'); + echo $idle->objectCards(); } elseif ($_GET['type'] == 'object_tables') { header('Content-Type: text/html; charset=utf-8'); echo $idle->objectTables(); diff --git a/class.php b/class.php index 5c775e3..5aa8af1 100644 --- a/class.php +++ b/class.php @@ -17,6 +17,8 @@ class idlersConfig //Have slight background color for server table values: was special price and due soon const COLOR_TABLE = true; + + const DEFAULT_VIEW = 'CARDS';//CARDS or TABLE } class elementHelpers extends idlersConfig @@ -598,12 +600,17 @@ class idlers extends helperFunctions $this->outputString('
'); $this->outputString('
'); $this->viewSwitcherIcon(); - $this->tagOpen('div', '', 'cardsViewDiv'); - $this->serverCards(); - $this->sharedHostingCards(); - $this->domainCards(); + if (self::DEFAULT_VIEW == 'CARDS') { + $cards_start = 'active'; + $table_start = ''; + } else { + $cards_start = ''; + $table_start = 'active'; + } + $this->tagOpen('div', $cards_start, 'cardsViewDiv'); + //Object cards $this->tagClose('div'); - $this->tagOpen('div', '', 'tableViewDiv'); + $this->tagOpen('div', $table_start, 'tableViewDiv'); //Objects tables $this->tagClose('div', 2); $this->outputString('
'); @@ -981,6 +988,13 @@ class idlers extends helperFunctions } } + public function objectCards() + { + $this->serverCards(); + $this->sharedHostingCards(); + $this->domainCards(); + } + public function objectTables() { $this->serverTable(); @@ -3082,7 +3096,11 @@ class idlers extends helperFunctions protected function viewSwitcherIcon() { $this->rowColOpen('row text-center', 'col-12'); - $this->outputString(''); + if (self::DEFAULT_VIEW == 'CARDS') { + $this->outputString(''); + } else { + $this->outputString(''); + } $this->tagClose('div', 2); } From 00039c4d081685adeee90d15149e605ce6e24c4f Mon Sep 17 00:00:00 2001 From: cp6 Date: Sat, 30 Jan 2021 11:23:18 +1100 Subject: [PATCH 04/12] Fixed active status switching for object view type Fixed active status switching for object view type --- assets/js/scripts.min.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/assets/js/scripts.min.js b/assets/js/scripts.min.js index fe1b934..5c89531 100644 --- a/assets/js/scripts.min.js +++ b/assets/js/scripts.min.js @@ -348,6 +348,8 @@ $(document).on("click", "#viewSwitcherIcon", function () { } icon.removeClass("fa-table"); icon.addClass("fa-th"); + $("#tableViewDiv").addClass("active"); + $("#cardsViewDiv").removeClass("active"); $("#cardsViewDiv").hide(); $("#tableViewDiv").show(); $('#viewSwitchIcon').prop('title', 'Switch to cards'); From cf353906e7c56bb906b68977ea2c9a383ed0c6ec Mon Sep 17 00:00:00 2001 From: cp6 Date: Sun, 31 Jan 2021 00:03:38 +1100 Subject: [PATCH 05/12] Added attach domain to server or shared hosting Added attach domain to server or shared hosting --- assets/js/scripts.min.js | 1 + class.php | 61 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 60 insertions(+), 2 deletions(-) diff --git a/assets/js/scripts.min.js b/assets/js/scripts.min.js index 5c89531..8e0c1b2 100644 --- a/assets/js/scripts.min.js +++ b/assets/js/scripts.min.js @@ -454,6 +454,7 @@ function modalEditDomain(id) { $("#d_me_term").val(result["term"]); $("#d_me_ns1").val(result["ns1"]); $("#d_me_ns2").val(result["ns2"]); + $("#d_me_attached_to").val(result["attached_to"]); } }); } diff --git a/class.php b/class.php index 5aa8af1..35cd131 100644 --- a/class.php +++ b/class.php @@ -1563,6 +1563,27 @@ class idlers extends helperFunctions $this->tagClose('div', 4); } + protected function attachDomainInput() + { + $this->rowColOpen('form-row', 'col-12'); + $this->tagOpen('div', 'input-group'); + $this->inputPrepend('Attached to'); + $this->selectElement('d_me_attached_to'); + $select_servers = $this->dbConnect()->prepare("SELECT `id`, `hostname` FROM `servers`;"); + $select_servers->execute(); + $this->selectOption('', '', true);//Empty option for when not attached + while ($row = $select_servers->fetch(PDO::FETCH_ASSOC)) { + $this->selectOption($row['hostname'], $row['id']); + } + $select_shared = $this->dbConnect()->prepare("SELECT `id`, `domain` FROM `shared_hosting`;"); + $select_shared->execute(); + while ($row = $select_shared->fetch(PDO::FETCH_ASSOC)) { + $this->selectOption($row['domain'], $row['id']); + } + $this->tagClose('select'); + $this->tagClose('div', 3); + } + public function editDomainModal() { $this->outputString('