Integration of Github webhooks.

This commit is contained in:
usmannasir
2018-07-26 23:13:02 +05:00
parent 0af4297788
commit bdec3badf6
6 changed files with 128 additions and 23 deletions

View File

@@ -4245,6 +4245,8 @@ app.controller('setupGit', function($scope, $http, $timeout) {
$scope.gitLoading = true;
$scope.githubBranch = 'master';
$scope.installProg = true;
$scope.goBackDisable = true;
var statusFile;
var domain = $("#domainNamePage").text();
@@ -4282,7 +4284,7 @@ app.controller('setupGit', function($scope, $http, $timeout) {
$scope.installationSuccessfull = false;
$scope.couldNotConnect = true;
$scope.gitLoading = true;
$scope.goBackDisable = false;
$scope.goBackDisable = true;
$scope.installationURL = domain;
@@ -4306,6 +4308,7 @@ app.controller('setupGit', function($scope, $http, $timeout) {
$("#installProgress").css("width", "0%");
$scope.installPercentage = "0";
$scope.goBackDisable = false;
}
@@ -4326,6 +4329,7 @@ app.controller('setupGit', function($scope, $http, $timeout) {
$scope.canNotFetch = true;
$scope.couldNotConnect = false;
$scope.goBackDisable = false;
}
@@ -4343,7 +4347,7 @@ app.controller('setupGit', function($scope, $http, $timeout) {
$scope.gitLoading = false;
$scope.installProg = false;
$scope.currentStatus = "Starting installation..";
$scope.currentStatus = "Attaching GIT..";
url = "/websites/setupGitRepo";
@@ -4380,6 +4384,7 @@ app.controller('setupGit', function($scope, $http, $timeout) {
$scope.gitLoading = true;
$scope.errorMessage = response.data.error_message;
$scope.goBackDisable = false;
}
@@ -4394,4 +4399,17 @@ app.controller('setupGit', function($scope, $http, $timeout) {
};
$scope.goBack = function () {
$scope.installationDetailsForm = false;
$scope.installationProgress = true;
$scope.installProg = true;
$scope.installationFailed = true;
$scope.installationSuccessfull = true;
$scope.couldNotConnect = true;
$scope.gitLoading = true;
$scope.goBackDisable = true;
$("#installProgress").css("width", "0%");
};
});

View File

@@ -97,11 +97,11 @@
</div>
<div ng-hide="installationFailed" class="alert alert-danger">
<p>{% trans "Installation failed. Error message:" %} {$ errorMessage $}</p>
<p>{% trans "Error message:" %} {$ errorMessage $}</p>
</div>
<div ng-hide="installationSuccessfull" class="alert alert-success">
<p>{% trans "Installation successful. Visit:" %} {$ installationURL $}</p>
<p>{% trans "GIT Successfully attached. Visit:" %} {$ installationURL $}</p>
</div>
@@ -114,6 +114,14 @@
</div>
<div ng-hide="installationProgress" class="form-group">
<label class="col-sm-3 control-label"></label>
<div class="col-sm-4">
<button type="button" ng-disabled="goBackDisable" ng-click="goBack()" class="btn btn-primary btn-lg btn-block">{% trans "Go Back" %}</button>
</div>
</div>
</form>
</div>

View File

@@ -93,5 +93,8 @@ urlpatterns = [
url(r'^(?P<domain>([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?)/setupGit$', views.setupGit, name='setupGit'),
url(r'^setupGitRepo$', views.setupGitRepo, name='setupGitRepo'),
url(r'^(?P<domain>([\da-z\.-]+\.[a-z\.]{2,12}|[\d\.]+)([\/:?=&#]{1}[\da-z\.-]+)*[\/\?]?)/gitNotify$', views.gitNotify, name='gitNotify'),
]

View File

@@ -2560,4 +2560,31 @@ def setupGitRepo(request):
except KeyError, msg:
status = {"installStatus":0,"error":str(msg)}
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[installWordpress]")
return HttpResponse("Not Logged in as admin")
return HttpResponse("Not Logged in as admin")
def gitNotify(request, domain):
try:
if request.method == 'POST':
try:
extraArgs = {}
extraArgs['domain'] = domain
background = ApplicationInstaller('pull', extraArgs)
background.start()
data_ret = {'pulled': 1, 'error_message': 'None'}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException, msg:
data_ret = {'pulled': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except KeyError, msg:
data_ret = {"pulled":0,"error":str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)