Add timeout of 15 seconds for auto fetch button

This commit is contained in:
aditya.chandel
2025-06-19 11:20:20 -06:00
parent ddc0244234
commit 30e1a0b4fa
4 changed files with 18 additions and 11 deletions
@@ -139,7 +139,7 @@ public class BookMetadataUpdater {
.orElseGet(() -> categoryRepository.save(CategoryEntity.builder().name(categoryName).build())); .orElseGet(() -> categoryRepository.save(CategoryEntity.builder().name(categoryName).build()));
existingCategories.add(categoryEntity); existingCategories.add(categoryEntity);
` } }
metadata.setCategories(existingCategories); metadata.setCategories(existingCategories);
} else if (!newMetadata.getCategories().isEmpty()) { } else if (!newMetadata.getCategories().isEmpty()) {
Set<CategoryEntity> newCategoryEntities = new HashSet<>(); Set<CategoryEntity> newCategoryEntities = new HashSet<>();
@@ -198,17 +198,17 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
this.metadataMenuItems = [ this.metadataMenuItems = [
{ {
label: 'Refresh Metadata', label: 'Refresh Metadata',
icon: 'pi pi-refresh', icon: 'pi pi-sync',
command: () => this.updateMetadata() command: () => this.updateMetadata()
}, },
{ {
label: 'Edit Bulk Metadata', label: 'Bulk Metadata Editor',
icon: 'pi pi-pencil', icon: 'pi pi-table',
command: () => this.bulkEditMetadata() command: () => this.bulkEditMetadata()
}, },
{ {
label: 'Edit Multi Book Metadata', label: 'Multi-Book Metadata Editor',
icon: 'pi pi-pencil', icon: 'pi pi-clone',
command: () => this.multiBookEditMetadata() command: () => this.multiBookEditMetadata()
} }
]; ];
@@ -477,6 +477,10 @@ export class MetadataEditorComponent implements OnInit {
bookIds: [bookId], bookIds: [bookId],
}; };
this.bookService.autoRefreshMetadata(request).subscribe(); this.bookService.autoRefreshMetadata(request).subscribe();
setTimeout(() => {
this.isAutoFetching = false;
this.refreshingBookIds.delete(bookId);
}, 15000);
} }
onNext() { onNext() {
@@ -72,8 +72,8 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
header: 'Send Book to Email', header: 'Send Book to Email',
modal: true, modal: true,
closable: true, closable: true,
style: { position: 'absolute', top: '15%' }, style: {position: 'absolute', top: '15%'},
data: { bookId: metadata.bookId } data: {bookId: metadata.bookId}
}); });
} }
} }
@@ -170,6 +170,9 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
bookIds: [bookId], bookIds: [bookId],
}; };
this.bookService.autoRefreshMetadata(request).subscribe(); this.bookService.autoRefreshMetadata(request).subscribe();
setTimeout(() => {
this.isAutoFetching = false;
}, 15000);
} }
quickSend(bookId: number) { quickSend(bookId: number) {
@@ -192,10 +195,10 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
header: `Update Book's Shelves`, header: `Update Book's Shelves`,
modal: true, modal: true,
closable: true, closable: true,
contentStyle: { overflow: 'auto' }, contentStyle: {overflow: 'auto'},
baseZIndex: 10, baseZIndex: 10,
style: { position: 'absolute', top: '15%' }, style: {position: 'absolute', top: '15%'},
data: { book: this.bookService.getBookByIdFromState(bookId) } data: {book: this.bookService.getBookByIdFromState(bookId)}
}); });
} }