mirror of https://github.com/doccano/doccano.git
14 changed files with 253 additions and 18 deletions
Split View
Diff Options
-
0backend/3.9
-
3backend/api/urls.py
-
34backend/api/views.py
-
8backend/users/serializers.py
-
66frontend/components/auth/FormRegister.vue
-
2frontend/components/user/UserList.vue
-
6frontend/domain/models/user/user.ts
-
2frontend/i18n/en/rules.js
-
49frontend/mixins/databaseHealthMixin.js
-
11frontend/repositories/auth/apiAuthRepository.ts
-
7frontend/repositories/user/apiUserRepository.ts
-
26frontend/services/database.service.js
-
53frontend/store/auth.js
-
4yarn.lock
@ -1,7 +1,8 @@ |
|||
from django.urls import path |
|||
|
|||
from .views import TaskStatus |
|||
from .views import TaskStatus, DatabaseHealthCheck |
|||
|
|||
urlpatterns = [ |
|||
path(route="tasks/status/<task_id>", view=TaskStatus.as_view(), name="task_status"), |
|||
path(route="database/health", view=DatabaseHealthCheck.as_view(), name="database_health"), |
|||
] |
@ -0,0 +1,49 @@ |
|||
import DatabaseService from '@/services/database.service' |
|||
|
|||
export const databaseHealthMixin = { |
|||
data() { |
|||
return { |
|||
isDatabaseHealthy: true, |
|||
databaseMessage: '', |
|||
healthCheckInterval: null |
|||
} |
|||
}, |
|||
|
|||
mounted() { |
|||
this.startHealthCheck() |
|||
}, |
|||
|
|||
beforeDestroy() { |
|||
this.stopHealthCheck() |
|||
}, |
|||
|
|||
methods: { |
|||
async checkDatabaseHealth() { |
|||
try { |
|||
const result = await DatabaseService.checkHealth() |
|||
this.isDatabaseHealthy = result.isHealthy |
|||
this.databaseMessage = result.message |
|||
} catch (error) { |
|||
this.isDatabaseHealthy = false |
|||
this.databaseMessage = 'Base de dados não disponível, por favor tente mais tarde.' |
|||
} |
|||
}, |
|||
|
|||
startHealthCheck() { |
|||
// Verificação inicial
|
|||
this.checkDatabaseHealth() |
|||
|
|||
// Verificação a cada 10 segundos
|
|||
this.healthCheckInterval = setInterval(() => { |
|||
this.checkDatabaseHealth() |
|||
}, 10000) |
|||
}, |
|||
|
|||
stopHealthCheck() { |
|||
if (this.healthCheckInterval) { |
|||
clearInterval(this.healthCheckInterval) |
|||
this.healthCheckInterval = null |
|||
} |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,26 @@ |
|||
import ApiService from './api.service' |
|||
|
|||
class DatabaseService { |
|||
async checkHealth() { |
|||
try { |
|||
console.log('DatabaseService: Calling /database/health endpoint') |
|||
const response = await ApiService.get('/database/health') |
|||
console.log('DatabaseService: Response received:', response.data) |
|||
return { |
|||
isHealthy: response.data.status === 'healthy', |
|||
message: response.data.message, |
|||
status: response.data.status |
|||
} |
|||
} catch (error) { |
|||
console.error('DatabaseService: Error calling health endpoint:', error) |
|||
console.error('DatabaseService: Error response:', error.response) |
|||
return { |
|||
isHealthy: false, |
|||
message: 'Base de dados não disponível, por favor tente mais tarde.', |
|||
status: 'unhealthy' |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
export default new DatabaseService() |
@ -0,0 +1,4 @@ |
|||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. |
|||
# yarn lockfile v1 |
|||
|
|||
|
Write
Preview
Loading…
Cancel
Save