mirror of
https://github.com/Myxelium/Bridge-Multi.git
synced 2026-07-07 18:45:09 +00:00
Added database connection error handling
This commit is contained in:
@@ -1,9 +1,10 @@
|
|||||||
<div class="ui bottom attached borderless menu">
|
<div class="ui bottom attached borderless menu">
|
||||||
<div class="item">
|
<div class="item">
|
||||||
<!-- TODO: add advanced search -->
|
<!-- TODO: add advanced search -->
|
||||||
<div class="ui icon input" [class.loading]="searchService.isLoading()">
|
<div class="ui icon input" [class.loading]="isLoading()">
|
||||||
<input #searchBox type="text" placeholder=" Search..." (keyup.enter)="onSearch(searchBox.value)">
|
<input #searchBox type="text" placeholder=" Search..." (keyup.enter)="onSearch(searchBox.value)">
|
||||||
<i class="search icon"></i>
|
<i id="searchIcon" class="link icon" [ngClass]="isError ? 'red exclamation triangle' : 'search'"
|
||||||
|
data-content="Failed to connect to the Bridge database" data-position="bottom right"></i>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- <div #typeDropdown class="ui item dropdown">
|
<!-- <div #typeDropdown class="ui item dropdown">
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
#searchIcon {
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
@@ -8,13 +8,25 @@ import { SearchService } from 'src/app/core/services/search.service'
|
|||||||
})
|
})
|
||||||
export class SearchBarComponent implements AfterViewInit {
|
export class SearchBarComponent implements AfterViewInit {
|
||||||
|
|
||||||
|
isError = false
|
||||||
|
|
||||||
constructor(public searchService: SearchService) { }
|
constructor(public searchService: SearchService) { }
|
||||||
|
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
$('.ui.dropdown').dropdown()
|
$('.ui.dropdown').dropdown()
|
||||||
|
$('#searchIcon').popup({
|
||||||
|
onShow: () => this.isError // Only show the popup if there is an error
|
||||||
|
})
|
||||||
|
this.searchService.onSearchError(() => {
|
||||||
|
this.isError = true
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
onSearch(query: string) {
|
onSearch(query: string) {
|
||||||
this.searchService.newSearch(query)
|
this.searchService.newSearch(query)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isLoading() {
|
||||||
|
return this.searchService.isLoading()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -21,7 +21,12 @@ export class SearchService {
|
|||||||
if (this.awaitingResults) { return }
|
if (this.awaitingResults) { return }
|
||||||
this.awaitingResults = true
|
this.awaitingResults = true
|
||||||
this.currentQuery = { query, type: SearchType.Any, offset: 0, length: 50 + 1 } // TODO: make length a setting
|
this.currentQuery = { query, type: SearchType.Any, offset: 0, length: 50 + 1 } // TODO: make length a setting
|
||||||
this.results = this.trimLastChart(await this.electronService.invoke('song-search', this.currentQuery))
|
try {
|
||||||
|
this.results = this.trimLastChart(await this.electronService.invoke('song-search', this.currentQuery))
|
||||||
|
} catch (err) {
|
||||||
|
this.results = []
|
||||||
|
this.resultsChangedEmitter.error(undefined)
|
||||||
|
}
|
||||||
this.awaitingResults = false
|
this.awaitingResults = false
|
||||||
|
|
||||||
this.resultsChangedEmitter.emit(this.results)
|
this.resultsChangedEmitter.emit(this.results)
|
||||||
@@ -49,6 +54,14 @@ export class SearchService {
|
|||||||
this.newResultsEmitter.subscribe(callback)
|
this.newResultsEmitter.subscribe(callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event emitted when a search fails.
|
||||||
|
* (emitted before `onSearchChanged`)
|
||||||
|
*/
|
||||||
|
onSearchError(callback: () => void) {
|
||||||
|
this.resultsChangedEmitter.subscribe(() => { /** Do nothing */ }, callback)
|
||||||
|
}
|
||||||
|
|
||||||
get resultCount() {
|
get resultCount() {
|
||||||
return this.results.length
|
return this.results.length
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,13 +28,11 @@ class UpdateChecker {
|
|||||||
|
|
||||||
private registerUpdaterListeners() {
|
private registerUpdaterListeners() {
|
||||||
autoUpdater.on('error', (err: Error) => {
|
autoUpdater.on('error', (err: Error) => {
|
||||||
console.log('error callback', err)
|
|
||||||
emitIPCEvent('update-error', err)
|
emitIPCEvent('update-error', err)
|
||||||
})
|
})
|
||||||
|
|
||||||
autoUpdater.on('update-available', (info: UpdateInfo) => {
|
autoUpdater.on('update-available', (info: UpdateInfo) => {
|
||||||
updateAvailable = true
|
updateAvailable = true
|
||||||
console.log('update available callback', info)
|
|
||||||
emitIPCEvent('update-available', info)
|
emitIPCEvent('update-available', info)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -68,8 +66,7 @@ class GetCurrentVersionHandler implements IPCInvokeHandler<'get-current-version'
|
|||||||
* @returns the current version of Bridge.
|
* @returns the current version of Bridge.
|
||||||
*/
|
*/
|
||||||
handler() {
|
handler() {
|
||||||
console.log('Printing version:', autoUpdater.currentVersion.raw)
|
return autoUpdater.currentVersion.raw
|
||||||
return autoUpdater.currentVersion.raw // TODO: display this on the about page
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import * as path from 'path'
|
import { join } from 'path'
|
||||||
import { app } from 'electron'
|
import { app } from 'electron'
|
||||||
|
|
||||||
// Data paths
|
// Data paths
|
||||||
export const dataPath = path.join(app.getPath('userData'), 'bridge_data')
|
export const dataPath = join(app.getPath('userData'), 'bridge_data')
|
||||||
export const libraryPath = path.join(dataPath, 'library.db')
|
export const libraryPath = join(dataPath, 'library.db')
|
||||||
export const settingsPath = path.join(dataPath, 'settings.json')
|
export const settingsPath = join(dataPath, 'settings.json')
|
||||||
export const tempPath = path.join(dataPath, 'temp')
|
export const tempPath = join(dataPath, 'temp')
|
||||||
export const themesPath = path.join(dataPath, 'themes')
|
export const themesPath = join(dataPath, 'themes')
|
||||||
|
|
||||||
// URL
|
// URL
|
||||||
export const serverURL = '64.53.210.87'
|
export const serverURL = 'bridge-db.net'
|
||||||
Reference in New Issue
Block a user