Skip to content
Snippets Groups Projects
Commit 19a45fb7 authored by Reiter, Christoph's avatar Reiter, Christoph :snake:
Browse files

Re-format while code base

parent 48e14942
No related branches found
No related tags found
No related merge requests found
Pipeline #86195 passed
Showing
with 1914 additions and 1323 deletions
......@@ -14,11 +14,11 @@
"sourceType": "module"
},
"rules": {
"no-unused-vars": ["error", { "args": "none" }],
"no-unused-vars": ["error", {"args": "none"}],
"semi": [2, "always"],
"jsdoc/require-jsdoc": 0,
"jsdoc/require-param-description": 0,
"jsdoc/require-returns": 0,
"jsdoc/require-param-type": 0
}
}
\ No newline at end of file
}
{
"extends": [
"config:base",
"group:allNonMajor",
"schedule:weekly"
],
"ignorePresets": [":prHourlyLimit2"],
"rangeStrategy": "update-lockfile",
"composer": {
"enabled": false
},
"cloneSubmodules": true
}
\ No newline at end of file
"extends": ["config:base", "group:allNonMajor", "schedule:weekly"],
"ignorePresets": [":prHourlyLimit2"],
"rangeStrategy": "update-lockfile",
"composer": {
"enabled": false
},
"cloneSubmodules": true
}
{
"short_name": "esign",
"name": "Electronic Signature Service",
"start_url": "./",
"icons": [
{
"src": "images/icon-72x72.png",
"sizes": "72x72",
"type": "image/png"
},
{
"src": "images/icon-96x96.png",
"sizes": "96x96",
"type": "image/png"
},
{
"src": "images/icon-128x128.png",
"sizes": "128x128",
"type": "image/png"
},
{
"src": "images/icon-144x144.png",
"sizes": "144x144",
"type": "image/png"
},
{
"src": "images/icon-152x152.png",
"sizes": "152x152",
"type": "image/png"
},
{
"src": "images/icon-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "images/icon-384x384.png",
"sizes": "384x384",
"type": "image/png"
},
{
"src": "images/icon-256x256.png",
"sizes": "256x256",
"type": "image/png"
},
{
"src": "images/icon-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"background_color": "#FEFEFE",
"display": "standalone",
"theme_color": "#FFFFFF"
"short_name": "esign",
"name": "Electronic Signature Service",
"start_url": "./",
"icons": [
{
"src": "images/icon-72x72.png",
"sizes": "72x72",
"type": "image/png"
},
{
"src": "images/icon-96x96.png",
"sizes": "96x96",
"type": "image/png"
},
{
"src": "images/icon-128x128.png",
"sizes": "128x128",
"type": "image/png"
},
{
"src": "images/icon-144x144.png",
"sizes": "144x144",
"type": "image/png"
},
{
"src": "images/icon-152x152.png",
"sizes": "152x152",
"type": "image/png"
},
{
"src": "images/icon-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "images/icon-384x384.png",
"sizes": "384x384",
"type": "image/png"
},
{
"src": "images/icon-256x256.png",
"sizes": "256x256",
"type": "image/png"
},
{
"src": "images/icon-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"background_color": "#FEFEFE",
"display": "standalone",
"theme_color": "#FFFFFF"
}
{
"name": {
"de": "Elektronisches Signaturservice",
"en": "Electronic Signatures"
},
"short_name": {
"de": "Elektronisches Signaturservice",
"en": "Electronic Signatures"
},
"description": {
"de": "Mit dieser Applikation können Sie PDF-Dokumente signieren",
"en": "With this application you can sign PDF documents"
},
"routing_name": "signature",
"activities": [
{"path": "/app/dbp-qualified-signature-pdf-upload.metadata.json"},
{"path": "/app/dbp-signature-verification.metadata.json"},
{"path": "/app/dbp-official-signature-pdf-upload.metadata.json"}
],
"attributes": []
}
\ No newline at end of file
"name": {
"de": "Elektronisches Signaturservice",
"en": "Electronic Signatures"
},
"short_name": {
"de": "Elektronisches Signaturservice",
"en": "Electronic Signatures"
},
"description": {
"de": "Mit dieser Applikation können Sie PDF-Dokumente signieren",
"en": "With this application you can sign PDF documents"
},
"routing_name": "signature",
"activities": [
{"path": "/app/dbp-qualified-signature-pdf-upload.metadata.json"},
{"path": "/app/dbp-signature-verification.metadata.json"},
{"path": "/app/dbp-official-signature-pdf-upload.metadata.json"}
],
"attributes": []
}
......@@ -11,7 +11,7 @@ export default {
nextcloudName: 'TU Graz cloud',
pdfAsQualifiedlySigningServer: 'https://sig-dev.tugraz.at',
hiddenActivities: ['dbp-signature-verification-full'],
enableAnnotations: true
enableAnnotations: true,
},
bs: {
basePath: '/dist/',
......@@ -25,7 +25,7 @@ export default {
nextcloudName: 'TU Graz cloud',
pdfAsQualifiedlySigningServer: 'https://sig-dev.tugraz.at',
hiddenActivities: [],
enableAnnotations: true
enableAnnotations: true,
},
development: {
basePath: '/apps/signature/',
......@@ -39,7 +39,7 @@ export default {
nextcloudName: 'TU Graz cloud',
pdfAsQualifiedlySigningServer: 'https://sig-dev.tugraz.at',
hiddenActivities: ['dbp-signature-verification-full'],
enableAnnotations: true
enableAnnotations: true,
},
demo: {
basePath: '/apps/signature/',
......@@ -53,7 +53,7 @@ export default {
nextcloudName: 'TU Graz cloud',
pdfAsQualifiedlySigningServer: 'https://sig-demo.tugraz.at',
hiddenActivities: ['dbp-signature-verification-full'],
enableAnnotations: true
enableAnnotations: true,
},
production: {
basePath: '/',
......@@ -67,6 +67,6 @@ export default {
nextcloudName: 'TU Graz cloud',
pdfAsQualifiedlySigningServer: 'https://sig.tugraz.at',
hiddenActivities: ['dbp-signature-verification-full'],
enableAnnotations: false
enableAnnotations: false,
},
};
\ No newline at end of file
};
{
"short_name": "TU Graz esign",
"name": "TU Graz Electronic Signature Service",
"start_url": "./",
"icons": [
{
"src": "local/@dbp-topics/signature/icon-72x72.png",
"sizes": "72x72",
"type": "image/png"
},
{
"src": "local/@dbp-topics/signature/icon-96x96.png",
"sizes": "96x96",
"type": "image/png"
},
{
"src": "local/@dbp-topics/signature/icon-128x128.png",
"sizes": "128x128",
"type": "image/png"
},
{
"src": "local/@dbp-topics/signature/icon-144x144.png",
"sizes": "144x144",
"type": "image/png"
},
{
"src": "local/@dbp-topics/signature/icon-152x152.png",
"sizes": "152x152",
"type": "image/png"
},
{
"src": "local/@dbp-topics/signature/icon-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "local/@dbp-topics/signature/icon-384x384.png",
"sizes": "384x384",
"type": "image/png"
},
{
"src": "local/@dbp-topics/signature/icon-256x256.png",
"sizes": "256x256",
"type": "image/png"
},
{
"src": "local/@dbp-topics/signature/icon-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"background_color": "#FEFEFE",
"display": "standalone",
"theme_color": "#FFFFFF"
"short_name": "TU Graz esign",
"name": "TU Graz Electronic Signature Service",
"start_url": "./",
"icons": [
{
"src": "local/@dbp-topics/signature/icon-72x72.png",
"sizes": "72x72",
"type": "image/png"
},
{
"src": "local/@dbp-topics/signature/icon-96x96.png",
"sizes": "96x96",
"type": "image/png"
},
{
"src": "local/@dbp-topics/signature/icon-128x128.png",
"sizes": "128x128",
"type": "image/png"
},
{
"src": "local/@dbp-topics/signature/icon-144x144.png",
"sizes": "144x144",
"type": "image/png"
},
{
"src": "local/@dbp-topics/signature/icon-152x152.png",
"sizes": "152x152",
"type": "image/png"
},
{
"src": "local/@dbp-topics/signature/icon-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "local/@dbp-topics/signature/icon-384x384.png",
"sizes": "384x384",
"type": "image/png"
},
{
"src": "local/@dbp-topics/signature/icon-256x256.png",
"sizes": "256x256",
"type": "image/png"
},
{
"src": "local/@dbp-topics/signature/icon-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"background_color": "#FEFEFE",
"display": "standalone",
"theme_color": "#FFFFFF"
}
module.exports = {
input: [
'src/**/*.js',
],
input: ['src/**/*.js'],
output: './',
options: {
debug: false,
removeUnusedKeys: true,
lngs: ['en','de'],
lngs: ['en', 'de'],
func: {
list: ['i18n.t', '_i18n.t']
list: ['i18n.t', '_i18n.t'],
},
resource: {
loadPath: 'src/i18n/{{lng}}/{{ns}}.json',
savePath: 'src/i18n/{{lng}}/{{ns}}.json'
savePath: 'src/i18n/{{lng}}/{{ns}}.json',
},
},
}
};
module.exports = function(config) {
config.set({
basePath: 'dist',
frameworks: ['mocha'],
client: {
mocha: {
ui: 'tdd',
},
},
files: [
{pattern: './*.js', included: true, watched: true, served: true, type: 'module'},
{pattern: './**/*', included: false, watched: true, served: true},
],
autoWatch: true,
browsers: ['ChromiumHeadlessNoSandbox', 'FirefoxHeadless'],
customLaunchers: {
ChromiumHeadlessNoSandbox: {
base: 'ChromiumHeadless',
flags: ['--no-sandbox']
}
},
singleRun: false,
logLevel: config.LOG_ERROR
});
}
module.exports = function (config) {
config.set({
basePath: 'dist',
frameworks: ['mocha'],
client: {
mocha: {
ui: 'tdd',
},
},
files: [
{pattern: './*.js', included: true, watched: true, served: true, type: 'module'},
{pattern: './**/*', included: false, watched: true, served: true},
],
autoWatch: true,
browsers: ['ChromiumHeadlessNoSandbox', 'FirefoxHeadless'],
customLaunchers: {
ChromiumHeadlessNoSandbox: {
base: 'ChromiumHeadless',
flags: ['--no-sandbox'],
},
},
singleRun: false,
logLevel: config.LOG_ERROR,
});
};
{
"name": "@dbp-topics/signature",
"internalName": "dbp-signature",
"version": "1.0.26",
"main": "src/dbp-signature.js",
"license": "LGPL-2.1-or-later",
"repository": {
"type": "git",
"url": "https://gitlab.tugraz.at/dbp/esign/signature.git"
},
"private": true,
"workspaces": [
"vendor/toolkit/packages/*"
],
"devDependencies": {
"@babel/core": "^7.10.3",
"@babel/preset-env": "^7.10.3",
"@rollup/plugin-babel": "^5.0.4",
"@rollup/plugin-commonjs": "^21.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.0.0",
"@rollup/plugin-url": "^6.0.0",
"can-npm-publish": "^1.3.3",
"chai": "^4.2.0",
"eslint": "^8.0.1",
"eslint-plugin-jsdoc": "^37.0.0",
"glob": "^7.1.6",
"i18next-scanner": "^3.0.0",
"karma": "^6.0.0",
"karma-chrome-launcher": "^3.1.0",
"karma-firefox-launcher": "^2.1.0",
"karma-mocha": "^2.0.1",
"mocha": "^9.0.0",
"prettier": "^2.5.1",
"rollup": "^2.18.1",
"rollup-plugin-copy": "^3.3.0",
"rollup-plugin-delete": "^2.0.0",
"rollup-plugin-emit-ejs": "^3.1.0",
"rollup-plugin-license": "^2.1.0",
"rollup-plugin-serve": "^1.0.1",
"rollup-plugin-terser": "^7.0.2",
"selfsigned": "^2.0.0"
},
"dependencies": {
"@dbp-toolkit/app-shell": "^0.2.0",
"@dbp-toolkit/auth": "^0.2.0",
"@dbp-toolkit/common": "^0.2.0",
"@dbp-toolkit/file-handling": "^0.2.0",
"@dbp-toolkit/font-source-sans-pro": "^0.2.0",
"@dbp-toolkit/language-select": "^0.2.0",
"@dbp-toolkit/notification": "^0.2.0",
"@dbp-toolkit/organization-select": "^0.2.0",
"@dbp-toolkit/person-profile": "^0.2.0",
"@digital-blueprint/annotpdf": "^1.0.13-a",
"@open-wc/scoped-elements": "^2.0.0",
"fabric": "^4.2.0",
"file-saver": "^2.0.2",
"i18next": "^21.4.2",
"jszip": "^3.5.0",
"lit": "^2.0.0",
"pdfjs-dist": "^2.12.313",
"universal-router": "^9.0.1"
},
"scripts": {
"format": "yarn run format:eslint && yarn run format:prettier",
"format:eslint": "eslint \"**/*.{js,ts}\" --fix",
"format:prettier": "prettier \"**/*.{js,json,ts}\" --write",
"build": "rollup -c",
"i18next": "i18next-scanner",
"watch": "rollup -c --watch",
"watch-local": "yarn run watch",
"watch-full": "rollup -c --watch --environment FORCE_FULL",
"watch-bs": "rollup -c --watch --environment APP_ENV:bs",
"test": "rollup -c --environment APP_ENV:test && karma start --singleRun",
"test-full": "rollup -c --environment FORCE_FULL,APP_ENV:test && karma start --singleRun",
"lint": "eslint .",
"publish": "sed -i 's/\"private\": true/\"private\": false/' package.json && can-npm-publish --verbose 2>&1 && npm publish --access public 2>&1; sed -i 's/\"private\": false/\"private\": true/' package.json"
}
"name": "@dbp-topics/signature",
"internalName": "dbp-signature",
"version": "1.0.26",
"main": "src/dbp-signature.js",
"license": "LGPL-2.1-or-later",
"repository": {
"type": "git",
"url": "https://gitlab.tugraz.at/dbp/esign/signature.git"
},
"private": true,
"workspaces": [
"vendor/toolkit/packages/*"
],
"devDependencies": {
"@babel/core": "^7.10.3",
"@babel/preset-env": "^7.10.3",
"@rollup/plugin-babel": "^5.0.4",
"@rollup/plugin-commonjs": "^21.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.0.0",
"@rollup/plugin-url": "^6.0.0",
"can-npm-publish": "^1.3.3",
"chai": "^4.2.0",
"eslint": "^8.0.1",
"eslint-plugin-jsdoc": "^37.0.0",
"glob": "^7.1.6",
"i18next-scanner": "^3.0.0",
"karma": "^6.0.0",
"karma-chrome-launcher": "^3.1.0",
"karma-firefox-launcher": "^2.1.0",
"karma-mocha": "^2.0.1",
"mocha": "^9.0.0",
"prettier": "^2.5.1",
"rollup": "^2.18.1",
"rollup-plugin-copy": "^3.3.0",
"rollup-plugin-delete": "^2.0.0",
"rollup-plugin-emit-ejs": "^3.1.0",
"rollup-plugin-license": "^2.1.0",
"rollup-plugin-serve": "^1.0.1",
"rollup-plugin-terser": "^7.0.2",
"selfsigned": "^2.0.0"
},
"dependencies": {
"@dbp-toolkit/app-shell": "^0.2.0",
"@dbp-toolkit/auth": "^0.2.0",
"@dbp-toolkit/common": "^0.2.0",
"@dbp-toolkit/file-handling": "^0.2.0",
"@dbp-toolkit/font-source-sans-pro": "^0.2.0",
"@dbp-toolkit/language-select": "^0.2.0",
"@dbp-toolkit/notification": "^0.2.0",
"@dbp-toolkit/organization-select": "^0.2.0",
"@dbp-toolkit/person-profile": "^0.2.0",
"@digital-blueprint/annotpdf": "^1.0.13-a",
"@open-wc/scoped-elements": "^2.0.0",
"fabric": "^4.2.0",
"file-saver": "^2.0.2",
"i18next": "^21.4.2",
"jszip": "^3.5.0",
"lit": "^2.0.0",
"pdfjs-dist": "^2.12.313",
"universal-router": "^9.0.1"
},
"scripts": {
"format": "yarn run format:eslint && yarn run format:prettier",
"format:eslint": "eslint \"**/*.{js,ts}\" --fix",
"format:prettier": "prettier \"**/*.{js,json,ts}\" --write",
"build": "rollup -c",
"i18next": "i18next-scanner",
"watch": "rollup -c --watch",
"watch-local": "yarn run watch",
"watch-full": "rollup -c --watch --environment FORCE_FULL",
"watch-bs": "rollup -c --watch --environment APP_ENV:bs",
"test": "rollup -c --environment APP_ENV:test && karma start --singleRun",
"test-full": "rollup -c --environment FORCE_FULL,APP_ENV:test && karma start --singleRun",
"lint": "eslint .",
"publish": "sed -i 's/\"private\": true/\"private\": false/' package.json && can-npm-publish --verbose 2>&1 && npm publish --access public 2>&1; sed -i 's/\"private\": false/\"private\": true/' package.json"
}
}
......@@ -4,27 +4,32 @@ import glob from 'glob';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import copy from 'rollup-plugin-copy';
import {terser} from "rollup-plugin-terser";
import {terser} from 'rollup-plugin-terser';
import json from '@rollup/plugin-json';
import serve from 'rollup-plugin-serve';
import urlPlugin from "@rollup/plugin-url";
import urlPlugin from '@rollup/plugin-url';
import license from 'rollup-plugin-license';
import del from 'rollup-plugin-delete';
import emitEJS from 'rollup-plugin-emit-ejs'
import emitEJS from 'rollup-plugin-emit-ejs';
import {getBabelOutputPlugin} from '@rollup/plugin-babel';
import appConfig from './app.config.js';
import {getPackagePath, getBuildInfo, generateTLSConfig, getDistPath} from './vendor/toolkit/rollup.utils.js';
import {
getPackagePath,
getBuildInfo,
generateTLSConfig,
getDistPath,
} from './vendor/toolkit/rollup.utils.js';
const pkg = require('./package.json');
const appEnv = (typeof process.env.APP_ENV !== 'undefined') ? process.env.APP_ENV : 'local';
const appEnv = typeof process.env.APP_ENV !== 'undefined' ? process.env.APP_ENV : 'local';
const watch = process.env.ROLLUP_WATCH === 'true';
const buildFull = (!watch && appEnv !== 'test') || (process.env.FORCE_FULL !== undefined);
const buildFull = (!watch && appEnv !== 'test') || process.env.FORCE_FULL !== undefined;
let useTerser = buildFull;
let useBabel = buildFull;
let checkLicenses = buildFull;
let useHTTPS = false;
console.log("APP_ENV: " + appEnv);
console.log('APP_ENV: ' + appEnv);
let config;
if (appEnv in appConfig) {
......@@ -64,167 +69,205 @@ if (watch) {
}
function getOrigin(url) {
if (url)
return new URL(url).origin;
if (url) return new URL(url).origin;
return '';
}
config.CSP = `default-src 'self' 'unsafe-eval' 'unsafe-inline' \
${getOrigin(config.matomoUrl)} ${getOrigin(config.keyCloakBaseURL)} ${getOrigin(config.entryPointURL)} \
${getOrigin(config.matomoUrl)} ${getOrigin(config.keyCloakBaseURL)} ${getOrigin(
config.entryPointURL
)} \
httpbin.org ${getOrigin(config.nextcloudBaseURL)} www.handy-signatur.at \
${getOrigin(config.pdfAsQualifiedlySigningServer)}; \
img-src * blob: data:; font-src 'self' data:`;
export default (async () => {
let privatePath = await getDistPath(pkg.name)
let privatePath = await getDistPath(pkg.name);
return {
input: (appEnv != 'test') ? [
'src/' + pkg.internalName + '.js',
'src/dbp-official-signature-pdf-upload.js',
'src/dbp-qualified-signature-pdf-upload.js',
'src/dbp-signature-verification.js',
'src/dbp-signature-verification-full.js',
] : glob.sync('test/**/*.js'),
output: {
dir: 'dist',
entryFileNames: '[name].js',
chunkFileNames: 'shared/[name].[hash].[format].js',
format: 'esm',
sourcemap: true
},
preserveEntrySignatures: false,
// external: ['zlib', 'http', 'fs', 'https', 'url'],
onwarn: function (warning, warn) {
// ignore chai warnings
if (warning.code === 'CIRCULAR_DEPENDENCY' && warning.message.includes('/chai/')) {
return;
}
// keycloak bundled code uses eval
if (warning.code === 'EVAL') {
return;
}
warn(warning);
},
plugins: [
del({
targets: 'dist/*'
}),
emitEJS({
src: 'assets',
include: ['**/*.ejs', '**/.*.ejs'],
data: {
getUrl: (p) => {
return url.resolve(config.basePath, p);
},
getPrivateUrl: (p) => {
return url.resolve(`${config.basePath}${privatePath}/`, p);
},
isVisible: (name) => {
return !config.hiddenActivities.includes(name);
},
name: pkg.internalName,
entryPointURL: config.entryPointURL,
nextcloudWebAppPasswordURL: config.nextcloudWebAppPasswordURL,
nextcloudWebDavURL: config.nextcloudWebDavURL,
nextcloudBaseURL: config.nextcloudBaseURL,
nextcloudFileURL: config.nextcloudFileURL,
nextcloudName: config.nextcloudName,
keyCloakBaseURL: config.keyCloakBaseURL,
keyCloakClientId: config.keyCloakClientId,
keyCloakRealm: config.keyCloakRealm,
CSP: config.CSP,
matomoUrl: config.matomoUrl,
matomoSiteId: config.matomoSiteId,
buildInfo: getBuildInfo(appEnv),
enableAnnotations: config.enableAnnotations,
}
}),
resolve({
// ignore node_modules from vendored packages
moduleDirectories: [path.join(process.cwd(), 'node_modules')],
browser: true,
preferBuiltins: true
}),
checkLicenses && license({
banner: {
commentStyle: 'ignored',
content: `
input:
appEnv != 'test'
? [
'src/' + pkg.internalName + '.js',
'src/dbp-official-signature-pdf-upload.js',
'src/dbp-qualified-signature-pdf-upload.js',
'src/dbp-signature-verification.js',
'src/dbp-signature-verification-full.js',
]
: glob.sync('test/**/*.js'),
output: {
dir: 'dist',
entryFileNames: '[name].js',
chunkFileNames: 'shared/[name].[hash].[format].js',
format: 'esm',
sourcemap: true,
},
preserveEntrySignatures: false,
// external: ['zlib', 'http', 'fs', 'https', 'url'],
onwarn: function (warning, warn) {
// ignore chai warnings
if (warning.code === 'CIRCULAR_DEPENDENCY' && warning.message.includes('/chai/')) {
return;
}
// keycloak bundled code uses eval
if (warning.code === 'EVAL') {
return;
}
warn(warning);
},
plugins: [
del({
targets: 'dist/*',
}),
emitEJS({
src: 'assets',
include: ['**/*.ejs', '**/.*.ejs'],
data: {
getUrl: (p) => {
return url.resolve(config.basePath, p);
},
getPrivateUrl: (p) => {
return url.resolve(`${config.basePath}${privatePath}/`, p);
},
isVisible: (name) => {
return !config.hiddenActivities.includes(name);
},
name: pkg.internalName,
entryPointURL: config.entryPointURL,
nextcloudWebAppPasswordURL: config.nextcloudWebAppPasswordURL,
nextcloudWebDavURL: config.nextcloudWebDavURL,
nextcloudBaseURL: config.nextcloudBaseURL,
nextcloudFileURL: config.nextcloudFileURL,
nextcloudName: config.nextcloudName,
keyCloakBaseURL: config.keyCloakBaseURL,
keyCloakClientId: config.keyCloakClientId,
keyCloakRealm: config.keyCloakRealm,
CSP: config.CSP,
matomoUrl: config.matomoUrl,
matomoSiteId: config.matomoSiteId,
buildInfo: getBuildInfo(appEnv),
enableAnnotations: config.enableAnnotations,
},
}),
resolve({
// ignore node_modules from vendored packages
moduleDirectories: [path.join(process.cwd(), 'node_modules')],
browser: true,
preferBuiltins: true,
}),
checkLicenses &&
license({
banner: {
commentStyle: 'ignored',
content: `
License: <%= pkg.license %>
Dependencies:
<% _.forEach(dependencies, function (dependency) { if (dependency.name) { %>
<%= dependency.name %>: <%= dependency.license %><% }}) %>
`},
thirdParty: {
allow: {
test: '(MIT OR BSD-3-Clause OR Apache-2.0 OR LGPL-2.1-or-later)',
failOnUnlicensed: true,
failOnViolation: true,
},
},
}),
commonjs({
include: 'node_modules/**',
}),
json(),
urlPlugin({
limit: 0,
include: [
await getPackagePath('select2', '**/*.css'),
],
emitFiles: true,
fileName: 'shared/[name].[hash][extname]'
}),
copy({
targets: [
{src: 'assets/*-placeholder.png', dest: 'dist/' + await getDistPath(pkg.name)},
{src: 'assets/*.css', dest: 'dist/' + await getDistPath(pkg.name)},
{src: 'assets/*.ico', dest: 'dist/' + await getDistPath(pkg.name)},
{src: 'src/*.metadata.json', dest: 'dist'},
{src: 'assets/*.svg', dest: 'dist/' + await getDistPath(pkg.name)},
{src: 'assets/htaccess-shared', dest: 'dist/shared/', rename: '.htaccess'},
{src: 'assets/icon-*.png', dest: 'dist/' + await getDistPath(pkg.name)},
{src: 'assets/apple-*.png', dest: 'dist/' + await getDistPath(pkg.name)},
{src: 'assets/safari-*.svg', dest: 'dist/' + await getDistPath(pkg.name)},
{src: 'assets/images/*', dest: 'dist/images'},
{src: 'assets/manifest.json', dest: 'dist', rename: pkg.internalName + '.manifest.json'},
{src: 'assets/silent-check-sso.html', dest:'dist'},
{src: 'assets/dbp-signature-maintenance.html', dest:'dist'},
{
src: await getPackagePath('pdfjs-dist', 'legacy/build/pdf.worker.js'),
dest: 'dist/' + await getDistPath(pkg.name, 'pdfjs')
},
{src: await getPackagePath('pdfjs-dist', 'cmaps/*'), dest: 'dist/' + await getDistPath(pkg.name, 'pdfjs')}, // do we want all map files?
{src: await getPackagePath('@dbp-toolkit/font-source-sans-pro', 'files/*'), dest: 'dist/' + await getDistPath(pkg.name, 'fonts/source-sans-pro')},
{src: await getPackagePath('@dbp-toolkit/common', 'src/spinner.js'), dest: 'dist/' + await getDistPath(pkg.name)},
{src: await getPackagePath('@dbp-toolkit/common', 'misc/browser-check.js'), dest: 'dist/' + await getDistPath(pkg.name)},
{src: await getPackagePath('@dbp-toolkit/common', 'assets/icons/*.svg'), dest: 'dist/' + await getDistPath('@dbp-toolkit/common', 'icons')},
{src: await getPackagePath('tabulator-tables', 'dist/css'), dest: 'dist/' + await getDistPath('@dbp-toolkit/file-handling', 'tabulator-tables')},
],
}),
useBabel && getBabelOutputPlugin({
compact: false,
presets: [[
'@babel/preset-env', {
loose: true,
shippedProposals: true,
bugfixes: true,
modules: false,
targets: {
esmodules: true
}
}
]],
}),
useTerser ? terser() : false,
watch ? serve({
contentBase: '.',
host: '127.0.0.1',
port: 8001,
historyApiFallback: config.basePath + pkg.internalName + '.html',
https: useHTTPS ? await generateTLSConfig() : false,
headers: {
'Content-Security-Policy': config.CSP
},
}) : false
]
};})();
\ No newline at end of file
`,
},
thirdParty: {
allow: {
test: '(MIT OR BSD-3-Clause OR Apache-2.0 OR LGPL-2.1-or-later)',
failOnUnlicensed: true,
failOnViolation: true,
},
},
}),
commonjs({
include: 'node_modules/**',
}),
json(),
urlPlugin({
limit: 0,
include: [await getPackagePath('select2', '**/*.css')],
emitFiles: true,
fileName: 'shared/[name].[hash][extname]',
}),
copy({
targets: [
{
src: 'assets/*-placeholder.png',
dest: 'dist/' + (await getDistPath(pkg.name)),
},
{src: 'assets/*.css', dest: 'dist/' + (await getDistPath(pkg.name))},
{src: 'assets/*.ico', dest: 'dist/' + (await getDistPath(pkg.name))},
{src: 'src/*.metadata.json', dest: 'dist'},
{src: 'assets/*.svg', dest: 'dist/' + (await getDistPath(pkg.name))},
{src: 'assets/htaccess-shared', dest: 'dist/shared/', rename: '.htaccess'},
{src: 'assets/icon-*.png', dest: 'dist/' + (await getDistPath(pkg.name))},
{src: 'assets/apple-*.png', dest: 'dist/' + (await getDistPath(pkg.name))},
{src: 'assets/safari-*.svg', dest: 'dist/' + (await getDistPath(pkg.name))},
{src: 'assets/images/*', dest: 'dist/images'},
{
src: 'assets/manifest.json',
dest: 'dist',
rename: pkg.internalName + '.manifest.json',
},
{src: 'assets/silent-check-sso.html', dest: 'dist'},
{src: 'assets/dbp-signature-maintenance.html', dest: 'dist'},
{
src: await getPackagePath('pdfjs-dist', 'legacy/build/pdf.worker.js'),
dest: 'dist/' + (await getDistPath(pkg.name, 'pdfjs')),
},
{
src: await getPackagePath('pdfjs-dist', 'cmaps/*'),
dest: 'dist/' + (await getDistPath(pkg.name, 'pdfjs')),
}, // do we want all map files?
{
src: await getPackagePath('@dbp-toolkit/font-source-sans-pro', 'files/*'),
dest: 'dist/' + (await getDistPath(pkg.name, 'fonts/source-sans-pro')),
},
{
src: await getPackagePath('@dbp-toolkit/common', 'src/spinner.js'),
dest: 'dist/' + (await getDistPath(pkg.name)),
},
{
src: await getPackagePath('@dbp-toolkit/common', 'misc/browser-check.js'),
dest: 'dist/' + (await getDistPath(pkg.name)),
},
{
src: await getPackagePath('@dbp-toolkit/common', 'assets/icons/*.svg'),
dest: 'dist/' + (await getDistPath('@dbp-toolkit/common', 'icons')),
},
{
src: await getPackagePath('tabulator-tables', 'dist/css'),
dest:
'dist/' +
(await getDistPath('@dbp-toolkit/file-handling', 'tabulator-tables')),
},
],
}),
useBabel &&
getBabelOutputPlugin({
compact: false,
presets: [
[
'@babel/preset-env',
{
loose: true,
shippedProposals: true,
bugfixes: true,
modules: false,
targets: {
esmodules: true,
},
},
],
],
}),
useTerser ? terser() : false,
watch
? serve({
contentBase: '.',
host: '127.0.0.1',
port: 8001,
historyApiFallback: config.basePath + pkg.internalName + '.html',
https: useHTTPS ? await generateTLSConfig() : false,
headers: {
'Content-Security-Policy': config.CSP,
},
})
: false,
],
};
})();
......@@ -12,4 +12,4 @@ export class Activity {
let desc = this._data['description'];
return desc[lang] ?? desc['en'];
}
}
\ No newline at end of file
}
......@@ -9,16 +9,22 @@ export class BaseLitElement extends DBPLitElement {
static get properties() {
return {
...super.properties,
auth: { type: Object },
auth: {type: Object},
};
}
_(selector) {
return this.shadowRoot === null ? this.querySelector(selector) : this.shadowRoot.querySelector(selector);
return this.shadowRoot === null
? this.querySelector(selector)
: this.shadowRoot.querySelector(selector);
}
_hasSignaturePermissions(roleName) {
return (this.auth.person && Array.isArray(this.auth.person.roles) && this.auth.person.roles.indexOf(roleName) !== -1);
return (
this.auth.person &&
Array.isArray(this.auth.person.roles) &&
this.auth.person.roles.indexOf(roleName) !== -1
);
}
_updateAuth() {
......@@ -34,7 +40,7 @@ export class BaseLitElement extends DBPLitElement {
update(changedProperties) {
changedProperties.forEach((oldValue, propName) => {
switch (propName) {
case "auth":
case 'auth':
this._updateAuth();
break;
}
......@@ -51,12 +57,11 @@ export class BaseLitElement extends DBPLitElement {
}
isLoggedIn() {
return (this.auth.person !== undefined && this.auth.person !== null);
return this.auth.person !== undefined && this.auth.person !== null;
}
isLoading() {
if (this._loginStatus === "logged-out")
return false;
return (!this.isLoggedIn() && this.auth.token !== undefined);
if (this._loginStatus === 'logged-out') return false;
return !this.isLoggedIn() && this.auth.token !== undefined;
}
}
This diff is collapsed.
{
"element": "dbp-official-signature-pdf-upload",
"module_src": "dbp-official-signature-pdf-upload.js",
"routing_name": "official-pdf-upload",
"name": {
"de": "Dokumente amtssignieren",
"en": "Officially sign documents"
},
"short_name": {
"de": "Dokumente amtssignieren",
"en": "Officially sign documents"
},
"description": {
"de": "Erlaubt das Hochladen von PDF-Dokumenten, um sie mit einer Amtssignatur zu versehen",
"en": "Allows upload of PDF-documents to officially sign them"
},
"subscribe": "lang,entry-point-url,nextcloud-web-app-password-url,nextcloud-webdav-url,nextcloud-name,nextcloud-auth-info,nextcloud-file-url,auth,allow-annotating,file-handling-enabled-targets",
"required_roles": ["ROLE_SCOPE_OFFICIAL-SIGNATURE"]
"element": "dbp-official-signature-pdf-upload",
"module_src": "dbp-official-signature-pdf-upload.js",
"routing_name": "official-pdf-upload",
"name": {
"de": "Dokumente amtssignieren",
"en": "Officially sign documents"
},
"short_name": {
"de": "Dokumente amtssignieren",
"en": "Officially sign documents"
},
"description": {
"de": "Erlaubt das Hochladen von PDF-Dokumenten, um sie mit einer Amtssignatur zu versehen",
"en": "Allows upload of PDF-documents to officially sign them"
},
"subscribe": "lang,entry-point-url,nextcloud-web-app-password-url,nextcloud-webdav-url,nextcloud-name,nextcloud-auth-info,nextcloud-file-url,auth,allow-annotating,file-handling-enabled-targets",
"required_roles": ["ROLE_SCOPE_OFFICIAL-SIGNATURE"]
}
......@@ -4,8 +4,8 @@ import {classMap} from 'lit/directives/class-map.js';
import {ScopedElementsMixin} from '@open-wc/scoped-elements';
import DBPLitElement from '@dbp-toolkit/common/dbp-lit-element';
import {MiniSpinner, Icon} from '@dbp-toolkit/common';
import {OrganizationSelect} from "@dbp-toolkit/organization-select";
import { send } from '@dbp-toolkit/common/notification';
import {OrganizationSelect} from '@dbp-toolkit/organization-select';
import {send} from '@dbp-toolkit/common/notification';
import * as commonStyles from '@dbp-toolkit/common/styles';
import * as utils from './utils';
......@@ -38,24 +38,24 @@ export class PdfAnnotationView extends ScopedElementsMixin(DBPLitElement) {
static get properties() {
return {
...super.properties,
lang: { type: String },
key: { type: Number },
isTextHidden: { type: Boolean, attribute: false },
isSelected: { type: Boolean, attribute: false },
annotationRows: { type: Array, attribute: false },
queuedFilesAnnotationsCount: { type: Number, attribute: false },
lang: {type: String},
key: {type: Number},
isTextHidden: {type: Boolean, attribute: false},
isSelected: {type: Boolean, attribute: false},
annotationRows: {type: Array, attribute: false},
queuedFilesAnnotationsCount: {type: Number, attribute: false},
};
}
update(changedProperties) {
changedProperties.forEach((oldValue, propName) => {
switch (propName) {
case "lang":
case 'lang':
this._i18n.changeLanguage(this.lang);
break;
}
});
super.update(changedProperties);
}
......@@ -67,7 +67,7 @@ export class PdfAnnotationView extends ScopedElementsMixin(DBPLitElement) {
}
/**
* Deletes all fields and restore introduction text
* Deletes all fields and restore introduction text
*/
deleteAll() {
this.annotationRows = [];
......@@ -77,8 +77,11 @@ export class PdfAnnotationView extends ScopedElementsMixin(DBPLitElement) {
sendCancelEvent() {
console.log('cancel event called');
const event = new CustomEvent("dbp-pdf-annotations-cancel",
{ "detail": {}, bubbles: true, composed: true });
const event = new CustomEvent('dbp-pdf-annotations-cancel', {
detail: {},
bubbles: true,
composed: true,
});
this.dispatchEvent(event);
}
......@@ -90,12 +93,16 @@ export class PdfAnnotationView extends ScopedElementsMixin(DBPLitElement) {
if (annotationTypeData['hasOrganization']) {
let organization = annotation.organizationValue;
if (typeof organization === 'undefined' || organization === null || organization === '') {
if (
typeof organization === 'undefined' ||
organization === null ||
organization === ''
) {
send({
"summary": i18n.t('annotation-view.empty-organization-title'),
"body": i18n.t('annotation-view.empty-organization-message'),
"type": "danger",
"timeout": 5,
summary: i18n.t('annotation-view.empty-organization-title'),
body: i18n.t('annotation-view.empty-organization-message'),
type: 'danger',
timeout: 5,
});
return false;
}
......@@ -103,10 +110,12 @@ export class PdfAnnotationView extends ScopedElementsMixin(DBPLitElement) {
if (annotation['value'] === null || annotation['value'] === '') {
send({
"summary": i18n.t('annotation-view.empty-annotation-title', {annotationType: annotationTypeData.name[this.lang]}),
"body": i18n.t('annotation-view.empty-annotation-message'),
"type": "danger",
"timeout": 5,
summary: i18n.t('annotation-view.empty-annotation-title', {
annotationType: annotationTypeData.name[this.lang],
}),
body: i18n.t('annotation-view.empty-annotation-message'),
type: 'danger',
timeout: 5,
});
return false;
}
......@@ -114,12 +123,15 @@ export class PdfAnnotationView extends ScopedElementsMixin(DBPLitElement) {
const pattern = new RegExp('[A-Za-z0-9ÄäÖöÜüß*\\/?! &@()=+_-]*');
let matchResult = annotation['value'].match(pattern);
if (matchResult[0] === undefined || annotation['value'].length !== matchResult[0].length) {
if (
matchResult[0] === undefined ||
annotation['value'].length !== matchResult[0].length
) {
send({
"summary": i18n.t('annotation-view.invalid-annotation-text-title'),
"body": i18n.t('annotation-view.invalid-annotation-text-message'),
"type": "danger",
"timeout": 5,
summary: i18n.t('annotation-view.invalid-annotation-text-title'),
body: i18n.t('annotation-view.invalid-annotation-text-message'),
type: 'danger',
timeout: 5,
});
return false;
}
......@@ -134,13 +146,16 @@ export class PdfAnnotationView extends ScopedElementsMixin(DBPLitElement) {
if (!this.validateValues()) {
return;
}
const data = {
"key": this.key,
"annotationRows": this.annotationRows,
key: this.key,
annotationRows: this.annotationRows,
};
const event = new CustomEvent("dbp-pdf-annotations-save",
{ "detail": data, bubbles: true, composed: true });
const event = new CustomEvent('dbp-pdf-annotations-save', {
detail: data,
bubbles: true,
composed: true,
});
this.dispatchEvent(event);
if (this.annotationRows.length === 0) {
......@@ -160,7 +175,7 @@ export class PdfAnnotationView extends ScopedElementsMixin(DBPLitElement) {
let e = this._('#additional-select');
let type = e?.options[e?.selectedIndex]?.value;
this.annotationRows.push({'annotationType': type, 'value': ''});
this.annotationRows.push({annotationType: type, value: ''});
// we just need this so the UI will update
this.queuedFilesAnnotationsCount++;
......@@ -193,7 +208,7 @@ export class PdfAnnotationView extends ScopedElementsMixin(DBPLitElement) {
// delete this.annotationRows[id]; //length of array doesn't change
this.annotationRows.splice(id, 1);
if(this.annotationRows.length === 0) {
if (this.annotationRows.length === 0) {
this.isTextHidden = false;
this.sendCancelEvent();
}
......@@ -218,10 +233,10 @@ export class PdfAnnotationView extends ScopedElementsMixin(DBPLitElement) {
div.annotation-block {
display: grid;
row-gap: .3em;
row-gap: 0.3em;
align-items: center;
margin-left: 2px;
margin-right: 2px;
}
......@@ -233,7 +248,7 @@ export class PdfAnnotationView extends ScopedElementsMixin(DBPLitElement) {
.border {
border-top: var(--dbp-border-dark);
padding-bottom: .5em;
padding-bottom: 0.5em;
}
.border-wrapper {
border: var(--dbp-border-dark);
......@@ -260,7 +275,7 @@ export class PdfAnnotationView extends ScopedElementsMixin(DBPLitElement) {
}
.delete-elements .button {
margin-left: .5em;
margin-left: 0.5em;
}
select:not(.select) {
......@@ -314,9 +329,7 @@ export class PdfAnnotationView extends ScopedElementsMixin(DBPLitElement) {
}
/* Handling for small displays (like mobile devices) */
@media only screen
and (orientation: portrait)
and (max-width: 768px) {
@media only screen and (orientation: portrait) and (max-width: 768px) {
.nav-buttons {
flex-direction: column;
}
......@@ -326,7 +339,6 @@ export class PdfAnnotationView extends ScopedElementsMixin(DBPLitElement) {
grid-template-columns: auto 42px;
column-gap: 3px;
}
}
`;
}
......@@ -337,43 +349,64 @@ export class PdfAnnotationView extends ScopedElementsMixin(DBPLitElement) {
* @returns {*[]} Array of html templates
*/
getAnnotationsHtml() {
const i18n = this._i18n;
const annotations = this.annotationRows || [];
const ids = Object.keys(annotations);
let results = [];
const i18n = this._i18n;
const annotations = this.annotationRows || [];
const ids = Object.keys(annotations);
let results = [];
ids.forEach((id) => {
ids.forEach((id) => {
const data = this.annotationRows[id] || [];
const annotationTypeData = utils.getAnnotationTypes(data.annotationType);
const name = annotationTypeData.name[this.lang];
results.push(html`
<div class="${classMap({'with-organization': annotationTypeData.hasOrganization, 'annotation-block': true})}">
<div
class="${classMap({
'with-organization': annotationTypeData.hasOrganization,
'annotation-block': true,
})}">
<div class="inner-grid">
<label><strong>${name}</strong></label>
<button class="button close"
title="${i18n.t('annotation-view.remove-field')}"
@click="${() => { this.removeAnnotation(id); } }">
<dbp-icon name="trash"></dbp-icon></button>
<button
class="button close"
title="${i18n.t('annotation-view.remove-field')}"
@click="${() => {
this.removeAnnotation(id);
}}">
<dbp-icon name="trash"></dbp-icon>
</button>
</div>
<dbp-organization-select subscribe="lang:lang,entry-point-url:entry-point-url,auth:auth"
class="${classMap({hidden: !annotationTypeData.hasOrganization})}"
value="${data.organizationValue}"
@change=${e => {
this.updateAnnotation(id, 'organizationValue', e.target.value);
this.updateAnnotation(id, 'organizationNumber', JSON.parse(e.target.getAttribute("data-object")).alternateName);
}}></dbp-organization-select>
<input type="text" .value="${data.value}" class="input" pattern="[A-Za-z0-9ÄäÖöÜüß\*\\/! &@()=+_-]*"
placeholder="${annotationTypeData.hasOrganization ? i18n.t('annotation-view.businessnumber-placeholder') : i18n.t('annotation-view.intended-use-placeholder')}"
@change=${e => { this.updateAnnotation(id, 'value', e.target.value); }}>
<dbp-organization-select
subscribe="lang:lang,entry-point-url:entry-point-url,auth:auth"
class="${classMap({hidden: !annotationTypeData.hasOrganization})}"
value="${data.organizationValue}"
@change=${(e) => {
this.updateAnnotation(id, 'organizationValue', e.target.value);
this.updateAnnotation(
id,
'organizationNumber',
JSON.parse(e.target.getAttribute('data-object')).alternateName
);
}}></dbp-organization-select>
<input
type="text"
.value="${data.value}"
class="input"
pattern="[A-Za-z0-9ÄäÖöÜüß*\\/! &@()=+_-]*"
placeholder="${annotationTypeData.hasOrganization
? i18n.t('annotation-view.businessnumber-placeholder')
: i18n.t('annotation-view.intended-use-placeholder')}"
@change=${(e) => {
this.updateAnnotation(id, 'value', e.target.value);
}} />
</div>
`);
});
});
return results;
}
return results;
}
render() {
const i18n = this._i18n;
......@@ -383,22 +416,30 @@ export class PdfAnnotationView extends ScopedElementsMixin(DBPLitElement) {
<div class="nav-buttons">
<div class="add-elements">
<select id="additional-select" @change="${() => { this.isSelected = true; } }">
<select id="additional-select" @change="${() => {
this.isSelected = true;
}}">
${utils.getAnnotationTypeSelectOptionsHtml('', this.lang)}
<option value="" disabled selected>${i18n.t('annotation-view.insert-field')}</option>
<option value="" disabled selected>${i18n.t(
'annotation-view.insert-field'
)}</option>
</select>
<button class="button"
title="${i18n.t('annotation-view.insert-field')}"
@click="${() => { this.addAnnotation(); } }"
?disabled="${ !this.isSelected }">
@click="${() => {
this.addAnnotation();
}}"
?disabled="${!this.isSelected}">
<dbp-icon name="checkmark-circle"></dbp-icon></button>
</button>
</div>
<button class="button is-primary"
title="${i18n.t('annotation-view.save-all-button-title')}"
@click="${() => { this.saveAll(); } }"
?disabled="${ this.annotationRows.length === 0 }">
@click="${() => {
this.saveAll();
}}"
?disabled="${this.annotationRows.length === 0}">
${i18n.t('annotation-view.save-all-button-text')}
</button>
</div>
......@@ -408,16 +449,22 @@ export class PdfAnnotationView extends ScopedElementsMixin(DBPLitElement) {
</div>
<div id="fields-wrapper">
<div id="inside-fields">
<div class="text ${classMap({hidden: this.isTextHidden || this.annotationRows.length > 0})}">
<div class="text ${classMap({
hidden: this.isTextHidden || this.annotationRows.length > 0,
})}">
<p>${i18n.t('annotation-view.introduction')}</p>
</div>
${this.getAnnotationsHtml()}
</div>
<div class="delete-elements">
<button class="button ${classMap({hidden: !this.isTextHidden && this.annotationRows.length === 0})}"
<button class="button ${classMap({
hidden: !this.isTextHidden && this.annotationRows.length === 0,
})}"
title="${i18n.t('annotation-view.delete-all-button-title')}"
@click="${() => { this.deleteAll(); } }"
?disabled="${ this.annotationRows.length === 0 }">
@click="${() => {
this.deleteAll();
}}"
?disabled="${this.annotationRows.length === 0}">
${i18n.t('annotation-view.delete-all-button-text')}
</button>
</div>
......
This diff is collapsed.
This diff is collapsed.
{
"element": "dbp-qualified-signature-pdf-upload",
"module_src": "dbp-qualified-signature-pdf-upload.js",
"routing_name": "qualified-pdf-upload",
"name": {
"de": "Dokument persönlich signieren",
"en": "Personally sign document"
},
"short_name": {
"de": "Dokument persönlich signieren",
"en": "Personally sign document"
},
"description": {
"de": "Erlaubt das Hochladen von PDF-Dokumenten, um sie mit einer persönlichen elektronischen Signatur zu versehen",
"en": "Allows upload of PDF-documents to personally sign them"
},
"subscribe": "lang,entry-point-url,nextcloud-web-app-password-url,nextcloud-webdav-url,nextcloud-name,nextcloud-auth-info,nextcloud-file-url,file-handling-enabled-targets,auth,allow-annotating"
"element": "dbp-qualified-signature-pdf-upload",
"module_src": "dbp-qualified-signature-pdf-upload.js",
"routing_name": "qualified-pdf-upload",
"name": {
"de": "Dokument persönlich signieren",
"en": "Personally sign document"
},
"short_name": {
"de": "Dokument persönlich signieren",
"en": "Personally sign document"
},
"description": {
"de": "Erlaubt das Hochladen von PDF-Dokumenten, um sie mit einer persönlichen elektronischen Signatur zu versehen",
"en": "Allows upload of PDF-documents to personally sign them"
},
"subscribe": "lang,entry-point-url,nextcloud-web-app-password-url,nextcloud-webdav-url,nextcloud-name,nextcloud-auth-info,nextcloud-file-url,file-handling-enabled-targets,auth,allow-annotating"
}
import * as utils from "./utils";
import * as commonUtils from "@dbp-toolkit/common/utils";
import * as utils from './utils';
import * as commonUtils from '@dbp-toolkit/common/utils';
import {BaseLitElement} from './base-element.js';
import {SignatureEntry} from './signature-entry.js';
import {getPDFSignatureCount} from "./utils";
import {getPDFSignatureCount} from './utils';
export default class DBPSignatureLitElement extends BaseLitElement {
constructor() {
......@@ -14,7 +14,7 @@ export default class DBPSignatureLitElement extends BaseLitElement {
this._queueKey = 0;
// will be set in function update
this.fileSourceUrl = "";
this.fileSourceUrl = '';
this.fileSource = '';
this.nextcloudDefaultDir = '';
......@@ -53,11 +53,10 @@ export default class DBPSignatureLitElement extends BaseLitElement {
}
/**
* @param {*} key
* @param {*} name
* @param {*} key
* @param {*} name
*/
async showAnnotationView(key, name) {
this.queuedFilesAnnotationModes[key] = name;
console.log(name);
......@@ -90,8 +89,8 @@ export default class DBPSignatureLitElement extends BaseLitElement {
}
/**
*
* @param {*} event
*
* @param {*} event
*/
processAnnotationEvent(event) {
let annotationDetails = event.detail;
......@@ -102,13 +101,13 @@ export default class DBPSignatureLitElement extends BaseLitElement {
this.isAnnotationViewVisible = false;
this.addAnnotationInProgress = false;
this.queuedFilesAnnotationModes[this.currentPreviewQueueKey] = "text-selected";
this.queuedFilesAnnotationModes[this.currentPreviewQueueKey] = 'text-selected';
this.queuedFilesAnnotationSaved[this.currentPreviewQueueKey] = true;
}
/**
*
* @param {*} event
*
* @param {*} event
*/
processAnnotationCancelEvent(event) {
let key = this.currentPreviewQueueKey;
......@@ -117,7 +116,7 @@ export default class DBPSignatureLitElement extends BaseLitElement {
this.queuedFilesAnnotations[key] = undefined;
this.disableAnnotationsForKey(key);
this.queuedFilesAnnotationModes[this.currentPreviewQueueKey] = "no-text";
this.queuedFilesAnnotationModes[this.currentPreviewQueueKey] = 'no-text';
this.queuedFilesAnnotationSaved[this.currentPreviewQueueKey] = false;
}
......@@ -127,10 +126,13 @@ export default class DBPSignatureLitElement extends BaseLitElement {
hideAnnotationView() {
console.log('hide view - x click');
if (this.queuedFilesAnnotationSaved[this.currentPreviewQueueKey] !== undefined && this.queuedFilesAnnotationSaved[this.currentPreviewQueueKey]) {
this.queuedFilesAnnotationModes[this.currentPreviewQueueKey] = "text-selected";
if (
this.queuedFilesAnnotationSaved[this.currentPreviewQueueKey] !== undefined &&
this.queuedFilesAnnotationSaved[this.currentPreviewQueueKey]
) {
this.queuedFilesAnnotationModes[this.currentPreviewQueueKey] = 'text-selected';
} else {
this.queuedFilesAnnotationModes[this.currentPreviewQueueKey] = "no-text";
this.queuedFilesAnnotationModes[this.currentPreviewQueueKey] = 'no-text';
}
this.isAnnotationViewVisible = false;
this.addAnnotationInProgress = false;
......@@ -151,7 +153,7 @@ export default class DBPSignatureLitElement extends BaseLitElement {
const activityNameEN = this.activity.getName('en');
await commonUtils.asyncObjectForEach(annotations, async (annotation) => {
console.log("annotation", annotation);
console.log('annotation', annotation);
const annotationType = (annotation.annotationType || '').trim();
const organizationNumber = (annotation.organizationNumber || '').trim();
......@@ -164,8 +166,16 @@ export default class DBPSignatureLitElement extends BaseLitElement {
const annotationTypeData = utils.getAnnotationTypes(annotationType);
pdfFactory = await utils.addKeyValuePdfAnnotationsToAnnotationFactory(
pdfFactory, activityNameDE, activityNameEN, this.auth['user-full-name'], annotationType,
annotationTypeData.name.de, annotationTypeData.name.en, organizationNumber, value);
pdfFactory,
activityNameDE,
activityNameEN,
this.auth['user-full-name'],
annotationType,
annotationTypeData.name.de,
annotationTypeData.name.en,
organizationNumber,
value
);
});
// output the AnnotationFactory as File again
......@@ -287,17 +297,21 @@ export default class DBPSignatureLitElement extends BaseLitElement {
// add annotations
if (annotations.length > 0) {
file = await this.addAnnotationsToFile(file, annotations);
console.log("uploadFile file", file);
console.log('uploadFile file', file);
// Also send annotations to the server so they get included in the signature block
let userText = [];
for (let annotation of annotations) {
const annotationTypeData = utils.getAnnotationTypes(annotation['annotationType']);
const organizationNumberText = annotation['organizationNumber'] ? ` (${annotation['organizationNumber']})` : '';
const organizationNumberText = annotation['organizationNumber']
? ` (${annotation['organizationNumber']})`
: '';
userText.push({
'description': `${annotationTypeData.name.de || ''} / ${annotationTypeData.name.en || ''}`,
'value': annotation['value'] + organizationNumberText
description: `${annotationTypeData.name.de || ''} / ${
annotationTypeData.name.en || ''
}`,
value: annotation['value'] + organizationNumberText,
});
}
formData.append('user_text', JSON.stringify(userText));
......@@ -309,14 +323,13 @@ export default class DBPSignatureLitElement extends BaseLitElement {
formData.append(key, params[key]);
}
// I got a 60s timeout in Google Chrome and found no way to increase that
await fetch(url, {
method: 'POST',
headers: {
'Authorization': 'Bearer ' + this.auth.token,
Authorization: 'Bearer ' + this.auth.token,
},
body: formData
body: formData,
})
.then((response) => {
/* Done. Inform the user */
......@@ -337,10 +350,10 @@ export default class DBPSignatureLitElement extends BaseLitElement {
return;
}
let data = {
let data = {
fileName: file.name,
status: response.status,
json: {"hydra:description": ""}
json: {'hydra:description': ''},
};
try {
......@@ -356,8 +369,7 @@ export default class DBPSignatureLitElement extends BaseLitElement {
this.onFileUploadFinished(data);
}
onFileSourceSwitch(event)
{
onFileSourceSwitch(event) {
if (event.detail.source) {
this.fileSource = event.detail.source;
}
......@@ -376,15 +388,19 @@ export default class DBPSignatureLitElement extends BaseLitElement {
// add all signed pdf-files
this.signedFiles.forEach((file) => {
const arr = utils.convertDataURIToBinary(file.contentUrl);
const binaryFile = new File([arr], file.name, { type: utils.getDataURIContentType(file.contentUrl) });
const binaryFile = new File([arr], file.name, {
type: utils.getDataURIContentType(file.contentUrl),
});
files.push(binaryFile);
});
this.signedFilesToDownload = files.length;
this._("#file-sink").files = files;
this._("#zip-download-button").stop();
this._('#file-sink').files = files;
this._('#zip-download-button').stop();
// mark downloaded files buttons
const spans = this.shadowRoot.querySelectorAll('.file-block > div.header > span.filename > span.bold-filename');
spans.forEach(span => {
const spans = this.shadowRoot.querySelectorAll(
'.file-block > div.header > span.filename > span.bold-filename'
);
spans.forEach((span) => {
span.classList.remove('bold-filename');
});
}
......@@ -393,7 +409,7 @@ export default class DBPSignatureLitElement extends BaseLitElement {
* @param data
*/
onFileUploadFinished(data) {
console.log("Override me");
console.log('Override me');
}
/**
......@@ -405,12 +421,16 @@ export default class DBPSignatureLitElement extends BaseLitElement {
async downloadFileClickHandler(file, id) {
let files = [];
const arr = utils.convertDataURIToBinary(file.contentUrl);
const binaryFile = new File([arr], file.name, { type: utils.getDataURIContentType(file.contentUrl) });
const binaryFile = new File([arr], file.name, {
type: utils.getDataURIContentType(file.contentUrl),
});
files.push(binaryFile);
this.signedFilesToDownload = files.length;
this._("#file-sink").files = files;
this._('#file-sink').files = files;
// mark downloaded files button
const span = this.shadowRoot.querySelector('#' + id + ' > div.header > span.filename > span.bold-filename');
const span = this.shadowRoot.querySelector(
'#' + id + ' > div.header > span.filename > span.bold-filename'
);
if (span) {
span.classList.remove('bold-filename');
}
......@@ -420,8 +440,7 @@ export default class DBPSignatureLitElement extends BaseLitElement {
let entry = this.queuedFiles[id];
let sigCount = await getPDFSignatureCount(entry.file);
this.queuedFilesNeedsPlacement.delete(id);
if (sigCount > 0)
this.queuedFilesNeedsPlacement.set(id, true);
if (sigCount > 0) this.queuedFilesNeedsPlacement.set(id, true);
}
storePDFData(event) {
......@@ -442,7 +461,7 @@ export default class DBPSignatureLitElement extends BaseLitElement {
hidePDF(event) {
// reset placement mode to "auto" if no placement was confirmed previously
if (this.queuedFilesSignaturePlacements[this.currentPreviewQueueKey] === undefined) {
this.queuedFilesPlacementModes[this.currentPreviewQueueKey] = "auto";
this.queuedFilesPlacementModes[this.currentPreviewQueueKey] = 'auto';
}
this.signaturePlacementInProgress = false;
}
......@@ -451,7 +470,7 @@ export default class DBPSignatureLitElement extends BaseLitElement {
this.queuedFilesPlacementModes[key] = name;
console.log(name);
if (name === "manual") {
if (name === 'manual') {
this.showPreview(key, true);
} else if (this.currentPreviewQueueKey === key) {
this.signaturePlacementInProgress = false;
......@@ -472,8 +491,6 @@ export default class DBPSignatureLitElement extends BaseLitElement {
this.queueFile(ev.detail.file);
}
/**
* Re-Upload all failed files
*/
......@@ -489,7 +506,7 @@ export default class DBPSignatureLitElement extends BaseLitElement {
await this.fileQueueingClickHandler(file.file, id);
});
that._("#re-upload-all-button").stop();
that._('#re-upload-all-button').stop();
}
/**
......@@ -509,7 +526,7 @@ export default class DBPSignatureLitElement extends BaseLitElement {
* @param key
* @param withSigBlock
*/
async showPreview(key, withSigBlock=false) {
async showPreview(key, withSigBlock = false) {
if (this.signingProcessEnabled) {
return;
}
......@@ -521,18 +538,18 @@ export default class DBPSignatureLitElement extends BaseLitElement {
// start signature placement process
this.signaturePlacementInProgress = true;
this.withSigBlock = withSigBlock;
const previewTag = this.getScopedTagName("dbp-pdf-preview");
const previewTag = this.getScopedTagName('dbp-pdf-preview');
await this._(previewTag).showPDF(
entry.file,
withSigBlock, //this.queuedFilesPlacementModes[key] === "manual",
this.queuedFilesSignaturePlacements[key]);
this.queuedFilesSignaturePlacements[key]
);
}
onLanguageChanged(e) {
this.lang = e.detail.lang;
}
/**
* Takes a failed file off of the queue
*
......@@ -544,7 +561,6 @@ export default class DBPSignatureLitElement extends BaseLitElement {
return file;
}
clearSignedFiles() {
this.signedFiles = [];
this.signedFilesCount = 0;
......@@ -556,8 +572,11 @@ export default class DBPSignatureLitElement extends BaseLitElement {
}
isUserInterfaceDisabled() {
return this.signaturePlacementInProgress || this.externalAuthInProgress || this.uploadInProgress || this.addAnnotationInProgress;
return (
this.signaturePlacementInProgress ||
this.externalAuthInProgress ||
this.uploadInProgress ||
this.addAnnotationInProgress
);
}
}
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment