-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update Fuselage and its peer dependencies * Move and split existing hooks * Refactor useEndpointData
- Loading branch information
Showing
24 changed files
with
165 additions
and
198 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
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
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
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
8 changes: 4 additions & 4 deletions
8
...dashboard/client/hooks/useEndpointData.js → client/hooks/useEndpointData.js
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,9 @@ | ||
import { useCallback } from 'react'; | ||
import moment from 'moment'; | ||
|
||
import { useSetting } from '../contexts/SettingsContext'; | ||
|
||
export const useFormatDate = () => { | ||
const format = useSetting('Message_DateFormat'); | ||
return useCallback((time) => moment(time).format(format), [format]); | ||
}; |
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,21 @@ | ||
import { useCallback } from 'react'; | ||
import moment from 'moment'; | ||
|
||
import { useUserPreference } from '../contexts/UserContext'; | ||
import { useSetting } from '../contexts/SettingsContext'; | ||
|
||
export const useFormatDateAndTime = () => { | ||
const clockMode = useUserPreference('clockMode', false); | ||
const format = useSetting('Message_TimeAndDateFormat'); | ||
|
||
return useCallback((time) => { | ||
switch (clockMode) { | ||
case 1: | ||
return moment(time).format('MMMM D, Y h:mm A'); | ||
case 2: | ||
return moment(time).format('MMMM D, Y H:mm'); | ||
default: | ||
return moment(time).format(format); | ||
} | ||
}, [clockMode, format]); | ||
}; |
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,24 @@ | ||
import s from 'underscore.string'; | ||
|
||
const formatMemorySize = (memorySize) => { | ||
if (typeof memorySize !== 'number') { | ||
return null; | ||
} | ||
|
||
const units = ['bytes', 'kB', 'MB', 'GB']; | ||
|
||
let order; | ||
for (order = 0; order < units.length - 1; ++order) { | ||
const upperLimit = Math.pow(1024, order + 1); | ||
|
||
if (memorySize < upperLimit) { | ||
break; | ||
} | ||
} | ||
|
||
const divider = Math.pow(1024, order); | ||
const decimalDigits = order === 0 ? 0 : 2; | ||
return `${ s.numberFormat(memorySize / divider, decimalDigits) } ${ units[order] }`; | ||
}; | ||
|
||
export const useFormatMemorySize = () => formatMemorySize; |
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,22 @@ | ||
import { useCallback } from 'react'; | ||
import moment from 'moment'; | ||
|
||
import { useUserPreference } from '../contexts/UserContext'; | ||
import { useSetting } from '../contexts/SettingsContext'; | ||
|
||
const dayFormat = ['h:mm A', 'H:mm']; | ||
|
||
export const useFormatTime = () => { | ||
const clockMode = useUserPreference('clockMode', false); | ||
const format = useSetting('Message_TimeFormat'); | ||
const sameDay = dayFormat[clockMode - 1] || format; | ||
return useCallback((time) => { | ||
switch (clockMode) { | ||
case 1: | ||
case 2: | ||
return moment(time).format(sameDay); | ||
default: | ||
return moment(time).format(format); | ||
} | ||
}, [clockMode, format]); | ||
}; |
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.