Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Toolkit
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
Web Component Framework
Toolkit
Commits
5445f10e
Commit
5445f10e
authored
Aug 11, 2020
by
Tögl, Christina
Browse files
Options
Downloads
Patches
Plain Diff
Add 'replace-mode-all' functionality
parent
c975cc27
No related branches found
No related tags found
1 merge request
!1
Filehandling overwrite dialog
Pipeline
#12589
passed
Aug 11, 2020
Stage: test
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
packages/file-handling/src/dbp-nextcloud-file-picker.js
+45
-44
45 additions, 44 deletions
packages/file-handling/src/dbp-nextcloud-file-picker.js
with
45 additions
and
44 deletions
packages/file-handling/src/dbp-nextcloud-file-picker.js
+
45
−
44
View file @
5445f10e
...
...
@@ -41,6 +41,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
this
.
uploadFileDirectory
=
null
;
this
.
fileList
=
[];
this
.
fileNameCounter
=
0
;
this
.
forAll
=
false
;
}
static
get
scopedElements
()
{
...
...
@@ -383,19 +384,18 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
uploadFiles
(
files
,
directory
)
{
this
.
fileList
=
files
;
this
.
fileNameCounter
=
1
;
this
.
forAll
=
false
;
this
.
uploadFile
(
directory
);
}
async
uploadFile
(
directory
)
{
if
(
this
.
fileList
.
length
!==
0
)
{
let
file
=
this
.
fileList
[
0
];
console
.
log
(
"
FileList length:
"
,
this
.
fileList
.
length
);
console
.
log
(
"
FileList:
"
,
this
.
fileList
);
this
.
replaceFilename
=
file
.
name
;
console
.
log
(
"
before one file finished
"
);
let
path
=
directory
+
"
/
"
+
file
.
name
;
// https://github.com/perry-mitchell/webdav-client#putfilecontents
let
ret
=
false
;
let
that
=
this
;
let
contents
=
await
this
.
webDavClient
.
putFileContents
(
path
,
file
,
{
overwrite
:
false
,
onUploadProgress
:
progress
=>
{
...
...
@@ -412,13 +412,15 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
//this.statusText = error.message;
console
.
log
(
"
--- h-
"
,
error
.
message
);
if
(
error
.
message
.
search
(
"
412
"
)
!==
-
1
)
{
this
.
replaceModalDialog
(
file
,
directory
);
this
.
forAll
?
this
.
uploadFileAfterConflict
()
:
this
.
replaceModalDialog
(
file
,
directory
);
}
});
}
else
{
this
.
loading
=
false
;
this
.
statusText
=
""
;
this
.
_
(
"
#replace_mode_all
"
).
checked
=
false
;
this
.
forAll
=
false
;
const
event
=
new
CustomEvent
(
"
dbp-nextcloud-file-picker-file-uploaded-finished
"
,
{
bubbles
:
true
,
composed
:
true
});
this
.
dispatchEvent
(
event
);
...
...
@@ -426,7 +428,6 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
}
async
uploadFileAfterConflict
()
{
console
.
log
(
"
uploadFileAfterConflict
"
)
let
path
=
""
;
let
overwrite
=
false
;
let
file
=
this
.
uploadFileObject
;
...
...
@@ -434,42 +435,42 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
if
(
this
.
_
(
"
input[name='replacement']:checked
"
).
value
===
"
ignore
"
)
{
MicroModal
.
close
(
this
.
_
(
"
#replace-modal
"
));
console
.
log
(
"
############ ignore
"
);
this
.
fileList
.
shift
();
this
.
forAll
?
this
.
fileList
=
[]
:
this
.
fileList
.
shift
();
this
.
uploadFile
(
directory
);
return
true
;
}
else
if
(
this
.
_
(
"
input[name='replacement']:checked
"
).
value
===
"
new-name
"
)
{
}
else
if
(
this
.
_
(
"
input[name='replacement']:checked
"
).
value
===
"
new-name
"
)
{
path
=
directory
+
"
/
"
+
this
.
_
(
"
#replace-filename
"
).
value
;
console
.
log
(
"
############# new name checked
"
);
this
.
replaceFilename
=
this
.
_
(
"
#replace-filename
"
).
value
;
//this.fileNameCounter++; //TODO check
}
else
{
this
.
replaceFilename
=
this
.
forAll
?
this
.
getNextFilename
()
:
this
.
_
(
"
#replace-filename
"
).
value
;
}
else
{
path
=
directory
+
"
/
"
+
this
.
uploadFileObject
.
name
;
overwrite
=
true
;
console
.
log
(
"
uploadFileAfterConflict called
"
);
}
let
that
=
this
;
// https://github.com/perry-mitchell/webdav-client#putfilecontents
let
contents
=
await
this
.
webDavClient
.
putFileContents
(
path
,
file
,
{
overwrite
:
overwrite
,
onUploadProgress
:
progress
=>
{
.
putFileContents
(
path
,
file
,
{
overwrite
:
overwrite
,
onUploadProgress
:
progress
=>
{
console
.
log
(
`Uploaded
${
progress
.
loaded
}
bytes of
${
progress
.
total
}
`
);
}}).
then
(
content
=>
{
}
}).
then
(
content
=>
{
console
.
log
(
"
write file with name:
"
,
file
.
name
);
that
.
loading
=
false
;
that
.
statusText
=
""
;
console
.
log
(
"
FileList length:
"
,
this
.
fileList
.
length
);
//TODO
MicroModal
.
close
(
this
.
_
(
"
#replace-modal
"
));
that
.
fileList
.
shift
();
that
.
uploadFile
(
directory
);
}).
catch
(
error
=>
{
console
.
error
(
error
.
message
);
that
.
loading
=
false
;
that
.
statusText
=
error
.
message
;
//
that.loading = false;
//
that.statusText = error.message;
if
(
error
.
message
.
search
(
"
412
"
)
!==
-
1
)
{
MicroModal
.
close
(
that
.
_
(
"
#replace-modal
"
));
that
.
replaceModalDialog
(
file
,
directory
);
this
.
forAll
?
that
.
uploadFileAfterConflict
()
:
that
.
replaceModalDialog
(
file
,
directory
);
}
});
this
.
fileNameCounter
=
1
;
}
...
...
@@ -487,11 +488,11 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
*
* @returns {string} The next filename
*/
getNextFilename
()
{
//TODO
getNextFilename
()
{
//TODO
handle custom filenames
let
nextFilename
=
""
;
let
splitFilename
=
this
.
replaceFilename
.
split
(
"
.
"
);
let
splitBracket
=
splitFilename
[
0
].
split
(
'
(
'
)
let
splitBracket
=
splitFilename
[
0
].
split
(
'
(
'
)
;
if
(
splitBracket
.
length
>
1
)
{
let
numberString
=
splitBracket
[
1
].
split
(
'
)
'
);
if
(
numberString
.
length
>
1
&&
!
isNaN
(
parseInt
(
numberString
[
0
])))
{
...
...
@@ -518,7 +519,7 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
/**
* Disables or enables the input field for the new file name
*/
disable
InputField
()
{
set
InputField
Visibility
()
{
this
.
_
(
"
#replace-filename
"
).
disabled
=
!
this
.
_
(
"
#replace-new-name
"
).
checked
;
}
...
...
@@ -537,15 +538,15 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
/**
*
*/
cancel
E
ver
ything
()
{
cancel
O
ver
write
()
{
//TODO simplify?
this
.
fileList
=
[];
}
/**
*
*/
r
epeatForAllConflicts
()
{
//TODO
setR
epeatForAllConflicts
()
{
this
.
forAll
=
this
.
_
(
"
#replace_mode_all
"
).
checked
;
}
/**
...
...
@@ -1052,27 +1053,27 @@ export class NextcloudFilePicker extends ScopedElementsMixin(DBPLitElement) {
${
i18n
.
t
(
'
nextcloud-file-picker.replace-text
'
)}
?
</h3>
<div>
<input type="radio" id="replace-new-name" class="radio-btn" name="replacement" value="new-name" checked @click="
${()
=>
{
this
.
disable
InputField
();}}
">
<input type="radio" id="replace-new-name" class="radio-btn" name="replacement" value="new-name" checked @click="
${()
=>
{
this
.
set
InputField
Visibility
();}}
">
<label for="new-name">
${
i18n
.
t
(
'
nextcloud-file-picker.replace-new_name
'
)}
:
<input type="text" id="replace-filename" name="replace-filename" value="
${
this
.
getNextFilename
()}
" onClick="this.select();">
</label>
</div>
<div>
<input type="radio" class="radio-btn" name="replacement" value="replace" @click="
${()
=>
{
this
.
disable
InputField
();}}
">
<input type="radio" class="radio-btn" name="replacement" value="replace" @click="
${()
=>
{
this
.
set
InputField
Visibility
();}}
">
<label for="replace">
${
i18n
.
t
(
'
nextcloud-file-picker.replace-replace
'
)}
</label>
</div>
<div>
<input type="radio" class="radio-btn" name="replacement" value="ignore" @click="
${()
=>
{
this
.
disable
InputField
();}}
">
<input type="radio" class="radio-btn" name="replacement" value="ignore" @click="
${()
=>
{
this
.
set
InputField
Visibility
();}}
">
<label for="ignore">
${
i18n
.
t
(
'
nextcloud-file-picker.replace-skip
'
)}
</label>
</div>
</main>
<footer class="modal-footer">
<div class="modal-footer-btn">
<button class="button" data-micromodal-close aria-label="Close this dialog window" @click="
${()
=>
{
this
.
cancel
E
ver
ything
();}}
">
${
this
.
getCancelText
()}
</button>
<button class="button" data-micromodal-close aria-label="Close this dialog window" @click="
${()
=>
{
this
.
cancel
O
ver
write
();}}
">
${
this
.
getCancelText
()}
</button>
<button class="button select-button is-primary" @click="
${()
=>
{
this
.
uploadFileAfterConflict
();}}
">OK</button>
</div>
<div>
<input type="checkbox" id="replace_mode_all" name="replace_mode_all" value="replace_mode_all" @click="
${()
=>
{
this
.
r
epeatForAllConflicts
();}}
>
<input type="checkbox" id="replace_mode_all" name="replace_mode_all" value="replace_mode_all" @click="
${()
=>
{
this
.
setR
epeatForAllConflicts
();}}
>
<label for="replace_mode_all">
${
i18n
.
t
(
'
nextcloud-file-picker.replace-mode-all
'
)}
</label>
</div>
</footer>
...
...
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