some changes

develop
Jasper Levin Spahl 3 years ago
parent 0387eac358
commit a0cc7e7386
Signed by: jasper
GPG Key ID: 91991C9808A18BB0

@ -1,14 +0,0 @@
{
"0 debug pnpm:scope": {
"selected": 1
},
"1 error pnpm": {
"code": "ERR_PNPM_NO_IMPORTER_MANIFEST_FOUND",
"err": {
"name": "pnpm",
"message": "No package.json (or package.yaml, or package.json5) was found in \"/home/jasper/go/src/spahl.ddns.net/jasper/wok-able-backend\".",
"code": "ERR_PNPM_NO_IMPORTER_MANIFEST_FOUND",
"stack": "pnpm: No package.json (or package.yaml, or package.json5) was found in \"/home/jasper/go/src/spahl.ddns.net/jasper/wok-able-backend\".\n at readProjectManifest (/usr/pnpm-global/5/node_modules/.pnpm/pnpm@6.32.3/node_modules/pnpm/dist/pnpm.cjs:19818:13)\n at async Object.readProjectManifestOnly (/usr/pnpm-global/5/node_modules/.pnpm/pnpm@6.32.3/node_modules/pnpm/dist/pnpm.cjs:19822:28)\n at async readProjectManifestOnly (/usr/pnpm-global/5/node_modules/.pnpm/pnpm@6.32.3/node_modules/pnpm/dist/pnpm.cjs:43721:24)\n at async Object.handler (/usr/pnpm-global/5/node_modules/.pnpm/pnpm@6.32.3/node_modules/pnpm/dist/pnpm.cjs:177918:24)\n at async /usr/pnpm-global/5/node_modules/.pnpm/pnpm@6.32.3/node_modules/pnpm/dist/pnpm.cjs:182194:21\n at async run (/usr/pnpm-global/5/node_modules/.pnpm/pnpm@6.32.3/node_modules/pnpm/dist/pnpm.cjs:182168:34)\n at async runPnpm (/usr/pnpm-global/5/node_modules/.pnpm/pnpm@6.32.3/node_modules/pnpm/dist/pnpm.cjs:182387:5)\n at async /usr/pnpm-global/5/node_modules/.pnpm/pnpm@6.32.3/node_modules/pnpm/dist/pnpm.cjs:182379:7"
}
}
}

@ -1,22 +1,26 @@
{ {
// Verwendet IntelliSense zum Ermitteln möglicher Attribute. // Verwendet IntelliSense zum Ermitteln möglicher Attribute.
// Zeigen Sie auf vorhandene Attribute, um die zugehörigen Beschreibungen anzuzeigen. // Zeigen Sie auf vorhandene Attribute, um die zugehörigen Beschreibungen anzuzeigen.
// Weitere Informationen finden Sie unter https://go.microsoft.com/fwlink/?linkid=830387 // Weitere Informationen finden Sie unter https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0", "version": "0.2.0",
"configurations": [ "configurations": [
{
"name": "Launch Server",
"type": "go", {
"request": "launch", "name": "Attach to Process",
"mode": "debug", "type": "go",
"program": "main.go" "request": "attach",
}, "mode": "local",
{ "processId": 0
"name": "Launch Package", },
"type": "go", {
"request": "launch", "name": "Run Go Server",
"mode": "auto", "type": "go",
"program": "${fileDirname}" "request": "launch",
} "mode": "debug",
] "program": "${workspaceFolder}",
} "env": {},
"args": []
}
]
}

@ -0,0 +1,55 @@
# syntax=docker/dockerfile:1
##
## Build Backend
##
FROM golang:1.18-buster AS build_backend
ENV GO111MODULE=on \
CGO_ENABLE=1 \
GOOS=linux \
GOARCH=amd64
WORKDIR /app
COPY go.mod .
COPY go.sum .
RUN go mod download
RUN apt update && apt install -y ca-certificates
COPY *.go ./
COPY auth/. auth/.
COPY controllers/. controllers/.
COPY models/. models/.
COPY server/. server/.
RUN go build -a --installsuffix cgo -v -tags netgo -ldflags '-extldflags "-static"' -o /main .
##
## Build Frontend
##
FROM node:16 AS build_frontend
WORKDIR /usr/src/app
RUN npm install -g pnpm
COPY assets/package.json ./
COPY assets/pnpm-lock.yaml ./
RUN pnpm i
COPY assets/. .
RUN pnpm build
##
## Deploy
##
FROM scratch
LABEL maintainer="Jasper Spahl <jasperspahl@web.de>"
ENV WOKABLE_MODE="release"
WORKDIR /
COPY --from=build_backend /main ./
COPY --from=build_frontend /usr/src/app/dist/. assets/dist/.
EXPOSE 8080
ENTRYPOINT [ "/main" ]

@ -0,0 +1,2 @@
node_modules
npm-debug.log

@ -5,6 +5,7 @@ import {
Route, Route,
Navigate, Navigate,
} from "react-router-dom"; } from "react-router-dom";
import { ThemeProvider } from "styled-components";
import { useAppDispatch, useAppSelector } from "./app/hooks"; import { useAppDispatch, useAppSelector } from "./app/hooks";
import AuthRedirect from "./components/AuthRedirect"; import AuthRedirect from "./components/AuthRedirect";
@ -22,11 +23,13 @@ const Loading = () => <p>Loading</p>;
const App: React.FC = () => { const App: React.FC = () => {
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const state = useAppSelector((state) => state.auth.state); const state = useAppSelector((state) => state.auth.state);
const theme = useAppSelector((state) => state.theme);
useEffect(() => { useEffect(() => {
dispatch(verify()); dispatch(verify());
}, []); }, []);
return ( return (
<> <>
<ThemeProvider theme={theme}>
<GlobalStyles /> <GlobalStyles />
{state == "loading" ? ( {state == "loading" ? (
<Loading /> <Loading />
@ -102,6 +105,7 @@ const App: React.FC = () => {
</Routes> </Routes>
</Router> </Router>
)} )}
</ThemeProvider>
</> </>
); );
}; };

@ -1,11 +1,13 @@
import { configureStore } from "@reduxjs/toolkit"; import { configureStore } from "@reduxjs/toolkit";
import AuthReducer from "../features/auth/auth-slice"; import AuthReducer from "../features/auth/auth-slice";
import ThemeSlice from "../features/theme/theme-slice";
import {cardDeckApiSlice} from "../features/cardDecks/cardDeck-api-slice"; import {cardDeckApiSlice} from "../features/cardDecks/cardDeck-api-slice";
export const store = configureStore({ export const store = configureStore({
reducer: { reducer: {
auth: AuthReducer, auth: AuthReducer,
theme: ThemeSlice,
[cardDeckApiSlice.reducerPath]: cardDeckApiSlice.reducer [cardDeckApiSlice.reducerPath]: cardDeckApiSlice.reducer
}, },
middleware: (getDefaultMiddleware) => { middleware: (getDefaultMiddleware) => {

@ -0,0 +1,12 @@
import React from 'react'
import { StyledCard } from './styled'
const Card: React.FC = ({children}) => {
return (
<StyledCard>
{children}
</StyledCard>
)
}
export default Card

@ -0,0 +1,9 @@
import styled from "styled-components";
export const StyledCard = styled.div`
border-radius: ${props => props.theme.borderRadius};
padding: 16px;
width: 100%;
height: 100%;
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);
`;

@ -4,8 +4,10 @@ export const HeaderWrapper = styled.div`
left: var(--navbar-width); left: var(--navbar-width);
height: var(--toolbar-height); height: var(--toolbar-height);
width: 100%; width: 100%;
align-self: flex-start;
& > h1 { & > h1 {
padding: 16px; padding: 16px;
margin: 0;
display: flex; display: flex;
align-items: center; align-items: center;
height: 100%; height: 100%;

@ -1,4 +1,5 @@
import React from "react"; import React from "react";
import Card from "../Card/Card";
import { TextareaWithLabelWrapper } from "./styled"; import { TextareaWithLabelWrapper } from "./styled";
export interface ITextareaWithLabel { export interface ITextareaWithLabel {
@ -19,19 +20,21 @@ const TextareaWithLabel: React.FC<ITextareaWithLabel> = ({
rows, rows,
}) => { }) => {
return ( return (
<TextareaWithLabelWrapper> <Card>
<label htmlFor={label}>{label}</label> <TextareaWithLabelWrapper>
<textarea <label htmlFor={label}>{label}</label>
className="textbox" <textarea
id={label} className="textbox"
role="textbox" id={label}
onChange={onChange} role="textbox"
value={value} onChange={onChange}
placeholder={placeholder} value={value}
disabled={disabled} placeholder={placeholder}
rows={rows ? rows : 4} disabled={disabled}
></textarea> rows={rows ? rows : 4}
</TextareaWithLabelWrapper> ></textarea>
</TextareaWithLabelWrapper>
</Card>
); );
}; };

@ -0,0 +1,48 @@
import { createSlice } from "@reduxjs/toolkit";
export interface Color {
main: string;
contrastText: string;
}
export interface ColorPalette {
common: Color;
muted: Color;
primary: Color;
secondary: Color;
}
export interface Theme {
borderRadius: string;
palette: ColorPalette
}
const initialState: Theme = {
borderRadius: "4px",
palette: {
common: {
main: "#ffffff",
contrastText: "#222831",
},
muted: {
main: "#aaaaaa",
contrastText: "#222831"
},
primary: {
main: "#726a95",
contrastText: '#ffffff'
},
secondary: {
main: "#709bf0",
contrastText: "#ffffff",
}
}
}
const themeSlice = createSlice({
name: "theme",
initialState,
reducers: {
}
})
export const {} = themeSlice.actions;
export default themeSlice.reducer;

@ -6,8 +6,8 @@ import Navbar from "../../components/Navbar/Navbar";
const Base: React.FC = () => { const Base: React.FC = () => {
return ( return (
<BaseLayoutWrapper> <BaseLayoutWrapper>
<Navbar /> <Navbar />
<Outlet /> <Outlet />
</BaseLayoutWrapper> </BaseLayoutWrapper>
); );
}; };

@ -3,7 +3,8 @@ import styled from "styled-components";
export const BaseLayoutWrapper = styled.div` export const BaseLayoutWrapper = styled.div`
display: flex; display: flex;
padding: 0 0 0 var(--navbar-width); padding: 0 0 0 var(--navbar-width);
flex-direction: column;
width: 100%; width: 100%;
height: 100%; height: 100%;
overflow: hidden; overflow: hidden;
`; `;

@ -7,6 +7,7 @@ import { useFetchCardDeckByIdQuery } from "../../features/cardDecks/cardDeck-api
import { Link, useParams } from "react-router-dom"; import { Link, useParams } from "react-router-dom";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faPlus } from "@fortawesome/free-solid-svg-icons"; import { faPlus } from "@fortawesome/free-solid-svg-icons";
import Card from "../../components/Card/Card";
const Decks: React.FC = () => { const Decks: React.FC = () => {
const { id } = useParams(); const { id } = useParams();
@ -23,12 +24,14 @@ const Decks: React.FC = () => {
<h2>{data?.description}</h2> <h2>{data?.description}</h2>
<div className="flex"> <div className="flex">
{data?.cards.map((card) => ( {data?.cards.map((card) => (
<span key={card.id}> <Card>
<div className="deck"> <span key={card.id}>
<div className="title">{card.front}</div> <div className="deck">
<div className="desc">{card.back}</div> <div className="title">{card.front}</div>
</div> <div className="desc">{card.back}</div>
</span> </div>
</span>
</Card>
))} ))}
<Link to="new"> <Link to="new">
<div className="centered"> <div className="centered">

@ -3,6 +3,7 @@ import styled from "styled-components";
export const DecksOuterWrapper = styled.div` export const DecksOuterWrapper = styled.div`
height: 100%; height: 100%;
width: 100%; width: 100%;
flex-grow: 1;
padding-top: calc(var(--toolbar-height)); padding-top: calc(var(--toolbar-height));
`; `;

@ -8,6 +8,7 @@ import { Link } from "react-router-dom";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faPlus } from "@fortawesome/free-solid-svg-icons"; import { faPlus } from "@fortawesome/free-solid-svg-icons";
import { useAppSelector } from "../../app/hooks"; import { useAppSelector } from "../../app/hooks";
import Card from "../../components/Card/Card";
const Decks: React.FC = () => { const Decks: React.FC = () => {
const username = useAppSelector((state) => state.auth.user?.username); const username = useAppSelector((state) => state.auth.user?.username);
@ -21,13 +22,15 @@ const Decks: React.FC = () => {
) : ( ) : (
<DecksInnerWrapper> <DecksInnerWrapper>
{data.map((cardDeck) => ( {data.map((cardDeck) => (
<Link key={cardDeck.id} to={`${cardDeck.id}`}> <Card>
<div className="deck"> <Link key={cardDeck.id} to={`${cardDeck.id}`}>
<div className="title">{cardDeck.title}</div> <div className="deck">
<div className="desc">{cardDeck.description}</div> <div className="title">{cardDeck.title}</div>
<div className="count">Karten: {cardDeck.cards.length}</div> <div className="desc">{cardDeck.description}</div>
</div> <div className="count">Karten: {cardDeck.cards.length}</div>
</Link> </div>
</Link>
</Card>
))} ))}
<Link to="new"> <Link to="new">
<div className="centered"> <div className="centered">

@ -0,0 +1,6 @@
import "styled-components";
import {Theme} from "./features/theme/theme-slice";
declare module 'styled-components' {
export interface DefaultTheme extends Theme {}
}

@ -15,4 +15,4 @@ const Variables = css`
} }
`; `;
export default Variables; export default Variables;

@ -5,8 +5,8 @@ import (
"net/http" "net/http"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"spahl.ddns.net/jasper/wok-able-backend/auth" "spahl.ddns.net/jasper/wok-able/auth"
"spahl.ddns.net/jasper/wok-able-backend/models" "spahl.ddns.net/jasper/wok-able/models"
) )
func Register(c *gin.Context) { func Register(c *gin.Context) {

@ -2,8 +2,8 @@ package controllers
import ( import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
auth "spahl.ddns.net/jasper/wok-able-backend/controllers/authentication" auth "spahl.ddns.net/jasper/wok-able/controllers/authentication"
v1 "spahl.ddns.net/jasper/wok-able-backend/controllers/v1" v1 "spahl.ddns.net/jasper/wok-able/controllers/v1"
) )
func Setup(c *gin.Engine) { func Setup(c *gin.Engine) {

@ -5,8 +5,8 @@ import (
"strconv" "strconv"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"spahl.ddns.net/jasper/wok-able-backend/auth" "spahl.ddns.net/jasper/wok-able/auth"
"spahl.ddns.net/jasper/wok-able-backend/models" "spahl.ddns.net/jasper/wok-able/models"
) )
func getCardById(c *gin.Context) { func getCardById(c *gin.Context) {

@ -5,8 +5,8 @@ import (
"strconv" "strconv"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"spahl.ddns.net/jasper/wok-able-backend/auth" "spahl.ddns.net/jasper/wok-able/auth"
"spahl.ddns.net/jasper/wok-able-backend/models" "spahl.ddns.net/jasper/wok-able/models"
) )
func getCardDecks(c *gin.Context) { func getCardDecks(c *gin.Context) {

@ -2,9 +2,9 @@ package v1
import ( import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"spahl.ddns.net/jasper/wok-able-backend/auth" "spahl.ddns.net/jasper/wok-able/auth"
"spahl.ddns.net/jasper/wok-able-backend/controllers/v1/card" "spahl.ddns.net/jasper/wok-able/controllers/v1/card"
"spahl.ddns.net/jasper/wok-able-backend/controllers/v1/carddeck" "spahl.ddns.net/jasper/wok-able/controllers/v1/carddeck"
) )
func Setup(r *gin.RouterGroup) { func Setup(r *gin.RouterGroup) {

@ -1,4 +1,4 @@
module spahl.ddns.net/jasper/wok-able-backend module spahl.ddns.net/jasper/wok-able
go 1.18 go 1.18

@ -4,9 +4,9 @@ import (
"os" "os"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"spahl.ddns.net/jasper/wok-able-backend/auth" "spahl.ddns.net/jasper/wok-able/auth"
"spahl.ddns.net/jasper/wok-able-backend/models" "spahl.ddns.net/jasper/wok-able/models"
"spahl.ddns.net/jasper/wok-able-backend/server" "spahl.ddns.net/jasper/wok-able/server"
) )
func main() { func main() {

@ -4,7 +4,7 @@ import (
"crypto/rand" "crypto/rand"
"gorm.io/gorm" "gorm.io/gorm"
"spahl.ddns.net/jasper/wok-able-backend/auth" "spahl.ddns.net/jasper/wok-able/auth"
) )
const saltSize = 64 const saltSize = 64

@ -8,7 +8,7 @@ import (
"github.com/gin-contrib/static" "github.com/gin-contrib/static"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"spahl.ddns.net/jasper/wok-able-backend/controllers" "spahl.ddns.net/jasper/wok-able/controllers"
) )
var httpServer *http.Server var httpServer *http.Server

Loading…
Cancel
Save