From 5891df3a02588b8d9bc39fdbb5456545546e27d7 Mon Sep 17 00:00:00 2001
From: Ashesh <3626859+Ashesh3@users.noreply.github.com>
Date: Fri, 3 Nov 2023 17:50:46 +0530
Subject: [PATCH 1/3] Refactor middleware hostname in Feed component (#6538)
---
src/Common/hooks/useMSEplayer.ts | 2 ++
.../Assets/AssetType/ONVIFCamera.tsx | 12 +++++----
.../Facility/Consultations/Feed.tsx | 27 ++++++++++++++-----
3 files changed, 30 insertions(+), 11 deletions(-)
diff --git a/src/Common/hooks/useMSEplayer.ts b/src/Common/hooks/useMSEplayer.ts
index fcbf216ed6a..4d1bb36b9ac 100644
--- a/src/Common/hooks/useMSEplayer.ts
+++ b/src/Common/hooks/useMSEplayer.ts
@@ -20,6 +20,8 @@ interface UseMSEMediaPlayerOption {
export interface ICameraAssetState {
id: string;
accessKey: string;
+ middleware_address: string;
+ location_middleware: string;
}
export enum StreamStatus {
diff --git a/src/Components/Assets/AssetType/ONVIFCamera.tsx b/src/Components/Assets/AssetType/ONVIFCamera.tsx
index 4a3e475419e..44d4d372d73 100644
--- a/src/Components/Assets/AssetType/ONVIFCamera.tsx
+++ b/src/Components/Assets/AssetType/ONVIFCamera.tsx
@@ -53,6 +53,11 @@ const ONVIFCamera = ({ assetId, facilityId, asset, onUpdated }: Props) => {
}
}, [facility, facilityId]);
+ const fallbackMiddleware =
+ asset?.location_object?.middleware_address || facilityMiddlewareHostname;
+
+ const currentMiddleware = middlewareHostname || fallbackMiddleware;
+
useEffect(() => {
if (asset) {
setAssetType(asset?.asset_class);
@@ -105,7 +110,7 @@ const ONVIFCamera = ({ assetId, facilityId, asset, onUpdated }: Props) => {
try {
setLoadingAddPreset(true);
const presetData = await axios.get(
- `https://${facilityMiddlewareHostname}/status?hostname=${config.hostname}&port=${config.port}&username=${config.username}&password=${config.password}`
+ `https://${currentMiddleware}/status?hostname=${config.hostname}&port=${config.port}&username=${config.username}&password=${config.password}`
);
const { res } = await request(routes.createAssetBed, {
@@ -136,9 +141,6 @@ const ONVIFCamera = ({ assetId, facilityId, asset, onUpdated }: Props) => {
};
if (isLoading || loading || !facility) return ;
- const fallbackMiddleware =
- asset?.location_object?.middleware_address || facilityMiddlewareHostname;
-
return (
{["DistrictAdmin", "StateAdmin"].includes(authUser.user_type) && (
@@ -223,7 +225,7 @@ const ONVIFCamera = ({ assetId, facilityId, asset, onUpdated }: Props) => {
addPreset={addPreset}
isLoading={loadingAddPreset}
refreshPresetsHash={refreshPresetsHash}
- facilityMiddlewareHostname={facilityMiddlewareHostname}
+ facilityMiddlewareHostname={currentMiddleware}
/>
) : null}
diff --git a/src/Components/Facility/Consultations/Feed.tsx b/src/Components/Facility/Consultations/Feed.tsx
index 31691c736f4..3448d85a6a2 100644
--- a/src/Components/Facility/Consultations/Feed.tsx
+++ b/src/Components/Facility/Consultations/Feed.tsx
@@ -48,8 +48,11 @@ export const Feed: React.FC = ({ consultationId, facilityId }) => {
const [cameraAsset, setCameraAsset] = useState({
id: "",
accessKey: "",
+ middleware_address: "",
+ location_middleware: "",
});
- const [cameraMiddlewareHostname, setCameraMiddlewareHostname] = useState("");
+ const [facilityMiddlewareHostname, setFacilityMiddlewareHostname] =
+ useState("");
const [cameraConfig, setCameraConfig] = useState({});
const [isLoading, setIsLoading] = useState(true);
const [bedPresets, setBedPresets] = useState([]);
@@ -66,13 +69,19 @@ export const Feed: React.FC = ({ consultationId, facilityId }) => {
const res = await dispatch(getPermittedFacility(facilityId));
if (res.status === 200 && res.data) {
- setCameraMiddlewareHostname(res.data.middleware_address);
+ setFacilityMiddlewareHostname(res.data.middleware_address);
}
};
if (facilityId) fetchFacility();
}, [dispatch, facilityId]);
+ const fallbackMiddleware =
+ cameraAsset.location_middleware || facilityMiddlewareHostname;
+
+ const currentMiddleware =
+ cameraAsset.middleware_address || fallbackMiddleware;
+
useEffect(() => {
if (cameraState) {
setCameraState({
@@ -130,6 +139,12 @@ export const Feed: React.FC = ({ consultationId, facilityId }) => {
setCameraAsset({
id: bedAssets.data.results[0].asset_object.id,
accessKey: config[2] || "",
+ middleware_address:
+ bedAssets.data.results[0].asset_object?.meta
+ ?.middleware_hostname,
+ location_middleware:
+ bedAssets.data.results[0].asset_object.location_object
+ ?.middleware_address,
});
setCameraConfig(bedAssets.data.results[0].meta);
setCameraState({
@@ -170,8 +185,8 @@ export const Feed: React.FC = ({ consultationId, facilityId }) => {
);
const url = !isIOS
- ? `wss://${cameraMiddlewareHostname}/stream/${cameraAsset?.accessKey}/channel/0/mse?uuid=${cameraAsset?.accessKey}&channel=0`
- : `https://${cameraMiddlewareHostname}/stream/${cameraAsset?.accessKey}/channel/0/hls/live/index.m3u8?uuid=${cameraAsset?.accessKey}&channel=0`;
+ ? `wss://${currentMiddleware}/stream/${cameraAsset?.accessKey}/channel/0/mse?uuid=${cameraAsset?.accessKey}&channel=0`
+ : `https://${currentMiddleware}/stream/${cameraAsset?.accessKey}/channel/0/hls/live/index.m3u8?uuid=${cameraAsset?.accessKey}&channel=0`;
const {
startStream,
@@ -182,7 +197,7 @@ export const Feed: React.FC = ({ consultationId, facilityId }) => {
: // eslint-disable-next-line react-hooks/rules-of-hooks
useMSEMediaPlayer({
config: {
- middlewareHostname: cameraMiddlewareHostname,
+ middlewareHostname: currentMiddleware,
...cameraAsset,
},
url,
@@ -229,7 +244,7 @@ export const Feed: React.FC = ({ consultationId, facilityId }) => {
});
getBedPresets(cameraAsset);
}
- }, [cameraAsset, cameraMiddlewareHostname]);
+ }, [cameraAsset, currentMiddleware]);
useEffect(() => {
let tId: any;
From ac405ce4e9c51293d3d0cfb1fc4a6d8322417769 Mon Sep 17 00:00:00 2001
From: Ashesh <3626859+Ashesh3@users.noreply.github.com>
Date: Fri, 3 Nov 2023 20:33:34 +0530
Subject: [PATCH 2/3] Show camera feed button only for specific roles (#6540)
---
.../Facility/ConsultationDetails/index.tsx | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/src/Components/Facility/ConsultationDetails/index.tsx b/src/Components/Facility/ConsultationDetails/index.tsx
index 202c9200b0a..6fda874e3b3 100644
--- a/src/Components/Facility/ConsultationDetails/index.tsx
+++ b/src/Components/Facility/ConsultationDetails/index.tsx
@@ -335,14 +335,17 @@ export const ConsultationDetails = (props: any) => {
>
Doctor Connect
- {patientData.last_consultation?.id && (
-
- Camera Feed
-
- )}
+ {patientData.last_consultation?.id &&
+ ["DistrictAdmin", "StateAdmin", "Doctor"].includes(
+ authUser.user_type
+ ) && (
+
+ Camera Feed
+
+ )}
>
)}
Date: Fri, 3 Nov 2023 21:43:50 +0530
Subject: [PATCH 3/3] add auto deployment for staging gcp deployment (#6519)
---
.github/workflows/deploy.yaml | 42 +++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml
index 06b1cf8eff0..e5b3c768c49 100644
--- a/.github/workflows/deploy.yaml
+++ b/.github/workflows/deploy.yaml
@@ -180,6 +180,48 @@ jobs:
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
+ deploy-staging-gcp:
+ needs: build-production
+ name: Deploy to staging GCP cluster
+ runs-on: ubuntu-latest
+ environment:
+ name: Staging-GCP
+ url: https://care-staging.ohc.network/
+ steps:
+ - name: Checkout Kube Config
+ uses: actions/checkout@v3
+ with:
+ repository: coronasafe/care-staging-gcp
+ token: ${{ secrets.GIT_ACCESS_TOKEN }}
+ path: kube
+ ref: main
+
+ # Setup gcloud CLI
+ - uses: google-github-actions/setup-gcloud@94337306dda8180d967a56932ceb4ddcf01edae7
+ with:
+ service_account_key: ${{ secrets.GKE_SA_KEY }}
+ project_id: ${{ secrets.GKE_PROJECT }}
+
+ # Get the GKE credentials so we can deploy to the cluster
+ - uses: google-github-actions/get-gke-credentials@fb08709ba27618c31c09e014e1d8364b02e5042e
+ with:
+ cluster_name: ${{ secrets.GKE_CLUSTER }}
+ location: ${{ secrets.GKE_ZONE }}
+ credentials: ${{ secrets.GKE_SA_KEY }}
+
+ - name: install kubectl
+ uses: azure/setup-kubectl@v3.0
+ with:
+ version: "v1.23.6"
+ id: install
+
+ - name: Deploy Care Fe Production
+ run: |
+ mkdir -p $HOME/.kube/
+ cd kube/deployments/
+ sed -i -e "s/_BUILD_NUMBER_/${GITHUB_RUN_NUMBER}/g" care-fe.yaml
+ kubectl apply -f care-fe.yaml
+
deploy-production-manipur:
needs: build-production
name: Deploy to GKE Manipur