Skip to content

Commit

Permalink
working on code.js
Browse files Browse the repository at this point in the history
  • Loading branch information
myxxmikeyxx committed Jun 24, 2021
1 parent 7555359 commit a33c637
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 23 deletions.
54 changes: 31 additions & 23 deletions Code.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
// See restrictions at http://www.opensource.org/licenses/gpl-3.0.html


var headers = ['etag', 'Org Unit Path', 'Serial Number', 'Platform Version', 'Device Id', 'Status', 'Last Enrollment Time',
'Firmware Version', 'Last Sync', 'OS Version', 'Boot Mode', 'Annotated Location', 'Notes', 'Annotated User', 'Mac Address', ''];
// var headers = ['etag', 'Annotated Asset ID', 'Manufacture Date', 'Org Unit Path', 'Serial Number', 'Platform Version', 'Device Id','Status', 'Last Enrollment Time', 'Firmware Version', 'Last Sync', 'OS Version', 'Boot Mode', 'Annotated Location', 'Notes', 'Annotated User', 'Mac Address', ''];

var headers = ['Org Unit Path', 'Annotated User', 'Annotated Location', 'Annotated Asset ID', 'Notes', 'Mac Address', 'Ethernet Mac Address', 'etag', 'Platform Version', 'Device ID', 'Serial Number', 'Status', 'Last Enrollment', 'Recent Users', 'Active Time', 'Model Firmware Version', 'Last Sync', 'OS Version', 'Boot Mode', 'Support End Date'];

function myFunction() {

Expand Down Expand Up @@ -50,8 +51,8 @@ function menuItem4() {
// .alert('You clicked the second menu item!');
// moveColumns();
testingListChomeDevices();
setHeader();
filterSheet();
// setHeader();
// filterSheet();
}

function menuItem5() {
Expand Down Expand Up @@ -211,36 +212,43 @@ function testingListChomeDevices() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var allDevices = [];
var deviceKey = [];
var deviceValue = [];
var maxRow = sheet.getMaxRows();
var maxColumn = sheet.getMaxColumns();
sheet.clearContents();
if (maxRow > 2) {
clearSheet();
}
SpreadsheetApp.flush();
var response = AdminDirectory.Chromeosdevices.list('my_customer', { maxResults: 100, projection: "FULL" });
allDevices = allDevices.concat(response.chromeosdevices);
// Logger.log("Response: " + response);
// response.chromeosdevices.forEach(element => Browser.msgBox(element));
// allDevices.forEach(element => Browser.msgBox(element));
// https://www.freecodecamp.org/news/javascript-foreach-how-to-loop-through-an-array-in-js/
// allDevices.forEach(function () {
// // code

// });
// allDevices.forEach(element => {
// Browser.msgBox(element.count);
// });


// https://zetcode.com/javascript/jsonforeach/
// allDevices.forEach(obj => {
// Object.entries(obj).forEach(([key, value]) => {
// deviceKey.push(key)
// deviceValue.push(value)
// console.log(`${key} ${value}`);
// });
// console.log('-------------------');
// });

sheet.getRange(1, 1, 1, headers.length).setValues([headers]);
sheet.autoResizeColumn(headers.length);
SpreadsheetApp.flush();

var response = AdminDirectory.Chromeosdevices.list('my_customer', { maxResults: 1, projection: "FULL" });
Logger.log("Response: " + response);
Logger.log("Response Chrome Devices: " + response.chromeosdevices);
// allDevices = allDevices.concat(response.chromeosdevices);
allDevices.push(...response.chromeosdevices.pop());
setRowsData(sheet, allDevices);
// while (response.nextPageToken) {
// response = AdminDirectory.Chromeosdevices.list('my_customer', { maxResults: 100, projection: "FULL", pageToken: response.nextPageToken });
// // allDevices = allDevices.concat(response.chromeosdevices);
// allDevices.push(...response.chromeosdevices);
// }

if (allDevices.length > 0) {
if (allDevices.length > maxRow) {
sheet.insertRows(maxRow, (allDevices.length - maxRow));
}
setRowsData(sheet, allDevices);
}
SpreadsheetApp.flush();
} catch (err) {
Browser.msgBox("Error: " + err.message);
Expand Down
61 changes: 61 additions & 0 deletions testing2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"serialNumber":"F0TK393",
"osVersion":"85.0.4183.84",
"annotatedUser":"gadmin4th@greensburg.k12.in.us",
"macAddress":"dc41a992ba26",
"status":"ACTIVE",
"firmwareVersion":"Google_Fleex.11297.141.0",
"lastSync":"2021-01-25T19:15:56.586Z",
"lastEnrollmentTime":"2021-01-25T18:05:14.392Z",
"manufactureDate":"2020-12-11",
"etag":"\"ajuIDY2MlKKzrdUn942df2OCBNkpUIbNakI8lMkbmjA/FRfJivzNeYMenB01rPOqQADu5vA\"",
"autoUpdateExpiration":"1780297200000",
"orgUnitPath":"/Elementary Students/ElementaryChrome/4thGradeChrome",
"bootMode":"Verified",
"systemRamFreeReports":[
{"reportTime":"2021-01-25T18:05:27.296Z",
"systemRamFreeInfo":["2581913600"]}
],
"systemRamTotal":"3990949888",
"diskVolumeReports":[
{"volumeInfo":[
{"storageFree":"1995472896",
"storageTotal":"1995472896",
"volumeId":"/media/archive"},
{"storageFree":"11681792",
"storageTotal":"12042240",
"volumeId":"/usr/share/oem"},
{"storageFree":"1995472896",
"storageTotal":"1995472896",
"volumeId":"/media/removable"}
]}],
"kind":"admin#directory#chromeosdevice",
"cpuStatusReports":[
{"reportTime":"2021-01-25T18:05:27.296Z",
"cpuUtilizationPercentageInfo":[24]},
{"reportTime":"2021-01-25T18:06:27.267Z",
"cpuTemperatureInfo":[
{"label":"Core 1",
"temperature":37},
{"temperature":37,
"label":"Package id 0"},
{"temperature":37,
"label":"Core 0"},
{"label":"iwlwifi_1",
"temperature":29}
]}],
"deviceId":"bf9b0a6d-be3e-4710-a921-98c24558c20e",
"model":"Dell Chromebook 3100",
"activeTimeRanges":[
{"date":"2021-01-25",
"activeTime":60000}
],
"platformVersion":"13310.59.0 (Official Build) stable-channel octopus",
"tpmVersionInfo":{
"specLevel":"74",
"tpmModel":"1",
"manufacturer":"43524f53",
"vendorSpecific":"784347206654504D",
"firmwareVersion":"7921eab30ee34b3e",
"family":"322e3000"}
}
35 changes: 35 additions & 0 deletions testing3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
manufactureDate=2020-12-11,
diskVolumeReports=[
Ljava.lang.Object;@1db584d9,
macAddress=dc41a992ba26,
tpmVersionInfo={
manufacturer=43524f53,
specLevel=74,
tpmModel=1,
family=322e3000,
firmwareVersion=7921eab30ee34b3e,
vendorSpecific=784347206654504D},
autoUpdateExpiration=1780297200000,
lastSync=2021-01-25T19:15:56.586Z,
etag="ajuIDY2MlKKzrdUn942df2OCBNkpUIbNakI8lMkbmjA/FRfJivzNeYMenB01rPOqQADu5vA",
cpuStatusReports=[
Ljava.lang.Object;@53e00a99,
platformVersion=13310.59.0 (Official Build) stable-channel octopus,
systemRamFreeReports=[
Ljava.lang.Object;@336abaf2,
osVersion=85.0.4183.84,
status=ACTIVE,
orgUnitPath=/Elementary Students/ElementaryChrome/4thGradeChrome,
activeTimeRanges=[
Ljava.lang.Object;@64ce4361,
model=Dell Chromebook 3100,
deviceId=bf9b0a6d-be3e-4710-a921-98c24558c20e,
kind=admin#directory#chromeosdevice,
annotatedUser=gadmin4th@greensburg.k12.in.us,
systemRamTotal=3990949888,
serialNumber=F0TK393,
lastEnrollmentTime=2021-01-25T18:05:14.392Z,
firmwareVersion=Google_Fleex.11297.141.0,
bootMode=Verified
}

0 comments on commit a33c637

Please sign in to comment.