Commit 22c78429 authored by Francesc Guasch's avatar Francesc Guasch
Browse files

refactor(frontend): improved show active machines

parent 03b6a6d2
......@@ -414,9 +414,13 @@ ravadaApp.directive("solShowMachine", swMach)
$scope.hide_clones = true;
$scope.showClones = function(value){
$scope.auto_hide_clones = false;
$scope.show_active = false;
$scope.hide_clones = !value;
for (var i in $scope.list_machines){
mach = $scope.list_machines[i];
if (mach._level == 0 ) {
mach.show = true;
}
if (mach.is_base) {
$scope.toggle_show_clones(mach.id,value);
}
......@@ -548,16 +552,38 @@ ravadaApp.directive("solShowMachine", swMach)
}
};
$scope.do_show_active = function() {
$scope.show_active=true;
$scope.hide_clones = true;
$scope.n_active_hidden = 0;
var n_show = 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;
n_show++;
} else {
mach.show = false;
}
}
$scope.show_active=true;
$scope.n_show = n_show;
};
$scope.reload_list = function() {
$scope.show_active=false;
$scope.hide_clones = true;
$scope.n_active_hidden = 0;
for (var [key, mach ] of Object.entries($scope.list_machines)) {
if (mach._level == 0 ) {
mach.show = true;
} else {
mach.show = false;
if (mach.status == 'active') {
$scope.n_active_hidden++;
}
}
}
};
//On load code
$scope.modalOpened=false;
$scope.rename= {new_name: 'new_name'};
......
......@@ -24,10 +24,16 @@
<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"
ng-disabled="!n_active || (!n_active_hidden && !show_active)"
>
<span><%=l 'Show active' %></span>
<span ng-show="!show_active"
ng-enabled="n_active"
ng-click="do_show_active();"
><%=l 'Show active' %></span>
<span ng-show="show_active"
ng-click="reload_list()"
><%=l 'Hide active' %></span>
<span class="badge badge-warning">{{n_active}}</span>
</button>
......
......@@ -275,6 +275,11 @@
</tr>
</tbody>
</table>
<div ng-show="show_active && !n_show">
There are no active virtual machines.
<button ng-click="reload_list()">reload list</button>
</div>
</div>
</div>
</div>
......
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