[feat][apiKey] apiKey only on create is shown. Can be copied

This commit is contained in:
Tim Gröger 2024-10-15 08:27:14 +02:00
parent 6a738dc77e
commit c03fa689ba
1 changed files with 28 additions and 3 deletions

View File

@ -10,8 +10,27 @@
@click="$emit('delete', apiKey)"
/>
</q-card-section>
<q-card-section
v-if="apiKey.token"
class="fit row justify-start content-center items-center q-gutter-sm"
>
<q-input class="col" outlined label="API Key" :model-value="apiKey.token" />
<div class="row justify-end content-end items-end">
<q-btn color="primary" icon="mdi-content-copy" round @click="copyApiKey" />
</div>
<q-banner class="fit bg-primary text-white" inline dense rounded>
ApiKey wird nur einmalig angezeigt. Bitte kopieren!
</q-banner>
</q-card-section>
<q-card-section class="fit row justify-start content-center items-center q-gutter-sm">
<q-input class="fit" type="textarea" outlined label="Description" readonly />
<q-input
class="fit"
type="textarea"
outlined
label="Description"
readonly
:model-value="apiKey.description"
/>
</q-card-section>
</q-card>
</template>
@ -28,8 +47,14 @@ export default defineComponent({
emits: {
delete: (apiKey: FG.ApiKey) => !!apiKey,
},
setup() {
return {};
setup(props) {
async function copyApiKey() {
await navigator.clipboard.writeText(<string>props.apiKey.token);
console.log('copying api key', props.apiKey.token);
}
return {
copyApiKey,
};
},
});
</script>