Skip to content

Commit

Permalink
fix(overview): only enable flex-row layout on large screen
Browse files Browse the repository at this point in the history
  • Loading branch information
kunish committed Sep 3, 2023
1 parent bf340e2 commit be8b54a
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 29 deletions.
15 changes: 7 additions & 8 deletions src/components/ProxyPreviewBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const ProxyPreviewBar = (props: {
const latencyList = createMemo(() =>
props.proxyNameList.map((name) => latencyMap()[name]),
)

const all = createMemo(() => latencyList().length)
const good = createMemo(
() =>
Expand All @@ -35,9 +36,7 @@ export const ProxyPreviewBar = (props: {
const notConnected = createMemo(
() =>
latencyList().filter(
(latency) =>
latency === latencyQualityMap().NOT_CONNECTED ||
typeof latency !== 'number',
(latency) => latency === latencyQualityMap().NOT_CONNECTED,
).length,
)

Expand All @@ -47,27 +46,27 @@ export const ProxyPreviewBar = (props: {
<div
class="h-2 bg-success"
style={{
width: `${(good() * 100) / all()}%`, // cant use tw class cause dynamic classname wont import
width: `${(good() * 100) / all()}%`, // cant use tw class, otherwise dynamic classname won't be generated
}}
></div>
/>
<div
class="h-2 bg-warning"
style={{
width: `${(middle() * 100) / all()}%`,
}}
></div>
/>
<div
class="h-2 bg-error"
style={{
width: `${(slow() * 100) / all()}%`,
}}
></div>
/>
<div
class="h-2 bg-neutral"
style={{
width: `${(notConnected() * 100) / all()}%`,
}}
></div>
/>
</div>

<Latency name={props.now} />
Expand Down
23 changes: 14 additions & 9 deletions src/components/ProxyPreviewDots.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,27 @@ import { For } from 'solid-js'
import { twMerge } from 'tailwind-merge'
import { latencyQualityMap, useProxies } from '~/signals'

const LatencyDots = (p: { latency: number | undefined; selected: boolean }) => {
let dotClassName = p.selected
const LatencyDots = (props: {
latency: number | undefined
selected: boolean
}) => {
let dotClassName = props.selected
? 'bg-white border-4 border-success'
: 'bg-success'

if (
typeof p.latency !== 'number' ||
p.latency === latencyQualityMap().NOT_CONNECTED
typeof props.latency !== 'number' ||
props.latency === latencyQualityMap().NOT_CONNECTED
) {
dotClassName = p.selected
dotClassName = props.selected
? 'bg-white border-4 border-neutral'
: 'bg-neutral'
} else if (p.latency > latencyQualityMap().HIGH) {
dotClassName = p.selected ? 'bg-white border-4 border-error' : 'bg-error'
} else if (p.latency > latencyQualityMap().MEDIUM) {
dotClassName = p.selected
} else if (props.latency > latencyQualityMap().HIGH) {
dotClassName = props.selected
? 'bg-white border-4 border-error'
: 'bg-error'
} else if (props.latency > latencyQualityMap().MEDIUM) {
dotClassName = props.selected
? 'bg-white border-4 border-warning'
: 'bg-warning'
}
Expand Down
8 changes: 4 additions & 4 deletions src/pages/Config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ const ConfigForm = () => {
})

const [updatingGEODatabases, setUpdatingGEODatabases] = createSignal(false)
const [upgraging, setUpgraging] = createSignal(false)
const [upgrading, setUpgrading] = createSignal(false)
const [restarting, setRestarting] = createSignal(false)

const onUpdateGEODatabases = async () => {
Expand All @@ -145,11 +145,11 @@ const ConfigForm = () => {
}

const onUpgrade = async () => {
setUpgraging(true)
setUpgrading(true)
try {
await request.post('upgrade')
} catch {}
setUpgraging(false)
setUpgrading(false)
}

const onRestart = async () => {
Expand Down Expand Up @@ -190,7 +190,7 @@ const ConfigForm = () => {
{t('restartCore')}
</Button>

<Button loading={upgraging()} onClick={onUpgrade}>
<Button loading={upgrading()} onClick={onUpgrade}>
{t('upgradeCore')}
</Button>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default () => {
const [memories, setMemories] = createSignal<number[]>([])

// https://github.com/apexcharts/apexcharts.js/blob/main/samples/source/line/realtime.xml
// TODO: need a better way
// TODO: needs a better way
makeTimer(
() => {
setTraffics((traffics) => traffics.slice(-CHART_MAX_XAXIS))
Expand Down Expand Up @@ -152,7 +152,7 @@ export default () => {
</TrafficWidget>
</div>

<div class="rounded-box flex flex-col bg-base-300 sm:flex-row">
<div class="rounded-box flex flex-col bg-base-300 lg:flex-row">
<div class="m-4 flex-1">
<SolidApexCharts
type="area"
Expand Down
4 changes: 1 addition & 3 deletions src/pages/Rules.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ export default () => {
const [maxRuleRender, setMaxRuleRender] = createSignal(100)
const renderRules = createMemo(() => rules().slice(0, maxRuleRender()))

onMount(async () => {
updateRules()
})
onMount(updateRules)

const onUpdateProviderClick = async (e: MouseEvent, name: string) => {
const el = getBtnElFromClickEvent(e)
Expand Down
6 changes: 3 additions & 3 deletions src/pages/Setup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export default () => {

const { form } = createForm<z.infer<typeof schema>>({
extend: validator({ schema }),
onSubmit: onSubmit,
onSubmit,
})

const onRemove = (id: string) =>
Expand All @@ -88,14 +88,14 @@ export default () => {
const query = new URLSearchParams(window.location.search)

if (query.has('hostname')) {
onSubmit({
void onSubmit({
url: `http://${query.get('hostname')}${
query.get('port') && ':' + query.get('port')
}`,
secret: query.get('secret') ?? '',
})
} else {
onSubmit({
void onSubmit({
url: 'http://127.0.0.1:9090',
secret: '',
})
Expand Down

0 comments on commit be8b54a

Please sign in to comment.