Add reset action to VM management.
This commit is contained in:
parent
af41c78c07
commit
8d96307bb5
7 changed files with 126 additions and 18 deletions
|
|
@ -785,6 +785,20 @@ public class VmAccess extends FreeMarkerConlet<VmAccess.ResourceModel> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void confirmReset(NotifyConletModel event,
|
||||||
|
ConsoleConnection channel, ResourceModel model,
|
||||||
|
ResourceBundle resourceBundle) throws TemplateNotFoundException,
|
||||||
|
MalformedTemplateNameException, ParseException, IOException {
|
||||||
|
Template tpl = freemarkerConfig()
|
||||||
|
.getTemplate("VmAccess-confirmReset.ftl.html");
|
||||||
|
channel.respond(new OpenModalDialog(type(), model.getConletId(),
|
||||||
|
processTemplate(event, tpl,
|
||||||
|
fmModel(event, channel, model.getConletId(), model)))
|
||||||
|
.addOption("cancelable", true).addOption("closeLabel", "")
|
||||||
|
.addOption("title",
|
||||||
|
resourceBundle.getString("confirmResetTitle")));
|
||||||
|
}
|
||||||
|
|
||||||
private void openConsole(ConsoleConnection channel, ResourceModel model,
|
private void openConsole(ConsoleConnection channel, ResourceModel model,
|
||||||
VmChannel vmChannel, VmDefinition vmDef, Set<Permission> perms) {
|
VmChannel vmChannel, VmDefinition vmDef, Set<Permission> perms) {
|
||||||
var resourceBundle = resourceBundle(channel.locale());
|
var resourceBundle = resourceBundle(channel.locale());
|
||||||
|
|
@ -828,20 +842,6 @@ public class VmAccess extends FreeMarkerConlet<VmAccess.ResourceModel> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void confirmReset(NotifyConletModel event,
|
|
||||||
ConsoleConnection channel, ResourceModel model,
|
|
||||||
ResourceBundle resourceBundle) throws TemplateNotFoundException,
|
|
||||||
MalformedTemplateNameException, ParseException, IOException {
|
|
||||||
Template tpl = freemarkerConfig()
|
|
||||||
.getTemplate("VmAccess-confirmReset.ftl.html");
|
|
||||||
channel.respond(new OpenModalDialog(type(), model.getConletId(),
|
|
||||||
processTemplate(event, tpl,
|
|
||||||
fmModel(event, channel, model.getConletId(), model)))
|
|
||||||
.addOption("cancelable", true).addOption("closeLabel", "")
|
|
||||||
.addOption("title",
|
|
||||||
resourceBundle.getString("confirmResetTitle")));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean doSetLocale(SetLocale event, ConsoleConnection channel,
|
protected boolean doSetLocale(SetLocale event, ConsoleConnection channel,
|
||||||
String conletId) throws Exception {
|
String conletId) throws Exception {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
<div
|
||||||
|
class="jdrupes-vmoperator-vmmgmt jdrupes-vmoperator-vmmgmt-confirm-reset">
|
||||||
|
<p>${_("confirmResetMsg")}</p>
|
||||||
|
<p>
|
||||||
|
<span role="button" tabindex="0" class="svg-icon"
|
||||||
|
onclick="orgJDrupesVmOperatorVmMgmt.confirmReset('${conletType}', '${conletId}', '${vmName}')">
|
||||||
|
<svg viewBox="0 0 1541.33 1535.5083">
|
||||||
|
<path d="m 0,127.9968 v 448 c 0,35 29,64 64,64 h 448 c 35,0 64,-29 64,-64 0,-17 -6.92831,-33.07213 -19,-45 C 264.23058,241.7154 337.19508,314.89599 109,82.996795 c -11.999999,-12 -28,-19 -45,-19 -35,0 -64,29 -64,64.000005 z" />
|
||||||
|
<path d="m 772.97656,1535.5046 c 117.57061,0.3623 236.06134,-26.2848 345.77544,-81.4687 292.5708,-147.1572 459.8088,-465.37411 415.5214,-790.12504 C 1489.9861,339.15993 1243.597,77.463924 922.29883,14.342498 601.00067,-48.778928 274.05699,100.37563 110.62891,384.39133 c -34.855139,60.57216 -14.006492,137.9313 46.5664,172.78516 60.57172,34.85381 137.92941,14.00532 172.78321,-46.56641 109.97944,-191.12927 327.69604,-290.34657 543.53515,-247.94336 215.83913,42.40321 380.18953,216.77543 410.00973,435.44141 29.8203,218.66598 -81.8657,430.94957 -278.4863,529.84567 -196.6206,98.8962 -432.84043,61.8202 -589.90233,-92.6777 -24.91016,-24.5038 -85.48587,-83.3326 -119.02246,-52.9832 -24.01114,21.7292 -35.41741,29.5454 -59.9209,54.4559 -24.50381,24.9102 -35.33636,36.9034 -57.54543,60.4713 -38.1335,40.4667 34.10761,93.9685 59.01808,118.472 145.96311,143.5803 339.36149,219.2087 535.3125,219.8125 z"/>
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
@ -72,6 +72,16 @@
|
||||||
v-on:click="vmAction(entry.name, 'stop')"></span>
|
v-on:click="vmAction(entry.name, 'stop')"></span>
|
||||||
<span role="button" v-else class="fa fa-stop"
|
<span role="button" v-else class="fa fa-stop"
|
||||||
aria-disabled="true" :title="localize('Stop VM')"></span>
|
aria-disabled="true" :title="localize('Stop VM')"></span>
|
||||||
|
<span role="button"
|
||||||
|
:aria-disabled="!entry['running']
|
||||||
|
|| !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">
|
||||||
|
<path d="m 0,127.9968 v 448 c 0,35 29,64 64,64 h 448 c 35,0 64,-29 64,-64 0,-17 -6.92831,-33.07213 -19,-45 C 264.23058,241.7154 337.19508,314.89599 109,82.996795 c -11.999999,-12 -28,-19 -45,-19 -35,0 -64,29 -64,64.000005 z" />
|
||||||
|
<path d="m 772.97656,1535.5046 c 117.57061,0.3623 236.06134,-26.2848 345.77544,-81.4687 292.5708,-147.1572 459.8088,-465.37411 415.5214,-790.12504 C 1489.9861,339.15993 1243.597,77.463924 922.29883,14.342498 601.00067,-48.778928 274.05699,100.37563 110.62891,384.39133 c -34.855139,60.57216 -14.006492,137.9313 46.5664,172.78516 60.57172,34.85381 137.92941,14.00532 172.78321,-46.56641 109.97944,-191.12927 327.69604,-290.34657 543.53515,-247.94336 215.83913,42.40321 380.18953,216.77543 410.00973,435.44141 29.8203,218.66598 -81.8657,430.94957 -278.4863,529.84567 -196.6206,98.8962 -432.84043,61.8202 -589.90233,-92.6777 -24.91016,-24.5038 -85.48587,-83.3326 -119.02246,-52.9832 -24.01114,21.7292 -35.41741,29.5454 -59.9209,54.4559 -24.50381,24.9102 -35.33636,36.9034 -57.54543,60.4713 -38.1335,40.4667 34.10761,93.9685 59.01808,118.472 145.96311,143.5803 339.36149,219.2087 535.3125,219.8125 z"/>
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
<img role="button" :src="resourceBase + (!entry['running']
|
<img role="button" :src="resourceBase + (!entry['running']
|
||||||
? 'computer-off.svg' : (entry.usedFrom
|
? 'computer-off.svg' : (entry.usedFrom
|
||||||
? 'computer-in-use.svg' : 'computer.svg'))"
|
? 'computer-in-use.svg' : 'computer.svg'))"
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ consoleTakenNotification = Die Konsole wird von einem anderen Benutzer verwendet
|
||||||
Open\ console = Konsole anzeigen
|
Open\ console = Konsole anzeigen
|
||||||
Start\ VM = VM Starten
|
Start\ VM = VM Starten
|
||||||
Stop\ VM = VM Anhalten
|
Stop\ VM = VM Anhalten
|
||||||
|
Reset\ VM = VM zurücksetzen
|
||||||
|
|
||||||
Yes = Ja
|
Yes = Ja
|
||||||
No = Nein
|
No = Nein
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ import org.jdrupes.vmoperator.common.VmDefinition.Permission;
|
||||||
import org.jdrupes.vmoperator.manager.events.ChannelTracker;
|
import org.jdrupes.vmoperator.manager.events.ChannelTracker;
|
||||||
import org.jdrupes.vmoperator.manager.events.GetDisplayPassword;
|
import org.jdrupes.vmoperator.manager.events.GetDisplayPassword;
|
||||||
import org.jdrupes.vmoperator.manager.events.ModifyVm;
|
import org.jdrupes.vmoperator.manager.events.ModifyVm;
|
||||||
|
import org.jdrupes.vmoperator.manager.events.ResetVm;
|
||||||
import org.jdrupes.vmoperator.manager.events.VmChannel;
|
import org.jdrupes.vmoperator.manager.events.VmChannel;
|
||||||
import org.jdrupes.vmoperator.manager.events.VmDefChanged;
|
import org.jdrupes.vmoperator.manager.events.VmDefChanged;
|
||||||
import org.jdrupes.vmoperator.util.DataPath;
|
import org.jdrupes.vmoperator.util.DataPath;
|
||||||
|
|
@ -64,6 +65,7 @@ import org.jgrapes.webconsole.base.events.ConsoleReady;
|
||||||
import org.jgrapes.webconsole.base.events.DisplayNotification;
|
import org.jgrapes.webconsole.base.events.DisplayNotification;
|
||||||
import org.jgrapes.webconsole.base.events.NotifyConletModel;
|
import org.jgrapes.webconsole.base.events.NotifyConletModel;
|
||||||
import org.jgrapes.webconsole.base.events.NotifyConletView;
|
import org.jgrapes.webconsole.base.events.NotifyConletView;
|
||||||
|
import org.jgrapes.webconsole.base.events.OpenModalDialog;
|
||||||
import org.jgrapes.webconsole.base.events.RenderConlet;
|
import org.jgrapes.webconsole.base.events.RenderConlet;
|
||||||
import org.jgrapes.webconsole.base.events.RenderConletRequestBase;
|
import org.jgrapes.webconsole.base.events.RenderConletRequestBase;
|
||||||
import org.jgrapes.webconsole.base.events.SetLocale;
|
import org.jgrapes.webconsole.base.events.SetLocale;
|
||||||
|
|
@ -395,7 +397,8 @@ public class VmMgmt extends FreeMarkerConlet<VmMgmt.VmsModel> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("PMD.AvoidDecimalLiteralsInBigDecimalConstructor")
|
@SuppressWarnings({ "PMD.AvoidDecimalLiteralsInBigDecimalConstructor",
|
||||||
|
"PMD.NcssCount" })
|
||||||
protected void doUpdateConletState(NotifyConletModel event,
|
protected void doUpdateConletState(NotifyConletModel event,
|
||||||
ConsoleConnection channel, VmsModel model) throws Exception {
|
ConsoleConnection channel, VmsModel model) throws Exception {
|
||||||
event.stop();
|
event.stop();
|
||||||
|
|
@ -422,6 +425,16 @@ public class VmMgmt extends FreeMarkerConlet<VmMgmt.VmsModel> {
|
||||||
fire(new ModifyVm(vmName, "state", "Stopped", vmChannel));
|
fire(new ModifyVm(vmName, "state", "Stopped", vmChannel));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "reset":
|
||||||
|
if (perms.contains(VmDefinition.Permission.RESET)) {
|
||||||
|
confirmReset(event, channel, model, vmName);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "resetConfirmed":
|
||||||
|
if (perms.contains(VmDefinition.Permission.RESET)) {
|
||||||
|
fire(new ResetVm(vmName), vmChannel);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case "openConsole":
|
case "openConsole":
|
||||||
if (perms.contains(VmDefinition.Permission.ACCESS_CONSOLE)) {
|
if (perms.contains(VmDefinition.Permission.ACCESS_CONSOLE)) {
|
||||||
openConsole(channel, model, vmChannel, vmDef, user, perms);
|
openConsole(channel, model, vmChannel, vmDef, user, perms);
|
||||||
|
|
@ -443,6 +456,22 @@ public class VmMgmt extends FreeMarkerConlet<VmMgmt.VmsModel> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void confirmReset(NotifyConletModel event,
|
||||||
|
ConsoleConnection channel, VmsModel model, String vmName)
|
||||||
|
throws TemplateNotFoundException,
|
||||||
|
MalformedTemplateNameException, ParseException, IOException {
|
||||||
|
Template tpl = freemarkerConfig()
|
||||||
|
.getTemplate("VmMgmt-confirmReset.ftl.html");
|
||||||
|
ResourceBundle resourceBundle = resourceBundle(channel.locale());
|
||||||
|
var fmModel = fmModel(event, channel, model.getConletId(), model);
|
||||||
|
fmModel.put("vmName", vmName);
|
||||||
|
channel.respond(new OpenModalDialog(type(), model.getConletId(),
|
||||||
|
processTemplate(event, tpl, fmModel))
|
||||||
|
.addOption("cancelable", true).addOption("closeLabel", "")
|
||||||
|
.addOption("title",
|
||||||
|
resourceBundle.getString("confirmResetTitle")));
|
||||||
|
}
|
||||||
|
|
||||||
private void openConsole(ConsoleConnection channel, VmsModel model,
|
private void openConsole(ConsoleConnection channel, VmsModel model,
|
||||||
VmChannel vmChannel, VmDefinition vmDef, String user,
|
VmChannel vmChannel, VmDefinition vmDef, String user,
|
||||||
Set<Permission> perms) {
|
Set<Permission> perms) {
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,9 @@ declare global {
|
||||||
interface Window {
|
interface Window {
|
||||||
orgJDrupesVmOperatorVmMgmt: {
|
orgJDrupesVmOperatorVmMgmt: {
|
||||||
initPreview?: (previewDom: HTMLElement, isUpdate: boolean) => void,
|
initPreview?: (previewDom: HTMLElement, isUpdate: boolean) => void,
|
||||||
initView?: (viewDom: HTMLElement, isUpdate: boolean) => void
|
initView?: (viewDom: HTMLElement, isUpdate: boolean) => void,
|
||||||
|
confirmReset?: (conletType: string, conletId: string,
|
||||||
|
vmName: string) => void
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -236,4 +238,8 @@ JGConsole.registerConletFunction("org.jdrupes.vmoperator.vmmgmt.VmMgmt",
|
||||||
window.open(url, target.id);
|
window.open(url, target.id);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
window.orgJDrupesVmOperatorVmMgmt.confirmReset =
|
||||||
|
(conletType: string, conletId: string, vmName: string) => {
|
||||||
|
JGConsole.instance.closeModalDialog(conletType, conletId);
|
||||||
|
JGConsole.notifyConletModel(conletId, "resetConfirmed", vmName);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -115,6 +115,23 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
span[role="button"].svg-icon {
|
||||||
|
display: inline-block;
|
||||||
|
line-height: 1;
|
||||||
|
/* Align with forkawesome */
|
||||||
|
font-size: 14px;
|
||||||
|
fill: var(--primary);
|
||||||
|
|
||||||
|
&[aria-disabled="true"], &[aria-disabled=""] {
|
||||||
|
fill: var(--disabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
svg {
|
||||||
|
height: 2ex;
|
||||||
|
width: 1em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
img {
|
img {
|
||||||
display: inline;
|
display: inline;
|
||||||
height: 1.5em;
|
height: 1.5em;
|
||||||
|
|
@ -125,3 +142,35 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.jdrupes-vmoperator-vmmgmt.jdrupes-vmoperator-vmmgmt-confirm-reset {
|
||||||
|
|
||||||
|
[role=button] {
|
||||||
|
padding: 0.25rem;
|
||||||
|
|
||||||
|
&:not([aria-disabled]):hover, &[aria-disabled='false']:hover {
|
||||||
|
box-shadow: var(--darkening);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
span[role="button"].svg-icon {
|
||||||
|
display: inline-block;
|
||||||
|
line-height: 1;
|
||||||
|
/* Align with forkawesome */
|
||||||
|
font-size: 14px;
|
||||||
|
fill: var(--danger);
|
||||||
|
|
||||||
|
&[aria-disabled="true"], &[aria-disabled=""] {
|
||||||
|
fill: var(--disabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
svg {
|
||||||
|
width: 2.5em;
|
||||||
|
height: 2.5em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue