Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
KolloquiumVRWebsite
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
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nick Anton Christoph Kleine-Tebbe
KolloquiumVRWebsite
Commits
649e1b5b
Commit
649e1b5b
authored
3 years ago
by
Nick Anton Christoph Kleine-Tebbe
Browse files
Options
Downloads
Patches
Plain Diff
Fixed issue with deleting Kolloqs
parent
94bd3406
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
api/routes/kolloquiums.js
+42
-14
42 additions, 14 deletions
api/routes/kolloquiums.js
components/KolloquiumItem.vue
+14
-2
14 additions, 2 deletions
components/KolloquiumItem.vue
pages/index.vue
+62
-31
62 additions, 31 deletions
pages/index.vue
with
118 additions
and
47 deletions
api/routes/kolloquiums.js
+
42
−
14
View file @
649e1b5b
...
...
@@ -6,9 +6,15 @@ var fs = require("fs")
const
kolloquiumDirectory
=
'
Kolloquiums
'
function
getDirectories
(
path
)
{
return
fs
.
readdirSync
(
path
).
filter
(
function
(
file
)
{
return
fs
.
statSync
(
path
+
'
/
'
+
file
).
isDirectory
();
});
// check if directory exists
if
(
fs
.
existsSync
(
path
))
{
return
fs
.
readdirSync
(
path
).
filter
(
function
(
file
)
{
return
fs
.
statSync
(
path
+
'
/
'
+
file
).
isDirectory
();
});
}
else
{
console
.
log
(
'
Directory not found.
'
);
return
[]
}
}
function
isEmpty
(
checkString
)
{
...
...
@@ -54,6 +60,7 @@ fs.mkdir(kolloquiumDirectory,function(err) {
router
.
use
(
'
/getKolloquiums
'
,
(
req
,
res
)
=>
{
console
.
log
(
'
/getKolloquiums
'
)
var
directories
=
getDirectories
(
kolloquiumDirectory
)
console
.
log
(
'
Kolloquiums:
'
+
directories
)
return
res
.
json
({
kolloquiums
:
directories
});
...
...
@@ -96,19 +103,40 @@ router.use('/deleteKolloquium', (req, res) => {
})
}
fs
.
rmdir
(
kolloquiumDirectory
+
'
/
'
+
safeTitle
,
function
(
err
)
{
let
dirname
=
kolloquiumDirectory
+
'
/
'
+
safeTitle
fs
.
readdir
(
dirname
,
function
(
err
,
files
)
{
if
(
err
)
{
console
.
error
(
err
);
return
res
.
json
({
success
:
false
,
message
:
err
})
console
.
error
(
err
);
return
res
.
json
({
success
:
false
,
message
:
err
})
}
else
{
if
(
!
files
.
length
)
{
// directory appears to be empty
fs
.
rmdir
(
dirname
,
function
(
err
)
{
if
(
err
)
{
console
.
error
(
err
);
return
res
.
json
({
success
:
false
,
message
:
err
})
}
return
res
.
json
({
success
:
true
,
message
:
'
removed Kolloquium
'
+
safeTitle
})
});
}
else
{
// TODO: ask for confirmation to delete anyway
console
.
log
(
'
Directory is not empty. TODO: Ask for confirmation to delete anyway
'
)
return
res
.
json
({
success
:
false
,
message
:
'
Kolloquium
'
+
safeTitle
+
'
was not empty
'
})
}
}
});
return
res
.
json
({
success
:
true
,
message
:
'
removed Kolloquium
'
+
safeTitle
})
});
})
// Create Kolloquium
...
...
This diff is collapsed.
Click to expand it.
components/KolloquiumItem.vue
+
14
−
2
View file @
649e1b5b
...
...
@@ -3,10 +3,19 @@
:selected=
"selected"
>
<div
class=
"flex flex-row w-full"
>
<div
v-if=
"!inEdit"
class=
"w-full select-none text-left mr-1"
>
<div
v-if=
"!inEdit"
class=
"w-full select-none text-left mr-1"
@
click=
"selectMe()"
>
{{
title
}}
</div>
<input
v-if=
"inEdit"
class=
"w-full rounded border p-1"
v-model=
"title"
placeholder=
"Neues Kolloquium..."
/>
<input
v-if=
"inEdit"
class=
"w-full rounded border p-1"
v-model=
"title"
placeholder=
"Neues Kolloquium..."
/>
<client-only>
<button
v-if=
"inEdit"
...
...
@@ -65,6 +74,9 @@ export default {
},
deleteMe
()
{
this
.
$emit
(
"
deleteKolloquium
"
)
},
selectMe
()
{
this
.
$emit
(
"
selectKolloquium
"
)
}
}
}
...
...
This diff is collapsed.
Click to expand it.
pages/index.vue
+
62
−
31
View file @
649e1b5b
...
...
@@ -16,12 +16,12 @@
<KolloquiumItem
v-for=
"kolloquium in kolloquiums"
:key=
"kolloquium.title"
@
click.native=
"selectKolloquium(kolloquium)"
:selected=
"selectedKolloquium===kolloquium.title"
:title=
"kolloquium.title"
@
update:title=
"kolloquium.title=$event"
:inEdit=
"kolloquium.inEdit"
@
update:title=
"kolloquium.title=$event"
@
update:inEdit=
"toggleEdit(kolloquium, $event)"
@
selectKolloquium=
"selectKolloquium(kolloquium.title)"
@
deleteKolloquium=
"deleteKolloquium(kolloquium.title)"
/>
<ListItem
...
...
@@ -37,23 +37,33 @@
</div>
</
template
>
<
template
slot=
"content"
>
<p
class=
"text-xl"
><span
class=
"font-semibold"
>
Titel:
</span>
{{
selectedKolloquium
}}
</p>
<p
class=
"font-semibold mt-4 mb-1"
>
Abgaben:
</p>
<AbgabeItem
v-for=
"abgabe in abgaben"
:key=
"abgabe"
@
click.native=
"selectAbgabe(abgabe)"
:title=
"abgabe"
/>
<div
class=
"flex flex-row justify-between"
>
<button
class=
"border rounded mt-4 p-2 font-semibold text-white bg-green-500 hover:bg-green-600 focus:bg-green-700"
>
Aktivieren
</button>
<n-link
:to=
"'/abgabe/' + selectedKolloquium"
>
<button
class=
"border rounded mt-4 p-2 font-semibold text-white bg-blue-500 hover:bg-blue-600 focus:bg-blue-700"
>
Link Teilen
<div
v-if=
"selectedKolloquium"
>
<p
class=
"text-xl"
><span
class=
"font-semibold"
>
Titel:
</span>
{{
selectedKolloquium
}}
</p>
<p
class=
"font-semibold mt-4 mb-1"
>
Abgaben:
</p>
<div
v-if=
"abgaben.length > 0"
>
<AbgabeItem
v-for=
"abgabe in abgaben"
:key=
"abgabe"
@
click.native=
"selectAbgabe(abgabe)"
:title=
"abgabe"
/>
</div>
<div
v-else
>
Keine Abgaben
</div>
<div
class=
"flex flex-row justify-between"
>
<button
class=
"border rounded mt-4 p-2 font-semibold text-white bg-green-500 hover:bg-green-600 focus:bg-green-700"
>
Aktivieren
</button>
</n-link>
<n-link
:to=
"'/abgabe/' + selectedKolloquium"
>
<button
class=
"border rounded mt-4 p-2 font-semibold text-white bg-blue-500 hover:bg-blue-600 focus:bg-blue-700"
>
Link Teilen
</button>
</n-link>
</div>
</div>
<div
v-else
class=
"font-semibold"
>
Kein Kolloquium ausgewählt
</div>
</
template
>
</box>
...
...
@@ -80,11 +90,11 @@ export default {
}
},
methods
:
{
async
selectKolloquium
(
kolloquium
)
{
this
.
selectedKolloquium
=
kolloquium
.
t
itle
async
selectKolloquium
(
kolloquium
Title
)
{
this
.
selectedKolloquium
=
kolloquium
T
itle
this
.
selectedAbgabe
=
''
this
.
abgaben
=
[]
const
data
=
await
this
.
$axios
.
$post
(
'
/api/getAbgaben/
'
,
{
kolloquium
:
kolloquium
.
t
itle
})
const
data
=
await
this
.
$axios
.
$post
(
'
/api/getAbgaben/
'
,
{
kolloquium
:
kolloquium
T
itle
})
this
.
abgaben
=
data
.
abgaben
},
selectAbgabe
(
abgabe
)
{
...
...
@@ -98,7 +108,7 @@ export default {
this
.
kolloquiums
=
this
.
kolloquiums
.
filter
(
kolloquium
=>
kolloquium
.
title
.
length
>
0
);
this
.
kolloquiums
=
[...
this
.
kolloquiums
,
{
title
:
''
,
inEdit
:
true
,
isNew
:
true
}];
},
toggleEdit
(
kolloquium
,
{
inEdit
,
title
})
{
async
toggleEdit
(
kolloquium
,
{
inEdit
,
title
})
{
let
createNew
=
kolloquium
.
inEdit
&&
kolloquium
.
isNew
;
let
changeName
=
kolloquium
.
inEdit
&&
!
kolloquium
.
isNew
;
...
...
@@ -115,34 +125,55 @@ export default {
return
}
this
.
$axios
.
post
(
'
api/createKolloquium
'
,
{
title
:
title
})
this
.
refreshKolloquiumList
()
}
else
if
(
changeName
)
{
// TODO: Request confirmation before changing name so the link does not break
// TODO: Or make sure the link stays the same if the folder is renamed?
if
(
!
title
||
title
.
trim
().
length
==
0
)
{
return
}
kolloquium
.
title
=
title
this
.
$axios
.
post
(
'
api/renameKolloquium
'
,
{
oldTitle
:
kolloquium
.
title
,
newTitle
:
title
})
this
.
refreshKolloquiumList
()
}
},
deleteKolloquium
(
kolloquiumToDelete
)
{
this
.
kolloquiums
=
this
.
kolloquiums
.
filter
(
kolloquium
=>
kolloquium
.
title
!=
kolloquiumToDelete
);
this
.
selectedKolloquium
=
""
if
(
kolloquiumToDelete
!=
''
){
this
.
$axios
.
post
(
'
api/deleteKolloquium
'
,
{
title
:
kolloquiumToDelete
})
async
deleteKolloquium
(
kolloquiumTitle
)
{
this
.
selectedKolloquium
=
''
if
(
kolloquiumTitle
!=
''
){
this
.
$axios
.
post
(
'
api/deleteKolloquium
'
,
{
title
:
kolloquiumTitle
})
}
this
.
refreshKolloquiumList
()
},
async
refreshKolloquiumList
()
{
this
.
abgaben
=
[]
this
.
kolloquiums
=
[]
this
.
selectedKolloquium
=
''
this
.
selectedAbgabe
=
''
const
dataKolloquiums
=
await
this
.
$axios
.
$get
(
'
/api/getKolloquiums/
'
)
dataKolloquiums
.
kolloquiums
.
forEach
(
title
=>
{
this
.
kolloquiums
.
push
({
title
:
title
,
inEdit
:
false
})
})
}
},
async
asyncData
({
$axios
})
{
const
dataKolloquiums
=
await
$axios
.
$get
(
'
/api/getKolloquiums/
'
)
let
kolloquiumList
=
[]
let
abgaben
=
[]
const
dataKolloquiums
=
await
$axios
.
$get
(
'
/api/getKolloquiums/
'
)
dataKolloquiums
.
kolloquiums
.
forEach
(
title
=>
{
kolloquiumList
.
push
({
title
:
title
,
inEdit
:
false
})
})
const
dataAbgaben
=
await
$axios
.
$post
(
'
/api/getAbgaben/
'
,
{
kolloquium
:
kolloquiumList
[
0
].
title
})
return
{
kolloquiums
:
kolloquiumList
,
abgaben
:
dataAbgaben
.
abgaben
,
selectedKolloquium
:
kolloquiumList
[
0
].
title
}
if
(
kolloquiumList
.
length
!==
0
){
const
dataAbgaben
=
await
$axios
.
$post
(
'
/api/getAbgaben/
'
,
{
kolloquium
:
kolloquiumList
[
0
].
title
})
abgaben
=
dataAbgaben
.
abgaben
}
return
{
kolloquiums
:
kolloquiumList
,
abgaben
:
abgaben
}
},
}
</
script
>
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