mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-07 05:45:59 +01:00
count total commits in repo
This commit is contained in:
@@ -5790,6 +5790,7 @@ app.controller('installMagentoCTRL', function ($scope, $http, $timeout) {
|
||||
app.controller('manageGIT', function ($scope, $http, $timeout, $window) {
|
||||
|
||||
$scope.cyberpanelLoading = true;
|
||||
$scope.loadingSticks = true;
|
||||
$scope.gitTracking = true;
|
||||
$scope.gitEnable = true;
|
||||
|
||||
@@ -5827,6 +5828,7 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) {
|
||||
$scope.deploymentKey = response.data.deploymentKey;
|
||||
$scope.remote = response.data.remote;
|
||||
$scope.remoteResult = response.data.remoteResult;
|
||||
$scope.totalCommits = response.data.totalCommits;
|
||||
} else {
|
||||
$scope.gitTracking = false;
|
||||
$scope.gitEnable = true;
|
||||
@@ -5967,6 +5969,66 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) {
|
||||
|
||||
};
|
||||
|
||||
$scope.changeBranch = function () {
|
||||
|
||||
$scope.loadingSticks = false;
|
||||
$("#showStatus").modal();
|
||||
|
||||
url = "/websites/changeGitBranch";
|
||||
|
||||
|
||||
var data = {
|
||||
domain: $("#domain").text(),
|
||||
folder: $scope.folder,
|
||||
branchName: $scope.branchName
|
||||
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
$scope.loadingSticks = true;
|
||||
|
||||
if (response.data.status === 1) {
|
||||
new PNotify({
|
||||
title: 'Success',
|
||||
text: 'Changes applied.',
|
||||
type: 'success'
|
||||
});
|
||||
$scope.commandStatus = response.data.commandStatus;
|
||||
$timeout(function () {
|
||||
$window.location.reload();
|
||||
}, 3000);
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
$scope.commandStatus = response.data.commandStatus;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.loadingSticks = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page.',
|
||||
type: 'error'
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
function getCreationStatus() {
|
||||
|
||||
url = "/websites/installWordpressStatus";
|
||||
|
||||
@@ -43,18 +43,21 @@
|
||||
<table ng-hide="gitEnable" style="margin-top: 2%" class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Total Commits</th>
|
||||
<th>Branch</th>
|
||||
<th>Remote</th>
|
||||
<th>Status</th>
|
||||
|
||||
<th>Manage</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>{$ totalCommits $}</td>
|
||||
<td>
|
||||
<select ng-change="fetchFolderDetails()" ng-model="branchName" class="form-control">
|
||||
<select ng-change="changeBranch()" ng-model="branchName" class="form-control">
|
||||
<option ng-repeat="branch in branches track by $index">{$ branch $}</option>
|
||||
</select></td>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
|
||||
<button data-toggle="modal" data-target="#settings" style="margin-left: 2%"
|
||||
@@ -177,10 +180,51 @@
|
||||
|
||||
</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div id="showStatus" class="modal fade" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
|
||||
<!-- Modal content-->
|
||||
<div class="modal-content">
|
||||
<div class="modal-body">
|
||||
|
||||
<form name="containerSettingsForm" action="/" class="form-horizontal">
|
||||
<div ng-hide="loadingSticks" class="form-group">
|
||||
<div class="col-sm-12">
|
||||
<div class="loading-stick">
|
||||
<div class="stick bg-azure"></div>
|
||||
<div class="stick bg-azure"></div>
|
||||
<div class="stick bg-azure"></div>
|
||||
<div class="stick bg-azure"></div>
|
||||
<div class="stick bg-azure"></div>
|
||||
<div class="stick bg-azure"></div>
|
||||
<div class="stick bg-azure"></div>
|
||||
<div class="stick bg-azure"></div>
|
||||
<div class="stick bg-azure"></div>
|
||||
<div class="stick bg-azure"></div>
|
||||
<h1>Pleas wait...</h1>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="form-group">
|
||||
|
||||
<div class="col-sm-12">
|
||||
<textarea rows="3"
|
||||
class="form-control">{$ commandStatus $}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -123,6 +123,7 @@ urlpatterns = [
|
||||
url(r'^fetchFolderDetails$', views.fetchFolderDetails, name='fetchFolderDetails'),
|
||||
url(r'^initRepo$', views.initRepo, name='initRepo'),
|
||||
url(r'^setupRemote$', views.setupRemote, name='setupRemote'),
|
||||
url(r'^changeGitBranch$', views.changeGitBranch, name='changeGitBranch'),
|
||||
## Catch all for domains
|
||||
url(r'^(?P<domain>(.*))/(?P<childDomain>(.*))$', views.launchChild, name='launchChild'),
|
||||
url(r'^(?P<domain>(.*))$', views.domain, name='domain'),
|
||||
|
||||
@@ -749,3 +749,11 @@ def setupRemote(request):
|
||||
return wm.setupRemote(userID, json.loads(request.body))
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def changeGitBranch(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
wm = WebsiteManager()
|
||||
return wm.changeGitBranch(userID, json.loads(request.body))
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
@@ -2992,7 +2992,16 @@ StrictHostKeyChecking no
|
||||
remote = 0
|
||||
remoteResult = 'Remote currently not set.'
|
||||
|
||||
data_ret = {'status': 1, 'repo': 1, 'finalBranches': branches, 'deploymentKey': deploymentKey, 'remote': remote, 'remoteResult': remoteResult}
|
||||
## Find Total commits on current branch
|
||||
|
||||
command = 'git -C %s rev-list --count HEAD' % (self.folder)
|
||||
totalCommits = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
if totalCommits.find('fatal') > -1:
|
||||
totalCommits = '0'
|
||||
|
||||
data_ret = {'status': 1, 'repo': 1, 'finalBranches': branches, 'deploymentKey': deploymentKey,
|
||||
'remote': remote, 'remoteResult': remoteResult, 'totalCommits': totalCommits}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
@@ -3092,3 +3101,42 @@ StrictHostKeyChecking no
|
||||
data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
def changeGitBranch(self, userID=None, data=None):
|
||||
try:
|
||||
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
|
||||
self.domain = data['domain']
|
||||
self.folder = data['folder']
|
||||
self.branchName = data['branchName']
|
||||
|
||||
if ACLManager.checkOwnership(self.domain, admin, currentACL) == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson('status', 0)
|
||||
|
||||
if self.folderCheck():
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson()
|
||||
|
||||
## Check if remote exists
|
||||
|
||||
command = 'git -C %s checkout %s' % (self.folder, self.branchName.strip(' '))
|
||||
commandStatus = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
if commandStatus.find('Switched to branch') > -1:
|
||||
data_ret = {'status': 1, 'commandStatus': commandStatus + 'Refreshing page in 3 seconds..'}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
else:
|
||||
data_ret = {'status': 0, 'error_message': 'Failed to change branch', 'commandStatus': commandStatus}
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user