From 38c85ae8ca8bac820231d6f03655ad739cf46234 Mon Sep 17 00:00:00 2001
From: Christoph Reiter <reiter.christoph@gmail.com>
Date: Wed, 18 Mar 2020 12:37:12 +0100
Subject: [PATCH] Add a simple welcome page

This allows users to see what the applocation is about without
being logged in.
---
 assets/vpu-signature-welcome.metadata.json | 17 ++++++++
 assets/vpu-signature.topic.metadata.json   |  1 +
 rollup.config.js                           |  1 +
 src/i18n/de/translation.json               |  4 ++
 src/i18n/en/translation.json               |  4 ++
 src/vpu-signature-welcome.js               | 50 ++++++++++++++++++++++
 6 files changed, 77 insertions(+)
 create mode 100644 assets/vpu-signature-welcome.metadata.json
 create mode 100644 src/vpu-signature-welcome.js

diff --git a/assets/vpu-signature-welcome.metadata.json b/assets/vpu-signature-welcome.metadata.json
new file mode 100644
index 0000000..89bcc75
--- /dev/null
+++ b/assets/vpu-signature-welcome.metadata.json
@@ -0,0 +1,17 @@
+{
+  "element": "vpu-signature-welcome",
+  "module_src": "vpu-signature-welcome.js",
+  "routing_name": "welcome",
+  "name": {
+    "de": "Willkommen",
+    "en": "Welcome"
+  },
+  "short_name": {
+    "de": "Willkommen",
+    "en": "Welcome"
+  },
+  "description": {
+    "de": "",
+    "en": ""
+  }
+}
\ No newline at end of file
diff --git a/assets/vpu-signature.topic.metadata.json b/assets/vpu-signature.topic.metadata.json
index 10518bf..0efbf96 100644
--- a/assets/vpu-signature.topic.metadata.json
+++ b/assets/vpu-signature.topic.metadata.json
@@ -13,6 +13,7 @@
   },
   "routing_name": "signature",
   "activities": [
+    {"path": "vpu-signature-welcome.metadata.json"},
     {"path": "vpu-signature-pdf-upload.metadata.json"},
     {"path": "vpu-signature-profile.metadata.json",
      "visible": false}
diff --git a/rollup.config.js b/rollup.config.js
index 38569ac..3cf84de 100644
--- a/rollup.config.js
+++ b/rollup.config.js
@@ -144,6 +144,7 @@ export default {
       'src/vpu-signature.js',
       'src/vpu-signature-pdf-upload.js',
       'src/vpu-signature-profile.js',
+      'src/vpu-signature-welcome.js',
     ] : glob.sync('test/**/*.js'),
     output: {
       dir: 'dist',
diff --git a/src/i18n/de/translation.json b/src/i18n/de/translation.json
index 946a16b..b101f74 100644
--- a/src/i18n/de/translation.json
+++ b/src/i18n/de/translation.json
@@ -16,6 +16,10 @@
   "pdf-upload": {
     "button-refresh-title": "Aufstellung von {{name}} erneut laden"
   },
+  "welcome": {
+    "headline": "Willkommen beim Amtssignatureservice der TU Graz",
+    "description": "Mit dieser Applikation können Sie, sofern Sie dazu berechtigt sind, PDF Dateien im Namen der TU Graz signieren"
+  },
   "create-loan": {
     "info-no-existing-loans-summary": "Keine bestehenden Entlehnungen",
     "info-no-existing-loans-body": "Es wurden keine bestehenden Entlehnungen gefunden, das Buch kann entlehnt werden.",
diff --git a/src/i18n/en/translation.json b/src/i18n/en/translation.json
index 0244e9f..ede7bb9 100644
--- a/src/i18n/en/translation.json
+++ b/src/i18n/en/translation.json
@@ -16,6 +16,10 @@
   "pdf-upload": {
     "button-refresh-title": "Load pdf-upload from {{name}} again"
   },
+  "welcome": {
+    "headline": "Welcome to the official signature service of the TU Graz",
+    "description": "With this application you can, provided you are authorized to do so, sign PDF files in the name of the TU Graz"
+  },
   "create-loan": {
     "info-no-existing-loans-summary": "No existing loans",
     "info-no-existing-loans-body": "No existing loans were found, a new one can be created.",
diff --git a/src/vpu-signature-welcome.js b/src/vpu-signature-welcome.js
new file mode 100644
index 0000000..eb32301
--- /dev/null
+++ b/src/vpu-signature-welcome.js
@@ -0,0 +1,50 @@
+import {createI18nInstance} from './i18n.js';
+import {css, html, LitElement} from 'lit-element';
+import * as commonUtils from 'vpu-common/utils';
+import * as commonStyles from 'vpu-common/styles';
+import 'vpu-person-profile';
+
+const i18n = createI18nInstance();
+
+class SignatureWelcome extends LitElement {
+
+    constructor() {
+        super();
+        this.lang = i18n.language;
+
+    }
+
+    static get properties() {
+        return {
+            lang: { type: String },
+        };
+    }
+
+    update(changedProperties) {
+        changedProperties.forEach((oldValue, propName) => {
+            if (propName === "lang") {
+                i18n.changeLanguage(this.lang);
+            }
+        });
+
+        super.update(changedProperties);
+    }
+
+    static get styles() {
+        // language=css
+        return css`
+            ${commonStyles.getThemeCSS()}
+            ${commonStyles.getGeneralCSS()}
+        `;
+    }
+
+    render() {
+        return html`
+            <p>${i18n.t('welcome.headline')}</p>
+            <br>
+            <p>${i18n.t('welcome.description')}</p>
+        `;
+    }
+}
+
+commonUtils.defineCustomElement('vpu-signature-welcome', SignatureWelcome);
-- 
GitLab