diff --git a/JuicyDataUploader-1.0.0.tgz b/JuicyDataUploader-1.0.0.tgz new file mode 100644 index 0000000..6a85dee Binary files /dev/null and b/JuicyDataUploader-1.0.0.tgz differ diff --git a/css/styles.css b/css/styles.css index 29ce4f6..44b6b2d 100644 --- a/css/styles.css +++ b/css/styles.css @@ -33,7 +33,7 @@ h3 { .card { box-shadow: 0 2px 5px 0 rgba(0,0,0,.16), 0 2px 10px 0 rgba(0,0,0,.12); border-width: 0; - border-radius: 0; + border-radius: 8px; margin-top: 20px; padding: 10px; } diff --git a/index.html b/index.html index e199031..3f43d3c 100644 --- a/index.html +++ b/index.html @@ -12,27 +12,22 @@
-

ID

+
+

1

+
- +

Select the match ID

-

1

+

2

-

Upload schedule after it has been generated

@@ -41,13 +36,9 @@

Upload schedule after it has been generated

-

2

+

3

-

Sync matches after each match

@@ -57,29 +48,5 @@

Sync matches after each match

- + diff --git a/js/functions.js b/js/functions.js index ace11bd..451e497 100644 --- a/js/functions.js +++ b/js/functions.js @@ -6,27 +6,46 @@ var axios = require('axios'); // let folderPath; let ip = '159.89.154.135'; -document.addEventListener( - 'DOMContentLoaded', - function() { - axios - .get('http://localhost/apiv1/events/') - .then(function(response) { - console.log(response); - let eventIDList = response.data.eventCodes; - var x = document.getElementById('eventID'); - for (let i = 0; i < eventIDList.length; i++) { - var option = document.createElement('option'); - option.text = eventIDList[i]; - x.add(option); - } - }) - .catch(function(error) { - alert(error); - }); - }, - false -); +document.addEventListener('DOMContentLoaded', refresh(), false); + +function refresh() { + var x = document.getElementById('eventID'); + for (let i = 1; x.length > 1; i++) { + x.remove(1); + } + console.log(x) + checkEventID(); + axios + .get('http://localhost/apiv1/events/') + .then(function(response) { + console.log(response); + let eventIDList = response.data.eventCodes; + var x = document.getElementById('eventID'); + for (let i = 0; i < eventIDList.length; i++) { + var option = document.createElement('option'); + option.text = eventIDList[i]; + x.add(option); + } + }) + .catch(function(error) { + alert(error); + }); +} + +function checkEventID() { + let eventID = document.getElementById('eventID').value; + if (eventID != '') { + document.getElementById('uploadScheduleButton').disabled = false; + document.getElementById('syncButton').disabled = false; + document.getElementById('uploadScheduleButton').classList.replace('btn-secondary', 'btn-primary'); + document.getElementById('syncButton').classList.replace('btn-secondary', 'btn-success'); + } else { + document.getElementById('uploadScheduleButton').disabled = true; + document.getElementById('syncButton').disabled = true; + document.getElementById('uploadScheduleButton').classList.replace('btn-primary', 'btn-secondary'); + document.getElementById('syncButton').classList.replace('btn-success', 'btn-secondary'); + } +} document.getElementById('uploadScheduleButton').onclick = () => { let eventID = document.getElementById('eventID').value; @@ -68,6 +87,7 @@ document.getElementById('uploadScheduleButton').onclick = () => { .post('http://' + ip + '/api/events/ftc/event/uploadSchedule', schedule) .then(function(response) { console.log(response); + alert('Upload Successful'); }) .catch(function(error) { alert(error); @@ -80,164 +100,156 @@ document.getElementById('uploadScheduleButton').onclick = () => { document.getElementById('syncButton').onclick = () => { let eventID = document.getElementById('eventID').value; - axios - .get('http://localhost/apiv1/events/' + eventID + '/matches/') - .then(function(response) { - console.log(response) - scoringSystemSchedule = response.data.matches; - tempSchedule = []; - for (let i = 0; i < scoringSystemSchedule.length; i++) { - if (scoringSystemSchedule[i].finished) { - tempSchedule.push({ - matchNumber: scoringSystemSchedule[i].matchNumber, - teams: { - red1: scoringSystemSchedule[i].red.team1, - red2: scoringSystemSchedule[i].red.team2, - blue1: scoringSystemSchedule[i].blue.team1, - blue2: scoringSystemSchedule[i].blue.team2 - } - }); - } + axios.get('http://localhost/apiv1/events/' + eventID + '/matches/').then(function(response) { + console.log(response); + scoringSystemSchedule = response.data.matches; + tempSchedule = []; + for (let i = 0; i < scoringSystemSchedule.length; i++) { + if (scoringSystemSchedule[i].finished) { + tempSchedule.push({ + matchNumber: scoringSystemSchedule[i].matchNumber, + teams: { + red1: scoringSystemSchedule[i].red.team1, + red2: scoringSystemSchedule[i].red.team2, + blue1: scoringSystemSchedule[i].blue.team1, + blue2: scoringSystemSchedule[i].blue.team2 + } + }); } - let matchData = []; - let gameData = []; - let request = { - seasonId: { - season: '2018-2019', - first: 'ftc' - }, - eventKey: eventID, - gameData: gameData, - matchData: matchData - }; - let doneWhen0 = tempSchedule.length; - for (let i = 0; i < tempSchedule.length; i++) { - axios - .get( - 'http://localhost/apiv1/2019/events/' + - eventID + - '/matches/' + - tempSchedule[i].matchNumber - ) - .then(function(response) { - console.log(tempSchedule[i].matchNumber, response) - response = response.data; - matchData[i] = { - matchInformation: { - matchNumber: tempSchedule[i].matchNumber, - teams: tempSchedule[i].teams - }, - resultInformation: { - score: { - penalty: { - red: response.blue.penalty, - blue: response.red.penalty - } + } + let matchData = []; + let gameData = []; + let request = { + seasonId: { + season: '2018-2019', + first: 'ftc' + }, + eventKey: eventID, + gameData: gameData, + matchData: matchData + }; + console.log(tempSchedule); + let doneWhen0 = tempSchedule.length; + for (let i = 0; i < tempSchedule.length; i++) { + axios + .get('http://localhost/apiv1/2019/events/' + eventID + '/matches/' + tempSchedule[i].matchNumber) + .then(function(response) { + console.log(tempSchedule[i].matchNumber, response); + response = response.data; + matchData[i] = { + matchInformation: { + matchNumber: tempSchedule[i].matchNumber, + teams: tempSchedule[i].teams + }, + resultInformation: { + score: { + penalty: { + red: response.blue.penalty, + blue: response.red.penalty } } - }; - bluePartial = 0; - blueFull = 0; - redPartial = 0; - redFull = 0; - if (response.blue.endParking === 15) { - bluePartial = 1; - } - if (response.blue.endParking === 25) { - blueFull = 1; - } - if (response.blue.endParking === 30) { - bluePartial = 2; - } - if (response.blue.endParking === 40) { - blueFull = 1; - bluePartial = 1; - } - if (response.blue.endParking === 50) { - blueFull = 2; - } - if (response.red.endParking === 15) { - redPartial = 1; - } - if (response.red.endParking === 25) { - redFull = 1; - } - if (response.red.endParking === 30) { - redPartial = 2; - } - if (response.red.endParking === 40) { - redFull = 1; - redPartial = 1; - } - if (response.red.endParking == 50) { - redFull = 2; } + }; + bluePartial = 0; + blueFull = 0; + redPartial = 0; + redFull = 0; + if (response.blue.endParking === 15) { + bluePartial = 1; + } + if (response.blue.endParking === 25) { + blueFull = 1; + } + if (response.blue.endParking === 30) { + bluePartial = 2; + } + if (response.blue.endParking === 40) { + blueFull = 1; + bluePartial = 1; + } + if (response.blue.endParking === 50) { + blueFull = 2; + } + if (response.red.endParking === 15) { + redPartial = 1; + } + if (response.red.endParking === 25) { + redFull = 1; + } + if (response.red.endParking === 30) { + redPartial = 2; + } + if (response.red.endParking === 40) { + redFull = 1; + redPartial = 1; + } + if (response.red.endParking == 50) { + redFull = 2; + } - gameData[i*2] = { - matchInformation: { - matchNumber: tempSchedule[i].matchNumber, - robotAlliance: 'blue', - teams: [ - tempSchedule[i].teams.blue1, - tempSchedule[i].teams.blue2 - ] - }, - auto: { - landing: response.blue.landed / 30, - sampling: response.blue.mineralSample / 25, - claiming: response.blue.claimedDepot / 15, - parking: response.blue.autoParking / 10 - }, - driver: { - goldMineral: response.blue.landerGold / 5, - silverMineral: response.blue.landerSilver / 5, - anyMineral: response.blue.depotMinerals / 2 - }, - end: { - latched: response.blue.latchedLander / 50, - parkedCrater: bluePartial, - parkedCompletelyCrater: blueFull - } - }; - gameData[i*2+1] = { - matchInformation: { - matchNumber: tempSchedule[i].matchNumber, - robotAlliance: 'red', - teams: [tempSchedule[i].teams.red1, tempSchedule[i].teams.red2] - }, - auto: { - landing: response.red.landed / 30, - sampling: response.red.mineralSample / 25, - claiming: response.red.claimedDepot / 15, - parking: response.red.autoParking / 10 - }, - driver: { - goldMineral: response.red.landerGold / 5, - silverMineral: response.red.landerSilver / 5, - anyMineral: response.red.depotMinerals / 2 - }, - end: { - latched: response.red.latchedLander / 50, - parkedCrater: redPartial, - parkedCompletelyCrater: redFull - } - }; - doneWhen0--; - if(doneWhen0 == 0){ - console.log(request); - axios - .post('http://' + ip + '/api/events/ftc/event/uploadSync', request) - .then(function(response) { - console.log(response); - }) - .catch(function(error) { - alert(error); - }); + gameData[i * 2] = { + matchInformation: { + matchNumber: tempSchedule[i].matchNumber, + robotAlliance: 'blue', + teams: [tempSchedule[i].teams.blue1, tempSchedule[i].teams.blue2] + }, + auto: { + landing: response.blue.landed / 30, + sampling: response.blue.mineralSample / 25, + claiming: response.blue.claimedDepot / 15, + parking: response.blue.autoParking / 10 + }, + driver: { + goldMineral: response.blue.landerGold / 5, + silverMineral: response.blue.landerSilver / 5, + anyMineral: response.blue.depotMinerals / 2 + }, + end: { + latched: response.blue.latchedLander / 50, + parkedCrater: bluePartial, + parkedCompletelyCrater: blueFull } - }) - .catch(function(error) { - alert(error); - }); - } - }); -}; \ No newline at end of file + }; + gameData[i * 2 + 1] = { + matchInformation: { + matchNumber: tempSchedule[i].matchNumber, + robotAlliance: 'red', + teams: [tempSchedule[i].teams.red1, tempSchedule[i].teams.red2] + }, + auto: { + landing: response.red.landed / 30, + sampling: response.red.mineralSample / 25, + claiming: response.red.claimedDepot / 15, + parking: response.red.autoParking / 10 + }, + driver: { + goldMineral: response.red.landerGold / 5, + silverMineral: response.red.landerSilver / 5, + anyMineral: response.red.depotMinerals / 2 + }, + end: { + latched: response.red.latchedLander / 50, + parkedCrater: redPartial, + parkedCompletelyCrater: redFull + } + }; + doneWhen0--; + if (doneWhen0 == 0) { + console.log(request); + axios + .post('http://' + ip + '/api/events/ftc/event/uploadSync', request) + .then(function(response) { + console.log(response); + alert('Sync Successful'); + }) + .catch(function(error) { + alert(error); + }); + } + }) + .catch(function(error) { + alert(error); + }); + } + }); +}; diff --git a/main.js b/main.js index 47ec6b8..2664078 100644 --- a/main.js +++ b/main.js @@ -16,7 +16,7 @@ const {app, BrowserWindow} = require('electron') win.setTitle("Juicy Data Uploader") // Open the DevTools. - win.webContents.openDevTools() + // win.webContents.openDevTools() // Emitted when the window is closed. win.on('closed', () => {