Skip to content

Commit

Permalink
OAuthController.cs - added functionality to set username in CurrentUs…
Browse files Browse the repository at this point in the history
…erIsAdminOrNot

UserAdminBasicDetailsAC.cs - application class for admin panel logged
app.component.ts - added feild for username of logged user
index.html - displayed the name of user

Fixes - #216
  • Loading branch information
siddharthashw committed Mar 1, 2017
1 parent 48eb2c6 commit 1beb396
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 7 deletions.
Expand Up @@ -3,6 +3,7 @@
using Promact.Core.Repository.OauthCallsRepository;
using Promact.Core.Repository.SlackChannelRepository;
using Promact.Core.Repository.SlackUserRepository;
using Promact.Erp.DomainModel.ApplicationClass;
using Promact.Erp.DomainModel.ApplicationClass.SlackRequestAndResponse;
using Promact.Erp.DomainModel.DataRepository;
using Promact.Erp.DomainModel.Models;
Expand Down Expand Up @@ -237,14 +238,18 @@ public async Task<IHttpActionResult> SlackEventAsync(SlackEventApiAC slackEvent)
* @apiSuccessExample {json} Success-Response:
* HTTP/1.1 200 OK
* {
* true
* "FirstName : "Siddhartha",
* "IsAdmin" : true
* }
*/
[HttpGet]
[Route("oauth/user/admin")]
public async Task<IHttpActionResult> CurrentUserIsAdminOrNot()
{
return Ok(await _oauthCallRepository.CurrentUserIsAdminAsync());
UserAdminBasicDetailsAC userDetails = new UserAdminBasicDetailsAC();
userDetails.FirstName = (await _oauthCallRepository.GetUserByEmployeeIdAsync(GetUserId(User.Identity))).FirstName;
userDetails.IsAdmin = await _oauthCallRepository.CurrentUserIsAdminAsync();
return Ok(userDetails);
}
#endregion
}
Expand Down
@@ -0,0 +1,8 @@
namespace Promact.Erp.DomainModel.ApplicationClass
{
public class UserAdminBasicDetailsAC
{
public bool IsAdmin { get; set; }
public string FirstName { get; set; }
}
}
Expand Up @@ -156,6 +156,7 @@
<Compile Include="ApplicationClass\TaskMailDetailReportAc.cs" />
<Compile Include="ApplicationClass\TaskMailReportAc.cs" />
<Compile Include="ApplicationClass\EmailHashCodeAC.cs" />
<Compile Include="ApplicationClass\UserAdminBasicDetailsAC.cs" />
<Compile Include="Models\Group.cs" />
<Compile Include="Models\GroupEmailMapping.cs" />
<Compile Include="Models\MailSetting.cs" />
Expand Down
4 changes: 3 additions & 1 deletion Slack.Automation/Promact.Erp.Web/app/app.component.ts
Expand Up @@ -13,14 +13,16 @@ import { EmailHashCode } from './shared/emailHashCode';
export class AppComponent implements OnInit {
userIsAdmin: boolean;
hashCode: string;
username: string;
constructor(private loader: LoaderService, private httpService: AppComponentService, private emailHashCode: EmailHashCode) {
this.userIsAdmin = false;
}

ngOnInit() {
this.hashCode = this.emailHashCode.hashCode;
this.httpService.getUserIsAdminOrNot().subscribe((result) => {
this.userIsAdmin = (result === 'true');
this.userIsAdmin = result.IsAdmin;
this.username = result.FirstName;
});
}
}
8 changes: 4 additions & 4 deletions Slack.Automation/Promact.Erp.Web/app/index.html
Expand Up @@ -14,21 +14,21 @@
<a><i class="fa fa-home"></i> Scrum Bot <span class="fa fa-chevron-down"></span></a>
<ul class="nav child_menu">
<li><a routerLink="/scrum">Scrum Reports</a></li>
<li *ngIf="!userIsAdmin"><a routerLink="/scrum/mailsetting">Mail Setting</a></li>
<li *ngIf="userIsAdmin"><a routerLink="/scrum/mailsetting">Mail Setting</a></li>
</ul>
</li>
<li>
<a><i class="fa fa-home"></i> Task List Bot <span class="fa fa-chevron-down"></span></a>
<ul class="nav child_menu">
<li><a routerLink="task">Task Reports</a></li>
<li *ngIf="!userIsAdmin"><a routerLink="/task/mailsetting">Mail Setting</a></li>
<li *ngIf="userIsAdmin"><a routerLink="/task/mailsetting">Mail Setting</a></li>
</ul>
</li>
<li>
<a><i class="fa fa-home"></i> Leave Management <span class="fa fa-chevron-down"></span></a>
<ul class="nav child_menu">
<li><a routerLink="leave">Leave Reports</a></li>
<li *ngIf="!userIsAdmin"><a routerLink="/leave/mailsetting">Mail Setting</a></li>
<li *ngIf="userIsAdmin"><a routerLink="/leave/mailsetting">Mail Setting</a></li>
</ul>
</li>
</ul>
Expand All @@ -47,7 +47,7 @@
<ul class="nav navbar-nav navbar-right">
<li class="">
<a href="javascript:;" class="user-profile dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
<img src="https://www.gravatar.com/avatar/hashCode" alt="">John Doe
<img src="https://www.gravatar.com/avatar/hashCode" alt="">{{username}}
<span class="fa fa-angle-down"></span>
</a>
<ul class="dropdown-menu dropdown-usermenu pull-right">
Expand Down

0 comments on commit 1beb396

Please sign in to comment.