Improve admin UI (#2802)

This commit is contained in:
MeiMei 2018-10-02 23:42:46 +09:00 committed by syuilo
parent 7e50e03cfb
commit 7d11c8b767
8 changed files with 91 additions and 37 deletions

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="qldxjjsrseehkusjuoooapmsprvfrxyl mk-admin-card"> <div class="qldxjjsrseehkusjuoooapmsprvfrxyl mk-admin-card">
<header>%i18n:@announcements%</header> <header>%i18n:@announcements%</header>
<textarea v-model="broadcasts"></textarea> <textarea v-model="broadcasts" placeholder='[ { "title": "Title1", "text": "Text1" }, { "title": "Title2", "text": "Text2" } ]'></textarea>
<button class="ui" @click="save">%i18n:@save%</button> <button class="ui" @click="save">%i18n:@save%</button>
</div> </div>
</template> </template>
@ -22,8 +22,21 @@ export default Vue.extend({
}, },
methods: { methods: {
save() { save() {
let json;
try {
json = JSON.parse(this.broadcasts);
} catch (e) {
(this as any).os.apis.dialog({ text: `Failed: ${e}` });
return;
}
(this as any).api('admin/update-meta', { (this as any).api('admin/update-meta', {
broadcasts: JSON.parse(this.broadcasts) broadcasts: json
}).then(() => {
(this as any).os.apis.dialog({ text: `Saved` });
}.catch(e => {
(this as any).os.apis.dialog({ text: `Failed ${e}` });
}); });
} }
} }

View File

@ -13,7 +13,7 @@
<x-cpu-memory :connection="connection"/> <x-cpu-memory :connection="connection"/>
</div> </div>
<div class="form"> <div v-if="this.$store.state.i && this.$store.state.i.isAdmin" class="form">
<div> <div>
<label> <label>
<p>%i18n:@banner-url%</p> <p>%i18n:@banner-url%</p>
@ -81,6 +81,8 @@ export default Vue.extend({
invite() { invite() {
(this as any).api('admin/invite').then(x => { (this as any).api('admin/invite').then(x => {
this.inviteCode = x.code; this.inviteCode = x.code;
}).catch(e => {
(this as any).os.apis.dialog({ text: `Failed ${e}` });
}); });
}, },
updateMeta() { updateMeta() {
@ -88,6 +90,10 @@ export default Vue.extend({
disableRegistration: this.disableRegistration, disableRegistration: this.disableRegistration,
disableLocalTimeline: this.disableLocalTimeline, disableLocalTimeline: this.disableLocalTimeline,
bannerUrl: this.bannerUrl bannerUrl: this.bannerUrl
}).then(() => {
(this as any).os.apis.dialog({ text: `Saved` });
}).catch(e => {
(this as any).os.apis.dialog({ text: `Failed ${e}` });
}); });
} }
} }

View File

@ -24,6 +24,10 @@ export default Vue.extend({
save() { save() {
(this as any).api('admin/update-meta', { (this as any).api('admin/update-meta', {
hidedTags: this.hidedTags.split('\n') hidedTags: this.hidedTags.split('\n')
}).then(() => {
(this as any).os.apis.dialog({ text: `Saved` });
}).catch(e => {
(this as any).os.apis.dialog({ text: `Failed ${e}` });
}); });
} }
} }

View File

@ -21,6 +21,7 @@ export default Vue.extend({
async suspendUser() { async suspendUser() {
this.suspending = true; this.suspending = true;
const process = async () => {
const user = await (this as any).os.api( const user = await (this as any).os.api(
"users/show", "users/show",
parseAcct(this.username) parseAcct(this.username)
@ -30,9 +31,14 @@ export default Vue.extend({
userId: user.id userId: user.id
}); });
this.suspending = false;
(this as any).os.apis.dialog({ text: "%i18n:@suspended%" }); (this as any).os.apis.dialog({ text: "%i18n:@suspended%" });
};
await process().catch(e => {
(this as any).os.apis.dialog({ text: `Failed: ${e}` });
});
this.suspending = false;
} }
} }
}); });

View File

@ -21,6 +21,7 @@ export default Vue.extend({
async unsuspendUser() { async unsuspendUser() {
this.unsuspending = true; this.unsuspending = true;
const process = async () => {
const user = await (this as any).os.api( const user = await (this as any).os.api(
"users/show", "users/show",
parseAcct(this.username) parseAcct(this.username)
@ -30,9 +31,15 @@ export default Vue.extend({
userId: user.id userId: user.id
}); });
(this as any).os.apis.dialog({ text: "%i18n:@unsuspended%" });
};
await process().catch(e => {
(this as any).os.apis.dialog({ text: `Failed: ${e}` });
});
this.unsuspending = false; this.unsuspending = false;
(this as any).os.apis.dialog({ text: "%i18n:@unsuspended%" });
} }
} }
}); });

View File

@ -21,6 +21,7 @@ export default Vue.extend({
async unverifyUser() { async unverifyUser() {
this.unverifying = true; this.unverifying = true;
const process = async () => {
const user = await (this as any).os.api( const user = await (this as any).os.api(
"users/show", "users/show",
parseAcct(this.username) parseAcct(this.username)
@ -30,9 +31,14 @@ export default Vue.extend({
userId: user.id userId: user.id
}); });
this.unverifying = false;
(this as any).os.apis.dialog({ text: "%i18n:@unverified%" }); (this as any).os.apis.dialog({ text: "%i18n:@unverified%" });
};
await process().catch(e => {
(this as any).os.apis.dialog({ text: `Failed: ${e}` });
});
this.unverifying = false;
} }
} }
}); });

View File

@ -21,6 +21,7 @@ export default Vue.extend({
async verifyUser() { async verifyUser() {
this.verifying = true; this.verifying = true;
const process = async () => {
const user = await (this as any).os.api( const user = await (this as any).os.api(
"users/show", "users/show",
parseAcct(this.username) parseAcct(this.username)
@ -30,9 +31,14 @@ export default Vue.extend({
userId: user.id userId: user.id
}); });
this.verifying = false;
(this as any).os.apis.dialog({ text: "%i18n:@verified%" }); (this as any).os.apis.dialog({ text: "%i18n:@verified%" });
};
await process().catch(e => {
(this as any).os.apis.dialog({ text: `Failed: ${e}` });
});
this.verifying = false;
} }
} }
}); });

View File

@ -3,9 +3,15 @@
<nav> <nav>
<ul> <ul>
<li @click="nav('dashboard')" :class="{ active: page == 'dashboard' }">%fa:chalkboard .fw%%i18n:@dashboard%</li> <li @click="nav('dashboard')" :class="{ active: page == 'dashboard' }">%fa:chalkboard .fw%%i18n:@dashboard%</li>
<li @click="nav('users')" :class="{ active: page == 'users' }">%fa:users .fw%%i18n:@users%</li>
<li @click="nav('announcements')" :class="{ active: page == 'announcements' }">%fa:broadcast-tower .fw%%i18n:@announcements%</li> <li v-if="this.$store.state.i && this.$store.state.i.isAdmin"
<li @click="nav('hashtags')" :class="{ active: page == 'hashtags' }">%fa:hashtag .fw%%i18n:@hashtags%</li> @click="nav('users')" :class="{ active: page == 'users' }">%fa:users .fw%%i18n:@users%</li>
<li v-if="this.$store.state.i && this.$store.state.i.isAdmin"
@click="nav('announcements')" :class="{ active: page == 'announcements' }">%fa:broadcast-tower .fw%%i18n:@announcements%</li>
<li v-if="this.$store.state.i && this.$store.state.i.isAdmin"
@click="nav('hashtags')" :class="{ active: page == 'hashtags' }">%fa:hashtag .fw%%i18n:@hashtags%</li>
<!-- <li @click="nav('drive')" :class="{ active: page == 'drive' }">%fa:cloud .fw%%i18n:@drive%</li> --> <!-- <li @click="nav('drive')" :class="{ active: page == 'drive' }">%fa:cloud .fw%%i18n:@drive%</li> -->
<!-- <li @click="nav('update')" :class="{ active: page == 'update' }">%i18n:@update%</li> --> <!-- <li @click="nav('update')" :class="{ active: page == 'update' }">%i18n:@update%</li> -->