Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/brookshi/Hitchhiker
Browse files Browse the repository at this point in the history
  • Loading branch information
brookshi committed Jun 15, 2018
2 parents bb292c9 + c70e4f9 commit db32b97
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
14 changes: 12 additions & 2 deletions api/controllers/user_controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,23 @@ export default class UserController extends BaseController {

@POST()
async login(ctx: Koa.Context, @BodyParam body: DtoUser): Promise<ResObject> {
let checkLogin = await UserService.checkUser(body.email, body.password);
const checkLogin = await this.tryLogin(body);

if (!checkLogin.success) {
return checkLogin;
}

SessionService.login(ctx, (<User>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');
(<User>checkLogin.result.user).password = undefined;

Expand All @@ -58,7 +68,7 @@ export default class UserController extends BaseController {
@GET('/user/me')
async getUserInfo(ctx: Koa.Context): Promise<ResObject> {
const user = <User>(<any>ctx).session.user;
return await this.login(ctx, user);
return await this.tryLogin(user);
}

@GET('/user/logout')
Expand Down
11 changes: 8 additions & 3 deletions client/src/modules/stress_test/stress_run_diagram.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class StressRunDiagram extends React.Component<StressRunDiagramProps, StressRunD
type: 'scatter',
symbol: 'rect',
silent: true,
symbolSize: [30, 3],
symbolSize: [30 * 20 / names.length, 3],
z: 20
};
return {
Expand Down Expand Up @@ -326,7 +326,8 @@ class StressRunDiagram extends React.Component<StressRunDiagramProps, StressRunD

const titles = ['AverageDNS', 'AverageConnect', 'AverageRequest', 'Max', 'Min', 'Stddev', 'p95', 'p90', 'p75', 'p50'].map(s => 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<StressTableDisplay>(d => {
Expand Down Expand Up @@ -367,14 +368,18 @@ class StressRunDiagram extends React.Component<StressRunDiagramProps, StressRunD
key={t}
title={t}
dataIndex={dataIndexs[i]}
render={(text, record) => _.round((text || 0), 2)}
render={(text, record) => this.highlightCellIfNeed(text, errDataIndexs, dataIndexs[i])}
/>))
}
</StressTable>
</div>
);
}

private highlightCellIfNeed = (text: number, errDataIndexs: string[], index: string) => {
return text > 0 && errDataIndexs.some(e => e === index) ? (<span style={{ color: 'red', fontWeight: 'bold' }}>{_.round((text || 0), 2)}</span>) : _.round((text || 0), 2);
}

private generateExcel = () => {
const { name, runDate } = this.props;
var link = document.createElement('a');
Expand Down

0 comments on commit db32b97

Please sign in to comment.