diff --git a/baseTemplate/templates/baseTemplate/index.html b/baseTemplate/templates/baseTemplate/index.html index 0ff264bfb..ec13d76d9 100755 --- a/baseTemplate/templates/baseTemplate/index.html +++ b/baseTemplate/templates/baseTemplate/index.html @@ -89,9 +89,8 @@ href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css"> - - + {% block styles %} {% endblock %} diff --git a/plogical/virtualHostUtilities.py b/plogical/virtualHostUtilities.py index cd875c093..56bea68be 100644 --- a/plogical/virtualHostUtilities.py +++ b/plogical/virtualHostUtilities.py @@ -1222,12 +1222,17 @@ class virtualHostUtilities: return 0, str(msg) @staticmethod - def deleteDomain(virtualHostName): + def deleteDomain(virtualHostName, DeleteDocRoot=0): try: numberOfWebsites = Websites.objects.count() + ChildDomains.objects.count() vhost.deleteCoreConf(virtualHostName, numberOfWebsites) delWebsite = ChildDomains.objects.get(domain=virtualHostName) + + if DeleteDocRoot: + command = 'rm -rf %s' % (delWebsite.path) + ProcessUtilities.executioner(command) + delWebsite.delete() installUtilities.installUtilities.reStartLiteSpeed() @@ -1432,6 +1437,10 @@ def main(): parser.add_argument('--server', help='Switch server parameter.') + ## Doc root deletion for child domain + + parser.add_argument('--DeleteDocRoot', help='Doc root deletion for child domain.') + args = parser.parse_args() if args.function == "createVirtualHost": @@ -1524,7 +1533,7 @@ def main(): elif args.function == 'changeOpenBasedir': virtualHostUtilities.changeOpenBasedir(args.virtualHostName, args.openBasedirValue) elif args.function == 'deleteDomain': - virtualHostUtilities.deleteDomain(args.virtualHostName) + virtualHostUtilities.deleteDomain(args.virtualHostName, int(args.DeleteDocRoot)) elif args.function == 'switchServer': virtualHostUtilities.switchServer(args.virtualHostName, args.phpVersion, int(args.server), args.tempStatusPath) diff --git a/static/websiteFunctions/websiteFunctions.js b/static/websiteFunctions/websiteFunctions.js index ca0fed440..c8d19ef3b 100644 --- a/static/websiteFunctions/websiteFunctions.js +++ b/static/websiteFunctions/websiteFunctions.js @@ -20,6 +20,7 @@ function getCookie(name) { return cookieValue; } + /* Java script code to create account */ app.controller('createWebsite', function ($scope, $http, $timeout, $window) { @@ -388,7 +389,6 @@ app.controller('listWebsites', function ($scope, $http) { app.controller('listChildDomainsMain', function ($scope, $http, $timeout) { - $scope.currentPage = 1; $scope.recordsToShow = 10; @@ -700,7 +700,59 @@ app.controller('listChildDomainsMain', function ($scope, $http, $timeout) { } + var DeleteDomain; + $scope.deleteDomainInit = function (childDomainForDeletion){ + DeleteDomain = childDomainForDeletion; + }; + $scope.deleteChildDomain = function () { + $scope.cyberPanelLoading = false; + url = "/websites/submitDomainDeletion"; + + var data = { + websiteName: DeleteDomain, + DeleteDocRoot: $scope.DeleteDocRoot + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + function ListInitialDatas(response) { + $scope.cyberPanelLoading = true; + if (response.data.websiteDeleteStatus === 1) { + new PNotify({ + title: 'Success!', + text: 'Child Domain successfully deleted.', + type: 'success' + }); + $scope.getFurtherWebsitesFromDB(); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + + + } + + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + + } + + }; }); diff --git a/websiteFunctions/static/websiteFunctions/websiteFunctions.js b/websiteFunctions/static/websiteFunctions/websiteFunctions.js index ca0fed440..c8d19ef3b 100755 --- a/websiteFunctions/static/websiteFunctions/websiteFunctions.js +++ b/websiteFunctions/static/websiteFunctions/websiteFunctions.js @@ -20,6 +20,7 @@ function getCookie(name) { return cookieValue; } + /* Java script code to create account */ app.controller('createWebsite', function ($scope, $http, $timeout, $window) { @@ -388,7 +389,6 @@ app.controller('listWebsites', function ($scope, $http) { app.controller('listChildDomainsMain', function ($scope, $http, $timeout) { - $scope.currentPage = 1; $scope.recordsToShow = 10; @@ -700,7 +700,59 @@ app.controller('listChildDomainsMain', function ($scope, $http, $timeout) { } + var DeleteDomain; + $scope.deleteDomainInit = function (childDomainForDeletion){ + DeleteDomain = childDomainForDeletion; + }; + $scope.deleteChildDomain = function () { + $scope.cyberPanelLoading = false; + url = "/websites/submitDomainDeletion"; + + var data = { + websiteName: DeleteDomain, + DeleteDocRoot: $scope.DeleteDocRoot + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + function ListInitialDatas(response) { + $scope.cyberPanelLoading = true; + if (response.data.websiteDeleteStatus === 1) { + new PNotify({ + title: 'Success!', + text: 'Child Domain successfully deleted.', + type: 'success' + }); + $scope.getFurtherWebsitesFromDB(); + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + + + } + + function cantLoadInitialDatas(response) { + $scope.cyberPanelLoading = true; + new PNotify({ + title: 'Operation Failed!', + text: 'Could not connect to server, please refresh this page', + type: 'error' + }); + + } + + }; }); diff --git a/websiteFunctions/templates/websiteFunctions/listChildDomains.html b/websiteFunctions/templates/websiteFunctions/listChildDomains.html index 518a976e6..90fd1f462 100755 --- a/websiteFunctions/templates/websiteFunctions/listChildDomains.html +++ b/websiteFunctions/templates/websiteFunctions/listChildDomains.html @@ -57,7 +57,7 @@ -- - {$ web.path $} + File Manager
- - + + Delete +
×
diff --git a/websiteFunctions/website.py b/websiteFunctions/website.py index 527c6e2b7..a0b13fd84 100755 --- a/websiteFunctions/website.py +++ b/websiteFunctions/website.py @@ -535,13 +535,18 @@ class WebsiteManager: admin = Administrator.objects.get(pk=userID) websiteName = data['websiteName'] + try: + DeleteDocRoot = int(data['DeleteDocRoot']) + except: + DeleteDocRoot = 0 + if ACLManager.checkOwnership(websiteName, admin, currentACL) == 1: pass else: return ACLManager.loadErrorJson('websiteDeleteStatus', 0) execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" - execPath = execPath + " deleteDomain --virtualHostName " + websiteName + execPath = execPath + " deleteDomain --virtualHostName " + websiteName + ' --DeleteDocRoot %s' % (str(DeleteDocRoot)) ProcessUtilities.outputExecutioner(execPath) data_ret = {'status': 1, 'websiteDeleteStatus': 1, 'error_message': "None"}