Skip to content
Snippets Groups Projects
Commit 104e92b7 authored by Robert Goldmann's avatar Robert Goldmann
Browse files

#259 - started working on ui

parent 61238c44
No related branches found
No related tags found
No related merge requests found
Pipeline #176 passed
...@@ -2,8 +2,10 @@ package de.deadlocker8.budgetmaster.controller; ...@@ -2,8 +2,10 @@ package de.deadlocker8.budgetmaster.controller;
import de.deadlocker8.budgetmaster.authentication.User; import de.deadlocker8.budgetmaster.authentication.User;
import de.deadlocker8.budgetmaster.authentication.UserRepository; import de.deadlocker8.budgetmaster.authentication.UserRepository;
import de.deadlocker8.budgetmaster.database.AccountMatch;
import de.deadlocker8.budgetmaster.database.Database; import de.deadlocker8.budgetmaster.database.Database;
import de.deadlocker8.budgetmaster.database.DatabaseParser; import de.deadlocker8.budgetmaster.database.DatabaseParser;
import de.deadlocker8.budgetmaster.entities.Account;
import de.deadlocker8.budgetmaster.entities.Settings; import de.deadlocker8.budgetmaster.entities.Settings;
import de.deadlocker8.budgetmaster.repositories.AccountRepository; import de.deadlocker8.budgetmaster.repositories.AccountRepository;
import de.deadlocker8.budgetmaster.repositories.SettingsRepository; import de.deadlocker8.budgetmaster.repositories.SettingsRepository;
...@@ -32,6 +34,8 @@ import javax.servlet.ServletOutputStream; ...@@ -32,6 +34,8 @@ import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
@Controller @Controller
...@@ -165,8 +169,7 @@ public class SettingsController extends BaseController ...@@ -165,8 +169,7 @@ public class SettingsController extends BaseController
} }
@RequestMapping(value = "/settings/database/delete", method = RequestMethod.POST) @RequestMapping(value = "/settings/database/delete", method = RequestMethod.POST)
public String deleteDatabase(Model model, public String deleteDatabase(@RequestParam("verificationCode") String verificationCode,
@RequestParam("verificationCode") String verificationCode,
@RequestParam("verificationUserInput") String verificationUserInput) @RequestParam("verificationUserInput") String verificationUserInput)
{ {
if(verificationUserInput.equals(verificationCode)) if(verificationUserInput.equals(verificationCode))
...@@ -203,15 +206,17 @@ public class SettingsController extends BaseController ...@@ -203,15 +206,17 @@ public class SettingsController extends BaseController
String jsonString = new String(file.getBytes()); String jsonString = new String(file.getBytes());
DatabaseParser importer = new DatabaseParser(jsonString); DatabaseParser importer = new DatabaseParser(jsonString);
Database database = importer.parseDatabaseFromJSON(); Database database = importer.parseDatabaseFromJSON();
model.addAttribute("database", database);
model.addAttribute("availableAccounts", accountRepository.findAllByOrderByNameAsc());
return "import";
} }
catch(Exception e) catch(Exception e)
{ {
e.printStackTrace(); e.printStackTrace();
model.addAttribute("errorImportDatabase", e.getMessage()); model.addAttribute("errorImportDatabase", e.getMessage());
return "settings"; return "settings";
} }
//TODO redirect to account combination page
return "redirect:/settings";
} }
} }
\ No newline at end of file
package de.deadlocker8.budgetmaster.database;
import de.deadlocker8.budgetmaster.entities.Account;
public class AccountMatch
{
private Account accountSource;
private Account accountDestination;
public AccountMatch(Account accountSource)
{
this.accountSource = accountSource;
}
public Account getAccountSource()
{
return accountSource;
}
public void setAccountSource(Account accountSource)
{
this.accountSource = accountSource;
}
public Account getAccountDestination()
{
return accountDestination;
}
public void setAccountDestination(Account accountDestination)
{
this.accountDestination = accountDestination;
}
@Override
public String toString()
{
return "AccountMatch{" +
"accountSource=" + accountSource.getName() +
", accountDestination=" + accountDestination.getName() +
'}';
}
}
\ No newline at end of file
package de.deadlocker8.budgetmaster.services; package de.deadlocker8.budgetmaster.services;
import de.deadlocker8.budgetmaster.database.AccountMatch;
import de.deadlocker8.budgetmaster.entities.Account; import de.deadlocker8.budgetmaster.entities.Account;
import de.deadlocker8.budgetmaster.entities.Payment; import de.deadlocker8.budgetmaster.entities.Payment;
import de.deadlocker8.budgetmaster.entities.Settings; import de.deadlocker8.budgetmaster.entities.Settings;
...@@ -254,4 +255,15 @@ public class HelpersService ...@@ -254,4 +255,15 @@ public class HelpersService
{ {
return settingsService.getSettings(); return settingsService.getSettings();
} }
public List<AccountMatch> getAccountMatches(List<Account> accounts)
{
List<AccountMatch> accountMatches = new ArrayList<>();
for(Account account : accounts)
{
accountMatches.add(new AccountMatch(account));
}
return accountMatches;
}
} }
\ No newline at end of file
...@@ -87,6 +87,10 @@ info.title.database.delete=Datenbank l ...@@ -87,6 +87,10 @@ info.title.database.delete=Datenbank l
info.header.text.database.delete=Soll die Datenbank wirklich unwiderruflich gelscht werden? info.header.text.database.delete=Soll die Datenbank wirklich unwiderruflich gelscht werden?
info.text.database.delete=Zur Besttigung gib folgenden Code ein:\t{0} info.text.database.delete=Zur Besttigung gib folgenden Code ein:\t{0}
info.title.database.import.dialog=Datenbank importieren info.title.database.import.dialog=Datenbank importieren
info.subtitle.database.import=Konten zuordnen
info.database.import.source=Buchungen aus
info.database.import.destination=importieren in
info.database.import.or=oder
# WARNING # WARNING
warning.text.account.delete=Das Konto "{0}" kann nicht gelscht werden, da mindestens ein Konto existieren muss. Um dieses Konto zu lschen musst du zuerst ein neues anlegen. warning.text.account.delete=Das Konto "{0}" kann nicht gelscht werden, da mindestens ein Konto existieren muss. Um dieses Konto zu lschen musst du zuerst ein neues anlegen.
......
...@@ -87,6 +87,10 @@ info.title.database.delete=Delete Database ...@@ -87,6 +87,10 @@ info.title.database.delete=Delete Database
info.header.text.database.delete=Do you really want to delete the database? This can''t be undone. info.header.text.database.delete=Do you really want to delete the database? This can''t be undone.
info.text.database.delete=Please enter the following code for verification:\t{0} info.text.database.delete=Please enter the following code for verification:\t{0}
info.title.database.import.dialog=Import database info.title.database.import.dialog=Import database
info.subtitle.database.import=Assign accounts
info.database.import.source=Import payments from
info.database.import.destination=to
info.database.import.or=or
# WARNING # WARNING
warning.text.account.delete=The account "{0}" could not be deleted, because at least one account must exist at all time. You have to create a new account in order to delete this one. warning.text.account.delete=The account "{0}" could not be deleted, because at least one account must exist at all time. You have to create a new account in order to delete this one.
......
...@@ -130,7 +130,7 @@ main { ...@@ -130,7 +130,7 @@ main {
color: rgba(255, 255, 255, 0.87); color: rgba(255, 255, 255, 0.87);
} }
.btn { .btn, .btn-flat {
text-transform: capitalize; text-transform: capitalize;
} }
...@@ -452,6 +452,10 @@ input[type="radio"]:not(:checked) + label::before, [type="radio"]:not(:checked) ...@@ -452,6 +452,10 @@ input[type="radio"]:not(:checked) + label::before, [type="radio"]:not(:checked)
color: #FFFFFF; color: #FFFFFF;
} }
.import-text {
color: #4CABD3;
}
.hidden { .hidden {
display: none; display: none;
} }
......
...@@ -109,7 +109,7 @@ main { ...@@ -109,7 +109,7 @@ main {
color: rgba(0, 0, 0, 0.87); color: rgba(0, 0, 0, 0.87);
} }
.btn { .btn, .btn-flat {
text-transform: capitalize; text-transform: capitalize;
} }
...@@ -389,6 +389,10 @@ input[type="radio"]:checked + label::after, [type="radio"].with-gap:checked + la ...@@ -389,6 +389,10 @@ input[type="radio"]:checked + label::after, [type="radio"].with-gap:checked + la
color: #AAAAAA !important; color: #AAAAAA !important;
} }
.import-text {
color: #2E79B9;
}
.hidden { .hidden {
display: none; display: none;
} }
......
<html>
<head>
<#import "header.ftl" as header>
<@header.header "BudgetMaster"/>
</head>
<body class="budgetmaster-blue-light">
<#import "navbar.ftl" as navbar>
<@navbar.navbar "settings"/>
<main>
<div class="card main-card background-color">
<div class="container">
<div class="section center-align">
<div class="headline">${locale.getString("info.title.database.import.dialog")}</div>
<div>${locale.getString("info.subtitle.database.import")}</div>
</div>
</div>
<div class="container">
<#import "validation.ftl" as validation>
<form name="Import" action="/settings/database/import" method="post">
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
<table class="bordered">
<#list helpers.getAccountMatches(database.getAccounts()) as accountMatch>
<tr>
<td class="import-text">${locale.getString("info.database.import.source")}</td>
<td>${accountMatch.getAccountSource().getName()}</td>
<td class="import-text">${locale.getString("info.database.import.destination")}</td>
<td>
<select>
<#list availableAccounts as account>
<option value="${account.getName()}">${account.getName()}</option>
</#list>
</select>
</td>
<td class="import-text">${locale.getString("info.database.import.or")}</td>
<td>
<a href="/accounts/newAccount" class="btn waves-effect waves-light budgetmaster-blue"><i class="material-icons left">add</i>${locale.getString("title.account.new")}</a>
</td>
</tr>
</#list>
</table>
<#if availableAccounts?size == 0>
<div class="headline center-align">${locale.getString("placeholder")}</div>
</#if>
<br>
<#-- buttons -->
<div class="row">
<div class="col s12 m12 l4 offset-l4 center-align">
<button class="btn waves-effect waves-light budgetmaster-blue" type="submit" name="action">
<i class="material-icons left">unarchive</i>${locale.getString("settings.database.import")}
</button>
</div>
</div>
</form>
</div>
</div>
</main>
<!-- Scripts-->
<#import "scripts.ftl" as scripts>
<@scripts.scripts/>
</body>
</html>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment