Skip to content
This repository has been archived by the owner on Feb 26, 2023. It is now read-only.

Commit

Permalink
Merge pull request #155 from iverberk/0.5.1-fixes
Browse files Browse the repository at this point in the history
quick fixes for 0.5.0
  • Loading branch information
jippi authored Dec 9, 2016
2 parents 1fa30fe + 98e45cf commit 9284db7
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 21 deletions.
20 changes: 17 additions & 3 deletions backend/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ func (c *Connection) readPump() {
if err != nil {
break
}

c.process(action)
}
}
Expand Down Expand Up @@ -200,10 +201,10 @@ func (c *Connection) process(action Action) {
//
case watchMember:
go c.watchMember(action)
case unwatchMember:
c.watches.Remove(action.Payload.(string))
case fetchMember:
go c.fetchMember(action)
case unwatchMember:
c.watches.Remove(action.Payload.(string))

// Actions for a single evaluation
case watchEval:
Expand Down Expand Up @@ -514,6 +515,7 @@ func (c *Connection) watchFile(action Action) {
logger.Error("Could not decode payload")
return
}

addr := params["addr"].(string)
path := params["path"].(string)
allocID := params["allocID"].(string)
Expand Down Expand Up @@ -578,16 +580,23 @@ func (c *Connection) watchFile(action Action) {
go func() {
for {
n, err := r.Read(b[:cap(b)])

if !c.watches.Has(path) {
return
}

if err != nil {
return
}

if n > 0 {
lines <- b[0:n]
}
}
}()

c.watches.Add(path)

defer func() {
c.Infof("Stopped watching file with path: %s", path)
c.watches.Remove(path)
Expand All @@ -609,15 +618,19 @@ func (c *Connection) watchFile(action Action) {
Index: 0,
}

ticker := time.NewTicker(10 * time.Second)
ticker := time.NewTicker(1 * time.Second)

for {
select {

case <-c.destroyCh:
return

case line := <-lines:
if !c.watches.Has(path) {
return
}

c.send <- &Action{
Type: fetchedFile,
Payload: struct {
Expand All @@ -631,6 +644,7 @@ func (c *Connection) watchFile(action Action) {
},
Index: 0,
}

case <-ticker.C:
if !c.watches.Has(path) {
return
Expand Down
14 changes: 6 additions & 8 deletions frontend/src/components/AllocationFiles/AllocationFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ class AllocationFiles extends Component {
}

if (this.state.fileWatching && currentFile && currentFile !== nextFile) {
this.unwatchFile(nextProps, currentFile)
this.unwatchFile(this.props)

nextState.contents = ''
nextState.fileWatching = false
stateHaveChanged = true
Expand Down Expand Up @@ -116,7 +117,7 @@ class AllocationFiles extends Component {
return
}

this.unwatchFile(this.props, this.props.location.query.file)
this.unwatchFile(this.props)

this.setState({
contents: '',
Expand Down Expand Up @@ -184,14 +185,10 @@ class AllocationFiles extends Component {
})
}

unwatchFile (props, file) {
if (!this.findAllocNode(props)) {
return
}

unwatchFile (props) {
props.dispatch({
type: UNWATCH_FILE,
payload: file
payload: props.location.query.path + props.location.query.file
})
}

Expand All @@ -209,6 +206,7 @@ class AllocationFiles extends Component {
pathname: this.props.location.pathname,
query: { path }
})

return
}

Expand Down
8 changes: 5 additions & 3 deletions frontend/src/components/AllocationLink/AllocationLink.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,31 @@ import React, { PropTypes } from 'react'
import { Link } from 'react-router'
import { default as shortenUUID } from '../../helpers/uuid'

const AllocationLink = ({ children, allocationId, linkAppend, shortUUID }) => {
const AllocationLink = ({ children, allocationId, linkAppend, shortUUID, linkQuery }) => {
let innerChildren = children;

if (children === undefined) {
innerChildren = shortUUID ? shortenUUID(allocationId) : allocationId
}

return (
<Link to={{ pathname: `/allocations/${allocationId}${linkAppend}` }}>
<Link to={{ pathname: `/allocations/${allocationId}${linkAppend}`, query: linkQuery}}>
{ innerChildren }
</Link>
)
}

AllocationLink.defaultProps = {
shortUUID: true,
linkAppend: ''
linkAppend: '',
linkQuery: {},
}

AllocationLink.propTypes = {
children: PropTypes.array,
allocationId: PropTypes.string.isRequired,
linkAppend: PropTypes.string,
linkQuery: PropTypes.object,
shortUUID: PropTypes.boolean.isRequired
}

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/AllocationList/AllocationList.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class AllocationList extends PureComponent {
<Card>
<CardHeader title='Filter list' actAsExpander showExpandableButton />
<CardText expandable>
{ this.clientFilter() }
{ showClientColumn ? this.clientFilter() : null }
&nbsp;
{ this.clientStatusFilter() }
&nbsp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class AllocationListRow extends Component {
<FormatTime identifier={ allocation.ID } time={ allocation.CreateTime } />
</TableRowColumn>
<TableRowColumn style={{ width: 50 }}>
<AllocationLink allocationId={ allocation.ID } linkAppend='/files?path=/alloc/logs/'>
<AllocationLink allocationId={ allocation.ID } linkAppend='/files' linkQuery={{ path: '/alloc/logs/' }}>
<FontIcon className='material-icons'>format_align_left</FontIcon>
</AllocationLink>
</TableRowColumn>
Expand Down
6 changes: 1 addition & 5 deletions frontend/src/components/Progressbar/Progressbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ class Progressbar extends Component {
this.setState({ showLabel: true })
}

onPieClick() {
this.setState({ showLabel: !this.state.showLabel })
}

renderActiveShape(props) {
const { cx, cy, innerRadius, outerRadius, startAngle, endAngle, fill, payload, percent } = props;
const p = (percent * 100).toFixed(0)
Expand Down Expand Up @@ -114,7 +110,7 @@ class Progressbar extends Component {
<PieChart
onMouseEnter={ (data, index) => { this.onPieEnter(data, index) } }
onMouseLeave={ (data, index) => { this.onPieLeave(data, index) } }
onClick={ (data, index) => { this.onPieClick(data, index) } }
onClick={ (data, index) => { this.onPieEnter(data, index) } }
>
<Pie
activeIndex={ this.state.activeIndex }
Expand Down

0 comments on commit 9284db7

Please sign in to comment.