Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions DSL/Resql/services/POST/endpoints/get_common_endpoints.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,17 @@ SELECT
name,
type,
is_common,
definitions
definitions,
CASE WHEN :pagination THEN CEIL(COUNT(*) OVER() / :page_size::DECIMAL) ELSE 1 END AS total_pages
FROM endpoints
WHERE is_common = true
AND deleted IS FALSE
ORDER BY id DESC;
AND (:search IS NULL OR :search = '' OR LOWER(name) LIKE LOWER('%' || :search || '%'))
ORDER BY
CASE WHEN :sorting = 'created_at asc' THEN created_at END ASC NULLS LAST,
CASE WHEN :sorting = 'created_at desc' THEN created_at END DESC NULLS LAST,
CASE WHEN :sorting = 'name asc' THEN name END ASC NULLS LAST,
CASE WHEN :sorting = 'name desc' THEN name END DESC NULLS LAST,
created_at DESC
OFFSET (CASE WHEN :pagination THEN (GREATEST(:page, 1) - 1) * :page_size ELSE 0 END)
LIMIT (CASE WHEN :pagination THEN :page_size END);
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ FROM endpoints AS e
CROSS JOIN UserPreferences AS up
WHERE (e.service_id = :id::uuid OR e.is_common = true)
AND e.deleted IS FALSE
AND (:search IS NULL OR :search = '' OR LOWER(e.name) LIKE LOWER('%' || :search || '%'))
ORDER BY
CASE
WHEN up.endpoints IS NULL OR array_length(up.endpoints, 1) = 0 THEN 1
Expand All @@ -23,4 +24,4 @@ ORDER BY
CASE
WHEN up.endpoints IS NULL OR array_length(up.endpoints, 1) = 0 THEN e.id
ELSE NULL
END DESC;
END DESC;
17 changes: 0 additions & 17 deletions DSL/Ruuter/services/GET/endpoints/common.yml

This file was deleted.

48 changes: 48 additions & 0 deletions DSL/Ruuter/services/POST/endpoints/common.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
declaration:
call: declare
version: 0.1
description: "Decription placeholder for 'Common'"
method: post
accepts: json
returns: json
namespace: service
allowlist:
body:
- field: pagination
type: string
description: "Body field 'pagination'"
- field: page
type: string
description: "Body field 'page'"
- field: pageSize
type: string
description: "Body field 'pageSize'"
- field: sorting
type: string
description: "Body field 'sorting'"
- field: search
type: string
description: "Body field 'search'"

extract_request_data:
assign:
pagination: ${incoming.body.pagination}
page: ${incoming.body.page}
pageSize: ${incoming.body.pageSize}
sorting: ${incoming.body.sorting}
search: ${incoming.body.search}

get_common_endpoints:
call: http.post
args:
url: "[#SERVICE_RESQL]/endpoints/get_common_endpoints"
body:
pagination: ${pagination}
page: ${page}
page_size: ${pageSize}
sorting: ${sorting}
search: ${search}
result: res

return_result:
return: ${res.response.body}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ declaration:
call: declare
version: 0.1
description: "Decription placeholder for 'SERVICE-BY-ID'"
method: get
method: post
accepts: json
returns: json
namespace: service
Expand All @@ -11,15 +11,18 @@ declaration:
- field: cookie
type: string
description: "Cookie field"
params:
body:
- field: id
type: string
description: "Parameter 'id'"
description: "Body field 'id'"
- field: search
type: string
description: "Body field 'search'"

check_for_parameters:
switch:
- condition: ${incoming.params == null || incoming.params.id == null}
next: return_incorrect_request
extract_request_data:
assign:
id: ${incoming.body.id}
search: ${incoming.body.search}

get_user_info:
call: http.post
Expand All @@ -46,16 +49,17 @@ get_service_by_id:
args:
url: "[#SERVICE_RESQL]/get-service-by-id"
body:
id: ${incoming.params.id}
id: ${id}
result: service_results

get_endpoints_by_service_id:
call: http.post
args:
url: "[#SERVICE_RESQL]/endpoints/get_endpoints_by_service_id"
body:
id: ${incoming.params.id}
id: ${id}
user_id_code: ${idCode}
search: ${search}
result: endpoints_results

prepare_results:
Expand All @@ -80,11 +84,6 @@ return_ok:
return: ${results}
next: end

return_incorrect_request:
status: 400
return: "Required parameter(s) missing"
next: end

return_unauthorized:
status: 401
return: "unauthorized"
Expand Down
8 changes: 7 additions & 1 deletion GUI/src/pages/ServiceFlowPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ const ServiceFlowPage: FC = () => {
if (!id) {
await Promise.all([
useServiceStore.getState().loadStepPreferences(),
useServiceStore.getState().loadCommonEndpoints(),
useServiceStore.getState().loadCommonEndpoints(
false,
1,
10,
'created_at asc',
'', // To be added: search functionality in common endpoints
),
]);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion GUI/src/resources/api-constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const getAvailableIntents = (): string => `${baseUrl}/services/available-
export const jsonToYml = (): string => `${baseUrl}/saveJsonToYml`;
export const getFaultyServices = (page: number, pageSize: number, sort: string, order: string): string =>
`${baseUrl}/services/services-detailed/nok?page=${page}&page_size=${pageSize}&sort=${sort}&order=${order}`;
export const getServiceById = (id: string): string => `${baseUrl}/service-by-id?id=${id}`;
export const getServiceById = (): string => `${baseUrl}/service-by-id`;
export const createEndpoint = (): string => `${baseUrl}/services/create-endpoint`;
export const updateEndpoint = (id: string): string => `${baseUrl}/services/update-endpoint?id=${id}`;
export const deleteEndpoint = (): string => `${baseUrl}/services/delete-endpoint`;
Expand Down
30 changes: 24 additions & 6 deletions GUI/src/store/new-services.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,14 @@ export interface ServiceStoreState {
editEndpoint: (endpoint?: EndpointData) => void;
loadSecretVariables: () => Promise<void>;
loadTaraVariables: () => Promise<void>;
loadService: (id?: string, resetState?: boolean) => Promise<AxiosResponse<Service, any> | undefined>;
loadCommonEndpoints: () => Promise<void>;
loadService: (id?: string, resetState?: boolean, search?: string) => Promise<AxiosResponse<Service, any> | undefined>;
loadCommonEndpoints: (
isPagination: boolean,
page?: number,
pageSize?: number,
sorting?: string,
search?: string,
) => Promise<void>;
loadStepPreferences: () => Promise<void>;
getAvailableRequestValues: (endpoint: EndpointData) => PreDefinedEndpointEnvVariables;
onNameChange: (endpointId: string, oldName: string, newName: string) => void;
Expand Down Expand Up @@ -408,15 +414,15 @@ const useServiceStore = create<ServiceStoreState>((set, get) => ({
},
resetAssign: () => set({ assignElements: [] }),
resetRules: () => set({ rules: [], isYesNoQuestion: false }),
loadService: async (id, resetState) => {
loadService: async (id, resetState, search) => {
if (resetState === true) {
get().resetState();
}
let nodes = get().nodes;
let serviceResponse: AxiosResponse<Service, any> | undefined;

if (id) {
serviceResponse = await api.get<Service>(getServiceById(id));
serviceResponse = await api.post<Service>(getServiceById(), { id, search: search ?? '' });

const structure = JSON.parse(serviceResponse.data.structure?.value ?? '{}');
let endpoints = serviceResponse.data.endpoints.map((endpoint) => {
Expand Down Expand Up @@ -487,8 +493,20 @@ const useServiceStore = create<ServiceStoreState>((set, get) => ({
get().addProductionVariables(variables);
return serviceResponse;
},
loadCommonEndpoints: async () => {
const response = await api.get(getCommonEndpoints());
loadCommonEndpoints: async (
isPagination: boolean,
page?: number,
pageSize?: number,
sorting?: string,
search?: string,
) => {
const response = await api.post(getCommonEndpoints(), {
pagination: isPagination,
page,
pageSize,
sorting,
search,
});
const endpointsResponse: Array<
Pick<EndpointData, 'endpointId' | 'name' | 'type' | 'fileName' | 'isCommon'> & {
definitions: EndpointDefinitionJson;
Expand Down