diff --git a/README.md b/README.md index b8847d2..d8d26ad 100644 --- a/README.md +++ b/README.md @@ -5,23 +5,21 @@ A web app for displaying, organizing and storing information about servers (VPS) Despite what the name infers this self hosted web app isn't just for storing idling server information. By using a [YABs](https://github.com/masonr/yet-another-bench-script) output you can get disk & network speed values along with GeekBench 5 scores to do easier comparing and sorting. -[![Generic badge](https://img.shields.io/badge/version-1.2-blue.svg)](https://shields.io/) +[![Generic badge](https://img.shields.io/badge/version-1.3-blue.svg)](https://shields.io/) -## 1.2 changes: -**If you have version 1.1 or less already installed please run ```update.sql```** -* Added table view type (use switcher icon to change to this view) -* Added auto get IPv4/IPv6 based on hostname (Click icon at hostname input) -* Added up/down status (Click OS icon) -* Updated the order by table for better formatting -* Removed unused buttons from the CSS -* Updated Minor style changes -* Updated `update.sql` for pre-existing installations only. -* Updated when type DEDI selected "is_dedi" will be toggled -* Updated IPv4 no longer required field -* Fixed no location and/or provider causing uneven cards -* Updated delete labels -* Updated domain terms to be annual and longer only -* Fixed error when all speedtests are "busy" +## 1.3 changes: +**If you have version 1.2 already installed please run ```update1.2to1.3.sql```** +* Added constant to set main view type (cards or table). +* Fixed DNS GET requests. +* Added label field/input for servers. +* Fixed domain & shared hosting deletion. +* Updated to dns_get_record() instead of DNS API calling. +* Added KB/s to MB/s conversion. +* Fixed active status for view type div. +* Added attach domain to server or shared hosting. +* Updated search to include tags and labels. +* Updated server view more modal formatting. +* Updated server edit modal formatting. * Updated `my_idlers.sql` for changes ## Requires @@ -45,6 +43,7 @@ By using a [YABs](https://github.com/masonr/yet-another-bench-script) output you * Multi payment-term compatibility * Pre-defined operating systems * Assign tags +* Assign labels * Assign server type (KVM, OVZ, LXC & dedi) * Easy to edit values * Order by table @@ -57,11 +56,13 @@ By using a [YABs](https://github.com/masonr/yet-another-bench-script) output you * Download [the zip](https://github.com/cp6/my-idlers/archive/main.zip) and unpack the files from ```my-idlers-main/``` into your directory of choice. * Run `my_idlers.sql` in MySQL. -* **Only run ```update.sql``` if you have version 1.1 or less already installed.** +* **Only run ```update1.2to1.3.sql``` if you have version 1.2 installed.** * Edit ```class.php``` lines ```13-16``` for your MySQL details. * Edit ```class.php``` lines ```8-10``` for card order type. +* Make sure you have write access to process and store the YABs outputs. + ## Notes diff --git a/assets/css/style.css b/assets/css/style.css index 5e657ee..5691985 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -57,10 +57,6 @@ body { .container { max-width: 960px } - - .modal-lg { - max-width: 800px; - } } @media (min-width: 1200px) { @@ -196,6 +192,10 @@ body { } } +.mm-col { + margin-bottom: 0.2rem; +} + [tabindex="-1"]:focus { outline: 0 !important } @@ -249,7 +249,7 @@ a:hover { code { font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; - font-size: 87.5%; + font-size: 82%; color: #e83e8c; word-break: break-word } @@ -1534,4 +1534,10 @@ input:checked + .slider:before { .btn-bar-col { overflow-x: scroll } +} + +@media (min-width: 992px) { + .modal-lg { + max-width: 800px; + } } \ No newline at end of file diff --git a/assets/js/scripts.min.js b/assets/js/scripts.min.js index c5a0bcd..4cb5c1b 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,29 @@ $(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(); + $("#tableViewDiv").addClass("active"); + $("#cardsViewDiv").removeClass("active"); + $("#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'); } }); @@ -361,6 +383,7 @@ function modalServerEdit(id) { $("#me_tags").tagsinput('removeAll'); $("#me_server_id").val(result["server_id"]); $("#me_hostname").val(result["hostname"]); + $("#me_label").val(result["label"]); $("#me_hostname_header").text( result["hostname"]); $("#me_ns1").val(result["ns1"]); $("#me_ns2").val(result["ns2"]); @@ -432,6 +455,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/calls.php b/calls.php index 78afc3e..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(); @@ -64,7 +67,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(); diff --git a/class.php b/class.php index c3f191e..3277c13 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 @@ -523,9 +525,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; } @@ -596,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('
'); @@ -647,7 +656,7 @@ class idlers extends helperFunctions $this->editDomainModal(); $this->outputString('