Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature pdf export #85

Merged
merged 15 commits into from
Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"@fortawesome/fontawesome-svg-core": "^1.2.35",
"@fortawesome/free-solid-svg-icons": "^5.15.3",
"@fortawesome/vue-fontawesome": "^3.0.0-4",
"bulma": "^0.9.3",
"bulma": "^0.9.4",
"core-js": "^3.6.5",
"d3": "^7.0.0",
"vue": "^3.0.0",
Expand Down
28 changes: 19 additions & 9 deletions src/components/SideMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@
<span>Kennzahlen exportieren</span>
</button>

<a href="/#/Pdf" target="_blank" class="button">
<!-- Button richtig stylen-->
<span class="icon">
<font-awesome-icon icon="file-pdf" />
</span>
<span>PDF erstellen</span>
</a>

<p><br /></p>

<button class="button" @click="showStatistics">
Expand All @@ -84,12 +92,14 @@
</button>
</div>

<a href="http://www.easynwk.com/" target="_blank">Über die easyNWK</a>
<a href="https://github.com/fhstp/easynwk-web" target="_blank"
>Source Code (Version {{ appVersion }})</a
>
<a href="http://www.easynwk.com/impressum/">Impressum</a>
<img src="fhstp_sw_pos.png" width="80" height="80" />
<div class="links">
<a href="http://www.easynwk.com/" target="_blank">Über die easyNWK</a>
<a href="https://github.com/fhstp/easynwk-web" target="_blank"
>Source Code (Version {{ appVersion }})</a
>
<a href="http://www.easynwk.com/impressum/">Impressum</a>
<img src="fhstp_sw_pos.png" width="80" height="80" />
</div>
</div>
</div>
</template>
Expand Down Expand Up @@ -248,8 +258,8 @@ export default defineComponent({
background-color: white;
}

#sidepanel a,
#sidepanel img {
#sidepanel .links a,
#sidepanel .links img {
padding: 8px 8px 8px 32px;
text-decoration: none;
color: #c1c1c1;
Expand All @@ -258,7 +268,7 @@ export default defineComponent({
}

/* When you mouse over the navigation links, change their color */
#sidepanel a:hover {
#sidepanel .links a:hover {
color: #f1f1f1;
}

Expand Down
4 changes: 4 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ import {
faTrashAlt,
faInfoCircle,
faCheck,
faFilePdf,
faArrowLeft,
faInfo,
} from "@fortawesome/free-solid-svg-icons";

Expand Down Expand Up @@ -71,6 +73,8 @@ library.add(
faTrashAlt,
faInfoCircle,
faCheck,
faFilePdf,
faArrowLeft,
faInfo
);

Expand Down
6 changes: 6 additions & 0 deletions src/router/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router";
import Home from "../views/Home.vue";
import Pdf from "../views/Pdf.vue";

const routes: Array<RouteRecordRaw> = [
{
Expand All @@ -16,6 +17,11 @@ const routes: Array<RouteRecordRaw> = [
component: () =>
import(/* webpackChunkName: "about" */ "../views/About.vue"),
},
{
path: "/pdf",
name: "Pdf",
component: Pdf,
},
];

const router = createRouter({
Expand Down
2 changes: 1 addition & 1 deletion src/views/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export default defineComponent({

#titlebar {
font-size: 180%;
background: $fhstpblue; /* hsl(32, 100%, 50%); /* $light; */
background: $fhstpblue; /* #005096; /* $light; */
color: white;
padding: 1vmin 1vmin 0.3rem 1vmin;
margin: 0.5rem 1px 0 1px;
Expand Down
155 changes: 155 additions & 0 deletions src/views/Pdf.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
<template>
<div class="page">
<div id="printinfo">
<div class="buttons">
<button class="button" @click="createPdf">
<span class="icon">
<font-awesome-icon icon="file-pdf" />
</span>
<span>Drucken bzw. als PDF drucken</span>
</button>

<button class="button" onclick="window.close()">
<span class="icon">
<font-awesome-icon icon="arrow-left" />
</span>
<span>Schließen & zur easyNWK zurückkehren</span>
</button>
</div>
<p>
Wenn Sie eine PDF Datei dieser Ansicht erzeugen, indem Sie im
Druckdialog "Als PDF speichern" auswählen.
</p>
<p>
Sie können die Daten der Kontakte auch markieren, kopieren und in einem
Textverarbeitungsprogramm einfügen.
</p>
</div>

<div id="print">
<div id="titlebar">
<div id="brand"><i>easy</i>NWK</div>
</div>
<div id="egobar">
<p class="name">{{ "Ankerperson: " + ego.name }}</p>
<p>{{ ego.currentGender ? "Geschlecht: " + ego.currentGender : "" }}</p>
<p>{{ ego.age.length >= 1 ? "Alter: " + ego.age : "" }}</p>
<p>{{ ego.note.length >= 1 ? "Notiz: " + ego.note : "" }}</p>
</div>
<div class="columns">
<div class="column">
<p class="panel-heading">Kontakte</p>
<div
v-for="(alter, index) in alteri"
v-bind:key="index"
class="panel-block"
>
<p class="name">{{ alter.name }}</p>
<p>{{ alter.role }}</p>
<p>{{ alter.age.length >= 1 ? "Alter: " + alter.age : "" }}</p>
<p>{{ alter.human ? "" : "Mensch: Nein" }}</p>
<p>
{{
alter.human
? "Geschlecht: " + alter.currentGender
: "Kategorie: " + alter.currentGender
}}
</p>
<p>{{ alter.deceased ? "Verstorben: Ja" : "" }}</p>
<p>
Beziehung:
{{
alter.edgeType == 1
? "besteht"
: alter.edgeType == 2
? "multiplex"
: "keine aktuelle Beziehung"
}}
</p>
<p>{{ alter.note.length >= 1 ? "Notiz: " + alter.note : "" }}</p>
</div>
</div>
</div>
<NetworkMap />
</div>
</div>
</template>
<script lang="ts">
import NetworkMap from "@/components/NetworkMap.vue";
import { useStore } from "@/store";
import { defineComponent, computed, onMounted } from "vue";

export default defineComponent({
name: "Pdf",
components: { NetworkMap },
setup() {
const store = useStore();
// knows list of Alter from vuex
const alteri = computed(() => store.state.nwk.alteri);
const ego = computed(() => store.state.nwk.ego);

const createPdf = () => {
window.print();
};

onMounted(() => {
// the print dialog will open immediately
createPdf();
});

return {
alteri,
ego,
createPdf,
};
},
});
</script>

<style scoped>
* {
filter: grayscale(1) !important;
}
.name {
alex-rind marked this conversation as resolved.
Show resolved Hide resolved
font-weight: bold;
}
.panel-block {
display: flex;
background: none;
flex-direction: column;
align-items: baseline;
}
#brand {
margin: 0 0.5em;
font-weight: bold;
}
#egobar {
font-size: 1rem;
padding: 0.5rem 1vmin 1vmin 1vmin;
margin: 0 1px 1rem 1px;
border-radius: 0 0 6px 6px;
background: none;
}

#titlebar {
font-size: 180%;
color: gray;
padding: 1vmin 1vmin 0.3rem 1vmin;
margin: 0.5rem 1px 0 1px;
border-radius: 6px 6px 0 0;
flex-shrink: 0;

flex-direction: row;
flex-wrap: nowrap;
display: flex;
background: none;
}
.page {
margin: 2em 4em 2em;
}
@media print {
#printinfo {
display: none;
}
}
</style>