Skip to content

Commit

Permalink
NN-588 Added export window for graph
Browse files Browse the repository at this point in the history
  • Loading branch information
TripZz committed Sep 19, 2024
1 parent 63089c7 commit 0a4d10c
Show file tree
Hide file tree
Showing 7 changed files with 159 additions and 39 deletions.
2 changes: 1 addition & 1 deletion frontend/src/components/enrichment/PathwayList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ export default {
this.active_categories_set = new Set();
},
init_categories() {
this.reset_categories()
this.reset_categories();
for (let element of this.filter_terms) {
let checkCategory = element.label;
if (
Expand Down
151 changes: 116 additions & 35 deletions frontend/src/components/toolbar/modules/ExportScreen.vue
Original file line number Diff line number Diff line change
@@ -1,59 +1,140 @@
<template>
<div
class="tool-item"
v-on:mouseover="show_export = true"
v-on:mouseleave="show_export = false"
>
<span v-on:click="take_screen('white', 'png')">Save graph as</span>
<div id="select-de">></div>
<div class="subform-de-values" v-if="show_export">
<span v-on:click="take_screen('white', 'png')">White/.png</span>
<br />
<span v-on:click="take_screen('black', 'png')">Black/.png</span>
<br />
<span v-on:click="take_screen('white', 'svg')">White/.svg</span>
<br />
<span v-on:click="take_screen('black', 'svg')">Black/.svg</span>
<div>
<!-- Modal for export selection -->
<div v-if="show_export" class="export-modal-overlay">
<div class="export-modal">
<h2>Select Export Type</h2>

<!-- Export options -->
<div class="export-options">
<button class="export-option" @click="take_screen('white', 'png')">
White / .png
</button>
<button class="export-option" @click="take_screen('black', 'png')">
Black / .png
</button>
<button class="export-option" @click="take_screen('white', 'svg')">
White / .svg
</button>
<button class="export-option" @click="take_screen('black', 'svg')">
Black / .svg
</button>
</div>

<!-- Close button -->
<button class="close-btn" @click="show_export = false">Close</button>
</div>
</div>
</div>
</template>

<script>
export default {
name: "ExportScreen",
props: ["mode"],
props: ["mode", "filter_views"],
data() {
return {
show_export: false,
currentView: null,
};
},
mounted() {
this.emitter.on("openExportScreen", (state) => {
let checkView = new Set(this.filter_views);
if (!checkView.has(state)) {
this.show_export = true;
this.currentView = state;
}
});
},
methods: {
take_screen(mode, format) {
this.emitter.emit("exportGraph", {
params: { mode, format },
mode: this.mode,
});
let checkView = new Set(this.filter_views);
if (!checkView.has(this.currentView)) {
this.emitter.emit("exportGraph", {
params: { mode, format },
mode: this.currentView,
});
this.show_export = false; // Close modal after exporting
}
},
},
};
</script>

<style>
.subform-de-values {
<style scoped>
/* Button to trigger the modal */
.export-btn:hover {
background-color: #45a049;
}
/* Modal overlay */
.export-modal-overlay {
position: fixed;
margin-top: -0.3%;
left: 49.4%;
width: auto;
height: auto;
font-size: 0.9vw;
padding: 0.5vw;
border-style: solid;
border-width: 1px;
border-color: #0a0a1a;
background: rgba(222, 222, 222, 0.61);
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
display: flex;
justify-content: center;
align-items: center;
z-index: 999998;
}
/* Modal content */
.export-modal {
-webkit-backdrop-filter: blur(7.5px);
border: 1px solid #e0e0e0;
background-color: rgba(107, 107, 107, 0.5);
padding: 20px;
border-radius: 10px;
text-align: center;
width: 300px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
z-index: 999998;
}
.export-modal h2 {
margin-bottom: 20px;
font-size: 1.5rem;
color: white;
}
/* Export options */
.export-options {
display: flex;
flex-direction: column;
gap: 10px;
}
.export-option {
padding: 10px;
border: none;
background-color: #f0f0f0;
border-radius: 5px;
cursor: pointer;
font-size: 1rem;
transition: background-color 0.3s ease;
}
.export-option:hover {
background-color: #ddd;
}
/* Close button */
.close-btn {
margin-top: 20px;
padding: 8px 16px;
background-color: #ff4c4c;
color: white;
border: none;
border-radius: 5px;
text-align: left;
overflow: hidden;
cursor: default;
cursor: pointer;
}
.close-btn:hover {
background-color: #e04343;
}
</style>
27 changes: 27 additions & 0 deletions frontend/src/components/toolbar/modules/ExportingButton.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<template>
<div>
<div class="tool-item">
<span v-on:click="open_export()">Export proteins as .csv</span>
</div>
</div>
</template>

<script>
export default {
name: "ExportingButton",
props: ["mode"],
data() {
return {
};
},
methods: {
open_export() {
this.emitter.emit("openExportScreen", this.mode);
},
},
};
</script>

<style scoped>
</style>

6 changes: 3 additions & 3 deletions frontend/src/components/toolbar/windows/MenuWindow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</div>
<div class="window-label">export graph</div>
<div class="menu-items">
<ExportScreen :mode="mode"></ExportScreen>
<ExportingButton :mode="mode"></ExportingButton>
<ExportGraph v-if="mode == 'protein'"></ExportGraph>
<ExportProteins
v-if="mode == 'protein'"
Expand All @@ -36,7 +36,7 @@
<script>
import ExportProteins from "@/components/toolbar/modules/ExportProteins.vue";
import ExportEdges from "@/components/toolbar/modules/ExportEdges.vue";
import ExportScreen from "@/components/toolbar/modules/ExportScreen.vue";
import ExportingButton from "@/components/toolbar/modules/ExportingButton.vue";
import FDRValue from "@/components/toolbar/modules/FDRValue.vue";
import ExportGraph from "@/components/toolbar/modules/ExportGraph.vue";
import NodeLabelSelect from "@/components/toolbar/modules/NodeLabelSelect.vue";
Expand All @@ -50,7 +50,7 @@ export default {
props: ["tools_active", "mode", "gephi_data", "ensembl_name_index"],
emits: ["tools_active_changed"],
components: {
ExportScreen,
ExportingButton,
ExportGraph,
EdgeOpacity,
NodeLabelSelect,
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/views/CitationView.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<keep-alive>
<div class="citation-view">
<ExportScreen :mode="mode" :filter_views="filter_views"></ExportScreen>
<CitationVis
ref="CitationVis"
:active_node="active_node"
Expand Down Expand Up @@ -77,6 +78,7 @@ import CitationPane from "@/components/citation/CitationPane.vue";
import NetworkValues from "../components/interface/NetworkValues.vue";
import CitationToolBar from "../components/toolbar/CitationToolBar.vue";
import VerticalPaneCitation from "@/components/verticalpane/VerticalPaneCitation.vue";
import ExportScreen from "@/components/toolbar/modules/ExportScreen.vue";
export default {
name: "CitationView",
Expand All @@ -87,6 +89,7 @@ export default {
CitationToolBar,
CitationPaneSystem,
VerticalPaneCitation,
ExportScreen,
},
data() {
return {
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/views/ProteinView.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<template>
<div class="protein-view">
<keep-alive>
<ExportScreen :mode="mode" :filter_views="filter_views"></ExportScreen>
</keep-alive>
<keep-alive>
<MainVis
ref="mainVis"
Expand Down Expand Up @@ -96,6 +99,7 @@ import VerticalPane from "@/components/verticalpane/VerticalPane.vue";
import PaneSystem from "@/components/pane/PaneSystem.vue";
import NetworkValues from "../components/interface/NetworkValues.vue";
import MainToolBar from "../components/toolbar/MainToolBar.vue";
import ExportScreen from "@/components/toolbar/modules/ExportScreen.vue";
export default {
name: "ProteinView",
Expand All @@ -105,6 +109,7 @@ export default {
MainToolBar,
NetworkValues,
VerticalPane,
ExportScreen,
},
data() {
return {
Expand All @@ -126,6 +131,7 @@ export default {
node_cluster_index: null,
ensembl_name_index: null,
view: "protein view",
view_filtering: false,
filter_views: ["term", "citation"],
};
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/views/TermView.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<keep-alive>
<div class="term-view">
<ExportScreen :mode="mode" :filter_views="filter_views"></ExportScreen>
<TermVis
ref="termVis"
:active_node="active_node"
Expand Down Expand Up @@ -67,6 +68,7 @@ import TermPaneSystem from "@/components/pane/TermPaneSystem.vue";
import NetworkValues from "../components/interface/NetworkValues.vue";
import TermToolBar from "../components/toolbar/TermToolBar.vue";
import VerticalPanePathway from "@/components/verticalpane/VerticalPanePathway.vue";
import ExportScreen from "@/components/toolbar/modules/ExportScreen.vue";
export default {
name: "TermView",
Expand All @@ -76,6 +78,7 @@ export default {
TermToolBar,
TermPaneSystem,
VerticalPanePathway,
ExportScreen,
},
data() {
return {
Expand Down

0 comments on commit 0a4d10c

Please sign in to comment.