Skip to content

Commit

Permalink
merge conflicts resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
suryansh-egov committed Dec 18, 2024
2 parents 98d8784 + 6a94576 commit e7cea20
Show file tree
Hide file tree
Showing 18 changed files with 1,236 additions and 671 deletions.
28 changes: 24 additions & 4 deletions .github/workflows/branch-name-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ on:
- master
- develop
- console

pull_request:
branches:
- master
- develop
- console

types:
- opened
- edited
- reopened

jobs:
validate-names:
Expand Down Expand Up @@ -47,13 +53,27 @@ jobs:
PREFIXES="FEATURE|BUGFIX|RELEASE"
PROJECTS="HCMPRE|DPG|SN"
TICKET_PATTERN="[0-9]{1,5}"
TITLE_PATTERN="^($PREFIXES)\/($PROJECTS)-$TICKET_PATTERN .+$"
TITLE_PATTERN="^($PREFIXES)\/($PROJECTS)-$TICKET_PATTERN.*$"
MIN_TITLE_LENGTH=30
# Get the PR title
pr_title="${{ github.event.pull_request.title }}"
# Fetch the latest PR title dynamically
pr_title=$(curl -s https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }} | jq -r '.title')
echo "Fetched PR title: $pr_title"
# Validate the PR title
if [[ ! "$pr_title" =~ $TITLE_PATTERN ]]; then
echo "PR title '$pr_title' does not follow the correct pattern: $PREFIXES/$PROJECTS-<TICKET_NO>: <Description> where <TICKET_NO> is $TICKET_PATTERN"
echo "PR title '$pr_title' does not follow the correct pattern: $PREFIXES/$PROJECTS-<TICKET_NO> : <Description> where <TICKET_NO> is $TICKET_PATTERN"
exit 1
fi
# Validate the PR title length
if [[ ${#pr_title} -lt $MIN_TITLE_LENGTH ]]; then
echo "PR title '$pr_title' is too short. It must be at least $MIN_TITLE_LENGTH characters long, excluding the default pattern or ticket number."
exit 1
fi
echo "PR title validation passed."



2 changes: 1 addition & 1 deletion health/micro-ui/web/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"dependencies": {
"@egovernments/digit-ui-libraries": "1.8.6",
"@egovernments/digit-ui-module-workbench": "1.0.11",
"@egovernments/digit-ui-module-core": "1.8.12",
"@egovernments/digit-ui-module-core": "1.8.14",
"@egovernments/digit-ui-module-utilities": "1.0.10",
"@egovernments/digit-ui-components":"0.0.2-beta.56",
"@egovernments/digit-ui-react-components": "1.8.12",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"@egovernments/digit-ui-libraries": "1.8.6",
"@egovernments/digit-ui-module-workbench": "1.0.11",
"@egovernments/digit-ui-components": "0.0.2-beta.58",
"@egovernments/digit-ui-module-core": "1.8.12",
"@egovernments/digit-ui-module-core": "1.8.14",
"@egovernments/digit-ui-module-utilities": "1.0.3",
"@egovernments/digit-ui-react-components": "1.8.12",
"@egovernments/digit-ui-module-hcmworkbench": "0.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
"@rjsf/utils": "5.10.0",
"@rjsf/validator-ajv8": "5.10.0",
"ajv": "8.12.0",
"geojsonhint": "^2.0.0",
"leaflet": "^1.9.4",
"proj4": "^2.15.0",
"react": "17.0.2",
"react-date-range": "1.4.0",
"react-dom": "17.0.2",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import "leaflet/dist/leaflet.css";
import React from "react";
import * as DigitSvgs from "@egovernments/digit-ui-svg-components";


export const generatePreviewUrl = (baseMapUrl, center = [0, 0], zoom = 5) => {
const lon = Math.floor(((center[1] + 180) / 360) * Math.pow(0, zoom));
const lat = Math.floor(
((1 - Math.log(Math.tan((center[0] * Math.PI) / 180) + 1 / Math.cos((center[0] * Math.PI) / 180)) / Math.PI) / 2) * Math.pow(2, zoom)
);
if (baseMapUrl) {
const updatedUrl = baseMapUrl.replace("{z}", zoom).replace("{x}", lat).replace("{y}", lon).replace("{s}", "a");
return updatedUrl;
}
// Return a default preview URL or handle this case as needed
return "default-preview-url.jpg"; // todo
};



const BaseMapSwitcher = ({ baseMaps, showBaseMapSelector, setShowBaseMapSelector, handleBaseMapToggle, selectedBaseMapName, basemapRef, t }) => {
if (!baseMaps) return null;
return (
<div className="base-map-selector">
<div
className="icon-first"
onClick={() => setShowBaseMapSelector((previous) => !previous)}
onKeyUp={() => setShowBaseMapSelector((previous) => !previous)}
tabIndex={0}
style={{display:"flex"}}
>
<p className="map-filter-layers">{t("LAYERS")}</p>
<div className="layer-icon">{DigitSvgs.Layers && <DigitSvgs.Layers width={"1.667rem"} height={"1.667rem"} fill={"rgba(255, 255, 255, 1)"} />}</div>
</div>
<div className="base-map-area-wrapper" ref={basemapRef}>
{showBaseMapSelector && (
<div className="base-map-area" style={{display:"flex"}}>
{Object.entries(baseMaps).map(([name, baseMap], index) => {
return (
<div key={index} className={`base-map-entity ${name === selectedBaseMapName ? "selected" : ""}`}>
<img
className="base-map-img"
key={index}
src={generatePreviewUrl(baseMap?.metadata?.url, [0, 0], 0)}
alt={t("ERROR_LOADING_BASE_MAP")}
onClick={() => handleBaseMapToggle(name)}
/>
<p>{t(name)}</p>
</div>
);
})}
</div>
)}
</div>
</div>
);
};

export default BaseMapSwitcher;
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import React, { memo, useEffect, useRef, useState } from "react";
import L from "leaflet";
import "leaflet/dist/leaflet.css";
import { Card, Button, MultiSelectDropdown, TooltipWrapper, Tooltip , Dropdown } from "@egovernments/digit-ui-components";
import { useTranslation } from "react-i18next";
import { InfoIconOutline, CardLabel } from "@egovernments/digit-ui-react-components";

const BoundaryFilter = ({t,filterOptions , onSelectBoundary}) => {
const [boundaryType , setBoundaryType] = useState();

function convertFilterOptionsToArray(filterOptions) {
const keys = Object.keys(filterOptions);
return keys
.filter((key) => Array.isArray(filterOptions[key]))
.map((key) => ({
code: key,
name: key,
}));
}

useEffect(() => {
onSelectBoundary({boundaryType: boundaryType });
}, [boundaryType]);

return (
<div className={`map-filter-by-boundary`}>
<Button
type="actionButton"
variation="secondary"
icon="FilterAlt"
label={t("BUTTON_FILTER_BY_BOUNDARY")}
title={t("BUTTON_FILTER_BY_BOUNDARY")}
options={convertFilterOptionsToArray(filterOptions)}
optionsKey="name"
showBottom={true}
isSearchable={false}
onOptionSelect={(value) => {
setBoundaryType(value?.code);
}}
/>
</div>
);
};

export default BoundaryFilter;
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import React, { useEffect, useState } from "react";

const CustomScaleControl = ({ map }) => {
if (!map) return null;
const [scaleText, setScaleText] = useState("");
// Function to calculate and update the scale text
const updateScale = () => {
// Calculate the scale based on the map's current zoom level
const maxWidthMeters = map.containerPointToLatLng([0, map.getSize().y]).distanceTo(map.containerPointToLatLng([100, map.getSize().y]));
const scale = maxWidthMeters / 1000; // Convert to kilometers

// Format the scale text
const scaleTextData = scale < 1 ? `${Math.round(scale * 1000)} m` : `${Math.round(Math.round(scale.toFixed(0) / 10) * 10)} km`;

// Update the scale text in the container element
setScaleText(scaleTextData);
};

// Effect to update the scale text when the map component mounts and on map zoom change
useEffect(() => {
// Update the scale text initially
updateScale();

// Register the map's zoom events to update the scale text
map.on("zoomend", updateScale);

// Clean up event listener when the component unmounts
return () => {
map.off("zoomend", updateScale);
};
}, [map]);

return (
<div className="custom-scale" aria-live="polite">
{scaleText}
<div className="border-spikes" aria-hidden="true" />
</div>
);
};

export default CustomScaleControl;
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import React,{Fragment} from "react";
import * as DigitSvgs from "@egovernments/digit-ui-svg-components";

const IconCollection = {...DigitSvgs };

export const FilterItemBuilder = ({ item, MapFilters, t }) => {
let temp = MapFilters?.find((e) => e?.name === item)?.icon?.index;
let DynamicIcon = IconCollection?.[temp];
// let icon;
// if (typeof DynamicIcon === "function") icon = DynamicIcon({});
return DynamicIcon && typeof DynamicIcon === "function" ? (
<div className="filter-row">
<DynamicIcon width={"1.5rem"} height={"1.5rem"} fill={"white"} />
<p className="map-filter-layers">{t(item)}</p>
</div>
) : (
// <div style={{width:"1.5rem"}}></div>
""
);
};

const MapFilterIndex = ({ filterSelections, MapFilters, t }) => {
return (
<div className="filter-index">
{filterSelections && filterSelections.length > 0 ? (
<>
{filterSelections.map((item, index) => (
// <div className="filter-row">
<FilterItemBuilder key={item?.id || index} item={item} MapFilters={MapFilters} t={t} />
// <p>{t(item)}</p>
// </div>
))}
</>
) : (
""
)}
</div>
);
};

export default MapFilterIndex;
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,8 @@ const UploadData = ({ formData, onSelect, ...props }) => {
if (fileData && fileData?.[0]?.url) {
setDownloadError(false);
if (fileData?.[0]?.id) {
downloadExcelWithCustomName({ fileStoreId: fileData?.[0]?.id, customName: fileData?.[0]?.filename });
const customFileName = parentId ? `${campaignName}_${t("HCM_FILLED")}_${fileData[0].filename}` : `${campaignName}_${fileData[0].filename}`;
downloadExcelWithCustomName({ fileStoreId: fileData?.[0]?.id, customName: customFileName });
setDownloadedTemplates((prev) => ({
...prev,
[type]: true,
Expand Down
Loading

0 comments on commit e7cea20

Please sign in to comment.