Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MYG-53314 - Adding VIN to CSV for import #300

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions src/software/js-samples/importDevices.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!DOCTYPE html>
<html lang="en">

<head>
Expand Down Expand Up @@ -39,7 +39,7 @@ <h3>Import devices</h3>
on its own line as follows:
</p>
<div class="code">
<pre>SerialNumber,Name1,GroupName<br />SerialNumber,Name2,GroupName<br />SerialNumber,Name3,GroupName</pre>
<pre>SerialNumber,Name1,GroupName,VIN<br />SerialNumber,Name2,GroupName,VIN<br />SerialNumber,Name3,GroupName,VIN</pre>
</div>
<p>
<input id="createGroups" type="checkbox" checked="checked" /> <label for="createGroups">Automatically create new groups if needed</label>
Expand Down Expand Up @@ -109,8 +109,8 @@ <h2>Help</h2>
// Split up the device properties
var split = devices[i].split(",");

// Each imported device can only have 3 properties
if (split.length !== 3) {
// Each imported device can only have 4 properties
if (split.length !== 4) {
alert("There is an error on line " + (i + 1) + ": " + devices[i]);
return;
}
Expand All @@ -124,7 +124,10 @@ <h2>Help</h2>
alert("Group name on line " + (i + 1) + " exceeds 255 characters");
return;
}

if (split[3].length > 255) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dab09 I think that this might still be a split[2] for checking the length of the GroupName, with the split[3] it's evaluating the VIN.

alert("Group name on line " + (i + 1) + " exceeds 255 characters");
return;
}
// If create groups is enabled, queue up the new groups to be created
if (!groupCache.hasOwnProperty(split[2])) {
if (createGroups) {
Expand Down Expand Up @@ -176,16 +179,17 @@ <h2>Help</h2>

});

function addDevice(serialNumber, name, groupId) {
function addDevice(serialNumber, name, groupId, vin) {
api.call("Add", {
typeName: "Device",
entity: {
serialNumber: serialNumber,
name: name,
groups: [{
id: groupId
}]
}
}],
vin: vin
}
}, function (result) {
console.log("Successfully imported " + name + " (" + result + ")");
}, function (error) {
Expand Down