From a9136705c91236d4666d6812b21fad704da184ac Mon Sep 17 00:00:00 2001 From: ahmedyasser <26207361+1AhmedYasser@users.noreply.github.com> Date: Tue, 27 Feb 2024 22:40:45 +0200 Subject: [PATCH 01/11] Added Database Modifications --- .../changelog/1709066018-add-ready-status.sql | 3 ++ constants.ini | 2 ++ docker-compose.yml | 30 ++++++++++++++++--- 3 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 DSL/Liquibase/changelog/1709066018-add-ready-status.sql diff --git a/DSL/Liquibase/changelog/1709066018-add-ready-status.sql b/DSL/Liquibase/changelog/1709066018-add-ready-status.sql new file mode 100644 index 00000000..0bd2b9fe --- /dev/null +++ b/DSL/Liquibase/changelog/1709066018-add-ready-status.sql @@ -0,0 +1,3 @@ +-- liquibase formatted sql +-- changeset ahmedyasser:1709066018 +ALTER TYPE service_state ADD VALUE 'ready'; diff --git a/constants.ini b/constants.ini index b2e0fb76..ff2b5569 100644 --- a/constants.ini +++ b/constants.ini @@ -4,6 +4,8 @@ SERVICE_RESQL=http://resql:8087 SERVICE_USERS_RESQL=http://resql-users:8088 +SERVICE_TRAINING_RESQL=http://resql-training:8089 + SERVICE_NODE=http://node_server:3008 SERVICE_DOCKER_INT=http://host.docker.internal:8080 diff --git a/docker-compose.yml b/docker-compose.yml index a3a8952d..1d500209 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -26,7 +26,7 @@ services: environment: - POSTGRES_USER=byk - POSTGRES_PASSWORD=01234 - - POSTGRES_MULTIPLE_DATABASES=users_db,services_db + - POSTGRES_MULTIPLE_DATABASES=users_db,services_db,training_db ports: - 5433:5432 volumes: @@ -42,7 +42,8 @@ services: - database environment: - sqlms.datasources.[0].name=services - - sqlms.datasources.[0].jdbcUrl=jdbc:postgresql://database:5432/services_db + # - sqlms.datasources.[0].jdbcUrl=jdbc:postgresql://database:5432/services_db // For Local Use + - sqlms.datasources.[0].jdbcUrl=jdbc:postgresql://171.22.247.13:5435/services_db - sqlms.datasources.[0].username=byk - sqlms.datasources.[0].password=01234 - logging.level.org.springframework.boot=INFO @@ -62,9 +63,10 @@ services: environment: - server.port=8088 - sqlms.datasources.[0].name=users - - sqlms.datasources.[0].jdbcUrl=jdbc:postgresql://database:5432/users_db + # - sqlms.datasources.[0].jdbcUrl=jdbc:postgresql://database:5432/users_db // For Local Use + - sqlms.datasources.[0].jdbcUrl=jdbc:postgresql://171.22.247.13:5433/byk - sqlms.datasources.[0].username=byk - - sqlms.datasources.[0].password=01234 + - sqlms.datasources.[0].password=2nH09n6Gly - logging.level.org.springframework.boot=INFO ports: - 8088:8088 @@ -73,6 +75,26 @@ services: networks: - bykstack + resql_training: + container_name: resql-training + image: resql + depends_on: + - database + environment: + - server.port=8089 + - sqlms.datasources.[0].name=training + # - sqlms.datasources.[0].jdbcUrl=jdbc:postgresql://database:5432/training_db // For Local Use + - sqlms.datasources.[0].jdbcUrl=jdbc:postgresql://171.22.247.13:5434/train_db + - sqlms.datasources.[0].username=byk + - sqlms.datasources.[0].password=01234 + - logging.level.org.springframework.boot=INFO + ports: + - 8089:8089 + volumes: + - ./DSL/Resql/training:/workspace/app/templates/training + networks: + - bykstack + data_mapper: container_name: data_mapper image: data-mapper From fadb4fc40983957f9b743bf8cab49478a71bfd47 Mon Sep 17 00:00:00 2001 From: ahmedyasser <26207361+1AhmedYasser@users.noreply.github.com> Date: Wed, 28 Feb 2024 02:24:04 +0200 Subject: [PATCH 02/11] Added New Status logic --- DSL/Resql/training/delete-service-trigger.sql | 2 + DSL/Resql/training/get-service-trigger.sql | 9 ++ .../POST/services/check-intent-connection.yml | 15 ++++ DSL/Ruuter/POST/services/status.yml | 19 ++-- GUI/src/components/Dialog/Dialog.scss | 10 +++ GUI/src/components/Dialog/index.tsx | 48 +++++----- GUI/src/components/Modal/index.tsx | 34 +++---- GUI/src/components/ServicesTable/index.tsx | 88 +++++++++++++++---- GUI/src/i18n/en/common.json | 13 ++- GUI/src/i18n/et/common.json | 13 ++- GUI/src/resources/api-constants.ts | 3 +- GUI/src/store/services.store.ts | 72 +++++++++++---- GUI/src/styles/main.scss | 9 ++ GUI/src/types/service-state.ts | 3 +- 14 files changed, 251 insertions(+), 87 deletions(-) create mode 100644 DSL/Resql/training/delete-service-trigger.sql create mode 100644 DSL/Resql/training/get-service-trigger.sql create mode 100644 DSL/Ruuter/POST/services/check-intent-connection.yml diff --git a/DSL/Resql/training/delete-service-trigger.sql b/DSL/Resql/training/delete-service-trigger.sql new file mode 100644 index 00000000..69478de3 --- /dev/null +++ b/DSL/Resql/training/delete-service-trigger.sql @@ -0,0 +1,2 @@ +INSERT INTO service_trigger (intent, service, status, author_role) +VALUES (:intent, :serviceId, 'deleted', :authorRole) diff --git a/DSL/Resql/training/get-service-trigger.sql b/DSL/Resql/training/get-service-trigger.sql new file mode 100644 index 00000000..128df592 --- /dev/null +++ b/DSL/Resql/training/get-service-trigger.sql @@ -0,0 +1,9 @@ +SELECT id, intent, service, status, author_role, created +FROM service_trigger +WHERE service = :serviceId + AND id = ( + SELECT MAX(id) + FROM service_trigger + WHERE service = :serviceId + ) + AND status != 'deleted'; diff --git a/DSL/Ruuter/POST/services/check-intent-connection.yml b/DSL/Ruuter/POST/services/check-intent-connection.yml new file mode 100644 index 00000000..cd68b0c7 --- /dev/null +++ b/DSL/Ruuter/POST/services/check-intent-connection.yml @@ -0,0 +1,15 @@ +extract_request_data: + assign: + serviceId: ${incoming.body.serviceId} + +check_for_intent_connection: + call: http.post + args: + url: "[#SERVICE_TRAINING_RESQL]/get-service-trigger" + body: + serviceId: ${serviceId} + result: res + +return_result: + status: 200 + return: ${res.response.body[0]} diff --git a/DSL/Ruuter/POST/services/status.yml b/DSL/Ruuter/POST/services/status.yml index 4fc48646..aafc87c6 100644 --- a/DSL/Ruuter/POST/services/status.yml +++ b/DSL/Ruuter/POST/services/status.yml @@ -9,8 +9,8 @@ check_for_required_parameters: switch: - condition: ${id === null || new_state === null || ruuter_type === null} next: return_incorrect_request - - condition: ${new_state === "draft"} - next: return_cant_set_to_draft + - condition: ${new_state === "draft" || new_state === "ready"} + next: set_plain_status next: get_current_status get_current_status: @@ -44,6 +44,16 @@ set_status: result: res next: get_status_name +set_plain_status: + call: http.post + args: + url: "[#SERVICE_RESQL]/set-status" + body: + id: ${id} + new_state: ${new_state} + result: draft_res + next: return_ok + get_status_name: call: http.post args: @@ -115,11 +125,6 @@ return_incorrect_request: return: "Required parameter(s) missing" next: end -return_cant_set_to_draft: - status: 400 - return: "Changing state to draft is not allowed" - next: end - return_same_state_update: status: 400 return: "Service is already in this state" diff --git a/GUI/src/components/Dialog/Dialog.scss b/GUI/src/components/Dialog/Dialog.scss index ae6eaf6b..7af6a64b 100644 --- a/GUI/src/components/Dialog/Dialog.scss +++ b/GUI/src/components/Dialog/Dialog.scss @@ -14,6 +14,11 @@ width: 100%; max-width: 600px; z-index: 101; + max-height: 90vh; + + &--large { + max-width: 800px; + } &__overlay { position: fixed; @@ -47,6 +52,11 @@ font-size: 20px; } + &__body { + overflow: auto; + max-height: calc(90vh - 70px); + } + &__footer { border-top: 1px solid get-color(black-coral-2); } diff --git a/GUI/src/components/Dialog/index.tsx b/GUI/src/components/Dialog/index.tsx index 0be0d601..ad67501f 100644 --- a/GUI/src/components/Dialog/index.tsx +++ b/GUI/src/components/Dialog/index.tsx @@ -1,35 +1,39 @@ -import React, { FC, PropsWithChildren, ReactNode } from 'react'; -import * as RadixDialog from '@radix-ui/react-dialog'; -import { MdOutlineClose } from 'react-icons/md'; +import { FC, PropsWithChildren, ReactNode } from "react"; +import * as RadixDialog from "@radix-ui/react-dialog"; +import { MdOutlineClose } from "react-icons/md"; +import clsx from "clsx"; -import { Icon, Track } from '../../components'; -import './Dialog.scss'; +import { Icon, Track } from "components"; +import "./Dialog.scss"; type DialogProps = { - title: string; + title?: string | null; footer?: ReactNode; onClose: () => void; -} + size?: "default" | "large"; +}; -const Dialog: FC> = ({ title, footer, onClose, children }) => { +const Dialog: FC> = ({ title, footer, onClose, size = "default", children }) => { return ( - - -
- {title} - - - -
-
- {children} -
+ + + {title && ( +
+ {title} + + + +
+ )} +
{children}
{footer && ( - {footer} + + {footer} + )}
diff --git a/GUI/src/components/Modal/index.tsx b/GUI/src/components/Modal/index.tsx index 16af56da..d6dd692e 100644 --- a/GUI/src/components/Modal/index.tsx +++ b/GUI/src/components/Modal/index.tsx @@ -1,30 +1,32 @@ -import React, { FC, PropsWithChildren, ReactNode } from 'react'; -import * as RadixDialog from '@radix-ui/react-dialog'; -import { MdOutlineClose } from 'react-icons/md'; +import React, { FC, PropsWithChildren, ReactNode } from "react"; +import * as RadixDialog from "@radix-ui/react-dialog"; +import { MdOutlineClose } from "react-icons/md"; -import { Icon, Track } from '..'; -import './Modal.scss'; +import { Icon, Track } from ".."; +import "./Modal.scss"; type ModalProps = { - title: string; + title: string | null; footer?: ReactNode; onClose: () => void; -} +}; const Modal: FC> = ({ title, footer, onClose, children }) => { return ( - - -
- {title} -
-
- {children} -
+ + + {title && ( +
+ {title} +
+ )} +
{children}
{footer && ( - {footer} + + {footer} + )}
diff --git a/GUI/src/components/ServicesTable/index.tsx b/GUI/src/components/ServicesTable/index.tsx index b97a30bd..1923cc91 100644 --- a/GUI/src/components/ServicesTable/index.tsx +++ b/GUI/src/components/ServicesTable/index.tsx @@ -4,7 +4,7 @@ import { useNavigate } from "react-router-dom"; import { useTranslation } from "react-i18next"; import { MdDeleteOutline, MdOutlineDescription, MdOutlineEdit } from "react-icons/md"; import { IoCopyOutline } from "react-icons/io5"; -import { Button, Card, Icon, Label, Modal, Tooltip, Track } from ".."; +import { Button, Card, Dialog, Icon, Label, Modal, Tooltip, Track } from ".."; import { Service } from "../../types/service"; import { ServiceState } from "../../types/service-state"; import DataTable from "../DataTable"; @@ -14,6 +14,7 @@ import useStore from "store/store"; import useServiceListStore from "store/services.store"; import { ROUTES } from "resources/routes-constants"; import useToastStore from "store/toasts.store"; +import "../../styles/main.scss"; type ServicesTableProps = { isCommon?: boolean; @@ -35,7 +36,11 @@ const ServicesTable: FC = ({ isCommon = false }) => { const [isDeletePopupVisible, setDeletePopupVisible] = useState(false); const userInfo = useStore((state) => state.userInfo); const [isStatePopupVisible, setStatePopupVisible] = useState(false); + const [isReadyPopupVisible, setReadyPopupVisible] = useState(false); + const [isIntentConnectionPopupVisible, setIntentConnectionPopupVisible] = useState(false); const [popupText, setPopupText] = useState(""); + const [readyPopupText, setReadyPopupText] = useState(""); + const [isReadyStatusChecking, setReadyStatusChecking] = useState(false); const services = useServiceListStore((state) => state.services.filter((x) => x.isCommon === isCommon)); const columnHelper = createColumnHelper(); const navigate = useNavigate(); @@ -108,14 +113,27 @@ const ServicesTable: FC = ({ isCommon = false }) => { { - showStatePopup( - t( - props.row.original.state === ServiceState.Active - ? "overview.popup.setInactive" - : "overview.popup.setActive" - ) - ); useServiceListStore.getState().setSelectedService(props.row.original); + if (props.row.original.state === ServiceState.Ready) { + console.log("ready"); + // setReadyPopupText(text); + checkIntentConnection(); + setReadyStatusChecking(true); + setReadyPopupVisible(true); + // setTimeout(() => { + // setReadyStatusChecking(false); + // }, 2000); + } else { + showStatePopup( + t( + props.row.original.state === ServiceState.Draft + ? "overview.popup.setReady" + : props.row.original.state === ServiceState.Active + ? "overview.popup.setInactive" + : "overview.popup.setActive" + ) + ); + } }} >