Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
CloWM UI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Monitor
Service Desk
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
Computational Metagenomics
CloWM
CloWM UI
Commits
33d1ce44
Verified
Commit
33d1ce44
authored
2 years ago
by
Daniel Göbel
Browse files
Options
Downloads
Patches
Plain Diff
Add button to delete a s3 key
#16
parent
73473d20
No related branches found
No related tags found
1 merge request
!15
Manipulate S3 keys
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/components/S3KeyView.vue
+28
-1
28 additions, 1 deletion
src/components/S3KeyView.vue
src/views/object-storage/S3KeysView.vue
+55
-4
55 additions, 4 deletions
src/views/object-storage/S3KeysView.vue
with
83 additions
and
5 deletions
src/components/S3KeyView.vue
+
28
−
1
View file @
33d1ce44
...
...
@@ -3,9 +3,15 @@ import type { S3Key } from "@/client";
import
type
{
Ref
}
from
"
vue
"
;
import
{
ref
,
watch
}
from
"
vue
"
;
import
BootstrapIcon
from
"
@/components/BootstrapIcon.vue
"
;
import
DeleteModal
from
"
@/components/Modals/DeleteModal.vue
"
;
const
props
=
defineProps
<
{
s3key
:
S3Key
;
deletable
:
boolean
;
}
>
();
const
emit
=
defineEmits
<
{
(
e
:
"
delete-key
"
,
accessKey
:
string
):
void
;
}
>
();
watch
(
...
...
@@ -16,9 +22,22 @@ watch(
);
const
visibleSecret
:
Ref
<
boolean
>
=
ref
(
false
);
function
deleteKeyTrigger
()
{
if
(
props
.
deletable
)
{
emit
(
"
delete-key
"
,
props
.
s3key
.
access_key
);
}
}
</
script
>
<
template
>
<DeleteModal
modalID=
"delete-key-modal"
modal-label=
"Delete S3 Key"
:object-name-delete=
"props.s3key.access_key"
:back-modal-id=
"undefined"
@
confirm-delete=
"deleteKeyTrigger"
/>
<h3>
Access Key:
</h3>
<input
class=
"form-control-plaintext text-white fs-4"
...
...
@@ -52,7 +71,15 @@ const visibleSecret: Ref<boolean> = ref(false);
aria-describedby=
"s3-secret-key"
readonly
/>
<button
type=
"button"
class=
"btn btn-danger fs-5"
disabled
>
Delete
</button>
<button
type=
"button"
class=
"btn btn-danger fs-5"
:disabled=
"!props.deletable"
data-bs-toggle=
"modal"
data-bs-target=
"#delete-key-modal"
>
Delete
</button>
</
template
>
<
style
scoped
></
style
>
This diff is collapsed.
Click to expand it.
src/views/object-storage/S3KeysView.vue
+
55
−
4
View file @
33d1ce44
<
script
setup
lang=
"ts"
>
import
S3KeyView
from
"
@/components/S3KeyView.vue
"
;
import
{
reactive
,
onMounted
}
from
"
vue
"
;
import
{
reactive
,
onMounted
,
computed
}
from
"
vue
"
;
import
type
{
ComputedRef
}
from
"
vue
"
;
import
type
{
S3Key
}
from
"
@/client
"
;
import
{
KeyService
}
from
"
@/client
"
;
import
{
useAuthStore
}
from
"
@/stores/auth
"
;
import
{
Toast
}
from
"
bootstrap
"
;
const
authStore
=
useAuthStore
();
...
...
@@ -13,26 +15,51 @@ authStore.$onAction(({ name, args }) => {
}
});
let
successToast
:
Toast
|
null
=
null
;
const
keyState
=
reactive
({
keys
:
[],
activeKey
:
0
,
loading
:
true
,
initialLoading
:
true
,
deletedKey
:
""
,
}
as
{
keys
:
S3Key
[];
activeKey
:
number
;
loading
:
boolean
;
initialLoading
:
boolean
;
deletedKey
:
string
;
});
const
allowKeyDeletion
:
ComputedRef
<
boolean
>
=
computed
(
()
=>
keyState
.
keys
.
length
>
1
);
function
refreshKeys
(
uid
:
string
)
{
KeyService
.
keyGetUserKeys
(
uid
)
.
then
((
keys
)
=>
{
keyState
.
keys
=
keys
;
})
.
catch
((
err
)
=>
console
.
error
(
err
))
.
finally
(()
=>
(
keyState
.
loading
=
false
));
.
finally
(()
=>
(
keyState
.
initialLoading
=
false
));
}
function
deleteKey
(
accessKey
:
string
)
{
if
(
allowKeyDeletion
.
value
&&
authStore
.
user
!=
null
)
{
KeyService
.
keyDeleteUserKey
(
accessKey
,
authStore
.
user
.
uid
)
.
then
(()
=>
{
keyState
.
deletedKey
=
accessKey
;
keyState
.
activeKey
=
0
;
keyState
.
keys
=
keyState
.
keys
.
filter
(
(
s3key
)
=>
s3key
.
access_key
!==
accessKey
);
authStore
.
setS3Key
(
keyState
.
keys
[
0
]);
successToast
?.
show
();
})
.
catch
((
err
)
=>
console
.
error
(
err
));
}
}
onMounted
(()
=>
{
successToast
=
new
Toast
(
"
#successKeyToast
"
);
if
(
authStore
.
user
!=
null
)
{
refreshKeys
(
authStore
.
user
.
uid
);
}
...
...
@@ -40,6 +67,28 @@ onMounted(() => {
</
script
>
<
template
>
<div
class=
"toast-container position-fixed top-0 end-0 p-3"
>
<div
role=
"alert"
aria-live=
"assertive"
aria-atomic=
"true"
class=
"toast text-bg-success align-items-center border-0"
data-bs-autohide=
"true"
:id=
"'successKeyToast'"
>
<div
class=
"d-flex"
>
<div
class=
"toast-body"
>
Successfully deleted S3 Key
{{
keyState
.
deletedKey
}}
</div>
<button
type=
"button"
class=
"btn-close btn-close-white me-2 m-auto"
data-bs-dismiss=
"toast"
aria-label=
"Close"
></button>
</div>
</div>
</div>
<div
class=
"row m-2 border-bottom border-light mt-4"
>
<div
class=
"col-12"
></div>
<h1
class=
"mb-2 text-light"
>
S3 Keys
</h1>
...
...
@@ -63,6 +112,8 @@ onMounted(() => {
<s3-key-view
v-if=
"keyState.keys.length > 0"
:s3key=
"keyState.keys[keyState.activeKey]"
:deletable=
"allowKeyDeletion"
@
delete-key=
"deleteKey"
/>
<div
v-else
>
No keys here.
<br
/>
...
...
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