diff --git a/assets/javascripts/admin/controllers/admin-plugins-chat-provider.js.es6 b/assets/javascripts/admin/controllers/admin-plugins-chat-provider.js.es6 index e1dd35a..5fd9341 100644 --- a/assets/javascripts/admin/controllers/admin-plugins-chat-provider.js.es6 +++ b/assets/javascripts/admin/controllers/admin-plugins-chat-provider.js.es6 @@ -37,6 +37,11 @@ export default Ember.Controller.extend({ }, showError(error_key){ bootbox.alert(I18n.t(error_key)); + }, + test(){ + this.set('modalShowing', true); + var model = {provider:this.get('model.provider'), channel:''} + showModal('admin-plugins-chat-test', { model: model, admin: true }); } } diff --git a/assets/javascripts/admin/controllers/modals/admin-plugins-chat-test.js.es6 b/assets/javascripts/admin/controllers/modals/admin-plugins-chat-test.js.es6 new file mode 100644 index 0000000..0c97dfa --- /dev/null +++ b/assets/javascripts/admin/controllers/modals/admin-plugins-chat-test.js.es6 @@ -0,0 +1,43 @@ +import ModalFunctionality from 'discourse/mixins/modal-functionality'; +import { ajax } from 'discourse/lib/ajax'; + +export default Ember.Controller.extend(ModalFunctionality, { + sendDisabled: function(){ + if(this.get('model').topic_id && this.get('model').channel){ + return false + } + return true + }.property('model.topic_id', 'model.channel'), + + actions: { + + send: function(){ + self = this; + this.set('loading', true); + ajax("/admin/plugins/chat/test", { + data: { provider: this.get('model.provider.name'), + channel: this.get('model.channel'), + topic_id: this.get('model.topic_id') + }, + type: 'POST' + }).then(function (result) { + self.set('loading', false) + self.flash(I18n.t('chat_integration.test_modal.success'), 'success'); + }, function(e) { + self.set('loading', false); + + var response = e.jqXHR.responseJSON + var error_key = 'chat_integration.test_modal.error' + debugger; + if(response['error_key']){ + error_key = response['error_key'] + } + self.flash(I18n.t(error_key), 'error'); + + }); + } + + } + + +}); \ No newline at end of file diff --git a/assets/javascripts/admin/templates/modal/admin-plugins-chat-test.hbs b/assets/javascripts/admin/templates/modal/admin-plugins-chat-test.hbs new file mode 100644 index 0000000..7f2e404 --- /dev/null +++ b/assets/javascripts/admin/templates/modal/admin-plugins-chat-test.hbs @@ -0,0 +1,54 @@ +{{#d-modal-body id="chat_integration_test_modal" title="chat_integration.test_modal.title"}} +