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})) {
|
if(Roles.userIsInRole(Meteor.userId(), "laptop-management", {anyScope:true})) {
|
||||||
let query = {};
|
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 ? {
|
if (params.deviceId) query.deviceId = params.regex ? {
|
||||||
$regex: params.deviceId,
|
$regex: params.deviceId,
|
||||||
$options: "i"
|
$options: "i"
|
||||||
@@ -51,14 +61,14 @@ if (Meteor.isServer) {
|
|||||||
$regex: params.serial,
|
$regex: params.serial,
|
||||||
$options: "i"
|
$options: "i"
|
||||||
} : params.serial;
|
} : params.serial;
|
||||||
else if (params.assetId) {
|
// else if (params.assetId) {
|
||||||
let asset = Assets.findOne({assetId: params.assetId});
|
// let asset = Assets.findOne({assetId: params.assetId});
|
||||||
|
//
|
||||||
if(asset.serial) {
|
// if(asset.serial) {
|
||||||
// An exact search.
|
// // An exact search.
|
||||||
query.serial = asset.serial;
|
// query.serial = asset.serial;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
else if (params.email) query.email = params.regex ? {
|
else if (params.email) query.email = params.regex ? {
|
||||||
$regex: params.email,
|
$regex: params.email,
|
||||||
$options: "i"
|
$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.
|
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}
|
query.endTime = {'$gte': params.date}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
query = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(query) {
|
||||||
console.log("Collecting Chromebook Data: ");
|
console.log("Collecting Chromebook Data: ");
|
||||||
console.log(query);
|
console.log(query);
|
||||||
|
|
||||||
@@ -76,8 +90,9 @@ if (Meteor.isServer) {
|
|||||||
// console.log(result);
|
// console.log(result);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
} else return null;
|
||||||
}
|
}
|
||||||
else {return null;}
|
else return null;
|
||||||
}
|
}
|
||||||
// 'tasks.setChecked'(taskId, setChecked) {
|
// 'tasks.setChecked'(taskId, setChecked) {
|
||||||
// check(taskId, String);
|
// check(taskId, String);
|
||||||
|
|||||||
@@ -64,10 +64,10 @@
|
|||||||
<a href="/chromebooks">Chromebooks</a>
|
<a href="/chromebooks">Chromebooks</a>
|
||||||
{/if}
|
{/if}
|
||||||
{#if canManageLaptops}
|
{#if canManageLaptops}
|
||||||
<a href="/users">Users</a>
|
|
||||||
<a href="/assets">Assets</a>
|
<a href="/assets">Assets</a>
|
||||||
{/if}
|
{/if}
|
||||||
{#if isAdmin}
|
{#if isAdmin}
|
||||||
|
<a href="/users">Users</a>
|
||||||
<a href="/admin">Admin</a>
|
<a href="/admin">Admin</a>
|
||||||
{/if}
|
{/if}
|
||||||
</nav>
|
</nav>
|
||||||
@@ -82,7 +82,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</Route>
|
</Route>
|
||||||
<Route path="/assets">
|
<Route path="/assets">
|
||||||
{#if isAdmin}
|
{#if canManageLaptops}
|
||||||
<Assets/>
|
<Assets/>
|
||||||
{/if}
|
{/if}
|
||||||
</Route>
|
</Route>
|
||||||
|
|||||||
@@ -10,17 +10,28 @@
|
|||||||
import DateInput from "./DateInput.svelte";
|
import DateInput from "./DateInput.svelte";
|
||||||
import Button, { Label } from '@smui/button';
|
import Button, { Label } from '@smui/button';
|
||||||
import IconButton from '@smui/icon-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 serialInput = null;
|
||||||
let emailInput = null;
|
let emailInput = null;
|
||||||
let dateInput = null;
|
let dateInput = null;
|
||||||
let assetIdInput = null;
|
let assetIdInput = null;
|
||||||
|
|
||||||
|
onMount(async () => {
|
||||||
|
Meteor.subscribe('assets');
|
||||||
|
Meteor.subscribe('students');
|
||||||
|
Meteor.subscribe('staff');
|
||||||
|
Meteor.subscribe('assetTypes');
|
||||||
|
});
|
||||||
|
|
||||||
function serialSearch() {
|
function serialSearch() {
|
||||||
router.goto("/chromebooks?serial=" + encodeURIComponent(serialInput) + "®ex=true");
|
router.goto("/chromebooks?serial=" + encodeURIComponent(serialInput) + "®ex=true");
|
||||||
}
|
}
|
||||||
function assetIdSearch() {
|
function assetIdSearch() {
|
||||||
router.goto("/chromebooks?assetId=" + encodeURIComponent(assetIdInput) + "®ex=true");
|
router.goto("/chromebooks?assetId=" + encodeURIComponent(assetIdInput.toUpperCase()) + "®ex=false");
|
||||||
}
|
}
|
||||||
function emailSearch() {
|
function emailSearch() {
|
||||||
router.goto("/chromebooks?email=" + encodeURIComponent(emailInput) + "®ex=true");
|
router.goto("/chromebooks?email=" + encodeURIComponent(emailInput) + "®ex=true");
|
||||||
@@ -104,12 +115,31 @@
|
|||||||
|
|
||||||
if(!date && regex) params.regex = true;
|
if(!date && regex) params.regex = true;
|
||||||
|
|
||||||
console.log("Calling DataCollection.chromebookData")
|
// console.log("Calling DataCollection.chromebookData")
|
||||||
console.log(params);
|
// console.log(params);
|
||||||
Meteor.call("DataCollection.chromebookData", params, (error, result) => {
|
Meteor.call("DataCollection.chromebookData", params, (error, result) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
} else {
|
} 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;
|
chromebookData = result;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -126,10 +156,21 @@
|
|||||||
<div class="row col-12">
|
<div class="row col-12">
|
||||||
<ul>
|
<ul>
|
||||||
{#each chromebookData as data}
|
{#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?deviceId={encodeURIComponent(data.deviceId)}">{data.deviceId}</a><br/>
|
||||||
<a href="/chromebooks?serial={encodeURIComponent(data.serial)}">{data.serial}</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")}
|
{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>
|
</li>
|
||||||
{/each}
|
{/each}
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
Reference in New Issue
Block a user