Merge branch 'feature/GS-6'
This commit is contained in:
commit
8dceacd495
15
js/site.js
15
js/site.js
|
@ -45,9 +45,12 @@ $(document).ready(function() {
|
|||
$("#ajax_loader").hide();
|
||||
$('#resultmodal').modal('show');
|
||||
});
|
||||
});
|
||||
$("body").on("change", ".input[name=url]", function() {
|
||||
$(".label[for=expected]").html("Capture services after reboot? (1: yes; 0: no)");
|
||||
$(".input[name=url]").attr("placeholder", "1");
|
||||
})
|
||||
});
|
||||
});
|
||||
$("body").on("focusout", "input[name=url]", function() {
|
||||
if($("input[name=url]").val() == "reboot") {
|
||||
$("label[for=expected]").html("Capture services after reboot? (1: yes; 0: no)");
|
||||
$("input[name=expected]").attr("placeholder", "1");
|
||||
}
|
||||
});
|
||||
$("input[name=url]").focusout();
|
||||
});
|
12
runs.php
12
runs.php
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2017 Jeroen De Meerleer <me@jeroened.be>.
|
||||
* Copyright 2017-2018 Jeroen De Meerleer <me@jeroened.be>.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -26,7 +26,7 @@
|
|||
|
||||
require_once "include/initialize.inc.php";
|
||||
|
||||
$jobnameqry = $db->prepare("SELECT name, user FROM jobs WHERE jobID = ?");
|
||||
$jobnameqry = $db->prepare("SELECT name, user, url FROM jobs WHERE jobID = ?");
|
||||
$jobnameqry->execute(array($_GET['jobID']));
|
||||
$jobnameResult = $jobnameqry->fetchAll(PDO::FETCH_ASSOC);
|
||||
if ($jobnameResult[0]["user"] != $_SESSION["userID"]) {
|
||||
|
@ -34,8 +34,9 @@ if ($jobnameResult[0]["user"] != $_SESSION["userID"]) {
|
|||
exit;
|
||||
}
|
||||
$jobName = $jobnameResult[0]['name'];
|
||||
$rebootjob = $jobnameResult[0]['url'] == 'reboot' ? true : false;
|
||||
|
||||
$runsForJobQry = "SELECT runs.*, jobs.name FROM runs, jobs WHERE runs.job = jobs.jobID AND runs.job = ?";
|
||||
$runsForJobQry = "SELECT runs.*, jobs.jobID FROM runs, jobs WHERE runs.job = jobs.jobID AND runs.job = ?";
|
||||
$allruns = true;
|
||||
if(!(isset($_GET['allruns']) && $_GET['allruns'] == 1)) {
|
||||
$runsForJobQry .= " AND runs.statuscode <> jobs.expected";
|
||||
|
@ -48,9 +49,6 @@ $runsForJobResult = $runsForJob->fetchAll(PDO::FETCH_ASSOC);
|
|||
$loader = new Twig_Loader_Filesystem('templates');
|
||||
$twig = new Twig_Environment($loader, array('cache' => 'cache', "debug" => true));
|
||||
|
||||
//var_dump($alljobsResult);
|
||||
//exit;
|
||||
|
||||
$runsForJobRendered = array();$count = 0;
|
||||
foreach($runsForJobResult as $key=>$value) {
|
||||
$runsForJobRendered[$count]["runID"] = $value["runID"];
|
||||
|
@ -61,7 +59,7 @@ foreach($runsForJobResult as $key=>$value) {
|
|||
$count++;
|
||||
}
|
||||
|
||||
$twig_vars = array('jobID' => $_GET['jobID'], 'runs' => $runsForJobRendered, 'allruns' => $allruns, "title" => $jobName);
|
||||
$twig_vars = array('jobID' => $_GET['jobID'], 'rebootjob' => $rebootjob, 'runs' => $runsForJobRendered, 'allruns' => $allruns, "title" => $jobName);
|
||||
|
||||
//echo $twig->render('overview.html.twig', array('the' => 'variables', 'go' => 'here'));
|
||||
echo $twig->render('runs.html.twig', $twig_vars);
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
{% block title %}Overview of run for {{ title }}{% endblock %}
|
||||
{% block content %}
|
||||
<h2>Overview of runs for {{ title }}</h2>
|
||||
{% if allruns %}
|
||||
{% if rebootjob %}
|
||||
{% elseif allruns %}
|
||||
<p><a href="runs.php?jobID={{ jobID }}&allruns=0">Only show failed runs</a></p>
|
||||
{% elseif not allruns %}
|
||||
<p><a href="runs.php?jobID={{ jobID }}&allruns=1">Show all runs</a></p>
|
||||
|
@ -12,7 +13,7 @@
|
|||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title">
|
||||
<a data-toggle="collapse" data-parent="#accordion" href="#collapse{{ loop.index }}">({{ run.statuscode }}) {{ run.timestamp }}</a>
|
||||
<a data-toggle="collapse" data-parent="#accordion" href="#collapse{{ loop.index }}">{% if not rebootjob %}({{ run.statuscode }}){% endif %} {{ run.timestamp }}</a>
|
||||
</h4>
|
||||
</div>
|
||||
<div id="collapse{{ loop.index }}" class="panel-collapse collapse">
|
||||
|
|
14
webcron.php
14
webcron.php
|
@ -40,15 +40,13 @@ if (file_exists("cache/get-services.trigger")) {
|
|||
$rebootjobs = unserialize(file_get_contents("cache/get-services.trigger"));
|
||||
|
||||
foreach($rebootjobs as $job) {
|
||||
if($job['expected'] != 0) {
|
||||
$services = array();
|
||||
$url = "ssh " . $job['host'] . " '" . "sudo systemctl list-units | cat" . "' 2>&1";
|
||||
exec($url, $services);
|
||||
$services = implode("\n", $services);
|
||||
$services = array();
|
||||
$url = "ssh " . $job['host'] . " '" . "sudo systemctl list-units | cat" . "' 2>&1";
|
||||
exec($url, $services);
|
||||
$services = implode("\n", $services);
|
||||
|
||||
$stmt = $db->prepare("INSERT INTO runs(job, statuscode, result, timestamp) VALUES(?, ?, ?, ?)");
|
||||
$stmt->execute(array($job['jobID'], '200', $services, time()));
|
||||
}
|
||||
$stmt = $db->prepare("INSERT INTO runs(job, statuscode, result, timestamp) VALUES(?, ?, ?, ?)");
|
||||
$stmt->execute(array($job['jobID'], '0', $services, time()));
|
||||
}
|
||||
unlink("cache/get-services.trigger");
|
||||
unlink("cache/reboot-time.trigger");
|
||||
|
|
Loading…
Reference in New Issue
Block a user