2016-10-18 19:20:51 -07:00
|
|
|
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
|
|
|
//
|
|
|
|
// This software (Documize Community Edition) is licensed under
|
|
|
|
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
|
|
|
//
|
|
|
|
// You can operate outside the AGPL restrictions by purchasing
|
|
|
|
// Documize Enterprise Edition and obtaining a commercial license
|
|
|
|
// by contacting <sales@documize.com>.
|
|
|
|
//
|
|
|
|
// https://documize.com
|
|
|
|
|
2018-01-22 10:31:03 +00:00
|
|
|
import $ from 'jquery';
|
2017-11-16 13:28:05 +00:00
|
|
|
import { empty } from '@ember/object/computed';
|
2018-06-05 14:04:14 +01:00
|
|
|
import Notifier from '../../mixins/notifier';
|
2017-11-16 13:28:05 +00:00
|
|
|
import Component from '@ember/component';
|
2016-10-18 19:20:51 -07:00
|
|
|
|
2018-06-05 14:04:14 +01:00
|
|
|
export default Component.extend(Notifier, {
|
2017-11-16 13:28:05 +00:00
|
|
|
SMTPHostEmptyError: empty('model.smtp.host'),
|
|
|
|
SMTPPortEmptyError: empty('model.smtp.port'),
|
|
|
|
SMTPSenderEmptyError: empty('model.smtp.sender'),
|
2018-03-07 18:52:19 +00:00
|
|
|
senderNameError: empty('model.smtp.senderName'),
|
|
|
|
|
|
|
|
buttonText: 'Save & Test',
|
|
|
|
testSMTP: null,
|
2016-10-18 19:20:51 -07:00
|
|
|
|
|
|
|
actions: {
|
2017-02-22 20:03:40 -08:00
|
|
|
saveSMTP() {
|
2016-10-18 19:20:51 -07:00
|
|
|
if (this.get('SMTPHostEmptyError')) {
|
|
|
|
$("#smtp-host").focus();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (this.get('SMTPPortEmptyError')) {
|
|
|
|
$("#smtp-port").focus();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (this.get('SMTPSenderEmptyError')) {
|
|
|
|
$("#smtp-sender").focus();
|
|
|
|
return;
|
|
|
|
}
|
2018-03-07 18:52:19 +00:00
|
|
|
if (this.get('senderNameError')) {
|
|
|
|
$("#smtp-senderName").focus();
|
2016-10-18 19:20:51 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-03-07 18:52:19 +00:00
|
|
|
this.set('testSMTP', {
|
|
|
|
success: true,
|
|
|
|
message: ''
|
|
|
|
},
|
|
|
|
);
|
|
|
|
|
|
|
|
this.set('buttonText', 'Please wait...');
|
|
|
|
|
|
|
|
this.get('saveSMTP')().then((result) => {
|
2018-12-05 13:44:10 +00:00
|
|
|
this.notifySuccess('Saved');
|
2018-03-07 18:52:19 +00:00
|
|
|
this.set('buttonText', 'Save & Test');
|
|
|
|
this.set('testSMTP', result);
|
2017-02-22 20:03:40 -08:00
|
|
|
});
|
2016-10-18 19:20:51 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|