From c5dd1e4ed7413d4366070add4feead5790dfd0f0 Mon Sep 17 00:00:00 2001 From: usmannasir <01-134132-158@student.bahria.edu.pk> Date: Mon, 30 Jul 2018 17:33:28 +0500 Subject: [PATCH] Improved Website and Domain creation. --- CyberCP/settings.pyc | Bin 3917 -> 3952 bytes plogical/virtualHostUtilities.py | 111 ++++- static/websiteFunctions/websiteFunctions.js | 383 +++++++++++++----- .../websiteFunctions/websiteFunctions.js | 383 +++++++++++++----- .../websiteFunctions/createWebsite.html | 60 ++- .../templates/websiteFunctions/website.html | 64 +-- websiteFunctions/views.py | 43 +- 7 files changed, 749 insertions(+), 295 deletions(-) diff --git a/CyberCP/settings.pyc b/CyberCP/settings.pyc index 20fea15aaa38d8bf3a645094ca4160f57ffe360d..91146150a52389d1ebb4acdd3b4ec68ae805f029 100644 GIT binary patch delta 101 zcmX>r_d!mY`7 0: - print "0, This website already exists." + statusFile = open(tempStatusPath, 'w') + statusFile.writelines("This website already exists. [404]") + statusFile.close() return 0, "This website already exists." if ChildDomains.objects.filter(domain=virtualHostName).count() > 0: - print "0, This website already exists as child domain." + statusFile = open(tempStatusPath, 'w') + statusFile.writelines("This website already exists as child domain. [404]") + statusFile.close() return 0, "This website already exists as child domain." ####### Limitations Check End + statusFile = open(tempStatusPath, 'w') + statusFile.writelines('Creating DNS records..,10') + statusFile.close() + ##### Zone creation admin = Administrator.objects.get(userName=websiteOwner) @@ -57,12 +70,20 @@ class virtualHostUtilities: ## zone creation + statusFile = open(tempStatusPath, 'w') + statusFile.writelines('Setting up directories..,25') + statusFile.close() + if vhost.checkIfVirtualHostExists(virtualHostName) == 1: - print "0, Virtual Host Directory already exists!" + statusFile = open(tempStatusPath, 'w') + statusFile.writelines("Virtual Host Directory already exists. [404]") + statusFile.close() return 0, "Virtual Host Directory already exists!" if vhost.checkIfAliasExists(virtualHostName) == 1: - print "0, This domain exists as Alias." + statusFile = open(tempStatusPath, 'w') + statusFile.writelines("This domain exists as Alias. [404]") + statusFile.close() return 0, "This domain exists as Alias." if dkimCheck == 1: @@ -78,10 +99,18 @@ class virtualHostUtilities: if retValues[0] == 0: raise BaseException(retValues[1]) + statusFile = open(tempStatusPath, 'w') + statusFile.writelines('Creating configurations..,50') + statusFile.close() + retValues = vhost.createConfigInMainVirtualHostFile(virtualHostName) if retValues[0] == 0: raise BaseException(retValues[1]) + statusFile = open(tempStatusPath, 'w') + statusFile.writelines('Setting up SSL..,70') + statusFile.close() + if ssl == 1: installUtilities.installUtilities.reStartLiteSpeed() retValues = sslUtilities.issueSSLForDomain(virtualHostName, administratorEmail, sslPath) @@ -97,6 +126,10 @@ class virtualHostUtilities: ## Create Configurations ends here + statusFile = open(tempStatusPath, 'w') + statusFile.writelines('DKIM Setup..,90') + statusFile.close() + ## DKIM Check if dkimCheck == 1: @@ -110,13 +143,17 @@ class virtualHostUtilities: website.save() - print "1,None" + statusFile = open(tempStatusPath, 'w') + statusFile.writelines("Website successfully created. [200]") + statusFile.close() return 1, 'None' except BaseException, msg: vhost.deleteVirtualHostConfigurations(virtualHostName, numberOfSites) logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [createVirtualHost]") - print "0," + str(msg) + statusFile = open(tempStatusPath, 'w') + statusFile.writelines(str(msg) + " [404]") + statusFile.close() return 0, str(msg) @staticmethod @@ -774,8 +811,11 @@ class virtualHostUtilities: print "0," + str(msg) @staticmethod - def createDomain(masterDomain, virtualHostName, phpVersion, path, ssl, dkimCheck, openBasedir, restore, owner=None): + def createDomain(masterDomain, virtualHostName, phpVersion, path, ssl, dkimCheck, openBasedir, restore, owner=None, tempStatusPath = '/home/cyberpanel/fakePath'): try: + statusFile = open(tempStatusPath, 'w') + statusFile.writelines('Running some checks..,0') + statusFile.close() ## Check if this domain either exists as website or child domain @@ -784,11 +824,15 @@ class virtualHostUtilities: DNS.dnsTemplate(virtualHostName, admin) if Websites.objects.filter(domain=virtualHostName).count() > 0: - print "0, This Domain already exists as a website." + statusFile = open(tempStatusPath, 'w') + statusFile.writelines("This Domain already exists as a website. [404]") + statusFile.close() return 0, "This Domain already exists as a website." if ChildDomains.objects.filter(domain=virtualHostName).count() > 0: - print "0, This domain already exists as child domain." + statusFile = open(tempStatusPath, 'w') + statusFile.writelines("This domain already exists as child domain. [404]") + statusFile.close() return 0, "This domain already exists as child domain." ####### Limitations check @@ -801,7 +845,9 @@ class virtualHostUtilities: elif domainsInPackage > master.childdomains_set.all().count(): pass else: - print "0, Exceeded maximum number of domains for this package" + statusFile = open(tempStatusPath, 'w') + statusFile.writelines("Exceeded maximum number of domains for this package. [404]") + statusFile.close() return 0, "Exceeded maximum number of domains for this package" @@ -809,13 +855,21 @@ class virtualHostUtilities: if vhost.checkIfVirtualHostExists(virtualHostName) == 1: - print "0, Virtual Host Directory already exists!" + statusFile = open(tempStatusPath, 'w') + statusFile.writelines("Virtual Host Directory already exists. [404]") + statusFile.close() return 0, "Virtual Host Directory already exists!" if vhost.checkIfAliasExists(virtualHostName) == 1: - print "0, This domain exists as Alias." + statusFile = open(tempStatusPath, 'w') + statusFile.writelines("This domain exists as Alias. [404]") + statusFile.close() return 0, "This domain exists as Alias." + statusFile = open(tempStatusPath, 'w') + statusFile.writelines('DKIM Setup..,30') + statusFile.close() + if dkimCheck == 1: if mailUtilities.checkIfDKIMInstalled() == 0: raise BaseException("OpenDKIM is not installed, install OpenDKIM from DKIM Manager.") @@ -826,6 +880,10 @@ class virtualHostUtilities: FNULL = open(os.devnull, 'w') + statusFile = open(tempStatusPath, 'w') + statusFile.writelines('Creating configurations..,50') + statusFile.close() + retValues = vhost.createDirectoryForDomain(masterDomain, virtualHostName, phpVersion, path, master.adminEmail, master.externalApp, openBasedir) if retValues[0] == 0: @@ -838,6 +896,10 @@ class virtualHostUtilities: ## Now restart litespeed after initial configurations are done + statusFile = open(tempStatusPath, 'w') + statusFile.writelines('Creating SSL..,50') + statusFile.close() + if ssl == 1: installUtilities.installUtilities.reStartLiteSpeed() @@ -862,7 +924,9 @@ class virtualHostUtilities: website.save() - print "1,None" + statusFile = open(tempStatusPath, 'w') + statusFile.writelines("Domain successfully created. [200]") + statusFile.close() return 1, "None" except BaseException, msg: @@ -870,7 +934,9 @@ class virtualHostUtilities: vhost.deleteCoreConf(virtualHostName, numberOfWebsites) logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [createDomain]") - print "0," + str(msg) + statusFile = open(tempStatusPath, 'w') + statusFile.writelines(str(msg) + ". [404]") + statusFile.close() return 0, str(msg) @staticmethod @@ -994,7 +1060,6 @@ def main(): ## Arguments for OpenBasedir parser.add_argument('--openBasedirValue', help='open_base dir protection value!') - parser.add_argument('--tempStatusPath', help='Temporary Status file path.') @@ -1012,7 +1077,12 @@ def main(): except: openBasedir = 0 - virtualHostUtilities.createVirtualHost(args.virtualHostName, args.administratorEmail, args.phpVersion, args.virtualHostUser, int(args.numberOfSites), int(args.ssl), args.sslPath, dkimCheck, openBasedir, args.websiteOwner, args.package) + try: + tempStatusPath = args.tempStatusPath + except: + tempStatusPath = '/home/cyberpanel/fakePath' + + virtualHostUtilities.createVirtualHost(args.virtualHostName, args.administratorEmail, args.phpVersion, args.virtualHostUser, int(args.numberOfSites), int(args.ssl), args.sslPath, dkimCheck, openBasedir, args.websiteOwner, args.package, tempStatusPath) elif args.function == "deleteVirtualHostConfigurations": vhost.deleteVirtualHostConfigurations(args.virtualHostName,int(args.numberOfSites)) elif args.function == "createDomain": @@ -1026,7 +1096,12 @@ def main(): except: openBasedir = 0 - virtualHostUtilities.createDomain(args.masterDomain, args.virtualHostName, args.phpVersion, args.path, int(args.ssl), dkimCheck, openBasedir, args.restore, args.websiteOwner) + try: + tempStatusPath = args.tempStatusPath + except: + tempStatusPath = '/home/cyberpanel/fakePath' + + virtualHostUtilities.createDomain(args.masterDomain, args.virtualHostName, args.phpVersion, args.path, int(args.ssl), dkimCheck, openBasedir, args.restore, args.websiteOwner, tempStatusPath) elif args.function == "issueSSL": virtualHostUtilities.issueSSL(args.virtualHostName,args.path,args.administratorEmail) elif args.function == "changePHP": diff --git a/static/websiteFunctions/websiteFunctions.js b/static/websiteFunctions/websiteFunctions.js index fb7887c3d..9f1f53619 100644 --- a/static/websiteFunctions/websiteFunctions.js +++ b/static/websiteFunctions/websiteFunctions.js @@ -2,41 +2,54 @@ * Created by usman on 7/26/17. */ - -$("#websiteCreationFailed").hide(); -$("#websiteCreated").hide(); -$("#webSiteCreation").hide(); - /* Java script code to create account */ -app.controller('createWebsite', function($scope,$http) { +app.controller('createWebsite', function($scope, $http, $timeout, $window) { + $scope.webSiteCreationLoading = true; + $scope.installationDetailsForm = false; + $scope.installationProgress = true; + $scope.errorMessageBox = true; + $scope.success = true; + $scope.couldNotConnect = true; + $scope.goBackDisable = true; + + var statusFile; $scope.createWebsite = function(){ + $scope.webSiteCreationLoading = false; + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.errorMessageBox = true; + $scope.success = true; + $scope.couldNotConnect = true; + $scope.goBackDisable = true; + + $scope.currentStatus = "Starting creation.."; + + var ssl, dkimCheck, openBasedir; + if ($scope.sslCheck === true){ - var ssl = 1; + ssl = 1; } else{ - var ssl = 0 + ssl = 0 } if ($scope.dkimCheck === true){ - var dkimCheck = 1; + dkimCheck = 1; } else{ - var dkimCheck = 0 + dkimCheck = 0 } if ($scope.openBasedir === true){ - var openBasedir = 1; + openBasedir = 1; } else{ - var openBasedir = 0 + openBasedir = 0 } - - $("#webSiteCreation").fadeIn(); - url = "/websites/submitWebsiteCreation"; var package = $scope.packageForWebsite; @@ -67,35 +80,38 @@ app.controller('createWebsite', function($scope,$http) { function ListInitialDatas(response) { - $("#webSiteCreation").fadeOut(); - if(response.data.existsStatus == 1){ - $scope.errorMessage = response.data.error_message; - $("#websiteCreationFailed").fadeIn(); - $("#websiteCreated").hide(); - - } - - else if (response.data.createWebSiteStatus == 0) + if (response.data.createWebSiteStatus === 1) { - $scope.errorMessage = response.data.error_message; - $("#websiteCreationFailed").fadeIn(); - $("#websiteCreated").hide(); - + statusFile = response.data.tempStatusPath; + getCreationStatus(); } else{ - $("#websiteCreationFailed").hide(); - $("#websiteCreated").fadeIn(); - $scope.websiteDomain = domainName; + $scope.webSiteCreationLoading = true; + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.errorMessageBox = false; + $scope.success = true; + $scope.couldNotConnect = true; + $scope.goBackDisable = false; + $scope.errorMessage = response.data.error_message; } + } function cantLoadInitialDatas(response) { - $("#webSiteCreation").fadeOut(); - console.log("not good"); + + $scope.webSiteCreationLoading = true; + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.errorMessageBox = true; + $scope.success = true; + $scope.couldNotConnect = false; + $scope.goBackDisable = false; + } @@ -103,6 +119,97 @@ app.controller('createWebsite', function($scope,$http) { }; + $scope.goBack = function () { + $scope.webSiteCreationLoading = true; + $scope.installationDetailsForm = false; + $scope.installationProgress = true; + $scope.errorMessageBox = true; + $scope.success = true; + $scope.couldNotConnect = true; + $scope.goBackDisable = true; + $("#installProgress").css("width", "0%"); + }; + function getCreationStatus(){ + + url = "/websites/installWordpressStatus"; + + var data = { + statusFile: statusFile + }; + + var config = { + headers : { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + + $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if(response.data.abort === 1){ + + if(response.data.installStatus === 1){ + + $scope.webSiteCreationLoading = true; + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.errorMessageBox = true; + $scope.success = false; + $scope.couldNotConnect = true; + $scope.goBackDisable = false; + + $("#installProgress").css("width", "100%"); + $scope.installPercentage = "100"; + $scope.currentStatus = response.data.currentStatus; + $timeout.cancel(); + + } + else{ + + $scope.webSiteCreationLoading = true; + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.errorMessageBox = false; + $scope.success = true; + $scope.couldNotConnect = true; + $scope.goBackDisable = false; + + $scope.errorMessage = response.data.error_message; + + $("#installProgress").css("width", "0%"); + $scope.installPercentage = "0"; + $scope.goBackDisable = false; + + } + + } + else{ + $("#installProgress").css("width", response.data.installationProgress + "%"); + $scope.installPercentage = response.data.installationProgress; + $scope.currentStatus = response.data.currentStatus; + $timeout(getCreationStatus,1000); + } + + } + function cantLoadInitialDatas(response) { + + $scope.webSiteCreationLoading = true; + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.errorMessageBox = true; + $scope.success = true; + $scope.couldNotConnect = false; + $scope.goBackDisable = false; + + } + + + } }); /* Java script code to create account ends here */ @@ -165,7 +272,7 @@ app.controller('listWebsites', function($scope,$http) { function ListInitialData(response) { - if (response.data.listWebSiteStatus==1) { + if (response.data.listWebSiteStatus ===1) { var finalData = JSON.parse(response.data.data); $scope.WebSitesList = finalData; @@ -309,7 +416,7 @@ app.controller('modifyWebsitesController', function($scope,$http) { function ListInitialDatas(response) { - if (response.data.modifyStatus == 0) + if (response.data.modifyStatus === 0) { console.log(response.data); $scope.errorMessage = response.data.error_message; @@ -377,7 +484,7 @@ app.controller('modifyWebsitesController', function($scope,$http) { packForWeb:packForWeb, email:email, phpVersion:phpVersion, - admin:admin, + admin:admin }; var config = { @@ -391,7 +498,7 @@ app.controller('modifyWebsitesController', function($scope,$http) { function ListInitialDatas(response) { - if (response.data.saveStatus == 0) + if (response.data.saveStatus === 0) { $scope.errMessage = response.data.error_message; @@ -437,7 +544,7 @@ app.controller('modifyWebsitesController', function($scope,$http) { /* Java script code to create account */ -app.controller('websitePages', function($scope,$http) { +app.controller('websitePages', function($scope, $http, $timeout, $window) { $scope.logFileLoading = true; $scope.logsFeteched = true; @@ -914,7 +1021,6 @@ app.controller('websitePages', function($scope,$http) { $scope.configurationsBoxRewrite = true; }; - $scope.fetchRewriteFules = function(){ $scope.hidsslconfigs = true; @@ -1144,8 +1250,6 @@ app.controller('websitePages', function($scope,$http) { }; - - //////// Application Installation part $scope.installationDetailsForm = true; @@ -1156,7 +1260,6 @@ app.controller('websitePages', function($scope,$http) { $scope.couldNotConnect = true; - $scope.installationDetails = function(){ $scope.installationDetailsForm = !$scope.installationDetailsForm; @@ -1171,7 +1274,6 @@ app.controller('websitePages', function($scope,$http) { }; - $scope.installWordpress = function(){ @@ -1341,9 +1443,6 @@ app.controller('websitePages', function($scope,$http) { }; - - - //////// SSL Part $scope.sslSaved = true; @@ -1363,9 +1462,6 @@ app.controller('websitePages', function($scope,$http) { $scope.changePHPView = true; }; - - - $scope.saveSSL = function(){ @@ -1434,7 +1530,6 @@ app.controller('websitePages', function($scope,$http) { }; - //// Change PHP Master $scope.failedToChangePHPMaster = true; @@ -1455,7 +1550,6 @@ app.controller('websitePages', function($scope,$http) { $scope.changePHPView = false; }; - $scope.changePHPVersionMaster = function(childDomain,phpSelection){ // notifcations @@ -1522,10 +1616,7 @@ app.controller('websitePages', function($scope,$http) { } - } - - - + }; ////// create domain part @@ -1543,37 +1634,47 @@ app.controller('websitePages', function($scope,$http) { // notifcations settings $scope.domainLoading = true; - $scope.websiteCreationFailed = true; - $scope.domainCreated = true; + $scope.installationDetailsForm = false; + $scope.installationProgress = true; + $scope.errorMessageBox = true; + $scope.success = true; $scope.couldNotConnect = true; + $scope.goBackDisable = true; + + var statusFile; $scope.createDomain = function(){ - // notifcations settings $scope.domainLoading = false; - $scope.websiteCreationFailed = true; - $scope.domainCreated = true; + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.errorMessageBox = true; + $scope.success = true; $scope.couldNotConnect = true; + $scope.goBackDisable = true; + $scope.currentStatus = "Starting creation.."; + + var ssl, dkimCheck, openBasedir; if ($scope.sslCheck === true){ - var ssl = 1; + ssl = 1; } else{ - var ssl = 0 + ssl = 0 } if ($scope.dkimCheck === true){ - var dkimCheck = 1; + dkimCheck = 1; } else{ - var dkimCheck = 0 + dkimCheck = 0 } if ($scope.openBasedir === true){ - var openBasedir = 1; + openBasedir = 1; } else{ - var openBasedir = 0 + openBasedir = 0 } @@ -1609,40 +1710,36 @@ app.controller('websitePages', function($scope,$http) { function ListInitialDatas(response) { - - if(response.data.createWebSiteStatus === 1){ - - $scope.websiteDomain = domainName; - - // notifcations settings - $scope.domainLoading = true; - $scope.websiteCreationFailed = true; - $scope.domainCreated = false; - $scope.couldNotConnect = true - - + if (response.data.createWebSiteStatus === 1) + { + statusFile = response.data.tempStatusPath; + getCreationStatus(); } else{ - $scope.errorMessage = response.data.error_message; - - // notifcations settings $scope.domainLoading = true; - $scope.websiteCreationFailed = false; - $scope.domainCreated = true; + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.errorMessageBox = false; + $scope.success = true; $scope.couldNotConnect = true; + $scope.goBackDisable = false; + $scope.errorMessage = response.data.error_message; } + } function cantLoadInitialDatas(response) { - // notifcations settings - $scope.domainLoading = true; - $scope.websiteCreationFailed = true; - $scope.domainCreated = true; - $scope.couldNotConnect = false; + $scope.domainLoading = true; + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.errorMessageBox = true; + $scope.success = true; + $scope.couldNotConnect = false; + $scope.goBackDisable = false; } @@ -1652,6 +1749,99 @@ app.controller('websitePages', function($scope,$http) { }; + $scope.goBack = function () { + $scope.domainLoading = true; + $scope.installationDetailsForm = false; + $scope.installationProgress = true; + $scope.errorMessageBox = true; + $scope.success = true; + $scope.couldNotConnect = true; + $scope.goBackDisable = true; + $("#installProgress").css("width", "0%"); + }; + + function getCreationStatus(){ + + url = "/websites/installWordpressStatus"; + + var data = { + statusFile: statusFile + }; + + var config = { + headers : { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + + $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if(response.data.abort === 1){ + + if(response.data.installStatus === 1){ + + $scope.domainLoading = true; + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.errorMessageBox = true; + $scope.success = false; + $scope.couldNotConnect = true; + $scope.goBackDisable = false; + + $("#installProgress").css("width", "100%"); + $scope.installPercentage = "100"; + $scope.currentStatus = response.data.currentStatus; + $timeout.cancel(); + + } + else{ + + $scope.domainLoading = true; + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.errorMessageBox = false; + $scope.success = true; + $scope.couldNotConnect = true; + $scope.goBackDisable = false; + + $scope.errorMessage = response.data.error_message; + + $("#installProgress").css("width", "0%"); + $scope.installPercentage = "0"; + $scope.goBackDisable = false; + + } + + } + else{ + $("#installProgress").css("width", response.data.installationProgress + "%"); + $scope.installPercentage = response.data.installationProgress; + $scope.currentStatus = response.data.currentStatus; + $timeout(getCreationStatus,1000); + } + + } + function cantLoadInitialDatas(response) { + + $scope.domainLoading = true; + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.errorMessageBox = true; + $scope.success = true; + $scope.couldNotConnect = false; + $scope.goBackDisable = false; + + } + + + } + ////// List Domains Part @@ -2141,13 +2331,8 @@ app.controller('websitePages', function($scope,$http) { /* Java script code to create account ends here */ - - /* Java script code to suspend/un-suspend Website */ - - - app.controller('suspendWebsiteControl', function($scope,$http) { $scope.suspendLoading = true; @@ -2272,12 +2457,8 @@ app.controller('suspendWebsiteControl', function($scope,$http) { }); - - /* Java script code to suspend/un-suspend ends here */ - - /* Java script code to manage cron */ app.controller('manageCronController', function($scope,$http) { @@ -2606,10 +2787,8 @@ app.controller('manageCronController', function($scope,$http) { }); - /* Java script code to manage cron ends here */ - /* Java script code to manage cron */ app.controller('manageAliasController', function($scope,$http, $timeout, $window) { @@ -2868,7 +3047,6 @@ app.controller('manageAliasController', function($scope,$http, $timeout, $window }); - /* Java script code to manage cron ends here */ app.controller('launchChild', function($scope,$http) { @@ -3840,11 +4018,8 @@ app.controller('launchChild', function($scope,$http) { }); - - /* Application Installer */ - app.controller('installWordPressCTRL', function($scope, $http, $timeout) { $scope.installationDetailsForm = false; @@ -4038,7 +4213,6 @@ app.controller('installWordPressCTRL', function($scope, $http, $timeout) { }); - app.controller('installJoomlaCTRL', function($scope, $http, $timeout) { $scope.installationDetailsForm = false; @@ -4234,7 +4408,6 @@ app.controller('installJoomlaCTRL', function($scope, $http, $timeout) { }); - app.controller('setupGit', function($scope, $http, $timeout, $window) { $scope.installationDetailsForm = false; diff --git a/websiteFunctions/static/websiteFunctions/websiteFunctions.js b/websiteFunctions/static/websiteFunctions/websiteFunctions.js index fb7887c3d..9f1f53619 100644 --- a/websiteFunctions/static/websiteFunctions/websiteFunctions.js +++ b/websiteFunctions/static/websiteFunctions/websiteFunctions.js @@ -2,41 +2,54 @@ * Created by usman on 7/26/17. */ - -$("#websiteCreationFailed").hide(); -$("#websiteCreated").hide(); -$("#webSiteCreation").hide(); - /* Java script code to create account */ -app.controller('createWebsite', function($scope,$http) { +app.controller('createWebsite', function($scope, $http, $timeout, $window) { + $scope.webSiteCreationLoading = true; + $scope.installationDetailsForm = false; + $scope.installationProgress = true; + $scope.errorMessageBox = true; + $scope.success = true; + $scope.couldNotConnect = true; + $scope.goBackDisable = true; + + var statusFile; $scope.createWebsite = function(){ + $scope.webSiteCreationLoading = false; + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.errorMessageBox = true; + $scope.success = true; + $scope.couldNotConnect = true; + $scope.goBackDisable = true; + + $scope.currentStatus = "Starting creation.."; + + var ssl, dkimCheck, openBasedir; + if ($scope.sslCheck === true){ - var ssl = 1; + ssl = 1; } else{ - var ssl = 0 + ssl = 0 } if ($scope.dkimCheck === true){ - var dkimCheck = 1; + dkimCheck = 1; } else{ - var dkimCheck = 0 + dkimCheck = 0 } if ($scope.openBasedir === true){ - var openBasedir = 1; + openBasedir = 1; } else{ - var openBasedir = 0 + openBasedir = 0 } - - $("#webSiteCreation").fadeIn(); - url = "/websites/submitWebsiteCreation"; var package = $scope.packageForWebsite; @@ -67,35 +80,38 @@ app.controller('createWebsite', function($scope,$http) { function ListInitialDatas(response) { - $("#webSiteCreation").fadeOut(); - if(response.data.existsStatus == 1){ - $scope.errorMessage = response.data.error_message; - $("#websiteCreationFailed").fadeIn(); - $("#websiteCreated").hide(); - - } - - else if (response.data.createWebSiteStatus == 0) + if (response.data.createWebSiteStatus === 1) { - $scope.errorMessage = response.data.error_message; - $("#websiteCreationFailed").fadeIn(); - $("#websiteCreated").hide(); - + statusFile = response.data.tempStatusPath; + getCreationStatus(); } else{ - $("#websiteCreationFailed").hide(); - $("#websiteCreated").fadeIn(); - $scope.websiteDomain = domainName; + $scope.webSiteCreationLoading = true; + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.errorMessageBox = false; + $scope.success = true; + $scope.couldNotConnect = true; + $scope.goBackDisable = false; + $scope.errorMessage = response.data.error_message; } + } function cantLoadInitialDatas(response) { - $("#webSiteCreation").fadeOut(); - console.log("not good"); + + $scope.webSiteCreationLoading = true; + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.errorMessageBox = true; + $scope.success = true; + $scope.couldNotConnect = false; + $scope.goBackDisable = false; + } @@ -103,6 +119,97 @@ app.controller('createWebsite', function($scope,$http) { }; + $scope.goBack = function () { + $scope.webSiteCreationLoading = true; + $scope.installationDetailsForm = false; + $scope.installationProgress = true; + $scope.errorMessageBox = true; + $scope.success = true; + $scope.couldNotConnect = true; + $scope.goBackDisable = true; + $("#installProgress").css("width", "0%"); + }; + function getCreationStatus(){ + + url = "/websites/installWordpressStatus"; + + var data = { + statusFile: statusFile + }; + + var config = { + headers : { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + + $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if(response.data.abort === 1){ + + if(response.data.installStatus === 1){ + + $scope.webSiteCreationLoading = true; + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.errorMessageBox = true; + $scope.success = false; + $scope.couldNotConnect = true; + $scope.goBackDisable = false; + + $("#installProgress").css("width", "100%"); + $scope.installPercentage = "100"; + $scope.currentStatus = response.data.currentStatus; + $timeout.cancel(); + + } + else{ + + $scope.webSiteCreationLoading = true; + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.errorMessageBox = false; + $scope.success = true; + $scope.couldNotConnect = true; + $scope.goBackDisable = false; + + $scope.errorMessage = response.data.error_message; + + $("#installProgress").css("width", "0%"); + $scope.installPercentage = "0"; + $scope.goBackDisable = false; + + } + + } + else{ + $("#installProgress").css("width", response.data.installationProgress + "%"); + $scope.installPercentage = response.data.installationProgress; + $scope.currentStatus = response.data.currentStatus; + $timeout(getCreationStatus,1000); + } + + } + function cantLoadInitialDatas(response) { + + $scope.webSiteCreationLoading = true; + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.errorMessageBox = true; + $scope.success = true; + $scope.couldNotConnect = false; + $scope.goBackDisable = false; + + } + + + } }); /* Java script code to create account ends here */ @@ -165,7 +272,7 @@ app.controller('listWebsites', function($scope,$http) { function ListInitialData(response) { - if (response.data.listWebSiteStatus==1) { + if (response.data.listWebSiteStatus ===1) { var finalData = JSON.parse(response.data.data); $scope.WebSitesList = finalData; @@ -309,7 +416,7 @@ app.controller('modifyWebsitesController', function($scope,$http) { function ListInitialDatas(response) { - if (response.data.modifyStatus == 0) + if (response.data.modifyStatus === 0) { console.log(response.data); $scope.errorMessage = response.data.error_message; @@ -377,7 +484,7 @@ app.controller('modifyWebsitesController', function($scope,$http) { packForWeb:packForWeb, email:email, phpVersion:phpVersion, - admin:admin, + admin:admin }; var config = { @@ -391,7 +498,7 @@ app.controller('modifyWebsitesController', function($scope,$http) { function ListInitialDatas(response) { - if (response.data.saveStatus == 0) + if (response.data.saveStatus === 0) { $scope.errMessage = response.data.error_message; @@ -437,7 +544,7 @@ app.controller('modifyWebsitesController', function($scope,$http) { /* Java script code to create account */ -app.controller('websitePages', function($scope,$http) { +app.controller('websitePages', function($scope, $http, $timeout, $window) { $scope.logFileLoading = true; $scope.logsFeteched = true; @@ -914,7 +1021,6 @@ app.controller('websitePages', function($scope,$http) { $scope.configurationsBoxRewrite = true; }; - $scope.fetchRewriteFules = function(){ $scope.hidsslconfigs = true; @@ -1144,8 +1250,6 @@ app.controller('websitePages', function($scope,$http) { }; - - //////// Application Installation part $scope.installationDetailsForm = true; @@ -1156,7 +1260,6 @@ app.controller('websitePages', function($scope,$http) { $scope.couldNotConnect = true; - $scope.installationDetails = function(){ $scope.installationDetailsForm = !$scope.installationDetailsForm; @@ -1171,7 +1274,6 @@ app.controller('websitePages', function($scope,$http) { }; - $scope.installWordpress = function(){ @@ -1341,9 +1443,6 @@ app.controller('websitePages', function($scope,$http) { }; - - - //////// SSL Part $scope.sslSaved = true; @@ -1363,9 +1462,6 @@ app.controller('websitePages', function($scope,$http) { $scope.changePHPView = true; }; - - - $scope.saveSSL = function(){ @@ -1434,7 +1530,6 @@ app.controller('websitePages', function($scope,$http) { }; - //// Change PHP Master $scope.failedToChangePHPMaster = true; @@ -1455,7 +1550,6 @@ app.controller('websitePages', function($scope,$http) { $scope.changePHPView = false; }; - $scope.changePHPVersionMaster = function(childDomain,phpSelection){ // notifcations @@ -1522,10 +1616,7 @@ app.controller('websitePages', function($scope,$http) { } - } - - - + }; ////// create domain part @@ -1543,37 +1634,47 @@ app.controller('websitePages', function($scope,$http) { // notifcations settings $scope.domainLoading = true; - $scope.websiteCreationFailed = true; - $scope.domainCreated = true; + $scope.installationDetailsForm = false; + $scope.installationProgress = true; + $scope.errorMessageBox = true; + $scope.success = true; $scope.couldNotConnect = true; + $scope.goBackDisable = true; + + var statusFile; $scope.createDomain = function(){ - // notifcations settings $scope.domainLoading = false; - $scope.websiteCreationFailed = true; - $scope.domainCreated = true; + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.errorMessageBox = true; + $scope.success = true; $scope.couldNotConnect = true; + $scope.goBackDisable = true; + $scope.currentStatus = "Starting creation.."; + + var ssl, dkimCheck, openBasedir; if ($scope.sslCheck === true){ - var ssl = 1; + ssl = 1; } else{ - var ssl = 0 + ssl = 0 } if ($scope.dkimCheck === true){ - var dkimCheck = 1; + dkimCheck = 1; } else{ - var dkimCheck = 0 + dkimCheck = 0 } if ($scope.openBasedir === true){ - var openBasedir = 1; + openBasedir = 1; } else{ - var openBasedir = 0 + openBasedir = 0 } @@ -1609,40 +1710,36 @@ app.controller('websitePages', function($scope,$http) { function ListInitialDatas(response) { - - if(response.data.createWebSiteStatus === 1){ - - $scope.websiteDomain = domainName; - - // notifcations settings - $scope.domainLoading = true; - $scope.websiteCreationFailed = true; - $scope.domainCreated = false; - $scope.couldNotConnect = true - - + if (response.data.createWebSiteStatus === 1) + { + statusFile = response.data.tempStatusPath; + getCreationStatus(); } else{ - $scope.errorMessage = response.data.error_message; - - // notifcations settings $scope.domainLoading = true; - $scope.websiteCreationFailed = false; - $scope.domainCreated = true; + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.errorMessageBox = false; + $scope.success = true; $scope.couldNotConnect = true; + $scope.goBackDisable = false; + $scope.errorMessage = response.data.error_message; } + } function cantLoadInitialDatas(response) { - // notifcations settings - $scope.domainLoading = true; - $scope.websiteCreationFailed = true; - $scope.domainCreated = true; - $scope.couldNotConnect = false; + $scope.domainLoading = true; + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.errorMessageBox = true; + $scope.success = true; + $scope.couldNotConnect = false; + $scope.goBackDisable = false; } @@ -1652,6 +1749,99 @@ app.controller('websitePages', function($scope,$http) { }; + $scope.goBack = function () { + $scope.domainLoading = true; + $scope.installationDetailsForm = false; + $scope.installationProgress = true; + $scope.errorMessageBox = true; + $scope.success = true; + $scope.couldNotConnect = true; + $scope.goBackDisable = true; + $("#installProgress").css("width", "0%"); + }; + + function getCreationStatus(){ + + url = "/websites/installWordpressStatus"; + + var data = { + statusFile: statusFile + }; + + var config = { + headers : { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + + $http.post(url, data,config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if(response.data.abort === 1){ + + if(response.data.installStatus === 1){ + + $scope.domainLoading = true; + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.errorMessageBox = true; + $scope.success = false; + $scope.couldNotConnect = true; + $scope.goBackDisable = false; + + $("#installProgress").css("width", "100%"); + $scope.installPercentage = "100"; + $scope.currentStatus = response.data.currentStatus; + $timeout.cancel(); + + } + else{ + + $scope.domainLoading = true; + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.errorMessageBox = false; + $scope.success = true; + $scope.couldNotConnect = true; + $scope.goBackDisable = false; + + $scope.errorMessage = response.data.error_message; + + $("#installProgress").css("width", "0%"); + $scope.installPercentage = "0"; + $scope.goBackDisable = false; + + } + + } + else{ + $("#installProgress").css("width", response.data.installationProgress + "%"); + $scope.installPercentage = response.data.installationProgress; + $scope.currentStatus = response.data.currentStatus; + $timeout(getCreationStatus,1000); + } + + } + function cantLoadInitialDatas(response) { + + $scope.domainLoading = true; + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.errorMessageBox = true; + $scope.success = true; + $scope.couldNotConnect = false; + $scope.goBackDisable = false; + + } + + + } + ////// List Domains Part @@ -2141,13 +2331,8 @@ app.controller('websitePages', function($scope,$http) { /* Java script code to create account ends here */ - - /* Java script code to suspend/un-suspend Website */ - - - app.controller('suspendWebsiteControl', function($scope,$http) { $scope.suspendLoading = true; @@ -2272,12 +2457,8 @@ app.controller('suspendWebsiteControl', function($scope,$http) { }); - - /* Java script code to suspend/un-suspend ends here */ - - /* Java script code to manage cron */ app.controller('manageCronController', function($scope,$http) { @@ -2606,10 +2787,8 @@ app.controller('manageCronController', function($scope,$http) { }); - /* Java script code to manage cron ends here */ - /* Java script code to manage cron */ app.controller('manageAliasController', function($scope,$http, $timeout, $window) { @@ -2868,7 +3047,6 @@ app.controller('manageAliasController', function($scope,$http, $timeout, $window }); - /* Java script code to manage cron ends here */ app.controller('launchChild', function($scope,$http) { @@ -3840,11 +4018,8 @@ app.controller('launchChild', function($scope,$http) { }); - - /* Application Installer */ - app.controller('installWordPressCTRL', function($scope, $http, $timeout) { $scope.installationDetailsForm = false; @@ -4038,7 +4213,6 @@ app.controller('installWordPressCTRL', function($scope, $http, $timeout) { }); - app.controller('installJoomlaCTRL', function($scope, $http, $timeout) { $scope.installationDetailsForm = false; @@ -4234,7 +4408,6 @@ app.controller('installJoomlaCTRL', function($scope, $http, $timeout) { }); - app.controller('setupGit', function($scope, $http, $timeout, $window) { $scope.installationDetailsForm = false; diff --git a/websiteFunctions/templates/websiteFunctions/createWebsite.html b/websiteFunctions/templates/websiteFunctions/createWebsite.html index 517c7ed77..c347656a4 100644 --- a/websiteFunctions/templates/websiteFunctions/createWebsite.html +++ b/websiteFunctions/templates/websiteFunctions/createWebsite.html @@ -14,18 +14,18 @@ -
+

- {% trans "Website Details" %} + {% trans "Website Details" %}

-
+
-
+
@@ -48,7 +48,7 @@
-
+
@@ -56,7 +56,7 @@
{% trans "Invalid Domain (Note: You don't need to add 'http' or 'https')" %}
-
+
@@ -64,7 +64,7 @@
{% trans "Invalid Email" %}
-
+
+
-
{% trans "Invalid Domain (Note: You don't need to add 'http' or 'https')" %}
-
+
@@ -328,7 +326,7 @@
-
+