Rename vmviewer to vmaccess.

This commit is contained in:
Michael Lipp 2024-11-23 12:50:25 +01:00
parent 00adeba625
commit 27f983c18d
36 changed files with 58 additions and 56 deletions

View file

@ -31,8 +31,8 @@ dependencies {
runtimeOnly 'org.slf4j:slf4j-jdk14:[2.0.7,3)'
runtimeOnly 'org.apache.logging.log4j:log4j-to-jul:2.20.0'
runtimeOnly project(':org.jdrupes.vmoperator.vmaccess')
runtimeOnly project(':org.jdrupes.vmoperator.vmconlet')
runtimeOnly project(':org.jdrupes.vmoperator.vmviewer')
runtimeOnly project(':org.jdrupes.vmoperator.poolaccess')
}

View file

@ -0,0 +1 @@
org.jdrupes.vmoperator.vmaccess.VmAccessFactory

View file

@ -1,9 +1,9 @@
<div
class="jdrupes-vmoperator-vmviewer jdrupes-vmoperator-vmviewer-confirm-reset">
class="jdrupes-vmoperator-vmaccess jdrupes-vmoperator-vmaccess-confirm-reset">
<p>${_("confirmResetMsg")}</p>
<p>
<span role="button" tabindex="0" class="svg-icon"
onclick="orgJDrupesVmOperatorVmViewer.confirmReset('${conletType}', '${conletId}')">
onclick="orgJDrupesVmOperatorVmAccess.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"/>

View file

@ -1,7 +1,7 @@
<div title="${_("conletName")}"
class="jdrupes-vmoperator-vmviewer jdrupes-vmoperator-vmviewer-edit"
data-jgwc-on-load="orgJDrupesVmOperatorVmViewer.initEdit"
data-jgwc-on-action="orgJDrupesVmOperatorVmViewer.applyEdit"
class="jdrupes-vmoperator-vmaccess jdrupes-vmoperator-vmaccess-edit"
data-jgwc-on-load="orgJDrupesVmOperatorVmAccess.initEdit"
data-jgwc-on-action="orgJDrupesVmOperatorVmAccess.applyEdit"
data-jgwc-on-unload="JGConsole.jgwc.unmountVueApps">
<form :id="formId" ref="formDom" onsubmit="return false;">
<section>

View file

@ -1,7 +1,7 @@
<div
class="jdrupes-vmoperator-vmviewer jdrupes-vmoperator-vmviewer-preview"
class="jdrupes-vmoperator-vmaccess jdrupes-vmoperator-vmaccess-preview"
data-conlet-grid-rows="2" data-conlet-grid-columns="2"
data-jgwc-on-load="orgJDrupesVmOperatorVmViewer.initPreview"
data-jgwc-on-load="orgJDrupesVmOperatorVmAccess.initPreview"
data-jgwc-on-unload="JGConsole.jgwc.unmountVueApps"
data-conlet-resource-base="${conletResource('')}">
</div>

View file

@ -1,4 +1,4 @@
conletName = VM-Konsole
conletName = VM-Zugriff
okayLabel = Anwenden und Schließen
Select\ VM = VM auswählen

View file

@ -1,8 +1,8 @@
import typescript from 'rollup-plugin-typescript2';
import postcss from 'rollup-plugin-postcss';
let packagePath = "org/jdrupes/vmoperator/vmviewer";
let baseName = "VmViewer"
let packagePath = "org/jdrupes/vmoperator/vmaccess";
let baseName = "VmAccess"
let module = "build/generated/resources/" + packagePath
+ "/" + baseName + "-functions.js";

View file

@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.jdrupes.vmoperator.vmviewer;
package org.jdrupes.vmoperator.vmaccess;
import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonProperty;
@ -89,7 +89,7 @@ import org.jgrapes.webconsole.base.events.UpdateConletType;
import org.jgrapes.webconsole.base.freemarker.FreeMarkerConlet;
/**
* The Class VmViewer. The component supports the following
* The Class {@link VmAccess}. The component supports the following
* configuration properties:
*
* * `displayResource`: a map with the following entries:
@ -107,13 +107,13 @@ import org.jgrapes.webconsole.base.freemarker.FreeMarkerConlet;
*/
@SuppressWarnings({ "PMD.DataflowAnomalyAnalysis", "PMD.ExcessiveImports",
"PMD.CouplingBetweenObjects", "PMD.GodClass", "PMD.TooManyMethods" })
public class VmViewer extends FreeMarkerConlet<VmViewer.ViewerModel> {
public class VmAccess extends FreeMarkerConlet<VmAccess.ViewerModel> {
private static final String VM_NAME_PROPERTY = "vmName";
private static final String RENDERED
= VmViewer.class.getName() + ".rendered";
= VmAccess.class.getName() + ".rendered";
private static final String PENDING
= VmViewer.class.getName() + ".pending";
= VmAccess.class.getName() + ".pending";
private static final Set<RenderMode> MODES = RenderMode.asSet(
RenderMode.Preview, RenderMode.Edit);
private static final Set<RenderMode> MODES_FOR_GENERATED = RenderMode.asSet(
@ -140,7 +140,7 @@ public class VmViewer extends FreeMarkerConlet<VmViewer.ViewerModel> {
* on by default and that {@link Manager#fire(Event, Channel...)}
* sends the event to
*/
public VmViewer(Channel componentChannel) {
public VmAccess(Channel componentChannel) {
super(componentChannel);
}
@ -222,7 +222,7 @@ public class VmViewer extends FreeMarkerConlet<VmViewer.ViewerModel> {
.addRenderMode(RenderMode.Preview)
.addScript(new ScriptResource().setScriptType("module")
.setScriptUri(event.renderSupport().conletResource(
type(), "VmViewer-functions.js"))));
type(), "VmAccess-functions.js"))));
channel.session().put(RENDERED, new HashSet<>());
}
@ -259,7 +259,7 @@ public class VmViewer extends FreeMarkerConlet<VmViewer.ViewerModel> {
foundMissing = true;
}
fire(new AddConletRequest(event.event().event().renderSupport(),
VmViewer.class.getName(),
VmAccess.class.getName(),
RenderMode.asSet(RenderMode.Preview))
.addProperty(VM_NAME_PROPERTY, vmName),
connection);
@ -283,7 +283,7 @@ public class VmViewer extends FreeMarkerConlet<VmViewer.ViewerModel> {
private String storagePath(Session session, String conletId) {
return "/" + WebConsoleUtils.userFromSession(session)
.map(ConsoleUser::getName).orElse("")
+ "/" + VmViewer.class.getName() + "/" + conletId;
+ "/" + VmAccess.class.getName() + "/" + conletId;
}
@Override
@ -365,7 +365,7 @@ public class VmViewer extends FreeMarkerConlet<VmViewer.ViewerModel> {
// Render
Template tpl
= freemarkerConfig().getTemplate("VmViewer-preview.ftl.html");
= freemarkerConfig().getTemplate("VmAccess-preview.ftl.html");
channel.respond(new RenderConlet(type(), conletId,
processTemplate(event, tpl,
fmModel(event, channel, conletId, model)))
@ -383,7 +383,7 @@ public class VmViewer extends FreeMarkerConlet<VmViewer.ViewerModel> {
}
if (event.renderAs().contains(RenderMode.Edit)) {
Template tpl = freemarkerConfig()
.getTemplate("VmViewer-edit.ftl.html");
.getTemplate("VmAccess-edit.ftl.html");
var fmModel = fmModel(event, channel, conletId, model);
fmModel.put("vmNames", accessibleVms(channel));
channel.respond(new OpenModalDialog(type(), conletId,
@ -633,7 +633,7 @@ public class VmViewer extends FreeMarkerConlet<VmViewer.ViewerModel> {
ResourceBundle resourceBundle) throws TemplateNotFoundException,
MalformedTemplateNameException, ParseException, IOException {
Template tpl = freemarkerConfig()
.getTemplate("VmViewer-confirmReset.ftl.html");
.getTemplate("VmAccess-confirmReset.ftl.html");
channel.respond(new OpenModalDialog(type(), model.getConletId(),
processTemplate(event, tpl,
fmModel(event, channel, model.getConletId(), model)))

View file

@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.jdrupes.vmoperator.vmviewer;
package org.jdrupes.vmoperator.vmaccess;
import java.util.Map;
import java.util.Optional;
@ -25,9 +25,9 @@ import org.jgrapes.core.ComponentType;
import org.jgrapes.webconsole.base.ConletComponentFactory;
/**
* The factory service for {@link VmViewer}s.
* The factory service for {@link VmAccess}s.
*/
public class VmViewerFactory implements ConletComponentFactory {
public class VmAccessFactory implements ConletComponentFactory {
/*
* (non-Javadoc)
@ -36,7 +36,7 @@ public class VmViewerFactory implements ConletComponentFactory {
*/
@Override
public Class<? extends ComponentType> componentType() {
return VmViewer.class;
return VmAccess.class;
}
/*
@ -48,7 +48,7 @@ public class VmViewerFactory implements ConletComponentFactory {
@Override
public Optional<ComponentType> create(Channel componentChannel,
Map<?, ?> properties) {
return Optional.of(new VmViewer(componentChannel));
return Optional.of(new VmAccess(componentChannel));
}
}

View file

@ -24,12 +24,12 @@ import JgwcPlugin, { JGWC } from "jgwc";
import { provideApi, getApi } from "aash-plugin";
import l10nBundles from "l10nBundles";
import "./VmViewer-style.scss";
import "./VmAccess-style.scss";
// For global access
declare global {
interface Window {
orgJDrupesVmOperatorVmViewer: {
orgJDrupesVmOperatorVmAccess: {
initPreview?: (previewDom: HTMLElement, isUpdate: boolean) => void,
initEdit?: (viewDom: HTMLElement, isUpdate: boolean) => void,
applyEdit?: (viewDom: HTMLElement, apply: boolean) => void,
@ -38,7 +38,7 @@ declare global {
}
}
window.orgJDrupesVmOperatorVmViewer = {};
window.orgJDrupesVmOperatorVmAccess = {};
interface Api {
/* eslint-disable @typescript-eslint/no-explicit-any */
@ -51,7 +51,7 @@ const localize = (key: string) => {
l10nBundles, JGWC.lang(), key);
};
window.orgJDrupesVmOperatorVmViewer.initPreview = (previewDom: HTMLElement,
window.orgJDrupesVmOperatorVmAccess.initPreview = (previewDom: HTMLElement,
_isUpdate: boolean) => {
const app = createApp({
setup(_props: object) {
@ -107,7 +107,7 @@ window.orgJDrupesVmOperatorVmViewer.initPreview = (previewDom: HTMLElement,
:title="localize('Open console')"></span><span
style="visibility: hidden;"><img
:src="resourceBase + 'computer.svg'"></span></td>
<td class="jdrupes-vmoperator-vmviewer-preview-action-list">
<td class="jdrupes-vmoperator-vmaccess-preview-action-list">
<span role="button"
:aria-disabled="!startable || !permissions.includes('start')"
tabindex="0" class="fa fa-play" :title="localize('Start VM')"
@ -138,25 +138,25 @@ window.orgJDrupesVmOperatorVmViewer.initPreview = (previewDom: HTMLElement,
app.mount(previewDom);
};
JGConsole.registerConletFunction("org.jdrupes.vmoperator.vmviewer.VmViewer",
JGConsole.registerConletFunction("org.jdrupes.vmoperator.vmaccess.VmAccess",
"updateConfig", function(conletId: string, vmName: string) {
const conlet = JGConsole.findConletPreview(conletId);
if (!conlet) {
return;
}
const api = getApi<Api>(conlet.element().querySelector(
":scope .jdrupes-vmoperator-vmviewer-preview"))!;
":scope .jdrupes-vmoperator-vmaccess-preview"))!;
api.vmName = vmName;
});
JGConsole.registerConletFunction("org.jdrupes.vmoperator.vmviewer.VmViewer",
JGConsole.registerConletFunction("org.jdrupes.vmoperator.vmaccess.VmAccess",
"updateVmDefinition", function(conletId: string, vmDefinition: any) {
const conlet = JGConsole.findConletPreview(conletId);
if (!conlet) {
return;
}
const api = getApi<Api>(conlet.element().querySelector(
":scope .jdrupes-vmoperator-vmviewer-preview"))!;
":scope .jdrupes-vmoperator-vmaccess-preview"))!;
// Add some short-cuts for rendering
vmDefinition.name = vmDefinition.metadata.name;
vmDefinition.currentCpus = vmDefinition.status.cpus;
@ -173,13 +173,13 @@ JGConsole.registerConletFunction("org.jdrupes.vmoperator.vmviewer.VmViewer",
api.vmDefinition = vmDefinition;
});
JGConsole.registerConletFunction("org.jdrupes.vmoperator.vmviewer.VmViewer",
JGConsole.registerConletFunction("org.jdrupes.vmoperator.vmaccess.VmAccess",
"openConsole", function(_conletId: string, mimeType: string, data: string) {
let target = document.getElementById(
"org.jdrupes.vmoperator.vmviewer.VmViewer.target");
"org.jdrupes.vmoperator.vmaccess.VmAccess.target");
if (!target) {
target = document.createElement("iframe");
target.id = "org.jdrupes.vmoperator.vmviewer.VmViewer.target";
target.id = "org.jdrupes.vmoperator.vmaccess.VmAccess.target";
target.setAttribute("name", target.id);
target.setAttribute("style", "display: none;");
document.querySelector("body")!.append(target);
@ -188,7 +188,7 @@ JGConsole.registerConletFunction("org.jdrupes.vmoperator.vmviewer.VmViewer",
window.open(url, target.id);
});
window.orgJDrupesVmOperatorVmViewer.initEdit = (dialogDom: HTMLElement,
window.orgJDrupesVmOperatorVmAccess.initEdit = (dialogDom: HTMLElement,
isUpdate: boolean) => {
if (isUpdate) {
return;
@ -209,7 +209,7 @@ window.orgJDrupesVmOperatorVmViewer.initEdit = (dialogDom: HTMLElement,
const conlet = JGConsole.findConletPreview(conletId);
if (conlet) {
const api = getApi<Api>(conlet.element().querySelector(
":scope .jdrupes-vmoperator-vmviewer-preview"))!;
":scope .jdrupes-vmoperator-vmaccess-preview"))!;
vmNameInput.value = api.vmName;
}
@ -222,7 +222,7 @@ window.orgJDrupesVmOperatorVmViewer.initEdit = (dialogDom: HTMLElement,
app.mount(dialogDom);
}
window.orgJDrupesVmOperatorVmViewer.applyEdit =
window.orgJDrupesVmOperatorVmAccess.applyEdit =
(dialogDom: HTMLElement, apply: boolean) => {
if (!apply) {
return;
@ -233,7 +233,7 @@ window.orgJDrupesVmOperatorVmViewer.applyEdit =
JGConsole.notifyConletModel(conletId, "selectedVm", vmName);
}
window.orgJDrupesVmOperatorVmViewer.confirmReset =
window.orgJDrupesVmOperatorVmAccess.confirmReset =
(conletType: string, conletId: string) => {
JGConsole.instance.closeModalDialog(conletType, conletId);
JGConsole.notifyConletModel(conletId, "resetConfirmed");

View file

@ -19,7 +19,7 @@
/*
* Conlet specific styles.
*/
.jdrupes-vmoperator-vmviewer {
.jdrupes-vmoperator-vmaccess {
span[role="button"].svg-icon {
display: inline-block;
@ -47,7 +47,7 @@
}
}
.jdrupes-vmoperator-vmviewer.jdrupes-vmoperator-vmviewer-preview {
.jdrupes-vmoperator-vmaccess.jdrupes-vmoperator-vmaccess-preview {
img {
height: 3em;
@ -58,7 +58,7 @@
}
}
.jdrupes-vmoperator-vmviewer-preview-action-list {
.jdrupes-vmoperator-vmaccess-preview-action-list {
white-space: nowrap;
}
@ -76,13 +76,13 @@
}
}
.jdrupes-vmoperator-vmviewer.jdrupes-vmoperator-vmviewer-edit {
.jdrupes-vmoperator-vmaccess.jdrupes-vmoperator-vmaccess-edit {
select {
width: 15em;
}
}
.jdrupes-vmoperator-vmviewer.jdrupes-vmoperator-vmviewer-confirm-reset {
.jdrupes-vmoperator-vmaccess.jdrupes-vmoperator-vmaccess-confirm-reset {
p {
text-align: center;
}

View file

@ -1,6 +1,6 @@
/*
* VM-Operator
* Copyright (C) 2023 Michael N. Lipp
* Copyright (C) 2023, 2024 Michael N. Lipp
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
@ -16,4 +16,4 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.jdrupes.vmoperator.vmviewer;
package org.jdrupes.vmoperator.vmaccess;

View file

@ -14,7 +14,7 @@
"aash-plugin": ["./build/unpacked/org/jgrapes/webconsole/provider/jgwcvuecomponents/aash-vue-components/lib/AashPlugin"],
"jgconsole": ["./build/unpacked/org/jgrapes/webconsole/base/JGConsole"],
"jgwc": ["./build/unpacked/org/jgrapes/webconsole/provider/jgwcvuecomponents/jgwc-vue-components/jgwc-components"],
"l10nBundles": ["./src/org/jdrupes/vmoperator/vmviewer/browser/l10nBundles-stub"],
"l10nBundles": ["./src/org/jdrupes/vmoperator/vmaccess/browser/l10nBundles-stub"],
"vue": ["./build/unpacked/org/jgrapes/webconsole/provider/vue/vue/vue"]
}
},

View file

@ -1 +0,0 @@
org.jdrupes.vmoperator.vmviewer.VmViewerFactory

View file

@ -12,6 +12,8 @@ rootProject.name = 'VM-Operator'
include 'org.jdrupes.vmoperator.manager'
include 'org.jdrupes.vmoperator.manager.events'
include 'org.jdrupes.vmoperator.poolaccess'
include 'org.jdrupes.vmoperator.vmaccess'
include 'org.jdrupes.vmoperator.vmconlet'
include 'org.jdrupes.vmoperator.vmviewer'
include 'org.jdrupes.vmoperator.runner.qemu'

View file

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Before After
Before After

View file

@ -11,7 +11,7 @@ The idea of the user view is to provide an intuitive widget that
allows the users to access their own VMs and to optionally start
and stop them.
![VM-Viewer](VmViewer-preview.png)
![VM-Viewer](VmAccess-preview.png)
The configuration options resulting from this seemingly simple
requirement are unexpectedly complex.
@ -62,7 +62,7 @@ objects that either specify a role or a user.
"/ConsoleWeblet":
"/WebConsole":
"/ComponentCollector":
"/VmViewer":
"/VmAccess":
syncPreviewsFor:
- role: user
- user: test