Skip to content

Commit

Permalink
Merge pull request #93 from fhstp/feature_pdf_export
Browse files Browse the repository at this point in the history
NWK Ansichtseinstellungen an PDF als Get Parameter übergeben #47

auch vorläufige Lösung des View Options übernommen werden vgl. #92
  • Loading branch information
alex-rind authored Sep 22, 2022
2 parents 81e7fd9 + 5463a7c commit fd7039e
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 2 deletions.
23 changes: 22 additions & 1 deletion src/components/SideMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,24 @@
<span>Kennzahlen exportieren</span>
</button>

<a href="/#/Pdf" target="_blank" class="button">
<a
:href="
'/#/Pdf?pseudo=' +
pseudonyms +
'&hor=' +
horizons +
'&con=' +
connections +
'&alt=' +
alteriNames +
'&age=' +
showAge +
'&role=' +
showRole
"
target="_blank"
class="button"
>
<!-- Button richtig stylen-->
<span class="icon">
<font-awesome-icon icon="file-pdf" />
Expand Down Expand Up @@ -201,6 +218,10 @@ export default defineComponent({
toggleConnections: () => store.commit("view/toggle", "connections"),
alteriNames: computed(() => store.state.view.alteriNames),
toggleAlteriNames: () => store.commit("view/toggle", "alteriNames"),
showAge: computed(() => store.state.view.ageInNwk),
toggleAge: () => store.commit("view/toggle", "ageInNwk"),
showRole: computed(() => store.state.view.roleInNwk),
toggleRoleShort: () => store.commit("view/toggle", "roleInNwk"),
};
},
});
Expand Down
37 changes: 36 additions & 1 deletion src/views/Pdf.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,12 @@
import NetworkMap from "@/components/NetworkMap.vue";
import { useStore } from "@/store";
import { defineComponent, computed, onMounted } from "vue";
import { useRouter } from "vue-router";
export default defineComponent({
name: "Pdf",
components: { NetworkMap },
setup() {
setup: function () {
const store = useStore();
// knows list of Alter from vuex
const alteri = computed(() => store.state.nwk.alteri);
Expand All @@ -92,9 +93,43 @@ export default defineComponent({
window.print();
};
// TODO currently: workaround -> schönere Lösung
const readHttpGet = () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let pseudo: any = useRouter().currentRoute.value.query.pseudo;
pseudo = /true/i.test(pseudo);
pseudo ? store.commit("pseudonym/toggle") : "";
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let hor: any = useRouter().currentRoute.value.query.hor;
hor = /true/i.test(hor);
hor ? "" : store.commit("view/toggle", "horizons");
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let con: any = useRouter().currentRoute.value.query.con;
con = /true/i.test(con);
con ? "" : store.commit("view/toggle", "connections");
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let alt: any = useRouter().currentRoute.value.query.alt;
alt = /true/i.test(alt);
alt ? "" : store.commit("view/toggle", "alteriNames");
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let age: any = useRouter().currentRoute.value.query.age;
age = /true/i.test(age);
age ? store.commit("view/toggle", "ageInNwk") : "";
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let role: any = useRouter().currentRoute.value.query.role;
role = /true/i.test(role);
role ? store.commit("view/toggle", "roleInNwk") : "";
};
onMounted(() => {
// the print dialog will open immediately
createPdf();
readHttpGet();
});
return {
Expand Down

0 comments on commit fd7039e

Please sign in to comment.