Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Projets publics
Ravada-Mirror
Commits
a09b9992
Commit
a09b9992
authored
Dec 20, 2017
by
joelalju
Browse files
[#404] "Set base picture" button implemented. The base doesn't have the screenshot buttons.
parent
cc9ce163
Changes
4
Hide whitespace changes
Inline
Side-by-side
lib/Ravada.pm
View file @
a09b9992
...
...
@@ -8,6 +8,7 @@ our $VERSION = '0.2.10';
use
Carp
qw(carp croak)
;
use
Data::
Dumper
;
use
DBIx::
Connector
;
use
File::
Copy
;
use
Hash::
Util
qw(lock_hash)
;
use
Moose
;
use
POSIX
qw(WNOHANG)
;
...
...
@@ -1487,6 +1488,28 @@ sub _cmd_screenshot {
$request
->
error
("
No data received
")
if
!
$bytes
;
}
sub
_cmd_copy_screenshot
{
my
$self
=
shift
;
my
$request
=
shift
;
my
$id_domain
=
$request
->
args
('
id_domain
');
my
$domain
=
$self
->
search_domain_by_id
(
$id_domain
);
my
$id_base
=
$domain
->
id_base
;
my
$base
=
$self
->
search_domain_by_id
(
$id_base
);
if
(
!
$domain
->
file_screenshot
)
{
die
"
I don't have the screenshot of the domain
"
.
$domain
->
name
;
}
else
{
my
$base_screenshot
=
$domain
->
file_screenshot
();
$base_screenshot
=~
s{(.*)/\d+\.(\w+)}{$1/$id_base.$2}
;
$base
->
_post_screenshot
(
$base_screenshot
);
copy
(
$domain
->
file_screenshot
,
$base_screenshot
);
}
}
sub
_cmd_create
{
my
$self
=
shift
;
...
...
@@ -1896,6 +1919,7 @@ sub _req_method {
,
set_driver
=>
\
&_cmd_set_driver
,
domdisplay
=>
\
&_cmd_domdisplay
,
screenshot
=>
\
&_cmd_screenshot
,
copy_screenshot
=>
\
&_cmd_copy_screenshot
,
remove_base
=>
\
&_cmd_remove_base
,
ping_backend
=>
\
&_cmd_ping_backend
,
prepare_base
=>
\
&_cmd_prepare_base
...
...
lib/Ravada/Request.pm
View file @
a09b9992
...
...
@@ -55,6 +55,7 @@ our %VALID_ARG = (
,
shutdown_domain
=>
{
name
=>
2
,
id_domain
=>
2
,
uid
=>
1
,
timeout
=>
2
,
at
=>
2
}
,
force_shutdown_domain
=>
{
name
=>
1
,
uid
=>
1
,
at
=>
2
}
,
screenshot_domain
=>
{
id_domain
=>
1
,
filename
=>
2
}
,
copy_screenshot
=>
{
id_domain
=>
1
,
filename
=>
2
}
,
start_domain
=>
{
%$args_manage
,
remote_ip
=>
1
}
,
rename_domain
=>
{
uid
=>
1
,
name
=>
1
,
id_domain
=>
1
}
,
set_driver
=>
{
uid
=>
1
,
id_domain
=>
1
,
id_option
=>
1
}
...
...
@@ -685,6 +686,31 @@ sub screenshot_domain {
}
=head2 copy_screenshot
Request to copy a screenshot from a domain to another
=cut
sub
copy_screenshot
{
my
$proto
=
shift
;
my
$class
=
ref
(
$proto
)
||
$proto
;
my
$args
=
_check_args
('
copy_screenshot
',
@
_
);
$args
->
{
filename
}
=
''
if
!
exists
$args
->
{
filename
};
my
$self
=
{};
bless
(
$self
,
$class
);
return
$self
->
_new_request
(
command
=>
'
copy_screenshot
'
,
id_domain
=>
$args
->
{
id_domain
}
,
args
=>
$args
);
}
=head2 open_iptables
Request to open iptables for a remote client
...
...
public/js/ravada.js
View file @
a09b9992
...
...
@@ -153,12 +153,38 @@
};
$scope
.
reload_page_msg
=
false
;
$scope
.
action
=
function
(
target
,
action
,
machineId
){
$http
.
get
(
'
/
'
+
target
+
'
/
'
+
action
+
'
/
'
+
machineId
+
'
.json
'
);
$scope
.
reload_page_msg
=
true
;
setTimeout
(
function
()
{
window
.
location
.
reload
(
false
);
},
5000
);
$scope
.
fail_page_msg
=
false
;
$scope
.
screenshot
=
function
(
target
,
action
,
machineId
,
isActive
){
if
(
isActive
)
{
$http
.
get
(
'
/
'
+
target
+
'
/
'
+
action
+
'
/
'
+
machineId
+
'
.json
'
);
$scope
.
fail_page_msg
=
false
;
$scope
.
reload_page_msg
=
true
;
setTimeout
(
function
()
{
window
.
location
.
reload
(
false
);
},
5000
);
}
else
{
$scope
.
reload_page_msg
=
false
;
$scope
.
fail_page_msg
=
true
;
}
};
$scope
.
reload_page_copy_msg
=
false
;
$scope
.
fail_page_copy_msg
=
false
;
$scope
.
copy_done
=
false
;
$scope
.
copy_screenshot
=
function
(
target
,
action
,
machineId
,
fileScreenshot
){
if
(
fileScreenshot
!=
''
)
{
$http
.
get
(
'
/
'
+
target
+
'
/
'
+
action
+
'
/
'
+
machineId
+
'
.json
'
);
$scope
.
fail_page_copy_msg
=
false
;
$scope
.
reload_page_copy_msg
=
true
;
setTimeout
(
function
()
{
$scope
.
reload_page_copy_msg
=
false
;
},
2000
);
}
else
{
$scope
.
reload_page_copy_msg
=
false
;
$scope
.
fail_page_copy_msg
=
true
;
}
};
$scope
.
rename
=
function
(
machineId
,
old_name
)
{
...
...
@@ -197,7 +223,7 @@
$scope
.
set_public
=
function
(
machineId
,
value
)
{
$http
.
get
(
"
/machine/public/
"
+
machineId
+
"
/
"
+
value
);
};
//On load code
$scope
.
showmachineId
=
window
.
location
.
pathname
.
split
(
"
/
"
)[
3
].
split
(
"
.
"
)[
0
]
||
-
1
;
$http
.
get
(
'
/machine/info/
'
+
$scope
.
showmachineId
+
'
.json
'
).
then
(
function
(
response
)
{
...
...
rvd_front.pl
View file @
a09b9992
...
...
@@ -394,6 +394,12 @@ get '/machine/screenshot/(:id).(:type)' => sub {
return
screenshot_machine
(
$c
);
};
get
'
/machine/copy_screenshot/(:id).(:type)
'
=>
sub
{
my
$c
=
shift
;
return
access_denied
(
$c
)
if
!
$USER
->
is_admin
();
return
copy_screenshot
(
$c
);
};
get
'
/machine/pause/(:id).(:type)
'
=>
sub
{
my
$c
=
shift
;
return
pause_machine
(
$c
);
...
...
@@ -1378,6 +1384,13 @@ sub settings_machine {
)
if
$c
->
param
('
start
')
&&
!
$domain
->
is_active
;
_enable_buttons
(
$c
,
$domain
);
my
$file_screenshot
=
"
$DOCUMENT_ROOT
/img/screenshots/
"
.
$domain
->
id
.
"
.png
";
my
$req3
=
Ravada::
Request
->
copy_screenshot
(
id_domain
=>
$domain
->
id
,
filename
=>
$file_screenshot
)
if
$c
->
param
('
copy_screenshot
');
$c
->
stash
(
message
=>
'');
my
@reqs
=
();
...
...
@@ -1402,8 +1415,6 @@ sub settings_machine {
}
}
for
my
$req
(
@reqs
)
{
$RAVADA
->
wait_request
(
$req
,
60
)
}
...
...
@@ -1538,6 +1549,20 @@ sub screenshot_machine {
$c
->
render
(
json
=>
{
request
=>
$req
->
id
});
}
sub
copy_screenshot
{
my
$c
=
shift
;
return
login
(
$c
)
if
!
_logged_in
(
$c
);
my
$domain
=
_search_requested_machine
(
$c
);
my
$file_screenshot
=
"
$DOCUMENT_ROOT
/img/screenshots/
"
.
$domain
->
id
.
"
.png
";
my
$req
=
Ravada::
Request
->
copy_screenshot
(
id_domain
=>
$domain
->
id
,
filename
=>
$file_screenshot
);
$c
->
render
(
json
=>
{
request
=>
$req
->
id
});
}
sub
prepare_machine
{
my
$c
=
shift
;
return
login
(
$c
)
if
!
_logged_in
(
$c
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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