Added information to the chromebook data.
This commit is contained in:
@@ -43,6 +43,16 @@ if (Meteor.isServer) {
|
||||
if(Roles.userIsInRole(Meteor.userId(), "laptop-management", {anyScope:true})) {
|
||||
let query = {};
|
||||
|
||||
// For asset ID's, we need to get the serial from the asset collection first.
|
||||
if(params.assetId) {
|
||||
let asset = Assets.findOne({assetId : params.assetId});
|
||||
|
||||
if(asset) {
|
||||
params.serial = asset.serial;
|
||||
params.regex = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (params.deviceId) query.deviceId = params.regex ? {
|
||||
$regex: params.deviceId,
|
||||
$options: "i"
|
||||
@@ -51,14 +61,14 @@ if (Meteor.isServer) {
|
||||
$regex: params.serial,
|
||||
$options: "i"
|
||||
} : params.serial;
|
||||
else if (params.assetId) {
|
||||
let asset = Assets.findOne({assetId: params.assetId});
|
||||
|
||||
if(asset.serial) {
|
||||
// An exact search.
|
||||
query.serial = asset.serial;
|
||||
}
|
||||
}
|
||||
// else if (params.assetId) {
|
||||
// let asset = Assets.findOne({assetId: params.assetId});
|
||||
//
|
||||
// if(asset.serial) {
|
||||
// // An exact search.
|
||||
// query.serial = asset.serial;
|
||||
// }
|
||||
// }
|
||||
else if (params.email) query.email = params.regex ? {
|
||||
$regex: params.email,
|
||||
$options: "i"
|
||||
@@ -66,7 +76,11 @@ if (Meteor.isServer) {
|
||||
else if (params.date) { //Assume that date is a number. Finds all Chromebook Data with the last check in time greater than or equal to the given date.
|
||||
query.endTime = {'$gte': params.date}
|
||||
}
|
||||
else {
|
||||
query = undefined;
|
||||
}
|
||||
|
||||
if(query) {
|
||||
console.log("Collecting Chromebook Data: ");
|
||||
console.log(query);
|
||||
|
||||
@@ -76,8 +90,9 @@ if (Meteor.isServer) {
|
||||
// console.log(result);
|
||||
|
||||
return result;
|
||||
} else return null;
|
||||
}
|
||||
else {return null;}
|
||||
else return null;
|
||||
}
|
||||
// 'tasks.setChecked'(taskId, setChecked) {
|
||||
// check(taskId, String);
|
||||
|
||||
@@ -64,10 +64,10 @@
|
||||
<a href="/chromebooks">Chromebooks</a>
|
||||
{/if}
|
||||
{#if canManageLaptops}
|
||||
<a href="/users">Users</a>
|
||||
<a href="/assets">Assets</a>
|
||||
{/if}
|
||||
{#if isAdmin}
|
||||
<a href="/users">Users</a>
|
||||
<a href="/admin">Admin</a>
|
||||
{/if}
|
||||
</nav>
|
||||
@@ -82,7 +82,7 @@
|
||||
</div>
|
||||
</Route>
|
||||
<Route path="/assets">
|
||||
{#if isAdmin}
|
||||
{#if canManageLaptops}
|
||||
<Assets/>
|
||||
{/if}
|
||||
</Route>
|
||||
|
||||
@@ -10,17 +10,28 @@
|
||||
import DateInput from "./DateInput.svelte";
|
||||
import Button, { Label } from '@smui/button';
|
||||
import IconButton from '@smui/icon-button';
|
||||
import {onMount} from "svelte";
|
||||
import {Students} from "/imports/api/students";
|
||||
import {Staff} from "/imports/api/staff";
|
||||
import {AssetTypes} from "/imports/api/asset-types";
|
||||
|
||||
let serialInput = null;
|
||||
let emailInput = null;
|
||||
let dateInput = null;
|
||||
let assetIdInput = null;
|
||||
|
||||
onMount(async () => {
|
||||
Meteor.subscribe('assets');
|
||||
Meteor.subscribe('students');
|
||||
Meteor.subscribe('staff');
|
||||
Meteor.subscribe('assetTypes');
|
||||
});
|
||||
|
||||
function serialSearch() {
|
||||
router.goto("/chromebooks?serial=" + encodeURIComponent(serialInput) + "®ex=true");
|
||||
}
|
||||
function assetIdSearch() {
|
||||
router.goto("/chromebooks?assetId=" + encodeURIComponent(assetIdInput) + "®ex=true");
|
||||
router.goto("/chromebooks?assetId=" + encodeURIComponent(assetIdInput.toUpperCase()) + "®ex=false");
|
||||
}
|
||||
function emailSearch() {
|
||||
router.goto("/chromebooks?email=" + encodeURIComponent(emailInput) + "®ex=true");
|
||||
@@ -104,12 +115,31 @@
|
||||
|
||||
if(!date && regex) params.regex = true;
|
||||
|
||||
console.log("Calling DataCollection.chromebookData")
|
||||
console.log(params);
|
||||
// console.log("Calling DataCollection.chromebookData")
|
||||
// console.log(params);
|
||||
Meteor.call("DataCollection.chromebookData", params, (error, result) => {
|
||||
if (error) {
|
||||
console.error(error);
|
||||
} else {
|
||||
for(let next of result) {
|
||||
if(next.assetId) {
|
||||
next.asset = Assets.findOne({assetId: next.assetId});
|
||||
}
|
||||
if(next.email) {
|
||||
next.person = Students.findOne({email: next.email});
|
||||
|
||||
if(!next.person) next.person = Staff.findOne({email: next.email});
|
||||
}
|
||||
|
||||
if(next.asset) {
|
||||
next.assetType = AssetTypes.findOne({_id: next.asset.assetType})
|
||||
|
||||
if(next.asset.assigneeId) {
|
||||
next.assignedTo = next.asset.assigneeType === "Student" ? Students.findOne({_id: next.asset.assigneeId}) : Staff.findOne({_id: next.asset.assigneeId})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
chromebookData = result;
|
||||
}
|
||||
});
|
||||
@@ -126,10 +156,21 @@
|
||||
<div class="row col-12">
|
||||
<ul>
|
||||
{#each chromebookData as data}
|
||||
<li><a href="/chromebooks?email={encodeURIComponent(data.email)}">{data.email}</a><br/>
|
||||
<li>
|
||||
{#if data.person}
|
||||
{data.person.firstName} {data.person.lastName} (<a href="/chromebooks?email={encodeURIComponent(data.email)}">{data.email}</a>)<br/>
|
||||
{:else}
|
||||
<a href="/chromebooks?email={encodeURIComponent(data.email)}">{data.email}</a><br/>
|
||||
{/if}
|
||||
<a href="/chromebooks?deviceId={encodeURIComponent(data.deviceId)}">{data.deviceId}</a><br/>
|
||||
<a href="/chromebooks?serial={encodeURIComponent(data.serial)}">{data.serial}</a><br/>
|
||||
{new Date(data.startTime).toLocaleDateString("en-US") + "-" + new Date(data.endTime).toLocaleDateString("en-US")}
|
||||
{#if data.assetType}
|
||||
<br/>Asset Type: {data.assetType.name}
|
||||
{/if}
|
||||
{#if data.assignedTo}
|
||||
<br/>Currently assigned to: {next.assignedTo.firstName} {next.assignedTo.lastName} ({next.assignedTo.email})
|
||||
{/if}
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
|
||||
Reference in New Issue
Block a user