Skip to content

Commit

Permalink
show interjections based on role
Browse files Browse the repository at this point in the history
  • Loading branch information
shehan committed Apr 24, 2017
1 parent 6a4352c commit e728c49
Showing 1 changed file with 48 additions and 31 deletions.
79 changes: 48 additions & 31 deletions client/js/group-chat-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@
$scope.messages = [];
$scope.currentCard = '';
$scope.currentCommunicating = '';
$scope.roleInterpreter='';
$scope.roleCaptionist='';


console.log('User Role:'+AuthService.authenticatedUser().roleID);
document.getElementById("overlayScreen").style.width = "100%";
document.getElementById("overlayScreen").style.height = "100%";

Expand All @@ -38,42 +40,57 @@
$scope.groupMembers = response.data.users;
$scope.groupMembers.sort(compare);

$http.get('services/card/get-cards-for-group', {params: {GroupId: $scope.groupID}})
$http.get('services/role/get-all-roles', {params: {GroupId: $scope.groupID}})
.then(function (response) {
$scope.groupCards = response.data.cards;

$http.get('services/group/get-group-by-id', {params: {GroupId: $scope.groupID}})
for(var r=0; r<response.data.roles.length;r++)
{
if (response.data.roles[r].Name === 'Interpreter'){
$scope.roleInterpreter = response.data.roles[r].ID;
console.log('Int:'+$scope.roleInterpreter);
}

if (response.data.roles[r].Name === 'Captionist'){
$scope.roleCaptionist = response.data.roles[r].ID;
console.log('Cap:'+$scope.roleCaptionist);
}
}

$http.get('services/card/get-cards-for-group', {params: {GroupId: $scope.groupID}})
.then(function (response) {
$scope.group = response.data.group;
$scope.groupCards = response.data.cards;

$http.get('services/interjection/get-interjections-for-group', {params: {GroupId: $scope.groupID}})
$http.get('services/group/get-group-by-id', {params: {GroupId: $scope.groupID}})
.then(function (response) {

if (AuthService.authenticatedUser().roleID === '21' || AuthService.authenticatedUser().roleID === '31'){ //role ID's for Captionist and Interpreter
for(var i=0; i<response.data.interjections; i++)
{
if(response.data.interjections[i].IncludeCaptionist === true && AuthService.authenticatedUser().roleID === '21'){
$scope.groupInterjections.push(response.data.interjections[i])
$scope.group = response.data.group;

$http.get('services/interjection/get-interjections-for-group', {params: {GroupId: $scope.groupID}})
.then(function (response) {

if (AuthService.authenticatedUser().roleID === $scope.roleInterpreter || AuthService.authenticatedUser().roleID === $scope.roleCaptionist) { //role ID's for Captionist and Interpreter
for (var i = 0; i < response.data.interjections.length; i++) {
if (response.data.interjections[i].IncludeCaptionist === true && AuthService.authenticatedUser().roleID === $scope.roleCaptionist) {
$scope.groupInterjections.push(response.data.interjections[i])
}
if (response.data.interjections[i].IncludeInterpreter === true && AuthService.authenticatedUser().roleID === $scope.roleInterpreter) {
$scope.groupInterjections.push(response.data.interjections[i])
}
}
}
if(response.data.interjections[i].IncludeInterpreter === true && AuthService.authenticatedUser().roleID === '31'){
$scope.groupInterjections.push(response.data.interjections[i])
else {
$scope.groupInterjections = response.data.interjections;
}
}
}
else{
$scope.groupInterjections = response.data.interjections;
}

$scope.communicateInterjection = {
Title: "Communicating!",
Icon: "fa fa-microphone",
BackgroundColor: "#449d44",
TextColor: "#ffffff"
};
$scope.groupInterjections.splice(0, 0,$scope.communicateInterjection);

document.getElementById("overlayScreen").style.width = "0%";
document.getElementById("overlayScreen").style.height = "0%";

$scope.communicateInterjection = {
Title: "Communicating!",
Icon: "fa fa-microphone",
BackgroundColor: "#449d44",
TextColor: "#ffffff"
};
$scope.groupInterjections.splice(0, 0, $scope.communicateInterjection);

document.getElementById("overlayScreen").style.width = "0%";
document.getElementById("overlayScreen").style.height = "0%";
});
});
});
});
Expand Down

0 comments on commit e728c49

Please sign in to comment.