dce-reactkit 3.9.4-beta-logreviewer.4 → 3.9.4-beta-logreviewer.5
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/dist/cjs/index.js +73 -27
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +73 -27
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/LogReviewer.tsx +96 -31
- package/src/server/initServer.ts +7 -0
package/dist/cjs/index.js
CHANGED
|
@@ -3561,6 +3561,8 @@ var ActionType$6;
|
|
|
3561
3561
|
ActionType["DecrementPageNumber"] = "decrement-page-number";
|
|
3562
3562
|
// Set has another page
|
|
3563
3563
|
ActionType["SetHasAnotherPage"] = "set-has-another-page";
|
|
3564
|
+
// Set the number of pages
|
|
3565
|
+
ActionType["SetNumPages"] = "set-num-pages";
|
|
3564
3566
|
})(ActionType$6 || (ActionType$6 = {}));
|
|
3565
3567
|
/**
|
|
3566
3568
|
* Reducer that executes actions
|
|
@@ -3585,7 +3587,7 @@ const reducer$7 = (state, action) => {
|
|
|
3585
3587
|
return Object.assign(Object.assign({}, state), { expandedFilterDrawer: undefined });
|
|
3586
3588
|
}
|
|
3587
3589
|
case ActionType$6.ResetFilters: {
|
|
3588
|
-
return Object.assign(Object.assign({}, state), { dateFilterState: action.initDateFilterState, contextFilterState: action.initContextFilterState, tagFilterState: action.initTagFilterState, actionErrorFilterState: action.initActionErrorFilterState, advancedFilterState: action.initAdvancedFilterState,
|
|
3590
|
+
return Object.assign(Object.assign({}, state), { dateFilterState: action.initDateFilterState, contextFilterState: action.initContextFilterState, tagFilterState: action.initTagFilterState, actionErrorFilterState: action.initActionErrorFilterState, advancedFilterState: action.initAdvancedFilterState, pageNumber: 1 });
|
|
3589
3591
|
}
|
|
3590
3592
|
case ActionType$6.UpdateDateFilterState: {
|
|
3591
3593
|
return Object.assign(Object.assign({}, state), { dateFilterState: action.dateFilterState });
|
|
@@ -3611,6 +3613,9 @@ const reducer$7 = (state, action) => {
|
|
|
3611
3613
|
case ActionType$6.SetHasAnotherPage: {
|
|
3612
3614
|
return Object.assign(Object.assign({}, state), { hasAnotherPage: action.hasAnotherPage });
|
|
3613
3615
|
}
|
|
3616
|
+
case ActionType$6.SetNumPages: {
|
|
3617
|
+
return Object.assign(Object.assign({}, state), { numPages: action.numPages });
|
|
3618
|
+
}
|
|
3614
3619
|
default: {
|
|
3615
3620
|
return state;
|
|
3616
3621
|
}
|
|
@@ -3737,29 +3742,22 @@ const LogReviewer = (props) => {
|
|
|
3737
3742
|
advancedFilterState: initAdvancedFilterState,
|
|
3738
3743
|
pageNumber: 1,
|
|
3739
3744
|
hasAnotherPage: false,
|
|
3740
|
-
|
|
3745
|
+
numPages: 1,
|
|
3741
3746
|
};
|
|
3742
3747
|
// Initialize state
|
|
3743
3748
|
const [state, dispatch] = React.useReducer(reducer$7, initialState);
|
|
3744
3749
|
// Destructure common state
|
|
3745
|
-
const { loading, logs, expandedFilterDrawer, dateFilterState, contextFilterState, tagFilterState, actionErrorFilterState, advancedFilterState, pageNumber, hasAnotherPage,
|
|
3750
|
+
const { loading, logs, expandedFilterDrawer, dateFilterState, contextFilterState, tagFilterState, actionErrorFilterState, advancedFilterState, pageNumber, hasAnotherPage, numPages, } = state;
|
|
3746
3751
|
/*------------------------------------------------------------------------*/
|
|
3747
3752
|
/* ------------------------- Component Functions ------------------------ */
|
|
3748
3753
|
/*------------------------------------------------------------------------*/
|
|
3749
3754
|
/**
|
|
3750
3755
|
* Fetch logs from the server based on current filters
|
|
3751
3756
|
*/
|
|
3752
|
-
const fetchLogs = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
3757
|
+
const fetchLogs = (opts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
3758
|
+
const { filters, pageNum, countDocuments, } = opts;
|
|
3753
3759
|
dispatch({ type: ActionType$6.StartLoading });
|
|
3754
3760
|
try {
|
|
3755
|
-
// Prepare filter parameters
|
|
3756
|
-
const filters = {
|
|
3757
|
-
dateFilterState,
|
|
3758
|
-
contextFilterState,
|
|
3759
|
-
tagFilterState,
|
|
3760
|
-
actionErrorFilterState,
|
|
3761
|
-
advancedFilterState,
|
|
3762
|
-
};
|
|
3763
3761
|
// Send filters to the server
|
|
3764
3762
|
let fetchedLogs = [];
|
|
3765
3763
|
// Get logs from server
|
|
@@ -3767,8 +3765,9 @@ const LogReviewer = (props) => {
|
|
|
3767
3765
|
path: LOG_REVIEW_GET_LOGS_ROUTE,
|
|
3768
3766
|
method: 'GET',
|
|
3769
3767
|
params: {
|
|
3770
|
-
pageNumber,
|
|
3768
|
+
pageNumber: pageNum,
|
|
3771
3769
|
filters,
|
|
3770
|
+
countDocuments,
|
|
3772
3771
|
},
|
|
3773
3772
|
});
|
|
3774
3773
|
fetchedLogs = fetchedLogs.concat(response.items);
|
|
@@ -3776,6 +3775,12 @@ const LogReviewer = (props) => {
|
|
|
3776
3775
|
type: ActionType$6.SetHasAnotherPage,
|
|
3777
3776
|
hasAnotherPage: response.hasAnotherPage,
|
|
3778
3777
|
});
|
|
3778
|
+
if (countDocuments && response.numPages) {
|
|
3779
|
+
dispatch({
|
|
3780
|
+
type: ActionType$6.SetNumPages,
|
|
3781
|
+
numPages: response.numPages,
|
|
3782
|
+
});
|
|
3783
|
+
}
|
|
3779
3784
|
// Update logs in state
|
|
3780
3785
|
dispatch({
|
|
3781
3786
|
type: ActionType$6.FinishLoading,
|
|
@@ -3787,17 +3792,6 @@ const LogReviewer = (props) => {
|
|
|
3787
3792
|
}
|
|
3788
3793
|
});
|
|
3789
3794
|
/*------------------------------------------------------------------------*/
|
|
3790
|
-
/* ------------------------- Lifecycle Functions ------------------------ */
|
|
3791
|
-
/*------------------------------------------------------------------------*/
|
|
3792
|
-
/**
|
|
3793
|
-
* Fetch logs whenever page number changes or filters are reset
|
|
3794
|
-
*/
|
|
3795
|
-
React.useEffect(() => {
|
|
3796
|
-
fetchLogs();
|
|
3797
|
-
}, [
|
|
3798
|
-
pageNumber, numTimesFiltersReset,
|
|
3799
|
-
]);
|
|
3800
|
-
/*------------------------------------------------------------------------*/
|
|
3801
3795
|
/* ------------------------------- Render ------------------------------- */
|
|
3802
3796
|
/*------------------------------------------------------------------------*/
|
|
3803
3797
|
/*----------------------------------------*/
|
|
@@ -3816,6 +3810,17 @@ const LogReviewer = (props) => {
|
|
|
3816
3810
|
/*----------------------------------------*/
|
|
3817
3811
|
const paginationControls = logs.length > 0 && (React__default["default"].createElement("div", { className: "text-center mt-3" },
|
|
3818
3812
|
React__default["default"].createElement("button", { type: "button", className: "btn btn-secondary me-2", disabled: pageNumber <= 1, onClick: () => {
|
|
3813
|
+
fetchLogs({
|
|
3814
|
+
filters: {
|
|
3815
|
+
dateFilterState,
|
|
3816
|
+
contextFilterState,
|
|
3817
|
+
tagFilterState,
|
|
3818
|
+
actionErrorFilterState,
|
|
3819
|
+
advancedFilterState,
|
|
3820
|
+
},
|
|
3821
|
+
pageNum: pageNumber - 1,
|
|
3822
|
+
countDocuments: false,
|
|
3823
|
+
});
|
|
3819
3824
|
dispatch({
|
|
3820
3825
|
type: ActionType$6.DecrementPageNumber,
|
|
3821
3826
|
});
|
|
@@ -3825,8 +3830,23 @@ const LogReviewer = (props) => {
|
|
|
3825
3830
|
React__default["default"].createElement("span", { className: "mx-3" },
|
|
3826
3831
|
"Page",
|
|
3827
3832
|
' ',
|
|
3828
|
-
pageNumber
|
|
3833
|
+
pageNumber,
|
|
3834
|
+
' ',
|
|
3835
|
+
"of",
|
|
3836
|
+
' ',
|
|
3837
|
+
numPages),
|
|
3829
3838
|
React__default["default"].createElement("button", { type: "button", className: "btn btn-secondary ms-2", disabled: !hasAnotherPage, onClick: () => {
|
|
3839
|
+
fetchLogs({
|
|
3840
|
+
filters: {
|
|
3841
|
+
dateFilterState,
|
|
3842
|
+
contextFilterState,
|
|
3843
|
+
tagFilterState,
|
|
3844
|
+
actionErrorFilterState,
|
|
3845
|
+
advancedFilterState,
|
|
3846
|
+
},
|
|
3847
|
+
pageNum: pageNumber + 1,
|
|
3848
|
+
countDocuments: false,
|
|
3849
|
+
});
|
|
3830
3850
|
dispatch({
|
|
3831
3851
|
type: ActionType$6.IncrementPageNumber,
|
|
3832
3852
|
});
|
|
@@ -3881,6 +3901,17 @@ const LogReviewer = (props) => {
|
|
|
3881
3901
|
React__default["default"].createElement(reactFontawesome.FontAwesomeIcon, { icon: freeSolidSvgIcons.faList, className: "me-2" }),
|
|
3882
3902
|
"Advanced"),
|
|
3883
3903
|
React__default["default"].createElement("button", { type: "button", id: "LogReviewer-reset-filters-button", className: "btn btn-light", "aria-label": "reset filters", onClick: () => {
|
|
3904
|
+
fetchLogs({
|
|
3905
|
+
filters: {
|
|
3906
|
+
dateFilterState: initDateFilterState,
|
|
3907
|
+
contextFilterState: initContextFilterState,
|
|
3908
|
+
tagFilterState: initTagFilterState,
|
|
3909
|
+
actionErrorFilterState: initActionErrorFilterState,
|
|
3910
|
+
advancedFilterState: initAdvancedFilterState,
|
|
3911
|
+
},
|
|
3912
|
+
pageNum: 1,
|
|
3913
|
+
countDocuments: true,
|
|
3914
|
+
});
|
|
3884
3915
|
dispatch({
|
|
3885
3916
|
type: ActionType$6.ResetFilters,
|
|
3886
3917
|
initActionErrorFilterState,
|
|
@@ -3900,7 +3931,17 @@ const LogReviewer = (props) => {
|
|
|
3900
3931
|
dispatch({
|
|
3901
3932
|
type: ActionType$6.HideFilterDrawer,
|
|
3902
3933
|
});
|
|
3903
|
-
fetchLogs(
|
|
3934
|
+
fetchLogs({
|
|
3935
|
+
filters: {
|
|
3936
|
+
dateFilterState,
|
|
3937
|
+
contextFilterState,
|
|
3938
|
+
tagFilterState,
|
|
3939
|
+
actionErrorFilterState,
|
|
3940
|
+
advancedFilterState,
|
|
3941
|
+
},
|
|
3942
|
+
pageNum: 1,
|
|
3943
|
+
countDocuments: true,
|
|
3944
|
+
});
|
|
3904
3945
|
} },
|
|
3905
3946
|
React__default["default"].createElement(reactFontawesome.FontAwesomeIcon, { icon: freeSolidSvgIcons.faSearch }),
|
|
3906
3947
|
' ',
|
|
@@ -13810,10 +13851,11 @@ const initServer = (opts) => {
|
|
|
13810
13851
|
paramTypes: {
|
|
13811
13852
|
pageNumber: ParamType$1.Int,
|
|
13812
13853
|
filters: ParamType$1.JSON,
|
|
13854
|
+
countDocuments: ParamType$1.Boolean,
|
|
13813
13855
|
},
|
|
13814
13856
|
handler: ({ params }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
13815
13857
|
// Get user info
|
|
13816
|
-
const { pageNumber, userId, isAdmin, filters, } = params;
|
|
13858
|
+
const { pageNumber, userId, isAdmin, filters, countDocuments, } = params;
|
|
13817
13859
|
const { dateFilterState, contextFilterState, tagFilterState, actionErrorFilterState, advancedFilterState, } = filters;
|
|
13818
13860
|
// Validate user
|
|
13819
13861
|
const canReview = yield canReviewLogs(userId, isAdmin);
|
|
@@ -13980,6 +14022,10 @@ const initServer = (opts) => {
|
|
|
13980
14022
|
perPage: 50,
|
|
13981
14023
|
pageNumber,
|
|
13982
14024
|
});
|
|
14025
|
+
// Count documents if requested
|
|
14026
|
+
if (countDocuments) {
|
|
14027
|
+
response.numPages = Math.ceil((yield _logCollection.count(query)) / 50);
|
|
14028
|
+
}
|
|
13983
14029
|
// Return response
|
|
13984
14030
|
return response;
|
|
13985
14031
|
}),
|