2017-06-28 18:04:21 +01:00
|
|
|
import showModal from 'discourse/lib/show-modal';
|
2017-10-03 17:42:07 +08:00
|
|
|
import computed from "ember-addons/ember-computed-decorators";
|
2017-06-28 15:12:37 +01:00
|
|
|
|
|
|
|
|
export default Ember.Controller.extend({
|
2017-08-21 16:46:43 +01:00
|
|
|
modalShowing: false,
|
2017-07-18 16:17:03 +01:00
|
|
|
|
2017-10-03 17:42:07 +08:00
|
|
|
@computed('model.channels')
|
|
|
|
|
anyErrors(channels) {
|
|
|
|
|
let anyErrors = false;
|
|
|
|
|
|
|
|
|
|
channels.forEach((channel) => {
|
|
|
|
|
if (channel.error_key) {
|
2017-07-04 19:37:56 +01:00
|
|
|
anyErrors = true;
|
|
|
|
|
}
|
|
|
|
|
});
|
2017-10-03 17:42:07 +08:00
|
|
|
|
2017-07-04 19:37:56 +01:00
|
|
|
return anyErrors;
|
2017-10-03 17:42:07 +08:00
|
|
|
},
|
2017-07-04 19:37:56 +01:00
|
|
|
|
2017-06-28 18:04:21 +01:00
|
|
|
actions:{
|
2017-10-03 17:42:07 +08:00
|
|
|
createChannel() {
|
2017-08-21 16:46:43 +01:00
|
|
|
this.set('modalShowing', true);
|
2017-10-03 17:42:07 +08:00
|
|
|
|
|
|
|
|
const model = {
|
|
|
|
|
channel: this.store.createRecord('channel', { provider: this.get('model.provider.id'), data:{} }),
|
|
|
|
|
provider: this.get('model.provider')
|
|
|
|
|
};
|
|
|
|
|
|
2017-08-21 16:46:43 +01:00
|
|
|
showModal('admin-plugins-chat-edit-channel', { model: model, admin: true });
|
|
|
|
|
},
|
2017-10-03 17:42:07 +08:00
|
|
|
|
|
|
|
|
editChannel(channel) {
|
2017-08-21 16:46:43 +01:00
|
|
|
this.set('modalShowing', true);
|
2017-10-03 17:42:07 +08:00
|
|
|
|
|
|
|
|
const model = {
|
|
|
|
|
channel: channel,
|
|
|
|
|
provider: this.get('model.provider')
|
|
|
|
|
};
|
|
|
|
|
|
2017-08-21 16:46:43 +01:00
|
|
|
showModal('admin-plugins-chat-edit-channel', { model: model, admin: true });
|
|
|
|
|
},
|
2017-10-03 17:42:07 +08:00
|
|
|
|
|
|
|
|
testChannel(channel) {
|
2017-07-18 16:17:03 +01:00
|
|
|
this.set('modalShowing', true);
|
2017-10-03 17:42:07 +08:00
|
|
|
showModal('admin-plugins-chat-test', { model: { channel: channel }, admin: true });
|
2017-07-18 16:17:03 +01:00
|
|
|
},
|
2017-06-29 12:56:48 +01:00
|
|
|
|
2017-07-31 17:09:21 +01:00
|
|
|
createRule(channel){
|
|
|
|
|
this.set('modalShowing', true);
|
2017-10-03 17:42:07 +08:00
|
|
|
|
|
|
|
|
const model = {
|
|
|
|
|
rule: this.store.createRecord('rule', { channel_id: channel.id }),
|
|
|
|
|
channel: channel,
|
|
|
|
|
provider: this.get('model.provider'),
|
|
|
|
|
groups: this.get('model.groups')
|
|
|
|
|
};
|
|
|
|
|
|
2017-07-31 17:09:21 +01:00
|
|
|
showModal('admin-plugins-chat-edit-rule', { model: model, admin: true });
|
|
|
|
|
},
|
|
|
|
|
editRule(rule, channel){
|
|
|
|
|
this.set('modalShowing', true);
|
2017-10-03 17:42:07 +08:00
|
|
|
|
|
|
|
|
const model = {
|
|
|
|
|
rule: rule,
|
|
|
|
|
channel: channel,
|
|
|
|
|
provider: this.get('model.provider'),
|
|
|
|
|
groups: this.get('model.groups')
|
|
|
|
|
};
|
|
|
|
|
|
2017-07-31 17:09:21 +01:00
|
|
|
showModal('admin-plugins-chat-edit-rule', { model: model, admin: true });
|
|
|
|
|
},
|
2017-06-28 18:04:21 +01:00
|
|
|
}
|
2017-10-03 17:42:07 +08:00
|
|
|
});
|