* feat(ui): timeline zoom * stable draggable markers * integrate zoom into panels, ready up ai stuff for zoom * tabs for ai, slider styles * fixes for zoom tabs * code style
59 lines
1.3 KiB
TypeScript
59 lines
1.3 KiB
TypeScript
import { makeAutoObservable } from 'mobx';
|
|
|
|
import { aiService } from 'App/services';
|
|
|
|
export default class AiSummaryStore {
|
|
text = '';
|
|
toggleSummary = false;
|
|
isLoading = false;
|
|
|
|
constructor() {
|
|
makeAutoObservable(this);
|
|
}
|
|
|
|
setText(text: string) {
|
|
this.text = text;
|
|
}
|
|
|
|
setToggleSummary(toggleSummary: boolean) {
|
|
this.toggleSummary = toggleSummary;
|
|
}
|
|
|
|
setLoading(loading: boolean) {
|
|
this.isLoading = loading;
|
|
}
|
|
|
|
getSummary = async (sessionId: string) => {
|
|
if (this.isLoading) return;
|
|
|
|
this.setLoading(true);
|
|
this.setText('');
|
|
try {
|
|
const respText = await aiService.getSummary(sessionId);
|
|
if (!respText) return;
|
|
|
|
this.setText(respText);
|
|
} catch (e) {
|
|
console.error(e);
|
|
} finally {
|
|
this.setLoading(false);
|
|
}
|
|
};
|
|
|
|
getDetailedSummary = async (sessionId: string, networkEvents: any[], feat: 'errors' | 'issues' | 'journey', startTs: number, endTs: number) => {
|
|
if (this.isLoading) return;
|
|
|
|
this.setLoading(true);
|
|
this.setText('');
|
|
try {
|
|
const respText = await aiService.getDetailedSummary(sessionId, networkEvents,feat, startTs, endTs);
|
|
if (!respText) return;
|
|
|
|
this.setText(respText);
|
|
} catch (e) {
|
|
console.error(e);
|
|
} finally {
|
|
this.setLoading(false);
|
|
}
|
|
}
|
|
}
|