次のような構造は、ダッシュボードに適しています:
import React, { Component } from 'react';
import withWidth from 'material-ui/utils/withWidth';
import { AppBarMobile, GET_LIST, GET_MANY } from 'admin-on-rest';
import Welcome from './Welcome';
import Moment from 'react-moment';
class Dashspawn extends Component {
state = {};
componentDidMount() {
restClient(GET_LIST, 'spawns', {
filter: { state: 'jar'},
sort: { field: 'inoculationjar', order: 'ASC' },
pagination: { page: 1, perPage: 100 },
})
.then(response => response.data)
.then(newSpawn => {
this.setState({ newSpawn });
this.setState({ nbCurrentSpawn: newSpawn.reduce(nb => ++nb, 0) });
})
restClient(GET_LIST,....
}
render() {
const {
nbCurrentSpawn_month_one,
newSpawn,
newSpawn_month_one,
etc...
} = this.state;
const { width } = this.props;
return (
<div>
{width === 1 && <AppBarMobile title="Bali Mojo" />}
<Welcome style={styles.welcome} />
<div style={styles.flex}>
<div style={styles.leftCol}>
<div style={styles.flex}>
Some of your field components..
</div>
<div style={styles.rightCol}>
<div style={styles.flex}>
Some more of your field components..
</div>
</div>
</div>
);
}
}
export default withWidth()(Dashspawn);
・ホープ、このことができます。
psこれはGET_LIST
のコンポーネント例です。 restClient(GETLIST,..
とコンポーネントを追加してダッシュボードを作成します。
import React from 'react';
import { Card, CardTitle } from 'material-ui/Card';
import { List, ListItem } from 'material-ui/List';
import BlockIcon from 'material-ui/svg-icons/content/block';
import { translate } from 'admin-on-rest';
const styles = {
card: { borderLeft: 'solid 4px #4caf50', flex: 1, marginLeft: '2em' },
icon: { float: 'right', width: 64, height: 64, padding: 16, color: '#4caf50' },
};
export default translate(({ spawns = [], nb, unitsok, translate }) => (
<Card style={styles.card}>
<BlockIcon style={styles.icon} />
<CardTitle title={nb} subtitle={unitsok} />
<List>
{spawns.map(record =>
<ListItem
href={`#/spawns/${record.id}`}
key={record.id}
primaryText={record.spawncode}
secondaryText={new Date(record.inoculationbag).toString('dd-MMM-yyyy').slice(0, 15)}
/>
)}
</List>
</Card>
));
これまでにこれを達成する方法を見つけましたか?同じ問題で走っています... – AvantiC
残念ながらいいえ。私は、ダッシュボードでフィルタリングする機能を削除してしまいました。代わりに、対応するリソースの「リスト」の場所にリダイレクトするオプションを提供しました。ここでは、フィルタリングと並べ替えが利用可能になりました。 –
ああ、あまりにも悪い...共有のためにありがとう。 :) – AvantiC