-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6f6b096
commit d7e3af9
Showing
24 changed files
with
373 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import {ActivityIndicator} from 'react-native'; | ||
|
||
import {BaseView} from './baseView'; | ||
|
||
export const LoadingView = () => { | ||
return ( | ||
<BaseView className="flex-1"> | ||
<ActivityIndicator size={'large'} /> | ||
</BaseView> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export * from './useCameraEvents'; | ||
export * from './useConfig'; | ||
export * from './useRecordings'; | ||
export * from './useRecordingSummary'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import {getTimeZone} from 'react-native-localize'; | ||
import {useQuery} from 'react-query'; | ||
|
||
import {API_BASE} from '@env'; | ||
|
||
import {RecordingResponse} from '../types/recordings'; | ||
|
||
const URL = `${API_BASE}api/:camera/recordings/summary?timezone=:tz`; | ||
|
||
const fetchRecordingSummary = async (cameraName: string) => { | ||
const url = URL.replace(':camera', cameraName).replace(':tz', getTimeZone()); | ||
try { | ||
const response = await fetch(url, {method: 'get'}); | ||
const data = await response.json(); | ||
if (response.ok) { | ||
if (data) { | ||
return Promise.resolve(data as RecordingResponse[]); | ||
} | ||
} else { | ||
return Promise.reject(new Error('ResNotOK')); | ||
} | ||
} catch (e) { | ||
return Promise.reject(e); | ||
} | ||
}; | ||
|
||
export const useRecordingSummary = (cameraName?: string) => { | ||
return useQuery({ | ||
queryFn: () => fetchRecordingSummary(cameraName || ''), | ||
queryKey: ['recordings', cameraName], | ||
enabled: !!cameraName, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import {useQuery} from 'react-query'; | ||
|
||
import {API_BASE} from '@env'; | ||
|
||
// const buildEventUrl = (eventId: string) => { | ||
// const REC_URL = `${API_BASE}vod/event/${eventId}/index.m3u8`; | ||
// return REC_URL; | ||
// }; | ||
|
||
const URL = `${API_BASE}api/:camera/recordings`; | ||
|
||
const fetchRecordings = async (cameraName: string) => { | ||
const url = URL.replace(':camera', cameraName); | ||
try { | ||
const response = await fetch(url, {method: 'get'}); | ||
const data = await response.json(); | ||
if (response.ok) { | ||
if (data) { | ||
return Promise.resolve(data); | ||
} | ||
} else { | ||
return Promise.reject(new Error('ResNotOK')); | ||
} | ||
} catch (e) { | ||
return Promise.reject(e); | ||
} | ||
}; | ||
|
||
export const useRecordings = (cameraName?: string) => | ||
useQuery({ | ||
queryFn: () => fetchRecordings(cameraName || ''), | ||
queryKey: ['recordings', cameraName], | ||
enabled: !!cameraName, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export interface RecordingResponse { | ||
day: string; | ||
events: number; | ||
hours?: HoursEntity[] | null; | ||
} | ||
|
||
export interface HoursEntity { | ||
duration: number; | ||
events: number; | ||
hour: string; | ||
motion: number; | ||
objects: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.