diff --git a/clientApp/js/app.js b/clientApp/js/app.js index b9e5b15..14df407 100644 --- a/clientApp/js/app.js +++ b/clientApp/js/app.js @@ -74,6 +74,10 @@ var KnowNodesAppModule = angular.module('KnowNodesApp', ['angulartics', 'angular templateUrl: 'screens/userProfilePage', controller: UserProfilePageCtrl }). + when('/user/:id/:rid', { + templateUrl: 'screens/userProfilePage', + controller: UserProfilePageCtrl + }). otherwise({ redirectTo: '/' }); diff --git a/clientApp/js/controllers.js b/clientApp/js/controllers.js index 227b3af..9c687fd 100644 --- a/clientApp/js/controllers.js +++ b/clientApp/js/controllers.js @@ -188,6 +188,7 @@ function TripletListCtrl($scope, $routeParams, $location, userService, resource, }; $scope.orderProp = "-(upvotes-downvotes)"; + // First, check whether the resource is a KN Resource or a Wikipedia Article if ($routeParams.id != null) { // KN Resource @@ -340,10 +341,15 @@ function TripletInputCtrl($scope, $rootScope, $q, $route, wikinode, resource, co $scope.reversedDirection = false; $scope.$watch('concept', function (newValue) { - if ($scope.startResource == null) - $scope.startResource = newValue; + + if ($scope.startResource == null) + $scope.startResource = newValue; }); + + + + $scope.$on('resourceSelected', function (event, result) { event.stopPropagation(); $scope[result.resourceName] = result.resource; @@ -357,6 +363,7 @@ function TripletInputCtrl($scope, $rootScope, $q, $route, wikinode, resource, co $scope.endResource = start; } + $scope.bgColor = 'explain'; $scope.isFormValid = function () { @@ -438,7 +445,9 @@ function TripletInputCtrl($scope, $rootScope, $q, $route, wikinode, resource, co console.log("startID: ", startResourceId, "endId: ", endResourceId); connection.create(startResourceId, $scope.connectionTitle, $scope.connectionType, endResourceId) .success(function (data, status) { - $route.reload(); + // Dmitry Mod - When a triplet is added, redirect user to their profile page + window.location = '/user/' + $rootScope.user.KN_ID + '/' + $scope.startResource.KN_ID; + // $route.reload(); }) .error(function (data, status) { console.log('Connection creation failed with error : ' + status); @@ -458,8 +467,8 @@ function ResourceInputCtrl($scope) { function emit() { $scope.$emit('resourceSelected', {resourceName: $scope.resourceName, resource: $scope.resource}); - } + } $scope.clear = function () { $scope.resource = null; emit(); @@ -748,7 +757,7 @@ function VoteCtrl($scope, $http, loginModal) { }; } -function UserProfilePageCtrl($scope, $location, $http, $routeParams, userService) { +function UserProfilePageCtrl($scope, $location, $http, $routeParams, resource, userService) { $scope.knownodeList = {}; $scope.isUserLoggedIn = userService.isUserLoggedIn(); @@ -760,8 +769,21 @@ function UserProfilePageCtrl($scope, $location, $http, $routeParams, userService $scope.goToUrl = function (something) { $location.path(something); }; + // Dmitry Mod - show by default the most recent connection the user made on his page + $scope.orderProp = "-connection.__CreatedOn__"; - $scope.orderProp = "-(upvotes - downvotes)"; + if ($routeParams.rid) { + + // First, check whether the resource is a KN Resource or a Wikipedia Article + // KN Resource + resource.get($routeParams.rid).then(function (resource) { + $scope.startResource = resource; + + + }); + + + } } function InfoLineCtrl($scope, userService, $http) {