Unverified Commit 0ce5fa71 authored by Francesc Guasch's avatar Francesc Guasch Committed by GitHub
Browse files

Refactor refresh storage (#1661)

refactor(frontend): refresh storage

Storage cache is cleaned and a refresh button is added in new machine form

issue #1660
parent b90e88bc
......@@ -2,10 +2,11 @@
**Implemented enhancements:**
- LDAP groups base [\#1637]
- German translation updated [\#1653]
- Chinese (Simplified) translation updated [\#1653]
**Refactor**
**Bugfixes**
- Access to clone private base [\#1652]
- Anonymous users created when no anonymous access defined [\#1590]
\ No newline at end of file
......@@ -3,7 +3,7 @@ package Ravada;
use warnings;
use strict;
our $VERSION = '1.1.0';
our $VERSION = '1.1.2';
use Carp qw(carp croak cluck);
use Data::Dumper;
......@@ -65,6 +65,8 @@ our %VALID_CONFIG = (
,ravada_posix_group => undef
,groups_base => undef
,field => undef
,server => undef
,port => undef
}
,log => undef
);
......@@ -4501,9 +4503,6 @@ sub _cmd_set_driver {
sub _cmd_refresh_storage($self, $request=undef) {
if ($request && ( my $recent = $request->done_recently(60))) {
die "Command ".$request->command." run recently by ".$recent->id."\n";
}
my $vm;
if ($request && $request->defined_arg('id_vm')) {
$vm = Ravada::VM->open($request->defined_arg('id_vm'));
......
......@@ -1250,6 +1250,10 @@ sub add_node($self,%arg) {
return $req->id;
}
sub _cache_delete($self, $key) {
delete $self->{cache}->{$key};
}
sub _cache_store($self, $key, $value, $timeout=60) {
$self->{cache}->{$key} = [ $value, time+$timeout ];
}
......
......@@ -168,6 +168,25 @@ ravadaApp.directive("solShowMachine", swMach)
});
};
$scope.refresh_storage = function() {
$scope.refresh_working = true;
$http.post('/request/refresh_storage/',
JSON.stringify({})
).then(function(response) {
if(response.status == 300 ) {
console.error('Response error', response.status);
}
setTimeout(function(){
$http.get('/iso_file.json').then(function(response) {
$scope.isos = response.data;
$scope.refresh_working = false;
});
}, 3000);
}
);
};
$http.get('/list_machines.json').then(function(response) {
$scope.base = response.data;
});
......
......@@ -226,6 +226,7 @@ sub do_start {
# Ravada::Request->enforce_limits();
#Ravada::Request->refresh_vms();
Ravada::Request->refresh_storage();
for (;;) {
my $t0 = time;
$ravada->process_priority_requests()
......
......@@ -2458,6 +2458,7 @@ sub new_machine {
}
} else {
my $req = Ravada::Request->refresh_storage();
$RAVADA->_cache_delete('list_isos');
# TODO handle possible errors
}
$c->stash(errors => \@error);
......
<div class="tab-pane fade show active" id="fromtemplate" role="tabpanel">
<div class="card-body">
<form name="new_machineForm" role="form" method="post" action="/new_machine.html" novalidate>
<div ng-show="!images">Loading... <i class="fas fa-sync-alt fa-spin"></i></div>
<form name="new_machineForm" role="form" method="post" action="/new_machine.html" novalidate ng-show="images">
<div class="form-group row">
<label for="backend" class="col-xl-3 col-form-label"><%=l 'Backend' %> <a
title="Choose the virtualization type of the Virtual Machine." ng-show="backends.length > 1"><i class="fa fa-info-circle"></i></a></label>
......@@ -44,14 +45,17 @@
<div class="from-group row" ng-show="id_iso.name">
<br/>
<label for="iso_file" class="col-xl-3 col-form-label"><%=l 'Select ISO' %> <a
title="Select the .iso file the machine will utilize when installing the OS." href="http://ravada.readthedocs.io/en/latest/docs/new_iso_image.html"><i class="fa fa-info-circle"></i></a></label>
title="Select the .iso file the machine will utilize when installing the OS." href="http://ravada.readthedocs.io/en/latest/docs/new_iso_image.html"><i class="fa fa-info-circle"></i></a>
<i class="badge badge-warning" ng-click="refresh_storage()"><i class="fa fa-sync-alt" aria-hidden="true"></i></i>
</label>
<div class="col-lg-9" ng-init="iso_file = '<NONE>'" >
<input type="text" class="form-control" placeholder="<%=l 'Type the ISO pathname' %>"
name="id_file"
ng-model="id_file"
ng-hide="refresh_working || !isos"
required=""
uib-typeahead="item for item in getVisualizableObjects($viewValue, isos)"
typeahead-min-length="0">
typeahead-min-length="0"/>
</div>
</div>
</div>
......
Markdown is supported
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