Added a search for Chromebook usage after a specific date. Removed references to the schema code which was not working. Ran into a deployment issue that requires I manually run sudo npm run install from the bundle/programs/server folder after deploying.
This commit is contained in:
@@ -2,7 +2,7 @@ import {Mongo} from "meteor/mongo";
|
||||
import {Meteor} from "meteor/meteor";
|
||||
import { check } from 'meteor/check';
|
||||
import { Roles } from 'meteor/alanning:roles';
|
||||
import SimpleSchema from "simpl-schema";
|
||||
//import SimpleSchema from "simpl-schema";
|
||||
import {AssetTypes} from "./asset-types";
|
||||
|
||||
export const AssetAssignments = new Mongo.Collection('assetAssignments');
|
||||
|
||||
@@ -2,7 +2,7 @@ import {Mongo} from "meteor/mongo";
|
||||
import {Meteor} from "meteor/meteor";
|
||||
import { check } from 'meteor/check';
|
||||
import { Roles } from 'meteor/alanning:roles';
|
||||
import SimpleSchema from "simpl-schema";
|
||||
//import SimpleSchema from "simpl-schema";
|
||||
|
||||
//
|
||||
// An asset type is a specific type of equipment. Example: Lenovo 100e Chromebook.
|
||||
|
||||
@@ -2,7 +2,7 @@ import {Mongo} from "meteor/mongo";
|
||||
import {Meteor} from "meteor/meteor";
|
||||
import { check } from 'meteor/check';
|
||||
import { Roles } from 'meteor/alanning:roles';
|
||||
import SimpleSchema from "simpl-schema";
|
||||
//import SimpleSchema from "simpl-schema";
|
||||
import {AssetTypes} from "./asset-types";
|
||||
|
||||
export const Assets = new Mongo.Collection('assets');
|
||||
|
||||
@@ -52,10 +52,15 @@ if (Meteor.isServer) {
|
||||
$regex: params.email,
|
||||
$options: "i"
|
||||
} : params.email;
|
||||
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}
|
||||
}
|
||||
|
||||
// console.log("Collecting Chromebook Data: ");
|
||||
// console.log(query);
|
||||
let result = Meteor.Records.find(query).fetch();
|
||||
console.log("Collecting Chromebook Data: ");
|
||||
console.log(query);
|
||||
|
||||
//Sort by the last time the record was updated from most to least recent.
|
||||
let result = Meteor.Records.find(query, {sort: {endTime: -1}}).fetch();
|
||||
// console.log("Found: ");
|
||||
// console.log(result);
|
||||
|
||||
|
||||
@@ -54,15 +54,30 @@
|
||||
import HelperText from '@smui/textfield/helper-text';
|
||||
import Icon from '@smui/textfield/icon';
|
||||
import { Icon as CommonIcon } from '@smui/common';
|
||||
import DateInput from "./DateInput.svelte";
|
||||
|
||||
let serialInput = null;
|
||||
let emailInput = null;
|
||||
let dateInput = null;
|
||||
|
||||
$: serialInput = null;
|
||||
$: emailInput = null;
|
||||
function serialSearch() {
|
||||
router.goto("/chromebooks?serial=" + encodeURIComponent(serialInput) + "®ex=true");
|
||||
}
|
||||
function emailSearch() {
|
||||
router.goto("/chromebooks?email=" + encodeURIComponent(emailInput) + "®ex=true");
|
||||
}
|
||||
function dateSearch() {
|
||||
console.log("Date Search")
|
||||
console.log(dateInput);
|
||||
|
||||
if(dateInput) {
|
||||
console.log(dateInput instanceof Date)
|
||||
//console.log(!isNaN(date.valueOf()));
|
||||
console.log(dateInput.getTime())
|
||||
}
|
||||
if(dateInput && dateInput instanceof Date)
|
||||
router.goto("/chromebooks?date=" + encodeURIComponent(dateInput.getTime()));
|
||||
}
|
||||
|
||||
// console.log("Loading Script");
|
||||
// //Attempt to listen for URL changes (query portion specifically).
|
||||
@@ -85,37 +100,44 @@
|
||||
// console.log("Params: ");
|
||||
// console.log(params);
|
||||
|
||||
$: deviceId = null;
|
||||
$: serial = null;
|
||||
$: email = null
|
||||
$: regex = false;
|
||||
let deviceId = null;
|
||||
let serial = null;
|
||||
let email = null;
|
||||
let date = null;
|
||||
let regex = false;
|
||||
$: router.subscribe(query => {
|
||||
deviceId = router.location.query.get("deviceId");
|
||||
serial = router.location.query.get("serial");
|
||||
email = router.location.query.get("email");
|
||||
regex = router.location.query.get("regex");
|
||||
date = router.location.query.get("date");
|
||||
|
||||
if(deviceId) deviceId = decodeURIComponent(deviceId);
|
||||
if(serial) serial = decodeURIComponent(serial);
|
||||
if(email) email = decodeURIComponent(email);
|
||||
if(date) date = decodeURIComponent(date);
|
||||
if(regex) regex = true;
|
||||
|
||||
// console.log("Query:");
|
||||
// console.log(deviceId);
|
||||
// console.log(serial);
|
||||
// console.log(email);
|
||||
// console.log(date);
|
||||
});
|
||||
$: chromebookData = null;
|
||||
let chromebookData = null;
|
||||
$: {
|
||||
if(deviceId || serial || email) {
|
||||
if(deviceId || serial || email || date) {
|
||||
let params = {};
|
||||
|
||||
if(deviceId) params.deviceId = deviceId;
|
||||
else if(serial) params.serial = serial;
|
||||
else if(email) params.email = email;
|
||||
else if(date) params.date = parseInt(date, 10);
|
||||
|
||||
if(regex) params.regex = true;
|
||||
if(!date && regex) params.regex = true;
|
||||
|
||||
console.log("Calling DataCollection.chromebookData")
|
||||
console.log(params);
|
||||
Meteor.call("DataCollection.chromebookData", params, (error, result) => {
|
||||
if (error) {
|
||||
console.error(error);
|
||||
@@ -174,6 +196,11 @@
|
||||
<input type="text" bind:value="{emailInput}" placeholder="Email"/>@avpanthers.org<br/>
|
||||
<button type="button" role="button" on:click={emailSearch}>Search</button>
|
||||
</li>
|
||||
<li>
|
||||
All records since: <br/>
|
||||
<DateInput bind:date={dateInput}/>
|
||||
<button type="button" role="button" on:click={dateSearch}>Search</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
16
imports/ui/DateInput.svelte
Normal file
16
imports/ui/DateInput.svelte
Normal file
@@ -0,0 +1,16 @@
|
||||
<script>
|
||||
import dayjs from 'dayjs'
|
||||
|
||||
export let format = 'YYYY-MM-DD'
|
||||
export let date = new Date()
|
||||
|
||||
let internal
|
||||
|
||||
const input = (x) => (internal = dayjs(x).format(format))
|
||||
const output = (x) => (date = dayjs(x, format).toDate())
|
||||
|
||||
$: input(date)
|
||||
$: output(internal)
|
||||
</script>
|
||||
|
||||
<input type="date" bind:value={internal} />
|
||||
Reference in New Issue
Block a user