mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-12 08:16:11 +01:00
add loader
This commit is contained in:
@@ -2631,6 +2631,7 @@ app.controller('listWebsites', function ($scope, $http, $window) {
|
|||||||
$scope.getFurtherWebsitesFromDB();
|
$scope.getFurtherWebsitesFromDB();
|
||||||
|
|
||||||
$scope.showWPSites = function(domain) {
|
$scope.showWPSites = function(domain) {
|
||||||
|
$scope.loading = true;
|
||||||
console.log('showWPSites called for domain:', domain);
|
console.log('showWPSites called for domain:', domain);
|
||||||
|
|
||||||
// Make sure domain is defined
|
// Make sure domain is defined
|
||||||
@@ -2639,32 +2640,6 @@ app.controller('listWebsites', function ($scope, $http, $window) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the website in the list
|
|
||||||
var website = $scope.WebSitesList.find(function(site) {
|
|
||||||
return site.domain === domain;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!website) {
|
|
||||||
console.error('Website not found');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Toggle WordPress sites visibility
|
|
||||||
website.showWPSites = !website.showWPSites;
|
|
||||||
|
|
||||||
// If we're hiding the section, return early
|
|
||||||
if (!website.showWPSites) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we already have the data, no need to fetch again
|
|
||||||
if (website.wp_sites && website.wp_sites.length > 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set loading state
|
|
||||||
website.loadingWP = true;
|
|
||||||
|
|
||||||
var url = '/websites/fetchWPDetails';
|
var url = '/websites/fetchWPDetails';
|
||||||
var data = {
|
var data = {
|
||||||
domain: domain
|
domain: domain
|
||||||
@@ -2681,25 +2656,28 @@ app.controller('listWebsites', function ($scope, $http, $window) {
|
|||||||
'X-CSRFToken': getCookie('csrftoken')
|
'X-CSRFToken': getCookie('csrftoken')
|
||||||
}
|
}
|
||||||
}).then(function(response) {
|
}).then(function(response) {
|
||||||
|
$scope.loading = false;
|
||||||
console.log('Response received:', response);
|
console.log('Response received:', response);
|
||||||
if (response.data.status === 1 && response.data.fetchStatus === 1) {
|
if (response.data.status === 1 && response.data.fetchStatus === 1) {
|
||||||
website.wp_sites = response.data.data;
|
// Find the website in the list and update its properties
|
||||||
} else {
|
$scope.WebSitesList.forEach(function(website) {
|
||||||
new PNotify({
|
if (website.domain === domain) {
|
||||||
title: 'Operation Failed!',
|
website.wp_sites = response.data.sites;
|
||||||
text: response.data.error_message || 'Failed to fetch WordPress sites',
|
website.showWPSites = true;
|
||||||
type: 'error'
|
console.log('Updated website:', website);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
$("#listFail").hide();
|
||||||
|
} else {
|
||||||
|
$("#listFail").fadeIn();
|
||||||
|
$scope.errorMessage = response.data.error_message || 'Failed to fetch WordPress sites';
|
||||||
|
console.error('Error in response:', response.data.error_message);
|
||||||
}
|
}
|
||||||
}).catch(function(error) {
|
}).catch(function(error) {
|
||||||
console.error('Error:', error);
|
$scope.loading = true;
|
||||||
new PNotify({
|
$("#listFail").fadeIn();
|
||||||
title: 'Operation Failed!',
|
$scope.errorMessage = error.message || 'An error occurred while fetching WordPress sites';
|
||||||
text: 'Could not fetch WordPress sites. Please try again.',
|
console.error('Request failed:', error);
|
||||||
type: 'error'
|
|
||||||
});
|
|
||||||
}).finally(function() {
|
|
||||||
website.loadingWP = false;
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -5769,32 +5747,6 @@ app.controller('listWebsites', function ($scope, $http, $window) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the website in the list
|
|
||||||
var website = $scope.WebSitesList.find(function(site) {
|
|
||||||
return site.domain === domain;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!website) {
|
|
||||||
console.error('Website not found');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Toggle WordPress sites visibility
|
|
||||||
website.showWPSites = !website.showWPSites;
|
|
||||||
|
|
||||||
// If we're hiding the section, return early
|
|
||||||
if (!website.showWPSites) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we already have the data, no need to fetch again
|
|
||||||
if (website.wp_sites && website.wp_sites.length > 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set loading state
|
|
||||||
website.loadingWP = true;
|
|
||||||
|
|
||||||
var url = '/websites/fetchWPDetails';
|
var url = '/websites/fetchWPDetails';
|
||||||
var data = {
|
var data = {
|
||||||
domain: domain
|
domain: domain
|
||||||
@@ -5813,23 +5765,24 @@ app.controller('listWebsites', function ($scope, $http, $window) {
|
|||||||
}).then(function(response) {
|
}).then(function(response) {
|
||||||
console.log('Response received:', response);
|
console.log('Response received:', response);
|
||||||
if (response.data.status === 1 && response.data.fetchStatus === 1) {
|
if (response.data.status === 1 && response.data.fetchStatus === 1) {
|
||||||
website.wp_sites = response.data.data;
|
// Find the website in the list and update its properties
|
||||||
} else {
|
$scope.WebSitesList.forEach(function(website) {
|
||||||
new PNotify({
|
if (website.domain === domain) {
|
||||||
title: 'Operation Failed!',
|
website.wp_sites = response.data.sites;
|
||||||
text: response.data.error_message || 'Failed to fetch WordPress sites',
|
website.showWPSites = true;
|
||||||
type: 'error'
|
console.log('Updated website:', website);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
$("#listFail").hide();
|
||||||
|
} else {
|
||||||
|
$("#listFail").fadeIn();
|
||||||
|
$scope.errorMessage = response.data.error_message || 'Failed to fetch WordPress sites';
|
||||||
|
console.error('Error in response:', response.data.error_message);
|
||||||
}
|
}
|
||||||
}).catch(function(error) {
|
}).catch(function(error) {
|
||||||
console.error('Error:', error);
|
$("#listFail").fadeIn();
|
||||||
new PNotify({
|
$scope.errorMessage = error.message || 'An error occurred while fetching WordPress sites';
|
||||||
title: 'Operation Failed!',
|
console.error('Request failed:', error);
|
||||||
text: 'Could not fetch WordPress sites. Please try again.',
|
|
||||||
type: 'error'
|
|
||||||
});
|
|
||||||
}).finally(function() {
|
|
||||||
website.loadingWP = false;
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -9473,32 +9426,6 @@ app.controller('listWebsites', function ($scope, $http, $window) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the website in the list
|
|
||||||
var website = $scope.WebSitesList.find(function(site) {
|
|
||||||
return site.domain === domain;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!website) {
|
|
||||||
console.error('Website not found');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Toggle WordPress sites visibility
|
|
||||||
website.showWPSites = !website.showWPSites;
|
|
||||||
|
|
||||||
// If we're hiding the section, return early
|
|
||||||
if (!website.showWPSites) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we already have the data, no need to fetch again
|
|
||||||
if (website.wp_sites && website.wp_sites.length > 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set loading state
|
|
||||||
website.loadingWP = true;
|
|
||||||
|
|
||||||
var url = '/websites/fetchWPDetails';
|
var url = '/websites/fetchWPDetails';
|
||||||
var data = {
|
var data = {
|
||||||
domain: domain
|
domain: domain
|
||||||
@@ -9517,23 +9444,24 @@ app.controller('listWebsites', function ($scope, $http, $window) {
|
|||||||
}).then(function(response) {
|
}).then(function(response) {
|
||||||
console.log('Response received:', response);
|
console.log('Response received:', response);
|
||||||
if (response.data.status === 1 && response.data.fetchStatus === 1) {
|
if (response.data.status === 1 && response.data.fetchStatus === 1) {
|
||||||
website.wp_sites = response.data.data;
|
// Find the website in the list and update its properties
|
||||||
} else {
|
$scope.WebSitesList.forEach(function(website) {
|
||||||
new PNotify({
|
if (website.domain === domain) {
|
||||||
title: 'Operation Failed!',
|
website.wp_sites = response.data.sites;
|
||||||
text: response.data.error_message || 'Failed to fetch WordPress sites',
|
website.showWPSites = true;
|
||||||
type: 'error'
|
console.log('Updated website:', website);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
$("#listFail").hide();
|
||||||
|
} else {
|
||||||
|
$("#listFail").fadeIn();
|
||||||
|
$scope.errorMessage = response.data.error_message || 'Failed to fetch WordPress sites';
|
||||||
|
console.error('Error in response:', response.data.error_message);
|
||||||
}
|
}
|
||||||
}).catch(function(error) {
|
}).catch(function(error) {
|
||||||
console.error('Error:', error);
|
$("#listFail").fadeIn();
|
||||||
new PNotify({
|
$scope.errorMessage = error.message || 'An error occurred while fetching WordPress sites';
|
||||||
title: 'Operation Failed!',
|
console.error('Request failed:', error);
|
||||||
text: 'Could not fetch WordPress sites. Please try again.',
|
|
||||||
type: 'error'
|
|
||||||
});
|
|
||||||
}).finally(function() {
|
|
||||||
website.loadingWP = false;
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -13542,31 +13470,23 @@ app.controller('manageAliasController', function ($scope, $http, $timeout, $wind
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the website in the list
|
// Find the website in the list and set loading state
|
||||||
var website = $scope.WebSitesList.find(function(site) {
|
var site = $scope.WebSitesList.find(function(website) {
|
||||||
return site.domain === domain;
|
return website.domain === domain;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!website) {
|
if (!site) {
|
||||||
console.error('Website not found');
|
console.error('Website not found:', domain);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Toggle WordPress sites visibility
|
// Toggle visibility and handle loading state
|
||||||
website.showWPSites = !website.showWPSites;
|
site.showWPSites = !site.showWPSites;
|
||||||
|
|
||||||
// If we're hiding the section, return early
|
|
||||||
if (!website.showWPSites) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we already have the data, no need to fetch again
|
|
||||||
if (website.wp_sites && website.wp_sites.length > 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Only fetch if we're showing and don't have data yet
|
||||||
|
if (site.showWPSites && (!site.wp_sites || !site.wp_sites.length)) {
|
||||||
// Set loading state
|
// Set loading state
|
||||||
website.loadingWP = true;
|
site.loadingWPSites = true;
|
||||||
|
|
||||||
var url = '/websites/fetchWPDetails';
|
var url = '/websites/fetchWPDetails';
|
||||||
var data = {
|
var data = {
|
||||||
@@ -13586,24 +13506,22 @@ app.controller('manageAliasController', function ($scope, $http, $timeout, $wind
|
|||||||
}).then(function(response) {
|
}).then(function(response) {
|
||||||
console.log('Response received:', response);
|
console.log('Response received:', response);
|
||||||
if (response.data.status === 1 && response.data.fetchStatus === 1) {
|
if (response.data.status === 1 && response.data.fetchStatus === 1) {
|
||||||
website.wp_sites = response.data.data;
|
site.wp_sites = response.data.sites;
|
||||||
|
$("#listFail").hide();
|
||||||
} else {
|
} else {
|
||||||
new PNotify({
|
$("#listFail").fadeIn();
|
||||||
title: 'Operation Failed!',
|
$scope.errorMessage = response.data.error_message || 'Failed to fetch WordPress sites';
|
||||||
text: response.data.error_message || 'Failed to fetch WordPress sites',
|
console.error('Error in response:', response.data.error_message);
|
||||||
type: 'error'
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}).catch(function(error) {
|
}).catch(function(error) {
|
||||||
console.error('Error:', error);
|
$("#listFail").fadeIn();
|
||||||
new PNotify({
|
$scope.errorMessage = error.message || 'An error occurred while fetching WordPress sites';
|
||||||
title: 'Operation Failed!',
|
console.error('Request failed:', error);
|
||||||
text: 'Could not fetch WordPress sites. Please try again.',
|
|
||||||
type: 'error'
|
|
||||||
});
|
|
||||||
}).finally(function() {
|
}).finally(function() {
|
||||||
website.loadingWP = false;
|
// Clear loading state when done
|
||||||
|
site.loadingWPSites = false;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.updateSetting = function(wp, setting) {
|
$scope.updateSetting = function(wp, setting) {
|
||||||
|
|||||||
@@ -149,22 +149,13 @@
|
|||||||
<span ng-if="web.wp_sites && web.wp_sites.length > 0" style="text-transform: none">
|
<span ng-if="web.wp_sites && web.wp_sites.length > 0" style="text-transform: none">
|
||||||
{$ web.wp_sites.length $} WordPress Sites
|
{$ web.wp_sites.length $} WordPress Sites
|
||||||
</span>
|
</span>
|
||||||
|
<i ng-if="web.loadingWPSites" class="fa fa-spinner fa-spin" style="margin-left: 5px;"></i>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- WordPress Sites Loading State -->
|
|
||||||
<div class="col-md-12" ng-if="web.loadingWP" style="padding: 30px;">
|
|
||||||
<div class="text-center">
|
|
||||||
<div class="spinner-border text-primary" role="status" style="width: 2rem; height: 2rem;">
|
|
||||||
<span class="sr-only">Loading WordPress sites...</span>
|
|
||||||
</div>
|
|
||||||
<p class="mt-2">{% trans "Loading WordPress sites..." %}</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- WordPress Sites Section -->
|
<!-- WordPress Sites Section -->
|
||||||
<div class="col-md-12" ng-if="!web.loadingWP && web.showWPSites && web.wp_sites && web.wp_sites.length > 0" style="padding: 15px 30px;">
|
<div class="col-md-12" ng-if="web.showWPSites && web.wp_sites && web.wp_sites.length > 0" style="padding: 15px 30px;">
|
||||||
<div ng-repeat="wp in web.wp_sites" class="wp-site-item">
|
<div ng-repeat="wp in web.wp_sites" class="wp-site-item">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-12">
|
<div class="col-sm-12">
|
||||||
|
|||||||
Reference in New Issue
Block a user