mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-03-25 01:14:43 +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.save
|
||||
end
|
||||
|
||||
def currentUserTournaments
|
||||
@tournaments = current_user.tournaments
|
||||
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
|
||||
get "/api/tournaments" => "api#tournaments"
|
||||
get "/api/tournaments/user" => "api#currentUserTournaments"
|
||||
get "/api/tournaments/:tournament" => "api#tournament"
|
||||
get "/api/index" => "api#index"
|
||||
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'
|
||||
});
|
||||
|
||||
$routeProvider.when('/tournaments/user', {
|
||||
templateUrl: 'my-tournaments.html',
|
||||
controller: 'myTournamentsController'
|
||||
});
|
||||
|
||||
$routeProvider.when('/tournaments/:id', {
|
||||
templateUrl: 'tournaments-show.html',
|
||||
controller: 'tournamentController'
|
||||
|
||||
@@ -4,7 +4,12 @@ app.factory('tournamentsService', tournamentsService);
|
||||
function tournamentsService($http){
|
||||
var service = {};
|
||||
|
||||
|
||||
service.getMyTournaments = function(user){
|
||||
return $http({
|
||||
url: '/api/tournaments/user/',
|
||||
method: "GET"
|
||||
}).then(successResponse, errorCallback);
|
||||
};
|
||||
|
||||
service.getAllTournaments = function(){
|
||||
return $http({
|
||||
|
||||
@@ -28,22 +28,23 @@
|
||||
<li><a href="/#/tournaments">Browse Tournaments</a></li>
|
||||
<li><a href="/#/about">About</a></li>
|
||||
<li><a href="/#/tutorials">Tutorials</a></li>
|
||||
<li class="dropdown" id="menuLogin" ng-controller="loginController">
|
||||
<a ng-if="user == null" class="dropdown-toggle" data-toggle="dropdown" id="navLogin">Login</a>
|
||||
<li class="dropdown" ng-controller="loginController">
|
||||
<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;">
|
||||
<form class="form" id="formLogin">
|
||||
<input name="username" id="username" type="text" placeholder="Email" ng-model="credentials.email">
|
||||
<input name="password" id="password" type="password" placeholder="Password" ng-model="credentials.password"><br>
|
||||
<button type="button" id="btnLogin" class="btn" ng-click="login()">Login</button>
|
||||
<div class="form-group">
|
||||
<input name="username" class="form-control" id="username" type="text" placeholder="Email" ng-model="credentials.email">
|
||||
<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>
|
||||
</div>
|
||||
|
||||
<a ng-if="user != null" class="dropdown-toggle" data-toggle="dropdown" id="navLogout">{{user.email}}</a>
|
||||
<div ng-if="user != null" class="dropdown-menu" style="padding:17px;">
|
||||
<ul style="list-style-type: none;">
|
||||
<li ng-click="logout()">Logout</li>
|
||||
</ul>
|
||||
</div>
|
||||
<a ng-if="user != null" class="dropdown-toggle" data-toggle="dropdown">{{user.email}}<span class="caret"></a>
|
||||
<ul ng-if="user != null" class="dropdown-menu" style="list-style-type: none;">
|
||||
<li><a href="/#/tournaments/user">My Tournaments and schools</a></li>
|
||||
<li><a ng-click="logout()">Logout</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</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