Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ export class EventDataExplorerDialogComponent {
);
}

loadEvent(file: FileEvent) {
async loadEvent(file: FileEvent) {
this.loading = true;
this.error = this.fileLoader.loadEvent(
this.error = await this.fileLoader.loadEvent(
file.url,
this.eventDisplay,
file.nocache ? { cache: 'no-cache' } : {},
Expand All @@ -72,9 +72,9 @@ export class EventDataExplorerDialogComponent {
if (!this.error) this.onClose();
}

loadConfig(file: FileEvent) {
async loadConfig(file: FileEvent) {
this.loading = true;
this.error = this.fileLoader.makeRequest(
this.error = await this.fileLoader.makeRequest(
`${this.dialogData.apiURL}?type=config&f=${file.url}`,
'text',
(config) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,31 @@ export class FileLoaderService {
}

// returns whether an error was found
makeRequest(
async makeRequest(
urlPath: string,
responseType: 'json' | 'text' | 'blob',
onData: (data: any) => void,
options: any = {},
) {
fetch(urlPath, options)
.then((res) => res[responseType]())
.then((data) => {
if (responseType === 'blob') {
data
.arrayBuffer()
.then((buf) => this.unzip(buf))
.then((d) => onData(d));
} else {
onData(data);
}
})
.catch((error) => {
console.error(error);
): Promise<boolean> {
try {
const res = await fetch(urlPath, options);
if (!res.ok) {
console.error(`Request failed: ${res.status} ${res.statusText}`);
return true;
Comment thread
GaneshPatil7517 marked this conversation as resolved.
});
return false;
}
const data = await res[responseType]();
if (responseType === 'blob') {
const buf = await (data as Blob).arrayBuffer();
const unzipped = await this.unzip(buf);
onData(unzipped);
} else {
Comment thread
GaneshPatil7517 marked this conversation as resolved.
Outdated
onData(data);
}
return false;
} catch (error) {
console.error(error);
return true;
}
}

loadJSONEvent(eventData: string, eventDisplay: EventDisplayService) {
Expand All @@ -76,11 +78,11 @@ export class FileLoaderService {
eventDisplay.buildEventDataFromJSON(processedEventData);
}

loadEvent(
async loadEvent(
file: string,
eventDisplay: EventDisplayService,
options: any = {},
) {
): Promise<boolean> {
this.lastEventsURL = file;
this.lastEventsOptions = options;
const isZip = file.split('.').pop() === 'zip';
Expand Down
Loading