improved git file changes

This commit is contained in:
Usman Nasir
2020-03-13 20:41:50 +05:00
parent 0e31305dae
commit 59683599f4
9 changed files with 33 additions and 66 deletions

View File

@@ -2,10 +2,8 @@
* Created by usman on 7/24/17. * Created by usman on 7/24/17.
*/ */
/* Utilities */ /* Utilities */
function getCookie(name) { function getCookie(name) {
var cookieValue = null; var cookieValue = null;
if (document.cookie && document.cookie !== '') { if (document.cookie && document.cookie !== '') {
@@ -34,18 +32,15 @@ function randomPassword(length) {
/* Utilities ends here */ /* Utilities ends here */
/* Java script code to monitor system status */ /* Java script code to monitor system status */
var app = angular.module('CyberCP', []); var app = angular.module('CyberCP', []);
app.config(['$interpolateProvider', function($interpolateProvider) { app.config(['$interpolateProvider', function($interpolateProvider) {
$interpolateProvider.startSymbol('{$'); $interpolateProvider.startSymbol('{$');
$interpolateProvider.endSymbol('$}'); $interpolateProvider.endSymbol('$}');
}]); }]);
app.filter('getwebsitename', function() { app.filter('getwebsitename', function() {
return function(domain, uppercase) { return function(domain, uppercase) {
@@ -93,13 +88,8 @@ app.controller('systemStatusInfo', function($scope,$http,$timeout) {
} }
}); });
/* Admin status */ /* Admin status */
app.controller('adminController', function($scope,$http,$timeout) { app.controller('adminController', function($scope,$http,$timeout) {
url = "/base/getAdminStatus"; url = "/base/getAdminStatus";
@@ -315,11 +305,8 @@ app.controller('adminController', function($scope,$http,$timeout) {
function cantLoadInitialData(response) {} function cantLoadInitialData(response) {}
}); });
/* Load average */ /* Load average */
app.controller('loadAvg', function($scope,$http,$timeout) { app.controller('loadAvg', function($scope,$http,$timeout) {
//getStuff(); //getStuff();
@@ -350,13 +337,8 @@ app.controller('loadAvg', function($scope,$http,$timeout) {
} }
}); });
/// home page system status /// home page system status
app.controller('homePageStatus', function($scope,$http,$timeout) { app.controller('homePageStatus', function($scope,$http,$timeout) {
getStuff(); getStuff();
@@ -472,9 +454,6 @@ app.controller('homePageStatus', function($scope,$http,$timeout) {
} }
}); });
//////////// ////////////
function increment(){ function increment(){
@@ -488,11 +467,8 @@ function increment(){
increment(); increment();
//////////// ////////////
app.controller('versionManagment', function($scope,$http,$timeout) { app.controller('versionManagment', function($scope,$http,$timeout) {
$scope.upgradeLoading = true; $scope.upgradeLoading = true;

View File

@@ -130,7 +130,7 @@ def versionManagment(request):
currentBuild = data[1] currentBuild = data[1]
except: except:
currentVersion = latestVersion currentVersion = latestVersion
currentBuild = str(latestBuild) + 'E' currentBuild = str(5) + 'E'
return render(request, 'baseTemplate/versionManagment.html', {'build': currentBuild, return render(request, 'baseTemplate/versionManagment.html', {'build': currentBuild,
'currentVersion': currentVersion, 'currentVersion': currentVersion,

View File

@@ -193,7 +193,7 @@ def loadLoginPage(request):
firstName="Cyber",lastName="Panel", acl=acl, token=token) firstName="Cyber",lastName="Panel", acl=acl, token=token)
admin.save() admin.save()
vers = version(currentVersion="1.9", build=4) vers = version(currentVersion="1.9", build=5)
vers.save() vers.save()
package = Package(admin=admin, packageName="Default", diskSpace=1000, package = Package(admin=admin, packageName="Default", diskSpace=1000,

View File

@@ -34,7 +34,7 @@ def main():
firstName="Cyber", lastName="Panel", acl=acl, token=token) firstName="Cyber", lastName="Panel", acl=acl, token=token)
admin.save() admin.save()
vers = version(currentVersion="1.9", build=4) vers = version(currentVersion="1.9", build=5)
vers.save() vers.save()
package = Package(admin=admin, packageName="Default", diskSpace=1000, package = Package(admin=admin, packageName="Default", diskSpace=1000,

View File

@@ -2,10 +2,8 @@
* Created by usman on 7/24/17. * Created by usman on 7/24/17.
*/ */
/* Utilities */ /* Utilities */
function getCookie(name) { function getCookie(name) {
var cookieValue = null; var cookieValue = null;
if (document.cookie && document.cookie !== '') { if (document.cookie && document.cookie !== '') {
@@ -34,18 +32,15 @@ function randomPassword(length) {
/* Utilities ends here */ /* Utilities ends here */
/* Java script code to monitor system status */ /* Java script code to monitor system status */
var app = angular.module('CyberCP', []); var app = angular.module('CyberCP', []);
app.config(['$interpolateProvider', function($interpolateProvider) { app.config(['$interpolateProvider', function($interpolateProvider) {
$interpolateProvider.startSymbol('{$'); $interpolateProvider.startSymbol('{$');
$interpolateProvider.endSymbol('$}'); $interpolateProvider.endSymbol('$}');
}]); }]);
app.filter('getwebsitename', function() { app.filter('getwebsitename', function() {
return function(domain, uppercase) { return function(domain, uppercase) {
@@ -93,13 +88,8 @@ app.controller('systemStatusInfo', function($scope,$http,$timeout) {
} }
}); });
/* Admin status */ /* Admin status */
app.controller('adminController', function($scope,$http,$timeout) { app.controller('adminController', function($scope,$http,$timeout) {
url = "/base/getAdminStatus"; url = "/base/getAdminStatus";
@@ -315,11 +305,8 @@ app.controller('adminController', function($scope,$http,$timeout) {
function cantLoadInitialData(response) {} function cantLoadInitialData(response) {}
}); });
/* Load average */ /* Load average */
app.controller('loadAvg', function($scope,$http,$timeout) { app.controller('loadAvg', function($scope,$http,$timeout) {
//getStuff(); //getStuff();
@@ -350,13 +337,8 @@ app.controller('loadAvg', function($scope,$http,$timeout) {
} }
}); });
/// home page system status /// home page system status
app.controller('homePageStatus', function($scope,$http,$timeout) { app.controller('homePageStatus', function($scope,$http,$timeout) {
getStuff(); getStuff();
@@ -472,9 +454,6 @@ app.controller('homePageStatus', function($scope,$http,$timeout) {
} }
}); });
//////////// ////////////
function increment(){ function increment(){
@@ -488,11 +467,8 @@ function increment(){
increment(); increment();
//////////// ////////////
app.controller('versionManagment', function($scope,$http,$timeout) { app.controller('versionManagment', function($scope,$http,$timeout) {
$scope.upgradeLoading = true; $scope.upgradeLoading = true;

View File

@@ -6620,7 +6620,7 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) {
type: 'success' type: 'success'
}); });
$scope.fileStatus = false; $scope.fileStatus = false;
$scope.fileChangedContent = response.data.fileChangedContent; document.getElementById("fileChangedContent").innerHTML = response.data.fileChangedContent;
} else { } else {
new PNotify({ new PNotify({
title: 'Operation Failed!', title: 'Operation Failed!',

View File

@@ -6620,7 +6620,7 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) {
type: 'success' type: 'success'
}); });
$scope.fileStatus = false; $scope.fileStatus = false;
$scope.fileChangedContent = response.data.fileChangedContent; document.getElementById("fileChangedContent").innerHTML = response.data.fileChangedContent;
} else { } else {
new PNotify({ new PNotify({
title: 'Operation Failed!', title: 'Operation Failed!',

View File

@@ -626,7 +626,7 @@
<table ng-hide="gitCommitsTable" style="margin-top: 2%" class="table"> <table ng-hide="gitCommitsTable" style="margin-top: 2%" class="table">
<thead> <thead>
<tr> <tr>
<th>ID/th> <th>ID</th>
<th>Commit Hash</th> <th>Commit Hash</th>
<th>Description</th> <th>Description</th>
<th>Commiter</th> <th>Commiter</th>
@@ -665,30 +665,33 @@
<div class="form-group"> <div class="form-group">
<label class="col-sm-2 control-label">{% trans "Select File" %}</label> <label class="col-sm-2 control-label">{% trans "Select File" %}</label>
<div class="col-sm-10"> <div class="col-sm-10">
<select ng-change="fetchChangesInFile()" ng-model="$parent.changeFile" class="form-control"> <select ng-change="fetchChangesInFile()"
ng-model="$parent.changeFile" class="form-control">
<option ng-repeat="file in files track by $index"> <option ng-repeat="file in files track by $index">
{$ file $} {$ file $}
</option> </option>
</select> </select>
</div> </div>
<hr> <hr ng-hide="fileStatus">
<div ng-hide="fileStatus" <div ng-hide="fileStatus" class="example-box-wrapper">
style="margin-left: 0px; margin-right: 0px" <div class="row">
class="form-group"> <div class="col-md-12">
<label class="col-sm-2 control-label">{% trans "Git Diff" %}</label> <div class="content-box">
<div id="fileChangedContent" class="content-box-wrapper">
<div class="col-sm-10"> </div>
<textarea ng-model="fileChangedContent" rows="12" </div>
class="form-control"></textarea> </div>
</div> </div>
</div> </div>
</div> </div>
</form> </form>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -3653,9 +3653,21 @@ StrictHostKeyChecking no
return ACLManager.loadErrorJson() return ACLManager.loadErrorJson()
command = 'git -C %s show %s -- %s/%s' % (self.folder, self.commit, self.folder, self.file.strip('\n').strip(' ')) command = 'git -C %s show %s -- %s/%s' % (self.folder, self.commit, self.folder, self.file.strip('\n').strip(' '))
fileChangedContent = ProcessUtilities.outputExecutioner(command) fileChangedContent = ProcessUtilities.outputExecutioner(command).split('\n')
data_ret = {'status': 1, 'fileChangedContent': fileChangedContent} fileLen = len(fileChangedContent)
finalContent = ''
for i in range(12, fileLen-1):
if fileChangedContent[i][0] == '+':
finalContent = finalContent + '<p style="color:green">%s</p><br>' % (fileChangedContent[i])
elif fileChangedContent[i][0] == '-':
finalContent = finalContent + '<p style="color:red">%s</p><br>' % (fileChangedContent[i])
else:
finalContent = finalContent + '<p>%s</p><br>' % (fileChangedContent[i])
data_ret = {'status': 1, 'fileChangedContent': finalContent}
json_data = json.dumps(data_ret) json_data = json.dumps(data_ret)
return HttpResponse(json_data) return HttpResponse(json_data)