solved readfile problem of config
This commit is contained in:
parent
fa9d4f19d4
commit
ba9d9e6abb
3 changed files with 6 additions and 5 deletions
|
|
@ -1,3 +1,3 @@
|
||||||
{
|
{
|
||||||
"rootDir": "/home/rbrt/Schreibtisch/marvin/BLO"
|
"rootDir": "/home/rbrt/Schreibtisch"
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
// Config
|
|
||||||
import config from '/resources/config/config.json'
|
|
||||||
|
|
||||||
// Modules
|
// Modules
|
||||||
import createReport from 'docx-templates';
|
import createReport from 'docx-templates';
|
||||||
|
|
@ -17,9 +16,12 @@ import ObjektkatalogApi from './ObjektkatalogApi';
|
||||||
|
|
||||||
export async function fillTemplate(log, objectData) {
|
export async function fillTemplate(log, objectData) {
|
||||||
let buffer;
|
let buffer;
|
||||||
|
let configJson
|
||||||
// Create docx document.
|
// Create docx document.
|
||||||
if (objectData.httpStatus === 200) {
|
if (objectData.httpStatus === 200) {
|
||||||
try {
|
try {
|
||||||
|
let ConfigFile = fs.readFileSync('resources/config/config.json')
|
||||||
|
configJson = JSON.parse(ConfigFile)
|
||||||
// Read template.
|
// Read template.
|
||||||
const template = fs.readFileSync('resources/templates/rp-template.docx');
|
const template = fs.readFileSync('resources/templates/rp-template.docx');
|
||||||
// Create report.
|
// Create report.
|
||||||
|
|
@ -43,7 +45,7 @@ export async function fillTemplate(log, objectData) {
|
||||||
tip: 'Ist das Template vorhanden?',
|
tip: 'Ist das Template vorhanden?',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const folderPath = path.join(config.rootDir, objectData.inventarnummer);
|
const folderPath = path.join(configJson.rootDir, objectData.inventarnummer);
|
||||||
// Create Folder if necessary.
|
// Create Folder if necessary.
|
||||||
try {
|
try {
|
||||||
const createDir = await mkdir(folderPath, {recursive: true});
|
const createDir = await mkdir(folderPath, {recursive: true});
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,6 @@ export default function Settings() {
|
||||||
<NavLink className={'nav-icon'} to="/"><ArrowBackIosIcon/></NavLink>
|
<NavLink className={'nav-icon'} to="/"><ArrowBackIosIcon/></NavLink>
|
||||||
</header>
|
</header>
|
||||||
<main>
|
<main>
|
||||||
<div className={'full red v-distance'}>Die App muss nach Veränderungen neu gestartet werden!</div>
|
|
||||||
<form onSubmit={selectFolderHandler}>
|
<form onSubmit={selectFolderHandler}>
|
||||||
<label htmlFor={"output-root"}>
|
<label htmlFor={"output-root"}>
|
||||||
Wurzelverzeichnis
|
Wurzelverzeichnis
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue