Skip to content

Commit

Permalink
Merge branch 'develop' into fix#6429
Browse files Browse the repository at this point in the history
  • Loading branch information
nihal467 authored Nov 6, 2023
2 parents c6904e3 + e1eac85 commit 66731de
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 19 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
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
Expand Down
2 changes: 2 additions & 0 deletions src/Common/hooks/useMSEplayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ interface UseMSEMediaPlayerOption {
export interface ICameraAssetState {
id: string;
accessKey: string;
middleware_address: string;
location_middleware: string;
}

export enum StreamStatus {
Expand Down
12 changes: 7 additions & 5 deletions src/Components/Assets/AssetType/ONVIFCamera.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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, {
Expand Down Expand Up @@ -136,9 +141,6 @@ const ONVIFCamera = ({ assetId, facilityId, asset, onUpdated }: Props) => {
};
if (isLoading || loading || !facility) return <Loading />;

const fallbackMiddleware =
asset?.location_object?.middleware_address || facilityMiddlewareHostname;

return (
<div className="space-y-6">
{["DistrictAdmin", "StateAdmin"].includes(authUser.user_type) && (
Expand Down Expand Up @@ -223,7 +225,7 @@ const ONVIFCamera = ({ assetId, facilityId, asset, onUpdated }: Props) => {
addPreset={addPreset}
isLoading={loadingAddPreset}
refreshPresetsHash={refreshPresetsHash}
facilityMiddlewareHostname={facilityMiddlewareHostname}
facilityMiddlewareHostname={currentMiddleware}
/>
) : null}
</div>
Expand Down
19 changes: 11 additions & 8 deletions src/Components/Facility/ConsultationDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -335,14 +335,17 @@ export const ConsultationDetails = (props: any) => {
>
Doctor Connect
</button>
{patientData.last_consultation?.id && (
<Link
href={`/facility/${patientData.facility}/patient/${patientData.id}/consultation/${patientData.last_consultation?.id}/feed`}
className="btn btn-primary m-1 w-full hover:text-white"
>
Camera Feed
</Link>
)}
{patientData.last_consultation?.id &&
["DistrictAdmin", "StateAdmin", "Doctor"].includes(
authUser.user_type
) && (
<Link
href={`/facility/${patientData.facility}/patient/${patientData.id}/consultation/${patientData.last_consultation?.id}/feed`}
className="btn btn-primary m-1 w-full hover:text-white"
>
Camera Feed
</Link>
)}
</>
)}
<Link
Expand Down
27 changes: 21 additions & 6 deletions src/Components/Facility/Consultations/Feed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,11 @@ export const Feed: React.FC<IFeedProps> = ({ consultationId, facilityId }) => {
const [cameraAsset, setCameraAsset] = useState<ICameraAssetState>({
id: "",
accessKey: "",
middleware_address: "",
location_middleware: "",
});
const [cameraMiddlewareHostname, setCameraMiddlewareHostname] = useState("");
const [facilityMiddlewareHostname, setFacilityMiddlewareHostname] =
useState("");
const [cameraConfig, setCameraConfig] = useState<any>({});
const [isLoading, setIsLoading] = useState(true);
const [bedPresets, setBedPresets] = useState<any>([]);
Expand All @@ -66,13 +69,19 @@ export const Feed: React.FC<IFeedProps> = ({ 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({
Expand Down Expand Up @@ -130,6 +139,12 @@ export const Feed: React.FC<IFeedProps> = ({ 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({
Expand Down Expand Up @@ -170,8 +185,8 @@ export const Feed: React.FC<IFeedProps> = ({ 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,
Expand All @@ -182,7 +197,7 @@ export const Feed: React.FC<IFeedProps> = ({ consultationId, facilityId }) => {
: // eslint-disable-next-line react-hooks/rules-of-hooks
useMSEMediaPlayer({
config: {
middlewareHostname: cameraMiddlewareHostname,
middlewareHostname: currentMiddleware,
...cameraAsset,
},
url,
Expand Down Expand Up @@ -229,7 +244,7 @@ export const Feed: React.FC<IFeedProps> = ({ consultationId, facilityId }) => {
});
getBedPresets(cameraAsset);
}
}, [cameraAsset, cameraMiddlewareHostname]);
}, [cameraAsset, currentMiddleware]);

useEffect(() => {
let tId: any;
Expand Down

0 comments on commit 66731de

Please sign in to comment.