Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Projets publics
Ravada-Mirror
Commits
121cf51a
Commit
121cf51a
authored
Jul 17, 2019
by
Francesc Guasch
Browse files
Merge branch 'hotfix/0.4.6'
parents
19ea0399
64557493
Changes
3
Hide whitespace changes
Inline
Side-by-side
public/js/admin.js
View file @
121cf51a
...
...
@@ -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
;
...
...
rvd_front.pl
View file @
121cf51a
...
...
@@ -255,6 +255,11 @@ any '/new_machine' => sub {
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
;
...
...
templates/ng-templates/new_machine_other.html.ep
View file @
121cf51a
<div class="tab-pane fade" id="frommachine" role="tabpanel">
<div class="card-body">
<form class="form" method="post" action="/machine/copy">
<form name="new_machine_other_form"
role="form" method="post" action="/copy_machine" novalidate>
<div class="form-group row">
<input class="form-control" type="hidden" name="id_base" value="{{src_machine.id}}">
<label for="src_machine" class="col-xl-3 col-form-label"><%=l 'Source Machine' %></label>
...
...
@@ -8,8 +9,9 @@
<select class="form-control"
name ="src_machine"
ng-model="src_machine"
ng-options="item.name for item in base track by item.id"
ng-options="item.name for item in base
| orderBy:'name'
track by item.id
"
required=""
ng-change="get_machine_info(src_machine.id)"
></select>
</div>
</div>
...
...
@@ -21,10 +23,13 @@
</div>
<div class="form-group row">
<div class="col-xl-2">
<label class="col-xl-12 text-muted" for="copy_name
_{{src_machine.id}}
"><%=l 'Name' %>:</label>
<label class="col-xl-12 text-muted" for="copy_name"><%=l 'Name' %>:</label>
</div>
<div class="col-xl-10">
<input class="form-control" name="copy_name_{{src_machine.id}}" type="text" size="40"
<input class="form-control" name="copy_name" type="text" size="40"
ng-model="name"
ng-pattern ="/^[a-zA-Z0-9_-]+$/"
ng-change="validate_new_name()"
value="{{src_machine.name}}-copy">
<!-- todo check unique name -->
</div>
...
...
@@ -34,8 +39,10 @@
<label class="col-xl-12 text-muted" for="copy_ram">RAM (Gb):</label>
</div>
<div class="col-xl-2">
<input class="form-control" ng-model="ramsize" type="number" name="copy_ram"
min="1" max="4" required="">
<input class="form-control" ng-model="ramsize" type="text"
ng-pattern ="/^[0-9]+\.?[0-9]+$/"
name="copy_ram"
required="">
</div>
</div>
<div class="form-group row alert alert-warning"
...
...
@@ -44,11 +51,24 @@
prepared before it can be copied. This
process may take some minutes.
</div>
<div ng-show="name_duplicated" class="form-group row alert alert-danger"
role="alert">
<strong><%=l 'Error' %> : </strong> <%=l 'A machine with that name already exists.' %>
</div>
<div ng-show="new_machine_other_form.copy_name.$error.pattern"
class="form-group row alert alert-danger" role="alert">
<strong><%=l 'Error' %> : </strong> <%=l 'The machine name must contain only alphabetic, numbers, undercores and dashes.' %>
</div>
<div class="form-group row">
<button type="reset" class="btn btn-outline-secondary mr-2" onclick = "location='/admin/machines'"><%=l 'Cancel' %></button>
<input type="submit" class="btn btn-primary" value="<%=l 'Submit' %>">
<input type="submit" class="btn btn-primary" value="<%=l 'Submit' %>"
ng-disabled="new_machine_other_form.$invalid || name_duplicated"
>
</div>
</div>
</form>
</div>
</div>
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment