Skip to content

Commit

Permalink
Merge pull request #137 from khoa-nd/master
Browse files Browse the repository at this point in the history
Merged
  • Loading branch information
khoa-nd committed Jan 8, 2015
2 parents 0aa16ee + 514f243 commit 8181d7c
Show file tree
Hide file tree
Showing 25 changed files with 171 additions and 104 deletions.
4 changes: 3 additions & 1 deletion src/main/java/com/techlooper/controller/UserController.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ public List<FieldError> save(@RequestBody @Valid UserInfo userInfo, BindingResul

@SendToUser("/queue/info")
@MessageMapping("/user/findByKey")
public UserInfo getUserInfo(SocialRequest searchRequest/*, @DestinationVariable String username */) {
@ResponseBody
@RequestMapping(value = "/user/findByKey", method = RequestMethod.POST)
public UserInfo getUserInfo(@RequestBody @Valid SocialRequest searchRequest/*, @DestinationVariable String username */) {
UserInfo userInfo = userService.findUserInfoByKey(searchRequest.getKey());
userInfo.getLoginSource();
return userInfo;
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/techlooper/model/SocialRequest.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package com.techlooper.model;

import javax.validation.constraints.NotNull;

/**
* Created by phuonghqh on 12/12/14.
*/
public class SocialRequest {

@NotNull
private String key;

public String getKey() {
Expand Down
Binary file modified src/main/webapp/assets/images/ic-navi.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 0 additions & 3 deletions src/main/webapp/assets/modules/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ techlooper.config(["$routeProvider", "$translateProvider", "$authProvider", "loc
switch (rejection.status) {
case 403:
case 401:
//utils.sendNotification(jsonValue.notifications.loginFailed);
if (localStorageService.get(jsonValue.storage.back2Me) === true) {
utils.sendNotification(jsonValue.notifications.loginFailed);
}
Expand Down Expand Up @@ -133,8 +132,6 @@ techlooper.run(function (shortcutFactory, connectionFactory, loadingBoxFactory,
utils.apply();
return rsLocationPathFn;
}

userService.getUserInfo();
});

techlooper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ angular.module('Bubble').factory('bubbleFactory', function (utils, jsonValue, $l
var box = $$.getBox(size, size);
var randomCircles = $$.getCircles(box);

$(".bubble-chart-container").find("svg.bubbleChart").remove(); //remove all bubble chart svg
var svg = d3.select(".bubble-chart-container").append("svg")
.attr({preserveAspectRatio: "xMidYMid", width: size, height: size, class: "bubbleChart"})
.attr("viewBox", function (d) {return ["0 0", size, size].join(" ")});
Expand Down
3 changes: 2 additions & 1 deletion src/main/webapp/assets/modules/chart/chart.con.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
angular.module('Chart').controller('chartController', function ($scope, jsonValue, connectionFactory, utils, chartService) {
angular.module('Chart').controller('chartController', function ($scope, jsonValue, connectionFactory, utils, chartService, navigationService) {
utils.sendNotification(jsonValue.notifications.switchScope, $scope);

var events = jsonValue.events;
Expand All @@ -14,4 +14,5 @@ angular.module('Chart').controller('chartController', function ($scope, jsonValu
});

connectionFactory.receiveTechnicalTerms();
navigationService.reSetingPositionLangIcon();
});
44 changes: 29 additions & 15 deletions src/main/webapp/assets/modules/common/connection.fac.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ angular.module("Common").factory("connectionFactory",
errorHandler: function (error) {
if (error.headers !== undefined && error.headers.message.indexOf("AuthenticationCredentialsNotFoundException") >= 0) {
localStorageService.set(jsonValue.storage.back2Me, "true");
utils.sendNotification(jsonValue.notifications.loginFailed);
return utils.sendNotification(jsonValue.notifications.loginFailed);
}
return utils.sendNotification(jsonValue.notifications.http404);
}
}

Expand Down Expand Up @@ -91,23 +92,36 @@ angular.module("Common").factory("connectionFactory",
},

findUserInfoByKey: function () {
if (!broadcastClient.connected) {
rootScopeCallbacks.push({
fn: instance.findUserInfoByKey,
args: undefined
//HTTP version
$$.post(jsonValue.httpUri.getUserInfoByKey, {key: localStorageService.get(jsonValue.storage.key)})
.then(function(userInfo) {
$rootScope.userInfo = userInfo;
utils.sendNotification(jsonValue.notifications.userInfo, userInfo);
})
.catch(function() {
//localStorageService.set(jsonValue.storage.back2Me, "true");
utils.sendNotification(jsonValue.notifications.notUserInfo);
});
return instance.connectSocket();
}

var subscription = broadcastClient.subscribe(socketUri.subscribeUserInfo, function (response) {
var userInfo = JSON.parse(response.body);
$rootScope.userInfo = userInfo;
utils.sendNotification(jsonValue.notifications.userInfo, userInfo);
subscription.unsubscribe();
});

broadcastClient.send(socketUri.getUserInfoByKey, {},
JSON.stringify({key: localStorageService.get(jsonValue.storage.key)}));
// Websocket version - for nginx which support websocket version
//if (!broadcastClient.connected) {
// rootScopeCallbacks.push({
// fn: instance.findUserInfoByKey,
// args: undefined
// });
// return instance.connectSocket();
//}
//
//var subscription = broadcastClient.subscribe(socketUri.subscribeUserInfo, function (response) {
// var userInfo = JSON.parse(response.body);
// $rootScope.userInfo = userInfo;
// utils.sendNotification(jsonValue.notifications.userInfo, userInfo);
// subscription.unsubscribe();
//});
//
//broadcastClient.send(socketUri.getUserInfoByKey, {},
// JSON.stringify({key: localStorageService.get(jsonValue.storage.key)}));
},

/* @subscription */
Expand Down
4 changes: 3 additions & 1 deletion src/main/webapp/assets/modules/common/json.val.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ angular.module("Common").constant("jsonValue", {
loginSuccess: "Login success",
loginFailed: "Login failed",
userInfo: "User info",
notUserInfo: "Not get User info",
hideLoadingBox: "Hide loading box",
http404: "HTTP code 404",
logoutSuccess: "Logout success"
Expand Down Expand Up @@ -170,7 +171,8 @@ angular.module("Common").constant("jsonValue", {
userSave: "user/save",
login: "login",
logout: "logout",
verifyUserLogin: "user/verifyUserLogin"
verifyUserLogin: "user/verifyUserLogin",
getUserInfoByKey: "user/findByKey"
},

socketUri: {
Expand Down
7 changes: 7 additions & 0 deletions src/main/webapp/assets/modules/common/router.ser.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,20 @@ angular.module("Common").factory("routerService", function (jsonValue, utils, $l

logoutSuccess: function() {
$location.path("/");
},

changeUrl: function() {
if (utils.getView() !== jsonValue.views.signIn) {
localStorageService.remove(jsonValue.storage.back2Me);
}
}
}

utils.registerNotification(jsonValue.notifications.loginFailed, $$.loginFailed);
utils.registerNotification(jsonValue.notifications.logoutSuccess, $$.logoutSuccess);
utils.registerNotification(jsonValue.notifications.loginSuccess, $$.loginSuccess);
utils.registerNotification(jsonValue.notifications.http404, $$.http404);
utils.registerNotification(jsonValue.notifications.changeUrl, $$.changeUrl);

var instance = {
initialize: function () {}
Expand Down
4 changes: 2 additions & 2 deletions src/main/webapp/assets/modules/common/shortcut.fac.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
angular.module("Common").factory("shortcutFactory", function (jsonValue, $location, $rootScope, historyFactory, utils) {
angular.module("Common").factory("shortcutFactory", function (jsonValue, $location, $rootScope, historyFactory, utils, navigationService) {

var $$ = {
goBack: function () {
Expand All @@ -17,9 +17,9 @@ angular.module("Common").factory("shortcutFactory", function (jsonValue, $locati
}
$location.path(jsonValue.routerUris.jobsSearch);
break;

default:
$$.goBack();
navigationService.restoreNaviStyle();
break;
}
},
Expand Down
20 changes: 13 additions & 7 deletions src/main/webapp/assets/modules/common/user.ser.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,29 @@ angular.module("Common").factory("userService", function (jsonValue, utils, conn

getUserInfo: function () {
var deferred = $q.defer();
//TODO: check actual user logged-in
if ($rootScope.userInfo === undefined) {
defers.getUserInfo.push(deferred);

if (instance.notLoggedIn()) {
connectionFactory.findUserInfoByKey();
}
else {
$.each(defers.getUserInfo, function (i, d) {d.resolve($rootScope.userInfo);});
defers.getUserInfo.length = 0;
instance.resolve("getUserInfo", $rootScope.userInfo);
}
defers.getUserInfo.push(deferred);
return deferred.promise;
},

notLoggedIn: function() {
resolve: function (key, reply) {
$.each(defers[key], function (i, d) {d.resolve(reply);});
defers[key].length = 0;
},

//TODO: check actual user logged-in
notLoggedIn: function () {
return ($rootScope.userInfo === undefined);
}
}
instance.getUserInfo();//read userInfo

instance.getUserInfo(); //handle refresh button: read user-info
utils.registerNotification(jsonValue.notifications.userInfo, instance.getUserInfo);
return instance;
});
10 changes: 3 additions & 7 deletions src/main/webapp/assets/modules/job/searchBox.ser.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
angular.module("Jobs").factory("searchBoxService", function ($location, jsonValue, utils, $translate, shortcutFactory) {
angular.module("Jobs").factory("searchBoxService", function ($location, jsonValue, utils, $translate, shortcutFactory, navigationService) {
var scope, searchText, textArray;

var $$ = {
Expand Down Expand Up @@ -102,18 +102,14 @@ angular.module("Jobs").factory("searchBoxService", function ($location, jsonValu
shortcutFactory.trigger('esc');
var view = utils.getView();
if(view == jsonValue.views.pieChart || view == jsonValue.views.bubbleChart){
$('.navi-container').find('a.m-chart').parent().addClass('active');
$('.navi-container').find('a.m-search-jobs').parent().removeClass('active');
$('.main-navi-block').css('background','url(images/line-h.png) #000 right top repeat-y');
navigationService.restoreNaviStyle();
}
});
$('.btn-logo').click(function () {
shortcutFactory.trigger('esc');
var view = utils.getView();
if(view == jsonValue.views.pieChart || view == jsonValue.views.bubbleChart){
$('.navi-container').find('a.m-chart').parent().addClass('active');
$('.navi-container').find('a.m-search-jobs').parent().removeClass('active');
$('.main-navi-block').css('background','url(images/line-h.png) #000 right top repeat-y');
navigationService.restoreNaviStyle();
}
});

Expand Down
1 change: 1 addition & 0 deletions src/main/webapp/assets/modules/job/searchForm.con.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ angular.module('Jobs').controller('searchFormController', function (utils, $scop

animationFactory.animatePage();
navigationService.addSpaceforNavi();
navigationService.reSetingPositionLangIcon();
});
32 changes: 25 additions & 7 deletions src/main/webapp/assets/modules/navigation/navigation.ser.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ angular.module("Navigation").factory("navigationService", function (utils, jsonV
});
},
updateHighlight: function(){
if($rootScope.userInfo === undefined){
if(!userService.notLoggedIn()){
$('.main-navi-block').css('width', '0px');
$('.navi-container').css({'width': '0%', 'display': 'none'});
$('.manager-navi').find('.fa-bars').removeClass('active');
Expand All @@ -104,7 +104,7 @@ angular.module("Navigation").factory("navigationService", function (utils, jsonV
var menuItem = $('.navi-container').find('li');
menuItem.on('click', function(){
//utils.hideNavigationBar();
if($(this).find('a').hasClass('m-chart') || $(this).find('a').hasClass('m-search-jobs') || $(this).find('a').hasClass('sign-out-sign-in')){
if(!$(this).find('a').hasClass('m-languages')){
menuItem.removeClass('active');
$(this).addClass('active');
if($(this).find('a').hasClass('m-search-jobs')){
Expand All @@ -117,6 +117,12 @@ angular.module("Navigation").factory("navigationService", function (utils, jsonV
$('.navi-container').find('a.sign-out-sign-in').parent().removeClass('active');
$('.navi-container').find('a.m-chart').parent().addClass('active');
}
$('.techlooper-body').animate({
'padding-left': '85px'
});
$('.sub-page-header').animate({
'padding-left': '20px'
});
}
});
}
Expand All @@ -129,11 +135,11 @@ angular.module("Navigation").factory("navigationService", function (utils, jsonV
$$.naviControl();
},

restartTour: function () {
$('.infor-tour').on('click', function () {
tourService.restart();
});
},
//restartTour: function () {
// $('.infor-tour').on('click', function () {
// tourService.restart();
// });
//},
addSpaceforNavi: function(){
var page = $('.techlooper-body');
if($('.main-navi-block').width() == 85){
Expand All @@ -143,6 +149,18 @@ angular.module("Navigation").factory("navigationService", function (utils, jsonV
page.css('padding-left', '0');
$('.sub-page-header').css('padding-left', '90px');
}
},
reSetingPositionLangIcon: function(){
if($('.navbar').length > 0){
$('.languages-block').css('right','0');
}else{
$('.languages-block').css('right','55px');
}
},
restoreNaviStyle: function(){
$('.navi-container').find('a.m-chart').parent().addClass('active');
$('.navi-container').find('a.m-search-jobs').parent().removeClass('active');
$('.main-navi-block').css('background','url(images/line-h.png) #000 right top repeat-y');
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<div>
<div class="main-navi-block">
<div class="manager-navi">
<i class="fa fa-bars"></i>
Expand All @@ -10,11 +11,17 @@
<li ng-show="userInfo !== undefined"><a href="#/register" class="m-user-profile"><img ng-src="{{userInfo.profileImageUrl}}" alt=""/></a></li>
<li><a href="#/jobs/search" class="m-search-jobs"></a></li>
<li>
<translation></translation>
<div class="d-languages-block">
<translation></translation>
</div>
</li>
<li><a class="sign-out-sign-in {{userInfo === undefined ? 'm-sign-in' : 'm-sign-out'}}"
title="{{userInfo === undefined ? 'Sign In' : 'Sign Out'}}"></a></li>
<!--<li><a class="m-tour-guide infor-tour" title="Tour Guide"></a></li>-->
</ul>
</div>
</div>
<div class="languages-block">
<translation></translation>
</div>
</div>
1 change: 1 addition & 0 deletions src/main/webapp/assets/modules/register/register.con.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ angular.module('Register').controller('registerController',
utils.sendNotification(jsonValue.notifications.gotData);
});
navigationService.addSpaceforNavi();
navigationService.reSetingPositionLangIcon();
});
4 changes: 2 additions & 2 deletions src/main/webapp/assets/modules/register/register.ser.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ angular.module('Register').factory('registerService',
},

enableNotifications: function () {
return $(".register-contianer").is(":visible");
return utils.getView() === jsonValue.views.register;
}
}

Expand Down Expand Up @@ -95,7 +95,7 @@ angular.module('Register').factory('registerService',
}
};

//utils.registerNotification(jsonValue.notifications.userInfo, instance.updateUserInfo, $$.enableNotifications);
utils.registerNotification(jsonValue.notifications.notUserInfo, function () {localStorageService.set(jsonValue.storage.back2Me, "true");}, $$.enableNotifications);
utils.registerNotification(jsonValue.notifications.switchScope, $$.initialize, $$.enableNotifications);
return instance;
});
1 change: 1 addition & 0 deletions src/main/webapp/assets/modules/signin/signin.con.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ angular.module('SignIn').controller('signInController', function ($location, jso
//utils.sendNotification(jsonValue.notifications.gotData);
$scope.openOathDialog = signInService.openOathDialog;
navigationService.addSpaceforNavi();
navigationService.reSetingPositionLangIcon();
});
Loading

0 comments on commit 8181d7c

Please sign in to comment.