diff --git a/.DS_Store b/.DS_Store index 658d3c7e..bb207fa9 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 7b016a89..00000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "java.compile.nullAnalysis.mode": "automatic" -} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..6db22a6d --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,27 @@ +Change Log +All notable changes to this project will be documented in this file. + +The format is based on Keep a Changelog and this project adheres to Semantic Versioning. + +[Unreleased] - yyyy-mm-dd +Here we write upgrading notes for brands. It's a team effort to make them as straightforward as possible. + +Added +PROJECTNAME-XXXX MINOR Ticket title goes here. +PROJECTNAME-YYYY PATCH Ticket title goes here. +Changed +Fixed +[1.2.4] - 2017-03-15 +Here we would have the update steps for 1.2.4 for people to follow. + +Added +Changed +PROJECTNAME-ZZZZ PATCH Drupal.org is now used for composer. +Fixed +PROJECTNAME-TTTT PATCH Add logic to runsheet teaser delete to delete corresponding schedule cards. +[1.2.3] - 2017-03-14 +Added +Changed +Fixed +PROJECTNAME-UUUU MINOR Fix module foo tests +PROJECTNAME-RRRR MAJOR Module foo's timeline uses the browser timezone for date resolution diff --git a/MtdrSpring/backend/src/main/frontend/public/logo-transparente.png b/MtdrSpring/backend/src/main/frontend/public/logo-transparente.png deleted file mode 100644 index ed1d6406..00000000 Binary files a/MtdrSpring/backend/src/main/frontend/public/logo-transparente.png and /dev/null differ diff --git a/MtdrSpring/backend/src/main/frontend/src/App.js b/MtdrSpring/backend/src/main/frontend/src/App.js deleted file mode 100644 index 26e5d646..00000000 --- a/MtdrSpring/backend/src/main/frontend/src/App.js +++ /dev/null @@ -1,173 +0,0 @@ -import React, { useState, useEffect } from 'react'; -import NewItem from './NewItem'; -import API_LIST from './API'; -import DeleteIcon from '@mui/icons-material/Delete'; -import { Button, TableBody, TableCell, TableRow, CircularProgress, Table } from '@mui/material'; -import Moment from 'react-moment'; - -function App() { - const [isLoading, setLoading] = useState(false); - const [isInserting, setInserting] = useState(false); - const [items, setItems] = useState([]); - const [error, setError] = useState(); - - function deleteItem(deleteId) { - fetch(API_LIST + "/" + deleteId, { - method: 'DELETE', - }) - .then(response => { - if (response.ok) { - const remainingItems = items.filter(item => item.id !== deleteId); - setItems(remainingItems); - } else { - throw new Error('Something went wrong ...'); - } - }) - .catch(error => { - setError(error); - }); - } - - function toggleDone(event, id, description, done, details, priority, complexity) { - event.preventDefault(); - modifyItem(id, description, done, details, priority, complexity).then( - updatedItem => { - const updatedItems = items.map(item => item.id === id ? updatedItem : item); - setItems(updatedItems); - }, - error => { - setError(error); - } - ); - } - - function modifyItem(id, description, done, details, priority, complexity) { - var data = { description, done, details, priority, complexity }; - return fetch(API_LIST + "/" + id, { - method: 'PUT', - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify(data) - }) - .then(response => { - if (response.ok) { - return response.json(); - } else { - throw new Error('Something went wrong ...'); - } - }); - } - - useEffect(() => { - reloadItems(); - }, []); - - function addItem(newItem){ - setInserting(true); - fetch(API_LIST, { - method: 'POST', - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify(newItem), - }).then(response => { - if (response.ok) { - reloadItems(); // Reload all items to see the new addition - setInserting(false); - } else { - throw new Error('Something went wrong ...'); - } - }).catch(error => { - setInserting(false); - setError(error); - }); - } - - function reloadItems() { - setLoading(true); - fetch(API_LIST) - .then(response => { - if (response.ok) { - return response.json(); - } else { - throw new Error('Something went wrong ...'); - } - }) - .then(items => { - setLoading(false); - setItems(items); - }) - .catch(error => { - setLoading(false); - setError(error); - }); - } - - return ( -
- Logo - - {error &&

Error: {error.message}

} - {isLoading && } - {!isLoading && ( - <> -

Pending Tasks

- - - {items.filter(item => !item.done).map(item => ( - - {item.description} - {item.details} - {item.priority} - {item.complexity} - - {item.creation_ts} - - - - - - - - - ))} - -
-

Completed Tasks

- - - {items.filter(item => item.done).map(item => ( - - {item.description} - {item.details} - {item.priority} - {item.complexity} - - {item.creation_ts} - - - - - - - - - ))} - -
- - )} -
- ); -} - -export default App; diff --git a/MtdrSpring/backend/src/main/frontend/src/NewItem.js b/MtdrSpring/backend/src/main/frontend/src/NewItem.js deleted file mode 100644 index cc94e05d..00000000 --- a/MtdrSpring/backend/src/main/frontend/src/NewItem.js +++ /dev/null @@ -1,108 +0,0 @@ -import React, { useState } from "react"; -import { Button, TextField, MenuItem, FormControl, InputLabel, Select, Grid } from '@mui/material'; - -function NewItem(props) { - const [item, setItem] = useState({ - description: '', - details: '', - priority: 1, // valor predeterminado como número - complexity: 1, // valor predeterminado como número - }); - - function handleChange(e) { - const { name, value } = e.target; - setItem(prevItem => ({ - ...prevItem, - [name]: name === "priority" || name === "complexity" ? parseInt(value) : value - })); - } - - function handleSubmit(e) { - e.preventDefault(); - if (!item.description.trim()) { - return; - } - props.addItem(item); - setItem({ - description: '', - details: '', - priority: 1, - complexity: 1, - }); - } - - return ( -
-
- - - - - - - - - - Priority - - - - - - Complexity - - - - - - - -
-
- ); -} - -export default NewItem; diff --git a/MtdrSpring/backend/src/main/frontend/src/index.css b/MtdrSpring/backend/src/main/frontend/src/index.css deleted file mode 100644 index 04e76843..00000000 --- a/MtdrSpring/backend/src/main/frontend/src/index.css +++ /dev/null @@ -1,106 +0,0 @@ -/* -** Todo application version 1.0. -** -** Copyright (c) 2020, Oracle and/or its affiliates. -** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ -*/ -body { - /* from the redwood theme */ - background-color: #3A3632; /* Set the background color */ - width: 100%; - color: #FEF9F2; - font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', - 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', - sans-serif; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; - display: flex; - justify-content: center; - align-items: center; -} - -.App { - background: #201E1C; /* Background color for the app */ - color: #FEF9F2; - display: flex; - flex-direction: column; - align-items: center; - font-size: max(12px, min(2vw, 18px)); /* Responsive font size */ - margin: 1em auto; /* Center the .App container vertically and horizontally */ - padding: 1rem; - position: relative; - box-shadow: 0 10px 18px 0 rgba(0, 0, 0, 0.2), 0 4.5rem 8rem 0 rgba(0, 0, 0, 0.1); - border-radius: 0.5rem; - width: 100%; /* Full width */ - max-width: 50rem; /* Max width, adjust as needed */ -} - -div#maincontent, div#newinputform form { - width: 95%; -} - -div#maincontent { - margin: 0; - padding: 0; -} - -h1, h2 { - margin: 1rem 0; /* Unified margin for headings */ - padding: 0; -} - -#newiteminput, div#newinputform { - width: 100%; -} - -div#newinputform form { - display: flex; - flex-direction: row; - margin: 0 auto; -} - -table#itemlistNotDone, table#itemlistDone { - margin-bottom: 2rem; /* Uniform bottom margin for tables */ -} - -table.itemlist { - margin-top: 0.7rem; - border-collapse: collapse; - margin-bottom: 1rem; -} - -table.itemlist td { - border-bottom: solid 1px #5B5652; - padding: 0.5rem; -} - -table.itemlist td.description, table.itemlist td.date { - padding-left: 1rem; - padding-right: 1rem; - color: grey; - white-space: nowrap; -} - -table.itemlist tr:hover { - background-color: #161513; /* Hover color for table rows */ -} - -input, button, input[type="text"] { - font-family: inherit; - font-size: 100%; - line-height: 1; - margin: 0; - overflow: visible; - border-radius: 0.3rem; - padding-left: 10px; -} - -button.AddButton, button.DeleteButton, button.DoneButton { - font-size: max(8px, min(2vw, 12px)); - padding: 1.5em 0.5em; - background-color: #5F7D4F; /* Primary button background color */ -} - -button.AddButton:hover, button.DeleteButton:hover, button.DoneButton:hover { - background-color: #6F915D; /* Hover color for buttons */ -} diff --git a/MtdrSpring/backend/src/main/frontend/src/index.js b/MtdrSpring/backend/src/main/frontend/src/index.js deleted file mode 100644 index 044683e4..00000000 --- a/MtdrSpring/backend/src/main/frontend/src/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/* -## MyToDoReact version 1.0. -## -## Copyright (c) 2021 Oracle, Inc. -## Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ -*/ -/* - * @author jean.de.lavarene@oracle.com - */ - -import React from 'react'; -import ReactDOM from 'react-dom'; -import './index.css'; -import App from './App'; -import { createTheme, ThemeProvider, CssBaseline } from '@mui/material'; - -// Configurar el tema oscuro de Material-UI -const theme = createTheme({ - palette: { - mode: 'dark', // Activar el modo oscuro - background: { - default: '#3A3632' // Establece el color de fondo global de la aplicación - }, - primary: { - main: '#5F7D4F', // Color principal personalizado - }, - // Añadir más configuraciones de color según sea necesario - }, - // Configuraciones adicionales para componentes específicos si es necesario -}); - -ReactDOM.render( - - - - - - , - document.getElementById('root') -); diff --git a/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/util/BotLabels.java b/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/util/BotLabels.java deleted file mode 100644 index eb0fa537..00000000 --- a/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/util/BotLabels.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.springboot.MyTodoList.util; - -public enum BotLabels { - - SHOW_MAIN_SCREEN("🤖Menu principal🤖"), - HIDE_MAIN_SCREEN("⬇️Ocultar menu principal⬇️"), - LIST_ALL_ITEMS("🧑‍💻Mostrar mis DevOps Tasks🧑‍💻"), - ADD_NEW_ITEM("🆕Crear Task🆕"), - DONE("✅"), - UNDO("⤴️"), - DELETE("🗑"), - MY_TODO_LIST("🧑‍💻MIS DEVOPS TASKS🧑‍💻"), - DASH("-"), - TODO_DETAILS("🔹"); - - private String label; - - BotLabels(String enumLabel) { - this.label = enumLabel; - } - - public String getLabel() { - return label; - } - -} diff --git a/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/util/BotMessages.java b/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/util/BotMessages.java deleted file mode 100644 index a6d4af58..00000000 --- a/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/util/BotMessages.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.springboot.MyTodoList.util; - -public enum BotMessages { - - HELLO_MYTODO_BOT( - "¡Hola, soy DevBot🤖! Tu asistente personal para administrar tus tasks de DevOps.\nSelecciona una opción del menú. \n \nPuedes crear una nueva task con un mensaje, sólo escribe la siguiente información separada por punto y coma (;). \nTítulo;Descripción;Prioridad🟥🟧🟨(1,2,3);Complejidad😎🤨😰(1,2,3)"), - BOT_REGISTERED_STARTED("DevBot registrado e inicializado exitosamente."), - ITEM_DONE("¡Task completada! Selecciona /tasks para mostrar la lista de tasks, o /start para ir al Menu principal."), - ITEM_UNDONE("¡Task devuelta a lista de task pendientes! Selecciona /tasks para mostrar la lista de tasks, o /start para ir al Menu principal."), - ITEM_DELETED("¡Task borrada! Selecciona /tasks para mostrar la lista de tasks, o /start para ir al Menu principal."), - TYPE_NEW_TODO_ITEM("Para crear una nueva task, escribe siguiente la información separada por punto y coma (;). Título;Descripción;Prioridad (número del 1 al 3);Complejidad (que tan complejo del 1 al 3):"), - NEW_ITEM_ADDED("¡Task creada! Selecciona /tasks para mostrar la lista de tasks, o /start para ir al Menu principal."), - BYE("¡Hasta luego! Selecciona /start para volver a con tu DevBot"); - - private String message; - - BotMessages(String enumMessage) { - this.message = enumMessage; - } - - public String getMessage() { - return message; - } - -} diff --git a/.gitignore b/oci-react-samples-springboot-bot/.gitignore similarity index 100% rename from .gitignore rename to oci-react-samples-springboot-bot/.gitignore diff --git a/CONTRIBUTING.md b/oci-react-samples-springboot-bot/CONTRIBUTING.md similarity index 100% rename from CONTRIBUTING.md rename to oci-react-samples-springboot-bot/CONTRIBUTING.md diff --git a/LICENSE.txt b/oci-react-samples-springboot-bot/LICENSE.txt similarity index 100% rename from LICENSE.txt rename to oci-react-samples-springboot-bot/LICENSE.txt diff --git a/MtdrSpring/.gitignore b/oci-react-samples-springboot-bot/MtdrSpring/.gitignore similarity index 100% rename from MtdrSpring/.gitignore rename to oci-react-samples-springboot-bot/MtdrSpring/.gitignore diff --git a/MtdrSpring/backend/.mvn/wrapper/maven-wrapper.properties b/oci-react-samples-springboot-bot/MtdrSpring/backend/.mvn/wrapper/maven-wrapper.properties similarity index 100% rename from MtdrSpring/backend/.mvn/wrapper/maven-wrapper.properties rename to oci-react-samples-springboot-bot/MtdrSpring/backend/.mvn/wrapper/maven-wrapper.properties diff --git a/MtdrSpring/backend/Dockerfile b/oci-react-samples-springboot-bot/MtdrSpring/backend/Dockerfile similarity index 100% rename from MtdrSpring/backend/Dockerfile rename to oci-react-samples-springboot-bot/MtdrSpring/backend/Dockerfile diff --git a/MtdrSpring/backend/MyTodoList.iml b/oci-react-samples-springboot-bot/MtdrSpring/backend/MyTodoList.iml similarity index 100% rename from MtdrSpring/backend/MyTodoList.iml rename to oci-react-samples-springboot-bot/MtdrSpring/backend/MyTodoList.iml diff --git a/MtdrSpring/backend/build.sh b/oci-react-samples-springboot-bot/MtdrSpring/backend/build.sh similarity index 100% rename from MtdrSpring/backend/build.sh rename to oci-react-samples-springboot-bot/MtdrSpring/backend/build.sh diff --git a/MtdrSpring/backend/deploy.sh b/oci-react-samples-springboot-bot/MtdrSpring/backend/deploy.sh similarity index 100% rename from MtdrSpring/backend/deploy.sh rename to oci-react-samples-springboot-bot/MtdrSpring/backend/deploy.sh diff --git a/MtdrSpring/backend/mvnw b/oci-react-samples-springboot-bot/MtdrSpring/backend/mvnw similarity index 100% rename from MtdrSpring/backend/mvnw rename to oci-react-samples-springboot-bot/MtdrSpring/backend/mvnw diff --git a/MtdrSpring/backend/mvnw.cmd b/oci-react-samples-springboot-bot/MtdrSpring/backend/mvnw.cmd similarity index 100% rename from MtdrSpring/backend/mvnw.cmd rename to oci-react-samples-springboot-bot/MtdrSpring/backend/mvnw.cmd diff --git a/MtdrSpring/backend/pom.xml b/oci-react-samples-springboot-bot/MtdrSpring/backend/pom.xml similarity index 100% rename from MtdrSpring/backend/pom.xml rename to oci-react-samples-springboot-bot/MtdrSpring/backend/pom.xml diff --git a/MtdrSpring/backend/src/main/frontend/package-lock.json b/oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/frontend/package-lock.json similarity index 100% rename from MtdrSpring/backend/src/main/frontend/package-lock.json rename to oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/frontend/package-lock.json diff --git a/MtdrSpring/backend/src/main/frontend/package.json b/oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/frontend/package.json similarity index 100% rename from MtdrSpring/backend/src/main/frontend/package.json rename to oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/frontend/package.json diff --git a/MtdrSpring/backend/src/main/frontend/public/index.html b/oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/frontend/public/index.html similarity index 100% rename from MtdrSpring/backend/src/main/frontend/public/index.html rename to oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/frontend/public/index.html diff --git a/MtdrSpring/backend/src/main/frontend/public/manifest.json b/oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/frontend/public/manifest.json similarity index 100% rename from MtdrSpring/backend/src/main/frontend/public/manifest.json rename to oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/frontend/public/manifest.json diff --git a/MtdrSpring/backend/src/main/frontend/public/swagger_APIs_definition.json b/oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/frontend/public/swagger_APIs_definition.json similarity index 100% rename from MtdrSpring/backend/src/main/frontend/public/swagger_APIs_definition.json rename to oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/frontend/public/swagger_APIs_definition.json diff --git a/MtdrSpring/backend/src/main/frontend/public/swagger_APIs_definition.yaml b/oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/frontend/public/swagger_APIs_definition.yaml similarity index 100% rename from MtdrSpring/backend/src/main/frontend/public/swagger_APIs_definition.yaml rename to oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/frontend/public/swagger_APIs_definition.yaml diff --git a/MtdrSpring/backend/src/main/frontend/src/API.js b/oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/frontend/src/API.js similarity index 100% rename from MtdrSpring/backend/src/main/frontend/src/API.js rename to oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/frontend/src/API.js diff --git a/oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/frontend/src/App.js b/oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/frontend/src/App.js new file mode 100644 index 00000000..21462dd9 --- /dev/null +++ b/oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/frontend/src/App.js @@ -0,0 +1,240 @@ + /* +## MyToDoReact version 1.0. +## +## Copyright (c) 2022 Oracle, Inc. +## Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ +*/ +/* + * This is the application main React component. We're using "function" + * components in this application. No "class" components should be used for + * consistency. + * @author jean.de.lavarene@oracle.com + */ +import React, { useState, useEffect } from 'react'; +import NewItem from './NewItem'; +import API_LIST from './API'; +import DeleteIcon from '@mui/icons-material/Delete'; +import { Button, TableBody, CircularProgress } from '@mui/material'; +import Moment from 'react-moment'; + +/* In this application we're using Function Components with the State Hooks + * to manage the states. See the doc: https://reactjs.org/docs/hooks-state.html + * This App component represents the entire app. It renders a NewItem component + * and two tables: one that lists the todo items that are to be done and another + * one with the items that are already done. + */ +function App() { + // isLoading is true while waiting for the backend to return the list + // of items. We use this state to display a spinning circle: + const [isLoading, setLoading] = useState(false); + // Similar to isLoading, isInserting is true while waiting for the backend + // to insert a new item: + const [isInserting, setInserting] = useState(false); + // The list of todo items is stored in this state. It includes the "done" + // "not-done" items: + const [items, setItems] = useState([]); + // In case of an error during the API call: + const [error, setError] = useState(); + + function deleteItem(deleteId) { + // console.log("deleteItem("+deleteId+")") + fetch(API_LIST+"/"+deleteId, { + method: 'DELETE', + }) + .then(response => { + // console.log("response="); + // console.log(response); + if (response.ok) { + // console.log("deleteItem FETCH call is ok"); + return response; + } else { + throw new Error('Something went wrong ...'); + } + }) + .then( + (result) => { + const remainingItems = items.filter(item => item.id !== deleteId); + setItems(remainingItems); + }, + (error) => { + setError(error); + } + ); + } + function toggleDone(event, id, description, done) { + event.preventDefault(); + modifyItem(id, description, done).then( + (result) => { reloadOneIteam(id); }, + (error) => { setError(error); } + ); + } + function reloadOneIteam(id){ + fetch(API_LIST+"/"+id) + .then(response => { + if (response.ok) { + return response.json(); + } else { + throw new Error('Something went wrong ...'); + } + }) + .then( + (result) => { + const items2 = items.map( + x => (x.id === id ? { + ...x, + 'description':result.description, + 'done': result.done + } : x)); + setItems(items2); + }, + (error) => { + setError(error); + }); + } + function modifyItem(id, description, done) { + // console.log("deleteItem("+deleteId+")") + var data = {"description": description, "done": done}; + return fetch(API_LIST+"/"+id, { + method: 'PUT', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(data) + }) + .then(response => { + // console.log("response="); + // console.log(response); + if (response.ok) { + // console.log("deleteItem FETCH call is ok"); + return response; + } else { + throw new Error('Something went wrong ...'); + } + }); + } + /* + To simulate slow network, call sleep before making API calls. + const sleep = (milliseconds) => { + return new Promise(resolve => setTimeout(resolve, milliseconds)) + } + */ + useEffect(() => { + setLoading(true); + // sleep(5000).then(() => { + fetch(API_LIST) + .then(response => { + if (response.ok) { + return response.json(); + } else { + throw new Error('Something went wrong ...'); + } + }) + .then( + (result) => { + setLoading(false); + setItems(result); + }, + (error) => { + setLoading(false); + setError(error); + }); + + //}) + }, + // https://en.reactjs.org/docs/faq-ajax.html + [] // empty deps array [] means + // this useEffect will run once + // similar to componentDidMount() + ); + function addItem(text){ + console.log("addItem("+text+")") + setInserting(true); + var data = {}; + console.log(data); + data.description = text; + fetch(API_LIST, { + method: 'POST', + // We convert the React state to JSON and send it as the POST body + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(data), + }).then((response) => { + // This API doens't return a JSON document + console.log(response); + console.log(); + console.log(response.headers.location); + // return response.json(); + if (response.ok) { + return response; + } else { + throw new Error('Something went wrong ...'); + } + }).then( + (result) => { + var id = result.headers.get('location'); + var newItem = {"id": id, "description": text} + setItems([newItem, ...items]); + setInserting(false); + }, + (error) => { + setInserting(false); + setError(error); + } + ); + } + return ( +
+

MY TODO LIST

+ + { error && +

Error: {error.message}

+ } + { isLoading && + + } + { !isLoading && +
+ + + {items.map(item => ( + !item.done && ( + + + { /**/ } + + + + )))} + +
{item.description}{JSON.stringify(item, null, 2) }{item.createdAt}
+

+ Done items +

+ + + {items.map(item => ( + item.done && ( + + + + + + + + )))} + +
{item.description}{item.createdAt}
+
+ } + +
+ ); +} +export default App; diff --git a/oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/frontend/src/NewItem.js b/oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/frontend/src/NewItem.js new file mode 100644 index 00000000..c5215841 --- /dev/null +++ b/oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/frontend/src/NewItem.js @@ -0,0 +1,64 @@ +/* +## MyToDoReact version 1.0. +## +## Copyright (c) 2022 Oracle, Inc. +## Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ +*/ +/* + * Component that supports creating a new todo item. + * @author jean.de.lavarene@oracle.com + */ + +import React, { useState } from "react"; +import Button from '@mui/material/Button'; + + +function NewItem(props) { + const [item, setItem] = useState(''); + function handleSubmit(e) { + // console.log("NewItem.handleSubmit("+e+")"); + if (!item.trim()) { + return; + } + // addItem makes the REST API call: + props.addItem(item); + setItem(""); + e.preventDefault(); + } + function handleChange(e) { + setItem(e.target.value); + } + return ( +
+
+ { + if (event.key === 'Enter') { + handleSubmit(event); + } + }} + /> +    + +
+
+ ); +} + +export default NewItem; \ No newline at end of file diff --git a/oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/frontend/src/index.css b/oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/frontend/src/index.css new file mode 100644 index 00000000..b82c4de1 --- /dev/null +++ b/oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/frontend/src/index.css @@ -0,0 +1,134 @@ +/* +** Todo application version 1.0. +** +** Copyright (c) 2020, Oracle and/or its affiliates. +** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ +*/ +body { + /* from the redwood theme */ + background-color: #3A3632; + width: 100%; + max-width: 50rem; + margin: 0 auto; + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', + 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', + sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + } + .App { + background: #201E1C; + color: #FEF9F2; + display: flex; + flex-direction: column; + align-items: center; + font-size: max(12px,min(2vw, 18px)); /*calc(1vw + 1vmin);*/ + margin: 2rem 0 4rem 0; + padding: 1rem; + position: relative; + box-shadow: 0 10px 18px 0 rgba(0, 0, 0, 0.2), 0 4.5rem 8rem 0 rgba(0, 0, 0, 0.1); + border-radius: 0.5rem; + } + div#maincontent, div#newinputform form { + width: 95%; + } + div#maincontent { + margin: 0; + padding: 0; + } + h1 { + margin: 0.5rem 0 1rem 0; + padding: 0; + } + h2 { + margin: 0.1rem 0 0.1rem 0; + padding: 0; + } + #newiteminput { + width: 100%; + } + div#newinputform { + width: 100%; + } + div#newinputform form{ + display: flex; + flex-direction: row; + margin: 0 auto; + } + #donelist { + margin: 0; + padding: 0; + } + table#itemlistNotDone { + margin-bottom: 2rem; + } + table#itemlistDone { + margin-bottom: 3rem; + } + table.itemlist { + margin-top: 0.7rem; + border-collapse: collapse; + margin-bottom: 1rem; + } + table.itemlist td { + border-bottom: solid 1px #5B5652; + padding: .5rem; + } + table.itemlist td.description { + width: 100%; + padding-left: 1rem; + padding-right: 1rem; + } + table.itemlist td.date { + font-size: max(10px,min(1.5vw, 14px)); + color: grey; + white-space: nowrap; + padding-right: 0; + padding-left: 0; + } + table.itemlist tr:hover { + background-color: #161513; + } + input { + font-family: inherit; + font-size: 100%; + line-height: 1; + margin: 0; + } + button, + input { + overflow: visible; + } + input[type="text"] { + border-radius: 0.3rem; + padding-left: 10px; + } + button.AddButton, + button.DeleteButton, + button.AddButton, + button.DoneButton { + font-size: max(8px,min(2vw, 12px)); + padding: 0.35em 0.5em; + color:#161513; + } + /* from the redwood theme */ + button.AddButton { + color: #FEF9F2; + background-color: #5F7D4F; + } + button.AddButton:hover { + background-color: #6F915D; + } + button.DeleteButton { + color: #FEF9F2; + background-color: #D63B25; + } + button.DeleteButton:hover { + background-color: #EC4F3A + } + button.DoneButton { + background-color: #FBF9F8; + } + button.DoneButton:hover { + background-color: #D4CFCA; + } \ No newline at end of file diff --git a/oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/frontend/src/index.js b/oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/frontend/src/index.js new file mode 100644 index 00000000..6d58062d --- /dev/null +++ b/oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/frontend/src/index.js @@ -0,0 +1,21 @@ +/* +## MyToDoReact version 1.0. +## +## Copyright (c) 2021 Oracle, Inc. +## Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ +*/ +/* + * @author jean.de.lavarene@oracle.com + */ + +import React from 'react'; +import ReactDOM from 'react-dom'; +import './index.css'; +import App from './App'; + +ReactDOM.render( + + + , + document.getElementById('root') +); \ No newline at end of file diff --git a/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/MyTodoListApplication.java b/oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/MyTodoListApplication.java similarity index 100% rename from MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/MyTodoListApplication.java rename to oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/MyTodoListApplication.java diff --git a/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/config/CorsConfig.java b/oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/config/CorsConfig.java similarity index 100% rename from MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/config/CorsConfig.java rename to oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/config/CorsConfig.java diff --git a/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/config/DbSettings.java b/oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/config/DbSettings.java similarity index 100% rename from MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/config/DbSettings.java rename to oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/config/DbSettings.java diff --git a/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/config/OracleConfiguration.java b/oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/config/OracleConfiguration.java similarity index 100% rename from MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/config/OracleConfiguration.java rename to oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/config/OracleConfiguration.java diff --git a/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/controller/ToDoItemBotController.java b/oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/controller/ToDoItemBotController.java similarity index 58% rename from MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/controller/ToDoItemBotController.java rename to oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/controller/ToDoItemBotController.java index c17f851f..bffc5d18 100644 --- a/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/controller/ToDoItemBotController.java +++ b/oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/controller/ToDoItemBotController.java @@ -5,8 +5,6 @@ import java.util.List; import java.util.stream.Collectors; -import javax.ws.rs.Priorities; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.HttpHeaders; @@ -34,9 +32,6 @@ public class ToDoItemBotController extends TelegramLongPollingBot { private static final Logger logger = LoggerFactory.getLogger(ToDoItemBotController.class); private ToDoItemService toDoItemService; private String botName; - private String toDoAttribute; - private Boolean addingToDo; - private ToDoItem dummyToDoItem; public ToDoItemBotController(String botToken, String botName, ToDoItemService toDoItemService) { super(botToken); @@ -44,9 +39,6 @@ public ToDoItemBotController(String botToken, String botName, ToDoItemService to logger.info("Bot name: " + botName); this.toDoItemService = toDoItemService; this.botName = botName; - this.toDoAttribute = "Description"; - this.addingToDo = false; - this.dummyToDoItem = new ToDoItem(); } @Override @@ -56,7 +48,6 @@ public void onUpdateReceived(Update update) { String messageTextFromTelegram = update.getMessage().getText(); long chatId = update.getMessage().getChatId(); - long user_id = update.getMessage().getChat().getId(); if (messageTextFromTelegram.equals(BotCommands.START_COMMAND.getCommand()) || messageTextFromTelegram.equals(BotLabels.SHOW_MAIN_SCREEN.getLabel())) { @@ -64,7 +55,6 @@ public void onUpdateReceived(Update update) { SendMessage messageToTelegram = new SendMessage(); messageToTelegram.setChatId(chatId); messageToTelegram.setText(BotMessages.HELLO_MYTODO_BOT.getMessage()); - // messageToTelegram.setText(BotMessages.HELLO_MYTODO_BOT.getMessage() + "Hola dev:" + String.valueOf(user_id)); ReplyKeyboardMarkup keyboardMarkup = new ReplyKeyboardMarkup(); List keyboard = new ArrayList<>(); @@ -93,72 +83,7 @@ public void onUpdateReceived(Update update) { } catch (TelegramApiException e) { logger.error(e.getLocalizedMessage(), e); } - - //VER LOS DETALLES DE UN TODO, SE UTILIZA EL EMOJI DEL DIAMANTE PARA IDENTIFICAR ESTA ACCIÓN - } else if (messageTextFromTelegram.indexOf(BotLabels.TODO_DETAILS.getLabel()) != -1) { - - String todoSelected = messageTextFromTelegram.substring(0,messageTextFromTelegram.indexOf(BotLabels.DASH.getLabel())); - Integer todoId = Integer.valueOf(todoSelected); - - try { - - ToDoItem item = getToDoItemById(todoId).getBody(); - - String priority; - switch (item.getPriority()) { - case 1: - priority = "🟥 ALTA"; - break; - case 2: - priority = "🟧 MEDIA"; - break; - case 3: - priority = "🟨 BAJA"; - break; - default: - priority = "INDEFINIDA"; - } - - String complexity; - switch (item.getComplexity()) { - case 1: - complexity = "😎 BAJA"; - break; - case 2: - complexity = "🤨 MEDIA"; - break; - case 3: - complexity = "😨 ALTA"; - break; - default: - complexity = "INDEFINIDA"; - } - - String status; - if (item.isDone()) { - status = "Completada ⛳️"; - } else { - status = "En progreso 🛠️"; - } - - SendMessage messageToTelegram1 = new SendMessage(); - messageToTelegram1.setChatId(chatId); - messageToTelegram1.setText( "Claro! A continuación te muestro los detalles de tu task!"); - ReplyKeyboardRemove keyboardMarkup1 = new ReplyKeyboardRemove(true); - messageToTelegram1.setReplyMarkup(keyboardMarkup1); - execute(messageToTelegram1); - - SendMessage messageToTelegram = new SendMessage(); - messageToTelegram.setChatId(chatId); - messageToTelegram.setText( "Título: " + item.getDescription()+ ", " + "\nDescripción: " + " " + item.getDetails() + ", " + "\nPrioridad: " + priority + ", " + "\nComplejidad: " + complexity + ", " + " \nEstatus: " + status); - ReplyKeyboardRemove keyboardMarkup = new ReplyKeyboardRemove(true); - messageToTelegram.setReplyMarkup(keyboardMarkup); - execute(messageToTelegram); - } catch (Exception e) { - logger.error(e.getLocalizedMessage(), e); - } - } else if (messageTextFromTelegram.indexOf(BotLabels.DONE.getLabel()) != -1) { String done = messageTextFromTelegram.substring(0, @@ -213,14 +138,11 @@ public void onUpdateReceived(Update update) { BotHelper.sendMessageToTelegram(chatId, BotMessages.BYE.getMessage(), this); - //LISTAR TODOS LOS TODOS } else if (messageTextFromTelegram.equals(BotCommands.TODO_LIST.getCommand()) || messageTextFromTelegram.equals(BotLabels.LIST_ALL_ITEMS.getLabel()) || messageTextFromTelegram.equals(BotLabels.MY_TODO_LIST.getLabel())) { - - //AGREGAR SEGREGACION - List allItems = getAllToDoItems(); + List allItems = getAllToDoItems(); ReplyKeyboardMarkup keyboardMarkup = new ReplyKeyboardMarkup(); List keyboard = new ArrayList<>(); @@ -237,58 +159,23 @@ public void onUpdateReceived(Update update) { myTodoListTitleRow.add(BotLabels.MY_TODO_LIST.getLabel()); keyboard.add(myTodoListTitleRow); - List activeItems = allItems.stream().filter(item -> item.isDone() == false && (String.valueOf(user_id).equals(item.getIdAssignee()))) + List activeItems = allItems.stream().filter(item -> item.isDone() == false) .collect(Collectors.toList()); for (ToDoItem item : activeItems) { KeyboardRow currentRow = new KeyboardRow(); - // currentRow.add(item.getDescription()); - String prio = ""; - String comp = ""; - if(item.getPriority() <= 1) { - prio = "🟥"; - } else if(item.getPriority() == 2) { - prio = "🟧"; - } else if(item.getPriority() >= 3) { - prio = "🟨"; - } - if(item.getComplexity() <= 1) { - comp = "😎"; - } else if(item.getComplexity() == 2) { - comp = "🤨"; - } else if(item.getComplexity() >= 3) { - comp = "😰"; - } - // currentRow.add("Prioridad: " + prio + ", Complejidad: " + comp); - currentRow.add(item.getID() + BotLabels.DASH.getLabel() + BotLabels.TODO_DETAILS.getLabel() + item.getDescription() + " | Prioridad: " + prio + " | Complejidad: " + comp); + currentRow.add(item.getDescription()); currentRow.add(item.getID() + BotLabels.DASH.getLabel() + BotLabels.DONE.getLabel()); keyboard.add(currentRow); } - List doneItems = allItems.stream().filter(item -> item.isDone() == true && (String.valueOf(user_id).equals(item.getIdAssignee()))) + List doneItems = allItems.stream().filter(item -> item.isDone() == true) .collect(Collectors.toList()); for (ToDoItem item : doneItems) { KeyboardRow currentRow = new KeyboardRow(); - String prio = ""; - String comp = ""; - if(item.getPriority() <= 1) { - prio = "🟥"; - } else if(item.getPriority() == 2) { - prio = "🟧"; - } else if(item.getPriority() >= 3) { - prio = "🟨"; - } - if(item.getComplexity() <= 1) { - comp = "😎"; - } else if(item.getComplexity() == 2) { - comp = "🤨"; - } else if(item.getComplexity() >= 3) { - comp = "😰"; - } - // currentRow.add("Prioridad: " + prio + ", Complejidad: " + comp); - currentRow.add(item.getID() + BotLabels.DASH.getLabel() + BotLabels.TODO_DETAILS.getLabel() + item.getDescription() + " | Prioridad: " + prio + " | Complejidad: " + comp); + currentRow.add(item.getDescription()); currentRow.add(item.getID() + BotLabels.DASH.getLabel() + BotLabels.UNDO.getLabel()); currentRow.add(item.getID() + BotLabels.DASH.getLabel() + BotLabels.DELETE.getLabel()); keyboard.add(currentRow); @@ -311,123 +198,45 @@ public void onUpdateReceived(Update update) { } catch (TelegramApiException e) { logger.error(e.getLocalizedMessage(), e); } - - // AGREGAR NUEVO ITEM - } else if (addingToDo == true - || messageTextFromTelegram.equals(BotCommands.ADD_ITEM.getCommand()) + + } else if (messageTextFromTelegram.equals(BotCommands.ADD_ITEM.getCommand()) || messageTextFromTelegram.equals(BotLabels.ADD_NEW_ITEM.getLabel())) { - - if (toDoAttribute.equals("Description")) { - try { - SendMessage messageToTelegram = new SendMessage(); - messageToTelegram.setChatId(chatId); - messageToTelegram.setText("Introduce el título del ToDo:"); - // send message - execute(messageToTelegram); - - } catch (Exception e) { - logger.error(e.getLocalizedMessage(), e); - } - - toDoAttribute = "Details"; - - } else if (toDoAttribute.equals("Details")) { - - dummyToDoItem.setDescription(messageTextFromTelegram); - - try { - SendMessage messageToTelegram = new SendMessage(); - messageToTelegram.setChatId(chatId); - messageToTelegram.setText("Dale una descriptión al ToDo:"); - // send message - execute(messageToTelegram); - - } catch (Exception e) { - logger.error(e.getLocalizedMessage(), e); - } - - toDoAttribute = "Priority"; - - } else if (toDoAttribute.equals("Priority")) { - - dummyToDoItem.setDetails(messageTextFromTelegram); - - try { - SendMessage messageToTelegram = new SendMessage(); - messageToTelegram.setChatId(chatId); - messageToTelegram.setText("¿Qué prioridad tiene? \n (asignala con un numero) 🟥: 1, 🟧: 2, 🟨: 3"); - // send message - execute(messageToTelegram); - - } catch (Exception e) { - logger.error(e.getLocalizedMessage(), e); - } - - toDoAttribute = "Complexity"; - - } else if (toDoAttribute.equals("Complexity")) { - - dummyToDoItem.setPriority(Integer.valueOf(messageTextFromTelegram)); - - try { - SendMessage messageToTelegram = new SendMessage(); - messageToTelegram.setChatId(chatId); - messageToTelegram.setText("¿Qué complejidad tiene? \n (asignala con un numero) 😎: 1, 🤨: 2, 😰: 3"); - // send message - execute(messageToTelegram); - - } catch (Exception e) { - logger.error(e.getLocalizedMessage(), e); - } - - toDoAttribute = "Final"; - - } else if (toDoAttribute.equals("Final")) { - - dummyToDoItem.setComplexity(Integer.valueOf(messageTextFromTelegram)); - //agregar todo a bd - dummyToDoItem.setCreation_ts(OffsetDateTime.now()); - dummyToDoItem.setDone(false); - dummyToDoItem.setIdAssignee(String.valueOf(user_id)); - - try { - ResponseEntity entity = addToDoItem(dummyToDoItem); - } catch (Exception e) { - logger.error(e.getLocalizedMessage(), e); - } - - // Reseteo de las variables de control - addingToDo = false; - dummyToDoItem = new ToDoItem(); - toDoAttribute = "Description"; - - try { - SendMessage messageToTelegram = new SendMessage(); - messageToTelegram.setChatId(chatId); - messageToTelegram.setText(BotMessages.NEW_ITEM_ADDED.getMessage()); - // send message - execute(messageToTelegram); - - } catch (Exception e) { - logger.error(e.getLocalizedMessage(), e); - } + try { + SendMessage messageToTelegram = new SendMessage(); + messageToTelegram.setChatId(chatId); + messageToTelegram.setText(BotMessages.TYPE_NEW_TODO_ITEM.getMessage()); + // hide keyboard + ReplyKeyboardRemove keyboardMarkup = new ReplyKeyboardRemove(true); + messageToTelegram.setReplyMarkup(keyboardMarkup); + + // send message + execute(messageToTelegram); + + } catch (Exception e) { + logger.error(e.getLocalizedMessage(), e); } + } + else { try { + ToDoItem newItem = new ToDoItem(); + newItem.setDescription(messageTextFromTelegram); + newItem.setCreation_ts(OffsetDateTime.now()); + newItem.setDone(false); + ResponseEntity entity = addToDoItem(newItem); + SendMessage messageToTelegram = new SendMessage(); messageToTelegram.setChatId(chatId); - messageToTelegram.setText("Disculpa, no te he entendido. Inténtalo de nuevo."); - // send message - execute(messageToTelegram); + messageToTelegram.setText(BotMessages.NEW_ITEM_ADDED.getMessage()); + execute(messageToTelegram); } catch (Exception e) { logger.error(e.getLocalizedMessage(), e); } } } } - } @Override public String getBotUsername() { @@ -439,10 +248,6 @@ public List getAllToDoItems() { return toDoItemService.findAll(); } - // public List getAllDevItems(long devID) { - // return toDoItemService.findAllDevItems(devID) - // } - // GET BY ID /todolist/{id} public ResponseEntity getToDoItemById(@PathVariable int id) { try { diff --git a/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/controller/ToDoItemController.java b/oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/controller/ToDoItemController.java similarity index 99% rename from MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/controller/ToDoItemController.java rename to oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/controller/ToDoItemController.java index 75e57150..dfaacf4d 100644 --- a/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/controller/ToDoItemController.java +++ b/oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/controller/ToDoItemController.java @@ -42,8 +42,6 @@ public ResponseEntity addToDoItem(@RequestBody ToDoItem todoItem) throws Excepti return ResponseEntity.ok() .headers(responseHeaders).build(); } - - //@CrossOrigin @PutMapping(value = "todolist/{id}") public ResponseEntity updateToDoItem(@RequestBody ToDoItem toDoItem, @PathVariable int id){ diff --git a/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/model/ToDoItem.java b/oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/model/ToDoItem.java similarity index 52% rename from MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/model/ToDoItem.java rename to oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/model/ToDoItem.java index b2dda91a..18bf9835 100644 --- a/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/model/ToDoItem.java +++ b/oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/model/ToDoItem.java @@ -14,33 +14,20 @@ public class ToDoItem { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) int ID; - @Column(name = "DESCRIPTION") //Titulo + @Column(name = "DESCRIPTION") String description; - @Column(name = "DETAILS") //Descripcion - String details; - @Column(name = "PRIORITY") //Prioridad - int priority; - @Column(name = "COMPLEXITY") //Complejidad - int complexity; @Column(name = "CREATION_TS") OffsetDateTime creation_ts; @Column(name = "done") boolean done; - @Column(name = "IDASSIGNEE") - String idAssignee; - public ToDoItem(){ } - - public ToDoItem(int ID, String description, String details, int priority, int complexity, OffsetDateTime creation_ts, boolean done, String idAssignee) { + public ToDoItem(int ID, String description, OffsetDateTime creation_ts, boolean done) { this.ID = ID; this.description = description; - this.details = details; - this.priority = priority; this.creation_ts = creation_ts; this.done = done; - this.idAssignee = idAssignee; } public int getID() { @@ -59,30 +46,6 @@ public void setDescription(String description) { this.description = description; } - public String getDetails() { - return details; - } - - public void setDetails(String details) { - this.details = details; - } - - public int getPriority() { - return priority; - } - - public void setPriority(int priority) { - this.priority = priority; - } - - public int getComplexity() { - return complexity; - } - - public void setComplexity(int complexity) { - this.complexity = complexity; - } - public OffsetDateTime getCreation_ts() { return creation_ts; } @@ -94,15 +57,7 @@ public void setCreation_ts(OffsetDateTime creation_ts) { public boolean isDone() { return done; } - - public void setIdAssignee(String idAssignee){ - this.idAssignee = idAssignee; - } - public String getIdAssignee() { - return idAssignee; - } - public void setDone(boolean done) { this.done = done; } @@ -112,12 +67,8 @@ public String toString() { return "ToDoItem{" + "ID=" + ID + ", description='" + description + '\'' + - ", details='" + details + '\'' + - ", priority=" + priority + - ", complexity=" + complexity + ", creation_ts=" + creation_ts + ", done=" + done + - ", IDASSIGNEE=" + idAssignee + '}'; } } diff --git a/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/repository/ToDoItemRepository.java b/oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/repository/ToDoItemRepository.java similarity index 100% rename from MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/repository/ToDoItemRepository.java rename to oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/repository/ToDoItemRepository.java diff --git a/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/security/WebSecurityConfiguration.java b/oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/security/WebSecurityConfiguration.java similarity index 100% rename from MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/security/WebSecurityConfiguration.java rename to oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/security/WebSecurityConfiguration.java diff --git a/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/service/ToDoItemService.java b/oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/service/ToDoItemService.java similarity index 89% rename from MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/service/ToDoItemService.java rename to oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/service/ToDoItemService.java index 13ed1db2..6992d0c9 100644 --- a/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/service/ToDoItemService.java +++ b/oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/service/ToDoItemService.java @@ -46,11 +46,7 @@ public ToDoItem updateToDoItem(int id, ToDoItem td){ toDoItem.setID(id); toDoItem.setCreation_ts(td.getCreation_ts()); toDoItem.setDescription(td.getDescription()); - toDoItem.setDetails(td.getDetails()); - toDoItem.setPriority(td.getPriority()); - toDoItem.setComplexity(td.getComplexity()); toDoItem.setDone(td.isDone()); - toDoItem.setIdAssignee(td.getIdAssignee()); return toDoItemRepository.save(toDoItem); }else{ return null; diff --git a/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/util/BotCommands.java b/oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/util/BotCommands.java similarity index 76% rename from MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/util/BotCommands.java rename to oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/util/BotCommands.java index e50a72a5..35c26cd2 100644 --- a/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/util/BotCommands.java +++ b/oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/util/BotCommands.java @@ -3,9 +3,9 @@ public enum BotCommands { START_COMMAND("/start"), - HIDE_COMMAND("/ocultar"), - TODO_LIST("/tasks"), - ADD_ITEM("/creartask"); + HIDE_COMMAND("/hide"), + TODO_LIST("/todolist"), + ADD_ITEM("/additem"); private String command; diff --git a/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/util/BotHelper.java b/oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/util/BotHelper.java similarity index 100% rename from MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/util/BotHelper.java rename to oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/util/BotHelper.java diff --git a/oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/util/BotLabels.java b/oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/util/BotLabels.java new file mode 100644 index 00000000..bd1e7a45 --- /dev/null +++ b/oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/util/BotLabels.java @@ -0,0 +1,25 @@ +package com.springboot.MyTodoList.util; + +public enum BotLabels { + + SHOW_MAIN_SCREEN("Show Main Screen"), + HIDE_MAIN_SCREEN("Hide Main Screen"), + LIST_ALL_ITEMS("List All Items"), + ADD_NEW_ITEM("Add New Item"), + DONE("DONE"), + UNDO("UNDO"), + DELETE("DELETE"), + MY_TODO_LIST("MY TODO LIST"), + DASH("-"); + + private String label; + + BotLabels(String enumLabel) { + this.label = enumLabel; + } + + public String getLabel() { + return label; + } + +} diff --git a/oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/util/BotMessages.java b/oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/util/BotMessages.java new file mode 100644 index 00000000..f30cfb23 --- /dev/null +++ b/oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/java/com/springboot/MyTodoList/util/BotMessages.java @@ -0,0 +1,25 @@ +package com.springboot.MyTodoList.util; + +public enum BotMessages { + + HELLO_MYTODO_BOT( + "Hello! I'm MyTodoList Bot!\nType a new todo item below and press the send button (blue arrow), or select an option below:"), + BOT_REGISTERED_STARTED("Bot registered and started succesfully!"), + ITEM_DONE("Item done! Select /todolist to return to the list of todo items, or /start to go to the main screen."), + ITEM_UNDONE("Item undone! Select /todolist to return to the list of todo items, or /start to go to the main screen."), + ITEM_DELETED("Item deleted! Select /todolist to return to the list of todo items, or /start to go to the main screen."), + TYPE_NEW_TODO_ITEM("Type a new todo item below and press the send button (blue arrow) on the rigth-hand side."), + NEW_ITEM_ADDED("New item added! Select /todolist to return to the list of todo items, or /start to go to the main screen."), + BYE("Bye! Select /start to resume!"); + + private String message; + + BotMessages(String enumMessage) { + this.message = enumMessage; + } + + public String getMessage() { + return message; + } + +} diff --git a/MtdrSpring/backend/src/main/resources/application.properties b/oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/resources/application.properties similarity index 100% rename from MtdrSpring/backend/src/main/resources/application.properties rename to oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/resources/application.properties diff --git a/MtdrSpring/backend/src/main/resources/application.yaml b/oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/resources/application.yaml similarity index 100% rename from MtdrSpring/backend/src/main/resources/application.yaml rename to oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/resources/application.yaml diff --git a/MtdrSpring/backend/src/main/resources/todolistapp-springboot.yaml b/oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/resources/todolistapp-springboot.yaml similarity index 100% rename from MtdrSpring/backend/src/main/resources/todolistapp-springboot.yaml rename to oci-react-samples-springboot-bot/MtdrSpring/backend/src/main/resources/todolistapp-springboot.yaml diff --git a/MtdrSpring/backend/undeploy.sh b/oci-react-samples-springboot-bot/MtdrSpring/backend/undeploy.sh similarity index 100% rename from MtdrSpring/backend/undeploy.sh rename to oci-react-samples-springboot-bot/MtdrSpring/backend/undeploy.sh diff --git a/MtdrSpring/destroy.sh b/oci-react-samples-springboot-bot/MtdrSpring/destroy.sh similarity index 100% rename from MtdrSpring/destroy.sh rename to oci-react-samples-springboot-bot/MtdrSpring/destroy.sh diff --git a/MtdrSpring/env.sh b/oci-react-samples-springboot-bot/MtdrSpring/env.sh similarity index 100% rename from MtdrSpring/env.sh rename to oci-react-samples-springboot-bot/MtdrSpring/env.sh diff --git a/MtdrSpring/setup.sh b/oci-react-samples-springboot-bot/MtdrSpring/setup.sh similarity index 100% rename from MtdrSpring/setup.sh rename to oci-react-samples-springboot-bot/MtdrSpring/setup.sh diff --git a/MtdrSpring/terraform/apigateway.tf b/oci-react-samples-springboot-bot/MtdrSpring/terraform/apigateway.tf similarity index 100% rename from MtdrSpring/terraform/apigateway.tf rename to oci-react-samples-springboot-bot/MtdrSpring/terraform/apigateway.tf diff --git a/MtdrSpring/terraform/availability_domain.tf b/oci-react-samples-springboot-bot/MtdrSpring/terraform/availability_domain.tf similarity index 100% rename from MtdrSpring/terraform/availability_domain.tf rename to oci-react-samples-springboot-bot/MtdrSpring/terraform/availability_domain.tf diff --git a/MtdrSpring/terraform/containerengine.tf b/oci-react-samples-springboot-bot/MtdrSpring/terraform/containerengine.tf similarity index 100% rename from MtdrSpring/terraform/containerengine.tf rename to oci-react-samples-springboot-bot/MtdrSpring/terraform/containerengine.tf diff --git a/MtdrSpring/terraform/core.tf b/oci-react-samples-springboot-bot/MtdrSpring/terraform/core.tf similarity index 100% rename from MtdrSpring/terraform/core.tf rename to oci-react-samples-springboot-bot/MtdrSpring/terraform/core.tf diff --git a/MtdrSpring/terraform/database.tf b/oci-react-samples-springboot-bot/MtdrSpring/terraform/database.tf similarity index 100% rename from MtdrSpring/terraform/database.tf rename to oci-react-samples-springboot-bot/MtdrSpring/terraform/database.tf diff --git a/MtdrSpring/terraform/main-var.tf b/oci-react-samples-springboot-bot/MtdrSpring/terraform/main-var.tf similarity index 100% rename from MtdrSpring/terraform/main-var.tf rename to oci-react-samples-springboot-bot/MtdrSpring/terraform/main-var.tf diff --git a/MtdrSpring/terraform/object_storage.tf b/oci-react-samples-springboot-bot/MtdrSpring/terraform/object_storage.tf similarity index 100% rename from MtdrSpring/terraform/object_storage.tf rename to oci-react-samples-springboot-bot/MtdrSpring/terraform/object_storage.tf diff --git a/MtdrSpring/terraform/outputs.tf b/oci-react-samples-springboot-bot/MtdrSpring/terraform/outputs.tf similarity index 100% rename from MtdrSpring/terraform/outputs.tf rename to oci-react-samples-springboot-bot/MtdrSpring/terraform/outputs.tf diff --git a/MtdrSpring/terraform/provider.tf b/oci-react-samples-springboot-bot/MtdrSpring/terraform/provider.tf similarity index 100% rename from MtdrSpring/terraform/provider.tf rename to oci-react-samples-springboot-bot/MtdrSpring/terraform/provider.tf diff --git a/MtdrSpring/terraform/repositories.tf b/oci-react-samples-springboot-bot/MtdrSpring/terraform/repositories.tf similarity index 100% rename from MtdrSpring/terraform/repositories.tf rename to oci-react-samples-springboot-bot/MtdrSpring/terraform/repositories.tf diff --git a/MtdrSpring/utils/db-setup.sh b/oci-react-samples-springboot-bot/MtdrSpring/utils/db-setup.sh similarity index 95% rename from MtdrSpring/utils/db-setup.sh rename to oci-react-samples-springboot-bot/MtdrSpring/utils/db-setup.sh index c1ada6e6..3c6bddbd 100755 --- a/MtdrSpring/utils/db-setup.sh +++ b/oci-react-samples-springboot-bot/MtdrSpring/utils/db-setup.sh @@ -140,7 +140,7 @@ CREATE USER $U IDENTIFIED BY "$DB_PASSWORD" DEFAULT TABLESPACE data QUOTA UNLIMI GRANT CREATE SESSION, CREATE VIEW, CREATE SEQUENCE, CREATE PROCEDURE TO $U; GRANT CREATE TABLE, CREATE TRIGGER, CREATE TYPE, CREATE MATERIALIZED VIEW TO $U; GRANT CONNECT, RESOURCE, pdb_dba, SODA_APP to $U; -CREATE TABLE TODOUSER.todoitem (id NUMBER GENERATED ALWAYS AS IDENTITY, description VARCHAR2(4000), details VARCHAR2(4000), priority NUMBER(1,0), complexity NUMBER(1,0), creation_ts TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP, done NUMBER(1,0) , PRIMARY KEY (id)); +CREATE TABLE TODOUSER.todoitem (id NUMBER GENERATED ALWAYS AS IDENTITY, description VARCHAR2(4000), creation_ts TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP, done NUMBER(1,0) , PRIMARY KEY (id)); insert into TODOUSER.todoitem (description, done) values ('Manual item insert', 0); commit; ! diff --git a/MtdrSpring/utils/java-builds.sh b/oci-react-samples-springboot-bot/MtdrSpring/utils/java-builds.sh similarity index 100% rename from MtdrSpring/utils/java-builds.sh rename to oci-react-samples-springboot-bot/MtdrSpring/utils/java-builds.sh diff --git a/MtdrSpring/utils/kube_token_cache.sh b/oci-react-samples-springboot-bot/MtdrSpring/utils/kube_token_cache.sh similarity index 100% rename from MtdrSpring/utils/kube_token_cache.sh rename to oci-react-samples-springboot-bot/MtdrSpring/utils/kube_token_cache.sh diff --git a/MtdrSpring/utils/lb-destroy.sh b/oci-react-samples-springboot-bot/MtdrSpring/utils/lb-destroy.sh similarity index 100% rename from MtdrSpring/utils/lb-destroy.sh rename to oci-react-samples-springboot-bot/MtdrSpring/utils/lb-destroy.sh diff --git a/MtdrSpring/utils/main-destroy.sh b/oci-react-samples-springboot-bot/MtdrSpring/utils/main-destroy.sh similarity index 100% rename from MtdrSpring/utils/main-destroy.sh rename to oci-react-samples-springboot-bot/MtdrSpring/utils/main-destroy.sh diff --git a/MtdrSpring/utils/main-setup.sh b/oci-react-samples-springboot-bot/MtdrSpring/utils/main-setup.sh similarity index 100% rename from MtdrSpring/utils/main-setup.sh rename to oci-react-samples-springboot-bot/MtdrSpring/utils/main-setup.sh diff --git a/MtdrSpring/utils/oke-setup.sh b/oci-react-samples-springboot-bot/MtdrSpring/utils/oke-setup.sh similarity index 100% rename from MtdrSpring/utils/oke-setup.sh rename to oci-react-samples-springboot-bot/MtdrSpring/utils/oke-setup.sh diff --git a/MtdrSpring/utils/os-destroy.sh b/oci-react-samples-springboot-bot/MtdrSpring/utils/os-destroy.sh similarity index 100% rename from MtdrSpring/utils/os-destroy.sh rename to oci-react-samples-springboot-bot/MtdrSpring/utils/os-destroy.sh diff --git a/MtdrSpring/utils/python-scripts/generate-unique-key.py b/oci-react-samples-springboot-bot/MtdrSpring/utils/python-scripts/generate-unique-key.py similarity index 100% rename from MtdrSpring/utils/python-scripts/generate-unique-key.py rename to oci-react-samples-springboot-bot/MtdrSpring/utils/python-scripts/generate-unique-key.py diff --git a/MtdrSpring/utils/python-scripts/process-cluster-ocid-json.py b/oci-react-samples-springboot-bot/MtdrSpring/utils/python-scripts/process-cluster-ocid-json.py similarity index 100% rename from MtdrSpring/utils/python-scripts/process-cluster-ocid-json.py rename to oci-react-samples-springboot-bot/MtdrSpring/utils/python-scripts/process-cluster-ocid-json.py diff --git a/MtdrSpring/utils/repo-destroy.sh b/oci-react-samples-springboot-bot/MtdrSpring/utils/repo-destroy.sh similarity index 100% rename from MtdrSpring/utils/repo-destroy.sh rename to oci-react-samples-springboot-bot/MtdrSpring/utils/repo-destroy.sh diff --git a/MtdrSpring/utils/state-functions.sh b/oci-react-samples-springboot-bot/MtdrSpring/utils/state-functions.sh similarity index 100% rename from MtdrSpring/utils/state-functions.sh rename to oci-react-samples-springboot-bot/MtdrSpring/utils/state-functions.sh diff --git a/MtdrSpring/utils/terraform.sh b/oci-react-samples-springboot-bot/MtdrSpring/utils/terraform.sh similarity index 100% rename from MtdrSpring/utils/terraform.sh rename to oci-react-samples-springboot-bot/MtdrSpring/utils/terraform.sh diff --git a/oci-react-samples-springboot-bot/README.md b/oci-react-samples-springboot-bot/README.md new file mode 100644 index 00000000..d6ce8b30 --- /dev/null +++ b/oci-react-samples-springboot-bot/README.md @@ -0,0 +1,19 @@ +# oci-react-samples +A repository for full stack Cloud Native applications with a React JS frontend and various backends (Java, Python, DotNet, and so on) on the Oracle Cloud Infrastructure. + +![image](https://user-images.githubusercontent.com/7783295/116454396-cbfb7a00-a814-11eb-8196-ba2113858e8b.png) + + +## MyToDo React JS +The `mtdrworkshop` repository hosts the materiald (code, scripts and instructions) for building and deploying Cloud Native Application using a Java/Helidon backend + + +### Requirements +The lab executes scripts that require the following software to run properly: (These are already installed on and included with the OCI Cloud Shell) +* oci-cli +* python 2.7^ +* terraform +* kubectl +* mvn (maven) + +## Expect more ... diff --git a/SECURITY.md b/oci-react-samples-springboot-bot/SECURITY.md similarity index 100% rename from SECURITY.md rename to oci-react-samples-springboot-bot/SECURITY.md diff --git a/THIRD_PARTY_LICENSES.txt b/oci-react-samples-springboot-bot/THIRD_PARTY_LICENSES.txt similarity index 100% rename from THIRD_PARTY_LICENSES.txt rename to oci-react-samples-springboot-bot/THIRD_PARTY_LICENSES.txt diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index 64b5a1ab..00000000 --- a/package-lock.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "Oracle-Java-Bot-Eq2", - "lockfileVersion": 3, - "requires": true, - "packages": {} -}