-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
220 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export const useKeys = () => { | ||
return useAsyncData<{ keys: BKey[] }>("keys", () => $fetch("/backend/keys"), { | ||
default() { | ||
return { keys: [] }; | ||
}, | ||
}); | ||
}; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<script setup lang="ts"> | ||
definePageMeta({ | ||
middleware: ["auth"], | ||
}); | ||
const columns = [ | ||
{ | ||
key: "display_name", | ||
label: "Name", | ||
}, | ||
{ | ||
key: "id", | ||
label: "Fingerprint", | ||
}, | ||
{ | ||
key: "actions", | ||
}, | ||
]; | ||
const { data: keys, refresh: refreshKeys } = await useKeys(); | ||
const deletionWorking = ref(false); | ||
async function deleteKey(id: string) { | ||
if (!confirm("Are you sure you want to delete this key?")) { | ||
return; | ||
} | ||
deletionWorking.value = true; | ||
try { | ||
await $fetch("/backend/keys/delete", { | ||
method: "POST", | ||
body: JSON.stringify({ id }), | ||
}); | ||
} catch (e: any) { | ||
handleError(e); | ||
} finally { | ||
deletionWorking.value = false; | ||
} | ||
refreshKeys(); | ||
} | ||
</script> | ||
|
||
<template> | ||
<SkeletonDashboard title-name="SSH Keys" title-icon="i-mdi-key-chain"> | ||
<div class="mb-4"> | ||
<UButton | ||
:to="{ name: 'dashboard-profile-keys-new' }" | ||
icon="i-mdi-plus" | ||
label="Add SSH Key" | ||
></UButton> | ||
</div> | ||
<UTable :rows="keys.keys" :columns="columns"> | ||
<template #actions-data="{ row }"> | ||
<UButton | ||
variant="link" | ||
color="red" | ||
icon="i-mdi-trash" | ||
label="Delete" | ||
@click="deleteKey(row.id)" | ||
></UButton> | ||
</template> | ||
</UTable> | ||
</SkeletonDashboard> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<script setup lang="ts"> | ||
import type { FormError, FormSubmitEvent } from "#ui/types"; | ||
definePageMeta({ | ||
middleware: ["auth"], | ||
}); | ||
const state = reactive({ | ||
display_name: undefined, | ||
public_key: undefined, | ||
}); | ||
const validate = (state: any): FormError[] => { | ||
const errors = []; | ||
if (!state.display_name) | ||
errors.push({ path: "display_name", message: "Required" }); | ||
if (!state.public_key) | ||
errors.push({ path: "public_key", message: "Required" }); | ||
return errors; | ||
}; | ||
const working = ref(false); | ||
async function onSubmit(event: FormSubmitEvent<any>) { | ||
working.value = true; | ||
try { | ||
await $fetch("/backend/keys/create", { | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify(event.data), | ||
}); | ||
navigateTo({ name: "dashboard-profile-keys" }); | ||
} catch (e: any) { | ||
handleError(e); | ||
} finally { | ||
working.value = false; | ||
} | ||
} | ||
</script> | ||
|
||
<template> | ||
<SkeletonDashboard title-name="SSH Keys" title-icon="i-mdi-key-chain"> | ||
<UForm | ||
:validate="validate" | ||
:state="state" | ||
class="space-y-4 w-80" | ||
@submit="onSubmit" | ||
> | ||
<UFormGroup label="Display Name" name="display_name"> | ||
<UInput v-model="state.display_name" /> | ||
</UFormGroup> | ||
|
||
<UFormGroup label="Public Key" name="public_key"> | ||
<UTextarea v-model="state.public_key" :rows="12" /> | ||
</UFormGroup> | ||
|
||
<UButton | ||
type="submit" | ||
:disabled="working" | ||
:loading="working" | ||
icon="i-mdi-check" | ||
label="Submit" | ||
> | ||
</UButton> | ||
</UForm> | ||
</SkeletonDashboard> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters