Found more JSON properties to change into JavaScript camelCase

This commit is contained in:
the-djmaze 2023-01-26 10:41:55 +01:00
parent b9ef8ae2c9
commit 974350ebee
45 changed files with 361 additions and 412 deletions

View file

@ -29,7 +29,7 @@ export class AccountPopupView extends AbstractViewPopup {
submitForm(form) {
if (!this.submitRequest() && form.reportValidity()) {
const data = new FormData(form);
data.set('New', this.isNew() ? 1 : 0);
data.set('new', this.isNew() ? 1 : 0);
this.submitRequest(true);
Remote.request('AccountSetup', (iError, data) => {
this.submitRequest(false);

View file

@ -1482,7 +1482,7 @@ export class ComposePopupView extends AbstractViewPopup {
signature.body = await OpenPGPUserStore.sign(data.toString(), sign[1], 1);
signed.children.push(signature);
params.signed = signed.toString();
params.Boundary = signed.boundary;
params.boundary = signed.boundary;
data = signed;
} else if ('gnupg' == sign[0]) {
// TODO: sign in PHP fails

View file

@ -104,10 +104,10 @@ export class ContactsPopupView extends AbstractViewPopup {
const contacts = this.contactsCheckedOrSelected();
if (contacts.length) {
let selectorContact = this.selectorContact(),
Uids = [],
uids = [],
count = 0;
contacts.forEach(contact => {
Uids.push(contact.id());
uids.push(contact.id());
if (selectorContact && selectorContact.id() === contact.id()) {
this.selectorContact(selectorContact = null);
}
@ -127,7 +127,7 @@ export class ContactsPopupView extends AbstractViewPopup {
}
this.reloadContactList();
}, {
Uids: Uids.join(',')
uids: uids.join(',')
}
);
}

View file

@ -14,13 +14,64 @@ import { AskPopupView } from 'View/Popup/Ask';
const
capitalize = string => string.charAt(0).toUpperCase() + string.slice(1),
domainDefaults = {
enableSmartPorts: false,
savingError: '',
name: '',
imapHost: '',
imapPort: 143,
imapType: 0,
imapTimeout: 300,
imapShortLogin: false,
// SSL
imapSslVerify_peer: false,
imapSslAllow_self_signed: false,
// Options
imapDisable_list_status: false,
imapDisable_metadata: false,
imapDisable_move: false,
imapDisable_sort: false,
imapDisable_thread: false,
imapExpunge_all_on_delete: false,
imapFast_simple_search: true,
imapFetch_new_messages: true,
imapForce_select: false,
imapFolder_list_limit: 200,
imapMessage_all_headers: false,
imapMessage_list_limit: 0,
imapSearch_filter: '',
sieveEnabled: false,
sieveHost: '',
sievePort: 4190,
sieveType: 0,
sieveTimeout: 10,
smtpHost: '',
smtpPort: 25,
smtpType: 0,
smtpTimeout: 60,
smtpShortLogin: false,
smtpUseAuth: true,
smtpSetSender: false,
smtpUsePhpMail: false,
// SSL
smtpSslVerify_peer: false,
smtpSslAllow_self_signed: false,
whiteList: '',
aliasName: ''
},
domainToParams = oDomain => ({
Name: oDomain.name(),
name: oDomain.name,
IMAP: {
host: oDomain.imapHost(),
port: oDomain.imapPort(),
host: oDomain.imapHost,
port: oDomain.imapPort,
secure: pInt(oDomain.imapType()),
timeout: oDomain.imapTimeout(),
timeout: oDomain.imapTimeout,
shortLogin: !!oDomain.imapShortLogin(),
ssl: {
verify_peer: !!oDomain.imapSslVerify_peer(),
@ -44,10 +95,10 @@ const
*/
},
SMTP: {
host: oDomain.smtpHost(),
port: oDomain.smtpPort(),
host: oDomain.smtpHost,
port: oDomain.smtpPort,
secure: pInt(oDomain.smtpType()),
timeout: oDomain.smtpTimeout(),
timeout: oDomain.smtpTimeout,
shortLogin: !!oDomain.smtpShortLogin(),
ssl: {
verify_peer: !!oDomain.smtpSslVerify_peer(),
@ -60,10 +111,10 @@ const
},
Sieve: {
enabled: !!oDomain.sieveEnabled(),
host: oDomain.sieveHost(),
port: oDomain.sievePort(),
host: oDomain.sieveHost,
port: oDomain.sievePort,
secure: pInt(oDomain.sieveType()),
timeout: oDomain.sieveTimeout(),
timeout: oDomain.sieveTimeout,
shortLogin: !!oDomain.imapShortLogin(),
ssl: {
verify_peer: !!oDomain.imapSslVerify_peer(),
@ -71,14 +122,14 @@ const
allow_self_signed: !!oDomain.imapSslAllow_self_signed()
}
},
whiteList: oDomain.whiteList()
whiteList: oDomain.whiteList
});
export class DomainPopupView extends AbstractViewPopup {
constructor() {
super('Domain');
addObservablesTo(this, this.getDefaults());
addObservablesTo(this, domainDefaults);
addObservablesTo(this, {
edit: false,
@ -99,21 +150,11 @@ export class DomainPopupView extends AbstractViewPopup {
headerText: () => {
const name = this.name(),
aliasName = this.aliasName();
let result = '';
if (this.edit()) {
result = i18n('POPUPS_DOMAIN/TITLE_EDIT_DOMAIN', { NAME: name });
if (aliasName) {
result += ' ⫘ ' + aliasName;
}
} else {
result = name
? i18n('POPUPS_DOMAIN/TITLE_ADD_DOMAIN_WITH_NAME', { NAME: name })
: i18n('POPUPS_DOMAIN/TITLE_ADD_DOMAIN');
}
return result;
return this.edit()
? i18n('POPUPS_DOMAIN/TITLE_EDIT_DOMAIN', { NAME: name }) + (aliasName ? ' ⫘ ' + aliasName : '')
: (name
? i18n('POPUPS_DOMAIN/TITLE_ADD_DOMAIN_WITH_NAME', { NAME: name })
: i18n('POPUPS_DOMAIN/TITLE_ADD_DOMAIN'));
},
domainDesc: () => {
@ -213,7 +254,7 @@ export class DomainPopupView extends AbstractViewPopup {
}
},
Object.assign(domainToParams(this), {
Create: this.edit() ? 0 : 1
create: this.edit() ? 0 : 1
})
);
}
@ -260,7 +301,9 @@ export class DomainPopupView extends AbstractViewPopup {
onShow(oDomain) {
this.saving(false);
this.clearTesting();
this.clearForm();
this.edit(false);
forEachObjectEntry(domainDefaults, (key, value) => this[key](value));
this.enableSmartPorts(true);
if (oDomain) {
this.enableSmartPorts(false);
this.edit(true);
@ -284,64 +327,4 @@ export class DomainPopupView extends AbstractViewPopup {
this.enableSmartPorts(true);
}
}
getDefaults() {
return {
enableSmartPorts: false,
savingError: '',
name: '',
imapHost: '',
imapPort: 143,
imapType: 0,
imapTimeout: 300,
imapShortLogin: false,
// SSL
imapSslVerify_peer: false,
imapSslAllow_self_signed: false,
// Options
imapDisable_list_status: false,
imapDisable_metadata: false,
imapDisable_move: false,
imapDisable_sort: false,
imapDisable_thread: false,
imapExpunge_all_on_delete: false,
imapFast_simple_search: true,
imapFetch_new_messages: true,
imapForce_select: false,
imapFolder_list_limit: 200,
imapMessage_all_headers: false,
imapMessage_list_limit: 0,
imapSearch_filter: '',
sieveEnabled: false,
sieveHost: '',
sievePort: 4190,
sieveType: 0,
sieveTimeout: 10,
smtpHost: '',
smtpPort: 25,
smtpType: 0,
smtpTimeout: 60,
smtpShortLogin: false,
smtpUseAuth: true,
smtpSetSender: false,
smtpUsePhpMail: false,
// SSL
smtpSslVerify_peer: false,
smtpSslAllow_self_signed: false,
whiteList: '',
aliasName: ''
};
}
clearForm() {
this.edit(false);
forEachObjectEntry(this.getDefaults(), (key, value) => this[key](value));
this.enableSmartPorts(true);
}
}

View file

@ -46,21 +46,15 @@ export class DomainAliasPopupView extends AbstractViewPopup {
this.close();
}
}, {
Name: this.name(),
Alias: this.alias()
name: this.name,
alias: this.alias
});
}
onShow() {
this.clearForm();
}
clearForm() {
this.saving(false);
this.savingError('');
this.name('');
this.alias('');
}
}

View file

@ -41,19 +41,19 @@ export class PluginPopupView extends AbstractViewPopup {
saveCommand() {
const oConfig = {
Id: this.id(),
Settings: {}
id: this.id,
settings: {}
},
setItem = item => {
let value = item.value();
if (false === value || true === value) {
value = value ? 1 : 0;
}
oConfig.Settings[item.Name] = value;
oConfig.settings[item.name] = value;
};
this.config.forEach(oItem => {
if (7 == oItem.Type) {
if (7 == oItem.type) {
// Group
oItem.config.forEach(oSubItem => setItem(oSubItem));
} else {
@ -76,15 +76,15 @@ export class PluginPopupView extends AbstractViewPopup {
this.config([]);
if (oPlugin) {
this.id(oPlugin.Id);
this.name(oPlugin.Name);
this.readme(oPlugin.Readme);
this.id(oPlugin.id);
this.name(oPlugin.name);
this.readme(oPlugin.readme);
const config = oPlugin.Config;
const config = oPlugin.config;
if (arrayLength(config)) {
this.config(
config.map(item => {
if (7 == item.Type) {
if (7 == item.type) {
// Group
item.config.forEach(subItem => {
subItem.value = ko.observable(subItem.value);

View file

@ -13,11 +13,11 @@ import { doc,
} from 'Common/Globals';
import { arrayLength } from 'Common/Utils';
import { computedPaginatorHelper, showMessageComposer, populateMessageBody, download, moveAction } from 'Common/UtilsUser';
import { computedPaginatorHelper, showMessageComposer, populateMessageBody, downloadZip, moveAction } from 'Common/UtilsUser';
import { FileInfo } from 'Common/File';
import { isFullscreen, toggleFullscreen } from 'Common/Fullscreen';
import { mailBox, attachmentDownload } from 'Common/Links';
import { mailBox } from 'Common/Links';
import { Selector } from 'Common/Selector';
import { i18n } from 'Common/Translator';
@ -367,23 +367,7 @@ export class MailMessageList extends AbstractViewRight {
let hashes = []/*, uids = []*/;
// MessagelistUserStore.forEach(message => message.checked() && uids.push(message.uid));
MessagelistUserStore.forEach(message => message.checked() && hashes.push(message.requestHash));
if (hashes.length) {
Remote.post('AttachmentsActions', null, {
Do: 'Zip',
folder: MessagelistUserStore().folder,
// Uids: uids,
Hashes: hashes
})
.then(result => {
let hash = result?.Result?.fileHash;
if (hash) {
download(attachmentDownload(hash), hash+'.zip');
} else {
alert('Download failed');
}
})
.catch(() => alert('Download failed'));
}
downloadZip(hashes, null, null, MessagelistUserStore().folder);
}
downloadAttachCommand() {
@ -397,21 +381,7 @@ export class MailMessageList extends AbstractViewRight {
});
}
});
if (hashes.length) {
Remote.post('AttachmentsActions', null, {
Do: 'Zip',
Hashes: hashes
})
.then(result => {
let hash = result?.Result?.fileHash;
if (hash) {
download(attachmentDownload(hash), hash+'.zip');
} else {
alert('Download failed');
}
})
.catch(() => alert('Download failed'));
}
downloadZip(hashes);
}
deleteWithoutMoveCommand() {
@ -505,8 +475,8 @@ export class MailMessageList extends AbstractViewRight {
Remote.request('MessageSetSeenToAll', null, {
folder: sFolderFullName,
SetAction: 1,
ThreadUids: uids.join(',')
setAction: 1,
threadUids: uids.join(',')
});
MessagelistUserStore.reloadFlagsAndCachedMessage();

View file

@ -23,13 +23,12 @@ import {
} from 'Common/Globals';
import { arrayLength } from 'Common/Utils';
import { download, mailToHelper, showMessageComposer, moveAction } from 'Common/UtilsUser';
import { download, downloadZip, mailToHelper, showMessageComposer, moveAction } from 'Common/UtilsUser';
import { isFullscreen, exitFullscreen, toggleFullscreen } from 'Common/Fullscreen';
import { SMAudio } from 'Common/Audio';
import { i18n } from 'Common/Translator';
import { attachmentDownload } from 'Common/Links';
import { MessageFlagsCache } from 'Common/Cache';
@ -486,21 +485,10 @@ export class MailMessageView extends AbstractViewRight {
const hashes = (currentMessage()?.attachments || [])
.map(item => item?.checked() /*&& !item?.isLinked()*/ ? item.download : '')
.filter(v => v);
if (hashes.length) {
Remote.post('AttachmentsActions', this.downloadAsZipLoading, {
Do: 'Zip',
Hashes: hashes
})
.then(result => {
let hash = result?.Result?.fileHash;
if (hash) {
download(attachmentDownload(hash), hash+'.zip');
} else {
this.downloadAsZipError(true);
}
})
.catch(() => this.downloadAsZipError(true));
}
downloadZip(hashes,
() => this.downloadAsZipError(true),
this.downloadAsZipLoading
);
}
/**