Added new admin login text input (Admin/Security)

Themes now work for admin panel too.
This commit is contained in:
RainLoop Team 2014-10-18 19:06:31 +04:00
parent 8cf8b94d39
commit adb92ba3ef
7 changed files with 162 additions and 82 deletions

View file

@ -89,6 +89,9 @@
});
self.theme.subscribe(function (sValue) {
Utils.changeTheme(sValue, self.themeTrigger);
Remote.saveAdminConfig(f3, {
'Theme': Utils.trim(sValue)
});

View file

@ -27,6 +27,7 @@
this.capaTwoFactorAuth = ko.observable(Settings.capa(Enums.Capa.TwoFactor));
this.adminLogin = ko.observable(Settings.settingsGet('AdminLogin'));
this.adminLoginError = ko.observable(false);
this.adminPassword = ko.observable('');
this.adminPasswordNew = ko.observable('');
this.adminPasswordNew2 = ko.observable('');
@ -40,6 +41,10 @@
this.adminPasswordUpdateSuccess(false);
}, this);
this.adminLogin.subscribe(function () {
this.adminLoginError(false);
}, this);
this.adminPasswordNew.subscribe(function () {
this.adminPasswordUpdateError(false);
this.adminPasswordUpdateSuccess(false);
@ -54,6 +59,12 @@
this.saveNewAdminPasswordCommand = Utils.createCommand(this, function () {
if ('' === Utils.trim(this.adminLogin()))
{
this.adminLoginError(true);
return false;
}
if (this.adminPasswordNew() !== this.adminPasswordNew2())
{
this.adminPasswordNewError(true);
@ -64,12 +75,13 @@
this.adminPasswordUpdateSuccess(false);
Remote.saveNewAdminPassword(this.onNewAdminPasswordResponse, {
'Login': this.adminLogin(),
'Password': this.adminPassword(),
'NewPassword': this.adminPasswordNew()
});
}, function () {
return '' !== this.adminPassword() && '' !== this.adminPasswordNew() && '' !== this.adminPasswordNew2();
return '' !== Utils.trim(this.adminLogin()) && '' !== this.adminPassword();
});
this.onNewAdminPasswordResponse = _.bind(this.onNewAdminPasswordResponse, this);

View file

@ -38,74 +38,7 @@
oTheme.selected(sValue === oTheme.name);
});
var
oThemeLink = $('#rlThemeLink'),
oThemeStyle = $('#rlThemeStyle'),
sUrl = oThemeLink.attr('href')
;
if (!sUrl)
{
sUrl = oThemeStyle.attr('data-href');
}
if (sUrl)
{
sUrl = sUrl.toString().replace(/\/-\/[^\/]+\/\-\//, '/-/' + sValue + '/-/');
sUrl = sUrl.toString().replace(/\/Css\/[^\/]+\/User\//, '/Css/0/User/');
if ('Json/' !== sUrl.substring(sUrl.length - 5, sUrl.length))
{
sUrl += 'Json/';
}
window.clearTimeout(self.iTimer);
self.themeTrigger(Enums.SaveSettingsStep.Animate);
if (this.oThemeAjaxRequest && this.oThemeAjaxRequest.abort)
{
this.oThemeAjaxRequest.abort();
}
this.oThemeAjaxRequest = $.ajax({
'url': sUrl,
'dataType': 'json'
}).done(function(aData) {
if (aData && Utils.isArray(aData) && 2 === aData.length)
{
if (oThemeLink && oThemeLink[0] && (!oThemeStyle || !oThemeStyle[0]))
{
oThemeStyle = $('<style id="rlThemeStyle"></style>');
oThemeLink.after(oThemeStyle);
oThemeLink.remove();
}
if (oThemeStyle && oThemeStyle[0])
{
oThemeStyle.attr('data-href', sUrl).attr('data-theme', aData[0]);
if (oThemeStyle && oThemeStyle[0] && oThemeStyle[0].styleSheet && !Utils.isUnd(oThemeStyle[0].styleSheet.cssText))
{
oThemeStyle[0].styleSheet.cssText = aData[1];
}
else
{
oThemeStyle.text(aData[1]);
}
}
self.themeTrigger(Enums.SaveSettingsStep.TrueResult);
}
}).always(function() {
self.iTimer = window.setTimeout(function () {
self.themeTrigger(Enums.SaveSettingsStep.Idle);
}, 1000);
self.oThemeAjaxRequest = null;
});
}
Utils.changeTheme(sValue, self.themeTrigger);
Remote.saveSettings(null, {
'Theme': sValue