import React from 'react';
import ReactDom from 'react-dom';
-import {BrowserRouter as Router, Route, Link, Redirect, Switch} from 'react-router-dom';
+import {HashRouter as Router, Route, Link, Redirect, Switch} from 'react-router-dom';
import createHistory from 'history/createHashHistory'
const history = createHistory()
import {spring, AnimatedRoute, AnimatedSwitch} from 'react-router-transition';
</Layout>
);
return (
- <Router history={history}>
+ <Router>
<AnimatedSwitch
atEnter={bounceTransition.atEnter}
atLeave={bounceTransition.atLeave}
<Card>
<Card.Content>
<Image floated='right' size='mini'
- src='http://www.semantic-ui.cn/images/avatar2/small/lena.png'/>
+ src={machine.avatar}/>
<Card.Header>Farmer: {machine.alias}</Card.Header>
<Card.Meta>report num: {machine.reports}</Card.Meta>
<Card.Description>
super(props);
}
+ scrollToAnchor(anchorName) {
+ if (anchorName) {
+ let anchorElement = document.getElementById(anchorName);
+ if(anchorElement) { anchorElement.scrollIntoView(); }
+ }
+ }
+
render() {
let info = this.props.info
let name = this.props.name
let _list2 = 0
return (
<List.Item as='li'>
- <h3>{key}</h3>
+ <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 className='info-list' as='ul'>
<List.Item as='li'>
- <h2>{name} Info</h2>
+
+ <a href='javascript:void(0)' id={name + 'Info'} onClick={()=>this.scrollToAnchor(name + 'Info')}><h2>{name} Info</h2></a>
<List.List as='ul'>
{_list}
.card-container{
- margin-left: 0%;
+ margin-left: 5px;
+ margin-right: 5px;
}
.card-div{
padding-left: 2px;
});
return (
- <Table celled striped key={key}>
+ <Table celled striped>
<Table.Header>
<Table.Row>
<Table.HeaderCell colSpan="4">Clients:{key} scale:10 <a href=""> >>prev</a>
);
}
+//todo
+// function TrendCell(trend) {
+// const isNull = !list;
+// const isEmpty = !isNull && !list.length;
+// let improvedIconClassName = trend.improved > 0 ? 'improved' : 'anonymous'
+// let quoIconClassName = trend.quo > 0 ? 'quo' : 'anonymous'
+// let regressiveIconClassName = trend.regressive > 0 ? 'regressive' : 'anonymous'
+// if (!trend.is_first) {
+// return (
+// <Table.Cell textAlign='center'>
+// first report
+// </Table.Cell>
+// );
+// } else {
+// return (
+// <div>
+// <Table.Cell textAlign='center'>
+// <Icon className={"bgc-clear " + improvedIconClassName} name='smile outline' size='large'/>
+// <Bubble num={trend.improved} name="improved"/>
+// </Table.Cell>
+// <Table.Cell textAlign='center'>
+// <Icon className={"bgc-clear " + quoIconClassName} name='meh outline' size='large'/>
+// <Bubble num={trend.quo} name="quo"/>
+// </Table.Cell>
+// <Table.Cell textAlign='center'>
+// <Icon className={"bgc-clear " + regressiveIconClassName} name='frown outline'
+// size='large'/>
+// <Bubble num={trend.regressive} name="regressive"/>
+// </Table.Cell>
+// </div>
+// );
+// }
+//
+// }
+
// general basic table
class BasicTable extends React.Component {
constructor(props) {
<Table.Cell>{branch}</Table.Cell>
{/*trending-data*/}
+
<Table.Cell textAlign='center'>
<Icon className={"bgc-clear " + improvedIconClassName} name='smile outline' size='large'/>
<Bubble num={trend.improved} name="improved"/>
size='large'/>
<Bubble num={trend.regressive} name="regressive"/>
</Table.Cell>
+
+
<Table.Cell textAlign='center'>
<Link color='linkedin' to={'detailInfo/' + record.uuid}>
<Icon name='linkify'/> Link
</Link>
</Table.Cell>
+
+
{/*date*/}
<Table.Cell>{record.add_time}</Table.Cell>
</Table.Row>
from test_records.models import TestRecord
from users.models import UserMachine, Alias, UserProfile
from django.db.models import Q
+import hashlib
class AliasSerializer(serializers.ModelSerializer):
'''
alias = serializers.SerializerMethodField()
reports = serializers.SerializerMethodField()
owner = serializers.SerializerMethodField()
+ avatar = serializers.SerializerMethodField()
class Meta:
model = UserMachine
# fields = "__all__"
- fields = ('alias', 'os_name', 'os_version', 'comp_name', 'comp_version', 'reports', 'owner')
+ fields = ('alias', 'os_name', 'os_version', 'comp_name', 'comp_version', 'reports', 'owner' , 'avatar')
def get_alias(self, obj):
target_alias = Alias.objects.filter(id=obj.alias_id).first()
def get_owner(self, obj):
target_owner = UserProfile.objects.filter(id=obj.machine_owner_id).values('email').first()
- return target_owner['email']
\ No newline at end of file
+ return target_owner['email']
+
+ def get_avatar(self, obj):
+ target_owner = UserProfile.objects.filter(id=obj.machine_owner_id).values('email').first()
+
+ avatar = 'http://s.gravatar.com/avatar/' + hashlib.md5(target_owner['email']).hexdigest()
+ print avatar
+ return avatar
\ No newline at end of file