From ab33c5aa31d60713c6d8d1b5867fe6f7e3478afd Mon Sep 17 00:00:00 2001 From: Usman Nasir Date: Mon, 16 Mar 2020 19:14:39 +0500 Subject: [PATCH] add git configurations --- plogical/acl.py | 10 ++ plogical/test.py | 9 -- static/websiteFunctions/websiteFunctions.js | 56 ++++++++ .../websiteFunctions/websiteFunctions.js | 56 ++++++++ .../templates/websiteFunctions/manageGIT.html | 121 +++++++++++++++--- websiteFunctions/urls.py | 1 + websiteFunctions/views.py | 8 ++ websiteFunctions/website.py | 80 +++++++++++- 8 files changed, 313 insertions(+), 28 deletions(-) diff --git a/plogical/acl.py b/plogical/acl.py index b1dce0148..f9e23d08a 100755 --- a/plogical/acl.py +++ b/plogical/acl.py @@ -16,6 +16,16 @@ from dockerManager.models import Containers from re import M, I, compile class ACLManager: + @staticmethod + def fetchIP(): + try: + ipFile = "/etc/cyberpanel/machineIP" + f = open(ipFile) + ipData = f.read() + return ipData.split('\n', 1)[0] + except BaseException: + return "192.168.100.1" + @staticmethod def validateInput(value, regex = None): if regex == None: diff --git a/plogical/test.py b/plogical/test.py index 2ad1745e2..e69de29bb 100755 --- a/plogical/test.py +++ b/plogical/test.py @@ -1,9 +0,0 @@ -import re - - -verifer = re.compile(r'[a-zA-Z0-9_-]+') - -if verifer.match('Helloworld'): - print ('hello world') -else: - print('not hello world') \ No newline at end of file diff --git a/static/websiteFunctions/websiteFunctions.js b/static/websiteFunctions/websiteFunctions.js index f164d3deb..9e32255e0 100644 --- a/static/websiteFunctions/websiteFunctions.js +++ b/static/websiteFunctions/websiteFunctions.js @@ -5832,6 +5832,10 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) { $scope.remoteResult = response.data.remoteResult; $scope.totalCommits = response.data.totalCommits; $scope.home = response.data.home; + $scope.webHookURL = response.data.webHookURL; + $scope.autoCommitCurrent = response.data.autoCommitCurrent; + $scope.autoPushCurrent = response.data.autoPushCurrent; + $scope.emailLogsCurrent = response.data.emailLogsCurrent; } else { $scope.gitTracking = false; $scope.gitEnable = true; @@ -6658,5 +6662,57 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) { } }; + $scope.saveGitConfigurations = function () { + + $scope.cyberpanelLoading = false; + + url = "/websites/saveGitConfigurations"; + + + var data = { + domain: $("#domain").text(), + folder: $scope.folder, + autoCommit: $scope.autoCommit, + autoPush: $scope.autoPush, + emailLogs: $scope.emailLogs, + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + function ListInitialDatas(response) { + $scope.cyberpanelLoading = true; + if (response.data.status === 1) { + new PNotify({ + title: 'Success', + text: 'Successfully saved.', + type: 'success' + }); + } 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' + }); + + + } + }; + }); /* Java script code to git tracking ends here */ diff --git a/websiteFunctions/static/websiteFunctions/websiteFunctions.js b/websiteFunctions/static/websiteFunctions/websiteFunctions.js index f164d3deb..9e32255e0 100755 --- a/websiteFunctions/static/websiteFunctions/websiteFunctions.js +++ b/websiteFunctions/static/websiteFunctions/websiteFunctions.js @@ -5832,6 +5832,10 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) { $scope.remoteResult = response.data.remoteResult; $scope.totalCommits = response.data.totalCommits; $scope.home = response.data.home; + $scope.webHookURL = response.data.webHookURL; + $scope.autoCommitCurrent = response.data.autoCommitCurrent; + $scope.autoPushCurrent = response.data.autoPushCurrent; + $scope.emailLogsCurrent = response.data.emailLogsCurrent; } else { $scope.gitTracking = false; $scope.gitEnable = true; @@ -6658,5 +6662,57 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) { } }; + $scope.saveGitConfigurations = function () { + + $scope.cyberpanelLoading = false; + + url = "/websites/saveGitConfigurations"; + + + var data = { + domain: $("#domain").text(), + folder: $scope.folder, + autoCommit: $scope.autoCommit, + autoPush: $scope.autoPush, + emailLogs: $scope.emailLogs, + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + function ListInitialDatas(response) { + $scope.cyberpanelLoading = true; + if (response.data.status === 1) { + new PNotify({ + title: 'Success', + text: 'Successfully saved.', + type: 'success' + }); + } 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' + }); + + + } + }; + }); /* Java script code to git tracking ends here */ diff --git a/websiteFunctions/templates/websiteFunctions/manageGIT.html b/websiteFunctions/templates/websiteFunctions/manageGIT.html index f4af8690b..6d2aa937a 100755 --- a/websiteFunctions/templates/websiteFunctions/manageGIT.html +++ b/websiteFunctions/templates/websiteFunctions/manageGIT.html @@ -158,6 +158,89 @@ Attach Existing Repo + + + Configure + + + +