️ improve: channel add used

This commit is contained in:
MartialBE 2024-04-05 16:16:22 +08:00
parent 3c302279ef
commit 3cf92daef5
No known key found for this signature in database
GPG Key ID: F5A7AC860020C896
4 changed files with 50 additions and 51 deletions

View File

@ -263,8 +263,8 @@ func GetChannelExpensesByPeriod(startTimestamp, endTimestamp int64) (LogStatisti
JOIN channels ON logs.channel_id = channels.id JOIN channels ON logs.channel_id = channels.id
WHERE logs.type=2 WHERE logs.type=2
AND logs.created_at BETWEEN ? AND ? AND logs.created_at BETWEEN ? AND ?
GROUP BY date, channels.name GROUP BY date, channels.id
ORDER BY date, channels.name ORDER BY date, channels.id
`, startTimestamp, endTimestamp).Scan(&LogStatistics).Error `, startTimestamp, endTimestamp).Scan(&LogStatistics).Error
return LogStatistics, err return LogStatistics, err

View File

@ -37,7 +37,7 @@ import { IconDotsVertical, IconEdit, IconTrash, IconCopy, IconWorldWww } from '@
import { styled, alpha } from '@mui/material/styles'; import { styled, alpha } from '@mui/material/styles';
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown'; import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
import KeyboardArrowUpIcon from '@mui/icons-material/KeyboardArrowUp'; import KeyboardArrowUpIcon from '@mui/icons-material/KeyboardArrowUp';
import { copy } from 'utils/common'; import { copy, renderQuota } from 'utils/common';
const StyledMenu = styled((props) => ( const StyledMenu = styled((props) => (
<Menu <Menu
@ -233,6 +233,7 @@ export default function ChannelTableRow({ item, manageChannel, handleOpenModal,
{renderBalance(item.type, itemBalance)} {renderBalance(item.type, itemBalance)}
</Tooltip> </Tooltip>
</TableCell> </TableCell>
<TableCell>{renderQuota(item.used_quota)}</TableCell>
<TableCell> <TableCell>
<TextField <TextField
id={`priority-${item.id}`} id={`priority-${item.id}`}
@ -350,7 +351,7 @@ export default function ChannelTableRow({ item, manageChannel, handleOpenModal,
))} ))}
</StyledMenu> </StyledMenu>
<TableRow> <TableRow>
<TableCell style={{ paddingBottom: 0, paddingTop: 0, textAlign: 'left' }} colSpan={11}> <TableCell style={{ paddingBottom: 0, paddingTop: 0, textAlign: 'left' }} colSpan={12}>
<Collapse in={openRow} timeout="auto" unmountOnExit> <Collapse in={openRow} timeout="auto" unmountOnExit>
<Grid container spacing={1}> <Grid container spacing={1}>
<Grid item xs={12}> <Grid item xs={12}>

View File

@ -387,6 +387,7 @@ export default function ChannelPage() {
{ id: 'status', label: '状态', disableSort: false }, { id: 'status', label: '状态', disableSort: false },
{ id: 'response_time', label: '响应时间', disableSort: false }, { id: 'response_time', label: '响应时间', disableSort: false },
{ id: 'balance', label: '余额', disableSort: false }, { id: 'balance', label: '余额', disableSort: false },
{ id: 'used', label: '已使用', disableSort: false },
{ id: 'priority', label: '优先级', disableSort: false, width: '80px' }, { id: 'priority', label: '优先级', disableSort: false, width: '80px' },
{ id: 'weight', label: '权重', disableSort: false, width: '80px' }, { id: 'weight', label: '权重', disableSort: false, width: '80px' },
{ id: 'action', label: '操作', disableSort: true } { id: 'action', label: '操作', disableSort: true }

View File

@ -100,53 +100,6 @@ export default function TableToolBar({ filterName, handleFilterName, userIsAdmin
/> />
</LocalizationProvider> </LocalizationProvider>
</FormControl> </FormControl>
</Stack>
<Stack direction={{ xs: 'column', sm: 'row' }} spacing={{ xs: 3, sm: 2, md: 4 }} padding={'24px'}>
{userIsAdmin && (
<FormControl>
<InputLabel htmlFor="channel-channel-label">渠道ID</InputLabel>
<OutlinedInput
id="channel"
name="channel"
sx={{
minWidth: '100%'
}}
label="渠道ID"
value={filterName.channel}
onChange={handleFilterName}
placeholder="渠道ID"
startAdornment={
<InputAdornment position="start">
<IconSitemap stroke={1.5} size="20px" color={grey500} />
</InputAdornment>
}
/>
</FormControl>
)}
{userIsAdmin && (
<FormControl>
<InputLabel htmlFor="channel-username-label">用户名称</InputLabel>
<OutlinedInput
id="username"
name="username"
sx={{
minWidth: '100%'
}}
label="用户名称"
value={filterName.username}
onChange={handleFilterName}
placeholder="用户名称"
startAdornment={
<InputAdornment position="start">
<IconUser stroke={1.5} size="20px" color={grey500} />
</InputAdornment>
}
/>
</FormControl>
)}
<FormControl sx={{ minWidth: '22%' }}> <FormControl sx={{ minWidth: '22%' }}>
<InputLabel htmlFor="channel-type-label">类型</InputLabel> <InputLabel htmlFor="channel-type-label">类型</InputLabel>
<Select <Select
@ -176,6 +129,50 @@ export default function TableToolBar({ filterName, handleFilterName, userIsAdmin
</Select> </Select>
</FormControl> </FormControl>
</Stack> </Stack>
{userIsAdmin && (
<Stack direction={{ xs: 'column', sm: 'row' }} spacing={{ xs: 3, sm: 2, md: 4 }} padding={'24px'}>
<FormControl>
<InputLabel htmlFor="channel-channel-label">渠道ID</InputLabel>
<OutlinedInput
id="channel"
name="channel"
sx={{
minWidth: '100%'
}}
label="渠道ID"
value={filterName.channel}
onChange={handleFilterName}
placeholder="渠道ID"
startAdornment={
<InputAdornment position="start">
<IconSitemap stroke={1.5} size="20px" color={grey500} />
</InputAdornment>
}
/>
</FormControl>
<FormControl>
<InputLabel htmlFor="channel-username-label">用户名称</InputLabel>
<OutlinedInput
id="username"
name="username"
sx={{
minWidth: '100%'
}}
label="用户名称"
value={filterName.username}
onChange={handleFilterName}
placeholder="用户名称"
startAdornment={
<InputAdornment position="start">
<IconUser stroke={1.5} size="20px" color={grey500} />
</InputAdornment>
}
/>
</FormControl>
</Stack>
)}
</> </>
); );
} }