mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-22 22:37:01 +00:00
Made login form look better and made user
menu look better.
This commit is contained in:
@@ -21,4 +21,8 @@ class ApiController < ApplicationController
|
|||||||
@tournament = Tournament.new(JSON.parse(params[:tournament]))
|
@tournament = Tournament.new(JSON.parse(params[:tournament]))
|
||||||
@tournament.save
|
@tournament.save
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def currentUserTournaments
|
||||||
|
@tournaments = current_user.tournaments
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
3
app/views/api/currentUserTournaments.jbuilder
Normal file
3
app/views/api/currentUserTournaments.jbuilder
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
json.array!(@tournaments) do |tournament|
|
||||||
|
json.extract! tournament, :id, :name, :address, :director, :director_email, :date
|
||||||
|
end
|
||||||
@@ -54,6 +54,7 @@ Wrestling::Application.routes.draw do
|
|||||||
|
|
||||||
#API
|
#API
|
||||||
get "/api/tournaments" => "api#tournaments"
|
get "/api/tournaments" => "api#tournaments"
|
||||||
|
get "/api/tournaments/user" => "api#currentUserTournaments"
|
||||||
get "/api/tournaments/:tournament" => "api#tournament"
|
get "/api/tournaments/:tournament" => "api#tournament"
|
||||||
get "/api/index" => "api#index"
|
get "/api/index" => "api#index"
|
||||||
post "/api/tournaments/new" => "newTournament"
|
post "/api/tournaments/new" => "newTournament"
|
||||||
|
|||||||
11
frontend/app/js/controllers/my-tournaments.js
Normal file
11
frontend/app/js/controllers/my-tournaments.js
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
app.controller("myTournamentsController", function($scope, tournamentsService, $rootScope) {
|
||||||
|
|
||||||
|
tournamentsService.getMyTournaments().then(function(data) {
|
||||||
|
//this will execute when the
|
||||||
|
//AJAX call completes.
|
||||||
|
$scope.allTournaments = data;
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
@@ -24,6 +24,11 @@ app.config(['$routeProvider', '$locationProvider', function($routeProvider,$loca
|
|||||||
controller: 'tournamentsController'
|
controller: 'tournamentsController'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$routeProvider.when('/tournaments/user', {
|
||||||
|
templateUrl: 'my-tournaments.html',
|
||||||
|
controller: 'myTournamentsController'
|
||||||
|
});
|
||||||
|
|
||||||
$routeProvider.when('/tournaments/:id', {
|
$routeProvider.when('/tournaments/:id', {
|
||||||
templateUrl: 'tournaments-show.html',
|
templateUrl: 'tournaments-show.html',
|
||||||
controller: 'tournamentController'
|
controller: 'tournamentController'
|
||||||
|
|||||||
@@ -4,7 +4,12 @@ app.factory('tournamentsService', tournamentsService);
|
|||||||
function tournamentsService($http){
|
function tournamentsService($http){
|
||||||
var service = {};
|
var service = {};
|
||||||
|
|
||||||
|
service.getMyTournaments = function(user){
|
||||||
|
return $http({
|
||||||
|
url: '/api/tournaments/user/',
|
||||||
|
method: "GET"
|
||||||
|
}).then(successResponse, errorCallback);
|
||||||
|
};
|
||||||
|
|
||||||
service.getAllTournaments = function(){
|
service.getAllTournaments = function(){
|
||||||
return $http({
|
return $http({
|
||||||
|
|||||||
@@ -28,22 +28,23 @@
|
|||||||
<li><a href="/#/tournaments">Browse Tournaments</a></li>
|
<li><a href="/#/tournaments">Browse Tournaments</a></li>
|
||||||
<li><a href="/#/about">About</a></li>
|
<li><a href="/#/about">About</a></li>
|
||||||
<li><a href="/#/tutorials">Tutorials</a></li>
|
<li><a href="/#/tutorials">Tutorials</a></li>
|
||||||
<li class="dropdown" id="menuLogin" ng-controller="loginController">
|
<li class="dropdown" ng-controller="loginController">
|
||||||
<a ng-if="user == null" class="dropdown-toggle" data-toggle="dropdown" id="navLogin">Login</a>
|
<a ng-if="user == null" class="dropdown-toggle" data-toggle="dropdown">Login<span class="caret"></a>
|
||||||
<div ng-if="user == null" class="dropdown-menu" style="padding:17px;">
|
<div ng-if="user == null" class="dropdown-menu" style="padding:17px;">
|
||||||
<form class="form" id="formLogin">
|
<form class="form" id="formLogin">
|
||||||
<input name="username" id="username" type="text" placeholder="Email" ng-model="credentials.email">
|
<div class="form-group">
|
||||||
<input name="password" id="password" type="password" placeholder="Password" ng-model="credentials.password"><br>
|
<input name="username" class="form-control" id="username" type="text" placeholder="Email" ng-model="credentials.email">
|
||||||
<button type="button" id="btnLogin" class="btn" ng-click="login()">Login</button>
|
<input name="password" class="form-control" id="password" type="password" placeholder="Password" ng-model="credentials.password"><br>
|
||||||
|
<button type="button" id="btnLogin" class="btn btn-primary" ng-click="login()">Login</button>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<a ng-if="user != null" class="dropdown-toggle" data-toggle="dropdown" id="navLogout">{{user.email}}</a>
|
<a ng-if="user != null" class="dropdown-toggle" data-toggle="dropdown">{{user.email}}<span class="caret"></a>
|
||||||
<div ng-if="user != null" class="dropdown-menu" style="padding:17px;">
|
<ul ng-if="user != null" class="dropdown-menu" style="list-style-type: none;">
|
||||||
<ul style="list-style-type: none;">
|
<li><a href="/#/tournaments/user">My Tournaments and schools</a></li>
|
||||||
<li ng-click="logout()">Logout</li>
|
<li><a ng-click="logout()">Logout</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div><!--/.nav-collapse -->
|
</div><!--/.nav-collapse -->
|
||||||
|
|||||||
17
frontend/app/pages/tournaments/my-tournaments.html
Normal file
17
frontend/app/pages/tournaments/my-tournaments.html
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<h2>My Tournaments</h2>
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<table class="table">
|
||||||
|
<thead class="font-spot-color">
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Date</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr ng-repeat="tournament in allTournaments">
|
||||||
|
<td><a ng-href="/#/tournaments/{{tournament.id}}">{{ tournament.name }}</a></td>
|
||||||
|
<td>{{ tournament.date }}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
Reference in New Issue
Block a user