mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-30 04:29:21 +03:00
es5 -> es2015 (last stage)
Signature plugin fixes Add view decorator A large number of fixes
This commit is contained in:
parent
e88c193334
commit
17669b7be0
153 changed files with 21193 additions and 21115 deletions
|
|
@ -1,141 +1,131 @@
|
|||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
import ko from 'ko';
|
||||
import _ from '_';
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
Translator = require('Common/Translator'),
|
||||
import {
|
||||
trim, createCommand,
|
||||
triggerAutocompleteInputChange
|
||||
} from 'Common/Utils';
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
Remote = require('Remote/Admin/Ajax'),
|
||||
import {StorageResultType, Notification, Magics} from 'Common/Enums';
|
||||
import {getNotification} from 'Common/Translator';
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
import * as Settings from 'Storage/Settings';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function LoginAdminView()
|
||||
import Remote from 'Remote/Admin/Ajax';
|
||||
|
||||
import {getApp} from 'Helper/Apps/Admin';
|
||||
|
||||
import {view, ViewType, routeOff} from 'Knoin/Knoin';
|
||||
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||
|
||||
@view({
|
||||
name: 'View/Admin/Login',
|
||||
type: ViewType.Center,
|
||||
templateID: 'AdminLogin'
|
||||
})
|
||||
class LoginAdminView extends AbstractViewNext
|
||||
{
|
||||
AbstractView.call(this, 'Center', 'AdminLogin');
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.logoPowered = !!Settings.settingsGet('LoginPowered');
|
||||
this.logoPowered = !!Settings.settingsGet('LoginPowered');
|
||||
|
||||
this.mobile = !!Settings.appSettingsGet('mobile');
|
||||
this.mobileDevice = !!Settings.appSettingsGet('mobileDevice');
|
||||
this.mobile = !!Settings.appSettingsGet('mobile');
|
||||
this.mobileDevice = !!Settings.appSettingsGet('mobileDevice');
|
||||
|
||||
this.login = ko.observable('');
|
||||
this.password = ko.observable('');
|
||||
this.login = ko.observable('');
|
||||
this.password = ko.observable('');
|
||||
|
||||
this.loginError = ko.observable(false);
|
||||
this.passwordError = ko.observable(false);
|
||||
this.loginError = ko.observable(false);
|
||||
this.passwordError = ko.observable(false);
|
||||
|
||||
this.loginErrorAnimation = ko.observable(false).extend({'falseTimeout': 500});
|
||||
this.passwordErrorAnimation = ko.observable(false).extend({'falseTimeout': 500});
|
||||
this.loginErrorAnimation = ko.observable(false).extend({'falseTimeout': 500});
|
||||
this.passwordErrorAnimation = ko.observable(false).extend({'falseTimeout': 500});
|
||||
|
||||
this.loginFocus = ko.observable(false);
|
||||
this.loginFocus = ko.observable(false);
|
||||
|
||||
this.formHidden = ko.observable(false);
|
||||
this.formHidden = ko.observable(false);
|
||||
|
||||
this.formError = ko.computed(function() {
|
||||
return this.loginErrorAnimation() || this.passwordErrorAnimation();
|
||||
}, this);
|
||||
this.formError = ko.computed(() => this.loginErrorAnimation() || this.passwordErrorAnimation());
|
||||
|
||||
this.login.subscribe(function() {
|
||||
this.loginError(false);
|
||||
}, this);
|
||||
this.login.subscribe(() => this.loginError(false));
|
||||
|
||||
this.password.subscribe(function() {
|
||||
this.passwordError(false);
|
||||
}, this);
|
||||
this.password.subscribe(() => this.passwordError(false));
|
||||
|
||||
this.loginError.subscribe(function(bV) {
|
||||
this.loginErrorAnimation(!!bV);
|
||||
}, this);
|
||||
this.loginError.subscribe((v) => this.loginErrorAnimation(!!v));
|
||||
|
||||
this.passwordError.subscribe(function(bV) {
|
||||
this.passwordErrorAnimation(!!bV);
|
||||
}, this);
|
||||
this.passwordError.subscribe((v) => {
|
||||
this.passwordErrorAnimation(!!v);
|
||||
});
|
||||
|
||||
this.submitRequest = ko.observable(false);
|
||||
this.submitError = ko.observable('');
|
||||
this.submitRequest = ko.observable(false);
|
||||
this.submitError = ko.observable('');
|
||||
|
||||
this.submitCommand = Utils.createCommand(this, function() {
|
||||
this.submitCommand = createCommand(() => {
|
||||
|
||||
Utils.triggerAutocompleteInputChange();
|
||||
triggerAutocompleteInputChange();
|
||||
|
||||
this.loginError(false);
|
||||
this.passwordError(false);
|
||||
this.loginError(false);
|
||||
this.passwordError(false);
|
||||
|
||||
this.loginError('' === Utils.trim(this.login()));
|
||||
this.passwordError('' === Utils.trim(this.password()));
|
||||
this.loginError('' === trim(this.login()));
|
||||
this.passwordError('' === trim(this.password()));
|
||||
|
||||
if (this.loginError() || this.passwordError())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
this.submitRequest(true);
|
||||
|
||||
Remote.adminLogin(_.bind(function(sResult, oData) {
|
||||
|
||||
if (Enums.StorageResultType.Success === sResult && oData && 'AdminLogin' === oData.Action)
|
||||
if (this.loginError() || this.passwordError())
|
||||
{
|
||||
if (oData.Result)
|
||||
return false;
|
||||
}
|
||||
|
||||
this.submitRequest(true);
|
||||
|
||||
Remote.adminLogin((sResult, oData) => {
|
||||
|
||||
if (StorageResultType.Success === sResult && oData && 'AdminLogin' === oData.Action)
|
||||
{
|
||||
require('App/Admin').default.loginAndLogoutReload(true);
|
||||
if (oData.Result)
|
||||
{
|
||||
getApp().loginAndLogoutReload(true);
|
||||
}
|
||||
else if (oData.ErrorCode)
|
||||
{
|
||||
this.submitRequest(false);
|
||||
this.submitError(getNotification(oData.ErrorCode));
|
||||
}
|
||||
}
|
||||
else if (oData.ErrorCode)
|
||||
else
|
||||
{
|
||||
this.submitRequest(false);
|
||||
this.submitError(Translator.getNotification(oData.ErrorCode));
|
||||
this.submitError(getNotification(Notification.UnknownError));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.submitRequest(false);
|
||||
this.submitError(Translator.getNotification(Enums.Notification.UnknownError));
|
||||
}
|
||||
|
||||
}, this), this.login(), this.password());
|
||||
}, this.login(), this.password());
|
||||
|
||||
return true;
|
||||
return true;
|
||||
|
||||
}, function() {
|
||||
return !this.submitRequest();
|
||||
});
|
||||
}, () => !this.submitRequest());
|
||||
}
|
||||
|
||||
kn.constructorEnd(this);
|
||||
onShow() {
|
||||
|
||||
routeOff();
|
||||
|
||||
_.delay(() => {
|
||||
this.loginFocus(true);
|
||||
}, Magics.Time100ms);
|
||||
}
|
||||
|
||||
onHide() {
|
||||
this.loginFocus(false);
|
||||
}
|
||||
|
||||
onBuild() {
|
||||
triggerAutocompleteInputChange(true);
|
||||
}
|
||||
|
||||
submitForm() {
|
||||
this.submitCommand();
|
||||
}
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Admin/Login', 'AdminLoginViewModel'], LoginAdminView);
|
||||
_.extend(LoginAdminView.prototype, AbstractView.prototype);
|
||||
|
||||
LoginAdminView.prototype.onShow = function()
|
||||
{
|
||||
kn.routeOff();
|
||||
|
||||
_.delay(_.bind(function() {
|
||||
this.loginFocus(true);
|
||||
}, this), Enums.Magics.Time100ms);
|
||||
|
||||
};
|
||||
|
||||
LoginAdminView.prototype.onHide = function()
|
||||
{
|
||||
this.loginFocus(false);
|
||||
};
|
||||
|
||||
LoginAdminView.prototype.onBuild = function()
|
||||
{
|
||||
Utils.triggerAutocompleteInputChange(true);
|
||||
};
|
||||
|
||||
LoginAdminView.prototype.submitForm = function()
|
||||
{
|
||||
this.submitCommand();
|
||||
};
|
||||
|
||||
module.exports = LoginAdminView;
|
||||
export {LoginAdminView, LoginAdminView as default};
|
||||
|
|
|
|||
|
|
@ -1,69 +1,66 @@
|
|||
|
||||
var
|
||||
_ = require('_'),
|
||||
$ = require('$'),
|
||||
key = require('key'),
|
||||
import _ from '_';
|
||||
import $ from '$';
|
||||
import key from 'key';
|
||||
|
||||
Globals = require('Common/Globals'),
|
||||
Enums = require('Common/Enums'),
|
||||
import {leftPanelDisabled} from 'Common/Globals';
|
||||
import {Magics} from 'Common/Enums';
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
import {view, ViewType, setHash} from 'Knoin/Knoin';
|
||||
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param {?} oScreen
|
||||
*
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function MenuSettingsAdminView(oScreen)
|
||||
@view({
|
||||
name: 'View/Admin/Settings/Menu',
|
||||
type: ViewType.Left,
|
||||
templateID: 'AdminMenu'
|
||||
})
|
||||
class MenuSettingsAdminView extends AbstractViewNext
|
||||
{
|
||||
AbstractView.call(this, 'Left', 'AdminMenu');
|
||||
/**
|
||||
* @param {?} screen
|
||||
*/
|
||||
constructor(screen) {
|
||||
|
||||
this.leftPanelDisabled = Globals.leftPanelDisabled;
|
||||
super();
|
||||
|
||||
this.menu = oScreen.menu;
|
||||
this.leftPanelDisabled = leftPanelDisabled;
|
||||
|
||||
kn.constructorEnd(this);
|
||||
this.menu = screen.menu;
|
||||
}
|
||||
|
||||
link(route) {
|
||||
return '#/' + route;
|
||||
}
|
||||
|
||||
onBuild(dom) {
|
||||
|
||||
key('up, down', _.throttle((event, handler) => {
|
||||
|
||||
const
|
||||
up = handler && 'up' === handler.shortcut,
|
||||
$items = $('.b-admin-menu .e-item', dom);
|
||||
|
||||
if (event && $items.length)
|
||||
{
|
||||
let index = $items.index($items.filter('.selected'));
|
||||
if (up && 0 < index)
|
||||
{
|
||||
index -= 1;
|
||||
}
|
||||
else if (!up && index < $items.length - 1)
|
||||
{
|
||||
index += 1;
|
||||
}
|
||||
|
||||
const sH = $items.eq(index).attr('href');
|
||||
if (sH)
|
||||
{
|
||||
setHash(sH, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
}, Magics.Time200ms));
|
||||
}
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Admin/Settings/Menu', 'AdminSettingsMenuViewModel'], MenuSettingsAdminView);
|
||||
_.extend(MenuSettingsAdminView.prototype, AbstractView.prototype);
|
||||
|
||||
MenuSettingsAdminView.prototype.link = function(sRoute)
|
||||
{
|
||||
return '#/' + sRoute;
|
||||
};
|
||||
|
||||
MenuSettingsAdminView.prototype.onBuild = function(oDom)
|
||||
{
|
||||
key('up, down', _.throttle(function(event, handler) {
|
||||
|
||||
var
|
||||
sH = '',
|
||||
bUp = handler && 'up' === handler.shortcut,
|
||||
$items = $('.b-admin-menu .e-item', oDom);
|
||||
|
||||
if (event && $items.length)
|
||||
{
|
||||
var index = $items.index($items.filter('.selected'));
|
||||
if (bUp && 0 < index)
|
||||
{
|
||||
index -= 1;
|
||||
}
|
||||
else if (!bUp && index < $items.length - 1)
|
||||
{
|
||||
index += 1;
|
||||
}
|
||||
|
||||
sH = $items.eq(index).attr('href');
|
||||
if (sH)
|
||||
{
|
||||
kn.setHash(sH, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
}, Enums.Magics.Time200ms));
|
||||
};
|
||||
|
||||
module.exports = MenuSettingsAdminView;
|
||||
export {MenuSettingsAdminView, MenuSettingsAdminView as default};
|
||||
|
|
|
|||
|
|
@ -1,51 +1,55 @@
|
|||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
/* global RL_COMMUNITY */
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
Remote = require('Remote/Admin/Ajax'),
|
||||
import ko from 'ko';
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
import * as Settings from 'Storage/Settings';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function PaneSettingsAdminView()
|
||||
import Remote from 'Remote/Admin/Ajax';
|
||||
|
||||
import DomainStore from 'Stores/Admin/Domain';
|
||||
import PluginStore from 'Stores/Admin/Plugin';
|
||||
import PackageStore from 'Stores/Admin/Package';
|
||||
|
||||
import {getApp} from 'Helper/Apps/Admin';
|
||||
|
||||
import {view, ViewType} from 'Knoin/Knoin';
|
||||
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||
|
||||
@view({
|
||||
name: 'View/Admin/Settings/Pane',
|
||||
type: ViewType.Right,
|
||||
templateID: 'AdminPane'
|
||||
})
|
||||
class PaneSettingsAdminView extends AbstractViewNext
|
||||
{
|
||||
AbstractView.call(this, 'Right', 'AdminPane');
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.adminDomain = ko.observable(Settings.settingsGet('AdminDomain'));
|
||||
this.version = ko.observable(Settings.appSettingsGet('version'));
|
||||
this.adminDomain = ko.observable(Settings.settingsGet('AdminDomain'));
|
||||
this.version = ko.observable(Settings.appSettingsGet('version'));
|
||||
|
||||
this.capa = !!Settings.settingsGet('PremType');
|
||||
this.community = RL_COMMUNITY;
|
||||
this.capa = !!Settings.settingsGet('PremType');
|
||||
this.community = RL_COMMUNITY;
|
||||
|
||||
this.adminManLoading = ko.computed(function() {
|
||||
return '000' !== [
|
||||
require('Stores/Admin/Domain').domains.loading() ? '1' : '0',
|
||||
require('Stores/Admin/Plugin').plugins.loading() ? '1' : '0',
|
||||
require('Stores/Admin/Package').packages.loading() ? '1' : '0'
|
||||
].join('');
|
||||
}, this);
|
||||
this.adminManLoading = ko.computed(
|
||||
() => '000' !== [
|
||||
DomainStore.domains.loading() ? '1' : '0',
|
||||
PluginStore.plugins.loading() ? '1' : '0',
|
||||
PackageStore.packages.loading() ? '1' : '0'
|
||||
].join('')
|
||||
);
|
||||
|
||||
this.adminManLoadingVisibility = ko.computed(function() {
|
||||
return this.adminManLoading() ? 'visible' : 'hidden';
|
||||
}, this).extend({'rateLimit': 300});
|
||||
this.adminManLoadingVisibility = ko.computed(
|
||||
() => (this.adminManLoading() ? 'visible' : 'hidden')
|
||||
).extend({rateLimit: 300});
|
||||
}
|
||||
|
||||
kn.constructorEnd(this);
|
||||
logoutClick() {
|
||||
Remote.adminLogout(() => {
|
||||
getApp().loginAndLogoutReload(true, true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Admin/Settings/Pane', 'AdminSettingsPaneViewModel'], PaneSettingsAdminView);
|
||||
_.extend(PaneSettingsAdminView.prototype, AbstractView.prototype);
|
||||
|
||||
PaneSettingsAdminView.prototype.logoutClick = function()
|
||||
{
|
||||
Remote.adminLogout(function() {
|
||||
require('App/Admin').default.loginAndLogoutReload(true, true);
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = PaneSettingsAdminView;
|
||||
export {PaneSettingsAdminView, PaneSettingsAdminView as default};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue