",{}).bind('contextmenu', mliContextMenuOpen).addClass("contextMenu").attr("accId",acc.id).attr("accAddr",acc.address);
+ $("",{class: "idx", text: i}).appendTo(row);
+ $(" | ",{class: "", text: acc.address}).appendTo(row);
+ $(" | ",{class: "", text: acc.login}).appendTo(row);
+ $(" | ",{class: "", text: acc.module}).appendTo(row);
+ $(" | ",{class: "", text: acc.default?langPack.core.iface.yes:langPack.core.iface.no}).appendTo(row);
+ $(" | ",{class: "button", style: "text-align: center", append: $("",{class: "fas fa-ellipsis-h"})})
+ .click(mliContextMenuOpen)
+ .appendTo(row);
+ $("",{append: row}).appendTo(tx);
+ });
+
+ })
+}
+
+function mliContextMenuOpen(el) {
+ UI.contextMenuOpen(el,[
+ {title: langPack.core.iface.mailAccounts.setDefault, onClick: function() {
+ accDefault_Click(el);
+ }},
+ {title: langPack.core.iface.edit, onClick: function() {
+ accEdit_Click(el);
+ }},
+
+ {title: langPack.core.iface.delete, onClick: function() {
+ accDelete_Click(el);
+ }},
+
+ ],$(el.target).closest("tr").attr("accaddr"));
+ return false;
+}
+
+function accDelete_Click(ref) {
+ var acid=($(ref.target).closest("tr").attr("accid"));
+ var buttons={};
+ buttons[langPack.core.iface.dialodDelButton]=function() {
+ $("#dialogInfo").dialog("close");
+ API.exec({
+ requestType: "DELETE",
+ method: "core/mailAccount/"+acid,
+ onSuccess: function(json) {
+ reloadList();
+ },
+ errDict: langPack.core.iface.mailAccounts.errors,
+ });
+
+ };
+
+ buttons[langPack.core.iface.dialodCloseButton]=function() { $("#dialogInfo").dialog("close"); }
+
+ UI.showInfoDialog(langPack.core.iface.mailAccounts.delDialogText+" #"+acid+" "+$(ref.target).closest("tr").attr("accAddr"),langPack.core.iface.delete,buttons);
+}
+
+function accDefault_Click(ref) {
+ var acid=($(ref.target).closest("tr").attr("accid"));
+ var buttons={};
+ buttons[langPack.core.iface.set]=function() {
+ $("#dialogInfo").dialog("close");
+ API.exec({
+ requestType: "GET",
+ method: "core/mailAccount/"+acid+"/setDefault",
+ onSuccess: function(json) {
+ reloadList();
+ },
+ errDict: langPack.core.iface.mailAccounts.errors,
+ });
+
+ };
+
+ buttons[langPack.core.iface.dialodCloseButton]=function() { $("#dialogInfo").dialog("close"); }
+
+ UI.showInfoDialog(langPack.core.iface.mailAccounts.setDefaultDialogText+" #"+acid+" "+$(ref.target).closest("tr").attr("accAddr"),langPack.core.iface.set,buttons);
+}
+
+function accEdit_Click(ref) {
+ var buttons={};
+ var acid=($(ref.target).closest("tr").attr("accid"));
+
+ buttons[langPack.core.iface.add]=async function() {
+ let fdata=UI.collectForm("addgrp", true,false, false,true);
+ if (fdata.validateErrCount==0) {
+ API.exec({
+ errDict: langPack.core.iface.register.errors,
+ requestType: "PATCH",
+ data: {
+ address: fdata.address.val,
+ rxURL: fdata.rxUrl.val,
+ txURL: fdata.txUrl.val,
+ login: fdata.login.val,
+ password: fdata.passwd.val,
+ rxFolder: fdata.rxInbox.val,
+ rxArchiveFolder: fdata.rxArchive.val,
+ },
+ method: "core/mailAccount/"+acid,
+ onSuccess: function(json) {
+ UI.closeDialog('addgrp');
+ reloadList();
+ },
+ });
+
+ }
+ };
+ buttons[langPack.core.iface.dialodCloseButton]=function() { UI.closeDialog('addgrp');}
+
+
+ UI.createDialog(
+ UI.addFieldGroup([
+ UI.addField({title: langPack.core.iface.mailAccounts.address, type: "input", item: "acc_address", reqx:true}),
+ UI.addField({title: langPack.core.iface.mailAccounts.login, type: "input", item: "acc_login",reqx:false}),
+ UI.addField({title: langPack.core.iface.password, type: "passwordNew", item: "acc_passwd",reqx:false}),
+ UI.addField({title: langPack.core.iface.mailAccounts.rxURL, type: "input", item: "acc_rxUrl",reqx:true}),
+ UI.addField({title: langPack.core.iface.mailAccounts.txURL, type: "input", item: "acc_txUrl",reqx:true}),
+ UI.addField({title: langPack.core.iface.mailAccounts.rxFolder, type: "input", item: "reg_rxInbox",reqx: true, val: "INBOX" }),
+ UI.addField({title: langPack.core.iface.mailAccounts.archiveFolder, type: "input", item: "reg_rxArchive",reqx:true, val: "Archive"}),
+
+ ]),
+ langPack.core.iface.add,
+ buttons,
+ 515,1,'addgrp');
+
+ API.exec({
+ errDict: langPack.core.iface.register.errors,
+ requestType: "GET",
+ method: "core/mailAccount/"+acid,
+ onSuccess: function(json) {
+ $("#acc_address").val(json.data.address);
+ $("#acc_login").val(json.data.login);
+ $("#acc_rxUrl").val(json.data.rxProto+(json.data.rxSSL?"s":"")+"://"+json.data.rxServer+":"+json.data.rxPort);
+ $("#acc_txUrl").val(json.data.txProto+(json.data.txSSL?"s":"")+"://"+json.data.txServer+":"+json.data.txPort);
+ $("#reg_rxInbox").val(json.data.rxFolder);
+ $("#reg_rxArchive").val(json.data.rxArchiveFolder);
+ return false;
+ },
+ });
+
+ UI.openDialog('addgrp');
+}
+
diff --git a/static/js/core/coreModule.js b/static/js/core/coreModule.js
index fec834c..f2acbf6 100644
--- a/static/js/core/coreModule.js
+++ b/static/js/core/coreModule.js
@@ -10,6 +10,8 @@ export var menuSelector={
"module":"adminModules",
"users":"adminUsers",
"group":"adminGrous",
+ mailAccounts:"mailAccounts",
+ oauth: "oauth",
};
export function load() {
@@ -59,6 +61,16 @@ export function load() {
mod.load();
})
break;
+ case "mailAccounts":
+ import("./coreMailAccounts.js").then(function(mod) {
+ mod.load();
+ })
+ break;
+ case "oauth":
+ import("./coreOAuthProfiles.js").then(function(mod) {
+ mod.load();
+ })
+ break;
default:
diff --git a/static/js/core/coreOAuthProfiles.js b/static/js/core/coreOAuthProfiles.js
new file mode 100644
index 0000000..a0e6bac
--- /dev/null
+++ b/static/js/core/coreOAuthProfiles.js
@@ -0,0 +1,228 @@
+export function load() {
+ UI.breadcrumbsUpdate(langPack.core.breadcrumbs.modTitle+" / "+langPack.core.breadcrumbs.oauth);
+
+ UI.createTabsPanel({
+ methods:{"title":langPack.core.iface.oauth.allTitle, preLoad: reloadList,buttons: UI.addButton({id: "btn_acctadd",icon: "fas fa-plus",title: langPack.core.iface.oauth.addButtonTitle, onClick: btnAdd_click})},
+
+ })
+}
+
+function reloadList(ref) {
+ $("div.widget.methods").empty();
+ API.exec("GET","core/oAuthProfile/list",{},function(json) {
+ let tx = $("",{class: "datatable sel"});
+ $("",{class: "idx", text: "#"}).appendTo(tx);
+ $(" | ",{class: "", text: langPack.core.iface.title}).appendTo(tx);
+ $(" | ",{class: "", text: langPack.core.iface.url}).appendTo(tx);
+ $(" | ",{class: "", text: langPack.core.iface.active}).appendTo(tx);
+ $(" | ",{class: "button", style: "text-align: center", append: $("",{class: "fas fa-ellipsis-h"})}).appendTo(tx);
+
+ tx.appendTo("div.widget.methods");
+
+ let i=0;
+ $.each(json.data, function(idx, acc) {
+ i++;
+ let row=$("",{}).bind('contextmenu', mliContextMenuOpen).addClass("contextMenu").attr("accActive",acc.enabled?1:0).attr("accHash",acc.hash).attr("accId",acc.id).attr("accName",acc.name);
+ $("",{class: "idx", text: i}).appendTo(row);
+ $(" | ",{class: "", text: acc.name}).appendTo(row);
+ $(" | ",{class: "", text: acc.url}).appendTo(row);
+ $(" | ",{class: "", text: acc.enabled?langPack.core.iface.yes:langPack.core.iface.no}).appendTo(row);
+ $(" | ",{class: "button", style: "text-align: center", append: $("",{class: "fas fa-ellipsis-h"})})
+ .click(mliContextMenuOpen)
+ .appendTo(row);
+ $("",{append: row}).appendTo(tx);
+ });
+
+ })
+}
+
+function mliContextMenuOpen(el) {
+
+ let menuItems=[];
+ let menuOnOff;
+ if ($(el.target).closest("tr").attr("accActive")==1) {
+ menuOnOff= {title: langPack.core.iface.disable, onClick: function() { profileDisable_Click(el) ; }};
+ } else {
+ menuOnOff= {title: langPack.core.iface.enable, onClick: function() { profileEnable_Click(el);}};
+ }
+ menuItems.push(
+ {title: "CopyURL", onClick: function() { UI.copySelText(getCallbackUrl($(el.target).closest("tr").attr("accHash")));}},
+ menuOnOff,
+ {title: langPack.core.iface.edit, onClick: function() { profileEdit_Click(el); }},
+ {title: langPack.core.iface.delete, onClick: function() { profileDelete_Click(el);}},
+ );
+ UI.contextMenuOpen(el,menuItems,$(el.target).closest("tr").attr("accName"));
+ return false;
+}
+
+function profileDisable_Click(ref) {
+ var acid=($(ref.target).closest("tr").attr("accId"));
+ var buttons={};
+ buttons[langPack.core.iface.disable]=function() {
+ $("#dialogInfo").dialog("close");
+ API.exec({
+ requestType: "GET",
+ method: "core/oAuthProfile/"+acid+"/disable",
+ onSuccess: function(json) {
+ reloadList();
+ },
+ errDict: langPack.core.iface.oauth.errors,
+ });
+
+ };
+
+ buttons[langPack.core.iface.dialodCloseButton]=function() { $("#dialogInfo").dialog("close"); }
+
+ UI.showInfoDialog(langPack.core.iface.disable+" #"+acid+" "+$(ref.target).closest("tr").attr("accName"),langPack.core.iface.disable,buttons);
+
+}
+
+function profileEnable_Click(ref) {
+ var acid=($(ref.target).closest("tr").attr("accid"));
+ var buttons={};
+ buttons[langPack.core.iface.enable]=function() {
+ $("#dialogInfo").dialog("close");
+ API.exec({
+ requestType: "GET",
+ method: "core/oAuthProfile/"+acid+"/enable",
+ onSuccess: function(json) {
+ reloadList();
+ },
+ errDict: langPack.core.iface.oauth.errors,
+ });
+
+ };
+
+ buttons[langPack.core.iface.dialodCloseButton]=function() { $("#dialogInfo").dialog("close"); }
+
+ UI.showInfoDialog(langPack.core.iface.enable+" #"+acid+" "+$(ref.target).closest("tr").attr("accName"),langPack.core.iface.enable,buttons);
+
+}
+
+function profileDelete_Click(ref) {
+ var acid=($(ref.target).closest("tr").attr("accid"));
+ var buttons={};
+ buttons[langPack.core.iface.delete]=function() {
+ $("#dialogInfo").dialog("close");
+ API.exec({
+ requestType: "DELETE",
+ method: "core/oAuthProfile/"+acid,
+ onSuccess: function(json) {
+ reloadList();
+ },
+ errDict: langPack.core.iface.oauth.errors,
+ });
+
+ };
+
+ buttons[langPack.core.iface.dialodCloseButton]=function() { $("#dialogInfo").dialog("close"); }
+
+ UI.showInfoDialog(langPack.core.iface.delete+" #"+acid+" "+$(ref.target).closest("tr").attr("accName"),langPack.core.iface.delete,buttons);
+
+}
+
+function btnAdd_click(ref) {
+ var buttons={};
+ var hash=UI.genPassword("0123456789abcdef", 64);
+ buttons[langPack.core.iface.add]=async function() {
+ let fdata=UI.collectForm("addgrp", true,false, false,true);
+ if (fdata.validateErrCount==0) {
+ API.exec({
+ errDict: langPack.core.iface.register.errors,
+ requestType: "PUT",
+ data: {
+ name: fdata.name.val,
+ url: fdata.url.val,
+ clientId: fdata.clientId.val,
+ clientKey: fdata.clientKey.val,
+ config: fdata.type.val,
+ hash: hash,
+ },
+ method: "core/oAuthProfile",
+ onSuccess: function(json) {
+ UI.closeDialog('addgrp');
+ reloadList();
+ },
+ });
+
+ }
+ };
+ buttons[langPack.core.iface.dialodCloseButton]=function() { UI.closeDialog('addgrp');}
+
+
+ UI.createDialog(
+ UI.addFieldGroup([
+ UI.addField({title: langPack.core.iface.title, type: "input", item: "acc_name", reqx:true}),
+ UI.addField({title: langPack.core.iface.url, type: "input", item: "acc_url",reqx:false}),
+ UI.addField({title: langPack.core.iface.template, type: "select", item: "acc_type",reqx:true, args: {"":"--"+langPack.core.iface.oauth.selectPreset+"--","vk":"VK","yandex":"Yandex", "gitea":"Gitea", "gitlab":"Gitlab"}}),
+ UI.addField({title: langPack.core.iface.oauth.callback, type: "multiline", args: {rows: 4}, item: "acc_callbackurl", disabled: true, val: "callback"}),
+ UI.addField({title: langPack.core.iface.oauth.clientId, type: "input", item: "acc_clientId",reqx:true}),
+ UI.addField({title: langPack.core.iface.oauth.clientKey, type: "input", item: "acc_clientKey",reqx:true}),
+ ]),
+ langPack.core.iface.add,
+ buttons,
+ 515,1,'addgrp');
+ $("#acc_callbackurl").val(getCallbackUrl(hash));
+ UI.openDialog('addgrp');
+}
+
+function getCallbackUrl(hash) {
+ return API.settings.get("sitePrefix")+"/auth/oauth/"+hash;
+}
+
+function profileEdit_Click(ref) {
+ var acid=($(ref.target).closest("tr").attr("accid"));
+ var buttons={};
+ buttons[langPack.core.iface.edit]=async function() {
+ let fdata=UI.collectForm("addgrp", true,false, false,true);
+ if (fdata.validateErrCount==0) {
+ API.exec({
+ errDict: langPack.core.iface.register.errors,
+ requestType: "PATCH",
+ data: {
+ name: fdata.name.val,
+ url: fdata.url.val,
+ clientId: fdata.clientId.val,
+ clientKey: fdata.clientKey.val,
+ config: fdata.type.val,
+ },
+ method: "core/oAuthProfile/"+acid,
+ onSuccess: function(json) {
+ UI.closeDialog('addgrp');
+ reloadList();
+ },
+ });
+
+ }
+ };
+ buttons[langPack.core.iface.dialodCloseButton]=function() { UI.closeDialog('addgrp');}
+
+
+ UI.createDialog(
+ UI.addFieldGroup([
+ UI.addField({title: langPack.core.iface.title, type: "input", item: "acc_name", reqx:true}),
+ UI.addField({title: langPack.core.iface.url, type: "input", item: "acc_url",reqx:false}),
+ UI.addField({title: langPack.core.iface.template, type: "select", item: "acc_type",reqx:true, args: {"":"--"+langPack.core.iface.oauth.selectPreset+"--","vk":"VK","yandex":"Yandex", "gitea":"Gitea", "gitlab":"Gitlab"}}),
+ UI.addField({title: langPack.core.iface.oauth.clientId, type: "input", item: "acc_clientId",reqx:true}),
+ UI.addField({title: langPack.core.iface.oauth.clientKey, type: "input", item: "acc_clientKey",reqx:false}),
+ ]),
+ langPack.core.iface.add,
+ buttons,
+ 385,1,'addgrp');
+ API.exec({
+ errDict: langPack.core.iface.register.errors,
+ requestType: "GET",
+ method: "core/oAuthProfile/"+acid,
+ onSuccess: function(json) {
+ $("#acc_name").val(json.data.name);
+ $("#acc_url").val(json.data.url);
+ $("#acc_type").val(json.data.config);
+ $("#acc_clientId").val(json.data.clientId);
+ return false;
+ },
+ });
+
+ UI.openDialog('addgrp');
+
+}
+
diff --git a/static/js/core/lang_ru.js b/static/js/core/lang_ru.js
index c3ea78d..d1c6240 100644
--- a/static/js/core/lang_ru.js
+++ b/static/js/core/lang_ru.js
@@ -8,6 +8,8 @@ export var langItem={
ok0: "Операция завершена успешно",
dataEmpty: "Информация недоступна, скорее здесь ничего нет.",
emptyInvCode: "-нет-",
+ enable: "Активировать",
+ disable: "Заблокировать",
dataLoading: "Информация загружается",
loginFailedDialogTitle: "Ошибка авторизации",
loginFailed401text: "Неправильные имя пользователя или пароль\nУточните данные и попробуйте еще раз",
@@ -17,10 +19,12 @@ export var langItem={
active: "Активен",
version: "Версия",
title: "Наименование",
+ url: "URL",
desc: "Описание",
installed: "Установлен",
install: "Установить",
set: "Установить",
+ edit: "Изменить",
updated: "Обновлен",
invCode: "invCode",
dialodCloseButton: "Закрыть",
@@ -132,6 +136,34 @@ export var langItem={
URNF: "Пользователь не найден либо восстановление пароля не предусмотрено спосбом авторизации",
IVCC: "Некорректный код подтверждения. Проверьте правильность кода и повторите попытку.",
}
+ },
+ mailAccounts: {
+ allTitle: "Учетные записи электронной почты",
+ addButtonTitle: "Добавить УЗ",
+ address: "Адрес",
+ login: "Логин",
+ module: "Модуль",
+ rxURL: "RX URL",
+ txURL: "TX URL",
+ rxFolder: "Входящие",
+ archiveFolder: "Архив",
+ default: "Основной",
+ setDefault: "Сделать основным",
+ delDialogText: "Удалить аккаунт",
+ setDefaultDialogText: "Установить основным аккаунт",
+ errors: {
+ DDAX: "Нельзя удалить основной аккаунт",
+ }
+ },
+ oauth: {
+ allTitle: "Методы oAuth",
+ addButtonTitle: "Добавить метод",
+ clientId: "ID Клиента",
+ clientKey: "Секретный ключ",
+ callback: "URL возврата",
+ selectPreset: "Выберите шаблон",
+ errors: {
+ }
}
},
@@ -140,7 +172,9 @@ export var langItem={
modules: "Модули",
users: "Пользователи",
groups: "Группы",
- myprofile: "Мой профиль"
+ myprofile: "Мой профиль",
+ mailAccounts: "Учетные записи ЭП",
+ oauth: "oAuth",
},
date: {
diff --git a/static/js/core/login.js b/static/js/core/login.js
index 8c5c290..728a03e 100644
--- a/static/js/core/login.js
+++ b/static/js/core/login.js
@@ -3,7 +3,8 @@ import * as UI from './ui.js';
import { langPack, lpCacheDrop } from './langpack.js';
export function load() {
- $("body").empty();
+ $("body").empty().addClass("login");
+ $("html").addClass("login");
if (UI.parceURL().module=='auth' && UI.parceURL().function=='oauth') {
let hash = UI.parceURL().id;
diff --git a/static/js/core/ui.js b/static/js/core/ui.js
index 3185f5b..e4b5fad 100644
--- a/static/js/core/ui.js
+++ b/static/js/core/ui.js
@@ -295,7 +295,7 @@ export function addField(ref)//title, item, blockstyle, fieldstyle, type, args,
let password=genPassword();
$("#"+item_id).val(password);
$("#"+item_id).change();
- if (typeof(ref.newPasswdGenCallback)) {
+ if (typeof(ref.newPasswdGenCallback)=="function") {
ref.newPasswdGenCallback(password);
}
@@ -763,8 +763,8 @@ export function setTitle(title, desc)
}
export function initBody() {
-
- $("body").empty();
+ $("html").removeClass("login");
+ $("body").empty().removeClass("login");
$("",{id: "contextMenu", class: "contextMenu"}).appendTo("body").hide();
$(" ", { class: "t_global"})
.appendTo("body")
diff --git a/static/theme/core/main.css b/static/theme/core/main.css
index 9192a0e..53e709c 100644
--- a/static/theme/core/main.css
+++ b/static/theme/core/main.css
@@ -1518,6 +1518,10 @@ div.t_main
width: 1681px;
}
+div.mainfame {
+ width: 1676px;
+}
+
div.t_global
{
width: 1881px;
@@ -1848,6 +1852,10 @@ div.t_main
width: 1360px;
}
+div#mainframe {
+ width: 1343px !important;
+}
+
div.t_global
{
width: 1560px;
@@ -1926,6 +1934,10 @@ div.t_main
margin-right: 0;
}
+div#mainframe {
+ width: 1022px !important;
+}
+
div.t_global
{
width: 1239px;
@@ -2039,6 +2051,10 @@ div.t_main
}
+div#mainframe {
+ width: 1022px !important;
+}
+
div.t_global
{
width: 1035px;
@@ -2135,6 +2151,10 @@ div.t_main
width: 710px;
}
+div#mainframe {
+ width: 699px !important;
+}
+
div.t_global
{
width: 710px;
| | |