Skip to content

Commit

Permalink
Merge branch 'coronasafe:develop' into Fix-#7086
Browse files Browse the repository at this point in the history
  • Loading branch information
AshrafMd-1 authored Feb 15, 2024
2 parents 37b8a8e + dacc7f8 commit 916e2bf
Show file tree
Hide file tree
Showing 57 changed files with 1,195 additions and 1,261 deletions.
2 changes: 0 additions & 2 deletions cypress/e2e/assets_spec/asset_homepage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,13 @@ describe("Asset Tab", () => {
it("Filter Asset", () => {
assetFilters.filterAssets(
"Dummy Facility 40",
"INTERNAL",
"ACTIVE",
"ONVIF Camera",
"Camera Loc"
);
assetFilters.clickadvancefilter();
assetFilters.clickslideoverbackbutton(); // to verify the back button doesn't clear applied filters
assetFilters.assertFacilityText("Dummy Facility 40");
assetFilters.assertAssetTypeText("INTERNAL");
assetFilters.assertAssetClassText("ONVIF");
assetFilters.assertStatusText("ACTIVE");
assetFilters.assertLocationText("Camera Loc");
Expand Down
4 changes: 0 additions & 4 deletions cypress/e2e/assets_spec/assets_creation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ describe("Asset", () => {
assetPage.clickCreateAsset();

assetPage.verifyEmptyAssetNameError();
assetPage.verifyEmptyAssetTypeError();
assetPage.verifyEmptyLocationError();
assetPage.verifyEmptyStatusError();
assetPage.verifyEmptyPhoneError();
Expand All @@ -41,7 +40,6 @@ describe("Asset", () => {
assetPage.createAsset();
assetPage.selectFacility("Dummy Facility 40");
assetPage.selectLocation("Camera Loc");
assetPage.selectAssetType("Internal");
assetPage.selectAssetClass("ONVIF Camera");

const qr_id_1 = uuidv4();
Expand All @@ -68,7 +66,6 @@ describe("Asset", () => {
const qr_id_2 = uuidv4();

assetPage.selectLocation("Camera Loc");
assetPage.selectAssetType("Internal");
assetPage.selectAssetClass("ONVIF Camera");
assetPage.enterAssetDetails(
"New Test Asset 2",
Expand Down Expand Up @@ -141,7 +138,6 @@ describe("Asset", () => {
assetPage.createAsset();
assetPage.selectFacility("Dummy Facility 40");
assetPage.selectLocation("Camera Loc");
assetPage.selectAssetType("Internal");
assetPage.selectAssetClass("HL7 Vitals Monitor");

const qr_id_1 = uuidv4();
Expand Down
7 changes: 0 additions & 7 deletions cypress/e2e/sample_test_spec/filter.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@ describe("Sample Filter", () => {
.click();
});

it("Filter by Asset Type", () => {
cy.get("#result").click();
cy.get("li[role='option']")
.contains(/^POSITIVE$/)
.click();
});

it("Filter by sample type", () => {
cy.get("#sample_type").click();
cy.get("li[role='option']")
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/users_spec/user_creation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe("User Creation", () => {
}
return result;
};
const username = makeid(25);
const username = makeid(8);
const alreadylinkedusersviews = [
"devdoctor",
"devstaff2",
Expand Down
15 changes: 0 additions & 15 deletions cypress/pageobject/Asset/AssetCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@ export class AssetPage {
});
}

selectAssetType(assetType: string) {
cy.get("[data-testid=asset-type-input] button")
.click()
.then(() => {
cy.get("[role='option']").contains(assetType).click();
});
}

selectAssetClass(assetClass: string) {
cy.get("[data-testid=asset-class-input] button")
.click()
Expand Down Expand Up @@ -205,13 +197,6 @@ export class AssetPage {
);
}

verifyEmptyAssetTypeError() {
cy.get("[data-testid=asset-type-input] span").should(
"contain",
"Select an asset type"
);
}

verifyEmptyStatusError() {
cy.get("[data-testid=asset-working-status-input] span").should(
"contain",
Expand Down
9 changes: 0 additions & 9 deletions cypress/pageobject/Asset/AssetFilters.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
export class AssetFilters {
filterAssets(
facilityName: string,
assetType: string,
assetStatus: string,
assetClass: string,
assetLocation: string
Expand All @@ -13,11 +12,6 @@ export class AssetFilters {
.then(() => {
cy.get("[role='option']").contains(facilityName).click();
});
cy.get("#asset-type")
.click()
.then(() => {
cy.get("[role='option']").contains(assetType).click();
});
cy.get("#asset-status")
.click()
.then(() => {
Expand Down Expand Up @@ -65,9 +59,6 @@ export class AssetFilters {
assertFacilityText(text) {
cy.get("[data-testid=Facility]").should("contain", text);
}
assertAssetTypeText(text) {
cy.get("[data-testid='Asset Type']").should("contain", text);
}
assertAssetClassText(text) {
cy.get("[data-testid='Asset Class']").should("contain", text);
}
Expand Down
3 changes: 2 additions & 1 deletion public/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@
"sample_format_asset_import": "https://spreadsheets.google.com/feeds/download/spreadsheets/Export?key=11JaEhNHdyCHth4YQs_44YaRlP77Rrqe81VSEfg1glko&exportFormat=xlsx",
"sample_format_external_result_import": "/External-Results-Template.csv",
"enable_abdm": true,
"enable_hcx": false
"enable_hcx": false,
"min_encounter_date": "2020-01-01"
}
2 changes: 1 addition & 1 deletion src/CAREUI/display/Timeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface TimelineEvent<TType = string> {
}

interface TimelineProps {
className: string;
className?: string;
children: React.ReactNode | React.ReactNode[];
name: string;
}
Expand Down
29 changes: 13 additions & 16 deletions src/CAREUI/misc/PaginatedList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import ButtonV2, {
import CareIcon from "../icons/CareIcon";
import { classNames } from "../../Utils/utils";
import Pagination from "../../Components/Common/Pagination";
import Timeline from "../display/Timeline";

const DEFAULT_PER_PAGE_LIMIT = 14;

Expand Down Expand Up @@ -135,21 +134,19 @@ const Items = <TItem extends object>(props: ItemsProps<TItem>) => {
}

return (
<Timeline className="rounded-lg bg-white p-2 shadow" name="log update">
<ul className={props.className}>
{loading && props.shimmer
? Array.from({ length: props.shimmerCount ?? 8 }).map((_, i) => (
<li key={i} className="w-full">
{props.shimmer}
</li>
))
: items.map((item, index, items) => (
<li key={index} className="w-full">
{props.children(item, items)}
</li>
))}
</ul>
</Timeline>
<ul className={props.className}>
{loading && props.shimmer
? Array.from({ length: props.shimmerCount ?? 8 }).map((_, i) => (
<li key={i} className="w-full">
{props.shimmer}
</li>
))
: items.map((item, index, items) => (
<li key={index} className="w-full">
{props.children(item, items)}
</li>
))}
</ul>
);
};

Expand Down
5 changes: 5 additions & 0 deletions src/Common/hooks/useConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ export interface IConfig {
*/
wartime_shifting: boolean;
jwt_token_refresh_interval?: number;

/*
* Minimum date for a possible consultation encounter.
*/
min_encounter_date: string;
}

const useConfig = () => {
Expand Down
2 changes: 1 addition & 1 deletion src/Common/validation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const validateName = (name: string) => {
};

export const validateUsername = (username: string) => {
const pattern = /^[\w.@+-]+[^.@+_-]$/;
const pattern = /^(?!.*[._-]{2})[a-z0-9](?:[a-z0-9._-]{2,14}[a-z0-9])$/s;
return pattern.test(username);
};

Expand Down
16 changes: 0 additions & 16 deletions src/Components/Assets/AssetFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ const getDate = (value: any) =>
function AssetFilter(props: any) {
const { filter, onChange, closeFilter, removeFilters } = props;
const [facility, setFacility] = useState<FacilityModel | null>(null);
const [asset_type, setAssetType] = useState<string>(
filter.asset_type ? filter.asset_type : ""
);
const [asset_status, setAssetStatus] = useState<string>(filter.status || "");
const [asset_class, setAssetClass] = useState<string>(
filter.asset_class || ""
Expand Down Expand Up @@ -61,7 +58,6 @@ function AssetFilter(props: any) {
const applyFilter = () => {
const data = {
facility: facilityId,
asset_type: asset_type ?? "",
asset_class: asset_class ?? "",
status: asset_status ?? "",
location: locationId ?? "",
Expand Down Expand Up @@ -125,18 +121,6 @@ function AssetFilter(props: any) {
</div>
)}

<SelectFormField
label="Asset Type"
errorClassName="hidden"
id="asset-type"
name="asset_type"
options={["EXTERNAL", "INTERNAL"]}
optionLabel={(o) => o}
optionValue={(o) => o}
value={asset_type}
onChange={({ value }) => setAssetType(value)}
/>

<SelectFormField
id="asset-status"
name="asset_status"
Expand Down
12 changes: 6 additions & 6 deletions src/Components/Assets/AssetManage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -365,11 +365,6 @@ const AssetManage = (props: AssetManageProps) => {
{asset?.description}
</div>
<div className="flex flex-wrap gap-2">
{asset?.asset_type === "INTERNAL" ? (
<Chip text="Internal" startIcon="l-building" />
) : (
<Chip text="External" startIcon="l-globe" />
)}
{asset?.status === "ACTIVE" ? (
<Chip text="Active" startIcon="l-check" />
) : (
Expand Down Expand Up @@ -503,7 +498,12 @@ const AssetManage = (props: AssetManageProps) => {
</div>
{asset?.id &&
asset?.asset_class &&
asset?.asset_class != AssetClass.NONE && <Uptime assetId={asset?.id} />}
asset?.asset_class != AssetClass.NONE && (
<Uptime
route={routes.listAssetAvailability}
params={{ external_id: asset.id }}
/>
)}
<div className="mb-4 mt-8 text-xl font-semibold">Service History</div>
<div
className="min-w-full overflow-hidden overflow-x-auto align-middle shadow sm:rounded-lg"
Expand Down
12 changes: 4 additions & 8 deletions src/Components/Assets/AssetTypes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export interface AssetData {
manufacturer: string;
warranty_amc_end_of_validity: string;
resolved_middleware?: ResolvedMiddleware;
latest_status: string;
last_service: AssetService;
meta?: {
[key: string]: any;
Expand All @@ -112,16 +113,11 @@ export interface AssetsResponse {
results: AssetData[];
}

export interface AssetUptimeRecord {
id: string;
asset: {
id: string;
name: string;
};
export interface AvailabilityRecord {
linked_id: string;
linked_model: string;
status: string;
timestamp: string;
created_date: string;
modified_date: string;
}

export interface AssetTransaction {
Expand Down
14 changes: 7 additions & 7 deletions src/Components/Assets/AssetsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ const AssetsList = () => {
const [isScannerActive, setIsScannerActive] = useState(false);
const [totalCount, setTotalCount] = useState(0);
const [facility, setFacility] = useState<FacilityModel>();
const [asset_type, setAssetType] = useState<string>();
const [status, setStatus] = useState<string>();
const [asset_class, setAssetClass] = useState<string>();
const [importAssetModalOpen, setImportAssetModalOpen] = useState(false);
Expand All @@ -60,7 +59,6 @@ const AssetsList = () => {
offset: (qParams.page ? qParams.page - 1 : 0) * resultsPerPage,
search_text: qParams.search || "",
facility: qParams.facility || "",
asset_type: qParams.asset_type || "",
asset_class: qParams.asset_class || "",
location: qParams.facility ? qParams.location || "" : "",
status: qParams.status || "",
Expand Down Expand Up @@ -91,10 +89,6 @@ const AssetsList = () => {
prefetch: !!qParams.facility,
});

useEffect(() => {
setAssetType(qParams.asset_type);
}, [qParams.asset_type]);

useEffect(() => {
setStatus(qParams.status);
}, [qParams.status]);
Expand Down Expand Up @@ -240,6 +234,13 @@ const AssetsList = () => {
<Chip variant="danger" startIcon="l-cog" text="Not Working" />
)}
{warrantyAmcValidityChip(asset.warranty_amc_end_of_validity)}
{asset?.latest_status === "Down" && (
<Chip
variant="danger"
startIcon="l-link-broken"
text={asset?.latest_status}
/>
)}{" "}
</div>
</div>
</Link>
Expand Down Expand Up @@ -380,7 +381,6 @@ const AssetsList = () => {
qParams.facility && facilityObject?.name
),
badge("Name/Serial No./QR ID", "search"),
value("Asset Type", "asset_type", asset_type ?? ""),
value("Asset Class", "asset_class", asset_class ?? ""),
value("Status", "status", status?.replace(/_/g, " ") ?? ""),
value(
Expand Down
Loading

0 comments on commit 916e2bf

Please sign in to comment.