From bec74df3e6949ecdeb9dd4604b0508b8e3f5039c Mon Sep 17 00:00:00 2001 From: usmannasir Date: Wed, 2 Apr 2025 13:42:05 +0500 Subject: [PATCH] wp sites under main sites --- .../websiteFunctions/websiteFunctions.js | 10 ++- .../websiteFunctions/listWebsites.html | 34 ++++++++ websiteFunctions/website.py | 83 ++++++------------- 3 files changed, 67 insertions(+), 60 deletions(-) diff --git a/websiteFunctions/static/websiteFunctions/websiteFunctions.js b/websiteFunctions/static/websiteFunctions/websiteFunctions.js index ae41912fa..298f2d69b 100755 --- a/websiteFunctions/static/websiteFunctions/websiteFunctions.js +++ b/websiteFunctions/static/websiteFunctions/websiteFunctions.js @@ -1353,7 +1353,7 @@ app.controller('WPsiteHome', function ($scope, $http, $timeout, $compile, $windo } function cantLoadInitialDatas(response) { - $('#wordpresshomeloading').hide(); + //$('#wordpresshomeloading').hide(); $scope.wordpresshomeloading = true; $scope.stagingDetailsForm = true; $scope.installationProgress = false; @@ -2640,6 +2640,14 @@ app.controller('listWebsites', function ($scope, $http) { $scope.currentPage = 1; $scope.recordsToShow = 10; + $scope.toggleWPSites = function(index) { + if (!$scope.WebSitesList[index].showWPSites) { + $scope.WebSitesList[index].showWPSites = true; + } else { + $scope.WebSitesList[index].showWPSites = false; + } + }; + $scope.getFurtherWebsitesFromDB = function () { var config = { diff --git a/websiteFunctions/templates/websiteFunctions/listWebsites.html b/websiteFunctions/templates/websiteFunctions/listWebsites.html index de049d08a..b70e04b96 100755 --- a/websiteFunctions/templates/websiteFunctions/listWebsites.html +++ b/websiteFunctions/templates/websiteFunctions/listWebsites.html @@ -101,6 +101,40 @@ title="Owner">  +
+ + + {$ web.wp_sites.length $} WordPress Sites + +
+ + + +
+

WordPress Sites

+
+
+
+
+ {$ wp.title $} +
+ {$ wp.url $} +
+
+ Version: {$ wp.version $} +
+ PHP: {$ wp.phpVersion $} +
+ +
+
+
diff --git a/websiteFunctions/website.py b/websiteFunctions/website.py index 34bbfe897..f5f6eaa74 100755 --- a/websiteFunctions/website.py +++ b/websiteFunctions/website.py @@ -2425,68 +2425,33 @@ Require valid-user""" return HttpResponse(json_data) def findWebsitesListJson(self, websites): - - json_data = "[" - checker = 0 - - try: - ipFile = "/etc/cyberpanel/machineIP" - f = open(ipFile) - ipData = f.read() - ipAddress = ipData.split('\n', 1)[0] - except BaseException as msg: - logging.CyberCPLogFileWriter.writeToFile("Failed to read machine IP, error:" + str(msg)) - ipAddress = "192.168.100.1" - - ### lets first find php path - - from plogical.phpUtilities import phpUtilities - - if os.path.exists(ProcessUtilities.debugPath): - logging.CyberCPLogFileWriter.writeToFile(f'findWebsitesListJson 1') - - for items in websites: - if os.path.exists(ProcessUtilities.debugPath): - logging.CyberCPLogFileWriter.writeToFile(f'findWebsitesListJson 2') - if items.state == 0: - state = "Suspended" - else: - state = "Active" - - vhFile = f'/usr/local/lsws/conf/vhosts/{items.domain}/vhost.conf' - - if os.path.exists(ProcessUtilities.debugPath): - logging.CyberCPLogFileWriter.writeToFile(vhFile) - + json_data = [] + for website in websites: + wp_sites = [] try: - PHPVersionActual = phpUtilities.WrapGetPHPVersionFromFileToGetVersionWithPHP(vhFile) + wp_sites = WPSites.objects.filter(owner=website) + wp_sites = [{ + 'id': wp.id, + 'title': wp.title, + 'url': wp.FinalURL, + 'version': wp.version if hasattr(wp, 'version') else 'Unknown', + 'phpVersion': wp.phpVersion if hasattr(wp, 'phpVersion') else 'Unknown' + } for wp in wp_sites] except: - PHPVersionActual = 'PHP 8.1' + pass - if os.path.exists(ProcessUtilities.debugPath): - logging.CyberCPLogFileWriter.writeToFile(f'findWebsitesListJson 3') - - DiskUsage, DiskUsagePercentage, bwInMB, bwUsage = virtualHostUtilities.FindStats(items) - if os.path.exists(ProcessUtilities.debugPath): - logging.CyberCPLogFileWriter.writeToFile(f'findWebsitesListJson 4') - try: - diskUsed = "%sMB" % str(DiskUsage) - except: - diskUsed = "%sMB" % str(0) - - dic = {'domain': items.domain, 'adminEmail': items.adminEmail, 'ipAddress': ipAddress, - 'admin': items.admin.userName, 'package': items.package.packageName, 'state': state, - 'diskUsed': diskUsed, 'phpVersion': PHPVersionActual} - - if checker == 0: - json_data = json_data + json.dumps(dic) - checker = 1 - else: - json_data = json_data + ',' + json.dumps(dic) - - json_data = json_data + ']' - - return json_data + json_data.append({ + 'domain': website.domain, + 'adminEmail': website.adminEmail, + 'phpVersion': website.phpSelection, + 'state': website.state, + 'ipAddress': website.ipAddress, + 'diskUsed': website.diskUsed, + 'package': website.package, + 'admin': website.admin, + 'wp_sites': wp_sites + }) + return json.dumps(json_data)