Skip to content

Commit

Permalink
Ausgabe von Fehlermeldungen bei Dokumentverarbeitung
Browse files Browse the repository at this point in the history
Suchpfade für imports ergänzt
Schülermodel erweitert
Substitution von rootdir/bassdir ermöglicht
  • Loading branch information
Stefan Zündorf committed May 21, 2022
1 parent 4a711f1 commit acf78ee
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 24 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,21 @@
"@rollup/plugin-commonjs": "^21.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.0.0",
"@rollup/plugin-replace": "^4.0.0",
"bulma": "^0.9.1",
"cheap-watch": "^1.0.2",
"comlink": "^4.3.0",
"electron-store": "^8.0.0",
"electron-util": "^0.17.0",
"idb-keyval": "^6.0.2",
"mark.js": "^8.11.1",
"knex": "^1.0.3",
"mark.js": "^8.11.1",
"mysql": "^2.18.1",
"objection": "^3.0.0",
"pg": "^8.4.1",
"require-from-string": "^2.0.2",
"rollup": "^2.42.0",
"rollup-plugin-includepaths": "^0.2.4",
"rollup-plugin-svelte": "^7.0.0",
"schild": "^0.8.0",
"serialize-error": "^9.0.0",
Expand Down
29 changes: 19 additions & 10 deletions src/components/Dokument.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
const options = {
source: join($configData.reports, args.repo, args.file),
basedir: join($configData.reports, args.repo),
rootdir: join($configData.reports),
dest: join($configData.userData),
debug: $configData.debug,
cache: $configData.cache,
Expand Down Expand Up @@ -151,11 +152,14 @@
</script>

<!-- svelte-ignore component-name-lowercase -->
<webview src="about:blank" preload="./preload.js" use:startup />
<webview src="about:blank" preload="./preload.js" disablewebsecurity use:startup />
{#if $error}
<div class="fehlermeldung">
<h3 class="is-size-3">{$error.message}</h3>
<pre>{$error.stack}</pre>
<div style="margin-bottom:1em">Bei der Verarbeitung des Dokuments ist folgender Fehler aufgetreten:</div>
<div style="overflow:auto">
<pre style="font-size:1.3rem; font-weigth:bold; color:white; background-color:rgba(100,100,100,0.8); white-space: pre-wrap;">{$error.message}</pre>
<pre style="background-color:rgba(200, 220, 240, 0.8); white-space: pre-wrap;">{$error.stack}</pre>
</div>
</div>
{/if}

Expand All @@ -164,12 +168,17 @@
height: -webkit-fill-available;
}
.fehlermeldung {
position: absolute;
left: 250px;
bottom: 0;
background: rgba(255, 255, 255, 0.9);
width: 100%;
height: 200px;
overflow: auto;
position: sticky;
margin: auto;
width: 90%;
left: auto;
height: 30%;
border: 2px solid red;
bottom: 1em;
padding: 1em;
background: rgba(255, 255, 255, 0.7);
display: flex;
flex-direction: column;
justify-content: stretch;
}
</style>
52 changes: 41 additions & 11 deletions src/document_models/dschueler.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,42 +21,72 @@ export class DSchueler {
} while(s)
return na
}
get gewaehltesSchuljahrStartDatum() {
return new Date(this.gewaehltesJahr,7,1) // 1.8. des Schuljahres
}
get gewaehltesSchuljahrEndDatum() {
return new Date(this.gewaehltesJahr+1,6,31) // 31.7. des Schuljahres
}
get naechsterAbschnitt () {
let na= this.abschnitte.find(a => a.Jahr === this.gewaehltesJahr && a.Abschnitt === this.gewaehlteAbschnittsNummer+1)
if(na) return na
return this.abschnitte.find(a => a.Jahr === this.gewaehltesJahr+1 && a.Abschnitt === 0)
}
volljaehrigAm (datum) {
if (!datum || !this.Geburtsdatum) return false
var g = new Date(this.Geburtsdatum)
var d = new Date(datum)
return (d.getFullYear() - g.getFullYear() - ((d.getMonth() > g.getMonth() || (d.getMonth() === g.getMonth() && d.getDay() >= g.getDay())) ? 0 : 1)) >= 18
}

get gewaehlterAbschnitt () {
return this.abschnitte.find(a => a.Jahr === this.gewaehltesJahr && a.Abschnitt === this.gewaehlteAbschnittsNummer)
}
get gewaehlterJahrgang () {
return this.gewaehlterAbschnitt.Jahrgang
}
get anrede () {
get VollstaendigerName () {
return (this.Vorname + " "+ (this.Zusatz ? (this.Zusatz+" ") : "") +this.Name)
}
get VollstaendigeAnrede () {
return ((this.Geschlecht === 3 ? 'Herr ' : 'Frau ' ) + this.Vorname + " "+ (this.Zusatz ? (this.Zusatz+" ") : "") +this.Name)
}
get VollstaendigeBriefAnrede () {
return ((this.Geschlecht === 3 ? 'Sehr geehrter Herr ' : 'Sehr geehrte Frau ')+ (this.Zusatz ? (this.Zusatz+" ") : "") + this.Name)
}
get Anrede () {
return (this.Geschlecht === 3 ? 'Herr' : 'Frau')
}
get geehrte_r () {
return this.Geschlecht === 3 ? 'geehrter Herr' : 'geehrte Frau'
}
get schueler_in () {
get Schueler_in () {
return (this.Geschlecht === 3 ? 'Schüler' : 'Schülerin')
}
get studierende_r () {
get artikel () {
return (this.Geschlecht === 3 ? 'der' : 'die')
}
get Artikel () {
return (this.Geschlecht === 3 ? 'Der' : 'Die')
}
get geschlecht () {
return (this.Geschlecht === 3 ? 'männlich' : 'weiblich')
}
get pronomen () {
return (this.Geschlecht === 3 ? 'er' : 'sie')
}
get Pronomen () {
return (this.Geschlecht === 3 ? 'Er' : 'Sie')
}
get Studierende_r () {
return (this.Geschlecht === 3 ? 'Studierender' : 'Studierende')
}
get berufsbezeichnung_mw () {
get Berufsbezeichnung_mw () {
if (this.fachklasse) return this.Geschlecht === 3 ? this.fachklasse.Bezeichnung : this.fachklasse.Beschreibung_W
else return 'Keine Fachklasse zugeordnet'
}
get volljaehrig () {
get istVolljaehrig () {
return this.Volljaehrig === '+'
}
istVolljaehrigAm (datum) {
if (!datum || !this.Geburtsdatum) return false
var g = new Date(this.Geburtsdatum)
var d = new Date(datum)
return (d.getFullYear() - g.getFullYear() - ((d.getMonth() > g.getMonth() || (d.getMonth() === g.getMonth() && d.getDay() >= g.getDay())) ? 0 : 1)) >= 18
}
}

4 changes: 2 additions & 2 deletions src/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const Mark = require('mark.js')
const requireFromString = require('require-from-string');

global.R = (lib) => require(lib)

let svelte, props, Component, componentPath, mark, compiled_module

function runMark () {
Expand Down Expand Up @@ -39,9 +40,8 @@ ipcRenderer.on('set_dokument', async () => {
generic_pdf: svelte.generic_pdf
})
} catch (error) {
// const { serializeError } = await import('serialize-error')
console.log('Das Svelte-Dokument konnte nicht geladen werden:', error)
// ipcRenderer.sendToHost('error_message', serializeError(error))
ipcRenderer.sendToHost('error_message', error)
}
runMark()
})
Expand Down
20 changes: 20 additions & 0 deletions src/rollup_worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import json from "@rollup/plugin-json";
import { get, set } from 'idb-keyval';
import includePaths from 'rollup-plugin-includepaths'
import replace from '@rollup/plugin-replace'

// svelte components möchten svelte importieren. Da wir aber auch components
// ohne node_modules zulassen, müssen wir das Verzeichnis an svelte weiterreichen
const __nodeModules = process.env.PROD
? presolve(__dirname, "node_modules/svelte")
: presolve(__dirname, "../node_modules/svelte");


class RollupBuild {
async build(options, callback) {
let cache
Expand All @@ -23,11 +26,28 @@ class RollupBuild {
console.log('Komponente wurde im Cache gefunden')
}
}
console.log(`${options.rootdir}/.js`)
this.input = {
input: presolve(options.source),
perf: true,
treeshake: false,
plugins: [
includePaths({
include: {},
paths: [`${options.rootdir}/.js`],
external: [],
extensions: ['.js']
}),
includePaths({
include: {},
paths: [`${options.rootdir}/.vorlagen`],
external: [],
extensions: ['.svelte']
}),
replace({
"__rootdir":options.rootdir.replace(/\\/g, "/"),
"__basedir":options.basedir.replace("\\","/"),
}),
json({ preferConst: true }),
svelte({
emitCss: false,
Expand Down

0 comments on commit acf78ee

Please sign in to comment.