Compare commits
4 Commits
Author | SHA1 | Date |
---|---|---|
|
1621f90f0c | |
|
e9b91ff4e3 | |
|
7bc983e151 | |
|
301683da86 |
|
@ -15,26 +15,16 @@ jobs:
|
|||
echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
|
||||
echo "${{ gitea.workspace }} is a workspace folder"
|
||||
- name: Check out repo code 📝
|
||||
uses: actions/checkout@v3
|
||||
- name: Set up PostgreSQL 🐘
|
||||
uses: postgres-actions/setup-postgres@v1
|
||||
with:
|
||||
postgres-version: '15'
|
||||
postgres-user: 'developer'
|
||||
postgres-password: 'magazinchik_forever'
|
||||
postgres-port: '5432'
|
||||
- name: Init db 📜
|
||||
env:
|
||||
PGPASSWORD: magazinchik_forever
|
||||
run: |
|
||||
psql -h localhost -U developer -p 5432 -f ${{ gitea.workspace }}/Db/_localhost-2024_07_27_12_51_02-dump.sql
|
||||
uses: actions/checkout@v4
|
||||
- name: Setup .NET 🛠️
|
||||
uses: actions/setup-dotnet@v3
|
||||
with:
|
||||
dotnet-version: '8.0.x'
|
||||
dotnet-version: "8.0.x"
|
||||
- name: Restore dependencies 🔪
|
||||
run: dotnet restore
|
||||
- name: Build debug app ☢️
|
||||
run: dotnet build -c Debug --no-restore
|
||||
run: |
|
||||
dotnet build -c Debug --no-restore
|
||||
cp ${{gitea.workspace}}/Yuna.Website/Yuna.Website.Server/GlobalSettings.json ${{gitea.workspace}}/Yuna.Tests/bin/Debug/net8.0/globalSettings.json
|
||||
- name: Run unit tests 💊
|
||||
run: dotnet test -c Debug --no-build
|
||||
run: dotnet test -c Debug --no-build
|
||||
|
|
|
@ -8,5 +8,12 @@
|
|||
<jdbc-url>jdbc:postgresql://localhost:5432/</jdbc-url>
|
||||
<working-dir>$ProjectFileDir$</working-dir>
|
||||
</data-source>
|
||||
<data-source source="LOCAL" name="@192.168.1.4" uuid="ae69a462-875b-4cc5-9753-fd1984187688">
|
||||
<driver-ref>postgresql</driver-ref>
|
||||
<synchronize>true</synchronize>
|
||||
<jdbc-driver>org.postgresql.Driver</jdbc-driver>
|
||||
<jdbc-url>jdbc:postgresql://eva00.vasich:5432/postgres</jdbc-url>
|
||||
<working-dir>$ProjectFileDir$</working-dir>
|
||||
</data-source>
|
||||
</component>
|
||||
</project>
|
|
@ -1,371 +0,0 @@
|
|||
--
|
||||
-- PostgreSQL database dump
|
||||
--
|
||||
|
||||
-- Dumped from database version 15.2
|
||||
-- Dumped by pg_dump version 15.2
|
||||
|
||||
SET statement_timeout = 0;
|
||||
SET lock_timeout = 0;
|
||||
SET idle_in_transaction_session_timeout = 0;
|
||||
SET client_encoding = 'UTF8';
|
||||
SET standard_conforming_strings = on;
|
||||
SELECT pg_catalog.set_config('search_path', '', false);
|
||||
SET check_function_bodies = false;
|
||||
SET xmloption = content;
|
||||
SET client_min_messages = warning;
|
||||
SET row_security = off;
|
||||
|
||||
--
|
||||
-- Name: Yuna; Type: DATABASE; Schema: -; Owner: developer
|
||||
--
|
||||
|
||||
CREATE DATABASE "Yuna" WITH TEMPLATE = template0 ENCODING = 'UTF8' LOCALE_PROVIDER = libc LOCALE = 'Russian_Russia.1251';
|
||||
|
||||
|
||||
ALTER DATABASE "Yuna" OWNER TO developer;
|
||||
|
||||
\connect "Yuna"
|
||||
|
||||
SET statement_timeout = 0;
|
||||
SET lock_timeout = 0;
|
||||
SET idle_in_transaction_session_timeout = 0;
|
||||
SET client_encoding = 'UTF8';
|
||||
SET standard_conforming_strings = on;
|
||||
SELECT pg_catalog.set_config('search_path', '', false);
|
||||
SET check_function_bodies = false;
|
||||
SET xmloption = content;
|
||||
SET client_min_messages = warning;
|
||||
SET row_security = off;
|
||||
|
||||
SET default_tablespace = '';
|
||||
|
||||
SET default_table_access_method = heap;
|
||||
|
||||
--
|
||||
-- Name: Yuna_Devices; Type: TABLE; Schema: public; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE public."Yuna_Devices" (
|
||||
"Id" bigint NOT NULL,
|
||||
"Name" character varying(128) NOT NULL,
|
||||
"Description" character varying(255),
|
||||
"DeviceUrl" character varying(255),
|
||||
"UserId" bigint NOT NULL,
|
||||
"IsDeleted" boolean DEFAULT false NOT NULL
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE public."Yuna_Devices" OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- Name: Yuna_Devices_Id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE SEQUENCE public."Yuna_Devices_Id_seq"
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
ALTER TABLE public."Yuna_Devices_Id_seq" OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- Name: Yuna_Devices_Id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER SEQUENCE public."Yuna_Devices_Id_seq" OWNED BY public."Yuna_Devices"."Id";
|
||||
|
||||
|
||||
--
|
||||
-- Name: Yuna_Props; Type: TABLE; Schema: public; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE public."Yuna_Props" (
|
||||
"Id" bigint NOT NULL,
|
||||
"Name" character varying(100) NOT NULL,
|
||||
"MeasureName" character varying(255),
|
||||
"JsonValueName" character varying(255),
|
||||
"Type" smallint
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE public."Yuna_Props" OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- Name: Yuna_Props_Id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE SEQUENCE public."Yuna_Props_Id_seq"
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
ALTER TABLE public."Yuna_Props_Id_seq" OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- Name: Yuna_Props_Id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER SEQUENCE public."Yuna_Props_Id_seq" OWNED BY public."Yuna_Props"."Id";
|
||||
|
||||
|
||||
--
|
||||
-- Name: Yuna_Props_In_Devices; Type: TABLE; Schema: public; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE public."Yuna_Props_In_Devices" (
|
||||
"Id" bigint NOT NULL,
|
||||
"PropId" bigint NOT NULL,
|
||||
"DeviceId" bigint NOT NULL
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE public."Yuna_Props_In_Devices" OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- Name: Yuna_Props_In_Devices_Id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE SEQUENCE public."Yuna_Props_In_Devices_Id_seq"
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
ALTER TABLE public."Yuna_Props_In_Devices_Id_seq" OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- Name: Yuna_Props_In_Devices_Id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER SEQUENCE public."Yuna_Props_In_Devices_Id_seq" OWNED BY public."Yuna_Props_In_Devices"."Id";
|
||||
|
||||
|
||||
--
|
||||
-- Name: Yuna_Users; Type: TABLE; Schema: public; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE TABLE public."Yuna_Users" (
|
||||
"Id" bigint NOT NULL,
|
||||
"Username" character varying(32) NOT NULL,
|
||||
"HashedPassword" character varying(255) NOT NULL,
|
||||
"IsAdmin" boolean NOT NULL
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE public."Yuna_Users" OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- Name: Yuna_Users_Id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE SEQUENCE public."Yuna_Users_Id_seq"
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
ALTER TABLE public."Yuna_Users_Id_seq" OWNER TO postgres;
|
||||
|
||||
--
|
||||
-- Name: Yuna_Users_Id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER SEQUENCE public."Yuna_Users_Id_seq" OWNED BY public."Yuna_Users"."Id";
|
||||
|
||||
|
||||
--
|
||||
-- Name: Yuna_Devices Id; Type: DEFAULT; Schema: public; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public."Yuna_Devices" ALTER COLUMN "Id" SET DEFAULT nextval('public."Yuna_Devices_Id_seq"'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: Yuna_Props Id; Type: DEFAULT; Schema: public; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public."Yuna_Props" ALTER COLUMN "Id" SET DEFAULT nextval('public."Yuna_Props_Id_seq"'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: Yuna_Props_In_Devices Id; Type: DEFAULT; Schema: public; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public."Yuna_Props_In_Devices" ALTER COLUMN "Id" SET DEFAULT nextval('public."Yuna_Props_In_Devices_Id_seq"'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: Yuna_Users Id; Type: DEFAULT; Schema: public; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public."Yuna_Users" ALTER COLUMN "Id" SET DEFAULT nextval('public."Yuna_Users_Id_seq"'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Data for Name: Yuna_Devices; Type: TABLE DATA; Schema: public; Owner: postgres
|
||||
--
|
||||
|
||||
INSERT INTO public."Yuna_Devices" ("Id", "Name", "Description", "DeviceUrl", "UserId", "IsDeleted") VALUES (9, 'Test Device', 'Test descr', 'sdfsdfsdfsdf', 8, false);
|
||||
INSERT INTO public."Yuna_Devices" ("Id", "Name", "Description", "DeviceUrl", "UserId", "IsDeleted") VALUES (6, 'TenkiChan', 'Supa Weather', 'http://192.168.1.89/sensors', 8, false);
|
||||
INSERT INTO public."Yuna_Devices" ("Id", "Name", "Description", "DeviceUrl", "UserId", "IsDeleted") VALUES (3, 'Test Device', 'Test Description', 'Test Urldfg', 1, true);
|
||||
INSERT INTO public."Yuna_Devices" ("Id", "Name", "Description", "DeviceUrl", "UserId", "IsDeleted") VALUES (8, 'Test Devicedfgdfgdfgf', 'Test Description', 'Test Url11111111', 1, true);
|
||||
INSERT INTO public."Yuna_Devices" ("Id", "Name", "Description", "DeviceUrl", "UserId", "IsDeleted") VALUES (11, 'string', 'string', 'ffffffffffdgghfghfghfgfghfgfghfg', 8, true);
|
||||
INSERT INTO public."Yuna_Devices" ("Id", "Name", "Description", "DeviceUrl", "UserId", "IsDeleted") VALUES (12, 'Test Device', 'Test Description', 'Test Url', 1, true);
|
||||
INSERT INTO public."Yuna_Devices" ("Id", "Name", "Description", "DeviceUrl", "UserId", "IsDeleted") VALUES (13, 'Test Device', 'Test Description', 'Test Url', 1, true);
|
||||
INSERT INTO public."Yuna_Devices" ("Id", "Name", "Description", "DeviceUrl", "UserId", "IsDeleted") VALUES (10, 'string', 'string', 'fffdg', 8, true);
|
||||
INSERT INTO public."Yuna_Devices" ("Id", "Name", "Description", "DeviceUrl", "UserId", "IsDeleted") VALUES (4, 'Test Device', 'Nyanyanyadfgdfgfdgfdg', 'Test Urldfgdfgdfgdf', 1, false);
|
||||
INSERT INTO public."Yuna_Devices" ("Id", "Name", "Description", "DeviceUrl", "UserId", "IsDeleted") VALUES (1, 'strin111', 'strin', 'strindddd', 1, false);
|
||||
INSERT INTO public."Yuna_Devices" ("Id", "Name", "Description", "DeviceUrl", "UserId", "IsDeleted") VALUES (14, 'Test Device', 'Test Description', 'Test Url', 1, false);
|
||||
|
||||
|
||||
--
|
||||
-- Data for Name: Yuna_Props; Type: TABLE DATA; Schema: public; Owner: postgres
|
||||
--
|
||||
|
||||
INSERT INTO public."Yuna_Props" ("Id", "Name", "MeasureName", "JsonValueName", "Type") VALUES (1, 'test', 'test', 'test', 0);
|
||||
INSERT INTO public."Yuna_Props" ("Id", "Name", "MeasureName", "JsonValueName", "Type") VALUES (2, 'test', 'test', 'test', 0);
|
||||
INSERT INTO public."Yuna_Props" ("Id", "Name", "MeasureName", "JsonValueName", "Type") VALUES (3, 'Temp', 'C', 'string', 0);
|
||||
INSERT INTO public."Yuna_Props" ("Id", "Name", "MeasureName", "JsonValueName", "Type") VALUES (4, 'string', 'string', 'string', 0);
|
||||
INSERT INTO public."Yuna_Props" ("Id", "Name", "MeasureName", "JsonValueName", "Type") VALUES (5, 'strding', 'strding', 'strding', 0);
|
||||
INSERT INTO public."Yuna_Props" ("Id", "Name", "MeasureName", "JsonValueName", "Type") VALUES (6, 'SupaTest', 'testing', 'sssss', 0);
|
||||
INSERT INTO public."Yuna_Props" ("Id", "Name", "MeasureName", "JsonValueName", "Type") VALUES (7, 'test', 'test', 'test', 0);
|
||||
INSERT INTO public."Yuna_Props" ("Id", "Name", "MeasureName", "JsonValueName", "Type") VALUES (8, 'Температура', '°C', 'temperature', 0);
|
||||
INSERT INTO public."Yuna_Props" ("Id", "Name", "MeasureName", "JsonValueName", "Type") VALUES (9, 'Влажность', '%', 'humidity', 0);
|
||||
INSERT INTO public."Yuna_Props" ("Id", "Name", "MeasureName", "JsonValueName", "Type") VALUES (10, 'Концентрация CO2', 'см³/м³', 'ppm', 0);
|
||||
INSERT INTO public."Yuna_Props" ("Id", "Name", "MeasureName", "JsonValueName", "Type") VALUES (11, 'test', 'test', 'test', 0);
|
||||
|
||||
|
||||
--
|
||||
-- Data for Name: Yuna_Props_In_Devices; Type: TABLE DATA; Schema: public; Owner: postgres
|
||||
--
|
||||
|
||||
INSERT INTO public."Yuna_Props_In_Devices" ("Id", "PropId", "DeviceId") VALUES (1, 1, 1);
|
||||
INSERT INTO public."Yuna_Props_In_Devices" ("Id", "PropId", "DeviceId") VALUES (21, 4, 1);
|
||||
INSERT INTO public."Yuna_Props_In_Devices" ("Id", "PropId", "DeviceId") VALUES (22, 5, 1);
|
||||
INSERT INTO public."Yuna_Props_In_Devices" ("Id", "PropId", "DeviceId") VALUES (32, 6, 1);
|
||||
INSERT INTO public."Yuna_Props_In_Devices" ("Id", "PropId", "DeviceId") VALUES (39, 3, 1);
|
||||
INSERT INTO public."Yuna_Props_In_Devices" ("Id", "PropId", "DeviceId") VALUES (40, 8, 6);
|
||||
INSERT INTO public."Yuna_Props_In_Devices" ("Id", "PropId", "DeviceId") VALUES (41, 9, 6);
|
||||
INSERT INTO public."Yuna_Props_In_Devices" ("Id", "PropId", "DeviceId") VALUES (42, 10, 6);
|
||||
INSERT INTO public."Yuna_Props_In_Devices" ("Id", "PropId", "DeviceId") VALUES (43, 1, 9);
|
||||
INSERT INTO public."Yuna_Props_In_Devices" ("Id", "PropId", "DeviceId") VALUES (44, 2, 9);
|
||||
INSERT INTO public."Yuna_Props_In_Devices" ("Id", "PropId", "DeviceId") VALUES (45, 3, 9);
|
||||
INSERT INTO public."Yuna_Props_In_Devices" ("Id", "PropId", "DeviceId") VALUES (46, 4, 9);
|
||||
INSERT INTO public."Yuna_Props_In_Devices" ("Id", "PropId", "DeviceId") VALUES (47, 5, 10);
|
||||
INSERT INTO public."Yuna_Props_In_Devices" ("Id", "PropId", "DeviceId") VALUES (48, 6, 10);
|
||||
INSERT INTO public."Yuna_Props_In_Devices" ("Id", "PropId", "DeviceId") VALUES (49, 5, 11);
|
||||
|
||||
|
||||
--
|
||||
-- Data for Name: Yuna_Users; Type: TABLE DATA; Schema: public; Owner: postgres
|
||||
--
|
||||
|
||||
INSERT INTO public."Yuna_Users" ("Id", "Username", "HashedPassword", "IsAdmin") VALUES (1, 'asd1', '2', true);
|
||||
INSERT INTO public."Yuna_Users" ("Id", "Username", "HashedPassword", "IsAdmin") VALUES (2, 'test', '123', false);
|
||||
INSERT INTO public."Yuna_Users" ("Id", "Username", "HashedPassword", "IsAdmin") VALUES (3, 'test', '123', false);
|
||||
INSERT INTO public."Yuna_Users" ("Id", "Username", "HashedPassword", "IsAdmin") VALUES (4, 'test', '123', false);
|
||||
INSERT INTO public."Yuna_Users" ("Id", "Username", "HashedPassword", "IsAdmin") VALUES (5, 'test', '123', false);
|
||||
INSERT INTO public."Yuna_Users" ("Id", "Username", "HashedPassword", "IsAdmin") VALUES (6, 'test', '123', false);
|
||||
INSERT INTO public."Yuna_Users" ("Id", "Username", "HashedPassword", "IsAdmin") VALUES (8, 'test1', 'EbvfS/o9GSL7wkbnix+BzMpCLJqfWqeTgimj3u9CknA=', false);
|
||||
INSERT INTO public."Yuna_Users" ("Id", "Username", "HashedPassword", "IsAdmin") VALUES (7, 'vasich', 'V64zSeugpX/I4ZSqot7K0NQBOGdMNYNclXButwoXasI=', true);
|
||||
INSERT INTO public."Yuna_Users" ("Id", "Username", "HashedPassword", "IsAdmin") VALUES (9, 'test', '123', false);
|
||||
|
||||
|
||||
--
|
||||
-- Name: Yuna_Devices_Id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
|
||||
--
|
||||
|
||||
SELECT pg_catalog.setval('public."Yuna_Devices_Id_seq"', 14, true);
|
||||
|
||||
|
||||
--
|
||||
-- Name: Yuna_Props_Id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
|
||||
--
|
||||
|
||||
SELECT pg_catalog.setval('public."Yuna_Props_Id_seq"', 11, true);
|
||||
|
||||
|
||||
--
|
||||
-- Name: Yuna_Props_In_Devices_Id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
|
||||
--
|
||||
|
||||
SELECT pg_catalog.setval('public."Yuna_Props_In_Devices_Id_seq"', 49, true);
|
||||
|
||||
|
||||
--
|
||||
-- Name: Yuna_Users_Id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
|
||||
--
|
||||
|
||||
SELECT pg_catalog.setval('public."Yuna_Users_Id_seq"', 9, true);
|
||||
|
||||
|
||||
--
|
||||
-- Name: Yuna_Devices Yuna_Devices_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public."Yuna_Devices"
|
||||
ADD CONSTRAINT "Yuna_Devices_pkey" PRIMARY KEY ("Id");
|
||||
|
||||
|
||||
--
|
||||
-- Name: Yuna_Props_In_Devices Yuna_Props_In_Devices_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public."Yuna_Props_In_Devices"
|
||||
ADD CONSTRAINT "Yuna_Props_In_Devices_pkey" PRIMARY KEY ("Id");
|
||||
|
||||
|
||||
--
|
||||
-- Name: Yuna_Props Yuna_Props_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public."Yuna_Props"
|
||||
ADD CONSTRAINT "Yuna_Props_pkey" PRIMARY KEY ("Id");
|
||||
|
||||
|
||||
--
|
||||
-- Name: Yuna_Users_index_1; Type: INDEX; Schema: public; Owner: postgres
|
||||
--
|
||||
|
||||
CREATE UNIQUE INDEX "Yuna_Users_index_1" ON public."Yuna_Users" USING btree ("Id");
|
||||
|
||||
|
||||
--
|
||||
-- Name: Yuna_Props_In_Devices Yuna_Props_In_Devices_relation_2; Type: FK CONSTRAINT; Schema: public; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public."Yuna_Props_In_Devices"
|
||||
ADD CONSTRAINT "Yuna_Props_In_Devices_relation_2" FOREIGN KEY ("DeviceId") REFERENCES public."Yuna_Devices"("Id") ON DELETE CASCADE;
|
||||
|
||||
|
||||
--
|
||||
-- Name: Yuna_Props_In_Devices Yuna_Props_In_Devices_relation_3; Type: FK CONSTRAINT; Schema: public; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public."Yuna_Props_In_Devices"
|
||||
ADD CONSTRAINT "Yuna_Props_In_Devices_relation_3" FOREIGN KEY ("PropId") REFERENCES public."Yuna_Props"("Id") ON DELETE CASCADE;
|
||||
|
||||
|
||||
--
|
||||
-- Name: Yuna_Devices fk_user_id; Type: FK CONSTRAINT; Schema: public; Owner: postgres
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public."Yuna_Devices"
|
||||
ADD CONSTRAINT fk_user_id FOREIGN KEY ("UserId") REFERENCES public."Yuna_Users"("Id");
|
||||
|
||||
|
||||
--
|
||||
-- PostgreSQL database dump complete
|
||||
--
|
||||
|
Binary file not shown.
|
@ -1,24 +0,0 @@
|
|||
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
|
||||
USER app
|
||||
WORKDIR /app
|
||||
EXPOSE 8080
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
WORKDIR /src
|
||||
COPY ["Yuna.OauthServer/Yuna.OauthServer.csproj", "Yuna.OauthServer/"]
|
||||
RUN dotnet restore "./Yuna.OauthServer/Yuna.OauthServer.csproj"
|
||||
COPY . .
|
||||
WORKDIR "/src/Yuna.OauthServer"
|
||||
RUN dotnet build "./Yuna.OauthServer.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
||||
|
||||
FROM build AS publish
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
RUN dotnet publish "./Yuna.OauthServer.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
||||
|
||||
FROM base AS final
|
||||
WORKDIR /app
|
||||
COPY --from=publish /app/publish .
|
||||
ENTRYPOINT ["dotnet", "Yuna.OauthServer.dll"]
|
|
@ -1,19 +0,0 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Yuna.OauthServer.Endpoints.Auth.DTO;
|
||||
|
||||
namespace Yuna.OauthServer.Endpoints.Auth
|
||||
{
|
||||
public class AuthEndpoints
|
||||
{
|
||||
public void Define(WebApplication app)
|
||||
{
|
||||
app.MapGet("oauth/auth", Authorize)
|
||||
}
|
||||
|
||||
public IResult Authorize([AsParameters] AuthRequest request)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
using Microsoft.AspNetCore.Components;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Yuna.OauthServer.Endpoints.Auth.DTO
|
||||
{
|
||||
|
||||
public class AuthRequest
|
||||
{
|
||||
public string response_type { get; set; } = null!;
|
||||
public string client_id { get; set; } = null!;
|
||||
public string redirect_uri { get; set; } = null!;
|
||||
|
||||
}
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
namespace Yuna.OauthServer.Endpoints.Auth.DTO
|
||||
{
|
||||
public class AuthResponse
|
||||
{
|
||||
public string ResponseType { get;} = "code";
|
||||
public string Code { get; set; } = null!;
|
||||
public string RedirectUri { get; set; } = null!;
|
||||
}
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
namespace Yuna.OauthServer.Model
|
||||
{
|
||||
public class Client
|
||||
{
|
||||
|
||||
public Client(string clientName, int clientId, string secret, string clientUri, string redirectUri)
|
||||
{
|
||||
ClientName = clientName;
|
||||
ClientId = clientId;
|
||||
ClientSecret = secret;
|
||||
ClientUri = clientUri;
|
||||
RedirectUri = redirectUri;
|
||||
}
|
||||
|
||||
public string ClientName { get; set; }
|
||||
public int ClientId { get; set; }
|
||||
public string ClientSecret { get; set; }
|
||||
//public string ClientType { get; set; }
|
||||
//public List<string> GrantType { get; set; }
|
||||
public bool IsActive { get; set; } = false;
|
||||
//public List<string> AllowedScopes { get; set; }
|
||||
public string? ClientUri { get; set; }
|
||||
public string RedirectUri { get; set; }
|
||||
}
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Yuna.OauthServer.Model
|
||||
{
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
}
|
||||
|
||||
var summaries = new[]
|
||||
{
|
||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||
};
|
||||
|
||||
app.MapGet("/weatherforecast", () =>
|
||||
{
|
||||
var forecast = Enumerable.Range(1, 5).Select(index =>
|
||||
new WeatherForecast
|
||||
(
|
||||
DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
|
||||
Random.Shared.Next(-20, 55),
|
||||
summaries[Random.Shared.Next(summaries.Length)]
|
||||
))
|
||||
.ToArray();
|
||||
return forecast;
|
||||
})
|
||||
.WithName("GetWeatherForecast")
|
||||
.WithOpenApi();
|
||||
|
||||
app.Run();
|
||||
|
||||
internal record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary)
|
||||
{
|
||||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
{
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"dotnetRunMessages": true,
|
||||
"applicationUrl": "http://localhost:5026"
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"Container (Dockerfile)": {
|
||||
"commandName": "Docker",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_HTTP_PORTS": "8080"
|
||||
},
|
||||
"publishAllPorts": true
|
||||
}
|
||||
},
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:47304",
|
||||
"sslPort": 0
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
using Yuna.OauthServer.Model;
|
||||
|
||||
namespace Yuna.OauthServer.Storage
|
||||
{
|
||||
public class ClientsList
|
||||
{
|
||||
public List<Client> Clients = new()
|
||||
{
|
||||
new Client("yandex", 0, "5aS3dFgH7jK9lM1nO5pQrT",)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.2" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.6" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.0.0-preview1" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -1,6 +0,0 @@
|
|||
@Yuna.OauthServer_HostAddress = http://localhost:5026
|
||||
|
||||
GET {{Yuna.OauthServer_HostAddress}}/weatherforecast/
|
||||
Accept: application/json
|
||||
|
||||
###
|
|
@ -1,8 +0,0 @@
|
|||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
|
@ -26,6 +26,10 @@ namespace Yuna.Website.Server.API
|
|||
.Produces(200)
|
||||
.Produces(400);
|
||||
|
||||
app.MapPost("/api/auth/logout", Logout)
|
||||
.WithTags("auth")
|
||||
.Produces(200);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -37,9 +41,18 @@ namespace Yuna.Website.Server.API
|
|||
var hashedPassword = Encrypter.HashPassword(request.RawPassword, request.UserName);
|
||||
if (!hashedPassword.Equals(userFromDb.HashedPassword)) return Results.Unauthorized();
|
||||
await SetAccessToken(context, tokenService, userFromDb);
|
||||
SetFrontendCookie(userFromDb, context);
|
||||
return Results.Ok("");
|
||||
}
|
||||
|
||||
public async Task<IResult> Logout(HttpContext context, object? additionalInfo = null)
|
||||
{
|
||||
await context.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
|
||||
context.ClearCookies();
|
||||
|
||||
return Results.Ok();
|
||||
}
|
||||
|
||||
|
||||
private static async Task SetAccessToken(HttpContext context, ITokenService tokenService, User userFromDb)
|
||||
{
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
},
|
||||
"ConnectionStrings": {
|
||||
"BarcodeService": "http://localhost:7799/barcode",
|
||||
"Db": "User ID=developer;Password=magazinchik_forever;Server=localhost;Port=5432;Database=Yuna;Pooling=true;IncludeErrorDetail=true;",
|
||||
"Db": "User ID=developer;Password=vasich_dev_pg;Server=eva00.vasich;Port=5432;Database=Yuna;Pooling=true;IncludeErrorDetail=true;",
|
||||
"UserDb": "User ID=developer;Password=magazinchik_forever;Server=localhost;Port=5432;Database=UserKeeper;Pooling=true;",
|
||||
"RabbitMq": "host=localhost;username=guest;password=guest",
|
||||
"Redis": "localhost:5002"
|
||||
|
|
|
@ -24,13 +24,28 @@ namespace Yuna.Website.Server.Infrastructure
|
|||
return default!;
|
||||
}
|
||||
|
||||
public static void SaveToCookies<T>(this HttpContext context, string key, T value, TimeSpan? maxAge = null)
|
||||
public static void SaveToCookies<T>(this HttpContext context, string key, T value, TimeSpan? maxAge = null, bool httpOnly = false)
|
||||
{
|
||||
var dataStr = System.Text.Json.JsonSerializer.Serialize<T>(value);
|
||||
|
||||
if (context.Request.Cookies.ContainsKey(key)) context.Response.Cookies.Delete(key);
|
||||
|
||||
context.Response.Cookies.Append(key, dataStr, new CookieOptions() { HttpOnly = true, MaxAge = maxAge ?? TimeSpan.FromDays(365) });
|
||||
var sameSite = !Settings.IsDevEnv;
|
||||
|
||||
context.Response.Cookies.Append(key, dataStr, new CookieOptions()
|
||||
{ HttpOnly = httpOnly,
|
||||
MaxAge = maxAge ?? TimeSpan.FromDays(365),
|
||||
SameSite = sameSite ? SameSiteMode.Strict : SameSiteMode.None ,
|
||||
Secure = true
|
||||
});
|
||||
}
|
||||
|
||||
public static void ClearCookies(this HttpContext context)
|
||||
{
|
||||
foreach (var cookie in context.Request.Cookies)
|
||||
{
|
||||
context.Response.Cookies.Delete(cookie.Key);
|
||||
}
|
||||
}
|
||||
|
||||
public static long? GetUserIdFromCookie(this HttpContext context)
|
||||
|
|
|
@ -9,8 +9,11 @@ namespace Yuna.Website.Server.Infrastructure
|
|||
{
|
||||
Id = user.Id;
|
||||
Username = user.UserName;
|
||||
IsAdmin = user.IsAdmin;
|
||||
}
|
||||
|
||||
[JsonPropertyName("isAdmin")]
|
||||
public bool IsAdmin { get; }
|
||||
|
||||
[JsonPropertyName("username")]
|
||||
public string Username { get; }
|
||||
|
|
|
@ -10,10 +10,14 @@ namespace Yuna.Website.Server.Infrastructure
|
|||
public static string ReferalCode { get; private set; } = null!;
|
||||
public static string DbConnectionStr { get; private set; } = null!;
|
||||
|
||||
public static bool IsDevEnv { get; private set; } = false;
|
||||
public static bool IsProduction => !IsDevEnv;
|
||||
public static string HttpsExternalUrl { get; private set; } = null!;
|
||||
|
||||
public static void Init()
|
||||
public static void Init(bool isDev = true)
|
||||
{
|
||||
IsDevEnv = isDev;
|
||||
|
||||
var jsonText = File.ReadAllText("globalSettings.json");
|
||||
using JsonDocument document = JsonDocument.Parse(jsonText);
|
||||
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
using Yuna.Website.Server.Model.YandexDevice;
|
||||
|
||||
namespace Yuna.Website.Server.Model
|
||||
{
|
||||
public class DeviceMapping
|
||||
{
|
||||
public YandexDeviceType DeviceType { get; set; }
|
||||
public Device Device { get; set; }
|
||||
public Dictionary<long,YandexProp> PropMappings { get; set; }
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Yuna.Website.Server.Model.YandexDevice
|
||||
{
|
||||
public enum YandexDeviceType
|
||||
{
|
||||
ClimateSensor = 0
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
namespace Yuna.Website.Server.Model.YandexDevice
|
||||
{
|
||||
public static class YandexExtensions
|
||||
{
|
||||
public static string ToJsonName(this YandexDeviceType type)
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case YandexDeviceType.ClimateSensor:
|
||||
return "sensor.climate";
|
||||
|
||||
default:
|
||||
return "yuna_error";
|
||||
}
|
||||
}
|
||||
|
||||
public static string ToJsonName(this YandexPropType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case YandexPropType.Float:
|
||||
return "float";
|
||||
|
||||
default:
|
||||
return "yuna_error";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Yuna.Website.Server.Model.YandexDevice
|
||||
{
|
||||
public class YandexParameter
|
||||
{
|
||||
[JsonPropertyName("instance")]
|
||||
public string Instance { get; set; }
|
||||
|
||||
[JsonPropertyName("unit")]
|
||||
public string Unit { get; set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Yuna.Website.Server.Model.YandexDevice
|
||||
{
|
||||
public class YandexProp
|
||||
{
|
||||
public YandexProp()
|
||||
{ }
|
||||
|
||||
public YandexProp(YandexPropType type, bool retrievable, bool reportable, YandexParameter parameter)
|
||||
{
|
||||
Type = type;
|
||||
Retrievable = retrievable;
|
||||
Reportable = reportable;
|
||||
Parameter = parameter;
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public YandexPropType Type { get; set; }
|
||||
|
||||
[JsonPropertyName("type")]
|
||||
public string JsonPropName => Type.ToJsonName();
|
||||
|
||||
[JsonPropertyName("retrievable")]
|
||||
public bool Retrievable { get; set; } = true;
|
||||
|
||||
[JsonPropertyName("reportable")]
|
||||
public bool Reportable { get; set; } = true;
|
||||
|
||||
[JsonPropertyName("parameters")]
|
||||
public YandexParameter Parameter { get; set; } = null!;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
namespace Yuna.Website.Server.Model.YandexDevice
|
||||
{
|
||||
public enum YandexPropType
|
||||
{
|
||||
Float = 0,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
namespace Yuna.Website.Server.Services.MappingService
|
||||
{
|
||||
public interface IMappingService
|
||||
{
|
||||
}
|
||||
}
|
|
@ -18,7 +18,7 @@ namespace Yuna.Website.Server
|
|||
{
|
||||
public static void LoadConfigs(WebApplicationBuilder builder)
|
||||
{
|
||||
Settings.Init();
|
||||
Settings.Init(builder.Environment.IsDevelopment());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -206,8 +206,8 @@ namespace Yuna.Website.Server
|
|||
.AllowAnyMethod()
|
||||
.AllowAnyHeader()
|
||||
.AllowCredentials()
|
||||
.SetIsOriginAllowed(origin => true) // Разрешить все источники
|
||||
.WithExposedHeaders("Location")); // Разрешить заголовок Location)
|
||||
.SetIsOriginAllowed(origin => true) // Разрешить все источники
|
||||
.WithExposedHeaders("Location")); // Разрешить заголовок Location)
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<DockerfileContext>..\..</DockerfileContext>
|
||||
<SpaRoot>..\yuna.website.client</SpaRoot>
|
||||
<SpaProxyLaunchCommand>npm run dev</SpaProxyLaunchCommand>
|
||||
<SpaProxyServerUrl>https://localhost:5173</SpaProxyServerUrl>
|
||||
<SpaProxyServerUrl>https://192.168.1.2:5173</SpaProxyServerUrl>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -10,12 +10,14 @@
|
|||
"dependencies": {
|
||||
"@chakra-ui/react": "^2.8.2",
|
||||
"axios": "^1.7.2",
|
||||
"js-cookie": "^3.0.5",
|
||||
"mobx": "^6.13.0",
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"react-router-dom": "^6.24.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/js-cookie": "^3.0.6",
|
||||
"@types/node": "^20.12.0",
|
||||
"@types/react": "^18.3.3",
|
||||
"@types/react-dom": "^18.3.0",
|
||||
|
@ -2582,6 +2584,12 @@
|
|||
"integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/js-cookie": {
|
||||
"version": "3.0.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/js-cookie/-/js-cookie-3.0.6.tgz",
|
||||
"integrity": "sha512-wkw9yd1kEXOPnvEeEV1Go1MmxtBJL0RR79aOTAApecWFVu7w0NNXNqhcWgvw2YgZDYadliXkl14pa3WXw5jlCQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/lodash": {
|
||||
"version": "4.17.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.6.tgz",
|
||||
|
@ -4153,6 +4161,14 @@
|
|||
"integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/js-cookie": {
|
||||
"version": "3.0.5",
|
||||
"resolved": "https://registry.npmjs.org/js-cookie/-/js-cookie-3.0.5.tgz",
|
||||
"integrity": "sha512-cEiJEAEoIbWfCZYKWhVwFuvPX1gETRYPw6LlaTKoxD3s2AkXzkCjnp6h0V77ozyqj0jakteJ4YqDJT830+lVGw==",
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
}
|
||||
},
|
||||
"node_modules/js-tokens": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"dev": "vite --host 192.168.1.2 --port 5173",
|
||||
"build": "tsc -b && vite build",
|
||||
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
||||
"preview": "vite preview"
|
||||
|
@ -12,12 +12,14 @@
|
|||
"dependencies": {
|
||||
"@chakra-ui/react": "^2.8.2",
|
||||
"axios": "^1.7.2",
|
||||
"js-cookie": "^3.0.5",
|
||||
"mobx": "^6.13.0",
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"react-router-dom": "^6.24.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/js-cookie": "^3.0.6",
|
||||
"@types/node": "^20.12.0",
|
||||
"@types/react": "^18.3.3",
|
||||
"@types/react-dom": "^18.3.0",
|
||||
|
@ -31,4 +33,4 @@
|
|||
"typescript": "^5.2.2",
|
||||
"vite": "^5.3.1"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,18 @@
|
|||
import { useNavigate } from "react-router-dom";
|
||||
import "../resources/styles/header.scss"
|
||||
import { yunaGlobal } from "../utils/cookies/Yuna";
|
||||
import { Button, Icon, IconButton } from "@chakra-ui/react";
|
||||
import { MdOutlineLogout } from "react-icons/md";
|
||||
import { LoginPageService } from "../pages/login/LoginPageService";
|
||||
|
||||
export const Header = () => {
|
||||
const navigate = useNavigate();
|
||||
|
||||
const onLogout = async () => {
|
||||
await LoginPageService.logout();
|
||||
navigate("/login");
|
||||
}
|
||||
|
||||
return (
|
||||
<div style={{
|
||||
display: 'flex',
|
||||
|
@ -8,6 +20,29 @@ export const Header = () => {
|
|||
paddingTop: 10
|
||||
}}>
|
||||
<header className="header">
|
||||
<h1>Yuna</h1>
|
||||
</header></div>);
|
||||
<h1 onClick={() => navigate("/")}>Yuna</h1>
|
||||
<nav>
|
||||
<a onClick={() => navigate("/mappings")}>Маппинги</a>
|
||||
</nav>
|
||||
<div style={{
|
||||
width: '100%',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
alignItems: 'flex-end',
|
||||
paddingRight: '5px'
|
||||
}}>
|
||||
<span >{'Приветик, ' + yunaGlobal.user?.username}
|
||||
<IconButton
|
||||
icon={<MdOutlineLogout />}
|
||||
size='sm'
|
||||
color="black"
|
||||
colorScheme="white"
|
||||
aria-label={"logout"}
|
||||
onClick={() => onLogout()} /></span>
|
||||
{yunaGlobal.user?.isAdmin && <span
|
||||
style={{ paddingRight: 10 }}
|
||||
className="micro-text important" >Ого, ты админ 💅</span>}
|
||||
</div>
|
||||
</header>
|
||||
</div>);
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
import { Yuna } from "./utils/cookies/Yuna";
|
||||
|
||||
|
||||
declare global {
|
||||
// eslint-disable-next-line no-var
|
||||
var yuna: Yuna;
|
||||
}
|
||||
|
||||
export { }
|
|
@ -3,6 +3,9 @@ import ReactDOM from 'react-dom/client'
|
|||
import { RouterProvider } from 'react-router-dom'
|
||||
import "./resources/styles/common.scss"
|
||||
import { router } from './router'
|
||||
import { yunaGlobal } from './utils/cookies/Yuna'
|
||||
|
||||
globalThis.yuna = yunaGlobal;
|
||||
|
||||
ReactDOM.createRoot(document.getElementById('root')!).render(
|
||||
<React.StrictMode>
|
||||
|
|
|
@ -5,8 +5,6 @@ import { EditModal } from "./components/modals/EditModal";
|
|||
export const HomePage = () => {
|
||||
return (
|
||||
<>
|
||||
|
||||
<Header />
|
||||
<DeviceList />
|
||||
<EditModal />
|
||||
</>
|
||||
|
|
|
@ -11,10 +11,10 @@ export const DeviceList = observer(() => {
|
|||
}, [])
|
||||
|
||||
return (
|
||||
< main className="main" >
|
||||
< >
|
||||
{homePageStore.isLoading ? <LoadingComponent /> :
|
||||
homePageStore.devices.length > 0
|
||||
&& homePageStore.devices.map(x => <DeviceCard key={x.id} data={x} />)
|
||||
}
|
||||
</main >);
|
||||
</>);
|
||||
});
|
|
@ -2,9 +2,29 @@ import { Button, Center, Input, Spinner } from "@chakra-ui/react";
|
|||
import "../../resources/styles/loginPage.scss"
|
||||
import { observer } from "mobx-react"
|
||||
import { LoginPageStore } from "./LoginPageStore";
|
||||
import { useRef } from "react";
|
||||
|
||||
const store = new LoginPageStore();
|
||||
export const LoginPage = observer(() => {
|
||||
|
||||
const loginRef = useRef<HTMLInputElement>(null);
|
||||
const passwordRef = useRef<HTMLInputElement>(null);
|
||||
|
||||
const handleKeyDown = (key: string) => {
|
||||
if (key === "ArrowDown") {
|
||||
if (document.activeElement === loginRef.current) {
|
||||
passwordRef.current?.focus();
|
||||
}
|
||||
} else if (key === "ArrowUp") {
|
||||
if (document.activeElement === passwordRef.current) {
|
||||
loginRef.current?.focus();
|
||||
}
|
||||
}
|
||||
|
||||
else if (key === "Enter") store.handleLogin();
|
||||
};
|
||||
|
||||
|
||||
return (
|
||||
<div className="container_wrapper">
|
||||
<div className="login_container">
|
||||
|
@ -22,14 +42,18 @@ export const LoginPage = observer(() => {
|
|||
</>
|
||||
: <>
|
||||
<Input
|
||||
ref={loginRef}
|
||||
placeholder="Логин"
|
||||
value={store.login}
|
||||
onChange={e => store.setLogin(e.target.value)}
|
||||
onKeyDown={x => handleKeyDown(x.key)}
|
||||
marginBottom={5} />
|
||||
<Input
|
||||
ref={passwordRef}
|
||||
placeholder="Пароль"
|
||||
type="password"
|
||||
marginBottom={7}
|
||||
onKeyDown={x => handleKeyDown(x.key)}
|
||||
value={store.password}
|
||||
onChange={e => store.setPassword(e.target.value)} />
|
||||
</>}
|
||||
|
|
|
@ -22,6 +22,12 @@ export class LoginPageService {
|
|||
}
|
||||
}
|
||||
|
||||
public static async logout(): Promise<boolean> {
|
||||
const response = await api.post("auth/logout");
|
||||
if (response.status === 200) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static async loginOauth(request: IOauthLoginRequest): Promise<IOauthLoginResult> {
|
||||
|
|
|
@ -7,6 +7,7 @@ import { IOauthQueryParams } from "./types";
|
|||
|
||||
|
||||
export class LoginPageStore {
|
||||
|
||||
toast = createStandaloneToast();
|
||||
login: string = "";
|
||||
password: string = "";
|
||||
|
@ -84,7 +85,7 @@ export class LoginPageStore {
|
|||
return;
|
||||
}
|
||||
|
||||
window.location.replace("https://localhost:5173");
|
||||
window.location.replace("/");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
import { observer } from "mobx-react"
|
||||
|
||||
export const MappingsPage = observer(() => {
|
||||
return <>
|
||||
</>
|
||||
})
|
|
@ -1,5 +1,6 @@
|
|||
* {
|
||||
font-family: 'Montserrat';
|
||||
|
||||
}
|
||||
|
||||
.container_wrapper {
|
||||
|
@ -15,4 +16,12 @@
|
|||
font-display: block;
|
||||
font-family: 'Montserrat';
|
||||
src: url(../fonts/Montserrat-VariableFont_wght.ttf);
|
||||
}
|
||||
|
||||
.micro-text {
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
.important {
|
||||
color: red;
|
||||
}
|
|
@ -2,6 +2,9 @@
|
|||
position: fixed;
|
||||
background: #4FD1C5;
|
||||
border-radius: 10px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
//border-bottom: solid black 1px;
|
||||
width: 80%;
|
||||
height: 70px;
|
||||
|
@ -10,10 +13,31 @@
|
|||
/* x-offset y-offset blur-radius color */
|
||||
|
||||
h1 {
|
||||
padding-top: 10px;
|
||||
transition: color 0.3s;
|
||||
font-size: 30px;
|
||||
padding-left: 30px;
|
||||
}
|
||||
|
||||
h1:hover {
|
||||
cursor: pointer;
|
||||
color: white;
|
||||
}
|
||||
|
||||
nav {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
padding-top: 10px;
|
||||
padding-left: 30px;
|
||||
|
||||
a {
|
||||
color: black;
|
||||
transition: color 0.3s;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
cursor: pointer;
|
||||
color: white;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,8 +1,10 @@
|
|||
import { ChakraProvider } from "@chakra-ui/react";
|
||||
import { Outlet, createBrowserRouter } from "react-router-dom";
|
||||
import { Navigate, Outlet, createBrowserRouter } from "react-router-dom";
|
||||
import { LoginPage } from "./pages/login/LoginPage";
|
||||
import { YunaTheme } from "./theme";
|
||||
import { HomePage } from "./pages/home/HomePage";
|
||||
import { MappingsPage } from "./pages/mappings/MappingsPage";
|
||||
import { Header } from "./components/Header";
|
||||
|
||||
|
||||
|
||||
|
@ -13,13 +15,31 @@ export const router = createBrowserRouter([
|
|||
errorElement: <h1>Something gone wrong</h1>,
|
||||
children:
|
||||
[
|
||||
{
|
||||
path: "/",
|
||||
element: <Navigate to="/home" replace />
|
||||
},
|
||||
{
|
||||
path: "home",
|
||||
element: <HomePage />
|
||||
element: <>
|
||||
<Header />
|
||||
<main className="main" >
|
||||
<HomePage />
|
||||
</main>
|
||||
</>
|
||||
},
|
||||
{
|
||||
path: "mappings",
|
||||
element: <>
|
||||
<Header />
|
||||
<main className="main" >
|
||||
<MappingsPage />
|
||||
</main>
|
||||
</>
|
||||
},
|
||||
{
|
||||
path: "settings",
|
||||
element: <>set</>
|
||||
element: <><Header />set</>
|
||||
},
|
||||
{
|
||||
path: "login",
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
import Cookies from 'js-cookie';
|
||||
|
||||
class Yuna {
|
||||
|
||||
getUser() {
|
||||
const cookieStr = Cookies.get("user");
|
||||
if (cookieStr) {
|
||||
const decodedCookie = decodeURIComponent(cookieStr);
|
||||
return JSON.parse(decodedCookie) as IUserCookie;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
user: IUserCookie | undefined = this.getUser()
|
||||
|
||||
}
|
||||
|
||||
export const yunaGlobal = new Yuna();
|
||||
|
||||
|
||||
interface IUserCookie {
|
||||
isAdmin: boolean
|
||||
username: string,
|
||||
id: number
|
||||
}
|
8
Yuna.sln
8
Yuna.sln
|
@ -3,13 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.9.34607.119
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yuna.OauthServer", "Yuna.OauthServer\Yuna.OauthServer.csproj", "{28C99E60-5614-47D9-9640-CFF3F1B1A81F}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yuna.Website.Server", "Yuna.Website\Yuna.Website.Server\Yuna.Website.Server.csproj", "{52C97D16-8D70-4E62-8038-A6137C5268E3}"
|
||||
EndProject
|
||||
Project("{54A90642-561A-4BB1-A94E-469ADEE60C69}") = "yuna.website.client", "Yuna.Website\yuna.website.client\yuna.website.client.esproj", "{12C022B1-3125-49DA-9E41-DD2FEAABBB11}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Yuna.Tests", "Yuna.Tests\Yuna.Tests.csproj", "{47ECE6AC-C195-4EDF-B40C-AA44DBF8E107}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yuna.Tests", "Yuna.Tests\Yuna.Tests.csproj", "{47ECE6AC-C195-4EDF-B40C-AA44DBF8E107}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{52C97D16-8D70-4E62-8038-A6137C5268E3} = {52C97D16-8D70-4E62-8038-A6137C5268E3}
|
||||
EndProjectSection
|
||||
|
@ -20,10 +18,6 @@ Global
|
|||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{28C99E60-5614-47D9-9640-CFF3F1B1A81F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{28C99E60-5614-47D9-9640-CFF3F1B1A81F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{28C99E60-5614-47D9-9640-CFF3F1B1A81F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{28C99E60-5614-47D9-9640-CFF3F1B1A81F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{52C97D16-8D70-4E62-8038-A6137C5268E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{52C97D16-8D70-4E62-8038-A6137C5268E3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{52C97D16-8D70-4E62-8038-A6137C5268E3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
|
|
Loading…
Reference in New Issue