@trackunit/filters-asset-filter-definitions 2.1.94 → 2.1.96

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/index.cjs.js CHANGED
@@ -99,6 +99,7 @@ var defaultTranslations = {
99
99
  "assetFilters.metadataCompleteness.ALL": "All",
100
100
  "assetFilters.metadataCompleteness.COMPLETE": "Complete",
101
101
  "assetFilters.metadataCompleteness.PARTIAL": "Partial",
102
+ "assetFilters.modbusProfile.label": "Modbus profile",
102
103
  "assetFilters.ownerAccountNameFilter.label": "Owner",
103
104
  "assetFilters.partnerFilter.label": "Partner",
104
105
  "assetFilters.pendingTelematicsDevicesFilter.label": "Pending Telematics Devices",
@@ -363,7 +364,7 @@ const GET_ACCESS_MANAGEMENT_MODE_DESIRED_SUMMARY = client.gql `
363
364
  }
364
365
  }
365
366
  `;
366
- const FETCH_LIMIT$e = 1000;
367
+ const FETCH_LIMIT$f = 1000;
367
368
  /**
368
369
  Renders the Access Management Mode Filter view with the provided props.
369
370
 
@@ -377,7 +378,7 @@ const AccessManagementModeFilterView = ({ filterDefinition, filterState, filterB
377
378
  const { data, loading } = reactGraphqlHooks.useQuery(GET_ACCESS_MANAGEMENT_MODE_DESIRED_SUMMARY, {
378
379
  fetchPolicy: "cache-first",
379
380
  variables: {
380
- limit: FETCH_LIMIT$e,
381
+ limit: FETCH_LIMIT$f,
381
382
  filters: {
382
383
  ...activeFilters,
383
384
  accessManagementDesiredModes: null, // Omit the filters own values so list shows options correctly
@@ -518,6 +519,77 @@ const servicePlanStatus = {
518
519
  PLANNED: "PLANNED",
519
520
  UPCOMING: "UPCOMING",
520
521
  };
522
+ const GetFleetCountriesSummaryDocument = {
523
+ kind: "Document",
524
+ definitions: [
525
+ {
526
+ kind: "OperationDefinition",
527
+ operation: "query",
528
+ name: { kind: "Name", value: "GetFleetCountriesSummary" },
529
+ variableDefinitions: [
530
+ {
531
+ kind: "VariableDefinition",
532
+ variable: { kind: "Variable", name: { kind: "Name", value: "filters" } },
533
+ type: { kind: "NamedType", name: { kind: "Name", value: "AssetFiltersInput" } },
534
+ },
535
+ {
536
+ kind: "VariableDefinition",
537
+ variable: { kind: "Variable", name: { kind: "Name", value: "limit" } },
538
+ type: { kind: "NamedType", name: { kind: "Name", value: "Int" } },
539
+ },
540
+ ],
541
+ selectionSet: {
542
+ kind: "SelectionSet",
543
+ selections: [
544
+ {
545
+ kind: "Field",
546
+ name: { kind: "Name", value: "assetSummary" },
547
+ arguments: [
548
+ {
549
+ kind: "Argument",
550
+ name: { kind: "Name", value: "filters" },
551
+ value: { kind: "Variable", name: { kind: "Name", value: "filters" } },
552
+ },
553
+ ],
554
+ selectionSet: {
555
+ kind: "SelectionSet",
556
+ selections: [
557
+ {
558
+ kind: "Field",
559
+ name: { kind: "Name", value: "countries" },
560
+ arguments: [
561
+ {
562
+ kind: "Argument",
563
+ name: { kind: "Name", value: "limit" },
564
+ value: { kind: "Variable", name: { kind: "Name", value: "limit" } },
565
+ },
566
+ ],
567
+ selectionSet: {
568
+ kind: "SelectionSet",
569
+ selections: [
570
+ { kind: "Field", name: { kind: "Name", value: "total" } },
571
+ {
572
+ kind: "Field",
573
+ name: { kind: "Name", value: "summary" },
574
+ selectionSet: {
575
+ kind: "SelectionSet",
576
+ selections: [
577
+ { kind: "Field", name: { kind: "Name", value: "key" } },
578
+ { kind: "Field", name: { kind: "Name", value: "count" } },
579
+ ],
580
+ },
581
+ },
582
+ ],
583
+ },
584
+ },
585
+ ],
586
+ },
587
+ },
588
+ ],
589
+ },
590
+ },
591
+ ],
592
+ };
521
593
  const DeviceHealthIssueCategorySummariesDocument = {
522
594
  kind: "Document",
523
595
  definitions: [
@@ -835,6 +907,87 @@ const GetFleetFirmwareVersionSummaryDocument = {
835
907
  },
836
908
  ],
837
909
  };
910
+ const GetFleetModbusProfileSummaryDocument = {
911
+ kind: "Document",
912
+ definitions: [
913
+ {
914
+ kind: "OperationDefinition",
915
+ operation: "query",
916
+ name: { kind: "Name", value: "GetFleetModbusProfileSummary" },
917
+ variableDefinitions: [
918
+ {
919
+ kind: "VariableDefinition",
920
+ variable: { kind: "Variable", name: { kind: "Name", value: "filters" } },
921
+ type: { kind: "NamedType", name: { kind: "Name", value: "AssetFiltersInput" } },
922
+ },
923
+ {
924
+ kind: "VariableDefinition",
925
+ variable: { kind: "Variable", name: { kind: "Name", value: "search" } },
926
+ type: { kind: "NamedType", name: { kind: "Name", value: "String" } },
927
+ },
928
+ {
929
+ kind: "VariableDefinition",
930
+ variable: { kind: "Variable", name: { kind: "Name", value: "limit" } },
931
+ type: { kind: "NamedType", name: { kind: "Name", value: "Int" } },
932
+ },
933
+ ],
934
+ selectionSet: {
935
+ kind: "SelectionSet",
936
+ selections: [
937
+ {
938
+ kind: "Field",
939
+ name: { kind: "Name", value: "assetSummary" },
940
+ arguments: [
941
+ {
942
+ kind: "Argument",
943
+ name: { kind: "Name", value: "filters" },
944
+ value: { kind: "Variable", name: { kind: "Name", value: "filters" } },
945
+ },
946
+ ],
947
+ selectionSet: {
948
+ kind: "SelectionSet",
949
+ selections: [
950
+ {
951
+ kind: "Field",
952
+ name: { kind: "Name", value: "modbusProfileSummary" },
953
+ arguments: [
954
+ {
955
+ kind: "Argument",
956
+ name: { kind: "Name", value: "filter" },
957
+ value: { kind: "Variable", name: { kind: "Name", value: "search" } },
958
+ },
959
+ {
960
+ kind: "Argument",
961
+ name: { kind: "Name", value: "limit" },
962
+ value: { kind: "Variable", name: { kind: "Name", value: "limit" } },
963
+ },
964
+ ],
965
+ selectionSet: {
966
+ kind: "SelectionSet",
967
+ selections: [
968
+ { kind: "Field", name: { kind: "Name", value: "total" } },
969
+ {
970
+ kind: "Field",
971
+ name: { kind: "Name", value: "summary" },
972
+ selectionSet: {
973
+ kind: "SelectionSet",
974
+ selections: [
975
+ { kind: "Field", name: { kind: "Name", value: "key" } },
976
+ { kind: "Field", name: { kind: "Name", value: "count" } },
977
+ ],
978
+ },
979
+ },
980
+ ],
981
+ },
982
+ },
983
+ ],
984
+ },
985
+ },
986
+ ],
987
+ },
988
+ },
989
+ ],
990
+ };
838
991
  const GetFleetAssetTypesSummaryDocument = {
839
992
  kind: "Document",
840
993
  definitions: [
@@ -2980,7 +3133,7 @@ const useAssetTypeFilter = ({ showTypes } = { showTypes: ALL_TYPES }) => {
2980
3133
  return result;
2981
3134
  };
2982
3135
 
2983
- const FETCH_LIMIT$d = 1000;
3136
+ const FETCH_LIMIT$e = 1000;
2984
3137
  /**
2985
3138
  * React component for rendering the brand filter.
2986
3139
  *
@@ -2996,7 +3149,7 @@ const BrandFilterView = (props) => {
2996
3149
  const { data, loading } = reactGraphqlHooks.useQuery(GetFleetBrandsSummaryDocument, {
2997
3150
  fetchPolicy: "cache-first",
2998
3151
  variables: {
2999
- limit: FETCH_LIMIT$d,
3152
+ limit: FETCH_LIMIT$e,
3000
3153
  search: debouncedSearch.trim(),
3001
3154
  filters: {
3002
3155
  ...activeFilters,
@@ -3013,7 +3166,7 @@ const BrandFilterView = (props) => {
3013
3166
  return result;
3014
3167
  }, [data?.assetSummary?.brands?.summary, getMachineTypeTranslation]);
3015
3168
  react.useEffect(() => {
3016
- setShowRequestMoreUseSearch(options.length === FETCH_LIMIT$d);
3169
+ setShowRequestMoreUseSearch(options.length === FETCH_LIMIT$e);
3017
3170
  }, [options]);
3018
3171
  return (jsxRuntime.jsx(filtersFilterBar.DefaultCheckboxFilter, { ...props, customSearch: { value: searchText, onChange: setSearchText, onClear: () => setSearchText("") }, loading: loading, options: options, showRequestMoreUseSearch: showRequestMoreUseSearch }));
3019
3172
  };
@@ -3040,6 +3193,71 @@ const useBrandFilter = () => {
3040
3193
  return result;
3041
3194
  };
3042
3195
 
3196
+ /**
3197
+ * Build the country filter options from the SFS country summary, translating each
3198
+ * code to its localized name and ordering the list alphabetically by that name.
3199
+ *
3200
+ * @param summary - The country summary entries (code + asset count) from the SFS dimension.
3201
+ * @param languages - Preferred display languages, typically `i18n.languages`.
3202
+ * @returns {Array<{ key: string; count: number; label: string }>} Filter options sorted alphabetically by localized name.
3203
+ */
3204
+ const buildCountryOptions = (summary, languages) => {
3205
+ return summary
3206
+ .map(country => ({
3207
+ key: country.key,
3208
+ count: country.count,
3209
+ label: sharedUtils.getCountryName(country.key, languages),
3210
+ }))
3211
+ .sort((a, b) => sharedUtils.stringCompare(a.label, b.label));
3212
+ };
3213
+
3214
+ const COUNTRY_FETCH_LIMIT = 300;
3215
+ /**
3216
+ * React component for rendering the country filter.
3217
+ *
3218
+ * @param {FilterViewProps<string[]>} props - The component's properties, including filter state and values.
3219
+ * @returns {ReactElement} The country filter component.
3220
+ */
3221
+ const CountryFilter = (props) => {
3222
+ const [, i18n] = useTranslation();
3223
+ const activeFilters = filtersGraphqlHook.useActiveAssetFilters(props.filterState.values);
3224
+ const { data, loading } = reactGraphqlHooks.useQuery(GetFleetCountriesSummaryDocument, {
3225
+ fetchPolicy: "cache-first",
3226
+ variables: {
3227
+ limit: COUNTRY_FETCH_LIMIT,
3228
+ filters: {
3229
+ ...activeFilters,
3230
+ countries: null, // Omit the filters own values so list shows options correctly
3231
+ },
3232
+ },
3233
+ });
3234
+ const options = react.useMemo(() => {
3235
+ return buildCountryOptions(data?.assetSummary?.countries?.summary ?? [], i18n.languages);
3236
+ }, [data?.assetSummary?.countries?.summary, i18n.languages]);
3237
+ return jsxRuntime.jsx(filtersFilterBar.DefaultCheckboxFilter, { ...props, loading: loading, options: options });
3238
+ };
3239
+
3240
+ /**
3241
+ * Get the Country filter definition
3242
+ *
3243
+ * @returns {StringArrayFilterDefinition} The Country filter definition
3244
+ */
3245
+ const useCountryFilter = () => {
3246
+ const [t, i18n] = useTranslation();
3247
+ return react.useMemo(() => {
3248
+ return {
3249
+ filterKey: "countries",
3250
+ type: "stringArray",
3251
+ group: "CURRENT_LOCATION",
3252
+ title: t("fleetlist.column.country"),
3253
+ valueAsText(value) {
3254
+ return value.map(code => sharedUtils.getCountryName(code, i18n.languages));
3255
+ },
3256
+ component: props => jsxRuntime.jsx(CountryFilter, { ...props }),
3257
+ };
3258
+ }, [t, i18n.languages]);
3259
+ };
3260
+
3043
3261
  const mapCriticalityToLabelId = (state) => {
3044
3262
  switch (state) {
3045
3263
  case assetCriticalityState.CRITICAL:
@@ -3112,7 +3330,7 @@ const useCriticalityFilter = () => {
3112
3330
  return result;
3113
3331
  };
3114
3332
 
3115
- const FETCH_LIMIT$c = 1000;
3333
+ const FETCH_LIMIT$d = 1000;
3116
3334
  /**
3117
3335
  * Custom hook to fetch customer summary data based on active filters and search text.
3118
3336
  *
@@ -3127,7 +3345,7 @@ const useCustomerData = (filterValues, customerId) => {
3127
3345
  const { data, loading } = reactGraphqlHooks.useQuery(GetCustomerIdSummaryDocument, {
3128
3346
  fetchPolicy: "cache-first",
3129
3347
  variables: {
3130
- limit: FETCH_LIMIT$c,
3348
+ limit: FETCH_LIMIT$d,
3131
3349
  search: debouncedSearch,
3132
3350
  filters: {
3133
3351
  ...activeFilters,
@@ -3544,7 +3762,7 @@ const useDeviceTypesFilter = (showInFilterBar) => {
3544
3762
  }, [t, showInFilterBar]);
3545
3763
  };
3546
3764
 
3547
- const FETCH_LIMIT$b = 1000;
3765
+ const FETCH_LIMIT$c = 1000;
3548
3766
  /**
3549
3767
  * The Firmware Version Filter component.
3550
3768
  *
@@ -3565,7 +3783,7 @@ const FirmwareVersionFilter = ({ filterDefinition, filterState, filterBarActions
3565
3783
  const debouncedSearch = reactComponents.useDebounce(searchText, { delay: 500 });
3566
3784
  const { data, loading } = reactGraphqlHooks.useQuery(GetFleetFirmwareVersionSummaryDocument, {
3567
3785
  variables: {
3568
- limit: FETCH_LIMIT$b,
3786
+ limit: FETCH_LIMIT$c,
3569
3787
  search: debouncedSearch,
3570
3788
  filters: {
3571
3789
  ...activeFilters,
@@ -3582,7 +3800,7 @@ const FirmwareVersionFilter = ({ filterDefinition, filterState, filterBarActions
3582
3800
  return result;
3583
3801
  }, [data?.assetSummary?.firmwareVersionSummary?.summary, t]);
3584
3802
  react.useEffect(() => {
3585
- setShowRequestMoreUseSearch(options.length === FETCH_LIMIT$b);
3803
+ setShowRequestMoreUseSearch(options.length === FETCH_LIMIT$c);
3586
3804
  }, [options]);
3587
3805
  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 }));
3588
3806
  };
@@ -3649,7 +3867,7 @@ const useFollowedFilter = () => {
3649
3867
  return result;
3650
3868
  };
3651
3869
 
3652
- const FETCH_LIMIT$a = 1000;
3870
+ const FETCH_LIMIT$b = 1000;
3653
3871
  /**
3654
3872
  * The GroupIdsFilterView component is a filter view for group IDs.
3655
3873
  * It utilizes a checkbox filter with a search feature to display and manage group selections.
@@ -3665,7 +3883,7 @@ const GroupIdsFilterView = (props) => {
3665
3883
  const { data, loading } = reactGraphqlHooks.useQuery(GetFleetGroupSummaryDocument, {
3666
3884
  fetchPolicy: "cache-first",
3667
3885
  variables: {
3668
- limit: FETCH_LIMIT$a,
3886
+ limit: FETCH_LIMIT$b,
3669
3887
  search: debouncedSearch,
3670
3888
  filters: {
3671
3889
  ...activeFilters,
@@ -3689,7 +3907,7 @@ const GroupIdsFilterView = (props) => {
3689
3907
  return result;
3690
3908
  }, [data?.assetSummary?.groups, props.hasCount]);
3691
3909
  react.useEffect(() => {
3692
- setShowRequestMoreUseSearch(options.length === FETCH_LIMIT$a);
3910
+ setShowRequestMoreUseSearch(options.length === FETCH_LIMIT$b);
3693
3911
  }, [options]);
3694
3912
  return (jsxRuntime.jsx(filtersFilterBar.DefaultCheckboxFilter, { ...props, customSearch: { value: searchText, onChange: setSearchText, onClear: () => setSearchText("") }, loading: loading, options: options, showRequestMoreUseSearch: showRequestMoreUseSearch }));
3695
3913
  };
@@ -4184,6 +4402,67 @@ const useMetadataCompletenessFilter = ({ isDefault } = {}) => {
4184
4402
  return result;
4185
4403
  };
4186
4404
 
4405
+ const FETCH_LIMIT$a = 1000;
4406
+ /**
4407
+ * The Modbus Profile Filter component.
4408
+ *
4409
+ * Provides an interface to select Modbus profiles. It fetches data from a GraphQL query
4410
+ * and integrates with the filter bar's filtering logic.
4411
+ *
4412
+ * @param props - The filter view props.
4413
+ * @param props.filterDefinition - The filter's definition.
4414
+ * @param props.filterState - The current state of the filter, including selected values.
4415
+ * @param props.filterBarActions - Actions for the filter's interaction with the filter bar.
4416
+ * @returns {ReactElement} React component to render the Modbus profile filter.
4417
+ */
4418
+ const ModbusProfileFilter = ({ filterDefinition, filterState, filterBarActions, ...props }) => {
4419
+ const [t] = useTranslation();
4420
+ const activeFilters = filtersGraphqlHook.useActiveAssetFilters(filterState.values);
4421
+ const [showRequestMoreUseSearch, setShowRequestMoreUseSearch] = react.useState(false);
4422
+ const [searchText, setSearchText] = react.useState("");
4423
+ const debouncedSearch = reactComponents.useDebounce(searchText, { delay: 500 });
4424
+ const { data, loading } = reactGraphqlHooks.useQuery(GetFleetModbusProfileSummaryDocument, {
4425
+ variables: {
4426
+ limit: FETCH_LIMIT$a,
4427
+ search: debouncedSearch,
4428
+ filters: {
4429
+ ...activeFilters,
4430
+ modbusProfile: null, // Omit the filters own values so list shows options correctly
4431
+ },
4432
+ },
4433
+ fetchPolicy: "cache-first",
4434
+ });
4435
+ const options = react.useMemo(() => {
4436
+ const result = data?.assetSummary?.modbusProfileSummary?.summary.map(modbusProfile => ({
4437
+ ...modbusProfile,
4438
+ label: modbusProfile.key.toUpperCase() === "UNDEFINED" ? t(`machine.types.Unknown`) : modbusProfile.key,
4439
+ })) ?? [];
4440
+ return result;
4441
+ }, [data?.assetSummary?.modbusProfileSummary?.summary, t]);
4442
+ react.useEffect(() => {
4443
+ setShowRequestMoreUseSearch(options.length === FETCH_LIMIT$a);
4444
+ }, [options]);
4445
+ 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 }));
4446
+ };
4447
+
4448
+ /**
4449
+ * Get the Modbus Profile filter definition
4450
+ *
4451
+ * @returns {ValueNameArrayFilterDefinition} The Modbus Profile filter definition
4452
+ */
4453
+ const useModbusProfileFilter = () => {
4454
+ const [t] = useTranslation();
4455
+ return react.useMemo(() => {
4456
+ return {
4457
+ filterKey: "modbusProfile",
4458
+ type: "valueNameArray",
4459
+ group: "DEVICE",
4460
+ title: t("assetFilters.modbusProfile.label"),
4461
+ component: props => jsxRuntime.jsx(ModbusProfileFilter, { ...props }),
4462
+ };
4463
+ }, [t]);
4464
+ };
4465
+
4187
4466
  const FETCH_LIMIT$9 = 1000;
4188
4467
  /**
4189
4468
  * Renders a custom model filter component, allowing filtering of active assets by models.
@@ -5675,6 +5954,7 @@ const useDefaultAssetFilterBarDefinition = () => {
5675
5954
  const siteIds = useSiteIdsFilter(siteEnabledProps);
5676
5955
  const siteDepotOwnershipIds = useSiteDepotOwnershipIdsFilter();
5677
5956
  const brands = useBrandFilter();
5957
+ const countries = useCountryFilter();
5678
5958
  const models = useModelsFilter();
5679
5959
  const types = useTypesFilter();
5680
5960
  const activity = useActivityFilter();
@@ -5732,6 +6012,7 @@ const useDefaultAssetFilterBarDefinition = () => {
5732
6012
  metadataCompleteness,
5733
6013
  siteIds,
5734
6014
  siteType,
6015
+ countries,
5735
6016
  area,
5736
6017
  groups,
5737
6018
  ownerAccountIds,
@@ -5766,6 +6047,7 @@ const useDefaultAssetFilterBarDefinition = () => {
5766
6047
  assetType,
5767
6048
  metadataCompleteness,
5768
6049
  brands,
6050
+ countries,
5769
6051
  models,
5770
6052
  types,
5771
6053
  activity,
@@ -5866,6 +6148,7 @@ exports.useAreaFilter = useAreaFilter;
5866
6148
  exports.useAssetIdsFilter = useAssetIdsFilter;
5867
6149
  exports.useAssetTypeFilter = useAssetTypeFilter;
5868
6150
  exports.useBrandFilter = useBrandFilter;
6151
+ exports.useCountryFilter = useCountryFilter;
5869
6152
  exports.useCriticalityFilter = useCriticalityFilter;
5870
6153
  exports.useCustomerIdsFilter = useCustomerIdsFilter;
5871
6154
  exports.useDefaultAssetFilterBarDefinition = useDefaultAssetFilterBarDefinition;
@@ -5884,6 +6167,7 @@ exports.useInsightsBatteryStateOfChargePercentFilter = useInsightsBatteryStateOf
5884
6167
  exports.useInsightsFuelLevelFilter = useInsightsFuelLevelFilter;
5885
6168
  exports.useLastSeenFilter = useLastSeenFilter;
5886
6169
  exports.useMetadataCompletenessFilter = useMetadataCompletenessFilter;
6170
+ exports.useModbusProfileFilter = useModbusProfileFilter;
5887
6171
  exports.useModelsFilter = useModelsFilter;
5888
6172
  exports.useOwnerAccountIdsFilter = useOwnerAccountIdsFilter;
5889
6173
  exports.usePartnerFilter = usePartnerFilter;