Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
688 changes: 665 additions & 23 deletions CageUI/package-lock.json

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions CageUI/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,20 @@
"author": "Board of Regents of the University of Wisconsin System",
"license": "Apache-2.0",
"dependencies": {
"@emotion/react": "^11.14.0",
"@emotion/styled": "^11.14.1",
"@labkey/api": "1.51.5",
"@labkey/components": "7.43.0",
"@mui/icons-material": "^9.0.1",
"@mui/material": "^9.0.1",
"@mui/x-data-grid": "^8.28.6",
"@mui/x-date-pickers": "^9.2.0",
"d3": "^7.9.0",
"dayjs": "^1.11.21",
"react": "~18.3.1",
"react-bootstrap": "~2.10.10",
"react-dom": "~18.3.1",
"react-is": "^18.3.1",
"react-select": "^5.10.2",
"react-svg": "^16.4.2"
},
Expand Down
43 changes: 43 additions & 0 deletions CageUI/resources/queries/cageui/ghost_cages.query.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!--
~ /*
~ * Copyright (c) 2026 Board of Regents of the University of Wisconsin System
~ *
~ * Licensed under the Apache License, Version 2.0 (the "License");
~ * you may not use this file except in compliance with the License.
~ * You may obtain a copy of the License at
~ *
~ * http://www.apache.org/licenses/LICENSE-2.0
~ *
~ * Unless required by applicable law or agreed to in writing, software
~ * distributed under the License is distributed on an "AS IS" BASIS,
~ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ * See the License for the specific language governing permissions and
~ * limitations under the License.
~ */
-->

<query xmlns="http://labkey.org/data/xml/query">
<metadata>
<tables xmlns="http://labkey.org/data/xml">
<table tableName="ghost_cages" tableDbType="TABLE">
<tableTitle>Ghost Cages</tableTitle>
<columns>
<column columnName="rowid">
<isKeyField>true</isKeyField>
</column>
<column columnName="cage_objectid"/>
<column columnName="positionid"/>
<column columnName="rack_group"/>
<column columnName="rack_objectid"/>
<column columnName="group_rotation"/>
<column columnName="cage"/>
<column columnName="container"/>
<column columnName="createdby"/>
<column columnName="created"/>
<column columnName="modified"/>
<column columnName="modifiedby"/>
</columns>
</table>
</tables>
</metadata>
</query>
9 changes: 1 addition & 8 deletions CageUI/resources/queries/cageui/layout_history.query.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,7 @@
<isKeyField>true</isKeyField>
</column>
<column columnName="historyid"/>
<column columnName="cage">
<fk>
<fkDbSchema>cageui</fkDbSchema>
<fkTable>cages</fkTable>
<fkColumnName>objectid</fkColumnName>
<fkDisplayColumnName>cage_number</fkDisplayColumnName>
</fk>
</column>
<column columnName="cage"/>
<column columnName="extra_context"/>
<column columnName="object_type">
<datatype>integer</datatype>
Expand Down
16 changes: 16 additions & 0 deletions CageUI/resources/schemas/cageui.xml
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,20 @@
<column columnName="modifiedby"/>
</columns>
</table>
<table tableName="ghost_cages" tableDbType="TABLE">
<columns>
<column columnName="rowid"/>
<column columnName="cage_objectid"/>
<column columnName="positionid"/>
<column columnName="rack_group"/>
<column columnName="rack_objectid"/>
<column columnName="group_rotation"/>
<column columnName="cage"/>
<column columnName="container"/>
<column columnName="createdby"/>
<column columnName="created"/>
<column columnName="modified"/>
<column columnName="modifiedby"/>
</columns>
</table>
</tables>
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
*
* * Copyright (c) 2026 Board of Regents of the University of Wisconsin System
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/

DROP TABLE IF EXISTS cageui.ghost_cages;
CREATE TABLE cageui.ghost_cages
(
rowid SERIAL NOT NULL,
cage_objectid VARCHAR NOT NULL,
positionid INTEGER,
rack_group INTEGER NOT NULL,
rack_objectid VARCHAR NOT NULL,
group_rotation INTEGER NOT NULL,
cage INTEGER NOT NULL,
container entityid NOT NULL,
createdby userid,
created TIMESTAMP,
modifiedby userid,
modified TIMESTAMP,
CONSTRAINT PK_ghost_cages PRIMARY KEY (rowid),
CONSTRAINT FK_ghost_cages_container FOREIGN KEY (container) REFERENCES core.Containers (EntityId)
);

insert into ehr_lookups.lookups (set_name,container,value, category, title, description)
select setname, container, 8 as value, 'Caging' as category, 'Ghost Cage' as title, 4 as description from ehr_lookups.lookup_sets where setname='cageui_item_types';

insert into ehr_lookups.lookups (set_name,container,value, title)
select setname, container, 'ghostCage' as value, '/cageui/static/cage.svg' as title from ehr_lookups.lookup_sets where setname='cageui_svg_urls';

INSERT INTO ehr_lookups.lookup_sets (setname, label, description, keyField, container)
select 'adoption_status' as setname,
'Adoption Status Field Values' as label,
'List of possible adoption progress statuses' as description,
'value' as keyField,
container from ehr_lookups.lookup_sets where setname='ancestry';

insert into ehr_lookups.lookups (set_name,container,value, title)
select setname, container, 0 as value, 'Start' as title from ehr_lookups.lookup_sets where setname='adoption_status';

insert into ehr_lookups.lookups (set_name,container,value, title)
select setname, container, 1 as value, 'End' as title from ehr_lookups.lookup_sets where setname='adoption_status';

insert into ehr_lookups.lookups (set_name,container,value, title)
select setname, container, 2 as value, 'Pause' as title from ehr_lookups.lookup_sets where setname='adoption_status';

insert into ehr_lookups.lookups (set_name,container,value, title)
select setname, container, 3 as value, 'Resume' as title from ehr_lookups.lookup_sets where setname='adoption_status';


INSERT INTO ehr_lookups.lookup_sets (setname, label, description, keyField, container)
select 'adoption_results' as setname,
'Adoption Result Field Values' as label,
'List of possible adoption results' as description,
'value' as keyField,
container from ehr_lookups.lookup_sets where setname='ancestry';

insert into ehr_lookups.lookups (set_name,container,value, title)
select setname, container, 0 as value, 'Success' as title from ehr_lookups.lookup_sets where setname='adoption_results';

insert into ehr_lookups.lookups (set_name,container,value, title)
select setname, container, 1 as value, 'Failure' as title from ehr_lookups.lookup_sets where setname='adoption_results';
42 changes: 22 additions & 20 deletions CageUI/resources/web/CageUI/static/legend.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 18 additions & 1 deletion CageUI/src/client/api/labkeyActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { ActionURL, Ajax, Query, Security, Utils } from '@labkey/api';
import { CageMods, Rack, RackConditionOption, Room, SessionLog } from '../types/typings';
import { buildURL } from '@labkey/components';
import { RackSwitchOption } from '../types/homeTypes';
import { AdoptionData } from '../types/adoptionFormTypes';

export function labkeyActionSelectWithPromise(
options: Query.SelectRowsOptions,
Expand Down Expand Up @@ -165,7 +166,7 @@ export function saveRoomLayout(room: Room, mods: CageMods[], prevRoomName: strin

export function createNewRoomFromRackChange(room: Room, newRackOption: RackSwitchOption, prevRack: Rack ): Promise<{
room: Room,
rack: string;
rack: string,
errors: any[]
}> {
return new Promise((resolve, reject) => {
Expand Down Expand Up @@ -193,4 +194,20 @@ export function updateRackConditionStatus(rack: RackSwitchOption, condition: Rac
jsonData: {rack: rack.value.objectId, condition: condition.value},
});
});
}

// This function is for submitting a adoption form.
export function startAdoptionSubmission(animals: AdoptionData[]): Promise<{
success: boolean,
errors: any[]
}> {
return new Promise((resolve, reject) => {
Ajax.request({
url: buildURL('cageui', 'submitAdoptionForm.api'),
method: 'POST',
success: (res) => resolve(JSON.parse(res.response)),
failure: Utils.getCallbackWrapper((error) => reject(error)),
jsonData: {adoptionData: animals},
});
});
}
31 changes: 30 additions & 1 deletion CageUI/src/client/api/popularQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import { Filter, Query } from '@labkey/api';
import { labkeyActionSelectWithPromise } from './labkeyActions';
import { EHRCageMods } from '../types/homeTypes';
import { CageData, CageHistoryData, RackData } from '../types/typings';
import { CageData, CageHistoryData, GhostCageData, RackData } from '../types/typings';

export const cageModLookup = async (columns: string[], filterArray: Filter.IFilter[]): Promise<EHRCageMods[]> => {
const config: Query.SelectRowsOptions = {
Expand Down Expand Up @@ -100,6 +100,35 @@ export const fetchCage = async (objectId: string): Promise<CageData> => {
}
};

export const fetchGhostCage = async (objectId: string): Promise<GhostCageData> => {
const config: Query.SelectRowsOptions = {
schemaName: 'cageui',
queryName: 'ghost_cages',
filterArray: [Filter.create('cage_objectid', objectId, Filter.Types.EQUAL)]
};

try {
const res = await labkeyActionSelectWithPromise(config);
if (res.rows.length === 1) {
return {
rowid: res.rows[0].rowid,
cageObjId: res.rows[0].cage_objectid,
positionId: res.rows[0].positionid,
rackGroup: res.rows[0].rack_group,
rack: 0,
rackObjId: res.rows[0].rack_objectid,
groupRotation: res.rows[0].group_rotation,
cage: res.rows[0].cage,
};
} else {
throw new Error('Error fetching ghost cage data');
}
}
catch (e) {
throw new Error('Error fetching ghost cage data: ' + (e as Error).message);
}
};

export const fetchRack = async (objectId: string): Promise<RackData> => {
const config: Query.SelectRowsOptions = {
schemaName: 'cageui',
Expand Down
Loading
Loading