...
 
Commits (19)
/* Controllers */
root.controller('DashboardCtrl', ['$scope', '$http', '$stateParams', '$location', '$rightFactory', '$languageFactory', '$skillsFactory', '$eventsFactory', '$navigationFactory', '$activitiesFactory', '$state', '$projectFactory', '$userFactory', '$tasksFactory', function ($scope, $http, $stateParams, $location, $rightFactory, $languageFactory, $skillsFactory, $eventsFactory, $navigationFactory, $activitiesFactory, $state, $projectFactory, $userFactory, $tasksFactory) {
root.controller('DashboardCtrl', ['$scope', '$http', '$stateParams', '$location', '$rightFactory', '$languageFactory', '$skillsFactory', '$eventsFactory', '$navigationFactory', '$activitiesFactory', '$state', '$projectFactory', '$userFactory', '$tasksFactory', '$chatEventsFactory', function ($scope, $http, $stateParams, $location, $rightFactory, $languageFactory, $skillsFactory, $eventsFactory, $navigationFactory, $activitiesFactory, $state, $projectFactory, $userFactory, $tasksFactory, $chatEventsFactory) {
$scope.activities = [];
$scope.discussions = [];
......@@ -60,6 +60,10 @@ root.controller('DashboardCtrl', ['$scope', '$http', '$stateParams', '$location'
})
}
$scope.manageDiscussions = function (activity) {
$chatEventsFactory.promptNewDiscussion({activity : activity, prompt : "newFromActivity"});
};
$scope.getTasks = function () {
......
......@@ -2,7 +2,7 @@
/* Controllers */
root.controller('ProjectOverviewCtrl', ['$scope', '$state', '$http', '$stateParams', '$rightFactory', '$languageFactory', '$projectFactory', '$userFactory', '$portfolioManagerFactory', function ($scope, $state, $http, $stateParams, $rightFactory, $languageFactory, $projectFactory, $userFactory, $portfolioManagerFactory) {
root.controller('ProjectOverviewCtrl', ['$scope', '$state', '$http', '$stateParams', '$rightFactory', '$languageFactory', '$projectFactory', '$userFactory', '$portfolioManagerFactory', '$chatEventsFactory', function ($scope, $state, $http, $stateParams, $rightFactory, $languageFactory, $projectFactory, $userFactory, $portfolioManagerFactory, $chatEventsFactory) {
var projectCtrl = this;
projectCtrl.shortName = $stateParams.projectName;
......@@ -176,10 +176,8 @@ root.controller('ProjectOverviewCtrl', ['$scope', '$state', '$http', '$statePara
projectCtrl.startDiscussion = function () {
var projectId = $scope._getProject();
console.log(projectId);
}
$chatEventsFactory.promptNewDiscussion({ projectId : $scope._getProject(), prompt : "newFromProject"});
}
projectCtrl.onReady();
......
......@@ -2,7 +2,7 @@
/* Controllers */
root.controller('PortfolioCtrl', ['$scope', '$http', '$stateParams', '$rightFactory', '$languageFactory', '$projectFactory', "$portfolioManagerFactory", "$alertFactory", "$userFactory", function ($scope, $http, $stateParams, $rightFactory, $languageFactory, $projectFactory, $portfolioManagerFactory, $alertFactory, $userFactory) {
root.controller('PortfolioCtrl', ['$scope', '$http', '$stateParams', '$rightFactory', '$languageFactory', '$projectFactory', "$portfolioManagerFactory", "$alertFactory", "$userFactory", '$chatEventsFactory', function ($scope, $http, $stateParams, $rightFactory, $languageFactory, $projectFactory, $portfolioManagerFactory, $alertFactory, $userFactory, $chatEventsFactory) {
var group = this;
......@@ -13,6 +13,7 @@ root.controller('PortfolioCtrl', ['$scope', '$http', '$stateParams', '$rightFact
group.displayCard = true;
group.countNumber = countNumber;
group.isTutor = $userFactory.isTutor();
group.startDiscussion = startDiscussion;
if ($languageFactory.isReady()) getGroupDetails(true)
else $languageFactory.onInitLang($scope, getGroupDetails(true));
......@@ -299,4 +300,9 @@ root.controller('PortfolioCtrl', ['$scope', '$http', '$stateParams', '$rightFact
})
function startDiscussion() {
$chatEventsFactory.promptNewDiscussion({ projectId : $scope._getProject(), prompt : "newFromProject"});
}
}])
\ No newline at end of file
......@@ -31,7 +31,7 @@
</div>
<div style="margin-top:5px;text-align: right">
<button class="pull-right secondary" ng-click="startDiscussion()"
<button class="pull-right secondary" ng-click="portfolioCtrl.startDiscussion()"
ng-if='_userGroups[_getFullGroup()]!="STUDENT"'>{{::_labels.newDiscussion}}
</button>
<button ng-click="portfolioCtrl.newProject()">{{::_labels.addProject}}</button>
......
......@@ -10,7 +10,7 @@
<li ui-sref="project.members" class="pointerOn no-ajaxify"><a>{{::_labels.members}}</a></li>
<li ui-sref="project.settings" class="pointerOn no-ajaxify"><a>{{::_labels.settings}}</a></li>
<button class="pull-right secondary" ng-click="startDiscussion()"
<button class="pull-right secondary" ng-click="projectCtrl.startDiscussion()"
ng-if='_userGroups[_getFullGroup()]!="STUDENT"'>{{::_labels.deliverableDiscussions}}
</button>
<button class="hide pull-right" ng-if="projectCtrl.currentProject.fav" ng-click="setProjectFavourite(0)">
......
......@@ -54,22 +54,32 @@ root.controller('ChatPopupNewCtrl', ['$scope', '$chatFactory', "$chatEventsFacto
chatCtrl.closePopup = function () {
chatCtrl.newElement.firstMessage="";
chatCtrl.newElement.label="";
$chatEventsFactory.promptCancel();
}
chatCtrl.newDiscussion = function () {
var projectId = $(projectSelected).val();
var discussion = {ownerId: session.user, projectId: projectId, label: chatCtrl.newElement.label};
//angular.copy(chatCtrl.newElement,discussion);
discussion.members = chatCtrl.newElement.listRecipients.map(function (e) {
//Récupération des membres de la discussion
var members = chatCtrl.newElement.listRecipients.map(function (e) {
return e.id
});
var projectId = 0;
// Si on a un projetId on le récupère
if(chatCtrl.newElement.projectId ){
projectId=chatCtrl.newElement.projectId;
}
var discussion = {ownerId: session.user, projectId: projectId, label: chatCtrl.newElement.label, members : members, content : chatCtrl.newElement.firstMessage};
//angular.copy(chatCtrl.newElement,discussion);
discussion.attachment = chatCtrl.newElement.attachment;
$chatFactory.addDiscussion(discussion, function (data) {
$chatFactory.getUserDiscussions();
})
$chatFactory.addDiscussion(discussion);
chatCtrl.closePopup();
}
......@@ -77,17 +87,91 @@ root.controller('ChatPopupNewCtrl', ['$scope', '$chatFactory', "$chatEventsFacto
chatCtrl.init = function (params) {
chatCtrl.params = params;
// Si on a projectId, on précharge la liste des membres cas : newFromActivity et newFromProject
if (params.projectId) {
$projectFactory.get_project_projectMembers(params.projectId, function (data) {
if (data.status == "success") {
chatCtrl.newElement.listRecipients = data.details;
}
})
}
$scope.$watch('chatCtrl.newElement.visibility', function(value) {
if(value == "project"){
chatCtrl.getProjectMembers();
} else {
chatCtrl.newElement.listRecipients = [
$scope._getUser()
];
//L'id est un string integer au lieu d'être un integer
chatCtrl.newElement.listRecipients[0].id= parseInt(chatCtrl.newElement.listRecipients[0].id);
}
});
chatCtrl.labelTitle = params.labelTitle;
//TODO modfier pour voir ce que ça fait
chatCtrl.showType = false;
switch (params.prompt) {
case "newFromActivity":
chatCtrl.editLabelDiscussion = false;
chatCtrl.showVisibility = false;
chatCtrl.newElement = $chatModelFactory.newElement;
chatCtrl.newElement.projectId = params.projectId;
chatCtrl.editPopupDiscussion = true;
break;
case "newFromProject":
chatCtrl.editLabelDiscussion = false;
chatCtrl.showVisibility = false;
chatCtrl.newElement = $chatModelFactory.newElement;
chatCtrl.newElement.projectId = params.projectId;
chatCtrl.editPopupDiscussion = true;
break;
case "newFromRightMenu":
chatCtrl.editLabelDiscussion = true;
chatCtrl.showVisibility = true;
chatCtrl.newElement = $chatModelFactory.newElement;
chatCtrl.editPopupDiscussion = true;
//On charge les projets
$serverFactory.runCommand("get_user_project", {}, function (data) {
chatCtrl.projects = data.details;
});
break;
case "update" :
chatCtrl.editLabelDiscussion = true;
chatCtrl.showVisibility = false;
chatCtrl.newElement = $chatModelFactory.model.currentDiscussion;
chatCtrl.editPopupDiscussion = true;
break;
}
/*
//projectId? labelTitle showFirstMessage
chatCtrl.params = params;
chatCtrl.editLabelDiscussion = true;
chatCtrl.labelTitle = params.labelTitle;
chatCtrl.showType = false;
chatCtrl.showVisibility = true;
if (params.prompt == "new") {
chatCtrl.newElement = $chatModelFactory.newElement
chatCtrl.showVisibility = true;
chatCtrl.editPopupDiscussion = false;
}
......@@ -100,10 +184,20 @@ root.controller('ChatPopupNewCtrl', ['$scope', '$chatFactory', "$chatEventsFacto
if (params.projectId) {
chatCtrl.newElement.projectId = params.projectId;
$projectFactory.get_project_parents(params.projectId, function (data) {
/* $projectFactory.get_project_parents(params.projectId, function (data) {
if (data.details) {
chatCtrl.params.portfolioId = data.details[0].parentProject;
}
})*/
/* chatCtrl.showVisibility = false;
$projectFactory.get_project_projectMembers(params.projectId, function (data) {
if (data.status == "success") {
console.log(data);
chatCtrl.newElement.listRecipients = data.details;
//$scope._setNotification("addUser", "");
}
})
}
......@@ -112,11 +206,11 @@ root.controller('ChatPopupNewCtrl', ['$scope', '$chatFactory', "$chatEventsFacto
$serverFactory.runCommand("get_user_project", {}, function (data) {
chatCtrl.projects = data.details;
console.log("projects", chatCtrl.projects)
});
});*/
}
function removeRecipient(recipient) {
chatCtrl.removeRecipient = function(recipient) {
var index = $scope._arrayObjectIndexOf(chatCtrl.newElement.listRecipients, recipient.label, "label");
if (index > -1) {
chatCtrl.newElement.listRecipients.splice(index, 1);
......@@ -133,8 +227,8 @@ root.controller('ChatPopupNewCtrl', ['$scope', '$chatFactory', "$chatEventsFacto
chatCtrl.getProjectMembers = function () {
console.log('projectId ' + $(projectSelected).val());
var projectId = $(projectSelected).val();
// console.log('projectId ' + $(projectSelected).val());
var projectId = chatCtrl.projectSelected;
$projectFactory.get_project_projectMembers(projectId, function (data) {
if (data.status == "success") {
console.log(data);
......
......@@ -9,7 +9,7 @@
<input type="text" ng-model="chatCtrl.newElement.label" placeholder="{{::_labels.placeholderChat}}">
</div>
<div class="form-group has-error" ng-init="chatCtrl.newElement.type='other'"
ng-show="chatCtrl.showType == true">
ng-if="chatCtrl.showType">
<label>{{::_labels.chatType}}</label><span class="required-item"> *</span>
<div class="row">
......@@ -29,51 +29,46 @@
{{::_labels.chatOther}}</label>
</div>
</div>
</div>
<div class="form-group has-error">
<div class="form-group has-error" ng-if="chatCtrl.showVisibility">
<label>{{::_labels.chatVisibility}}</label><span class="required-item"> *</span>
<div class="row">
<div class="col-md-4">
<label class="small">
<input name="radioVisibility" type="radio" ng-model="chatCtrl.newElement.visibility"
value="project"> {{::_labels.chatProject}}
<select id= "projectSelected" ng-change="chatCtrl.getProjectMembers()" ng-model="chatCtrl.projects" ng-if="chatCtrl.newElement.visibility=='project'" class="inline">
<option ng-repeat="prj in chatCtrl.projects track by prj.id" value="{{prj.id}}">{{prj.fullName}} </option>
<select id= "projectSelected" ng-change="chatCtrl.getProjectMembers()" ng-model="chatCtrl.projectSelected" ng-if="chatCtrl.newElement.visibility=='project'" class="inline">
<option ng-repeat="prj in chatCtrl.projects track by prj.id " value="{{prj.id}}">{{prj.fullName}} </option>
</select>
</label>
</div>
<div class="col-md-4">
<label class="small"><input name="radioVisibility" type="radio"
ng-model="chatCtrl.newElement.visibility" value="portfolio">
{{::_labels.chatPortfolio}}</label>
<select ng-if="chatCtrl.newElement.visibility=='portfolio'" class="inline">
<option ng-repeat="prj in ::chatCtrl.projects track by prj.id" value="{{prj.id}}">{{prj.fullName}}</option>
</select>
</div>
<div class="col-md-4">
<label class="small"><input name="radioVisibility" type="radio"
ng-model="chatCtrl.newElement.visibility" value="custom">
ng-model="chatCtrl.newElement.visibility" value="custom" checked>
{{::_labels.chatCustom}}</label>
</div>
</div>
</div>
<div class="form-group has-error">
<label>{{::_labels.addMembers}}</label><span class="required-item"> *</span>
<div style="">
<input ng-if="chatCtrl.editPopupDiscussion || chatCtrl.editLabelDiscussion" type="text"
ng-disabled="chatCtrl.showVisibility && chatCtrl.newElement.visibility!='custom'"
placeholder="{{::_labels.placeholderMembers}}" id="inputMembers"
ng-change="chatCtrl.changeSearchMembers()" value="" ng-model="chatCtrl.newElement.recipient">
<div ng-if="chatCtrl.newElement.visibility=='custom'" >
<label>{{::_labels.addMembers}}</label><span class="required-item"> *</span>
<div>
<input type="text"
placeholder="{{::_labels.placeholderMembers}}" id="inputMembers"
ng-change="chatCtrl.changeSearchMembers()" value="" ng-model="chatCtrl.newElement.recipient">
</div>
</div>
<div>
<div class="separator"></div>
<div class="separator"></div>
<div class="borders">
<div class='jt-editor' style='height: 100px;overflow-y: auto;overflow-x: hidden;'>
<div class="row row-members">
<div ng-repeat="recipient in chatCtrl.newElement.listRecipients track by $index"
<div ng-repeat="recipient in chatCtrl.newElement.listRecipients track by recipient.id"
style="display:inline-block; padding: 5px">
<!--<img width="30" height="30" ng-src="{{recipient['avatar']?recipient['avatar']:_urls.defaultAvatar}}">-->
<user user="recipient" size="30" label="true" label-position="'right'"></user>
......@@ -95,7 +90,7 @@
</div>
<p ng-if="!chatCtrl.editPopupDiscussion">{{::_labels.chatNotOwner}}</p>
<div class="form-group has-error" ng-if="chatCtrl.editPopupDiscussion && chatCtrl.showVisibility == true">
<div class="form-group has-error" ng-if="chatCtrl.editPopupDiscussion">
<label>{{::_labels.firstMessage}}</label><span class="required-item"> *</span>
<textarea type="text" style="height:120px;" required ng-model="chatCtrl.newElement.firstMessage"></textarea>
</div>
......
......@@ -31,8 +31,8 @@ root.controller('ChatWindowsContainerCtrl', ['$scope', '$chatFactory', "$chatEve
chatWindowsCtrl.loadMoreMessages = function (discussion, nbElements) {
var beginIndex = discussion.elements[0].id;
$chatFactory.getDiscussionsElements(discussionId, nbElements, beginIndex, true);
var beginIndex = discussion.messages[0].id;
$chatFactory.getDiscussionsElements(discussion.id, nbElements, beginIndex, true);
}
......@@ -86,24 +86,42 @@ root.controller('ChatWindowsContainerCtrl', ['$scope', '$chatFactory', "$chatEve
scrollDiscussion(params.discussionId);
});
$chatEventsFactory.onNewDiscussion($scope, function (params ){
console.log("Nouvel discussion ", params);
$chatFactory.getUserDiscussions();
})
$chatEventsFactory.onPromptNewDiscussion($scope, function (params) {
if (params.attachment) {
params.labelTitle = $languageFactory._labels.newDiscussionAbout;
$chatModelFactory.newElement = {attachment: params.attachment};
params.showFirstMessage = true;
if (params.attachment.projectId) {
switch (params.prompt) {
case "newFromActivity":
params.projectId = params.attachment.projectId;
}
} else {
params.labelTitle = $languageFactory._labels.newDiscussion;
$chatModelFactory.newElement.listRecipients = [{
"id": $rightFactory.session.userId,
"label": $rightFactory.session.userLabel,
"avatar": $rightFactory.session.userAvatar
}]
params.labelTitle = $languageFactory._labels.newDiscussionAbout;
params.projectId = params.activity.project.id;
params.showFirstMessage = true;
if(params.activity.elementId && params.activity.section && params.projectId){
$chatModelFactory.newElement.attachment = {
id: params.activity.elementId,
type: params.activity.section,
projectId : params.projectId,
}
}
break;
case "newFromProject":
case "newFromRightMenu":
params.labelTitle = $languageFactory._labels.newDiscussion;
/* $chatModelFactory.newElement.listRecipients = [{
"id": $rightFactory.session.userId,
"label": $rightFactory.session.userLabel,
"avatar": $rightFactory.session.userAvatar
}];*/
break;
}
......@@ -120,6 +138,8 @@ root.controller('ChatWindowsContainerCtrl', ['$scope', '$chatFactory', "$chatEve
});
$languageFactory.onInitLang($scope, init, true);
}]);
......
......@@ -9,7 +9,7 @@ root.controller('ListDiscussionsCtrl', ['$scope', '$chatEventsFactory', '$chatFa
listDiscussionsCtrl.newDiscussion = function () {
$chatEventsFactory.promptNewDiscussion();
$chatEventsFactory.promptNewDiscussion({projectId : 0 , prompt : "newFromRightMenu"});
}
......
......@@ -2,7 +2,7 @@
<h4>
{{::_labels.myDiscussions}}
{{::_labels.myDiscussions}} (Beta)
</h4>
......
......@@ -153,9 +153,9 @@ function $chatEventsFactory($rootScope, $chatModelFactory, $chatFactory) {
};
returns.promptNewDiscussion = function () {
returns.promptNewDiscussion = function (params) {
$rootScope.$broadcast(PROMPT_NEW_DISCUSSION, {});
$rootScope.$broadcast(PROMPT_NEW_DISCUSSION, params);
};
returns.onPromptNewDiscussion = function ($scope, handler) {
......@@ -180,21 +180,21 @@ function $chatEventsFactory($rootScope, $chatModelFactory, $chatFactory) {
switch (val.name) {
case NEW_DISCUSSION:
$chatEventsFactory.newDiscussion(val.id);
returns.newDiscussion(val.id);
break;
case ADD_USER_TO_DISCUSSION:
$chatEventsFactory.addUserToDiscussion(val.id);
returns.addUserToDiscussion(val.id);
break;
case DELETE_USER_FROM_DISCUSSION:
$chatEventsFactory.deleteUserFromDiscussion(val.id);
returns.deleteUserFromDiscussion(val.id);
break;
case DELETE_USER_FROM_DISCUSSION:
$chatEventsFactory.deleteUserFromDiscussion(val.id);
returns.deleteUserFromDiscussion(val.id);
break;
default:
activityNotification(val.id, val.name, data.key);
returns.activityNotification(val.id, val.name, data.key);
break;
}
......
......@@ -29,7 +29,10 @@ function $chatFactory($rightFactory, $chatModelFactory, $utilsFactory, $injector
groupBy: "user"
}, function (response) {
$chatModelFactory.model.discussions = response.details;
if (success) success(discussions);
$chatModelFactory.model.discussions.forEach(discussion => $injector.get('$firebaseFactory').loadChatMessages(discussion));
if (success) {
success(response.details);
}
}, failure);
}
......@@ -188,8 +191,21 @@ function $chatFactory($rightFactory, $chatModelFactory, $utilsFactory, $injector
function post_discussion_addDiscussion(discussion, success, failure) {
return $serverFactory.runCommand("post_discussion", {discussion: discussion}, function (response) {
$injector.get('$firebaseFactory').addEvent(response.details, $injector.get('$chatEventsFactory').NEW_DISCUSSION);
if (success) success(response.details);
discussion.members.forEach( member => $injector.get('$firebaseFactory').addEvent(response.details, $injector.get('$chatEventsFactory').NEW_DISCUSSION, member))
if(response.status=="success"){
returns.getUserDiscussions(null,null,function (data) {
$injector.get('$chatEventsFactory').openDiscussion(data[0].id);
});
}
}, failure);
}
......@@ -218,6 +234,33 @@ function $chatFactory($rightFactory, $chatModelFactory, $utilsFactory, $injector
}
returns.getDiscussionByMembers = function (userId, listRecipients, success, failure) {
return get_discussion_byMembers(userId, listRecipients, success, failure)
}
/**
* [post_discussion_renameDiscussion]
* @param int discussionId, String label: new discussion name
* @return promise
*/
function get_discussion_byMembers(userId, listRecipients, success, failure) {
return $serverFactory.runCommand("get_discussion_byMembers", {
discussion : {
userId: userId,
listRecipients: listRecipients
}
}, function (response) {
if (success) {
success(response.details);
}
}, failure);
}
return returns;
}
......
......@@ -179,7 +179,7 @@ function $firebaseFactory($rootScope, $timeout, $chatEventsFactory, $rightFactor
var setEvent = function (data) {
var val = data.val();
console.log("firebase event", val)
if (val.name.indexOf("_DISCUSSION") != -1) {
if (val.name.indexOf("Discussion") != -1) {
$chatEventsFactory.handleFirebaseEvent(val);
resetEvent(data.key, userId);
} else
......@@ -268,7 +268,6 @@ function $firebaseFactory($rootScope, $timeout, $chatEventsFactory, $rightFactor
messagesRef.orderByChild("status").equalTo(1).limitToLast(12).on('child_changed', onNewMessage);
}
// Saves a new message on the Firebase DB.
var sendMessage = function (chatId, msgId) {
// Add a new message entry to the Firebase Database.
......
......@@ -60,29 +60,30 @@ angular.module('myApp.filters', []).filter('interpolate', ['version', function (
return $sce.trustAsHtml(string);
}
}]).filter('keylength', function () {
return function (input) {
if (!angular.isObject(input)) {
return 0;
//throw Error("Usage of non-objects with keylength filter!!")
return function (input) {
if (!angular.isObject(input)) {
return 0;
//throw Error("Usage of non-objects with keylength filter!!")
}
return Object.keys(input).length;
}
return Object.keys(input).length;
}
}).filter('newlines', function () {
return function (text) {
if (text) return text.replace(/\n/g, '<br/>');
else return text;
}
}).filter('formatUTF8', function () {
return function (text) {
if (text) return text.replace(/u00e0/g, "à").replace(/u00e9/g, "é").replace(/u00e8/g, "è").replace(/u00ea/g, "ê").replace(/u00e7/g, "ç").replace(/u0027/g, "'").replace(/u2019/g, "'").replace(/u00ab/g, '"').replace(/u00bb/g, '"').replace(/u2026/g, "...").replace(/u2026/g, "œ").replace(/u00e2/g, "â"); //
else return text;
}
}).filter('userShortName', ['$utilsFactory', function ($utilsFactory) {
return function (user) {
return $utilsFactory.formatUser(user).shortName;
}
}]).filter('userAvatar', ['$utilsFactory', function ($utilsFactory) {
return function (user) {
return user.avatar ? user.avatar : $utilsFactory.defaultThumbnail("user");
}
}]);
}).filter('newlines', function () {
return function (text) {
if (text) return text.replace(/\n/g, '<br/>');
else return text;
}
}).filter('formatUTF8', function () {
return function (text) {
if (text) return text.replace(/u00e0/g, "à").replace(/u00e9/g, "é").replace(/u00e8/g, "è").replace(/u00ea/g, "ê").replace(/u00e7/g, "ç").replace(/u0027/g, "'").replace(/u2019/g, "'").replace(/u00ab/g, '"').replace(/u00bb/g, '"').replace(/u2026/g, "...").replace(/u2026/g, "œ").replace(/u00e2/g, "â"); //
else return text;
}
}).filter('userShortName', ['$utilsFactory', function ($utilsFactory) {
return function (user) {
return $utilsFactory.formatUser(user).shortName;
}
}]).filter('userAvatar', ['$utilsFactory', function ($utilsFactory) {
return function (user) {
return user.avatar ? user.avatar : $utilsFactory.defaultThumbnail("user");
}
}]);
......@@ -12,7 +12,7 @@ var _showTourMessage = function () {
/* Controllers */
var root = angular.module('myApp.controllers', ['ngSanitize','angulartics', 'angulartics.google.analytics',"jsTag",'chart.js','rzModule','vcRecaptcha','angular-intro', 'toastr','ngAvatar']).
controller('CommonCtrl', ['$scope','$sce','$serverFactory','$routeParams','$rootScope','$cookieStore','$location','$http', '$mediaFactory','$languageFactory','$wizardFactory','$userFactory','$rightFactory','$navigationFactory',"$subscriptionFactory","$timeout", "$messageFactory", "$firebaseFactory", "$projectFactory", "$utilsFactory", '$state', '$stateParams','$transitions','$rightMenuFactory','$alertFactory', function($scope,$sce,$serverFactory,$routeParams,$rootScope,$cookieStore,$location,$http, $mediaFactory,$languageFactory,$wizardFactory,$userFactory,$rightFactory,$navigationFactory,$subscriptionFactory,$timeout,$messageFactory, $firebaseFactory, $projectFactory, $utilsFactory, $state,$stateParams,$transitions,$rightMenuFactory, $alertFactory) {
controller('CommonCtrl', ['$scope','$sce','$serverFactory','$routeParams','$rootScope','$cookieStore','$location','$http', '$mediaFactory','$languageFactory','$wizardFactory','$userFactory','$rightFactory','$navigationFactory',"$subscriptionFactory","$timeout", "$messageFactory", "$firebaseFactory", "$projectFactory", "$utilsFactory", '$state', '$stateParams','$transitions','$rightMenuFactory','$alertFactory', '$chatFactory', '$chatEventsFactory', function($scope,$sce,$serverFactory,$routeParams,$rootScope,$cookieStore,$location,$http, $mediaFactory,$languageFactory,$wizardFactory,$userFactory,$rightFactory,$navigationFactory,$subscriptionFactory,$timeout,$messageFactory, $firebaseFactory, $projectFactory, $utilsFactory, $state,$stateParams,$transitions,$rightMenuFactory, $alertFactory, $chatFactory,$chatEventsFactory ) {
$rootScope.__root = __root;
......@@ -201,11 +201,13 @@ controller('CommonCtrl', ['$scope','$sce','$serverFactory','$routeParams','$root
$scope._getUser = function () {
var fullName = $scope._getUserLabel().split(" ");
return {
id: $scope._getUserId(),
email: $scope._getUserMail(),
avatar: $scope._getUserAvatar(),
firstName: $scope._getUserLabel(true)
firstName: fullName[0],
lastName : fullName[1]
}
}
$scope._getUserLabel = function (firstnameOnly) {
......@@ -1034,9 +1036,33 @@ controller('CommonCtrl', ['$scope','$sce','$serverFactory','$routeParams','$root
if (user.id == session.user || user.id == "") return false;
var recipients = [];
recipients.push({id: session.user});
recipients.push({id: user.id});
$messageFactory.setData('chatUsers', recipients);
recipients.push(parseInt(session.user));
recipients.push(user.id);
// useless ?
// $messageFactory.setData('chatUsers', recipients);
$chatFactory.getDiscussionByMembers(session.user,recipients,function(data){
console.log("GDBM" + data);
if(data[0]){
$chatEventsFactory.openDiscussion(data[0]);
} else {
var discussion = {
ownerId: session.user,
projectId: 0,
members: recipients
};
$chatFactory.addDiscussion(discussion, function (data) {
console.log();
/*$chatFactory.getUserDiscussions(null,null, function (data){
console.log(data);
$chatEventsFactory.openDiscussion();
});
$chatEventsFactory.openDiscussion(data[0].id);*/
});
}
});
}
$scope._getFileIconClass = function (file) {
......