diff --git a/mdot/mdot_mqtt/mdot_mqtt/meeting_table b/mdot/mdot_mqtt/mdot_mqtt/meeting_table new file mode 100644 index 0000000..f440bb0 --- /dev/null +++ b/mdot/mdot_mqtt/mdot_mqtt/meeting_table @@ -0,0 +1,110 @@ +-- +-- PostgreSQL database dump +-- + +-- Dumped from database version 9.5.1 +-- Dumped by pg_dump version 9.5.1 + +-- Started on 2016-08-18 15:46:39 BST + +SET statement_timeout = 0; +SET lock_timeout = 0; +SET client_encoding = 'UTF8'; +SET standard_conforming_strings = on; +SET check_function_bodies = false; +SET client_min_messages = warning; +SET row_security = off; + +SET search_path = public, pg_catalog; + +SET default_tablespace = ''; + +SET default_with_oids = false; + +-- +-- TOC entry 188 (class 1259 OID 63387) +-- Name: meeting; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE meeting ( + id integer NOT NULL, + locationid integer, + logged timestamp with time zone, + count smallint, + start timestamp with time zone, + "end" timestamp with time zone +); + + +ALTER TABLE meeting OWNER TO postgres; + +-- +-- TOC entry 187 (class 1259 OID 63385) +-- Name: meeting_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- + +CREATE SEQUENCE meeting_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE meeting_id_seq OWNER TO postgres; + +-- +-- TOC entry 2387 (class 0 OID 0) +-- Dependencies: 187 +-- Name: meeting_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres +-- + +ALTER SEQUENCE meeting_id_seq OWNED BY meeting.id; + + +-- +-- TOC entry 2266 (class 2604 OID 63390) +-- Name: id; Type: DEFAULT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY meeting ALTER COLUMN id SET DEFAULT nextval('meeting_id_seq'::regclass); + + +-- +-- TOC entry 2382 (class 0 OID 63387) +-- Dependencies: 188 +-- Data for Name: meeting; Type: TABLE DATA; Schema: public; Owner: postgres +-- + +COPY meeting (id, locationid, logged, count, start, "end") FROM stdin; +3 1 2016-08-18 15:39:26+01 4 2016-08-04 13:00:00+01 2016-08-04 13:45:00+01 +4 1 2016-08-18 15:39:51+01 11 2014-08-04 14:00:00+01 2014-08-04 14:45:00+01 +5 1 2016-08-18 15:40:29+01 2 2016-08-04 14:45:00+01 2016-08-04 14:55:00+01 +6 1 2016-08-18 15:40:55+01 3 2016-08-04 15:04:00+01 2016-08-04 16:06:00+01 +7 1 2016-08-18 15:41:25+01 2 2016-08-05 11:05:00+01 2016-08-05 12:15:00+01 +8 1 2016-08-18 15:41:47+01 1 2016-08-05 14:10:00+01 2016-08-05 14:25:00+01 +9 1 2016-08-18 15:42:08+01 4 2016-08-05 15:00:00+01 2016-08-05 15:30:00+01 +10 1 2016-08-18 15:42:37+01 4 2016-08-05 15:30:00+01 2016-08-05 16:23:00+01 +11 1 2016-08-18 15:43:02+01 8 2016-08-08 11:00:00+01 2016-08-08 12:12:00+01 +12 1 2016-08-18 15:43:29+01 7 2016-08-08 15:37:00+01 2016-08-08 16:50:00+01 +13 1 2016-08-18 15:44:10+01 5 2016-08-09 10:02:00+01 2016-08-09 10:15:00+01 +14 1 2016-08-18 15:44:34+01 6 2016-08-09 10:15:00+01 2016-08-09 12:05:00+01 +15 1 2016-08-18 15:44:52+01 1 2016-08-09 13:05:00+01 2016-08-09 13:10:00+01 +\. + + +-- +-- TOC entry 2388 (class 0 OID 0) +-- Dependencies: 187 +-- Name: meeting_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres +-- + +SELECT pg_catalog.setval('meeting_id_seq', 15, true); + + +-- Completed on 2016-08-18 15:46:39 BST + +-- +-- PostgreSQL database dump complete +-- + diff --git a/mdot/mdot_server/mdot_server/app.js b/mdot/mdot_server/mdot_server/app.js index 1fdb976..5d89d9a 100644 --- a/mdot/mdot_server/mdot_server/app.js +++ b/mdot/mdot_server/mdot_server/app.js @@ -31,6 +31,7 @@ var isProduction = false; var mdotApi = require('./lib/mdot/api.js'); var mdotApiV2 = require('./lib/mdot/apiv2.js'); var trackApi = require('./lib/mdot/track.js'); +var meetingApi = require('./lib/mdot/meeting.js'); process.env.NODE_ENV = process.env.NODE_ENV || 'development'; @@ -83,6 +84,7 @@ function originIsAllowed(origin) { mdotApi(app); mdotApiV2(app); trackApi(app); +meetingApi(app); //app.get('/api/mdot/:id', mDot.getData); diff --git a/mdot/mdot_server/mdot_server/app/js/mdot.js b/mdot/mdot_server/mdot_server/app/js/mdot.js index dbf4b84..af08b79 100644 --- a/mdot/mdot_server/mdot_server/app/js/mdot.js +++ b/mdot/mdot_server/mdot_server/app/js/mdot.js @@ -155,7 +155,7 @@ var that = this; that.$el.append(this.template); - /* Var that = this; + /* var that = this; this.$el.empty(); this.collection.each(function(model) { var events = model.get('events'); diff --git a/mdot/mdot_server/mdot_server/app/js/meeting.js b/mdot/mdot_server/mdot_server/app/js/meeting.js new file mode 100644 index 0000000..32e736f --- /dev/null +++ b/mdot/mdot_server/mdot_server/app/js/meeting.js @@ -0,0 +1,57 @@ +'use strict'; +/* global Backbone, _, $, AmCharts */ +/* global meetingView */ +/* jshint browser: true , devel: true */ + + +(function($) { + +var MeetingModel = Backbone.Model.extend({ + url: '/apiv2/meeting' +}); + +var MeetingView = Backbone.View.extend({ + el: '#meetingForm', + initialize: function() { + }, + events: { + submit: 'submit' + }, + submit: function(event) { + var self = this; + var newObj = {}; + var dString; + event.preventDefault(); + notification.clearAll(); + + newObj.roomId = parseInt(this.$el.find('select#device')[0].value); + + dString = [this.$el.find('input#from')[0].value, this.$el.find('input#start')[0].value].join(' '); + newObj.start = Date.create(dString); + + dString = [this.$el.find('input#from')[0].value, this.$el.find('input#end')[0].value].join(' '); + newObj.end = Date.create(dString); + + newObj.occupancy = parseInt(this.$el.find('input#occupancy')[0].value); + + var meetingRec = new MeetingModel(newObj); + meetingRec.save(null, { + success: function(model, response) { + console.log('success'); + notification.notify('success', 'Meeting successfully logged.'); + self.$el[0].reset(); + }, + error: function(model, response) { + console.error('error', response); + notification.notify('error', 'The meeting couldn\'t be logged.'); + } + }); + } +}); + +var meetingView = new MeetingView(); + + +})(jQuery); + + diff --git a/mdot/mdot_server/mdot_server/app/meeting.html b/mdot/mdot_server/mdot_server/app/meeting.html new file mode 100644 index 0000000..7c08a21 --- /dev/null +++ b/mdot/mdot_server/mdot_server/app/meeting.html @@ -0,0 +1,76 @@ + + +
+ + +