Skip to content

Commit

Permalink
fixed when event dispatch error when stream table not show
Browse files Browse the repository at this point in the history
  • Loading branch information
CopyDemon committed Apr 1, 2024
1 parent 8458624 commit 8c35abb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,24 @@ export class MainFV {
stream_table:any;
toolbar: any;
cleanToolBarEvent: any;
viewInLogPanel:any;


constructor (flowsheetId:any, port:string | number, isFvShow:boolean, isVariablesShow:boolean, isStreamTableShow:boolean) {
constructor (
flowsheetId:any,
port:string | number,
isFvShow:boolean,
isVariablesShow:boolean,
isStreamTableShow:boolean,
viewInLogPanel: {streamTable:boolean, diagnosticsLogs:boolean}
) {
this.flowsheetId = flowsheetId;
//which panel is show
// which panel is show
this.isFvShow = isFvShow;
// this.isVariablesShow = isVariablesShow;
this.isStreamTableShow = isStreamTableShow;
// check if bottom log panel show stream table or diagnostics log
this.viewInLogPanel = viewInLogPanel;

//Gerneate url for fetch data
this.baseUrl = `http://localhost:${port}`
Expand Down Expand Up @@ -92,7 +102,7 @@ export class MainFV {
if(isFvShow) this.renderModel(this.model); //this only run when fv is show
//render stream table
//if statment control when stream table not show the stream table should not render
if(isStreamTableShow) this.stream_table = new StreamTable(this, this.model);
if(isStreamTableShow) this.stream_table = new StreamTable(this, this.model, this.viewInLogPanel);
// new this.toolbar
this.toolbar = new Toolbar(this, this.paper, this.stream_table, this.flowsheetId, this.getFSUrl,this.putFSUrl, this.isFvShow);
// get toolbar event cleanup function
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,10 @@ export class Paper {
}
}
);
idaesCanvas!.dispatchEvent(removeHighlightStreamEvent);
streamTable!.dispatchEvent(removeHighlightStreamEvent);

if(idaesCanvas) idaesCanvas!.dispatchEvent(removeHighlightStreamEvent);
if(streamTable) streamTable!.dispatchEvent(removeHighlightStreamEvent);

});

// Link labels will appear and disappear on right click. Replaces browser context menu
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,12 @@ export class StreamTable {
gridCellMouseLeaveFn : any;
existing_var_types: any;
_gridOptions:any;
viewInLogPanel: any;


constructor(app:any, model:any) {
constructor(app:any, model:any, viewInLogPanel:any) {
this._app = app;
this.viewInLogPanel = viewInLogPanel
// Define brushing event handlers
this.defineTableBrushingFns();
this.initTable(model);
Expand Down Expand Up @@ -280,7 +282,7 @@ export class StreamTable {
let streamTable = document.querySelector('#stream-table-data');
let idaesCanvas = document.querySelector('#fv');

if(!streamTable || !idaesCanvas) return;
if(!streamTable || !idaesCanvas || !this.viewInLogPanel.streamTable) return;
// Function to highlight a stream table column
this.highlightFn = (event:any) => {
let streamGridCells = streamTable!.querySelectorAll(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ export default function FlowsheetWrapper(){
//get server port base on UI port number, vite running on 5173 on dev
server_port == "5173" ? server_port = 8000 : server_port = server_port;
//when template loaded then render flowsheet, variable, stream table to page with minFV class.
fv = new MainFV(fv_id, server_port, isFvShow, false, isStreamTableShow); //The false is placeholder for isVariableShow, now variable panel is not show
fv = new MainFV(fv_id, server_port, isFvShow, false, isStreamTableShow, viewInLogPanel); //The false is placeholder for isVariableShow, now variable panel is not show
}else{
fv = undefined;
}

return ()=>{
// clean up event handler
if (fv && typeof fv.cleanToolBarEvent === 'function') {
fv.cleanToolBarEvent();
}
Expand Down

0 comments on commit 8c35abb

Please sign in to comment.