Centralize evaluation of console accessibility.
This commit is contained in:
parent
7437a17c9f
commit
2524172c12
5 changed files with 85 additions and 66 deletions
|
|
@ -60,21 +60,21 @@
|
|||
<td class="jdrupes-vmoperator-vmmgmt-view-action-list">
|
||||
<span role="button"
|
||||
v-if="entry.spec.vm.state != 'Running' && !entry['running']
|
||||
&& entry.permissions.includes('start')"
|
||||
&& entry.permissions.includes('START')"
|
||||
tabindex="0" class="fa fa-play" :title="localize('Start VM')"
|
||||
v-on:click="vmAction(entry.name, 'start')"></span>
|
||||
<span role="button" v-else class="fa fa-play"
|
||||
aria-disabled="true" :title="localize('Start VM')"></span>
|
||||
<span role="button"
|
||||
v-if="entry.spec.vm.state != 'Stopped' && entry['running']
|
||||
&& entry.permissions.includes('stop')"
|
||||
&& entry.permissions.includes('STOP')"
|
||||
tabindex="0" class="fa fa-stop" :title="localize('Stop VM')"
|
||||
v-on:click="vmAction(entry.name, 'stop')"></span>
|
||||
<span role="button" v-else class="fa fa-stop"
|
||||
aria-disabled="true" :title="localize('Stop VM')"></span>
|
||||
<span role="button"
|
||||
:aria-disabled="!entry['running']
|
||||
|| !entry.permissions.includes('reset')"
|
||||
|| !entry.permissions.includes('RESET')"
|
||||
tabindex="0" class="svg-icon" :title="localize('Reset VM')"
|
||||
v-on:click="vmAction(entry.name, 'reset')">
|
||||
<svg viewBox="0 0 1541.33 1535.5083">
|
||||
|
|
@ -86,8 +86,7 @@
|
|||
? 'computer-off.svg' : (entry.usedFrom
|
||||
? 'computer-in-use.svg' : 'computer.svg'))"
|
||||
:title="localize('Open console')"
|
||||
:aria-disabled="!entry['running']
|
||||
|| !(entry.permissions.includes('accessConsole'))"
|
||||
:aria-disabled="!entry.consoleAccessible"
|
||||
v-on:click="vmAction(entry.name, 'openConsole')">
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
|||
|
|
@ -249,14 +249,15 @@ public class VmMgmt extends FreeMarkerConlet<VmMgmt.VmsModel> {
|
|||
.toBigInteger());
|
||||
|
||||
// Build result
|
||||
var perms = vmDef.permissionsFor(user, roles);
|
||||
return Map.of("metadata",
|
||||
Map.of("namespace", vmDef.namespace(),
|
||||
"name", vmDef.name()),
|
||||
"spec", spec,
|
||||
"status", status,
|
||||
"nodeName", vmDef.extra().map(VmExtraData::nodeName).orElse(""),
|
||||
"permissions", vmDef.permissionsFor(user, roles).stream()
|
||||
.map(VmDefinition.Permission::toString).toList());
|
||||
"consoleAccessible", vmDef.consoleAccessible(user, perms),
|
||||
"permissions", perms);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -438,9 +439,7 @@ public class VmMgmt extends FreeMarkerConlet<VmMgmt.VmsModel> {
|
|||
}
|
||||
break;
|
||||
case "openConsole":
|
||||
if (perms.contains(VmDefinition.Permission.ACCESS_CONSOLE)) {
|
||||
openConsole(channel, model, vmChannel, vmDef, user, perms);
|
||||
}
|
||||
openConsole(channel, model, vmChannel, vmDef, user, perms);
|
||||
break;
|
||||
case "cpus":
|
||||
fire(new ModifyVm(vmName, "currentCpus",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue