From 8c50c267ad347c795e00e065f613faa1a5beed0f Mon Sep 17 00:00:00 2001 From: Himanshu Date: Fri, 30 Sep 2022 16:23:43 +0530 Subject: [PATCH] Added linting for JSON data input --- .gitignore | 3 ++- api/docker-compose.yml | 18 +++++++++--------- api/package.json | 5 +++-- ui/src/layouts/template.tsx | 23 ++++++++++++++++++++++- yarn.lock | 4 ++++ 5 files changed, 40 insertions(+), 13 deletions(-) create mode 100644 yarn.lock diff --git a/.gitignore b/.gitignore index ccb0e47d..7ff6b932 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ pgdata dist node_modules/ -history \ No newline at end of file +history +package-lock.json \ No newline at end of file diff --git a/api/docker-compose.yml b/api/docker-compose.yml index cc45582a..302b4944 100644 --- a/api/docker-compose.yml +++ b/api/docker-compose.yml @@ -26,12 +26,12 @@ services: # HASURA_GRAPHQL_ENABLED_LOG_TYPES: startup, http-log, webhook-log, websocket-log, query-log # HASURA_GRAPHQL_ADMIN_SECRET: ${HASURA_ADMIN_PASS} - templater: - image: sha256:a8e39ea135548eacb2d6277d6a67d9e36d0da2d1130042bc6eff6646e7e1854b - ports: - - '3007:3000' - depends_on: - - templaterDb - restart: always - environment: - DATABASE_URL: ${DATABASE_URL} + # templater: + # image: sha256:a8e39ea135548eacb2d6277d6a67d9e36d0da2d1130042bc6eff6646e7e1854b + # ports: + # - '3007:3000' + # depends_on: + # - templaterDb + # restart: always + # environment: + # DATABASE_URL: ${DATABASE_URL} diff --git a/api/package.json b/api/package.json index 5db38298..7a150bdb 100644 --- a/api/package.json +++ b/api/package.json @@ -32,16 +32,17 @@ "@nestjs/platform-express": "^8.0.0", "@nestjs/platform-fastify": "^8.2.6", "@nestjs/swagger": "^5.1.5", - "@prisma/client": "3.5.0", + "@prisma/client": "4.3.1", "@types/nunjucks": "^3.2.1", "ejs": "^3.1.6", "fastify-cors": "^6.0.3", "fastify-swagger": "^4.15.0", "json-bigint": "^1.0.0", "nunjucks": "^3.2.3", + "parse-json": "^6.0.2", "passport-google-oauth20": "^2.0.0", "passport-jwt": "^4.0.0", - "prisma": "3.5.0", + "prisma": "4.3.1", "reflect-metadata": "^0.1.13", "rimraf": "^3.0.2", "rxjs": "^7.2.0", diff --git a/ui/src/layouts/template.tsx b/ui/src/layouts/template.tsx index 43a8ddb0..dfac9efa 100644 --- a/ui/src/layouts/template.tsx +++ b/ui/src/layouts/template.tsx @@ -1,4 +1,7 @@ import AceEditor, { IAceOptions } from 'react-ace'; +import 'ace-builds/src-noconflict/mode-json'; +import 'ace-builds/src-noconflict/theme-github'; +import 'ace-builds/webpack-resolver'; import { Box, SimpleGrid } from '@chakra-ui/react'; import { QueryClient, QueryClientProvider, useQuery } from 'react-query'; import axios, { AxiosResponse } from 'axios'; @@ -34,6 +37,7 @@ export function BodyEditor(props: any) { enableSnippets: false, showLineNumbers: true, tabSize: 2, + useWorker: false, }} name="UNIQUE_ID_OF_DIV" value={props.bodyValue} @@ -77,6 +81,9 @@ export function RenderedTemplate(props: any) { readOnly={true} name="RENDERED_TEMPLATE" editorProps={{ $blockScrolling: true }} + setOptions={{ + useWorker: false, + }} /> ); @@ -92,6 +99,9 @@ export function RenderedTemplate(props: any) { readOnly={true} name="RENDERED_TEMPLATE" editorProps={{ $blockScrolling: true }} + setOptions={{ + useWorker: false, + }} /> ); @@ -106,6 +116,9 @@ export function RenderedTemplate(props: any) { readOnly={true} name="RENDERED_TEMPLATE" editorProps={{ $blockScrolling: true }} + setOptions={{ + useWorker: false, + }} /> ); @@ -119,9 +132,17 @@ export function DataEditor(props: any) { mode="json" theme="monokai" name="JSON_EDITOR" + showGutter={true} value={props.dataValue} + onValidate={() => { + console.log('An error has occured'); + }} onChange={(val) => { - console.log({ val }); + // try { + // let myResponse = JSON.parse(val); + // } catch (e) { + console.log(val); + // } props.setDataValue(val); }} editorProps={{ $blockScrolling: true }} diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 00000000..fb57ccd1 --- /dev/null +++ b/yarn.lock @@ -0,0 +1,4 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + +