From a10c39a4e3b9df85cce712df341c023a01255c0a Mon Sep 17 00:00:00 2001 From: hrushikesh07 Date: Tue, 20 Dec 2016 12:21:45 +0530 Subject: [PATCH] firebase test --- client/cat3/main.html | 2 + client/cat3/src/main.js | 2 +- .../sections/dashboard/track/track.html | 13 +- .../sections/dashboard/track/trackCtrl.js | 123 +++++++++++++++++- 4 files changed, 133 insertions(+), 7 deletions(-) diff --git a/client/cat3/main.html b/client/cat3/main.html index d7cfa2ac0..427554ce5 100644 --- a/client/cat3/main.html +++ b/client/cat3/main.html @@ -37,6 +37,8 @@ + + diff --git a/client/cat3/src/main.js b/client/cat3/src/main.js index 55ec51ab8..389caf669 100644 --- a/client/cat3/src/main.js +++ b/client/cat3/src/main.js @@ -12,7 +12,7 @@ * All modules/feature will be through * */ -var angularApp = angular.module('catapp', ['ui.router','ngTouch','toastr', +var angularApp = angular.module('catapp', ['ui.router','ngTouch','toastr','firebase', 'global.login', 'global.breadcrumb', 'authentication', diff --git a/client/cat3/src/partials/sections/dashboard/track/track.html b/client/cat3/src/partials/sections/dashboard/track/track.html index 6103062cb..7ff89150b 100644 --- a/client/cat3/src/partials/sections/dashboard/track/track.html +++ b/client/cat3/src/partials/sections/dashboard/track/track.html @@ -1,3 +1,10 @@ -
- {{Text}} -
\ No newline at end of file +
+

{{ day.name }}

+
+ + +
+
\ No newline at end of file diff --git a/client/cat3/src/partials/sections/dashboard/track/trackCtrl.js b/client/cat3/src/partials/sections/dashboard/track/trackCtrl.js index 38b7e6e8d..116ff2885 100644 --- a/client/cat3/src/partials/sections/dashboard/track/trackCtrl.js +++ b/client/cat3/src/partials/sections/dashboard/track/trackCtrl.js @@ -1,7 +1,124 @@ (function (angular) { - "use strict"; angular.module('dashboard.track', []) - .controller('trackCtrl',['$scope', function ($scope) { - $scope.Text = 'Track page'; + .controller('trackCtrl',['$scope','$firebase', function ($scope,$firebase) { + + // get # of real time users + var listRef = new Firebase("https://burning-torch-4263.firebaseio.com/presence/"); + var userRef = listRef.push(); + + // Add ourselves to presence list when online. + var presenceRef = new Firebase("https://burning-torch-4263.firebaseio.com/.info/connected"); + presenceRef.on("value", function(snap) { + if (snap.val()) { + userRef.set(true); + // Remove ourselves when we disconnect. + userRef.onDisconnect().remove(); + } + }); + + listRef.on("value", function(snap) { + $scope.online = snap.numChildren(); + }); + + var ref = new Firebase("https://burning-torch-4263.firebaseio.com/days"); + var fb = $firebase(ref); + + // three way data binding + var syncObject = fb.$asObject(); + syncObject.$bindTo($scope, 'days'); + + $scope.reset = function() { + fb.$set({ + monday: { + name: 'Monday', + slots: { + 0900: { + time: '9:00am', + booked: false + }, + 0110: { + time: '11:00am', + booked: false + }, + 100: { + time: '1:00pm', + booked: false + }, + 300: { + time: '3:00pm', + booked: false + }, + 500: { + time: '5:00pm', + booked: false + }, + 700: { + time: '7:00pm', + booked: false + } + } + }, + tuesday: { + name: 'Tuesday', + slots: { + 0900: { + time: '9:00am', + booked: false + }, + 0110: { + time: '11:00am', + booked: false + }, + 100: { + time: '1:00pm', + booked: false + }, + 300: { + time: '3:00pm', + booked: false + }, + 500: { + time: '5:00pm', + booked: false + }, + 700: { + time: '7:00pm', + booked: false + } + } + }, + wednesday: { + name: 'Wednesday', + slots: { + 0900: { + time: '9:00am', + booked: false + }, + 0110: { + time: '11:00am', + booked: false + }, + 100: { + time: '1:00pm', + booked: false + }, + 300: { + time: '3:00pm', + booked: false + }, + 500: { + time: '5:00pm', + booked: false + }, + 700: { + time: '7:00pm', + booked: false + } + } + } + }); + }; + }]); + })(angular); \ No newline at end of file