From: Hongyuan Ma Date: Sat, 23 Jun 2018 05:08:10 +0000 (+0800) Subject: add record/filters X-Git-Url: http://git.postgresql.org/gitweb/static/session/%7B%7Bsession.id%7D%7D-%7B%7Bsession.title%7Cslugify%7D%7D?a=commitdiff_plain;h=545a1b5de6a059ddff2cede7ae7ad2fc259f0e8b;p=pgperffarm.git add record/filters --- diff --git a/front-end/src/component/result-filter/index.jsx b/front-end/src/component/result-filter/index.jsx index 77bfe28..69991b7 100644 --- a/front-end/src/component/result-filter/index.jsx +++ b/front-end/src/component/result-filter/index.jsx @@ -14,28 +14,37 @@ class ResultFilter extends React.Component { selected: [{ 'cate': 'Category 1', 'index': 2, - 'data': [ - 'All', - 'Improving', - 'Regressive' - ], - }, { - 'cate': 'Category 2', - 'index': 1, 'data': [ 'All', '7 days', '30 days' ], - }, { - 'cate': 'Category 3', - 'index': 1, - 'data': [ - 'All', - 'item3-1', - 'item3-2' - ], }], + // selected: [{ + // 'cate': 'Category 1', + // 'index': 2, + // 'data': [ + // 'All', + // 'Improving', + // 'Regressive' + // ], + // }, { + // 'cate': 'Category 2', + // 'index': 1, + // 'data': [ + // 'All', + // '7 days', + // '30 days' + // ], + // }, { + // 'cate': 'Category 3', + // 'index': 1, + // 'data': [ + // 'All', + // 'item3-1', + // 'item3-2' + // ], + // }], isClear: true }; diff --git a/front-end/src/util/basic-table/index.css b/front-end/src/util/basic-table/index.css index f8c930f..0fe34f8 100644 --- a/front-end/src/util/basic-table/index.css +++ b/front-end/src/util/basic-table/index.css @@ -8,4 +8,36 @@ .ReactTable .rt-tr-group:nth-child(2n) { background-color: #ffffff; +} + +.bgc-clear{ + background-color: #ffffff; +} + +.anonymous { + color: #e8e8e8; +} + +.anonymous :hover { + color: lightgrey; +} +.improved { + color: #7cb305; +} + +.quo { + color: #40a9ff; +} + +.regressive { + color: #fa541c; +} + +.mini-label { + font-weight: 100!important; + font-size: 0.1em!important; + min-width: 1.3em!important; + min-height: 0.1em!important; + padding: .2em!important; + line-height: 0.5em!important; } \ No newline at end of file diff --git a/front-end/src/util/basic-table/index.jsx b/front-end/src/util/basic-table/index.jsx index 21b49e5..e63141d 100644 --- a/front-end/src/util/basic-table/index.jsx +++ b/front-end/src/util/basic-table/index.jsx @@ -1,8 +1,21 @@ import React from 'react'; -import {Icon, Table, Menu, Message, Button} from 'semantic-ui-react' +import {Icon, Table, Label, Message, Button} from 'semantic-ui-react' import Pagination from 'util/pagination/index.jsx' import './index.css'; +function Bubble(props) { + + if (props.num <= 0) { + return null; + } + let className = props.name + 'IconClassName'; + return ( + + ); +} + // general basic table class BasicTable extends React.Component { constructor(props) { @@ -14,9 +27,11 @@ class BasicTable extends React.Component { } } - onPageNumChange(current){ + + + onPageNumChange(current) { this.setState({ - currentPage : current + currentPage: current }, () => { this.props.loadfunc(current); }); @@ -36,6 +51,9 @@ class BasicTable extends React.Component { let branch = record.pg_info.pg_branch; let trend = record.trend + let improvedIconClassName = trend.improved > 0 ? 'improved' : 'anonymous' + let quoIconClassName = trend.quo > 0 ? 'quo' : 'anonymous' + let regressiveIconClassName = trend.regressive > 0 ? 'regressive' : 'anonymous' return ( @@ -50,23 +68,27 @@ class BasicTable extends React.Component { {/*trending-data*/} - {trend.improved} + + - {trend.quo} + + - {trend.regressive} + + - - + + {/**/} {/*date*/} - {new Date().toDateString()} + {record.add_time} ); }); @@ -97,18 +119,19 @@ class BasicTable extends React.Component { {/**/} - {/**/} - {/**/} - {/**/} - {/*1*/} - {/*2*/} - {/*3*/} - {/*4*/} - {/**/} - {/**/} - {/**/} + {/**/} + {/**/} + {/**/} + {/*1*/} + {/*2*/} + {/*3*/} + {/*4*/} + {/**/} + {/**/} + {/**/} {/**/} - this.onPageNumChange(current)} pageSize={2} current={this.state.currentPage} total={this.props.total}/> + this.onPageNumChange(current)} pageSize={2} + current={this.state.currentPage} total={this.props.total}/> @@ -118,6 +141,8 @@ class BasicTable extends React.Component { ); } + + } export default BasicTable; \ No newline at end of file diff --git a/web/apps/test_records/filters.py b/web/apps/test_records/filters.py new file mode 100644 index 0000000..998f3d7 --- /dev/null +++ b/web/apps/test_records/filters.py @@ -0,0 +1,17 @@ + +# -*- coding: utf-8 -*- +import django_filters +from django.db.models import Q + +from .models import TestRecord + + +class TestRecordListFilter(django_filters.rest_framework.FilterSet): + """ + TestRecordListFilter + """ + date = django_filters.DateTimeFilter(name='add_time',lookup_expr='gte') + + class Meta: + model = TestRecord + fields = ['date', ] \ No newline at end of file diff --git a/web/apps/test_records/views.py b/web/apps/test_records/views.py index 41a7667..2f4d911 100644 --- a/web/apps/test_records/views.py +++ b/web/apps/test_records/views.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals +import django_filters import shortuuid from django.contrib.auth.hashers import make_password @@ -8,6 +9,7 @@ from django.shortcuts import render from rest_framework.pagination import PageNumberPagination from exception import TestDataUploadError +from filters import TestRecordListFilter from models import UserMachine, TestCategory from pgperffarm.settings import DB_ENUM from .serializer import TestRecordListSerializer, TestRecordDetailSerializer, LinuxInfoSerializer, MetaInfoSerializer, \ @@ -36,7 +38,8 @@ class TestRecordListViewSet(mixins.ListModelMixin, viewsets.GenericViewSet): queryset = TestRecord.objects.all().order_by('add_time') serializer_class = TestRecordListSerializer pagination_class = StandardResultsSetPagination - + filter_backends = (django_filters.rest_framework.DjangoFilterBackend,) + filter_class = TestRecordListFilter class TestRecordDetailViewSet(mixins.RetrieveModelMixin, viewsets.GenericViewSet): """ diff --git a/web/pgperffarm/settings.py b/web/pgperffarm/settings.py index afe66af..a02e3cf 100644 --- a/web/pgperffarm/settings.py +++ b/web/pgperffarm/settings.py @@ -46,9 +46,11 @@ INSTALLED_APPS = ( 'django.contrib.staticfiles', 'django_gravatar', 'rest_framework', + 'django_filters', 'rest_framework.authtoken', 'users', 'test_records', + 'crispy_forms', 'user_operation', ) @@ -133,6 +135,7 @@ REST_FRAMEWORK = { # 'rest_framework.authentication.BasicAuthentication', # 'rest_framework.authentication.SessionAuthentication', # ), + 'DEFAULT_FILTER_BACKENDS': ('django_filters.rest_framework.DjangoFilterBackend',), 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination', 'PAGE_SIZE': 20 }