mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-07 13:56:01 +01:00
update code to add design from main wp page
This commit is contained in:
@@ -237,7 +237,7 @@ app.controller('createWebsite', function ($scope, $http, $timeout, $window) {
|
|||||||
$("#listFail").hide();
|
$("#listFail").hide();
|
||||||
|
|
||||||
|
|
||||||
app.controller('listWebsites', function ($scope, $http) {
|
app.controller('listWebsites', function ($scope, $http, $window) {
|
||||||
|
|
||||||
|
|
||||||
$scope.currentPage = 1;
|
$scope.currentPage = 1;
|
||||||
@@ -384,6 +384,178 @@ app.controller('listWebsites', function ($scope, $http) {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.getFullUrl = function(url) {
|
||||||
|
if (!url) return '';
|
||||||
|
if (url.startsWith('http://') || url.startsWith('https://')) {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
return 'https://' + url;
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.showWPSites = function(domain) {
|
||||||
|
var site = $scope.WebSitesList.find(function(site) {
|
||||||
|
return site.domain === domain;
|
||||||
|
});
|
||||||
|
if (site) {
|
||||||
|
site.showWPSites = !site.showWPSites;
|
||||||
|
if (site.showWPSites && (!site.wp_sites || !site.wp_sites.length)) {
|
||||||
|
// Fetch WordPress sites if not already loaded
|
||||||
|
var config = {
|
||||||
|
headers: {
|
||||||
|
'X-CSRFToken': getCookie('csrftoken')
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var data = { domain: domain };
|
||||||
|
$http.post('/websites/getWordPressSites', data, config).then(
|
||||||
|
function(response) {
|
||||||
|
if (response.data.status === 1) {
|
||||||
|
site.wp_sites = response.data.sites;
|
||||||
|
site.wp_sites.forEach(function(wp) {
|
||||||
|
fetchWPSiteData(wp);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
new PNotify({
|
||||||
|
title: 'Error!',
|
||||||
|
text: response.data.error_message || 'Could not fetch WordPress sites',
|
||||||
|
type: 'error'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
function(response) {
|
||||||
|
new PNotify({
|
||||||
|
title: 'Error!',
|
||||||
|
text: 'Could not connect to server',
|
||||||
|
type: 'error'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
function fetchWPSiteData(wp) {
|
||||||
|
var config = {
|
||||||
|
headers: {
|
||||||
|
'X-CSRFToken': getCookie('csrftoken')
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var data = { WPid: wp.id };
|
||||||
|
|
||||||
|
// Fetch site data
|
||||||
|
$http.post('/websites/FetchWPdata', data, config).then(
|
||||||
|
function(response) {
|
||||||
|
if (response.data.status === 1) {
|
||||||
|
var data = response.data.ret_data;
|
||||||
|
wp.version = data.version;
|
||||||
|
wp.phpVersion = data.phpVersion || 'PHP 7.4';
|
||||||
|
wp.searchIndex = data.searchIndex === 1;
|
||||||
|
wp.debugging = data.debugging === 1;
|
||||||
|
wp.passwordProtection = data.passwordprotection === 1;
|
||||||
|
wp.maintenanceMode = data.maintenanceMode === 1;
|
||||||
|
fetchPluginData(wp);
|
||||||
|
fetchThemeData(wp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function fetchPluginData(wp) {
|
||||||
|
var config = {
|
||||||
|
headers: {
|
||||||
|
'X-CSRFToken': getCookie('csrftoken')
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var data = { WPid: wp.id };
|
||||||
|
$http.post('/websites/GetCurrentPlugins', data, config).then(
|
||||||
|
function(response) {
|
||||||
|
if (response.data.status === 1) {
|
||||||
|
var plugins = JSON.parse(response.data.plugins);
|
||||||
|
wp.activePlugins = plugins.filter(function(p) { return p.status === 'active'; }).length;
|
||||||
|
wp.totalPlugins = plugins.length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function fetchThemeData(wp) {
|
||||||
|
var config = {
|
||||||
|
headers: {
|
||||||
|
'X-CSRFToken': getCookie('csrftoken')
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var data = { WPid: wp.id };
|
||||||
|
$http.post('/websites/GetCurrentThemes', data, config).then(
|
||||||
|
function(response) {
|
||||||
|
if (response.data.status === 1) {
|
||||||
|
var themes = JSON.parse(response.data.themes);
|
||||||
|
wp.theme = themes.find(function(t) { return t.status === 'active'; }).name;
|
||||||
|
wp.totalThemes = themes.length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$scope.updateSetting = function(wp, setting) {
|
||||||
|
var settingMap = {
|
||||||
|
'search-indexing': 'searchIndex',
|
||||||
|
'debugging': 'debugging',
|
||||||
|
'password-protection': 'passwordProtection',
|
||||||
|
'maintenance-mode': 'maintenanceMode'
|
||||||
|
};
|
||||||
|
|
||||||
|
var data = {
|
||||||
|
siteId: wp.id,
|
||||||
|
setting: setting,
|
||||||
|
value: wp[settingMap[setting]] ? 1 : 0
|
||||||
|
};
|
||||||
|
|
||||||
|
var config = {
|
||||||
|
headers: {
|
||||||
|
'X-CSRFToken': getCookie('csrftoken')
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$http.post('/websites/UpdateWPSettings', data, config).then(
|
||||||
|
function(response) {
|
||||||
|
if (!response.data.status) {
|
||||||
|
wp[settingMap[setting]] = !wp[settingMap[setting]];
|
||||||
|
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'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
function(response) {
|
||||||
|
wp[settingMap[setting]] = !wp[settingMap[setting]];
|
||||||
|
new PNotify({
|
||||||
|
title: 'Operation Failed!',
|
||||||
|
text: 'Could not connect to server, please try again.',
|
||||||
|
type: 'error'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.wpLogin = function(wpId) {
|
||||||
|
window.open('/websites/AutoLogin?id=' + wpId, '_blank');
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.manageWP = function(wpId) {
|
||||||
|
window.location.href = '/websites/WPHome?ID=' + wpId;
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.deleteWPSite = function(wp) {
|
||||||
|
if (confirm('Are you sure you want to delete this WordPress site? This action cannot be undone.')) {
|
||||||
|
window.location.href = '/websites/ListWPSites?DeleteID=' + wp.id;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -113,69 +113,150 @@
|
|||||||
|
|
||||||
<!-- WordPress Sites Section -->
|
<!-- WordPress Sites Section -->
|
||||||
<div class="col-md-12" ng-if="web.showWPSites && web.wp_sites && web.wp_sites.length > 0">
|
<div class="col-md-12" ng-if="web.showWPSites && web.wp_sites && web.wp_sites.length > 0">
|
||||||
<div ng-repeat="wp in web.wp_sites" style="margin: 15px 0; padding: 20px; background: white; border: 1px solid #ddd; border-radius: 4px;">
|
<div ng-repeat="wp in web.wp_sites" class="wp-site-item">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-6">
|
<div class="col-sm-12">
|
||||||
<span style="font-size: 16px;" ng-bind="wp.title"></span>
|
<div class="wp-site-header">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<h4>{$ wp.title $}</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6 text-right">
|
<div class="col-sm-4 text-right">
|
||||||
<button class="btn btn-default btn-sm" style="margin-right: 5px;" ng-click="visitSite(wp.url)">Visit Site</button>
|
<button class="btn btn-primary btn-sm" ng-click="manageWP(wp.id)">
|
||||||
<button class="btn btn-default btn-sm" style="margin-right: 5px;" ng-click="wpLogin(wp.id)">WP Login</button>
|
<i class="fas fa-cog"></i> Manage
|
||||||
<button class="btn btn-primary btn-sm" ng-click="manageWP(wp.id)">MANAGE</button>
|
</button>
|
||||||
|
<button class="btn btn-danger btn-sm" ng-click="deleteWPSite(wp)">
|
||||||
|
<i class="fas fa-trash"></i> Delete
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<div class="row" style="margin-top: 30px;">
|
<div class="wp-site-content">
|
||||||
<div class="col-md-3">
|
<div class="row">
|
||||||
<div style="border-top: 1px solid #ddd; padding-top: 15px;">
|
<div class="col-sm-3">
|
||||||
<div style="color: #666; font-size: 12px; margin-bottom: 5px;">WordPress</div>
|
<img ng-src="https://api.microlink.io/?url={$ getFullUrl(wp.url) $}&screenshot=true&meta=false&embed=screenshot.url"
|
||||||
<div ng-bind="wp.version || 'Unknown'"></div>
|
alt="{$ wp.title $}"
|
||||||
|
class="img-responsive"
|
||||||
|
style="max-width: 100%; margin-bottom: 10px;"
|
||||||
|
onerror="this.onerror=null; this.src='https://s.wordpress.org/style/images/about/WordPress-logotype-standard.png';">
|
||||||
|
<div class="text-center">
|
||||||
|
<a ng-href="{$ getFullUrl(wp.url) $}" target="_blank" class="btn btn-default btn-sm">
|
||||||
|
<i class="fas fa-external-link-alt"></i> Visit Site
|
||||||
|
</a>
|
||||||
|
<a ng-click="wpLogin(wp.id)" class="btn btn-primary btn-sm" style="cursor: pointer;">
|
||||||
|
<i class="fab fa-wordpress"></i> WP Login
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-3">
|
||||||
|
<div class="info-box">
|
||||||
|
<label>WordPress</label>
|
||||||
|
<span>{$ wp.version || 'Unknown' $}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-3">
|
||||||
|
<div class="info-box">
|
||||||
|
<label>PHP Version</label>
|
||||||
|
<span>{$ wp.phpVersion || 'Loading...' $}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-3">
|
||||||
|
<div class="info-box">
|
||||||
|
<label>Theme</label>
|
||||||
|
<span>{$ wp.theme || 'twentytwentyfive' $}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-3">
|
||||||
|
<div class="info-box">
|
||||||
|
<label>Plugins</label>
|
||||||
|
<span>{$ wp.activePlugins || '0' $} active</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mt-3">
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<div class="checkbox">
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" ng-model="wp.searchIndex" ng-change="updateSetting(wp, 'search-indexing')">
|
||||||
|
Search engine indexing
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="checkbox">
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" ng-model="wp.debugging" ng-change="updateSetting(wp, 'debugging')">
|
||||||
|
Debugging
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<div class="checkbox">
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" ng-model="wp.passwordProtection" ng-change="updateSetting(wp, 'password-protection')">
|
||||||
|
Password protection
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="checkbox">
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" ng-model="wp.maintenanceMode" ng-change="updateSetting(wp, 'maintenance-mode')">
|
||||||
|
Maintenance mode
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-3">
|
|
||||||
<div style="border-top: 1px solid #ddd; padding-top: 15px;">
|
|
||||||
<div style="color: #666; font-size: 12px; margin-bottom: 5px;">PHP Version</div>
|
|
||||||
<div ng-bind="wp.phpVersion || 'Unknown'"></div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-3">
|
|
||||||
<div style="border-top: 1px solid #ddd; padding-top: 15px;">
|
|
||||||
<div style="color: #666; font-size: 12px; margin-bottom: 5px;">Theme</div>
|
|
||||||
<div ng-bind="wp.theme || 'Unknown'"></div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-3">
|
|
||||||
<div style="border-top: 1px solid #ddd; padding-top: 15px;">
|
|
||||||
<div style="color: #666; font-size: 12px; margin-bottom: 5px;">Plugins</div>
|
|
||||||
<div>{$ wp.activePlugins || '0' $} active</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row" style="margin-top: 20px;">
|
<style>
|
||||||
<div class="col-md-6">
|
.wp-site-item {
|
||||||
<div style="margin-bottom: 10px;">
|
border: 1px solid #ddd;
|
||||||
<input type="checkbox" ng-model="wp.searchIndex" ng-change="updateSetting(wp, 'search-indexing')" style="margin-right: 5px;">
|
margin-bottom: 20px;
|
||||||
<span style="color: #666;">Search engine indexing</span>
|
border-radius: 4px;
|
||||||
</div>
|
background: white;
|
||||||
<div>
|
}
|
||||||
<input type="checkbox" ng-model="wp.debugging" ng-change="updateSetting(wp, 'debugging')" style="margin-right: 5px;">
|
.wp-site-header {
|
||||||
<span style="color: #666;">Debugging</span>
|
padding: 15px;
|
||||||
</div>
|
border-bottom: 1px solid #ddd;
|
||||||
</div>
|
background: #f5f5f5;
|
||||||
<div class="col-md-6">
|
}
|
||||||
<div style="margin-bottom: 10px;">
|
.wp-site-content {
|
||||||
<input type="checkbox" ng-model="wp.passwordProtection" ng-change="updateSetting(wp, 'password-protection')" style="margin-right: 5px;">
|
padding: 15px;
|
||||||
<span style="color: #666;">Password protection</span>
|
}
|
||||||
</div>
|
.info-box {
|
||||||
<div>
|
margin-bottom: 15px;
|
||||||
<input type="checkbox" ng-model="wp.maintenanceMode" ng-change="updateSetting(wp, 'maintenance-mode')" style="margin-right: 5px;">
|
}
|
||||||
<span style="color: #666;">Maintenance mode</span>
|
.info-box label {
|
||||||
</div>
|
display: block;
|
||||||
</div>
|
font-size: 12px;
|
||||||
</div>
|
color: #666;
|
||||||
</div>
|
margin-bottom: 5px;
|
||||||
</div>
|
}
|
||||||
|
.info-box span {
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
.checkbox {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
.mt-3 {
|
||||||
|
margin-top: 1rem;
|
||||||
|
}
|
||||||
|
.btn {
|
||||||
|
margin: 0 2px;
|
||||||
|
}
|
||||||
|
.btn i {
|
||||||
|
margin-right: 5px;
|
||||||
|
}
|
||||||
|
.text-center .btn {
|
||||||
|
min-width: 100px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
<div id="listFail" class="alert alert-danger">
|
<div id="listFail" class="alert alert-danger">
|
||||||
<p>{% trans "Cannot list websites. Error message:" %} {$ errorMessage $}</p>
|
<p>{% trans "Cannot list websites. Error message:" %} {$ errorMessage $}</p>
|
||||||
|
|||||||
Reference in New Issue
Block a user