Skip to content

Commit

Permalink
update and fixed download image event now its auto clean itself and f…
Browse files Browse the repository at this point in the history
…ix when log panel show diagnostics, won't auto new stream table instence
  • Loading branch information
CopyDemon committed Apr 1, 2024
1 parent 1d0387a commit d6789b2
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,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, this.viewInLogPanel);
if(isStreamTableShow && viewInLogPanel.streamTable) 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 @@ -283,6 +283,7 @@ export class StreamTable {
let idaesCanvas = document.querySelector('#fv');

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 @@ -176,7 +176,7 @@ export class Toolbar {
//this element is static and 100% there.
const headerExportImageBtn = document.querySelector("#headerExportImageBtn") as HTMLElement;
const headerExportSvgBtn = document.querySelector("#headerExportSvgBtn") as HTMLElement;

console.log(`event reged`)
headerExportImageBtn.addEventListener("click", () => {
let p = this._paper.paper;
const model_id = this.flowsheetId
Expand Down Expand Up @@ -286,10 +286,12 @@ export class Toolbar {
*/

cleanUpEvent(){
// zoom btns
let zoomInBtn = document.getElementById('zoom-in-btn');
let zoomOutBtn = document.getElementById('zoom-out-btn');
let zoomFitBtn = document.getElementById('zoom-to-fit');


if(zoomInBtn){
let zoomInBtnClone = zoomInBtn.cloneNode(true);
zoomInBtn.parentNode!.replaceChild(zoomInBtnClone, zoomInBtn);
Expand All @@ -302,5 +304,42 @@ export class Toolbar {
let zoomFitBtnClone = zoomFitBtn.cloneNode(true);
zoomFitBtn.parentNode!.replaceChild(zoomFitBtnClone, zoomFitBtn);
};

// reset image download btns to reset event listener
// image export btns
let flowsheetComponentHeaderDropdownContainer = document.getElementById('flowsheet_component_header_dropdown_container');
let headerExportImageBtn = document.getElementById('headerExportImageBtn');
let headerExportSvgBtn = document.getElementById('headerExportSvgBtn');

// 1. download png btn
if(headerExportImageBtn){
let headerExportImageBtnClone = headerExportImageBtn.cloneNode(true)
if(flowsheetComponentHeaderDropdownContainer){
flowsheetComponentHeaderDropdownContainer.replaceChild(headerExportImageBtnClone, headerExportImageBtn);
}else{
console.log(`error no parent nodes`)
}
};

// 2 download svg btn
if(headerExportSvgBtn){
let headerExportSvgBtnClone = headerExportSvgBtn.cloneNode(true);
if(flowsheetComponentHeaderDropdownContainer){
flowsheetComponentHeaderDropdownContainer.replaceChild(headerExportSvgBtnClone, headerExportSvgBtn);
}else{
console.log(`error download svg btn replacement failed, in toolbar, parent not found!`);
}
};

// reset save btn event listener
let saveBtn = document.getElementById('save_btn');
if(saveBtn){
let saveBtnClone = saveBtn.cloneNode(true);
if(saveBtn.parentNode){
saveBtn.parentNode.replaceChild(saveBtnClone, saveBtn);
}else{
console.log(`error save btn replacement error handle in toolbar, parent not found!`);
}
}
}
}
2 changes: 1 addition & 1 deletion IDAES-UI/src/components/mosaic/mosic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ function conditionallyRenderPanelHeaderBtn(
{/*download*/}
<Button className="mosaic_flowsheet_header_download" minimal>
<Icon icon={IconNames.BRING_DATA} size={20} />
<ul className="mosaic_dropdown_download">
<ul id="flowsheet_component_header_dropdown_container" className="mosaic_dropdown_download">
<li id="headerExportImageBtn">Export PNG</li>
<li id="headerExportSvgBtn">Export SVG</li>
</ul>
Expand Down

0 comments on commit d6789b2

Please sign in to comment.