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

feat(frontend): show active machines (#1676)

also polished admin machines
parent c750dfd0
......@@ -245,9 +245,18 @@ msgstr "Machine settings"
msgid "Cannot remove base, machine has clones"
msgstr "Cannot remove base, machine has clones"
msgid "Show active"
msgstr "Show active"
msgid "Show clones"
msgstr "Show clones"
msgid "show clones"
msgstr "show clones"
msgid "Hide clones"
msgstr "Hide clones"
msgid "hide clones"
msgstr "hide clones"
......@@ -308,7 +317,7 @@ msgid "Password"
msgstr "Password"
msgid "Start session"
msgstr "Start session\n"
msgstr "Start session"
msgid "bits) in your computer."
msgstr "bits) in your computer."
......
......@@ -60,8 +60,23 @@
cursor: not-allowed;
}
span.request{
color: black;
}
.machine {
font-weight: normal;
color: black;
}
.base {
font-weight: bold;
color: black;
}
.active_machine {
color: darkgreen;
}
.comment {
......
......@@ -234,6 +234,8 @@ ravadaApp.directive("solShowMachine", swMach)
function machinesPageC($scope, $http, $timeout) {
$scope.list_machines_time = 0;
$scope.n_active=0;
$scope.show_active=false;
if( $scope.check_netdata && $scope.check_netdata != "0" ) {
var url = $scope.check_netdata;
$scope.check_netdata = 0;
......@@ -283,8 +285,12 @@ ravadaApp.directive("solShowMachine", swMach)
if (Object.keys($scope.list_machines).length != data.length) {
$scope.list_machines = {};
}
var n_active_current = 0;
$scope.n_active_hidden = 0;
$scope.n_clones = 0;
for (var i=0, iLength = data.length; i<iLength; i++){
mach = data[i];
if (mach.id_base>0) { $scope.n_clones++ }
if (typeof $scope.list_machines[i] == 'undefined'
|| $scope.list_machines[i].id != mach.id
|| $scope.list_machines[i].date_changed != mach.date_changed
......@@ -299,11 +305,20 @@ ravadaApp.directive("solShowMachine", swMach)
mach.show = true;
}
if (typeof $scope.show_clones[mach.id] == 'undefined') {
$scope.show_clones[mach.id] = false;
// $scope.show_clones[mach.id] = false;
}
$scope.list_machines[i] = mach;
}
if (mach.status == 'active') {
n_active_current++;
if (!mach.show) {
$scope.n_active_hidden++;
console.log(mach.name);
}
}
}
$scope.n_active=n_active_current;
if ( $scope.show_active ) { $scope.do_show_active() };
});
}
}
......@@ -367,8 +382,8 @@ ravadaApp.directive("solShowMachine", swMach)
$scope.hide_clones = !value;
for (var i in $scope.list_machines){
mach = $scope.list_machines[i];
if (!mach.id_base) {
$scope.show_clones[mach.id] = value;
if (mach.is_base) {
$scope.toggle_show_clones(mach.id,value);
}
}
}
......@@ -440,8 +455,18 @@ ravadaApp.directive("solShowMachine", swMach)
$scope.cancel_modal=function(){
$scope.modalOpened=false;
}
$scope.toggle_show_clones =function(id) {
$scope.show_clones[id] = !$scope.show_clones[id];
$scope.toggle_show_clones =function(id, value) {
if (typeof(value) == 'undefined') {
$scope.show_clones[id] = !$scope.show_clones[id];
} else {
$scope.show_clones[id] = value;
}
if (!$scope.show_clones[id]) {
$scope.show_active = false;
$scope.hide_clones = true;
}
$scope.n_active_hidden = 0;
$scope.n_active = 0;
for (var [key, mach ] of Object.entries($scope.list_machines)) {
if (mach.id_base == id) {
mach.show = $scope.show_clones[id];
......@@ -450,7 +475,15 @@ ravadaApp.directive("solShowMachine", swMach)
$scope.set_show_clones(mach.id, false);
}
}
if (mach.status == 'active') {
$scope.n_active++;
if (!mach.show) {
$scope.n_active_hidden++;
}
}
}
$scope.lock_show_active=false;
}
$scope.set_show_clones = function(id, show) {
$scope.show_clones[id] = show;
......@@ -464,6 +497,32 @@ ravadaApp.directive("solShowMachine", swMach)
}
}
}
machine_base = function(id) {
for (var [key, mach ] of Object.entries($scope.list_machines)) {
if (mach.id == id ) {
return mach;
}
}
};
show_parents = function(mach) {
var id_base = mach.id_base;
if (id_base) {
$scope.set_show_clones(mach.id_base, true);
show_parents(machine_base(id_base));
}
};
$scope.do_show_active = function() {
$scope.n_active_hidden = 0;
for (var [key, mach ] of Object.entries($scope.list_machines)) {
if (mach.status =='active') {
$scope.show_machine[mach.id_base] = true;
show_parents(mach);
mach.show = true;
}
}
$scope.show_active=true;
};
//On load code
$scope.modalOpened=false;
$scope.rename= {new_name: 'new_name'};
......@@ -472,6 +531,7 @@ ravadaApp.directive("solShowMachine", swMach)
$scope.show_clones = { '0': false };
$scope.show_machine = { '0': false };
$scope.pingbe_fail = false;
$scope.show_active=false;
var time0 = new Date() / 1000;
};
......
<div
ng-cloak="true"
ng-show="requests[0]"
ng-controler="requestsCtrl">
<button type="button" class="btn btn-primary btn-sm"
<div class="row">
<div class="col-md-8">
% if ($_user->can_create_machine){
<a type="button" class="btn btn-success btn-sm"
href="/new_machine.html">
<b><%=l 'New Machine' %></b>
<i ng-show="download_working"
title="<%=l 'Downloading' %>"
class="fa fa-angle-double-down" aria-hidden="true"></i>
<i ng-show="download_done && !download_working"
class="fa fa-check" aria-hidden="true"></i>
</a>
% }
<button type="button" class="btn btn-outline-primary btn-sm"
ng-enabled="requests.length"
ng-click="show_requests = !show_requests"
>Requests
><%=l 'Requests' %>
<span class="badge badge-warning" ng-hide="show_requests">{{requests.length}}</span>
<span class="badge badge-warning" ng-show="show_requests">hide</span>
</button>
<button type="button" class="btn btn-outline-primary btn-sm"
ng-click="do_show_active();"
ng-disabled="!n_active_hidden"
>
<span><%=l 'Show active' %></span>
<span class="badge badge-warning">{{n_active}}</span>
</button>
<button type="button" class="btn btn-outline-primary btn-sm">
<a ng-show="hide_clones" ng-click="showClones(true)"
align="right"><%=l 'show clones' %></a>
<a ng-show="!hide_clones" ng-click="showClones(false)"
align="right"><%=l 'hide clones' %></a>
</button>
<button class="btn btn-outline-warning btn-sm"
title="<%=l 'Reload' %>"
ng-click="list_machines={};subscribe_all('<%= url_for('ws_subscribe')->to_abs %>');"><i class="fa fa-sync-alt" aria-hidden="true"></i></button>
</div>
<div class="col-md-3">
</div>
</div>
<div ng-show="show_requests"
class="alert alert-light border-primary text-primary" role="alert" id="requests"
class="alert alert-light border-primary" role="alert" id="requests"
>
<div ng-repeat="request in requests">
<span class="badge badge-pill badge-light">{{request.date}} |</span>
{{request.command}}
<b>{{request.domain}}</b>
<span class="badge-pill badge-light">{{request.date}}</span>
<span class="request">
<b>{{request.command}}</b>
{{request.domain}}
<i>{{request.status}}</i>
<span class="badge badge-pill badge-light">{{request.error}}</span>
</span>
<span class="error">{{request.error}}</span>
</div>
</div>
</div>
......@@ -100,20 +100,6 @@
</div>
<div class="row">
<div class="col-md-5"><h2><%=l 'Virtual Machines' %></h2></div>
<div class="col-md-4" align="left">
% if ($_user->can_create_machine){
<h2>
<button class="btn btn-warning" ng-click="list_machines={};subscribe_all('<%= url_for('ws_subscribe')->to_abs %>');"><i class="fa fa-sync-alt" aria-hidden="true"></i></button>
<a type="button" class="btn btn-success" href="/new_machine.html">
<b><%=l 'New Machine' %></b>
<i ng-show="download_working"
class="fa fa-angle-double-down" aria-hidden="true"></i>
<i ng-show="download_done && !download_working"
class="fa fa-check" aria-hidden="true"></i>
</a>
</h2>
% }
</div>
</div>
%= include 'bootstrap/requests'
......@@ -125,14 +111,6 @@
<tr>
<th ><div class="lgMachName machine-button" style="display:inline;float:down">
<%=l 'Machine Name' %></div>
<div style="float:right" ng-show="n_clones">
<a ng-show="hide_clones" ng-click="showClones(true)"
class="badge badge-primary dropdown-toggle text-white"
align="right"><%=l 'show clones' %></a>
<a ng-show="!hide_clones" ng-click="showClones(false)"
class="badge badge-primary dropdown-toggle text-white"
align="right"><%=l 'hide clones' %></a>
</div>
</th>
<th class="lgMachToggle">
<span
......@@ -158,8 +136,12 @@
<i class="far fa-file-alt" title="Pool" ng-show="machine.is_pool"></i>
<a align="right" href="/machine/manage/{{machine.id}}.html"
ng-class="{base: machine.is_base
,disabled: !machine.can_manage}"
class="machine"
ng-class="{
disabled: !machine.can_manage
,base: machine.is_base
,active_machine: machine.status == 'active'
}"
title ="<%=l 'Manage machine' %>">{{machine.name}}</a> {{machine.comment}}
<span class="comment" ng-show="machine.is_volatile"><%=l 'Volatile' %></span>
<button ng-show="machine.has_clones" type="button"
......
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