Initial cut - untested.

This commit is contained in:
2025-09-25 09:31:02 -07:00
parent 7a0666cc6c
commit 3775522265
33 changed files with 351 additions and 346 deletions

View File

@@ -59,17 +59,17 @@ const AssignmentsByAsset = () => {
const [assetIdInput, setAssetIdInput] = useState(undefined)
const {foundAsset} = useTracker(() => {
const {foundAsset} = useTracker(async () => {
let foundAsset = null;
if(assetId) {
foundAsset = Assets.findOne({assetId: assetId});
foundAsset = await Assets.findOneAsync({assetId: assetId});
if(foundAsset) {
foundAsset.assetType = AssetTypes.findOne({_id: foundAsset.assetTypeId})
foundAsset.assetType = await AssetTypes.findOneAsync({_id: foundAsset.assetTypeId})
if(foundAsset.assigneeId)
foundAsset.assignee = foundAsset.assigneeType === "Student" ? Students.findOne({_id: foundAsset.assigneeId}) : Staff.findOne({_id: foundAsset.assigneeId})
foundAsset.assignee = foundAsset.assigneeType === "Student" ? await Students.findOneAsync({_id: foundAsset.assigneeId}) : await Staff.findOneAsync({_id: foundAsset.assigneeId})
}
}
@@ -99,7 +99,7 @@ const AssignmentsByAsset = () => {
const [assignmentData, setAssignmentData] = useState([])
// Collect the usage and assignment data when the selected person changes.
useEffect(() => {
useEffect(async () => {
try {
if(foundAsset) {
let query = {assetId: foundAsset.assetId}
@@ -107,11 +107,11 @@ const AssignmentsByAsset = () => {
console.log("Requesting asset historical data")
console.log(query)
Meteor.call('DataCollection.chromebookData', query, (err, result) => {
await Meteor.callAsync('DataCollection.chromebookData', query, (err, result) => {
if (err) console.error(err)
else setUsageData(result)
})
Meteor.call('AssetAssignmentHistory.get', query, (err, result) => {
await Meteor.callAsync('AssetAssignmentHistory.get', query, (err, result) => {
if (err) console.error(err)
else setAssignmentData(result)
})
@@ -149,19 +149,19 @@ const AssignmentsByAsset = () => {
setUnassignConditionDetails(foundAsset.conditionDetails || "")
setOpenUnassignDialog(true);
}
const unassignDialogClosed = (unassign) => {
const unassignDialogClosed = async (unassign) => {
setOpenUnassignDialog(false)
if(unassign === true) {
if(unassignDialogEditConditionOnly) {
Meteor.call('assets.updateCondition', foundAsset._id, unassignCondition, unassignConditionDetails, (err, result) => {
await Meteor.callAsync('assets.updateCondition', foundAsset._id, unassignCondition, unassignConditionDetails, (err, result) => {
if(err) console.error(err)
else if(assetIdInput) assetIdInput.focus()
})
}
else {
// Call assets.unassign(assetId, comment, condition, conditionDetails, date)
Meteor.call('assets.unassign', foundAsset.assetId, unassignComment, unassignCondition, unassignConditionDetails, (err, result) => {
await Meteor.callAsync('assets.unassign', foundAsset.assetId, unassignComment, unassignCondition, unassignConditionDetails, (err, result) => {
if (err) console.error(err)
else if (assetIdInput) assetIdInput.focus()
})

View File

@@ -62,7 +62,7 @@ const AssignmentsByPerson = () => {
const [searchInput, setSearchInput] = useState(undefined)
const {people} = useTracker(() => {
const {people} = useTracker(async () => {
let people = [];
if(search && search.length > 1) {
@@ -80,8 +80,8 @@ const AssignmentsByPerson = () => {
// Look for students/staff that are active or whose active flag is not set.
if(!includeInactive) query = {$and: [query, {$or: [{active: true}, {active: {$exists: false}}]}]}
const students = Students.find(query).fetch();
const staff = Staff.find(query).fetch();
const students = await Students.find(query).fetchAsync();
const staff = await Staff.find(query).fetchAsync();
for(let next of students) next.type = "Student"
for(let next of staff) next.type = "Staff"
@@ -92,11 +92,11 @@ const AssignmentsByPerson = () => {
return {people}
}, [search]);
const {assets} = useTracker(() => {
const {assets} = useTracker(async () => {
let assets = [];
if(selectedPerson) {
assets = Assets.find({assigneeId: selectedPerson._id}).fetch();
assets = await Assets.find({assigneeId: selectedPerson._id}).fetchAsync();
for(let next of assets) {
next.assetType = AssetTypes.findOne({_id: next.assetTypeId})
@@ -106,17 +106,17 @@ const AssignmentsByPerson = () => {
return {assets}
}, [selectedPerson]);
const {foundAsset} = useTracker(() => {
const {foundAsset} = useTracker(async () => {
let foundAsset = null;
if(assetId) {
foundAsset = Assets.findOne({assetId: assetId});
foundAsset = await Assets.findOneAsync({assetId: assetId});
if(foundAsset) {
foundAsset.assetType = AssetTypes.findOne({_id: foundAsset.assetTypeId})
foundAsset.assetType = await AssetTypes.findOneAsync({_id: foundAsset.assetTypeId})
if(foundAsset.assigneeId)
foundAsset.assignee = foundAsset.assigneeType === "Student" ? Students.findOne({_id: foundAsset.assigneeId}) : Staff.findOne({_id: foundAsset.assigneeId})
foundAsset.assignee = foundAsset.assigneeType === "Student" ? await Students.findOneAsync({_id: foundAsset.assigneeId}) : await Staff.findOneAsync({_id: foundAsset.assigneeId})
}
}
@@ -127,7 +127,7 @@ const AssignmentsByPerson = () => {
const [assignmentData, setAssignmentData] = useState([])
// Collect the usage and assignment data when the selected person changes.
useEffect(() => {
useEffect(async () => {
try {
if(selectedPerson) {
let query = selectedPerson.type === "Student" ? {studentId: selectedPerson._id} : {staffId: selectedPerson._id}
@@ -135,11 +135,11 @@ const AssignmentsByPerson = () => {
console.log("Collecting person history")
console.log(query)
Meteor.call('DataCollection.chromebookData', query, (err, result) => {
await Meteor.callAsync('DataCollection.chromebookData', query, (err, result) => {
if (err) console.error(err)
else setUsageData(result)
})
Meteor.call('AssetAssignmentHistory.get', query, (err, result) => {
await Meteor.callAsync('AssetAssignmentHistory.get', query, (err, result) => {
if (err) console.error(err)
else setAssignmentData(result)
})
@@ -161,12 +161,12 @@ const AssignmentsByPerson = () => {
setOpenAssignDialog(true)
}
}
const assignDialogClosed = (assign) => {
const assignDialogClosed = async (assign) => {
setOpenAssignDialog(false)
if(assign === true) {
// Call assets.assign
Meteor.call('assets.assign', foundAsset.assetId, selectedPerson.type, selectedPerson._id, assignCondition, assignConditionDetails, (err, result) => {
await Meteor.callAsync('assets.assign', foundAsset.assetId, selectedPerson.type, selectedPerson._id, assignCondition, assignConditionDetails, (err, result) => {
if(err) console.error(err)
else {
// Clear the asset id field and set focus to it.
@@ -193,19 +193,19 @@ const AssignmentsByPerson = () => {
setUnassignConditionDetails(asset.conditionDetails || "")
setOpenUnassignDialog(true);
}
const unassignDialogClosed = (unassign) => {
const unassignDialogClosed = async (unassign) => {
setOpenUnassignDialog(false)
if(unassign === true) {
if(unassignDialogEditConditionOnly) {
Meteor.call('assets.updateCondition', unassignAsset._id, unassignCondition, unassignConditionDetails, (err, result) => {
await Meteor.callAsync('assets.updateCondition', unassignAsset._id, unassignCondition, unassignConditionDetails, (err, result) => {
if(err) console.error(err)
else if(assetIdInput) assetIdInput.focus()
})
}
else {
// Call assets.unassign(assetId, comment, condition, conditionDetails, date)
Meteor.call('assets.unassign', unassignAsset.assetId, unassignComment, unassignCondition, unassignConditionDetails, (err, result) => {
await Meteor.callAsync('assets.unassign', unassignAsset.assetId, unassignComment, unassignCondition, unassignConditionDetails, (err, result) => {
if(err) console.error(err)
else if(assetIdInput) assetIdInput.focus()
})
@@ -322,7 +322,7 @@ const AssignmentsByPerson = () => {
})}
</TextField>
</div>
<TextField style={{marginTop: '1rem',minWidth: '30rem'}} multiline rows={4} variant="outlined" label="Condition Details" value={assignConditionDetails} onChange={(e) => {setAssignConditionDetails(e.target.value)}}/>
<TextField style={{marginTop: '1rem',minWidth: '30rem'}} multiline rows={4} variant="outlined" label="Condition Details" value={assignConditionDetails} onChange={(e,v) => {setAssignConditionDetails(v)}}/>
</DialogContent>
<DialogActions>
<Button onClick={() => assignDialogClosed(true)}>Assign</Button>

View File

@@ -16,10 +16,10 @@ import Button from "@mui/material/Button";
const AssignmentsReport = () => {
const theme = useTheme();
const {people} = useTracker(() => {
let assets = Assets.find({assigneeId: {$exists: true}, assigneeType: "Student"}).fetch()
let assetTypes = AssetTypes.find().fetch()
let students = Students.find().fetch()
const {people} = useTracker(async () => {
let assets = await Assets.find({assigneeId: {$exists: true}, assigneeType: "Student"}).fetchAsync()
let assetTypes = await AssetTypes.find().fetchAsync()
let students = await Students.find().fetchAsync()
let people = []
let assetTypesById = assetTypes.reduce((map, obj) => {map[obj._id] = obj; return map}, {})