From b83e7f2fa57acfc8b76a5f8c32bd790a6471be54 Mon Sep 17 00:00:00 2001
From: unknown <n.santhanam@redkarma.eu>
Date: Thu, 25 Feb 2021 11:16:55 +0530
Subject: [PATCH] TMSS-494

Changes updated based on review comments
---
 .../src/components/JSONEditor/JEditor.js      | 23 +++++++++----------
 .../Scheduling/Scheduling.Constraints.js      |  2 +-
 .../tmss_webapp/src/utils/unit.converter.js   |  4 ++--
 3 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/SAS/TMSS/frontend/tmss_webapp/src/components/JSONEditor/JEditor.js b/SAS/TMSS/frontend/tmss_webapp/src/components/JSONEditor/JEditor.js
index 31430018464..c339a9188b3 100644
--- a/SAS/TMSS/frontend/tmss_webapp/src/components/JSONEditor/JEditor.js
+++ b/SAS/TMSS/frontend/tmss_webapp/src/components/JSONEditor/JEditor.js
@@ -8,6 +8,7 @@ import _ from 'lodash';
 import UnitConverter from '../../utils/unit.converter'
 import $RefParser from "@apidevtools/json-schema-ref-parser";
 import "@fortawesome/fontawesome-free/css/all.css";
+import flatpickr from 'flatpickr';
 import "flatpickr/dist/flatpickr.css";
 const JSONEditor = require("@json-editor/json-editor").JSONEditor;
 
@@ -148,7 +149,7 @@ function Jeditor(props) {
                     errors.push({
                         path: path,
                         property: 'validationType',
-                        message: 'Not a valid input. Mimimum: 00:00:00.0000, Maximum:23:59:59.0000'
+                        message: 'Not a valid input. Mimimum: 00:00:00.0000, Maximum:23:59:59.9999'
                     });
                 }
             }   else if (schema.validationType === "angle") {
@@ -156,7 +157,7 @@ function Jeditor(props) {
                     errors.push({
                         path: path,
                         property: 'validationType',
-                        message: 'Not a valid input. Mimimum: 00:00:00.0000, Maximum:90:00:00.0000'
+                        message: 'Not a valid input. Mimimum: 00:00:00.0000, Maximum:90:00:00.9999'
                     });
                 }
             } else if (schema.validationType === "distanceOnSky") {
@@ -260,12 +261,12 @@ function Jeditor(props) {
             options: {
                 "grid_columns": 4,
                 "inputAttributes": {
-                    "placeholder": isDegree?"DD:mm:ss.ms":"HH:mm:ss:ms"
+                    "placeholder": isDegree?"DD:mm:ss.ssss":"HH:mm:ss.ssss"
                 },
                 "cleave": {
                     numericOnly: true,
                     blocks: [2, 2, 2, 4],
-                    delimiters: isDegree ? [':', ':','.'] : [':', ':', ':'],
+                    delimiters: isDegree ? [':', ':','.'] : [':', ':', '.'],
                     delimiterLazyShow: true
                 }
             }
@@ -440,12 +441,12 @@ function Jeditor(props) {
      */
     function validateTime(prpOutput) {
         const splitOutput = prpOutput.split(':');
-        const isMilliSecondsPresent = splitOutput[3];
-        if (splitOutput.length < 3 || (isMilliSecondsPresent[1] && isMilliSecondsPresent[1].length > 4)) {
+        if (splitOutput.length < 3) {
         // if (splitOutput.length < 3) {
             return false;
         }   else {
-            if (parseInt(splitOutput[0]) > 23 || parseInt(splitOutput[1])>59 || parseInt(splitOutput[2])>59) {
+            if (parseInt(splitOutput[0]) > 23 || parseInt(splitOutput[1])>59 || parseInt(splitOutput[2])>59 )
+             {
                 return false;
             }
             const timeValue = parseInt(splitOutput[0]*60*60) + parseInt(splitOutput[1]*60) + parseInt(splitOutput[2]*1000);
@@ -462,15 +463,13 @@ function Jeditor(props) {
      */
     function validateAngle(prpOutput) {
         const splitOutput = prpOutput.split(':');
-        const isMilliSecondsPresent = prpOutput.split('.');
-        if (splitOutput.length < 3 || isMilliSecondsPresent[1].length > 4) {
-        //if (splitOutput.length < 3) {
+        if (splitOutput.length < 3) {
             return false;
         }   else {
-            if (parseInt(splitOutput[0]) > 90 || parseInt(splitOutput[1])>59 || parseInt(splitOutput[2])>59 || parseInt(splitOutput[3])>999) {
+            if (parseInt(splitOutput[0]) > 90 || parseInt(splitOutput[1])>59 || parseInt(splitOutput[2])>59) {
                 return false;
             }
-            const timeValue = parseInt(splitOutput[0]*60*60) + parseInt(splitOutput[1]*60) + parseInt(splitOutput[2]*1000 + parseInt(splitOutput[3]));
+            const timeValue = parseInt(splitOutput[0]*60*60) + parseInt(splitOutput[1]*60) + parseInt(splitOutput[2]*1000);
             if (timeValue > 324000) {
                 return false;
             }
diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/Scheduling.Constraints.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/Scheduling.Constraints.js
index ff0ccab1672..caad1b2674b 100644
--- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/Scheduling.Constraints.js
+++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/Scheduling.Constraints.js
@@ -71,7 +71,7 @@ export default (props) => {
         propertyValue.skipFormat = true;
         propertyValue.options = {
             "inputAttributes": {
-                "placeholder": "mm/dd/yyyy,--:--:--"
+                "placeholder": "yyyy-mm-dd,--:--:--"
               },
             "flatpickr": {
                 "inlineHideInput": true,
diff --git a/SAS/TMSS/frontend/tmss_webapp/src/utils/unit.converter.js b/SAS/TMSS/frontend/tmss_webapp/src/utils/unit.converter.js
index 4b848390ed0..a409966edcf 100644
--- a/SAS/TMSS/frontend/tmss_webapp/src/utils/unit.converter.js
+++ b/SAS/TMSS/frontend/tmss_webapp/src/utils/unit.converter.js
@@ -106,7 +106,7 @@ const UnitConverter = {
             if (isDegree) {
                 return ((splitOutput[0]*1 + splitOutput[1]/60 + splitOutput[2].split('.')[0]/3600 + milliSeconds/36000000)*Math.PI/180);
             }   else {
-                return ((splitOutput[0]*15 + splitOutput[1]/4  + splitOutput[2]/240 + splitOutput[3]/2400000)*Math.PI/180);
+                return ((splitOutput[0]*15 + splitOutput[1]/4  + splitOutput[2].split('.')[0]/240 + milliSeconds/2400000)*Math.PI/180);
             }
         }else{
             return "00:00:00.0000";
@@ -114,7 +114,7 @@ const UnitConverter = {
     },
 
     /**
-     * Function to add leading zeros in end
+     * Function to add trailing zeros in end
      * @param {*} number 
      * @param {*} digits 
      */
-- 
GitLab