Skip to content

Commit

Permalink
update(console): optimize log font, add missing auth (#2337)
Browse files Browse the repository at this point in the history
  • Loading branch information
waynelwz authored Jun 9, 2023
1 parent ff71a9e commit e99ca3f
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 44 deletions.
14 changes: 11 additions & 3 deletions console/packages/starwhale-ui/src/IconFont/fonts/iconfont.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
@font-face {
font-family: "iconfont"; /* Project id 3410006 */
src: url('iconfont.woff2?t=1684302879106') format('woff2'),
url('iconfont.woff?t=1684302879106') format('woff'),
url('iconfont.ttf?t=1684302879106') format('truetype');
src: url('iconfont.woff2?t=1686280722163') format('woff2'),
url('iconfont.woff?t=1686280722163') format('woff'),
url('iconfont.ttf?t=1686280722163') format('truetype');
}

.iconfont {
Expand All @@ -13,6 +13,14 @@
-moz-osx-font-smoothing: grayscale;
}

.icon-vscode:before {
content: "\e66b";
}

.icon-WeChat2:before {
content: "\e66a";
}

.icon-layout-1:before {
content: "\e667";
}
Expand Down

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions console/packages/starwhale-ui/src/IconFont/fonts/iconfont.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@
"css_prefix_text": "icon-",
"description": "",
"glyphs": [
{
"icon_id": "35913528",
"name": "vscode",
"font_class": "vscode",
"unicode": "e66b",
"unicode_decimal": 58987
},
{
"icon_id": "35869570",
"name": "WeChat2",
"font_class": "WeChat2",
"unicode": "e66a",
"unicode_decimal": 58986
},
{
"icon_id": "35478546",
"name": "layout-1",
Expand Down
4 changes: 2 additions & 2 deletions console/packages/starwhale-ui/src/IconFont/fonts/iconfont.ttf
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
3 changes: 3 additions & 0 deletions console/packages/starwhale-ui/src/IconFont/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ export type IconTypesT =
| 'layout-1'
| 'layout-2'
| 'layout-3'
| 'WeChat'
| 'WeChat2'
| 'vscode'

interface IIconFontProps {
style?: React.CSSProperties
Expand Down
8 changes: 7 additions & 1 deletion console/src/components/LogViewer/LogView.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
.pf-c-log-viewer {
--pf-c-log-viewer__text--FontSize: 16px;
// --pf-c-log-viewer__text--FontSize: 12px;
// --pf-c-log-viewer__text--FontFamily: 'Monaco', monospace;
// --pf-c-log-viewer__index--FontFamily: 'Monaco', monospace;
--pf-c-button--LineHeight: 1;
.pf-c-log-viewer__list {
font-size: 12px;
font-family: 'Roboto Mono', monospace;
}

.pf-c-log-viewer__scroll-container {
&::-webkit-scrollbar {
Expand Down
16 changes: 12 additions & 4 deletions console/src/pages/Evaluation/EvaluationOverviewLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,26 +80,34 @@ function EvaluationOverviewLayout({ children }: IJobLayoutProps) {
<>
<Button onClick={() => handleAction(job.id, JobActionType.CANCEL)}>{t('Cancel')}</Button>
&nbsp;&nbsp;
<Button onClick={() => handleAction(job.id, JobActionType.PAUSE)}>{t('Pause')}</Button>
<WithCurrentAuth id='job-pause'>
<Button onClick={() => handleAction(job.id, JobActionType.PAUSE)}>{t('Pause')}</Button>
</WithCurrentAuth>
</>
),
[JobStatusType.RUNNING]: (
<>
<Button onClick={() => handleAction(job.id, JobActionType.CANCEL)}>{t('Cancel')}</Button>
&nbsp;&nbsp;
<Button onClick={() => handleAction(job.id, JobActionType.PAUSE)}>{t('Pause')}</Button>
<WithCurrentAuth id='job-pause'>
<Button onClick={() => handleAction(job.id, JobActionType.PAUSE)}>{t('Pause')}</Button>
</WithCurrentAuth>
</>
),
[JobStatusType.PAUSED]: (
<>
<Button onClick={() => handleAction(job.id, JobActionType.CANCEL)}>{t('Cancel')}</Button>
&nbsp;&nbsp;
<Button onClick={() => handleAction(job.id, JobActionType.RESUME)}>{t('Resume')}</Button>
<WithCurrentAuth id='job-resume'>
<Button onClick={() => handleAction(job.id, JobActionType.RESUME)}>{t('Resume')}</Button>
</WithCurrentAuth>
</>
),
[JobStatusType.FAIL]: (
<>
<Button onClick={() => handleAction(job.id, JobActionType.RESUME)}>{t('Resume')}</Button>
<WithCurrentAuth id='job-resume'>
<Button onClick={() => handleAction(job.id, JobActionType.RESUME)}>{t('Resume')}</Button>
</WithCurrentAuth>
</>
),
}
Expand Down
60 changes: 31 additions & 29 deletions console/src/pages/Job/TaskListCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import qs from 'qs'
import moment from 'moment'
import JobStatus from '@/domain/job/components/JobStatus'
import { WithCurrentAuth } from '@/api/WithAuth'
import { IconFont } from '@starwhale/ui'

export interface ITaskListCardProps {
header: React.ReactNode
Expand Down Expand Up @@ -46,7 +47,6 @@ export default function TaskListCard({ header, onAction }: ITaskListCardProps) {
t('Task ID'),
t('Step'),
t('Resource Pool'),
t('Debug'),
t('Started'),
t('End Time'),
t('Duration'),
Expand All @@ -59,41 +59,43 @@ export default function TaskListCard({ header, onAction }: ITaskListCardProps) {
task.id,
task.stepName,
task.resourcePool,
<WithCurrentAuth id='job-dev' key='devUrl'>
{(bool: boolean) =>
bool && task.devUrl ? (
<a target='_blank' href={task.devUrl} rel='noreferrer'>
{t('To Debug')}
</a>
) : (
'-'
)
}
</WithCurrentAuth>,
task.startedTime && formatTimestampDateTime(task.startedTime),
task.finishedTime && formatTimestampDateTime(task.finishedTime),
task.finishedTime && task.startedTime && task.finishedTime !== -1 && task.startedTime !== -1
? moment.duration(task.finishedTime - task.startedTime, 'milliseconds').humanize()
: '-',
<JobStatus key='status' status={task.taskStatus as any} />,
<StyledLink
key={task.uuid}
onClick={(e: any) => {
// eslint-disalbe-next-line no-unused-expressions
const trDom = e.currentTarget.closest('tr')
const trDoms = trDom?.parentElement?.children
_.forEach(trDoms, (d) => {
d?.classList.remove('tr--selected')
})
trDom?.classList.add('tr--selected')
<p key='action' style={{ display: 'flex', gap: '10px' }}>
<StyledLink
key={task.uuid}
onClick={(e: any) => {
// eslint-disalbe-next-line no-unused-expressions
const trDom = e.currentTarget.closest('tr')
const trDoms = trDom?.parentElement?.children
_.forEach(trDoms, (d) => {
d?.classList.remove('tr--selected')
})
trDom?.classList.add('tr--selected')

onAction?.('viewlog', {
...task,
})
}}
>
{t('View Log')}
</StyledLink>,
onAction?.('viewlog', {
...task,
})
}}
>
{t('View Log')}
</StyledLink>
<WithCurrentAuth id='job-dev' key='devUrl'>
{(bool: boolean) =>
bool && task.devUrl ? (
<a target='_blank' href={task.devUrl} rel='noreferrer' title='debug'>
<IconFont type='vscode' size={14} />
</a>
) : (
''
)
}
</WithCurrentAuth>
</p>,
]
}) ?? []
}
Expand Down

0 comments on commit e99ca3f

Please sign in to comment.