1 import { Component, OnInit } from '@angular/core';
2 import { UserbarService, UserProfileService } from 'src/app/shared/services';
3 import { DomSanitizer } from '@angular/platform-browser';
6 selector: 'app-userbar',
7 templateUrl: './userbar.component.html',
8 styleUrls: ['./userbar.component.scss']
10 export class UserbarComponent implements OnInit {
14 intervalPromise = null;
16 myservice: UserbarService;
17 constructor(private sanitizer: DomSanitizer, private userbarService: UserbarService, private userProfileService: UserProfileService) { }
21 this.myservice = this.userbarService;
23 // this.userbarService.getOnlineUserUpdateRate().subscribe((_res: any) => {
24 // if (_res != null) {
25 // var rate = parseInt(_res.onlineUserUpdateRate);
26 // var duration = parseInt(_res.onlineUserUpdateDuration);
27 // this.userbarService.setMaxRefreshCount((duration / rate) + 1);
28 // this.userbarService.setRefreshCount(this.userbarService.maxCount);
29 // if (rate != NaN && duration != NaN) {
30 // // $log.debug('UserbarCtlr: scheduling function at interval ' + millis);
31 // this.updateRate = rate;
32 // this.start(this.updateRate);
36 this.updateActiveUsers();
40 // this.userbarService.decrementRefreshCount();
41 this.userProfileService.getActiveUser().subscribe((_res: any) => {
43 // $log.error('UserbarCtrl::updateActiveUsers: failed to get active user');
47 if (_res.length < maxItems)
48 maxItems = _res.length;
49 for (var i = 0; i < maxItems; i++) {
52 linkQ: this.sanitizer.bypassSecurityTrustResourceUrl('qto://talk/' + _res[i]),
53 linkPic: 'https://tspace.web.att.com/profiles/photo.do?uid=' + _res[i]
55 this.userList.push(data);
65 // var footerOff = $('#online-userbar').offset().top;
66 // var headOff = $('#footer').offset().top;
67 // var defaultOffSet = 45;
68 // $(".online-user-container").css({
69 // "height": headOff - footerOff - defaultOffSet
76 this.isOpen = !this.isOpen;
80 // stops any running interval to avoid two intervals running at the same time
82 // store the interval promise
83 this.intervalPromise = setInterval(this.updateActiveUsers, rate);
88 if (this.intervalPromise != null) {
89 clearInterval(this.intervalPromise);
90 this.intervalPromise = null;