diff --git a/api/controllers/user_controller.ts b/api/controllers/user_controller.ts index ba10809..2587ff0 100644 --- a/api/controllers/user_controller.ts +++ b/api/controllers/user_controller.ts @@ -42,13 +42,23 @@ export default class UserController extends BaseController { @POST() async login(ctx: Koa.Context, @BodyParam body: DtoUser): Promise { - let checkLogin = await UserService.checkUser(body.email, body.password); + const checkLogin = await this.tryLogin(body); + if (!checkLogin.success) { return checkLogin; } SessionService.login(ctx, (checkLogin.result.user).id); + return checkLogin; + } + + private async tryLogin(user: DtoUser) { + let checkLogin = await UserService.checkUser(user.email, user.password); + if (!checkLogin.success) { + return checkLogin; + } + checkLogin.message = Message.get('userLoginSuccess'); (checkLogin.result.user).password = undefined; @@ -58,7 +68,7 @@ export default class UserController extends BaseController { @GET('/user/me') async getUserInfo(ctx: Koa.Context): Promise { const user = (ctx).session.user; - return await this.login(ctx, user); + return await this.tryLogin(user); } @GET('/user/logout') diff --git a/client/src/modules/stress_test/stress_run_diagram.tsx b/client/src/modules/stress_test/stress_run_diagram.tsx index a174555..3e68989 100644 --- a/client/src/modules/stress_test/stress_run_diagram.tsx +++ b/client/src/modules/stress_test/stress_run_diagram.tsx @@ -162,7 +162,7 @@ class StressRunDiagram extends React.Component LocalesString.get(`Common.${s}`)).concat(['ErrRatio', 'TestFailed', 'NoResponse', 'ServerError500'].map(s => LocalesString.get(`Stress.${s}`))); - const dataIndexs = ['averageDns', 'averageConnect', 'averageRequest', 'high', 'low', 'stddev', 'p95', 'p90', 'p75', 'p50', 'errRatio', 'testFailed', 'noRes', 'm500']; + const errDataIndexs = ['errRatio', 'testFailed', 'noRes', 'm500']; + const dataIndexs = ['averageDns', 'averageConnect', 'averageRequest', 'high', 'low', 'stddev', 'p95', 'p90', 'p75', 'p50'].concat(errDataIndexs); const keys = Object.keys(runState.stressReqDuration); const dataSource = keys.map(d => { @@ -367,7 +368,7 @@ class StressRunDiagram extends React.Component _.round((text || 0), 2)} + render={(text, record) => this.highlightCellIfNeed(text, errDataIndexs, dataIndexs[i])} />)) } @@ -375,6 +376,10 @@ class StressRunDiagram extends React.Component { + return text > 0 && errDataIndexs.some(e => e === index) ? ({_.round((text || 0), 2)}) : _.round((text || 0), 2); + } + private generateExcel = () => { const { name, runDate } = this.props; var link = document.createElement('a');