mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-06 21:35:55 +01:00
wp sites under main sites
This commit is contained in:
@@ -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 = {
|
||||
|
||||
@@ -101,6 +101,40 @@
|
||||
title="Owner"> </i>
|
||||
<span ng-bind="web.admin" style="text-transform: none"></span>
|
||||
</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"> </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 id="listFail" class="alert alert-danger">
|
||||
|
||||
@@ -2425,68 +2425,33 @@ Require valid-user"""
|
||||
return HttpResponse(json_data)
|
||||
|
||||
def findWebsitesListJson(self, websites):
|
||||
|
||||
json_data = "["
|
||||
checker = 0
|
||||
|
||||
json_data = []
|
||||
for website in websites:
|
||||
wp_sites = []
|
||||
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)
|
||||
|
||||
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)
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user