mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-06 13:25:51 +01:00
fetch wp site data
This commit is contained in:
@@ -2689,24 +2689,26 @@ app.controller('listWebsites', function ($scope, $http, $window) {
|
|||||||
console.log('showWPSites called with index:', index);
|
console.log('showWPSites called with index:', index);
|
||||||
console.log('Current WebSitesList:', $scope.WebSitesList);
|
console.log('Current WebSitesList:', $scope.WebSitesList);
|
||||||
|
|
||||||
var web = $scope.WebSitesList[index];
|
$scope.selectedWebsite = $scope.WebSitesList[index];
|
||||||
console.log('Selected website:', web);
|
console.log('Selected website:', $scope.selectedWebsite);
|
||||||
|
|
||||||
// Fetch WordPress sites for this website
|
// Always fetch fresh data
|
||||||
var url = '/websites/ListWPSitesForWebsite';
|
var url = '/websites/FetchWPdata';
|
||||||
|
var data = {
|
||||||
|
domain: $scope.selectedWebsite.domain,
|
||||||
|
websiteName: $scope.selectedWebsite.domain
|
||||||
|
};
|
||||||
|
|
||||||
$http({
|
$http({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: url,
|
url: url,
|
||||||
|
data: JSON.stringify(data),
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'X-CSRFToken': getCookie('csrftoken')
|
'X-CSRFToken': getCookie('csrftoken')
|
||||||
},
|
|
||||||
data: {
|
|
||||||
websiteName: web.domain
|
|
||||||
}
|
}
|
||||||
}).then(function(response) {
|
}).then(function(response) {
|
||||||
console.log('WP Sites Response:', response);
|
console.log('WP Details Response:', response);
|
||||||
|
|
||||||
// Check if response is HTML (login page)
|
// Check if response is HTML (login page)
|
||||||
if (typeof response.data === 'string' && response.data.includes('<!DOCTYPE html>')) {
|
if (typeof response.data === 'string' && response.data.includes('<!DOCTYPE html>')) {
|
||||||
@@ -2717,23 +2719,39 @@ app.controller('listWebsites', function ($scope, $http, $window) {
|
|||||||
|
|
||||||
if (response.data && response.data.status === 1) {
|
if (response.data && response.data.status === 1) {
|
||||||
try {
|
try {
|
||||||
// Update the website's wp_sites property
|
// If single site, wrap in array
|
||||||
$scope.WebSitesList[index].wp_sites = response.data.wp_sites;
|
var sites = Array.isArray(response.data.data) ? response.data.data : [response.data.data];
|
||||||
$scope.WebSitesList[index].showWPSites = true;
|
|
||||||
} catch (error) {
|
$scope.selectedWebsite.wp_sites = sites.map(function(site) {
|
||||||
console.error('Error processing WP sites:', error);
|
return {
|
||||||
$("#listFail").fadeIn();
|
id: site.id || $scope.selectedWebsite.domain,
|
||||||
$scope.errorMessage = 'Error processing WordPress sites data';
|
title: site.title || site.domain || $scope.selectedWebsite.domain,
|
||||||
|
url: site.url || 'http://' + $scope.selectedWebsite.domain,
|
||||||
|
version: site.version || 'Unknown',
|
||||||
|
phpVersion: site.php_version || 'Unknown',
|
||||||
|
theme: site.theme || 'Unknown',
|
||||||
|
activePlugins: site.active_plugins || 0,
|
||||||
|
searchIndex: site.search_index === 'enabled',
|
||||||
|
debugging: site.debugging === 'enabled',
|
||||||
|
passwordProtection: site.password_protection === 'enabled',
|
||||||
|
maintenanceMode: site.maintenance_mode === 'enabled'
|
||||||
|
};
|
||||||
|
});
|
||||||
|
$scope.selectedWebsite.showWPSites = true;
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Error processing WordPress data:', e);
|
||||||
|
$scope.selectedWebsite.showWPSites = false;
|
||||||
|
$scope.selectedWebsite.wp_sites = [];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.error('Error fetching WP sites:', response.data.error_message);
|
console.error('Error fetching WordPress sites:', response.data.error_message);
|
||||||
$("#listFail").fadeIn();
|
$scope.selectedWebsite.showWPSites = false;
|
||||||
$scope.errorMessage = response.data.error_message || 'Error fetching WordPress sites';
|
$scope.selectedWebsite.wp_sites = [];
|
||||||
}
|
}
|
||||||
}).catch(function(error) {
|
}, function(error) {
|
||||||
console.error('Error fetching WordPress sites:', error);
|
console.error('Error fetching WordPress sites:', error);
|
||||||
$("#listFail").fadeIn();
|
$scope.selectedWebsite.showWPSites = false;
|
||||||
$scope.errorMessage = error.message || 'An error occurred while fetching WordPress sites';
|
$scope.selectedWebsite.wp_sites = [];
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -8226,24 +8244,26 @@ app.controller('listWebsites', function ($scope, $http, $window) {
|
|||||||
console.log('showWPSites called with index:', index);
|
console.log('showWPSites called with index:', index);
|
||||||
console.log('Current WebSitesList:', $scope.WebSitesList);
|
console.log('Current WebSitesList:', $scope.WebSitesList);
|
||||||
|
|
||||||
var web = $scope.WebSitesList[index];
|
$scope.selectedWebsite = $scope.WebSitesList[index];
|
||||||
console.log('Selected website:', web);
|
console.log('Selected website:', $scope.selectedWebsite);
|
||||||
|
|
||||||
// Fetch WordPress sites for this website
|
// Always fetch fresh data
|
||||||
var url = '/websites/ListWPSitesForWebsite';
|
var url = '/websites/FetchWPdata';
|
||||||
|
var data = {
|
||||||
|
domain: $scope.selectedWebsite.domain,
|
||||||
|
websiteName: $scope.selectedWebsite.domain
|
||||||
|
};
|
||||||
|
|
||||||
$http({
|
$http({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: url,
|
url: url,
|
||||||
|
data: JSON.stringify(data),
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'X-CSRFToken': getCookie('csrftoken')
|
'X-CSRFToken': getCookie('csrftoken')
|
||||||
},
|
|
||||||
data: {
|
|
||||||
websiteName: web.domain
|
|
||||||
}
|
}
|
||||||
}).then(function(response) {
|
}).then(function(response) {
|
||||||
console.log('WP Sites Response:', response);
|
console.log('WP Details Response:', response);
|
||||||
|
|
||||||
// Check if response is HTML (login page)
|
// Check if response is HTML (login page)
|
||||||
if (typeof response.data === 'string' && response.data.includes('<!DOCTYPE html>')) {
|
if (typeof response.data === 'string' && response.data.includes('<!DOCTYPE html>')) {
|
||||||
@@ -8254,23 +8274,39 @@ app.controller('listWebsites', function ($scope, $http, $window) {
|
|||||||
|
|
||||||
if (response.data && response.data.status === 1) {
|
if (response.data && response.data.status === 1) {
|
||||||
try {
|
try {
|
||||||
// Update the website's wp_sites property
|
// If single site, wrap in array
|
||||||
$scope.WebSitesList[index].wp_sites = response.data.wp_sites;
|
var sites = Array.isArray(response.data.data) ? response.data.data : [response.data.data];
|
||||||
$scope.WebSitesList[index].showWPSites = true;
|
|
||||||
} catch (error) {
|
$scope.selectedWebsite.wp_sites = sites.map(function(site) {
|
||||||
console.error('Error processing WP sites:', error);
|
return {
|
||||||
$("#listFail").fadeIn();
|
id: site.id || $scope.selectedWebsite.domain,
|
||||||
$scope.errorMessage = 'Error processing WordPress sites data';
|
title: site.title || site.domain || $scope.selectedWebsite.domain,
|
||||||
|
url: site.url || 'http://' + $scope.selectedWebsite.domain,
|
||||||
|
version: site.version || 'Unknown',
|
||||||
|
phpVersion: site.php_version || 'Unknown',
|
||||||
|
theme: site.theme || 'Unknown',
|
||||||
|
activePlugins: site.active_plugins || 0,
|
||||||
|
searchIndex: site.search_index === 'enabled',
|
||||||
|
debugging: site.debugging === 'enabled',
|
||||||
|
passwordProtection: site.password_protection === 'enabled',
|
||||||
|
maintenanceMode: site.maintenance_mode === 'enabled'
|
||||||
|
};
|
||||||
|
});
|
||||||
|
$scope.selectedWebsite.showWPSites = true;
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Error processing WordPress data:', e);
|
||||||
|
$scope.selectedWebsite.showWPSites = false;
|
||||||
|
$scope.selectedWebsite.wp_sites = [];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.error('Error fetching WP sites:', response.data.error_message);
|
console.error('Error fetching WordPress sites:', response.data.error_message);
|
||||||
$("#listFail").fadeIn();
|
$scope.selectedWebsite.showWPSites = false;
|
||||||
$scope.errorMessage = response.data.error_message || 'Error fetching WordPress sites';
|
$scope.selectedWebsite.wp_sites = [];
|
||||||
}
|
}
|
||||||
}).catch(function(error) {
|
}, function(error) {
|
||||||
console.error('Error fetching WordPress sites:', error);
|
console.error('Error fetching WordPress sites:', error);
|
||||||
$("#listFail").fadeIn();
|
$scope.selectedWebsite.showWPSites = false;
|
||||||
$scope.errorMessage = error.message || 'An error occurred while fetching WordPress sites';
|
$scope.selectedWebsite.wp_sites = [];
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -12145,24 +12181,26 @@ app.controller('manageAliasController', function ($scope, $http, $timeout, $wind
|
|||||||
console.log('showWPSites called with index:', index);
|
console.log('showWPSites called with index:', index);
|
||||||
console.log('Current WebSitesList:', $scope.WebSitesList);
|
console.log('Current WebSitesList:', $scope.WebSitesList);
|
||||||
|
|
||||||
var web = $scope.WebSitesList[index];
|
$scope.selectedWebsite = $scope.WebSitesList[index];
|
||||||
console.log('Selected website:', web);
|
console.log('Selected website:', $scope.selectedWebsite);
|
||||||
|
|
||||||
// Fetch WordPress sites for this website
|
// Always fetch fresh data
|
||||||
var url = '/websites/ListWPSitesForWebsite';
|
var url = '/websites/FetchWPdata';
|
||||||
|
var data = {
|
||||||
|
domain: $scope.selectedWebsite.domain,
|
||||||
|
websiteName: $scope.selectedWebsite.domain
|
||||||
|
};
|
||||||
|
|
||||||
$http({
|
$http({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: url,
|
url: url,
|
||||||
|
data: JSON.stringify(data),
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'X-CSRFToken': getCookie('csrftoken')
|
'X-CSRFToken': getCookie('csrftoken')
|
||||||
},
|
|
||||||
data: {
|
|
||||||
websiteName: web.domain
|
|
||||||
}
|
}
|
||||||
}).then(function(response) {
|
}).then(function(response) {
|
||||||
console.log('WP Sites Response:', response);
|
console.log('WP Details Response:', response);
|
||||||
|
|
||||||
// Check if response is HTML (login page)
|
// Check if response is HTML (login page)
|
||||||
if (typeof response.data === 'string' && response.data.includes('<!DOCTYPE html>')) {
|
if (typeof response.data === 'string' && response.data.includes('<!DOCTYPE html>')) {
|
||||||
@@ -12173,23 +12211,39 @@ app.controller('manageAliasController', function ($scope, $http, $timeout, $wind
|
|||||||
|
|
||||||
if (response.data && response.data.status === 1) {
|
if (response.data && response.data.status === 1) {
|
||||||
try {
|
try {
|
||||||
// Update the website's wp_sites property
|
// If single site, wrap in array
|
||||||
$scope.WebSitesList[index].wp_sites = response.data.wp_sites;
|
var sites = Array.isArray(response.data.data) ? response.data.data : [response.data.data];
|
||||||
$scope.WebSitesList[index].showWPSites = true;
|
|
||||||
} catch (error) {
|
$scope.selectedWebsite.wp_sites = sites.map(function(site) {
|
||||||
console.error('Error processing WP sites:', error);
|
return {
|
||||||
$("#listFail").fadeIn();
|
id: site.id || $scope.selectedWebsite.domain,
|
||||||
$scope.errorMessage = 'Error processing WordPress sites data';
|
title: site.title || site.domain || $scope.selectedWebsite.domain,
|
||||||
|
url: site.url || 'http://' + $scope.selectedWebsite.domain,
|
||||||
|
version: site.version || 'Unknown',
|
||||||
|
phpVersion: site.php_version || 'Unknown',
|
||||||
|
theme: site.theme || 'Unknown',
|
||||||
|
activePlugins: site.active_plugins || 0,
|
||||||
|
searchIndex: site.search_index === 'enabled',
|
||||||
|
debugging: site.debugging === 'enabled',
|
||||||
|
passwordProtection: site.password_protection === 'enabled',
|
||||||
|
maintenanceMode: site.maintenance_mode === 'enabled'
|
||||||
|
};
|
||||||
|
});
|
||||||
|
$scope.selectedWebsite.showWPSites = true;
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Error processing WordPress data:', e);
|
||||||
|
$scope.selectedWebsite.showWPSites = false;
|
||||||
|
$scope.selectedWebsite.wp_sites = [];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.error('Error fetching WP sites:', response.data.error_message);
|
console.error('Error fetching WordPress sites:', response.data.error_message);
|
||||||
$("#listFail").fadeIn();
|
$scope.selectedWebsite.showWPSites = false;
|
||||||
$scope.errorMessage = response.data.error_message || 'Error fetching WordPress sites';
|
$scope.selectedWebsite.wp_sites = [];
|
||||||
}
|
}
|
||||||
}).catch(function(error) {
|
}, function(error) {
|
||||||
console.error('Error fetching WordPress sites:', error);
|
console.error('Error fetching WordPress sites:', error);
|
||||||
$("#listFail").fadeIn();
|
$scope.selectedWebsite.showWPSites = false;
|
||||||
$scope.errorMessage = error.message || 'An error occurred while fetching WordPress sites';
|
$scope.selectedWebsite.wp_sites = [];
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ urlpatterns = [
|
|||||||
# WordPress
|
# WordPress
|
||||||
path('createWordpress', views.WPCreate, name='createWordpress'),
|
path('createWordpress', views.WPCreate, name='createWordpress'),
|
||||||
path('ListWPSites', views.ListWPSites, name='ListWPSites'),
|
path('ListWPSites', views.ListWPSites, name='ListWPSites'),
|
||||||
path('ListWPSitesForWebsite', views.ListWPSitesForWebsite, name='ListWPSitesForWebsite'),
|
|
||||||
path('WPHome', views.WPHome, name='WPHome'),
|
path('WPHome', views.WPHome, name='WPHome'),
|
||||||
path('RestoreBackups', views.RestoreBackups, name='RestoreBackups'),
|
path('RestoreBackups', views.RestoreBackups, name='RestoreBackups'),
|
||||||
path('RestoreHome', views.RestoreHome, name='RestoreHome'),
|
path('RestoreHome', views.RestoreHome, name='RestoreHome'),
|
||||||
|
|||||||
@@ -46,14 +46,6 @@ def ListWPSites(request):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
return redirect(loadLoginPage)
|
return redirect(loadLoginPage)
|
||||||
|
|
||||||
def ListWPSitesForWebsite(request):
|
|
||||||
try:
|
|
||||||
userID = request.session['userID']
|
|
||||||
wm = WebsiteManager()
|
|
||||||
return wm.ListWPSitesForWebsite(userID, request.POST)
|
|
||||||
except KeyError:
|
|
||||||
return redirect(loadLoginPage)
|
|
||||||
|
|
||||||
def WPHome(request):
|
def WPHome(request):
|
||||||
try:
|
try:
|
||||||
userID = request.session['userID']
|
userID = request.session['userID']
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user