mizzkey/src/client/app/desktop/views/pages/admin/admin.dashboard.vue

138 lines
3.3 KiB
Vue
Raw Normal View History

2018-08-13 18:05:58 +02:00
<template>
2018-08-25 08:40:22 +02:00
<div class="obdskegsannmntldydackcpzezagxqfy mk-admin-card">
2018-08-17 20:52:24 +02:00
<header>%i18n:@dashboard%</header>
2018-09-11 19:48:19 +02:00
2018-08-17 20:52:24 +02:00
<div v-if="stats" class="stats">
<div><b>%fa:user% {{ stats.originalUsersCount | number }}</b><span>%i18n:@original-users%</span></div>
2018-08-17 21:52:06 +02:00
<div><span>%fa:user% {{ stats.usersCount | number }}</span><span>%i18n:@all-users%</span></div>
2018-08-25 15:07:10 +02:00
<div><b>%fa:pencil-alt% {{ stats.originalNotesCount | number }}</b><span>%i18n:@original-notes%</span></div>
<div><span>%fa:pencil-alt% {{ stats.notesCount | number }}</span><span>%i18n:@all-notes%</span></div>
2018-08-17 21:52:06 +02:00
</div>
2018-09-11 19:48:19 +02:00
2018-08-17 21:52:06 +02:00
<div class="cpu-memory">
<x-cpu-memory :connection="connection"/>
2018-08-14 09:53:57 +02:00
</div>
2018-09-11 19:48:19 +02:00
2018-10-02 16:42:46 +02:00
<div v-if="this.$store.state.i && this.$store.state.i.isAdmin" class="form">
2018-09-20 10:21:16 +02:00
<div>
<label>
<p>%i18n:@banner-url%</p>
<input v-model="bannerUrl">
</label>
<button class="ui" @click="updateMeta">%i18n:@save%</button>
</div>
2018-09-11 19:48:19 +02:00
<div>
<label>
<input type="checkbox" v-model="disableRegistration" @change="updateMeta">
<span>%i18n:@disableRegistration%</span>
</label>
<button class="ui" @click="invite">%i18n:@invite%</button>
<p v-if="inviteCode">Code: <code>{{ inviteCode }}</code></p>
</div>
<div>
<label>
<input type="checkbox" v-model="disableLocalTimeline" @change="updateMeta">
<span>%i18n:@disableLocalTimeline%</span>
</label>
</div>
2018-08-17 12:17:23 +02:00
</div>
2018-08-13 18:05:58 +02:00
</div>
</template>
<script lang="ts">
import Vue from "vue";
2018-08-17 21:52:06 +02:00
import XCpuMemory from "./admin.cpu-memory.vue";
2018-08-13 18:05:58 +02:00
export default Vue.extend({
2018-08-17 21:52:06 +02:00
components: {
XCpuMemory
},
2018-08-13 18:05:58 +02:00
data() {
return {
2018-08-17 12:17:23 +02:00
stats: null,
disableRegistration: false,
2018-09-11 19:48:19 +02:00
disableLocalTimeline: false,
2018-09-20 10:21:16 +02:00
bannerUrl: null,
2018-08-17 21:52:06 +02:00
inviteCode: null,
connection: null,
connectionId: null
2018-08-13 18:05:58 +02:00
};
},
created() {
2018-08-17 21:52:06 +02:00
this.connection = (this as any).os.streams.serverStatsStream.getConnection();
this.connectionId = (this as any).os.streams.serverStatsStream.use();
(this as any).os.getMeta().then(meta => {
this.disableRegistration = meta.disableRegistration;
2018-09-11 19:48:19 +02:00
this.disableLocalTimeline = meta.disableLocalTimeline;
2018-09-20 10:21:16 +02:00
this.bannerUrl = meta.bannerUrl;
});
2018-08-13 18:05:58 +02:00
(this as any).api('stats').then(stats => {
this.stats = stats;
});
2018-08-17 12:17:23 +02:00
},
2018-08-17 21:52:06 +02:00
beforeDestroy() {
(this as any).os.streams.serverStatsStream.dispose(this.connectionId);
},
2018-08-17 12:17:23 +02:00
methods: {
invite() {
(this as any).api('admin/invite').then(x => {
this.inviteCode = x.code;
2018-10-02 16:42:46 +02:00
}).catch(e => {
(this as any).os.apis.dialog({ text: `Failed ${e}` });
2018-08-17 12:17:23 +02:00
});
},
updateMeta() {
(this as any).api('admin/update-meta', {
2018-09-11 19:48:19 +02:00
disableRegistration: this.disableRegistration,
2018-09-20 10:21:16 +02:00
disableLocalTimeline: this.disableLocalTimeline,
bannerUrl: this.bannerUrl
2018-10-02 16:42:46 +02:00
}).then(() => {
(this as any).os.apis.dialog({ text: `Saved` });
}).catch(e => {
(this as any).os.apis.dialog({ text: `Failed ${e}` });
});
2018-08-17 12:17:23 +02:00
}
2018-08-13 18:05:58 +02:00
}
});
</script>
2018-08-13 21:30:42 +02:00
<style lang="stylus" scoped>
2018-09-26 13:19:35 +02:00
2018-08-17 20:52:24 +02:00
.obdskegsannmntldydackcpzezagxqfy
> .stats
display flex
justify-content center
margin-bottom 16px
2018-08-17 21:52:06 +02:00
padding 16px
border solid 1px #eee
border-radius 8px
2018-08-17 20:52:24 +02:00
> div
flex 1
text-align center
2018-08-17 21:52:06 +02:00
> *:first-child
2018-08-17 20:52:24 +02:00
display block
2018-09-26 13:19:35 +02:00
color var(--primary)
2018-08-17 20:52:24 +02:00
2018-08-17 21:52:06 +02:00
> *:last-child
2018-08-17 20:52:24 +02:00
font-size 70%
> .cpu-memory
margin-bottom 16px
padding 16px
border solid 1px #eee
border-radius: 8px
2018-09-11 19:48:19 +02:00
> .form
> div
2018-09-20 10:21:16 +02:00
padding 16px
2018-09-11 19:48:19 +02:00
border-bottom solid 1px #eee
2018-08-13 21:30:42 +02:00
</style>