Skip to content

Commit

Permalink
fix: improved open ports section on start (#1884)
Browse files Browse the repository at this point in the history
  • Loading branch information
frankiejol authored Nov 9, 2022
1 parent e4e66fc commit 67eb099
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 21 deletions.
14 changes: 9 additions & 5 deletions public/js/ravada.js
Original file line number Diff line number Diff line change
Expand Up @@ -1168,25 +1168,28 @@
}
}
});
if ($scope.domain && $scope.domain.is_active && $scope.request.status == 'done') {
if ($scope.request_open_ports && $scope.domain && $scope.domain.ip && $scope.domain.requests == 0) {
$scope.request_open_ports_done = true;
}

if ($scope.domain && $scope.domain.is_active && $scope.request.status == 'done' && $scope.domain.requests == 0 && (!$scope.open_ports || $scope.request_open_ports_done) && $scope.redirect_time--<0) {
$scope.redirect();
if ($scope.auto_view && !redirected_display && $scope.domain_display[0]
&& $scope.domain_display[0].file_extension
&& $scope.domain.ports.length==0
&& !$scope.domain_display[0].password) {
location.href='/machine/display/'+$scope.domain_display[0].driver+"/"
+$scope.domain.id+"."+$scope.domain_display[0].file_extension;
redirected_display=true;
}
}
if ($scope.request_open_ports && $scope.domain && $scope.domain.ip && $scope.domain.requests == 0) {
$scope.request_open_ports_done = true;
}

}
}

$scope.reload_ports = function() {
$scope.request_open_ports_done = false;
$scope.redirect_time=2;
$scope.domain.requests=-1;
$http.post('/request/close_exposed_ports/'
,JSON.stringify(
{ 'id_domain': $scope.domain.id})
Expand All @@ -1213,6 +1216,7 @@
$scope.redirect_done = false;
//$scope.wait_request();
$scope.view_clicked=false;
$scope.redirect_time = 1;
};
// list users
function usersCrtl($scope, $http, request, listUsers) {
Expand Down
12 changes: 0 additions & 12 deletions script/rvd_front
Original file line number Diff line number Diff line change
Expand Up @@ -2745,7 +2745,6 @@ sub provision_req($c, $id_base, $name, $ram=0, $disk=0) {
, remote_ip => _remote_ip($c)
)
}
$name = _new_domain_name($name);
}

app->log->info($USER->name." requesting create_domain ".$name." from "._remote_ip($c))
Expand All @@ -2762,17 +2761,6 @@ sub provision_req($c, $id_base, $name, $ram=0, $disk=0) {

}

sub _new_domain_name {
confess;
my $name = shift;
my $count = 1;
my $name2;
for ( ;; ) {
$name2 = "$name-".++$count;
return $name2 if !$RAVADA->domain_exists($name2);
}
}

sub run_request($c, $request, $anonymous = 0) {
my $timeout = $SESSION_TIMEOUT;
$timeout = $SESSION_TIMEOUT_ADMIN if $USER->is_admin;
Expand Down
8 changes: 4 additions & 4 deletions templates/main/run_request.html.ep
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@
</h3>
<div>
<button
ng-show="request_open_ports && request_open_ports_done"
ng-show="request_open_ports && domain.requests==0"
ng-click="reload_ports()"
><%=l 'reopen' %></button>
<small>
<i ng-hide="request_open_ports && request_open_ports_done"
class="fas fa-sync-alt fa-spin"></i>
<i ng-hide="domain.requests==0"
class="fas fa-sync-alt fa-spin"></i>
</small>
</div>
</div>
Expand Down Expand Up @@ -91,7 +91,7 @@
</div><!-- domain is active -->
<div>
<div class="panel-body">
<div ng-show="request.error && (!defined domain || !domain.is_active)">{{request.error}}</div>
<div ng-show="request && request.error && (!domain || !domain.is_active)">{{request.error}}</div>
<div ng-show="domain && request.status == 'done' && (!domain || domain.is_active == 0) && count_start>2"><%=l 'The machine is down.' %>
<button type="submit" class="btn btn-primary" onclick="location.reload('forceGet')"><%=l 'Start again' %></button>
</div>
Expand Down

0 comments on commit 67eb099

Please sign in to comment.