From 8a6d501cda8f1bf0e8912ac9cc1aa834a22bef04 Mon Sep 17 00:00:00 2001 From: Alex Mikhalev Date: Sat, 11 Aug 2018 19:59:20 +0300 Subject: [PATCH] refactoring --- client/components/App.tsx | 10 +++--- client/components/DeviceView.tsx | 4 +-- client/components/NavBar.tsx | 10 +++--- client/components/ProgramTable.tsx | 4 +-- client/pages/LoginPage.tsx | 2 +- client/pages/LogoutPage.tsx | 2 +- client/pages/ProgramPage.tsx | 4 +-- client/sprinklersRpc/WebSocketRpcClient.ts | 7 +++- client/state/AppState.ts | 40 ++++++++++++---------- client/state/HttpApi.ts | 35 ++++++++++++++++++- client/state/TokenStore.ts | 40 ---------------------- 11 files changed, 80 insertions(+), 78 deletions(-) diff --git a/client/components/App.tsx b/client/components/App.tsx index 7f9a4c3..2d8a52a 100644 --- a/client/components/App.tsx +++ b/client/components/App.tsx @@ -5,7 +5,7 @@ import { Container } from "semantic-ui-react"; import { MessagesView, NavBar } from "@client/components"; import * as p from "@client/pages"; -import * as rp from "@client/routePaths"; +import * as route from "@client/routePaths"; // tslint:disable:ordered-imports import "font-awesome/css/font-awesome.css"; @@ -18,8 +18,8 @@ function NavContainer() { - - + + @@ -31,8 +31,8 @@ function NavContainer() { export default function App() { return ( - - + + ); diff --git a/client/components/DeviceView.tsx b/client/components/DeviceView.tsx index fd5a5b5..6ed54c8 100644 --- a/client/components/DeviceView.tsx +++ b/client/components/DeviceView.tsx @@ -4,7 +4,7 @@ import * as React from "react"; import { Grid, Header, Icon, Item, SemanticICONS } from "semantic-ui-react"; import * as p from "@client/pages"; -import * as rp from "@client/routePaths"; +import * as route from "@client/routePaths"; import { AppState, injectState } from "@client/state"; import { ConnectionState as ConState } from "@common/sprinklersRpc"; import { Route, RouteComponentProps, withRouter } from "react-router"; @@ -67,7 +67,7 @@ class DeviceView extends React.Component - + ); return ( diff --git a/client/components/NavBar.tsx b/client/components/NavBar.tsx index e3ce604..541fae2 100644 --- a/client/components/NavBar.tsx +++ b/client/components/NavBar.tsx @@ -3,7 +3,7 @@ import * as React from "react"; import { Link } from "react-router-dom"; import { Menu } from "semantic-ui-react"; -import * as rp from "@client/routePaths"; +import * as route from "@client/routePaths"; import { AppState, ConsumeState, injectState } from "@client/state"; interface NavItemProps { @@ -26,17 +26,17 @@ function NavBar({ appState }: { appState: AppState }) { let loginMenu; if (appState.isLoggedIn) { loginMenu = ( - Logout + Logout ); } else { loginMenu = ( - Login + Login ); } return ( - Device grinklers - Messages test + Device grinklers + Messages test {loginMenu} diff --git a/client/components/ProgramTable.tsx b/client/components/ProgramTable.tsx index a6aa60e..c67eaeb 100644 --- a/client/components/ProgramTable.tsx +++ b/client/components/ProgramTable.tsx @@ -5,7 +5,7 @@ import { Link } from "react-router-dom"; import { Button, ButtonProps, Form, Icon, Table } from "semantic-ui-react"; import { ProgramSequenceView, ScheduleView } from "@client/components"; -import * as rp from "@client/routePaths"; +import * as route from "@client/routePaths"; import { Program, SprinklersDevice } from "@common/sprinklersRpc"; @observer @@ -21,7 +21,7 @@ class ProgramRows extends React.Component<{ const { name, running, enabled, schedule, sequence } = program; const buttonStyle: ButtonProps = { size: "small", compact: false }; - const detailUrl = rp.program(device.id, program.id); + const detailUrl = route.program(device.id, program.id); const stopStartButton = (