Skip to content

Commit

Permalink
Merge branch 'reporting' of https://github.com/socfortress/CoPilot in…
Browse files Browse the repository at this point in the history
…to reporting
  • Loading branch information
taylorwalton committed Mar 1, 2024
2 parents 55d2e7a + c84ad57 commit c21807f
Show file tree
Hide file tree
Showing 5 changed files with 263 additions and 30 deletions.
96 changes: 73 additions & 23 deletions frontend/package-lock.json

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

4 changes: 2 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"vue": "^3.4.21",
"vue-advanced-cropper": "^2.8.8",
"vue-highlight-words": "^3.0.1",
"vue-i18n": "^9.9.1",
"vue-i18n": "^9.10.1",
"vue-router": "^4.3.0",
"vue-sjv": "^0.0.6",
"vue3-apexcharts": "^1.5.2",
Expand All @@ -81,7 +81,7 @@
"@types/lodash": "^4.14.202",
"@types/markdown-it": "^13.0.7",
"@types/markdown-it-highlightjs": "^3.3.4",
"@types/node": "^20.11.22",
"@types/node": "^20.11.24",
"@types/validator": "^13.11.9",
"@vitejs/plugin-vue": "^5.0.4",
"@vitejs/plugin-vue-jsx": "^3.1.0",
Expand Down
163 changes: 163 additions & 0 deletions frontend/src/components/reportCreation/Panels.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
<template>
<div class="report-panels">
isDirty:{{ isDirty }},{{ linksList.length }}
<div class="panels-container grid grid-cols-2 gap-6" :class="{ printing }">
<div class="panel" v-for="panel of linksList" :key="panel.panel_id">
<iframe :src="panel.panel_url + '&theme=light'" v-show="panelTheme === 'light'"></iframe>
<iframe :src="panel.panel_url + '&theme=dark'" v-show="panelTheme === 'dark'"></iframe>
</div>
</div>

<div class="toolbar">
<n-button type="success" v-if="linksList.length" @click="print()">
<template #icon>
<Icon :name="PrintIcon"></Icon>
</template>
Print Report
</n-button>
</div>
</div>
</template>

<script setup lang="ts">
import { NButton } from "naive-ui"
import type { PanelLink } from "@/types/reporting"
import Icon from "@/components/common/Icon.vue"
import { ref, nextTick } from "vue"
// import html2canvas from "html2canvas"
// @ts-ignore
// import domtoimage from "dom-to-image-more"
const isDirty = defineModel<boolean>("isDirty", { default: false })
const printing = ref(false)
const panelTheme = ref<"light" | "dark">("light")
const { linksList } = defineProps<{
linksList: PanelLink[]
}>()
const PrintIcon = "carbon:printer"
function print() {
printing.value = true
// panelTheme.value = "light"
nextTick(() => {
setTimeout(() => {
window.print()
// panelTheme.value = "dark"
printing.value = false
}, 2000)
})
/*
// @ts-ignore
html2canvas(document.querySelector(".page"), { allowTaint: true, useCORS: true }).then(canvas => {
//document.body.appendChild(canvas)
console.log(canvas.toDataURL("image/jpeg", 0.9))
})
var node = document.querySelector(".page")
domtoimage
.toPng(node)
// @ts-ignore
.then(function (dataUrl) {
var img = new Image()
img.src = dataUrl
console.log(dataUrl)
document.body.appendChild(img)
})
// @ts-ignore
.catch(function (error) {
console.error("oops, something went wrong!", error)
})
*/
}
</script>

<style lang="scss" scoped>
.report-panels {
.panels-container {
.panel {
iframe {
width: 100%;
height: 500px;
}
}
&.printing {
grid-template-columns: repeat(1, minmax(0, 1fr));
max-width: 600px;
}
}
}
</style>

<style lang="scss">
@media print {
html,
body {
overflow: initial;
}
body {
#app {
height: initial;
background-color: white;
& > .n-config-provider {
& > .layout {
display: block;
height: initial;
background-color: white;
& > .header-bar {
display: none;
}
& > .main {
background-color: white;
overflow: initial;
height: initial;
header.toolbar {
display: none;
}
footer.footer {
display: none;
}
& > .n-scrollbar {
overflow: initial;
height: initial;
& > .n-scrollbar-container {
overflow: initial;
height: initial;
}
}
.page {
.report-wizard {
display: none;
}
.report-panels {
max-width: 600px;
.panels-container {
grid-template-columns: repeat(1, minmax(0, 1fr));
.panel {
border: 2px solid black;
}
}
.toolbar {
display: none;
}
}
}
}
}
}
}
}
}
</style>
Loading

0 comments on commit c21807f

Please sign in to comment.