From 5ada72873f93005d8d6312df64862463b5da0c49 Mon Sep 17 00:00:00 2001 From: Robert Nasarek Date: Thu, 25 Aug 2022 13:30:44 +0200 Subject: [PATCH] first commit --- .babelrc | 6 + .editorconfig | 14 ++ .gitignore | 67 ++++++ .npmignore | 6 + LICENSE | 21 ++ README.md | 4 + code-of-conduct.md | 46 +++++ .../electron-react-webpack-boilerplate.png | Bin 0 -> 19924 bytes main.js | 125 +++++++++++ package.json | 80 +++++++ postcss.config.js | 16 ++ preload.js | 7 + src/DocxInserter.js | 77 +++++++ src/ObjektkatalogApi.js | 131 ++++++++++++ src/actions/getData.js | 7 + src/assets/css/App.css | 3 + src/assets/css/_example/_example.css | 22 ++ src/assets/templates/lbb-template.docx | Bin 0 -> 5496 bytes src/assets/templates/rp-template.docx | Bin 0 -> 5496 bytes src/components/App.js | 121 +++++++++++ src/components/DataForm.js | 43 ++++ src/components/Log.js | 45 ++++ src/config/config.json | 3 + src/index.html | 18 ++ src/index.js | 26 +++ src/routes/settings.js | 79 +++++++ src/shared/constants.js | 7 + src/styles.css | 195 ++++++++++++++++++ webpack.build.config.js | 61 ++++++ webpack.dev.config.js | 56 +++++ 30 files changed, 1286 insertions(+) create mode 100644 .babelrc create mode 100644 .editorconfig create mode 100644 .gitignore create mode 100644 .npmignore create mode 100644 LICENSE create mode 100644 README.md create mode 100644 code-of-conduct.md create mode 100644 docs/images/electron-react-webpack-boilerplate.png create mode 100644 main.js create mode 100644 package.json create mode 100644 postcss.config.js create mode 100644 preload.js create mode 100644 src/DocxInserter.js create mode 100644 src/ObjektkatalogApi.js create mode 100644 src/actions/getData.js create mode 100644 src/assets/css/App.css create mode 100644 src/assets/css/_example/_example.css create mode 100644 src/assets/templates/lbb-template.docx create mode 100644 src/assets/templates/rp-template.docx create mode 100644 src/components/App.js create mode 100644 src/components/DataForm.js create mode 100644 src/components/Log.js create mode 100644 src/config/config.json create mode 100644 src/index.html create mode 100644 src/index.js create mode 100644 src/routes/settings.js create mode 100644 src/shared/constants.js create mode 100644 src/styles.css create mode 100644 webpack.build.config.js create mode 100644 webpack.dev.config.js diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..85196b5 --- /dev/null +++ b/.babelrc @@ -0,0 +1,6 @@ +{ + "presets": [ + "@babel/preset-react", + "@babel/preset-env" + ] +} diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..60f6667 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,14 @@ +# editorconfig.org + +root = true + +[*] +charset = utf-8 +end_of_line = crlf +indent_size = 2 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2a8f3c9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,67 @@ +# Build folder and files # +########################## +builds/ + +# Development folders and files # +################################# +.tmp/ +dist/ +node_modules/ +*.compiled.* + +# Folder config file # +###################### +Desktop.ini + +# Folder notes # +################ +_ignore/ + +# Log files & folders # +####################### +logs/ +*.log +npm-debug.log* +.npm + +# Packages # +############ +# it's better to unpack these files and commit the raw source +# git has its own built in compression methods +*.7z +*.dmg +*.gz +*.iso +*.jar +*.rar +*.tar +*.zip + +# Photoshop & Illustrator files # +################################# +*.ai +*.eps +*.psd + +# Windows & Mac file caches # +############################# +.DS_Store +Thumbs.db +ehthumbs.db + +# Windows shortcuts # +##################### +*.lnk + +# IDE +######################## +.idea + +# Lock-Files +######################## +package-lock.json +yarn.lock + +# Miscallaneos +report.docx +misc diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..ed678db --- /dev/null +++ b/.npmignore @@ -0,0 +1,6 @@ +_ignore/ +docs/ +builds/ +dist/ +.editorconfig +code-of-conduct.md diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..ecffc92 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) Alex Devero (alexdevero.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..189951b --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +Document manager for germanic national museum + +[Boilerplate](https://github.com/alexdevero/electron-react-webpack-boilerplate.git) by [Alex Devero](https://github.com/alexdevero/) + diff --git a/code-of-conduct.md b/code-of-conduct.md new file mode 100644 index 0000000..00f53d7 --- /dev/null +++ b/code-of-conduct.md @@ -0,0 +1,46 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at deveroalex@gmail.com. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]. + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ diff --git a/docs/images/electron-react-webpack-boilerplate.png b/docs/images/electron-react-webpack-boilerplate.png new file mode 100644 index 0000000000000000000000000000000000000000..b7d910a5708b86bde9e1dfbc4fcd50d0a9d97279 GIT binary patch literal 19924 zcmb5VWmJ^k7dAX}cMTnblyr9p42`se(jf@aQqmwbG$`GTpn%ed)X-hh$N_Yxz9e=wf8=I?-QIGqO>%X@UW?{K_C#Gin4+Z2!sLye%@lD0Fu^@6jY!A z(o)w`^l>&71d0 zf9@>fqrU#VpE-Vj=G9!|SvK87;{NM;*b)4pJ*gnz-Ry1KWKq{dZf=R+8(4Hi zcJKk*0bcJOF*|$r@Ypwz5$h<~@JUW5GWPiTp=q-Gs#0rc;`3RW;(3m8)mQJA3WB%w zhR!LUwz}SV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W4eexcriU2B*au1%QV)RRNL(I$9pYCL$7*i@kM zqFhuUJjqB&(Urn-rLigre=nN01z$%%iZc%T0C~vjQCz<$fwdOY7sOS!1lW&sxxwtN zn|Bul8-jDk03}=BdBQvnHCL+0^^t_+j!e8)g(AuW>nA5K5k(<#4dFw{qgD1>b)KfQ z#BWN<4}RBqzfH@dsn#!vtSWIjb0W|sy_zwc_aAi|WLLhPUyA{`K3N0o6?NZJ0ZQyx z&`XV?q6~DBq<~seYgIFbG)~D5a5Bua&Je+pY_$QX$HIfW7=Xj4gtlq$QHr{pAO! zI-pmv$D2He%CTgfkEJzA2$>l|WxSSyQnBLxY^?6PpuXb2+RoOfgka{fjrR7e~fy|cBS!oKZ73tW}&y5 zbsQ>(u#4bN+>91OV17c~e>OOOrp6Sf%@$$Z8QkpE4MRO0GCf1ZfSq|( zy3rIjTDJoDVayKo=p1q6aEBBEQznZVsWwergQ#}r5+3-{&;nEich8F`$8Wc%7KpII zY3Y%{X$shg(meoW@nbn%1#*V7rj7pP!CCkq0j=WG9>B9$QUUz(L>A{)KL~J>2h^X6 zuv82(wJf0`hHYpukE7Una#n6iHd@7h+}WHblfrBRh=ja=Lw)mj;K>WJmzqg@Cuy=e zmjXRqCuHTNg50s8I#bOGvsFX+EWqj zzhO!9uKSZfU{q~HxQnA&S>J%w^`Guo&+awVM7$;VDopLHy1$dcphet0QDLgkuc<^F MY+Y>bTj7%a2M#%r{Qv*} literal 0 HcmV?d00001 diff --git a/main.js b/main.js new file mode 100644 index 0000000..8915834 --- /dev/null +++ b/main.js @@ -0,0 +1,125 @@ +'use strict' + +// Import parts of electron to use +const { app, BrowserWindow, dialog, ipcMain } = require('electron') +const path = require('path') +const url = require('url') + +// Keep a global reference of the window object, if you don't, the window will +// be closed automatically when the JavaScript object is garbage collected. +let mainWindow; + +// Keep a reference for dev mode +let dev = false + +// Broken: +// if (process.defaultApp || /[\\/]electron-prebuilt[\\/]/.test(process.execPath) || /[\\/]electron[\\/]/.test(process.execPath)) { +// dev = true +// } + +if (process.env.NODE_ENV !== undefined && process.env.NODE_ENV === 'development') { + dev = true +} + +// Temporary fix broken high-dpi scale factor on Windows (125% scaling) +// info: https://github.com/electron/electron/issues/9691 +if (process.platform === 'win32') { + app.commandLine.appendSwitch('high-dpi-support', 'true') + app.commandLine.appendSwitch('force-device-scale-factor', '1') +} + +// Functions + +async function handleFileOpen() { + const { canceled, filePaths } = await dialog.showOpenDialog(mainWindow, {properties: ['openDirectory']}) + if (canceled) { + return + } else { + return filePaths[0] + } +} + +function createWindow() { + // Create the browser window. + mainWindow = new BrowserWindow({ + width: 400, + height: 600, + show: false, + webPreferences: { + preload: path.join(__dirname, 'preload.js'), + nodeIntegration: true, + contextIsolation: false + } + }) + + // and load the index.html of the app. + let indexPath + + if (dev && process.argv.indexOf('--noDevServer') === -1) { + indexPath = url.format({ + protocol: 'http:', + host: 'localhost:8080', + pathname: 'index.html', + slashes: true + }) + } else { + indexPath = url.format({ + protocol: 'file:', + pathname: path.join(__dirname, 'dist', 'index.html'), + slashes: true + }) + } + + mainWindow.loadURL(indexPath) + + // Don't show until we are ready and loaded + mainWindow.once('ready-to-show', () => { + mainWindow.show() + + // Open the DevTools automatically if developing + if (dev) { + const { default: installExtension, REACT_DEVELOPER_TOOLS } = require('electron-devtools-installer') + + installExtension(REACT_DEVELOPER_TOOLS) + .catch(err => console.log('Error loading React DevTools: ', err)) + mainWindow.webContents.openDevTools() + } + }) + + // Emitted when the window is closed. + mainWindow.on('closed', function() { + // Dereference the window object, usually you would store windows + // in an array if your app supports multi windows, this is the time + // when you should delete the corresponding element. + mainWindow = null + }) +} + +// This method will be called when Electron has finished +// initialization and is ready to create browser windows. +// Some APIs can only be used after this event occurs. +app.on('ready', () => { + ipcMain.handle('dialog:openFile', handleFileOpen) + createWindow(); + +}) + +// Quit when all windows are closed. +app.on('window-all-closed', () => { + // On macOS it is common for applications and their menu bar + // to stay active until the user quits explicitly with Cmd + Q + if (process.platform !== 'darwin') { + app.quit() + } +}) + +app.on('activate', () => { + // On macOS it's common to re-create a window in the app when the + // dock icon is clicked and there are no other windows open. + if (mainWindow === null) { + createWindow() + } + +}) + +// IPC-Channel handling diff --git a/package.json b/package.json new file mode 100644 index 0000000..6d7f786 --- /dev/null +++ b/package.json @@ -0,0 +1,80 @@ +{ + "name": "marvin", + "version": "0.1.0", + "description": "GNM Document Manager", + "license": "MIT", + "private": false, + "repository": { + "type": "git", + "url": "https://github.com/rnsrk/marvin.git" + }, + "author": { + "name": "Robert Nasarek", + "email": "r.nasarek@gnm.de", + "url": "https://github.com/rnsrk" + }, + "keywords": [ + "gnm", + "electron", + "react", + "react", + "webpack" + ], + "engines": { + "node": ">=9.0.0", + "npm": ">=5.0.0", + "yarn": ">=1.0.0" + }, + "browserslist": [ + "last 4 versions" + ], + "main": "main.js", + "scripts": { + "prod": "cross-env NODE_ENV=production webpack --mode production --config webpack.build.config.js && electron --noDevServer .", + "start": "cross-env NODE_ENV=development webpack serve --hot --host 0.0.0.0 --config=./webpack.dev.config.js --mode development", + "build": "cross-env NODE_ENV=production webpack --config webpack.build.config.js --mode production", + "package": "npm run build", + "postpackage": "electron-packager ./ --out=./builds" + }, + "dependencies": { + "@emotion/react": "^11.10.0", + "@emotion/styled": "^11.10.0", + "@mui/icons-material": "^5.10.2", + "@mui/material": "^5.10.2", + "docx-templates": "^4.9.2", + "fast-xml-parser": "^4.0.9", + "file-saver": "^2.0.5", + "node-fetch": "^3.2.10", + "postcss": "^8.4.16", + "react": "^18.2.0", + "react-async-devtools": "^10.0.1", + "react-dom": "^18.2.0", + "react-router-dom": "^6.3.0", + "write-json-file": "^5.0.0", + "xml-parse-from-string": "^1.0.1", + "xml2js": "^0.4.23" + }, + "devDependencies": { + "@babel/core": "^7.18.10", + "@babel/preset-env": "^7.18.10", + "@babel/preset-react": "^7.18.6", + "babel-loader": "^8.2.5", + "cross-env": "^7.0.3", + "css-loader": "^6.7.1", + "electron": "^20.0.3", + "electron-devtools-installer": "^3.2.0", + "electron-packager": "^15.5.1", + "file-loader": "^6.2.0", + "html-webpack-plugin": "^5.5.0", + "mini-css-extract-plugin": "^2.6.1", + "postcss-import": "^14.1.0", + "postcss-loader": "^7.0.1", + "postcss-nested": "^5.0.6", + "postcss-preset-env": "^7.8.0", + "postcss-pxtorem": "^6.0.0", + "style-loader": "^3.3.1", + "webpack": "^5.74.0", + "webpack-cli": "^4.10.0", + "webpack-dev-server": "^4.10.0" + } +} diff --git a/postcss.config.js b/postcss.config.js new file mode 100644 index 0000000..098a054 --- /dev/null +++ b/postcss.config.js @@ -0,0 +1,16 @@ +module.exports = { + plugins: { + 'postcss-import': {}, + 'postcss-nested': {}, + 'postcss-preset-env': {}, + 'postcss-pxtorem': { + rootValue: 16, + unitPrecision: 5, + propList: ['*'], + selectorBlackList: ['html', 'body'], + replace: true, + mediaQuery: false, + minPixelValue: 0 + } + } +} diff --git a/preload.js b/preload.js new file mode 100644 index 0000000..93d3606 --- /dev/null +++ b/preload.js @@ -0,0 +1,7 @@ +const { ipcRenderer } = require('electron') + +window.openFile = async () => { + return await ipcRenderer.invoke('dialog:openFile') +} + + diff --git a/src/DocxInserter.js b/src/DocxInserter.js new file mode 100644 index 0000000..b2a7d04 --- /dev/null +++ b/src/DocxInserter.js @@ -0,0 +1,77 @@ +// Config +import config from './config/config.json' + +// Modules +import createReport from 'docx-templates'; +import fs from 'fs'; +import { mkdir } from 'node:fs/promises'; +import path from 'path'; + +// Components +import ObjektkatalogApi from './ObjektkatalogApi'; + +//////////////////// +// Main // +//////////////////// + +export async function fillTemplate(log, objectData) { + + let buffer; + // Create docx document. + if (objectData.httpStatus === 200) { + try { + // Read template. + const template = fs.readFileSync('src/assets/templates/rp-template.docx'); + // Create report. + buffer = await createReport({ + template, + data: { + inventarnummer: objectData.inventarnummer, + titel: objectData.titel, + hersteller: objectData.hersteller, + herstellungsort: objectData.herstellungsort, + herstellungsdatum: objectData.herstellungsdatum, + materialTechnik: objectData.materialTechnik, + masse: objectData.masse + } + }); + } catch (err) { + log = { + ...log, + status: 'red', + message: 'Konnte Template nicht öffnen: ' + err, + tip: 'Ist das Template vorhanden?', + }; + } + + const folderPath = path.join(config.rootDir, objectData.inventarnummer); + // Create Folder if necessary. + try { + const createDir = await mkdir(folderPath, {recursive: true}); + } catch (err) { + log = { + ...log, + status: 'green', + message: 'Konnte den Pfad nicht erstellen' + err, + tip: 'Bestehen Schreibrechte auf dem Ordner?' + } + } + // Write document to disk. + if (buffer) { + fs.writeFileSync(path.join(folderPath, 'report.docx'), buffer) + log = { + ...log, + status: 'green', + message: 'Dokument erstellt', + }; + } + } else { + log = { + status: 'red', + message: 'Fehler bei der Kommunikation mit dem Objektkatalog', + code: objectData.httpStatus, + tip: 'Ist die Inventarnummer richtig?', + }; + } + return log; +} diff --git a/src/ObjektkatalogApi.js b/src/ObjektkatalogApi.js new file mode 100644 index 0000000..98beea7 --- /dev/null +++ b/src/ObjektkatalogApi.js @@ -0,0 +1,131 @@ +const {parseString} = require("xml2js"); + +/* + * Sends Object ID to Objektkatalog-API and receives JSON + */ +class ObjektkatalogApi { + json; + short; + raw; + async getData(objectId) { + if (objectId) { + const response = await fetch('https://objektkatalog.gnm.de/rest_export/' + objectId); + if (response.status === 200) { + const responseJson = await response.json(); //extract JSON from the http response + if (responseJson.length !== 0) { + this.raw = { + eid: responseJson[0]['eid'], + allgemeineBezeichnung: responseJson[0]['fc6392714594e73ddb2fa363815a8fdf'], + beschreibung: responseJson[0]['f81f557caccf45074edfb65ff077011f'], + darstellung: responseJson[0]['f217e1053b1e29411d4b00f3b1e1d52b'], + erwerbsmethode: responseJson[0]['fa4aa035d411275cd36a2fbb5c159a2c'], + fruehstes: responseJson[0]['ff4a178095c895a12fce6320c04ba0b0'], + fundort: responseJson[0]['f1c2bf9f6f3d78302bbfa9cc8b3e439c'], + gehoertZuAggregation: responseJson[0]['fca2cff9e713e02b93be1f9f19dff88e'], + herstellerString: responseJson[0]['f9f9408fdacc1230497c591c89655777'], + herstellungsdatum: responseJson[0]['fd9f0912229c78d94dd6f807e683d06e'], + herstellungsort: responseJson[0]['fbbccf2979c1143b0fa25325a849b121'], + individuelleEinordnung: responseJson[0]['f8e7a568a6a0fb8907b41f5ba8a9cabe'], + inventarnummer: responseJson[0]['f9830c2c7747a792ebbe1ca2587d1f26'], + klassifikation: responseJson[0]['fdcd0101d5c77884d185560aa7521645'], + masse: responseJson[0]['ffdac65ffbb12438e2fef5b26533c909'], + materialTechnik: responseJson[0]['f23b67bd18913642fc3936c1f2af5682'], + muster: responseJson[0]['f88917aeadae224c8d2c1fec35720dc8'], + provisio: responseJson[0]['f930a6ca774cc5640694c5aa081c1e66'], + sammlung: responseJson[0]['ffd22ba4399f8d62e61c4e99463dddaa'], + spaetestens: responseJson[0]['f1c2bf9f6f3d78302bbfa9cc8b3e439c'], + standort: responseJson[0]['f95e9be48ed110cf4f92298712d364bd'], + titel: responseJson[0]['f2049b2456b20f8fd80f714e154f1d47'], + unterbringung: responseJson[0]['f15265e39237868a568ee63453492b17'], + vitrinentext: responseJson[0]['fe5e3ff18aedf1d25c639dc79fb24ad1'], + zustandsbeschreibung: responseJson[0]['f54b6da6006ea444c33a348b8c4370a8'] + } + } else { + return {httpStatus: 404}; + } + } else { + return {httpStatus: response.status}; + } + } else { + return {httpStatus: 400} + } + + // Inventarnummer + let inventarnummer; + if (this.raw.inventarnummer.length !== 0) { + inventarnummer = this.raw.inventarnummer[0].value; + } else { + inventarnummer = 'unbekannt'; + } + + // Titel + let titel; + if (this.raw.titel.length !== 0) { + titel = this.raw.titel[0].value; + } else { + titel = 'unbekannt'; + } + + // Hersteller + let herstellerArray = []; + let hersteller; + + if (this.raw.herstellerString.length !== 0) { + this.raw.herstellerString.forEach((item) => { + parseString(item.value, (err, result) => { + herstellerArray.push(result['results']['lido:eventActor'][0]['lido:actorInRole'][0]['lido:actor'][0]['lido:nameActorSet'][0]['lido:appellationValue'][0]['_']); + return hersteller = herstellerArray.join(';') + }) + }); + } else { + hersteller = 'unbekannt'; + } + + // Herstellungsort + let herstellungsort; + if (this.raw.herstellungsort.length !== 0) { + herstellungsort = this.raw.herstellungsort[0].value + } else { + herstellungsort = 'unbekannt'; + } + + // Herstellungsdatum + let herstellungsdatum; + if (this.raw.herstellungsdatum.length !== 0) { + herstellungsdatum = this.raw.herstellungsdatum[0].value + } else { + herstellungsdatum = 'unbekannt'; + } + + // Material und Technik + let materialTechnik; + if (this.raw.materialTechnik.length !== 0) { + materialTechnik = this.raw.materialTechnik[0].value + } else { + materialTechnik = 'unbekannt'; + } + + // Maße + let masse; + if (this.raw.masse.length !== 0) { + parseString(this.raw.masse[0].value, (err, result) => { + return masse = result['results']['lido:objectMeasurementsSet'][0]['lido:displayObjectMeasurements'][0]; + }) + } + + return this.short = { + inventarnummer: inventarnummer, + titel: titel, + hersteller: hersteller, + herstellungsort: herstellungsort, + herstellungsdatum: herstellungsdatum, + materialTechnik: materialTechnik, + masse: masse, + httpStatus: 200, + } + + + } +} + +module.exports = ObjektkatalogApi; diff --git a/src/actions/getData.js b/src/actions/getData.js new file mode 100644 index 0000000..5d04706 --- /dev/null +++ b/src/actions/getData.js @@ -0,0 +1,7 @@ +import GnmObject from "../ObjektkatalogApi"; + +/* + * + */ + + diff --git a/src/assets/css/App.css b/src/assets/css/App.css new file mode 100644 index 0000000..9411970 --- /dev/null +++ b/src/assets/css/App.css @@ -0,0 +1,3 @@ +/* Main CSS file */ + +@import '_example/_example.css'; diff --git a/src/assets/css/_example/_example.css b/src/assets/css/_example/_example.css new file mode 100644 index 0000000..472ead8 --- /dev/null +++ b/src/assets/css/_example/_example.css @@ -0,0 +1,22 @@ +/* Example stylesheet */ +@media screen and (prefers-color-scheme: light), screen and (prefers-color-scheme: no-preference) { + /* Light theme */ + body{ + color: #000; + background-color: #fff; + } +} + +@media screen and (prefers-color-scheme: dark) { + /* Dark theme */ + body { + color: #fff; + background-color: #000; + } +} + +h1 { + font-family: Helvetica, Arial, sans-serif; + font-size: 21px; + font-weight: 200; +} diff --git a/src/assets/templates/lbb-template.docx b/src/assets/templates/lbb-template.docx new file mode 100644 index 0000000000000000000000000000000000000000..69667af30134979f8863a74dee0bb080f3d212c1 GIT binary patch literal 5496 zcmaJ_2RPep_m0>r_N)>`QF~LWs4Ak=tUaT|-dl|pHEVB5Y(=SA8m(P5n%Y}Xt466- z?Ea(g`+fEH|GhoQFITQBInVVx_c`Z&&VBAduyLpX1OxhFk@5)OjX2b4`$ zGugu2hTXp!z84~;ulF6sUTB7G3!ZKUI}I5)R)*Hq^OSl$OE?>k%~dqwVW zl6+reToR%fV!dbFeVAMd5kXlakG_Dn{cY9~2HLdaA^g{ga3Nl~g;v>Av&Py`kio={ zuZku8OzZoZg|Nlxy|!NXji(+D?k*Oe?XnB z?zuU;xC>Z0yIJ%5I6A~8_Gxv1sl(B-x5EQf6a6C9RBh^-wR%2!dCX`^I)0R+&l_t+ zusiN((QOYdFRh+1mG4HBCwW(^i~BwPDj!aXd`+PxaK~00p$HeTijTfPqdB*&jUv<6VmC21pw^+F>vG;183plavryw zgg&QsLGs(^)2Mfr5GEigfs|5UDNo@Qv9Rs<4U)*`oed6;P+z2BBcdCAV&2;a#y2Nc zro=zuX5Uv@h0=1e1NrWjd88zv7p=D)p zu_DtkBoRwNsM^y4@yE3Mo>(J-l4*gE_ zt$Q3OV)5d9!UW<&29tW148)eHUs>tjnL}#~*q~iQH*8RiJzj9&2b-9ETxt6Iez}7T zTRi(Z#GKH#zPZH^r8|C~F6)%eSHvT?2D-J`@H?_gv#Z6f@;ASehttbG3c@}|yaw@L zP85Uql|Ld*brEqZPj?Sz$Dg1N))2J|Qim)!9Q38nE1*-`$N4 z^k)m*j*DQCRUf`_daHtblEUtl01r2Sj}*ko=X_cusnXVqGG~6Aw~WWz;x%r}hWn%! zE1DNhMZ{)Zy-Du~P^L zI{)Qh&Y9KUvEZT2G~M~R7RCUy?)=nPhXZwpZ z6YgRTNFIjHz0yBdtV^Cy?4;b4tQg2JshYz0ct|6cBvdg*hzM zAH#gkh(F=D2*j4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G|jEBPb2 zZMkjvXKRZCkBMQ$wCwLOeE;vQ?SFeYcWVz1n3K&B^yq&~sRVRVG_Fe6u9Yk6me!VR<;=QiXp|kJQql>BV*Bt|U-7Q4q`r?}wpFyp<9W6(@vnxOI^s`_Y5dj89IOh3x z7|)fD(Jf4lVq}4tj<1WgyUF>riAe6lBl>HQ8b<>WiBlnUC}yjIGEWl(@oMCM&TTe)RB3tbIWy6~{SA z3gds-HF- { + let log; + + // States + + /* Initialize state of the log. + * log: variables fpr logging message. + * logClass: for visibility of log
. + */ + const [logState, setLogState] = useState({ + log: { + status: '', + message: '', + code: '', + tip:'', + }, // with message, code, tip + logClass: 'inactive' + }); + + const [objectData, setObjectData] = useState( + { + inventarnummer: '', + titel: '', + hersteller: '', + herstellungsort: '', + herstellungsdatum: '', + materialTechnik: '', + masse: '', + httpStatus: 500, + } + ); + + const [checkUpVisibility, setCheckUpVisibility] = useState( + false + ); + + // Handler + async function getDataAndAskForCheckUpClickHandler(e) { + // Prevent page reload. + e.preventDefault(); + + // Get objectId from user input. + let objectId = document.getElementById('object-id').value + + // Get object data from objektkatalog.gnm.de + let objektkatalogApi = new ObjektkatalogApi(); + let objectData = await objektkatalogApi.getData(objectId); + + console.log(objectData) + + log = await fillTemplate(log, objectData); + // Set new state of log div with message and visibility class + setLogState({ + log: log, + logStatus: 'active' + }); + } + + return ( +
+
+ +
+
+
+
+
+ + +
+
+ + +
+ + + +
+
+ +
+
+ {/* We give state and state setter of the parent as params to the child components, so that child events can change parent states */} + +
+
+ ) +} + +export default App diff --git a/src/components/DataForm.js b/src/components/DataForm.js new file mode 100644 index 0000000..9231f58 --- /dev/null +++ b/src/components/DataForm.js @@ -0,0 +1,43 @@ +// React +import React from 'react' + +//////////////////// +// Main // +//////////////////// + +export const DataForm = () => { + return (
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+
+ ) +} diff --git a/src/components/Log.js b/src/components/Log.js new file mode 100644 index 0000000..94045d0 --- /dev/null +++ b/src/components/Log.js @@ -0,0 +1,45 @@ +// React +import React from 'react' + +//////////////////// +// Main // +//////////////////// + +export const Log = ({logState, setLogState}) => { + let code; + let tip; + + const closeLog = (e, logClass) => { + e.preventDefault() + setLogState({log: logState.log, + logClass: 'inactive'}); + } + + const classes = 'round-box flex ' + logState.log.status + ' ' + logState.logClass + if (logState.log.code) { + code = ' Code: ' + logState.log.code + } else { + code = '' + } + if (logState.log.tip) { + tip = ' Tipp: ' + logState.log.tip + } else { + tip = '' + } + return ( +
+
+
+ +
+
+

{logState.log.message}

+

{code}

+

{tip}

+
+
+
+ ) +} + + diff --git a/src/config/config.json b/src/config/config.json new file mode 100644 index 0000000..f62e2f6 --- /dev/null +++ b/src/config/config.json @@ -0,0 +1,3 @@ +{ + "rootDir": "/home/rbrt/Dokumente/marvin" +} \ No newline at end of file diff --git a/src/index.html b/src/index.html new file mode 100644 index 0000000..24f6758 --- /dev/null +++ b/src/index.html @@ -0,0 +1,18 @@ + + + + + + + + + Marvin + + + +
+ + + diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..817d8e3 --- /dev/null +++ b/src/index.js @@ -0,0 +1,26 @@ +// React +import {createRoot} from 'react-dom/client' +import { + HashRouter, + Routes, + Route} from "react-router-dom"; +import React from "react"; + +// Components +import App from './components/App' + +// Routes +import Settings from "./routes/settings"; + +// entry index.html is managed by webpack via HtmlWebpackPlugin + +const container = document.getElementById('root'); +const root = createRoot(container); +root.render( + + + } /> + } /> + + +); diff --git a/src/routes/settings.js b/src/routes/settings.js new file mode 100644 index 0000000..f101a63 --- /dev/null +++ b/src/routes/settings.js @@ -0,0 +1,79 @@ +import config from '../config/config.json' + +// Icons +import ArrowBackIosIcon from '@mui/icons-material/ArrowBackIos'; +import EditIcon from '@mui/icons-material/Edit'; + +// Modules +const {writeFile} = require('fs'); + +// React +import React, {useState} from "react"; +import {Link} from "react-router-dom"; + + +//////////////////// +// Main // +//////////////////// + +export default function Settings() { + let rootDir; + const [disableButton, setDisableButton] = useState(true) + + async function selectFolderHandler() { + return rootDir = await window.openFile(); + + } + + + + // Handler + function saveInputClickHandler(rootDir) { + if (rootDir) { + config.rootDir = rootDir + writeFile('src/config/config.json', JSON.stringify(config, null, 2), (error) => { + if (error) { + console.log('An error has occurred ', error); + return; + } + console.log('Data written successfully to disk'); + }); + } + } + + return ( +
+
+ +
+
+
+ +
+ + +
+
+
+ +
+ ); +} diff --git a/src/shared/constants.js b/src/shared/constants.js new file mode 100644 index 0000000..1a3981b --- /dev/null +++ b/src/shared/constants.js @@ -0,0 +1,7 @@ +module.exports = { + channels: { + GET_DATA: 'get_data', + }, + log: { + } +}; diff --git a/src/styles.css b/src/styles.css new file mode 100644 index 0000000..efa39dc --- /dev/null +++ b/src/styles.css @@ -0,0 +1,195 @@ +@import url('https://fonts.googleapis.com/css?family=Roboto'); + +a { + color: #d5d5d5; +} + +.active { + display: block; +} + +body { + background-color: #00152E ; + color: #d5d5d5; + font-family: 'Roboto', regular, serif; + font-size: larger; +} + + +.center { + margin: 0 auto; +} + +.column { + flex-direction: column; +} + +.container { + width: 300px; + margin: 0 auto; +} +.cut { + max-width: max-content; +} + +div { + padding: 0.5em; +} + +.edit-button { + background-color: #d5d5d5; + font-family: roboto, sans-serif; + font-size: 1rem; + border-radius: 0 0.4rem 0.4rem 0; + border: unset; + padding: 0 4px; + height: 1.1rem; +} + +.edit-input { + border-radius: 0.4rem 0 0 0.4rem; +} + +.flex { + display: flex; + } + +.flex-full { + flex: 1 +} +.flex-wrap { + display: flex; + flex-wrap: wrap; +} + +.full { + width: 100%; +} + +.green { + background-color: darkgreen; +} + +.inactive { + display: none; +} + +input { + border-top: none; + border-right: none; + border-left: none; + border-bottom: 2px solid darkred; + border-radius: 3px; +} + +input:focus { +background-color: #d5d5d5; + color: #00152E; +} + +input.edit-input:not(:disabled) { + background-color: #d5d5d5; + color: #00152E; +} + + +.input-field { + background-color: #00152E ; + color: #d5d5d5; + font-size: medium; + +} + + + +.justify-content-end { + justify-content: end; +} + +.justify-content-space-between { + justify-content: space-between; +} + +label { + padding-right: 5px; +} + +.log { + font-size: 0.75em; + height: 5em; +} + +p { + margin: 0; +} + +.position-absolute { + position: absolute; +} + +.position-relative { + position: relative; +} + +.red { + background-color: crimson; +} + +.round-box { + border-radius: 6px; +} + +select { + border: none; + font-size: medium; + outline: none; + +} + +.send-button { + font-family: roboto, sans-serif; + font-size: 1rem; + border-radius: 0.4rem; + border: unset; + background-color: darkred; + color: #d5d5d5; +} + +.scroll-y { + overflow-y: scroll; +} + +.select-folder-field { + background-color: #00152E ; + color: #d5d5d5; + width: 100%; + font-size: .85rem; +} + + +.sticky-edit { + display: flex; + align-items: flex-start; +} +textarea, textarea:focus, input:focus{ + outline: none; + font-size: medium; +; +} + +textarea.select-folder-field, textarea.select-folder-field:focus, input.select-folder-field:focus { + font-size: .85rem; +} + +.top-distance { + margin-top: 1em; +} + +.v-distance { + margin-top: 0.25em; + margin-bottom: 0.25em; +} + +.yellow{ + background-color: goldenrod; +} diff --git a/webpack.build.config.js b/webpack.build.config.js new file mode 100644 index 0000000..c0aefc8 --- /dev/null +++ b/webpack.build.config.js @@ -0,0 +1,61 @@ +const webpack = require('webpack') +const path = require('path') +const HtmlWebpackPlugin = require('html-webpack-plugin') +const MiniCssExtractPlugin = require('mini-css-extract-plugin') + +// Any directories you will be adding code/files into, need to be added to this array so webpack will pick them up +const defaultInclude = path.resolve(__dirname, 'src') + +module.exports = { + module: { + rules: [ + { + test: /\.css$/, + use: [ + MiniCssExtractPlugin.loader, + 'css-loader', + 'postcss-loader' + ], + include: defaultInclude + }, + { + test: /\.jsx?$/, + use: [{ loader: 'babel-loader' }], + include: defaultInclude + }, + { + test: /\.(jpe?g|png|gif)$/, + use: [{ loader: 'file-loader?name=img/[name]__[hash:base64:5].[ext]' }], + include: defaultInclude + }, + { + test: /\.(eot|svg|ttf|woff|woff2)$/, + use: [{ loader: 'file-loader?name=font/[name]__[hash:base64:5].[ext]' }], + include: defaultInclude + } + ] + }, + target: 'electron-renderer', + plugins: [ + new HtmlWebpackPlugin({title: 'Marvin'}), + new MiniCssExtractPlugin({ + // Options similar to the same options in webpackOptions.output + // both options are optional + filename: 'bundle.css', + chunkFilename: '[id].css' + }), + new webpack.DefinePlugin({ + 'process.env.NODE_ENV': JSON.stringify('production') + }), + // new MinifyPlugin() + ], + stats: { + colors: true, + children: false, + chunks: false, + modules: false + }, + optimization: { + minimize: true + } +} diff --git a/webpack.dev.config.js b/webpack.dev.config.js new file mode 100644 index 0000000..6420d03 --- /dev/null +++ b/webpack.dev.config.js @@ -0,0 +1,56 @@ +const webpack = require('webpack') +const path = require('path') +const HtmlWebpackPlugin = require('html-webpack-plugin') +const { spawn } = require('child_process') + +// Any directories you will be adding code/files into, need to be added to this array so webpack will pick them up +const defaultInclude = path.resolve(__dirname, 'src') + +module.exports = { + module: { + rules: [ + { + test: /\.css$/, + use: [{ loader: 'style-loader' }, { loader: 'css-loader' }, { loader: 'postcss-loader' }], + include: defaultInclude + }, + { + test: /\.jsx?$/, + use: [{ loader: 'babel-loader' }], + include: defaultInclude + }, + { + test: /\.(jpe?g|png|gif)$/, + use: [{ loader: 'file-loader?name=img/[name]__[hash:base64:5].[ext]' }], + include: defaultInclude + }, + { + test: /\.(eot|svg|ttf|woff|woff2)$/, + use: [{ loader: 'file-loader?name=font/[name]__[hash:base64:5].[ext]' }], + include: defaultInclude + } + ] + }, + target: 'electron-renderer', + plugins: [ + new HtmlWebpackPlugin({ + title: 'Marvin', + template: 'src/index.html'}), + new webpack.DefinePlugin({ + 'process.env.NODE_ENV': JSON.stringify('development') + }) + ], + devtool: 'cheap-source-map', + devServer: { + static: path.resolve(__dirname, 'dist'), + onBeforeSetupMiddleware() { + spawn( + 'electron', + ['.'], + { shell: true, env: process.env, stdio: 'inherit' } + ) + .on('close', code => process.exit(0)) + .on('error', spawnError => console.error(spawnError)) + } + } +}