wp sites under main sites

This commit is contained in:
usmannasir
2025-04-02 13:42:05 +05:00
parent e4d0c3b64f
commit bec74df3e6
3 changed files with 67 additions and 60 deletions

View File

@@ -1353,7 +1353,7 @@ app.controller('WPsiteHome', function ($scope, $http, $timeout, $compile, $windo
} }
function cantLoadInitialDatas(response) { function cantLoadInitialDatas(response) {
$('#wordpresshomeloading').hide(); //$('#wordpresshomeloading').hide();
$scope.wordpresshomeloading = true; $scope.wordpresshomeloading = true;
$scope.stagingDetailsForm = true; $scope.stagingDetailsForm = true;
$scope.installationProgress = false; $scope.installationProgress = false;
@@ -2640,6 +2640,14 @@ app.controller('listWebsites', function ($scope, $http) {
$scope.currentPage = 1; $scope.currentPage = 1;
$scope.recordsToShow = 10; $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 () { $scope.getFurtherWebsitesFromDB = function () {
var config = { var config = {

View File

@@ -101,6 +101,40 @@
title="Owner">&emsp;</i> title="Owner">&emsp;</i>
<span ng-bind="web.admin" style="text-transform: none"></span> <span ng-bind="web.admin" style="text-transform: none"></span>
</div> </div>
<div class="col-md-3 content-box-header">
<i class="p fa fa-plus btn-icon text-muted" ng-click="toggleWPSites($index)"
data-toggle="tooltip" data-placement="right" title="Show WordPress Sites">&emsp;</i>
<span ng-if="web.wp_sites && web.wp_sites.length > 0" style="text-transform: none">
{$ web.wp_sites.length $} WordPress Sites
</span>
</div>
</div>
<!-- WordPress Sites Section -->
<div class="col-md-12" ng-if="web.showWPSites && web.wp_sites && web.wp_sites.length > 0"
style="background-color: #f9f9f9; padding: 15px; margin-top: 10px;">
<h4>WordPress Sites</h4>
<div class="row" ng-repeat="wp in web.wp_sites">
<div class="col-md-12" style="margin-bottom: 10px; padding: 10px; border: 1px solid #ddd; border-radius: 4px;">
<div class="row">
<div class="col-md-4">
<strong>{$ wp.title $}</strong>
<br>
<a href="{$ wp.url $}" target="_blank">{$ wp.url $}</a>
</div>
<div class="col-md-4">
<span>Version: {$ wp.version $}</span>
<br>
<span>PHP: {$ wp.phpVersion $}</span>
</div>
<div class="col-md-4 text-right">
<a href="/websites/WPHome?ID={$ wp.id $}" class="btn btn-primary btn-sm">
<i class="fa fa-cog"></i> Manage
</a>
</div>
</div>
</div>
</div>
</div> </div>
<div id="listFail" class="alert alert-danger"> <div id="listFail" class="alert alert-danger">

View File

@@ -2425,68 +2425,33 @@ Require valid-user"""
return HttpResponse(json_data) return HttpResponse(json_data)
def findWebsitesListJson(self, websites): def findWebsitesListJson(self, websites):
json_data = []
json_data = "[" for website in websites:
checker = 0 wp_sites = []
try: try:
ipFile = "/etc/cyberpanel/machineIP" wp_sites = WPSites.objects.filter(owner=website)
f = open(ipFile) wp_sites = [{
ipData = f.read() 'id': wp.id,
ipAddress = ipData.split('\n', 1)[0] 'title': wp.title,
except BaseException as msg: 'url': wp.FinalURL,
logging.CyberCPLogFileWriter.writeToFile("Failed to read machine IP, error:" + str(msg)) 'version': wp.version if hasattr(wp, 'version') else 'Unknown',
ipAddress = "192.168.100.1" 'phpVersion': wp.phpVersion if hasattr(wp, 'phpVersion') else 'Unknown'
} for wp in wp_sites]
### 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)
try:
PHPVersionActual = phpUtilities.WrapGetPHPVersionFromFileToGetVersionWithPHP(vhFile)
except: except:
PHPVersionActual = 'PHP 8.1' pass
if os.path.exists(ProcessUtilities.debugPath): json_data.append({
logging.CyberCPLogFileWriter.writeToFile(f'findWebsitesListJson 3') 'domain': website.domain,
'adminEmail': website.adminEmail,
DiskUsage, DiskUsagePercentage, bwInMB, bwUsage = virtualHostUtilities.FindStats(items) 'phpVersion': website.phpSelection,
if os.path.exists(ProcessUtilities.debugPath): 'state': website.state,
logging.CyberCPLogFileWriter.writeToFile(f'findWebsitesListJson 4') 'ipAddress': website.ipAddress,
try: 'diskUsed': website.diskUsed,
diskUsed = "%sMB" % str(DiskUsage) 'package': website.package,
except: 'admin': website.admin,
diskUsed = "%sMB" % str(0) 'wp_sites': wp_sites
})
dic = {'domain': items.domain, 'adminEmail': items.adminEmail, 'ipAddress': ipAddress, return json.dumps(json_data)
'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