mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-06 13:25:51 +01:00
view commits
This commit is contained in:
@@ -5801,6 +5801,7 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) {
|
||||
$scope.fetchFolderDetails = function () {
|
||||
|
||||
$scope.cyberpanelLoading = false;
|
||||
$scope.gitCommitsTable = true;
|
||||
|
||||
url = "/websites/fetchFolderDetails";
|
||||
|
||||
@@ -5808,7 +5809,6 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) {
|
||||
var data = {
|
||||
domain: $("#domain").text(),
|
||||
folder: $scope.folder
|
||||
|
||||
};
|
||||
|
||||
var config = {
|
||||
@@ -6477,5 +6477,58 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) {
|
||||
}
|
||||
};
|
||||
|
||||
$scope.fetchCommits = function () {
|
||||
|
||||
$scope.cyberpanelLoading = false;
|
||||
|
||||
url = "/websites/fetchCommits";
|
||||
|
||||
|
||||
var data = {
|
||||
domain: $("#domain").text(),
|
||||
folder: $scope.folder
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
$scope.gitCommitsTable = false;
|
||||
if (response.data.status === 1) {
|
||||
new PNotify({
|
||||
title: 'Success',
|
||||
text: 'Successfully fetched.',
|
||||
type: 'success'
|
||||
});
|
||||
$scope.commits = JSON.parse(response.data.commits);
|
||||
} 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 */
|
||||
|
||||
@@ -5801,6 +5801,7 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) {
|
||||
$scope.fetchFolderDetails = function () {
|
||||
|
||||
$scope.cyberpanelLoading = false;
|
||||
$scope.gitCommitsTable = true;
|
||||
|
||||
url = "/websites/fetchFolderDetails";
|
||||
|
||||
@@ -5808,7 +5809,6 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) {
|
||||
var data = {
|
||||
domain: $("#domain").text(),
|
||||
folder: $scope.folder
|
||||
|
||||
};
|
||||
|
||||
var config = {
|
||||
@@ -6477,5 +6477,58 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) {
|
||||
}
|
||||
};
|
||||
|
||||
$scope.fetchCommits = function () {
|
||||
|
||||
$scope.cyberpanelLoading = false;
|
||||
|
||||
url = "/websites/fetchCommits";
|
||||
|
||||
|
||||
var data = {
|
||||
domain: $("#domain").text(),
|
||||
folder: $scope.folder
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
$scope.gitCommitsTable = false;
|
||||
if (response.data.status === 1) {
|
||||
new PNotify({
|
||||
title: 'Success',
|
||||
text: 'Successfully fetched.',
|
||||
type: 'success'
|
||||
});
|
||||
$scope.commits = JSON.parse(response.data.commits);
|
||||
} 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 */
|
||||
|
||||
@@ -384,7 +384,8 @@
|
||||
<input name="radio-toggle-1" type="radio">
|
||||
Push To Remote
|
||||
</a>
|
||||
<a ng-click="fetchGitignore()" data-toggle="modal" data-target="#gitignore" href="#" class="btn btn-info">
|
||||
<a ng-click="fetchGitignore()" data-toggle="modal" data-target="#gitignore" href="#"
|
||||
class="btn btn-info">
|
||||
<input name="radio-toggle-1" type="radio">
|
||||
Edit .gitignore
|
||||
</a>
|
||||
@@ -403,7 +404,8 @@
|
||||
<form name="containerSettingsForm" action="/" class="form-horizontal">
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-12 control-label" style="text-align: center;">{% trans "Contents of .gitignore, use the box below to Add/Edit content of .gitingore file." %}</label>
|
||||
<label class="col-sm-12 control-label"
|
||||
style="text-align: center;">{% trans "Contents of .gitignore, use the box below to Add/Edit content of .gitingore file." %}</label>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
@@ -411,7 +413,8 @@
|
||||
<div class="form-group">
|
||||
|
||||
<div class="col-sm-12">
|
||||
<textarea ng-model="gitIgnoreContent" rows="3" class="form-control"></textarea>
|
||||
<textarea ng-model="gitIgnoreContent" rows="3"
|
||||
class="form-control"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -452,7 +455,8 @@
|
||||
|
||||
<form name="containerSettingsForm" action="/" class="form-horizontal">
|
||||
<div class="form-group">
|
||||
<label class="col-sm-13 control-label" style="text-align: center;">{% trans "Removing git tracking is not reversible, it will delete all of your commit history, however your files stays there." %}</label>
|
||||
<label class="col-sm-13 control-label"
|
||||
style="text-align: center;">{% trans "Removing git tracking is not reversible, it will delete all of your commit history, however your files stays there." %}</label>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -616,7 +620,7 @@
|
||||
|
||||
</td>
|
||||
<td>
|
||||
<button data-toggle="modal" data-target="#settings" style="margin-left: 2%"
|
||||
<button ng-click="fetchCommits()" style="margin-left: 2%"
|
||||
type="button" class="btn btn-primary">
|
||||
{% trans "View Commits" %}
|
||||
</button>
|
||||
@@ -630,149 +634,18 @@
|
||||
<table ng-hide="gitCommitsTable" style="margin-top: 2%" class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Total Commits</th>
|
||||
<th>Branch</th>
|
||||
<th>Remote</th>
|
||||
<th>Commits</th>
|
||||
<th>Commit Hash</th>
|
||||
<th>Description</th>
|
||||
<th>Commiter</th>
|
||||
<th>Commit Time</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="bs-badge badge-success">{$ totalCommits $}</span>
|
||||
</td>
|
||||
<td>
|
||||
<select ng-change="changeBranch()" ng-model="branchName" class="form-control">
|
||||
<option ng-repeat="branch in branches track by $index">{$ branch $}</option>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
|
||||
<button data-toggle="modal" data-target="#settings" style="margin-left: 2%"
|
||||
type="button" class="btn btn-primary">
|
||||
{% trans "View/Setup Remote" %}
|
||||
</button>
|
||||
|
||||
<div id="settings" class="modal fade" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
|
||||
<!-- Modal content-->
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal">×
|
||||
</button>
|
||||
<h4 class="modal-title">{% trans "Setup Remote" %}</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
<form name="containerSettingsForm" action="/" class="form-horizontal">
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Git Host" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input placeholder="Ex. github.com or gitlab.com"
|
||||
name="gitHost" type="text" class="form-control"
|
||||
ng-model="$parent.gitHost" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Username" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input name="gitUsername" type="text" class="form-control"
|
||||
ng-model="$parent.gitUsername" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="installationDetailsForm" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Repo Name" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input name="gitReponame" type="text" class="form-control"
|
||||
ng-model="$parent.gitReponame" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="form-group">
|
||||
|
||||
<div class="col-sm-12">
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{% trans "Current Remote" %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12">
|
||||
<textarea rows="2"
|
||||
class="form-control">{$ remoteResult $}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="form-group">
|
||||
|
||||
<div class="col-sm-12">
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{% trans "Deployment Key" %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12">
|
||||
<textarea rows="5"
|
||||
class="form-control">{$ deploymentKey $}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" ng-disabled="savingSettings"
|
||||
class="btn btn-primary"
|
||||
ng-click="setupRemote()">Save <img ng-hide="cyberpanelLoading"
|
||||
src="/static/images/loading.gif"
|
||||
style="display: none;">
|
||||
</button>
|
||||
<button type="button" ng-disabled="savingSettings"
|
||||
class="btn btn-default" data-dismiss="modal">
|
||||
Close
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</td>
|
||||
<td>
|
||||
<button data-toggle="modal" data-target="#settings" style="margin-left: 2%"
|
||||
type="button" class="btn btn-primary">
|
||||
{% trans "View Commits" %}
|
||||
</button>
|
||||
</td>
|
||||
<tr ng-repeat="commit in commits track by $index">
|
||||
<td ng-bind="commit.commit"></td>
|
||||
<td ng-bind="commit.message"></td>
|
||||
<td ng-bind="commit.name"></td>
|
||||
<td ng-bind="commit.date"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -132,6 +132,7 @@ urlpatterns = [
|
||||
url(r'^removeTracking$', views.removeTracking, name='removeTracking'),
|
||||
url(r'^fetchGitignore$', views.fetchGitignore, name='fetchGitignore'),
|
||||
url(r'^saveGitIgnore$', views.saveGitIgnore, name='saveGitIgnore'),
|
||||
url(r'^fetchCommits$', views.fetchCommits, name='fetchCommits'),
|
||||
|
||||
|
||||
## Catch all for domains
|
||||
|
||||
@@ -821,3 +821,11 @@ def saveGitIgnore(request):
|
||||
return wm.saveGitIgnore(userID, json.loads(request.body))
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def fetchCommits(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
wm = WebsiteManager()
|
||||
return wm.fetchCommits(userID, json.loads(request.body))
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
@@ -2770,7 +2770,6 @@ StrictHostKeyChecking no
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
def syncToMaster(self, request=None, userID=None, data=None, childDomain = None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
@@ -2833,14 +2832,11 @@ StrictHostKeyChecking no
|
||||
writeToFile.write(message)
|
||||
writeToFile.close()
|
||||
|
||||
|
||||
extraArgs['tempStatusPath'] = tempStatusPath
|
||||
|
||||
st = StagingSetup('startSyncing', extraArgs)
|
||||
st.start()
|
||||
|
||||
|
||||
|
||||
data_ret = {'status': 1, 'error_message': 'None', 'tempStatusPath': tempStatusPath}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
@@ -3551,3 +3547,39 @@ StrictHostKeyChecking no
|
||||
data_ret = {'status': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
def fetchCommits(self, userID=None, data=None):
|
||||
try:
|
||||
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
|
||||
self.domain = data['domain']
|
||||
self.folder = data['folder']
|
||||
|
||||
if ACLManager.checkOwnership(self.domain, admin, currentACL) == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson('status', 0)
|
||||
|
||||
if self.folderCheck():
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson()
|
||||
|
||||
initCommand = """log --pretty=format:'{%n "commit": "%h",%n "message": "%s", %n "name": "%cn", %n "date": "%cd"%n},' -10"""
|
||||
|
||||
command = 'git -C %s %s' % (self.folder, initCommand)
|
||||
commits = '[%s]' % (ProcessUtilities.outputExecutioner(command).rstrip(','))
|
||||
|
||||
commits = json.loads(commits)
|
||||
commits = json.dumps(commits)
|
||||
|
||||
data_ret = {'status': 1, 'commits': commits}
|
||||
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