mirror of
https://gitlab.silvrtree.co.uk/martind2000/old-silvrgit.git
synced 2025-01-10 21:55:08 +00:00
added temp to see if it works with api
This commit is contained in:
parent
4150a65220
commit
ef8ef39c17
108
app/js/temp.js
Normal file
108
app/js/temp.js
Normal file
@ -0,0 +1,108 @@
|
||||
var app = angular.module( "Temp", []);
|
||||
app.controller(
|
||||
"TempController",
|
||||
function( $scope, tempService) {
|
||||
|
||||
$scope.tempData = [];
|
||||
|
||||
loadRemoteData();
|
||||
|
||||
function applyRemoteData(newData)
|
||||
{
|
||||
$scope.tempData = newData;
|
||||
}
|
||||
|
||||
function loadRemoteData() {
|
||||
tempService.getTemp()
|
||||
.then(
|
||||
function(tempData) {
|
||||
applyRemoteData(tempData);
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
app.service(
|
||||
"tempService",
|
||||
function($http, $q) {
|
||||
return({getTemp:getTemp});
|
||||
|
||||
function getTemp() {
|
||||
var request = $http({
|
||||
method: "get",
|
||||
url:"http://api.silvrtree.co.uk/temp/all",
|
||||
params: {
|
||||
/* action:"get"*/
|
||||
}
|
||||
});
|
||||
return (request.then(handleSuccess, handleError));
|
||||
}
|
||||
|
||||
|
||||
function handleError(response) {
|
||||
if ( !angular.isObject(response.data) || !response.data.message) {
|
||||
return( $q.reject("An unknown error occured"));
|
||||
}
|
||||
|
||||
return($q.reject(response.data.message));
|
||||
}
|
||||
|
||||
function handleSuccess(response)
|
||||
{
|
||||
return(response.data);
|
||||
}
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(function () {
|
||||
console.log('Starting socket?');
|
||||
var url = "ws://api.silvrtree.co.uk:8039";
|
||||
|
||||
var wsCtor = window['MozWebSocket'] ? MozWebSocket : WebSocket;
|
||||
this.socket = new wsCtor(url, 'stream');
|
||||
|
||||
|
||||
|
||||
|
||||
this.handleData = function(d) {
|
||||
switch(d.id) {
|
||||
case 'LightingDataReceived':
|
||||
// this.updateLighting(d.sensorData.d);
|
||||
break;
|
||||
case 'ProjectorDataReceived':
|
||||
// this.updateProj(d.sensorData.d);
|
||||
break;
|
||||
case 'HeatingDataReceived':
|
||||
break;
|
||||
default:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
this.handleWebsocketMessage = function (message) {
|
||||
try {
|
||||
var command = JSON.parse(message.data);
|
||||
}
|
||||
catch (e) { /* do nothing */
|
||||
}
|
||||
|
||||
if (command) {
|
||||
//this.dispatchCommand(command);
|
||||
this.handleData(command);
|
||||
}
|
||||
};
|
||||
|
||||
this.handleWebsocketClose = function () {
|
||||
alert("WebSocket Connection Closed.");
|
||||
};
|
||||
|
||||
this.socket.onmessage = this.handleWebsocketMessage.bind(this);
|
||||
this.socket.onclose = this.handleWebsocketClose.bind(this);
|
||||
})();
|
69
app/js/weight.js
Normal file
69
app/js/weight.js
Normal file
@ -0,0 +1,69 @@
|
||||
var app = angular.module("Weight", []);
|
||||
app.controller("WeightController", function ($scope, weightService) {
|
||||
$scope.newWeight = 0;
|
||||
|
||||
$scope.weightData = [];
|
||||
|
||||
loadRemoteData();
|
||||
|
||||
|
||||
function applyRemoteData(newData) {
|
||||
$scope.weightData = newData;
|
||||
}
|
||||
|
||||
|
||||
function loadRemoteData() {
|
||||
weightService.getWeight()
|
||||
.then(
|
||||
function (weightData) {
|
||||
applyRemoteData(weightData);
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
$scope.submitForm = function() {
|
||||
"use strict";
|
||||
console.log('Submitting..');
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
app.service(
|
||||
"weightService",
|
||||
function ($http, $q) {
|
||||
return ({getWeight: getWeight});
|
||||
|
||||
function getWeight() {
|
||||
var request = $http({
|
||||
method: "get",
|
||||
url: "/weight/all",
|
||||
params: {
|
||||
/* action:"get"*/
|
||||
}
|
||||
});
|
||||
return (request.then(handleSuccess, handleError));
|
||||
}
|
||||
|
||||
function setWeight(w) {
|
||||
"use strict";
|
||||
|
||||
$http({method: 'post', url: '/weight', params: {weight: w}});
|
||||
|
||||
}
|
||||
|
||||
|
||||
function handleError(response) {
|
||||
if (!angular.isObject(response.data) || !response.data.message) {
|
||||
return ( $q.reject("An unknown error occured"));
|
||||
}
|
||||
|
||||
return ($q.reject(response.data.message));
|
||||
}
|
||||
|
||||
function handleSuccess(response) {
|
||||
return (response.data);
|
||||
}
|
||||
|
||||
}
|
||||
);
|
15
lib/today.js
15
lib/today.js
@ -334,12 +334,25 @@ module.exports = {
|
||||
|
||||
try {
|
||||
calHandler.getSimpleCalV2('https://calendar.google.com/calendar/ical/martind2000%40gmail.com/private-40cfebc9f7dcfa7fde6b9bf2f0092c93/basic.ics', function(v) {
|
||||
todayCache.data.cal = v;
|
||||
todayCache.data.cal.entries = todayCache.data.cal.entries.concat(v.entries) ;
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
logger.error(e);
|
||||
}
|
||||
|
||||
try {
|
||||
calHandler.getSimpleCalV2('https://calendar.google.com/calendar/ical/mt5pgdhknvgoc8usfnrso9vkv0%40group.calendar.google.com/public/basic.ics', function(v) {
|
||||
todayCache.data.cal.entries = todayCache.data.cal.entries.concat(v.entries) ;
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
logger.error(e);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
;
|
||||
|
4
views/partials/angular_footer.ejs
Normal file
4
views/partials/angular_footer.ejs
Normal file
@ -0,0 +1,4 @@
|
||||
</body>
|
||||
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.9/angular.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/sugar/1.4.1/sugar.min.js"></script>
|
||||
</html>
|
64
views/partials/angular_head.ejs
Normal file
64
views/partials/angular_head.ejs
Normal file
@ -0,0 +1,64 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="">
|
||||
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="viewport" content="width=360; initial-scale=1;">
|
||||
<meta charset="UTF-8">
|
||||
<title>Events</title>
|
||||
|
||||
<meta name="Author" content="" />
|
||||
<link href="//fonts.googleapis.com/css?family=Roboto+Slab:400,300,700" rel="stylesheet" type="text/css">
|
||||
<link rel="stylesheet" type="text/css" href="css/mui.css">
|
||||
<link rel="stylesheet" type="text/css" href="../css/mui.css">
|
||||
<style>
|
||||
body {
|
||||
font-family: 'Roboto Slab', "Helvetica Neue", Helvetica, Arial;
|
||||
}
|
||||
ul {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
li {
|
||||
display: inline;
|
||||
margin: 0;
|
||||
padding: 0 4px 0 0;
|
||||
}
|
||||
|
||||
.dates {
|
||||
padding: 2px;
|
||||
border: solid 1px #80007e;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
#btc, #fx {
|
||||
font-size: 75%;
|
||||
}
|
||||
|
||||
.up, .ontime {
|
||||
color: darkgreen;
|
||||
}
|
||||
|
||||
.down, .delayed {
|
||||
color: darkred;
|
||||
}
|
||||
|
||||
.nochange {
|
||||
color: #000000;
|
||||
}
|
||||
.password {
|
||||
border: 1px solid #cccccc;
|
||||
background-color: #efefef;
|
||||
font-family: monospace;
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
.mui--text-danger {
|
||||
color: #F44336;
|
||||
}
|
||||
</style>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/zepto/1.1.4/zepto.min.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
Loading…
Reference in New Issue
Block a user