Skip to content
This repository has been archived by the owner on Dec 7, 2020. It is now read-only.

Commit

Permalink
Merge pull request #276 from EC-Nordbund/add_serienbrief
Browse files Browse the repository at this point in the history
Add serienbrief
  • Loading branch information
mathe42 authored Nov 29, 2018
2 parents 613c12e + a97db25 commit 35d96ce
Show file tree
Hide file tree
Showing 4 changed files with 192 additions and 114 deletions.
14 changes: 7 additions & 7 deletions src/plugins/formConfig/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {
rule,
required,
maxLength,
exactLength,
inArray,
exactLength
} from '@/plugins/rules'
maxLength,
required,
rule
} from '@/plugins/rules';

interface IConfig {
label?: string
Expand Down Expand Up @@ -178,7 +178,7 @@ export const akConfig: IConfig = {
}

export const ecKreisConfig: IConfig = {
name: 'ecKreisID',
name: 'ecKreis',
label: 'Wähle einen EC-Kreis',
componentName: 'ec-select-ecKreis',
clearable: true
Expand Down Expand Up @@ -313,4 +313,4 @@ export const maxTNConfig: IConfig = {
step: 1,
'thumb-label': true,
required: true
}
}
95 changes: 39 additions & 56 deletions src/plugins/updateChecker.ts
Original file line number Diff line number Diff line change
@@ -1,61 +1,44 @@
import version, {
isPrerelease
} from '@/plugins/version/version'

import electron, {
isElectron,
isProduction
} from '@/plugins/electron'
import electron, { isElectron, isProduction } from '@/plugins/electron';
import version, { isPrerelease } from '@/plugins/version/version';

// Wenn isElectron + isProduction Chack für Upates
if (isElectron && isProduction) {
;(async () => {
// get fetcher
const fetch = eval("require('node-fetch')")

// querx
const res = await fetch(
'https://api.github.com/repos/ecnordbund/ec-verwaltungs-app/releases'
)

// get Result
const resultJSON: Array<{
prerelease: boolean
tag_name: string
published_at: string
assets: Array<{
name: string
browser_download_url: string
}>
}> = await res.json()

const latest = resultJSON.filter(
v => v.prerelease === isPrerelease
)[0]

if (latest.tag_name === `v${version}`) {
return
;(async () => {
// get fetcher
const fetch = eval("require('node-fetch')")

// querx
const res = await fetch('https://ec-api.de/version')

// get Result
const resultJSON: {
version: string
} = await res.json()

if (version !== resultJSON.version) {
let url = ''

switch (eval("require('os').platform()")) {
case 'win32':
url = `https://github.com/EC-Nordbund/ec-verwaltungs-app/releases/download/v${
resultJSON.version
}/EC-Verwaltungs-App-${
resultJSON.version
}.Setup.exe`
break
case 'darwin':
url = `https://github.com/EC-Nordbund/ec-verwaltungs-app/releases/download/v${
resultJSON.version
}/EC-Verwaltungs-App-${resultJSON.version}.dmg`
break
default:
url = `https://github.com/EC-Nordbund/ec-verwaltungs-app/releases/download/v${
resultJSON.version
}/ec-verwaltungs-app_${
resultJSON.version
}_amd64.deb`
break
}

const url = latest.assets
.map(v => {
const endungsArray = v.name.split('.')
const endung = endungsArray[endungsArray.length - 1]
return {
url: v.browser_download_url,
endung
}
})
.filter(
v =>
v.endung ===
(<any>{
win32: 'exe',
darwin: 'dmg',
linux: 'deb'
})[(<any>window).process.platform]
)[0].url

// show msgBox
electron.remote.dialog.showMessageBox(
{
Expand All @@ -73,5 +56,5 @@ Wir empfehlen dir das Update sofort zu installieren! (Dauer: wenige Minuten)`,
}
}
)
})()
}
}
})()
3 changes: 0 additions & 3 deletions src/views/anmeldungen/details.vue
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ import { getClient } from '@/plugins/apollo'
import event from '@/plugins/eventbus'
import {jsZip, Docxtemplater} from '@/plugins/docx'
import {exec} from 'child_process'
const loadGQL = gql`
query($authToken: String!, $anmeldeID: String!) {
Expand Down Expand Up @@ -475,15 +474,13 @@ export default class anmeldungsDetails extends reloaderBase {
const zipData = new jsZip(fileContent)
const briefTemplate = new Docxtemplater()
briefTemplate.loadZip(zipData)
console.log(this.data.anmeldung)
briefTemplate.setData(this.manageData(this.data.anmeldung))
briefTemplate.render()
const fertigerBrief = briefTemplate.getZip().generate({type: 'nodebuffer'});
const tmpPath = electron.remote.app.getPath('temp').split('\\').join('/')
const tmpFile = tmpPath + '/' + Math.random().toString(36).substring(7) + '.docx'
fs.writeFileSync(tmpFile, fertigerBrief)
console.log(tmpFile)
eval(`require('child_process').exec('start ${tmpFile}')`)
} else {
alert('Kein Brief ausgewählt.')
Expand Down
Loading

0 comments on commit 35d96ce

Please sign in to comment.