mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-07 13:56:01 +01:00
view changed files
This commit is contained in:
@@ -6530,5 +6530,119 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) {
|
||||
}
|
||||
};
|
||||
|
||||
var currentComit;
|
||||
|
||||
$scope.fetchFiles = function (commit) {
|
||||
|
||||
currentComit = commit;
|
||||
$scope.cyberpanelLoading = false;
|
||||
|
||||
url = "/websites/fetchFiles";
|
||||
|
||||
|
||||
var data = {
|
||||
domain: $("#domain").text(),
|
||||
folder: $scope.folder,
|
||||
commit: commit
|
||||
};
|
||||
|
||||
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.files = response.data.files;
|
||||
} 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'
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
$scope.fileStatus = true;
|
||||
|
||||
$scope.fetchChangesInFile = function () {
|
||||
|
||||
$scope.cyberpanelLoading = false;
|
||||
|
||||
url = "/websites/fetchChangesInFile";
|
||||
|
||||
|
||||
var data = {
|
||||
domain: $("#domain").text(),
|
||||
folder: $scope.folder,
|
||||
file: $scope.changeFile,
|
||||
commit: currentComit
|
||||
};
|
||||
|
||||
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 fetched.',
|
||||
type: 'success'
|
||||
});
|
||||
$scope.fileStatus = false;
|
||||
$scope.fileChangedContent = response.data.fileChangedContent;
|
||||
} 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 */
|
||||
|
||||
@@ -6530,5 +6530,119 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) {
|
||||
}
|
||||
};
|
||||
|
||||
var currentComit;
|
||||
|
||||
$scope.fetchFiles = function (commit) {
|
||||
|
||||
currentComit = commit;
|
||||
$scope.cyberpanelLoading = false;
|
||||
|
||||
url = "/websites/fetchFiles";
|
||||
|
||||
|
||||
var data = {
|
||||
domain: $("#domain").text(),
|
||||
folder: $scope.folder,
|
||||
commit: commit
|
||||
};
|
||||
|
||||
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.files = response.data.files;
|
||||
} 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'
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
$scope.fileStatus = true;
|
||||
|
||||
$scope.fetchChangesInFile = function () {
|
||||
|
||||
$scope.cyberpanelLoading = false;
|
||||
|
||||
url = "/websites/fetchChangesInFile";
|
||||
|
||||
|
||||
var data = {
|
||||
domain: $("#domain").text(),
|
||||
folder: $scope.folder,
|
||||
file: $scope.changeFile,
|
||||
commit: currentComit
|
||||
};
|
||||
|
||||
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 fetched.',
|
||||
type: 'success'
|
||||
});
|
||||
$scope.fileStatus = false;
|
||||
$scope.fileChangedContent = response.data.fileChangedContent;
|
||||
} 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 */
|
||||
|
||||
@@ -138,9 +138,8 @@
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary"
|
||||
ng-click="attachRepoGIT()">Attach <img ng-hide="cyberpanelLoading"
|
||||
src="/static/images/loading.gif"
|
||||
style="display: none;">
|
||||
ng-click="attachRepoGIT()">Attach <img
|
||||
ng-hide="cyberpanelLoading" src="{% static 'images/loading.gif' %}">
|
||||
</button>
|
||||
<button type="button" ng-disabled="savingSettings"
|
||||
class="btn btn-default" data-dismiss="modal">
|
||||
@@ -252,9 +251,8 @@
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary"
|
||||
ng-click="attachRepoGIT()">Attach <img ng-hide="cyberpanelLoading"
|
||||
src="/static/images/loading.gif"
|
||||
style="display: none;">
|
||||
ng-click="attachRepoGIT()">Attach <img
|
||||
ng-hide="cyberpanelLoading" src="{% static 'images/loading.gif' %}">
|
||||
</button>
|
||||
<button type="button" ng-disabled="savingSettings"
|
||||
class="btn btn-default" data-dismiss="modal">
|
||||
@@ -307,10 +305,8 @@
|
||||
<div class="modal-footer">
|
||||
<button type="button"
|
||||
class="btn btn-primary"
|
||||
ng-click="createNewBranch()">Create New Branch<img
|
||||
ng-hide="cyberpanelLoading"
|
||||
src="/static/images/loading.gif"
|
||||
style="display: none;">
|
||||
ng-click="createNewBranch()">Create New Branch <img
|
||||
ng-hide="cyberpanelLoading" src="{% static 'images/loading.gif' %}">
|
||||
</button>
|
||||
<button type="button"
|
||||
class="btn btn-default" data-dismiss="modal">
|
||||
@@ -363,9 +359,8 @@
|
||||
<div class="modal-footer">
|
||||
<button type="button"
|
||||
class="btn btn-primary"
|
||||
ng-click="commitChanges()">Commit<img ng-hide="cyberpanelLoading"
|
||||
src="/static/images/loading.gif"
|
||||
style="display: none;">
|
||||
ng-click="commitChanges()">Commit <img
|
||||
ng-hide="cyberpanelLoading" src="{% static 'images/loading.gif' %}">
|
||||
</button>
|
||||
<button type="button"
|
||||
class="btn btn-default" data-dismiss="modal">
|
||||
@@ -424,9 +419,8 @@
|
||||
<div class="modal-footer">
|
||||
<button type="button"
|
||||
class="btn btn-primary"
|
||||
ng-click="saveGitIgnore()">Save<img ng-hide="$parent.cyberpanelLoading"
|
||||
src="/static/images/loading.gif"
|
||||
style="display: none;">
|
||||
ng-click="saveGitIgnore()">Save <img
|
||||
ng-hide="cyberpanelLoading" src="{% static 'images/loading.gif' %}">
|
||||
</button>
|
||||
<button type="button"
|
||||
class="btn btn-default" data-dismiss="modal">
|
||||
@@ -464,10 +458,8 @@
|
||||
<div class="modal-footer">
|
||||
<button type="button"
|
||||
class="btn btn-primary"
|
||||
ng-click="removeTracking()">Remove<img
|
||||
ng-hide="cyberpanelLoading"
|
||||
src="/static/images/loading.gif"
|
||||
style="display: none;" data-dismiss="modal">
|
||||
ng-click="removeTracking()">Remove <img
|
||||
ng-hide="cyberpanelLoading" src="{% static 'images/loading.gif' %}">
|
||||
</button>
|
||||
<button type="button"
|
||||
class="btn btn-default" data-dismiss="modal">
|
||||
@@ -605,9 +597,9 @@
|
||||
<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;">
|
||||
ng-click="setupRemote()">Save <img
|
||||
ng-hide="cyberpanelLoading"
|
||||
src="{% static 'images/loading.gif' %}">
|
||||
</button>
|
||||
<button type="button" ng-disabled="savingSettings"
|
||||
class="btn btn-default" data-dismiss="modal">
|
||||
@@ -634,18 +626,78 @@
|
||||
<table ng-hide="gitCommitsTable" style="margin-top: 2%" class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID/th>
|
||||
<th>Commit Hash</th>
|
||||
<th>Description</th>
|
||||
<th>Commiter</th>
|
||||
<th>Commit Time</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="commit in commits track by $index">
|
||||
<td ng-bind="commit.id"></td>
|
||||
<td ng-bind="commit.commit"></td>
|
||||
<td ng-bind="commit.message"></td>
|
||||
<td ng-bind="commit.name"></td>
|
||||
<td ng-bind="commit.date"></td>
|
||||
<td>
|
||||
|
||||
<button ng-click="fetchFiles(commit.commit)" data-toggle="modal"
|
||||
data-target="#viewChanges" style="margin-left: 2%"
|
||||
type="button" class="btn btn-primary">
|
||||
{% trans "View Changes" %}
|
||||
</button>
|
||||
|
||||
<div id="viewChanges" class="modal fade" role="dialog">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<!-- Modal content-->
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal">×
|
||||
</button>
|
||||
<h4 class="modal-title">{% trans "View Changes" %}</h4> <img
|
||||
ng-hide="cyberpanelLoading" src="{% static 'images/loading.gif' %}">
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
<form name="containerSettingsForm" action="/" class="form-horizontal">
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label">{% trans "Select File" %}</label>
|
||||
<div class="col-sm-10">
|
||||
<select ng-change="fetchChangesInFile()" ng-model="$parent.changeFile" class="form-control">
|
||||
<option ng-repeat="file in files track by $index">
|
||||
{$ file $}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<div ng-hide="fileStatus"
|
||||
style="margin-left: 0px; margin-right: 0px"
|
||||
class="form-group">
|
||||
<label class="col-sm-2 control-label">{% trans "Git Diff" %}</label>
|
||||
|
||||
<div class="col-sm-10">
|
||||
<textarea ng-model="fileChangedContent" rows="12"
|
||||
class="form-control"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<img title="Delete this commit." ng-click="deleteRecord(record.id)"
|
||||
src="{% static 'images/delete.png' %}">
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -133,6 +133,8 @@ urlpatterns = [
|
||||
url(r'^fetchGitignore$', views.fetchGitignore, name='fetchGitignore'),
|
||||
url(r'^saveGitIgnore$', views.saveGitIgnore, name='saveGitIgnore'),
|
||||
url(r'^fetchCommits$', views.fetchCommits, name='fetchCommits'),
|
||||
url(r'^fetchFiles$', views.fetchFiles, name='fetchFiles'),
|
||||
url(r'^fetchChangesInFile$', views.fetchChangesInFile, name='fetchChangesInFile'),
|
||||
|
||||
|
||||
## Catch all for domains
|
||||
|
||||
@@ -829,3 +829,19 @@ def fetchCommits(request):
|
||||
return wm.fetchCommits(userID, json.loads(request.body))
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def fetchFiles(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
wm = WebsiteManager()
|
||||
return wm.fetchFiles(userID, json.loads(request.body))
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def fetchChangesInFile(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
wm = WebsiteManager()
|
||||
return wm.fetchChangesInFile(userID, json.loads(request.body))
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
@@ -3574,11 +3574,13 @@ StrictHostKeyChecking no
|
||||
|
||||
json_data = "["
|
||||
checker = 0
|
||||
id = 1
|
||||
|
||||
for commit in commits:
|
||||
cm = commit.split('|')
|
||||
|
||||
dic = {'commit': cm[0], 'message': cm[1].replace('"', "'"), 'name': cm[2], 'date': cm[3]}
|
||||
dic = {'id': str(id),'commit': cm[0], 'message': cm[1].replace('"', "'"), 'name': cm[2], 'date': cm[3]}
|
||||
id = id + 1
|
||||
|
||||
if checker == 0:
|
||||
json_data = json_data + json.dumps(dic)
|
||||
@@ -3596,3 +3598,68 @@ StrictHostKeyChecking no
|
||||
data_ret = {'status': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
def fetchFiles(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.commit = data['commit']
|
||||
|
||||
if ACLManager.checkOwnership(self.domain, admin, currentACL) == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson('status', 0)
|
||||
|
||||
if self.folderCheck():
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson()
|
||||
|
||||
command = 'git -C %s diff-tree --no-commit-id --name-only -r %s' % (self.folder, self.commit)
|
||||
files = ProcessUtilities.outputExecutioner(command).split('\n')
|
||||
|
||||
data_ret = {'status': 1, 'files': files}
|
||||
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 fetchChangesInFile(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.file = data['file']
|
||||
self.commit = data['commit']
|
||||
|
||||
if ACLManager.checkOwnership(self.domain, admin, currentACL) == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson('status', 0)
|
||||
|
||||
if self.folderCheck():
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson()
|
||||
|
||||
command = 'git -C %s show %s -- %s/%s' % (self.folder, self.commit, self.folder, self.file.strip('\n').strip(' '))
|
||||
fileChangedContent = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
data_ret = {'status': 1, 'fileChangedContent': fileChangedContent}
|
||||
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