From eb3030ed0ad5aa93b99d237867480c989369930c Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 18 Jun 2018 11:48:22 +0200 Subject: waaaay better nav! --- app/client/common/header.component.js | 31 ++++++++++++++++++++------- app/client/modules/pix2pix/pix2pix.actions.js | 4 ++-- app/client/system/system.reducer.js | 2 +- 3 files changed, 26 insertions(+), 11 deletions(-) (limited to 'app/client') diff --git a/app/client/common/header.component.js b/app/client/common/header.component.js index 85e1895..11eb761 100644 --- a/app/client/common/header.component.js +++ b/app/client/common/header.component.js @@ -7,19 +7,26 @@ import * as systemActions from '../system/system.actions' import modules from '../modules' +function NavLink(props){ + if (! props.to) { + return {props.children} + } + let children = props.to === props.location.pathname ? {props.children} : props.children + return ( + {children} + ) +} + function Header(props){ - const { site, app, fps, playing, actions, location } = props + const { site, app, fps, playing, actions, location, history } = props const tool_list = Object.keys(modules).map((name, i) => { const label = name.replace(/_/, " ") return }) const tool = modules[app.tool] const links = tool.links().map((link,i) => { - let name = link.url === location.pathname ? {link.name} : link.name return ( - - {link.url ? {name} : name} - + {link.name} ) }) return ( @@ -27,12 +34,20 @@ function Header(props){ {playing && {fps} fps} {links} - { + let path = window.location.pathname.split("/") + path.shift() + console.log(path) + if (path[0] in modules && path[1]) { + history.push('/' + e.target.value + '/' + path[1] + '/') + } + actions.changeTool(e.target.value, true) + }} value={app.tool}> {tool_list} - system - dashboard + system + dashboard {site.name} cortex ) diff --git a/app/client/modules/pix2pix/pix2pix.actions.js b/app/client/modules/pix2pix/pix2pix.actions.js index 2359ebf..50cceb6 100644 --- a/app/client/modules/pix2pix/pix2pix.actions.js +++ b/app/client/modules/pix2pix/pix2pix.actions.js @@ -35,11 +35,11 @@ export const load_directories = (id) => (dispatch) => { // console.log(datasetUsage) const sequenceDirectories = sequences.filter(s => s.dir) - console.log(sequenceDirectories) + // console.log(sequenceDirectories) sequenceDirectories.forEach(dir => { const dataset = datasetLoader.getDataset(module, datasetLookup, dir.name) dataset.isBuilt = true - console.log(dir.name, dataset) + // console.log(dir.name, dataset) }) datasets.filter(s => s.dir).forEach(dir => { diff --git a/app/client/system/system.reducer.js b/app/client/system/system.reducer.js index b6c5a83..cc6fe6a 100644 --- a/app/client/system/system.reducer.js +++ b/app/client/system/system.reducer.js @@ -46,7 +46,7 @@ const systemInitialState = { const modules = ['pix2pix','samplernn','pix2wav'].reduce((a,b) => (a[b]=b,a),{}) const systemReducer = (state = systemInitialState, action) => { - console.log(action.type) + // console.log(action.type) let processor = null switch(action.type) { case types.socket.connect: -- cgit v1.2.3-70-g09d2