Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Signature Frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
digital blueprint
Electronic Signature Service
Signature Frontend
Commits
d25cfd94
Unverified
Commit
d25cfd94
authored
5 years ago
by
Bekerle, Patrizio
Browse files
Options
Downloads
Patches
Plain Diff
Add more webdav file handling and table columns (
#26
)
parent
b86b3fb6
No related branches found
No related tags found
No related merge requests found
Pipeline
#11855
passed with warnings
5 years ago
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/vpu-nextcloud-file-picker.js
+82
-43
82 additions, 43 deletions
src/vpu-nextcloud-file-picker.js
with
82 additions
and
43 deletions
src/vpu-nextcloud-file-picker.js
+
82
−
43
View file @
d25cfd94
...
@@ -24,8 +24,8 @@ export class NextcloudFilePicker extends ScopedElementsMixin(VPULitElement) {
...
@@ -24,8 +24,8 @@ export class NextcloudFilePicker extends ScopedElementsMixin(VPULitElement) {
this
.
loginWindow
=
null
;
this
.
loginWindow
=
null
;
this
.
isPickerActive
=
false
;
this
.
isPickerActive
=
false
;
this
.
statusText
=
""
;
this
.
statusText
=
""
;
this
.
lastDirectoryPath
=
"
/
"
;
this
.
directoryPath
=
"
/
"
;
this
.
directoryPath
=
"
/
"
;
this
.
directoryContents
=
[];
this
.
webDavClient
=
null
;
this
.
webDavClient
=
null
;
this
.
tabulatorTable
=
null
;
this
.
tabulatorTable
=
null
;
...
@@ -49,7 +49,6 @@ export class NextcloudFilePicker extends ScopedElementsMixin(VPULitElement) {
...
@@ -49,7 +49,6 @@ export class NextcloudFilePicker extends ScopedElementsMixin(VPULitElement) {
isPickerActive
:
{
type
:
Boolean
,
attribute
:
false
},
isPickerActive
:
{
type
:
Boolean
,
attribute
:
false
},
statusText
:
{
type
:
String
,
attribute
:
false
},
statusText
:
{
type
:
String
,
attribute
:
false
},
directoryPath
:
{
type
:
String
,
attribute
:
false
},
directoryPath
:
{
type
:
String
,
attribute
:
false
},
directoryContents
:
{
type
:
Array
,
attribute
:
false
},
};
};
}
}
...
@@ -78,11 +77,38 @@ export class NextcloudFilePicker extends ScopedElementsMixin(VPULitElement) {
...
@@ -78,11 +77,38 @@ export class NextcloudFilePicker extends ScopedElementsMixin(VPULitElement) {
window
.
addEventListener
(
'
message
'
,
this
.
_onReceiveWindowMessage
);
window
.
addEventListener
(
'
message
'
,
this
.
_onReceiveWindowMessage
);
// http://tabulator.info/docs/4.7
// http://tabulator.info/docs/4.7
this
.
tabulatorTable
=
new
Tabulator
(
this
.
_
(
"
#directory-content-table
"
),
{});
// TODO: format size and lastmod
// TODO: translation of column headers
// TODO: mime type icon
this
.
tabulatorTable
=
new
Tabulator
(
this
.
_
(
"
#directory-content-table
"
),
{
layout
:
"
fitDataStretch
"
,
selectable
:
true
,
columns
:
[
{
title
:
"
Filename
"
,
field
:
"
basename
"
},
{
title
:
"
Size
"
,
field
:
"
size
"
,
formatter
:
(
cell
,
formatterParams
,
onRendered
)
=>
{
return
cell
.
getRow
().
getData
().
type
===
"
directory
"
?
""
:
humanFileSize
(
cell
.
getValue
());}},
{
title
:
"
Type
"
,
field
:
"
type
"
},
{
title
:
"
Mime
"
,
field
:
"
mime
"
},
{
title
:
"
Last modified
"
,
field
:
"
lastmod
"
,
sorter
:
"
date
"
},
],
rowClick
:
(
e
,
row
)
=>
{
const
data
=
row
.
getData
();
switch
(
data
.
type
)
{
case
"
directory
"
:
this
.
directoryClicked
(
e
,
data
);
break
;
case
"
file
"
:
console
.
log
(
"
file selected
"
,
data
);
break
;
}
},
});
});
});
}
}
openFilePicker
()
{
openFilePicker
()
{
// TODO: translation
this
.
statusText
=
"
Auth in progress
"
;
this
.
statusText
=
"
Auth in progress
"
;
this
.
loginWindow
=
window
.
open
(
this
.
authUrl
,
"
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
"
);
...
@@ -107,7 +133,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(VPULitElement) {
...
@@ -107,7 +133,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(VPULitElement) {
}
}
);
);
this
.
loadDirectory
(
""
);
this
.
loadDirectory
(
"
/
"
);
}
}
}
}
...
@@ -117,20 +143,18 @@ export class NextcloudFilePicker extends ScopedElementsMixin(VPULitElement) {
...
@@ -117,20 +143,18 @@ export class NextcloudFilePicker extends ScopedElementsMixin(VPULitElement) {
* @param path
* @param path
*/
*/
loadDirectory
(
path
)
{
loadDirectory
(
path
)
{
// TODO: translation
this
.
statusText
=
"
Loading directory from Nextcloud:
"
+
path
;
this
.
statusText
=
"
Loading directory from Nextcloud:
"
+
path
;
this
.
lastDirectoryPath
=
this
.
directoryPath
;
this
.
directoryPath
=
path
;
this
.
directoryPath
=
path
;
this
.
directoryContents
=
[];
// https://github.com/perry-mitchell/webdav-client#getdirectorycontents
// https://github.com/perry-mitchell/webdav-client#getdirectorycontents
this
.
webDavClient
this
.
webDavClient
.
getDirectoryContents
(
path
)
.
getDirectoryContents
(
path
,
{
details
:
true
}
)
.
then
(
contents
=>
{
.
then
(
contents
=>
{
console
.
log
(
"
contents
"
,
contents
);
console
.
log
(
"
contents
"
,
contents
);
this
.
statusText
=
""
;
this
.
statusText
=
""
;
this
.
directoryContents
=
contents
;
this
.
tabulatorTable
.
setData
(
contents
.
data
);
this
.
tabulatorTable
.
setData
(
contents
);
this
.
isPickerActive
=
true
;
this
.
isPickerActive
=
true
;
}).
catch
(
error
=>
{
}).
catch
(
error
=>
{
console
.
error
(
error
.
message
);
console
.
error
(
error
.
message
);
...
@@ -139,41 +163,53 @@ export class NextcloudFilePicker extends ScopedElementsMixin(VPULitElement) {
...
@@ -139,41 +163,53 @@ export class NextcloudFilePicker extends ScopedElementsMixin(VPULitElement) {
});
});
}
}
static
get
styles
()
{
directoryClicked
(
event
,
file
)
{
// language=css
this
.
loadDirectory
(
file
.
filename
);
return
css
`
event
.
preventDefault
();
${
commonStyles
.
getGeneralCSS
()}
}
${
commonStyles
.
getButtonCSS
()}
.block
{
downloadFiles
(
files
)
{
margin-bottom: 10px
;
files
.
forEach
((
file
)
=>
this
.
downloadFile
(
file
))
;
}
}
`
;
downloadFile
(
file
)
{
this
.
statusText
=
"
Loading
"
+
file
.
filename
+
"
...
"
;
// https://github.com/perry-mitchell/webdav-client#getfilecontents
this
.
webDavClient
.
getFileContents
(
file
.
filename
)
.
then
(
contents
=>
{
console
.
log
(
"
contents
"
,
contents
);
// TODO: Generate file and send event
this
.
statusText
=
""
;
}).
catch
(
error
=>
{
console
.
error
(
error
.
message
);
this
.
statusText
=
error
.
message
;
});
}
}
/**
/**
* Returns the
list of files in a
directory
* Returns the
parent
directory
path
*
*
* @returns {
*[]}
* @returns {
string} parent directory path
*/
*/
getDirectoryContentsHtml
()
{
getParentDirectoryPath
()
{
let
results
=
[];
let
path
=
this
.
directoryPath
.
replace
(
/
\/
$/
,
""
);
path
=
path
.
replace
(
path
.
split
(
"
/
"
).
pop
(),
""
).
replace
(
/
\/
$/
,
""
);
// this.directoryContents.forEach((content) => {
// results.push(html`
// <tr>
// <td><a href="#" @click="${(e) => { this.fileClicked(content, e); }}">${content.filename}</a></td>
// <td>${content.size}</td>
// </tr>
// `);
// });
return
results
;
return
(
path
===
""
)
?
"
/
"
:
path
;
}
}
fileClicked
(
file
,
event
)
{
static
get
styles
()
{
this
.
loadDirectory
(
this
.
directoryPath
+
file
.
filename
);
// language=css
event
.
preventDefault
();
return
css
`
${
commonStyles
.
getGeneralCSS
()}
${
commonStyles
.
getButtonCSS
()}
.block {
margin-bottom: 10px;
}
`
;
}
}
render
()
{
render
()
{
...
@@ -194,13 +230,16 @@ export class NextcloudFilePicker extends ScopedElementsMixin(VPULitElement) {
...
@@ -194,13 +230,16 @@ export class NextcloudFilePicker extends ScopedElementsMixin(VPULitElement) {
</div>
</div>
<div class="block
${
classMap
({
hidden
:
!
this
.
isPickerActive
})}
">
<div class="block
${
classMap
({
hidden
:
!
this
.
isPickerActive
})}
">
<h2>
${
this
.
directoryPath
}
</h2>
<h2>
${
this
.
directoryPath
}
</h2>
<table id="directory-content-table">
<button class="button is-small"
<thead>
title="
${
i18n
.
t
(
'
nextcloud-file-picker.folder-last
'
)}
"
<th>Filename</th>
@click="
${()
=>
{
this
.
loadDirectory
(
this
.
lastDirectoryPath
);
}}
">⇦</button>
<th>Size</th>
<button class="button is-small"
</thead>
title="
${
i18n
.
t
(
'
nextcloud-file-picker.folder-up
'
)}
"
<tbody>
${
this
.
getDirectoryContentsHtml
()}
</tbody>
@click="
${()
=>
{
this
.
loadDirectory
(
this
.
getParentDirectoryPath
());
}}
">⇧</button>
</table>
<table id="directory-content-table"></table>
<button class="button"
title="
${
i18n
.
t
(
'
nextcloud-file-picker.folder-up
'
)}
"
@click="
${()
=>
{
this
.
downloadFiles
(
this
.
tabulatorTable
.
getSelectedData
());
}}
">
${
i18n
.
t
(
'
nextcloud-file-picker.select-files
'
)}
</button>
</div>
</div>
`
;
`
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment