Skip to content

Commit

Permalink
all features ready.... BOUYAAAAAA
Browse files Browse the repository at this point in the history
  • Loading branch information
begarco committed Mar 15, 2017
1 parent f0b9fab commit fed55bb
Show file tree
Hide file tree
Showing 15 changed files with 511 additions and 170 deletions.
424 changes: 292 additions & 132 deletions .idea/workspace.xml

Large diffs are not rendered by default.

16 changes: 13 additions & 3 deletions app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ angular.module('TaskOverflowApp', [
$rootScope.SERVER_URL="http://localhost:8080/";
$rootScope.CONF_SERVER_URL="http://localhost:666/";
$rootScope.FEATURES={};
$rootScope.HEALTHCHECK={};
})

.config(
Expand Down Expand Up @@ -86,7 +87,7 @@ angular.module('TaskOverflowApp', [
badges_superman_desc: 'Get 100 points from gamification.',
badges_hercule_desc: 'Get 50 points from gamification.',
badges_nbone_desc: 'Write your first message.',

stupid_question: 'Do you like cats?',
user_username_label: 'Username',
user_password_label: 'Password',

Expand Down Expand Up @@ -159,7 +160,7 @@ angular.module('TaskOverflowApp', [
myMessage_content_label: 'Contenu',
answerMessage_content_label: 'Contenu',
questionMessage_content_label: 'Contenu',

stupid_question: 'Aimez-vous les chats?',
profile_firstname_label: 'Prénom',
profile_lastname_label: 'Nom',
profile_email_label: 'Email',
Expand All @@ -177,4 +178,13 @@ angular.module('TaskOverflowApp', [
return function(items) {
return items? items.slice().reverse() : [];
};
});
})

.filter('capitalize', function() {
return function(input, scope) {
if (input!=null)
input = input.toLowerCase();
return input.substring(0,1).toUpperCase()+input.substring(1);
}
})
;
6 changes: 6 additions & 0 deletions app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
height: auto;
}


.cat {
width: 100%;
height: auto;
}

.fix-image {
height: 64px;
width: auto;
Expand Down
2 changes: 1 addition & 1 deletion app/badge/badge.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="container-fluid">
<section class="row">
<section class="row" ng-show="isAvailable('badge')">
<h1 class="col-sm-offset-2 page-title">{{ "home_nav_badges" | translate }}</h1>
<span ng-repeat="badge in badges | reverse" ng-include src="'/badge/displayBadge'"></span>
</section>
Expand Down
6 changes: 5 additions & 1 deletion app/badge/badge.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@ angular.module('TaskOverflowApp.badge', ['ngRoute'])
;
}])

.controller('BadgeCtrl', function ( $scope, $location, $rootScope ) {
.controller('BadgeCtrl', function ( $scope, $location, $http, $rootScope, Features ) {
$scope.bob = "Je m'appelle Bob.";

$http.get($rootScope.SERVER_URL+'badge').
then(function(response) {
$scope.badges = response.data;
});

$scope.isAvailable = function(feature) {
return Features.isAvailable(feature);
};
})

.controller('BadgeShowCtrl', function ( $scope, $location, $http, $routeParams, $rootScope ) {
Expand Down
2 changes: 1 addition & 1 deletion app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<li><a href="/question" ng-show="session.isAvailable('question')" translate="home_nav_questions"></a></li>
<li><a href="/tag" ng-show="session.isAvailable('tag')" translate="home_nav_tags"></a></li>
<li><a href="/badge" ng-show="session.isAvailable('badge')" translate="home_nav_badges"></a></li>
<li><a href="/user" ng-show="session.isAvailable('user')" translate="home_nav_users"></a></li>
<li><a href="/user" translate="home_nav_users"></a></li>

<li ng-if="!session.isLog()" ng-show="session.isAvailable('user')"><a href="/register" translate="home_nav_signin"></a></li>
<li ng-if="!session.isLog()" ng-show="session.isAvailable('user')"><a href="/login" translate="home_nav_login"></a></li>
Expand Down
6 changes: 5 additions & 1 deletion app/question/question.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ <h1 class="col-sm-offset-1 col-xs-10">{{ 'home_welcome' | translate }}</h1>
<p class="col-xs-12 col-sm-offset-1 col-sm-10 text-justify">{{ 'home_presentation' | translate }}</p>

<h1 class="col-sm-offset-2 col-xs-8 page-title">{{ 'home_nav_questions' | translate }}</h1>
<div class="col-xs-offset-1 col-xs-10">
<div class="col-xs-offset-1 col-xs-10" ng-show="isAvailable('question')">
<table class="table">
<thead>
<tr>
Expand All @@ -25,6 +25,10 @@ <h1 class="col-sm-offset-2 col-xs-8 page-title">{{ 'home_nav_questions' | transl
</table>
<div ></div>
</div>
<div class="col-xs-offset-1 col-xs-10" ng-show="!isAvailable('question')">
<h2>{{'stupid_question'|translate}}</h2>
<img class="cat" src="http://thecatapi.com/api/images/get?format=src&type=gif"/>
</div>

</section>
</div>
6 changes: 5 additions & 1 deletion app/question/question.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,18 @@ angular.module('TaskOverflowApp.question', ['ngRoute'])
;
}])

.controller('QuestionCtrl', function ( $scope, $location, $http, $rootScope ) {
.controller('QuestionCtrl', function ( $scope, $location, $http, $rootScope, Features ) {
$scope.bob = "Je m'appelle Bob.";
$scope.questions = [];

$http.get($rootScope.SERVER_URL+'question').
then(function(response) {
$scope.questions = response.data;
});

$scope.isAvailable = function(feature) {
return Features.isAvailable(feature);
};
})

.controller('QuestionCreateCtrl', function ( $scope, $location, $http, $routeParams, $window, Session, $route, $rootScope ) {
Expand Down
18 changes: 12 additions & 6 deletions app/session/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,19 @@ angular.module('TaskOverflowApp.session', ['ngRoute'])
});
}
})
.controller('SessionCtrl', function ( $scope, $location, $http, $window, $rootScope, Features ) {
.controller('SessionCtrl', function ( $scope, $location, $http, $window, $rootScope, $interval, Features ) {
var session = this;
var services = ['question','user','tag','badge'];

for(var i = 0 ; i < services.length ; ++i)
Features.check(services[i]);

$interval( function(services){
console.log("Service availability update");
for(var i = 0 ; i < services.length ; ++i)
Features.check(services[i]);

}.bind(null,services), 5000);

session.userid = function () {
return $window.sessionStorage.userid == undefined ? null : $window.sessionStorage.userid;
Expand Down Expand Up @@ -88,11 +99,6 @@ angular.module('TaskOverflowApp.session', ['ngRoute'])
return Features.isAvailable(feature);
};

session.debug = function () {
console.log("COUCOU");
console.log($rootScope.FEATURES);
}

})

.service('Session', function( $location, $http, $window ){
Expand Down
2 changes: 1 addition & 1 deletion app/tag/tag.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="container-fluid">
<section class="row">
<section class="row" ng-show="isAvailable('tag')">
<h1 class="col-sm-offset-2 page-title">{{ "home_nav_tags" | translate }}</h1>

<div class="col-sm-offset-2 col-sm-4 col-xs-12">
Expand Down
6 changes: 5 additions & 1 deletion app/tag/tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ angular.module('TaskOverflowApp.tag', ['ngRoute'])
;
}])

.controller('TagCtrl', function ( $scope, $location, $http, $rootScope ) {
.controller('TagCtrl', function ( $scope, $location, $http, $rootScope, Features ) {
$scope.bob = "Je m'appelle Bob.";

$scope.tags1 = [];
Expand All @@ -33,6 +33,10 @@ angular.module('TaskOverflowApp.tag', ['ngRoute'])
side = !side;
}
});

$scope.isAvailable = function(feature) {
return Features.isAvailable(feature);
};
})

.controller('TagShowCtrl', function ( $scope, $location, $http, $routeParams, $rootScope ) {
Expand Down
10 changes: 10 additions & 0 deletions app/user/displayRandomUser.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<div class="jumbotron">
<div class="row">
<div class="col-xs-12 text-center">
<img class="profil-image" src="{{user.picture.medium}}" />
</div>
<div class="col-xs-12">
<h2 class="text-center">{{user.name.first | capitalize}} {{user.name.last | capitalize}}</h2>
</div>
</div>
</div>
15 changes: 10 additions & 5 deletions app/user/user.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
<div class="container-fluid">
<h1 class="col-sm-offset-2 page-title">{{'home_nav_users' | translate}}</h1>
<div class="col-sm-offset-2 col-xs-offset-1 col-sm-8 col-xs-10">
<div ng-repeat="user in users" class="col-sm-4 col-xs-12">
<div ng-include="'/user/displaySimpleUser'"></div>
</div>
<h1 class="col-sm-offset-2 page-title">{{'home_nav_users' | translate}}</h1>
<div class="col-sm-offset-2 col-xs-offset-1 col-sm-8 col-xs-10" ng-show="isAvailable('user')" >
<div ng-repeat="user in users" class="col-sm-4 col-xs-12">
<div ng-include="'/user/displaySimpleUser'"></div>
</div>
</div>
<div class="col-sm-offset-2 col-xs-offset-1 col-sm-8 col-xs-10" ng-show="!isAvailable('user')" >
<div ng-repeat="user in randomUsers" class="col-sm-6 col-xs-12">
<div ng-include="'/user/displayRandomUser'"></div>
</div>
</div>
</div>
10 changes: 9 additions & 1 deletion app/user/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,21 @@ angular.module('TaskOverflowApp.user', ['ngRoute'])
;
}])

.controller('UserCtrl', function ( $scope, $location, $http, Session, $rootScope ) {
.controller('UserCtrl', function ( $scope, $location, $http, Session, $rootScope, Features ) {
$scope.bob = "Je m'appelle Bob.";

$scope.isAvailable = function(feature) {
return Features.isAvailable(feature);
};

$http.get($rootScope.SERVER_URL+'user').
then(function(response) {
$scope.users = response.data;
});
$http.get('https://api.randomuser.me/?results=6').
then(function(response) {
$scope.randomUsers = response.data.results;
});
})

.controller('UserShowCtrl', function ( $scope, $location, $http, $routeParams, $window, $route, Session, $rootScope ) {
Expand Down
Loading

0 comments on commit fed55bb

Please sign in to comment.