dce-reactkit 3.9.4-beta.1 → 3.9.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.
@@ -48,25 +48,33 @@ export declare const confirm: (title: string, text: string, opts?: {
48
48
  * Show a prompt modal asking the user for input
49
49
  * @author Yuen Ler Chow
50
50
  * @param title the title text to display at the top of the prompt
51
- * @param text the text to display in the prompt
52
51
  * @param [opts={}] additional options for the prompt dialog
53
- * @param [opts.placeholder] the placeholder text for the input field
52
+ * @param [opts.textAboveInputField] the text to display in the prompt
54
53
  * @param [opts.defaultText] the default text for the input field
54
+ * @param [opts.placeholder] the placeholder text for the input field
55
55
  * @param [opts.confirmButtonText=Okay] the text of the confirm button
56
56
  * @param [opts.confirmButtonVariant=Variant.Dark] the variant of the confirm button
57
57
  * @param [opts.cancelButtonText=Cancel] the text of the cancel button
58
58
  * @param [opts.cancelButtonVariant=Variant.Secondary] the variant of the cancel button
59
+ * @param [opts.minNumChars] the minimum number of characters required for
60
+ * the input to be valid
61
+ * @param [opts.findValidationError] a function that takes the input text and
62
+ * returns an error message if the input is invalid, returns undefined if the
63
+ * input is valid
64
+ * @param [opts.ariaLabel] the aria label for the input field
59
65
  * @returns Promise that resolves with the input string or null if canceled
60
66
  */
61
- export declare const prompt: (title: string, text: string, currentInputFieldText: string, opts?: {
62
- placeholder?: string | undefined;
67
+ export declare const prompt: (title: string, opts?: {
68
+ textAboveInputField?: string | undefined;
63
69
  defaultText?: string | undefined;
70
+ placeholder?: string | undefined;
64
71
  confirmButtonText?: string | undefined;
65
72
  confirmButtonVariant?: Variant | undefined;
66
73
  cancelButtonText?: string | undefined;
67
74
  cancelButtonVariant?: Variant | undefined;
68
75
  minNumChars?: number | undefined;
69
76
  findValidationError?: ((text: string) => string | undefined) | undefined;
77
+ ariaLabel?: string | undefined;
70
78
  } | undefined) => Promise<string | null>;
71
79
  /**
72
80
  * Show a fatal error message
@@ -1,4 +1,4 @@
1
- import AppWrapper, { alert, confirm, showFatalError, addFatalErrorHandler, leaveToURL } from './components/AppWrapper';
1
+ import AppWrapper, { alert, prompt, confirm, showFatalError, addFatalErrorHandler, leaveToURL } from './components/AppWrapper';
2
2
  import LoadingSpinner from './components/LoadingSpinner';
3
3
  import ErrorBox from './components/ErrorBox';
4
4
  import Modal from './components/Modal';
@@ -99,4 +99,4 @@ import PickableItem from './components/ItemPicker/types/PickableItem';
99
99
  import DBEntry from './components/DBEntryManagerPanel/types/DBEntry';
100
100
  import DBEntryField from './components/DBEntryManagerPanel/types/DBEntryField';
101
101
  import DBEntryFieldType from './components/DBEntryManagerPanel/types/DBEntryFieldType';
102
- export { AppWrapper, LoadingSpinner, ErrorBox, Modal, TabBox, RadioButton, CheckboxButton, ButtonInputGroup, SimpleDateChooser, Drawer, PopSuccessMark, PopFailureMark, PopPendingMark, CopiableBox, ItemPicker, LogReviewer, IntelliTable, CSVDownloadButton, DBEntryManagerPanel, Tooltip, ToggleSwitch, AutoscrollToBottomContainer, MultiSwitch, Dropdown, alert, confirm, showFatalError, ErrorWithCode, MINUTE_IN_MS, HOUR_IN_MS, DAY_IN_MS, DynamicWord, abbreviate, avg, ceilToNumDecimals, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, getOrdinal, getTimeInfoInET, stubServerEndpoint, startMinWait, getHumanReadableDate, getPartOfDay, stringsToHumanReadableList, onlyKeepLetters, parallelLimit, getMonthName, genCSV, canReviewLogs, isMobileOrTablet, extractProp, compareArraysByProp, genCommaList, validateEmail, validatePhoneNumber, validateString, getLocalTimeInfo, idify, makeLinksClickable, prefixWithAOrAn, everyAsync, filterAsync, forEachAsync, mapAsync, someAsync, capitalize, shuffleArray, initClient, visitServerEndpoint, logClientEvent, addFatalErrorHandler, leaveToURL, combineClassNames, useForceRender, setClientEventMetadataPopulator, initServer, genRouteHandler, handleError, handleSuccess, initLogCollection, addDBEditorEndpoints, visitEndpointOnAnotherServer, ModalButtonType, ModalSize, ModalType, ReactKitErrorCode, Variant, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, LogFunction, IntelliTableColumn, DropdownItemType, PickableItem, DBEntry, DBEntryField, DBEntryFieldType, ParamType, };
102
+ export { AppWrapper, LoadingSpinner, ErrorBox, Modal, TabBox, RadioButton, CheckboxButton, ButtonInputGroup, SimpleDateChooser, Drawer, PopSuccessMark, PopFailureMark, PopPendingMark, CopiableBox, ItemPicker, LogReviewer, IntelliTable, CSVDownloadButton, DBEntryManagerPanel, Tooltip, ToggleSwitch, AutoscrollToBottomContainer, MultiSwitch, Dropdown, alert, prompt, confirm, showFatalError, ErrorWithCode, MINUTE_IN_MS, HOUR_IN_MS, DAY_IN_MS, DynamicWord, abbreviate, avg, ceilToNumDecimals, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, getOrdinal, getTimeInfoInET, stubServerEndpoint, startMinWait, getHumanReadableDate, getPartOfDay, stringsToHumanReadableList, onlyKeepLetters, parallelLimit, getMonthName, genCSV, canReviewLogs, isMobileOrTablet, extractProp, compareArraysByProp, genCommaList, validateEmail, validatePhoneNumber, validateString, getLocalTimeInfo, idify, makeLinksClickable, prefixWithAOrAn, everyAsync, filterAsync, forEachAsync, mapAsync, someAsync, capitalize, shuffleArray, initClient, visitServerEndpoint, logClientEvent, addFatalErrorHandler, leaveToURL, combineClassNames, useForceRender, setClientEventMetadataPopulator, initServer, genRouteHandler, handleError, handleSuccess, initLogCollection, addDBEditorEndpoints, visitEndpointOnAnotherServer, ModalButtonType, ModalSize, ModalType, ReactKitErrorCode, Variant, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, LogFunction, IntelliTableColumn, DropdownItemType, PickableItem, DBEntry, DBEntryField, DBEntryFieldType, ParamType, };
package/dist/index.d.ts CHANGED
@@ -63,6 +63,38 @@ declare const confirm: (title: string, text: string, opts?: {
63
63
  cancelButtonText?: string;
64
64
  cancelButtonVariant?: Variant;
65
65
  }) => Promise<boolean>;
66
+ /**
67
+ * Show a prompt modal asking the user for input
68
+ * @author Yuen Ler Chow
69
+ * @param title the title text to display at the top of the prompt
70
+ * @param [opts={}] additional options for the prompt dialog
71
+ * @param [opts.textAboveInputField] the text to display in the prompt
72
+ * @param [opts.defaultText] the default text for the input field
73
+ * @param [opts.placeholder] the placeholder text for the input field
74
+ * @param [opts.confirmButtonText=Okay] the text of the confirm button
75
+ * @param [opts.confirmButtonVariant=Variant.Dark] the variant of the confirm button
76
+ * @param [opts.cancelButtonText=Cancel] the text of the cancel button
77
+ * @param [opts.cancelButtonVariant=Variant.Secondary] the variant of the cancel button
78
+ * @param [opts.minNumChars] the minimum number of characters required for
79
+ * the input to be valid
80
+ * @param [opts.findValidationError] a function that takes the input text and
81
+ * returns an error message if the input is invalid, returns undefined if the
82
+ * input is valid
83
+ * @param [opts.ariaLabel] the aria label for the input field
84
+ * @returns Promise that resolves with the input string or null if canceled
85
+ */
86
+ declare const prompt: (title: string, opts?: {
87
+ textAboveInputField?: string | undefined;
88
+ defaultText?: string | undefined;
89
+ placeholder?: string | undefined;
90
+ confirmButtonText?: string | undefined;
91
+ confirmButtonVariant?: Variant | undefined;
92
+ cancelButtonText?: string | undefined;
93
+ cancelButtonVariant?: Variant | undefined;
94
+ minNumChars?: number | undefined;
95
+ findValidationError?: ((text: string) => string | undefined) | undefined;
96
+ ariaLabel?: string | undefined;
97
+ } | undefined) => Promise<string | null>;
66
98
  /**
67
99
  * Show a fatal error message
68
100
  * @author Gabe Abrams
@@ -1691,4 +1723,4 @@ declare const LogBuiltInMetadata: {
1691
1723
  };
1692
1724
  };
1693
1725
 
1694
- export { AppWrapper, AutoscrollToBottomContainer, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, DAY_IN_MS, DBEntry, DBEntryField, DBEntryFieldType, DBEntryManagerPanel, DayOfWeek, Drawer, Dropdown, DropdownItemType, DynamicWord, ErrorBox, ErrorWithCode, HOUR_IN_MS, IntelliTable, IntelliTableColumn, ItemPicker, LoadingSpinner, Log, LogAction, LogBuiltInMetadata, LogFunction, LogMetadataType, LogReviewer, LogSource, LogType, MINUTE_IN_MS, Modal, ModalButtonType, ModalSize, ModalType, MultiSwitch, ParamType, PickableItem, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode, SimpleDateChooser, TabBox, ToggleSwitch, Tooltip, 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 };
1726
+ export { AppWrapper, AutoscrollToBottomContainer, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, DAY_IN_MS, DBEntry, DBEntryField, DBEntryFieldType, DBEntryManagerPanel, DayOfWeek, Drawer, Dropdown, DropdownItemType, DynamicWord, ErrorBox, ErrorWithCode, HOUR_IN_MS, IntelliTable, IntelliTableColumn, ItemPicker, LoadingSpinner, Log, LogAction, LogBuiltInMetadata, LogFunction, LogMetadataType, LogReviewer, LogSource, LogType, MINUTE_IN_MS, Modal, ModalButtonType, ModalSize, ModalType, MultiSwitch, ParamType, PickableItem, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode, SimpleDateChooser, TabBox, ToggleSwitch, Tooltip, 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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dce-reactkit",
3
- "version": "3.9.4-beta.1",
3
+ "version": "3.9.5",
4
4
  "description": "Shared components for Harvard DCE apps",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -246,23 +246,25 @@ export const confirm = async (
246
246
 
247
247
  // Stored copies of setters
248
248
  let setPromptInfo: (
249
- info:
250
- | undefined
251
- | {
252
- title: string;
253
- text: string;
254
- currentInputFieldText: string,
255
- opts: {
256
- placeholder?: string,
257
- defaultText?: string,
258
- confirmButtonText?: string,
259
- confirmButtonVariant?: Variant,
260
- cancelButtonText?: string,
261
- cancelButtonVariant?: Variant,
262
- minNumChars?: number,
263
- findValidationError?: (text: string) => string | undefined,
264
- },
265
- },
249
+ info: (
250
+ | undefined
251
+ | {
252
+ title: string,
253
+ currentInputFieldText: string,
254
+ opts: {
255
+ textAboveInputField?: string,
256
+ placeholder?: string,
257
+ defaultText?: string,
258
+ confirmButtonText?: string,
259
+ confirmButtonVariant?: Variant,
260
+ cancelButtonText?: string,
261
+ cancelButtonVariant?: Variant,
262
+ minNumChars?: number,
263
+ findValidationError?: (text: string) => string | undefined,
264
+ ariaLabel?: string,
265
+ },
266
+ }
267
+ ),
266
268
  ) => void;
267
269
 
268
270
  // Function to call when prompt is closed
@@ -272,29 +274,35 @@ let onPromptClosed: (result: string | null) => void;
272
274
  * Show a prompt modal asking the user for input
273
275
  * @author Yuen Ler Chow
274
276
  * @param title the title text to display at the top of the prompt
275
- * @param text the text to display in the prompt
276
277
  * @param [opts={}] additional options for the prompt dialog
277
- * @param [opts.placeholder] the placeholder text for the input field
278
+ * @param [opts.textAboveInputField] the text to display in the prompt
278
279
  * @param [opts.defaultText] the default text for the input field
280
+ * @param [opts.placeholder] the placeholder text for the input field
279
281
  * @param [opts.confirmButtonText=Okay] the text of the confirm button
280
282
  * @param [opts.confirmButtonVariant=Variant.Dark] the variant of the confirm button
281
283
  * @param [opts.cancelButtonText=Cancel] the text of the cancel button
282
284
  * @param [opts.cancelButtonVariant=Variant.Secondary] the variant of the cancel button
285
+ * @param [opts.minNumChars] the minimum number of characters required for
286
+ * the input to be valid
287
+ * @param [opts.findValidationError] a function that takes the input text and
288
+ * returns an error message if the input is invalid, returns undefined if the
289
+ * input is valid
290
+ * @param [opts.ariaLabel] the aria label for the input field
283
291
  * @returns Promise that resolves with the input string or null if canceled
284
292
  */
285
293
  export const prompt = async (
286
294
  title: string,
287
- text: string,
288
- currentInputFieldText: string,
289
295
  opts?: {
290
- placeholder?: string,
296
+ textAboveInputField?: string,
291
297
  defaultText?: string,
298
+ placeholder?: string,
292
299
  confirmButtonText?: string,
293
300
  confirmButtonVariant?: Variant,
294
301
  cancelButtonText?: string,
295
302
  cancelButtonVariant?: Variant,
296
303
  minNumChars?: number,
297
304
  findValidationError?: (text: string) => string | undefined,
305
+ ariaLabel?: string,
298
306
  },
299
307
  ): Promise<string | null> => {
300
308
  // Wait for helper to exist
@@ -308,10 +316,11 @@ export const prompt = async (
308
316
  while (!resultPassesValidation) {
309
317
  // eslint-disable-next-line no-alert
310
318
  const result = window.prompt(
311
- `${title}\n\n${text}`,
319
+ `${title}\n\n${opts?.textAboveInputField ?? ''}`,
312
320
  opts?.defaultText ?? '',
313
321
  );
314
322
 
323
+ // Exit loop if user cancels
315
324
  if (result === null) {
316
325
  return null;
317
326
  }
@@ -331,9 +340,24 @@ export const prompt = async (
331
340
 
332
341
  // Show validation issue
333
342
  if (minNumCharsValidationError || customValidationError) {
343
+ // Create error message
344
+ const errorMessage = (
345
+ [
346
+ minNumCharsValidationError,
347
+ customValidationError,
348
+ ]
349
+ // Filter out undefined messages
350
+ .filter((msg) => {
351
+ return !!msg;
352
+ })
353
+ // Join messages with newlines
354
+ .join('\n')
355
+ );
356
+
357
+ // Show alert
334
358
  alert(
335
359
  'Invalid Input',
336
- `${minNumCharsValidationError ?? ''} ${customValidationError ?? ''}`,
360
+ errorMessage,
337
361
  );
338
362
  } else {
339
363
  return result;
@@ -351,8 +375,7 @@ export const prompt = async (
351
375
  // Show the prompt
352
376
  setPromptInfo({
353
377
  title,
354
- text,
355
- currentInputFieldText,
378
+ currentInputFieldText: (opts?.defaultText ?? ''),
356
379
  opts: (opts ?? {}),
357
380
  });
358
381
  });
@@ -585,22 +608,23 @@ const AppWrapper: React.FC<Props> = (props: Props): React.ReactElement => {
585
608
 
586
609
  // Prompt
587
610
  const [promptInfo, setPromptInfoInner] = useState<
588
- | undefined
589
- | {
590
- title: string,
591
- text: string,
592
- currentInputFieldText: string,
593
- opts: {
594
- placeholder?: string,
595
- defaultText?: string,
596
- confirmButtonText?: string,
597
- confirmButtonVariant?: Variant,
598
- cancelButtonText?: string,
599
- cancelButtonVariant?: Variant,
600
- minNumChars?: number,
601
- findValidationError?: (text: string) => string | undefined,
611
+ | undefined
612
+ | {
613
+ title: string,
614
+ currentInputFieldText: string,
615
+ opts: {
616
+ textAboveInputField?: string,
617
+ placeholder?: string,
618
+ defaultText?: string,
619
+ confirmButtonText?: string,
620
+ confirmButtonVariant?: Variant,
621
+ cancelButtonText?: string,
622
+ cancelButtonVariant?: Variant,
623
+ minNumChars?: number,
624
+ findValidationError?: (text: string) => string | undefined,
625
+ ariaLabel?: string,
626
+ }
602
627
  }
603
- }
604
628
  >(undefined);
605
629
  setPromptInfo = setPromptInfoInner;
606
630
 
@@ -691,9 +715,9 @@ const AppWrapper: React.FC<Props> = (props: Props): React.ReactElement => {
691
715
 
692
716
  modal = (
693
717
  <ModalForWrapper
694
- key={`prompt-${promptInfo.title}-${promptInfo.text}`}
718
+ key={`prompt-${promptInfo.title}`}
695
719
  title={promptInfo.title}
696
- // only show the cancel button if there is a validation error
720
+ // Don't show ok button if there is a validation error
697
721
  type={(
698
722
  (customValidationError || minNumCharsValidationError)
699
723
  ? ModalType.Cancel
@@ -704,14 +728,17 @@ const AppWrapper: React.FC<Props> = (props: Props): React.ReactElement => {
704
728
  cancelLabel={promptInfo.opts.cancelButtonText}
705
729
  cancelVariant={promptInfo.opts.cancelButtonVariant}
706
730
  onClose={(buttonType) => {
731
+ // Get result
707
732
  const result = (
708
733
  buttonType === ModalButtonType.Okay
709
734
  ? promptInfo.currentInputFieldText
710
735
  : null
711
736
  );
712
737
 
738
+ // Close prompt
713
739
  setPromptInfo(undefined);
714
740
 
741
+ // Call handler
715
742
  if (onPromptClosed) {
716
743
  onPromptClosed(result);
717
744
  }
@@ -719,10 +746,19 @@ const AppWrapper: React.FC<Props> = (props: Props): React.ReactElement => {
719
746
  onTopOfOtherModals
720
747
  dontAllowBackdropExit
721
748
  >
722
- <div className="d-flex flex-column align-items-center">
723
- <p>{promptInfo.text}</p>
749
+ <div>
750
+ {/* Message above input field */}
751
+ {promptInfo.opts.textAboveInputField && (
752
+ <div>
753
+ {promptInfo.opts.textAboveInputField}
754
+ </div>
755
+ )}
756
+
757
+ {/* Input field */}
724
758
  <input
725
759
  type="text"
760
+ className="form-control"
761
+ aria-label={promptInfo.opts.ariaLabel}
726
762
  placeholder={promptInfo.opts.placeholder}
727
763
  value={promptInfo.currentInputFieldText}
728
764
  onChange={(e) => {
@@ -731,14 +767,18 @@ const AppWrapper: React.FC<Props> = (props: Props): React.ReactElement => {
731
767
  currentInputFieldText: e.target.value,
732
768
  });
733
769
  }}
770
+ // eslint-disable-next-line jsx-a11y/no-autofocus
771
+ autoFocus
734
772
  />
773
+
774
+ {/* Validation errors */}
735
775
  {minNumCharsValidationError && (
736
- <div className="text-danger bg-danger bg-opacity-25 p-2 m-1 rounded">
776
+ <div className="text-danger fw-bold mt-2">
737
777
  {minNumCharsValidationError}
738
778
  </div>
739
779
  )}
740
780
  {customValidationError && (
741
- <div className="text-danger bg-danger bg-opacity-25 p-2 m-1 rounded">
781
+ <div className="text-danger fw-bold mt-2">
742
782
  {customValidationError}
743
783
  </div>
744
784
  )}
@@ -959,10 +959,23 @@ const LogReviewer: React.FC<Props> = (props) => {
959
959
  const { year, month } = toLoad[i];
960
960
 
961
961
  // Load
962
- const logs = await visitServerEndpoint({
963
- path: `${LOG_REVIEW_ROUTE_PATH_PREFIX}/years/${year}/months/${month}`,
964
- method: 'GET',
965
- });
962
+ let logs: Log[] = [];
963
+ let pageNumber = 1;
964
+ let hasAnotherPage = true;
965
+
966
+ while (hasAnotherPage) {
967
+ const response = await visitServerEndpoint({
968
+ path: `${LOG_REVIEW_ROUTE_PATH_PREFIX}/years/${year}/months/${month}`,
969
+ method: 'GET',
970
+ params: {
971
+ pageNumber,
972
+ },
973
+ });
974
+
975
+ logs = logs.concat(response.items);
976
+ hasAnotherPage = response.hasAnotherPage;
977
+ pageNumber += 1;
978
+ }
966
979
 
967
980
  // Add to map
968
981
  if (!logMap[year]) {
package/src/index.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  // Import components
2
2
  import AppWrapper, {
3
3
  alert,
4
+ prompt,
4
5
  confirm,
5
6
  showFatalError,
6
7
  addFatalErrorHandler,
@@ -148,6 +149,7 @@ export {
148
149
  Dropdown,
149
150
  // Global functions
150
151
  alert,
152
+ prompt,
151
153
  confirm,
152
154
  showFatalError,
153
155
  // Errors
@@ -14,6 +14,11 @@ const initLogCollection = (Collection: any) => {
14
14
  'context',
15
15
  'subcontext',
16
16
  'tags',
17
+ 'year',
18
+ 'month',
19
+ 'day',
20
+ 'hour',
21
+ 'type',
17
22
  ],
18
23
  },
19
24
  );
@@ -246,12 +246,14 @@ const initServer = (
246
246
  paramTypes: {
247
247
  year: ParamType.Int,
248
248
  month: ParamType.Int,
249
+ pageNumber: ParamType.Int,
249
250
  },
250
251
  handler: async ({ params }) => {
251
252
  // Get user info
252
253
  const {
253
254
  year,
254
255
  month,
256
+ pageNumber,
255
257
  userId,
256
258
  isAdmin,
257
259
  } = params;
@@ -266,13 +268,17 @@ const initServer = (
266
268
  }
267
269
 
268
270
  // Query for logs
269
- const logs: Log[] = await _logCollection.find({
270
- year,
271
- month,
271
+ const response = await _logCollection.findPaged({
272
+ query: {
273
+ year,
274
+ month,
275
+ },
276
+ perPage: 1000,
277
+ pageNumber,
272
278
  });
273
279
 
274
- // Return logs
275
- return logs;
280
+ // Return response
281
+ return response;
276
282
  },
277
283
  }),
278
284
  );