[GitHub] [incubator-druid] vogievetsky commented on a change in pull request #8777: Web console: Interval input component

2019-11-05 Thread GitBox
vogievetsky commented on a change in pull request #8777: Web console: Interval 
input component
URL: https://github.com/apache/incubator-druid/pull/8777#discussion_r342884494
 
 

 ##
 File path: web-console/src/views/query-view/query-output/query-output.scss
 ##
 @@ -22,6 +22,7 @@
 top: 0;
 bottom: 0;
 width: 100%;
+font-variant-numeric: tabular-nums;
 
 Review comment:
   look at https://css-tricks.com/almanac/properties/f/font-variant-numeric/
   
   I think you also want to add `font-feature-settings: tnum`


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org
For additional commands, e-mail: commits-h...@druid.apache.org



[GitHub] [incubator-druid] vogievetsky commented on a change in pull request #8777: Web console: Interval input component

2019-11-05 Thread GitBox
vogievetsky commented on a change in pull request #8777: Web console: Interval 
input component
URL: https://github.com/apache/incubator-druid/pull/8777#discussion_r342883478
 
 

 ##
 File path: web-console/src/components/interval-input/interval-input.tsx
 ##
 @@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { Button, InputGroup, Popover, Position } from '@blueprintjs/core';
+import { DateRange, DateRangePicker } from '@blueprintjs/datetime';
+import { IconNames } from '@blueprintjs/icons';
+import React, { useState } from 'react';
+
+import './interval-input.scss';
+
+const CURRENT_YEAR = new Date().getUTCFullYear();
+
+export interface IntervalInputProps {
+  interval: string;
+  placeholder: string | undefined;
+  onValueChange: (interval: string) => void;
+}
+
+export const IntervalInput = React.memo(function IntervalInput(props: 
IntervalInputProps) {
+  const [tempInterval, setTempInterval] = useState();
+  const { interval, placeholder, onValueChange } = props;
+
+  function removeLocalTimezone(localDate: Date): Date {
+// Function removes the local timezone of the date and displays it in UTC
+return new Date(localDate.getTime() - localDate.getTimezoneOffset() * 
6);
+  }
+
+  function parseInterval(interval: string): DateRange {
+const dates = interval.split('/');
+if (dates.length !== 2) {
+  return [undefined, undefined];
+}
+const startDate = Date.parse(dates[0]) ? new Date(dates[0]) : undefined;
+const endDate = Date.parse(dates[1]) ? new Date(dates[1]) : undefined;
+// Must check if the start and end dates are within range
+return [
+  startDate && startDate.getFullYear() < CURRENT_YEAR - 20 ? undefined : 
startDate,
+  endDate && endDate.getFullYear() > CURRENT_YEAR ? undefined : endDate,
+];
+  }
+  function parseDateRange(localRange: DateRange): string {
+// This function takes in the dates selected from datepicker in local 
time, and displays them in UTC
+// Shall Blueprint make any changes to the way dates are selected, this 
function will have to be reworked
+const [localStartDate, localEndDate] = localRange;
+return `${
+  localStartDate
+? removeLocalTimezone(localStartDate)
+.toISOString()
+.substring(0, 19)
+: ''
+}/${
+  localEndDate
+? removeLocalTimezone(localEndDate)
+.toISOString()
+.substring(0, 19)
+: ''
+}`;
+  }
+
+  return (
+

[GitHub] [incubator-druid] vogievetsky commented on a change in pull request #8777: Web console: Interval input component

2019-11-05 Thread GitBox
vogievetsky commented on a change in pull request #8777: Web console: Interval 
input component
URL: https://github.com/apache/incubator-druid/pull/8777#discussion_r342883764
 
 

 ##
 File path: web-console/src/components/interval-input/interval-input.tsx
 ##
 @@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { Button, InputGroup, Popover, Position } from '@blueprintjs/core';
+import { DateRange, DateRangePicker } from '@blueprintjs/datetime';
+import { IconNames } from '@blueprintjs/icons';
+import React, { useState } from 'react';
+
+import './interval-input.scss';
+
+const CURRENT_YEAR = new Date().getUTCFullYear();
+
+export interface IntervalInputProps {
+  interval: string;
+  placeholder: string | undefined;
+  onValueChange: (interval: string) => void;
+}
+
+export const IntervalInput = React.memo(function IntervalInput(props: 
IntervalInputProps) {
+  const [tempInterval, setTempInterval] = useState();
+  const { interval, placeholder, onValueChange } = props;
+
+  function removeLocalTimezone(localDate: Date): Date {
+// Function removes the local timezone of the date and displays it in UTC
+return new Date(localDate.getTime() - localDate.getTimezoneOffset() * 
6);
+  }
+
+  function parseInterval(interval: string): DateRange {
+const dates = interval.split('/');
+if (dates.length !== 2) {
+  return [undefined, undefined];
+}
+const startDate = Date.parse(dates[0]) ? new Date(dates[0]) : undefined;
+const endDate = Date.parse(dates[1]) ? new Date(dates[1]) : undefined;
+// Must check if the start and end dates are within range
+return [
+  startDate && startDate.getFullYear() < CURRENT_YEAR - 20 ? undefined : 
startDate,
+  endDate && endDate.getFullYear() > CURRENT_YEAR ? undefined : endDate,
+];
+  }
+  function parseDateRange(localRange: DateRange): string {
+// This function takes in the dates selected from datepicker in local 
time, and displays them in UTC
+// Shall Blueprint make any changes to the way dates are selected, this 
function will have to be reworked
+const [localStartDate, localEndDate] = localRange;
+return `${
+  localStartDate
+? removeLocalTimezone(localStartDate)
+.toISOString()
+.substring(0, 19)
+: ''
+}/${
+  localEndDate
+? removeLocalTimezone(localEndDate)
+.toISOString()
+.substring(0, 19)
+: ''
+}`;
+  }
+
+  return (
+
+   {
+  onValueChange(parseDateRange(selectedRange));
+}}
+  />
+}
+position={Position.BOTTOM_RIGHT}
+  >
+
+  
+
+  }
+  onChange={(e: any) => {
+if (
+  (e.target.value.match(/^[\-0-9T:/]+$/g) && e.target.value.length <= 
39) ||
 
 Review comment:
   This is not what you want, you want to filter here.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org
For additional commands, e-mail: commits-h...@druid.apache.org