Removed unused methods

This commit is contained in:
Borna Rajković 2024-01-01 17:58:47 +01:00
parent 9bdb5dd129
commit 0173086939
6 changed files with 4 additions and 500 deletions

View File

@ -111,6 +111,7 @@ h3 {
color: #999; color: #999;
} }
.form-field input, .form-field textarea { .form-field input, .form-field textarea {
box-sizing: border-box;
width: 100%; width: 100%;
border: none; border: none;
border-bottom: 1px solid #bbb; border-bottom: 1px solid #bbb;
@ -390,5 +391,6 @@ dialog::backdrop {
} }
dialog { dialog {
width: 400px; width: 400px;
max-width: 100vh; max-width: 80vw;
} box-sizing: border-box;
}

View File

@ -1,317 +0,0 @@
/* cleanup */
:root {
--primary: #9222dd;
--primary-darker: #6400a2;
--primary-contrast: #eee;
}
* {
box-sizing: border-box;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
padding: 0;
margin: 0;
}
header {
padding: 1rem 2rem;
width: 100%;
background: var(--primary);
color: var(--primary-contrast);
}
header h1 {
font-size: 1.25em;
}
header a {
color: var(--primary-contrast);
text-decoration: none;
}
button {
all: unset;
padding: 0.25em 0.5em;
color: var(--primary-contrast);
background: var(--primary);
border: solid 1px var(--primary-darker);
border-radius: 0.25em;
font-size: 0.875em;
--text: var(--primary-contrast);
}
select {
all: unset;
color: #111;
padding: 0.25em 0.5em;
background: #dddddd;
border: solid 1px #cccccc;
border-radius: 0.25em;
font-size: 0.875em;
}
nav {
padding: 1rem 2rem;
width: 100%;
background: #f7f7f7;
}
nav a, nav button {
display: inline-block;
text-decoration: none;
color: #333;
font-size: 1rem;
border: none;
background: none;
padding: 0.5rem 1rem;
transition: ease-out 0.2s;
border-radius: 0;
}
nav a:hover, nav button:hover {
background: #e0e0e0;
color: #000;
transition: ease-out 0.2s;
}
nav a.selected, nav button.selected {
background: #216897;
color: white;
}
table {
border-radius: 0.5em;
}
table:not(.clean) {
width: 100%;
}
table th, table td {
text-align: left;
}
table {
border-spacing: 0;
/*border-collapse: collapse;*/
}
table thead * {
background: #666;
color: #fff;
}
table th, table td {
padding: 0.4rem 0.4rem;
}
table:not(.clean) tbody tr:nth-child(2n+1) {
background: #fcfcfc;
}
table:not(.clean) tbody tr:nth-child(2n) {
background: #f2f2f2;
}
button {
padding: 0.25rem 1rem;
}
.card {
padding: 1em;
background: #fff;
border-radius: 0.2rem;
border: 1px solid #bbb;
}
.card .card-title {
margin-bottom: 0.5em;
}
.card p {
margin-bottom: 0.5em;
}
form section {
width: fit-content;
}
/* styling */
form section:not(.radio-group) label+:not(select) {
display: flex;
}
form section {
padding-bottom: 0.75rem;
}
form section > input {
width: 200px;
padding: 0.2em 0.5em;
border-radius: 0.25em;
border: 1px solid #aaa;
}
form section > textarea {
width: 200px;
padding: 0.2em 0.5em;
border: 1px solid #aaa;
border-radius: 0.25em;
}
form section select {
display: block;
width: 200px;
border: none;
font-size: 0.9rem;
padding: 0.2em 0.5em;
background: #ddd;
}
form section label.checkbox {
display: block;
overflow: hidden;
width: 200px;
}
form section input[type=checkbox] {
vertical-align: middle;
float: right;
}
section.radio-group input {
display: none;
}
section.radio-group div label {
display: inline-block;
padding: 0.25rem 0.75rem;
background: #ddd;
}
section.radio-group div label {
min-width: 64px;
text-align: center;
font-size: 0.9rem;
}
section.radio-group div label:first-of-type {
border-top-left-radius: 0.25rem;
border-bottom-left-radius: 0.25rem;
}
section.radio-group div label:last-of-type {
border-top-right-radius: 0.25rem;
border-bottom-right-radius: 0.25rem;
}
section.radio-group div input:checked+label {
background: #555;
color: white;
}
img.icon, button.icon svg {
height: 1.2em;
width: 1.2em;
}
button.icon, a.icon {
display: flex;
align-content: baseline;
gap: 0.3em;
}
button.icon svg, button.icon svg * {
fill: var(--text, var(--primary-contrast));
color: var(--text, var(--primary-contrast));
stroke: var(--text, var(--primary-contrast));
}
main {
display: flex;
flex-wrap: wrap;
max-width: 1280px;
margin: auto;
}
.container {
max-width: 1280px;
margin: auto;
}
section#search {
margin: 1em;
width: fit-content;
}
.index-page {
margin: 1em auto;
align-content: center;
gap: 1em;
}
.index-page section {
flex-grow: 1;
}
.index-page section article {
margin: auto;
width: 300px;
max-width: 90vw;
}
section#results {
margin: 1em;
flex-grow: 1;
}
button.clean {
display: inline-block;
padding: 0.4rem;
border: none;
background: none;
text-decoration: none;
color: #000;
cursor: pointer;
}
section#results a, section#results button {
display: inline-block;
padding: 0.4rem;
border: none;
background: none;
text-decoration: none;
color: #000;
cursor: pointer;
}
dialog {
position: fixed;
left: 50%;
top: 80px;
transform: translate(-50%, 0);
max-height: calc(100vh - 160px);
overflow-y: scroll;
}
section.actions {
padding: 0;
}
article.single-holiday {
padding-bottom: 0.5em;
margin-bottom: 1em;
border-bottom: 2px solid #a0a0a0;
}
.optional-selector {
border: 1px solid #666;
border-radius: 0.5em;
}
.optional-selector .header {
padding: 1em;
background: #666;
margin-bottom: 0.5em;
color: white;
border-top-left-radius: 0.5em;
border-top-right-radius: 0.5em;
}
.optional-selector > *:not(.header) {
margin: 0 1em;
}
.hide {
display: none;
}
.source-code {
padding: 1em;
}
.source-code, .source-code * {
background: #777;
color: #fff;
font-family: 'Courier New', Courier, monospace;
}

19
main.go
View File

@ -82,22 +82,6 @@ func main() {
years, _ := yearService.Find() years, _ := yearService.Find()
c.HTML(http.StatusOK, "documentation.gohtml", gin.H{"Years": years, "Countries": countries}) c.HTML(http.StatusOK, "documentation.gohtml", gin.H{"Years": years, "Countries": countries})
}) })
g.GET("/search", func(c *gin.Context) {
request := holiday.Search{}
if err := c.ShouldBindQuery(&request); err != nil {
c.AbortWithError(http.StatusBadRequest, err)
return
}
search := holiday.Search{Country: request.Country, Date: request.Date}
holidays, _ := holidayService.Find(search, holiday.Paging{PageSize: 100})
countries, _ := countryService.Find()
c.HTML(http.StatusOK, "search.gohtml", gin.H{"Countries": countries, "Search": search, "Holidays": mapHolidays(holidays).Holidays})
})
g.GET("/dialogs/check-is-a-holiday", func(c *gin.Context) {
countries, _ := countryService.Find()
c.HTML(http.StatusOK, "check-is-a-holiday.gohtml", gin.H{"Countries": countries})
})
log.Fatal(http.ListenAndServe(":5281", g)) log.Fatal(http.ListenAndServe(":5281", g))
} }
@ -122,7 +106,6 @@ func loadTemplates(g *gin.Engine) {
g.LoadHTMLFiles( g.LoadHTMLFiles(
"templates/index.gohtml", "templates/index.gohtml",
"templates/results.gohtml", "templates/results.gohtml",
"templates/search.gohtml",
"templates/documentation.gohtml", "templates/documentation.gohtml",
"templates/admin_dashboard.gohtml", "templates/admin_dashboard.gohtml",
@ -131,7 +114,6 @@ func loadTemplates(g *gin.Engine) {
"templates/dialogs/add-holiday.gohtml", "templates/dialogs/add-holiday.gohtml",
"templates/dialogs/edit-holiday.gohtml", "templates/dialogs/edit-holiday.gohtml",
"templates/dialogs/delete-holiday.gohtml", "templates/dialogs/delete-holiday.gohtml",
"templates/dialogs/check-is-a-holiday.gohtml",
"templates/dialogs/add-country.gohtml", "templates/dialogs/add-country.gohtml",
"templates/dialogs/edit-country.gohtml", "templates/dialogs/edit-country.gohtml",
@ -145,7 +127,6 @@ func IncludeHTML(path string) template.HTML {
log.Println("includeHTML - error reading file: %v", err) log.Println("includeHTML - error reading file: %v", err)
return "" return ""
} }
return template.HTML(string(b)) return template.HTML(string(b))
} }

View File

@ -1,66 +1,3 @@
<!--
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Holiday-api | Admin dashboard</title>
<link rel="stylesheet" href="/assets/style.css">
<script src="/assets/global.js"></script>
</head>
<body>
<div id="dialog-container"></div>
<header>
<section class="container">
<h1><a href="/">Holiday-api | Countries</a></h1>
</section>
</header>
<nav>
<section class="container">
<a href="/admin">Search</a>
<a class="selected" href="#">Countries</a>
<button data-type="dialog" data-trigger="#create-card" data-url="/admin/dialogs/add-holiday">Add new holiday</button>
</section>
</nav>
<main>
<section style="margin: 1em; flex-grow: 1">
<form action="/admin/countries" method="post">
<table style="width: 100%">
<thead>
<tr>
<th>Iso name</th>
<th>Name</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td><section><input minlength="2" maxlength="2" required id="iso_name" type="text" name="iso_name"></section></td>
<td><section><input minlength="1" maxlength="45" required id="name" type="text" name="name"></section></td>
<td><button>Create country</button></td>
</tr>
{{range $entry := .Countries}}
<tr>
<td>{{$entry.IsoName}}</td>
<td>{{$entry.Name}}</td>
<td>
<button type="button" data-type="dialog" data-trigger="#update-card" data-url="/admin/dialogs/edit-country?id={{$entry.Id}}" class="clean icon"><img class="icon" src="/assets/icons/edit.svg"></button>
<button type="button" data-type="dialog" data-trigger="#delete-card" data-url="/admin/dialogs/delete-country?id={{$entry.Id}}" class="clean icon"><img class="icon" src="/assets/icons/trash-delete.svg"></button>
</td>
</tr>
{{end}}
</tbody>
</table>
</form>
</section>
</main>
</body>
</html>
-->
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>

View File

@ -1,23 +0,0 @@
<dialog class="card" data-closeable id="check-is-a-holiday">
<div style="display: flex;">
<h2 style="margin-right: 1em;">Is it a holiday?</h2>
<button onclick="closeDialog('#check-is-a-holiday')" class="clean icon"><img class="icon" src="/assets/icons/close-x.svg"></button>
</div>
<form method="get" action="/search">
<section>
<label for="country">Country:</label>
<select id="country" name="country">
{{range $entry := .Countries}}
<option value="{{$entry.IsoName}}">{{$entry.Name}}</option>
{{end}}
</select>
</section>
<section>
<label for="date">Date:</label>
<input id="date" name="date" type="date" required>
</section>
<section class="actions">
<button style="width: 100%;" type="submit">Check is a holiday</button>
</section>
</form>
</dialog>

View File

@ -1,76 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Holiday-api | Admin dashboard</title>
<link rel="stylesheet" href="/assets/style.css">
<script src="/assets/global.js"></script>
</head>
<body>
<div id="dialog-container"></div>
<header>
<section class="container">
<h1><a href="/">Holiday-api | {{.Search.Date.Format "2006-01-02"}}</a></h1>
</section>
</header>
<nav>
<section class="container">
<a href="/">Search</a>
<a href="/documentation">Documentation</a>
<a class="selected" href="#">For date</a>
</section>
</nav>
<main>
<section id="search">
<article class="card">
<h2 style="margin-right: 1em;">Is it a holiday?</h2>
<form method="get" action="/search">
<section>
<label for="country">Country:</label>
<select id="country" name="country">
{{range $entry := .Countries}}
<option {{if eq $.Search.Country $entry.IsoName}}selected{{end}} value="{{$entry.IsoName}}">{{$entry.Name}}</option>
{{end}}
</select>
</section>
<section>
<label for="date">Date:</label>
<input id="date" value="{{.Search.Date.Format "2006-01-02"}}" name="date" type="date" required>
</section>
<section class="actions">
<button style="width: 100%;" type="submit">Check is a holiday</button>
</section>
</form>
</article>
</section>
<section id="results">
<h2 style="margin-bottom: 1em;">Results</h2>
{{range $entry := .Holidays}}
<article class="single-holiday">
<table class="clean">
<tbody>
<tr>
<th>Name: </th>
<td>{{$entry.Name}}</td>
</tr>
<tr>
<th>Description: </th>
<td>{{$entry.Description}}</td>
</tr>
<tr>
<th>Is state holiday: </th>
<td><img class="icon" src="{{if $entry.IsStateHoliday}}/assets/icons/done-v.svg{{else}}/assets/images/close-x.svg{{end}}"></td>
</tr>
<tr>
<th>Is religious holiday: </th>
<td><img class="icon" src="{{if $entry.IsReligiousHoliday}}/assets/icons/done-v.svg{{else}}/assets/images/close-x.svg{{end}}"></td>
</tr>
</tbody>
</table>
</article>
{{end}}
</section>
</main>
</body>
</html>