add Accordion when info too long
authorHongyuan Ma <CS_MaleicAcid@163.com>
Sat, 30 Jun 2018 14:15:57 +0000 (22:15 +0800)
committerHongyuan Ma <CS_MaleicAcid@163.com>
Sat, 30 Jun 2018 14:15:57 +0000 (22:15 +0800)
front-end/src/component/info-list/index.css
front-end/src/component/info-list/index.jsx
front-end/src/page/detailInfo/index.css
front-end/src/util/basic-table/index.jsx
web/apps/test_records/models.py
web/db_tools/data/alias_data.py
web/pgperffarm/settings.py

index 4db74bae18e043d7c4ea5020c4f74d408914a514..2876f2ea54df9e267df158327eea5f3004f19cd5 100644 (file)
@@ -2,5 +2,23 @@
     font-size: 18px!important;
 }
 .clear-list-style {
-    list-style: none!important;
+    list-style-type: none!important;
+}
+.pre {
+    white-space:pre-wrap;
+}
+
+/*Simulation style*/
+.accordion .title{
+    font-family: Lato,'Helvetica Neue',Arial,Helvetica,sans-serif;
+    line-height: 1.28571429em;
+    /*margin: calc(2rem - .14285714em) 0 1rem;*/
+    font-weight: 700;
+    padding: 0;
+    font-size: 1.28571429rem;
+    color: #4183c4!important;
+}
+
+.accordion .title i{
+    color: #000!important;
 }
\ No newline at end of file
index 7548cbc5193241e2f4f3f28643aae41697f13bea..681fa2d0a2273419176e38a0ea7ecfb31432e7e4 100644 (file)
@@ -1,43 +1,83 @@
 import React from 'react';
 
 import './index.css';
-import {List, Item} from 'semantic-ui-react'
+import {List, Item, Accordion} from 'semantic-ui-react'
 class InfoList extends React.Component {
     constructor(props) {
         super(props);
     }
 
-    scrollToAnchor(anchorName)  {
+    scrollToAnchor(anchorName) {
         if (anchorName) {
             let anchorElement = document.getElementById(anchorName);
-            if(anchorElement) { anchorElement.scrollIntoView(); }
+            if (anchorElement) {
+                anchorElement.scrollIntoView();
+            }
         }
     }
 
     render() {
         let info = this.props.info
         let name = this.props.name
-        let _list = Object.keys(info).map(key => {
-            let _list2 = 0
-            return (
-                <List.Item as='li'>
-                    <a href='javascript:void(0)' id={'name'+key} onClick={()=>this.scrollToAnchor('name' + key)}><h3>{'name' + key}</h3></a>
-                    {/*<h3>{key}</h3>*/}
-                    <List.List as='ul'>
-                        <List.Item className="clear-list-style" >{info[key]}</List.Item>
-                    </List.List>
-                </List.Item>
-            );
-        });
+        let _list = []
+        React.Children.forEach(Object.keys(info), (child, i) => {
+            // console.log('child: ' + i)
+            let Item
+            if(info[child].length >= 300) {
+                console.log(child+' is too long')
+
+                let panel =[{
+                    title: child,
+                    content: info[child],
+                }]
+
+                 Item = (
+                    <List.Item className='clear-list-style' key={i} value='-'>
+                        <Accordion className='pre' defaultActiveIndex={[0, 0]} panels={panel} exclusive={false} fluid />
+
+                        {/*<a href='javascript:void(0)' id={'' + child} onClick={() => this.scrollToAnchor('' + child)}>*/}
+                            {/*<h3>{'' + child}301</h3></a>*/}
+                        {/*/!*<h3>{key}</h3>*!/*/}
+                        {/*<List.List as='ul'>*/}
+                            {/*<List.Item className="clear-list-style pre">{info[child]}</List.Item>*/}
+                        {/*</List.List>*/}
+
+                    </List.Item>
+                )
+            }else{
+                 Item = (
+                    <List.Item as='li' key={i}>
+                        <a href='javascript:void(0)' id={'' + child} onClick={() => this.scrollToAnchor('' + child)}>
+                            <h3>{'' + child}</h3></a>
+                        {/*<h3>{key}</h3>*/}
+                        <List.List as='ul'>
+                            <List.Item className="clear-list-style pre">{info[child]}</List.Item>
+                        </List.List>
+                    </List.Item>
+                )
+            }
+
+
+            _list.push({
+                key: `label${i}`,
+                value: Item
+            })
+        })
+
+        const itemComponents = _list.map(item => {
+            return <div key={item.key}>{item.value}</div>
+        })
+
         return (
             <List className='info-list' as='ul'>
 
                 <List.Item as='li'>
 
-                    <a href='javascript:void(0)' id={name + 'Info'} onClick={()=>this.scrollToAnchor(name + 'Info')}><h2>{name} Info</h2></a>
+                    <a href='javascript:void(0)' id={name + 'Info'} onClick={() => this.scrollToAnchor(name + 'Info')}>
+                        <h2>{name} Info</h2></a>
                     <List.List as='ul'>
 
-                        {_list}
+                        {itemComponents}
                         {/*<List.Item as='li'>*/}
                         {/*<a href='#'>Link to somewhere</a>*/}
                         {/*</List.Item>*/}
@@ -47,8 +87,6 @@ class InfoList extends React.Component {
                     </List.List>
 
                 </List.Item>
-
-                <List.Item as='li'>Warranty</List.Item>
             </List>
         );
     }
index 8d5a658fa69a8845465e69e39099c973cb4fb874..6da6a003b1f9e1ada8caaec269529d00a8ca7ff0 100644 (file)
@@ -1,3 +1,7 @@
+.record-title{
+    padding-left: 14px;
+}
+
 .card-container{
     margin-left: 5px;
     margin-right: 5px;
index 47c5198503168a1c45185835f8ddc55787e30a91..21f24741812408d5193b98f7d9095756e982b112 100644 (file)
@@ -143,9 +143,9 @@ class BasicTable extends React.Component {
                         <Table.HeaderCell rowSpan='2'>Date</Table.HeaderCell>
                     </Table.Row>
                     <Table.Row>
-                        <Table.HeaderCell>improved</Table.HeaderCell>
-                        <Table.HeaderCell>quo</Table.HeaderCell>
-                        <Table.HeaderCell>regressive</Table.HeaderCell>
+                        <Table.HeaderCell>improvement</Table.HeaderCell>
+                        <Table.HeaderCell>status quo</Table.HeaderCell>
+                        <Table.HeaderCell>regression</Table.HeaderCell>
                     </Table.Row>
 
                 </Table.Header>
index 9b3e278ffe37a3e288407d8c67eeb57b9980e55d..856eb530a3e5683131f327531c04eff10281f3d0 100644 (file)
@@ -222,10 +222,10 @@ class TestResult(models.Model):
     threads = models.IntegerField(verbose_name="threads", help_text="threads of the test result")
 
     MODE_CHOICE = (
-        ('simple', 'simple'),
-        ('other', 'other'),
+        ('simple', 1),
+        ('other', 2),
     )
-    mode = models.IntegerField(choices=MODE_CHOICE, default='simple', verbose_name="mode", help_text="test mode")
+    mode = models.IntegerField(choices=MODE_CHOICE, verbose_name="mode", help_text="test mode")
     add_time = models.DateTimeField(default=timezone.now, verbose_name="test result added time")
 
     class Meta:
index e5fd40271094861b10d5ef4c428041bd6f03e608..d9a643b49d7dc5f1b8a01bbadf0190952b300093 100644 (file)
@@ -1,6 +1,74 @@
 row_data = [
+    {
+        'name': 'Avocado',
+        'is_used': True
+    },
     {
         'name': 'Cabbage',
         'is_used': True
     },
+    {
+        'name': 'Cucumber',
+        'is_used': False
+    },
+    {
+        'name': 'Celery',
+        'is_used': False
+    },
+    {
+        'name': 'Celtuce',
+        'is_used': False
+    },
+    {
+        'name': 'Chaya',
+        'is_used': False
+    },
+    {
+        'name': 'Chicory',
+        'is_used': False
+    },
+    {
+        'name': 'Cress',
+        'is_used': False
+    },
+    {
+        'name': 'Dandelion',
+        'is_used': False
+    },
+    {
+        'name': 'Eggplant',
+        'is_used': False
+    },
+    {
+        'name': 'Fiddlehead',
+        'is_used': False
+    },
+    {
+        'name': 'Grape',
+        'is_used': False
+    },
+    {
+        'name': 'Luffa',
+        'is_used': False
+    },
+    {
+        'name': 'Kale',
+        'is_used': False
+    },
+    {
+        'name': 'Kale',
+        'is_used': False
+    },
+    {
+        'name': 'Pepper',
+        'is_used': False
+    },
+    {
+        'name': 'Sorrel',
+        'is_used': False
+    },
+    {
+        'name': 'Squash',
+        'is_used': False
+    },
 ]
index ed73111fe3b74c52c13f897c718d15ae98c90f25..c6210ff231cab6d4300ad73e0f8ac267bd3a1e74 100644 (file)
@@ -142,8 +142,8 @@ REST_FRAMEWORK = {
 
 DB_ENUM = {
     "mode":{
-        "simple":'simple',
-        "other":'other'
+        "simple":1,
+        "other":2
     },
     "status": {
         "none": -1,