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
+
+
+
+
@@ -319,7 +402,7 @@
- Commit Changes
+ Commit
@@ -373,11 +456,11 @@
- Pull From Remote
+ Pull
- Push To Remote
+ Push
@@ -433,7 +516,7 @@
- Remove Git
+ Remove
@@ -667,7 +750,8 @@
-
-
-
-
-
-
- | # |
- {$ currentSelectedFile $} |
-
-
-
-
-
-
+
+
+
+
+
+ | # |
+ {$ currentSelectedFile $} |
+
+
+
+
+
+
diff --git a/websiteFunctions/urls.py b/websiteFunctions/urls.py
index 9e7ba879b..6939b2dae 100755
--- a/websiteFunctions/urls.py
+++ b/websiteFunctions/urls.py
@@ -135,6 +135,7 @@ urlpatterns = [
url(r'^fetchCommits$', views.fetchCommits, name='fetchCommits'),
url(r'^fetchFiles$', views.fetchFiles, name='fetchFiles'),
url(r'^fetchChangesInFile$', views.fetchChangesInFile, name='fetchChangesInFile'),
+ url(r'^saveGitConfigurations$', views.saveGitConfigurations, name='saveGitConfigurations'),
## Catch all for domains
diff --git a/websiteFunctions/views.py b/websiteFunctions/views.py
index 84f64c7a3..d7c17010a 100755
--- a/websiteFunctions/views.py
+++ b/websiteFunctions/views.py
@@ -843,5 +843,13 @@ def fetchChangesInFile(request):
userID = request.session['userID']
wm = WebsiteManager()
return wm.fetchChangesInFile(userID, json.loads(request.body))
+ except KeyError:
+ return redirect(loadLoginPage)
+
+def saveGitConfigurations(request):
+ try:
+ userID = request.session['userID']
+ wm = WebsiteManager()
+ return wm.saveGitConfigurations(userID, json.loads(request.body))
except KeyError:
return redirect(loadLoginPage)
\ No newline at end of file
diff --git a/websiteFunctions/website.py b/websiteFunctions/website.py
index 093f26d16..71c4ee505 100755
--- a/websiteFunctions/website.py
+++ b/websiteFunctions/website.py
@@ -3000,8 +3000,31 @@ StrictHostKeyChecking no
if self.folder == '/home/%s' % (self.domain):
home = 1
+ ## Fetch Configurations
+
+ gitConfFolder = '/home/cyberpanel/git'
+ gitConFile = '%s/%s' % (gitConfFolder, self.domain)
+
+ if os.path.exists(gitConFile):
+ gitConf = json.loads(open(gitConFile, 'r').read())
+
+ autoCommitCurrent = gitConf['autoCommit']
+ autoPushCurrent = gitConf['autoPush']
+ emailLogsCurrent = gitConf['emailLogs']
+ else:
+ autoCommitCurrent = 'Never'
+ autoPushCurrent = 'Never'
+ emailLogsCurrent = 'False'
+
+ ##
+
+ webHookURL = 'https://%s/websites/%s/webhook' % (ACLManager.fetchIP(), self.domain)
+
data_ret = {'status': 1, 'repo': 1, 'finalBranches': branches, 'deploymentKey': deploymentKey,
- 'remote': remote, 'remoteResult': remoteResult, 'totalCommits': totalCommits, 'home': home}
+ 'remote': remote, 'remoteResult': remoteResult, 'totalCommits': totalCommits, 'home': home,
+ 'webHookURL': webHookURL, 'autoCommitCurrent': autoCommitCurrent,
+ 'autoPushCurrent':autoPushCurrent, 'emailLogsCurrent': emailLogsCurrent}
+
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
@@ -3750,6 +3773,61 @@ StrictHostKeyChecking no
data_ret = {'status': 0, 'error_message': 'Not a text file.'}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
+ except BaseException as msg:
+ data_ret = {'status': 0, 'error_message': str(msg)}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
+ def saveGitConfigurations(self, userID=None, data=None):
+ try:
+
+ currentACL = ACLManager.loadedACL(userID)
+ admin = Administrator.objects.get(pk=userID)
+
+ self.domain = data['domain']
+ self.folder = data['folder']
+
+ dic = {}
+
+ dic['autoCommit'] = data['autoCommit']
+
+ try:
+ dic['autoPush'] = data['autoPush']
+ except:
+ dic['autoCommit'] = 'Never'
+
+ try:
+ dic['emailLogs'] = data['emailLogs']
+ except:
+ dic['emailLogs'] = False
+
+
+ if ACLManager.checkOwnership(self.domain, admin, currentACL) == 1:
+ pass
+ else:
+ return ACLManager.loadErrorJson('status', 0)
+
+ if self.folderCheck():
+ pass
+ else:
+ return ACLManager.loadErrorJson()
+
+ ##
+
+ gitConfFolder = '/home/cyberpanel/git'
+ gitConFile = '%s/%s' % (gitConfFolder, self.domain)
+
+ if not os.path.exists(gitConfFolder):
+ os.mkdir(gitConfFolder)
+
+ writeToFile = open(gitConFile, 'w')
+ writeToFile.write(json.dumps(dic))
+ writeToFile.close()
+
+ data_ret = {'status': 1}
+ json_data = json.dumps(data_ret)
+ return HttpResponse(json_data)
+
except BaseException as msg:
data_ret = {'status': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)