paricafe/packages/frontend/src/pages/settings/apps.vue

103 lines
2.4 KiB
Vue
Raw Normal View History

<template>
2023-01-05 22:40:17 -06:00
<div class="_gaps_m">
2021-11-19 04:36:12 -06:00
<FormPagination ref="list" :pagination="pagination">
<template #empty>
<div class="_fullinfo">
<img :src="infoImageUrl" class="_ghost"/>
<div>{{ i18n.ts.nothing }}</div>
</div>
</template>
<template #default="{items}">
<div class="_gaps">
2023-05-24 03:50:15 -05:00
<div v-for="token in items" :key="token.id" class="_panel" :class="$style.app">
<img v-if="token.iconUrl" :class="$style.appIcon" :src="token.iconUrl" alt=""/>
<div :class="$style.appBody">
<div :class="$style.appName">{{ token.name }}</div>
<div>{{ token.description }}</div>
<MkKeyValue oneline>
<template #key>{{ i18n.ts.installedDate }}</template>
<template #value><MkTime :time="token.createdAt"/></template>
</MkKeyValue>
<MkKeyValue oneline>
<template #key>{{ i18n.ts.lastUsedDate }}</template>
<template #value><MkTime :time="token.lastUsedAt"/></template>
</MkKeyValue>
<details>
<summary>{{ i18n.ts.details }}</summary>
<ul>
<li v-for="p in token.permission" :key="p">{{ i18n.t(`_permissions.${p}`) }}</li>
</ul>
</details>
2023-05-24 03:50:15 -05:00
<div>
<MkButton inline danger @click="revoke(token)"><i class="ti ti-trash"></i></MkButton>
</div>
2023-01-05 04:50:52 -06:00
</div>
</div>
</div>
</template>
</FormPagination>
2022-01-04 03:21:00 -06:00
</div>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import FormPagination from '@/components/MkPagination.vue';
2021-11-11 11:02:25 -06:00
import * as os from '@/os';
import { i18n } from '@/i18n';
import { definePageMetadata } from '@/scripts/page-metadata';
2023-01-05 04:50:52 -06:00
import MkKeyValue from '@/components/MkKeyValue.vue';
import MkButton from '@/components/MkButton.vue';
import { infoImageUrl } from '@/instance';
const list = ref<any>(null);
const pagination = {
endpoint: 'i/apps' as const,
limit: 100,
noPaging: true,
params: {
sort: '+lastUsedAt',
},
};
function revoke(token) {
os.api('i/revoke-token', { tokenId: token.id }).then(() => {
list.value.reload();
});
}
const headerActions = $computed(() => []);
const headerTabs = $computed(() => []);
definePageMetadata({
title: i18n.ts.installedApps,
icon: 'ti ti-plug',
});
</script>
2023-05-24 03:50:15 -05:00
<style lang="scss" module>
.app {
display: flex;
padding: 16px;
2023-05-24 03:50:15 -05:00
}
2023-05-24 03:50:15 -05:00
.appIcon {
display: block;
flex-shrink: 0;
margin: 0 12px 0 0;
width: 50px;
height: 50px;
border-radius: 8px;
}
2023-05-24 03:50:15 -05:00
.appBody {
width: calc(100% - 62px);
position: relative;
}
2023-05-24 03:50:15 -05:00
.appName {
font-weight: bold;
}
</style>