From a4b6cbf40f5586dee24c7a7b841ec834cd93af28 Mon Sep 17 00:00:00 2001 From: usmannasir Date: Thu, 25 Jan 2024 10:44:06 +0500 Subject: [PATCH] complete the onboarding function --- .../baseTemplate/custom-js/system-status.js | 156 +++++++++++++++++- .../templates/baseTemplate/index.html | 46 +++--- .../templates/baseTemplate/onboarding.html | 115 +++++++++++++ baseTemplate/urls.py | 3 + baseTemplate/views.py | 95 +++++++++-- .../templates/manageSSL/sslForHostName.html | 111 +++++++------ .../templates/manageSSL/sslForMailServer.html | 113 +++++++------ plogical/IncScheduler.py | 20 +++ plogical/httpProc.py | 20 +++ plogical/virtualHostUtilities.py | 76 +++++++-- 10 files changed, 606 insertions(+), 149 deletions(-) create mode 100755 baseTemplate/templates/baseTemplate/onboarding.html diff --git a/baseTemplate/static/baseTemplate/custom-js/system-status.js b/baseTemplate/static/baseTemplate/custom-js/system-status.js index 9fe052f0a..5fdf3370d 100644 --- a/baseTemplate/static/baseTemplate/custom-js/system-status.js +++ b/baseTemplate/static/baseTemplate/custom-js/system-status.js @@ -5,7 +5,6 @@ /* Utilities */ - function getCookie(name) { var cookieValue = null; if (document.cookie && document.cookie !== '') { @@ -576,8 +575,6 @@ app.controller('versionManagment', function ($scope, $http, $timeout) { }; - - url = "/base/upgrade"; $http.post(url, data, config).then(ListInitialData, cantLoadInitialData); @@ -717,3 +714,156 @@ app.controller('designtheme', function ($scope, $http, $timeout) { }); +app.controller('OnboardingCP', function ($scope, $http, $timeout, $window) { + + $scope.cyberpanelLoading = true; + $scope.ExecutionStatus = true; + $scope.ReportStatus = true; + $scope.OnboardineDone = true; + + + function statusFunc() { + $scope.cyberpanelLoading = false; + $scope.ExecutionStatus = false; + var url = "/emailPremium/statusFunc"; + + var data = { + statusFile: statusFile + }; + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialData, cantLoadInitialData); + + + function ListInitialData(response) { + if (response.data.status === 1) { + if (response.data.abort === 1) { + $scope.functionProgress = {"width": "100%"}; + $scope.functionStatus = response.data.currentStatus; + $scope.cyberpanelLoading = true; + $scope.OnboardineDone = false; + $timeout.cancel(); + } else { + $scope.functionProgress = {"width": response.data.installationProgress + "%"}; + $scope.functionStatus = response.data.currentStatus; + $timeout(statusFunc, 3000); + } + + } else { + $scope.cyberpanelLoading = true; + $scope.functionStatus = response.data.error_message; + $scope.functionProgress = {"width": response.data.installationProgress + "%"}; + $timeout.cancel(); + } + + } + + function cantLoadInitialData(response) { + $scope.functionProgress = {"width": response.data.installationProgress + "%"}; + $scope.functionStatus = 'Could not connect to server, please refresh this page.'; + $timeout.cancel(); + } + } + + $scope.RunOnboarding = function () { + $scope.cyberpanelLoading = false; + $scope.OnboardineDone = true; + + var url = "/base/runonboarding"; + + var data = { + hostname: $scope.hostname, + rDNSCheck: $scope.rDNSCheck + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialData, cantLoadInitialData); + + function ListInitialData(response) { + $scope.cyberpanelLoading = true; + if (response.data.status === 1) { + statusFile = response.data.tempStatusPath; + statusFunc(); + + + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + + } + + function cantLoadInitialData(response) { + $scope.cyberpanelLoading = true; + + new PNotify({ + title: 'Error', + text: 'Could not connect to server, please refresh this page.', + type: 'error' + }); + } + }; + + $scope.RestartCyberPanel = function () { + $scope.cyberpanelLoading = false; + + var url = "/base/RestartCyberPanel"; + + var data = { + + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialData, cantLoadInitialData); + $scope.cyberpanelLoading = true; + new PNotify({ + title: 'Success', + text: 'Refresh your browser after 3 seconds to fetch new SSL.', + type: 'success' + }); + + function ListInitialData(response) { + $scope.cyberpanelLoading = true; + if (response.data.status === 1) { + + } else { + new PNotify({ + title: 'Operation Failed!', + text: response.data.error_message, + type: 'error' + }); + } + + } + + function cantLoadInitialData(response) { + $scope.cyberpanelLoading = true; + + new PNotify({ + title: 'Error', + text: 'Could not connect to server, please refresh this page.', + type: 'error' + }); + } + }; + +}); \ No newline at end of file diff --git a/baseTemplate/templates/baseTemplate/index.html b/baseTemplate/templates/baseTemplate/index.html index 03d9aa5dc..90c47ab92 100755 --- a/baseTemplate/templates/baseTemplate/index.html +++ b/baseTemplate/templates/baseTemplate/index.html @@ -849,22 +849,22 @@ -{# #} + {# #}