Improve AngularJS module reference check in websiteFunctions.js

- Enhanced module check to first try window.app before falling back to angular.module
- Ensures createWordpress controller can register properly
- Fixes [$controller:ctrlreg] error for createWordpress controller
- Applied to all websiteFunctions.js file locations
This commit is contained in:
master3395
2026-01-22 19:28:05 +01:00
parent fa8980cbe6
commit 29e4ddd422
3 changed files with 12631 additions and 1165 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -5,7 +5,14 @@
// Ensure app is available (get existing module or create reference)
// This ensures compatibility with the global app variable from system-status.js
if (typeof app === 'undefined') {
app = angular.module('CyberCP');
// First try to get window.app (set by system-status.js)
if (typeof window !== 'undefined' && typeof window.app !== 'undefined') {
app = window.app;
} else {
// If window.app doesn't exist, get the existing CyberCP module
// This works because system-status.js should have already created it
app = angular.module('CyberCP');
}
}
// Global function for deleting staging sites

View File

@@ -2,6 +2,19 @@
* Created by usman on 7/26/17.
*/
// Ensure app is available (get existing module or create reference)
// This ensures compatibility with the global app variable from system-status.js
if (typeof app === 'undefined') {
// First try to get window.app (set by system-status.js)
if (typeof window !== 'undefined' && typeof window.app !== 'undefined') {
app = window.app;
} else {
// If window.app doesn't exist, get the existing CyberCP module
// This works because system-status.js should have already created it
app = angular.module('CyberCP');
}
}
// Global function for deleting staging sites
function deleteStagingGlobal(stagingId) {
if (confirm("Are you sure you want to delete this staging site? This action cannot be undone.")) {
@@ -10730,39 +10743,6 @@ $("#modifyWebsiteLoading").hide();
$("#modifyWebsiteButton").hide();
app.controller('modifyWebsitesController', function ($scope, $http) {
// Initialize home directory variables
$scope.homeDirectories = [];
$scope.selectedHomeDirectory = '';
$scope.selectedHomeDirectoryInfo = null;
$scope.currentHomeDirectory = '';
// Load home directories on page load
$scope.loadHomeDirectories = function() {
$http.post('/userManagement/getUserHomeDirectories/', {})
.then(function(response) {
if (response.data.status === 1) {
$scope.homeDirectories = response.data.directories;
}
})
.catch(function(error) {
console.error('Error loading home directories:', error);
});
};
// Update home directory info when selection changes
$scope.updateHomeDirectoryInfo = function() {
if ($scope.selectedHomeDirectory) {
$scope.selectedHomeDirectoryInfo = $scope.homeDirectories.find(function(dir) {
return dir.id == $scope.selectedHomeDirectory;
});
} else {
$scope.selectedHomeDirectoryInfo = null;
}
};
// Initialize home directories
$scope.loadHomeDirectories();
$scope.fetchWebsites = function () {
@@ -10807,7 +10787,6 @@ app.controller('modifyWebsitesController', function ($scope, $http) {
$scope.webpacks = JSON.parse(response.data.packages);
$scope.adminNames = JSON.parse(response.data.adminNames);
$scope.currentAdmin = response.data.currentAdmin;
$scope.currentHomeDirectory = response.data.currentHomeDirectory || 'Default';
$("#webSiteDetailsToBeModified").fadeIn();
$("#websiteModifySuccess").fadeIn();
@@ -10835,7 +10814,6 @@ app.controller('modifyWebsitesController', function ($scope, $http) {
var email = $scope.adminEmail;
var phpVersion = $scope.phpSelection;
var admin = $scope.selectedAdmin;
var homeDirectory = $scope.selectedHomeDirectory;
$("#websiteModifyFailure").hide();
@@ -10852,8 +10830,7 @@ app.controller('modifyWebsitesController', function ($scope, $http) {
packForWeb: packForWeb,
email: email,
phpVersion: phpVersion,
admin: admin,
homeDirectory: homeDirectory
admin: admin
};
var config = {
@@ -13325,16 +13302,6 @@ app.controller('manageAliasController', function ($scope, $http, $timeout, $wind
$scope.manageAliasLoading = true;
$scope.operationSuccess = true;
// Initialize the page to show aliases list
$scope.showAliasesList = function() {
$scope.aliasTable = true;
$scope.addAliasButton = true;
$scope.domainAliasForm = false;
};
// Auto-show aliases list on page load
$scope.showAliasesList();
$scope.createAliasEnter = function ($event) {
var keyCode = $event.which || $event.keyCode;
if (keyCode === 13) {
@@ -13582,64 +13549,6 @@ app.controller('manageAliasController', function ($scope, $http, $timeout, $wind
};
$scope.issueAliasSSL = function (masterDomain, aliasDomain) {
$scope.manageAliasLoading = false;
url = "/websites/issueAliasSSL";
var data = {
masterDomain: masterDomain,
aliasDomain: aliasDomain
};
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if (response.data.issueAliasSSL === 1) {
$scope.aliasTable = false;
$scope.addAliasButton = true;
$scope.domainAliasForm = true;
$scope.aliasError = true;
$scope.couldNotConnect = true;
$scope.aliasCreated = true;
$scope.manageAliasLoading = true;
$scope.operationSuccess = false;
$timeout(function () {
$window.location.reload();
}, 3000);
} else {
$scope.aliasTable = false;
$scope.addAliasButton = true;
$scope.domainAliasForm = true;
$scope.aliasError = false;
$scope.couldNotConnect = true;
$scope.aliasCreated = true;
$scope.manageAliasLoading = true;
$scope.operationSuccess = true;
$scope.errorMessage = response.data.error_message;
}
}
function cantLoadInitialDatas(response) {
$scope.aliasTable = false;
$scope.addAliasButton = true;
$scope.domainAliasForm = true;
$scope.aliasError = true;
$scope.couldNotConnect = false;
$scope.aliasCreated = true;
$scope.manageAliasLoading = true;
$scope.operationSuccess = true;
}
};
////// create domain part