2025-08-01 14:56:30 +05:00
/ * *
* Created by usman on 8 / 4 / 17.
* /
/* Java script code to create account */
app . controller ( 'createFTPAccount' , function ( $scope , $http ) {
2026-02-03 19:50:17 +01:00
// Initialize all ng-hide variables to hide alerts on page load
2026-01-30 19:46:05 +01:00
$scope . ftpLoading = false ;
$scope . ftpDetails = true ;
$scope . canNotCreateFTP = true ;
$scope . successfullyCreatedFTP = true ;
$scope . couldNotConnect = true ;
$scope . generatedPasswordView = true ;
2025-08-01 14:56:30 +05:00
2026-01-30 19:46:05 +01:00
$ ( document ) . ready ( function ( ) {
v2.5.5-dev: FTP Create Account fix, ftp_quotas table, CP_VERSION, mailUtilities indent, deploy scripts and docs
- baseTemplate: CP_VERSION from CYBERPANEL_FULL_VERSION (2.5.5.dev) for cache busting
- FTP Create Account: inline script + polling + scope sync so details form shows after website select
- ftp.js: showFTPDetails, select2/change handlers (ftp/static, static, public/static)
- sql/create_ftp_quotas.sql + deploy-ftp-quotas-table.sh for /ftp/quotaManagement
- plogical/mailUtilities.py: indentation fix in DNS query try/except block
- deploy-ftp-create-account-fix.sh, to-do docs (FTP-QUOTAS-TABLE-FIX, V2.5.5-DEV-FIXES-AND-DEPLOY, RUNTIME-VS-REPO)
2026-02-04 02:33:32 +01:00
$ ( ".ftpDetails, .account-details" ) . hide ( ) ;
2026-02-03 19:50:17 +01:00
$ ( ".ftpPasswordView" ) . hide ( ) ;
// Only use select2 if it's actually a function (avoids errors when Rocket Loader defers scripts)
2026-01-30 19:46:05 +01:00
if ( typeof $ !== 'undefined' && $ && typeof $ . fn !== 'undefined' && typeof $ . fn . select2 === 'function' ) {
try {
var $sel = $ ( '.create-ftp-acct-select' ) ;
if ( $sel . length ) {
$sel . select2 ( ) ;
$sel . on ( 'select2:select' , function ( e ) {
var data = e . params . data ;
2026-02-14 23:02:47 +01:00
$scope . $evalAsync ( function ( ) {
$scope . ftpDomain = data . text ;
$scope . ftpDetails = false ;
} ) ;
v2.5.5-dev: FTP Create Account fix, ftp_quotas table, CP_VERSION, mailUtilities indent, deploy scripts and docs
- baseTemplate: CP_VERSION from CYBERPANEL_FULL_VERSION (2.5.5.dev) for cache busting
- FTP Create Account: inline script + polling + scope sync so details form shows after website select
- ftp.js: showFTPDetails, select2/change handlers (ftp/static, static, public/static)
- sql/create_ftp_quotas.sql + deploy-ftp-quotas-table.sh for /ftp/quotaManagement
- plogical/mailUtilities.py: indentation fix in DNS query try/except block
- deploy-ftp-create-account-fix.sh, to-do docs (FTP-QUOTAS-TABLE-FIX, V2.5.5-DEV-FIXES-AND-DEPLOY, RUNTIME-VS-REPO)
2026-02-04 02:33:32 +01:00
$ ( ".ftpDetails, .account-details" ) . show ( ) ;
2026-01-30 19:46:05 +01:00
} ) ;
} else {
initNativeSelect ( ) ;
}
} catch ( err ) {
initNativeSelect ( ) ;
}
} else {
initNativeSelect ( ) ;
}
function initNativeSelect ( ) {
$ ( '.create-ftp-acct-select' ) . off ( 'select2:select' ) . on ( 'change' , function ( ) {
2026-02-14 23:02:47 +01:00
var val = $ ( this ) . val ( ) ;
$scope . $evalAsync ( function ( ) {
$scope . ftpDomain = val ;
$scope . ftpDetails = ( val && val !== '' ) ? false : true ;
} ) ;
v2.5.5-dev: FTP Create Account fix, ftp_quotas table, CP_VERSION, mailUtilities indent, deploy scripts and docs
- baseTemplate: CP_VERSION from CYBERPANEL_FULL_VERSION (2.5.5.dev) for cache busting
- FTP Create Account: inline script + polling + scope sync so details form shows after website select
- ftp.js: showFTPDetails, select2/change handlers (ftp/static, static, public/static)
- sql/create_ftp_quotas.sql + deploy-ftp-quotas-table.sh for /ftp/quotaManagement
- plogical/mailUtilities.py: indentation fix in DNS query try/except block
- deploy-ftp-create-account-fix.sh, to-do docs (FTP-QUOTAS-TABLE-FIX, V2.5.5-DEV-FIXES-AND-DEPLOY, RUNTIME-VS-REPO)
2026-02-04 02:33:32 +01:00
$ ( ".ftpDetails, .account-details" ) . show ( ) ;
2026-01-30 19:46:05 +01:00
} ) ;
}
2025-08-01 14:56:30 +05:00
} ) ;
2026-02-03 19:50:17 +01:00
$scope . showFTPDetails = function ( ) {
2026-01-30 19:46:05 +01:00
if ( $scope . ftpDomain && $scope . ftpDomain !== "" ) {
$scope . ftpDetails = false ;
v2.5.5-dev: FTP Create Account fix, ftp_quotas table, CP_VERSION, mailUtilities indent, deploy scripts and docs
- baseTemplate: CP_VERSION from CYBERPANEL_FULL_VERSION (2.5.5.dev) for cache busting
- FTP Create Account: inline script + polling + scope sync so details form shows after website select
- ftp.js: showFTPDetails, select2/change handlers (ftp/static, static, public/static)
- sql/create_ftp_quotas.sql + deploy-ftp-quotas-table.sh for /ftp/quotaManagement
- plogical/mailUtilities.py: indentation fix in DNS query try/except block
- deploy-ftp-create-account-fix.sh, to-do docs (FTP-QUOTAS-TABLE-FIX, V2.5.5-DEV-FIXES-AND-DEPLOY, RUNTIME-VS-REPO)
2026-02-04 02:33:32 +01:00
$ ( ".ftpDetails, .account-details" ) . show ( ) ;
2026-01-30 19:46:05 +01:00
} else {
$scope . ftpDetails = true ;
v2.5.5-dev: FTP Create Account fix, ftp_quotas table, CP_VERSION, mailUtilities indent, deploy scripts and docs
- baseTemplate: CP_VERSION from CYBERPANEL_FULL_VERSION (2.5.5.dev) for cache busting
- FTP Create Account: inline script + polling + scope sync so details form shows after website select
- ftp.js: showFTPDetails, select2/change handlers (ftp/static, static, public/static)
- sql/create_ftp_quotas.sql + deploy-ftp-quotas-table.sh for /ftp/quotaManagement
- plogical/mailUtilities.py: indentation fix in DNS query try/except block
- deploy-ftp-create-account-fix.sh, to-do docs (FTP-QUOTAS-TABLE-FIX, V2.5.5-DEV-FIXES-AND-DEPLOY, RUNTIME-VS-REPO)
2026-02-04 02:33:32 +01:00
$ ( ".ftpDetails, .account-details" ) . hide ( ) ;
2026-01-30 19:46:05 +01:00
}
} ;
2025-08-01 14:56:30 +05:00
$scope . createFTPAccount = function ( ) {
2026-02-03 19:50:17 +01:00
$scope . ftpLoading = true ; // Show loading while creating
2025-08-01 14:56:30 +05:00
$scope . ftpDetails = false ;
2026-01-30 19:46:05 +01:00
$scope . canNotCreateFTP = true ;
$scope . successfullyCreatedFTP = true ;
2025-08-01 14:56:30 +05:00
$scope . couldNotConnect = true ;
var ftpDomain = $scope . ftpDomain ;
var ftpUserName = $scope . ftpUserName ;
var ftpPassword = $scope . ftpPassword ;
var path = $scope . ftpPath ;
2026-02-03 19:50:17 +01:00
// Enhanced path validation
if ( typeof path === 'undefined' || path === null ) {
path = "" ;
} else {
path = path . trim ( ) ;
}
// Client-side path validation
if ( path && path !== "" ) {
// Check for dangerous characters
var dangerousChars = /[;&|$`'"<>*?~]/ ;
if ( dangerousChars . test ( path ) ) {
$scope . ftpLoading = false ;
$scope . canNotCreateFTP = false ;
$scope . successfullyCreatedFTP = true ;
$scope . couldNotConnect = true ;
$scope . errorMessage = "Invalid path: Path contains dangerous characters" ;
return ;
}
// Check for path traversal attempts
if ( path . indexOf ( ".." ) !== - 1 || path . indexOf ( "~" ) !== - 1 ) {
$scope . ftpLoading = false ;
$scope . canNotCreateFTP = false ;
$scope . successfullyCreatedFTP = true ;
$scope . couldNotConnect = true ;
$scope . errorMessage = "Invalid path: Path cannot contain '..' or '~'" ;
return ;
}
// Check if path starts with slash (should be relative)
if ( path . startsWith ( "/" ) ) {
$scope . ftpLoading = false ;
$scope . canNotCreateFTP = false ;
$scope . successfullyCreatedFTP = true ;
$scope . couldNotConnect = true ;
$scope . errorMessage = "Invalid path: Path must be relative (not starting with '/')" ;
return ;
}
}
var url = "/ftp/submitFTPCreation" ;
2025-08-01 14:56:30 +05:00
var data = {
ftpDomain : ftpDomain ,
ftpUserName : ftpUserName ,
passwordByPass : ftpPassword ,
2026-02-03 19:50:17 +01:00
path : path || '' ,
api : '0' ,
2026-01-30 19:46:05 +01:00
enableCustomQuota : $scope . enableCustomQuota || false ,
customQuotaSize : $scope . customQuotaSize || 0 ,
2025-08-01 14:56:30 +05:00
} ;
var config = {
headers : {
'X-CSRFToken' : getCookie ( 'csrftoken' )
}
} ;
$http . post ( url , data , config ) . then ( ListInitialDatas , cantLoadInitialDatas ) ;
function ListInitialDatas ( response ) {
2026-02-03 19:50:17 +01:00
if ( response . data && response . data . creatFTPStatus === 1 ) {
$scope . ftpLoading = false ; // Hide loading on success
2026-01-30 19:46:05 +01:00
$scope . successfullyCreatedFTP = false ;
$scope . canNotCreateFTP = true ;
$scope . couldNotConnect = true ;
2026-02-03 19:50:17 +01:00
$scope . createdFTPUsername = ( response . data . createdFTPUsername != null && response . data . createdFTPUsername !== '' ) ? response . data . createdFTPUsername : ( ftpDomain + '_' + ftpUserName ) ;
2026-01-30 19:46:05 +01:00
if ( typeof PNotify !== 'undefined' ) {
new PNotify ( { title : 'Success!' , text : 'FTP account successfully created.' , type : 'success' } ) ;
}
2025-08-01 14:56:30 +05:00
} else {
2026-01-30 19:46:05 +01:00
$scope . ftpLoading = false ;
$scope . canNotCreateFTP = false ;
$scope . successfullyCreatedFTP = true ;
$scope . couldNotConnect = true ;
2026-02-03 19:50:17 +01:00
$scope . errorMessage = ( response . data && response . data . error _message ) ? response . data . error _message : 'Unknown error' ;
2026-01-30 19:46:05 +01:00
if ( typeof PNotify !== 'undefined' ) {
2026-02-03 19:50:17 +01:00
new PNotify ( { title : 'Operation Failed!' , text : $scope . errorMessage , type : 'error' } ) ;
2026-01-30 19:46:05 +01:00
}
2025-08-01 14:56:30 +05:00
}
}
2026-02-03 19:50:17 +01:00
2025-08-01 14:56:30 +05:00
function cantLoadInitialDatas ( response ) {
2026-01-30 19:46:05 +01:00
$scope . ftpLoading = false ;
2026-02-03 19:50:17 +01:00
if ( $scope . successfullyCreatedFTP !== false ) {
$scope . couldNotConnect = false ;
$scope . canNotCreateFTP = true ;
$scope . successfullyCreatedFTP = true ;
if ( typeof PNotify !== 'undefined' ) {
new PNotify ( { title : 'Operation Failed!' , text : 'Could not connect to server, please refresh this page' , type : 'error' } ) ;
}
2026-01-30 19:46:05 +01:00
}
2025-08-01 14:56:30 +05:00
}
} ;
$scope . hideFewDetails = function ( ) {
2026-01-30 19:46:05 +01:00
$scope . successfullyCreatedFTP = true ;
$scope . canNotCreateFTP = true ;
$scope . couldNotConnect = true ;
2025-08-01 14:56:30 +05:00
} ;
///
$scope . generatePassword = function ( ) {
2026-01-30 19:46:05 +01:00
$ ( ".ftpPasswordView" ) . show ( ) ;
$scope . generatedPasswordView = false ;
2025-08-01 14:56:30 +05:00
$scope . ftpPassword = randomPassword ( 16 ) ;
} ;
$scope . usePassword = function ( ) {
2026-01-30 19:46:05 +01:00
$ ( ".ftpPasswordView" ) . hide ( ) ;
$scope . generatedPasswordView = true ;
} ;
2026-02-03 19:50:17 +01:00
// Quota management functions
$scope . toggleCustomQuota = function ( ) {
if ( ! $scope . enableCustomQuota ) {
$scope . customQuotaSize = 0 ;
}
2025-08-01 14:56:30 +05:00
} ;
} ) ;
/* Java script code to create account ends here */
/* Java script code to delete ftp account */
app . controller ( 'deleteFTPAccount' , function ( $scope , $http ) {
$scope . ftpAccountsOfDomain = true ;
$scope . deleteFTPButton = true ;
$scope . deleteFailure = true ;
$scope . deleteSuccess = true ;
$scope . couldNotConnect = true ;
$scope . deleteFTPButtonInit = true ;
$scope . getFTPAccounts = function ( ) {
$scope . ftpAccountsOfDomain = true ;
$scope . deleteFTPButton = true ;
$scope . deleteFailure = true ;
$scope . deleteSuccess = true ;
$scope . couldNotConnect = true ;
$scope . deleteFTPButtonInit = true ;
var url = "/ftp/fetchFTPAccounts" ;
var data = {
ftpDomain : $scope . selectedDomain ,
} ;
var config = {
headers : {
'X-CSRFToken' : getCookie ( 'csrftoken' )
}
} ;
$http . post ( url , data , config ) . then ( ListInitialDatas , cantLoadInitialDatas ) ;
function ListInitialDatas ( response ) {
if ( response . data . fetchStatus == 1 ) {
$scope . ftpAccountsFeteched = JSON . parse ( response . data . data ) ;
$scope . ftpAccountsOfDomain = false ;
$scope . deleteFTPButton = true ;
$scope . deleteFailure = true ;
$scope . deleteSuccess = true ;
$scope . couldNotConnect = true ;
$scope . deleteFTPButtonInit = false ;
} else {
$scope . ftpAccountsOfDomain = true ;
$scope . deleteFTPButton = true ;
2026-02-03 19:50:17 +01:00
$scope . deleteFailure = false ;
2025-08-01 14:56:30 +05:00
$scope . deleteSuccess = true ;
2026-02-03 19:50:17 +01:00
$scope . couldNotConnect = true ;
2025-08-01 14:56:30 +05:00
$scope . deleteFTPButtonInit = true ;
2026-02-03 19:50:17 +01:00
$scope . errorMessage = ( response . data && ( response . data . error _message || response . data . errorMessage ) ) || 'Unknown error' ;
2025-08-01 14:56:30 +05:00
}
}
function cantLoadInitialDatas ( response ) {
$scope . ftpAccountsOfDomain = true ;
$scope . deleteFTPButton = true ;
$scope . deleteFailure = true ;
$scope . deleteSuccess = true ;
$scope . couldNotConnect = false ;
$scope . deleteFTPButtonInit = true ;
}
} ;
$scope . deleteFTPAccount = function ( ) {
$scope . ftpAccountsOfDomain = false ;
$scope . deleteFTPButton = false ;
$scope . deleteFailure = true ;
$scope . deleteSuccess = true ;
$scope . couldNotConnect = true ;
$scope . deleteFTPButtonInit = false ;
} ;
$scope . deleteFTPFinal = function ( ) {
var url = "/ftp/submitFTPDelete" ;
var data = {
ftpUsername : $scope . selectedFTPAccount ,
} ;
var config = {
headers : {
'X-CSRFToken' : getCookie ( 'csrftoken' )
}
} ;
$http . post ( url , data , config ) . then ( ListInitialDatas , cantLoadInitialDatas ) ;
function ListInitialDatas ( response ) {
if ( response . data . deleteStatus == 1 ) {
$scope . ftpAccountsOfDomain = true ;
$scope . deleteFTPButton = true ;
$scope . deleteFailure = true ;
$scope . deleteSuccess = false ;
$scope . couldNotConnect = true ;
$scope . deleteFTPButtonInit = true ;
$scope . ftpUserNameDeleted = $scope . selectedFTPAccount ;
} else {
$scope . ftpAccountsOfDomain = true ;
$scope . deleteFTPButton = true ;
$scope . deleteFailure = false ;
$scope . deleteSuccess = true ;
$scope . couldNotConnect = true ;
$scope . deleteFTPButtonInit = false ;
$scope . errorMessage = response . data . error _message ;
}
}
function cantLoadInitialDatas ( response ) {
$scope . ftpAccountsOfDomain = true ;
$scope . deleteFTPButton = true ;
$scope . deleteFailure = false ;
$scope . deleteSuccess = true ;
$scope . couldNotConnect = false ;
$scope . deleteFTPButtonInit = true ;
}
} ;
} ) ;
/* Java script code to delete ftp account ends here */
app . controller ( 'listFTPAccounts' , function ( $scope , $http ) {
$scope . recordsFetched = true ;
$scope . passwordChanged = true ;
$scope . canNotChangePassword = true ;
$scope . couldNotConnect = true ;
2026-02-03 19:50:17 +01:00
$scope . ftpLoading = false ;
2025-08-01 14:56:30 +05:00
$scope . ftpAccounts = true ;
$scope . changePasswordBox = true ;
2026-02-03 19:50:17 +01:00
$scope . quotaManagementBox = true ;
2025-08-01 14:56:30 +05:00
$scope . notificationsBox = true ;
var globalFTPUsername = "" ;
$scope . fetchFTPAccounts = function ( ) {
populateCurrentRecords ( ) ;
} ;
$scope . changePassword = function ( ftpUsername ) {
$scope . recordsFetched = true ;
$scope . passwordChanged = true ;
$scope . canNotChangePassword = true ;
$scope . couldNotConnect = true ;
2026-02-03 19:50:17 +01:00
$scope . ftpLoading = false ; // Don't show loading when opening password dialog
2025-08-01 14:56:30 +05:00
$scope . changePasswordBox = false ;
$scope . notificationsBox = true ;
$scope . ftpUsername = ftpUsername ;
globalFTPUsername = ftpUsername ;
} ;
$scope . changePasswordBtn = function ( ) {
2026-02-03 19:50:17 +01:00
$scope . ftpLoading = true ; // Show loading while changing password
2025-08-01 14:56:30 +05:00
url = "/ftp/changePassword" ;
var data = {
ftpUserName : globalFTPUsername ,
passwordByPass : $scope . ftpPassword ,
} ;
var config = {
headers : {
'X-CSRFToken' : getCookie ( 'csrftoken' )
}
} ;
$http . post ( url , data , config ) . then ( ListInitialDatas , cantLoadInitialDatas ) ;
function ListInitialDatas ( response ) {
if ( response . data . changePasswordStatus == 1 ) {
$scope . notificationsBox = false ;
$scope . passwordChanged = false ;
2026-02-03 19:50:17 +01:00
$scope . ftpLoading = false ; // Hide loading when done
2025-08-01 14:56:30 +05:00
$scope . domainFeteched = $scope . selectedDomain ;
} else {
$scope . notificationsBox = false ;
$scope . canNotChangePassword = false ;
2026-02-03 19:50:17 +01:00
$scope . ftpLoading = false ; // Hide loading on error
2025-08-01 14:56:30 +05:00
$scope . canNotChangePassword = false ;
$scope . errorMessage = response . data . error _message ;
}
}
function cantLoadInitialDatas ( response ) {
$scope . notificationsBox = false ;
$scope . couldNotConnect = false ;
2026-02-03 19:50:17 +01:00
$scope . ftpLoading = false ; // Hide loading on connection error
2025-08-01 14:56:30 +05:00
}
} ;
function populateCurrentRecords ( ) {
$scope . recordsFetched = true ;
$scope . passwordChanged = true ;
$scope . canNotChangePassword = true ;
$scope . couldNotConnect = true ;
2026-02-03 19:50:17 +01:00
$scope . ftpLoading = true ; // Show loading while fetching
2025-08-01 14:56:30 +05:00
$scope . ftpAccounts = true ;
$scope . changePasswordBox = true ;
var selectedDomain = $scope . selectedDomain ;
url = "/ftp/getAllFTPAccounts" ;
var data = {
selectedDomain : selectedDomain ,
} ;
var config = {
headers : {
'X-CSRFToken' : getCookie ( 'csrftoken' )
}
} ;
$http . post ( url , data , config ) . then ( ListInitialDatas , cantLoadInitialDatas ) ;
function ListInitialDatas ( response ) {
if ( response . data . fetchStatus == 1 ) {
$scope . records = JSON . parse ( response . data . data ) ;
$scope . notificationsBox = false ;
$scope . recordsFetched = false ;
$scope . passwordChanged = true ;
$scope . canNotChangePassword = true ;
$scope . couldNotConnect = true ;
2026-02-03 19:50:17 +01:00
$scope . ftpLoading = false ; // Hide loading when done
2025-08-01 14:56:30 +05:00
$scope . ftpAccounts = false ;
$scope . changePasswordBox = true ;
$scope . domainFeteched = $scope . selectedDomain ;
} else {
$scope . notificationsBox = false ;
$scope . recordsFetched = true ;
$scope . passwordChanged = true ;
$scope . canNotChangePassword = true ;
$scope . couldNotConnect = true ;
2026-02-03 19:50:17 +01:00
$scope . ftpLoading = false ; // Hide loading on error
2025-08-01 14:56:30 +05:00
$scope . ftpAccounts = true ;
$scope . changePasswordBox = true ;
$scope . errorMessage = response . data . error _message ;
}
}
function cantLoadInitialDatas ( response ) {
$scope . notificationsBox = false ;
$scope . recordsFetched = true ;
$scope . passwordChanged = true ;
$scope . canNotChangePassword = true ;
$scope . couldNotConnect = false ;
2026-02-03 19:50:17 +01:00
$scope . ftpLoading = false ; // Hide loading on connection error
2025-08-01 14:56:30 +05:00
$scope . ftpAccounts = true ;
$scope . changePasswordBox = true ;
}
}
////
$scope . generatedPasswordView = true ;
$scope . generatePassword = function ( ) {
$scope . generatedPasswordView = false ;
$scope . ftpPassword = randomPassword ( 16 ) ;
} ;
$scope . usePassword = function ( ) {
$scope . generatedPasswordView = true ;
} ;
2026-02-03 19:50:17 +01:00
// Quota management functions
$scope . manageQuota = function ( record ) {
$scope . recordsFetched = true ;
$scope . passwordChanged = true ;
$scope . canNotChangePassword = true ;
$scope . couldNotConnect = true ;
$scope . ftpLoading = false ;
$scope . quotaManagementBox = false ;
$scope . notificationsBox = true ;
$scope . ftpUsername = record . user ;
globalFTPUsername = record . user ;
// Set current quota info
$scope . currentQuotaInfo = record . quotasize ;
$scope . packageQuota = record . package _quota ;
$scope . enableCustomQuotaEdit = record . custom _quota _enabled ;
$scope . customQuotaSizeEdit = record . custom _quota _size || 0 ;
} ;
$scope . toggleCustomQuotaEdit = function ( ) {
if ( ! $scope . enableCustomQuotaEdit ) {
$scope . customQuotaSizeEdit = 0 ;
}
} ;
$scope . updateQuotaBtn = function ( ) {
$scope . ftpLoading = true ;
url = "/ftp/updateFTPQuota" ;
var data = {
ftpUserName : globalFTPUsername ,
customQuotaSize : parseInt ( $scope . customQuotaSizeEdit ) || 0 ,
enableCustomQuota : $scope . enableCustomQuotaEdit || false ,
} ;
var config = {
headers : {
'X-CSRFToken' : getCookie ( 'csrftoken' )
}
} ;
$http . post ( url , data , config ) . then ( ListInitialDatas , cantLoadInitialDatas ) ;
function ListInitialDatas ( response ) {
if ( response . data . updateQuotaStatus == 1 ) {
$scope . notificationsBox = false ;
$scope . quotaUpdated = false ;
$scope . ftpLoading = false ;
$scope . domainFeteched = $scope . selectedDomain ;
// Refresh the records to show updated quota
populateCurrentRecords ( ) ;
// Show success notification
if ( typeof PNotify !== 'undefined' ) {
new PNotify ( {
title : 'Success!' ,
text : 'FTP quota updated successfully.' ,
type : 'success'
} ) ;
}
} else {
$scope . notificationsBox = false ;
$scope . quotaUpdateFailed = false ;
$scope . ftpLoading = false ;
$scope . errorMessage = response . data . error _message ;
// Show error notification
if ( typeof PNotify !== 'undefined' ) {
new PNotify ( {
title : 'Error!' ,
text : response . data . error _message ,
type : 'error'
} ) ;
}
}
}
function cantLoadInitialDatas ( response ) {
$scope . notificationsBox = false ;
$scope . couldNotConnect = false ;
$scope . ftpLoading = false ;
// Show error notification
if ( typeof PNotify !== 'undefined' ) {
new PNotify ( {
title : 'Error!' ,
text : 'Could not connect to server.' ,
type : 'error'
} ) ;
}
}
} ;
2025-08-01 14:56:30 +05:00
} ) ;
2026-02-03 19:50:17 +01:00
app . controller ( 'Resetftpconf' , function ( $scope , $http , $timeout , $window ) {
$scope . Loading = true ;
$scope . NotifyBox = true ;
$scope . InstallBox = true ;
$scope . installationDetailsForm = false ;
$scope . alertType = '' ;
$scope . errorMessage = '' ;
$scope . resetftp = function ( ) {
$scope . Loading = false ;
$scope . installationDetailsForm = true ;
$scope . InstallBox = false ;
$scope . alertType = '' ;
$scope . NotifyBox = true ;
var url = "/ftp/resetftpnow" ;
var data = { } ;
var config = {
headers : {
'X-CSRFToken' : getCookie ( 'csrftoken' ) ,
'Content-Type' : 'application/json'
}
} ;
$http . post ( url , data , config ) . then ( ListInitialData , cantLoadInitialData ) ;
function ListInitialData ( response ) {
if ( response . data && response . data . status === 1 ) {
$scope . NotifyBox = true ;
$scope . InstallBox = false ;
$scope . Loading = false ;
$scope . alertType = '' ;
$scope . statusfile = response . data . tempStatusPath ;
$timeout ( getRequestStatus , 1000 ) ;
} else {
$scope . errorMessage = ( response . data && ( response . data . error _message || response . data . errorMessage ) ) || 'Unknown error' ;
$scope . alertType = 'failedToStart' ;
$scope . NotifyBox = false ;
$scope . InstallBox = true ;
$scope . Loading = false ;
}
}
function cantLoadInitialData ( response ) {
$scope . errorMessage = ( response && response . data && ( response . data . error _message || response . data . errorMessage ) ) || 'Could not connect to server. Please refresh this page.' ;
$scope . alertType = 'couldNotConnect' ;
$scope . NotifyBox = false ;
$scope . InstallBox = true ;
$scope . Loading = false ;
try {
new PNotify ( { title : 'Error!' , text : $scope . errorMessage , type : 'error' } ) ;
} catch ( e ) { }
}
}
var statusPollPromise = null ;
function getRequestStatus ( ) {
$scope . NotifyBox = true ;
$scope . InstallBox = false ;
$scope . Loading = false ;
$scope . alertType = '' ;
var url = "/ftp/getresetstatus" ;
var data = { statusfile : $scope . statusfile } ;
var config = {
headers : {
'X-CSRFToken' : getCookie ( 'csrftoken' ) ,
'Content-Type' : 'application/json'
}
} ;
$http . post ( url , data , config ) . then ( ListInitialDatas , cantLoadInitialDatas ) ;
function ListInitialDatas ( response ) {
if ( ! response . data ) return ;
if ( response . data . abort === 0 ) {
$scope . alertType = '' ;
$scope . requestData = response . data . requestStatus || '' ;
statusPollPromise = $timeout ( getRequestStatus , 1000 ) ;
} else {
if ( statusPollPromise ) {
$timeout . cancel ( statusPollPromise ) ;
statusPollPromise = null ;
}
$scope . NotifyBox = false ;
$scope . InstallBox = false ;
$scope . Loading = false ;
$scope . requestData = response . data . requestStatus || '' ;
if ( response . data . installed === 0 ) {
$scope . alertType = 'resetFailed' ;
$scope . errorMessage = response . data . error _message || 'Reset failed' ;
} else {
$scope . alertType = 'success' ;
$timeout ( function ( ) { $window . location . reload ( ) ; } , 3000 ) ;
}
}
}
function cantLoadInitialDatas ( response ) {
if ( statusPollPromise ) {
$timeout . cancel ( statusPollPromise ) ;
statusPollPromise = null ;
}
$scope . alertType = 'couldNotConnect' ;
$scope . errorMessage = ( response && response . data && ( response . data . error _message || response . data . errorMessage ) ) || 'Could not connect to server. Please refresh this page.' ;
$scope . NotifyBox = false ;
$scope . InstallBox = true ;
$scope . Loading = false ;
}
}
} ) ;