Skip to content
Snippets Groups Projects
Commit cf4a1110 authored by Steinwender, Tamara's avatar Steinwender, Tamara
Browse files

Clean code

parent 19b7851a
No related branches found
No related tags found
No related merge requests found
Pipeline #12820 passed
...@@ -125,8 +125,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { ...@@ -125,8 +125,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
{title: i18n.t('nextcloud-file-picker.filename'), responsive: 0, widthGrow:5, minWidth: 150, field: "basename", sorter: "alphanum", {title: i18n.t('nextcloud-file-picker.filename'), responsive: 0, widthGrow:5, minWidth: 150, field: "basename", sorter: "alphanum",
formatter: (cell) => { formatter: (cell) => {
var data = cell.getRow().getData(); var data = cell.getRow().getData();
if (data.edit) if (data.edit) {
{
cell.getElement().classList.add("fokus-edit"); cell.getElement().classList.add("fokus-edit");
} }
return cell.getValue(); return cell.getValue();
...@@ -184,8 +183,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { ...@@ -184,8 +183,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
rowClick: (e, row) => { rowClick: (e, row) => {
const data = row.getData(); const data = row.getData();
if(!row.getElement().classList.contains("no-select")) if (!row.getElement().classList.contains("no-select")) {
{
if (this.directoriesOnly) { if (this.directoriesOnly) {
// comment out if you want to navigate through folders with double click // comment out if you want to navigate through folders with double click
const data = row.getData(); const data = row.getData();
...@@ -228,21 +226,22 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { ...@@ -228,21 +226,22 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
// Strg + click select mode on desktop // Strg + click select mode on desktop
/*if (this.tabulatorTable.browserMobile === false) /*if (this.tabulatorTable.browserMobile === false) {
{
this.tabulatorTable.options.selectableRangeMode = "click"; this.tabulatorTable.options.selectableRangeMode = "click";
}*/ }*/
if (typeof this.allowedMimeTypes !== 'undefined' && !this.directoriesOnly) { if (typeof this.allowedMimeTypes !== 'undefined' && !this.directoriesOnly) {
this.tabulatorTable.setFilter(this.checkFileType, this.allowedMimeTypes); this.tabulatorTable.setFilter(this.checkFileType, this.allowedMimeTypes);
} }
if (typeof this.directoriesOnly !== 'undefined' && this.directoriesOnly) // comment this in to show only directories in filesink
{ /*
// comment this in to show only directories if (typeof this.directoriesOnly !== 'undefined' && this.directoriesOnly) {
/*this.tabulatorTable.setFilter([ this.tabulatorTable.setFilter([
{field:"type", type:"=", value:"directory"}, {field:"type", type:"=", value:"directory"},
]);*/ ]);
} }
*/
}); });
} }
...@@ -285,7 +284,6 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { ...@@ -285,7 +284,6 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
if (this.webDavClient === null) if (this.webDavClient === null)
{ {
const data = event.data; const data = event.data;
console.log("context", this.directoriesOnly);
if (data.type === "webapppassword") { if (data.type === "webapppassword") {
if (this.loginWindow !== null) { if (this.loginWindow !== null) {
...@@ -293,7 +291,6 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { ...@@ -293,7 +291,6 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
} }
const apiUrl = this.webDavUrl + "/" + data.loginName; const apiUrl = this.webDavUrl + "/" + data.loginName;
//console.log("url: ", this.webDavUrl);
// see https://github.com/perry-mitchell/webdav-client/blob/master/API.md#module_WebDAV.createClient // see https://github.com/perry-mitchell/webdav-client/blob/master/API.md#module_WebDAV.createClient
this.webDavClient = createClient( this.webDavClient = createClient(
...@@ -352,7 +349,6 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { ...@@ -352,7 +349,6 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
this.loading = false; this.loading = false;
this.statusText = ""; this.statusText = "";
this.tabulatorTable.setData(contents.data); this.tabulatorTable.setData(contents.data);
console.log("!!!!!!!!!!!!!!!!!!!!!!!!", contents.data)
this.isPickerActive = true; this.isPickerActive = true;
if (!this.activeDirectoryRights.includes("CK") && !this.activeDirectoryRights.includes("NV")) { if (!this.activeDirectoryRights.includes("CK") && !this.activeDirectoryRights.includes("NV")) {
this._("#download-button").setAttribute("disabled", "true"); this._("#download-button").setAttribute("disabled", "true");
...@@ -390,8 +386,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { ...@@ -390,8 +386,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
*/ */
directoryClicked(event, file) { directoryClicked(event, file) {
// save rights of clicked directory // save rights of clicked directory
if (typeof file.props !== 'undefined') if (typeof file.props !== 'undefined') {
{
this.activeDirectoryRights = file.props.permissions; this.activeDirectoryRights = file.props.permissions;
if (typeof file.props['acl-list'] !== "undefined" && if (typeof file.props['acl-list'] !== "undefined" &&
typeof file.props['acl-list']['acl']['acl-permissions'] !== "undefined" && file.props['acl-list']['acl']['acl-permissions']) { typeof file.props['acl-list']['acl']['acl-permissions'] !== "undefined" && file.props['acl-list']['acl']['acl-permissions']) {
...@@ -454,8 +449,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { ...@@ -454,8 +449,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
this.tabulatorTable.deselectRow(); this.tabulatorTable.deselectRow();
let path; let path;
if (!directory[0]) if (!directory[0]) {
{
path = this.directoryPath; path = this.directoryPath;
} }
else { else {
...@@ -499,7 +493,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { ...@@ -499,7 +493,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
this.statusText = i18n.t('nextcloud-file-picker.upload-to', {path: path}); this.statusText = i18n.t('nextcloud-file-picker.upload-to', {path: path});
let contents = await this.webDavClient let contents = await this.webDavClient
.putFileContents(path, file, { overwrite: false, onUploadProgress: progress => { .putFileContents(path, file, { overwrite: false, onUploadProgress: progress => {
console.log(`Uploaded ${progress.loaded} bytes of ${progress.total}`); /* console.log(`Uploaded ${progress.loaded} bytes of ${progress.total}`);*/
}}).then(function() { }}).then(function() {
that.uploadCount += 1; that.uploadCount += 1;
that.fileList.shift(); that.fileList.shift();
...@@ -569,7 +563,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { ...@@ -569,7 +563,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
let contents = await this.webDavClient let contents = await this.webDavClient
.putFileContents(path, file, { .putFileContents(path, file, {
overwrite: overwrite, onUploadProgress: progress => { overwrite: overwrite, onUploadProgress: progress => {
console.log(`Uploaded ${progress.loaded} bytes of ${progress.total}`); /*console.log(`Uploaded ${progress.loaded} bytes of ${progress.total}`);*/
} }
}).then(content => { }).then(content => {
MicroModal.close(this._("#replace-modal")); MicroModal.close(this._("#replace-modal"));
...@@ -619,18 +613,14 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { ...@@ -619,18 +613,14 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
} }
/* ACL permissions: If ACL > permssions comment this in /* ACL permissions: If ACL > permssions comment this in
if (this.activeDirectoryACL !== '') if (this.activeDirectoryACL !== '') {
{
console.log("ACL SET"); console.log("ACL SET");
active_directory_perm = "MG"; active_directory_perm = "MG";
if (this.activeDirectoryACL & (1 << (3 - 1))) {
if (this.activeDirectoryACL & (1 << (3 - 1)))
{
active_directory_perm = "CK"; active_directory_perm = "CK";
console.log("ACL CREATE"); console.log("ACL CREATE");
} }
if (this.activeDirectoryACL & (1 << (2 - 1))) if (this.activeDirectoryACL & (1 << (2 - 1))) {
{
active_directory_perm += "NV"; active_directory_perm += "NV";
console.log("ACL WRITE"); console.log("ACL WRITE");
} }
...@@ -638,18 +628,15 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { ...@@ -638,18 +628,15 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
// if file has acl rights take that // if file has acl rights take that
if (typeof rows[0].getData().props['acl-list'] !== 'undefined' && rows[0].getData().props['acl-list'] && if (typeof rows[0].getData().props['acl-list'] !== 'undefined' && rows[0].getData().props['acl-list'] &&
rows[0].getData().props['acl-list']['acl']['acl-permissions'] !== '') rows[0].getData().props['acl-list']['acl']['acl-permissions'] !== '') {
{
console.log("FILE HAS ACL"); console.log("FILE HAS ACL");
file_perm = "MG"; file_perm = "MG";
if (rows[0].getData().props['acl-list']['acl']['acl-permissions'] & (1 << (3 - 1))) if (rows[0].getData().props['acl-list']['acl']['acl-permissions'] & (1 << (3 - 1))) {
{
file_perm = "CK"; file_perm = "CK";
console.log("FILE ACL CREATE"); console.log("FILE ACL CREATE");
} }
if (rows[0].getData().props['acl-list']['acl']['acl-permissions'] & (1 << (2 - 1))) if (rows[0].getData().props['acl-list']['acl']['acl-permissions'] & (1 << (2 - 1))) {
{
file_perm += "NV"; file_perm += "NV";
console.log("FILE ACL WRITE"); console.log("FILE ACL WRITE");
} }
...@@ -657,20 +644,17 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { ...@@ -657,20 +644,17 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
*/ */
// all allowed // all allowed
if (active_directory_perm.includes("CK") && file_perm.includes("NV")) if (active_directory_perm.includes("CK") && file_perm.includes("NV")) {
{
return -1; return -1;
} }
// read only file but you can write to directory = only create and no edit // read only file but you can write to directory = only create and no edit
if (active_directory_perm.includes("CK") && !file_perm.includes("NV")) if (active_directory_perm.includes("CK") && !file_perm.includes("NV")) {
{
return 1; return 1;
} }
// only edit and no create // only edit and no create
if (!active_directory_perm.includes("CK") && file_perm.includes("NV")) if (!active_directory_perm.includes("CK") && file_perm.includes("NV")) {
{
return 2; return 2;
} }
...@@ -734,7 +718,6 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { ...@@ -734,7 +718,6 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
} }
closeDialog(e) { closeDialog(e) {
console.log("closeDialog");
MicroModal.close(this._('#modal-picker')); MicroModal.close(this._('#modal-picker'));
} }
...@@ -902,8 +885,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { ...@@ -902,8 +885,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
let htmlpath = []; let htmlpath = [];
htmlpath[0] = html`<span class="breadcrumb"><a class="home-link" @click="${() => { this.loadDirectory(""); }}" title="${i18n.t('nextcloud-file-picker.folder-home')}"><dbp-icon name="home"></dbp-icon> </a></span>`; htmlpath[0] = html`<span class="breadcrumb"><a class="home-link" @click="${() => { this.loadDirectory(""); }}" title="${i18n.t('nextcloud-file-picker.folder-home')}"><dbp-icon name="home"></dbp-icon> </a></span>`;
const directories = this.directoryPath.split('/'); const directories = this.directoryPath.split('/');
if (directories[1] === "") if (directories[1] === "") {
{
return htmlpath; return htmlpath;
} }
for(let i = 1; i < directories.length; i ++) for(let i = 1; i < directories.length; i ++)
...@@ -933,8 +915,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { ...@@ -933,8 +915,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
getCloudLogo() { getCloudLogo() {
let cloudLogo = html `<dbp-icon name="cloud" class="nextcloud-logo-icon"></dbp-icon>`; let cloudLogo = html `<dbp-icon name="cloud" class="nextcloud-logo-icon"></dbp-icon>`;
if (this.nextcloudName === "TU Graz cloud") if (this.nextcloudName === "TU Graz cloud") {
{
cloudLogo = html` cloudLogo = html`
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 97.6 81.74"> <svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 97.6 81.74">
<g> <g>
...@@ -1067,9 +1048,6 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { ...@@ -1067,9 +1048,6 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
} }
.tabulator-row.tabulator-selectable.tabulator-selectable:hover{ .tabulator-row.tabulator-selectable.tabulator-selectable:hover{
/*background-color: var(--dbp-secondary-bg-color);
color: var(--dbp-secondary-text-color);*/
background-color: white; background-color: white;
color: var(--dbp-dark); color: var(--dbp-dark);
} }
...@@ -1318,15 +1296,14 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { ...@@ -1318,15 +1296,14 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
font-size: 1.2rem; font-size: 1.2rem;
} }
.nextcloud-content{
height: auto;
}
.nextcloud-logo-sm{ .nextcloud-logo-sm{
display: none; display: none;
} }
.nextcloud-logo{
margin: 0 auto;
}
.tabulator .tabulator-tableHolder{ .tabulator .tabulator-tableHolder{
white-space: inherit; white-space: inherit;
} }
...@@ -1335,10 +1312,8 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { ...@@ -1335,10 +1312,8 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
} }
.wrapper{ .wrapper{
display: grid; display: flex;
grid-template-rows: inherit; justify-content: space-between;
grid-template-columns: 100%;
grid-template-areas: "content" "footer";
} }
.nextcloud-header{ .nextcloud-header{
...@@ -1348,6 +1323,8 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { ...@@ -1348,6 +1323,8 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
.nextcloud-content, .nextcloud-intro{ .nextcloud-content, .nextcloud-intro{
grid-area: content; grid-area: content;
height:100%;
justify-content:center;
} }
.nextcloud-intro{ .nextcloud-intro{
...@@ -1389,18 +1366,21 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) { ...@@ -1389,18 +1366,21 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
max-width: 100%; max-width: 100%;
} }
.hidden{
display:none;
}
} }
`; `;
} }
render() { render() {
const tabulatorCss = commonUtils.getAssetURL('local/dbp-file-source/tabulator-tables/css/tabulator.min.css'); const tabulatorCss = commonUtils.getAssetURL('local/dbp-file-source/tabulator-tables/css/tabulator.min.css');
console.log("tabulatorCss", tabulatorCss);
return html` return html`
<div class="wrapper"> <div class="wrapper">
<link rel="stylesheet" href="${tabulatorCss}"> <link rel="stylesheet" href="${tabulatorCss}">
<div class="nextcloud-intro"> <div class="nextcloud-intro ${classMap({hidden: this.isPickerActive})}">
<div class="nextcloud-logo ${classMap({"nextcloud-logo-sm": this.isPickerActive})}"> <div class="nextcloud-logo ${classMap({"nextcloud-logo-sm": this.isPickerActive})}">
${this.getCloudLogo()} ${this.getCloudLogo()}
</div> </div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment