adding chat features, admin features and bug fixes
This commit is contained in:
19
frontend/src/services/admin.ts
Normal file
19
frontend/src/services/admin.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { api } from './api';
|
||||
import type { MonitoredService, PingResult, StatusSummary, SystemHealth, UserOverview, BroadcastPayload } from '../types/admin.types';
|
||||
|
||||
interface ApiResponse<T> {
|
||||
success: boolean;
|
||||
data: T;
|
||||
}
|
||||
|
||||
export const adminApi = {
|
||||
getServices: () => api.get<ApiResponse<MonitoredService[]>>('/api/admin/services').then(r => r.data.data),
|
||||
createService: (data: { name: string; url: string }) => api.post<ApiResponse<MonitoredService>>('/api/admin/services', data).then(r => r.data.data),
|
||||
updateService: (id: string, data: Partial<MonitoredService>) => api.put<ApiResponse<MonitoredService>>(`/api/admin/services/${id}`, data).then(r => r.data.data),
|
||||
deleteService: (id: string) => api.delete(`/api/admin/services/${id}`).then(() => undefined),
|
||||
pingAll: () => api.get<ApiResponse<PingResult[]>>('/api/admin/services/ping').then(r => r.data.data),
|
||||
getStatusSummary: () => api.get<ApiResponse<StatusSummary>>('/api/admin/services/status-summary').then(r => r.data.data),
|
||||
getSystemHealth: () => api.get<ApiResponse<SystemHealth>>('/api/admin/system/health').then(r => r.data.data),
|
||||
getUsers: () => api.get<ApiResponse<UserOverview[]>>('/api/admin/users').then(r => r.data.data),
|
||||
broadcast: (data: BroadcastPayload) => api.post<ApiResponse<{ sent: number }>>('/api/admin/notifications/broadcast', data).then(r => r.data.data),
|
||||
};
|
||||
@@ -1,5 +1,5 @@
|
||||
import { api } from './api';
|
||||
import type { BookStackRecentResponse, BookStackSearchResponse } from '../types/bookstack.types';
|
||||
import type { BookStackRecentResponse, BookStackSearchResponse, BookStackPageDetail } from '../types/bookstack.types';
|
||||
|
||||
interface ApiResponse<T> {
|
||||
success: boolean;
|
||||
@@ -14,6 +14,12 @@ export const bookstackApi = {
|
||||
.then((r) => ({ configured: r.data.configured, data: r.data.data }));
|
||||
},
|
||||
|
||||
getPage(id: number): Promise<{ configured: boolean; data: BookStackPageDetail | null }> {
|
||||
return api
|
||||
.get<ApiResponse<BookStackPageDetail | null>>(`/api/bookstack/pages/${id}`)
|
||||
.then((r) => ({ configured: r.data.configured, data: r.data.data }));
|
||||
},
|
||||
|
||||
search(query: string): Promise<BookStackSearchResponse> {
|
||||
return api
|
||||
.get<ApiResponse<BookStackSearchResponse['data']>>('/api/bookstack/search', {
|
||||
|
||||
15
frontend/src/services/config.ts
Normal file
15
frontend/src/services/config.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { api } from './api';
|
||||
import type { ExternalLinks } from '../types/config.types';
|
||||
|
||||
interface ApiResponse<T> {
|
||||
success: boolean;
|
||||
data: T;
|
||||
}
|
||||
|
||||
export const configApi = {
|
||||
getExternalLinks(): Promise<ExternalLinks> {
|
||||
return api
|
||||
.get<ApiResponse<ExternalLinks>>('/api/config/external-links')
|
||||
.then((r) => r.data.data);
|
||||
},
|
||||
};
|
||||
@@ -1,5 +1,5 @@
|
||||
import { api } from './api';
|
||||
import type { NextcloudTalkData, NextcloudConnectData, NextcloudPollData } from '../types/nextcloud.types';
|
||||
import type { NextcloudTalkData, NextcloudConnectData, NextcloudPollData, NextcloudMessage, NextcloudRoomListData } from '../types/nextcloud.types';
|
||||
|
||||
interface ApiResponse<T> {
|
||||
success: boolean;
|
||||
@@ -30,4 +30,28 @@ export const nextcloudApi = {
|
||||
.delete('/api/nextcloud/talk/connect')
|
||||
.then(() => undefined);
|
||||
},
|
||||
|
||||
getRooms(): Promise<NextcloudRoomListData> {
|
||||
return api
|
||||
.get<ApiResponse<NextcloudRoomListData>>('/api/nextcloud/talk/rooms')
|
||||
.then((r) => r.data.data);
|
||||
},
|
||||
|
||||
getMessages(token: string): Promise<NextcloudMessage[]> {
|
||||
return api
|
||||
.get<ApiResponse<NextcloudMessage[]>>(`/api/nextcloud/talk/rooms/${encodeURIComponent(token)}/messages`)
|
||||
.then((r) => r.data.data);
|
||||
},
|
||||
|
||||
sendMessage(token: string, message: string): Promise<void> {
|
||||
return api
|
||||
.post(`/api/nextcloud/talk/rooms/${encodeURIComponent(token)}/messages`, { message })
|
||||
.then(() => undefined);
|
||||
},
|
||||
|
||||
markAsRead(token: string): Promise<void> {
|
||||
return api
|
||||
.post(`/api/nextcloud/talk/rooms/${encodeURIComponent(token)}/read`)
|
||||
.then(() => undefined);
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user