Skip to content

Commit 586d530

Browse files
authored
Merge pull request #1298 from utmstack/backlog/fix_logexplorer_tabs
fix(log_explorer): tab content edition not saving state on change
2 parents 15654c3 + 05ccff1 commit 586d530

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

frontend/src/app/log-analyzer/explorer/log-analyzer-tabs/log-analyzer-tabs.component.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,9 @@ export class LogAnalyzerTabsComponent implements OnInit, OnDestroy {
4747
this.addNewTab(this.query.name, this.query, params);
4848
});
4949
} else {
50-
if (isRefresh) {
51-
this.tabService.deleteActiveTab();
50+
if (this.tabService.getTabCount() ==0) {
51+
this.addNewTab(null, null, params);
5252
}
53-
this.addNewTab(null, null, params);
5453
}
5554
});
5655

@@ -63,7 +62,9 @@ export class LogAnalyzerTabsComponent implements OnInit, OnDestroy {
6362
this.tabService.onSaveTabSubject
6463
.pipe(takeUntil(this.destroy$),
6564
filter(query => !!query))
66-
.subscribe(query => this.tabService.updateActiveTab(query));
65+
.subscribe(query => {
66+
this.tabService.updateActiveTab(query)
67+
});
6768

6869
this.router.events.pipe(
6970
filter(event => event instanceof NavigationStart),
@@ -119,7 +120,7 @@ export class LogAnalyzerTabsComponent implements OnInit, OnDestroy {
119120
}
120121

121122
trackByFn(index: number, tab: TabType): any {
122-
return tab.uuid;
123+
return `${tab.uuid}-${index}`;
123124
}
124125

125126
ngOnDestroy(): void {

frontend/src/app/log-analyzer/shared/services/tab.service.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@ import { TabType } from '../type/tab.type';
66
@Injectable()
77
export class TabService {
88
private tabs: TabType[] = [];
9-
private tabSubject = new BehaviorSubject<TabType[]>(this.tabs);
10-
public tabs$ = this.tabSubject.asObservable();
9+
private tabSubject = new BehaviorSubject<TabType[]>([]);
1110
public onSaveTabSubject = new Subject<LogAnalyzerQueryType>();
1211

12+
13+
14+
15+
public get tabs$(){
16+
return this.tabSubject.asObservable();
17+
}
1318
/**
1419
* Add a new tab and make it active.
1520
* @param tab The tab to add.
@@ -22,6 +27,7 @@ export class TabService {
2227
active: true,
2328
};
2429
this.tabs.push(newTab);
30+
2531
this.emitTabs();
2632
}
2733

@@ -111,6 +117,8 @@ export class TabService {
111117
* Emit the latest state of the tabs.
112118
*/
113119
private emitTabs(): void {
114-
this.tabSubject.next(this.tabs);
120+
//avoiding javascript to send references to the subject
121+
const tabsDeepcopy = JSON.parse(JSON.stringify(this.tabs))
122+
this.tabSubject.next([...this.tabs]);
115123
}
116124
}

frontend/src/environments/environment.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
export const environment = {
66
production: false,
7-
// SERVER_API_URL: 'https://192.168.1.18/',
8-
SERVER_API_URL: 'http://localhost:8080/',
7+
SERVER_API_URL: 'https://192.168.1.18/',
8+
//SERVER_API_URL: 'http://localhost:8080/',
99
SERVER_API_CONTEXT: '',
1010
SESSION_AUTH_TOKEN: window.location.host.split(':')[0].toLocaleUpperCase(),
1111
WEBSOCKET_URL: '//localhost:8080',

0 commit comments

Comments
 (0)