diff --git a/core/fox/baseClass.php b/core/fox/baseClass.php index 08d2f44..13e9d22 100644 --- a/core/fox/baseClass.php +++ b/core/fox/baseClass.php @@ -581,6 +581,9 @@ class baseClass extends dbStoredBase implements \JsonSerializable, jsonImportabl $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 ($page<1) { $page=1;} $limit = "LIMIT ".($pageSize*($page-1)).", ".$pageSize; diff --git a/core/fox/s3client.php b/core/fox/s3client.php index c190b5d..ea4da0f 100644 --- a/core/fox/s3client.php +++ b/core/fox/s3client.php @@ -25,7 +25,7 @@ class s3client implements objectStorageClient 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) { @@ -78,6 +78,7 @@ class s3client implements objectStorageClient "Key" => $key, "Body" => $data ]); + gc_collect_cycles(); } 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([ - "Bucket" => $this->prefix . $bucket + "Bucket" => $this->prefix . $bucket, + "Marker"=>$marker ])["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 = []) { return $this->s3->{$method}($args); @@ -113,6 +135,10 @@ class s3client implements objectStorageClient "Bucket" => $this->prefix . $bucket ]); } + + public function __destruct() { + $this->s3=null; + } } ?> \ No newline at end of file diff --git a/core/fox/user.php b/core/fox/user.php index b54c6ef..7d8f908 100644 --- a/core/fox/user.php +++ b/core/fox/user.php @@ -332,15 +332,7 @@ class user extends baseClass implements externalCallable $request->getRequestBodyItem("page"), $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) { diff --git a/static/js/core/api.js b/static/js/core/api.js index 10fdaef..4a87362 100644 --- a/static/js/core/api.js +++ b/static/js/core/api.js @@ -1,6 +1,12 @@ import * as UI from './ui.js'; import { langPack } from './langpack.js'; +export function loadModule(modPath) { + import(modPath).then(function(mod) { + mod.load(); + }) +} + // errDict export function exec(requestType, method , data, onSuccess,noblank,onError,version) { diff --git a/static/js/core/coreComps.js b/static/js/core/coreComps.js index dd75f52..a493aee 100644 --- a/static/js/core/coreComps.js +++ b/static/js/core/coreComps.js @@ -97,7 +97,21 @@ async function compEdit_Click(el) { 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.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}), @@ -110,22 +124,11 @@ async function compEdit_Click(el) { {val:"parner",title: langPack.core.iface.comps.partner}, ]}), ]), - langPack.core.iface.edit, + title, buttons, 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) { var buttons={}; buttons[langPack.core.iface.dialodAddButton]=function() { @@ -145,23 +148,7 @@ function btnCmpAdd_Click(ref) { buttons[langPack.core.iface.dialodCloseButton]=function() { UI.closeDialog('ItemAdd'); } - UI.createDialog( - 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' - ); + compAddEditDialog_Create(langPack.core.iface.add, buttons); UI.openDialog('ItemAdd'); } diff --git a/static/js/core/coreModule.js b/static/js/core/coreModule.js index 5a23f88..eb2e088 100644 --- a/static/js/core/coreModule.js +++ b/static/js/core/coreModule.js @@ -1,8 +1,5 @@ import * as API from './api.js'; import * as UI from './ui.js'; -import { langPack } from './langpack.js'; - - export var menuSelector={ "groups":"adminGrous", @@ -15,73 +12,29 @@ export var menuSelector={ 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() { let ref=UI.parceURL(); - switch (ref.function) { - case undefined: - break; - - case "myprofile": - import("./coreMyProfile.js").then(function(mod) { - mod.load(); - }) - 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); + + if (isset(modSelector[ref.function])) { + API.loadModule(modSelector[ref.function]); + } else if (!isset(ref.function)) { + // TODO: Implement default start page for core module + return true; + } else { + throw new Error(404); } return true; } \ No newline at end of file diff --git a/static/js/core/ui.js b/static/js/core/ui.js index 004bd76..3196193 100644 --- a/static/js/core/ui.js +++ b/static/js/core/ui.js @@ -442,7 +442,13 @@ export function addField(ref)//title, item, blockstyle, fieldstyle, type, args, title.append($("",{ class: "dialogFieldTitle_Reqx",text: "*", title: langPack.core.iface.errReqx })); } - var rv=$("
",{ + let rvv=$("
",{ + class: "crm_entity_field_value", + append: item, + style: ref.fieldstyle + }); + + let rv=$("
",{ class: "crm_entity_field_block", style: ref.blockstyle, append: $("
",{ @@ -451,11 +457,7 @@ export function addField(ref)//title, item, blockstyle, fieldstyle, type, args, append: title }) - .add($("
",{ - class: "crm_entity_field_value", - append: item, - style: ref.fieldstyle - })) + .add(rvv) }); if (type=="label") { @@ -464,9 +466,13 @@ export function addField(ref)//title, item, blockstyle, fieldstyle, type, args, rv.addClass("clickable"); } + } + + if (type=="label" || type=="href") { if (typeof(ref.onContextMenu)=="function") { - rv.bind('contextmenu click', ref.onContextMenu); + rv.bind('contextmenu', ref.onContextMenu); rv.addClass("withContextMenu"); + rvv.append($("",{style: "padding: 0 10px 0 10px; float: right;", class: "fas fa-ellipsis-v"}).bind('contextmenu click', ref.onContextMenu)) } } diff --git a/static/theme/core/main.css b/static/theme/core/main.css index c17168c..050051e 100644 --- a/static/theme/core/main.css +++ b/static/theme/core/main.css @@ -214,7 +214,7 @@ div.header_user width: 100%; height: 100%; position: fixed; - z-index: 200; + z-index: 2000; top: 0; left: 0; backdrop-filter: blur(1px); @@ -941,7 +941,8 @@ table.datatable.selm tr.ss.contextMenu, table.datatable.sel tr.contextMenu a, table.datatable.selm tbody.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; }