@esvndev/es-react-config-setting 1.0.86 → 1.0.88

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,3 +2,4 @@ import { key_format } from "../../shared/type";
2
2
  export declare const GLOBAL_WINDOW_VARIABLE: Record<string, any>;
3
3
  export declare const INIT_CONFIG_SETTING: () => Promise<void>;
4
4
  export declare const get_conf: (key: string, type?: key_format) => any;
5
+ export declare const set_filter: (filter: any) => any;
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@ interface ISettingApp {
5
5
  eventClose?: (obj: any) => void;
6
6
  isOpen: boolean;
7
7
  }
8
- type key_format = 'text' | 'int' | 'decimal' | 'byte' | 'object';
8
+ type key_format = 'text' | 'int' | 'decimal' | 'byte' | 'object' | 'bool';
9
9
 
10
10
  declare const SettingApp: (props: ISettingApp) => react_jsx_runtime.JSX.Element;
11
11
 
package/dist/index.js CHANGED
@@ -17017,12 +17017,15 @@ const GetSettingGroup = (callback) => {
17017
17017
  callback({ status: false, data: error });
17018
17018
  });
17019
17019
  };
17020
- const GetSettingConfigClient = async (callback) => {
17020
+ const GetSettingConfigClient = async (filter, callback) => {
17021
17021
  const _url = `${BASE_URL}/api/escore/get-setting-config-client`;
17022
17022
  const _obj = {
17023
17023
  ModuleId: REACT_APP_PRODUCT_CODE,
17024
17024
  StateId: '',
17025
- Option: JSON.stringify({ version: localStorage.getItem("app_config_setting_version") })
17025
+ Option: JSON.stringify({
17026
+ version: localStorage.getItem("app_config_setting_version"),
17027
+ ...(filter ?? {})
17028
+ })
17026
17029
  };
17027
17030
  const options = {
17028
17031
  method: 'POST',
@@ -17165,7 +17168,6 @@ const SettingApp = (props) => {
17165
17168
  }]
17166
17169
  }, obj.file, (rs) => {
17167
17170
  console.log(rs);
17168
- loadSettingConfigByGroup(dataTabSelected.current);
17169
17171
  });
17170
17172
  if (eventChange)
17171
17173
  eventChange([{ key: obj.key, value: obj.value, state: "update" }]);
@@ -17227,7 +17229,7 @@ const SettingApp = (props) => {
17227
17229
  allowed_defects_per_model_day: null
17228
17230
  }).current;
17229
17231
  //Cấu hình thông số delay tránh gửi liên tục
17230
- const change_save = (root, obj, e, index, _index, dataRoot) => {
17232
+ const change_save = (root, obj, e) => {
17231
17233
  const _m = saveSettings;
17232
17234
  if (saveSettings && _m[obj.id] !== null) {
17233
17235
  clearTimeout(_m[obj.id]);
@@ -17262,18 +17264,16 @@ const SettingApp = (props) => {
17262
17264
  _m[obj.id] = setTimeout(() => {
17263
17265
  _eventChange(_data);
17264
17266
  }, time_update);
17265
- dataRoot[index].data[_index] = value;
17266
- setSettingData([...dataRoot]);
17267
17267
  };
17268
17268
  //Hàm sử dụng tạo theo loại giá trị
17269
- const _renderInput = (root, data, index, _index, dataRoot) => {
17269
+ const _renderInput = (root, data) => {
17270
17270
  const value = formState[data.id] ?? data.value ?? "";
17271
17271
  switch (data.type) {
17272
17272
  case "switch":
17273
17273
  case "checkbox":
17274
- return (jsxRuntime.jsx("div", { className: "checkbox", title: data.description, children: jsxRuntime.jsx(Input$1, { style: { width: '237px !important' }, type: "checkbox", checked: (value === "true"), onChange: (e) => change_save(root, data, e, index, _index, dataRoot) }) }, data.id));
17274
+ return (jsxRuntime.jsx("div", { className: "checkbox", title: data.description, children: jsxRuntime.jsx(Input$1, { style: { width: '237px !important' }, type: "checkbox", checked: (value === "true" || value === true), onChange: (e) => change_save(root, data, e) }) }, data.id));
17275
17275
  case "radio":
17276
- return (jsxRuntime.jsx("div", { className: "radio-group", title: data.description, children: data.option?.map((opt, index) => (jsxRuntime.jsxs("label", { children: [jsxRuntime.jsx(Input$1, { type: "radio", name: data.name, value: opt.value, checked: value === opt.value, onChange: (e) => change_save(root, data, e, index, _index, dataRoot) }), opt.name] }, index))) }, data.id));
17276
+ return (jsxRuntime.jsx("div", { className: "radio-group", title: data.description, children: data.option?.map((opt, index) => (jsxRuntime.jsxs("label", { children: [jsxRuntime.jsx(Input$1, { type: "radio", name: data.name, value: opt.value, checked: value === opt.value, onChange: (e) => change_save(root, data, e) }), opt.name] }, index))) }, data.id));
17277
17277
  case "combobox":
17278
17278
  let _data_option = [];
17279
17279
  if (data.option) {
@@ -17285,7 +17285,7 @@ const SettingApp = (props) => {
17285
17285
  }
17286
17286
  }
17287
17287
  data.option = _data_option;
17288
- return (jsxRuntime.jsx("div", { className: "combobox", title: data.description, children: jsxRuntime.jsxs(Input$1, { type: "select", className: "input-custom", name: data.name, value: value, onChange: (e) => change_save(root, data, e, index, _index, dataRoot), children: [jsxRuntime.jsx("option", { value: "", children: "Ch\u1ECDn m\u1ED9t gi\u00E1 tr\u1ECB" }), data.option?.map((opt, index) => (jsxRuntime.jsx("option", { value: opt.value, children: opt.name }, index)))] }) }, data.id));
17288
+ return (jsxRuntime.jsx("div", { className: "combobox", title: data.description, children: jsxRuntime.jsxs(Input$1, { type: "select", className: "input-custom", name: data.name, value: value, onChange: (e) => change_save(root, data, e), children: [jsxRuntime.jsx("option", { value: "", children: "Ch\u1ECDn m\u1ED9t gi\u00E1 tr\u1ECB" }), data.option?.map((opt, index) => (jsxRuntime.jsx("option", { value: opt.value, children: opt.name }, index)))] }) }, data.id));
17289
17289
  case "slider":
17290
17290
  case "text":
17291
17291
  case "password":
@@ -17294,12 +17294,12 @@ const SettingApp = (props) => {
17294
17294
  case "time":
17295
17295
  case "datetime":
17296
17296
  case "color":
17297
- return (jsxRuntime.jsx("div", { className: `${data.type}-input`, title: data.description, children: jsxRuntime.jsx(Input$1, { type: data.type, className: "input-custom", value: value, placeholder: data.name, onChange: (e) => change_save(root, data, e, index, _index, dataRoot) }) }, data.id));
17297
+ return (jsxRuntime.jsx("div", { className: `${data.type}-input`, title: data.description, children: jsxRuntime.jsx(Input$1, { type: data.type, className: "input-custom", value: value, placeholder: data.name, onChange: (e) => change_save(root, data, e) }) }, data.id));
17298
17298
  case "image":
17299
17299
  case "file":
17300
- return (jsxRuntime.jsx("div", { className: "file-input", title: data.description, children: jsxRuntime.jsx(Input$1, { type: "file", className: "input-custom", onChange: (e) => change_save(root, data, e, index, _index, dataRoot) }) }, data.id));
17300
+ return (jsxRuntime.jsx("div", { className: "file-input", title: data.description, children: jsxRuntime.jsx(Input$1, { type: "file", className: "input-custom", onChange: (e) => change_save(root, data, e) }) }, data.id));
17301
17301
  default:
17302
- return (jsxRuntime.jsx("div", { className: `${data.type ?? 'normal'}-input`, title: data.description, children: jsxRuntime.jsx(Input$1, { type: data.type ?? "text", value: value, onChange: (e) => change_save(root, data, e, index, _index, dataRoot) }) }, data.id));
17302
+ return (jsxRuntime.jsx("div", { className: `${data.type ?? 'normal'}-input`, title: data.description, children: jsxRuntime.jsx(Input$1, { type: data.type ?? "text", value: value, onChange: (e) => change_save(root, data, e) }) }, data.id));
17303
17303
  }
17304
17304
  };
17305
17305
  //hàm tạo các thông số cấu hình và cài đặt
@@ -17309,7 +17309,7 @@ const SettingApp = (props) => {
17309
17309
  jsxRuntime.jsx("div", { className: "setting-section-desc", children: jsxRuntime.jsx("div", { className: "", children: jsxRuntime.jsx("span", { children: item.description }) }) })
17310
17310
  : null, item.data ?
17311
17311
  jsxRuntime.jsx("div", { className: "setting-section-content ", children: item.data.length > 0 ? item.data.map((_item, _index) => {
17312
- return (jsxRuntime.jsxs("div", { className: 'flx flx-al-c flx-sp-btw setting-section-content__item ' + (item.data.length === 1 ? "single" : (_index === 0 ? 'first' : (_index === item.data.length - 1 ? 'last' : ""))), children: [jsxRuntime.jsxs("div", { className: "flx flx-col", style: { flex: "0 0 fit-content", maxWidth: '50%' }, children: [jsxRuntime.jsx("span", { children: _item.name }), jsxRuntime.jsx("span", { className: "setting-section-content__description", children: _item.description })] }), jsxRuntime.jsx("div", { style: { maxWidth: "50%" }, children: jsxRuntime.jsx("div", { style: { width: "100%", boxSizing: "border-box" }, children: _renderInput(item, _item, index, _index, settingData) }) })] }));
17312
+ return (jsxRuntime.jsxs("div", { className: 'flx flx-al-c flx-sp-btw setting-section-content__item ' + (item.data.length === 1 ? "single" : (_index === 0 ? 'first' : (_index === item.data.length - 1 ? 'last' : ""))), children: [jsxRuntime.jsxs("div", { className: "flx flx-col", style: { flex: "0 0 fit-content", maxWidth: '50%' }, children: [jsxRuntime.jsx("span", { children: _item.name }), jsxRuntime.jsx("span", { className: "setting-section-content__description", children: _item.description })] }), jsxRuntime.jsx("div", { style: { maxWidth: "50%" }, children: jsxRuntime.jsx("div", { style: { width: "100%", boxSizing: "border-box" }, children: _renderInput(item, _item) }) })] }));
17313
17313
  }) : null }) : null] }));
17314
17314
  })
17315
17315
  : null);
@@ -17324,7 +17324,8 @@ const SettingApp = (props) => {
17324
17324
 
17325
17325
  const GLOBAL_WINDOW_VARIABLE = {};
17326
17326
  const VARIABLE_FRIVATE = {
17327
- FIRST_LOAD: true
17327
+ FIRST_LOAD: true,
17328
+ FILTER_SETUP: {}
17328
17329
  };
17329
17330
  let intervalId = null;
17330
17331
  var TIME_RELOAD = 15000;
@@ -17336,10 +17337,10 @@ const INIT_CONFIG_SETTING = async () => {
17336
17337
  intervalId = null;
17337
17338
  }
17338
17339
  if (!localStorage.getItem("app_config_setting_version")) {
17339
- await _FETCH_AND_UPDATE();
17340
+ await _FETCH_AND_UPDATE(VARIABLE_FRIVATE.FILTER_SETUP);
17340
17341
  }
17341
17342
  intervalId = setInterval(() => {
17342
- _FETCH_AND_UPDATE();
17343
+ _FETCH_AND_UPDATE(VARIABLE_FRIVATE.FILTER_SETUP);
17343
17344
  }, TIME_RELOAD);
17344
17345
  };
17345
17346
  function base64ToBytesLength(base64String) {
@@ -17364,6 +17365,9 @@ const get_conf = (key, type) => {
17364
17365
  case "text":
17365
17366
  _ = GLOBAL_WINDOW_VARIABLE[key].value;
17366
17367
  break;
17368
+ case "bool":
17369
+ _ = GLOBAL_WINDOW_VARIABLE[key].value == "true" || GLOBAL_WINDOW_VARIABLE[key].value == true ? true : false;
17370
+ break;
17367
17371
  case "int":
17368
17372
  try {
17369
17373
  _ = parseInt(GLOBAL_WINDOW_VARIABLE[key].value);
@@ -17395,8 +17399,8 @@ const get_conf = (key, type) => {
17395
17399
  }
17396
17400
  return _;
17397
17401
  };
17398
- const _FETCH_AND_UPDATE = async () => {
17399
- await GetSettingConfigClient((data) => {
17402
+ const _FETCH_AND_UPDATE = async (filter) => {
17403
+ await GetSettingConfigClient(filter, (data) => {
17400
17404
  try {
17401
17405
  if (data?.isupdatetime) {
17402
17406
  TIME_RELOAD = (data?.timeupdate < 5000 || data?.timeupdate > 300000) ? 5000 : data?.timeupdate;