Skip to content

Commit

Permalink
Version 1.5.0 (#19)
Browse files Browse the repository at this point in the history
* starting

* WIP: Adding Header in scrap production process

UI impl
Server store & get

* production scrap with header

* update

Server:
bump express 4.18.2 to 4.19.2
bump express-session 1.17.3 to 1.18.0
bump winston 3.11.0 to 3.13.0
bump yaml 2.3.4 to 2.4.1

Client:
bump @tabler/icons-webfont 2.40.0 to 2.47.0
bump react-intl 6.5.2 to 6.6.5
bump react-router-dom 6.18.0 to 6.22.3
bump storybook 7.6.15 to 7.6.17

* httpheader component

will be reused for actions

* fix

* V1.5.0

---------
  • Loading branch information
dhenry123 authored Apr 13, 2024
1 parent 4c433e9 commit 9d34720
Show file tree
Hide file tree
Showing 34 changed files with 2,882 additions and 1,871 deletions.
4 changes: 3 additions & 1 deletion README-fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ Ne jamais exposer UTDON directement sur internet (utilisez un VPN si nécessaire
Le contenu des deux bases de données est chiffré partiellement :

- user.json: Le mot de passe de l'administrateur (non réversible) et le jeton d'authentification (réversible)
- database.json: Les chaînes d'authentification pour les "urls" de monitoring et de la chaine CI/CD (réversibles).
- database.json:
- Les chaînes d'authentification pour les "urls" de monitoring et de la chaine CI/CD (réversibles).
- HTTP header associé au processus de "production scrap".

### Si vous avez perdu le mot de passe admin

Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ Never expose UTDON directly to the Internet (use a VPN if necessary). UTDON is a
The contents of both databases are partially encrypted:

- user.json: Administrator password (non-reversible) and authentication token (reversible)
- database.json: Authentication strings for monitoring urls and CI/CD chain (reversible).
- database.json:
- Authentication strings for monitoring urls and CI/CD chain (reversible).
- HTTP header associated with the production scrap process

### If you've lost the admin password

Expand Down
3,197 changes: 1,872 additions & 1,325 deletions client/package-lock.json

Large diffs are not rendered by default.

40 changes: 20 additions & 20 deletions client/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mytinydc-utdon-client",
"private": true,
"version": "1.4.0",
"version": "1.5.0",
"description": "Application for tracking obsolete FOSS applications - UI",
"type": "module",
"scripts": {
Expand All @@ -17,36 +17,36 @@
},
"dependencies": {
"@reduxjs/toolkit": "^1.9.7",
"@tabler/icons-webfont": "^2.40.0",
"@tabler/icons-webfont": "^2.47.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-intl": "^6.5.2",
"react-intl": "^6.6.5",
"react-multi-select-component": "^4.3.4",
"react-redux": "^8.1.3",
"react-router-dom": "^6.18.0"
"react-router-dom": "^6.22.3"
},
"devDependencies": {
"@storybook/addon-essentials": "^7.6.15",
"@storybook/addon-interactions": "^7.6.15",
"@storybook/addon-links": "^7.6.15",
"@storybook/addon-essentials": "^7.6.17",
"@storybook/addon-interactions": "^7.6.17",
"@storybook/addon-links": "^7.6.17",
"@storybook/blocks": "^7.6.15",
"@storybook/react": "^7.6.15",
"@storybook/react-vite": "^7.6.15",
"@storybook/react-vite": "^7.6.17",
"@storybook/testing-library": "^0.2.2",
"@types/react": "^18.2.15",
"@types/react-dom": "^18.2.7",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"@vitejs/plugin-react": "^4.0.3",
"eslint": "^8.45.0",
"@types/react": "^18.2.75",
"@types/react-dom": "^18.2.24",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"@vitejs/plugin-react": "^4.2.1",
"eslint": "^8.57.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.3",
"eslint-plugin-react-refresh": "^0.4.6",
"eslint-plugin-storybook": "^0.6.15",
"sass": "^1.69.5",
"storybook": "^7.6.15",
"storybook-addon-react-router-v6": "^2.0.10",
"typescript": "^5.0.2",
"vite": "^4.4.5"
"sass": "^1.74.1",
"storybook": "^7.6.17",
"storybook-addon-react-router-v6": "^2.0.15",
"typescript": "^5.4.4",
"vite": "^4.5.3"
},
"repository": {
"type": "git",
Expand Down
23 changes: 18 additions & 5 deletions client/src/api/mytinydcUPDONApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
NewUserType,
UptodateForm,
} from "../../../src/Global.types";
import { buildHeader } from "../helpers/rtk";

export const mytinydcUPDONApi = createApi({
// Query service name
Expand Down Expand Up @@ -39,11 +40,23 @@ export const mytinydcUPDONApi = createApi({
}),
}),
getScrapUrl: builder.query({
query: (url: string) => ({
url: `/scrap/${encodeURIComponent(url)}`,
// scrap result is always text
responseHandler: (response) => response.text(),
}),
query: (data: {
url: string;
headerkey?: string;
headervalue?: string;
}) =>
data.headerkey && data.headervalue
? {
url: `/scrap/${encodeURIComponent(data.url)}`,
headers: buildHeader(`${data.headerkey}:${data.headervalue}`),
// scrap result is always text
responseHandler: (response) => response.text(),
}
: {
url: `/scrap/${encodeURIComponent(data.url)}`,
// scrap result is always text
responseHandler: (response) => response.text(),
},
}),
postCheck: builder.mutation({
query: (checkData: UptodateForm) => ({
Expand Down
5 changes: 5 additions & 0 deletions client/src/components/FieldSet.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
// important to use ellipsis
min-width: 0;
legend {
display: flex;
flex-direction: row;
font-weight: bold;
.IconWithTooltip {
margin: 0 0.5rem;
}
}
.content {
max-width: 100%;
Expand Down
18 changes: 16 additions & 2 deletions client/src/components/FieldSet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,30 @@
*/

import "./FieldSet.scss";
import { IconWithTooltip } from "./IconWithTooltip";

export interface FieldSetProps {
children?: JSX.Element | string | JSX.Element[];
legend: string;
className?: string;
toolTipIcon?: string;
toolTipContent?: string;
}
export const FieldSet = ({ legend, children, className }: FieldSetProps) => {
export const FieldSet = ({
legend,
children,
className,
toolTipIcon = "help",
toolTipContent,
}: FieldSetProps) => {
return (
<fieldset className={`FieldSet ${className ? className : ""}`}>
<legend>{legend}</legend>
<legend>
{legend}
{toolTipContent ? (
<IconWithTooltip icon={toolTipIcon} tooltipContent={toolTipContent} />
) : null}
</legend>
<div className="content">{children}</div>
</fieldset>
);
Expand Down
19 changes: 19 additions & 0 deletions client/src/components/HttpHeader.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@import "../app/css/root.scss";
.HttpHeader {
.content {
display: flex;
flex-direction: row;
column-gap: 1rem;
.inputgeneric::placeholder {
color: #8c6cb1;
font-weight: bold;
font-size: 0.7rem;
}
.headerhttpkey {
width: 8rem !important;
}
.headerhttpvalue {
flex-grow: 1;
}
}
}
52 changes: 52 additions & 0 deletions client/src/components/HttpHeader.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import type { Meta, StoryObj } from "@storybook/react";
// import { useArgs } from "@storybook/preview-api";

import { HttpHeader } from "./HttpHeader";
import {
reactRouterParameters,
withRouter,
} from "storybook-addon-react-router-v6";

// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
const meta = {
title: "NewComponent/HttpHeader",
component: HttpHeader,
decorators: [withRouter],
parameters: {
// Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/react/configure/story-layout
layout: "fullscreen",
reactRouter: reactRouterParameters({
location: { path: "/" },
}),
},
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/react/writing-docs/autodocs
tags: ["autodocs"],
// More on argTypes: https://storybook.js.org/docs/react/api/argtypes
argTypes: {},
} satisfies Meta<typeof HttpHeader>;

export default meta;
type Story = StoryObj<typeof meta>;

// If you need to keep state in storybook, you also could use the app redux store
// const Component = ({ ...args }) => {
// const [, setArgs] = useArgs();
// const onChange = (value: string) => {
// // Call the provided callback
// // This is used for the Actions tab
// args.onChange?.(value);
//
// // Update the arg in Storybook
// setArgs({ value });
// };
// return <HttpHeader {...args} onChange={onChange} />;
// };
export const Primary: Story = {
args: {
handleOnChange: () => {},
headerkey: "",
headervalue: "",
},
// if you need to get a specific render see SelectArs component...
// render: (args) => Component(args),
};
61 changes: 61 additions & 0 deletions client/src/components/HttpHeader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/**
* @author DHENRY for mytinydc.com
* @license AGPL3
*/

import { useIntl } from "react-intl";

import "./HttpHeader.scss";
import { FieldSet } from "./FieldSet";
import InputGeneric from "./InputGeneric";
import { UptodateFormFields } from "../../../src/Global.types";
interface HttpHeaderProps {
handleOnChange: (key: UptodateFormFields, value: string | string[]) => void;
headerkey: string;
headervalue: string;
}
export const HttpHeader = ({
handleOnChange,
headerkey,
headervalue,
}: HttpHeaderProps) => {
const intl = useIntl();

return (
<FieldSet
legend={intl.formatMessage({ id: "HTTP Header" })}
className="HttpHeader"
toolTipContent={`${intl.formatMessage({
id: "(Optional) HTTP Header, use when authentication with token is needed",
})}
${intl.formatMessage({ id: "eg" })}:
- ${intl.formatMessage({
id: "Attribut: Authorization ; value: Bearer myauthtoken",
})}
- ${intl.formatMessage({
id: "Attribut: X-Auth ; value: myauthtoken",
})}
`}
>
<InputGeneric
className="headerhttpkey"
value={headerkey}
placeholder={intl.formatMessage({ id: "HTTP header attribut" })}
title={intl.formatMessage({ id: "HTTP header attribut" })}
onChange={(value: string) => handleOnChange("headerkey", value)}
/>
<InputGeneric
className="headerhttpvalue"
placeholder={intl.formatMessage({
id: "HTTP header attribute value",
})}
title={intl.formatMessage({
id: "HTTP header attribute value",
})}
value={headervalue}
onChange={(value: string) => handleOnChange("headervalue", value)}
/>
</FieldSet>
);
};
27 changes: 27 additions & 0 deletions client/src/components/IconWithTooltip.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
@import "../app/css/root.scss";
.IconWithTooltip {
.tooltip {
position: absolute;
z-index: 9999; /* Set a high z-index value */
background-color: #fff;
border: 1px solid #ccc;
padding: 5px;
border-radius: 4px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
display: flex;
flex-direction: column;
.tooltiptitle {
border-bottom: 1px solid #ccc;
margin: 0.5rem;
align-self: center;
}
.tooltipbody {
margin: 1rem;
font-weight: normal;
}
}
i {
font-size: 1.2rem;
color: rgb(91, 159, 185);
}
}
51 changes: 51 additions & 0 deletions client/src/components/IconWithTooltip.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import type { Meta, StoryObj } from "@storybook/react";
// import { useArgs } from "@storybook/preview-api";

import { IconWithTooltip } from "./IconWithTooltip";
import {
reactRouterParameters,
withRouter,
} from "storybook-addon-react-router-v6";

// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
const meta = {
title: "NewComponent/IconWithTooltip",
component: IconWithTooltip,
decorators: [withRouter],
parameters: {
// Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/react/configure/story-layout
layout: "fullscreen",
reactRouter: reactRouterParameters({
location: { path: "/" },
}),
},
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/react/writing-docs/autodocs
tags: ["autodocs"],
// More on argTypes: https://storybook.js.org/docs/react/api/argtypes
argTypes: {},
} satisfies Meta<typeof IconWithTooltip>;

export default meta;
type Story = StoryObj<typeof meta>;

// If you need to keep state in storybook, you also could use the app redux store
// const Component = ({ ...args }) => {
// const [, setArgs] = useArgs();
// const onChange = (value: string) => {
// // Call the provided callback
// // This is used for the Actions tab
// args.onChange?.(value);
//
// // Update the arg in Storybook
// setArgs({ value });
// };
// return <IconWithTooltip {...args} onChange={onChange} />;
// };
export const Primary: Story = {
args: {
icon: "help",
tooltipContent: "test",
},
// if you need to get a specific render see SelectArs component...
// render: (args) => Component(args),
};
Loading

0 comments on commit 9d34720

Please sign in to comment.