Skip to content

Commit

Permalink
Use a new datetime picker for the schedule page
Browse files Browse the repository at this point in the history
The current datetime picker is somewhat not very ergonomic when it comes to picking the time and fails to display correctly on some browers.
This one taken from react-widgets should ease up start time selection for schedules.
Some dependency upgrades were needed as well as converting the style.css file to style.scss (sass).
  • Loading branch information
adejanovski committed Jun 21, 2018
1 parent 32c779f commit c4feb99
Show file tree
Hide file tree
Showing 5 changed files with 165 additions and 122 deletions.
17 changes: 13 additions & 4 deletions src/ui/app/jsx/schedule-form.jsx
@@ -1,7 +1,13 @@
import React from "react";
import { WithContext as ReactTags } from 'react-tag-input';
import $ from "jquery";
import { DateTimePicker } from 'react-widgets';
import momentLocalizer from 'react-widgets-moment';
import Moment from 'moment';
import moment from "moment";

Moment.locale(navigator.language);
momentLocalizer();

const scheduleForm = React.createClass({

Expand All @@ -19,7 +25,7 @@ const scheduleForm = React.createClass({
return {
addScheduleResultMsg: null, clusterNames: [], submitEnabled: false,
clusterName: this.props.currentCluster!="all"?this.props.currentCluster:this.props.clusterNames[0], keyspace: "", tables: "", owner: null, segments: null,
parallelism: null, intensity: null, startTime: null, intervalDays: null, incrementalRepair: null, formCollapsed: true, nodes: null, datacenters: null,
parallelism: null, intensity: null, startTime: moment().toDate(), intervalDays: null, incrementalRepair: null, formCollapsed: true, nodes: null, datacenters: null,
nodes: "", datacenters: "", blacklistedTables: "", nodeList: [], datacenterList: [], clusterStatus: {}, urlPrefix: URL_PREFIX, nodeSuggestions: [], datacenterSuggestions: [],
clusterTables: {}, tableSuggestions: [], blacklistSuggestions: [], tableList: [], blacklistList: [], keyspaceList: [], keyspaceSuggestions: [],
blacklistReadOnly: false, tablelistReadOnly: false, advancedFormCollapsed: true, repairThreadCount: 1
Expand Down Expand Up @@ -94,7 +100,7 @@ const scheduleForm = React.createClass({
_onAdd: function(e) {
const schedule = {
clusterName: this.state.clusterName, keyspace: this.state.keyspace,
owner: this.state.owner, scheduleTriggerTime: this.state.startTime,
owner: this.state.owner, scheduleTriggerTime: moment(this.state.startTime).format("YYYY-MM-DDTHH:mm:ss"),
scheduleDaysBetween: this.state.intervalDays
};
if(this.state.tables) schedule.tables = this.state.tables;
Expand Down Expand Up @@ -404,8 +410,11 @@ const scheduleForm = React.createClass({
<div className="form-group">
<label htmlFor="in_startTime" className="col-sm-3 control-label">Start time*</label>
<div className="col-sm-9 col-md-7 col-lg-5">
<input type="datetime-local" required className="form-control"
onChange={this._handleChange} value={this.state.startTime} id="in_startTime"/>
<DateTimePicker
value={this.state.startTime}
onChange={value => this.setState({ startTime: value })}
step={15}
/>
</div>
</div>
<div className="form-group">
Expand Down
112 changes: 0 additions & 112 deletions src/ui/app/style.css

This file was deleted.

136 changes: 136 additions & 0 deletions src/ui/app/style.scss
@@ -0,0 +1,136 @@
//colors
$black: #000;
$color_concrete_approx: #f3f3f3;
$color_curious_blue_approx: #3498db;
$color_gallery_approx: #eee;
$color_alto_approx: #ddd;
$color_silver_chalice_approx: #aaa;
$black_20: rgba(0,0,0,.2);
$white: white;
$color_spindle_approx: #b7cfe0;

tr[data-toggle='collapse'] {
cursor: pointer;
}
td[data-toggle='collapse'] {
cursor: pointer;
}
.progress-bar {
color: $black;
}
.clusterLoader {
border: 16px solid $color_concrete_approx;
border-top: 16px solid $color_curious_blue_approx;
//Instead of the line below you could use @include border-radius($radius, $vertical-radius)
border-radius: 50%;
width: 4em;
height: 4em;
animation: spin 2s linear infinite;
}
.smallLoader {
border: 16px solid $color_concrete_approx;
border-top: 16px solid $color_curious_blue_approx;
//Instead of the line below you could use @include border-radius($radius, $vertical-radius)
border-radius: 50%;
width: 2em;
height: 2em;
animation: spin 2s linear infinite;
}
@keyframes spin {
0% {
//Instead of the line below you could use @include transform($scale, $rotate, $transx, $transy, $skewx, $skewy, $originx, $originy)
transform: rotate(0deg);
}
100% {
//Instead of the line below you could use @include transform($scale, $rotate, $transx, $transy, $skewx, $skewy, $originx, $originy)
transform: rotate(360deg);
}
}
div {
&.ReactTags__tags {
position: relative;
}
&.ReactTags__tagInput {
width: 200px;
//Instead of the line below you could use @include border-radius($radius, $vertical-radius)
border-radius: 2px;
display: inline-block;
input.ReactTags__tagInputField {
height: 31px;
margin: 0;
font-size: 12px;
width: 100%;
border: 1px solid $color_gallery_approx;
&:focus {
height: 31px;
margin: 0;
font-size: 12px;
width: 100%;
border: 1px solid $color_gallery_approx;
}
}
}
&.ReactTags__selected {
span.ReactTags__tag {
border: 1px solid $color_alto_approx;
background: $color_gallery_approx;
font-size: 12px;
display: inline-block;
padding: 5px;
margin: 0 5px;
//Instead of the line below you could use @include border-radius($radius, $vertical-radius)
border-radius: 2px;
}
a.ReactTags__remove {
color: $color_silver_chalice_approx;
margin-left: 5px;
cursor: pointer;
}
}
&.ReactTags__suggestions {
position: absolute;
z-index: 10000;
ul {
list-style-type: none;
//Instead of the line below you could use @include box-shadow($shadow-1, $shadow-2, $shadow-3, $shadow-4, $shadow-5, $shadow-6, $shadow-7, $shadow-8, $shadow-9, $shadow-10)
box-shadow: .05em .01em .5em $black_20;
background: $white;
width: 200px;
li.ReactTags__activeSuggestion {
background: $color_spindle_approx;
cursor: pointer;
}
}
li {
border-bottom: 1px solid $color_alto_approx;
padding: 5px 10px;
margin: 0;
mark {
text-decoration: underline;
background: none;
font-weight: 600;
}
}
}
}
.form-control-hidden {
display: none;
}
.large-modal {
width: 90%;
}
.form-inline input {
margin: 0 1em;
}
.form-condensed .form-group {
margin-top: .5em;
margin-bottom: .5em;
}
td > button {
margin-right: .5em;
}

$font-size: 16px;
$input-height: 2.5em; // at 16px, this an even 40px

@import '~react-widgets/lib/scss/react-widgets';
17 changes: 13 additions & 4 deletions src/ui/package.json
Expand Up @@ -19,17 +19,26 @@
"css-loader": "^0.9.1",
"file-loader": "^0.8.1",
"jsx-loader": "^0.12.2",
"react": "^0.14.0",
"react-dom": "^0.14.0",
"react": "^15.0.0",
"react-dom": "^15.0.0",
"react-bootstrap": "^0.31.0",
"react-hot-loader": "^1.2.4",
"style-loader": "^0.8.3",
"url-loader": "^0.5.5",
"webpack": "^1.7.3",
"webpack": "^1.15.0",
"webpack-dev-server": "^1.7.0",
"react-tag-input": "^4.7.2",
"html-webpack-plugin": "^2.30.1",
"react-notification-system": "^0.2.0"
"react-notification-system": "^0.2.0",
"react-widgets": "^4.3.2",
"lodash": "^4.17.10",
"moment": "^2.22.2",
"react-widgets-moment": "^4.0.15",
"raw-loader": "^0.5.1",
"sass-loader": "^7.0.3",
"scss":"^0.2.4",
"node-sass":"^4.9.0",
"resolve-url-loader": "^2.3.0"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
Expand Down
5 changes: 3 additions & 2 deletions src/ui/webpack.config.js
Expand Up @@ -3,7 +3,7 @@ var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');

var _commonDeps = [
"bootstrap.css", "sb-admin-2.css", "timeline.css", "font-awesome.css", "metisMenu.css", "style.css",
"bootstrap.css", "sb-admin-2.css", "timeline.css", "font-awesome.css", "metisMenu.css", "style.scss",
"jquery", "react", "bootstrap", "metisMenu", "sb-admin-2", "rxjs"
];

Expand Down Expand Up @@ -125,9 +125,10 @@ module.exports = {
include: path.join(__dirname, 'app')
},
{ test: /\.css$/, loader: "style-loader!css-loader" },
{ test: /\.scss$/, loaders: ["style","css","resolve-url","sass?sourceMap"]},
// loaders for font-awesome
{ test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: "url-loader?limit=10000&minetype=application/font-woff" },
{ test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: "file-loader" }
{ test: /\.(gif|ttf|eot|svg?)(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: 'url-loader?name=[name].[ext]' }
]
}
};

0 comments on commit c4feb99

Please sign in to comment.