Add assignment based on last usage.

This commit is contained in:
Michael Lipp 2025-01-25 13:35:51 +01:00
parent 877d4c69cd
commit 5d722abd2e
9 changed files with 186 additions and 32 deletions

View file

@ -5,3 +5,4 @@ okayLabel = Apply and Close
confirmResetTitle = Confirm reset
confirmResetMsg = Resetting the VM may cause loss of data. \
Please confirm to continue.
poolEmptyNotification = No VM available. Please consult your administrator.

View file

@ -11,3 +11,6 @@ Open\ console = Konsole anzeigen
confirmResetTitle = Zurücksetzen bestätigen
confirmResetMsg = Zurücksetzen der VM kann zu Datenverlust führen. \
Bitte bestätigen um fortzufahren.
poolEmptyNotification = Keine VM verfügbar. Wenden Sie sich bitte an den \
Systemadministrator.

View file

@ -86,6 +86,7 @@ import org.jgrapes.webconsole.base.events.ConsoleConfigured;
import org.jgrapes.webconsole.base.events.ConsolePrepared;
import org.jgrapes.webconsole.base.events.ConsoleReady;
import org.jgrapes.webconsole.base.events.DeleteConlet;
import org.jgrapes.webconsole.base.events.DisplayNotification;
import org.jgrapes.webconsole.base.events.NotifyConletModel;
import org.jgrapes.webconsole.base.events.NotifyConletView;
import org.jgrapes.webconsole.base.events.OpenModalDialog;
@ -717,10 +718,9 @@ public class VmAccess extends FreeMarkerConlet<VmAccess.ResourceModel> {
}
}
@Override
@SuppressWarnings({ "PMD.AvoidDecimalLiteralsInBigDecimalConstructor",
"PMD.ConfusingArgumentToVarargsMethod", "PMD.NcssCount",
@SuppressWarnings({ "PMD.NcssCount", "PMD.CognitiveComplexity",
"PMD.AvoidLiteralsInIfCondition" })
@Override
protected void doUpdateConletState(NotifyConletModel event,
ConsoleConnection channel, ResourceModel model) throws Exception {
event.stop();
@ -741,7 +741,11 @@ public class VmAccess extends FreeMarkerConlet<VmAccess.ResourceModel> {
vmData = Optional.ofNullable(appPipeline
.fire(new AssignVm(model.name(), user)).get());
if (vmData.isEmpty()) {
// TODO message
ResourceBundle resourceBundle
= resourceBundle(channel.locale());
channel.respond(new DisplayNotification(
resourceBundle.getString("poolEmptyNotification"),
Map.of("autoClose", 15_000, "type", "Error")));
return;
}
}