dce-reactkit 3.9.4-beta-prompt.2 → 3.9.4-beta-logreviewer.2

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/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import React__default, { useState, useRef, useEffect, useReducer, forwardRef, useContext, useLayoutEffect, createContext, useMemo, useCallback, Component, Fragment } from 'react';
3
- import { faExclamationTriangle, faHourglassEnd, faCircle, faDotCircle, faCheckSquare, faHourglass, faClipboard, faChevronDown, faChevronRight, faCloudDownloadAlt, faMinus, faCheckCircle, faXmarkCircle, faSort, faSortDown, faSortUp, faCalendar, faTag, faHammer, faList, faTimes, faSave, faTrash, faCog, faPlus } from '@fortawesome/free-solid-svg-icons';
3
+ import { faExclamationTriangle, faHourglassEnd, faCircle, faDotCircle, faCheckSquare, faHourglass, faClipboard, faChevronDown, faChevronRight, faCloudDownloadAlt, faMinus, faCheckCircle, faXmarkCircle, faSort, faSortDown, faSortUp, faArrowLeft, faArrowRight, faCalendar, faTag, faHammer, faList, faTimes, faSave, faTrash, faCog, faPlus } from '@fortawesome/free-solid-svg-icons';
4
4
  import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
5
5
  import ReactDOM, { createPortal } from 'react-dom';
6
6
  import { faCircle as faCircle$1, faSquareMinus, faSquare } from '@fortawesome/free-regular-svg-icons';
@@ -158,7 +158,6 @@ var ModalButtonType$1 = ModalButtonType;
158
158
  var ModalType;
159
159
  (function (ModalType) {
160
160
  ModalType["Okay"] = "okay";
161
- ModalType["Cancel"] = "cancel";
162
161
  ModalType["OkayCancel"] = "okay-cancel";
163
162
  ModalType["YesNo"] = "yes-no";
164
163
  ModalType["YesNoCancel"] = "yes-no-cancel";
@@ -313,9 +312,6 @@ const modalTypeToModalButtonTypes = {
313
312
  [ModalType$1.Okay]: [
314
313
  ModalButtonType$1.Okay,
315
314
  ],
316
- [ModalType$1.Cancel]: [
317
- ModalButtonType$1.Cancel,
318
- ],
319
315
  [ModalType$1.OkayCancel]: [
320
316
  ModalButtonType$1.Okay,
321
317
  ModalButtonType$1.Cancel,
@@ -1056,74 +1052,6 @@ const confirm = (title, text, opts) => __awaiter(void 0, void 0, void 0, functio
1056
1052
  });
1057
1053
  });
1058
1054
  /*----------------------------------------*/
1059
- /* --------------- Prompt -------------- */
1060
- /*----------------------------------------*/
1061
- // Stored copies of setters
1062
- let setPromptInfo;
1063
- // Function to call when prompt is closed
1064
- let onPromptClosed;
1065
- /**
1066
- * Show a prompt modal asking the user for input
1067
- * @author Yuen Ler Chow
1068
- * @param title the title text to display at the top of the prompt
1069
- * @param text the text to display in the prompt
1070
- * @param [opts={}] additional options for the prompt dialog
1071
- * @param [opts.placeholder] the placeholder text for the input field
1072
- * @param [opts.defaultText] the default text for the input field
1073
- * @param [opts.confirmButtonText=Okay] the text of the confirm button
1074
- * @param [opts.confirmButtonVariant=Variant.Dark] the variant of the confirm button
1075
- * @param [opts.cancelButtonText=Cancel] the text of the cancel button
1076
- * @param [opts.cancelButtonVariant=Variant.Secondary] the variant of the cancel button
1077
- * @returns Promise that resolves with the input string or null if canceled
1078
- */
1079
- const prompt = (title, text, opts) => __awaiter(void 0, void 0, void 0, function* () {
1080
- var _a;
1081
- // Wait for helper to exist
1082
- yield waitForHelper(() => {
1083
- return !!setPromptInfo;
1084
- });
1085
- // Fallback if prompt is not available
1086
- if (!setPromptInfo) {
1087
- const resultPassesValidation = false;
1088
- while (!resultPassesValidation) {
1089
- // eslint-disable-next-line no-alert
1090
- const result = window.prompt(`${title}\n\n${text}`, (_a = opts === null || opts === void 0 ? void 0 : opts.defaultText) !== null && _a !== void 0 ? _a : '');
1091
- if (result === null) {
1092
- return null;
1093
- }
1094
- // Validate min num chars
1095
- const minNumCharsValidationError = (((opts === null || opts === void 0 ? void 0 : opts.minNumChars) && result.length < opts.minNumChars)
1096
- ? `Please enter at least ${opts.minNumChars} characters.`
1097
- : undefined);
1098
- // Run custom validation
1099
- const customValidationError = ((opts === null || opts === void 0 ? void 0 : opts.findValidationError)
1100
- && opts.findValidationError(result));
1101
- // Show validation issue
1102
- if (minNumCharsValidationError || customValidationError) {
1103
- alert('Invalid Input', `${minNumCharsValidationError !== null && minNumCharsValidationError !== void 0 ? minNumCharsValidationError : ''} ${customValidationError !== null && customValidationError !== void 0 ? customValidationError : ''}`);
1104
- }
1105
- else {
1106
- return result;
1107
- }
1108
- }
1109
- }
1110
- // Return promise that resolves with result of prompt
1111
- return new Promise((resolve) => {
1112
- var _a;
1113
- // Setup handler
1114
- onPromptClosed = (result) => {
1115
- resolve(result);
1116
- };
1117
- // Show the prompt
1118
- setPromptInfo({
1119
- title,
1120
- text,
1121
- currentInputFieldText: ((_a = opts === null || opts === void 0 ? void 0 : opts.defaultText) !== null && _a !== void 0 ? _a : ''),
1122
- opts: (opts !== null && opts !== void 0 ? opts : {}),
1123
- });
1124
- });
1125
- });
1126
- /*----------------------------------------*/
1127
1055
  /* ------------- Fatal Error ------------ */
1128
1056
  /*----------------------------------------*/
1129
1057
  // Stored copies of setters
@@ -1139,14 +1067,14 @@ const fatalErrorHandlers = [];
1139
1067
  * @param [errorTitle] title of the error box
1140
1068
  */
1141
1069
  const showFatalError = (error, errorTitle = 'An Error Occurred') => __awaiter(void 0, void 0, void 0, function* () {
1142
- var _b, _c;
1070
+ var _a, _b;
1143
1071
  // Determine message and code
1144
1072
  const message = (typeof error === 'string'
1145
1073
  ? error.trim()
1146
- : String((_b = error.message) !== null && _b !== void 0 ? _b : 'An unknown error occurred.'));
1074
+ : String((_a = error.message) !== null && _a !== void 0 ? _a : 'An unknown error occurred.'));
1147
1075
  const code = (typeof error === 'string'
1148
1076
  ? ReactKitErrorCode$1.NoCode
1149
- : String((_c = error.code) !== null && _c !== void 0 ? _c : ReactKitErrorCode$1.NoCode));
1077
+ : String((_b = error.code) !== null && _b !== void 0 ? _b : ReactKitErrorCode$1.NoCode));
1150
1078
  // Call all fatal error listeners
1151
1079
  try {
1152
1080
  fatalErrorHandlers.forEach((handler) => {
@@ -1273,9 +1201,6 @@ const AppWrapper = (props) => {
1273
1201
  // Confirm
1274
1202
  const [confirmInfo, setConfirmInfoInner,] = useState(undefined);
1275
1203
  setConfirmInfo = setConfirmInfoInner;
1276
- // Prompt
1277
- const [promptInfo, setPromptInfoInner] = useState(undefined);
1278
- setPromptInfo = setPromptInfoInner;
1279
1204
  // Session expired
1280
1205
  const [sessionHasExpired, setSessionHasExpiredInner,] = useState(false);
1281
1206
  setSessionHasExpired = setSessionHasExpiredInner;
@@ -1306,37 +1231,6 @@ const AppWrapper = (props) => {
1306
1231
  }
1307
1232
  }, onTopOfOtherModals: true, dontAllowBackdropExit: true }, confirmInfo.text));
1308
1233
  }
1309
- /* ------------- Prompt ------------ */
1310
- if (promptInfo) {
1311
- // Run min char validation
1312
- const minNumCharsValidationError = ((promptInfo.opts.minNumChars
1313
- && promptInfo.currentInputFieldText.length < promptInfo.opts.minNumChars)
1314
- ? `Please enter at least ${promptInfo.opts.minNumChars} characters.`
1315
- : undefined);
1316
- // Run custom validation
1317
- const customValidationError = (promptInfo.opts.findValidationError
1318
- && promptInfo.opts.findValidationError(promptInfo.currentInputFieldText));
1319
- modal = (React__default.createElement(Modal, { key: `prompt-${promptInfo.title}-${promptInfo.text}`, title: promptInfo.title,
1320
- // Don't show ok button if there is a validation error
1321
- type: ((customValidationError || minNumCharsValidationError)
1322
- ? ModalType$1.Cancel
1323
- : ModalType$1.OkayCancel), okayLabel: promptInfo.opts.confirmButtonText, okayVariant: promptInfo.opts.confirmButtonVariant, cancelLabel: promptInfo.opts.cancelButtonText, cancelVariant: promptInfo.opts.cancelButtonVariant, onClose: (buttonType) => {
1324
- const result = (buttonType === ModalButtonType$1.Okay
1325
- ? promptInfo.currentInputFieldText
1326
- : null);
1327
- setPromptInfo(undefined);
1328
- if (onPromptClosed) {
1329
- onPromptClosed(result);
1330
- }
1331
- }, onTopOfOtherModals: true, dontAllowBackdropExit: true },
1332
- React__default.createElement("div", { className: "p-3" },
1333
- React__default.createElement("p", null, promptInfo.text),
1334
- React__default.createElement("input", { type: "text", className: "form-control mb-2", placeholder: promptInfo.opts.placeholder, value: promptInfo.currentInputFieldText, onChange: (e) => {
1335
- return setPromptInfo(Object.assign(Object.assign({}, promptInfo), { currentInputFieldText: e.target.value }));
1336
- } }),
1337
- minNumCharsValidationError && (React__default.createElement("div", { className: "text-danger fw-bold mt-2" }, minNumCharsValidationError)),
1338
- customValidationError && (React__default.createElement("div", { className: "text-danger fw-bold mt-2" }, customValidationError)))));
1339
- }
1340
1234
  /* ------ Custom Modal Portals ------ */
1341
1235
  // Custom modal portals
1342
1236
  const customModalPortals = [];
@@ -3615,7 +3509,7 @@ var ActionType$6;
3615
3509
  (function (ActionType) {
3616
3510
  // Show the loading bar
3617
3511
  ActionType["StartLoading"] = "start-loading";
3618
- // Finish loading one or more months of logs
3512
+ // Finish loading logs
3619
3513
  ActionType["FinishLoading"] = "finish-loading";
3620
3514
  // Reset filters to initial values
3621
3515
  ActionType["ResetFilters"] = "reset-filters";
@@ -3633,6 +3527,12 @@ var ActionType$6;
3633
3527
  ActionType["UpdateActionErrorFilterState"] = "update-action-error-filter-state";
3634
3528
  // Update the advanced filter state
3635
3529
  ActionType["UpdateAdvancedFilterState"] = "update-advanced-filter-state";
3530
+ // Increment the page number
3531
+ ActionType["IncrementPageNumber"] = "increment-page-number";
3532
+ // Decrement the page number
3533
+ ActionType["DecrementPageNumber"] = "decrement-page-number";
3534
+ // Set has another page
3535
+ ActionType["SetHasAnotherPage"] = "set-has-another-page";
3636
3536
  })(ActionType$6 || (ActionType$6 = {}));
3637
3537
  /**
3638
3538
  * Reducer that executes actions
@@ -3646,7 +3546,7 @@ const reducer$7 = (state, action) => {
3646
3546
  return Object.assign(Object.assign({}, state), { loading: true });
3647
3547
  }
3648
3548
  case ActionType$6.FinishLoading: {
3649
- return Object.assign(Object.assign({}, state), { loading: false, logMap: action.logMap });
3549
+ return Object.assign(Object.assign({}, state), { loading: false, logs: action.logs });
3650
3550
  }
3651
3551
  case ActionType$6.ToggleFilterDrawer: {
3652
3552
  return Object.assign(Object.assign({}, state), { expandedFilterDrawer: (state.expandedFilterDrawer === action.filterDrawer
@@ -3674,6 +3574,12 @@ const reducer$7 = (state, action) => {
3674
3574
  case ActionType$6.UpdateAdvancedFilterState: {
3675
3575
  return Object.assign(Object.assign({}, state), { advancedFilterState: action.advancedFilterState });
3676
3576
  }
3577
+ case ActionType$6.IncrementPageNumber: {
3578
+ return Object.assign(Object.assign({}, state), { pageNumber: state.pageNumber + 1 });
3579
+ }
3580
+ case ActionType$6.DecrementPageNumber: {
3581
+ return Object.assign(Object.assign({}, state), { pageNumber: state.pageNumber - 1 });
3582
+ }
3677
3583
  default: {
3678
3584
  return state;
3679
3585
  }
@@ -3791,115 +3697,78 @@ const LogReviewer = (props) => {
3791
3697
  // Initial state
3792
3698
  const initialState = {
3793
3699
  loading: true,
3794
- logMap: {},
3700
+ logs: [],
3795
3701
  expandedFilterDrawer: undefined,
3796
3702
  dateFilterState: initDateFilterState,
3797
3703
  contextFilterState: initContextFilterState,
3798
3704
  tagFilterState: initTagFilterState,
3799
3705
  actionErrorFilterState: initActionErrorFilterState,
3800
3706
  advancedFilterState: initAdvancedFilterState,
3707
+ pageNumber: 1,
3708
+ hasAnotherPage: false,
3801
3709
  };
3802
3710
  // Initialize state
3803
3711
  const [state, dispatch] = useReducer(reducer$7, initialState);
3804
3712
  // Destructure common state
3805
- const { loading, logMap, expandedFilterDrawer, dateFilterState, contextFilterState, tagFilterState, actionErrorFilterState, advancedFilterState, } = state;
3713
+ const { loading, logs, expandedFilterDrawer, dateFilterState, contextFilterState, tagFilterState, actionErrorFilterState, advancedFilterState, pageNumber, hasAnotherPage, } = state;
3806
3714
  /*------------------------------------------------------------------------*/
3807
3715
  /* ------------------------- Component Functions ------------------------ */
3808
3716
  /*------------------------------------------------------------------------*/
3809
3717
  /**
3810
- * Get the list of year/month combos that need to be loaded given a new
3811
- * start or end date and the existing logMap
3812
- * @author Gabe Abrams
3813
- * @param newDateFilterState the new date filter state
3814
- * @returns list of year/month combos that need to be loaded
3718
+ * Fetch logs from the server based on current filters
3815
3719
  */
3816
- const listMonthsToLoad = (newDateFilterState) => {
3817
- // List of year/month combos that need to be loaded
3818
- const toLoad = [];
3819
- // Loop through dates
3820
- let { year, month } = newDateFilterState.startDate;
3821
- while (
3822
- // Earlier year
3823
- (year < newDateFilterState.endDate.year)
3824
- // Current year but included month
3825
- || (year === newDateFilterState.endDate.year
3826
- && month <= newDateFilterState.endDate.month)) {
3827
- // Add to list if not already loaded
3828
- if (!logMap[year]
3829
- || !logMap[year][month]) {
3830
- toLoad.push({
3831
- year,
3832
- month,
3833
- });
3834
- }
3835
- // Increment
3836
- month += 1;
3837
- if (month > 12) {
3838
- month -= 12;
3839
- year += 1;
3840
- }
3841
- }
3842
- // Return
3843
- return toLoad;
3844
- };
3845
- /**
3846
- * Handle updated start/end dates (updates state, loads if necessary)
3847
- * @author Gabe Abrams
3848
- * @param newDateFilterState the new date filter state
3849
- */
3850
- const handleDateRangeUpdated = (newDateFilterState) => __awaiter(void 0, void 0, void 0, function* () {
3851
- // Update state
3852
- dispatch({
3853
- type: ActionType$6.UpdateDateFilterState,
3854
- dateFilterState: newDateFilterState,
3855
- });
3856
- // Check which year/month combos we need to load
3857
- const toLoad = listMonthsToLoad(newDateFilterState);
3858
- // If nothing to load, finished
3859
- if (toLoad.length === 0) {
3860
- return;
3861
- }
3862
- // Start loading
3863
- dispatch({
3864
- type: ActionType$6.StartLoading,
3865
- });
3866
- // Load required months
3720
+ const fetchLogs = () => __awaiter(void 0, void 0, void 0, function* () {
3721
+ dispatch({ type: ActionType$6.StartLoading });
3867
3722
  try {
3868
- for (let i = 0; i < toLoad.length; i++) {
3869
- // Destructure
3870
- const { year, month } = toLoad[i];
3871
- // Load
3872
- const logs = yield visitServerEndpoint({
3873
- path: `${LOG_REVIEW_ROUTE_PATH_PREFIX}/years/${year}/months/${month}`,
3874
- method: 'GET',
3875
- });
3876
- // Add to map
3877
- if (!logMap[year]) {
3878
- logMap[year] = {};
3879
- }
3880
- logMap[year][month] = logs;
3881
- }
3723
+ // Prepare filter parameters
3724
+ const filters = {
3725
+ startDate: dateFilterState.startDate,
3726
+ endDate: dateFilterState.endDate,
3727
+ contextFilterState,
3728
+ tagFilterState,
3729
+ actionErrorFilterState,
3730
+ advancedFilterState,
3731
+ };
3732
+ // Send filters to the server
3733
+ let fetchedLogs = [];
3734
+ const response = yield visitServerEndpoint({
3735
+ path: `${LOG_REVIEW_ROUTE_PATH_PREFIX}/logs`,
3736
+ method: 'GET',
3737
+ params: {
3738
+ pageNumber,
3739
+ filters,
3740
+ },
3741
+ });
3742
+ fetchedLogs = fetchedLogs.concat(response.items);
3743
+ dispatch({
3744
+ type: ActionType$6.SetHasAnotherPage,
3745
+ hasAnotherPage: response.hasAnotherPage,
3746
+ });
3747
+ // Update logs in state
3748
+ dispatch({
3749
+ type: ActionType$6.FinishLoading,
3750
+ logs: fetchedLogs,
3751
+ });
3882
3752
  }
3883
3753
  catch (err) {
3884
3754
  return showFatalError(err);
3885
3755
  }
3886
- // Finish loading
3887
- dispatch({
3888
- type: ActionType$6.FinishLoading,
3889
- logMap,
3890
- });
3891
3756
  });
3892
3757
  /*------------------------------------------------------------------------*/
3893
3758
  /* ------------------------- Lifecycle Functions ------------------------ */
3894
3759
  /*------------------------------------------------------------------------*/
3895
3760
  /**
3896
- * Mount
3897
- * @author Gabe Abrams
3761
+ * Fetch logs whenever filters change
3898
3762
  */
3899
3763
  useEffect(() => {
3900
- // Perform initial load
3901
- handleDateRangeUpdated(dateFilterState);
3902
- }, []);
3764
+ fetchLogs();
3765
+ }, [
3766
+ dateFilterState,
3767
+ contextFilterState,
3768
+ tagFilterState,
3769
+ actionErrorFilterState,
3770
+ advancedFilterState,
3771
+ ]);
3903
3772
  /*------------------------------------------------------------------------*/
3904
3773
  /* ------------------------------- Render ------------------------------- */
3905
3774
  /*------------------------------------------------------------------------*/
@@ -3914,703 +3783,472 @@ const LogReviewer = (props) => {
3914
3783
  React__default.createElement(LoadingSpinner, null)));
3915
3784
  }
3916
3785
  /* ------------ Review UI ----------- */
3917
- if (!loading) {
3918
- /*----------------------------------------*/
3919
- /* --------------- Filters -------------- */
3920
- /*----------------------------------------*/
3921
- // Filter toggle
3922
- const filterToggles = (React__default.createElement("div", { className: "LogReviewer-filter-toggles" },
3923
- React__default.createElement("h3", { className: "m-0" }, "Filters:"),
3924
- React__default.createElement("div", { className: "LogReviewer-filter-toggle-buttons alert alert-secondary p-2 m-0" },
3925
- React__default.createElement("button", { type: "button", id: "LogReviewer-toggle-date-filter-drawer", className: `btn btn-${FilterDrawer.Date === expandedFilterDrawer ? 'warning' : 'light'} me-2`, "aria-label": "toggle date filter drawer", onClick: () => {
3926
- dispatch({
3927
- type: ActionType$6.ToggleFilterDrawer,
3928
- filterDrawer: FilterDrawer.Date,
3929
- });
3930
- } },
3931
- React__default.createElement(FontAwesomeIcon, { icon: faCalendar, className: "me-2" }),
3932
- "Date"),
3933
- React__default.createElement("button", { type: "button", id: "LogReviewer-toggle-context-filter-drawer", className: `btn btn-${FilterDrawer.Context === expandedFilterDrawer ? 'warning' : 'light'} me-2`, "aria-label": "toggle context filter drawer", onClick: () => {
3934
- dispatch({
3935
- type: ActionType$6.ToggleFilterDrawer,
3936
- filterDrawer: FilterDrawer.Context,
3937
- });
3938
- } },
3939
- React__default.createElement(FontAwesomeIcon, { icon: faCircle, className: "me-2" }),
3940
- "Context"),
3941
- (LogMetadata.Tag && Object.keys(LogMetadata.Tag).length > 0) && (React__default.createElement("button", { type: "button", id: "LogReviewer-toggle-tag-filter-drawer", className: `btn btn-${FilterDrawer.Tag === expandedFilterDrawer ? 'warning' : 'light'} me-2`, "aria-label": "toggle tag filter drawer", onClick: () => {
3942
- dispatch({
3943
- type: ActionType$6.ToggleFilterDrawer,
3944
- filterDrawer: FilterDrawer.Tag,
3945
- });
3946
- } },
3947
- React__default.createElement(FontAwesomeIcon, { icon: faTag, className: "me-2" }),
3948
- "Tag")),
3949
- React__default.createElement("button", { type: "button", id: "LogReviewer-toggle-action-filter-drawer", className: `btn btn-${FilterDrawer.Action === expandedFilterDrawer ? 'warning' : 'light'} me-2`, "aria-label": "toggle action and error filter drawer", onClick: () => {
3950
- dispatch({
3951
- type: ActionType$6.ToggleFilterDrawer,
3952
- filterDrawer: FilterDrawer.Action,
3953
- });
3954
- } },
3955
- React__default.createElement(FontAwesomeIcon, { icon: faHammer, className: "me-2" }),
3956
- "Action"),
3957
- React__default.createElement("button", { type: "button", id: "LogReviewer-toggle-advanced-filter-drawer", className: `btn btn-${FilterDrawer.Advanced === expandedFilterDrawer ? 'warning' : 'light'} me-2`, "aria-label": "toggle advanced filter drawer", onClick: () => {
3786
+ /*----------------------------------------*/
3787
+ /* ------------ Pagination -------------- */
3788
+ /*----------------------------------------*/
3789
+ const paginationControls = logs.length > 0 && (React__default.createElement("div", { className: "text-center mt-3" },
3790
+ React__default.createElement("button", { type: "button", className: "btn btn-secondary me-2", disabled: pageNumber <= 1, onClick: () => {
3791
+ dispatch({
3792
+ type: ActionType$6.DecrementPageNumber,
3793
+ });
3794
+ } },
3795
+ React__default.createElement(FontAwesomeIcon, { icon: faArrowLeft, className: "me-2" }),
3796
+ "Previous Page"),
3797
+ React__default.createElement("span", { className: "mx-3" },
3798
+ "Page",
3799
+ ' ',
3800
+ pageNumber),
3801
+ React__default.createElement("button", { type: "button", className: "btn btn-secondary ms-2", disabled: !hasAnotherPage, onClick: () => {
3802
+ dispatch({
3803
+ type: ActionType$6.IncrementPageNumber,
3804
+ });
3805
+ } },
3806
+ "Next Page",
3807
+ React__default.createElement(FontAwesomeIcon, { icon: faArrowRight, className: "ms-2" }))));
3808
+ /*----------------------------------------*/
3809
+ /* --------------- Filters -------------- */
3810
+ /*----------------------------------------*/
3811
+ // Filter toggle
3812
+ const filterToggles = (React__default.createElement("div", { className: "LogReviewer-filter-toggles" },
3813
+ React__default.createElement("h3", { className: "m-0" }, "Filters:"),
3814
+ React__default.createElement("div", { className: "LogReviewer-filter-toggle-buttons alert alert-secondary p-2 m-0" },
3815
+ React__default.createElement("button", { type: "button", id: "LogReviewer-toggle-date-filter-drawer", className: `btn btn-${FilterDrawer.Date === expandedFilterDrawer ? 'warning' : 'light'} me-2`, "aria-label": "toggle date filter drawer", onClick: () => {
3816
+ dispatch({
3817
+ type: ActionType$6.ToggleFilterDrawer,
3818
+ filterDrawer: FilterDrawer.Date,
3819
+ });
3820
+ } },
3821
+ React__default.createElement(FontAwesomeIcon, { icon: faCalendar, className: "me-2" }),
3822
+ "Date"),
3823
+ React__default.createElement("button", { type: "button", id: "LogReviewer-toggle-context-filter-drawer", className: `btn btn-${FilterDrawer.Context === expandedFilterDrawer ? 'warning' : 'light'} me-2`, "aria-label": "toggle context filter drawer", onClick: () => {
3824
+ dispatch({
3825
+ type: ActionType$6.ToggleFilterDrawer,
3826
+ filterDrawer: FilterDrawer.Context,
3827
+ });
3828
+ } },
3829
+ React__default.createElement(FontAwesomeIcon, { icon: faCircle, className: "me-2" }),
3830
+ "Context"),
3831
+ (LogMetadata.Tag && Object.keys(LogMetadata.Tag).length > 0) && (React__default.createElement("button", { type: "button", id: "LogReviewer-toggle-tag-filter-drawer", className: `btn btn-${FilterDrawer.Tag === expandedFilterDrawer ? 'warning' : 'light'} me-2`, "aria-label": "toggle tag filter drawer", onClick: () => {
3832
+ dispatch({
3833
+ type: ActionType$6.ToggleFilterDrawer,
3834
+ filterDrawer: FilterDrawer.Tag,
3835
+ });
3836
+ } },
3837
+ React__default.createElement(FontAwesomeIcon, { icon: faTag, className: "me-2" }),
3838
+ "Tag")),
3839
+ React__default.createElement("button", { type: "button", id: "LogReviewer-toggle-action-filter-drawer", className: `btn btn-${FilterDrawer.Action === expandedFilterDrawer ? 'warning' : 'light'} me-2`, "aria-label": "toggle action and error filter drawer", onClick: () => {
3840
+ dispatch({
3841
+ type: ActionType$6.ToggleFilterDrawer,
3842
+ filterDrawer: FilterDrawer.Action,
3843
+ });
3844
+ } },
3845
+ React__default.createElement(FontAwesomeIcon, { icon: faHammer, className: "me-2" }),
3846
+ "Action"),
3847
+ React__default.createElement("button", { type: "button", id: "LogReviewer-toggle-advanced-filter-drawer", className: `btn btn-${FilterDrawer.Advanced === expandedFilterDrawer ? 'warning' : 'light'} me-2`, "aria-label": "toggle advanced filter drawer", onClick: () => {
3848
+ dispatch({
3849
+ type: ActionType$6.ToggleFilterDrawer,
3850
+ filterDrawer: FilterDrawer.Advanced,
3851
+ });
3852
+ } },
3853
+ React__default.createElement(FontAwesomeIcon, { icon: faList, className: "me-2" }),
3854
+ "Advanced"),
3855
+ React__default.createElement("button", { type: "button", id: "LogReviewer-reset-filters-button", className: "btn btn-light", "aria-label": "reset filters", onClick: () => {
3856
+ dispatch({
3857
+ type: ActionType$6.ResetFilters,
3858
+ initActionErrorFilterState,
3859
+ initAdvancedFilterState,
3860
+ initContextFilterState,
3861
+ initDateFilterState,
3862
+ initTagFilterState,
3863
+ });
3864
+ } },
3865
+ React__default.createElement(FontAwesomeIcon, { icon: faTimes }),
3866
+ ' ',
3867
+ "Reset"))));
3868
+ // Filter drawer
3869
+ let filterDrawer;
3870
+ if (expandedFilterDrawer) {
3871
+ if (expandedFilterDrawer === FilterDrawer.Date) {
3872
+ filterDrawer = (React__default.createElement(TabBox, { title: "Date" },
3873
+ React__default.createElement(SimpleDateChooser, { ariaLabel: "filter start date", name: "filter-start-date", year: dateFilterState.startDate.year, month: dateFilterState.startDate.month, day: dateFilterState.startDate.day, chooseFromPast: true, numMonthsToShow: 36, onChange: (month, day, year) => {
3874
+ dateFilterState.startDate = { month, day, year };
3958
3875
  dispatch({
3959
- type: ActionType$6.ToggleFilterDrawer,
3960
- filterDrawer: FilterDrawer.Advanced,
3876
+ type: ActionType$6.UpdateDateFilterState,
3877
+ dateFilterState,
3961
3878
  });
3962
- } },
3963
- React__default.createElement(FontAwesomeIcon, { icon: faList, className: "me-2" }),
3964
- "Advanced"),
3965
- React__default.createElement("button", { type: "button", id: "LogReviewer-reset-filters-button", className: "btn btn-light", "aria-label": "reset filters", onClick: () => {
3879
+ } }),
3880
+ ' ',
3881
+ "to",
3882
+ ' ',
3883
+ React__default.createElement(SimpleDateChooser, { ariaLabel: "filter end date", name: "filter-end-date", year: dateFilterState.endDate.year, month: dateFilterState.endDate.month, day: dateFilterState.endDate.day, chooseFromPast: true, numMonthsToShow: 12, onChange: (month, day, year) => {
3884
+ if (year < dateFilterState.startDate.year
3885
+ || (year === dateFilterState.startDate.year
3886
+ && month < dateFilterState.startDate.month)
3887
+ || (year === dateFilterState.startDate.year
3888
+ && month === dateFilterState.startDate.month
3889
+ && day < dateFilterState.startDate.day)) {
3890
+ return alert('Invalid Start Date', 'The start date cannot be before the end date.');
3891
+ }
3892
+ dateFilterState.endDate = { month, day, year };
3966
3893
  dispatch({
3967
- type: ActionType$6.ResetFilters,
3968
- initActionErrorFilterState,
3969
- initAdvancedFilterState,
3970
- initContextFilterState,
3971
- initDateFilterState,
3972
- initTagFilterState,
3894
+ type: ActionType$6.UpdateDateFilterState,
3895
+ dateFilterState,
3973
3896
  });
3974
- } },
3975
- React__default.createElement(FontAwesomeIcon, { icon: faTimes }),
3976
- ' ',
3977
- "Reset"))));
3978
- // Filter drawer
3979
- let filterDrawer;
3980
- if (expandedFilterDrawer) {
3981
- if (expandedFilterDrawer === FilterDrawer.Date) {
3982
- filterDrawer = (React__default.createElement(TabBox, { title: "Date" },
3983
- React__default.createElement(SimpleDateChooser, { ariaLabel: "filter start date", name: "filter-start-date", year: dateFilterState.startDate.year, month: dateFilterState.startDate.month, day: dateFilterState.startDate.day, chooseFromPast: true, numMonthsToShow: 36, onChange: (month, day, year) => {
3984
- dateFilterState.startDate = { month, day, year };
3985
- handleDateRangeUpdated(dateFilterState);
3986
- } }),
3987
- ' ',
3988
- "to",
3989
- ' ',
3990
- React__default.createElement(SimpleDateChooser, { ariaLabel: "filter end date", name: "filter-end-date", year: dateFilterState.endDate.year, month: dateFilterState.endDate.month, day: dateFilterState.endDate.day, chooseFromPast: true, numMonthsToShow: 12, onChange: (month, day, year) => {
3991
- if (year < dateFilterState.startDate.year
3992
- || (year === dateFilterState.startDate.year
3993
- && month < dateFilterState.startDate.month)
3994
- || (year === dateFilterState.startDate.year
3995
- && month === dateFilterState.startDate.month
3996
- && day < dateFilterState.startDate.day)) {
3997
- return alert('Invalid Start Date', 'The start date cannot be before the end date.');
3998
- }
3999
- dateFilterState.endDate = { month, day, year };
4000
- handleDateRangeUpdated(dateFilterState);
4001
- } })));
4002
- }
4003
- else if (expandedFilterDrawer === FilterDrawer.Context) {
4004
- // Create item picker items
4005
- const builtInPickableItem = {
4006
- id: 'built-in-contexts',
4007
- name: 'Auto-logged',
4008
- isGroup: true,
4009
- children: [],
4010
- };
4011
- const pickableItems = [];
4012
- Object.keys(contextMap)
4013
- .forEach((context) => {
4014
- const value = contextMap[context];
4015
- if (typeof value === 'string') {
4016
- // No subcategories
4017
- const item = {
4018
- id: context,
4019
- name: genHumanReadableName(context),
4020
- isGroup: false,
4021
- checked: !!contextFilterState[context],
4022
- };
4023
- // Add built-in items to its own folder
4024
- const isBuiltIn = context in LogBuiltInMetadata.Context;
4025
- if (isBuiltIn) {
4026
- // Add to built-in pickable item
4027
- builtInPickableItem.children.push(item);
4028
- }
4029
- else {
4030
- // Add to pickable items list
4031
- pickableItems.push(item);
4032
- }
4033
- return;
4034
- }
4035
- // Has subcategories
4036
- const children = (Object.keys(value)
4037
- // Remove parent name
4038
- .filter((subcontext) => {
4039
- return subcontext !== '_';
4040
- })
4041
- // Create child pickable items
4042
- .map((subcontext) => {
4043
- return {
4044
- id: subcontext,
4045
- name: genHumanReadableName(subcontext),
4046
- isGroup: false,
4047
- checked: contextFilterState[context][subcontext],
4048
- };
4049
- }));
3897
+ } })));
3898
+ }
3899
+ else if (expandedFilterDrawer === FilterDrawer.Context) {
3900
+ // Create item picker items
3901
+ const builtInPickableItem = {
3902
+ id: 'built-in-contexts',
3903
+ name: 'Auto-logged',
3904
+ isGroup: true,
3905
+ children: [],
3906
+ };
3907
+ const pickableItems = [];
3908
+ Object.keys(contextMap)
3909
+ .forEach((context) => {
3910
+ const value = contextMap[context];
3911
+ if (typeof value === 'string') {
3912
+ // No subcategories
4050
3913
  const item = {
4051
3914
  id: context,
4052
3915
  name: genHumanReadableName(context),
4053
- isGroup: true,
4054
- children,
3916
+ isGroup: false,
3917
+ checked: !!contextFilterState[context],
4055
3918
  };
4056
- pickableItems.push(item);
4057
- });
4058
- // Add built-in contexts to end ofl ist
4059
- pickableItems.push(builtInPickableItem);
4060
- // Create filter UI
4061
- filterDrawer = (React__default.createElement(ItemPicker, { title: "Context", items: pickableItems, onChanged: (updatedItems) => {
4062
- // Update our state
4063
- updatedItems.forEach((pickableItem) => {
4064
- if (pickableItem.isGroup) {
4065
- // Has subcontexts
4066
- if (pickableItem.id === 'built-in-contexts') {
4067
- // Built-in
4068
- // Treat as if these were top-level contexts
4069
- pickableItem.children.forEach((subcontextItem) => {
4070
- contextFilterState[subcontextItem.id] = ('checked' in subcontextItem
4071
- && subcontextItem.checked);
4072
- });
4073
- }
4074
- else {
4075
- // Not built-in
4076
- pickableItem.children.forEach((subcontextItem) => {
4077
- if (!subcontextItem.isGroup) {
4078
- contextFilterState[pickableItem.id][subcontextItem.id] = (subcontextItem.checked);
4079
- }
4080
- });
4081
- }
3919
+ // Add built-in items to its own folder
3920
+ const isBuiltIn = context in LogBuiltInMetadata.Context;
3921
+ if (isBuiltIn) {
3922
+ // Add to built-in pickable item
3923
+ builtInPickableItem.children.push(item);
3924
+ }
3925
+ else {
3926
+ // Add to pickable items list
3927
+ pickableItems.push(item);
3928
+ }
3929
+ return;
3930
+ }
3931
+ // Has subcategories
3932
+ const children = (Object.keys(value)
3933
+ // Remove parent name
3934
+ .filter((subcontext) => {
3935
+ return subcontext !== '_';
3936
+ })
3937
+ // Create child pickable items
3938
+ .map((subcontext) => {
3939
+ return {
3940
+ id: subcontext,
3941
+ name: genHumanReadableName(subcontext),
3942
+ isGroup: false,
3943
+ checked: contextFilterState[context][subcontext],
3944
+ };
3945
+ }));
3946
+ const item = {
3947
+ id: context,
3948
+ name: genHumanReadableName(context),
3949
+ isGroup: true,
3950
+ children,
3951
+ };
3952
+ pickableItems.push(item);
3953
+ });
3954
+ // Add built-in contexts to end ofl ist
3955
+ pickableItems.push(builtInPickableItem);
3956
+ // Create filter UI
3957
+ filterDrawer = (React__default.createElement(ItemPicker, { title: "Context", items: pickableItems, onChanged: (updatedItems) => {
3958
+ // Update our state
3959
+ updatedItems.forEach((pickableItem) => {
3960
+ if (pickableItem.isGroup) {
3961
+ // Has subcontexts
3962
+ if (pickableItem.id === 'built-in-contexts') {
3963
+ // Built-in
3964
+ // Treat as if these were top-level contexts
3965
+ pickableItem.children.forEach((subcontextItem) => {
3966
+ contextFilterState[subcontextItem.id] = ('checked' in subcontextItem
3967
+ && subcontextItem.checked);
3968
+ });
4082
3969
  }
4083
3970
  else {
4084
- // No subcontexts
4085
- contextFilterState[pickableItem.id] = (pickableItem.checked);
3971
+ // Not built-in
3972
+ pickableItem.children.forEach((subcontextItem) => {
3973
+ if (!subcontextItem.isGroup) {
3974
+ contextFilterState[pickableItem.id][subcontextItem.id] = (subcontextItem.checked);
3975
+ }
3976
+ });
4086
3977
  }
4087
- });
4088
- dispatch({
4089
- type: ActionType$6.UpdateContextFilterState,
4090
- contextFilterState,
4091
- });
4092
- } }));
4093
- }
4094
- else if (expandedFilterDrawer === FilterDrawer.Tag) {
4095
- // Create filter UI
4096
- filterDrawer = (React__default.createElement(TabBox, { title: "Tags" },
4097
- React__default.createElement("div", null, "If any tags are selected, logs must contain at least one (but not necessarily all) of the selected tags."),
4098
- React__default.createElement("div", { className: "d-flex gap-1 flex-wrap" }, Object.keys((_d = LogMetadata.Tag) !== null && _d !== void 0 ? _d : {})
4099
- .map((tag) => {
4100
- const description = genHumanReadableName(tag);
4101
- return (React__default.createElement(CheckboxButton, { key: tag, id: `LogReviewer-tag-${tag}-checkbox`, text: description, ariaLabel: `require that logs be tagged with "${description}" or any other selected tag`, checked: tagFilterState[tag], onChanged: (checked) => {
4102
- tagFilterState[tag] = checked;
3978
+ }
3979
+ else {
3980
+ // No subcontexts
3981
+ contextFilterState[pickableItem.id] = (pickableItem.checked);
3982
+ }
3983
+ });
3984
+ dispatch({
3985
+ type: ActionType$6.UpdateContextFilterState,
3986
+ contextFilterState,
3987
+ });
3988
+ } }));
3989
+ }
3990
+ else if (expandedFilterDrawer === FilterDrawer.Tag) {
3991
+ // Create filter UI
3992
+ filterDrawer = (React__default.createElement(TabBox, { title: "Tags" },
3993
+ React__default.createElement("div", null, "If any tags are selected, logs must contain at least one (but not necessarily all) of the selected tags."),
3994
+ React__default.createElement("div", { className: "d-flex gap-1 flex-wrap" }, Object.keys((_d = LogMetadata.Tag) !== null && _d !== void 0 ? _d : {})
3995
+ .map((tag) => {
3996
+ const description = genHumanReadableName(tag);
3997
+ return (React__default.createElement(CheckboxButton, { key: tag, id: `LogReviewer-tag-${tag}-checkbox`, text: description, ariaLabel: `require that logs be tagged with "${description}" or any other selected tag`, checked: tagFilterState[tag], onChanged: (checked) => {
3998
+ tagFilterState[tag] = checked;
3999
+ dispatch({
4000
+ type: ActionType$6.UpdateTagFilterState,
4001
+ tagFilterState,
4002
+ });
4003
+ } }));
4004
+ }))));
4005
+ }
4006
+ else if (expandedFilterDrawer === FilterDrawer.Action) {
4007
+ // Create filter UI
4008
+ filterDrawer = (React__default.createElement(React__default.Fragment, null,
4009
+ React__default.createElement(TabBox, { title: "Log Type" },
4010
+ React__default.createElement(RadioButton, { id: "LogReviewer-type-all", text: "All Logs", onSelected: () => {
4011
+ actionErrorFilterState.type = undefined;
4012
+ dispatch({
4013
+ type: ActionType$6.UpdateActionErrorFilterState,
4014
+ actionErrorFilterState,
4015
+ });
4016
+ }, ariaLabel: "show logs of all types", selected: actionErrorFilterState.type === undefined }),
4017
+ React__default.createElement(RadioButton, { id: "LogReviewer-type-action-only", text: "Action Logs Only", onSelected: () => {
4018
+ actionErrorFilterState.type = LogType$1.Action;
4019
+ dispatch({
4020
+ type: ActionType$6.UpdateActionErrorFilterState,
4021
+ actionErrorFilterState,
4022
+ });
4023
+ }, ariaLabel: "only show action logs", selected: actionErrorFilterState.type === LogType$1.Action }),
4024
+ React__default.createElement(RadioButton, { id: "LogReviewer-type-error-only", text: "Action Error Only", onSelected: () => {
4025
+ actionErrorFilterState.type = LogType$1.Error;
4026
+ dispatch({
4027
+ type: ActionType$6.UpdateActionErrorFilterState,
4028
+ actionErrorFilterState,
4029
+ });
4030
+ }, ariaLabel: "only show error logs", selected: actionErrorFilterState.type === LogType$1.Error, noMarginOnRight: true })),
4031
+ (actionErrorFilterState.type === undefined
4032
+ || actionErrorFilterState.type === LogType$1.Action) && (React__default.createElement(TabBox, { title: "Action Log Details" },
4033
+ React__default.createElement(ButtonInputGroup, { label: "Action", className: "mb-2", wrapButtonsAndAddGaps: true }, Object.keys(LogAction$1)
4034
+ .map((action) => {
4035
+ const description = genHumanReadableName(action);
4036
+ return (React__default.createElement(CheckboxButton, { key: action, id: `LogReviewer-action-${action}-checkbox`, text: description, ariaLabel: `include logs with action type "${description}" in results`, noMarginOnRight: true, checked: actionErrorFilterState.action[action], onChanged: (checked) => {
4037
+ actionErrorFilterState.action[action] = checked;
4103
4038
  dispatch({
4104
- type: ActionType$6.UpdateTagFilterState,
4105
- tagFilterState,
4039
+ type: ActionType$6.UpdateActionErrorFilterState,
4040
+ actionErrorFilterState,
4106
4041
  });
4107
4042
  } }));
4108
- }))));
4109
- }
4110
- else if (expandedFilterDrawer === FilterDrawer.Action) {
4111
- // Create filter UI
4112
- filterDrawer = (React__default.createElement(React__default.Fragment, null,
4113
- React__default.createElement(TabBox, { title: "Log Type" },
4114
- React__default.createElement(RadioButton, { id: "LogReviewer-type-all", text: "All Logs", onSelected: () => {
4115
- actionErrorFilterState.type = undefined;
4043
+ })),
4044
+ React__default.createElement(ButtonInputGroup, { label: "Target", wrapButtonsAndAddGaps: true }, Object.keys(targetMap)
4045
+ .map((target) => {
4046
+ const description = genHumanReadableName(target);
4047
+ return (React__default.createElement(CheckboxButton, { key: target, id: `LogReviewer-target-${target}-checkbox`, text: description, ariaLabel: `include logs with target "${description}" in results`, checked: actionErrorFilterState.target[target], noMarginOnRight: true, onChanged: (checked) => {
4048
+ actionErrorFilterState.target[target] = checked;
4116
4049
  dispatch({
4117
4050
  type: ActionType$6.UpdateActionErrorFilterState,
4118
4051
  actionErrorFilterState,
4119
4052
  });
4120
- }, ariaLabel: "show logs of all types", selected: actionErrorFilterState.type === undefined }),
4121
- React__default.createElement(RadioButton, { id: "LogReviewer-type-action-only", text: "Action Logs Only", onSelected: () => {
4122
- actionErrorFilterState.type = LogType$1.Action;
4053
+ } }));
4054
+ })))),
4055
+ (actionErrorFilterState.type === undefined
4056
+ || actionErrorFilterState.type === LogType$1.Error) && (React__default.createElement(TabBox, { title: "Error Log Details" },
4057
+ React__default.createElement("div", { className: "input-group mb-2" },
4058
+ React__default.createElement("span", { className: "input-group-text" }, "Error Message"),
4059
+ React__default.createElement("input", { type: "text", className: "form-control", "aria-label": "query for error message", value: actionErrorFilterState.errorMessage, placeholder: "e.g. undefined is not a function", onChange: (e) => {
4060
+ actionErrorFilterState.errorMessage = e.target.value;
4123
4061
  dispatch({
4124
4062
  type: ActionType$6.UpdateActionErrorFilterState,
4125
4063
  actionErrorFilterState,
4126
4064
  });
4127
- }, ariaLabel: "only show action logs", selected: actionErrorFilterState.type === LogType$1.Action }),
4128
- React__default.createElement(RadioButton, { id: "LogReviewer-type-error-only", text: "Action Error Only", onSelected: () => {
4129
- actionErrorFilterState.type = LogType$1.Error;
4065
+ } })),
4066
+ React__default.createElement("div", { className: "input-group mb-2" },
4067
+ React__default.createElement("span", { className: "input-group-text" }, "Error Code"),
4068
+ React__default.createElement("input", { type: "text", className: "form-control", "aria-label": "query for error code", value: actionErrorFilterState.errorCode, placeholder: "e.g. GC22", onChange: (e) => {
4069
+ actionErrorFilterState.errorCode = ((e.target.value)
4070
+ .trim()
4071
+ .toUpperCase());
4130
4072
  dispatch({
4131
4073
  type: ActionType$6.UpdateActionErrorFilterState,
4132
4074
  actionErrorFilterState,
4133
4075
  });
4134
- }, ariaLabel: "only show error logs", selected: actionErrorFilterState.type === LogType$1.Error, noMarginOnRight: true })),
4135
- (actionErrorFilterState.type === undefined
4136
- || actionErrorFilterState.type === LogType$1.Action) && (React__default.createElement(TabBox, { title: "Action Log Details" },
4137
- React__default.createElement(ButtonInputGroup, { label: "Action", className: "mb-2", wrapButtonsAndAddGaps: true }, Object.keys(LogAction$1)
4138
- .map((action) => {
4139
- const description = genHumanReadableName(action);
4140
- return (React__default.createElement(CheckboxButton, { key: action, id: `LogReviewer-action-${action}-checkbox`, text: description, ariaLabel: `include logs with action type "${description}" in results`, noMarginOnRight: true, checked: actionErrorFilterState.action[action], onChanged: (checked) => {
4141
- actionErrorFilterState.action[action] = checked;
4142
- dispatch({
4143
- type: ActionType$6.UpdateActionErrorFilterState,
4144
- actionErrorFilterState,
4145
- });
4146
- } }));
4147
- })),
4148
- React__default.createElement(ButtonInputGroup, { label: "Target", wrapButtonsAndAddGaps: true }, Object.keys(targetMap)
4149
- .map((target) => {
4150
- const description = genHumanReadableName(target);
4151
- return (React__default.createElement(CheckboxButton, { key: target, id: `LogReviewer-target-${target}-checkbox`, text: description, ariaLabel: `include logs with target "${description}" in results`, checked: actionErrorFilterState.target[target], noMarginOnRight: true, onChanged: (checked) => {
4152
- actionErrorFilterState.target[target] = checked;
4153
- dispatch({
4154
- type: ActionType$6.UpdateActionErrorFilterState,
4155
- actionErrorFilterState,
4156
- });
4157
- } }));
4158
- })))),
4159
- (actionErrorFilterState.type === undefined
4160
- || actionErrorFilterState.type === LogType$1.Error) && (React__default.createElement(TabBox, { title: "Error Log Details" },
4161
- React__default.createElement("div", { className: "input-group mb-2" },
4162
- React__default.createElement("span", { className: "input-group-text" }, "Error Message"),
4163
- React__default.createElement("input", { type: "text", className: "form-control", "aria-label": "query for error message", value: actionErrorFilterState.errorMessage, placeholder: "e.g. undefined is not a function", onChange: (e) => {
4164
- actionErrorFilterState.errorMessage = e.target.value;
4165
- dispatch({
4166
- type: ActionType$6.UpdateActionErrorFilterState,
4167
- actionErrorFilterState,
4168
- });
4169
- } })),
4170
- React__default.createElement("div", { className: "input-group mb-2" },
4171
- React__default.createElement("span", { className: "input-group-text" }, "Error Code"),
4172
- React__default.createElement("input", { type: "text", className: "form-control", "aria-label": "query for error code", value: actionErrorFilterState.errorCode, placeholder: "e.g. GC22", onChange: (e) => {
4173
- actionErrorFilterState.errorCode = ((e.target.value)
4174
- .trim()
4175
- .toUpperCase());
4176
- dispatch({
4177
- type: ActionType$6.UpdateActionErrorFilterState,
4178
- actionErrorFilterState,
4179
- });
4180
- } }))))));
4181
- }
4182
- else if (expandedFilterDrawer === FilterDrawer.Advanced) {
4183
- // Create advanced filter ui
4184
- filterDrawer = (React__default.createElement(React__default.Fragment, null,
4185
- React__default.createElement(TabBox, { title: "User" },
4186
- React__default.createElement("div", { className: "input-group mb-2" },
4187
- React__default.createElement("span", { className: "input-group-text" }, "User First Name"),
4188
- React__default.createElement("input", { type: "text", className: "form-control", "aria-label": "query for user first name", value: advancedFilterState.userFirstName, placeholder: "e.g. Divardo", onChange: (e) => {
4189
- advancedFilterState.userFirstName = e.target.value;
4190
- dispatch({
4191
- type: ActionType$6.UpdateAdvancedFilterState,
4192
- advancedFilterState,
4193
- });
4194
- } })),
4195
- React__default.createElement("div", { className: "input-group mb-2" },
4196
- React__default.createElement("span", { className: "input-group-text" }, "User Last Name"),
4197
- React__default.createElement("input", { type: "text", className: "form-control", "aria-label": "query for user last name", value: advancedFilterState.userLastName, placeholder: "e.g. Calicci", onChange: (e) => {
4198
- advancedFilterState.userLastName = e.target.value;
4199
- dispatch({
4200
- type: ActionType$6.UpdateAdvancedFilterState,
4201
- advancedFilterState,
4202
- });
4203
- } })),
4204
- React__default.createElement("div", { className: "input-group mb-2" },
4205
- React__default.createElement("span", { className: "input-group-text" }, "User Email"),
4206
- React__default.createElement("input", { type: "text", className: "form-control", "aria-label": "query for user email", value: advancedFilterState.userEmail, placeholder: "e.g. calicci@fas.harvard.edu", onChange: (e) => {
4207
- advancedFilterState.userEmail = ((e.target.value)
4076
+ } }))))));
4077
+ }
4078
+ else if (expandedFilterDrawer === FilterDrawer.Advanced) {
4079
+ // Create advanced filter ui
4080
+ filterDrawer = (React__default.createElement(React__default.Fragment, null,
4081
+ React__default.createElement(TabBox, { title: "User" },
4082
+ React__default.createElement("div", { className: "input-group mb-2" },
4083
+ React__default.createElement("span", { className: "input-group-text" }, "User First Name"),
4084
+ React__default.createElement("input", { type: "text", className: "form-control", "aria-label": "query for user first name", value: advancedFilterState.userFirstName, placeholder: "e.g. Divardo", onChange: (e) => {
4085
+ advancedFilterState.userFirstName = e.target.value;
4086
+ dispatch({
4087
+ type: ActionType$6.UpdateAdvancedFilterState,
4088
+ advancedFilterState,
4089
+ });
4090
+ } })),
4091
+ React__default.createElement("div", { className: "input-group mb-2" },
4092
+ React__default.createElement("span", { className: "input-group-text" }, "User Last Name"),
4093
+ React__default.createElement("input", { type: "text", className: "form-control", "aria-label": "query for user last name", value: advancedFilterState.userLastName, placeholder: "e.g. Calicci", onChange: (e) => {
4094
+ advancedFilterState.userLastName = e.target.value;
4095
+ dispatch({
4096
+ type: ActionType$6.UpdateAdvancedFilterState,
4097
+ advancedFilterState,
4098
+ });
4099
+ } })),
4100
+ React__default.createElement("div", { className: "input-group mb-2" },
4101
+ React__default.createElement("span", { className: "input-group-text" }, "User Email"),
4102
+ React__default.createElement("input", { type: "text", className: "form-control", "aria-label": "query for user email", value: advancedFilterState.userEmail, placeholder: "e.g. calicci@fas.harvard.edu", onChange: (e) => {
4103
+ advancedFilterState.userEmail = ((e.target.value)
4104
+ .trim());
4105
+ dispatch({
4106
+ type: ActionType$6.UpdateAdvancedFilterState,
4107
+ advancedFilterState,
4108
+ });
4109
+ } })),
4110
+ React__default.createElement("div", { className: "input-group mb-2" },
4111
+ React__default.createElement("span", { className: "input-group-text" }, "User Canvas Id"),
4112
+ React__default.createElement("input", { type: "text", className: "form-control", "aria-label": "query for user canvas id", value: advancedFilterState.userId, placeholder: "e.g. 104985", onChange: (e) => {
4113
+ const { value } = e.target;
4114
+ // Only update if value contains only numbers
4115
+ if (/^\d+$/.test(value)) {
4116
+ advancedFilterState.userId = ((e.target.value)
4208
4117
  .trim());
4209
- dispatch({
4210
- type: ActionType$6.UpdateAdvancedFilterState,
4211
- advancedFilterState,
4212
- });
4213
- } })),
4214
- React__default.createElement("div", { className: "input-group mb-2" },
4215
- React__default.createElement("span", { className: "input-group-text" }, "User Canvas Id"),
4216
- React__default.createElement("input", { type: "text", className: "form-control", "aria-label": "query for user canvas id", value: advancedFilterState.userId, placeholder: "e.g. 104985", onChange: (e) => {
4217
- const { value } = e.target;
4218
- // Only update if value contains only numbers
4219
- if (/^\d+$/.test(value)) {
4220
- advancedFilterState.userId = ((e.target.value)
4221
- .trim());
4222
- }
4223
- dispatch({
4224
- type: ActionType$6.UpdateAdvancedFilterState,
4225
- advancedFilterState,
4226
- });
4227
- } })),
4228
- React__default.createElement(ButtonInputGroup, { label: "Role" },
4229
- React__default.createElement(CheckboxButton, { text: "Students", onChanged: (checked) => {
4230
- advancedFilterState.includeLearners = checked;
4231
- dispatch({
4232
- type: ActionType$6.UpdateAdvancedFilterState,
4233
- advancedFilterState,
4234
- });
4235
- }, checked: advancedFilterState.includeLearners, ariaLabel: "show logs from students" }),
4236
- React__default.createElement(CheckboxButton, { text: "Teaching Team Members", onChanged: (checked) => {
4237
- advancedFilterState.includeTTMs = checked;
4238
- dispatch({
4239
- type: ActionType$6.UpdateAdvancedFilterState,
4240
- advancedFilterState,
4241
- });
4242
- }, checked: advancedFilterState.includeTTMs, ariaLabel: "show logs from teaching team members" }),
4243
- React__default.createElement(CheckboxButton, { text: "Admins", onChanged: (checked) => {
4244
- advancedFilterState.includeAdmins = checked;
4245
- dispatch({
4246
- type: ActionType$6.UpdateAdvancedFilterState,
4247
- advancedFilterState,
4248
- });
4249
- }, checked: advancedFilterState.includeAdmins, ariaLabel: "show logs from admins" }))),
4250
- React__default.createElement(TabBox, { title: "Course" },
4118
+ }
4119
+ dispatch({
4120
+ type: ActionType$6.UpdateAdvancedFilterState,
4121
+ advancedFilterState,
4122
+ });
4123
+ } })),
4124
+ React__default.createElement(ButtonInputGroup, { label: "Role" },
4125
+ React__default.createElement(CheckboxButton, { text: "Students", onChanged: (checked) => {
4126
+ advancedFilterState.includeLearners = checked;
4127
+ dispatch({
4128
+ type: ActionType$6.UpdateAdvancedFilterState,
4129
+ advancedFilterState,
4130
+ });
4131
+ }, checked: advancedFilterState.includeLearners, ariaLabel: "show logs from students" }),
4132
+ React__default.createElement(CheckboxButton, { text: "Teaching Team Members", onChanged: (checked) => {
4133
+ advancedFilterState.includeTTMs = checked;
4134
+ dispatch({
4135
+ type: ActionType$6.UpdateAdvancedFilterState,
4136
+ advancedFilterState,
4137
+ });
4138
+ }, checked: advancedFilterState.includeTTMs, ariaLabel: "show logs from teaching team members" }),
4139
+ React__default.createElement(CheckboxButton, { text: "Admins", onChanged: (checked) => {
4140
+ advancedFilterState.includeAdmins = checked;
4141
+ dispatch({
4142
+ type: ActionType$6.UpdateAdvancedFilterState,
4143
+ advancedFilterState,
4144
+ });
4145
+ }, checked: advancedFilterState.includeAdmins, ariaLabel: "show logs from admins" }))),
4146
+ React__default.createElement(TabBox, { title: "Course" },
4147
+ React__default.createElement("div", { className: "input-group mb-2" },
4148
+ React__default.createElement("span", { className: "input-group-text" }, "Course Name"),
4149
+ React__default.createElement("input", { type: "text", className: "form-control", "aria-label": "query for course name", value: advancedFilterState.courseName, placeholder: "e.g. GLC 200", onChange: (e) => {
4150
+ advancedFilterState.courseName = e.target.value;
4151
+ dispatch({
4152
+ type: ActionType$6.UpdateAdvancedFilterState,
4153
+ advancedFilterState,
4154
+ });
4155
+ } })),
4156
+ React__default.createElement("div", { className: "input-group mb-2" },
4157
+ React__default.createElement("span", { className: "input-group-text" }, "Course Canvas Id"),
4158
+ React__default.createElement("input", { type: "text", className: "form-control", "aria-label": "query for course canvas id", value: advancedFilterState.courseId, placeholder: "e.g. 15948", onChange: (e) => {
4159
+ const { value } = e.target;
4160
+ // Only update if value contains only numbers
4161
+ if (/^\d+$/.test(value)) {
4162
+ advancedFilterState.courseId = ((e.target.value)
4163
+ .trim());
4164
+ }
4165
+ dispatch({
4166
+ type: ActionType$6.UpdateAdvancedFilterState,
4167
+ advancedFilterState,
4168
+ });
4169
+ } }))),
4170
+ React__default.createElement(TabBox, { title: "Device" },
4171
+ React__default.createElement(ButtonInputGroup, { label: "Device Type" },
4172
+ React__default.createElement(RadioButton, { text: "All Devices", ariaLabel: "show logs from all devices", selected: advancedFilterState.isMobile === undefined, onSelected: () => {
4173
+ advancedFilterState.isMobile = undefined;
4174
+ dispatch({
4175
+ type: ActionType$6.UpdateAdvancedFilterState,
4176
+ advancedFilterState,
4177
+ });
4178
+ } }),
4179
+ React__default.createElement(RadioButton, { text: "Mobile Only", ariaLabel: "show logs from mobile devices", selected: advancedFilterState.isMobile === true, onSelected: () => {
4180
+ advancedFilterState.isMobile = true;
4181
+ dispatch({
4182
+ type: ActionType$6.UpdateAdvancedFilterState,
4183
+ advancedFilterState,
4184
+ });
4185
+ } }),
4186
+ React__default.createElement(RadioButton, { text: "Desktop Only", ariaLabel: "show logs from desktop devices", selected: advancedFilterState.isMobile === false, onSelected: () => {
4187
+ advancedFilterState.isMobile = false;
4188
+ dispatch({
4189
+ type: ActionType$6.UpdateAdvancedFilterState,
4190
+ advancedFilterState,
4191
+ });
4192
+ }, noMarginOnRight: true }))),
4193
+ React__default.createElement(TabBox, { title: "Source" },
4194
+ React__default.createElement(ButtonInputGroup, { label: "Source Type" },
4195
+ React__default.createElement(RadioButton, { text: "Both", ariaLabel: "show logs from all sources", selected: advancedFilterState.source === undefined, onSelected: () => {
4196
+ advancedFilterState.source = undefined;
4197
+ dispatch({
4198
+ type: ActionType$6.UpdateAdvancedFilterState,
4199
+ advancedFilterState,
4200
+ });
4201
+ } }),
4202
+ React__default.createElement(RadioButton, { text: "Client Only", ariaLabel: "show logs from client source", selected: advancedFilterState.source === LogSource$1.Client, onSelected: () => {
4203
+ advancedFilterState.source = LogSource$1.Client;
4204
+ dispatch({
4205
+ type: ActionType$6.UpdateAdvancedFilterState,
4206
+ advancedFilterState,
4207
+ });
4208
+ } }),
4209
+ React__default.createElement(RadioButton, { text: "Server Only", ariaLabel: "show logs from server source", selected: advancedFilterState.source === LogSource$1.Server, onSelected: () => {
4210
+ advancedFilterState.source = LogSource$1.Server;
4211
+ dispatch({
4212
+ type: ActionType$6.UpdateAdvancedFilterState,
4213
+ advancedFilterState,
4214
+ });
4215
+ }, noMarginOnRight: true })),
4216
+ advancedFilterState.source !== LogSource$1.Client && (React__default.createElement("div", { className: "mt-2" },
4251
4217
  React__default.createElement("div", { className: "input-group mb-2" },
4252
- React__default.createElement("span", { className: "input-group-text" }, "Course Name"),
4253
- React__default.createElement("input", { type: "text", className: "form-control", "aria-label": "query for course name", value: advancedFilterState.courseName, placeholder: "e.g. GLC 200", onChange: (e) => {
4254
- advancedFilterState.courseName = e.target.value;
4218
+ React__default.createElement("span", { className: "input-group-text" }, "Server Route Path"),
4219
+ React__default.createElement("input", { type: "text", className: "form-control", "aria-label": "query for server route path", value: advancedFilterState.routePath, placeholder: "e.g. /api/ttm/courses/12345", onChange: (e) => {
4220
+ advancedFilterState.courseName = ((e.target.value)
4221
+ .trim());
4255
4222
  dispatch({
4256
4223
  type: ActionType$6.UpdateAdvancedFilterState,
4257
4224
  advancedFilterState,
4258
4225
  });
4259
4226
  } })),
4260
4227
  React__default.createElement("div", { className: "input-group mb-2" },
4261
- React__default.createElement("span", { className: "input-group-text" }, "Course Canvas Id"),
4262
- React__default.createElement("input", { type: "text", className: "form-control", "aria-label": "query for course canvas id", value: advancedFilterState.courseId, placeholder: "e.g. 15948", onChange: (e) => {
4263
- const { value } = e.target;
4264
- // Only update if value contains only numbers
4265
- if (/^\d+$/.test(value)) {
4266
- advancedFilterState.courseId = ((e.target.value)
4267
- .trim());
4268
- }
4269
- dispatch({
4270
- type: ActionType$6.UpdateAdvancedFilterState,
4271
- advancedFilterState,
4272
- });
4273
- } }))),
4274
- React__default.createElement(TabBox, { title: "Device" },
4275
- React__default.createElement(ButtonInputGroup, { label: "Device Type" },
4276
- React__default.createElement(RadioButton, { text: "All Devices", ariaLabel: "show logs from all devices", selected: advancedFilterState.isMobile === undefined, onSelected: () => {
4277
- advancedFilterState.isMobile = undefined;
4278
- dispatch({
4279
- type: ActionType$6.UpdateAdvancedFilterState,
4280
- advancedFilterState,
4281
- });
4282
- } }),
4283
- React__default.createElement(RadioButton, { text: "Mobile Only", ariaLabel: "show logs from mobile devices", selected: advancedFilterState.isMobile === true, onSelected: () => {
4284
- advancedFilterState.isMobile = true;
4285
- dispatch({
4286
- type: ActionType$6.UpdateAdvancedFilterState,
4287
- advancedFilterState,
4288
- });
4289
- } }),
4290
- React__default.createElement(RadioButton, { text: "Desktop Only", ariaLabel: "show logs from desktop devices", selected: advancedFilterState.isMobile === false, onSelected: () => {
4291
- advancedFilterState.isMobile = false;
4292
- dispatch({
4293
- type: ActionType$6.UpdateAdvancedFilterState,
4294
- advancedFilterState,
4295
- });
4296
- }, noMarginOnRight: true }))),
4297
- React__default.createElement(TabBox, { title: "Source" },
4298
- React__default.createElement(ButtonInputGroup, { label: "Source Type" },
4299
- React__default.createElement(RadioButton, { text: "Both", ariaLabel: "show logs from all sources", selected: advancedFilterState.source === undefined, onSelected: () => {
4300
- advancedFilterState.source = undefined;
4301
- dispatch({
4302
- type: ActionType$6.UpdateAdvancedFilterState,
4303
- advancedFilterState,
4304
- });
4305
- } }),
4306
- React__default.createElement(RadioButton, { text: "Client Only", ariaLabel: "show logs from client source", selected: advancedFilterState.source === LogSource$1.Client, onSelected: () => {
4307
- advancedFilterState.source = LogSource$1.Client;
4308
- dispatch({
4309
- type: ActionType$6.UpdateAdvancedFilterState,
4310
- advancedFilterState,
4311
- });
4312
- } }),
4313
- React__default.createElement(RadioButton, { text: "Server Only", ariaLabel: "show logs from server source", selected: advancedFilterState.source === LogSource$1.Server, onSelected: () => {
4314
- advancedFilterState.source = LogSource$1.Server;
4228
+ React__default.createElement("span", { className: "input-group-text" }, "Server Route Template"),
4229
+ React__default.createElement("input", { type: "text", className: "form-control", "aria-label": "query for server route template", value: advancedFilterState.routeTemplate, placeholder: "e.g. /api/ttm/courses/:courseId", onChange: (e) => {
4230
+ advancedFilterState.courseName = ((e.target.value)
4231
+ .trim());
4315
4232
  dispatch({
4316
4233
  type: ActionType$6.UpdateAdvancedFilterState,
4317
4234
  advancedFilterState,
4318
4235
  });
4319
- }, noMarginOnRight: true })),
4320
- advancedFilterState.source !== LogSource$1.Client && (React__default.createElement("div", { className: "mt-2" },
4321
- React__default.createElement("div", { className: "input-group mb-2" },
4322
- React__default.createElement("span", { className: "input-group-text" }, "Server Route Path"),
4323
- React__default.createElement("input", { type: "text", className: "form-control", "aria-label": "query for server route path", value: advancedFilterState.routePath, placeholder: "e.g. /api/ttm/courses/12345", onChange: (e) => {
4324
- advancedFilterState.courseName = ((e.target.value)
4325
- .trim());
4326
- dispatch({
4327
- type: ActionType$6.UpdateAdvancedFilterState,
4328
- advancedFilterState,
4329
- });
4330
- } })),
4331
- React__default.createElement("div", { className: "input-group mb-2" },
4332
- React__default.createElement("span", { className: "input-group-text" }, "Server Route Template"),
4333
- React__default.createElement("input", { type: "text", className: "form-control", "aria-label": "query for server route template", value: advancedFilterState.routeTemplate, placeholder: "e.g. /api/ttm/courses/:courseId", onChange: (e) => {
4334
- advancedFilterState.courseName = ((e.target.value)
4335
- .trim());
4336
- dispatch({
4337
- type: ActionType$6.UpdateAdvancedFilterState,
4338
- advancedFilterState,
4339
- });
4340
- } })))))));
4341
- }
4342
- }
4343
- // Filters UI
4344
- const filters = (React__default.createElement(React__default.Fragment, null,
4345
- filterToggles,
4346
- filterDrawer && (React__default.createElement(Drawer, { customBackgroundColor: "#eee" }, filterDrawer))));
4347
- // Actually filter the logs
4348
- // > Perform filters
4349
- const logs = [];
4350
- Object.keys(logMap).forEach((year) => {
4351
- Object.keys(logMap[year]).forEach((month) => {
4352
- logMap[year][month].forEach((log) => {
4353
- /* ----------- Date Filter ---------- */
4354
- var _a;
4355
- // Before start date
4356
- if (
4357
- // Previous year
4358
- log.year < dateFilterState.startDate.year
4359
- // Same year, earlier month
4360
- || ((log.year === dateFilterState.startDate.year)
4361
- && (log.month < dateFilterState.startDate.month))
4362
- // Same year, same month, earlier day
4363
- || ((log.year === dateFilterState.startDate.year)
4364
- && (log.month === dateFilterState.startDate.month)
4365
- && (log.day < dateFilterState.startDate.day))) {
4366
- return;
4367
- }
4368
- // After end date
4369
- if (
4370
- // Later year
4371
- log.year > dateFilterState.endDate.year
4372
- // Same year, later month
4373
- || ((log.year === dateFilterState.endDate.year)
4374
- && (log.month > dateFilterState.endDate.month))
4375
- // Same year, same month, later day
4376
- || ((log.year === dateFilterState.endDate.year)
4377
- && (log.month === dateFilterState.endDate.month)
4378
- && (log.day > dateFilterState.endDate.day))) {
4379
- return;
4380
- }
4381
- /* --------- Context Filter --------- */
4382
- // Context doesn't match
4383
- if (
4384
- // Whole context is deselected
4385
- contextFilterState[log.context] === false
4386
- // None of the subcontexts are selected
4387
- || (
4388
- // Has subcontexts
4389
- typeof contextFilterState[log.context] !== 'boolean'
4390
- // None of the subcontexts are selected
4391
- && Object.values((_a = contextFilterState[log.context]) !== null && _a !== void 0 ? _a : {})
4392
- .every((isSelected) => {
4393
- return !isSelected;
4394
- }))) {
4395
- return;
4396
- }
4397
- // Subcontext doesn't match
4398
- if (
4399
- // Log context is not "uncategorized" (no point in further filters)
4400
- log.context !== LogBuiltInMetadata.Context.Uncategorized
4401
- // Log has a subcontext
4402
- && log.subcontext
4403
- // Context has subcontexts
4404
- && (contextFilterState[log.context]
4405
- && contextFilterState[log.context] !== false
4406
- && contextFilterState[log.context] !== true)
4407
- // Subcontext is not selected
4408
- && !contextFilterState[log.context][log.subcontext]) {
4409
- return;
4410
- }
4411
- /* -------------- Tags -------------- */
4412
- // No tags match
4413
- if (
4414
- // At least one tag is required
4415
- Object.values(tagFilterState)
4416
- .filter((isSelected) => {
4417
- return isSelected;
4418
- })
4419
- .length > 0
4420
- // No tags match
4421
- && log.tags.every((tag) => {
4422
- return !tagFilterState[tag];
4423
- })) {
4424
- return;
4425
- }
4426
- /* ------- Actions and Errors ------- */
4427
- // Log type doesn't match
4428
- if (
4429
- // Filter won't allow all types
4430
- actionErrorFilterState.type !== undefined
4431
- // Log type doesn't match
4432
- && actionErrorFilterState.type !== log.type) {
4433
- return;
4434
- }
4435
- // Filter errors
4436
- if (log.type === LogType$1.Error) {
4437
- // Message doesn't match
4438
- if (
4439
- // Message exists
4440
- log.errorMessage
4441
- // Message filter exists
4442
- && actionErrorFilterState.errorMessage.trim().length > 0
4443
- // Message doesn't match
4444
- && log.errorMessage.toLowerCase().includes(actionErrorFilterState.errorMessage.trim().toLowerCase())) {
4445
- return;
4446
- }
4447
- // Code doesn't match
4448
- if (
4449
- // Code exists
4450
- log.errorCode
4451
- // Code filter exists
4452
- && actionErrorFilterState.errorCode.trim().length > 0
4453
- // Code doesn't match
4454
- && log.errorCode.toUpperCase().includes(actionErrorFilterState.errorCode.trim().toUpperCase())) {
4455
- return;
4456
- }
4457
- }
4458
- // Filter actions
4459
- if (log.type === LogType$1.Action) {
4460
- // Target isn't selected
4461
- if (
4462
- // Target exists
4463
- log.target
4464
- // Target isn't selected
4465
- && !actionErrorFilterState.target[log.target]) {
4466
- return;
4467
- }
4468
- // Action
4469
- if (
4470
- // Action exists
4471
- log.action
4472
- // Action isn't selected
4473
- && !actionErrorFilterState.action[log.action]) {
4474
- return;
4475
- }
4476
- }
4477
- /* --------- Advanced Filter -------- */
4478
- // First name doesn't match
4479
- if (
4480
- // First name exists
4481
- log.userFirstName
4482
- // First name query doesn't match
4483
- && !log.userFirstName.toLowerCase().includes(advancedFilterState.userFirstName.toLowerCase().trim())) {
4484
- return;
4485
- }
4486
- // Last name doesn't match
4487
- if (
4488
- // Last name exists
4489
- log.userLastName
4490
- // Last name query doesn't match
4491
- && !log.userLastName.toLowerCase().includes(advancedFilterState.userLastName.toLowerCase().trim())) {
4492
- return;
4493
- }
4494
- // Email doesn't match
4495
- if (
4496
- // Email exists
4497
- log.userEmail
4498
- // Email query doesn't match
4499
- && !log.userEmail.toLowerCase().includes(advancedFilterState.userEmail.toLowerCase().trim())) {
4500
- return;
4501
- }
4502
- // User id doesn't match
4503
- if (
4504
- // User id exists
4505
- log.userId
4506
- // User id doesn't match
4507
- && !String(log.userId).includes(advancedFilterState.userId.trim())) {
4508
- return;
4509
- }
4510
- // Learner not allowed
4511
- if (
4512
- // User is a learner
4513
- log.isLearner
4514
- // Learners aren't included
4515
- && !advancedFilterState.includeLearners) {
4516
- return;
4517
- }
4518
- // TTM not allowed
4519
- if (
4520
- // User is a ttm
4521
- log.isTTM
4522
- // TTMs aren't included
4523
- && !advancedFilterState.includeTTMs) {
4524
- return;
4525
- }
4526
- // Admin not allowed
4527
- if (
4528
- // User is an admin
4529
- log.isAdmin
4530
- // Admins aren't included
4531
- && !advancedFilterState.includeAdmins) {
4532
- return;
4533
- }
4534
- // Course Id doesn't match
4535
- if (
4536
- // Course Id exists
4537
- log.courseId
4538
- // Course Id doesn't match
4539
- && !String(log.courseId).includes(advancedFilterState.courseId.trim())) {
4540
- return;
4541
- }
4542
- // Course name doesn't match
4543
- if (
4544
- // Course name exists
4545
- log.courseName
4546
- // Course name doesn't match
4547
- && !String(log.courseName).includes(advancedFilterState.courseName.trim())) {
4548
- return;
4549
- }
4550
- // Mobile filter doesn't match
4551
- if (
4552
- // Mobile filter exists
4553
- advancedFilterState.isMobile !== undefined
4554
- // Device info exists
4555
- && log.device
4556
- // Mobile filter doesn't match
4557
- && (advancedFilterState.isMobile !== log.device.isMobile)) {
4558
- return;
4559
- }
4560
- // Log source doesn't match
4561
- if (
4562
- // Source filter exists
4563
- advancedFilterState.source !== undefined
4564
- // Source info exists
4565
- && log.source
4566
- // Source filter doesn't match
4567
- && (advancedFilterState.source !== log.source)) {
4568
- return;
4569
- }
4570
- // Route path doesn't match (Only for server source)
4571
- if (
4572
- // Source is server
4573
- (log.source === LogSource$1.Server)
4574
- // Route path is being filtered
4575
- && (advancedFilterState.routePath.trim().length)
4576
- // Route path doesn't match
4577
- && !(log.routePath.includes(advancedFilterState.routePath.trim()))) {
4578
- return;
4579
- }
4580
- // Route template doesn't match (Only for server source)
4581
- if (
4582
- // Source is server
4583
- (log.source === LogSource$1.Server)
4584
- // Route template is being filtered
4585
- && (advancedFilterState.routeTemplate.trim().length)
4586
- // Route template doesn't match
4587
- && !(log.routeTemplate.includes(advancedFilterState.routeTemplate.trim()))) {
4588
- return;
4589
- }
4590
- /* -------------- Done -------------- */
4591
- // Made it past all filters. Add to the list
4592
- logs.push(log);
4593
- });
4594
- });
4595
- });
4596
- /*----------------------------------------*/
4597
- /* ---------------- Data ---------------- */
4598
- /*----------------------------------------*/
4599
- // Nothing to show notice
4600
- const noLogsNotice = (logs.length === 0
4601
- ? (React__default.createElement("div", { className: "alert alert-warning text-center mt-2" },
4236
+ } })))))));
4237
+ }
4238
+ }
4239
+ // Filters UI
4240
+ const filters = (React__default.createElement(React__default.Fragment, null,
4241
+ filterToggles,
4242
+ filterDrawer && (React__default.createElement(Drawer, { customBackgroundColor: "#eee" }, filterDrawer))));
4243
+ // Main body
4244
+ body = (React__default.createElement(React__default.Fragment, null,
4245
+ filters,
4246
+ React__default.createElement("div", { className: "mt-2" },
4247
+ React__default.createElement(IntelliTable, { title: "Matching Logs:", csvName: `Logs from ${getHumanReadableDate()}`, id: "logs", data: logs, columns: columns }),
4248
+ logs.length === 0 && (React__default.createElement("div", { className: "alert alert-warning text-center mt-2" },
4602
4249
  React__default.createElement("h4", { className: "m-1" }, "No Logs to Show"),
4603
- React__default.createElement("div", null, "Either your filters are too strict or no matching logs have been created yet.")))
4604
- : undefined);
4605
- // Create intelliTable
4606
- const dataTable = (React__default.createElement(IntelliTable, { title: "Matching Logs:", csvName: `Logs from ${getHumanReadableDate()}`, id: "logs", data: logs, columns: columns }));
4607
- // Main body
4608
- body = (React__default.createElement(React__default.Fragment, null,
4609
- filters,
4610
- React__default.createElement("div", { className: "mt-2" },
4611
- dataTable,
4612
- noLogsNotice)));
4613
- }
4250
+ React__default.createElement("div", null, "Either your filters are too strict or no matching logs have been created yet."))),
4251
+ paginationControls)));
4614
4252
  /* ---------- Wrap in Modal --------- */
4615
4253
  return (React__default.createElement("div", { className: "LogReviewer-outer-container" },
4616
4254
  React__default.createElement("style", null, style$2),
@@ -14122,32 +13760,138 @@ const initServer = (opts) => {
14122
13760
  }),
14123
13761
  }));
14124
13762
  /**
14125
- * Get all logs for a certain month
14126
- * @author Gabe Abrams
14127
- * @param {number} year the year to query (e.g. 2022)
14128
- * @param {number} month the month to query (e.g. 1 = January)
14129
- * @returns {Log[]} list of logs from the given month
14130
- */
14131
- opts.app.get(`${LOG_REVIEW_ROUTE_PATH_PREFIX}/years/:year/months/:month`, genRouteHandler({
13763
+ * Get filtered logs based on provided filters
13764
+ * @author Gabe Abrams, Yuen Ler Chow
13765
+ * @returns {Log[]} list of logs that match the filters
13766
+ */
13767
+ opts.app.get(`${LOG_REVIEW_ROUTE_PATH_PREFIX}/logs`, genRouteHandler({
14132
13768
  paramTypes: {
14133
- year: ParamType$1.Int,
14134
- month: ParamType$1.Int,
13769
+ pageNumber: ParamType$1.Int,
13770
+ filters: ParamType$1.JSON,
14135
13771
  },
14136
13772
  handler: ({ params }) => __awaiter(void 0, void 0, void 0, function* () {
14137
13773
  // Get user info
14138
- const { year, month, userId, isAdmin, } = params;
13774
+ const { pageNumber, userId, isAdmin, filters, } = params;
14139
13775
  // Validate user
14140
13776
  const canReview = yield canReviewLogs(userId, isAdmin);
14141
13777
  if (!canReview) {
14142
13778
  throw new ErrorWithCode('You cannot access this resource because you do not have the appropriate permissions.', ReactKitErrorCode$1.NotAllowedToReviewLogs);
14143
13779
  }
13780
+ // Build MongoDB query based on filters
13781
+ const query = {};
13782
+ /* -------------- Date Filter ------------- */
13783
+ const { startDate, endDate } = filters.dateFilterState;
13784
+ const startTimestamp = new Date(startDate.year, startDate.month - 1, startDate.day).getTime();
13785
+ const endTimestamp = new Date(endDate.year, endDate.month - 1, endDate.day + 1).getTime() - 1;
13786
+ query.timestamp = {
13787
+ $gte: startTimestamp,
13788
+ $lte: endTimestamp,
13789
+ };
13790
+ /* ------------ Context Filter ------------ */
13791
+ const { contextFilterState } = filters;
13792
+ const contextConditions = [];
13793
+ Object.keys(contextFilterState).forEach((context) => {
13794
+ const value = contextFilterState[context];
13795
+ if (typeof value === 'boolean') {
13796
+ if (value) {
13797
+ // The entire context is selected
13798
+ contextConditions.push({ context });
13799
+ }
13800
+ }
13801
+ else {
13802
+ // The context has subcontexts
13803
+ const subcontexts = Object.keys(value).filter((subcontext) => { return value[subcontext]; });
13804
+ if (subcontexts.length > 0) {
13805
+ contextConditions.push({
13806
+ context,
13807
+ subcontext: { $in: subcontexts },
13808
+ });
13809
+ }
13810
+ }
13811
+ });
13812
+ if (contextConditions.length > 0) {
13813
+ query.$or = contextConditions;
13814
+ }
13815
+ /* -------------- Tag Filter -------------- */
13816
+ const { tagFilterState } = filters;
13817
+ const selectedTags = Object.keys(tagFilterState).filter((tag) => { return tagFilterState[tag]; });
13818
+ if (selectedTags.length > 0) {
13819
+ query.tags = { $in: selectedTags };
13820
+ }
13821
+ /* --------- Action/Error Filter ---------- */
13822
+ const { actionErrorFilterState } = filters;
13823
+ if (actionErrorFilterState.type) {
13824
+ query.type = actionErrorFilterState.type;
13825
+ }
13826
+ if (actionErrorFilterState.type === 'error' && actionErrorFilterState.errorMessage) {
13827
+ query.errorMessage = { $regex: actionErrorFilterState.errorMessage, $options: 'i' };
13828
+ }
13829
+ if (actionErrorFilterState.type === 'error' && actionErrorFilterState.errorCode) {
13830
+ query.errorCode = { $regex: actionErrorFilterState.errorCode, $options: 'i' };
13831
+ }
13832
+ if (actionErrorFilterState.type === 'action') {
13833
+ const selectedTargets = Object.keys(actionErrorFilterState.target).filter((target) => { return actionErrorFilterState.target[target]; });
13834
+ const selectedActions = Object.keys(actionErrorFilterState.action).filter((action) => { return actionErrorFilterState.action[action]; });
13835
+ if (selectedTargets.length > 0) {
13836
+ query.target = { $in: selectedTargets };
13837
+ }
13838
+ if (selectedActions.length > 0) {
13839
+ query.action = { $in: selectedActions };
13840
+ }
13841
+ }
13842
+ /* ------------ Advanced Filter ----------- */
13843
+ const { advancedFilterState } = filters;
13844
+ if (advancedFilterState.userFirstName) {
13845
+ query.userFirstName = { $regex: advancedFilterState.userFirstName, $options: 'i' };
13846
+ }
13847
+ if (advancedFilterState.userLastName) {
13848
+ query.userLastName = { $regex: advancedFilterState.userLastName, $options: 'i' };
13849
+ }
13850
+ if (advancedFilterState.userEmail) {
13851
+ query.userEmail = { $regex: advancedFilterState.userEmail, $options: 'i' };
13852
+ }
13853
+ if (advancedFilterState.userId) {
13854
+ query.userId = parseInt(advancedFilterState.userId, 10);
13855
+ }
13856
+ const roles = [];
13857
+ if (advancedFilterState.includeLearners) {
13858
+ roles.push({ isLearner: true });
13859
+ }
13860
+ if (advancedFilterState.includeTTMs) {
13861
+ roles.push({ isTTM: true });
13862
+ }
13863
+ if (advancedFilterState.includeAdmins) {
13864
+ roles.push({ isAdmin: true });
13865
+ }
13866
+ if (roles.length > 0) {
13867
+ query.$and = [{ $or: roles }];
13868
+ }
13869
+ if (advancedFilterState.courseId) {
13870
+ query.courseId = parseInt(advancedFilterState.courseId, 10);
13871
+ }
13872
+ if (advancedFilterState.courseName) {
13873
+ query.courseName = { $regex: advancedFilterState.courseName, $options: 'i' };
13874
+ }
13875
+ if (advancedFilterState.isMobile !== undefined) {
13876
+ query['device.isMobile'] = advancedFilterState.isMobile;
13877
+ }
13878
+ if (advancedFilterState.source) {
13879
+ query.source = advancedFilterState.source;
13880
+ }
13881
+ if (advancedFilterState.routePath) {
13882
+ query.routePath = { $regex: advancedFilterState.routePath, $options: 'i' };
13883
+ }
13884
+ if (advancedFilterState.routeTemplate) {
13885
+ query.routeTemplate = { $regex: advancedFilterState.routeTemplate, $options: 'i' };
13886
+ }
14144
13887
  // Query for logs
14145
- const logs = yield _logCollection.find({
14146
- year,
14147
- month,
13888
+ const response = yield _logCollection.findPaged({
13889
+ query,
13890
+ perPage: 50,
13891
+ pageNumber,
14148
13892
  });
14149
- // Return logs
14150
- return logs;
13893
+ // Return response
13894
+ return response;
14151
13895
  }),
14152
13896
  }));
14153
13897
  };
@@ -16315,5 +16059,5 @@ var DayOfWeek;
16315
16059
  })(DayOfWeek || (DayOfWeek = {}));
16316
16060
  var DayOfWeek$1 = DayOfWeek;
16317
16061
 
16318
- export { AppWrapper, AutoscrollToBottomContainer, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, DAY_IN_MS, DBEntryFieldType$1 as DBEntryFieldType, DBEntryManagerPanel, DayOfWeek$1 as DayOfWeek, Drawer, Dropdown, DropdownItemType$1 as DropdownItemType, DynamicWord, ErrorBox, ErrorWithCode, HOUR_IN_MS, IntelliTable, ItemPicker, LoadingSpinner, LogAction$1 as LogAction, LogBuiltInMetadata, LogReviewer, LogSource$1 as LogSource, LogType$1 as LogType, MINUTE_IN_MS, Modal, ModalButtonType$1 as ModalButtonType, ModalSize$1 as ModalSize, ModalType$1 as ModalType, MultiSwitch, ParamType$1 as ParamType, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode$1 as ReactKitErrorCode, SimpleDateChooser, TabBox, ToggleSwitch, Tooltip, Variant$1 as Variant, abbreviate, addDBEditorEndpoints, addFatalErrorHandler, alert, avg, canReviewLogs, capitalize, ceilToNumDecimals, combineClassNames, compareArraysByProp, confirm, everyAsync, extractProp, filterAsync, floorToNumDecimals, forEachAsync, forceNumIntoBounds, genCSV, genCommaList, genRouteHandler, getHumanReadableDate, getLocalTimeInfo, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, handleError, handleSuccess, idify, initClient, initLogCollection, initServer, isMobileOrTablet, leaveToURL, logClientEvent, makeLinksClickable, mapAsync, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, prefixWithAOrAn, prompt, roundToNumDecimals, setClientEventMetadataPopulator, showFatalError, shuffleArray, someAsync, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, useForceRender, validateEmail, validatePhoneNumber, validateString, visitEndpointOnAnotherServer, visitServerEndpoint, waitMs };
16062
+ export { AppWrapper, AutoscrollToBottomContainer, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, DAY_IN_MS, DBEntryFieldType$1 as DBEntryFieldType, DBEntryManagerPanel, DayOfWeek$1 as DayOfWeek, Drawer, Dropdown, DropdownItemType$1 as DropdownItemType, DynamicWord, ErrorBox, ErrorWithCode, HOUR_IN_MS, IntelliTable, ItemPicker, LoadingSpinner, LogAction$1 as LogAction, LogBuiltInMetadata, LogReviewer, LogSource$1 as LogSource, LogType$1 as LogType, MINUTE_IN_MS, Modal, ModalButtonType$1 as ModalButtonType, ModalSize$1 as ModalSize, ModalType$1 as ModalType, MultiSwitch, ParamType$1 as ParamType, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode$1 as ReactKitErrorCode, SimpleDateChooser, TabBox, ToggleSwitch, Tooltip, Variant$1 as Variant, abbreviate, addDBEditorEndpoints, addFatalErrorHandler, alert, avg, canReviewLogs, capitalize, ceilToNumDecimals, combineClassNames, compareArraysByProp, confirm, everyAsync, extractProp, filterAsync, floorToNumDecimals, forEachAsync, forceNumIntoBounds, genCSV, genCommaList, genRouteHandler, getHumanReadableDate, getLocalTimeInfo, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, handleError, handleSuccess, idify, initClient, initLogCollection, initServer, isMobileOrTablet, leaveToURL, logClientEvent, makeLinksClickable, mapAsync, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, prefixWithAOrAn, roundToNumDecimals, setClientEventMetadataPopulator, showFatalError, shuffleArray, someAsync, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, useForceRender, validateEmail, validatePhoneNumber, validateString, visitEndpointOnAnotherServer, visitServerEndpoint, waitMs };
16319
16063
  //# sourceMappingURL=index.js.map