Commit 5b0070b3 authored by joansp's avatar joansp
Browse files

Machines list final style and get req

parent 124ac04c
......@@ -156,7 +156,7 @@ sub _check_has_clones {
}
sub _check_free_memory{
die "No free memory" if !( (freemem() / 1024) < 500000 );
# die "No free memory" if !( (freemem() / 1024) < 500000 );
}
sub _check_disk_modified {
......
......@@ -407,6 +407,8 @@ sub is_paused {
my $self = shift;
my ($state, $reason) = $self->domain->get_state();
return 0 if $state == 1;
#TODO, find out which one of those id "1" and remove it from this list
#
......
......@@ -97,6 +97,21 @@
$http.get(toGet);
};
$scope.pause = function(machineId){
var toGet = '/machine/pause/'+machineId+'.json';
$http.get(toGet);
};
$scope.resume = function(machineId){
var toGet = '/machine/resume/'+machineId+'.json';
$http.get(toGet);
};
$scope.start = function(machineId){
var toGet = '/machine/start/'+machineId+'.json';
$http.get(toGet);
};
};
function swListMach() {
......
......@@ -16,16 +16,30 @@
<td>
<a data-toggle="modal" data-target="#modal{{machine.id}}">{{machine.name}}</a>
</td>
<td><i ng-show="{{machine.is_base}}" class="fa fa-check" aria-hidden="true"></i><i ng-hide="{{machine.is_base}}" class="fa fa-times" aria-hidden="true"></i></td>
<td><i ng-show="{{machine.is_active}}" class="fa fa-check" aria-hidden="true"></i><i ng-show="{{!machine.is_active}}" class="fa fa-times" aria-hidden="true"></i></td>
<td>
<i ng-show="{{machine.is_base}}" class="fa fa-check" aria-hidden="true"></i>
<a ng-hide="{{machine.is_base}}" ng-click="prepare(machine.id)" href=""><i class="fa fa-times" aria-hidden="true"></i></a>
</td>
<td>
<a ng-show="{{machine.is_active}}" ng-click="shutdown(machine.id)"><i class="fa fa-check" aria-hidden="true"></i></a>
<a ng-show="{{!machine.is_active}}" ng-click="start(machine.id)"><i class="fa fa-times" aria-hidden="true"></i></td></a>
<td>
<a class="btn btn-primary btn-sm" href="/machine/manage/{{machine.id}}.html">Manage</a>
<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>
<button type="button" ng-click="screenshot(machine.id)" ng-show="{{machine.is_active}}" class="btn btn-primary btn-sm">Screenshot</button>
<button type="button" ng-click="prepare(machine.id)" ng-hide="{{machine.is_base}}" class="btn btn-primary btn-sm">Prepare Base</button>
<button type="button" ng-click="shutdown(machine.id)" ng-show="{{machine.is_active}}" class="btn btn-warning btn-sm"></strong> ShutDown</button>
<a class="btn btn-primary btn-sm" href="/machine/view/{{machine.id}}.html"><i class="fa fa-desktop" aria-hidden="true"></i>&nbsp View</a>
<a ng-show="{{machine.is_base}}" class="btn btn-primary btn-sm" href="/machine/clone/{{machine.id}}.html"><i class="fa fa-files-o" aria-hidden="true"></i>&nbsp Clone</a>
<button type="button" ng-click="screenshot(machine.id)" ng-show="{{machine.is_active}}" class="btn btn-primary btn-sm"><i class="fa fa-camera" aria-hidden="true"></i>&nbspScreenshot</button>
<button type="button" ng-click="shutdown(machine.id)" ng-show="{{machine.is_active}}" class="btn btn-warning btn-sm"></strong><i class="fa fa-power-off" aria-hidden="true"></i>&nbsp ShutDown</button>
<i id="spinn{{machine.id}}" class="fa fa-spinner fa-spin fa-fw" style="float: right; display: none;"></i>
<span style="float:right;" ng-show="{{machine.is_paused && machine.is_active}}" class="label label-warning">Paused</span>
</td>
</tr>
......@@ -44,13 +58,35 @@
</h4>
</div>
<div class="modal-body">
<img src="/img/screenshots/6.png" width="400" alt="No screenshot avaiable for this machine">
<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_active}}" class="btn btn-primary btn-sm" href="/machine/screenshot/{{machine.id}}.html">Screenshot</a>
<a 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" ng-click="shutdown(machine.id)"><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"><strong>&nbsp;<i class="fa fa-trash-o" aria-hidden="true"></i></strong> Delete</a>
<div style="width:100%; margin-bottom:10px;">
<img src="/img/screenshots/6.png" width="400" alt="No screenshot avaiable for this machine">
</div>
<div style="width:100%; margin-bottom:10px;">
<a class="btn btn-primary btn-sm" href="/machine/view/{{machine.id}}.html"><i class="fa fa-desktop" aria-hidden="true"></i>&nbsp View</a>
<button type="button" ng-click="start(machine.id)" ng-hide="{{machine.is_active}}" class="btn btn-success btn-sm"><i class="fa fa-play" aria-hidden="true"></i>&nbsp Start</button>
<button type="button" ng-click="resume(machine.id)" ng-show="{{machine.is_active && machine.is_paused}}" class="btn btn-success btn-sm"><i class="fa fa-repeat" aria-hidden="true"></i>&nbsp Resume</button>
<button type="button" ng-click="pause(machine.id)" ng-show="{{machine.is_active && !machine.is_paused}}" class="btn btn-success btn-sm"><i class="fa fa-pause" aria-hidden="true"></i>&nbsp Pause</button>
</div>
<div style="width:100%; margin-bottom:10px;">
<a ng-show="{{machine.is_base}}" class="btn btn-primary btn-sm" href="/machine/clone/{{machine.id}}.html"><i class="fa fa-files-o" aria-hidden="true"></i>&nbsp Clone</a>
<button type="button" ng-click="prepare(machine.id)" ng-hide="{{machine.is_base}}" class="btn btn-primary btn-sm"><i class="fa fa-plus" aria-hidden="true"></i>&nbsp Prepare Base</button>
<button type="button" ng-click="screenshot(machine.id)" ng-show="{{machine.is_active}}" class="btn btn-primary btn-sm"><i class="fa fa-camera" aria-hidden="true"></i>&nbsp Screenshot</button>
<button type="button" ng-click="shutdown(machine.id)" ng-show="{{machine.is_active}}" class="btn btn-warning btn-sm"></strong><i class="fa fa-power-off" aria-hidden="true"></i>&nbsp ShutDown</button>
<a class="btn btn-danger btn-sm" href="/machine/remove/{{machine.id}}.html"><strong>&nbsp;<i class="fa fa-trash-o" aria-hidden="true"></i></strong> Delete</a>
</div>
</div>
<div class="modal-footer">
......
......@@ -227,6 +227,20 @@ get '/machine/screenshot/*.json' => sub {
return screenshot_machine($c);
};
get '/machine/pause/*.json' => sub {
my $c = shift;
return pause_machine($c);
};
get '/machine/resume/*.json' => sub {
my $c = shift;
return resume_machine($c);
};
get '/machine/start/*.json' => sub {
my $c = shift;
return start_machine($c);
};
##############################################
#
......@@ -720,8 +734,8 @@ sub shutdown_machine {
my $c = shift;
return login($c) if !_logged_in($c);
my ($base, $type) = _search_requested_machine($c);
my $req = Ravada::Request->shutdown_domain(name => $base->name, uid => $USER->id);
my ($domain, $type) = _search_requested_machine($c);
my $req = Ravada::Request->shutdown_domain(name => $domain->name, uid => $USER->id);
return $c->redirect_to('/machines') if $type eq 'html';
return $c->render(json => { req => $req->id });
......@@ -772,8 +786,7 @@ sub screenshot_machine {
id_domain => $domain->id
,filename => $file_screenshot
);
$c->render(template => 'bootstrap/machines');
$c->render(json => { request => $req->id});
}
sub prepare_machine {
......@@ -801,8 +814,38 @@ sub prepare_machine {
,uid => $USER->id
);
$c->render(template => 'bootstrap/machines');
$c->render(json => { request => $req->id});
}
sub start_machine {
my $c = shift;
return login($c) if !_logged_in($c);
my ($domain, $type) = _search_requested_machine($c);
my $req = Ravada::Request->start_domain(name => $domain->name, uid => $USER->id);
return $c->render(json => { req => $req->id });
}
sub pause_machine {
my $c = shift;
return login($c) if !_logged_in($c);
my ($domain, $type) = _search_requested_machine($c);
my $req = Ravada::Request->pause_domain(name => $domain->name, uid => $USER->id);
return $c->render(json => { req => $req->id });
}
sub resume_machine {
my $c = shift;
return login($c) if !_logged_in($c);
my ($domain, $type) = _search_requested_machine($c);
my $req = Ravada::Request->resume_domain(name => $domain->name, uid => $USER->id);
return $c->render(json => { req => $req->id });
}
sub list_requests {
......
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