This commit is contained in:
parent
0a1f89a270
commit
6a3f6c5e3e
19 changed files with 275 additions and 36 deletions
|
|
@ -5,7 +5,7 @@ plugins {
|
|||
dependencies {
|
||||
implementation project(':org.jdrupes.vmoperator.manager.events')
|
||||
|
||||
implementation 'org.jgrapes:org.jgrapes.webconsole.base:[1.3.0,2)'
|
||||
implementation 'org.jgrapes:org.jgrapes.webconsole.base:[1.7.0,2)'
|
||||
implementation 'org.jgrapes:org.jgrapes.webconsole.provider.vue:[1,2)'
|
||||
implementation 'org.jgrapes:org.jgrapes.webconsole.provider.jgwcvuecomponents:[1.2,2)'
|
||||
implementation 'org.jgrapes:org.jgrapes.webconsole.provider.chartjs:[1.2,2)'
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
<div
|
||||
class="jdrupes-vmoperator-vmviewer jdrupes-vmoperator-vmviewer-confirm-reset">
|
||||
<p>${_("confirmResetMsg")}</p>
|
||||
<p>
|
||||
<span role="button" tabindex="0" class="svg-icon"
|
||||
onclick="orgJDrupesVmOperatorVmViewer.confirmReset('${conletType}', '${conletId}')">
|
||||
<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>
|
||||
|
|
@ -1,7 +1,8 @@
|
|||
<div title="${_("conletName")}" class="jdrupes-vmoperator-vmviewer-edit"
|
||||
data-jgwc-on-load="orgJDrupesVmOperatorVmViewer.initEdit"
|
||||
data-jgwc-on-action="orgJDrupesVmOperatorVmViewer.applyEdit"
|
||||
data-jgwc-on-unload="JGConsole.jgwc.unmountVueApps">
|
||||
<div title="${_("conletName")}"
|
||||
class="jdrupes-vmoperator-vmviewer jdrupes-vmoperator-vmviewer-edit"
|
||||
data-jgwc-on-load="orgJDrupesVmOperatorVmViewer.initEdit"
|
||||
data-jgwc-on-action="orgJDrupesVmOperatorVmViewer.applyEdit"
|
||||
data-jgwc-on-unload="JGConsole.jgwc.unmountVueApps">
|
||||
<form :id="formId" ref="formDom" onsubmit="return false;">
|
||||
<section>
|
||||
<span>{{ localize("Select VM") }}</span>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<div class="jdrupes-vmoperator-vmviewer jdrupes-vmoperator-vmviewer-preview"
|
||||
<div
|
||||
class="jdrupes-vmoperator-vmviewer jdrupes-vmoperator-vmviewer-preview"
|
||||
data-conlet-grid-rows="2" data-conlet-grid-columns="2"
|
||||
data-jgwc-on-load="orgJDrupesVmOperatorVmViewer.initPreview"
|
||||
data-jgwc-on-unload="JGConsole.jgwc.unmountVueApps"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
conletName = VM Console
|
||||
|
||||
okayLabel = Apply and Close
|
||||
|
||||
confirmResetTitle = Confirm reset
|
||||
confirmResetMsg = Resetting the VM may cause loss of data. \
|
||||
Please confirm to continue.
|
||||
|
|
|
|||
|
|
@ -5,4 +5,9 @@ Select\ VM = VM ausw
|
|||
|
||||
Start\ VM = VM starten
|
||||
Stop\ VM = VM anhalten
|
||||
Reset\ VM = VM zurücksetzen
|
||||
Open\ console = Konsole anzeigen
|
||||
|
||||
confirmResetTitle = Zurücksetzen bestätigen
|
||||
confirmResetMsg = Zurücksetzen der VM kann zu Datenverlust führen. \
|
||||
Bitte bestätigen um fortzufahren.
|
||||
|
|
|
|||
|
|
@ -0,0 +1,42 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
width="1541.33"
|
||||
height="1535.5083"
|
||||
version="1.1"
|
||||
id="svg1"
|
||||
sodipodi:docname="reset-icon2.svg"
|
||||
inkscape:version="1.3.2 (091e20ef0f, 2023-11-25)"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg">
|
||||
<defs
|
||||
id="defs1" />
|
||||
<sodipodi:namedview
|
||||
id="namedview1"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:showpageshadow="2"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:deskcolor="#d1d1d1"
|
||||
inkscape:zoom="0.34987054"
|
||||
inkscape:cx="704.54631"
|
||||
inkscape:cy="711.69181"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1011"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="32"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="svg1" />
|
||||
<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"
|
||||
id="path1"
|
||||
sodipodi:nodetypes="sssssscss" />
|
||||
<path
|
||||
style="color:#000000;fill:#000000;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0;-inkscape-stroke:none;paint-order:fill markers stroke"
|
||||
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"
|
||||
id="path2"
|
||||
sodipodi:nodetypes="sssscccssscscscs" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.4 KiB |
|
|
@ -54,6 +54,7 @@ import org.jdrupes.vmoperator.common.VmDefinitionModel.Permission;
|
|||
import org.jdrupes.vmoperator.manager.events.ChannelCache;
|
||||
import org.jdrupes.vmoperator.manager.events.GetDisplayPassword;
|
||||
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.VmDefChanged;
|
||||
import org.jdrupes.vmoperator.util.GsonPtr;
|
||||
|
|
@ -93,7 +94,7 @@ import org.jgrapes.webconsole.base.freemarker.FreeMarkerConlet;
|
|||
* The Class VmViewer.
|
||||
*/
|
||||
@SuppressWarnings({ "PMD.DataflowAnomalyAnalysis", "PMD.ExcessiveImports",
|
||||
"PMD.CouplingBetweenObjects", "PMD.GodClass" })
|
||||
"PMD.CouplingBetweenObjects", "PMD.GodClass", "PMD.TooManyMethods" })
|
||||
public class VmViewer extends FreeMarkerConlet<VmViewer.ViewerModel> {
|
||||
|
||||
private static final String VM_NAME_PROPERTY = "vmName";
|
||||
|
|
@ -465,12 +466,12 @@ public class VmViewer extends FreeMarkerConlet<VmViewer.ViewerModel> {
|
|||
|
||||
@Override
|
||||
@SuppressWarnings({ "PMD.AvoidDecimalLiteralsInBigDecimalConstructor",
|
||||
"PMD.ConfusingArgumentToVarargsMethod" })
|
||||
"PMD.ConfusingArgumentToVarargsMethod", "PMD.NcssCount" })
|
||||
protected void doUpdateConletState(NotifyConletModel event,
|
||||
ConsoleConnection channel, ViewerModel model)
|
||||
throws Exception {
|
||||
event.stop();
|
||||
var both = Optional.ofNullable(event.params().asString(0))
|
||||
var both = Optional.ofNullable(model.vmName())
|
||||
.flatMap(vm -> channelManager.both(vm));
|
||||
if (both.isEmpty()) {
|
||||
return;
|
||||
|
|
@ -479,6 +480,7 @@ public class VmViewer extends FreeMarkerConlet<VmViewer.ViewerModel> {
|
|||
var vmDef = both.get().associated;
|
||||
var vmName = vmDef.metadata().getName();
|
||||
var perms = permissions(vmDef, channel.session());
|
||||
var resourceBundle = resourceBundle(channel.locale());
|
||||
switch (event.method()) {
|
||||
case "selectedVm":
|
||||
model.setVmName(event.params().asString(0));
|
||||
|
|
@ -497,6 +499,16 @@ public class VmViewer extends FreeMarkerConlet<VmViewer.ViewerModel> {
|
|||
fire(new ModifyVm(vmName, "state", "Stopped", vmChannel));
|
||||
}
|
||||
break;
|
||||
case "reset":
|
||||
if (perms.contains(Permission.RESET)) {
|
||||
confirmReset(event, channel, model, resourceBundle);
|
||||
}
|
||||
break;
|
||||
case "resetConfirmed":
|
||||
if (perms.contains(Permission.RESET)) {
|
||||
fire(new ResetVm(vmName), vmChannel);
|
||||
}
|
||||
break;
|
||||
case "openConsole":
|
||||
if (perms.contains(Permission.ACCESS_CONSOLE)) {
|
||||
var pwQuery = Event.onCompletion(new GetDisplayPassword(vmDef),
|
||||
|
|
@ -577,6 +589,20 @@ public class VmViewer extends FreeMarkerConlet<VmViewer.ViewerModel> {
|
|||
.findFirst().or(() -> addrs.stream().findFirst());
|
||||
}
|
||||
|
||||
private void confirmReset(NotifyConletModel event,
|
||||
ConsoleConnection channel, ViewerModel model,
|
||||
ResourceBundle resourceBundle) throws TemplateNotFoundException,
|
||||
MalformedTemplateNameException, ParseException, IOException {
|
||||
Template tpl = freemarkerConfig()
|
||||
.getTemplate("VmViewer-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
|
||||
protected boolean doSetLocale(SetLocale event, ConsoleConnection channel,
|
||||
String conletId) throws Exception {
|
||||
|
|
|
|||
|
|
@ -31,8 +31,9 @@ declare global {
|
|||
interface Window {
|
||||
orgJDrupesVmOperatorVmViewer: {
|
||||
initPreview?: (previewDom: HTMLElement, isUpdate: boolean) => void,
|
||||
initEdit?: (viewDom: HTMLElement, isUpdate: boolean) => void
|
||||
applyEdit?: (viewDom: HTMLElement, apply: boolean) => void
|
||||
initEdit?: (viewDom: HTMLElement, isUpdate: boolean) => void,
|
||||
applyEdit?: (viewDom: HTMLElement, apply: boolean) => void,
|
||||
confirmReset?: (conletType: string, conletId: string) => void
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -74,7 +75,7 @@ window.orgJDrupesVmOperatorVmViewer.initPreview = (previewDom: HTMLElement,
|
|||
provideApi(previewDom, previewApi);
|
||||
|
||||
const vmAction = (vmName: string, action: string) => {
|
||||
JGConsole.notifyConletModel(conletId, action, vmName);
|
||||
JGConsole.notifyConletModel(conletId, action);
|
||||
};
|
||||
|
||||
return { localize, resourceBase, vmDef, vmAction };
|
||||
|
|
@ -83,7 +84,7 @@ window.orgJDrupesVmOperatorVmViewer.initPreview = (previewDom: HTMLElement,
|
|||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><img role=button
|
||||
<td rowspan="2"><img role=button
|
||||
:aria-disabled="!vmDef.running || !vmDef.userPermissions
|
||||
|| !vmDef.userPermissions.includes('accessConsole')"
|
||||
v-on:click="vmAction(vmDef.name, 'openConsole')"
|
||||
|
|
@ -106,6 +107,15 @@ window.orgJDrupesVmOperatorVmViewer.initPreview = (previewDom: HTMLElement,
|
|||
v-on:click="vmAction(vmDef.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="!vmDef.running || !vmDef.userPermissions.includes('reset')"
|
||||
tabindex="0" class="svg-icon" :title="localize('Reset VM')"
|
||||
v-on:click="vmAction(vmDef.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>
|
||||
</td>
|
||||
<td v-else>
|
||||
</td>
|
||||
|
|
@ -211,3 +221,9 @@ window.orgJDrupesVmOperatorVmViewer.applyEdit =
|
|||
const vmName = getApi<ref<string>>(dialogDom!)!.value;
|
||||
JGConsole.notifyConletModel(conletId, "selectedVm", vmName);
|
||||
}
|
||||
|
||||
window.orgJDrupesVmOperatorVmViewer.confirmReset =
|
||||
(conletType: string, conletId: string) => {
|
||||
JGConsole.instance.closeModalDialog(conletType, conletId);
|
||||
JGConsole.notifyConletModel(conletId, "resetConfirmed");
|
||||
}
|
||||
|
|
@ -19,7 +19,24 @@
|
|||
/*
|
||||
* Conlet specific styles.
|
||||
*/
|
||||
.jdrupes-vmoperator-vmviewer-preview {
|
||||
.jdrupes-vmoperator-vmviewer {
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
[role=button] {
|
||||
padding: 0.25rem;
|
||||
|
|
@ -28,7 +45,10 @@
|
|||
box-shadow: var(--darkening);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.jdrupes-vmoperator-vmviewer.jdrupes-vmoperator-vmviewer-preview {
|
||||
|
||||
img {
|
||||
height: 3em;
|
||||
padding: 0.25rem;
|
||||
|
|
@ -37,14 +57,30 @@
|
|||
opacity: 0.4;
|
||||
}
|
||||
}
|
||||
|
||||
.jdrupes-vmoperator-vmviewer-preview-action-list {
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
.jdrupes-vmoperator-vmviewer-preview-action-list {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.jdrupes-vmoperator-vmviewer-edit {
|
||||
.jdrupes-vmoperator-vmviewer.jdrupes-vmoperator-vmviewer-edit {
|
||||
select {
|
||||
width: 15em;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.jdrupes-vmoperator-vmviewer.jdrupes-vmoperator-vmviewer-confirm-reset {
|
||||
p {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
span[role="button"].svg-icon {
|
||||
fill: var(--danger);
|
||||
|
||||
svg {
|
||||
width: 2.5em;
|
||||
height: 2.5em;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue