Workplace Widget 5.10.5
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
<script setup lang="ts">
|
||||
import {computed, ref, watch, onBeforeUnmount} from 'vue';
|
||||
import type {HmiWidget} from '../types';
|
||||
import {shouldAutoStartWidget} from './cheerpjAutoStart';
|
||||
|
||||
const props = defineProps<{widget:HmiWidget;demo:boolean}>();
|
||||
const url = computed(()=>String(props.widget.props.jnlpUrl||'').trim());
|
||||
const workplace = computed(()=>props.widget.type==='ui.cheerpj-workplace');
|
||||
const autoStartEnabled = computed(()=>shouldAutoStartWidget(props.widget.type,props.widget.props));
|
||||
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');
|
||||
@@ -49,10 +51,16 @@ function onMessage(e:MessageEvent){
|
||||
status.value=String(data.message||'').slice(0,350);
|
||||
if(data.state==='error')failure.value=status.value;
|
||||
}
|
||||
watch([url,javaVersion,displayMode],stop);
|
||||
watch(()=>props.demo, v=>{if(v)stop();},{immediate:true});
|
||||
watch(()=>[props.demo,props.widget.props.autoStart,url.value] as const,([demo,auto,jnlp])=>{
|
||||
if(!demo&&auto===true&&jnlp&&!launchRequested.value)launch();
|
||||
// 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],()=>{
|
||||
if(!launchRequested.value)return;
|
||||
stop();
|
||||
if(!props.demo && autoStartEnabled.value && url.value)launch();
|
||||
});
|
||||
watch(()=>[props.demo,autoStartEnabled.value,url.value] as const,([demo,enabled,jnlp])=>{
|
||||
if(demo || !enabled){ if(launchRequested.value)stop(); return; }
|
||||
if(jnlp&&!launchRequested.value)launch();
|
||||
},{immediate:true});
|
||||
window.addEventListener('message',onMessage);
|
||||
onBeforeUnmount(()=>window.removeEventListener('message',onMessage));
|
||||
|
||||
@@ -34,7 +34,7 @@ export const widgetCatalog: WidgetDefinition[] = [
|
||||
{type:'ui.metal-panel',label:'Metall-/Carbon-Panel',group:'Gestaltung',icon:'▧',description:'Neon-Paneel mit Überschrift, Badge und frei editierbarem Text',w:6,h:3,props:{title:'Workplan & Details',description:'Auftragsinformationen und Status der aktuellen Station',footer:'iTAC MES / IMSAPI',tag:'PRODUKTION',tone:'cyan'}},
|
||||
{type:'ui.image',label:'Bild / Logo',group:'Gestaltung',icon:'▧',description:'PNG/JPEG/WebP hochladen, frei verschieben und skalieren',w:4,h:3,props:{title:'Bild',assetId:'',objectFit:'contain',background:'#ffffff'}},
|
||||
{type:'ui.cheerpj',label:'CheerpJ · JNLP Anwendung',group:'Integration',icon:'☕',description:'JNLP auf derselben HTTP- oder HTTPS-Origin starten, frei verschieben und skalieren; Java-Web-Start-Anwendung per CheerpJ Core (Lizenz beachten)',w:9,h:7,props:{title:'Java-Anwendung',jnlpUrl:'',javaVersion:8,autoStart:false,displayMode:'fit'}},
|
||||
{type:'ui.cheerpj-workplace',label:'iTAC Workplace · CheerpJ (Java 11)',group:'Integration',icon:'🏭',description:'iTAC Workplace Java-Web-Start-Anwendung; 129 JARs vom selben MES-Host via zugriffsgeschützter Bridge, native RXTX-Funktionen nicht garantiert.',w:12,h:10,props:{title:'iTAC MES Workplace',jnlpUrl:'/backend/api/hmi/v1/cheerpj/workplace/manifest.jnlp',javaVersion:11,autoStart:false,displayMode:'fit'}},
|
||||
{type:'ui.cheerpj-workplace',label:'iTAC Workplace · CheerpJ (Java 11)',group:'Integration',icon:'🏭',description:'iTAC Workplace Java-Web-Start-Anwendung; 129 JARs vom selben MES-Host via zugriffsgeschützter Bridge, native RXTX-Funktionen nicht garantiert.',w:12,h:10,props:{title:'iTAC MES Workplace',jnlpUrl:'/backend/api/hmi/v1/cheerpj/workplace/manifest.jnlp',javaVersion:11,autoStart:true,manualStartOnly:false,displayMode:'fit'}},
|
||||
{type:'ui.script',label:'REST-JavaScript',group:'Entwicklung',icon:'⌘',description:'Sicher isoliertes JavaScript mit REST-GET-Schnittstelle und Ergebnisanzeige',w:6,h:4,props:{title:'REST-Daten',buttonText:'REST ausführen',script:"return await rest.get('/backend/api/hmi/v1/pages');"}},
|
||||
{type:'ui.text',label:'Text / Hinweis',group:'Allgemein',icon:'≡',description:'Hinweistext mit Überschrift',w:4,h:2,props:{title:'Hinweis',text:'Informationen für die Fertigung'}},
|
||||
{type:'ui.table',label:'Universelle Tabelle',group:'Allgemein',icon:'▤',description:'Read-only JSON Tabelle über freigegebene Workbench-API',w:6,h:4,props:{title:'Datentabelle',fields:[]}},
|
||||
|
||||
9
hmi-frontend/src/widgets/cheerpjAutoStart.ts
Normal file
9
hmi-frontend/src/widgets/cheerpjAutoStart.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
/** Runtime startup policy for the CheerpJ widgets.
|
||||
* Historical Workplace exports contain autoStart:false because that used to be the
|
||||
* default. Since V5.10.4 they auto-run unless an editor explicitly selects manual mode.
|
||||
* Generic JNLP widgets remain opt-in.
|
||||
*/
|
||||
export function shouldAutoStartWidget(type:string, props:Record<string,unknown>):boolean {
|
||||
if(type==='ui.cheerpj-workplace')return props.manualStartOnly !== true;
|
||||
return props.autoStart === true;
|
||||
}
|
||||
Reference in New Issue
Block a user