mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-30 20:49:20 +03:00
Added "Attachment size limit" setting (Admin panel) (#114)
This commit is contained in:
parent
40a0f8b821
commit
0b5e4f534d
14 changed files with 387 additions and 224 deletions
|
|
@ -6,7 +6,7 @@
|
|||
function AdminGeneral()
|
||||
{
|
||||
var oData = RL.data();
|
||||
|
||||
|
||||
this.mainLanguage = oData.mainLanguage;
|
||||
this.mainTheme = oData.mainTheme;
|
||||
|
||||
|
|
@ -18,7 +18,16 @@ function AdminGeneral()
|
|||
this.capaGravatar = oData.capaGravatar;
|
||||
this.capaAdditionalAccounts = oData.capaAdditionalAccounts;
|
||||
this.capaAdditionalIdentities = oData.capaAdditionalIdentities;
|
||||
|
||||
|
||||
this.mainAttachmentLimit = ko.observable(Utils.pInt(RL.settingsGet('AttachmentLimit')) / (1024 * 1024)).extend({'posInterer': 25});
|
||||
this.uploadData = RL.settingsGet('PhpUploadSizes');
|
||||
this.uploadDataDesc = this.uploadData && (this.uploadData['upload_max_filesize'] || this.uploadData['post_max_size']) ?
|
||||
[
|
||||
this.uploadData['upload_max_filesize'] ? 'upload_max_filesize = ' + this.uploadData['upload_max_filesize'] + '; ' : '',
|
||||
this.uploadData['post_max_size'] ? 'post_max_size = ' + this.uploadData['post_max_size'] : ''
|
||||
].join('')
|
||||
: '';
|
||||
|
||||
this.themesOptions = ko.computed(function () {
|
||||
return _.map(oData.themes(), function (sTheme) {
|
||||
return {
|
||||
|
|
@ -31,9 +40,10 @@ function AdminGeneral()
|
|||
this.mainLanguageFullName = ko.computed(function () {
|
||||
return Utils.convertLangName(this.mainLanguage());
|
||||
}, this);
|
||||
|
||||
|
||||
this.weakPassword = !!RL.settingsGet('WeakPassword');
|
||||
|
||||
|
||||
this.attachmentLimitTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
|
||||
this.languageTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
|
||||
this.themeTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
|
||||
}
|
||||
|
|
@ -46,10 +56,17 @@ AdminGeneral.prototype.onBuild = function ()
|
|||
_.delay(function () {
|
||||
|
||||
var
|
||||
f1 = Utils.settingsSaveHelperSimpleFunction(self.attachmentLimitTrigger, self),
|
||||
f2 = Utils.settingsSaveHelperSimpleFunction(self.languageTrigger, self),
|
||||
f3 = Utils.settingsSaveHelperSimpleFunction(self.themeTrigger, self)
|
||||
;
|
||||
|
||||
self.mainAttachmentLimit.subscribe(function (sValue) {
|
||||
RL.remote().saveAdminConfig(f1, {
|
||||
'AttachmentLimit': Utils.pInt(sValue)
|
||||
});
|
||||
});
|
||||
|
||||
self.language.subscribe(function (sValue) {
|
||||
RL.remote().saveAdminConfig(f2, {
|
||||
'Language': Utils.trim(sValue)
|
||||
|
|
@ -61,7 +78,7 @@ AdminGeneral.prototype.onBuild = function ()
|
|||
'Theme': Utils.trim(sValue)
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
self.capaAdditionalAccounts.subscribe(function (bValue) {
|
||||
RL.remote().saveAdminConfig(null, {
|
||||
'CapaAdditionalAccounts': bValue ? '1' : '0'
|
||||
|
|
@ -99,3 +116,12 @@ AdminGeneral.prototype.selectLanguage = function ()
|
|||
{
|
||||
kn.showScreenPopup(PopupsLanguagesViewModel);
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
AdminGeneral.prototype.phpInfoLink = function ()
|
||||
{
|
||||
return RL.link().phpInfo();
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -722,6 +722,30 @@ ko.extenders.trimmer = function (oTarget)
|
|||
return oResult;
|
||||
};
|
||||
|
||||
ko.extenders.posInterer = function (oTarget, iDefault)
|
||||
{
|
||||
var oResult = ko.computed({
|
||||
'read': oTarget,
|
||||
'write': function (sNewValue) {
|
||||
var iNew = Utils.pInt(sNewValue.toString(), iDefault);
|
||||
if (0 >= iNew)
|
||||
{
|
||||
iNew = iDefault;
|
||||
}
|
||||
|
||||
if (iNew === oTarget() && '' + iNew !== '' + sNewValue)
|
||||
{
|
||||
oTarget(iNew + 1);
|
||||
}
|
||||
|
||||
oTarget(iNew);
|
||||
}
|
||||
});
|
||||
|
||||
oResult(oTarget());
|
||||
return oResult;
|
||||
};
|
||||
|
||||
ko.extenders.reversible = function (oTarget)
|
||||
{
|
||||
var mValue = oTarget();
|
||||
|
|
|
|||
|
|
@ -46,11 +46,13 @@ Utils.isPosNumeric = function (mValue, bIncludeZero)
|
|||
|
||||
/**
|
||||
* @param {*} iValue
|
||||
* @param {number=} iDefault = 0
|
||||
* @return {number}
|
||||
*/
|
||||
Utils.pInt = function (iValue)
|
||||
Utils.pInt = function (iValue, iDefault)
|
||||
{
|
||||
return Utils.isNormal(iValue) && '' !== iValue ? window.parseInt(iValue, 10) : 0;
|
||||
var iResult = Utils.isNormal(iValue) && '' !== iValue ? window.parseInt(iValue, 10) : (iDefault || 0);
|
||||
return window.isNaN(iResult) ? (iDefault || 0) : iResult;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
function PopupsDomainViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsDomain');
|
||||
|
||||
|
||||
this.edit = ko.observable(false);
|
||||
this.saving = ko.observable(false);
|
||||
this.savingError = ko.observable('');
|
||||
|
|
@ -19,14 +19,14 @@ function PopupsDomainViewModel()
|
|||
this.testingSmtpError = ko.observable(false);
|
||||
this.testingImapErrorDesc = ko.observable('');
|
||||
this.testingSmtpErrorDesc = ko.observable('');
|
||||
|
||||
|
||||
this.testingImapError.subscribe(function (bValue) {
|
||||
if (!bValue)
|
||||
{
|
||||
this.testingImapErrorDesc('');
|
||||
}
|
||||
}, this);
|
||||
|
||||
|
||||
this.testingSmtpError.subscribe(function (bValue) {
|
||||
if (!bValue)
|
||||
{
|
||||
|
|
@ -44,11 +44,11 @@ function PopupsDomainViewModel()
|
|||
this.name.focused = ko.observable(false);
|
||||
|
||||
this.imapServer = ko.observable('');
|
||||
this.imapPort = ko.observable(Consts.Values.ImapDefaulPort);
|
||||
this.imapPort = ko.observable('' + Consts.Values.ImapDefaulPort);
|
||||
this.imapSecure = ko.observable(Enums.ServerSecure.None);
|
||||
this.imapShortLogin = ko.observable(false);
|
||||
this.smtpServer = ko.observable('');
|
||||
this.smtpPort = ko.observable(Consts.Values.SmtpDefaulPort);
|
||||
this.smtpPort = ko.observable('' + Consts.Values.SmtpDefaulPort);
|
||||
this.smtpSecure = ko.observable(Enums.ServerSecure.None);
|
||||
this.smtpShortLogin = ko.observable(false);
|
||||
this.smtpAuth = ko.observable(true);
|
||||
|
|
@ -83,11 +83,11 @@ function PopupsDomainViewModel()
|
|||
!this.edit(),
|
||||
this.name(),
|
||||
this.imapServer(),
|
||||
this.imapPort(),
|
||||
Utils.pInt(this.imapPort()),
|
||||
this.imapSecure(),
|
||||
this.imapShortLogin(),
|
||||
this.smtpServer(),
|
||||
this.smtpPort(),
|
||||
Utils.pInt(this.smtpPort()),
|
||||
this.smtpSecure(),
|
||||
this.smtpShortLogin(),
|
||||
this.smtpAuth(),
|
||||
|
|
@ -105,10 +105,10 @@ function PopupsDomainViewModel()
|
|||
_.bind(this.onTestConnectionResponse, this),
|
||||
this.name(),
|
||||
this.imapServer(),
|
||||
this.imapPort(),
|
||||
Utils.pInt(this.imapPort()),
|
||||
this.imapSecure(),
|
||||
this.smtpServer(),
|
||||
this.smtpPort(),
|
||||
Utils.pInt(this.smtpPort()),
|
||||
this.smtpSecure(),
|
||||
this.smtpAuth()
|
||||
);
|
||||
|
|
@ -132,7 +132,7 @@ function PopupsDomainViewModel()
|
|||
this.smtpServer(this.imapServer().replace(/imap/ig, 'smtp'));
|
||||
}
|
||||
}, this);
|
||||
|
||||
|
||||
this.imapSecure.subscribe(function (sValue) {
|
||||
var iPort = Utils.pInt(this.imapPort());
|
||||
sValue = Utils.pString(sValue);
|
||||
|
|
@ -141,13 +141,13 @@ function PopupsDomainViewModel()
|
|||
case '0':
|
||||
if (993 === iPort)
|
||||
{
|
||||
this.imapPort(143);
|
||||
this.imapPort('143');
|
||||
}
|
||||
break;
|
||||
case '1':
|
||||
if (143 === iPort)
|
||||
{
|
||||
this.imapPort(993);
|
||||
this.imapPort('993');
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -161,19 +161,19 @@ function PopupsDomainViewModel()
|
|||
case '0':
|
||||
if (465 === iPort || 587 === iPort)
|
||||
{
|
||||
this.smtpPort(25);
|
||||
this.smtpPort('25');
|
||||
}
|
||||
break;
|
||||
case '1':
|
||||
if (25 === iPort || 587 === iPort)
|
||||
{
|
||||
this.smtpPort(465);
|
||||
this.smtpPort('465');
|
||||
}
|
||||
break;
|
||||
case '2':
|
||||
if (25 === iPort || 465 === iPort)
|
||||
{
|
||||
this.smtpPort(587);
|
||||
this.smtpPort('587');
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -253,11 +253,11 @@ PopupsDomainViewModel.prototype.onShow = function (oDomain)
|
|||
|
||||
this.name(Utils.trim(oDomain.Name));
|
||||
this.imapServer(Utils.trim(oDomain.IncHost));
|
||||
this.imapPort(Utils.pInt(oDomain.IncPort));
|
||||
this.imapPort('' + Utils.pInt(oDomain.IncPort));
|
||||
this.imapSecure(Utils.trim(oDomain.IncSecure));
|
||||
this.imapShortLogin(!!oDomain.IncShortLogin);
|
||||
this.smtpServer(Utils.trim(oDomain.OutHost));
|
||||
this.smtpPort(Utils.pInt(oDomain.OutPort));
|
||||
this.smtpPort('' + Utils.pInt(oDomain.OutPort));
|
||||
this.smtpSecure(Utils.trim(oDomain.OutSecure));
|
||||
this.smtpShortLogin(!!oDomain.OutShortLogin);
|
||||
this.smtpAuth(!!oDomain.OutAuth);
|
||||
|
|
@ -277,18 +277,18 @@ PopupsDomainViewModel.prototype.clearForm = function ()
|
|||
{
|
||||
this.edit(false);
|
||||
this.whiteListPage(false);
|
||||
|
||||
|
||||
this.savingError('');
|
||||
|
||||
this.name('');
|
||||
this.name.focused(false);
|
||||
|
||||
this.imapServer('');
|
||||
this.imapPort(Consts.Values.ImapDefaulPort);
|
||||
this.imapPort('' + Consts.Values.ImapDefaulPort);
|
||||
this.imapSecure(Enums.ServerSecure.None);
|
||||
this.imapShortLogin(false);
|
||||
this.smtpServer('');
|
||||
this.smtpPort(Consts.Values.SmtpDefaulPort);
|
||||
this.smtpPort('' + Consts.Values.SmtpDefaulPort);
|
||||
this.smtpSecure(Enums.ServerSecure.None);
|
||||
this.smtpShortLogin(false);
|
||||
this.smtpAuth(true);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue