--- /dev/null
+.improve{
+ background-color: #d9f7be;
+}
+.decline{
+ background-color: #ffccc7;
+}
\ No newline at end of file
--- /dev/null
+import React from 'react';
+import './index.css';
+import classNames from 'classnames';
+class ClientBox extends React.Component {
+ constructor(props) {
+ super(props);
+
+ this.state = {
+ isImprove: true,
+ };
+
+ }
+
+ render() {
+ let imgSrc = require('image/client-icon/' + this.props.clientNum + '.png');
+ let std = this.props.std;
+ let median = this.props.median;
+ let boxClass = classNames({
+ 'client-box': true,
+ 'improve': median > std,
+ 'decline': (median <= std)
+ });
+
+ return (
+ <div className={boxClass}>
+ <img src={imgSrc} alt=""/>
+ </div>
+ );
+ }
+}
+
+export default ClientBox;
\ No newline at end of file
// selected: newArr,
isClear: false
});
- this.handleIsLoading();
-
- console.log(this.props.isLoading)
- }
-
- handleIsLoading(e) {
- // console.log(e.target.value)
this.props.onIsLoadingChange(true);
+ this.props.onApplyBtnClick(true);
+ console.log('isLoading:' + this.props.isLoading)
}
resetButtonClick() {
import React from 'react';
// import './index.css';
import ResultFilter from 'component/result-filter/index.jsx';
+import ClientBox from 'component/client-box/index.jsx';
import Pagination from 'util/pagination/index.jsx';
import RateBar from 'util/rate-bar/index.jsx';
import TableList from 'util/table-list/index.jsx';
import Record from 'service/record-service.jsx'
import PGUtil from 'util/util.jsx'
-const _util = new PGUtil();
+const _util = new PGUtil();
const _record = new Record();
class Status extends React.Component {
constructor(props) {
]
},
- this.onPageChange = this.onPageChange.bind(this);
- this.handleIsLoading = this.handleIsLoading.bind(this);
+ this.onPageChange = this.onPageChange.bind(this);
+ this.onIsLoadingChange = this.onIsLoadingChange.bind(this);
+ this.handleApplyBtnClick = this.handleApplyBtnClick.bind(this);
}
componentDidMount() {
this.loadRecordList();
}
+ handleApplyBtnClick() {
+ console.log('apply btn clicked!')
+ this.loadRecordList()
+ }
+
// load record list
loadRecordList() {
+ let _this = this;
let listParam = {};
listParam.filter = this.state.filter;
// listParam.pageNum = this.state.pageNum;
_record.getRecordList(listParam).then(res => {
- console.log('res is:'+ res)
+ console.log('res is:' + res)
this.setState({
- list: res.result
+ list: res.results,
+ isLoading: false
});
+ _this.changeIsLoading(false);
}, errMsg => {
this.setState({
list: []
});
_util.errorTips(errMsg);
+
console.log(errMsg)
+ _this.changeIsLoading(false);
});
+
console.log(this.state.list)
}
});
}
- handleIsLoading(isLoading) {
+ changeIsLoading(flag) {
+ this.setState({
+ isLoading: flag
+ });
+ }
+
+ onIsLoadingChange(flag) {
+ console.log('flag:' + flag)
this.setState({
- isLoading: isLoading
- })
+ isLoading: flag
+ });
+ console.log('status isLoading:' + this.state.isLoading)
}
render() {
};
let listBody = this.state.list.map((machine, index) => {
+ let info = machine.machine_info[0];
+ let info_str = info.os_name + ' ' + info.os_version + ' ' + info.comp_name + ' ' + info.comp_version;
+ let client_max = machine.client_max_num
return (
+
<tr key={index}>
- <td>{machine.alias}</td>
- <td><a href={'mailto:' + machine.email}>{machine.email}</a></td>
+ <td><a href={'#'}>{info.alias}</a></td>
+
+ <td><a href={'#'}>{info_str}</a></td>
+
<td>
- {machine.clients}
+ <div>
+ <ClientBox clientNum="1" std="100" median="200">1</ClientBox>
+ <ClientBox clientNum="2" std="100" median="200">2</ClientBox>
+ <ClientBox clientNum="4" std={100} median={2}>4</ClientBox>
+ </div>
+
+ </td>
+ <td>
+ 1111
{/*<th rowspan="3"></th>*/}
{/*<th rowspan="3">1-2</th>*/}
{/*<th rowspan="2">1-3</th>*/}
{/*<th rowspan="3">1-5</th>*/}
</td>
+ <td rowSpan="2">
+ {machine.clients}
+ {/*<th rowspan="3"></th>*/}
+ {/*<th rowspan="3">1-2</th>*/}
+ {/*<th rowspan="2">1-3</th>*/}
+ {/*<th rowspan="1">1-4</th>*/}
+ {/*<th rowspan="3">1-5</th>*/}
+ </td>
<td>
- <div>
- <p>..</p>
- {/*<RateBar style={{float: 'right', zIndex: 999}} std={this.state.std} curMark={this.state.curMark2}/>*/}
- </div>
+
{/*<div style={{float: 'left'}}> <p>{machine.mark}</p></div>*/}
</td>
<td>{new Date().toDateString()}</td>
</p>
- <ResultFilter isLoading={this.state.isLoading} onIsLoadingChange={this.handleIsLoading}/>
+ <ResultFilter isLoading={this.state.isLoading} onIsLoadingChange={this.onIsLoadingChange}
+ onApplyBtnClick={this.handleApplyBtnClick}/>
- <TableList tableHeads={['alias', 'email', 'clients', 'mark', 'date']}>
+ <TableList tableHeads={['alias', 'System', 'ro', 'rw', 'date']}>
{listBody}
</TableList>
{/*<BasicTable></BasicTable>*/}
data: param.data || null,
success: res => {
// request success
- if (0 === res.status) {
- typeof resolve === 'function' && resolve(res.data, res.msg);
- }
- // nologin force to login
- else if (10 === res.status) {
- this.doLogin();
- }
- else {
- typeof reject === 'function' && reject(res.msg || res.data);
- }
+
+ typeof resolve === 'function' && resolve(res, res.msg);
+ // if (0 === res.status) {
+ // typeof resolve === 'function' && resolve(res.data, res.msg);
+ // }
+ // // nologin force to login
+ // else if (10 === res.status) {
+ // this.doLogin();
+ // }
+ // else {
+ // typeof reject === 'function' && reject(res.msg || res.data);
+ // }
},
error: err => {
typeof reject === 'function' && reject(err.statusText);
from rest_framework import serializers
from test_records.models import TestRecord, TestResult, PGInfo, LinuxInfo ,MetaInfo
+from users.serializer import UserMachineSerializer
+from users.models import UserMachine
from django.db.models import Q
class PGInfoSerializer(serializers.ModelSerializer):
meta_info = MetaInfoSerializer()
ro_info = serializers.SerializerMethodField()
rw_info = serializers.SerializerMethodField()
+ machine_info = serializers.SerializerMethodField()
+ client_max_num = serializers.SerializerMethodField()
class Meta:
model = TestRecord
- fields = "__all__"
+ fields = ('add_time', 'machine_info', 'pg_info', 'linux_info', 'meta_info', 'ro_info', 'rw_info', 'client_max_num')
def get_ro_info(self, obj):
all_data = TestResult.objects.filter(Q(test_record_id=obj.id ) ,test_cate_id=1)
rw_info_serializer = TestResultSerializer(all_data, many=True, context={'request': self.context['request']})
return rw_info_serializer.data
+ def get_machine_info(self, obj):
+ machine_data = UserMachine.objects.filter(Q(id=obj.test_machine_id.id))
+
+ machine_info_serializer = UserMachineSerializer(machine_data,many=True, context={'request': self.context['request']})
+ return machine_info_serializer.data
+
+ def get_client_max_num(self, obj):
+ ro_client_num = TestResult.objects.filter(Q(test_record_id=obj.id ) ,test_cate_id=1).order_by('clients').distinct('clients').count()
+ rw_client_num = TestResult.objects.filter(Q(test_record_id=obj.id ) ,test_cate_id=2).order_by('clients').distinct('clients').count()
+ return max(ro_client_num,rw_client_num)
+
class TestRecordDetailSerializer(serializers.ModelSerializer):
'''
queryset = TestRecord.objects.all()
serializer_class = TestRecordSerializer
pagination_class = StandardResultsSetPagination
- # authentication_classes = None
- # def get(self, request, *args, **kwargs):
- # return self.list(request, *args, **kwargs)
-
- # def post(self, request, *args, **kwargs):
- # return self.create(request, *args, **kwargs)
- # def get(self, request, format=None):
- # testRecords = TestRecord.objects.all()
- # records_serializer = TestRecordSerializer(testRecords, many=True)
- # return Response(records_serializer.data)
- #
- # def post(self, request, format=None):
- # serializer = TestRecordSerializer(data=request.data)
- # if serializer.is_valid():
- # serializer.save()
- # return Response(serializer.data, status=status.HTTP_201_CREATED)
- # return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
-
class TestRecordDetailViewSet(mixins.ListModelMixin, mixins.RetrieveModelMixin, viewsets.GenericViewSet):
"""
from django.db import models
from users.models import UserMachine
-# Create your models here.
-
-
+# Create your models here.
\ No newline at end of file
--- /dev/null
+from rest_framework import serializers
+from users.models import UserMachine
+from django.db.models import Q
+
+class UserMachineSerializer(serializers.ModelSerializer):
+
+ '''
+ use UserMachineSerializer
+ '''
+ class Meta:
+ model = UserMachine
+ # fields = "__all__"
+ fields = ('alias', 'os_name', 'os_version' ,'comp_name', 'comp_version')
\ No newline at end of file