TinyG Update Checker
Checks for updates for the TinyG in chilipeppr.
by Riley Porter
HTML
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<script src="http://www.chilipeppr.com/js/require.js"></script>
<div ng-controller="tgController" ng-cloak id="myTinygUpdateCheckerHtmlId">
<div ng-model="firmware.displayUpdate" ng-show="firmware.displayUpdate" class='alert alert-info'>
<label for="com-synthetos-updateText">TinyG Firmware Update:
<span ng-show="firmware.requiredUpdate" class="label label-danger">Required</span>
<span ng-show="firmware.optionalUpdate" class="label label-warning">Optional</span>
</label>
<!-- <p id='com-synthetos-updateText'><b>There is a update for your TinyG Firmware!</b>
--> <br> <a id="com-synthetos-firmwareCurrent">{{firmware.currentFirmware}}</a> is what your firmware version.
<br> <a id='com-synthetos-firmwareAvailable'>{{firmware.firmwareAvailable}}</a> is now available.
<p>Click <a href="http://synthetos.github.io/"> here</a> to get updating information...</p>
</div>
</div>
CSS
[ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak {
display: none !important;
}
#myTinygUpdateCheckerHtmlId {
margin:0px;
}
#com-synthetos-firmwareCurrent {
color:red;
}
#com-synthetos-firmwareAvailable {
color: green;
text-decoration: none;
}
#requiredUpdate {
label-warning
}
a {
text-decoration: none !important;
}
JavaScript
requirejs.config({
paths: {
angularjs: 'http://ajax.googleapis.com/ajax/libs/angularjs/1.3.11/angular',
},
shim: {},
});
// Test this element. This code is auto-removed by the chilipeppr.load()
cprequire_test(["inline:com-chilipeppr-widget-update-checker"], function (myTinygUpdateCheckerWidget) {
console.log("Tests running for " + myTinygUpdateCheckerWidget.id);
myTinygUpdateCheckerWidget.init(); //This code calls our main in the cpedefine. THIS IS NEEDED!
chilipeppr.publish("/com-chilipeppr-interface-cnccontroller/firmware", "429.01"); //Publish a fake fimware update
//To give the subscribe test function a go.
} /*end_test*/ );
cpdefine("inline:com-chilipeppr-widget-update-checker", ["chilipeppr_ready", "angularjs"], function (cp) {
return {
id: "com-chilipeppr-widget-update-checker",
url: "http://jsfiddle.net/ril3y/vpuo5mqL/show/light/",
fiddleurl: "http://jsfiddle.net/ril3y/vpuo5mqL/",
name: "Widget / TinyG Update Checker",
desc: "This widget checks for any updates to the TinyG Hardware.",
publish: {},
subscribe: {},
foreignPublish: {},
foreignSubscribe: {
'/com-chilipeppr-interface-cnccontroller/firmware': "Listens for firmware build to be published"
},
//This is like our Main function. It starts off the widget.
init: function () {
this.angularSetup(); //Setups the controllers and bootstraps the angular app
},
angularSetup: function () {
//=======================================================================================================================
//ANGULAR CODE HERE
//=======================================================================================================================
var myTinygUpdateChecker = angular.module('myTinygUpdateChecker', []);
//Controller
...