Skip to content

Commit f514a90

Browse files
AkshayBajajMLMarkLogic Builder
authored andcommitted
DHFPROD-8166: Export Graph To PNG in Modeling
1 parent a1339b5 commit f514a90

File tree

4 files changed

+28
-2
lines changed

4 files changed

+28
-2
lines changed

marklogic-data-hub-central/ui/e2e/cypress/integration/modeling/reader.spec.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,15 @@ describe("Entity Modeling: Reader Role", () => {
9595
it("can navigate to graph view from table view", () => {
9696
entityTypeTable.viewEntityInGraphView("Customer");
9797

98+
//To test graph view model png is downloaded successfully
99+
graphView.getExportGraphIcon().click().then(
100+
() => {
101+
cy.readFile("./cypress/downloads/graph-view-model.png", "base64").then(
102+
(downloadPng) => {
103+
expect(downloadPng).exist;
104+
});
105+
});
106+
98107
// To verify modeling info is rendered properly in graph view
99108
modelPage.clickModelingInfoIcon();
100109
modelPage.verifyModelingInfo();

marklogic-data-hub-central/ui/src/components/entities/merging/add-merge-rule/merge-rule-dialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ const MergeRuleDialog: React.FC<Props> = (props) => {
855855
<MLButton aria-label="add-slider-button" type="primary" size="default" className={styles.addSliderButton} onClick={onAddOptions}>Add</MLButton>
856856
</div>
857857
<div>
858-
<div><span className={styles.enableStrategySwitch}><b>Enable Merge Strategy Scale </b></span><Switch aria-label="mergeStrategy-scale-switch" defaultChecked={false} onChange={(e) => toggleDisplayPriorityOrderTimeline(e)}></Switch>
858+
<div><span className={styles.enableStrategySwitch}><b>Enable Priority Order Scale </b></span><Switch aria-label="mergeStrategy-scale-switch" defaultChecked={false} onChange={(e) => toggleDisplayPriorityOrderTimeline(e)}></Switch>
859859
<span>
860860
<MLTooltip title={MergeRuleTooltips.strategyScale} id="priority-order-tooltip" placement="right">
861861
<Icon type="question-circle" className={styles.questionCircle} theme="filled" />

marklogic-data-hub-central/ui/src/components/modeling/graph-view/graph-view.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const GraphView: React.FC<Props> = (props) => {
4040
const [graphEditMode, setGraphEditMode] = useState(false);
4141
const [coordsChanged, setCoordsChanged] = useState(false);
4242
const [splitPaneResized, setSplitPaneResized] = useState(false);
43+
const [exportPngButtonClicked, setExportPngButtonClicked] = useState(false);
4344

4445
useEffect(() => {
4546
if (coordsChanged) {
@@ -177,7 +178,7 @@ const GraphView: React.FC<Props> = (props) => {
177178
<span className={styles.disabledCursor}>{publishButton}</span>
178179
</MLTooltip>
179180
<MLTooltip title={ModelingTooltips.exportGraph} placement="topLeft">
180-
<FontAwesomeIcon className={styles.graphExportIcon} icon={faFileExport} aria-label="graph-export"/>
181+
<FontAwesomeIcon className={styles.graphExportIcon} icon={faFileExport} aria-label="graph-export" onClick={() => { setExportPngButtonClicked(true); }}/>
181182
</MLTooltip>
182183
</span>;
183184

@@ -251,6 +252,8 @@ const GraphView: React.FC<Props> = (props) => {
251252
getColor={getColor}
252253
splitPaneResized={splitPaneResized}
253254
setSplitPaneResized={setSplitPaneResized}
255+
exportPngButtonClicked = {exportPngButtonClicked}
256+
setExportPngButtonClicked = {setExportPngButtonClicked}
254257
/>
255258
</div>
256259
</div>;

marklogic-data-hub-central/ui/src/components/modeling/graph-view/graph-vis/graph-vis.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ type Props = {
3131
getColor: any;
3232
splitPaneResized: any;
3333
setSplitPaneResized: any;
34+
exportPngButtonClicked: boolean;
35+
setExportPngButtonClicked: any;
3436
};
3537

3638
let entityMetadata = {};
@@ -119,6 +121,18 @@ const GraphVis: React.FC<Props> = (props) => {
119121
}
120122
}, [network, modelingOptions.view]);
121123

124+
useEffect(() => {
125+
if (props.exportPngButtonClicked) {
126+
let canvas = document.getElementsByClassName("vis-network")[0]["canvas"];
127+
let link = document.createElement("a");
128+
link.href = canvas.toDataURL();
129+
link.setAttribute("download", "graph-view-model");
130+
document.body.appendChild(link);
131+
link.click();
132+
props.setExportPngButtonClicked(false);
133+
}
134+
}, [props.exportPngButtonClicked]);
135+
122136
const updateNetworkHeight = async () => {
123137
let baseHeight = Math.round(window.innerHeight-network.body.container.offsetTop);
124138
if (window.devicePixelRatio < 2) {

0 commit comments

Comments
 (0)