Skip to content
Snippets Groups Projects
Unverified Commit f603d659 authored by Bekerle, Patrizio's avatar Bekerle, Patrizio :fire:
Browse files

Add nextcloudWebDavURL and nextcloudWebAppPasswordURL (#26)

parent 9ba3100f
No related branches found
No related tags found
No related merge requests found
Pipeline #11814 passed
......@@ -34,6 +34,8 @@ console.log("build: " + build);
let basePath = '';
let entryPointURL = '';
let nextcloudBaseURL = 'https://cloud.tugraz.at';
let nextcloudWebAppPasswordURL = nextcloudBaseURL + '/apps/webapppassword';
let nextcloudWebDavURL = nextcloudBaseURL + '/remote.php/dav/files';
let keyCloakServer = '';
let keyCloakBaseURL = '';
let keyCloakClientId = '';
......@@ -47,7 +49,9 @@ switch (build) {
case 'local':
basePath = '/dist/';
entryPointURL = 'http://127.0.0.1:8000';
nextcloudBaseURL = 'http://localhost:8081/index.php';
nextcloudBaseURL = 'http://localhost:8081';
nextcloudWebAppPasswordURL = nextcloudBaseURL + '/index.php/apps/webapppassword';
nextcloudWebDavURL = nextcloudBaseURL + '/remote.php/dav/files';
keyCloakServer = 'auth-dev.tugraz.at';
keyCloakBaseURL = 'https://' + keyCloakServer + '/auth';
keyCloakClientId = 'auth-dev-mw-frontend-local';
......@@ -82,6 +86,7 @@ switch (build) {
basePath = '/apps/signature/';
entryPointURL = '';
nextcloudBaseURL = '';
nextcloudWebAppPasswordURL = '';
keyCloakServer = '';
keyCloakBaseURL = '';
keyCloakClientId = '';
......@@ -178,7 +183,8 @@ export default {
consts({
environment: build,
buildinfo: getBuildInfo(),
nextcloudBaseURL: nextcloudBaseURL,
nextcloudWebAppPasswordURL: nextcloudWebAppPasswordURL,
nextcloudWebDavURL: nextcloudWebDavURL,
}),
emitEJS({
src: 'assets',
......
import {createI18nInstance} from './i18n.js';
import {css, html} from 'lit-element';
import {classMap} from 'lit-html/directives/class-map.js';
import {live} from 'lit-html/directives/live.js';
import {ScopedElementsMixin} from '@open-wc/scoped-elements';
import VPULitElement from 'vpu-common/vpu-lit-element';
import {MiniSpinner} from 'vpu-common';
import * as commonUtils from "vpu-common/utils";
import * as commonStyles from 'vpu-common/styles';
import pdfjs from 'pdfjs-dist';
const i18n = createI18nInstance();
......@@ -18,7 +14,8 @@ export class FilePicker extends ScopedElementsMixin(VPULitElement) {
constructor() {
super();
this.lang = 'de';
this.baseUrl = '';
this.authUrl = '';
this.webDavUrl = '';
this.loginWindow = null;
this._onReceiveWindowMessage = this.onReceiveWindowMessage.bind(this);
......@@ -36,7 +33,8 @@ export class FilePicker extends ScopedElementsMixin(VPULitElement) {
static get properties() {
return {
lang: { type: String },
baseUrl: { type: String, attribute: "base-url" },
authUrl: { type: String, attribute: "auth-url" },
webDavUrl: { type: String, attribute: "web-dav-url" },
};
}
......@@ -67,7 +65,7 @@ export class FilePicker extends ScopedElementsMixin(VPULitElement) {
}
openFilePicker() {
this.loginWindow = window.open(this.baseUrl + "/apps/webapppassword/#", "Nextcloud Login",
this.loginWindow = window.open(this.authUrl, "Nextcloud Login",
"width=400,height=400,menubar=no,scrollbars=no,status=no,titlebar=no,toolbar=no");
}
......@@ -77,7 +75,34 @@ export class FilePicker extends ScopedElementsMixin(VPULitElement) {
if (data.type === "webapppassword") {
this.loginWindow.close();
alert("Login name: " + data.loginName + "\nApp password: " + data.token);
// alert("Login name: " + data.loginName + "\nApp password: " + data.token);
const apiUrl = this.webDavUrl + "/" + data.loginName;
fetch(apiUrl, {
method: 'PROPFIND',
headers: {
'Content-Type': 'text/xml',
'Authorization': 'Basic ' + btoa(data.loginName + ":" + data.token),
},
data: "<?xml version=\"1.0\"?>" +
"<a:propfind xmlns:a=\"DAV:\">" +
"<a:prop><a:resourcetype />" +
"</a:prop>" +
"</a:propfind>"
})
.then(result => {
console.log("result", result);
if (!result.ok) throw result;
return result.text();
})
.then((xml) => {
console.log("xml", xml);
}).catch(error => {
console.error("error", error);
});
}
}
......
......@@ -14,7 +14,8 @@ import {FileUpload} from 'vpu-file-upload';
import JSONLD from "vpu-common/jsonld";
import {TextSwitch} from './textswitch.js';
import {FilePicker} from "./vpu-file-picker";
import nextcloudBaseURL from 'consts:nextcloudBaseURL';
import nextcloudWebAppPasswordURL from 'consts:nextcloudWebAppPasswordURL';
import nextcloudWebDavURL from 'consts:nextcloudWebDavURL';
const i18n = createI18nInstance();
......@@ -1105,7 +1106,7 @@ class QualifiedSignaturePdfUpload extends ScopedElementsMixin(VPUSignatureLitEle
<vpu-mini-spinner></vpu-mini-spinner>
</div>
<!-- File picker test -->
<!-- <vpu-file-picker base-url="${nextcloudBaseURL}"></vpu-file-picker>-->
<!-- <vpu-file-picker lang="${this.lang}" auth-url="${nextcloudWebAppPasswordURL}" web-dav-url="${nextcloudWebDavURL}"></vpu-file-picker>-->
`;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment