Skip to content

Commit

Permalink
wip: show domain in other hds
Browse files Browse the repository at this point in the history
  • Loading branch information
frankiejol committed Feb 9, 2024
1 parent 35ab7c4 commit 6c23fe9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
25 changes: 16 additions & 9 deletions lib/Ravada/WebSocket.pm
Original file line number Diff line number Diff line change
Expand Up @@ -280,27 +280,34 @@ sub _list_domains_with_device($rvd,$row) {
push @domains, ($domain);
}
}
push @domains,( _list_domains_with_devices_locked($rvd, values %devices) );
for my $dev ( values %devices ) {
_get_domain_with_device($rvd, $dev);
}

$row->{_domains} = \@domains;
$row->{_bases} = \@bases;
$row->{devices} = [values %devices];
}

sub _list_domains_with_devices_locked($rvd, @devices) {
sub _get_domain_with_device($rvd, $dev) {
my $sql =
"SELECT d.id, d.name, d.is_base, d.status "
." FROM host_devices_domain_locked l, domains d "
." WHERE l.id_domain = d.id "
." AND ";
." AND l.name=?"
;

my $where = '';
for (@devices ) {
$where .= " OR " if $where;
$where .= " name = ? "
my $sth = $rvd->_dbh->prepare($sql);
$sth->execute($dev->{name});
my @domains;
while ( my ($id,$name,$is_base, $status, $is_locked, $device) = $sth->fetchrow ) {
$is_locked = 0 if !$is_locked || $status ne 'active';
$device = '' if !$device;
my $domain = { id => $id ,name => $name, is_locked => $is_locked
,is_base => $is_base ,device => $device
};
$dev->{domain} = $domain;# if $is_locked;
}
$sth = $rvd->_dbh->prepare($sql);
$sth->execute(@devices);
}

sub _list_requests($rvd, $args) {
Expand Down
2 changes: 1 addition & 1 deletion t/device/10_templates.t
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ sub test_frontend_list($vm) {
}
}
}
is($found,2) or exit;
is($found,2) or die Dumper($front_devices);
}

sub _mock_hd($vm, $path) {
Expand Down

0 comments on commit 6c23fe9

Please sign in to comment.