@trackunit/filters-asset-filter-definitions 2.1.100 → 2.2.0

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.
Files changed (47) hide show
  1. package/index.cjs.js +401 -5
  2. package/index.esm.js +400 -6
  3. package/migrations/entry.js.map +1 -0
  4. package/package.json +2 -2
  5. package/src/defaultFilters/defaults/CanProfileFilter/Can1ProfileFilter.d.ts +17 -0
  6. package/src/defaultFilters/defaults/CanProfileFilter/Can2ProfileFilter.d.ts +17 -0
  7. package/src/defaultFilters/defaults/CanProfileFilter/useCan1ProfileFilter.d.ts +7 -0
  8. package/src/defaultFilters/defaults/CanProfileFilter/useCan2ProfileFilter.d.ts +7 -0
  9. package/src/generated/graphql-api/gql.d.ts +32 -0
  10. package/src/generated/graphql-api/graphql.d.ts +78 -0
  11. package/src/generated/graphql-api/mock.d.ts +12 -0
  12. package/src/index.d.ts +2 -0
  13. package/src/translation.d.ts +2 -2
  14. package/translation.cjs.js +1 -0
  15. package/translation.cjs10.js +1 -0
  16. package/translation.cjs11.js +1 -0
  17. package/translation.cjs12.js +1 -0
  18. package/translation.cjs13.js +1 -0
  19. package/translation.cjs14.js +1 -0
  20. package/translation.cjs15.js +1 -0
  21. package/translation.cjs16.js +1 -0
  22. package/translation.cjs17.js +1 -0
  23. package/translation.cjs2.js +1 -0
  24. package/translation.cjs3.js +1 -0
  25. package/translation.cjs4.js +1 -0
  26. package/translation.cjs5.js +1 -0
  27. package/translation.cjs6.js +1 -0
  28. package/translation.cjs7.js +1 -0
  29. package/translation.cjs8.js +1 -0
  30. package/translation.cjs9.js +1 -0
  31. package/translation.esm.js +1 -0
  32. package/translation.esm10.js +1 -0
  33. package/translation.esm11.js +1 -0
  34. package/translation.esm12.js +1 -0
  35. package/translation.esm13.js +1 -0
  36. package/translation.esm14.js +1 -0
  37. package/translation.esm15.js +1 -0
  38. package/translation.esm16.js +1 -0
  39. package/translation.esm17.js +1 -0
  40. package/translation.esm2.js +1 -0
  41. package/translation.esm3.js +1 -0
  42. package/translation.esm4.js +1 -0
  43. package/translation.esm5.js +1 -0
  44. package/translation.esm6.js +1 -0
  45. package/translation.esm7.js +1 -0
  46. package/translation.esm8.js +1 -0
  47. package/translation.esm9.js +1 -0
package/index.cjs.js CHANGED
@@ -62,6 +62,8 @@ var defaultTranslations = {
62
62
  "assetFilters.assetType.TOOL": "Tools",
63
63
  "assetFilters.assetType.VEHICLE": "Vehicle",
64
64
  "assetFilters.boundingBoxFilter.value": "Within map area",
65
+ "assetFilters.can1Profile.label": "CAN1 profile",
66
+ "assetFilters.can2Profile.label": "CAN2 profile",
65
67
  "assetFilters.criticality.CRITICAL": "Critical",
66
68
  "assetFilters.criticality.LOW": "Low",
67
69
  "assetFilters.criticality.NONE": "Good",
@@ -364,7 +366,7 @@ const GET_ACCESS_MANAGEMENT_MODE_DESIRED_SUMMARY = client.gql `
364
366
  }
365
367
  }
366
368
  `;
367
- const FETCH_LIMIT$f = 1000;
369
+ const FETCH_LIMIT$h = 1000;
368
370
  /**
369
371
  Renders the Access Management Mode Filter view with the provided props.
370
372
 
@@ -378,7 +380,7 @@ const AccessManagementModeFilterView = ({ filterDefinition, filterState, filterB
378
380
  const { data, loading } = reactGraphqlHooks.useQuery(GET_ACCESS_MANAGEMENT_MODE_DESIRED_SUMMARY, {
379
381
  fetchPolicy: "cache-first",
380
382
  variables: {
381
- limit: FETCH_LIMIT$f,
383
+ limit: FETCH_LIMIT$h,
382
384
  filters: {
383
385
  ...activeFilters,
384
386
  accessManagementDesiredModes: null, // Omit the filters own values so list shows options correctly
@@ -519,6 +521,256 @@ const servicePlanStatus = {
519
521
  PLANNED: "PLANNED",
520
522
  UPCOMING: "UPCOMING",
521
523
  };
524
+ const TelematicsDeviceCan1ProfileNamesDocument = {
525
+ kind: "Document",
526
+ definitions: [
527
+ {
528
+ kind: "OperationDefinition",
529
+ operation: "query",
530
+ name: { kind: "Name", value: "TelematicsDeviceCan1ProfileNames" },
531
+ selectionSet: {
532
+ kind: "SelectionSet",
533
+ selections: [
534
+ {
535
+ kind: "Field",
536
+ name: { kind: "Name", value: "telematicsDeviceSummary" },
537
+ selectionSet: {
538
+ kind: "SelectionSet",
539
+ selections: [
540
+ {
541
+ kind: "Field",
542
+ name: { kind: "Name", value: "can1Profiles" },
543
+ selectionSet: {
544
+ kind: "SelectionSet",
545
+ selections: [
546
+ {
547
+ kind: "Field",
548
+ name: { kind: "Name", value: "summary" },
549
+ selectionSet: {
550
+ kind: "SelectionSet",
551
+ selections: [
552
+ { kind: "Field", name: { kind: "Name", value: "key" } },
553
+ { kind: "Field", name: { kind: "Name", value: "name" } },
554
+ ],
555
+ },
556
+ },
557
+ ],
558
+ },
559
+ },
560
+ ],
561
+ },
562
+ },
563
+ ],
564
+ },
565
+ },
566
+ ],
567
+ };
568
+ const GetFleetCan1ProfileSummaryDocument = {
569
+ kind: "Document",
570
+ definitions: [
571
+ {
572
+ kind: "OperationDefinition",
573
+ operation: "query",
574
+ name: { kind: "Name", value: "GetFleetCan1ProfileSummary" },
575
+ variableDefinitions: [
576
+ {
577
+ kind: "VariableDefinition",
578
+ variable: { kind: "Variable", name: { kind: "Name", value: "filters" } },
579
+ type: { kind: "NamedType", name: { kind: "Name", value: "AssetFiltersInput" } },
580
+ },
581
+ {
582
+ kind: "VariableDefinition",
583
+ variable: { kind: "Variable", name: { kind: "Name", value: "search" } },
584
+ type: { kind: "NamedType", name: { kind: "Name", value: "String" } },
585
+ },
586
+ {
587
+ kind: "VariableDefinition",
588
+ variable: { kind: "Variable", name: { kind: "Name", value: "limit" } },
589
+ type: { kind: "NamedType", name: { kind: "Name", value: "Int" } },
590
+ },
591
+ ],
592
+ selectionSet: {
593
+ kind: "SelectionSet",
594
+ selections: [
595
+ {
596
+ kind: "Field",
597
+ name: { kind: "Name", value: "assetSummary" },
598
+ arguments: [
599
+ {
600
+ kind: "Argument",
601
+ name: { kind: "Name", value: "filters" },
602
+ value: { kind: "Variable", name: { kind: "Name", value: "filters" } },
603
+ },
604
+ ],
605
+ selectionSet: {
606
+ kind: "SelectionSet",
607
+ selections: [
608
+ {
609
+ kind: "Field",
610
+ name: { kind: "Name", value: "can1ProfileSummary" },
611
+ arguments: [
612
+ {
613
+ kind: "Argument",
614
+ name: { kind: "Name", value: "filter" },
615
+ value: { kind: "Variable", name: { kind: "Name", value: "search" } },
616
+ },
617
+ {
618
+ kind: "Argument",
619
+ name: { kind: "Name", value: "limit" },
620
+ value: { kind: "Variable", name: { kind: "Name", value: "limit" } },
621
+ },
622
+ ],
623
+ selectionSet: {
624
+ kind: "SelectionSet",
625
+ selections: [
626
+ { kind: "Field", name: { kind: "Name", value: "total" } },
627
+ {
628
+ kind: "Field",
629
+ name: { kind: "Name", value: "summary" },
630
+ selectionSet: {
631
+ kind: "SelectionSet",
632
+ selections: [
633
+ { kind: "Field", name: { kind: "Name", value: "key" } },
634
+ { kind: "Field", name: { kind: "Name", value: "count" } },
635
+ ],
636
+ },
637
+ },
638
+ ],
639
+ },
640
+ },
641
+ ],
642
+ },
643
+ },
644
+ ],
645
+ },
646
+ },
647
+ ],
648
+ };
649
+ const TelematicsDeviceCan2ProfileNamesDocument = {
650
+ kind: "Document",
651
+ definitions: [
652
+ {
653
+ kind: "OperationDefinition",
654
+ operation: "query",
655
+ name: { kind: "Name", value: "TelematicsDeviceCan2ProfileNames" },
656
+ selectionSet: {
657
+ kind: "SelectionSet",
658
+ selections: [
659
+ {
660
+ kind: "Field",
661
+ name: { kind: "Name", value: "telematicsDeviceSummary" },
662
+ selectionSet: {
663
+ kind: "SelectionSet",
664
+ selections: [
665
+ {
666
+ kind: "Field",
667
+ name: { kind: "Name", value: "can2Profiles" },
668
+ selectionSet: {
669
+ kind: "SelectionSet",
670
+ selections: [
671
+ {
672
+ kind: "Field",
673
+ name: { kind: "Name", value: "summary" },
674
+ selectionSet: {
675
+ kind: "SelectionSet",
676
+ selections: [
677
+ { kind: "Field", name: { kind: "Name", value: "key" } },
678
+ { kind: "Field", name: { kind: "Name", value: "name" } },
679
+ ],
680
+ },
681
+ },
682
+ ],
683
+ },
684
+ },
685
+ ],
686
+ },
687
+ },
688
+ ],
689
+ },
690
+ },
691
+ ],
692
+ };
693
+ const GetFleetCan2ProfileSummaryDocument = {
694
+ kind: "Document",
695
+ definitions: [
696
+ {
697
+ kind: "OperationDefinition",
698
+ operation: "query",
699
+ name: { kind: "Name", value: "GetFleetCan2ProfileSummary" },
700
+ variableDefinitions: [
701
+ {
702
+ kind: "VariableDefinition",
703
+ variable: { kind: "Variable", name: { kind: "Name", value: "filters" } },
704
+ type: { kind: "NamedType", name: { kind: "Name", value: "AssetFiltersInput" } },
705
+ },
706
+ {
707
+ kind: "VariableDefinition",
708
+ variable: { kind: "Variable", name: { kind: "Name", value: "search" } },
709
+ type: { kind: "NamedType", name: { kind: "Name", value: "String" } },
710
+ },
711
+ {
712
+ kind: "VariableDefinition",
713
+ variable: { kind: "Variable", name: { kind: "Name", value: "limit" } },
714
+ type: { kind: "NamedType", name: { kind: "Name", value: "Int" } },
715
+ },
716
+ ],
717
+ selectionSet: {
718
+ kind: "SelectionSet",
719
+ selections: [
720
+ {
721
+ kind: "Field",
722
+ name: { kind: "Name", value: "assetSummary" },
723
+ arguments: [
724
+ {
725
+ kind: "Argument",
726
+ name: { kind: "Name", value: "filters" },
727
+ value: { kind: "Variable", name: { kind: "Name", value: "filters" } },
728
+ },
729
+ ],
730
+ selectionSet: {
731
+ kind: "SelectionSet",
732
+ selections: [
733
+ {
734
+ kind: "Field",
735
+ name: { kind: "Name", value: "can2ProfileSummary" },
736
+ arguments: [
737
+ {
738
+ kind: "Argument",
739
+ name: { kind: "Name", value: "filter" },
740
+ value: { kind: "Variable", name: { kind: "Name", value: "search" } },
741
+ },
742
+ {
743
+ kind: "Argument",
744
+ name: { kind: "Name", value: "limit" },
745
+ value: { kind: "Variable", name: { kind: "Name", value: "limit" } },
746
+ },
747
+ ],
748
+ selectionSet: {
749
+ kind: "SelectionSet",
750
+ selections: [
751
+ { kind: "Field", name: { kind: "Name", value: "total" } },
752
+ {
753
+ kind: "Field",
754
+ name: { kind: "Name", value: "summary" },
755
+ selectionSet: {
756
+ kind: "SelectionSet",
757
+ selections: [
758
+ { kind: "Field", name: { kind: "Name", value: "key" } },
759
+ { kind: "Field", name: { kind: "Name", value: "count" } },
760
+ ],
761
+ },
762
+ },
763
+ ],
764
+ },
765
+ },
766
+ ],
767
+ },
768
+ },
769
+ ],
770
+ },
771
+ },
772
+ ],
773
+ };
522
774
  const GetFleetCountriesSummaryDocument = {
523
775
  kind: "Document",
524
776
  definitions: [
@@ -3133,7 +3385,7 @@ const useAssetTypeFilter = ({ showTypes } = { showTypes: ALL_TYPES }) => {
3133
3385
  return result;
3134
3386
  };
3135
3387
 
3136
- const FETCH_LIMIT$e = 1000;
3388
+ const FETCH_LIMIT$g = 1000;
3137
3389
  /**
3138
3390
  * React component for rendering the brand filter.
3139
3391
  *
@@ -3149,7 +3401,7 @@ const BrandFilterView = (props) => {
3149
3401
  const { data, loading } = reactGraphqlHooks.useQuery(GetFleetBrandsSummaryDocument, {
3150
3402
  fetchPolicy: "cache-first",
3151
3403
  variables: {
3152
- limit: FETCH_LIMIT$e,
3404
+ limit: FETCH_LIMIT$g,
3153
3405
  search: debouncedSearch.trim(),
3154
3406
  filters: {
3155
3407
  ...activeFilters,
@@ -3166,7 +3418,7 @@ const BrandFilterView = (props) => {
3166
3418
  return result;
3167
3419
  }, [data?.assetSummary?.brands?.summary, getMachineTypeTranslation]);
3168
3420
  react.useEffect(() => {
3169
- setShowRequestMoreUseSearch(options.length === FETCH_LIMIT$e);
3421
+ setShowRequestMoreUseSearch(options.length === FETCH_LIMIT$g);
3170
3422
  }, [options]);
3171
3423
  return (jsxRuntime.jsx(filtersFilterBar.DefaultCheckboxFilter, { ...props, customSearch: { value: searchText, onChange: setSearchText, onClear: () => setSearchText("") }, loading: loading, options: options, showRequestMoreUseSearch: showRequestMoreUseSearch }));
3172
3424
  };
@@ -3193,6 +3445,148 @@ const useBrandFilter = () => {
3193
3445
  return result;
3194
3446
  };
3195
3447
 
3448
+ const FETCH_LIMIT$f = 1000;
3449
+ /**
3450
+ * The CAN 1 Profile Filter component.
3451
+ *
3452
+ * Provides an interface to select CAN profiles reported on the CAN1 port. Options are
3453
+ * fetched from a GraphQL query keyed by the profile key, but only the resolved profile
3454
+ * name is displayed. Searching is delegated to the backend, which matches against the
3455
+ * profile key.
3456
+ *
3457
+ * @param props - The filter view props.
3458
+ * @param props.filterDefinition - The filter's definition.
3459
+ * @param props.filterState - The current state of the filter, including selected values.
3460
+ * @param props.filterBarActions - Actions for the filter's interaction with the filter bar.
3461
+ * @returns {ReactElement} React component to render the CAN1 profile filter.
3462
+ */
3463
+ const Can1ProfileFilter = ({ filterDefinition, filterState, filterBarActions, ...props }) => {
3464
+ const [t] = useTranslation();
3465
+ const activeFilters = filtersGraphqlHook.useActiveAssetFilters(filterState.values);
3466
+ const [showRequestMoreUseSearch, setShowRequestMoreUseSearch] = react.useState(false);
3467
+ const [searchText, setSearchText] = react.useState("");
3468
+ const debouncedSearch = reactComponents.useDebounce(searchText, { delay: 500 });
3469
+ const { data, loading } = reactGraphqlHooks.useQuery(GetFleetCan1ProfileSummaryDocument, {
3470
+ variables: {
3471
+ limit: FETCH_LIMIT$f,
3472
+ search: debouncedSearch,
3473
+ filters: {
3474
+ ...activeFilters,
3475
+ can1Profile: null, // Omit the filters own values so list shows options correctly
3476
+ },
3477
+ },
3478
+ fetchPolicy: "cache-first",
3479
+ });
3480
+ const { data: profileNamesData } = reactGraphqlHooks.useQuery(TelematicsDeviceCan1ProfileNamesDocument, {
3481
+ context: { headers: { "TU-PREVIEW": "TELEMATICS_DEVICE_PREVIEW" } },
3482
+ fetchPolicy: "cache-first",
3483
+ });
3484
+ const profileNameByKey = react.useMemo(() => new Map(profileNamesData?.telematicsDeviceSummary?.can1Profiles?.summary?.map(profile => [profile.key, profile.name]) ??
3485
+ []), [profileNamesData?.telematicsDeviceSummary?.can1Profiles?.summary]);
3486
+ const options = react.useMemo(() => {
3487
+ const result = data?.assetSummary?.can1ProfileSummary?.summary.map(canProfile => {
3488
+ if (canProfile.key.toUpperCase() === "UNDEFINED") {
3489
+ return { ...canProfile, label: t(`machine.types.Unknown`) };
3490
+ }
3491
+ return { ...canProfile, label: profileNameByKey.get(canProfile.key) ?? canProfile.key };
3492
+ }) ?? [];
3493
+ return result;
3494
+ }, [data?.assetSummary?.can1ProfileSummary?.summary, profileNameByKey, t]);
3495
+ react.useEffect(() => {
3496
+ setShowRequestMoreUseSearch(options.length === FETCH_LIMIT$f);
3497
+ }, [options]);
3498
+ return (jsxRuntime.jsx(filtersFilterBar.DefaultCheckboxFilter, { ...props, customSearch: { value: searchText, onChange: setSearchText, onClear: () => setSearchText("") }, filterBarActions: filterBarActions, filterDefinition: filterDefinition, filterState: filterState, loading: loading, options: options, showRequestMoreUseSearch: showRequestMoreUseSearch }));
3499
+ };
3500
+
3501
+ /**
3502
+ * Get the CAN 1 Profile filter definition
3503
+ *
3504
+ * @returns {ValueNameArrayFilterDefinition} The CAN 1 Profile filter definition
3505
+ */
3506
+ const useCan1ProfileFilter = () => {
3507
+ const [t] = useTranslation();
3508
+ return react.useMemo(() => {
3509
+ return {
3510
+ filterKey: "can1Profile",
3511
+ type: "valueNameArray",
3512
+ group: "DEVICE",
3513
+ title: t("assetFilters.can1Profile.label"),
3514
+ component: props => jsxRuntime.jsx(Can1ProfileFilter, { ...props }),
3515
+ };
3516
+ }, [t]);
3517
+ };
3518
+
3519
+ const FETCH_LIMIT$e = 1000;
3520
+ /**
3521
+ * The CAN 2 Profile Filter component.
3522
+ *
3523
+ * Provides an interface to select CAN profiles reported on the CAN2 port. Options are
3524
+ * fetched from a GraphQL query keyed by the profile key, but only the resolved profile
3525
+ * name is displayed. Searching is delegated to the backend, which matches against the
3526
+ * profile key.
3527
+ *
3528
+ * @param props - The filter view props.
3529
+ * @param props.filterDefinition - The filter's definition.
3530
+ * @param props.filterState - The current state of the filter, including selected values.
3531
+ * @param props.filterBarActions - Actions for the filter's interaction with the filter bar.
3532
+ * @returns {ReactElement} React component to render the CAN2 profile filter.
3533
+ */
3534
+ const Can2ProfileFilter = ({ filterDefinition, filterState, filterBarActions, ...props }) => {
3535
+ const [t] = useTranslation();
3536
+ const activeFilters = filtersGraphqlHook.useActiveAssetFilters(filterState.values);
3537
+ const [showRequestMoreUseSearch, setShowRequestMoreUseSearch] = react.useState(false);
3538
+ const [searchText, setSearchText] = react.useState("");
3539
+ const debouncedSearch = reactComponents.useDebounce(searchText, { delay: 500 });
3540
+ const { data, loading } = reactGraphqlHooks.useQuery(GetFleetCan2ProfileSummaryDocument, {
3541
+ variables: {
3542
+ limit: FETCH_LIMIT$e,
3543
+ search: debouncedSearch,
3544
+ filters: {
3545
+ ...activeFilters,
3546
+ can2Profile: null, // Omit the filters own values so list shows options correctly
3547
+ },
3548
+ },
3549
+ fetchPolicy: "cache-first",
3550
+ });
3551
+ const { data: profileNamesData } = reactGraphqlHooks.useQuery(TelematicsDeviceCan2ProfileNamesDocument, {
3552
+ context: { headers: { "TU-PREVIEW": "TELEMATICS_DEVICE_PREVIEW" } },
3553
+ fetchPolicy: "cache-first",
3554
+ });
3555
+ const profileNameByKey = react.useMemo(() => new Map(profileNamesData?.telematicsDeviceSummary?.can2Profiles?.summary?.map(profile => [profile.key, profile.name]) ??
3556
+ []), [profileNamesData?.telematicsDeviceSummary?.can2Profiles?.summary]);
3557
+ const options = react.useMemo(() => {
3558
+ const result = data?.assetSummary?.can2ProfileSummary?.summary.map(canProfile => {
3559
+ if (canProfile.key.toUpperCase() === "UNDEFINED") {
3560
+ return { ...canProfile, label: t(`machine.types.Unknown`) };
3561
+ }
3562
+ return { ...canProfile, label: profileNameByKey.get(canProfile.key) ?? canProfile.key };
3563
+ }) ?? [];
3564
+ return result;
3565
+ }, [data?.assetSummary?.can2ProfileSummary?.summary, profileNameByKey, t]);
3566
+ react.useEffect(() => {
3567
+ setShowRequestMoreUseSearch(options.length === FETCH_LIMIT$e);
3568
+ }, [options]);
3569
+ return (jsxRuntime.jsx(filtersFilterBar.DefaultCheckboxFilter, { ...props, customSearch: { value: searchText, onChange: setSearchText, onClear: () => setSearchText("") }, filterBarActions: filterBarActions, filterDefinition: filterDefinition, filterState: filterState, loading: loading, options: options, showRequestMoreUseSearch: showRequestMoreUseSearch }));
3570
+ };
3571
+
3572
+ /**
3573
+ * Get the CAN 2 Profile filter definition
3574
+ *
3575
+ * @returns {ValueNameArrayFilterDefinition} The CAN 2 Profile filter definition
3576
+ */
3577
+ const useCan2ProfileFilter = () => {
3578
+ const [t] = useTranslation();
3579
+ return react.useMemo(() => {
3580
+ return {
3581
+ filterKey: "can2Profile",
3582
+ type: "valueNameArray",
3583
+ group: "DEVICE",
3584
+ title: t("assetFilters.can2Profile.label"),
3585
+ component: props => jsxRuntime.jsx(Can2ProfileFilter, { ...props }),
3586
+ };
3587
+ }, [t]);
3588
+ };
3589
+
3196
3590
  /**
3197
3591
  * Build the country filter options from the SFS country summary, translating each
3198
3592
  * code to its localized name and ordering the list alphabetically by that name.
@@ -6148,6 +6542,8 @@ exports.useAreaFilter = useAreaFilter;
6148
6542
  exports.useAssetIdsFilter = useAssetIdsFilter;
6149
6543
  exports.useAssetTypeFilter = useAssetTypeFilter;
6150
6544
  exports.useBrandFilter = useBrandFilter;
6545
+ exports.useCan1ProfileFilter = useCan1ProfileFilter;
6546
+ exports.useCan2ProfileFilter = useCan2ProfileFilter;
6151
6547
  exports.useCountryFilter = useCountryFilter;
6152
6548
  exports.useCriticalityFilter = useCriticalityFilter;
6153
6549
  exports.useCustomerIdsFilter = useCustomerIdsFilter;