import { DomSanitizer } from '@angular/platform-browser';
import { Tab } from './tab';
import { AddTabFunctionService } from 'src/app/shared/services/tab/add-tab-function.service';
+import { AuditLogService } from 'src/app/shared/services/auditLog/audit-log.service';
@Component({
selector: 'app-tabbar',
export class TabbarComponent implements OnInit {
tabs = [];
+ tabsInfoObject = [];
mainTab = 'Home';
selected = new FormControl(0);
collapedSideBar: boolean;
- constructor(private sanitizer: DomSanitizer, private addTabFuntionService: AddTabFunctionService) {
+ constructor(private sanitizer: DomSanitizer, private addTabFuntionService: AddTabFunctionService, private auditLogService: AuditLogService) {
}
this.addTabFuntionService.listen().subscribe((m: any) => {
console.log(m);
+ this.createAppObject(m);
this.addTab(true, m.title, m.url);
+
})
}
}
}
+ createAppObject(app:any) {
+ this.tabsInfoObject.push(app);
+ }
+
+ removeAppObject(index:number) {
+ this.tabsInfoObject.splice(index, 1);
+
+ }
+
removeTab(index: number) {
this.tabs.splice(index, 1);
}
}
tabChanged($event) {
+ console.log("$event.index "+$event.value);
for (const ttab of this.tabs) {
ttab.active = false;
if(this.tabs.length != 0 && $event.index != 0)
this.tabs[$event.index - 1].active = true;
}
+
+ setStyle() {
+ const style = {
+ 'margin-left': this.collapedSideBar ? '80px' : '370px',
+ };
+ return style;
+ }
+
+ auditLog($event) {
+ var app = this.tabsInfoObject[$event.index - 1];
+ var comment = '';
+ if(app.content==null || app.content==''){
+ comment= app.title;
+ }
+ else{
+ comment = app.content;
+ }
+ this.auditLogService.storeAudit(app.appId, 'tab', comment).subscribe(data => {
+ console.log('Tab action Saved');
+ }, error => {
+ console.log('auditLog Save Error' + error);
+ });
+ }
}