Skip to content

Commit

Permalink
Add dashboard views
Browse files Browse the repository at this point in the history
Add team class implementation
Add team repo
Update and add tests related
Add class Entity
User have to login before being redirected to his dashboard
Dashboard view have dropdown to change between personal and team 's
views
Each http#GET to the server use a token to identify itself to the serve
and a key for the view wanted
the token and the key are stored in a cookie (not in $rootScope ->
refreshing the page will flush the $rootScope -> lol)
Add login frontend controller and dashboard controller, all other
controller are obsolete
:a: The app has not the same features than before, for now :a:
  • Loading branch information
ttben committed Aug 27, 2015
1 parent f403c7b commit 81483be
Show file tree
Hide file tree
Showing 21 changed files with 693 additions and 109 deletions.
10 changes: 9 additions & 1 deletion backend/db.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
"users": [
{
"id": "2cf91e02-a320-4766-aa9f-6efce3142d44",
"name": "Jackie!",
"name": "Charlie",
"currentChallenges": [
],
"finishedBadgesMap": {
Expand All @@ -112,6 +112,14 @@
}
}
],
"teams": [
{
"id" : "28aa8108-8830-4f43-abd1-3ab643303d92",
"name" : "croquette",
"members" : ["2cf91e02-a320-4766-aa9f-6efce3142d44"],
"leader":"2cf91e02-a320-4766-aa9f-6efce3142d44"
}
],
"challenges": [
{
"id": "af0947e9-bf85-4233-8d50-2de787bf6021",
Expand Down
25 changes: 18 additions & 7 deletions backend/src/Backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import Server = require('./Server');

import DashboardRouter = require('./api/DashboardRouter');
import LoginRouter = require('./api/LoginRouter');

import BadgeRepository = require('./badge/BadgeRepository');
import BadgeFactory = require('./badge/BadgeFactory');
Expand All @@ -19,6 +20,9 @@ import UserRepository = require('./user/UserRepository');
import UserFactory = require('./user/UserFactory');
import User = require('./user/User');

import TeamRepository = require('./user/TeamRepository');
import TeamFactory = require('./user/TeamFactory');

import Operand = require('./condition/expression/Operand');
import GoalExpression = require('./condition/expression/GoalExpression');
import OverallGoalCondition = require('./condition/OverallGoalCondition');
Expand All @@ -41,6 +45,9 @@ class Backend extends Server {
public userRepository:UserRepository;
public userFactory:UserFactory;

public teamRepository:TeamRepository;
public teamFactory:TeamFactory;

private storingHandler:StoringHandler;

/**
Expand All @@ -66,10 +73,13 @@ class Backend extends Server {
this.userRepository = new UserRepository();
this.userFactory = new UserFactory();

this.teamRepository = new TeamRepository();
this.teamFactory = new TeamFactory();

this.storingHandler = new StoringHandler(this);

this.buildAPI();
this.loadData();
this.buildAPI();
}

/**
Expand All @@ -80,13 +90,14 @@ class Backend extends Server {
buildAPI() {
var self = this;

this.app.use('/dashboard', (new DashboardRouter(self.goalInstanceRepository, self.goalInstanceFactory, self.goalDefinitionRepository, self.userRepository,self.badgeRepository, new Middleware())).getRouter());
this.app.use('/dashboard', (new DashboardRouter(self.goalInstanceRepository, self.goalInstanceFactory, self.goalDefinitionRepository, self.userRepository, self.teamRepository, self.badgeRepository, new Middleware())).getRouter());
this.app.use('/login', (new LoginRouter(self.userRepository)).getRouter());

/*
this.app.use("/badges", (new BadgeRouter(self.badgeRepository, self.badgeFactory, self.userRepository, loginCheck)).getRouter());
this.app.use("/goals", (new GoalDefinitionRouter(self.goalDefinitionRepository, self.goalDefinitionFactory, self.goalInstanceRepository, self.userRepository)).getRouter());
this.app.use("/challenges", (new GoalInstanceRouter(self.goalInstanceRepository, self.goalInstanceFactory, self.goalDefinitionRepository, self.userRepository)).getRouter());
*/
this.app.use("/badges", (new BadgeRouter(self.badgeRepository, self.badgeFactory, self.userRepository, loginCheck)).getRouter());
this.app.use("/goals", (new GoalDefinitionRouter(self.goalDefinitionRepository, self.goalDefinitionFactory, self.goalInstanceRepository, self.userRepository)).getRouter());
this.app.use("/challenges", (new GoalInstanceRouter(self.goalInstanceRepository, self.goalInstanceFactory, self.goalDefinitionRepository, self.userRepository)).getRouter());
*/

this.app.get('/test', function (req, res) {
self.storingHandler.save(
Expand All @@ -103,7 +114,7 @@ class Backend extends Server {
loadData():void {
var self = this;
var result = self.storingHandler.load();
if(result.success) {
if (result.success) {
console.log(result.success);
}
else {
Expand Down
14 changes: 14 additions & 0 deletions backend/src/StoringHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ class StoringHandler {
this.fillUsersRepository(data);
this.backend.userRepository.displayShortState();

this.fillTeamRepository(data);
this.backend.teamRepository.displayShortState();

console.log("___________________________________________________________");

return {success: '+++\tRepositories filled correctly\t+++'};
Expand Down Expand Up @@ -85,6 +88,17 @@ class StoringHandler {
}
}

fillTeamRepository(data) {
var teams = data.teams;

for (var currentTeamIndex in teams) {
var currentTeamDescription = teams[currentTeamIndex];
var currentTeam = this.backend.teamFactory.createTeam(currentTeamDescription, this.backend.userRepository);
this.backend.teamRepository.addTeam(currentTeam);
}

}

fillChallengesRepository(data) {
var challenges = data.challenges;

Expand Down
Loading

0 comments on commit 81483be

Please sign in to comment.