C'est joli <3
This commit is contained in:
parent
11bab4d60b
commit
73f3b226d2
7
ajax.php
7
ajax.php
@ -4,6 +4,7 @@ require_once 'config/config.php';
|
||||
require_once 'config/color.php';
|
||||
require_once 'Net/SSH2.php';
|
||||
global $servers;
|
||||
$gitstatus = 'git fetch && git status';
|
||||
|
||||
if (!empty($_POST['section'])) {
|
||||
foreach ($servers as $ssh) {
|
||||
@ -18,12 +19,12 @@ if (!empty($_POST['action'])) {
|
||||
$session = new Net_SSH2($config['host'], $config['port']);
|
||||
if ($session->login($config['user'], $config['pass'])) {
|
||||
if ($_POST['action'] == 'status') {
|
||||
echo ansi2html($session->exec('cd ' . $config['path'] . ' && git fetch && git status'));
|
||||
echo ansi2html($session->exec('cd ' . $config['path'] . ' && ' . $gitstatus));
|
||||
} else if ($_POST['action'] == 'push') {
|
||||
$message = empty($_POST['message']) ? 'FTP' : $_POST['message'];
|
||||
//echo $session->exec('cd ' . $config['path'] . ' && git add -A && git commit -m "' . $message . '" && git push');
|
||||
//echo $session->exec('cd ' . $config['path'] . ' && git add -A && git commit -m "' . $message . '" && git push && ' . $gitstatus);
|
||||
} else if ($_POST['action'] == 'pull') {
|
||||
//echo $session->exec('cd ' . $config['path'] . ' && git pull');
|
||||
//echo $session->exec('cd ' . $config['path'] . ' && git pull && ' . $gitstatus);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,21 +1,25 @@
|
||||
.btn-group > .btn:first-child {
|
||||
.btn-group .btn:first-child {
|
||||
border-bottom-left-radius: 0;
|
||||
}
|
||||
|
||||
.btn-group > .btn:last-child {
|
||||
.btn-group .btn:last-child, .input-prepend input {
|
||||
border-bottom-right-radius: 0;
|
||||
}
|
||||
|
||||
.btn-group > .btn {
|
||||
.btn-group .btn {
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.btn-group .input-prepend .btn {
|
||||
border-left: 0;
|
||||
}
|
||||
|
||||
.label {
|
||||
position: relative;
|
||||
bottom: 4px;
|
||||
}
|
||||
|
||||
pre {
|
||||
pre, .btn-group .input-prepend .btn {
|
||||
border-top-left-radius: 0;
|
||||
}
|
||||
|
||||
@ -33,3 +37,9 @@ pre {
|
||||
background-repeat: no-repeat;
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
.input-prepend {
|
||||
margin-bottom: 0;
|
||||
position: relative;
|
||||
top: 1px;
|
||||
}
|
||||
|
@ -35,9 +35,12 @@ global $servers;
|
||||
<section id="<?php echo $id; ?>">
|
||||
<h3><?php echo $param['title']; ?> <span class="label"></span></h3>
|
||||
<div class="btn-group">
|
||||
<button class="btn" onclick="status('<?php echo $id; ?>');"><i class="icon-refresh"></i> Status</button>
|
||||
<button class="btn" onclick="push('<?php echo $id; ?>');"><i class="icon-arrow-up"></i> Push</button>
|
||||
<button class="btn" onclick="pull('<?php echo $id; ?>');"><i class="icon-arrow-down"></i> Pull</button>
|
||||
<button class="btn" onclick="callRequest('status', '<?php echo $id; ?>');"><i class="icon-refresh"></i> Status</button>
|
||||
<button class="btn" onclick="callRequest('pull', '<?php echo $id; ?>');"><i class="icon-arrow-down"></i> Pull</button>
|
||||
<div class="input-prepend">
|
||||
<button class="btn" type="button"><i class="icon-arrow-up"></i> Push</button>
|
||||
<input type="text" name="message" placeholder="Commit message">
|
||||
</div>
|
||||
</div>
|
||||
<pre></pre>
|
||||
</section>
|
||||
|
29
js/app.js
29
js/app.js
@ -1,20 +1,43 @@
|
||||
window.addEventListener('load', function() {
|
||||
var sections = document.querySelectorAll('section');
|
||||
for (var i = 0; i < sections.length; i++) {
|
||||
callRequest(sections[i].id);
|
||||
callRequest('status', sections[i].id);
|
||||
}
|
||||
});
|
||||
|
||||
function callRequest(section) {
|
||||
function callRequest(action, section, message) {
|
||||
var pre = document.querySelector('#' + section + ' pre');
|
||||
pre.innerHTML = '<span class="loading">Loading ...</span>';
|
||||
|
||||
var label = document.querySelector('#' + section + ' .label');
|
||||
label.classList.remove('label-success');
|
||||
label.classList.remove('label-important');
|
||||
label.classList.add('label-warning');
|
||||
label.innerHTML = 'Loading';
|
||||
|
||||
message = typeof(message) !== 'undefined' ? message : 'FTP';
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('POST', 'ajax.php');
|
||||
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
||||
xhr.send('action=status§ion=' + section);
|
||||
xhr.send('action=' + action + '§ion=' + section + '&message=' + message);
|
||||
xhr.onreadystatechange = function() {
|
||||
if (xhr.readyState === 4 && (xhr.status === 200 || xhr.status === 0)) {
|
||||
pre.innerHTML = xhr.responseText;
|
||||
|
||||
var splitLabel = xhr.responseText.split("\n").reverse();
|
||||
label.classList.remove('label-warning');
|
||||
if (splitLabel[1] !== 'nothing to commit (working directory clean)') {
|
||||
label.classList.add('label-important');
|
||||
label.innerHTML = 'Update needed';
|
||||
} else {
|
||||
label.classList.add('label-success');
|
||||
label.innerHTML = 'OK';
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function push(section) {
|
||||
//callRequest('push', section, document.getElementById('message').value);
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user