@@ -26,6 +26,8 @@ import { PlaceholderTableDataComponent } from '../skeletons/placeholder-table-da
2626import { NgIf } from '@angular/common' ;
2727import { RouterModule } from '@angular/router' ;
2828import { DeleteDomainDialogComponent } from './delete-domain-dialog/delete-domain-dialog.component' ;
29+ import { Title } from '@angular/platform-browser' ;
30+ import { Subscription } from 'rxjs' ;
2931
3032@Component ( {
3133 selector : 'app-company' ,
@@ -68,11 +70,11 @@ export class CompanyComponent {
6870 public companyCustomDomain : {
6971 id : string ,
7072 companyId : string ,
71- hostname : string
73+ hostname : string ,
7274 } = {
7375 id : null ,
7476 companyId : '' ,
75- hostname : ''
77+ hostname : '' ,
7678 } ;
7779
7880 public companyCustomDomainHostname : string ;
@@ -84,17 +86,21 @@ export class CompanyComponent {
8486 public submittingLogo : boolean = false ;
8587 public submittingFavicon : boolean = false ;
8688
87- get whiteLabelSettings ( ) : { logo : string , favicon : string } {
88- return this . _company . whiteLabelSettings || { logo : '' , favicon : '' } ;
89+ public companyTabTitle : string ;
90+ public submittingTabTitle : boolean = false ;
91+
92+ get whiteLabelSettings ( ) : { logo : string , favicon : string , tabTitle : string } {
93+ return this . _company . whiteLabelSettings || { logo : '' , favicon : '' , tabTitle : '' } ;
8994 }
9095
96+ private getTitleSubscription : Subscription ;
97+
9198 constructor (
9299 public _company : CompanyService ,
93100 public _user : UserService ,
94- // private _notifications: NotificationsService,
95101 public dialog : MatDialog ,
96102 private angulartics2 : Angulartics2 ,
97- // private title: Title
103+ private title : Title
98104 ) { }
99105
100106 ngOnInit ( ) {
@@ -103,6 +109,11 @@ export class CompanyComponent {
103109 this . isCustomDomain = true ;
104110 }
105111
112+ this . getTitleSubscription = this . _company . getCurrentTabTitle ( ) . subscribe ( title => {
113+ this . companyTabTitle = title ;
114+ this . title . setTitle ( `Company settings | ${ title || 'Rocketadmin' } ` ) ;
115+ } ) ;
116+
106117 this . _company . fetchCompany ( ) . subscribe ( res => {
107118 this . company = res ;
108119 this . setCompanyPlan ( res . subscriptionLevel ) ;
@@ -127,14 +138,19 @@ export class CompanyComponent {
127138 this . getCompanyMembers ( this . company . id ) ;
128139 } else if ( arg === 'domain' ) {
129140 this . getCompanyCustomDomain ( this . company . id ) ;
130- }
131- else if ( arg === 'updated-white-label-settings' ) {
141+ } else if ( arg === 'updated-white-label-settings' ) {
132142 // this.submittingLogo = true;
133143 this . _company . getWhiteLabelProperties ( this . company . id ) . subscribe ( ) ;
134- } ;
144+ }
135145 } ) ;
136146 }
137147
148+ ngOnDestroy ( ) {
149+ if ( this . getTitleSubscription ) {
150+ this . getTitleSubscription . unsubscribe ( ) ;
151+ }
152+ }
153+
138154 getCompanyMembers ( companyId : string ) {
139155 this . _company . fetchCompanyMembers ( companyId ) . subscribe ( res => {
140156 if ( this . company . invitations ) {
@@ -372,4 +388,26 @@ export class CompanyComponent {
372388 this . submittingFavicon = false ;
373389 } ) ;
374390 }
391+
392+ updateTabTitle ( ) {
393+ this . submittingTabTitle = true ;
394+ this . _company . updateTabTitle ( this . company . id , this . companyTabTitle ) . subscribe ( ( ) => {
395+ this . submittingTabTitle = false ;
396+ this . angulartics2 . eventTrack . next ( {
397+ action : 'Company: tab title is updated successfully' ,
398+ } ) ;
399+ } , err => {
400+ this . submittingTabTitle = false ;
401+ } ) ;
402+ }
403+
404+ deleteTabTitle ( ) {
405+ this . submittingTabTitle = true ;
406+ this . _company . removeTabTitle ( this . company . id ) . subscribe ( ( ) => {
407+ this . submittingTabTitle = false ;
408+ this . angulartics2 . eventTrack . next ( {
409+ action : 'Company: tab title is deleted successfully' ,
410+ } ) ;
411+ } ) ;
412+ }
375413}
0 commit comments