From 81f156f019452e336da7c2b29c22e92636590132 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Mon, 8 Mar 2021 14:25:22 +0100 Subject: [PATCH] ic-action: improve styling --- src/ic/ic-action.js | 78 ++++++++++++++++++++-------------------- src/ic/ics.js | 4 --- src/scenario/scenario.js | 2 -- 3 files changed, 38 insertions(+), 46 deletions(-) diff --git a/src/ic/ic-action.js b/src/ic/ic-action.js index 9c39da4..c5358c5 100644 --- a/src/ic/ic-action.js +++ b/src/ic/ic-action.js @@ -16,23 +16,24 @@ ******************************************************************************/ import React from 'react'; -import { Button, DropdownButton, Dropdown, InputGroup, FormControl } from 'react-bootstrap'; +import { Form, SplitButton, Dropdown, FormControl } from 'react-bootstrap'; import AppDispatcher from "../common/app-dispatcher"; import NotificationsFactory from "../common/data-managers/notifications-factory"; import NotificationsDataManager from "../common/data-managers/notifications-data-manager"; + +Number.prototype.pad = function(size) { + var s = String(this); + while (s.length < (size || 2)) { + s = "0" + s; + } + return s; +} + class ICAction extends React.Component { constructor(props) { super(props); - let t = new Date() - - Number.prototype.pad = function(size) { - var s = String(this); - while (s.length < (size || 2)) {s = "0" + s;} - return s; - } - let time = new Date(); time.setMinutes(5 * Math.round(time.getMinutes() / 5 + 1)) @@ -60,7 +61,7 @@ class ICAction extends React.Component { return; } - if (!this.props.hasConfigs) { + if (!this.props.configs) { let newAction = {}; newAction["action"] = action.data.action newAction["when"] = when @@ -203,13 +204,15 @@ class ICAction extends React.Component { render() { - let sendCommandDisabled = false; - if (!this.props.hasConfigs && this.props.selectedICs.length === 0 || this.state.selectedAction == null || this.state.selectedAction.id === "-1") { - sendCommandDisabled = true; - } - if (this.props.hasConfigs && this.props.selectedConfigs.length === 0|| this.state.selectedAction == null || this.state.selectedAction.id === "-1") { - sendCommandDisabled = true; - } + let disabled = this.state.selectedAction == null || + (this.props.configs + ? this.props.selectedConfigs.length === 0 + : this.props.selectedICs.length === 0 + ); + + let splitButtonStyle = { + marginLeft: '10px' + }; let time = this.state.time.getFullYear().pad(4) + '-' + this.state.time.getMonth().pad(2) + '-' + @@ -223,29 +226,24 @@ class ICAction extends React.Component { )); - return
- - - - {actionList} - - - - - - Select time for synced command execution -
; + return
+
+ + this.runAction(this.state.selectedAction, this.state.time)}> + {actionList} + + + Select time for synced command execution +
; } } diff --git a/src/ic/ics.js b/src/ic/ics.js index 6bf620b..4ef4ad6 100644 --- a/src/ic/ics.js +++ b/src/ic/ics.js @@ -506,12 +506,10 @@ class InfrastructureComponents extends Component { {this.state.currentUser.role === "Admin" && this.state.numberOfExternalICs > 0 ?
this.closeICModal(data)} ic={this.state.modalIC} token={this.state.sessionToken} - userRole={this.state.currentUser.role} sendControlCommand={(command, ic) => this.sendControlCommand(command, ic)}/> -
); } diff --git a/src/scenario/scenario.js b/src/scenario/scenario.js index 2bd909f..f1d2583 100644 --- a/src/scenario/scenario.js +++ b/src/scenario/scenario.js @@ -873,14 +873,12 @@ class Scenario extends React.Component { {this.state.ExternalICInUse ? (
this.copyConfig(index)} token = {this.state.sessionToken} actions={[ - { id: '-1', title: 'Action', data: { action: 'none' } }, { id: '0', title: 'Start', data: { action: 'start' } }, { id: '1', title: 'Stop', data: { action: 'stop' } }, { id: '2', title: 'Pause', data: { action: 'pause' } },