Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
max-db-bundle
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pdn-certic
max-db-bundle
Commits
5752716f
Commit
5752716f
authored
4 months ago
by
Jerome Chauveau
Browse files
Options
Downloads
Patches
Plain Diff
delete collection feature
parent
8eee3562
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
max-db.xqm
+4
-4
4 additions, 4 deletions
max-db.xqm
static/max-db.css
+5
-1
5 additions, 1 deletion
static/max-db.css
static/max-db.js
+30
-5
30 additions, 5 deletions
static/max-db.js
templates/index.html
+20
-9
20 additions, 9 deletions
templates/index.html
with
59 additions
and
19 deletions
max-db.xqm
+
4
−
4
View file @
5752716f
...
...
@@ -39,9 +39,9 @@ declare
%updating
%rest:path
(
"/bundles/max-db/{$path=.+}"
)
function
max-db:delete
(
$path
as
xs:string
){
if
(
db:exists
(
$database:max-db
,
$path
))
t
hen
db:delete
(
$database:max-db
,
$path
)
else
fn:error
(
fn:QName
(
'https://certic.unicaen.fr/max/max-db'
,
'err:
source-not-found'
)
,
'source file does not exist'
)
t
ry
{
db:delete
(
$database:max-db
,
$path
)
}
catch
*
{
fn:error
(
fn:QName
(
'https://certic.unicaen.fr/max/max-db'
,
'err:
cannot-delete'
)
,
$path
)
}
};
...
...
@@ -84,7 +84,7 @@ declare %private function max-db:max-collections() as xs:string*{
let
$prefix
:=
'/max/'
let
$collections
:=
distinct-values
(
for
$i
in
collection
(
'max/'
)
let
$path
:=
replace
(
replace
(
base-uri
(
$i
)
,
tokenize
(
base-uri
(
$i
)
,
'/'
)[
last
()]
,
''
)
,
$prefix
,
''
)
return
if
(
$path
=
''
)
then
()
else
$path
)
return
if
(
$path
=
''
)
then
'/'
else
$path
)
return
$collections
};
This diff is collapsed.
Click to expand it.
static/max-db.css
+
5
−
1
View file @
5752716f
#drop
_
zone
.active
{
#drop
-
zone
.active
{
background-color
:
#444
;
color
:
#FFF
;
}
header
h3
em
{
color
:
#888
;
}
ul
{
list-style-type
:
square
;
margin-left
:
0
;
...
...
This diff is collapsed.
Click to expand it.
static/max-db.js
+
30
−
5
View file @
5752716f
...
...
@@ -20,6 +20,23 @@ function deleteSource(source) {
}
function
downloadSource
(
source
){
alert
(
'
todo delete
'
+
source
)
}
function
deleteCurrentCollection
(){
if
(
confirm
(
`Supprimer
${
currentCollection
}
?`
))
{
fetch
(
`/bundles/max-db/
${
currentCollection
}
`
,
{
method
:
'
DELETE
'
}).
then
((
res
)
=>
{
if
(
res
.
status
==
200
){
window
.
location
.
href
=
'
/bundles/max-db/
'
;
}
else
{
res
.
text
().
then
((
message
)
=>
alert
(
`Une erreur est survenue, suppression impossible. \n\n
${
message
}
).`
))
}
})
}
}
function
openMoveSourceDialog
(
source
)
{
document
.
getElementById
(
'
modal-title
'
).
innerHTML
=
`Déplacer <em>
${
source
}
</em>`
if
(
!
modal
)
...
...
@@ -30,9 +47,10 @@ function openMoveSourceDialog(source) {
function
doMoveSource
(){
const
collection
=
document
.
getElementById
(
'
move-collection-select
'
).
value
console
.
debug
(
'
Move
'
+
currentSource
+
'
to
'
+
collection
)
const
path
=
currentCollection
===
'
/
'
?
currentSource
:
`
${
currentCollection
}
/
${
currentSource
}
`
console
.
debug
(
'
Move
'
+
path
+
'
to
'
+
collection
)
modal
.
hide
()
fetch
(
`/bundles/max-db/move?sourcePath=
${
currentSource
}
&collection=
${
collection
}
`
,
{
method
:
'
POST
'
}).
then
((
res
)
=>
{
fetch
(
`/bundles/max-db/move?sourcePath=
${
path
}
&collection=
${
collection
}
`
,
{
method
:
'
POST
'
}).
then
((
res
)
=>
{
if
(
res
.
status
==
200
)
window
.
location
.
reload
();
else
{
...
...
@@ -48,8 +66,12 @@ async function dropHandler(ev) {
const
droppedFiles
=
await
DirectoryDropReader
.
getFilesFromDropEvent
(
ev
)
console
.
debug
(
droppedFiles
)
const
files
=
[...
droppedFiles
][
0
]
files
.
forEach
((
f
)
=>
console
.
debug
(
f
))
console
.
debug
(
files
)
document
.
getElementById
(
'
drop-zone
'
).
classList
.
add
(
'
d-none
'
)
document
.
getElementById
(
'
progress-wrapper
'
).
classList
.
remove
(
'
d-none
'
)
const
progressBar
=
document
.
getElementById
(
'
progress
'
)
const
step
=
Math
.
floor
(
100
/
files
.
length
)
let
value
=
0
;
for
(
let
i
=
0
;
i
<
files
.
length
;
i
++
){
console
.
debug
(
files
[
i
])
const
f
=
files
[
i
]
...
...
@@ -61,17 +83,20 @@ async function dropHandler(ev) {
method
:
'
POST
'
,
body
:
data
,
})
value
+=
step
;
progressBar
.
value
=
value
;
progressBar
.
textContent
=
`
${
value
}
%`
;
}
window
.
location
.
reload
(
true
);
}
function
dragLeaveHandler
(
ev
)
{
ev
.
preventDefault
();
document
.
getElementById
(
"
drop
_
zone
"
).
classList
.
remove
(
'
active
'
);
document
.
getElementById
(
"
drop
-
zone
"
).
classList
.
remove
(
'
active
'
);
}
function
dragOverHandler
(
ev
)
{
ev
.
preventDefault
();
document
.
getElementById
(
"
drop
_
zone
"
).
classList
.
add
(
'
active
'
);
document
.
getElementById
(
"
drop
-
zone
"
).
classList
.
add
(
'
active
'
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
templates/index.html
+
20
−
9
View file @
5752716f
...
...
@@ -14,27 +14,34 @@
</script>
</head>
<body>
<main
class=
"container"
>
<main>
<sl-split-panel
position=
"75"
>
<div
slot=
"start"
style=
"height: 100vh; display: flex; flex-direction:column;
background: var(--sl-color-neutral-50);
"
style=
"height: 100vh; display: flex; flex-direction:column;
overflow-y:auto;
"
>
<div>
<div
class=
"m-5"
>
<header>
<h1
class=
"text-center"
>
Gestion des sources XML de MaX
</h1>
<h2>
Collection
<em>
{$collection}
</em></h2>
<h1
class=
"text-center mb-3"
>
Gestion des sources XML de MaX
</h1>
<h3
class=
"mt-3 d-flex justify-content-between"
>
<span>
Collection
<em>
{$collection}
</em></span>
<sl-icon-button
name=
"trash"
title=
"supprimer la collection"
label=
"supprimer la collection"
onclick=
"deleteCurrentCollection()"
>
</sl-icon-button>
</h3>
</header>
<section
class=
"mt-3"
>
<div
class=
"mt-5 mb-5 d-flex justify-content-center align-items-center"
id=
"drop
_
zone"
id=
"drop
-
zone"
ondrop=
"dropHandler(event);"
ondragleave=
"dragLeaveHandler(event)"
ondragover=
"dragOverHandler(event);"
style=
"min-height:100px;border: dashed 4px #ddd;"
>
Pour ajouter des sources, déposez un ou plusieurs fichiers XML dans cette zone
</div>
<div
id=
"progress-wrapper"
style=
"min-height:100px;"
class=
"d-none"
>
<sl-progress-bar
value=
"0"
id=
"progress"
>
0%
</sl-progress-bar>
</div>
</section>
<section>
<h3>
Sources XML (
<span
id=
"sources-count"
>
{count($sources[@type='xml'])}
</span>
)
</h3>
...
...
@@ -57,8 +64,12 @@
<td>
{string($source/@size)}
</td>
<td>
{string($source/@modified-date)}
</td>
<td
class=
"text-center"
>
<button
title=
"supprimer"
class=
"btn"
onclick=
"deleteSource('{$source/data()}')"
>
☓
</button>
<button
title=
"déplacer"
class=
"btn"
onclick=
"openMoveSourceDialog('{$source/data()}')"
>
↫
</button>
<sl-icon-button
name=
"download"
title=
"télécharger"
onclick=
"downloadSource('{$source/data()}')"
>
</sl-icon-button>
<sl-icon-button
name=
"hand-index"
title=
"déplacer"
onclick=
"openMoveSourceDialog('{$source/data()}')"
>
</sl-icon-button>
<sl-icon-button
name=
"trash"
title=
"supprimer"
onclick=
"deleteSource('{$source/data()}')"
>
</sl-icon-button>
</td>
</tr>
else()
...
...
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