Adapt to new webconsole base.

This commit is contained in:
Michael Lipp 2024-10-26 21:11:50 +02:00
parent 80fe921e6e
commit 23703bad3c
4 changed files with 15 additions and 13 deletions

View file

@ -17,7 +17,7 @@ dependencies {
implementation 'org.jgrapes:org.jgrapes.io:[2.12.1,3)' implementation 'org.jgrapes:org.jgrapes.io:[2.12.1,3)'
implementation 'org.jgrapes:org.jgrapes.http:[3.5.0,4)' implementation 'org.jgrapes:org.jgrapes.http:[3.5.0,4)'
implementation 'org.jgrapes:org.jgrapes.webconsole.base:[1.8.0,2)' implementation 'org.jgrapes:org.jgrapes.webconsole.base:[2.0.0,3)'
implementation 'org.jgrapes:org.jgrapes.webconsole.vuejs:[1.5.0,2)' implementation 'org.jgrapes:org.jgrapes.webconsole.vuejs:[1.5.0,2)'
implementation 'org.jgrapes:org.jgrapes.webconsole.rbac:[1.4.0,2)' implementation 'org.jgrapes:org.jgrapes.webconsole.rbac:[1.4.0,2)'
implementation 'org.jgrapes:org.jgrapes.webconlet.oidclogin:[1.7.0,2)' implementation 'org.jgrapes:org.jgrapes.webconlet.oidclogin:[1.7.0,2)'

View file

@ -5,7 +5,7 @@ plugins {
dependencies { dependencies {
implementation project(':org.jdrupes.vmoperator.manager.events') implementation project(':org.jdrupes.vmoperator.manager.events')
implementation 'org.jgrapes:org.jgrapes.webconsole.base:[1.8.0,2)' implementation 'org.jgrapes:org.jgrapes.webconsole.base:[2.0.0.3)'
implementation 'org.jgrapes:org.jgrapes.webconsole.provider.vue:[1,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.jgwcvuecomponents:[1.2,2)'
implementation 'org.jgrapes:org.jgrapes.webconsole.provider.chartjs:[1.2,2)' implementation 'org.jgrapes:org.jgrapes.webconsole.provider.chartjs:[1.2,2)'

View file

@ -5,7 +5,7 @@ plugins {
dependencies { dependencies {
implementation project(':org.jdrupes.vmoperator.manager.events') implementation project(':org.jdrupes.vmoperator.manager.events')
implementation 'org.jgrapes:org.jgrapes.webconsole.base:[1.8.0,2)' implementation 'org.jgrapes:org.jgrapes.webconsole.base:[2.0.0,3)'
implementation 'org.jgrapes:org.jgrapes.webconsole.provider.vue:[1,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.jgwcvuecomponents:[1.2,2)'
implementation 'org.jgrapes:org.jgrapes.webconsole.provider.chartjs:[1.2,2)' implementation 'org.jgrapes:org.jgrapes.webconsole.provider.chartjs:[1.2,2)'

View file

@ -25,6 +25,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive; import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSyntaxException;
import freemarker.core.ParseException; import freemarker.core.ParseException;
import freemarker.template.MalformedTemplateNameException; import freemarker.template.MalformedTemplateNameException;
import freemarker.template.Template; import freemarker.template.Template;
@ -47,8 +48,6 @@ import java.util.ResourceBundle;
import java.util.Set; import java.util.Set;
import java.util.logging.Level; import java.util.logging.Level;
import org.bouncycastle.util.Objects; import org.bouncycastle.util.Objects;
import org.jdrupes.json.JsonBeanDecoder;
import org.jdrupes.json.JsonDecodeException;
import org.jdrupes.vmoperator.common.K8sDynamicModel; import org.jdrupes.vmoperator.common.K8sDynamicModel;
import org.jdrupes.vmoperator.common.K8sObserver; import org.jdrupes.vmoperator.common.K8sObserver;
import org.jdrupes.vmoperator.common.VmDefinitionModel; import org.jdrupes.vmoperator.common.VmDefinitionModel;
@ -153,7 +152,7 @@ public class VmViewer extends FreeMarkerConlet<VmViewer.ViewerModel> {
* *
* @param event the event * @param event the event
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings({ "unchecked", "PMD.AvoidDuplicateLiterals" })
@Handler @Handler
public void onConfigurationUpdate(ConfigurationUpdate event) { public void onConfigurationUpdate(ConfigurationUpdate event) {
event.structured(componentPath()).ifPresent(c -> { event.structured(componentPath()).ifPresent(c -> {
@ -419,16 +418,19 @@ public class VmViewer extends FreeMarkerConlet<VmViewer.ViewerModel> {
if (Strings.isNullOrEmpty(model.vmName())) { if (Strings.isNullOrEmpty(model.vmName())) {
return; return;
} }
channelTracker.associated(model.vmName()).ifPresent(vmDef -> { channelTracker.value(model.vmName()).ifPresent(item -> {
try { try {
var def = JsonBeanDecoder.create(vmDef.data().toString()) var vmDef = item.associated();
.readObject(); @SuppressWarnings("unchecked")
def.setField("userPermissions", var def = (Map<String, Object>) item.channel().client()
.getJSON().getGson()
.fromJson(vmDef.data().toString(), Map.class);
def.put("userPermissions",
permissions(vmDef, channel.session()).stream() permissions(vmDef, channel.session()).stream()
.map(Permission::toString).toList()); .map(Permission::toString).toList());
channel.respond(new NotifyConletView(type(), channel.respond(new NotifyConletView(type(),
model.getConletId(), "updateVmDefinition", def)); model.getConletId(), "updateVmDefinition", def));
} catch (JsonDecodeException e) { } catch (JsonSyntaxException e) {
logger.log(Level.SEVERE, e, logger.log(Level.SEVERE, e,
() -> "Failed to serialize VM definition"); () -> "Failed to serialize VM definition");
} }
@ -458,7 +460,7 @@ public class VmViewer extends FreeMarkerConlet<VmViewer.ViewerModel> {
"PMD.AvoidInstantiatingObjectsInLoops", "PMD.AvoidDuplicateLiterals", "PMD.AvoidInstantiatingObjectsInLoops", "PMD.AvoidDuplicateLiterals",
"PMD.ConfusingArgumentToVarargsMethod" }) "PMD.ConfusingArgumentToVarargsMethod" })
public void onVmDefChanged(VmDefChanged event, VmChannel channel) public void onVmDefChanged(VmDefChanged event, VmChannel channel)
throws JsonDecodeException, IOException { throws IOException {
var vmDef = new VmDefinitionModel(channel.client().getJSON() var vmDef = new VmDefinitionModel(channel.client().getJSON()
.getGson(), event.vmDefinition().data()); .getGson(), event.vmDefinition().data());
GsonPtr.to(vmDef.data()).to("metadata").get(JsonObject.class) GsonPtr.to(vmDef.data()).to("metadata").get(JsonObject.class)
@ -547,7 +549,7 @@ public class VmViewer extends FreeMarkerConlet<VmViewer.ViewerModel> {
private void selectVm(NotifyConletModel event, ConsoleConnection channel, private void selectVm(NotifyConletModel event, ConsoleConnection channel,
ViewerModel model) throws JsonProcessingException { ViewerModel model) throws JsonProcessingException {
model.setVmName(event.params().asString(0)); model.setVmName(event.param(0));
String jsonState = objectMapper.writeValueAsString(model); String jsonState = objectMapper.writeValueAsString(model);
channel.respond(new KeyValueStoreUpdate().update(storagePath( channel.respond(new KeyValueStoreUpdate().update(storagePath(
channel.session(), model.getConletId()), jsonState)); channel.session(), model.getConletId()), jsonState));