From 42ac7b954da8216ca572adb82d5a354148769422 Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 5 Nov 2018 10:32:45 +0900 Subject: [PATCH] Improve admin panel usability --- locales/ja-JP.yml | 7 +++ src/client/app/admin/views/announcements.vue | 10 +++- src/client/app/admin/views/emoji.vue | 49 +++++++++++++++----- src/client/app/admin/views/instance.vue | 15 ++++-- 4 files changed, 65 insertions(+), 16 deletions(-) diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 2c5fc9c3db..4d87859d88 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -1081,6 +1081,7 @@ admin/views/instance.vue: disableLocalTimeline: "ローカルタイムラインを無効にする" invite: "招待" save: "保存" + saved: "保存しました" admin/views/charts.vue: title: "チャート" @@ -1132,10 +1133,15 @@ admin/views/emoji.vue: url: "絵文字画像URL" add: "追加" info: "50KB以下のPNG画像をおすすめします。" + added: "絵文字を登録しました" emojis: title: "絵文字一覧" update: "更新" remove: "削除" + updated: "更新しました" + remove-emoji: + are-you-sure: "「$1」を削除しますか?" + removed: "削除しました" admin/views/announcements.vue: announcements: "お知らせ" @@ -1144,6 +1150,7 @@ admin/views/announcements.vue: add: "追加" title: "タイトル" text: "内容" + saved: "保存しました" admin/views/hashtags.vue: hided-tags: "Hidden Tags" diff --git a/src/client/app/admin/views/announcements.vue b/src/client/app/admin/views/announcements.vue index 0e983c5a97..926426844d 100644 --- a/src/client/app/admin/views/announcements.vue +++ b/src/client/app/admin/views/announcements.vue @@ -54,9 +54,15 @@ export default Vue.extend({ (this as any).api('admin/update-meta', { broadcasts: this.announcements }).then(() => { - //(this as any).os.apis.dialog({ text: `Saved` }); + this.$swal({ + type: 'success', + text: '%i18n:@saved%' + }); }).catch(e => { - //(this as any).os.apis.dialog({ text: `Failed ${e}` }); + this.$swal({ + type: 'error', + text: e + }); }); } } diff --git a/src/client/app/admin/views/emoji.vue b/src/client/app/admin/views/emoji.vue index 7bcd905314..249028b22e 100644 --- a/src/client/app/admin/views/emoji.vue +++ b/src/client/app/admin/views/emoji.vue @@ -69,15 +69,22 @@ export default Vue.extend({ url: this.url, aliases: this.aliases.split(' ') }).then(() => { - //(this as any).os.apis.dialog({ text: `Added` }); + this.$swal({ + type: 'success', + text: '%i18n:@add-emoji.added%' + }); this.fetchEmojis(); }).catch(e => { - //(this as any).os.apis.dialog({ text: `Failed ${e}` }); + this.$swal({ + type: 'error', + text: e + }); }); }, fetchEmojis() { (this as any).api('admin/emoji/list').then(emojis => { + emojis.reverse(); emojis.forEach(e => e.aliases = (e.aliases || []).join(' ')); this.emojis = emojis; }); @@ -90,20 +97,40 @@ export default Vue.extend({ url: emoji.url, aliases: emoji.aliases.split(' ') }).then(() => { - //(this as any).os.apis.dialog({ text: `Updated` }); + this.$swal({ + type: 'success', + text: '%i18n:@updated%' + }); }).catch(e => { - //(this as any).os.apis.dialog({ text: `Failed ${e}` }); + this.$swal({ + type: 'error', + text: e + }); }); }, removeEmoji(emoji) { - (this as any).api('admin/emoji/remove', { - id: emoji.id - }).then(() => { - //(this as any).os.apis.dialog({ text: `Removed` }); - this.fetchEmojis(); - }).catch(e => { - //(this as any).os.apis.dialog({ text: `Failed ${e}` }); + this.$swal({ + type: 'warning', + text: '%i18n:@remove-emoji.are-you-sure%'.replace('$1', emoji.name), + showCancelButton: true + }).then(res => { + if (!res.value) return; + + (this as any).api('admin/emoji/remove', { + id: emoji.id + }).then(() => { + this.$swal({ + type: 'success', + text: '%i18n:@remove-emoji.removed%' + }); + this.fetchEmojis(); + }).catch(e => { + this.$swal({ + type: 'error', + text: e + }); + }); }); } } diff --git a/src/client/app/admin/views/instance.vue b/src/client/app/admin/views/instance.vue index e712c5c80d..85ef0a60c4 100644 --- a/src/client/app/admin/views/instance.vue +++ b/src/client/app/admin/views/instance.vue @@ -56,7 +56,10 @@ export default Vue.extend({ (this as any).api('admin/invite').then(x => { this.inviteCode = x.code; }).catch(e => { - //(this as any).os.apis.dialog({ text: `Failed ${e}` }); + this.$swal({ + type: 'error', + text: e + }); }); }, @@ -68,9 +71,15 @@ export default Vue.extend({ name: this.name, description: this.description }).then(() => { - //(this as any).os.apis.dialog({ text: `Saved` }); + this.$swal({ + type: 'success', + text: '%i18n:@saved%' + }); }).catch(e => { - //(this as any).os.apis.dialog({ text: `Failed ${e}` }); + this.$swal({ + type: 'error', + text: e + }); }); } }