additional setting for improved wp page

This commit is contained in:
usmannasir
2025-04-01 15:45:26 +05:00
parent b7f1ac8691
commit b999a8c074

View File

@@ -2,6 +2,10 @@
{% load i18n %} {% load i18n %}
{% block title %}{% trans "WordPress Toolkit - CyberPanel" %}{% endblock %} {% block title %}{% trans "WordPress Toolkit - CyberPanel" %}{% endblock %}
{% block header_scripts %}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.5/angular.min.js"></script>
{% endblock %}
{% block styles %} {% block styles %}
<style> <style>
.container { .container {
@@ -300,10 +304,10 @@
<div class="container" ng-controller="listWordPressSites"> <div class="container" ng-controller="listWordPressSites">
<div class="alert alert-info" ng-if="debug"> <div class="alert alert-info" ng-if="debug">
<h4>Debug Information</h4> <h4>Debug Information</h4>
<p>Total WordPress Sites: [[totalSites]]</p> <p>Total WordPress Sites: {$ totalSites $}</p>
<p>User ID: [[userId]]</p> <p>User ID: {$ userId $}</p>
<p>Is Admin: [[isAdmin]]</p> <p>Is Admin: {$ isAdmin $}</p>
<p>WP Sites Count: [[wpSitesCount]]</p> <p>WP Sites Count: {$ wpSitesCount $}</p>
</div> </div>
<div class="alert alert-info" ng-if="!wpSites || wpSites.length === 0"> <div class="alert alert-info" ng-if="!wpSites || wpSites.length === 0">
@@ -319,56 +323,56 @@
</div> </div>
</div> </div>
<div class="wp-site-card" ng-repeat="site in wpSites | filter:searchTerm" data-site-id="[[site.id]]"> <div class="wp-site-card" ng-repeat="site in wpSites | filter:searchTerm" data-site-id="{$ site.id $}">
<div class="wp-site-header"> <div class="wp-site-header">
<div> <div>
<input type="checkbox" class="site-selector"> <input type="checkbox" class="site-selector">
<a href="[[site.url]]" target="_blank">[[site.url]]</a> <a href="{$ site.url $}" target="_blank">{$ site.url $}</a>
<span class="badge bg-primary" ng-if="site.production_status">PRODUCTION</span> <span class="badge bg-primary" ng-if="site.production_status">PRODUCTION</span>
</div> </div>
<div class="action-buttons"> <div class="action-buttons">
<a href="{% url 'WPHome' %}?ID=[[site.id]]" class="btn-tool"> <a href="{% url 'WPHome' %}?ID={$ site.id $}" class="btn-tool">
<i class="fas fa-cog"></i> Manage <i class="fas fa-cog"></i> Manage
</a> </a>
<button type="button" class="btn-tool" ng-click="deleteWPSite(site)"> <button type="button" class="btn-tool" onclick="DeleteWPNow('{% url 'ListWPSites' %}?DeleteID={$ site.id $}')">
<i class="fas fa-trash"></i> Delete <i class="fas fa-trash"></i> Delete
</button> </button>
</div> </div>
</div> </div>
<div class="wp-site-content"> <div class="wp-site-content">
<img ng-src="[[site.screenshot || '{% static 'websiteFunctions/images/wp-default.png' %}' ]]" <img ng-src="{$ site.screenshot || '{% static 'websiteFunctions/images/wp-default.png' %}' $}"
class="wp-site-preview" alt="[[site.title]]"> class="wp-site-preview" alt="{$ site.title $}">
<div class="wp-site-info"> <div class="wp-site-info">
<h3>[[site.title]] <a href="{% url 'AutoLogin' %}?id=[[site.id]]" target="_blank" class="btn-tool">Login</a></h3> <h3>{$ site.title $} <a href="{% url 'AutoLogin' %}?id={$ site.id $}" target="_blank" class="btn-tool">Login</a></h3>
<div class="status-section"> <div class="status-section">
<div class="status-item"> <div class="status-item">
<span>WordPress</span> <span>WordPress</span>
<span class="wp-version" ng-class="{loading: !site.version}"> <span class="wp-version" ng-class="{loading: !site.version}">
<i class="fas fa-circle-notch fa-spin" ng-if="!site.version"></i> <i class="fas fa-circle-notch fa-spin" ng-if="!site.version"></i>
[[site.version || 'Loading...']] {$ site.version || 'Loading...' $}
</span> </span>
</div> </div>
<div class="status-item"> <div class="status-item">
<span>Plugins</span> <span>Plugins</span>
<span class="plugin-status" ng-class="{loading: !site.activePlugins}"> <span class="plugin-status" ng-class="{loading: !site.activePlugins}">
<i class="fas fa-circle-notch fa-spin" ng-if="!site.activePlugins"></i> <i class="fas fa-circle-notch fa-spin" ng-if="!site.activePlugins"></i>
[[site.activePlugins || 'Loading...']] {$ site.activePlugins || 'Loading...' $}
</span> </span>
</div> </div>
<div class="status-item"> <div class="status-item">
<span>Themes</span> <span>Themes</span>
<span class="theme-status" ng-class="{loading: !site.activeTheme}"> <span class="theme-status" ng-class="{loading: !site.activeTheme}">
<i class="fas fa-circle-notch fa-spin" ng-if="!site.activeTheme"></i> <i class="fas fa-circle-notch fa-spin" ng-if="!site.activeTheme"></i>
[[site.activeTheme || 'Loading...']] {$ site.activeTheme || 'Loading...' $}
</span> </span>
</div> </div>
<div class="status-item"> <div class="status-item">
<span>PHP</span> <span>PHP</span>
<span class="php-version" ng-class="{loading: !site.phpVersion}"> <span class="php-version" ng-class="{loading: !site.phpVersion}">
<i class="fas fa-circle-notch fa-spin" ng-if="!site.phpVersion"></i> <i class="fas fa-circle-notch fa-spin" ng-if="!site.phpVersion"></i>
[[site.phpVersion || 'Loading...']] {$ site.phpVersion || 'Loading...' $}
</span> </span>
</div> </div>
</div> </div>
@@ -410,13 +414,8 @@
</div> </div>
<script> <script>
var app = angular.module('CyberCP', []);
app.config(function($interpolateProvider) {
$interpolateProvider.startSymbol('[[');
$interpolateProvider.endSymbol(']]');
});
app.controller('listWordPressSites', function($scope, $http) { app.controller('listWordPressSites', function($scope, $http) {
// Initialize scope variables
$scope.wpSites = {{ wpsite|safe }}; $scope.wpSites = {{ wpsite|safe }};
$scope.debug = {{ debug_info|default:"false"|safe }}; $scope.debug = {{ debug_info|default:"false"|safe }};
$scope.totalSites = {{ total_sites|default:"0"|safe }}; $scope.totalSites = {{ total_sites|default:"0"|safe }};
@@ -424,12 +423,6 @@
$scope.isAdmin = {{ debug_info.is_admin|default:"0"|safe }}; $scope.isAdmin = {{ debug_info.is_admin|default:"0"|safe }};
$scope.wpSitesCount = {{ debug_info.wp_sites_count|default:"0"|safe }}; $scope.wpSitesCount = {{ debug_info.wp_sites_count|default:"0"|safe }};
$scope.deleteWPSite = function(site) {
if (confirm('Are you sure you want to delete this WordPress site? This action cannot be undone.')) {
window.location.href = "{% url 'ListWPSites' %}?DeleteID=" + site.id;
}
};
$scope.updateSetting = function(site, setting) { $scope.updateSetting = function(site, setting) {
var data = { var data = {
siteId: site.id, siteId: site.id,
@@ -437,33 +430,62 @@
value: site[setting] ? 1 : 0 value: site[setting] ? 1 : 0
}; };
$http.post("{% url 'UpdateWPSettings' %}", data) GLobalAjaxCall($http, "{% url 'UpdateWPSettings' %}", data,
.then(function(response) { function(response) {
if (!response.data.status) { if (!response.data.status) {
site[setting] = !site[setting]; site[setting] = !site[setting];
alert('Failed to update setting: ' + (response.data.error || 'Unknown error')); new PNotify({
title: 'Operation Failed!',
text: response.data.error_message || 'Unknown error',
type: 'error'
});
} else {
new PNotify({
title: 'Success!',
text: 'Setting updated successfully.',
type: 'success'
});
} }
}) },
.catch(function(error) { function(response) {
site[setting] = !site[setting]; site[setting] = !site[setting];
alert('Failed to update setting. Please try again.'); new PNotify({
}); title: 'Operation Failed!',
text: 'Could not connect to server, please try again.',
type: 'error'
});
}
);
}; };
// Initialize tooltips // Initialize tooltips
$(document).ready(function() { angular.element(document).ready(function() {
$('[data-toggle="tooltip"]').tooltip(); $('[data-toggle="tooltip"]').tooltip();
}); });
// Fetch site data for each site // Fetch site data for each site
$scope.wpSites.forEach(function(site) { function fetchSiteData(site) {
$http.post("{% url 'FetchWPdata' %}", { WPid: site.id }) var data = { WPid: site.id };
.then(function(response) {
GLobalAjaxCall($http, "{% url 'FetchWPdata' %}", data,
function(response) {
if (response.data.status === 1) { if (response.data.status === 1) {
angular.extend(site, response.data.ret_data); angular.extend(site, response.data.ret_data);
} }
}); },
}); function(response) {
new PNotify({
title: 'Operation Failed!',
text: 'Could not fetch site data, please refresh the page.',
type: 'error'
});
}
);
}
if ($scope.wpSites) {
$scope.wpSites.forEach(fetchSiteData);
}
}); });
</script> </script>
{% endblock content %} {% endblock content %}