diff --git a/api/firmware.py b/api/firmware.py index 03678c1..b4618d8 100644 --- a/api/firmware.py +++ b/api/firmware.py @@ -149,3 +149,17 @@ def post(self): body.get("from_fw_version")) self.slack_pusher.send_to_deploys_channel(message_text) + +class FirmwareCertifiedComboAPI(ProtectedRequestHandler): + def get(self): + self.hello_request( + api_url="firmware/certified_combinations", + type="GET" + ) + + def put(self): + self.hello_request( + api_url="firmware/certified_combinations", + type="PUT", + body_data=self.request.body + ) \ No newline at end of file diff --git a/app.yaml b/app.yaml index a710f19..b9c4622 100644 --- a/app.yaml +++ b/app.yaml @@ -1,5 +1,5 @@ application: 'hello-admin' -version: 59a +version: 59c runtime: python27 api_version: 1 diff --git a/static/css/firmware_certified_combo.css b/static/css/firmware_certified_combo.css new file mode 100644 index 0000000..a5b2eb7 --- /dev/null +++ b/static/css/firmware_certified_combo.css @@ -0,0 +1,3 @@ +th {text-align: left !important;} +table {background-color: white; margin-top: 10px;} +.submit-new {width: 100%;} \ No newline at end of file diff --git a/static/js/firmware_certified_combo.js b/static/js/firmware_certified_combo.js new file mode 100644 index 0000000..74c3b45 --- /dev/null +++ b/static/js/firmware_certified_combo.js @@ -0,0 +1,110 @@ +var FW_SEPERATOR = "___"; + +var NewComboModal = React.createClass({ + handleSubmit: function() { + var topFw = this.refs.topFw.getDOMNode().value; + var middleFw = this.refs.middleFw.getDOMNode().value; + + if (!topFw.isWhiteString() && !middleFw.isWhiteString()) { + console.log("data", this.props.data); + var data = this.props.data; + data.push(topFw + FW_SEPERATOR + middleFw); + console.log(data); + this.props.putFWCertifiedCombo(data); + this.props.getFWCertifiedCombo(); + } + + return false; + }, + render: function() { + return +
+
Add New Firmware Combo
+
+
+ +
+ +
+ +
+
+
+ +
+
; + } +}); + +var FirmwareCertifiedCombo = React.createClass({ + getInitialState: function() { + return {data: [], error: ""}; + }, + + getFWCertifiedCombo: function() { + $.ajax({ + url: "/api/firmware_certified_combo", + type: "GET", + success: function(response) { + console.log(response); + this.setState(response); + }.bind(this) + }); + return false; + }, + + putFWCertifiedCombo: function(combo) { + $.ajax({ + url: "/api/firmware_certified_combo", + type: "PUT", + data: JSON.stringify(combo), + success: function(response) { + console.log(response); + }.bind(this) + }); + return false; + }, + + componentDidMount: function() { + this.getFWCertifiedCombo(); + }, + + removeElement: function(ele) { + var updatedData = _.without(this.state.data, ele); + this.putFWCertifiedCombo(updatedData); + this.setState({data: updatedData}); + }, + + render: function() { + return
+ }> + + +
+ + + + + + + { + this.state.data.map(function(d){ + var topFw = d.split(FW_SEPERATOR)[0]; + var middleFw = d.split(FW_SEPERATOR)[1]; + return + + + + + }.bind(this)) + } +
Top Firmware VersionMiddle Firmware VersionAction
{topFw}{middleFw}
+ }> + + + +
; + } +}); + +React.render(, document.getElementById("firmware-certified-combo")); \ No newline at end of file diff --git a/template/base.html b/template/base.html index 28de05c..de9085e 100644 --- a/template/base.html +++ b/template/base.html @@ -77,6 +77,7 @@ Firmware Firmware History Upgrade Path + Version Combos

Data diff --git a/template/firmware_certified_combo.html b/template/firmware_certified_combo.html new file mode 100644 index 0000000..5412d75 --- /dev/null +++ b/template/firmware_certified_combo.html @@ -0,0 +1,10 @@ +{% extends "base_latest_react.html" %} +{% block extrastatic %} + + + +{% endblock %} + +{% block content %} +
+{% endblock %} diff --git a/url/api_urls.py b/url/api_urls.py index 8e657f8..01b6b50 100644 --- a/url/api_urls.py +++ b/url/api_urls.py @@ -23,7 +23,7 @@ from api.trends import TrendsAPI from api.uptime import SenseUptimeAPI from api.event import SenseEventsAPI -from api.firmware import FirmwareAPI +from api.firmware import FirmwareAPI, FirmwareCertifiedComboAPI from api.firmware import FirmwareHistoryAPI from api.firmware import FirmwareInfoAPI from api.firmware import FirmwareUnhashAPI @@ -182,5 +182,6 @@ ('/api/dropout_devices/?$', DropoutDevicesAPI), ('/api/pill_latest/pair/?$', LatestPillsAPI), ('/api/pill_latest/data/?$', LatestPillsDataAPI), + ('/api/firmware_certified_combo/?$', FirmwareCertifiedComboAPI), ] diff --git a/url/view_urls.py b/url/view_urls.py index 0a2c7f0..f33a968 100644 --- a/url/view_urls.py +++ b/url/view_urls.py @@ -1,7 +1,7 @@ from view.views import AccountProfileView, RoomConditionsMinuteView, TimelineV2View, LogsFacetHistoryView, \ TimelineLogsView, TimelineLogsHistoryView, DustCalibrationLeftOverView, HeartbeatView, KeyStoreBatchView, \ LogsLevelView, ESStatusView, ESAggregationView, FeedbackView, DropoutDevicesView, InsightsView, TrendsView, \ - LatestPillsView + LatestPillsView, FirmwareCertifiedComboView from view.views import ActiveDevicesHistoryView from view.views import AlarmRingsHistoryView from view.views import AlarmsView @@ -107,4 +107,5 @@ ('/trends/?$', TrendsView), ('/dropout_devices/?$', DropoutDevicesView), ('/latest_pills/?$', LatestPillsView), + ('/firmware_certified_combo/?$', FirmwareCertifiedComboView), ] \ No newline at end of file diff --git a/view/views.py b/view/views.py index 5f24366..8eefa85 100644 --- a/view/views.py +++ b/view/views.py @@ -306,4 +306,9 @@ def get(self): class LatestPillsView(ProtectedRequestHandler): def get(self): self.render_to_response(template_file='latest_pills.html', - context={'title': "Latest Pills"}) \ No newline at end of file + context={'title': "Latest Pills"}) + +class FirmwareCertifiedComboView(ProtectedRequestHandler): + def get(self): + self.render_to_response(template_file='firmware_certified_combo.html', + context={'title': "Firmware Certified Combo"}) \ No newline at end of file