Feature/web gui (#15)
Some checks failed
Java CI with Gradle / build (push) Has been cancelled

Add node display.
This commit is contained in:
Michael N. Lipp 2023-10-24 13:23:13 +02:00 committed by GitHub
parent b8e1074150
commit 8567a2f052
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 90 additions and 28 deletions

View file

@ -33,26 +33,33 @@
<tr :class="[(rowIndex % 2) ? 'odd' : 'even']"
:aria-expanded="(entry.name in detailsByName) ? 'true' : 'false'">
<td v-for="key in controller.keys"
v-bind:class="'column-' + key"
v-bind:title="key == 'name' ? entry['name']: false"
v-bind:rowspan="(key == 'name') && $aash.isDisclosed(scopedId(rowIndex)) ? 2 : false">
<aash-disclosure-button v-if="key === 'name'" :type="'div'"
:id-ref="scopedId(rowIndex)">
<span v-html="controller.breakBeforeDots(entry[key])"></span>
</aash-disclosure-button>
<span v-else-if="key === 'running'"
v-html="localize(entry[key] ? 'Yes' : 'No')"></span>
<span v-else-if="key === 'running' && entry[key]"
class="fa fa-check" :title="localize('Yes')"></span>
<span v-else-if="key === 'running' && !entry[key]"
class="fa fa-close" :title="localize('No')"></span>
<span v-else-if="key === 'currentRam'"
v-html="formatMemory(BigInt(entry[key]))"></span>
v-html="formatMemory(entry[key])"></span>
<span v-else
v-html="controller.breakBeforeDots(entry[key])"></span>
</td>
<td class="jdrupes-vmoperator-vmconlet-view-action-list">
<span role="button" v-if="!entry['running']"
<span role="button" v-if="entry.spec.vm.state != 'Running'"
tabindex="0" class="fa fa-play" :title="localize('Start VM')"
v-on:click="vmAction(entry.name, 'start')"></span>
<span role="button" v-if="entry['running']"
<span role="button" v-else class="fa fa-play"
aria-disabled="true" :title="localize('Start VM')"></span>
<span role="button" v-if="entry.spec.vm.state != 'Stopped'"
tabindex="0" class="fa fa-stop" :title="localize('Stop VM')"
v-on:click="vmAction(entry.name, 'stop')"></span>
<span role="button" v-else class="fa fa-stop"
aria-disabled="true" :title="localize('Stop VM')"></span>
</td>
</tr>
<tr :id="scopedId(rowIndex)" v-if="$aash.isDisclosed(scopedId(rowIndex))"

View file

@ -4,6 +4,7 @@ currentCpus = Current CPUs
currentRam = Current RAM
maximumCpus = Maximum CPUs
maximumRam = Maximum RAM
nodeName = Node
requestedCpus = Requested CPUs
requestedRam = Requested RAM
running = Running

View file

@ -5,6 +5,7 @@ currentCpus = Aktuelle CPUs
currentRam = Akuelles RAM
maximumCpus = Maximale CPUs
maximumRam = Maximales RAM
nodeName = Knoten
requestedCpus = Angeforderte CPUs
requestedRam = Angefordertes RAM
vmActions = Aktionen

View file

@ -166,11 +166,12 @@ public class VmConlet extends FreeMarkerConlet<VmConlet.VmsModel> {
public void onVmDefChanged(VmDefChanged event, VmChannel channel)
throws JsonDecodeException {
if (event.type() == Type.DELETED) {
vmInfos.remove(event.vmDefinition().getMetadata().getName());
var vmName = event.vmDefinition().getMetadata().getName();
vmInfos.remove(vmName);
for (var entry : conletIdsByConsoleConnection().entrySet()) {
for (String conletId : entry.getValue()) {
entry.getKey().respond(new NotifyConletView(type(),
conletId, "removeVm"));
conletId, "removeVm", vmName));
}
}
} else {

View file

@ -73,7 +73,7 @@ window.orgJDrupesVmOperatorVmConlet = {};
let vmInfos = reactive(new Map());
window.orgJDrupesVmOperatorVmConlet.initPreview
= (previewDom: HTMLElement, isUpdate: boolean) => {
= (previewDom: HTMLElement, _isUpdate: boolean) => {
const app = createApp({});
app.use(JgwcPlugin, []);
app.config.globalProperties.window = window;
@ -81,7 +81,7 @@ window.orgJDrupesVmOperatorVmConlet.initPreview
};
window.orgJDrupesVmOperatorVmConlet.initView = (viewDom: HTMLElement,
isUpdate: boolean) => {
_isUpdate: boolean) => {
const app = createApp({
setup(_props: any) {
const conletId: string
@ -96,7 +96,8 @@ window.orgJDrupesVmOperatorVmConlet.initView = (viewDom: HTMLElement,
["name", "vmname"],
["running", "running"],
["currentCpus", "currentCpus"],
["currentRam", "currentRam"]
["currentRam", "currentRam"],
["nodeName", "nodeName"]
], {
sortKey: "name",
sortOrder: "up"
@ -127,11 +128,11 @@ window.orgJDrupesVmOperatorVmConlet.initView = (viewDom: HTMLElement,
};
JGConsole.registerConletFunction("org.jdrupes.vmoperator.vmconlet.VmConlet",
"updateVm", function(conletId: String, vmDefinition: any) {
"updateVm", function(_conletId: String, vmDefinition: any) {
// Add some short-cuts for table controller
vmDefinition.name = vmDefinition.metadata.name;
vmDefinition.currentCpus = vmDefinition.status.cpus;
vmDefinition.currentRam = vmDefinition.status.ram;
vmDefinition.currentRam = BigInt(vmDefinition.status.ram);
for (let condition of vmDefinition.status.conditions) {
if (condition.type === "Running") {
vmDefinition.running = condition.status === "True";
@ -143,6 +144,6 @@ JGConsole.registerConletFunction("org.jdrupes.vmoperator.vmconlet.VmConlet",
});
JGConsole.registerConletFunction("org.jdrupes.vmoperator.vmconlet.VmConlet",
"removeVm", function(conletId: String, vmName: String) {
"removeVm", function(_conletId: String, vmName: String) {
vmInfos.delete(vmName);
});

View file

@ -49,3 +49,18 @@
padding-left: 1em;
}
.jdrupes-vmoperator-vmconlet-view-table {
td.column-running {
text-align: center;
span {
&.fa-check {
color: var(--success);
}
&.fa-close {
color: var(--danger);
}
}
}
}