From c03402bcdb0e7a4bb2f8e2c61e44518605d405bd Mon Sep 17 00:00:00 2001 From: jcwimer Date: Tue, 1 Mar 2016 16:15:19 +0000 Subject: [PATCH] Added a mock layout and an api call for angular --- app/views/api/tournaments.jbuilder | 2 +- frontend/app/js/app.js | 31 +------- frontend/app/js/homeController.js | 17 +++++ frontend/app/pages/index.us | 117 ++++++++++++++++++++--------- 4 files changed, 102 insertions(+), 65 deletions(-) create mode 100644 frontend/app/js/homeController.js diff --git a/app/views/api/tournaments.jbuilder b/app/views/api/tournaments.jbuilder index a0487e3..c9f6ee7 100644 --- a/app/views/api/tournaments.jbuilder +++ b/app/views/api/tournaments.jbuilder @@ -1,3 +1,3 @@ json.array!(@tournaments) do |tournament| - json.extract! tournament, :id, :name, :address, :director, :director_email + json.extract! tournament, :id, :name, :address, :director, :director_email, :date end \ No newline at end of file diff --git a/frontend/app/js/app.js b/frontend/app/js/app.js index 34d039c..899b26e 100644 --- a/frontend/app/js/app.js +++ b/frontend/app/js/app.js @@ -1,30 +1 @@ -function ctrl($scope){ - $scope.rows = ['Paul','John','Lucie']; - $scope.temp = false; - - $scope.addRow = function(){ - $scope.temp = false; - $scope.addName=""; - }; - - $scope.deleteRow = function(row){ - $scope.rows.splice($scope.rows.indexOf(row),1); - }; - - $scope.plural = function (tab){ - return tab.length > 1 ? 's': ''; - }; - - $scope.addTemp = function(){ - if($scope.temp) $scope.rows.pop(); - else if($scope.addName) $scope.temp = true; - - if($scope.addName) $scope.rows.push($scope.addName); - else $scope.temp = false; - }; - - $scope.isTemp = function(i){ - return i==$scope.rows.length-1 && $scope.temp; - }; - -} \ No newline at end of file +var app = angular.module("wrestlingdev", []); \ No newline at end of file diff --git a/frontend/app/js/homeController.js b/frontend/app/js/homeController.js new file mode 100644 index 0000000..4e261b4 --- /dev/null +++ b/frontend/app/js/homeController.js @@ -0,0 +1,17 @@ +app.controller("homeController", function($scope, $http) { + $scope.message = "Test message in scope."; + + + $http({ + method: 'GET', + url: '/api/tournaments/' + }).then(function successCallback(response) { + // this callback will be called asynchronously + // when the response is available + $scope.query = response.data; + }, function errorCallback(response) { + // called asynchronously if an error occurs + // or server returns response with an error status. + $scope.query = "Nothing there"; + }); +}); \ No newline at end of file diff --git a/frontend/app/pages/index.us b/frontend/app/pages/index.us index fdd4042..b380a2f 100644 --- a/frontend/app/pages/index.us +++ b/frontend/app/pages/index.us @@ -1,36 +1,85 @@ - - - - - - - -Angular JS Demo - - -

{{rows.length}} Friend{{plural(rows)}} ? (only {{rows.length-1}} actually....)

-
- - - - + + + WrestlingDev + + + + + + + +
+ + + +
+
+
+ +
+
+
+

All Tournaments

+
+ + + + + + + + + + + + + + + + + + + +
NameAddressDirectorDirector EmailDate
{{ tournament.name }}{{ tournament.address }}{{ tournament.director }}{{ tournament.director_email }}{{ tournament.date }}
+
+
+
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + - - - - - -
- - - - - - -
{{$index+1}}{{row}} - -
- - - \ No newline at end of file