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,157 +329,162 @@
<div ng-hide="conatinerview"> <div ng-hide="conatinerview">
<div> <div>
<div ng-show="ContainerList.length > 0">
<div id="page-title" class="mb-4"> <div ng-repeat="web in ContainerList">
<h2 id="domainNamePage" class="d-flex justify-content-between align-items-center"> <div class="mb-5">
<span>{% trans "Currently managing: " %} {$ cName $}</span> <div id="page-title" class="mb-4">
<button class="btn btn-warning" data-toggle="modal" data-target="#Recreatedockerapp"> <h2 id="domainNamePage" class="d-flex justify-content-between align-items-center">
<i class="fa fa-refresh btn-icon"></i> Recreate <span>{% trans "Currently managing: " %} {$ web.name $}</span>
</button> <button class="btn btn-warning" data-toggle="modal" data-target="#Recreatedockerapp">
</h2> <i class="fa fa-refresh btn-icon"></i> Recreate
<p class="text-muted"> </button>
{% trans "Container ID" %}: <code>{$ cid $}</code> </h2>
</p> <p class="text-muted">
</div> {% trans "Container ID" %}: <code>{$ web.id $}</code>
</p>
<div class="container-fluid p-0">
<div class="panel panel-body">
<h3 class="content-box-header d-flex justify-content-between align-items-center mb-4">
{% trans "Container Information" %}
<img id="infoLoading" src="/static/images/loading.gif" style="display: none;">
</h3>
<div class="row g-4">
<div class="col-md-6">
<div class="info-box shadow-sm">
<h4 class="border-bottom pb-2 mb-3">Basic Information</h4>
<div class="info-list">
<p class="mb-2"><strong>Container ID:</strong> <code>{$ cid $}</code></p>
<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'}">
{$ status $}
</span>
</p>
<p class="mb-2"><strong>Created:</strong> {$ created | date:'medium' $}</p>
<p class="mb-2"><strong>Uptime:</strong> {$ uptime $}</p>
</div>
</div>
<div class="info-box shadow-sm mt-4">
<h4 class="border-bottom pb-2 mb-3">Resource Usage</h4>
<div class="mb-3">
<label class="mb-2">Memory Usage</label>
<div class="progress" style="height: 20px;">
<div class="progress-bar" role="progressbar"
ng-style="{'width': memoryUsagePercent + '%'}"
aria-valuenow="{$ memoryUsagePercent $}"
aria-valuemin="0"
aria-valuemax="100">
{$ memoryUsagePercent | number:1 $}%
</div>
</div>
</div>
<div>
<label class="mb-2">CPU Usage</label>
<div class="progress" style="height: 20px;">
<div class="progress-bar" role="progressbar"
ng-style="{'width': cpuUsagePercent + '%'}"
aria-valuenow="{$ cpuUsagePercent $}"
aria-valuemin="0"
aria-valuemax="100">
{$ cpuUsagePercent | number:1 $}%
</div>
</div>
</div>
</div>
</div> </div>
<div class="col-md-6"> <div class="container-fluid p-0">
<div class="info-box shadow-sm"> <div class="panel panel-body">
<h4 class="border-bottom pb-2 mb-3">Network & Ports</h4> <h3 class="content-box-header d-flex justify-content-between align-items-center mb-4">
<div ng-if="ports && (ports | objLength) > 0"> {% trans "Container Information" %}
<div class="table-responsive"> <img id="infoLoading" src="/static/images/loading.gif" style="display: none;">
<table class="table table-striped table-hover mb-0"> </h3>
<thead>
<tr>
<th>Container Port</th>
<th>Host Binding</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="(containerPort, hostBindings) in ports">
<td><code>{$ containerPort $}</code></td>
<td>
<span ng-repeat="binding in hostBindings" class="badge bg-light text-dark me-2">
{$ binding.HostIp || '0.0.0.0' $}:{$ binding.HostPort $}
</span>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div ng-if="!ports || (ports | objLength) === 0" class="text-muted">
<p class="mb-0">No ports exposed</p>
</div>
</div>
<div class="info-box shadow-sm mt-4"> <div class="row g-4">
<h4 class="border-bottom pb-2 mb-3">Volumes</h4> <div class="col-md-6">
<div ng-if="volumes && volumes.length > 0"> <div class="info-box shadow-sm">
<div class="table-responsive"> <h4 class="border-bottom pb-2 mb-3">Basic Information</h4>
<table class="table table-striped table-hover mb-0"> <div class="info-list">
<thead> <p class="mb-2"><strong>Container ID:</strong> <code>{$ web.id $}</code></p>
<tr> <p class="mb-2"><strong>Status:</strong>
<th>Source</th> <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'}">
<th>Destination</th> {$ web.status $}
<th>Mode</th> </span>
</tr> </p>
</thead> <p class="mb-2"><strong>Created:</strong> {$ web.created | date:'medium' $}</p>
<tbody> <p class="mb-2"><strong>Uptime:</strong> {$ web.uptime $}</p>
<tr ng-repeat="volume in volumes"> </div>
<td><code>{$ volume.Source $}</code></td> </div>
<td><code>{$ volume.Destination $}</code></td>
<td><span class="badge bg-secondary">{$ volume.Mode $}</span></td>
</tr>
</tbody>
</table>
</div>
</div>
<div ng-if="!volumes || volumes.length === 0" class="text-muted">
<p class="mb-0">No volumes mounted</p>
</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">Resource Usage</h4>
<div ng-if="environment && environment.length > 0"> <div class="mb-3">
<div class="table-responsive"> <label class="mb-2">Memory Usage</label>
<table class="table table-striped table-hover mb-0"> <div class="progress" style="height: 20px;">
<thead> <div class="progress-bar" role="progressbar"
<tr> ng-style="{'width': web.memoryUsagePercent + '%'}"
<th>Variable</th> aria-valuenow="{$ web.memoryUsagePercent $}"
<th>Value</th> aria-valuemin="0"
</tr> aria-valuemax="100">
</thead> {$ web.memoryUsagePercent | number:1 $}%
<tbody> </div>
<tr ng-repeat="env in environment"> </div>
<td><code>{$ env.split('=')[0] $}</code></td> </div>
<td><code>{$ env.split('=')[1] $}</code></td> <div>
</tr> <label class="mb-2">CPU Usage</label>
</tbody> <div class="progress" style="height: 20px;">
</table> <div class="progress-bar" role="progressbar"
ng-style="{'width': web.cpuUsagePercent + '%'}"
aria-valuenow="{$ web.cpuUsagePercent $}"
aria-valuemin="0"
aria-valuemax="100">
{$ web.cpuUsagePercent | number:1 $}%
</div>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="info-box shadow-sm">
<h4 class="border-bottom pb-2 mb-3">Network & Ports</h4>
<div ng-if="web.ports && (web.ports | objLength) > 0">
<div class="table-responsive">
<table class="table table-striped table-hover mb-0">
<thead>
<tr>
<th>Container Port</th>
<th>Host Binding</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="(containerPort, hostBindings) in web.ports">
<td><code>{$ containerPort $}</code></td>
<td>
<span ng-repeat="binding in hostBindings" class="badge bg-light text-dark me-2">
{$ binding.HostIp || '0.0.0.0' $}:{$ binding.HostPort $}
</span>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div ng-if="!web.ports || (web.ports | objLength) === 0" class="text-muted">
<p class="mb-0">No ports exposed</p>
</div>
</div>
<div class="info-box shadow-sm mt-4">
<h4 class="border-bottom pb-2 mb-3">Volumes</h4>
<div ng-if="web.volumes && web.volumes.length > 0">
<div class="table-responsive">
<table class="table table-striped table-hover mb-0">
<thead>
<tr>
<th>Source</th>
<th>Destination</th>
<th>Mode</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="volume in web.volumes">
<td><code>{$ volume.Source $}</code></td>
<td><code>{$ volume.Destination $}</code></td>
<td><span class="badge bg-secondary">{$ volume.Mode $}</span></td>
</tr>
</tbody>
</table>
</div>
</div>
<div ng-if="!web.volumes || web.volumes.length === 0" class="text-muted">
<p class="mb-0">No volumes mounted</p>
</div>
</div>
<div class="info-box shadow-sm mt-4">
<h4 class="border-bottom pb-2 mb-3">Environment Variables</h4>
<div ng-if="web.environment && web.environment.length > 0">
<div class="table-responsive">
<table class="table table-striped table-hover mb-0">
<thead>
<tr>
<th>Variable</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="env in web.environment">
<td><code>{$ env.split('=')[0] $}</code></td>
<td><code>{$ env.split('=')[1] $}</code></td>
</tr>
</tbody>
</table>
</div>
</div>
<div ng-if="!web.environment || web.environment.length === 0" class="text-muted">
<p class="mb-0">No environment variables set</p>
</div>
</div>
</div> </div>
</div>
<div ng-if="!environment || environment.length === 0" class="text-muted">
<p class="mb-0">No environment variables set</p>
</div> </div>
</div> </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,29 +6755,41 @@ 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):
adminNames = ACLManager.loadAllUsers(userID) url = "https://platform.cyberpersons.com/CyberpanelAdOns/Adonpermission"
Data = {'adminNames': adminNames} data = {
"name": "docker-manager",
"IP": ACLManager.GetServerIP()
}
import requests
response = requests.post(url, data=json.dumps(data))
Status = response.json()['status']
if PackageAssignment.objects.all().count() == 0: if (Status == 1) or ProcessUtilities.decideServer() == ProcessUtilities.ent:
adminNames = ACLManager.loadAllUsers(userID)
Data = {'adminNames': adminNames}
name = 'Default' if PackageAssignment.objects.all().count() == 0:
cpu = 2 name = 'Default'
Memory = 1024 cpu = 2
Bandwidth = '100' Memory = 1024
disk = '100' Bandwidth = '100'
disk = '100'
saveobj = DockerPackages(Name=name, CPUs=cpu, Ram=Memory, Bandwidth=Bandwidth, DiskSpace=disk, config='') saveobj = DockerPackages(Name=name, CPUs=cpu, Ram=Memory, Bandwidth=Bandwidth, DiskSpace=disk, config='')
saveobj.save() saveobj.save()
userobj = Administrator.objects.get(pk=1) userobj = Administrator.objects.get(pk=1)
sv = PackageAssignment(user=userobj, package=saveobj) sv = PackageAssignment(user=userobj, package=saveobj)
sv.save() sv.save()
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,153 +7095,30 @@ 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()
}
currentACL = ACLManager.loadedACL(userID) import requests
admin = Administrator.objects.get(pk=userID) response = requests.post(url, data=json.dumps(data))
Status = response.json()['status']
ds = DockerSites.objects.get(pk=self.domain) if (Status == 1) or ProcessUtilities.decideServer() == ProcessUtilities.ent:
currentACL = ACLManager.loadedACL(userID)
admin = Administrator.objects.get(pk=userID)
if ACLManager.checkOwnership(ds.admin.domain, admin, currentACL) == 1: ds = DockerSites.objects.get(pk=self.domain)
pass
if ACLManager.checkOwnership(ds.admin.domain, admin, currentACL) == 1:
pass
else:
return ACLManager.loadError()
proc = httpProc(request, 'websiteFunctions/DockerSiteHome.html',
{'dockerSite': ds})
return proc.render()
else: else:
return ACLManager.loadError() from django.shortcuts import reverse
return redirect(reverse('pricing'))
proc = httpProc(request, 'websiteFunctions/DockerSiteHome.html',
{'dockerSite': ds})
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:
maintenanceMode = 1
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)