+ %fa:grin R% %i18n:@emojis.title%
+
+
+
+ %i18n:@add-emoji.name%
+ %i18n:@add-emoji.name-desc%
+
+
+ %i18n:@add-emoji.aliases%
+ %i18n:@add-emoji.aliases-desc%
+
+
+ %i18n:@add-emoji.url%
+
+
+ %fa:save R% %i18n:@emojis.update%
+ %fa:trash-alt R% %i18n:@emojis.remove%
+
+
+
@@ -29,16 +51,54 @@ export default Vue.extend({
name: '',
url: '',
aliases: '',
+ emojis: []
};
},
+
+ mounted() {
+ this.fetchEmojis();
+ },
+
methods: {
add() {
- (this as any).api('admin/add-emoji', {
+ (this as any).api('admin/emoji/add', {
name: this.name,
url: this.url,
aliases: this.aliases.split(' ')
}).then(() => {
(this as any).os.apis.dialog({ text: `Added` });
+ this.fetchEmojis();
+ }).catch(e => {
+ (this as any).os.apis.dialog({ text: `Failed ${e}` });
+ });
+ },
+
+ fetchEmojis() {
+ (this as any).api('admin/emoji/list').then(emojis => {
+ emojis.forEach(e => e.aliases = (e.aliases || []).join(' '));
+ this.emojis = emojis;
+ });
+ },
+
+ updateEmoji(emoji) {
+ (this as any).api('admin/emoji/update', {
+ id: emoji.id,
+ name: emoji.name,
+ url: emoji.url,
+ aliases: emoji.aliases.split(' ')
+ }).then(() => {
+ (this as any).os.apis.dialog({ text: `Updated` });
+ }).catch(e => {
+ (this as any).os.apis.dialog({ text: `Failed ${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}` });
});