Workplace Widget 5.10.5
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
"test:widget": "node tests/widget-package.mjs",
|
||||
"test:navigation": "node --experimental-strip-types tests/navigation.mjs",
|
||||
"test:bootstrap": "node tests/bootstrap-contract.mjs",
|
||||
"test:cheerpj": "node tests/cheerpj-runner.mjs",
|
||||
"test:cheerpj": "node tests/cheerpj-runner.mjs && node --experimental-strip-types tests/cheerpj-autostart.mjs",
|
||||
"test:theme": "node tests/neon-theme.mjs && node tests/futuristic-v54.mjs"
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
@@ -322,6 +322,20 @@ function removeWidget(){
|
||||
if(mode.value!=='template'||!selectedWidget.value||selectedWidget.value.mandatory)return;
|
||||
widgets.value=widgets.value.filter(x=>x.id!==selectedId.value);selectedId.value='';resetGrid();
|
||||
}
|
||||
function cheerpjAutostartSelected():boolean {
|
||||
if(!selectedWidget.value)return false;
|
||||
const widget=selectedWidget.value;
|
||||
return widget.type==='ui.cheerpj-workplace'
|
||||
? widget.props.manualStartOnly !== true
|
||||
: widget.props.autoStart === true;
|
||||
}
|
||||
function changeCheerpjAutostart(enabled:boolean){
|
||||
if(!selectedWidget.value)return;
|
||||
selectedWidget.value.props.autoStart=enabled;
|
||||
if(selectedWidget.value.type==='ui.cheerpj-workplace')
|
||||
selectedWidget.value.props.manualStartOnly=!enabled;
|
||||
propJson.value=widgetPropsJson(selectedWidget.value);
|
||||
}
|
||||
function applyProperties(){
|
||||
if(!selectedWidget.value||mode.value!=='template')return;
|
||||
try {const parsed=JSON.parse(propJson.value);if(typeof parsed!=='object'||Array.isArray(parsed)||parsed===null)throw Error('JSON-Objekt erwartet');
|
||||
@@ -546,7 +560,8 @@ onBeforeUnmount(()=>{delete document.body.dataset.hmiTheme;window.removeEventLis
|
||||
<option value="fit">Automatisch an Widgetgröße anpassen</option>
|
||||
<option value="original">Original 1280 × 1024 (Scrollmodus)</option>
|
||||
</select>
|
||||
<label class="check-row"><input type="checkbox" :checked="selectedWidget.props.autoStart===true" @change="selectedWidget.props.autoStart=($event.target as HTMLInputElement).checked;propJson=widgetPropsJson(selectedWidget)"/> Beim Öffnen der Page starten</label>
|
||||
<label class="check-row"><input type="checkbox" :checked="cheerpjAutostartSelected()" @change="changeCheerpjAutostart(($event.target as HTMLInputElement).checked)"/> Beim Öffnen der Page automatisch starten</label>
|
||||
<p v-if="selectedWidget.type==='ui.cheerpj-workplace'" class="inspector-help">Der Workplace startet im Werker-Modus automatisch, auch bei älteren importierten Widgets. Im Designer wird keine VM gestartet. Bei deaktivierter Option bleibt der manuelle Start-Button erhalten.</p>
|
||||
<p v-if="selectedWidget.type==='ui.cheerpj-workplace'" class="inspector-help">iTAC Workplace: authentifizierte GlassFish-Bridge zum IMSAPI-Host derselben Installation. 129 Bibliotheken + ResizeBridge V2, Java 11; native RXTX-Treiber nicht garantiert. Keine frei wählbare externe URL.</p>
|
||||
<p v-else class="inspector-help">Direkter JNLP-Start wird für Anwendungen auf derselben HTTP-/HTTPS-Origin unterstützt. HTTP nur im geschützten Netz; selbstsigniertes HTTPS benötigt eine vertraute CA. JNLP- und JAR-Dateien müssen per Browser abrufbar sein. Fremde Hosts benötigen eine gesondert freigegebene Bereitstellung; CheerpJ-Lizenz beachten.</p>
|
||||
</template>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
13
hmi-frontend/tests/cheerpj-autostart.mjs
Normal file
13
hmi-frontend/tests/cheerpj-autostart.mjs
Normal file
@@ -0,0 +1,13 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import {shouldAutoStartWidget} from '../src/widgets/cheerpjAutoStart.ts';
|
||||
// Newly created and historic Workplace widgets must start automatically.
|
||||
assert.equal(shouldAutoStartWidget('ui.cheerpj-workplace',{autoStart:true}),true);
|
||||
assert.equal(shouldAutoStartWidget('ui.cheerpj-workplace',{autoStart:false}),true);
|
||||
assert.equal(shouldAutoStartWidget('ui.cheerpj-workplace',{}),true);
|
||||
// Only an explicitly disabled runtime option stops Workplace autostart.
|
||||
assert.equal(shouldAutoStartWidget('ui.cheerpj-workplace',{manualStartOnly:true,autoStart:true}),false);
|
||||
assert.equal(shouldAutoStartWidget('ui.cheerpj-workplace',{manualStartOnly:false,autoStart:false}),true);
|
||||
// Generic JNLP remains opt-in to avoid unexpected Java program execution.
|
||||
assert.equal(shouldAutoStartWidget('ui.cheerpj',{autoStart:false}),false);
|
||||
assert.equal(shouldAutoStartWidget('ui.cheerpj',{autoStart:true}),true);
|
||||
console.log('CheerpJ autostart policy: 7 assertions passed.');
|
||||
Reference in New Issue
Block a user