show both containers by default

This commit is contained in:
usmannasir
2025-04-11 13:00:53 +05:00
parent bc125ddf0f
commit 492db203fa
3 changed files with 201 additions and 310 deletions

View File

@@ -376,7 +376,6 @@
<a href="#" title="{% trans 'Dockersite' %}"> <a href="#" title="{% trans 'Dockersite' %}">
<div class="glyph-icon icon-globe" title="{% trans 'Docker Apps' %}"></div> <div class="glyph-icon icon-globe" title="{% trans 'Docker Apps' %}"></div>
<span>{% trans "Docker Apps" %}</span> <span>{% trans "Docker Apps" %}</span>
<span class="bs-label badge-yellow">{% trans "Beta" %}</span>
</a> </a>
<div class="sidebar-submenu"> <div class="sidebar-submenu">

View File

@@ -183,9 +183,7 @@
<tr ng-repeat="web in ContainerList track by $index"> <tr ng-repeat="web in ContainerList track by $index">
<td ng-bind="web.name"></td> <td ng-bind="web.name"></td>
<td ng-click="Lunchcontainer(web.id)"><img width="30px" height="30" class="" <td ng-init="Lunchcontainer(web.id)"></td>
src="{% static 'baseTemplate/assets/image-resources/webPanel.png' %}">
</td>
{# <td ng-bind="web.admin"></td>#} {# <td ng-bind="web.admin"></td>#}
{# <td ng-bind="web.image"></td>#} {# <td ng-bind="web.image"></td>#}
{# <td ng-bind="web.tag"></td>#} {# <td ng-bind="web.tag"></td>#}
@@ -331,20 +329,21 @@
<div ng-hide="conatinerview"> <div ng-hide="conatinerview">
<div> <div>
<div ng-show="ContainerList.length > 0">
<div ng-repeat="web in ContainerList">
<div class="mb-5">
<div id="page-title" class="mb-4"> <div id="page-title" class="mb-4">
<h2 id="domainNamePage" class="d-flex justify-content-between align-items-center"> <h2 id="domainNamePage" class="d-flex justify-content-between align-items-center">
<span>{% trans "Currently managing: " %} {$ cName $}</span> <span>{% trans "Currently managing: " %} {$ web.name $}</span>
<button class="btn btn-warning" data-toggle="modal" data-target="#Recreatedockerapp"> <button class="btn btn-warning" data-toggle="modal" data-target="#Recreatedockerapp">
<i class="fa fa-refresh btn-icon"></i> Recreate <i class="fa fa-refresh btn-icon"></i> Recreate
</button> </button>
</h2> </h2>
<p class="text-muted"> <p class="text-muted">
{% trans "Container ID" %}: <code>{$ cid $}</code> {% trans "Container ID" %}: <code>{$ web.id $}</code>
</p> </p>
</div> </div>
<div class="container-fluid p-0"> <div class="container-fluid p-0">
<div class="panel panel-body"> <div class="panel panel-body">
<h3 class="content-box-header d-flex justify-content-between align-items-center mb-4"> <h3 class="content-box-header d-flex justify-content-between align-items-center mb-4">
@@ -357,14 +356,14 @@
<div class="info-box shadow-sm"> <div class="info-box shadow-sm">
<h4 class="border-bottom pb-2 mb-3">Basic Information</h4> <h4 class="border-bottom pb-2 mb-3">Basic Information</h4>
<div class="info-list"> <div class="info-list">
<p class="mb-2"><strong>Container ID:</strong> <code>{$ cid $}</code></p> <p class="mb-2"><strong>Container ID:</strong> <code>{$ web.id $}</code></p>
<p class="mb-2"><strong>Status:</strong> <p class="mb-2"><strong>Status:</strong>
<span class="label px-3 py-1 rounded" ng-class="{'label-success': status === 'running', 'label-danger': status === 'stopped', 'label-warning': status !== 'running' && status !== 'stopped'}"> <span class="label px-3 py-1 rounded" ng-class="{'label-success': web.status === 'running', 'label-danger': web.status === 'stopped', 'label-warning': web.status !== 'running' && web.status !== 'stopped'}">
{$ status $} {$ web.status $}
</span> </span>
</p> </p>
<p class="mb-2"><strong>Created:</strong> {$ created | date:'medium' $}</p> <p class="mb-2"><strong>Created:</strong> {$ web.created | date:'medium' $}</p>
<p class="mb-2"><strong>Uptime:</strong> {$ uptime $}</p> <p class="mb-2"><strong>Uptime:</strong> {$ web.uptime $}</p>
</div> </div>
</div> </div>
@@ -374,11 +373,11 @@
<label class="mb-2">Memory Usage</label> <label class="mb-2">Memory Usage</label>
<div class="progress" style="height: 20px;"> <div class="progress" style="height: 20px;">
<div class="progress-bar" role="progressbar" <div class="progress-bar" role="progressbar"
ng-style="{'width': memoryUsagePercent + '%'}" ng-style="{'width': web.memoryUsagePercent + '%'}"
aria-valuenow="{$ memoryUsagePercent $}" aria-valuenow="{$ web.memoryUsagePercent $}"
aria-valuemin="0" aria-valuemin="0"
aria-valuemax="100"> aria-valuemax="100">
{$ memoryUsagePercent | number:1 $}% {$ web.memoryUsagePercent | number:1 $}%
</div> </div>
</div> </div>
</div> </div>
@@ -386,11 +385,11 @@
<label class="mb-2">CPU Usage</label> <label class="mb-2">CPU Usage</label>
<div class="progress" style="height: 20px;"> <div class="progress" style="height: 20px;">
<div class="progress-bar" role="progressbar" <div class="progress-bar" role="progressbar"
ng-style="{'width': cpuUsagePercent + '%'}" ng-style="{'width': web.cpuUsagePercent + '%'}"
aria-valuenow="{$ cpuUsagePercent $}" aria-valuenow="{$ web.cpuUsagePercent $}"
aria-valuemin="0" aria-valuemin="0"
aria-valuemax="100"> aria-valuemax="100">
{$ cpuUsagePercent | number:1 $}% {$ web.cpuUsagePercent | number:1 $}%
</div> </div>
</div> </div>
</div> </div>
@@ -400,7 +399,7 @@
<div class="col-md-6"> <div class="col-md-6">
<div class="info-box shadow-sm"> <div class="info-box shadow-sm">
<h4 class="border-bottom pb-2 mb-3">Network & Ports</h4> <h4 class="border-bottom pb-2 mb-3">Network & Ports</h4>
<div ng-if="ports && (ports | objLength) > 0"> <div ng-if="web.ports && (web.ports | objLength) > 0">
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-striped table-hover mb-0"> <table class="table table-striped table-hover mb-0">
<thead> <thead>
@@ -410,7 +409,7 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr ng-repeat="(containerPort, hostBindings) in ports"> <tr ng-repeat="(containerPort, hostBindings) in web.ports">
<td><code>{$ containerPort $}</code></td> <td><code>{$ containerPort $}</code></td>
<td> <td>
<span ng-repeat="binding in hostBindings" class="badge bg-light text-dark me-2"> <span ng-repeat="binding in hostBindings" class="badge bg-light text-dark me-2">
@@ -422,14 +421,14 @@
</table> </table>
</div> </div>
</div> </div>
<div ng-if="!ports || (ports | objLength) === 0" class="text-muted"> <div ng-if="!web.ports || (web.ports | objLength) === 0" class="text-muted">
<p class="mb-0">No ports exposed</p> <p class="mb-0">No ports exposed</p>
</div> </div>
</div> </div>
<div class="info-box shadow-sm mt-4"> <div class="info-box shadow-sm mt-4">
<h4 class="border-bottom pb-2 mb-3">Volumes</h4> <h4 class="border-bottom pb-2 mb-3">Volumes</h4>
<div ng-if="volumes && volumes.length > 0"> <div ng-if="web.volumes && web.volumes.length > 0">
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-striped table-hover mb-0"> <table class="table table-striped table-hover mb-0">
<thead> <thead>
@@ -440,7 +439,7 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr ng-repeat="volume in volumes"> <tr ng-repeat="volume in web.volumes">
<td><code>{$ volume.Source $}</code></td> <td><code>{$ volume.Source $}</code></td>
<td><code>{$ volume.Destination $}</code></td> <td><code>{$ volume.Destination $}</code></td>
<td><span class="badge bg-secondary">{$ volume.Mode $}</span></td> <td><span class="badge bg-secondary">{$ volume.Mode $}</span></td>
@@ -449,14 +448,14 @@
</table> </table>
</div> </div>
</div> </div>
<div ng-if="!volumes || volumes.length === 0" class="text-muted"> <div ng-if="!web.volumes || web.volumes.length === 0" class="text-muted">
<p class="mb-0">No volumes mounted</p> <p class="mb-0">No volumes mounted</p>
</div> </div>
</div> </div>
<div class="info-box shadow-sm mt-4"> <div class="info-box shadow-sm mt-4">
<h4 class="border-bottom pb-2 mb-3">Environment Variables</h4> <h4 class="border-bottom pb-2 mb-3">Environment Variables</h4>
<div ng-if="environment && environment.length > 0"> <div ng-if="web.environment && web.environment.length > 0">
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-striped table-hover mb-0"> <table class="table table-striped table-hover mb-0">
<thead> <thead>
@@ -466,7 +465,7 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr ng-repeat="env in environment"> <tr ng-repeat="env in web.environment">
<td><code>{$ env.split('=')[0] $}</code></td> <td><code>{$ env.split('=')[0] $}</code></td>
<td><code>{$ env.split('=')[1] $}</code></td> <td><code>{$ env.split('=')[1] $}</code></td>
</tr> </tr>
@@ -474,7 +473,7 @@
</table> </table>
</div> </div>
</div> </div>
<div ng-if="!environment || environment.length === 0" class="text-muted"> <div ng-if="!web.environment || web.environment.length === 0" class="text-muted">
<p class="mb-0">No environment variables set</p> <p class="mb-0">No environment variables set</p>
</div> </div>
</div> </div>
@@ -482,6 +481,10 @@
</div> </div>
</div> </div>
</div> </div>
</div>
</div>
</div>
<div id="Recreatedockerapp" class="modal fade" role="dialog"> <div id="Recreatedockerapp" class="modal fade" role="dialog">
<div class="modal-dialog modal-lg"> <div class="modal-dialog modal-lg">
<!-- Modal content--> <!-- Modal content-->
@@ -550,9 +553,9 @@
<div class="content-box panel-body"> <div class="content-box panel-body">
<h3 class="content-box-header" ng-init="loadLogs('{{ name }}')"> <h3 class="content-box-header" ng-init="loadLogs('{{ web.name }}')">
{% trans "Logs" %} {% trans "Logs" %}
<span style="cursor:pointer;" class="pull-right" ng-click="loadLogs('{{ name }}')"><i <span style="cursor:pointer;" class="pull-right" ng-click="loadLogs('{{ web.name }}')"><i
class="fa fa-refresh btn-icon"></i></span> class="fa fa-refresh btn-icon"></i></span>
</h3> </h3>
@@ -586,7 +589,7 @@
<form name="containerSettingsForm" action="/" class="form-horizontal"> <form name="containerSettingsForm" action="/" class="form-horizontal">
<div ng-hide="installationDetailsForm" class="form-group"> <div ng-hide="installationDetailsForm" class="form-group">
<label class="col-sm-3 control-label">{% trans "Memory limit" %}</label> <label class="col-sm-3 control-label">{% trans "Memory limit" %}</label>
<div class="col-sm-6" ng-init="memory={{ memoryLimit }}"> <div class="col-sm-6" ng-init="memory={{ web.memoryLimit }}">
<input name="memory" type="number" class="form-control" <input name="memory" type="number" class="form-control"
ng-model="memory" required> ng-model="memory" required>
</div> </div>
@@ -596,7 +599,7 @@
<div ng-hide="installationDetailsForm" class="form-group"> <div ng-hide="installationDetailsForm" class="form-group">
<label class="col-sm-3 control-label">Start on reboot</label> <label class="col-sm-3 control-label">Start on reboot</label>
<div class="col-sm-9"> <div class="col-sm-9">
<div class="checkbox" ng-init="startOnReboot={{ startOnReboot }}"> <div class="checkbox" ng-init="startOnReboot={{ web.startOnReboot }}">
<label> <label>
<input ng-model="startOnReboot" type="checkbox" value="" <input ng-model="startOnReboot" type="checkbox" value=""
class="ng-pristine ng-untouched ng-valid ng-empty"> class="ng-pristine ng-untouched ng-valid ng-empty">

View File

@@ -6755,12 +6755,21 @@ StrictHostKeyChecking no
return proc.render() return proc.render()
def CreateDockersite(self, request=None, userID=None, data=None): def CreateDockersite(self, request=None, userID=None, data=None):
url = "https://platform.cyberpersons.com/CyberpanelAdOns/Adonpermission"
data = {
"name": "docker-manager",
"IP": ACLManager.GetServerIP()
}
import requests
response = requests.post(url, data=json.dumps(data))
Status = response.json()['status']
if (Status == 1) or ProcessUtilities.decideServer() == ProcessUtilities.ent:
adminNames = ACLManager.loadAllUsers(userID) adminNames = ACLManager.loadAllUsers(userID)
Data = {'adminNames': adminNames} Data = {'adminNames': adminNames}
if PackageAssignment.objects.all().count() == 0: if PackageAssignment.objects.all().count() == 0:
name = 'Default' name = 'Default'
cpu = 2 cpu = 2
Memory = 1024 Memory = 1024
@@ -6778,6 +6787,9 @@ StrictHostKeyChecking no
proc = httpProc(request, 'websiteFunctions/CreateDockerSite.html', proc = httpProc(request, 'websiteFunctions/CreateDockerSite.html',
Data, 'createWebsite') Data, 'createWebsite')
return proc.render() return proc.render()
else:
from django.shortcuts import reverse
return redirect(reverse('pricing'))
def AddDockerpackage(self, userID=None, data=None): def AddDockerpackage(self, userID=None, data=None):
try: try:
@@ -7083,7 +7095,17 @@ StrictHostKeyChecking no
return HttpResponse(final_json) return HttpResponse(final_json)
def Dockersitehome(self, request=None, userID=None, data=None, DeleteID=None): def Dockersitehome(self, request=None, userID=None, data=None, DeleteID=None):
url = "https://platform.cyberpersons.com/CyberpanelAdOns/Adonpermission"
data = {
"name": "docker-manager",
"IP": ACLManager.GetServerIP()
}
import requests
response = requests.post(url, data=json.dumps(data))
Status = response.json()['status']
if (Status == 1) or ProcessUtilities.decideServer() == ProcessUtilities.ent:
currentACL = ACLManager.loadedACL(userID) currentACL = ACLManager.loadedACL(userID)
admin = Administrator.objects.get(pk=userID) admin = Administrator.objects.get(pk=userID)
@@ -7097,139 +7119,6 @@ StrictHostKeyChecking no
proc = httpProc(request, 'websiteFunctions/DockerSiteHome.html', proc = httpProc(request, 'websiteFunctions/DockerSiteHome.html',
{'dockerSite': ds}) {'dockerSite': ds})
return proc.render() return proc.render()
try:
currentACL = ACLManager.loadedACL(userID)
admin = Administrator.objects.get(pk=userID)
domain = data['domain']
website = Websites.objects.get(domain=domain)
if ACLManager.checkOwnership(domain, admin, currentACL) != 1:
return ACLManager.loadErrorJson('fetchStatus', 0)
wp_sites = WPSites.objects.filter(owner=website)
sites = []
Vhuser = website.externalApp
PHPVersion = website.phpSelection
php = ACLManager.getPHPString(PHPVersion)
FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
for site in wp_sites:
command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp core version --skip-plugins --skip-themes --path=%s 2>/dev/null' % (
Vhuser, FinalPHPPath, site.path)
version = ProcessUtilities.outputExecutioner(command, None, True)
version = html.escape(version)
sites.append({
'id': site.id,
'title': site.title,
'url': site.FinalURL,
'path': site.path,
'version': version,
})
data_ret = {'status': 1, 'fetchStatus': 1, 'error_message': "None", "sites": sites}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException as msg:
data_ret = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
def fetchWPSitesForDomain(self, userID=None, data=None):
try:
currentACL = ACLManager.loadedACL(userID)
admin = Administrator.objects.get(pk=userID)
domain = data['domain']
website = Websites.objects.get(domain=domain)
if ACLManager.checkOwnership(domain, admin, currentACL) != 1:
return ACLManager.loadErrorJson('fetchStatus', 0)
wp_sites = WPSites.objects.filter(owner=website)
sites = []
Vhuser = website.externalApp
PHPVersion = website.phpSelection
php = ACLManager.getPHPString(PHPVersion)
FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
for site in wp_sites:
command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp core version --skip-plugins --skip-themes --path=%s 2>/dev/null' % (
Vhuser, FinalPHPPath, site.path)
version = ProcessUtilities.outputExecutioner(command, None, True)
version = html.escape(version)
# Get current theme
command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp theme list --status=active --field=name --skip-plugins --skip-themes --path=%s 2>/dev/null' % (
Vhuser, FinalPHPPath, site.path)
currentTheme = ProcessUtilities.outputExecutioner(command, None, True)
currentTheme = currentTheme.strip()
# Get number of plugins
command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp plugin list --field=name --skip-plugins --skip-themes --path=%s 2>/dev/null' % (
Vhuser, FinalPHPPath, site.path)
plugins = ProcessUtilities.outputExecutioner(command, None, True)
pluginCount = len([p for p in plugins.split('\n') if p.strip()])
# Generate screenshot URL
site_url = site.FinalURL
if not site_url.startswith(('http://', 'https://')):
site_url = f'https://{site_url}'
command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp config list --skip-plugins --skip-themes --path=%s' % (
Vhuser, FinalPHPPath, site.path)
stdout = ProcessUtilities.outputExecutioner(command)
debugging = 0
for items in stdout.split('\n'):
if items.find('WP_DEBUG true constant') > -1:
debugging = 1
break
command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp option get blog_public --skip-plugins --skip-themes --path=%s' % (
Vhuser, FinalPHPPath, site.path)
stdoutput = ProcessUtilities.outputExecutioner(command)
searchindex = int(stdoutput.splitlines()[-1])
command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp maintenance-mode status --skip-plugins --skip-themes --path=%s' % (
Vhuser, FinalPHPPath, site.path)
maintenanceMod = ProcessUtilities.outputExecutioner(command)
result = maintenanceMod.splitlines()[-1]
if result.find('not active') > -1:
maintenanceMode = 0
else: else:
maintenanceMode = 1 from django.shortcuts import reverse
return redirect(reverse('pricing'))
sites.append({
'id': site.id,
'title': site.title,
'url': site.FinalURL,
'path': site.path,
'version': version,
'phpVersion': site.owner.phpSelection,
'theme': currentTheme,
'activePlugins': pluginCount,
'debugging': debugging,
'searchIndex': searchindex,
'maintenanceMode': maintenanceMode,
'screenshot': f'https://api.microlink.io/?url={site_url}&screenshot=true&meta=false&embed=screenshot.url'
})
data_ret = {'status': 1, 'fetchStatus': 1, 'error_message': "None", "sites": sites}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException as msg:
data_ret = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)