From 64557493ea4839a4db431f948a0219ab0c491aa0 Mon Sep 17 00:00:00 2001 From: Francesc Guasch Date: Wed, 17 Jul 2019 12:11:43 +0200 Subject: [PATCH] fix(frontend); new machine from other - The submission sub was used by copy machine that expected json arguments. - Slightly improved the form with check patterns issue #1112 --- public/js/admin.js | 10 ++++++ rvd_front.pl | 23 +++++++++++++ .../ng-templates/new_machine_other.html.ep | 34 +++++++++++++++---- 3 files changed, 60 insertions(+), 7 deletions(-) diff --git a/public/js/admin.js b/public/js/admin.js index e35a8c557..7873228cd 100644 --- a/public/js/admin.js +++ b/public/js/admin.js @@ -99,6 +99,16 @@ ravadaApp.directive("solShowMachine", swMach) $scope.seeswap = !($scope.seeswap); }; + $scope.get_machine_info = function(id) { + $http.get('/machine/info/'+id+'.json') + .then( function(response) { + $scope.machine = response.data; + $scope.ramsize = ($scope.machine.max_mem / 1024 / 1024); + if ( $scope.ramsize <1 ) { + $scope.ramsize = 1; + } + }); + }; $http.get('/list_machines.json').then(function(response) { $scope.base = response.data; diff --git a/rvd_front.pl b/rvd_front.pl index c86eadf61..c63081077 100644 --- a/rvd_front.pl +++ b/rvd_front.pl @@ -255,6 +255,11 @@ return new_machine($c); }; +any '/copy_machine' => sub { + my $c = shift; + return new_machine_copy($c); +}; + get '/domain/new.html' => sub { my $c = shift; @@ -2090,6 +2095,24 @@ sub copy_machine { return $c->render(json => { request => [map { $_->id } @ reqs ] } ); } +sub new_machine_copy($c) { + my $id_base = $c->param('src_machine'); + my $copy_name = $c->param('copy_name'); + + my $ram = $c->param('copy_ram'); + $ram = 0 if !$ram || $ram !~ /^\d+(\.\d+)?$/; + $ram = int($ram*1024*1024); + + my $req = Ravada::Request->clone( + uid => $USER->id + ,id_domain => $id_base + ,name => $copy_name + ,memory => $ram + ); + + return $c->redirect_to("/admin/machines"); +} + sub copy_machine_many($base, $number, $create_args) { my $domains = $RAVADA->list_domains; my %domain_exists = map { $_->{name} => 1 } @$domains; diff --git a/templates/ng-templates/new_machine_other.html.ep b/templates/ng-templates/new_machine_other.html.ep index 554f6d26b..9edea8dc9 100644 --- a/templates/ng-templates/new_machine_other.html.ep +++ b/templates/ng-templates/new_machine_other.html.ep @@ -1,6 +1,7 @@
-
+
@@ -8,8 +9,9 @@
@@ -21,10 +23,13 @@
- +
-
@@ -34,8 +39,10 @@
- +
+ + + +
- +
+