Commit 48456740 authored by Francesc Guasch's avatar Francesc Guasch
Browse files

Merge branch 'master' of https://github.com/UPC/ravada

parents 0c2a1aa6 1055bc0e
......@@ -295,32 +295,32 @@ sub _update_domain_drivers_types($self) {
id => 4,
,name => 'image'
,description => 'Graphics Options'
,vm => 'qemu'
,vm => 'KVM'
},
jpeg => {
id => 5,
,name => 'jpeg'
,description => 'Graphics Options'
,vm => 'qemu'
,vm => 'KVM'
},
zlib => {
id => 6,
,name => 'zlib'
,description => 'Graphics Options'
,vm => 'qemu'
,vm => 'KVM'
},
playback => {
id => 7,
,name => 'playback'
,description => 'Graphics Options'
,vm => 'qemu'
,vm => 'KVM'
},
streaming => {
id => 8,
,name => 'streaming'
,description => 'Graphics Options'
,vm => 'qemu'
,vm => 'KVM'
}
};
......
......@@ -1468,14 +1468,16 @@ sub drivers {
_init_connector();
$type = 'qemu' if $type =~ /^KVM$/;
my $type2 = $type;
$type2 = 'KVM' if $type =~ /qemu/;
$type2 = 'qemu' if $type =~ /KVM;/;
my $query = "SELECT id from domain_drivers_types "
." WHERE vm=?";
." WHERE (vm=? or vm=?)";
$query .= " AND name=?" if $name;
my $sth = $$CONNECTOR->dbh->prepare($query);
my @sql_args = ($type);
my @sql_args = ($type,$type2);
push @sql_args,($name) if $name;
$sth->execute(@sql_args);
......
......@@ -186,7 +186,7 @@ sub list_domains {
my $self = shift;
my %args = @_;
my $query = "SELECT name, id, id_base, is_base FROM domains ORDER BY name";
my $query = "SELECT name, id, id_base, is_base FROM domains ";
my $where = '';
for my $field ( sort keys %args ) {
......@@ -195,7 +195,7 @@ sub list_domains {
}
$where = "WHERE $where" if $where;
my $sth = $CONNECTOR->dbh->prepare("$query $where");
my $sth = $CONNECTOR->dbh->prepare("$query $where ORDER BY name");
$sth->execute(map { $args{$_} } sort keys %args);
my @domains = ();
......
......@@ -169,8 +169,8 @@
$scope.validate_new_name = function(old_name) {
$scope.new_name_duplicated = false;
if(!$scope.new_name || old_name == $scope.new_name) {
$scope.new_name_invalid=true;
if(old_name == $scope.new_name) {
$scope.new_name_invalid=false;
return;
}
var valid_domain_name = /^[a-zA-Z][\w_-]+$/;
......@@ -194,6 +194,9 @@
//On load code
$scope.showmachineId = window.location.pathname.split("/")[3].split(".")[0] || -1 ;
$http.get('/machine/info/'+$scope.showmachineId+'.json').then(function(response) {
$scope.showmachine=response.data;
});
// $scope.getSingleMachine();
// $scope.updatePromise = $interval($scope.getSingleMachine,3000);
};
......
......@@ -438,8 +438,7 @@ get '/machine/rename/#id/#value' => sub {
any '/machine/copy' => sub {
my $c = shift;
return access_denied($c) if !$USER -> can_copy();
# return access_denied($c) if !$USER -> can_clone_all();
return access_denied($c) if !$USER -> can_clone_all();
return copy_machine($c);
};
......
......@@ -72,6 +72,8 @@ sub test_drivers_type {
isa_ok(\@drivers,'ARRAY');
my $driver_type = $domain->drivers($type);
ok($driver_type,"[$vm_name] Expecting a driver type $type") or return;
isa_ok($driver_type, "Ravada::Domain::Driver") or return;
my $value = $driver_type->get_value();
is($value,undef,"Expecting no value for $type");
......
......@@ -7,7 +7,7 @@
% if ($USER->can_change_settings && $domain->drivers) {
<li class="nav"><a href="#drivers" data-toggle="tab">Drivers</a></li>
% }
% if ($domain->type eq 'KVM') {
% if ($domain->drivers) {
<li class="nav"><a href="#graphics" data-toggle="tab">Graphics</a></li>
% }
% if ($USER->can_clone_all){
......
......@@ -11,7 +11,10 @@
</div>
<div class="col-md-10">
<input class="form-control" name="copy_name_{{showmachine.id}}" type="text" size="40"
value="{{showmachine.name}}-copy">
value="{{showmachine.name}}-copy"
ng-model="new_name"
ng-change="validate_new_name(showmachine.name)"
>
<!-- todo check unique name -->
</div>
</div>
......@@ -23,9 +26,23 @@
<input class="form-control" name="copy_ram" type="text" size="3" value="1">
</div>
</div>
<input type="submit">
<input type="submit" class="btn btn-default"
ng-disabled="new_name_duplicated || new_name_invalid || new_name === showmachine.name"
>
<button type="reset">Cancel</button>
</form>
<div class="form-group has-error">
<label ng-show="new_name_duplicated"
class="control-label" for="new_name">
This name is duplicated
</label>
<label ng-show="new_name_invalid"
class="control-label" for="new_name">
This name is invalid. It can only contain words and numbers
and must start by a letter.
</label>
</div>
</div>
</div>
......@@ -5,11 +5,9 @@
</div>
% }
% my $driver = $domain->drivers("image");
% my ($first, $second) = $driver->get_options();
<div ng-show="<%= !defined ($domain->get_driver("image")) %>" class="alert alert-danger">
<strong>This machine has not Graphics parameters!</strong>
</div>
% my %recomend = (
% image => 'auto_glz'
% ,jpeg => 'auto'
......@@ -22,7 +20,7 @@
</div>
<form class="form-horizontal" action="<%= $action %>" method="post">
% for my $driver_name (qw(image jpeg zlib playback streaming)) {
% my $driver = $domain->drivers($driver_name);
% my $driver = $domain->drivers($driver_name) or next;
<div class="row">
<div class="col-md-2">
......
......@@ -4,7 +4,7 @@
% $message_rename = 'This VM is running and can\'t be renamed.';
% $disable_rename = 1;
% }
% if ( $domain->is_hibernated ) {
% if ( $domain->is_hibernated) {
% $message_rename = 'This VM has a saved hybernated state and can\'t be renamed.';
% $disable_rename = 1;
% }
......
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