@vmscloud/moz-ui-grid-vue 0.1.41
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.
- package/README.md +71 -0
- package/dist/MozGrid.vue.d.ts +127 -0
- package/dist/bridge/VueRenderer.d.ts +37 -0
- package/dist/bridge/fieldBuilder.d.ts +9 -0
- package/dist/bridge/lifecycle.d.ts +6 -0
- package/dist/bridge/templateRegistry.d.ts +8 -0
- package/dist/chunks/index-BDQ0HlwR.js +3404 -0
- package/dist/chunks/index-D5KJLBGW.cjs +14 -0
- package/dist/chunks/notification.contract-BTOch6ed.js +16 -0
- package/dist/chunks/notification.contract-oFkBaE2U.cjs +1 -0
- package/dist/compat/MozGridVue.vue.d.ts +645 -0
- package/dist/compat/MozPivotVue.vue.d.ts +606 -0
- package/dist/compat/index.d.ts +9 -0
- package/dist/compat/legacyGridAliases.d.ts +8 -0
- package/dist/composables/useGridPreset.d.ts +19 -0
- package/dist/contracts/UserLayoutInstance.d.ts +38 -0
- package/dist/contracts/notification.contract.d.ts +41 -0
- package/dist/contracts/userLayout.contract.d.ts +16 -0
- package/dist/index.cjs +26 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +90599 -0
- package/dist/legacy/components/common/Dragging.d.ts +17 -0
- package/dist/legacy/components/common/Dragging.vue.d.ts +49 -0
- package/dist/legacy/components/common/custom-cell/FormulaEngine.d.ts +256 -0
- package/dist/legacy/components/common/custom-cell/FormulaInput.vue.d.ts +33 -0
- package/dist/legacy/components/common/custom-cell/GridCustomCell.vue.d.ts +23 -0
- package/dist/legacy/components/common/custom-cell/useFormulaAutocomplete.d.ts +44 -0
- package/dist/legacy/components/common/excel/ClientExcelUploadPopup.vue.d.ts +201 -0
- package/dist/legacy/components/common/excel/assets/IconDropZone.vue.d.ts +2 -0
- package/dist/legacy/components/common/excel/assets/IconFileUpload.vue.d.ts +2 -0
- package/dist/legacy/components/common/filter/GridFilter.vue.d.ts +23 -0
- package/dist/legacy/components/common/footer/GridFooter.vue.d.ts +29 -0
- package/dist/legacy/components/common/sort/GridSort.vue.d.ts +23 -0
- package/dist/legacy/components/common/toolbar/GridSearchInput.vue.d.ts +33 -0
- package/dist/legacy/components/grid/MozGridVue.vue.d.ts +2041 -0
- package/dist/legacy/components/grid/MozGridVueCore.vue.d.ts +118 -0
- package/dist/legacy/components/grid/bulk-editor/GridBulkEditor.vue.d.ts +10 -0
- package/dist/legacy/components/grid/column-settings/AlignPicker.vue.d.ts +10 -0
- package/dist/legacy/components/grid/column-settings/ColorSwatchPicker.vue.d.ts +11 -0
- package/dist/legacy/components/grid/column-settings/ColumnListItem.vue.d.ts +17 -0
- package/dist/legacy/components/grid/column-settings/ColumnOptionsPanel.vue.d.ts +32 -0
- package/dist/legacy/components/grid/column-settings/FontSizePicker.vue.d.ts +10 -0
- package/dist/legacy/components/grid/column-settings/FontStyleToggles.vue.d.ts +15 -0
- package/dist/legacy/components/grid/column-settings/MaskPresetPicker.vue.d.ts +14 -0
- package/dist/legacy/components/grid/context-menu/GridContextMenu.vue.d.ts +208 -0
- package/dist/legacy/components/grid/group-panel/GroupPanel.vue.d.ts +18 -0
- package/dist/legacy/components/grid/toolbar/ColumnPicker.vue.d.ts +17 -0
- package/dist/legacy/components/grid/toolbar/ColumnSettings.vue.d.ts +30 -0
- package/dist/legacy/components/grid/toolbar/GridOptionModal.vue.d.ts +211 -0
- package/dist/legacy/components/grid/toolbar/GridToolBox.vue.d.ts +69 -0
- package/dist/legacy/components/pivot/MozPivotVue.vue.d.ts +1868 -0
- package/dist/legacy/components/pivot/PivotContextMenu.vue.d.ts +634 -0
- package/dist/legacy/components/pivot/PivotFieldChip.vue.d.ts +16 -0
- package/dist/legacy/components/pivot/PivotFieldDropZone.vue.d.ts +26 -0
- package/dist/legacy/components/pivot/PivotFieldPanel.vue.d.ts +28 -0
- package/dist/legacy/components/pivot/PivotOptionModal.vue.d.ts +534 -0
- package/dist/legacy/components/pivot/PivotToolBox.vue.d.ts +79 -0
- package/dist/legacy/components/pivot/chart/EChart.vue.d.ts +13 -0
- package/dist/legacy/components/pivot/chart/MozPivotChart.types.d.ts +16 -0
- package/dist/legacy/components/pivot/chart/MozPivotChart.vue.d.ts +14 -0
- package/dist/legacy/components/pivot/chart/PivotChartDetail.vue.d.ts +13 -0
- package/dist/legacy/components/pivot/chart/PivotChartMini.vue.d.ts +18 -0
- package/dist/legacy/components/pivot/chart/PivotChartMultiple.vue.d.ts +18 -0
- package/dist/legacy/components/pivot/chart/PivotChartToolbar.vue.d.ts +38 -0
- package/dist/legacy/components/pivot/chart/chartUtils.d.ts +45 -0
- package/dist/legacy/components/pivot/chart/useChartData.d.ts +35 -0
- package/dist/legacy/composables/useCellTooltip.d.ts +8 -0
- package/dist/legacy/composables/useClientExcelExport.d.ts +24 -0
- package/dist/legacy/composables/useClientExcelStore.d.ts +16 -0
- package/dist/legacy/composables/useColumnFormatter.d.ts +45 -0
- package/dist/legacy/composables/useColumnSettings.d.ts +35 -0
- package/dist/legacy/composables/useContextMenu.d.ts +71 -0
- package/dist/legacy/composables/useGridBulkEditor.d.ts +36 -0
- package/dist/legacy/composables/useGridChanges.d.ts +28 -0
- package/dist/legacy/composables/useGridColumns.d.ts +37 -0
- package/dist/legacy/composables/useGridCustomCell.d.ts +34 -0
- package/dist/legacy/composables/useGridEvents.d.ts +14 -0
- package/dist/legacy/composables/useGridFilter.d.ts +38 -0
- package/dist/legacy/composables/useGridInstance.d.ts +16 -0
- package/dist/legacy/composables/useGridSelect.d.ts +18 -0
- package/dist/legacy/composables/useGridSelection.d.ts +18 -0
- package/dist/legacy/composables/useGridSort.d.ts +38 -0
- package/dist/legacy/composables/useGridUndoRedo.d.ts +28 -0
- package/dist/legacy/composables/useGridValidation.d.ts +28 -0
- package/dist/legacy/composables/useMaskPresets.d.ts +38 -0
- package/dist/legacy/composables/useSearchHighlight.d.ts +12 -0
- package/dist/legacy/icons/IconAdd.vue.d.ts +11 -0
- package/dist/legacy/icons/IconArrowDownWithTail.vue.d.ts +11 -0
- package/dist/legacy/icons/IconArrowLeft.vue.d.ts +11 -0
- package/dist/legacy/icons/IconArrowLeftWithTail.vue.d.ts +11 -0
- package/dist/legacy/icons/IconArrowRight.vue.d.ts +11 -0
- package/dist/legacy/icons/IconArrowUpCenter.vue.d.ts +11 -0
- package/dist/legacy/icons/IconArrowUpWithTail.vue.d.ts +11 -0
- package/dist/legacy/icons/IconChart.vue.d.ts +11 -0
- package/dist/legacy/icons/IconClose.vue.d.ts +13 -0
- package/dist/legacy/icons/IconColorPicker.vue.d.ts +11 -0
- package/dist/legacy/icons/IconCustomCell.vue.d.ts +11 -0
- package/dist/legacy/icons/IconDecide.vue.d.ts +11 -0
- package/dist/legacy/icons/IconDownload.vue.d.ts +11 -0
- package/dist/legacy/icons/IconDragHandler.vue.d.ts +11 -0
- package/dist/legacy/icons/IconFilter.vue.d.ts +11 -0
- package/dist/legacy/icons/IconInfoFilled.vue.d.ts +11 -0
- package/dist/legacy/icons/IconRedo.vue.d.ts +9 -0
- package/dist/legacy/icons/IconReset.vue.d.ts +9 -0
- package/dist/legacy/icons/IconResetGridToolbar.vue.d.ts +11 -0
- package/dist/legacy/icons/IconSearch.vue.d.ts +11 -0
- package/dist/legacy/icons/IconSetting.vue.d.ts +11 -0
- package/dist/legacy/icons/IconSettingFilled.vue.d.ts +11 -0
- package/dist/legacy/icons/IconSort.vue.d.ts +11 -0
- package/dist/legacy/icons/IconToastWarning.vue.d.ts +11 -0
- package/dist/legacy/icons/IconUndo.vue.d.ts +9 -0
- package/dist/legacy/icons/index.d.ts +25 -0
- package/dist/legacy/index.d.ts +69 -0
- package/dist/legacy/shared/colorPresets.d.ts +36 -0
- package/dist/legacy/store/UploadRefreshRegistry.d.ts +5 -0
- package/dist/legacy/store/excelStore.d.ts +89 -0
- package/dist/legacy/store/index.d.ts +231 -0
- package/dist/legacy/stores/index.d.ts +2 -0
- package/dist/legacy/stores/projectInfo/projectInfo.contract.d.ts +130 -0
- package/dist/legacy/stories/Autofit.stories.d.ts +9 -0
- package/dist/legacy/stories/CRUD.stories.d.ts +9 -0
- package/dist/legacy/stories/CellAttributes.stories.d.ts +19 -0
- package/dist/legacy/stories/CellMask.stories.d.ts +19 -0
- package/dist/legacy/stories/ClientExcel.stories.d.ts +8 -0
- package/dist/legacy/stories/Clipboard.stories.d.ts +12 -0
- package/dist/legacy/stories/ColumnVisibility.stories.d.ts +12 -0
- package/dist/legacy/stories/ColumnWidths.stories.d.ts +11 -0
- package/dist/legacy/stories/CustomSortFilter.stories.d.ts +7 -0
- package/dist/legacy/stories/DynamicRowHeight.stories.d.ts +13 -0
- package/dist/legacy/stories/Editors.stories.d.ts +9 -0
- package/dist/legacy/stories/EmptyState.stories.d.ts +10 -0
- package/dist/legacy/stories/FormatRow.stories.d.ts +20 -0
- package/dist/legacy/stories/Grouping.stories.d.ts +14 -0
- package/dist/legacy/stories/HeaderGroup.stories.d.ts +11 -0
- package/dist/legacy/stories/LargeData.stories.d.ts +19 -0
- package/dist/legacy/stories/MasterDetail.stories.d.ts +17 -0
- package/dist/legacy/stories/Merge.stories.d.ts +10 -0
- package/dist/legacy/stories/MultiRow.stories.d.ts +12 -0
- package/dist/legacy/stories/MultiRowCrud.stories.d.ts +11 -0
- package/dist/legacy/stories/MultiRowGroup.stories.d.ts +11 -0
- package/dist/legacy/stories/Pinning.stories.d.ts +44 -0
- package/dist/legacy/stories/Pivot.stories.d.ts +23 -0
- package/dist/legacy/stories/PivotAdvanced.stories.d.ts +20 -0
- package/dist/legacy/stories/PivotChart.stories.d.ts +23 -0
- package/dist/legacy/stories/PivotNonNumeric.stories.d.ts +27 -0
- package/dist/legacy/stories/Preset.stories.d.ts +11 -0
- package/dist/legacy/stories/ReactiveAPI.stories.d.ts +8 -0
- package/dist/legacy/stories/ReactiveSafety.stories.d.ts +28 -0
- package/dist/legacy/stories/Repro.stories.d.ts +36 -0
- package/dist/legacy/stories/RowAPI.stories.d.ts +12 -0
- package/dist/legacy/stories/SelectionModes.stories.d.ts +35 -0
- package/dist/legacy/stories/Streaming.stories.d.ts +12 -0
- package/dist/legacy/stories/Tree.stories.d.ts +13 -0
- package/dist/legacy/stories/WorkerMode.stories.d.ts +15 -0
- package/dist/legacy/stories/_helpers/localDataLoader.d.ts +7 -0
- package/dist/legacy/stories/_helpers/sampleData.d.ts +117 -0
- package/dist/legacy/types/FileParameter.d.ts +31 -0
- package/dist/legacy/types/StreamingParameter.d.ts +18 -0
- package/dist/legacy/types/excel.types.d.ts +48 -0
- package/dist/legacy/types/index.d.ts +10 -0
- package/dist/legacy/types/pivot-props.d.ts +140 -0
- package/dist/legacy/types/props.d.ts +176 -0
- package/dist/legacy/types/toolbar.d.ts +225 -0
- package/dist/legacy/utils/async/debounce.d.ts +4 -0
- package/dist/legacy/utils/crypto/crypto.d.ts +7 -0
- package/dist/legacy/utils/dialog/dialog.d.ts +19 -0
- package/dist/legacy/utils/excel/ExcelGuard.d.ts +73 -0
- package/dist/legacy/utils/excel/ExcelImportUtil.d.ts +34 -0
- package/dist/legacy/utils/excel/ExcelQueueManager.d.ts +57 -0
- package/dist/legacy/utils/excel/ExcelTaskRunner.d.ts +17 -0
- package/dist/legacy/utils/excel/ExcelTimeoutManager.d.ts +37 -0
- package/dist/legacy/utils/file.d.ts +34 -0
- package/dist/legacy/utils/http/rest.d.ts +5 -0
- package/dist/legacy/utils/id/generator.d.ts +2 -0
- package/dist/legacy/utils/index.d.ts +10 -0
- package/dist/store.cjs +1 -0
- package/dist/store.js +8 -0
- package/dist/stories/ColumnLockVisible.stories.d.ts +42 -0
- package/dist/stories/DateBooleanFilter.stories.d.ts +42 -0
- package/dist/stories/DisplayedRowApi.stories.d.ts +28 -0
- package/dist/stories/FieldId.stories.d.ts +113 -0
- package/dist/stories/GroupPanelWithoutToolbox.stories.d.ts +28 -0
- package/dist/stories/GroupRowRecycle.stories.d.ts +45 -0
- package/dist/stories/GroupTreeExpandNav.stories.d.ts +41 -0
- package/dist/stories/LargeData.stories.d.ts +20 -0
- package/dist/stories/MozGrid.stories.d.ts +51 -0
- package/dist/stories/PivotBarInitiallyOpen.stories.d.ts +69 -0
- package/dist/stories/PivotBarWithoutToolbox.stories.d.ts +39 -0
- package/dist/stories/SelectionApiPlayground.stories.d.ts +28 -0
- package/dist/stories/SingleSelectionModes.stories.d.ts +47 -0
- package/dist/stories/WideColumns.stories.d.ts +17 -0
- package/dist/style.css +1 -0
- package/dist/templates/CellEditor.d.ts +27 -0
- package/dist/templates/CellTemplate.d.ts +27 -0
- package/dist/templates/DetailTemplate.d.ts +60 -0
- package/dist/templates/GroupTemplate.d.ts +17 -0
- package/dist/templates/HeaderTemplate.d.ts +25 -0
- package/dist/types/injection-keys.d.ts +24 -0
- package/dist/types/slots.d.ts +49 -0
- package/dist/utils/excel/ExcelGuard.cjs +1 -0
- package/dist/utils/excel/ExcelGuard.js +74 -0
- package/dist/utils/excel/ExcelImportUtil.cjs +1 -0
- package/dist/utils/excel/ExcelImportUtil.js +61 -0
- package/dist/utils/excel/ExcelQueueManager.cjs +1 -0
- package/dist/utils/excel/ExcelQueueManager.js +10 -0
- package/dist/utils/excel/ExcelTaskRunner.cjs +1 -0
- package/dist/utils/excel/ExcelTaskRunner.js +12 -0
- package/dist/utils/excel/ExcelTimeoutManager.cjs +1 -0
- package/dist/utils/excel/ExcelTimeoutManager.js +420 -0
- package/docs/manual/examples.md +2385 -0
- package/docs/manual/reference.md +4695 -0
- package/docs/manual/reference_vue.md +709 -0
- package/package.json +129 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
const LOCK_PREFIX = "moz_excel_dl_lock";
|
|
2
|
+
const SESSIONS_PREFIX = "moz_excel_sessions";
|
|
3
|
+
let initialized = false;
|
|
4
|
+
const inMemoryLocks = /* @__PURE__ */ new Map();
|
|
5
|
+
const getUserLockKey = (tenantId, userId) => {
|
|
6
|
+
const t = tenantId || "none";
|
|
7
|
+
const u = userId || "unknown";
|
|
8
|
+
return `${LOCK_PREFIX}:${t}:${u}`;
|
|
9
|
+
};
|
|
10
|
+
const isLocked = (key) => {
|
|
11
|
+
const data = inMemoryLocks.get(key);
|
|
12
|
+
if (!data) return false;
|
|
13
|
+
if (data.expiresAt && Date.now() > data.expiresAt) {
|
|
14
|
+
inMemoryLocks.delete(key);
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
return true;
|
|
18
|
+
};
|
|
19
|
+
const lock = (key, sessionId, ttlMs = 5 * 60 * 1e3) => {
|
|
20
|
+
const payload = {
|
|
21
|
+
key,
|
|
22
|
+
sessionId,
|
|
23
|
+
expiresAt: Date.now() + ttlMs
|
|
24
|
+
};
|
|
25
|
+
inMemoryLocks.set(key, payload);
|
|
26
|
+
};
|
|
27
|
+
const unlock = (key) => {
|
|
28
|
+
inMemoryLocks.delete(key);
|
|
29
|
+
};
|
|
30
|
+
const initExcelGuard = () => {
|
|
31
|
+
if (initialized) return;
|
|
32
|
+
initialized = true;
|
|
33
|
+
};
|
|
34
|
+
const getSessionsKey = (tenantId, userId) => {
|
|
35
|
+
const t = tenantId || "none";
|
|
36
|
+
const u = userId || "unknown";
|
|
37
|
+
return `${SESSIONS_PREFIX}:${t}:${u}`;
|
|
38
|
+
};
|
|
39
|
+
const getAllSessions = (tenantId, userId) => {
|
|
40
|
+
const key = getSessionsKey(tenantId, userId);
|
|
41
|
+
try {
|
|
42
|
+
const raw = localStorage.getItem(key);
|
|
43
|
+
if (!raw) return {};
|
|
44
|
+
return JSON.parse(raw);
|
|
45
|
+
} catch {
|
|
46
|
+
return {};
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const setSession = (_tenantId, _userId, _sessionId, _fileName, _operationType = "download") => {
|
|
50
|
+
};
|
|
51
|
+
const updateSessionFileName = (_tenantId, _userId, _sessionId, _fileName) => {
|
|
52
|
+
};
|
|
53
|
+
const removeSession = (_tenantId, _userId, _sessionId) => {
|
|
54
|
+
};
|
|
55
|
+
const ExcelGuard = {
|
|
56
|
+
getUserLockKey,
|
|
57
|
+
isLocked,
|
|
58
|
+
lock,
|
|
59
|
+
unlock,
|
|
60
|
+
initExcelGuard
|
|
61
|
+
};
|
|
62
|
+
export {
|
|
63
|
+
ExcelGuard as default,
|
|
64
|
+
getAllSessions,
|
|
65
|
+
getSessionsKey,
|
|
66
|
+
getUserLockKey,
|
|
67
|
+
initExcelGuard,
|
|
68
|
+
isLocked,
|
|
69
|
+
lock,
|
|
70
|
+
removeSession,
|
|
71
|
+
setSession,
|
|
72
|
+
unlock,
|
|
73
|
+
updateSessionFileName
|
|
74
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../chunks/index-D5KJLBGW.cjs"),r=require("pinia"),a=a=>{const{tableID:t,flexGrid:o,primaryKeyColumns:s,usePreclear:l=!1,setUploadMessage:n,additionalColumns:i,targetStorage:u,refreshKey:d,propExclusionMessage:p=""}=a,c=e.useExcelStore(),{excelInfo:m}=r.storeToRefs(c),g=new Set(["cfg_demand"]);m.value.targetTable=t,m.value.refreshKey=d??t,m.value.columnMap=c.createColumnMapForImport(o,s),m.value.useDataPreclear=l,m.value.targetStorage=u;const y=i||{};m.value.additionalColumns=y,m.value.additionalClearConditions=y;g.has(t)?(null==n||n(p),m.value.disableMasterProperty=!0):(null==n||n(""),m.value.disableMasterProperty=!1),c.show(l)};exports.createSmartEditorImporter=e=>{const{tableID:r,flexGrid:t,primaryKeyColumns:o,setUploadMessage:s,additionalColumns:l,targetStorage:n,refreshKey:i,propExclusionMessage:u}=e;return e=>{const d=t();if(!d)return;const p=l?l():void 0;a({tableID:r,flexGrid:d,primaryKeyColumns:o(),usePreclear:e,setUploadMessage:s,additionalColumns:p,targetStorage:n,refreshKey:i,propExclusionMessage:u})}},exports.handleSmartEditorImportExcel=a;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { a as useExcelStore } from "../../chunks/index-BDQ0HlwR.js";
|
|
2
|
+
import { storeToRefs } from "pinia";
|
|
3
|
+
const handleSmartEditorImportExcel = (params) => {
|
|
4
|
+
const {
|
|
5
|
+
tableID,
|
|
6
|
+
flexGrid,
|
|
7
|
+
primaryKeyColumns,
|
|
8
|
+
usePreclear = false,
|
|
9
|
+
setUploadMessage,
|
|
10
|
+
additionalColumns,
|
|
11
|
+
targetStorage,
|
|
12
|
+
refreshKey,
|
|
13
|
+
propExclusionMessage = ""
|
|
14
|
+
} = params;
|
|
15
|
+
const excelModule = useExcelStore();
|
|
16
|
+
const { excelInfo } = storeToRefs(excelModule);
|
|
17
|
+
const PROP_EXCLUDED_TABLE_IDS = /* @__PURE__ */ new Set(["cfg_demand"]);
|
|
18
|
+
excelInfo.value.targetTable = tableID;
|
|
19
|
+
excelInfo.value.refreshKey = refreshKey ?? tableID;
|
|
20
|
+
excelInfo.value.columnMap = excelModule.createColumnMapForImport(flexGrid, primaryKeyColumns);
|
|
21
|
+
excelInfo.value.useDataPreclear = usePreclear;
|
|
22
|
+
excelInfo.value.targetStorage = targetStorage;
|
|
23
|
+
const finalAdditionalColumns = additionalColumns || {};
|
|
24
|
+
excelInfo.value.additionalColumns = finalAdditionalColumns;
|
|
25
|
+
excelInfo.value.additionalClearConditions = finalAdditionalColumns;
|
|
26
|
+
const isPropExcluded = PROP_EXCLUDED_TABLE_IDS.has(tableID);
|
|
27
|
+
if (isPropExcluded) {
|
|
28
|
+
setUploadMessage == null ? void 0 : setUploadMessage(propExclusionMessage);
|
|
29
|
+
excelInfo.value.disableMasterProperty = true;
|
|
30
|
+
} else {
|
|
31
|
+
setUploadMessage == null ? void 0 : setUploadMessage("");
|
|
32
|
+
excelInfo.value.disableMasterProperty = false;
|
|
33
|
+
}
|
|
34
|
+
excelModule.show(usePreclear);
|
|
35
|
+
};
|
|
36
|
+
const createSmartEditorImporter = (params) => {
|
|
37
|
+
const { tableID, flexGrid, primaryKeyColumns, setUploadMessage, additionalColumns, targetStorage, refreshKey, propExclusionMessage } = params;
|
|
38
|
+
return (usePreclear) => {
|
|
39
|
+
const grid = flexGrid();
|
|
40
|
+
if (!grid) {
|
|
41
|
+
console.warn("FlexGrid가 아직 초기화되지 않았습니다.");
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const additionalColumnsData = additionalColumns ? additionalColumns() : void 0;
|
|
45
|
+
handleSmartEditorImportExcel({
|
|
46
|
+
tableID,
|
|
47
|
+
flexGrid: grid,
|
|
48
|
+
primaryKeyColumns: primaryKeyColumns(),
|
|
49
|
+
usePreclear,
|
|
50
|
+
setUploadMessage,
|
|
51
|
+
additionalColumns: additionalColumnsData,
|
|
52
|
+
targetStorage,
|
|
53
|
+
refreshKey,
|
|
54
|
+
propExclusionMessage
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
export {
|
|
59
|
+
createSmartEditorImporter,
|
|
60
|
+
handleSmartEditorImportExcel
|
|
61
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),require("pinia"),require("vue"),require("./ExcelGuard.cjs");const e=require("./ExcelTimeoutManager.cjs");require("../../chunks/index-D5KJLBGW.cjs"),exports.default=e.ExcelQueueManager,exports.queue=e.queue,exports.useExcelQueueStore=e.useExcelQueueStore;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"}),require("../../chunks/notification.contract-oFkBaE2U.cjs"),require("../../chunks/index-D5KJLBGW.cjs"),require("dayjs"),require("./ExcelGuard.cjs");const e=require("./ExcelTimeoutManager.cjs");require("pinia"),require("vue"),exports.cancelExcelTask=e.cancelExcelTask,exports.startDownloadTask=e.startDownloadTask,exports.useExcelTaskStore=e.useExcelTaskStore;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import "../../chunks/notification.contract-BTOch6ed.js";
|
|
2
|
+
import "../../chunks/index-BDQ0HlwR.js";
|
|
3
|
+
import "dayjs";
|
|
4
|
+
import "./ExcelGuard.js";
|
|
5
|
+
import { c, s, u } from "./ExcelTimeoutManager.js";
|
|
6
|
+
import "pinia";
|
|
7
|
+
import "vue";
|
|
8
|
+
export {
|
|
9
|
+
c as cancelExcelTask,
|
|
10
|
+
s as startDownloadTask,
|
|
11
|
+
u as useExcelTaskStore
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=Object.defineProperty,t=(t,n,r)=>((t,n,r)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[n]=r)(t,"symbol"!=typeof n?n+"":n,r);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("pinia"),r=require("vue"),o=require("./ExcelGuard.cjs"),i=require("../../chunks/notification.contract-oFkBaE2U.cjs"),a=require("../../chunks/index-D5KJLBGW.cjs"),s=require("dayjs"),l=require("@vmscloud/moz-ui-components"),u=e=>e?btoa(encodeURIComponent(e)):"",c=Symbol.for("MozProjectInfo");function d(){const e=r.inject(c);if(!e)throw new Error("[ProjectInfo] store not provided. make sure provideProjectInfo() is called in root component (e.g., App.vue).");return e}const p=n.defineStore("excelTimeout",()=>{const e=d(),t=l.useMozLocale();return{tenantID:r.computed(()=>{var t;return(null==(t=e.tenantInfo)?void 0:t.tenantID)||""}),userID:r.computed(()=>{var t;return(null==(t=e.userInfo)?void 0:t.id)||""}),timeoutMessage:r.computed(()=>t.value.Grid.requestTimedOut)}}),v=class e{constructor(){t(this,"timers",new Map),t(this,"timeoutMs",3e5)}static getInstance(){return e.instance||(e.instance=new e),e.instance}clear(e){const t=this.timers.get(e);t&&clearTimeout(t),this.timers.delete(e)}start(e,t=this.timeoutMs){if(!e)return;this.clear(e);const n=i.useGridNotificationStore(),r=a.useExcelStore(),s=p(),l=window.setTimeout(()=>{var t,i;if(!n)return;const a=n.eventMessages.find(t=>{var n;return(null==(n=t.prop_value)?void 0:n.session_id)===e});a&&a.prop_value&&(a.prop_value.status="error",a.prop_value.error_message=a.prop_value.error_message||s.timeoutMessage),r.excelFileMap.delete(e);const l=o.getUserLockKey(s.tenantID,s.userID);o.unlock(l),null==(t=I.removeDownloadByClientId)||t.call(I,e),null==(i=I.tryStartNext)||i.call(I),o.removeSession(s.tenantID,s.userID),this.clear(e)},t);this.timers.set(e,l)}};t(v,"instance");let m=v;const _=m.getInstance(),f=n.defineStore("excelTask",()=>{const e=d(),t=r.computed(()=>e.currentProjectID),n=r.computed(()=>{var t;return(null==(t=e.tenantInfo)?void 0:t.tenantID)||""}),l=r.computed(()=>{var t;return(null==(t=e.tenantInfo)?void 0:t.tenantName)||""}),c=r.computed(()=>{var t;return(null==(t=e.userInfo)?void 0:t.id)||""}),p=r.computed(()=>{var t;return(null==(t=e.userInfo)?void 0:t.name)||""}),v=r.computed(()=>{var t;return(null==(t=e.currentProject)?void 0:t.projectNM)||""});return{startDownloadTask:async e=>{const r=a.useExcelStore(),d=i.useGridNotificationStore();if(!d){const e=o.getUserLockKey(n.value,c.value);return o.unlock(e),null}const m={...e||{}};m.project_id=m.project_id||t.value,m.api_key&&(m.data_path=`/api/aps/backend/${t.value}/${m.api_key}`,delete m.api_key),m.column_source&&(m.column_map=r.createColumnMapForExport(m.column_source),delete m.column_source),m.field_source&&(m.column_map=r.createFieldMapForExport(m.field_source),delete m.field_source),m.client_id||(m.client_id=a.generateGUID());const f=o.getUserLockKey(n.value,c.value),h=localStorage.getItem(f);if(h)try{const e=JSON.parse(h);if((null==e?void 0:e.sessionId)&&e.sessionId!==m.client_id)return null}catch{o.lock(f,m.client_id)}else o.lock(f,m.client_id);o.setSession(n.value,c.value,m.client_id,m.file_name||""),m.file_format||(m.file_format="excel"),r.excelFileMap.set(m.client_id,m.file_name),_.start(m.client_id);const g={noti_type:"progress",header_key:"text-file_download",noti_datetime:s().format("YYYY-MM-DD HH:mm:ss"),noti_sender_id:"",prop_value:{session_id:m.client_id,file_name:`${m.file_name||""}_${s().format("YYYYMMDD")}`,status:"in_progress",progress_per:0,operation_type:"download",remain_time:-1}};d.eventMessages.find(e=>{var t;return(null==(t=e.prop_value)?void 0:t.session_id)===m.client_id})||d.eventMessages.unshift(g);try{await r.requestGenerateExcel(m,{headers:{"tenant-id":u(n.value),"tenant-name":u(l.value),"project-name":u(v.value),"user-name":u(p.value)}}).then(e=>{const t=e.data.data.file_name,i=m.client_id;r.excelFileMap.set(i,t),o.updateSessionFileName(n.value,c.value,i,t);const a=d.eventMessages.find(e=>{var t;return(null==(t=e.prop_value)?void 0:t.session_id)===i});a&&a.prop_value&&(a.prop_value.file_name=t)}).catch(e=>{r.excelFileMap.delete(m.client_id);const t=d.eventMessages.find(e=>{var t;return(null==(t=e.prop_value)?void 0:t.session_id)===m.client_id});t&&t.prop_value&&(t.prop_value.status="error"),_.clear(m.client_id),o.unlock(f)})}catch(y){r.excelFileMap.delete(m.client_id),_.clear(m.client_id),o.unlock(f)}return{sessionId:m.client_id}},cancelExcelTask:async(e,t,r)=>{var a,s;if("upload"===t)return;const l=i.useGridNotificationStore();l&&l.markSessionCanceled(e),r&&await r(e);const u=o.getUserLockKey(n.value,c.value);o.unlock(u),null==(a=I.removeDownloadByClientId)||a.call(I,e),o.removeSession(n.value,c.value),null==(s=I.tryStartNext)||s.call(I)}}}),h=async e=>f().startDownloadTask(e),g=n.defineStore("excelQueue",()=>{const e=d();return{tenantID:r.computed(()=>{var t;return(null==(t=e.tenantInfo)?void 0:t.tenantID)||""}),userID:r.computed(()=>{var t;return(null==(t=e.userInfo)?void 0:t.id)||""})}}),y=class e{constructor(){t(this,"inMemoryUploadQueue",[]),t(this,"inMemoryDownloadQueue",[]),t(this,"initialized",!1)}static getInstance(){return e.instance||(e.instance=new e),e.instance}initSubscriptions(){this.initialized||(this.initialized=!0,o.initExcelGuard())}loadQueue(){return this.inMemoryDownloadQueue.slice()}saveQueue(e){this.inMemoryDownloadQueue=e}enqueueDownload(e){this.initSubscriptions();const t=this.loadQueue(),n={id:a.generateGUID(),type:"download",payload:{...e},meta:{fileName:null==e?void 0:e.file_name,createdAt:Date.now()}};return t.push(n),this.saveQueue(t),this.tryStartNext(),this.getTotalQueueLength()}getQueueLength(){return this.loadQueue().length}getUploadQueueLength(){return this.inMemoryUploadQueue.length}getTotalQueueLength(){return this.getQueueLength()+this.getUploadQueueLength()}enqueueUpload(e,t){this.initSubscriptions();const n={id:a.generateGUID(),type:"upload",start:e,meta:{fileName:t,createdAt:Date.now()}};return this.inMemoryUploadQueue.push(n),this.tryStartNext(),this.getTotalQueueLength()}removeDownloadByClientId(e){if(!e)return;const t=this.loadQueue(),n=t.findIndex(t=>{var n;return"download"===t.type&&(null==(n=t.payload)?void 0:n.client_id)===e});-1!==n&&(t.splice(n,1),this.saveQueue(t))}async tryStartNext(){this.initSubscriptions();const e=g(),t=o.getUserLockKey(e.tenantID,e.userID);if(o.isLocked(t))return;const n=this.loadQueue(),r=n.length>0?n[0]:null,i=this.inMemoryUploadQueue.length>0?this.inMemoryUploadQueue[0]:null;if(!r&&!i)return;if((()=>{var e,t;if(r&&i){return((null==(e=r.meta)?void 0:e.createdAt)??0)<=((null==(t=i.meta)?void 0:t.createdAt)??0)}return!!r})()&&"download"===(null==r?void 0:r.type)){const e={...r.payload};e.client_id||(e.client_id=a.generateGUID()),o.lock(t,e.client_id),n.shift(),this.saveQueue(n);try{await h(e)}catch(s){o.unlock(t)}return}if(i){const e=this.inMemoryUploadQueue.shift();try{await Promise.resolve(e.start())}catch(s){}return}}};t(y,"instance");let x=y;const I=x.getInstance();exports.ExcelQueueManager=x,exports.cancelExcelTask=async(e,t,n)=>f().cancelExcelTask(e,t,n),exports.default=m,exports.excelTimeoutManager=_,exports.queue=I,exports.startDownloadTask=h,exports.useExcelQueueStore=g,exports.useExcelTaskStore=f,exports.useExcelTimeoutStore=p;
|
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
import { defineStore } from "pinia";
|
|
5
|
+
import { inject, computed } from "vue";
|
|
6
|
+
import { getUserLockKey, unlock, removeSession, lock, setSession, updateSessionFileName, isLocked, initExcelGuard } from "./ExcelGuard.js";
|
|
7
|
+
import { u as useGridNotificationStore } from "../../chunks/notification.contract-BTOch6ed.js";
|
|
8
|
+
import { a as useExcelStore, g as generateGUID } from "../../chunks/index-BDQ0HlwR.js";
|
|
9
|
+
import dayjs from "dayjs";
|
|
10
|
+
import { useMozLocale } from "@vmscloud/moz-ui-components";
|
|
11
|
+
const encodeUnescapeBtoa = (text) => {
|
|
12
|
+
if (!text) return "";
|
|
13
|
+
return btoa(encodeURIComponent(text));
|
|
14
|
+
};
|
|
15
|
+
const ProjectInfoKey = Symbol.for("MozProjectInfo");
|
|
16
|
+
function useProjectInfo() {
|
|
17
|
+
const store = inject(ProjectInfoKey);
|
|
18
|
+
if (!store) {
|
|
19
|
+
throw new Error(
|
|
20
|
+
"[ProjectInfo] store not provided. make sure provideProjectInfo() is called in root component (e.g., App.vue)."
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
return store;
|
|
24
|
+
}
|
|
25
|
+
const useExcelTimeoutStore = defineStore("excelTimeout", () => {
|
|
26
|
+
const projectInfo = useProjectInfo();
|
|
27
|
+
const locale = useMozLocale();
|
|
28
|
+
const tenantID = computed(() => {
|
|
29
|
+
var _a;
|
|
30
|
+
return ((_a = projectInfo.tenantInfo) == null ? void 0 : _a.tenantID) || "";
|
|
31
|
+
});
|
|
32
|
+
const userID = computed(() => {
|
|
33
|
+
var _a;
|
|
34
|
+
return ((_a = projectInfo.userInfo) == null ? void 0 : _a.id) || "";
|
|
35
|
+
});
|
|
36
|
+
const timeoutMessage = computed(() => locale.value.Grid.requestTimedOut);
|
|
37
|
+
return {
|
|
38
|
+
tenantID,
|
|
39
|
+
userID,
|
|
40
|
+
timeoutMessage
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
const _ExcelTimeoutManager = class _ExcelTimeoutManager {
|
|
44
|
+
constructor() {
|
|
45
|
+
__publicField(this, "timers", /* @__PURE__ */ new Map());
|
|
46
|
+
__publicField(this, "timeoutMs", 5 * 60 * 1e3);
|
|
47
|
+
}
|
|
48
|
+
// timeout 시간 5분
|
|
49
|
+
static getInstance() {
|
|
50
|
+
if (!_ExcelTimeoutManager.instance) {
|
|
51
|
+
_ExcelTimeoutManager.instance = new _ExcelTimeoutManager();
|
|
52
|
+
}
|
|
53
|
+
return _ExcelTimeoutManager.instance;
|
|
54
|
+
}
|
|
55
|
+
/** 지정 세션의 타이머 해제 */
|
|
56
|
+
clear(sessionId) {
|
|
57
|
+
const timerId = this.timers.get(sessionId);
|
|
58
|
+
if (timerId) {
|
|
59
|
+
clearTimeout(timerId);
|
|
60
|
+
}
|
|
61
|
+
this.timers.delete(sessionId);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* 타임아웃 타이머 시작
|
|
65
|
+
* @param sessionId 세션 ID
|
|
66
|
+
* @param timeoutMs 타임아웃 시간 (기본 1분)
|
|
67
|
+
*/
|
|
68
|
+
start(sessionId, timeoutMs = this.timeoutMs) {
|
|
69
|
+
if (!sessionId) return;
|
|
70
|
+
this.clear(sessionId);
|
|
71
|
+
const notificationStore = useGridNotificationStore();
|
|
72
|
+
const excelStore = useExcelStore();
|
|
73
|
+
const timeoutStore = useExcelTimeoutStore();
|
|
74
|
+
const timerId = window.setTimeout(() => {
|
|
75
|
+
var _a, _b;
|
|
76
|
+
if (!notificationStore) {
|
|
77
|
+
console.warn("Notification store not available");
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const target = notificationStore.eventMessages.find((msg) => {
|
|
81
|
+
var _a2;
|
|
82
|
+
return ((_a2 = msg.prop_value) == null ? void 0 : _a2.session_id) === sessionId;
|
|
83
|
+
});
|
|
84
|
+
if (target && target.prop_value) {
|
|
85
|
+
target.prop_value.status = "error";
|
|
86
|
+
target.prop_value.error_message = target.prop_value.error_message || timeoutStore.timeoutMessage;
|
|
87
|
+
}
|
|
88
|
+
excelStore.excelFileMap.delete(sessionId);
|
|
89
|
+
const key = getUserLockKey(timeoutStore.tenantID, timeoutStore.userID);
|
|
90
|
+
unlock(key);
|
|
91
|
+
(_a = queue.removeDownloadByClientId) == null ? void 0 : _a.call(queue, sessionId);
|
|
92
|
+
(_b = queue.tryStartNext) == null ? void 0 : _b.call(queue);
|
|
93
|
+
removeSession(timeoutStore.tenantID, timeoutStore.userID);
|
|
94
|
+
this.clear(sessionId);
|
|
95
|
+
}, timeoutMs);
|
|
96
|
+
this.timers.set(sessionId, timerId);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
__publicField(_ExcelTimeoutManager, "instance");
|
|
100
|
+
let ExcelTimeoutManager = _ExcelTimeoutManager;
|
|
101
|
+
const excelTimeoutManager = ExcelTimeoutManager.getInstance();
|
|
102
|
+
const useExcelTaskStore = defineStore("excelTask", () => {
|
|
103
|
+
const projectInfo = useProjectInfo();
|
|
104
|
+
const projectID = computed(() => projectInfo.currentProjectID);
|
|
105
|
+
const tenantID = computed(() => {
|
|
106
|
+
var _a;
|
|
107
|
+
return ((_a = projectInfo.tenantInfo) == null ? void 0 : _a.tenantID) || "";
|
|
108
|
+
});
|
|
109
|
+
const tenantNM = computed(() => {
|
|
110
|
+
var _a;
|
|
111
|
+
return ((_a = projectInfo.tenantInfo) == null ? void 0 : _a.tenantName) || "";
|
|
112
|
+
});
|
|
113
|
+
const userID = computed(() => {
|
|
114
|
+
var _a;
|
|
115
|
+
return ((_a = projectInfo.userInfo) == null ? void 0 : _a.id) || "";
|
|
116
|
+
});
|
|
117
|
+
const userNM = computed(() => {
|
|
118
|
+
var _a;
|
|
119
|
+
return ((_a = projectInfo.userInfo) == null ? void 0 : _a.name) || "";
|
|
120
|
+
});
|
|
121
|
+
const projectNM = computed(() => {
|
|
122
|
+
var _a;
|
|
123
|
+
return ((_a = projectInfo.currentProject) == null ? void 0 : _a.projectNM) || "";
|
|
124
|
+
});
|
|
125
|
+
const startDownloadTask2 = async (param) => {
|
|
126
|
+
const excelModule = useExcelStore();
|
|
127
|
+
const notificationStore = useGridNotificationStore();
|
|
128
|
+
if (!notificationStore) {
|
|
129
|
+
console.warn("Notification store not available");
|
|
130
|
+
const lockKey2 = getUserLockKey(tenantID.value, userID.value);
|
|
131
|
+
unlock(lockKey2);
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
const working = { ...param || {} };
|
|
135
|
+
working.project_id = working.project_id || projectID.value;
|
|
136
|
+
if (working.api_key) {
|
|
137
|
+
working.data_path = `/api/aps/backend/${projectID.value}/${working.api_key}`;
|
|
138
|
+
delete working.api_key;
|
|
139
|
+
}
|
|
140
|
+
if (working.column_source) {
|
|
141
|
+
working.column_map = excelModule.createColumnMapForExport(working.column_source);
|
|
142
|
+
delete working.column_source;
|
|
143
|
+
}
|
|
144
|
+
if (working.field_source) {
|
|
145
|
+
working.column_map = excelModule.createFieldMapForExport(working.field_source);
|
|
146
|
+
delete working.field_source;
|
|
147
|
+
}
|
|
148
|
+
if (!working.client_id) {
|
|
149
|
+
working.client_id = generateGUID();
|
|
150
|
+
}
|
|
151
|
+
const lockKey = getUserLockKey(tenantID.value, userID.value);
|
|
152
|
+
const raw = localStorage.getItem(lockKey);
|
|
153
|
+
if (!raw) {
|
|
154
|
+
lock(lockKey, working.client_id);
|
|
155
|
+
} else {
|
|
156
|
+
try {
|
|
157
|
+
const data = JSON.parse(raw);
|
|
158
|
+
if ((data == null ? void 0 : data.sessionId) && data.sessionId !== working.client_id) {
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
} catch {
|
|
162
|
+
lock(lockKey, working.client_id);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
setSession(tenantID.value, userID.value, working.client_id, working.file_name || "");
|
|
166
|
+
if (!working.file_format) working.file_format = "excel";
|
|
167
|
+
excelModule.excelFileMap.set(working.client_id, working.file_name);
|
|
168
|
+
excelTimeoutManager.start(working.client_id);
|
|
169
|
+
const exampleMessage = {
|
|
170
|
+
noti_type: "progress",
|
|
171
|
+
header_key: "text-file_download",
|
|
172
|
+
noti_datetime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
|
|
173
|
+
noti_sender_id: "",
|
|
174
|
+
prop_value: {
|
|
175
|
+
session_id: working.client_id,
|
|
176
|
+
file_name: `${working.file_name || ""}_${dayjs().format("YYYYMMDD")}`,
|
|
177
|
+
status: "in_progress",
|
|
178
|
+
progress_per: 0,
|
|
179
|
+
operation_type: "download",
|
|
180
|
+
remain_time: -1
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
const exists = notificationStore.eventMessages.find((msg) => {
|
|
184
|
+
var _a;
|
|
185
|
+
return ((_a = msg.prop_value) == null ? void 0 : _a.session_id) === working.client_id;
|
|
186
|
+
});
|
|
187
|
+
if (!exists) {
|
|
188
|
+
notificationStore.eventMessages.unshift(exampleMessage);
|
|
189
|
+
}
|
|
190
|
+
try {
|
|
191
|
+
await excelModule.requestGenerateExcel(working, {
|
|
192
|
+
headers: {
|
|
193
|
+
"tenant-id": encodeUnescapeBtoa(tenantID.value),
|
|
194
|
+
"tenant-name": encodeUnescapeBtoa(tenantNM.value),
|
|
195
|
+
"project-name": encodeUnescapeBtoa(projectNM.value),
|
|
196
|
+
"user-name": encodeUnescapeBtoa(userNM.value)
|
|
197
|
+
}
|
|
198
|
+
}).then((result) => {
|
|
199
|
+
const finalFileName = result.data.data.file_name;
|
|
200
|
+
const sessionId = working.client_id;
|
|
201
|
+
excelModule.excelFileMap.set(sessionId, finalFileName);
|
|
202
|
+
updateSessionFileName(tenantID.value, userID.value, sessionId, finalFileName);
|
|
203
|
+
const message = notificationStore.eventMessages.find((msg) => {
|
|
204
|
+
var _a;
|
|
205
|
+
return ((_a = msg.prop_value) == null ? void 0 : _a.session_id) === sessionId;
|
|
206
|
+
});
|
|
207
|
+
if (message && message.prop_value) {
|
|
208
|
+
message.prop_value.file_name = finalFileName;
|
|
209
|
+
}
|
|
210
|
+
}).catch((e) => {
|
|
211
|
+
console.warn(e);
|
|
212
|
+
excelModule.excelFileMap.delete(working.client_id);
|
|
213
|
+
const message = notificationStore.eventMessages.find((msg) => {
|
|
214
|
+
var _a;
|
|
215
|
+
return ((_a = msg.prop_value) == null ? void 0 : _a.session_id) === working.client_id;
|
|
216
|
+
});
|
|
217
|
+
if (message && message.prop_value) {
|
|
218
|
+
message.prop_value.status = "error";
|
|
219
|
+
}
|
|
220
|
+
excelTimeoutManager.clear(working.client_id);
|
|
221
|
+
unlock(lockKey);
|
|
222
|
+
});
|
|
223
|
+
} catch (e) {
|
|
224
|
+
console.warn(e);
|
|
225
|
+
excelModule.excelFileMap.delete(working.client_id);
|
|
226
|
+
excelTimeoutManager.clear(working.client_id);
|
|
227
|
+
unlock(lockKey);
|
|
228
|
+
}
|
|
229
|
+
return { sessionId: working.client_id };
|
|
230
|
+
};
|
|
231
|
+
const cancelExcelTask2 = async (sessionId, operation, cancelFn) => {
|
|
232
|
+
var _a, _b;
|
|
233
|
+
if (operation === "upload") return;
|
|
234
|
+
const notificationStore = useGridNotificationStore();
|
|
235
|
+
if (notificationStore) {
|
|
236
|
+
notificationStore.markSessionCanceled(sessionId);
|
|
237
|
+
}
|
|
238
|
+
if (cancelFn) {
|
|
239
|
+
await cancelFn(sessionId);
|
|
240
|
+
}
|
|
241
|
+
const key = getUserLockKey(tenantID.value, userID.value);
|
|
242
|
+
unlock(key);
|
|
243
|
+
(_a = queue.removeDownloadByClientId) == null ? void 0 : _a.call(queue, sessionId);
|
|
244
|
+
removeSession(tenantID.value, userID.value);
|
|
245
|
+
(_b = queue.tryStartNext) == null ? void 0 : _b.call(queue);
|
|
246
|
+
};
|
|
247
|
+
return {
|
|
248
|
+
startDownloadTask: startDownloadTask2,
|
|
249
|
+
cancelExcelTask: cancelExcelTask2
|
|
250
|
+
};
|
|
251
|
+
});
|
|
252
|
+
const startDownloadTask = async (param) => {
|
|
253
|
+
const store = useExcelTaskStore();
|
|
254
|
+
return store.startDownloadTask(param);
|
|
255
|
+
};
|
|
256
|
+
const cancelExcelTask = async (sessionId, operation, cancelFn) => {
|
|
257
|
+
const store = useExcelTaskStore();
|
|
258
|
+
return store.cancelExcelTask(sessionId, operation, cancelFn);
|
|
259
|
+
};
|
|
260
|
+
const useExcelQueueStore = defineStore("excelQueue", () => {
|
|
261
|
+
const projectInfo = useProjectInfo();
|
|
262
|
+
const tenantID = computed(() => {
|
|
263
|
+
var _a;
|
|
264
|
+
return ((_a = projectInfo.tenantInfo) == null ? void 0 : _a.tenantID) || "";
|
|
265
|
+
});
|
|
266
|
+
const userID = computed(() => {
|
|
267
|
+
var _a;
|
|
268
|
+
return ((_a = projectInfo.userInfo) == null ? void 0 : _a.id) || "";
|
|
269
|
+
});
|
|
270
|
+
return {
|
|
271
|
+
tenantID,
|
|
272
|
+
userID
|
|
273
|
+
};
|
|
274
|
+
});
|
|
275
|
+
const _ExcelQueueManager = class _ExcelQueueManager {
|
|
276
|
+
constructor() {
|
|
277
|
+
__publicField(this, "inMemoryUploadQueue", []);
|
|
278
|
+
__publicField(this, "inMemoryDownloadQueue", []);
|
|
279
|
+
__publicField(this, "initialized", false);
|
|
280
|
+
}
|
|
281
|
+
static getInstance() {
|
|
282
|
+
if (!_ExcelQueueManager.instance) {
|
|
283
|
+
_ExcelQueueManager.instance = new _ExcelQueueManager();
|
|
284
|
+
}
|
|
285
|
+
return _ExcelQueueManager.instance;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* 초기화 훅 (단일 탭 모드에서는 실질 동작 없음)
|
|
289
|
+
*/
|
|
290
|
+
initSubscriptions() {
|
|
291
|
+
if (this.initialized) return;
|
|
292
|
+
this.initialized = true;
|
|
293
|
+
initExcelGuard();
|
|
294
|
+
}
|
|
295
|
+
/** 현재 다운로드 큐 스냅샷 반환 */
|
|
296
|
+
loadQueue() {
|
|
297
|
+
return this.inMemoryDownloadQueue.slice();
|
|
298
|
+
}
|
|
299
|
+
/** 다운로드 큐 저장 */
|
|
300
|
+
saveQueue(queue2) {
|
|
301
|
+
this.inMemoryDownloadQueue = queue2;
|
|
302
|
+
}
|
|
303
|
+
/** 다운로드 작업 추가 후 즉시 실행 시도 */
|
|
304
|
+
enqueueDownload(param) {
|
|
305
|
+
this.initSubscriptions();
|
|
306
|
+
const queue2 = this.loadQueue();
|
|
307
|
+
const task = {
|
|
308
|
+
id: generateGUID(),
|
|
309
|
+
type: "download",
|
|
310
|
+
payload: { ...param },
|
|
311
|
+
meta: { fileName: param == null ? void 0 : param.file_name, createdAt: Date.now() }
|
|
312
|
+
};
|
|
313
|
+
queue2.push(task);
|
|
314
|
+
this.saveQueue(queue2);
|
|
315
|
+
this.tryStartNext();
|
|
316
|
+
return this.getTotalQueueLength();
|
|
317
|
+
}
|
|
318
|
+
/** 다운로드 큐 길이 */
|
|
319
|
+
getQueueLength() {
|
|
320
|
+
return this.loadQueue().length;
|
|
321
|
+
}
|
|
322
|
+
/** 업로드 큐 길이 */
|
|
323
|
+
getUploadQueueLength() {
|
|
324
|
+
return this.inMemoryUploadQueue.length;
|
|
325
|
+
}
|
|
326
|
+
/** 전체 큐 길이 (다운로드+업로드) */
|
|
327
|
+
getTotalQueueLength() {
|
|
328
|
+
return this.getQueueLength() + this.getUploadQueueLength();
|
|
329
|
+
}
|
|
330
|
+
/** 업로드 작업 추가 후 즉시 실행 시도 */
|
|
331
|
+
enqueueUpload(start, fileName) {
|
|
332
|
+
this.initSubscriptions();
|
|
333
|
+
const task = {
|
|
334
|
+
id: generateGUID(),
|
|
335
|
+
type: "upload",
|
|
336
|
+
start,
|
|
337
|
+
meta: { fileName, createdAt: Date.now() }
|
|
338
|
+
};
|
|
339
|
+
this.inMemoryUploadQueue.push(task);
|
|
340
|
+
this.tryStartNext();
|
|
341
|
+
return this.getTotalQueueLength();
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* 큐에서 특정 client_id(download) 항목 제거
|
|
345
|
+
*/
|
|
346
|
+
/**
|
|
347
|
+
* 큐에서 특정 client_id(download) 항목 제거
|
|
348
|
+
*/
|
|
349
|
+
removeDownloadByClientId(clientId) {
|
|
350
|
+
if (!clientId) return;
|
|
351
|
+
const queue2 = this.loadQueue();
|
|
352
|
+
const idx = queue2.findIndex((t) => {
|
|
353
|
+
var _a;
|
|
354
|
+
return t.type === "download" && ((_a = t.payload) == null ? void 0 : _a.client_id) === clientId;
|
|
355
|
+
});
|
|
356
|
+
if (idx !== -1) {
|
|
357
|
+
queue2.splice(idx, 1);
|
|
358
|
+
this.saveQueue(queue2);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* 다음 작업 실행 시도 (다운로드 우선순위: 생성시각)
|
|
363
|
+
*/
|
|
364
|
+
async tryStartNext() {
|
|
365
|
+
this.initSubscriptions();
|
|
366
|
+
const queueStore = useExcelQueueStore();
|
|
367
|
+
const lockKey = getUserLockKey(queueStore.tenantID, queueStore.userID);
|
|
368
|
+
if (isLocked(lockKey)) return;
|
|
369
|
+
const downloadQueue = this.loadQueue();
|
|
370
|
+
const nextDownload = downloadQueue.length > 0 ? downloadQueue[0] : null;
|
|
371
|
+
const nextUpload = this.inMemoryUploadQueue.length > 0 ? this.inMemoryUploadQueue[0] : null;
|
|
372
|
+
if (!nextDownload && !nextUpload) return;
|
|
373
|
+
const shouldRunDownloadFirst = (() => {
|
|
374
|
+
var _a, _b;
|
|
375
|
+
if (nextDownload && nextUpload) {
|
|
376
|
+
const dAt = ((_a = nextDownload.meta) == null ? void 0 : _a.createdAt) ?? 0;
|
|
377
|
+
const uAt = ((_b = nextUpload.meta) == null ? void 0 : _b.createdAt) ?? 0;
|
|
378
|
+
return dAt <= uAt;
|
|
379
|
+
}
|
|
380
|
+
return !!nextDownload;
|
|
381
|
+
})();
|
|
382
|
+
if (shouldRunDownloadFirst && (nextDownload == null ? void 0 : nextDownload.type) === "download") {
|
|
383
|
+
const payload = { ...nextDownload.payload };
|
|
384
|
+
if (!payload.client_id) payload.client_id = generateGUID();
|
|
385
|
+
lock(lockKey, payload.client_id);
|
|
386
|
+
downloadQueue.shift();
|
|
387
|
+
this.saveQueue(downloadQueue);
|
|
388
|
+
try {
|
|
389
|
+
await startDownloadTask(payload);
|
|
390
|
+
} catch (e) {
|
|
391
|
+
console.warn("startDownloadTask failed:", e);
|
|
392
|
+
unlock(lockKey);
|
|
393
|
+
}
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
if (nextUpload) {
|
|
397
|
+
const task = this.inMemoryUploadQueue.shift();
|
|
398
|
+
try {
|
|
399
|
+
await Promise.resolve(task.start());
|
|
400
|
+
} catch (e) {
|
|
401
|
+
console.warn("startUploadTask failed:", e);
|
|
402
|
+
}
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
__publicField(_ExcelQueueManager, "instance");
|
|
408
|
+
let ExcelQueueManager = _ExcelQueueManager;
|
|
409
|
+
const queue = ExcelQueueManager.getInstance();
|
|
410
|
+
export {
|
|
411
|
+
ExcelQueueManager as E,
|
|
412
|
+
useExcelQueueStore as a,
|
|
413
|
+
cancelExcelTask as c,
|
|
414
|
+
ExcelTimeoutManager as default,
|
|
415
|
+
excelTimeoutManager,
|
|
416
|
+
queue as q,
|
|
417
|
+
startDownloadTask as s,
|
|
418
|
+
useExcelTaskStore as u,
|
|
419
|
+
useExcelTimeoutStore
|
|
420
|
+
};
|