web turd
This commit is contained in:
parent
01c1476b02
commit
17ed4cdb6f
8 changed files with 159 additions and 7 deletions
54
src/Nyanlabs.Umogen.Server/Pages/Contracts.razor
Normal file
54
src/Nyanlabs.Umogen.Server/Pages/Contracts.razor
Normal file
|
@ -0,0 +1,54 @@
|
|||
@page "/contracts"
|
||||
@using Umogen.Core;
|
||||
@using Umogen.Core.Models;
|
||||
@inject IJSRuntime js
|
||||
|
||||
<PageTitle>Umowy</PageTitle>
|
||||
|
||||
<h2 class="text-center">Umowy</h2>
|
||||
|
||||
<div class="form-control">
|
||||
<input type="text" placeholder="Osoba" @bind-value="_person" />
|
||||
</div>
|
||||
<div class="form-control">
|
||||
<input type="text" placeholder="Wynagrodzenie" @bind-value="_value" />
|
||||
</div>
|
||||
<div class="form-control">
|
||||
<input type="text" placeholder="Wpisz dane" @bind-value="_prompt" />
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-control">
|
||||
<div class="text-center"><b>OUT:</b> @output</div>
|
||||
</div>
|
||||
|
||||
<button class="btn btn-primary" @onclick="Process">Wyszukaj</button>
|
||||
|
||||
@code {
|
||||
private string _prompt, _person, _value;
|
||||
private string output = "";
|
||||
|
||||
private async Task Process()
|
||||
{
|
||||
output = string.Empty;
|
||||
using UmoEngine eng = new("/home/nya/Dev/csharp/umogen/umogenkey.secret");
|
||||
UmoProcess proc = new(eng);
|
||||
Thread.Yield();
|
||||
await foreach (var str in proc.Ask(_prompt))
|
||||
{
|
||||
output += str;
|
||||
Console.Write(str);
|
||||
this.StateHasChanged();
|
||||
}
|
||||
|
||||
var anal = System.Text.Json.JsonSerializer.Deserialize<UmoAnalModel>(output, Umogen.JSON_OPTS);
|
||||
UmoDocumentResult res = new(null, new Person("Kotek", "Miauczyński", "CBS4327563", "04281308999", new DateTime(2004, 08,
|
||||
13)),
|
||||
new Person("Kotek", "Miauczyński", "CBS4327563", "04281308999", new DateTime(2004, 08, 13)), ValidTime.Invalid, 2137,
|
||||
anal);
|
||||
|
||||
var bytes = await res.ProcessPdf(Path.Combine("/home/nya/Dev/csharp/umogen/",
|
||||
$"templates/{anal.Doctype.TemplateDoc()}"));
|
||||
await js.InvokeVoidAsync("blobby", bytes);
|
||||
}
|
||||
}
|
20
src/Nyanlabs.Umogen.Server/Pages/People.razor
Normal file
20
src/Nyanlabs.Umogen.Server/Pages/People.razor
Normal file
|
@ -0,0 +1,20 @@
|
|||
@page "/people"
|
||||
|
||||
<PageTitle>Osoby</PageTitle>
|
||||
|
||||
<h2 class="text-center">Osoby</h2>
|
||||
|
||||
<button @onclick="Toggle">Dodaj nowe osoby</button>
|
||||
@if (addVis)
|
||||
{
|
||||
<PersonAddForm OnSubmit="Toggle" />
|
||||
}
|
||||
|
||||
@code {
|
||||
private bool addVis = false;
|
||||
|
||||
private void Toggle()
|
||||
{
|
||||
addVis = !addVis;
|
||||
}
|
||||
}
|
|
@ -10,9 +10,12 @@
|
|||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<base href="~/" />
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet"
|
||||
integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
|
||||
<link href="css/site.css" rel="stylesheet" />
|
||||
<link href="Nyanlabs.Umogen.Server.styles.css" rel="stylesheet" />
|
||||
<link rel="icon" href="favicon.ico" />
|
||||
<script src="penis.js"></script>
|
||||
<component type="typeof(HeadOutlet)" render-mode="ServerPrerendered" />
|
||||
</head>
|
||||
|
||||
|
|
|
@ -2,9 +2,7 @@
|
|||
|
||||
<PageTitle>umogen</PageTitle>
|
||||
|
||||
<div class="nav-side">
|
||||
<Navi />
|
||||
</div>
|
||||
<div class="page">
|
||||
<main>
|
||||
<article class="content px-4">
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
<div class="container">
|
||||
<h1>umogen</h1>
|
||||
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="#">umogen</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent"
|
||||
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" aria-current="page" href="/">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/people">Osoby</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/contracts">Umowy</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
h2 {
|
||||
h1 {
|
||||
text-align: center;
|
||||
}
|
||||
|
|
38
src/Nyanlabs.Umogen.Server/Shared/PersonAddForm.razor
Normal file
38
src/Nyanlabs.Umogen.Server/Shared/PersonAddForm.razor
Normal file
|
@ -0,0 +1,38 @@
|
|||
<h2 class="text-center">Dodaj osobę</h2>
|
||||
<div class="container">
|
||||
<form>
|
||||
<div class="mb-3">
|
||||
<label for="name" class="form-label">Imię</label>
|
||||
<input type="text" class="form-control" id="name" @bind-value="_name">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="surname" class="form-label">Nazwisko</label>
|
||||
<input type="text" class="form-control" id="surname" @bind-value="_surname">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="pesel" class="form-label">PESEL</label>
|
||||
<input type="text" class="form-control" id="pesel" @bind-value="_pesel">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="cbs" class="form-label">Seria dowodu</label>
|
||||
<input type="text" class="form-control" id="cbs" @bind-value="_id">
|
||||
</div>
|
||||
<button @onclick="Submit" class="btn btn-primary">Dodaj</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
public required Action OnSubmit { get; set; }
|
||||
|
||||
private string _name = string.Empty,
|
||||
_surname = string.Empty,
|
||||
_pesel = string.Empty,
|
||||
_id = string.Empty;
|
||||
|
||||
private void Submit()
|
||||
{
|
||||
Core.Models.Person p = new(_name, _surname, _id, _pesel);
|
||||
OnSubmit.Invoke();
|
||||
}
|
||||
}
|
20
src/Nyanlabs.Umogen.Server/wwwroot/penis.js
Normal file
20
src/Nyanlabs.Umogen.Server/wwwroot/penis.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
//I lost ;w;
|
||||
|
||||
function blobby(arr) {
|
||||
const url = window.URL.createObjectURL(
|
||||
new Blob([arr], { type: "application/pdf" })
|
||||
);
|
||||
|
||||
var downloadLink = document.createElement("a");
|
||||
downloadLink.target = "_blank";
|
||||
downloadLink.download = "umo.pdf";
|
||||
|
||||
// set object URL as the anchor's href
|
||||
downloadLink.href = url;
|
||||
|
||||
// append the anchor to document body
|
||||
document.body.append(downloadLink);
|
||||
|
||||
// fire a click event on the anchor
|
||||
downloadLink.click();
|
||||
}
|
Loading…
Reference in a new issue