diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..2a1b73f --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,31 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: bug +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Desktop (please complete the following information):** + - OS: [e.g. Windows 11] + - Application Version [e.g. 0.1.0] + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..bbcbbe7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: '' +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.idea/.name b/.idea/.name deleted file mode 100644 index 5f91060..0000000 --- a/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -TrabalhoTeoriaDaComputacao \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml deleted file mode 100644 index 345048b..0000000 --- a/.idea/compiler.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml deleted file mode 100644 index 712ab9d..0000000 --- a/.idea/jarRepositories.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__junit_junit_4_12.xml b/.idea/libraries/Maven__junit_junit_4_12.xml deleted file mode 100644 index d411041..0000000 --- a/.idea/libraries/Maven__junit_junit_4_12.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml b/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml deleted file mode 100644 index f58bbc1..0000000 --- a/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 7193838..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index ef4e2f6..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml deleted file mode 100644 index e96534f..0000000 --- a/.idea/uiDesigner.xml +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1dd..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml deleted file mode 100644 index 5eddde0..0000000 --- a/.idea/workspace.xml +++ /dev/null @@ -1,212 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - { @@ -175,7 +199,7 @@ export const Menu = () => { {getIndexOfFileRow()} - + { type="file" onChange={handleInput} /> - + @@ -195,11 +219,11 @@ export const Menu = () => { {getIndexOfFileRow() + 1} - + - Iniciar + Start @@ -210,7 +234,7 @@ export const Menu = () => { return ( -

Essa codificaçao está atualmente em desenvolvimento

+

This coding is currently under development

) } @@ -226,7 +250,13 @@ export const Menu = () => { : renderInitButton() } - + + ); }; diff --git a/frontend/src/components/SidePanel/Menu/style.js b/frontend/src/components/SidePanel/Menu/style.js index 6fad866..de8902f 100644 --- a/frontend/src/components/SidePanel/Menu/style.js +++ b/frontend/src/components/SidePanel/Menu/style.js @@ -85,12 +85,32 @@ export const CodificationCards = styled.section` margin-top: 10px; `; +export const ModalContainer = styled.div` + width: 800px; + overflow-y: auto; + max-height: 100%; + img{ + max-width: 100%; + } +` + export const Card = styled.div` display: flex; flex-direction: column; align-items: center; cursor: pointer; + &:hover .explanation-icon{ + visibility:visible; + transform:1s; + } + + .explanation-icon{ + visibility:hidden; + position: absolute; + transform: translate(28px, -11px); + } + .card-image { border-radius: 10px; background-color: ${(props) => diff --git a/frontend/src/components/SidePanel/Text/index.tsx b/frontend/src/components/SidePanel/Text/index.tsx index e365ae9..38285ac 100644 --- a/frontend/src/components/SidePanel/Text/index.tsx +++ b/frontend/src/components/SidePanel/Text/index.tsx @@ -1,30 +1,26 @@ import React from "react"; -import {useIndex, useCodewords, useTheme} from '../../../context' +import { useIndex, useCodewords, useTheme } from "../../../context"; import { Typografy } from "../../Typografy"; -import { Container} from './style'; +import { Container } from "./style"; export const Text = () => { + const [index] = useIndex(); + const [codewords] = useCodewords(); + const [theme] = useTheme(); - const [index,] = useIndex(); - const [codewords,] = useCodewords(); - const [theme] = useTheme() - - - function renderText(){ - if(index>0){ - let finalString = ''; - for(let i =0;i{finalString}

- } - } return ( - - {renderText()} + +

+ {codewords.map((codeword, i) => { + const simbol = codeword.value; + if (i === index - 1) { + return {simbol}; + } else { + return {simbol}; + } + })} +

- ) + ); }; diff --git a/frontend/src/components/SidePanel/Text/style.js b/frontend/src/components/SidePanel/Text/style.js index 9c83732..9a1a624 100644 --- a/frontend/src/components/SidePanel/Text/style.js +++ b/frontend/src/components/SidePanel/Text/style.js @@ -1,24 +1,29 @@ -import styled from 'styled-components' -import { BLUE_GRAY, PRIMARY, WHITE } from '../../../constants/colors' +import styled from "styled-components"; +import { BLUE_GRAY, PRIMARY, WHITE } from "../../../constants/colors"; export const Container = styled.div` - background-color: ${props=>props.isDark?BLUE_GRAY:WHITE}; - border-radius: 10px; - padding: 16px; - display: flex; - flex-direction: column; - width: 30%; - overflow-y: auto; + background-color: ${(props) => (props.isDark ? BLUE_GRAY : WHITE)}; + border-radius: 10px; + padding: 16px; + display: flex; + flex-direction: column; + width: 30%; + overflow-y: auto; - .text-title{ - color:${PRIMARY}; - text-align:center; - } + .text-title { + color: ${PRIMARY}; + text-align: center; + } + + p { + margin-top: 10px; + text-align: center; + background-color: transparent; + color: ${(props) => (props.isDark ? "white" : "black")}; - p{ - margin-top: 10px; - text-align: center; - background-color:transparent; - color: ${props=>props.isDark?'white':'dark'}; + .actual-symbol { + color: ${PRIMARY}; + font-weight: bold; } -` \ No newline at end of file + } +`; diff --git a/frontend/src/components/SyncLoader/index.tsx b/frontend/src/components/SyncLoader/index.tsx new file mode 100644 index 0000000..f39a1e7 --- /dev/null +++ b/frontend/src/components/SyncLoader/index.tsx @@ -0,0 +1,35 @@ +import React from 'react'; +import {Container} from './style' +import {useTheme} from '../../context' +import { Typografy } from '../Typografy'; +import { Icon } from '../Icon'; +import { SyncState } from '../../enums/SyncState'; +import { Button } from '../Button'; + +export const SyncLoader = ({isSync, setIsSync}) =>{ + + const [theme] = useTheme(); + + return ( + +
+ {isSync == SyncState.UNSYNC ? + <> + +

Wait while we initialize the application services

+ + + + + : + <> + + { + setIsSync(SyncState.UNSYNC) + }}>Try again + + } +
+
+ ) +} \ No newline at end of file diff --git a/frontend/src/components/SyncLoader/style.js b/frontend/src/components/SyncLoader/style.js new file mode 100644 index 0000000..a33eb9e --- /dev/null +++ b/frontend/src/components/SyncLoader/style.js @@ -0,0 +1,41 @@ +import styled from 'styled-components'; +import { BLUE_GRAY, DARKEST, LIGHTEST_GRAY, PRIMARY } from '../../constants/colors'; + +export const Container = styled.main` + width:100%; + height:100%; + display:flex; + align-items:center; + justify-content:center; + background-color:${props=>props.isDark? DARKEST: LIGHTEST_GRAY}; + + + .center-view{ + position: relative; + top: -60px; + padding:15px 30px; + border-radius:12px; + background-color:${props=>props.isDark? BLUE_GRAY: 'white'}; + display:flex; + flex-direction:column; + justify-content:center; + + .text{ + margin-bottom:20px; + text-align:center; + color:${props=>props.isDark? PRIMARY: 'black'}; + } + + p{ + color:${props=>props.isDark? 'white': 'black'}; + margin-bottom:10px; + font-size:0.8rem; + } + + .icon-container{ + display:flex; + justify-content:center; + animation:rotate360 infinite 2s forwards; + } + } +` diff --git a/frontend/src/components/index.ts b/frontend/src/components/index.ts index 354c0bc..18fe9da 100644 --- a/frontend/src/components/index.ts +++ b/frontend/src/components/index.ts @@ -4,4 +4,6 @@ export {Button} from './Button' export {Typografy} from './Typografy' export {Header} from './Header' export {SidePanel} from './SidePanel' -export {ExecutionWindow} from './ExecutionWindow' \ No newline at end of file +export {ExecutionWindow} from './ExecutionWindow' +export {SyncLoader} from './SyncLoader' +export {ModalUsers} from './ModalUsers' \ No newline at end of file diff --git a/frontend/src/constants/codifications.tsx b/frontend/src/constants/codifications.tsx index bb51e01..7644436 100644 --- a/frontend/src/constants/codifications.tsx +++ b/frontend/src/constants/codifications.tsx @@ -3,42 +3,57 @@ import { CodificationMethod } from "../enums/CodificationMethod"; import React from 'react'; import { Codification } from '../models/codification' +import GoulombExplanation from '../assets/codificationsExplanations/Goulomb.png'; +import DeltaExplanation from '../assets/codificationsExplanations/Delta.png'; +import UnarioExplanation from '../assets/codificationsExplanations/Unario.png'; +import HuffmanExplanation from '../assets/codificationsExplanations/Huffman.png'; +import EliasExplanation from '../assets/codificationsExplanations/EliasGamma.png'; +import FibonacciExplanation from '../assets/codificationsExplanations/Fibonacci.png'; + + export default [ new Codification( "Goulomb", "goulomb", CodificationMethod.GOULOMB, - + , + GoulombExplanation ), new Codification( "Elias Gamma", "elias-gamma", CodificationMethod.ELIAS_GAMMA, - + , + EliasExplanation ), new Codification( "Delta", "delta", CodificationMethod.DELTA, - + , + DeltaExplanation ), new Codification( "Fibonacci", "fibonacci", CodificationMethod.FIBONACCI, - + , + FibonacciExplanation ), new Codification( - "Unario", + "Unary", "unary", CodificationMethod.UNARIO, - + , + UnarioExplanation ), new Codification( "Hamming", "hamming", CodificationMethod.HAMMING, - + , + null ), new Codification( - "Huffman Estático", + "Static Huffman", "huffman", CodificationMethod.HUFFMAN, - + , + HuffmanExplanation ) ] \ No newline at end of file diff --git a/frontend/src/enums/SyncState.ts b/frontend/src/enums/SyncState.ts new file mode 100644 index 0000000..05c880b --- /dev/null +++ b/frontend/src/enums/SyncState.ts @@ -0,0 +1,3 @@ +export enum SyncState{ + UNSYNC, SYNC, FAILED +} \ No newline at end of file diff --git a/frontend/src/hooks/index.ts b/frontend/src/hooks/index.ts index 0da02d1..3cea454 100644 --- a/frontend/src/hooks/index.ts +++ b/frontend/src/hooks/index.ts @@ -1,2 +1,4 @@ -export {useModal} from './useModal' -export * from './useCodification' \ No newline at end of file +export {useModal} from './useModal'; +export {api} from './useApi'; +export {sync} from './useSync'; +export * from './useCodification'; \ No newline at end of file diff --git a/frontend/src/hooks/useCodification/baseApi.ts b/frontend/src/hooks/useApi/index.ts similarity index 74% rename from frontend/src/hooks/useCodification/baseApi.ts rename to frontend/src/hooks/useApi/index.ts index 0804d4c..5e19419 100644 --- a/frontend/src/hooks/useCodification/baseApi.ts +++ b/frontend/src/hooks/useApi/index.ts @@ -1,8 +1,6 @@ import axios from 'axios'; -const api = axios.create({ +export const api = axios.create({ baseURL:"http://localhost:10022", headers: { "Content-Type": "application/json; charset=UTF-8" } }) - -export default api; \ No newline at end of file diff --git a/frontend/src/hooks/useCodification/index.ts b/frontend/src/hooks/useCodification/index.ts index 75fc85f..f63f2b6 100644 --- a/frontend/src/hooks/useCodification/index.ts +++ b/frontend/src/hooks/useCodification/index.ts @@ -1,4 +1,4 @@ -import api from './baseApi' +import {api} from '../index' export async function encode(method:string, path:string, divisor:number){ const data = (method==='goulomb') ? {path:path, divisor:divisor} : path; diff --git a/frontend/src/hooks/useSync/index.ts b/frontend/src/hooks/useSync/index.ts new file mode 100644 index 0000000..106b3aa --- /dev/null +++ b/frontend/src/hooks/useSync/index.ts @@ -0,0 +1,8 @@ +import {api} from '../index' + +export async function sync(){ + return await api.get(`/sync`); +} + + + diff --git a/frontend/src/index.css b/frontend/src/index.css index 4e65957..6cda529 100644 --- a/frontend/src/index.css +++ b/frontend/src/index.css @@ -94,6 +94,14 @@ li{ } } +@keyframes rotate360{ + 0%{ + transform: rotate(0deg); + }100%{ + transform: rotate(360deg); + } +} + .custom-icon:hover{ transform:scale(1.1); transition:0.5s; diff --git a/frontend/src/models/codification.ts b/frontend/src/models/codification.ts index f022ccd..cff5199 100644 --- a/frontend/src/models/codification.ts +++ b/frontend/src/models/codification.ts @@ -1,16 +1,23 @@ -import { ReactElement } from "react" +import { ReactElement } from "react"; -export class Codification{ - name:string; - urlName:string; - codificationType: number; - icon: ReactElement; +export class Codification { + name: string; + urlName: string; + codificationType: number; + icon: ReactElement; + explanationImage: any; - constructor(name:string, urlName:string, codificationType:number, icon:ReactElement){ - this.name=name; - this.urlName=urlName; - this.codificationType = codificationType; - this.icon = icon; - } - -} \ No newline at end of file + constructor( + name: string, + urlName: string, + codificationType: number, + icon: ReactElement, + explanationImage: any + ) { + this.name = name; + this.urlName = urlName; + this.codificationType = codificationType; + this.icon = icon; + this.explanationImage = explanationImage; + } +} diff --git a/frontend/src/pages/main/index.tsx b/frontend/src/pages/main/index.tsx index 70bdfa2..93271bc 100644 --- a/frontend/src/pages/main/index.tsx +++ b/frontend/src/pages/main/index.tsx @@ -1,19 +1,55 @@ -import React, { useState } from 'react' -import { ExecutionWindow, SidePanel, Header } from '../../components' +import React, { useEffect, useState } from 'react' +import { ExecutionWindow, SidePanel, Header, SyncLoader } from '../../components' import { useTheme } from '../../context'; import {Container, MainProgram} from './styles' +import {sync} from '../../hooks/index' +import {SyncState} from '../../enums/SyncState' export const Main = () => { const [onError, setOnError] = useState() const [theme] = useTheme(); + + const [isSync, setIsSync] = useState(SyncState.UNSYNC); + const LIMIT_REQUISITIONS = 15; + const TIME_BETWEEN_REQUISITIONS = 2000; + + useEffect(()=>{ + if(isSync == SyncState.UNSYNC){ + getSyncConfirmation() + } + },[isSync]) + + async function getSyncConfirmation(){ + let i=0; + + const interval = setInterval(async ()=>{ + console.log('entrou') + i++; + if(i
- - - - + {isSync === SyncState.SYNC ? + + + + + : + + } ) }; diff --git a/frontend/src/scripts/electronBuilder.js b/frontend/src/scripts/electronBuilder.js new file mode 100644 index 0000000..5714585 --- /dev/null +++ b/frontend/src/scripts/electronBuilder.js @@ -0,0 +1,20 @@ +const fs = require('fs'); +const finalPath = './public/electron.js' + +const args = process.argv.slice(2).reduce((acc, arg) => { + let [k, v = true] = arg.split('=') + acc[k] = v + return acc +}, {}) + +let copyPath =''; + +if(args.isDev){ + copyPath = './src/scripts/electronFiles/electronForDev.js' +}else{ + copyPath = './src/scripts/electronFiles/electronForBuild.js' +} + +const content = fs.readFileSync(copyPath, {encoding:'utf8', flag:'r'}); +fs.writeFileSync(finalPath,content,{encoding:'utf8',flag:'w'}) + diff --git a/frontend/src/scripts/electronFiles/electronForBuild.js b/frontend/src/scripts/electronFiles/electronForBuild.js new file mode 100644 index 0000000..9df1ef1 --- /dev/null +++ b/frontend/src/scripts/electronFiles/electronForBuild.js @@ -0,0 +1,58 @@ +const {app, BrowserWindow} = require("electron"); +const isDev = require("electron-is-dev"); + +const childProcess = require("child_process"); +const path = require("path"); +const {killPortProcess} = require('kill-port-process'); + +function createWindow() { + (async () => { + await killPortProcess(10022); + })(); + + const jarPath = path.resolve( + __dirname, + "..", + "..", + "..", + "public", + "backend_jar", + "encodedecodestepbystep-0.0.1-SNAPSHOT.jar" + ); + console.log(jarPath); + + const child = childProcess.spawn("java", ['-jar', jarPath]); + + const win = new BrowserWindow({ + width: 800, + height: 800, + webPreferences: { + nodeIntegration: true, + }, + icon: __dirname + "/favicon.png", + }); + + win.on("close", (e) => { + child.kill(); + }); + + win.loadURL( + isDev + ? "http://localhost:3000" + : `file://${path.join(__dirname, "../build/index.html")}` + ); +} + +app.whenReady().then(createWindow); + +app.on("window-all-closed", () => { + if (process.platform !== "darwin") { + app.quit(); + } +}); + +app.on("activate", () => { + if (BrowserWindow.getAllWindows().length === 0) { + createWindow(); + } +}); diff --git a/frontend/src/scripts/electronFiles/electronForDev.js b/frontend/src/scripts/electronFiles/electronForDev.js new file mode 100644 index 0000000..8114766 --- /dev/null +++ b/frontend/src/scripts/electronFiles/electronForDev.js @@ -0,0 +1,34 @@ +const {app, BrowserWindow} = require('electron') +const isDev = require('electron-is-dev'); + +const path = require("path"); + +function createWindow() { + + const win = new BrowserWindow({ + width: 800, + height: 800, + webPreferences: { + nodeIntegration: true + }, + icon: __dirname + '/favicon.png' + }) + + win.loadURL( + isDev ? 'http://localhost:3000' : `file://${path.join(__dirname, "../build/index.html")}` + ) +} + +app.whenReady().then(createWindow) + +app.on('window-all-closed', () => { + if (process.platform !== 'darwin') { + app.quit() + } +}) + +app.on('activate', () => { + if (BrowserWindow.getAllWindows().length === 0) { + createWindow() + } +}) diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json index 39f121e..575475c 100644 --- a/frontend/tsconfig.json +++ b/frontend/tsconfig.json @@ -18,8 +18,9 @@ "resolveJsonModule": true, "isolatedModules": true, "noEmit": true, - "jsx": "react", - "strict": false + "jsx": "react-jsx", + "strict": false, + "noFallthroughCasesInSwitch": true }, "include": [ "src"