Weekly sync 2022-07-04

This commit is contained in:
Pavel Dmitriev 2022-07-04 15:46:25 +03:00
parent eab59a060b
commit 6cbf608b94
8 changed files with 93 additions and 119 deletions

View File

@ -581,6 +581,9 @@ class baseClass extends dbStoredBase implements \JsonSerializable, jsonImportabl
$where = (empty($where)?"":"(".$where.") AND ")."`".static::$deletedFieldName."` = 0"; $where = (empty($where)?"":"(".$where.") AND ")."`".static::$deletedFieldName."` = 0";
} }
$pageSize=is_numeric($pageSize)?((int)$pageSize):null;
$page=is_numeric($page)?((int)$page):null;
if ($pageSize!==null) { if ($pageSize!==null) {
if ($page<1) { $page=1;} if ($page<1) { $page=1;}
$limit = "LIMIT ".($pageSize*($page-1)).", ".$pageSize; $limit = "LIMIT ".($pageSize*($page-1)).", ".$pageSize;

View File

@ -25,7 +25,7 @@ class s3client implements objectStorageClient
protected string $prefix = ""; protected string $prefix = "";
protected \Aws\S3\S3Client $s3; protected ?\Aws\S3\S3Client $s3;
public function __construct($endpoint = null, $accessKey = null, $secretKey = null, $regionId = null, $prefix = null) public function __construct($endpoint = null, $accessKey = null, $secretKey = null, $regionId = null, $prefix = null)
{ {
@ -78,6 +78,7 @@ class s3client implements objectStorageClient
"Key" => $key, "Key" => $key,
"Body" => $data "Body" => $data
]); ]);
gc_collect_cycles();
} }
public function deleteObject($bucket, $key) public function deleteObject($bucket, $key)
@ -88,13 +89,34 @@ class s3client implements objectStorageClient
]); ]);
} }
public function listObjects($bucket) public function listObjects($bucket, $marker=0)
{ {
return $this->s3->listObjects([ return $this->s3->listObjects([
"Bucket" => $this->prefix . $bucket "Bucket" => $this->prefix . $bucket,
"Marker"=>$marker
])["Contents"]; ])["Contents"];
} }
public function listAllObjects($bucket)
{
$rv=[];
$cnt=0;
$marker=null;
while(true) {
$cx=0;
$list = $this->listObjects($bucket,$marker);
if ($list==null) { break; }
foreach ($list as $key=>$obj) {
$cnt++;
$cx++;
$rv[]=$obj;
$marker=$obj["Key"];
}
if ($cx==0) { break; }
}
return $rv;
}
public function exec($method, $args = []) public function exec($method, $args = [])
{ {
return $this->s3->{$method}($args); return $this->s3->{$method}($args);
@ -113,6 +135,10 @@ class s3client implements objectStorageClient
"Bucket" => $this->prefix . $bucket "Bucket" => $this->prefix . $bucket
]); ]);
} }
public function __destruct() {
$this->s3=null;
}
} }
?> ?>

View File

@ -332,15 +332,7 @@ class user extends baseClass implements externalCallable
$request->getRequestBodyItem("page"), $request->getRequestBodyItem("page"),
$opts $opts
); );
if (! $request->user->checkAccess("adminUsers", "core")) {
throw new foxException("Forbidden", 403);
}
$pageSize=common::clearInput($request->requestBody->pageSize,"0-9");
if (empty($pageSize)) { $pageSize=$request->user->config["pageSize"];}
return static::search(common::clearInput($request->requestBody->pattern), $pageSize)->result;
} }
public static function APIX_GET_sendEMailConfirmation(request $request) { public static function APIX_GET_sendEMailConfirmation(request $request) {

View File

@ -1,6 +1,12 @@
import * as UI from './ui.js'; import * as UI from './ui.js';
import { langPack } from './langpack.js'; import { langPack } from './langpack.js';
export function loadModule(modPath) {
import(modPath).then(function(mod) {
mod.load();
})
}
// errDict // errDict
export function exec(requestType, method , data, onSuccess,noblank,onError,version) export function exec(requestType, method , data, onSuccess,noblank,onError,version)
{ {

View File

@ -97,7 +97,21 @@ async function compEdit_Click(el) {
buttons[langPack.core.iface.dialodCloseButton]=function() { UI.closeDialog('ItemAdd'); } buttons[langPack.core.iface.dialodCloseButton]=function() { UI.closeDialog('ItemAdd'); }
UI.createDialog( compAddEditDialog_Create(langPack.core.iface.edit, buttons);
await API.exec("GET",UI.parceURL().module+"/company/"+id,{}, function onAjaxSuccess(json,_textStatus) {
$("#cao_name").val(json.data.name);
$("#cao_qName").val(json.data.qName);
$("#cao_description").val(json.data.description);
$("#cao_type").val(json.data.type);
});
UI.openDialog('ItemAdd');
}
function compAddEditDialog_Create(title, buttons) {
UI.createDialog(
UI.addFieldGroup([ UI.addFieldGroup([
UI.addField({title: langPack.core.iface.title, item: "cao_name", type: "input",reqx: true}), UI.addField({title: langPack.core.iface.title, item: "cao_name", type: "input",reqx: true}),
UI.addField({title: langPack.core.iface.comps.qName, item: "cao_qName", type: "input",reqx: true}), UI.addField({title: langPack.core.iface.comps.qName, item: "cao_qName", type: "input",reqx: true}),
@ -110,22 +124,11 @@ async function compEdit_Click(el) {
{val:"parner",title: langPack.core.iface.comps.partner}, {val:"parner",title: langPack.core.iface.comps.partner},
]}), ]}),
]), ]),
langPack.core.iface.edit, title,
buttons, buttons,
350,1,'ItemAdd' 350,1,'ItemAdd'
); );
await API.exec("GET",UI.parceURL().module+"/company/"+id,{}, function onAjaxSuccess(json,_textStatus) {
$("#cao_name").val(json.data.name);
$("#cao_qName").val(json.data.qName);
$("#cao_description").val(json.data.description);
$("#cao_type").val(json.data.type);
});
UI.openDialog('ItemAdd');
} }
function btnCmpAdd_Click(ref) { function btnCmpAdd_Click(ref) {
var buttons={}; var buttons={};
buttons[langPack.core.iface.dialodAddButton]=function() { buttons[langPack.core.iface.dialodAddButton]=function() {
@ -145,23 +148,7 @@ function btnCmpAdd_Click(ref) {
buttons[langPack.core.iface.dialodCloseButton]=function() { UI.closeDialog('ItemAdd'); } buttons[langPack.core.iface.dialodCloseButton]=function() { UI.closeDialog('ItemAdd'); }
UI.createDialog( compAddEditDialog_Create(langPack.core.iface.add, buttons);
UI.addFieldGroup([
UI.addField({title: langPack.core.iface.title, item: "cao_name", type: "input",reqx: true}),
UI.addField({title: langPack.core.iface.comps.qName, item: "cao_qName", type: "input",reqx: true}),
UI.addField({title: langPack.core.iface.desc, item: "cao_description", type: "input"}),
UI.addField({title: langPack.core.iface.type, item: "cao_type", type: "select", reqx: true, args: [
{val:"",title: ""},
{val:"company",title: langPack.core.iface.comps.company},
{val:"client",title: langPack.core.iface.comps.client},
{val:"supplier",title: langPack.core.iface.comps.supplier},
{val:"parner",title: langPack.core.iface.comps.partner},
]}),
]),
langPack.core.iface.add,
buttons,
350,1,'ItemAdd'
);
UI.openDialog('ItemAdd'); UI.openDialog('ItemAdd');
} }

View File

@ -1,8 +1,5 @@
import * as API from './api.js'; import * as API from './api.js';
import * as UI from './ui.js'; import * as UI from './ui.js';
import { langPack } from './langpack.js';
export var menuSelector={ export var menuSelector={
"groups":"adminGrous", "groups":"adminGrous",
@ -15,73 +12,29 @@ export var menuSelector={
comps: "adminComps" comps: "adminComps"
}; };
export var modSelector={
"myprofile": "./coreMyProfile.js",
"modules": "./coreModules.js",
"module": "./coreModView.js",
"groups": "./coreGroups.js",
"group": "./coreGroup.js",
"users": "./coreUsers.js",
"userEmailConfirm": "./userMailConfirm.js",
"mailAccounts": "./coreMailAccounts.js",
"oauth": "./coreOAuthProfiles.js",
"comps": "./coreComps.js"
}
export function load() { export function load() {
let ref=UI.parceURL(); let ref=UI.parceURL();
switch (ref.function) {
case undefined: if (isset(modSelector[ref.function])) {
break; API.loadModule(modSelector[ref.function]);
} else if (!isset(ref.function)) {
case "myprofile": // TODO: Implement default start page for core module
import("./coreMyProfile.js").then(function(mod) { return true;
mod.load(); } else {
}) throw new Error(404);
break;
case "modules":
import("./coreModules.js").then(function(mod) {
mod.load();
})
break;
case "module":
import("./coreModView.js").then(function(mod) {
mod.load();
})
break;
case "groups":
import("./coreGroups.js").then(function(mod) {
mod.load();
})
break;
case "group":
import("./coreGroup.js").then(function(mod) {
mod.load();
})
break;
case "users":
import("./coreUsers.js").then(function(mod) {
mod.load();
})
break;
case "userEmailConfirm":
import("./userMailConfirm.js").then(function(mod) {
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;
case "comps":
import("./coreComps.js").then(function(mod) {
mod.load();
})
break;
default:
throw new Error(404);
} }
return true; return true;
} }

View File

@ -442,7 +442,13 @@ export function addField(ref)//title, item, blockstyle, fieldstyle, type, args,
title.append($("<span>",{ class: "dialogFieldTitle_Reqx",text: "*", title: langPack.core.iface.errReqx })); title.append($("<span>",{ class: "dialogFieldTitle_Reqx",text: "*", title: langPack.core.iface.errReqx }));
} }
var rv=$("<div>",{ let rvv=$("<div>",{
class: "crm_entity_field_value",
append: item,
style: ref.fieldstyle
});
let rv=$("<div>",{
class: "crm_entity_field_block", class: "crm_entity_field_block",
style: ref.blockstyle, style: ref.blockstyle,
append: $("<div>",{ append: $("<div>",{
@ -451,11 +457,7 @@ export function addField(ref)//title, item, blockstyle, fieldstyle, type, args,
append: title append: title
}) })
.add($("<div>",{ .add(rvv)
class: "crm_entity_field_value",
append: item,
style: ref.fieldstyle
}))
}); });
if (type=="label") { if (type=="label") {
@ -464,9 +466,13 @@ export function addField(ref)//title, item, blockstyle, fieldstyle, type, args,
rv.addClass("clickable"); rv.addClass("clickable");
} }
}
if (type=="label" || type=="href") {
if (typeof(ref.onContextMenu)=="function") { if (typeof(ref.onContextMenu)=="function") {
rv.bind('contextmenu click', ref.onContextMenu); rv.bind('contextmenu', ref.onContextMenu);
rv.addClass("withContextMenu"); rv.addClass("withContextMenu");
rvv.append($("<i>",{style: "padding: 0 10px 0 10px; float: right;", class: "fas fa-ellipsis-v"}).bind('contextmenu click', ref.onContextMenu))
} }
} }

View File

@ -214,7 +214,7 @@ div.header_user
width: 100%; width: 100%;
height: 100%; height: 100%;
position: fixed; position: fixed;
z-index: 200; z-index: 2000;
top: 0; top: 0;
left: 0; left: 0;
backdrop-filter: blur(1px); backdrop-filter: blur(1px);
@ -941,7 +941,8 @@ table.datatable.selm tr.ss.contextMenu,
table.datatable.sel tr.contextMenu a, table.datatable.sel tr.contextMenu a,
table.datatable.selm tbody.contextMenu a, table.datatable.selm tbody.contextMenu a,
table.datatable.selm tr.ss.contextMenu a, table.datatable.selm tr.ss.contextMenu a,
div.crm_entity_field_block.withContextMenu { div.crm_entity_field_block.withContextMenu,
div.crm_entity_field_block.withContextMenu a {
cursor: context-menu; cursor: context-menu;
} }