Workplace Widget 5.10.23
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
import {computed, ref, watch, onBeforeUnmount} from 'vue';
|
||||
import type {HmiWidget} from '../types';
|
||||
import {shouldAutoStartWidget} from './cheerpjAutoStart';
|
||||
import {takeWorkplaceCredentials,offerWorkplaceCredentials} from '../workplaceHandoff';
|
||||
|
||||
const props = defineProps<{widget:HmiWidget;demo:boolean}>();
|
||||
const url = computed(()=>String(props.widget.props.jnlpUrl||'').trim());
|
||||
@@ -10,11 +11,22 @@ const autoStartEnabled = computed(()=>shouldAutoStartWidget(props.widget.type,pr
|
||||
const javaVersion = computed(()=>[8,11,17].includes(Number(props.widget.props.javaVersion))?Number(props.widget.props.javaVersion):8);
|
||||
const windowProtocolWarning = window.location.protocol==='http:' && !['localhost','127.0.0.1'].includes(window.location.hostname);
|
||||
const displayMode = computed(()=>['fit','original'].includes(String(props.widget.props.displayMode))?String(props.widget.props.displayMode):'fit');
|
||||
const windowMode = ref<'off'|'diagnose'|'rescue'>('diagnose'); // Client-only; no vendor settings changed.
|
||||
const launchRequested = ref(false);
|
||||
const failure = ref('');
|
||||
const status = ref('');
|
||||
const workplaceAuthStatus=ref('');
|
||||
const manualUser=ref('');
|
||||
const manualPassword=ref('');
|
||||
const manualClient=ref('any');
|
||||
const secureTransfer=window.location.protocol==='https:' || ['localhost','127.0.0.1'].includes(window.location.hostname);
|
||||
const sequence = ref(0);
|
||||
const frame = ref<HTMLIFrameElement|null>(null);
|
||||
// Newer CheerpJ provides improved Java 11/AWT support. The previous runtime
|
||||
// remains selectable while vendor application compatibility is assessed.
|
||||
const runtimeVersion = ref<'5.0'|'4.3'>(workplace.value ? '5.0' : '4.3');
|
||||
const frameSrc = computed(()=>'/backend/hmi/cheerpj-runner.html?runtime='+runtimeVersion.value);
|
||||
const standaloneHref = computed(()=>'/backend/hmi/cheerpj-runner.html?standalone=workplace&runtime='+runtimeVersion.value+'&windows='+windowMode.value);
|
||||
const requestId = computed(()=>`${props.widget.id}-${sequence.value}`);
|
||||
|
||||
function validate():string {
|
||||
@@ -31,26 +43,75 @@ function validate():string {
|
||||
return '';
|
||||
}
|
||||
function launch(){
|
||||
failure.value=validate();status.value='';
|
||||
failure.value=validate();status.value='';workplaceAuthStatus.value='';
|
||||
if(failure.value || props.demo)return;
|
||||
sequence.value+=1;launchRequested.value=true;
|
||||
}
|
||||
function stop(){launchRequested.value=false;status.value='';}
|
||||
function setWindowMode(event:Event){
|
||||
const selected=(event.target as HTMLSelectElement).value;
|
||||
const next=selected==='rescue'?'rescue':selected==='off'?'off':'diagnose';
|
||||
if(windowMode.value===next)return;
|
||||
windowMode.value=next;
|
||||
if(launchRequested.value){stop();launch();}
|
||||
}
|
||||
function setRuntime(event:Event){
|
||||
const selected=(event.target as HTMLSelectElement).value;
|
||||
const next=selected==='4.3'?'4.3':'5.0';
|
||||
if(runtimeVersion.value===next)return;
|
||||
runtimeVersion.value=next;
|
||||
if(launchRequested.value){stop();launch();}
|
||||
}
|
||||
async function openFullscreen(){
|
||||
const host=document.getElementById('cheerpj-'+props.widget.id);
|
||||
if(host?.requestFullscreen)await host.requestFullscreen();
|
||||
}
|
||||
function onFrameLoad(){
|
||||
if(!frame.value||!launchRequested.value)return;
|
||||
frame.value.contentWindow?.postMessage({type:'hmi-cheerpj-launch',requestId:requestId.value,jnlpUrl:new URL(url.value,window.location.origin).href,javaVersion:javaVersion.value,workplace:workplace.value,displayMode:displayMode.value},window.location.origin);
|
||||
frame.value.contentWindow?.postMessage({type:'hmi-cheerpj-launch',requestId:requestId.value,jnlpUrl:new URL(url.value,window.location.origin).href,javaVersion:javaVersion.value,workplace:workplace.value,displayMode:displayMode.value,windowMode:windowMode.value,browserCredentials:workplace.value && secureTransfer},window.location.origin);
|
||||
}
|
||||
function offerManualWorkplaceLogin(){
|
||||
if(!secureTransfer){workplaceAuthStatus.value='Passwortübergabe erfordert HTTPS.';return;}
|
||||
if(!manualUser.value.trim()||!manualPassword.value||!manualClient.value.trim()){
|
||||
workplaceAuthStatus.value='Bitte Benutzer, Passwort und Mandant angeben.';return;
|
||||
}
|
||||
offerWorkplaceCredentials(manualUser.value.trim(),manualPassword.value,manualClient.value.trim());
|
||||
manualPassword.value='';workplaceAuthStatus.value='Anmeldung einmalig vorgemerkt. Workplace neu starten, falls er bereits läuft.';
|
||||
if(launchRequested.value){stop();launch();}
|
||||
}
|
||||
function onMessage(e:MessageEvent){
|
||||
if(e.origin!==window.location.origin||e.source!==frame.value?.contentWindow)return;
|
||||
const data=e.data;
|
||||
if(!data||data.type!=='hmi-cheerpj-state'||data.requestId!==requestId.value)return;
|
||||
if(!data||data.requestId!==requestId.value)return;
|
||||
if(!workplace.value && data.type!=='hmi-cheerpj-state')return;
|
||||
if(data.type==='hmi-cheerpj-credential-request'){
|
||||
// Only the explicitly selected, same-origin iframe can consume the offer.
|
||||
// Never hand credentials to an unrelated JNLP widget or an arbitrary frame.
|
||||
const credentials=secureTransfer?takeWorkplaceCredentials():null;
|
||||
if(credentials){
|
||||
frame.value?.contentWindow?.postMessage({type:'hmi-cheerpj-credentials',requestId:requestId.value,
|
||||
username:credentials.username,password:credentials.password,client:credentials.client},window.location.origin);
|
||||
workplaceAuthStatus.value='Zugangsdaten an Workplace übergeben; MES-Anmeldung wird geprüft.';
|
||||
}else{
|
||||
frame.value?.contentWindow?.postMessage({type:'hmi-cheerpj-credentials-unavailable',requestId:requestId.value},window.location.origin);
|
||||
workplaceAuthStatus.value='Keine einmaligen Browser-Anmeldedaten vorhanden. Bei Bedarf unten erneut eingeben.';
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(data.type==='hmi-cheerpj-auth-result'){
|
||||
const state=Number(data.code);
|
||||
workplaceAuthStatus.value=state===1?'Workplace-MES-Anmeldung erfolgreich bestätigt.'
|
||||
:state===2?'Workplace-MES-Anmeldung abgelehnt. Anmeldedaten prüfen.'
|
||||
:state===3?'Workplace hatte bereits eine eigene MES-Anmeldung.'
|
||||
:state===4?'Workplace-Anmeldedaten abgelaufen oder MES-Service nicht bereit.'
|
||||
:'Workplace-Anmeldebridge fehlgeschlagen. Konsole prüfen.';
|
||||
return;
|
||||
}
|
||||
if(data.type!=='hmi-cheerpj-state')return;
|
||||
status.value=String(data.message||'').slice(0,350);
|
||||
if(data.state==='error')failure.value=status.value;
|
||||
}
|
||||
|
||||
// The workplace starts automatically in runtime, also for legacy templates with autoStart:false.
|
||||
// The designer never starts a VM. A manual stop lasts until the widget/page is reopened.
|
||||
watch([url,javaVersion,displayMode],()=>{
|
||||
@@ -70,16 +131,40 @@ onBeforeUnmount(()=>window.removeEventListener('message',onMessage));
|
||||
<div class="cheerpj-toolbar">
|
||||
<span class="cheerpj-caption">{{String(widget.props.title||'JNLP-Anwendung')}}</span>
|
||||
<span class="cheerpj-badge">{{workplace?'iTAC Workplace · ':''}}CheerpJ {{javaVersion}}</span>
|
||||
<label v-if="!demo && workplace" class="cheerpj-runtime-picker">CheerpJ
|
||||
<select :value="runtimeVersion" aria-label="CheerpJ Laufzeitversion" @change.stop="setRuntime">
|
||||
<option value="5.0">5.0</option><option value="4.3">4.3 (Fallback)</option>
|
||||
</select>
|
||||
</label>
|
||||
<label v-if="!demo && workplace" class="cheerpj-runtime-picker">Fenster
|
||||
<select :value="windowMode" aria-label="Swing Fensterdiagnose" @change.stop="setWindowMode">
|
||||
<option value="diagnose">Diagnose</option><option value="rescue">Dialoge zurückholen</option><option value="off">Aus</option>
|
||||
</select>
|
||||
</label>
|
||||
<a v-if="!demo && workplace" class="cheerpj-open-window" :href="standaloneHref" target="_blank" rel="noopener noreferrer" @click.stop>↗ Eigenes Fenster</a>
|
||||
<button v-if="!demo && workplace" type="button" @click.stop="openFullscreen">⛶ Vollbild</button>
|
||||
<button v-if="!demo && !launchRequested" type="button" @click.stop="launch" :disabled="!url">▶ Start</button>
|
||||
<template v-else-if="!demo"><button type="button" @click.stop="launch">↻ Neustart</button><button type="button" @click.stop="stop">■ Stop</button></template>
|
||||
</div>
|
||||
<div v-if="workplace" class="cheerpj-warning">Java 11 · 129 JARs · ResizeBridge V2 · native RXTX-Treiber/JNLP-JVM-Optionen sind nicht garantiert.</div>
|
||||
<div v-if="workplace" class="cheerpj-warning">Java 11 · „Fenster: Diagnose“ protokolliert virtuelle Bildschirmgrenzen und alle Swing-Dialoge. „Dialoge zurückholen“ korrigiert nur außerhalb liegende sichtbare JDialogs; ein JAAS-Fehler wird dadurch nicht behoben.</div>
|
||||
<form v-if="!demo && workplace" class="cheerpj-workplace-login" @submit.prevent="offerManualWorkplaceLogin">
|
||||
<details>
|
||||
<summary>Workplace-Anmeldung (falls Browser-Übergabe nicht verfügbar)</summary>
|
||||
<div class="cheerpj-workplace-login-fields">
|
||||
<label>MES-Benutzer <input v-model.trim="manualUser" autocomplete="username" maxlength="120" required /></label>
|
||||
<label>Passwort <input v-model="manualPassword" type="password" autocomplete="current-password" required /></label>
|
||||
<label>Mandant <input v-model.trim="manualClient" autocomplete="off" maxlength="120" required /></label>
|
||||
<button type="submit" :disabled="!secureTransfer">Einmalig an Workplace übergeben</button>
|
||||
</div>
|
||||
<small>Standardmandant „any“ wie im originalen iTAC-Autologin; Passwort wird nicht gespeichert. Nach der Übergabe läuft eine reguläre MES-Anmeldung.</small>
|
||||
</details>
|
||||
</form>
|
||||
<p v-if="workplace && workplaceAuthStatus" class="cheerpj-status" aria-live="polite">{{workplaceAuthStatus}}</p>
|
||||
<div v-if="!demo && windowProtocolWarning" class="cheerpj-warning">HTTP aktiv: Anmeldedaten und MES-Daten sind nicht transportverschlüsselt. Nur in geschützten Netzen einsetzen.</div>
|
||||
<div v-if="demo" class="cheerpj-placeholder">☕ CheerpJ-Vorschau: Der Java-Client wird erst im Werker-Modus gestartet.<small>{{url||'JNLP-Adresse noch nicht konfiguriert'}}</small></div>
|
||||
<div v-else-if="!launchRequested" class="cheerpj-placeholder">☕ JNLP-Anwendung starten<small>{{url||'Bitte eine JNLP-URL im Designer hinterlegen'}}</small></div>
|
||||
<div v-else class="cheerpj-display-wrapper" :class="{'cheerpj-display-wrapper--original':displayMode==='original'}">
|
||||
<iframe :key="sequence" ref="frame" class="cheerpj-frame" src="/backend/hmi/cheerpj-runner.html" title="CheerpJ Java-Anwendung" allow="clipboard-read; clipboard-write" @load="onFrameLoad" />
|
||||
<iframe :key="sequence" ref="frame" class="cheerpj-frame" :src="frameSrc" title="CheerpJ Java-Anwendung" allow="clipboard-read; clipboard-write" @load="onFrameLoad" />
|
||||
</div>
|
||||
<p v-if="failure" role="alert" class="cheerpj-alert">{{failure}}</p>
|
||||
<p v-else-if="status" aria-live="polite" class="cheerpj-status">{{status}}</p>
|
||||
|
||||
Reference in New Issue
Block a user