prettier --write

This commit is contained in:
RainLoop Team 2019-07-04 22:19:24 +03:00
parent 450528ff00
commit 8a0be3212d
164 changed files with 7053 additions and 9008 deletions

View file

@ -1,4 +1,3 @@
import window from 'window';
import $ from '$';
import _ from '_';
@ -7,19 +6,31 @@ import key from 'key';
import ssm from 'ssm';
import {
$win, $html, $doc,
startMicrotime, leftPanelDisabled, leftPanelType,
sUserAgent, bMobileDevice, bAnimationSupported
$win,
$html,
$doc,
startMicrotime,
leftPanelDisabled,
leftPanelType,
sUserAgent,
bMobileDevice,
bAnimationSupported
} from 'Common/Globals';
import {
noop, isNormal, pString, inArray, microtime, timestamp,
detectDropdownVisibility, windowResizeCallback
noop,
isNormal,
pString,
inArray,
microtime,
timestamp,
detectDropdownVisibility,
windowResizeCallback
} from 'Common/Utils';
import {KeyState, Magics} from 'Common/Enums';
import {root, rootAdmin, rootUser, populateAuthSuffix} from 'Common/Links';
import {initOnStartOrLangChange, initNotificationLanguage} from 'Common/Translator';
import { KeyState, Magics } from 'Common/Enums';
import { root, rootAdmin, rootUser, populateAuthSuffix } from 'Common/Links';
import { initOnStartOrLangChange, initNotificationLanguage } from 'Common/Translator';
import * as Events from 'Common/Events';
import * as Settings from 'Storage/Settings';
@ -27,16 +38,14 @@ import LanguageStore from 'Stores/Language';
import ThemeStore from 'Stores/Theme';
import SocialStore from 'Stores/Social';
import {routeOff, setHash} from 'Knoin/Knoin';
import {AbstractBoot} from 'Knoin/AbstractBoot';
import { routeOff, setHash } from 'Knoin/Knoin';
import { AbstractBoot } from 'Knoin/AbstractBoot';
class AbstractApp extends AbstractBoot
{
class AbstractApp extends AbstractBoot {
/**
* @param {RemoteStorage|AdminRemoteStorage} Remote
*/
constructor(Remote)
{
constructor(Remote) {
super();
this.googlePreviewSupportedCache = null;
@ -47,14 +56,15 @@ class AbstractApp extends AbstractBoot
this.iframe = $('<iframe class="internal-hiddden" />').appendTo('body');
$win.on('error', (event) => {
if (event && event.originalEvent && event.originalEvent.message &&
-1 === inArray(event.originalEvent.message, [
'Script error.', 'Uncaught Error: Error calling method on NPObject.'
]))
{
if (
event &&
event.originalEvent &&
event.originalEvent.message &&
-1 ===
inArray(event.originalEvent.message, ['Script error.', 'Uncaught Error: Error calling method on NPObject.'])
) {
const time = timestamp();
if (this.lastErrorTime >= time)
{
if (this.lastErrorTime >= time) {
return;
}
@ -76,19 +86,20 @@ class AbstractApp extends AbstractBoot
Events.pub('window.resize');
});
Events.sub('window.resize', _.throttle(() => {
const
iH = $win.height(),
iW = $win.height();
Events.sub(
'window.resize',
_.throttle(() => {
const iH = $win.height(),
iW = $win.height();
if ($win.__sizes[0] !== iH || $win.__sizes[1] !== iW)
{
$win.__sizes[0] = iH;
$win.__sizes[1] = iW;
if ($win.__sizes[0] !== iH || $win.__sizes[1] !== iW) {
$win.__sizes[0] = iH;
$win.__sizes[1] = iW;
Events.pub('window.resize.real');
}
}, Magics.Time50ms));
Events.pub('window.resize.real');
}
}, Magics.Time50ms)
);
// DEBUG
// Events.sub({
@ -100,21 +111,24 @@ class AbstractApp extends AbstractBoot
// }
// });
$doc.on('keydown', (event) => {
if (event && event.ctrlKey)
{
$html.addClass('rl-ctrl-key-pressed');
}
}).on('keyup', (event) => {
if (event && !event.ctrlKey)
{
$html.removeClass('rl-ctrl-key-pressed');
}
});
$doc
.on('keydown', (event) => {
if (event && event.ctrlKey) {
$html.addClass('rl-ctrl-key-pressed');
}
})
.on('keyup', (event) => {
if (event && !event.ctrlKey) {
$html.removeClass('rl-ctrl-key-pressed');
}
});
$doc.on('mousemove keypress click', _.debounce(() => {
Events.pub('rl.auto-logout-refresh');
}, Magics.Time5s));
$doc.on(
'mousemove keypress click',
_.debounce(() => {
Events.pub('rl.auto-logout-refresh');
}, Magics.Time5s)
);
key('esc, enter', KeyState.All, () => {
detectDropdownVisibility();
@ -138,17 +152,13 @@ class AbstractApp extends AbstractBoot
* @returns {boolean}
*/
download(link) {
if (sUserAgent && (-1 < sUserAgent.indexOf('chrome') || -1 < sUserAgent.indexOf('chrome')))
{
if (sUserAgent && (-1 < sUserAgent.indexOf('chrome') || -1 < sUserAgent.indexOf('chrome'))) {
const oLink = window.document.createElement('a');
oLink.href = link;
if (window.document && window.document.createEvent)
{
if (window.document && window.document.createEvent) {
const oE = window.document.createEvent.MouseEvents;
if (oE && oE.initEvent && oLink.dispatchEvent)
{
if (oE && oE.initEvent && oLink.dispatchEvent) {
oE.initEvent('click', true, true);
oLink.dispatchEvent(oE);
return true;
@ -156,13 +166,10 @@ class AbstractApp extends AbstractBoot
}
}
if (bMobileDevice)
{
if (bMobileDevice) {
window.open(link, '_self');
window.focus();
}
else
{
} else {
this.iframe.attr('src', link);
// window.document.location.href = link;
}
@ -174,10 +181,9 @@ class AbstractApp extends AbstractBoot
* @returns {boolean}
*/
googlePreviewSupported() {
if (null === this.googlePreviewSupportedCache)
{
this.googlePreviewSupportedCache = !!Settings.settingsGet('AllowGoogleSocial') &&
!!Settings.settingsGet('AllowGoogleSocialPreview');
if (null === this.googlePreviewSupportedCache) {
this.googlePreviewSupportedCache =
!!Settings.settingsGet('AllowGoogleSocial') && !!Settings.settingsGet('AllowGoogleSocialPreview');
}
return this.googlePreviewSupportedCache;
@ -187,9 +193,8 @@ class AbstractApp extends AbstractBoot
* @param {string} title
*/
setWindowTitle(title) {
title = ((isNormal(title) && 0 < title.length) ? '' + title : '');
if (Settings.settingsGet('Title'))
{
title = isNormal(title) && 0 < title.length ? '' + title : '';
if (Settings.settingsGet('Title')) {
title += (title ? ' - ' : '') + Settings.settingsGet('Title');
}
@ -204,8 +209,7 @@ class AbstractApp extends AbstractBoot
}
clearClientSideToken() {
if (window.__rlah_clear)
{
if (window.__rlah_clear) {
window.__rlah_clear();
}
}
@ -214,8 +218,7 @@ class AbstractApp extends AbstractBoot
* @param {string} token
*/
setClientSideToken(token) {
if (window.__rlah_set)
{
if (window.__rlah_set) {
window.__rlah_set(token);
Settings.settingsSet('AuthAccountHash', token);
@ -229,58 +232,42 @@ class AbstractApp extends AbstractBoot
* @param {boolean=} close = false
*/
loginAndLogoutReload(admin = false, logout = false, close = false) {
const inIframe = !!Settings.appSettingsGet('inIframe');
let customLogoutLink = pString(Settings.appSettingsGet('customLogoutLink'));
if (logout)
{
if (logout) {
this.clearClientSideToken();
}
if (logout && close && window.close)
{
if (logout && close && window.close) {
window.close();
}
customLogoutLink = customLogoutLink || (admin ? rootAdmin() : rootUser());
if (logout && window.location.href !== customLogoutLink)
{
if (logout && window.location.href !== customLogoutLink) {
_.delay(() => {
if (inIframe && window.parent)
{
if (inIframe && window.parent) {
window.parent.location.href = customLogoutLink;
}
else
{
} else {
window.location.href = customLogoutLink;
}
$win.trigger('rl.tooltips.diactivate');
}, Magics.Time100ms);
}
else
{
} else {
routeOff();
setHash(root(), true);
routeOff();
_.delay(() => {
if (inIframe && window.parent)
{
if (inIframe && window.parent) {
window.parent.location.reload();
}
else
{
} else {
window.location.reload();
}
$win.trigger('rl.tooltips.diactivate');
}, Magics.Time100ms);
}
}
@ -290,7 +277,6 @@ class AbstractApp extends AbstractBoot
}
bootstart() {
// log('Ps' + 'ss, hac' + 'kers! The' + 're\'s not' + 'hing inte' + 'resting :' + ')');
Events.pub('rl.bootstart');
@ -307,13 +293,10 @@ class AbstractApp extends AbstractBoot
ko.components.register('x-script', require('Component/Script').default);
// ko.components.register('svg-icon', require('Component/SvgIcon').default);
if (Settings.appSettingsGet('materialDesign') && bAnimationSupported)
{
if (Settings.appSettingsGet('materialDesign') && bAnimationSupported) {
ko.components.register('Checkbox', require('Component/MaterialDesign/Checkbox').default);
ko.components.register('CheckboxSimple', require('Component/Checkbox').default);
}
else
{
} else {
// ko.components.register('Checkbox', require('Component/Classic/Checkbox').default);
// ko.components.register('CheckboxSimple', require('Component/Classic/Checkbox').default);
ko.components.register('Checkbox', require('Component/Checkbox').default);
@ -332,8 +315,7 @@ class AbstractApp extends AbstractBoot
leftPanelDisabled(false);
});
if (!mobile)
{
if (!mobile) {
$html.addClass('rl-desktop');
ssm.addState({
@ -381,9 +363,7 @@ class AbstractApp extends AbstractBoot
$html.removeClass('ssm-state-desktop-large');
}
});
}
else
{
} else {
$html.addClass('ssm-state-mobile').addClass('rl-mobile');
Events.pub('ssm.mobile-enter');
}
@ -406,4 +386,4 @@ class AbstractApp extends AbstractBoot
}
}
export {AbstractApp, AbstractApp as default};
export { AbstractApp, AbstractApp as default };

View file

@ -1,13 +1,12 @@
import window from 'window';
import _ from '_';
import ko from 'ko';
import progressJs from 'progressJs';
import {root} from 'Common/Links';
import {getNotification} from 'Common/Translator';
import {StorageResultType, Notification} from 'Common/Enums';
import {pInt, isNormal, isArray, inArray, isUnd} from 'Common/Utils';
import { root } from 'Common/Links';
import { getNotification } from 'Common/Translator';
import { StorageResultType, Notification } from 'Common/Enums';
import { pInt, isNormal, isArray, inArray, isUnd } from 'Common/Utils';
import * as Settings from 'Storage/Settings';
@ -20,14 +19,13 @@ import PackageStore from 'Stores/Admin/Package';
import CoreStore from 'Stores/Admin/Core';
import Remote from 'Remote/Admin/Ajax';
import {SettingsAdminScreen} from 'Screen/Admin/Settings';
import {LoginAdminScreen} from 'Screen/Admin/Login';
import { SettingsAdminScreen } from 'Screen/Admin/Settings';
import { LoginAdminScreen } from 'Screen/Admin/Login';
import {hideLoading, routeOff, setHash, startScreens} from 'Knoin/Knoin';
import {AbstractApp} from 'App/Abstract';
import { hideLoading, routeOff, setHash, startScreens } from 'Knoin/Knoin';
import { AbstractApp } from 'App/Abstract';
class AdminApp extends AbstractApp
{
class AdminApp extends AbstractApp {
constructor() {
super(Remote);
}
@ -40,14 +38,15 @@ class AdminApp extends AbstractApp
DomainStore.domains.loading(true);
Remote.domainList((result, data) => {
DomainStore.domains.loading(false);
if (StorageResultType.Success === result && data && data.Result)
{
DomainStore.domains(_.map(data.Result, ([enabled, alias], name) => ({
name: name,
disabled: ko.observable(!enabled),
alias: alias,
deleteAccess: ko.observable(false)
})));
if (StorageResultType.Success === result && data && data.Result) {
DomainStore.domains(
_.map(data.Result, ([enabled, alias], name) => ({
name: name,
disabled: ko.observable(!enabled),
alias: alias,
deleteAccess: ko.observable(false)
}))
);
}
});
}
@ -56,13 +55,14 @@ class AdminApp extends AbstractApp
PluginStore.plugins.loading(true);
Remote.pluginList((result, data) => {
PluginStore.plugins.loading(false);
if (StorageResultType.Success === result && data && data.Result)
{
PluginStore.plugins(_.map(data.Result, (item) => ({
name: item.Name,
disabled: ko.observable(!item.Enabled),
configured: ko.observable(!!item.Configured)
})));
if (StorageResultType.Success === result && data && data.Result) {
PluginStore.plugins(
_.map(data.Result, (item) => ({
name: item.Name,
disabled: ko.observable(!item.Enabled),
configured: ko.observable(!!item.Configured)
}))
);
}
});
}
@ -72,8 +72,7 @@ class AdminApp extends AbstractApp
PackageStore.packagesReal(true);
Remote.packagesList((result, data) => {
PackageStore.packages.loading(false);
if (StorageResultType.Success === result && data && data.Result)
{
if (StorageResultType.Success === result && data && data.Result) {
PackageStore.packagesReal(!!data.Result.Real);
PackageStore.packagesMainUpdatable(!!data.Result.MainUpdatable);
@ -81,28 +80,25 @@ class AdminApp extends AbstractApp
const loading = {};
_.each(PackageStore.packages(), (item) => {
if (item && item.loading())
{
if (item && item.loading()) {
loading[item.file] = item;
}
});
if (isArray(data.Result.List))
{
list = _.compact(_.map(data.Result.List, (item) => {
if (item)
{
item.loading = ko.observable(!isUnd(loading[item.file]));
return 'core' === item.type && !item.canBeInstalled ? null : item;
}
return null;
}));
if (isArray(data.Result.List)) {
list = _.compact(
_.map(data.Result.List, (item) => {
if (item) {
item.loading = ko.observable(!isUnd(loading[item.file]));
return 'core' === item.type && !item.canBeInstalled ? null : item;
}
return null;
})
);
}
PackageStore.packages(list);
}
else
{
} else {
PackageStore.packagesReal(false);
}
});
@ -116,13 +112,10 @@ class AdminApp extends AbstractApp
CoreStore.coreRemoteVersion('');
CoreStore.coreRemoteRelease('');
CoreStore.coreVersionCompare(-2);
if (StorageResultType.Success === result && data && data.Result)
{
if (StorageResultType.Success === result && data && data.Result) {
CoreStore.coreReal(true);
window.location.reload();
}
else
{
} else {
CoreStore.coreReal(false);
}
});
@ -133,8 +126,7 @@ class AdminApp extends AbstractApp
CoreStore.coreReal(true);
Remote.coreData((result, data) => {
CoreStore.coreChecking(false);
if (StorageResultType.Success === result && data && data.Result)
{
if (StorageResultType.Success === result && data && data.Result) {
CoreStore.coreReal(!!data.Result.Real);
CoreStore.coreChannel(data.Result.Channel || 'stable');
CoreStore.coreType(data.Result.Type || 'stable');
@ -145,9 +137,7 @@ class AdminApp extends AbstractApp
CoreStore.coreRemoteVersion(data.Result.RemoteVersion || '');
CoreStore.coreRemoteRelease(data.Result.RemoteRelease || '');
CoreStore.coreVersionCompare(pInt(data.Result.VersionCompare));
}
else
{
} else {
CoreStore.coreReal(false);
CoreStore.coreChannel('stable');
CoreStore.coreType('stable');
@ -168,33 +158,25 @@ class AdminApp extends AbstractApp
LicenseStore.licenseError('');
Remote.licensing((result, data) => {
LicenseStore.licensingProcess(false);
if (StorageResultType.Success === result && data && data.Result && isNormal(data.Result.Expired))
{
if (StorageResultType.Success === result && data && data.Result && isNormal(data.Result.Expired)) {
LicenseStore.licenseValid(true);
LicenseStore.licenseExpired(pInt(data.Result.Expired));
LicenseStore.licenseError('');
LicenseStore.licensing(true);
AppStore.prem(true);
}
else
{
if (data && data.ErrorCode && -1 < inArray(pInt(data.ErrorCode), [
Notification.LicensingServerIsUnavailable,
Notification.LicensingExpired
]))
{
} else {
if (
data &&
data.ErrorCode &&
-1 < inArray(pInt(data.ErrorCode), [Notification.LicensingServerIsUnavailable, Notification.LicensingExpired])
) {
LicenseStore.licenseError(getNotification(pInt(data.ErrorCode)));
LicenseStore.licensing(true);
}
else
{
if (StorageResultType.Abort === result)
{
} else {
if (StorageResultType.Abort === result) {
LicenseStore.licenseError(getNotification(Notification.LicensingServerIsUnavailable));
LicenseStore.licensing(true);
}
else
{
} else {
LicenseStore.licensing(false);
}
}
@ -203,19 +185,16 @@ class AdminApp extends AbstractApp
}
bootend(bootendCallback = null) {
if (progressJs)
{
if (progressJs) {
progressJs.end();
}
if (bootendCallback)
{
if (bootendCallback) {
bootendCallback();
}
}
bootstart() {
super.bootstart();
AppStore.populate();
@ -223,8 +202,7 @@ class AdminApp extends AbstractApp
hideLoading();
if (!Settings.appSettingsGet('allowAdminPanel'))
{
if (!Settings.appSettingsGet('allowAdminPanel')) {
routeOff();
setHash(root(), true);
routeOff();
@ -232,20 +210,11 @@ class AdminApp extends AbstractApp
_.defer(() => {
window.location.href = '/';
});
}
else
{
if (Settings.settingsGet('Auth'))
{
startScreens([
SettingsAdminScreen
]);
}
else
{
startScreens([
LoginAdminScreen
]);
} else {
if (Settings.settingsGet('Auth')) {
startScreens([SettingsAdminScreen]);
} else {
startScreens([LoginAdminScreen]);
}
}

File diff suppressed because it is too large Load diff