Commit 99340ad8 authored by Francesc Guasch's avatar Francesc Guasch
Browse files

Merge branch 'develop' into feature/1166_limit

parents a2c2baef c930b0a0
......@@ -31,6 +31,7 @@ WriteMakefile(
,'Net::DNS' => 0
,'Net::SSH2' => 0
,'File::Rsync' => 0
,'DateTime::Format::DateParse'=> 0
},
BUILD_REQUIRES => {
'Test::Perl::Critic' => 0
......
......@@ -4,7 +4,7 @@ Architecture: all
Section: utils
Priority: optional
Maintainer: Francesc Guasch <frankie@telecos.upc.edu>
Depends: perl (>=5.18),libmojolicious-perl,mysql-common,libauthen-passphrase-perl, libdatetime-perl, libdbd-mysql-perl,libdbi-perl,libdbix-connector-perl,libipc-run3-perl,libio-stringy-perl,libnet-ldap-perl,libproc-pid-file-perl,libvirt-daemon-system,libsys-virt-perl,libxml-libxml-perl,libconfig-yaml-perl,libmoose-perl,libjson-xs-perl,qemu-utils,perlmagick,libmoosex-types-netaddr-ip-perl,libio-interface-perl,libiptables-chainmgr-perl,libnet-dns-perl,wget,liblocale-maketext-lexicon-perl,libmojolicious-plugin-i18n-perl,libdbd-sqlite3-perl, debconf (>= 0.2.26), adduser, libdigest-sha-perl, qemu-kvm, net-tools, libfile-rsync-perl, libnet-ssh2-perl, bridge-utils, libencode-locale-perl, libpbkdf2-tiny-perl
Depends: perl (>=5.18),libmojolicious-perl,mysql-common,libauthen-passphrase-perl, libdatetime-perl, libdbd-mysql-perl,libdbi-perl,libdbix-connector-perl,libipc-run3-perl,libio-stringy-perl,libnet-ldap-perl,libproc-pid-file-perl,libvirt-daemon-system,libsys-virt-perl,libxml-libxml-perl,libconfig-yaml-perl,libmoose-perl,libjson-xs-perl,qemu-utils,perlmagick,libmoosex-types-netaddr-ip-perl,libio-interface-perl,libiptables-chainmgr-perl,libnet-dns-perl,wget,liblocale-maketext-lexicon-perl,libmojolicious-plugin-i18n-perl,libdbd-sqlite3-perl, debconf (>= 0.2.26), adduser, libdigest-sha-perl, qemu-kvm, net-tools, libfile-rsync-perl, libnet-ssh2-perl, bridge-utils, libencode-locale-perl, libpbkdf2-tiny-perl, libdatetime-format-dateparse-perl
Description: Remote Virtual Desktops Manager
Ravada is a software that allows the user to connect to a
remote virtual desktop.
......@@ -4,7 +4,7 @@ Architecture: all
Section: utils
Priority: optional
Maintainer: Francesc Guasch <frankie@telecos.upc.edu>
Depends: perl (>=5.18),libmojolicious-perl,mysql-common,libauthen-passphrase-perl, libdatetime-perl, libdbd-mysql-perl,libdbi-perl,libdbix-connector-perl,libipc-run3-perl,libio-stringy-perl,libnet-ldap-perl,libproc-pid-file-perl,libvirt-bin,libvirt-daemon-system,libsys-virt-perl,libxml-libxml-perl,libconfig-yaml-perl,libmoose-perl,libjson-xs-perl,qemu-utils,perlmagick,libmoosex-types-netaddr-ip-perl,libio-interface-perl,libiptables-chainmgr-perl,libnet-dns-perl,wget,liblocale-maketext-lexicon-perl,libmojolicious-plugin-i18n-perl,libdbd-sqlite3-perl, debconf (>= 0.2.26), adduser, libdigest-sha-perl, qemu-kvm, net-tools, libfile-rsync-perl, libnet-ssh2-perl, bridge-utils, libencode-locale-perl, libpbkdf2-tiny-perl
Depends: perl (>=5.18),libmojolicious-perl,mysql-common,libauthen-passphrase-perl, libdatetime-perl, libdbd-mysql-perl,libdbi-perl,libdbix-connector-perl,libipc-run3-perl,libio-stringy-perl,libnet-ldap-perl,libproc-pid-file-perl,libvirt-bin,libvirt-daemon-system,libsys-virt-perl,libxml-libxml-perl,libconfig-yaml-perl,libmoose-perl,libjson-xs-perl,qemu-utils,perlmagick,libmoosex-types-netaddr-ip-perl,libio-interface-perl,libiptables-chainmgr-perl,libnet-dns-perl,wget,liblocale-maketext-lexicon-perl,libmojolicious-plugin-i18n-perl,libdbd-sqlite3-perl, debconf (>= 0.2.26), adduser, libdigest-sha-perl, qemu-kvm, net-tools, libfile-rsync-perl, libnet-ssh2-perl, bridge-utils, libencode-locale-perl, libpbkdf2-tiny-perl, libdatetime-format-dateparse-perl
Description: Remote Virtual Desktops Manager
Ravada is a software that allows the user to connect to a
remote virtual desktop.
......@@ -4,7 +4,7 @@ Architecture: all
Section: utils
Priority: optional
Maintainer: Francesc Guasch <frankie@telecos.upc.edu>
Depends: perl (>=5.18),libmojolicious-perl,mysql-common,libauthen-passphrase-perl, libdatetime-perl, libdbd-mysql-perl,libdbi-perl,libdbix-connector-perl,libipc-run3-perl,libio-stringy-perl,libnet-ldap-perl,libproc-pid-file-perl,libvirt-daemon-system,libsys-virt-perl,libxml-libxml-perl,libconfig-yaml-perl,libmoose-perl,libjson-xs-perl,qemu-utils,perlmagick,libmoosex-types-netaddr-ip-perl,libio-interface-perl,libiptables-chainmgr-perl,libnet-dns-perl,wget,liblocale-maketext-lexicon-perl,libmojolicious-plugin-i18n-perl,libdbd-sqlite3-perl, debconf (>= 0.2.26), adduser, libdigest-sha-perl, qemu-kvm, net-tools, libfile-rsync-perl, libnet-ssh2-perl, bridge-utils, libpbkdf2-tiny-perl
Depends: perl (>=5.18),libmojolicious-perl,mysql-common,libauthen-passphrase-perl, libdatetime-perl, libdbd-mysql-perl,libdbi-perl,libdbix-connector-perl,libipc-run3-perl,libio-stringy-perl,libnet-ldap-perl,libproc-pid-file-perl,libvirt-daemon-system,libsys-virt-perl,libxml-libxml-perl,libconfig-yaml-perl,libmoose-perl,libjson-xs-perl,qemu-utils,perlmagick,libmoosex-types-netaddr-ip-perl,libio-interface-perl,libiptables-chainmgr-perl,libnet-dns-perl,wget,liblocale-maketext-lexicon-perl,libmojolicious-plugin-i18n-perl,libdbd-sqlite3-perl, debconf (>= 0.2.26), adduser, libdigest-sha-perl, qemu-kvm, net-tools, libfile-rsync-perl, libnet-ssh2-perl, bridge-utils, libpbkdf2-tiny-perl, libdatetime-format-dateparse-perl
Description: Remote Virtual Desktops Manager
Ravada is a software that allows the user to connect to a
remote virtual desktop.
......@@ -4,7 +4,7 @@ Architecture: all
Section: utils
Priority: optional
Maintainer: Francesc Guasch <frankie@telecos.upc.edu>
Depends: perl (>=5.18),libmojolicious-perl,mysql-common,libauthen-passphrase-perl, libdatetime-perl, libdbd-mysql-perl,libdbi-perl,libdbix-connector-perl,libipc-run3-perl,libio-stringy-perl,libnet-ldap-perl,libproc-pid-file-perl,libvirt-daemon-system,libsys-virt-perl,libxml-libxml-perl,libconfig-yaml-perl,libmoose-perl,libjson-xs-perl,qemu-utils,perlmagick,libmoosex-types-netaddr-ip-perl,libio-interface-perl,libiptables-chainmgr-perl,libnet-dns-perl,wget,liblocale-maketext-lexicon-perl,libmojolicious-plugin-i18n-perl,libdbd-sqlite3-perl, debconf (>= 0.2.26), adduser, libdigest-sha-perl, qemu-kvm, net-tools, libfile-rsync-perl, libnet-ssh2-perl, bridge-utils, libpbkdf2-tiny-perl
Depends: perl (>=5.18),libmojolicious-perl,mysql-common,libauthen-passphrase-perl, libdatetime-perl, libdbd-mysql-perl,libdbi-perl,libdbix-connector-perl,libipc-run3-perl,libio-stringy-perl,libnet-ldap-perl,libproc-pid-file-perl,libvirt-daemon-system,libsys-virt-perl,libxml-libxml-perl,libconfig-yaml-perl,libmoose-perl,libjson-xs-perl,qemu-utils,perlmagick,libmoosex-types-netaddr-ip-perl,libio-interface-perl,libiptables-chainmgr-perl,libnet-dns-perl,wget,liblocale-maketext-lexicon-perl,libmojolicious-plugin-i18n-perl,libdbd-sqlite3-perl, debconf (>= 0.2.26), adduser, libdigest-sha-perl, qemu-kvm, net-tools, libfile-rsync-perl, libnet-ssh2-perl, bridge-utils, libpbkdf2-tiny-perl, libdatetime-format-dateparse-perl
Description: Remote Virtual Desktops Manager
Ravada is a software that allows the user to connect to a
remote virtual desktop.
......@@ -131,14 +131,14 @@ Returns: listref of machines
sub list_machines_user($self, $user, $access_data={}) {
my $sth = $CONNECTOR->dbh->prepare(
"SELECT id,name,is_public, screenshot"
"SELECT id,name,is_public, description, screenshot"
." FROM domains "
." WHERE is_base=1"
." ORDER BY name "
);
my ($id, $name, $is_public, $screenshot);
my ($id, $name, $is_public, $description, $screenshot);
$sth->execute;
$sth->bind_columns(\($id, $name, $is_public, $screenshot ));
$sth->bind_columns(\($id, $name, $is_public, $description, $screenshot));
my @list;
while ( $sth->fetch ) {
......@@ -152,6 +152,7 @@ sub list_machines_user($self, $user, $access_data={}) {
my %base = ( id => $id, name => $name
, is_public => ($is_public or 0)
, screenshot => ($screenshot or '')
, description => ($description or '')
, is_active => 0
, id_clone => undef
, name_clone => undef
......@@ -172,6 +173,8 @@ sub list_machines_user($self, $user, $access_data={}) {
$base{name_clone} = $clone->name;
$base{screenshot} = ( $clone->_data('screenshot')
or $base{screenshot});
$base{description} = ( $clone->_data('description')
or $base{description});
$base{is_active} = $clone->is_active;
$base{id_clone} = $clone->id;
$base{can_remove} = 0;
......@@ -1236,7 +1239,15 @@ sub is_in_maintenance($self) {
$settings->{frontend}->{maintenance_end}->{value});
my $now = DateTime->now();
return $now >= $start && $now <= $end;
if ( $now >= $start && $now <= $end ) {
return 1;
}
my $sth = $self->_dbh->prepare("UPDATE settings set value = 0 "
." WHERE id=? "
);
$sth->execute($settings->{frontend}->{maintenance}->{id});
return 0;
}
=head2 version
......
......@@ -863,3 +863,6 @@ msgstr ""
msgid "Enable last for not allowed restrictions."
msgstr ""
msgid "Add description"
msgstr ""
......@@ -393,4 +393,49 @@ ul.alert-dropdown {
.show>.nav-pills .nav-link{
color: white;
background-color: #d73a49 !important
}
\ No newline at end of file
}
.container {
position: relative;
width: 100%;
height: auto;
padding-right: 0;
padding-left: 0;
}
.overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
height: 100%;
width: 100%;
opacity: 0;
transition: .5s ease;
background-color: rgba(0, 0, 0, 0.5); /*#008CBA;*/
border-radius: calc(.25rem - 1px) calc(.25rem - 1px) 0 0;
border-top-left-radius: calc(-1px + 0.25rem);
border-top-right-radius: calc(-1px + 0.25rem);
border-bottom-right-radius: 0px;
border-bottom-left-radius: 0px;
border: 5px solid #FFFFFF;
pointer-events: none;
}
.container:hover .overlay {
opacity: 1;
}
.text {
color: white;
font-size: 17px;
font-weight: bold;
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
text-align: center;
}
......@@ -143,6 +143,7 @@
for (var i = 0; i < data.length; i++) {
if ( !$scope.machines[i] || $scope.machines[i].id != data[i].id ) {
$scope.machines[i] = data[i];
$scope.machines[i].description = data[i].description;
} else {
$scope.machines[i].can_hibernate = data[i].can_hibernate;
$scope.machines[i].id= data[i].id;
......@@ -153,6 +154,7 @@
$scope.machines[i].name = data[i].name;
$scope.machines[i].name_clone = data[i].name_clone;
$scope.machines[i].screenshot = data[i].screenshot;
$scope.machines[i].description = data[i].description;
}
if ( data[i].is_public == 1) {
$scope.public_bases++;
......
......@@ -151,12 +151,15 @@ hook before_routes => sub {
return if $url =~ m{^/(css|font|img|js)}
|| $url =~ m{^/fallback/.*\.(css|js|map)$};
return if $url =~ m{^/(anonymous|login|logout|requirements|robots.txt)};
return if $url =~ m{^/(login|logout|requirements|robots.txt)};
return maintenance($c, $RAVADA->settings_global->{frontend}->{maintenance_end}->{value})
if (!$USER || !$USER->is_operator) && $RAVADA->is_in_maintenance();
if ( $RAVADA->is_in_maintenance ) {
return login($c) if !$USER && $url =~ m{^/$};
return maintenance($c) if !$USER || !$USER->is_operator;
}
return if $url =~ m{^/anonymous};
# anonymous URLs
if (($url =~ m{^/machine/(clone|display|info|view)/}
|| $url =~ m{^/(list_bases_anonymous|request/)}i
|| $url =~ m{^/ws/subscribe}
......@@ -249,6 +252,7 @@ get '/anonymous/(#base_id).html' => sub {
};
get '/settings_global.json' => sub($c) {
$RAVADA->is_in_maintenance();
return $c->render(json => $RAVADA->settings_global );
};
......@@ -1402,6 +1406,7 @@ get '/iso/download/(#id).json' => sub {
websocket '/ws/subscribe' => sub {
my $c = shift;
my $expiration = $SESSION_TIMEOUT;
return if !$USER;
$expiration = $SESSION_TIMEOUT_ADMIN if $USER->is_admin;
$c->inactivity_timeout( $expiration );
$c->on(message => sub {
......@@ -1520,7 +1525,13 @@ sub login {
);
$auth_ok = Ravada::Auth::SQL->new(name => $auth_ok->name);
if ( $RAVADA->is_in_maintenance() ) {
return maintenance($c) unless $auth_ok->is_operator;
$auth_ok->send_message('Warning: Server under maintenance. <a href="/admin/settings">Settings</a>');
}
my $machines = $RAVADA->list_machines_user($auth_ok);
$url = "/machine/clone/". $machines->[0]->{id}.".html" if scalar(@$machines) == 1 && !($auth_ok->is_admin);
my $auto_view = 1;
......@@ -1677,6 +1688,11 @@ sub admin {
if ($page eq 'nodes') {
Ravada::Request->refresh_vms();
}
if ($page eq 'settings') {
my $url = $c->req->url->to_abs->path;
my $host = $c->req->url->to_abs->host;
$c->stash(url_login => "/login");
}
$c->render( template => 'main/admin_'.$page);
};
......@@ -2511,7 +2527,10 @@ sub _update_settings($arg, $orig_settings) {
}
};
sub maintenance($c, $maintenance_end) {
sub maintenance($c) {
my $maintenance_end = $RAVADA->settings_global->{frontend}->{maintenance_end}
->{value};
my $localtime_end = DateTime::Format::DateParse->parse_datetime($maintenance_end
);
# return $c->render(text => "Maintenance until ".$localtime_end->strftime('%Y-%m-%d %H:%M [%Z]'));
......
......@@ -46,6 +46,10 @@
ng-true-value="1" ng-false-value="0"
type="checkbox">
</div>
<div>
<%= l 'Admin users can still log in from' %>
<a href="<%= $url_login %>"><%= $url_login %></a>
</div>
</div>
<div class="row" ng-show="settings.frontend.maintenance.value == 1">
<div class="col-md-2">
......@@ -79,7 +83,6 @@
</div>
</div>
<div class="row">
<div class="col-md-2">
<button ng-click="update_settings()"
......
......@@ -8,7 +8,7 @@
$_anonymous=<%= ($_anonymous or 0) %>;
</script>
<div id="page-wrapper" ng-controller="bases" ng-init="anonymous=<%= $_anonymous or 0 %>;subscribe_list_machines_user('<%= url_for('ws_subscribe')->to_abs %>', $scope)">
<div id="page-wrapper" ng-controller="bases" ng-init="is_admin=<%= $user->is_admin %>;anonymous=<%= $_anonymous or 0 %>;subscribe_list_machines_user('<%= url_for('ws_subscribe')->to_abs %>', $scope)">
%= include 'main/list_bases_ng_head'
<!--MACHINES SELECTION-->
<div class="card-body">
......@@ -23,17 +23,23 @@
role="button">{{machine.name}}</a>
<i ng-show="!machine.is_public"><i class="far fa-eye-slash fa-xs" title="<%=l 'not public' %>"></i></i>
</h3>
<div class="container">
<a ng-show="machine.screenshot" href="/machine/clone/{{machine.id}}.html"><img
ng-src="data:image/png;base64,{{machine.screenshot}}" alt="{{machine.description}}" class="img-thumbnail" width="260"
ng-src="data:image/png;base64,{{machine.screenshot}}" alt="{{machine.name}}" class="img-thumbnail" width="260"
></a>
<a ng-show="!machine.screenshot" href="/machine/clone/{{machine.id}}.html"><img
src="/img/default_screenshot.png" class="screenshot-default img-thumbnail"
alt="{{machine.description}}"
width="260"></a>
alt="{{machine.name}}" width="260"
></a>
<div ng-show="machine.description || (!machine.description && is_admin)" class="overlay">
<div ng-show="machine.description" class="text" ng-bind-html="machine.description"></div>
<div ng-show="!machine.description" class="text"><a style="background-color: white; pointer-events: auto;" href="/machine/manage/{{machine.id}}.html#v-pills-description"><%=l 'Add description' %></a></div>
</div>
</div>
</div>
<div class="card-body" id="step2">
<div class="row">
<a type="button" class="btn btn-success" ng-hide="machine.action"
<a type="button" class="btn btn-success mr-2" ng-hide="machine.action"
href="/machine/clone/{{machine.id}}.html"><strong><i class="fa fa-play" aria-hidden="true"></i>&nbsp;<%=l 'Start' %></strong></a>
<a type="button" class="btn btn-danger text-white"
ng-show="machine.id_clone && !machine.is_active && machine.can_remove && !host_restore"
......
Supports Markdown
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