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); ...@@ -34,6 +34,8 @@ console.log("build: " + build);
let basePath = ''; let basePath = '';
let entryPointURL = ''; let entryPointURL = '';
let nextcloudBaseURL = 'https://cloud.tugraz.at'; let nextcloudBaseURL = 'https://cloud.tugraz.at';
let nextcloudWebAppPasswordURL = nextcloudBaseURL + '/apps/webapppassword';
let nextcloudWebDavURL = nextcloudBaseURL + '/remote.php/dav/files';
let keyCloakServer = ''; let keyCloakServer = '';
let keyCloakBaseURL = ''; let keyCloakBaseURL = '';
let keyCloakClientId = ''; let keyCloakClientId = '';
...@@ -47,7 +49,9 @@ switch (build) { ...@@ -47,7 +49,9 @@ switch (build) {
case 'local': case 'local':
basePath = '/dist/'; basePath = '/dist/';
entryPointURL = 'http://127.0.0.1:8000'; 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'; keyCloakServer = 'auth-dev.tugraz.at';
keyCloakBaseURL = 'https://' + keyCloakServer + '/auth'; keyCloakBaseURL = 'https://' + keyCloakServer + '/auth';
keyCloakClientId = 'auth-dev-mw-frontend-local'; keyCloakClientId = 'auth-dev-mw-frontend-local';
...@@ -82,6 +86,7 @@ switch (build) { ...@@ -82,6 +86,7 @@ switch (build) {
basePath = '/apps/signature/'; basePath = '/apps/signature/';
entryPointURL = ''; entryPointURL = '';
nextcloudBaseURL = ''; nextcloudBaseURL = '';
nextcloudWebAppPasswordURL = '';
keyCloakServer = ''; keyCloakServer = '';
keyCloakBaseURL = ''; keyCloakBaseURL = '';
keyCloakClientId = ''; keyCloakClientId = '';
...@@ -178,7 +183,8 @@ export default { ...@@ -178,7 +183,8 @@ export default {
consts({ consts({
environment: build, environment: build,
buildinfo: getBuildInfo(), buildinfo: getBuildInfo(),
nextcloudBaseURL: nextcloudBaseURL, nextcloudWebAppPasswordURL: nextcloudWebAppPasswordURL,
nextcloudWebDavURL: nextcloudWebDavURL,
}), }),
emitEJS({ emitEJS({
src: 'assets', src: 'assets',
......
import {createI18nInstance} from './i18n.js'; import {createI18nInstance} from './i18n.js';
import {css, html} from 'lit-element'; 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 {ScopedElementsMixin} from '@open-wc/scoped-elements';
import VPULitElement from 'vpu-common/vpu-lit-element'; import VPULitElement from 'vpu-common/vpu-lit-element';
import {MiniSpinner} from 'vpu-common'; import {MiniSpinner} from 'vpu-common';
import * as commonUtils from "vpu-common/utils";
import * as commonStyles from 'vpu-common/styles'; import * as commonStyles from 'vpu-common/styles';
import pdfjs from 'pdfjs-dist';
const i18n = createI18nInstance(); const i18n = createI18nInstance();
...@@ -18,7 +14,8 @@ export class FilePicker extends ScopedElementsMixin(VPULitElement) { ...@@ -18,7 +14,8 @@ export class FilePicker extends ScopedElementsMixin(VPULitElement) {
constructor() { constructor() {
super(); super();
this.lang = 'de'; this.lang = 'de';
this.baseUrl = ''; this.authUrl = '';
this.webDavUrl = '';
this.loginWindow = null; this.loginWindow = null;
this._onReceiveWindowMessage = this.onReceiveWindowMessage.bind(this); this._onReceiveWindowMessage = this.onReceiveWindowMessage.bind(this);
...@@ -36,7 +33,8 @@ export class FilePicker extends ScopedElementsMixin(VPULitElement) { ...@@ -36,7 +33,8 @@ export class FilePicker extends ScopedElementsMixin(VPULitElement) {
static get properties() { static get properties() {
return { return {
lang: { type: String }, 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) { ...@@ -67,7 +65,7 @@ export class FilePicker extends ScopedElementsMixin(VPULitElement) {
} }
openFilePicker() { 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"); "width=400,height=400,menubar=no,scrollbars=no,status=no,titlebar=no,toolbar=no");
} }
...@@ -77,7 +75,34 @@ export class FilePicker extends ScopedElementsMixin(VPULitElement) { ...@@ -77,7 +75,34 @@ export class FilePicker extends ScopedElementsMixin(VPULitElement) {
if (data.type === "webapppassword") { if (data.type === "webapppassword") {
this.loginWindow.close(); 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'; ...@@ -14,7 +14,8 @@ import {FileUpload} from 'vpu-file-upload';
import JSONLD from "vpu-common/jsonld"; import JSONLD from "vpu-common/jsonld";
import {TextSwitch} from './textswitch.js'; import {TextSwitch} from './textswitch.js';
import {FilePicker} from "./vpu-file-picker"; import {FilePicker} from "./vpu-file-picker";
import nextcloudBaseURL from 'consts:nextcloudBaseURL'; import nextcloudWebAppPasswordURL from 'consts:nextcloudWebAppPasswordURL';
import nextcloudWebDavURL from 'consts:nextcloudWebDavURL';
const i18n = createI18nInstance(); const i18n = createI18nInstance();
...@@ -1105,7 +1106,7 @@ class QualifiedSignaturePdfUpload extends ScopedElementsMixin(VPUSignatureLitEle ...@@ -1105,7 +1106,7 @@ class QualifiedSignaturePdfUpload extends ScopedElementsMixin(VPUSignatureLitEle
<vpu-mini-spinner></vpu-mini-spinner> <vpu-mini-spinner></vpu-mini-spinner>
</div> </div>
<!-- File picker test --> <!-- 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.
Please register or to comment