Commit 99698ee3 authored by joansp's avatar joansp
Browse files

Machines Status notifications

parent db21ee1b
......@@ -406,19 +406,19 @@ Returns a list of ruquests : ( id , domain_name, status, error )
sub list_requests {
my $self = shift;
my $sth = $CONNECTOR->dbh->prepare("SELECT id, args, status, error "
my $sth = $CONNECTOR->dbh->prepare("SELECT id, command, args, date_changed, status, error "
." FROM requests "
." WHERE status <> 'done' "
." ORDER BY date_changed DESC LIMIT 4"
);
$sth->execute;
my @reqs;
my ($id, $j_args, $status, $error);
$sth->bind_columns(\($id, $j_args, $status, $error));
my ($id, $command, $j_args, $date_changed, $status, $error);
$sth->bind_columns(\($id, $command, $j_args, $date_changed, $status, $error));
while ( $sth->fetch) {
my $args = decode_json($j_args) if $j_args;
push @reqs,{ id => $id, status => $status, error => $error , name => $args->{name}};
push @reqs,{ id => $id, command => $command, date_changed => $date_changed, status => $status, error => $error , name => $args->{name}};
}
$sth->finish;
return \@reqs;
......
......@@ -5,6 +5,7 @@
.directive("solShowNewmachine", swNewMach)
.directive("solShowListmachines", swListMach)
.directive("solShowCardsmachines", swCardsMach)
.directive("solShowMachinesNotifications", swMachNotif)
.service("request", gtRequest)
.service("listMach", gtListMach)
.controller("new_machine", newMachineCtrl)
......@@ -89,6 +90,13 @@
};
function swMachNotif() {
return {
restrict: "E",
templateUrl: '/templates/machines_notif.html',
};
}
function gtRequest($resource){
return $resource('/requests.json',{},{
......
<div class="panel-body">
<div class="col-lg-12">
<table class="table table-striped">
......@@ -6,7 +7,8 @@
<th>Machine Name</th>
<th>Base</th>
<th>Active</th>
<th colspan="2">Actions</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
......@@ -17,11 +19,13 @@
<td><a class="btn btn-primary btn-sm" href="/machine/view/{{machine.id}}.html">View</a>
<a ng-show="{{machine.is_base}}" class="btn btn-primary btn-sm" href="/machine/clone/{{machine.id}}.html">Clone</a>
<a ng-show="{{!machine.is_base}}" class="btn btn-primary btn-sm" href="/machine/prepare/{{machine.id}}.html">Prepare Base</a>
<a ng-show="{{machine.is_active}}" class="btn btn-warning btn-sm" href="/machine/shutdown/{{machine.id}}.html"><strong>&nbsp;<i class="fa fa-power-off" aria-hidden="true"></i></strong> ShutDown</a>
<a class="btn btn-danger btn-sm" href="/machine/remove/{{machine.id}}.html">Delete</a>
</td>
<td><a class="btn btn-danger btn-sm" href="/machine/remove/{{machine.id}}.html">X</a></td>
</tr>
</tbody>
</table>
</table>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">Machines Notifications<a style="float: right;" data-toggle="collapse" href="#collapse1"><i class="fa fa-angle-double-up" aria-hidden="true"></i></a> </h4>
</div>
<div id="collapse1" class="panel-collapse collapse in">
<div class="panel-body">
<ul style="padding: 25px; list-style: none">
<li ng-repeat="request in res">
<div ng-show="request.error != ''" class="alert alert-danger fade in">
<strong>Machine {{request.name}} -> {{request.command}}: </strong>Error: {{request.error}} {{request.date_changed | date:'MM/dd/yyyy @ h:mma'}}
</div>
<div ng-show="request.error == ''" class="alert alert-success fade in">
<strong>Machine {{request.name}} -> {{request.command}}: </strong>Status: {{request.status}} {{request.date_changed | date:'MM/dd/yyyy @ h:mma'}}
</div>
</li>
</ul>
</div>
</div>
</div>
......@@ -10,12 +10,17 @@
<div ng-controller="machines">
<div class="page-header">
<div class="panel panel-default">
<div class="panel-heading">
<h2>Machines List <button id="newMButton" style="float: right;" class="btn btn-success">New Machine</button></h2>
</div>
<sol-show-listmachines></sol-show-listmachines>
</div>
<div class="panel-heading">
<h2>Machines List <button id="newMButton" style="float: right;" class="btn btn-success">New Machine</button></h2>
</div>
<sol-show-listmachines></sol-show-listmachines>
</div>
</div>
<div class="page-header">
<sol-show-machines-notifications></sol-show-machines-notifications>
</div>
</div>
<div ng-controller="new_machine">
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment