<commit_before>import React from 'react'
import Route from 'react-route'

import AppBar from 'material-ui/lib/app-bar'
import IconButton from 'material-ui/lib/icon-button'
import ActionHome from 'material-ui/lib/svg-icons/action/home'
import Card from 'material-ui/lib/card/card'
import CardHeader from 'material-ui/lib/card/card-header'
import CardText from 'material-ui/lib/card/card-text'
import CardActions from 'material-ui/lib/card/card-actions'
import RaisedButton from 'material-ui/lib/raised-button'
import CircularProgress from 'material-ui/lib/circular-progress'

import PaperAvatar from './paper_avatar'
import { getTypeById } from './types'
import { getPersonParty } from './parties'


export default class PaperView extends React.Component {
  constructor(props) {
    super(props)
    this.state = {
      paper: {
        id: this.props.params.id
      }
    }
  }

  componentDidMount() {
    fetch(`/api/oparl/paper/${encodeURIComponent(this.state.paper.id)}`)
      .then(res => res.json())
      .then(paper => {
        paper.fileIds = paper.auxiliaryFile || []
        if (paper.mainFile) paper.fileIds.push(paper.mainFile)

        this.setState({
          paper: paper
        })
      })
  }

  render() {
    let paper = this.state.paper
    let fileCards = []
    function pushFileCards(file, role) {
      if (Array.isArray(file)) {
        file.forEach(f => pushFileCards(f, role))
      } else if (typeof file == 'string') {
        fileCards.push(<FileCard key={file} file={{ id: file }} role={role} paper={paper}/>)
      }
    }
    pushFileCards(paper.mainFile, "Hauptdatei")
    pushFileCards(paper.auxiliaryFile)

    return (
      <div>
        <AppBar
            title={
              <div>
                <PaperAvatar paper={paper} size={32}/>

                <span style={{ whiteSpace: 'pre-wrap' }}>
                  {paper.name}
                </span>
              </div>
            }
            iconElementLeft={
              <IconButton title="Zurück zur Suche"
                  onClick={ev => Route.go("/")}>
                <ActionHome/>
              </IconButton>
            }
            iconElementRight={
              <p style={{ margin: "16px 0 0", fontSize: "80%", color: 'white' }}>
                {iso8601ToDate(paper.publishedDate)}
              </p>
            }
            />

        {fileCards}

        {(paper.consultation || [])
         .filter(consultation => !!consultation.meeting)
         .map((consultation, i) =>
           <Meeting key={i} id={consultation.meeting} filesOf={paper.id} paper={paper}/>
        )}
      </div>
    )
  }
}

class Meeting extends React.Component {
  constructor(props) {
    super(props)

    this.state = {
      meeting: {}
    }
  }

  componentDidMount() {
    fetch(`/api/oparl/meeting/${encodeURIComponent(this.props.id)}`)<commit_msg>paper_view: replace home button with paper avatar<commit_after>import React from 'react'
import Route from 'react-route'

import AppBar from 'material-ui/lib/app-bar'
import Card from 'material-ui/lib/card/card'
import CardHeader from 'material-ui/lib/card/card-header'
import CardText from 'material-ui/lib/card/card-text'
import CardActions from 'material-ui/lib/card/card-actions'
import RaisedButton from 'material-ui/lib/raised-button'
import CircularProgress from 'material-ui/lib/circular-progress'

import PaperAvatar from './paper_avatar'
import { getTypeById } from './types'
import { getPersonParty } from './parties'


export default class PaperView extends React.Component {
  constructor(props) {
    super(props)
    this.state = {
      paper: {
        id: this.props.params.id
      }
    }
  }

  componentDidMount() {
    fetch(`/api/oparl/paper/${encodeURIComponent(this.state.paper.id)}`)
      .then(res => res.json())
      .then(paper => {
        paper.fileIds = paper.auxiliaryFile || []
        if (paper.mainFile) paper.fileIds.push(paper.mainFile)

        this.setState({
          paper: paper
        })
      })
  }

  render() {
    let paper = this.state.paper
    let fileCards = []
    function pushFileCards(file, role) {
      if (Array.isArray(file)) {
        file.forEach(f => pushFileCards(f, role))
      } else if (typeof file == 'string') {
        fileCards.push(<FileCard key={file} file={{ id: file }} role={role} paper={paper}/>)
      }
    }
    pushFileCards(paper.mainFile, "Hauptdatei")
    pushFileCards(paper.auxiliaryFile)

    return (
      <div>
        <AppBar
            iconElementLeft={
              <PaperAvatar paper={paper} size={48}/>
            }
            title={
              <span style={{ whiteSpace: 'pre-wrap' }}>
                {paper.name}
              </span>
            }
            iconElementRight={
              <p style={{ margin: "16px 0 0", fontSize: "80%", color: 'white' }}>
                {iso8601ToDate(paper.publishedDate)}
              </p>
            }
            />

        {fileCards}

        {(paper.consultation || [])
         .filter(consultation => !!consultation.meeting)
         .map((consultation, i) =>
           <Meeting key={i} id={consultation.meeting} filesOf={paper.id} paper={paper}/>
        )}
      </div>
    )
  }
}

class Meeting extends React.Component {
  constructor(props) {
    super(props)

    this.state = {
      meeting: {}
    }
  }

  componentDidMount() {
    fetch(`/api/oparl/meeting/${encodeURIComponent(this.props.id)}`)
{'fraction_non_alphanumeric': 0.1409642988590357, 'fraction_numerical': 0.004416635995583364, 'mean_word_length': 2.223606168446026, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2924543', 'n_tokens_mistral': 1717, 'n_tokens_neox': 1685, 'n_words': 325}