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:
2022-06-21 18:36:45 -07:00
parent c2466a284b
commit 3c58f3f8da
12 changed files with 555 additions and 301 deletions

View File

@@ -18,8 +18,8 @@ ecmascript@0.16.2 # Enable ECMAScript2015+ syntax in app code
typescript@4.5.4 # Enable TypeScript syntax in .ts and .tsx modules typescript@4.5.4 # Enable TypeScript syntax in .ts and .tsx modules
shell-server@0.5.0 # Server-side component of the `meteor shell` command shell-server@0.5.0 # Server-side component of the `meteor shell` command
aldeed:collection2 # Attaches a schema to a collection #aldeed:collection2 # Attaches a schema to a collection
aldeed:schema-index # Allows the schema to specify fields to be indexed #aldeed:schema-index # Allows the schema to specify fields to be indexed
svelte:compiler svelte:compiler
#static-html@1.3.2 #static-html@1.3.2

View File

@@ -5,11 +5,6 @@ accounts-password@2.3.1
accounts-ui@1.4.2 accounts-ui@1.4.2
accounts-ui-unstyled@1.7.0 accounts-ui-unstyled@1.7.0
alanning:roles@3.4.0 alanning:roles@3.4.0
aldeed:collection2@2.10.0
aldeed:collection2-core@1.2.0
aldeed:schema-deny@1.1.0
aldeed:schema-index@1.1.1
aldeed:simple-schema@1.5.4
allow-deny@1.1.1 allow-deny@1.1.1
autoupdate@1.8.0 autoupdate@1.8.0
babel-compiler@7.9.0 babel-compiler@7.9.0
@@ -52,7 +47,6 @@ launch-screen@1.3.0
less@4.0.0 less@4.0.0
localstorage@1.2.0 localstorage@1.2.0
logging@1.3.1 logging@1.3.1
mdg:validation-error@0.2.0
meteor@1.10.0 meteor@1.10.0
meteor-base@1.5.1 meteor-base@1.5.1
meteortesting:browser-tests@1.3.5 meteortesting:browser-tests@1.3.5
@@ -78,7 +72,6 @@ oauth2@1.3.1
observe-sequence@1.0.20 observe-sequence@1.0.20
ordered-dict@1.1.0 ordered-dict@1.1.0
promise@0.12.0 promise@0.12.0
raix:eventemitter@0.1.3
random@1.2.0 random@1.2.0
rate-limit@1.0.9 rate-limit@1.0.9
rdb:svelte-meteor-data@1.0.0 rdb:svelte-meteor-data@1.0.0

View File

@@ -2,7 +2,7 @@ import {Mongo} from "meteor/mongo";
import {Meteor} from "meteor/meteor"; import {Meteor} from "meteor/meteor";
import { check } from 'meteor/check'; import { check } from 'meteor/check';
import { Roles } from 'meteor/alanning:roles'; import { Roles } from 'meteor/alanning:roles';
import SimpleSchema from "simpl-schema"; //import SimpleSchema from "simpl-schema";
import {AssetTypes} from "./asset-types"; import {AssetTypes} from "./asset-types";
export const AssetAssignments = new Mongo.Collection('assetAssignments'); export const AssetAssignments = new Mongo.Collection('assetAssignments');

View File

@@ -2,7 +2,7 @@ import {Mongo} from "meteor/mongo";
import {Meteor} from "meteor/meteor"; import {Meteor} from "meteor/meteor";
import { check } from 'meteor/check'; import { check } from 'meteor/check';
import { Roles } from 'meteor/alanning:roles'; 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. // An asset type is a specific type of equipment. Example: Lenovo 100e Chromebook.

View File

@@ -2,7 +2,7 @@ import {Mongo} from "meteor/mongo";
import {Meteor} from "meteor/meteor"; import {Meteor} from "meteor/meteor";
import { check } from 'meteor/check'; import { check } from 'meteor/check';
import { Roles } from 'meteor/alanning:roles'; import { Roles } from 'meteor/alanning:roles';
import SimpleSchema from "simpl-schema"; //import SimpleSchema from "simpl-schema";
import {AssetTypes} from "./asset-types"; import {AssetTypes} from "./asset-types";
export const Assets = new Mongo.Collection('assets'); export const Assets = new Mongo.Collection('assets');

View File

@@ -52,10 +52,15 @@ if (Meteor.isServer) {
$regex: params.email, $regex: params.email,
$options: "i" $options: "i"
} : params.email; } : 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("Collecting Chromebook Data: ");
// console.log(query); console.log(query);
let result = Meteor.Records.find(query).fetch();
//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("Found: ");
// console.log(result); // console.log(result);

View File

@@ -54,15 +54,30 @@
import HelperText from '@smui/textfield/helper-text'; import HelperText from '@smui/textfield/helper-text';
import Icon from '@smui/textfield/icon'; import Icon from '@smui/textfield/icon';
import { Icon as CommonIcon } from '@smui/common'; 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() { function serialSearch() {
router.goto("/chromebooks?serial=" + encodeURIComponent(serialInput) + "&regex=true"); router.goto("/chromebooks?serial=" + encodeURIComponent(serialInput) + "&regex=true");
} }
function emailSearch() { function emailSearch() {
router.goto("/chromebooks?email=" + encodeURIComponent(emailInput) + "&regex=true"); router.goto("/chromebooks?email=" + encodeURIComponent(emailInput) + "&regex=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"); // console.log("Loading Script");
// //Attempt to listen for URL changes (query portion specifically). // //Attempt to listen for URL changes (query portion specifically).
@@ -85,37 +100,44 @@
// console.log("Params: "); // console.log("Params: ");
// console.log(params); // console.log(params);
$: deviceId = null; let deviceId = null;
$: serial = null; let serial = null;
$: email = null let email = null;
$: regex = false; let date = null;
let regex = false;
$: router.subscribe(query => { $: router.subscribe(query => {
deviceId = router.location.query.get("deviceId"); deviceId = router.location.query.get("deviceId");
serial = router.location.query.get("serial"); serial = router.location.query.get("serial");
email = router.location.query.get("email"); email = router.location.query.get("email");
regex = router.location.query.get("regex"); regex = router.location.query.get("regex");
date = router.location.query.get("date");
if(deviceId) deviceId = decodeURIComponent(deviceId); if(deviceId) deviceId = decodeURIComponent(deviceId);
if(serial) serial = decodeURIComponent(serial); if(serial) serial = decodeURIComponent(serial);
if(email) email = decodeURIComponent(email); if(email) email = decodeURIComponent(email);
if(date) date = decodeURIComponent(date);
if(regex) regex = true; if(regex) regex = true;
// console.log("Query:"); // console.log("Query:");
// console.log(deviceId); // console.log(deviceId);
// console.log(serial); // console.log(serial);
// console.log(email); // console.log(email);
// console.log(date);
}); });
$: chromebookData = null; let chromebookData = null;
$: { $: {
if(deviceId || serial || email) { if(deviceId || serial || email || date) {
let params = {}; let params = {};
if(deviceId) params.deviceId = deviceId; if(deviceId) params.deviceId = deviceId;
else if(serial) params.serial = serial; else if(serial) params.serial = serial;
else if(email) params.email = email; 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) => { Meteor.call("DataCollection.chromebookData", params, (error, result) => {
if (error) { if (error) {
console.error(error); console.error(error);
@@ -174,6 +196,11 @@
<input type="text" bind:value="{emailInput}" placeholder="Email"/>@avpanthers.org<br/> <input type="text" bind:value="{emailInput}" placeholder="Email"/>@avpanthers.org<br/>
<button type="button" role="button" on:click={emailSearch}>Search</button> <button type="button" role="button" on:click={emailSearch}>Search</button>
</li> </li>
<li>
All records since: <br/>
<DateInput bind:date={dateInput}/>
<button type="button" role="button" on:click={dateSearch}>Search</button>
</li>
</ul> </ul>
</div> </div>
</div> </div>

View 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} />

731
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -14,12 +14,12 @@
"dependencies": { "dependencies": {
"@babel/runtime": "^7.16.7", "@babel/runtime": "^7.16.7",
"connect-route": "^0.1.5", "connect-route": "^0.1.5",
"dayjs": "^1.11.3",
"html5-qrcode": "^2.2.0", "html5-qrcode": "^2.2.0",
"jquery": "^3.6.0", "jquery": "^3.6.0",
"meteor-node-stubs": "^1.0.0", "meteor-node-stubs": "^1.0.0",
"moment": "^2.29.2", "moment": "^2.29.2",
"mongodb": "^4.4.1", "mongodb": "^4.4.1",
"simpl-schema": "^1.12.2",
"svelte": "^3.46.4", "svelte": "^3.46.4",
"svelte-material-ui": "^6.0.0-beta.16", "svelte-material-ui": "^6.0.0-beta.16",
"tinro": "^0.6.12", "tinro": "^0.6.12",

View File

@@ -0,0 +1,32 @@
if(!process.env.MONGO_URL) {
console.log("Must provide the MONGO_URL environment variable point to the district central's main database. Should be of the format: `mongodb://localhost:27017/DatabaseName` or `mongodb://user_name:password@host.domain.com,host2.domain.com,host3.domain.com/DatabaseName?replicaSet=set_name`.")
process.exit(0);
}
if(!process.env.MONGO_URL2) {
console.log("Must provide the MONGO_URL2 environment variable pointing to the chromebook data collection dataset. Should be of the format: `mongodb://localhost:27017/DatabaseName` or `mongodb://user_name:password@host.domain.com,host2.domain.com,host3.domain.com/DatabaseName?replicaSet=set_name`.")
process.exit(0);
}
try {
let settings = Assets.getText('settings.json');
}
catch(e) {
console.log("Must have a /private/settings.json file with the following format:");
console.log(`
{
"google": {
"clientId": "xxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com",
"secret": "xxxxxxxxxxxxxxxxxxx",
"loginStyle": "redirect",
"scope": [
"email",
"https://www.googleapis.com/auth/plus.login",
"https://www.googleapis.com/auth/contacts.readonly"
]
}
}
`);
process.exit(0);
}

View File

@@ -1,4 +1,4 @@
import './CheckEnvironment.js';
import './DataCollection.js'; import './DataCollection.js';
import '../imports/api/'; import '../imports/api/';
import './google-oauth.js'; import './google-oauth.js';