mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-07 05:45:59 +01:00
git manager initial
This commit is contained in:
@@ -533,7 +533,7 @@ app.controller('listChildDomainsMain', function ($scope, $http, $timeout) {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.initConvert = function(virtualHost){
|
$scope.initConvert = function (virtualHost) {
|
||||||
$scope.domainName = virtualHost;
|
$scope.domainName = virtualHost;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -5785,3 +5785,142 @@ app.controller('installMagentoCTRL', function ($scope, $http, $timeout) {
|
|||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/* Java script code to git tracking */
|
||||||
|
app.controller('manageGIT', function ($scope, $http, $timeout, $window) {
|
||||||
|
|
||||||
|
$scope.cyberpanelLoading = true;
|
||||||
|
$scope.gitTracking = true;
|
||||||
|
$scope.gitEnable = true;
|
||||||
|
|
||||||
|
var statusFile;
|
||||||
|
|
||||||
|
$scope.fetchFolderDetails = function () {
|
||||||
|
|
||||||
|
$scope.cyberpanelLoading = false;
|
||||||
|
|
||||||
|
url = "/websites/fetchFolderDetails";
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
if (response.data.status === 1) {
|
||||||
|
if (response.data.repo === 1) {
|
||||||
|
$scope.gitTracking = true;
|
||||||
|
$scope.gitEnable = false;
|
||||||
|
} else {
|
||||||
|
$scope.gitTracking = false;
|
||||||
|
$scope.gitEnable = true;
|
||||||
|
}
|
||||||
|
} 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'
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
function getCreationStatus() {
|
||||||
|
|
||||||
|
url = "/websites/installWordpressStatus";
|
||||||
|
|
||||||
|
var data = {
|
||||||
|
statusFile: statusFile
|
||||||
|
};
|
||||||
|
|
||||||
|
var config = {
|
||||||
|
headers: {
|
||||||
|
'X-CSRFToken': getCookie('csrftoken')
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||||
|
|
||||||
|
|
||||||
|
function ListInitialDatas(response) {
|
||||||
|
|
||||||
|
|
||||||
|
if (response.data.abort === 1) {
|
||||||
|
|
||||||
|
if (response.data.installStatus === 1) {
|
||||||
|
|
||||||
|
$scope.cyberpanelLoading = true;
|
||||||
|
$scope.installationDetailsForm = true;
|
||||||
|
$scope.installationProgress = false;
|
||||||
|
$scope.goBackDisable = false;
|
||||||
|
|
||||||
|
$("#installProgress").css("width", "100%");
|
||||||
|
$scope.installPercentage = "100";
|
||||||
|
$scope.currentStatus = response.data.currentStatus;
|
||||||
|
$timeout.cancel();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
$scope.cyberpanelLoading = true;
|
||||||
|
$scope.installationDetailsForm = true;
|
||||||
|
$scope.installationProgress = false;
|
||||||
|
$scope.goBackDisable = false;
|
||||||
|
|
||||||
|
$scope.currentStatus = response.data.error_message;
|
||||||
|
|
||||||
|
$("#installProgress").css("width", "0%");
|
||||||
|
$scope.installPercentage = "0";
|
||||||
|
$scope.goBackDisable = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$("#installProgress").css("width", response.data.installationProgress + "%");
|
||||||
|
$scope.installPercentage = response.data.installationProgress;
|
||||||
|
$scope.currentStatus = response.data.currentStatus;
|
||||||
|
$timeout(getCreationStatus, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function cantLoadInitialDatas(response) {
|
||||||
|
|
||||||
|
$scope.cyberpanelLoading = true;
|
||||||
|
$scope.installationDetailsForm = true;
|
||||||
|
$scope.installationProgress = false;
|
||||||
|
$scope.goBackDisable = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
/* Java script code to git tracking ends here */
|
||||||
@@ -14,18 +14,18 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div ng-controller="sshAccess" class="panel">
|
<div ng-controller="manageGIT" class="panel">
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<h3 class="title-hero">
|
<h3 class="title-hero">
|
||||||
{% trans "Manage and track folders via Git for " %} {{ domainName }}.</span> <img
|
{% trans "Manage and track folders via Git for " %} <span id="domain">{{ domainName }}</span>. <img
|
||||||
ng-hide="wpInstallLoading" src="{% static 'images/loading.gif' %}">
|
ng-hide="cyberpanelLoading" src="{% static 'images/loading.gif' %}">
|
||||||
</h3>
|
</h3>
|
||||||
<div class="example-box-wrapper">
|
<div class="example-box-wrapper">
|
||||||
<form action="/" class="form-horizontal bordered-row">
|
<form action="/" class="form-horizontal bordered-row">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-3 control-label">{% trans "Select Website" %} </label>
|
<label class="col-sm-3 control-label">{% trans "Select Folder to Track" %} </label>
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<select ng-change="showFTPDetails()" ng-model="ftpDomain" class="form-control">
|
<select ng-change="fetchFolderDetails()" ng-model="folder" class="form-control">
|
||||||
{% for item in folders %}
|
{% for item in folders %}
|
||||||
<option>{{ item }}</option>
|
<option>{{ item }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
@@ -33,7 +33,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<table class="table">
|
<p style="margin: 2%" ng-hide="gitTracking">{% trans "This folder does not have Git tracking, click below to initiate a repository and start tracking files." %}</p>
|
||||||
|
<button ng-hide="gitTracking" style="margin-left: 2%" type="button" class="btn btn-primary"
|
||||||
|
ng-click="initRepo()">
|
||||||
|
Init Repo
|
||||||
|
</button>
|
||||||
|
<table ng-hide="gitEnable" style="margin-top: 2%" class="table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Folder</th>
|
<th>Folder</th>
|
||||||
|
|||||||
@@ -120,6 +120,7 @@ urlpatterns = [
|
|||||||
### Manage GIT
|
### Manage GIT
|
||||||
|
|
||||||
url(r'^(?P<domain>(.*))/manageGIT$', views.manageGIT, name='manageGIT'),
|
url(r'^(?P<domain>(.*))/manageGIT$', views.manageGIT, name='manageGIT'),
|
||||||
|
url(r'^fetchFolderDetails$', views.fetchFolderDetails, name='fetchFolderDetails'),
|
||||||
|
|
||||||
## Catch all for domains
|
## Catch all for domains
|
||||||
url(r'^(?P<domain>(.*))/(?P<childDomain>(.*))$', views.launchChild, name='launchChild'),
|
url(r'^(?P<domain>(.*))/(?P<childDomain>(.*))$', views.launchChild, name='launchChild'),
|
||||||
|
|||||||
@@ -725,3 +725,11 @@ def manageGIT(request, domain):
|
|||||||
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return redirect(loadLoginPage)
|
return redirect(loadLoginPage)
|
||||||
|
|
||||||
|
def fetchFolderDetails(request):
|
||||||
|
try:
|
||||||
|
userID = request.session['userID']
|
||||||
|
wm = WebsiteManager()
|
||||||
|
return wm.fetchFolderDetails(userID, json.loads(request.body))
|
||||||
|
except KeyError:
|
||||||
|
return redirect(loadLoginPage)
|
||||||
@@ -2789,7 +2789,6 @@ StrictHostKeyChecking no
|
|||||||
except BaseException as msg:
|
except BaseException as msg:
|
||||||
return HttpResponse(str(msg))
|
return HttpResponse(str(msg))
|
||||||
|
|
||||||
|
|
||||||
def startSync(self, userID=None, data=None):
|
def startSync(self, userID=None, data=None):
|
||||||
try:
|
try:
|
||||||
|
|
||||||
@@ -2851,7 +2850,6 @@ StrictHostKeyChecking no
|
|||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
|
||||||
def convertDomainToSite(self, userID=None, request=None):
|
def convertDomainToSite(self, userID=None, request=None):
|
||||||
try:
|
try:
|
||||||
|
|
||||||
@@ -2881,7 +2879,6 @@ StrictHostKeyChecking no
|
|||||||
return ACLManager.loadError()
|
return ACLManager.loadError()
|
||||||
|
|
||||||
website = Websites.objects.get(domain=self.domain)
|
website = Websites.objects.get(domain=self.domain)
|
||||||
externalApp = website.externalApp
|
|
||||||
|
|
||||||
folders = ['/home/%s' % (self.domain), '/home/vmail/%s' % (self.domain)]
|
folders = ['/home/%s' % (self.domain), '/home/vmail/%s' % (self.domain)]
|
||||||
|
|
||||||
@@ -2895,3 +2892,62 @@ StrictHostKeyChecking no
|
|||||||
{'domainName': self.domain, 'folders': folders})
|
{'domainName': self.domain, 'folders': folders})
|
||||||
except BaseException as msg:
|
except BaseException as msg:
|
||||||
return HttpResponse(str(msg))
|
return HttpResponse(str(msg))
|
||||||
|
|
||||||
|
def folderCheck(self):
|
||||||
|
domainPath = '/home/%s' % (self.domain)
|
||||||
|
vmailPath = '/home/vmail/%s' % (self.domain)
|
||||||
|
|
||||||
|
if self.folder == domainPath:
|
||||||
|
return 1
|
||||||
|
|
||||||
|
if self.folder == vmailPath:
|
||||||
|
return 1
|
||||||
|
|
||||||
|
website = Websites.objects.get(domain=self.domain)
|
||||||
|
|
||||||
|
for database in website.databases_set.all():
|
||||||
|
basePath = '/var/lib/mysql/'
|
||||||
|
dbPath = '%s%s' % (basePath, database.dbName)
|
||||||
|
|
||||||
|
if self.folder == dbPath:
|
||||||
|
return 1
|
||||||
|
|
||||||
|
return 0
|
||||||
|
|
||||||
|
def fetchFolderDetails(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()
|
||||||
|
|
||||||
|
|
||||||
|
gitPath = '%s/.git' % (self.folder)
|
||||||
|
|
||||||
|
command = 'ls -la %s' % (gitPath)
|
||||||
|
|
||||||
|
if ProcessUtilities.outputExecutioner(command).find('No such file or directory') > -1:
|
||||||
|
data_ret = {'status': 1, 'repo': 0}
|
||||||
|
json_data = json.dumps(data_ret)
|
||||||
|
return HttpResponse(json_data)
|
||||||
|
else:
|
||||||
|
data_ret = {'status': 1, 'repo': 1}
|
||||||
|
json_data = json.dumps(data_ret)
|
||||||
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
except BaseException as msg:
|
||||||
|
data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
|
||||||
|
json_data = json.dumps(data_ret)
|
||||||
|
return HttpResponse(json_data)
|
||||||
|
|||||||
Reference in New Issue
Block a user