preparing for project creation
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
import Login from "./Components/Login.svelte";
|
import Login from "./Components/Login.svelte";
|
||||||
import Messages from "./routes/message/Messages.svelte";
|
import Messages from "./routes/message/Messages.svelte";
|
||||||
import Menu from "./Components/Menu.svelte";
|
import Menu from "./Components/Menu.svelte";
|
||||||
|
import ProjectList from "./routes/project/List.svelte";
|
||||||
import ResetPw from "./routes/user/ResetPw.svelte";
|
import ResetPw from "./routes/user/ResetPw.svelte";
|
||||||
import Search from "./routes/search/Search.svelte";
|
import Search from "./routes/search/Search.svelte";
|
||||||
import SendDoc from "./routes/document/Send.svelte";
|
import SendDoc from "./routes/document/Send.svelte";
|
||||||
@@ -44,6 +45,7 @@
|
|||||||
<Route path="/document/:id/send" component={SendDoc} />
|
<Route path="/document/:id/send" component={SendDoc} />
|
||||||
<Route path="/document/:id/view" component={ViewDoc} />
|
<Route path="/document/:id/view" component={ViewDoc} />
|
||||||
<Route path="/message/settings" component={Messages} />
|
<Route path="/message/settings" component={Messages} />
|
||||||
|
<Route path="/project" component={ProjectList} />
|
||||||
<Route path="/search" component={Search} />
|
<Route path="/search" component={Search} />
|
||||||
<Route path="/user" component={User} />
|
<Route path="/user" component={User} />
|
||||||
<Route path="/user/create" component={EditUser} />
|
<Route path="/user/create" component={EditUser} />
|
||||||
|
|||||||
@@ -43,7 +43,6 @@
|
|||||||
|
|
||||||
if (timer) clearTimeout(timer);
|
if (timer) clearTimeout(timer);
|
||||||
timer = setTimeout(render,1000);
|
timer = setTimeout(render,1000);
|
||||||
// TODO: start timer, send text to renderer, update editValue.rendered
|
|
||||||
}
|
}
|
||||||
|
|
||||||
activeField.subscribe((val) => resetEdit());
|
activeField.subscribe((val) => resetEdit());
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ onMount(fetchModules);
|
|||||||
<nav>
|
<nav>
|
||||||
<a onclick={() => router.navigate('/user')}>{t('users')}</a>
|
<a onclick={() => router.navigate('/user')}>{t('users')}</a>
|
||||||
<a onclick={() => router.navigate('/document')}>{t('documents')}</a>
|
<a onclick={() => router.navigate('/document')}>{t('documents')}</a>
|
||||||
|
<a onclick={() => router.navigate('/project')}>{t('projects')}</a>
|
||||||
<a href="https://svelte.dev/tutorial/svelte/state" target="_blank">{t('tutorial')}</a>
|
<a href="https://svelte.dev/tutorial/svelte/state" target="_blank">{t('tutorial')}</a>
|
||||||
{#each modules as module,i}
|
{#each modules as module,i}
|
||||||
<a href={module.url}>{module.name}</a>
|
<a href={module.url}>{module.name}</a>
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
<script>
|
<script>
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import { t } from '../../translations.svelte.js';
|
import { t } from '../../translations.svelte.js';
|
||||||
|
import { user } from '../../user.svelte.js';
|
||||||
|
|
||||||
import { useTinyRouter } from 'svelte-tiny-router';
|
import { useTinyRouter } from 'svelte-tiny-router';
|
||||||
import LineEditor from '../../Components/LineEditor.svelte';
|
import LineEditor from '../../Components/LineEditor.svelte';
|
||||||
import MarkdownEditor from '../../Components/MarkdownEditor.svelte';
|
import MarkdownEditor from '../../Components/MarkdownEditor.svelte';
|
||||||
@@ -227,14 +229,16 @@
|
|||||||
<button onclick={render} disabled={pdfDisabled}>{t('create_pdf')}</button>
|
<button onclick={render} disabled={pdfDisabled}>{t('create_pdf')}</button>
|
||||||
<button onclick={() => router.navigate(`/document/${doc.id}/send`)} >{t('send_document')}</button>
|
<button onclick={() => router.navigate(`/document/${doc.id}/send`)} >{t('send_document')}</button>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
{#if user.name == 'Stephan Richter'}
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>TODO</legend>
|
<legend>TODO</legend>
|
||||||
<ul>
|
<ul>
|
||||||
<li>Preise in der Tabelle neu berechnen, wenn Positionen geändert werden</li>
|
<li>Preise in der Tabelle neu berechnen, wenn Positionen geändert werden</li>
|
||||||
</ul>
|
</ul>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if position_select}
|
{#if position_select}
|
||||||
<PositionSelector close={() => position_select=false} {doc} onSelect={addPosition} />
|
<PositionSelector close={() => position_select=false} {doc} onSelect={addPosition} />
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
19
frontend/src/routes/project/Create.svelte
Normal file
19
frontend/src/routes/project/Create.svelte
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<script>
|
||||||
|
import { useTinyRouter } from 'svelte-tiny-router';
|
||||||
|
import { onMount } from 'svelte';
|
||||||
|
import { t } from '../../translations.svelte.js';
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<fieldset>
|
||||||
|
<legend>
|
||||||
|
{t('create_new_project')}
|
||||||
|
</legend>
|
||||||
|
<fieldset>
|
||||||
|
<legend>{t('basic_data')}</legend>
|
||||||
|
<span class="warn">Company Selector</span>
|
||||||
|
<label>
|
||||||
|
<input type="text" />
|
||||||
|
{t('Name')}
|
||||||
|
</label>
|
||||||
|
</fieldset>
|
||||||
|
</fieldset>
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<script>
|
||||||
|
import { useTinyRouter } from 'svelte-tiny-router';
|
||||||
|
import { onMount } from 'svelte';
|
||||||
|
import { t } from '../../translations.svelte.js';
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<fieldset>
|
||||||
|
<legend>
|
||||||
|
{t('projects')}
|
||||||
|
<button>{t('create_new')}</button>
|
||||||
|
</legend>
|
||||||
|
</fieldset>
|
||||||
@@ -4,7 +4,10 @@ package de.srsoftware.umbrella.project;
|
|||||||
public class Constants {
|
public class Constants {
|
||||||
private Constants(){}
|
private Constants(){}
|
||||||
public static final String CONFIG_DATABASE = "umbrella.modules.project.database";
|
public static final String CONFIG_DATABASE = "umbrella.modules.project.database";
|
||||||
|
public static final String DB_VERSION = "project_db_version";
|
||||||
|
public static final String PERMISSIONS = "permissions";
|
||||||
public static final String TABLE_PROJECTS = "projects";
|
public static final String TABLE_PROJECTS = "projects";
|
||||||
|
public static final String TABLE_PROJECT_USERS = "project_users";
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,25 +3,125 @@ package de.srsoftware.umbrella.project;
|
|||||||
|
|
||||||
import static de.srsoftware.tools.jdbc.Condition.equal;
|
import static de.srsoftware.tools.jdbc.Condition.equal;
|
||||||
import static de.srsoftware.tools.jdbc.Condition.lessThan;
|
import static de.srsoftware.tools.jdbc.Condition.lessThan;
|
||||||
|
import static de.srsoftware.tools.jdbc.Query.insertInto;
|
||||||
import static de.srsoftware.tools.jdbc.Query.select;
|
import static de.srsoftware.tools.jdbc.Query.select;
|
||||||
import static de.srsoftware.umbrella.core.Constants.COMPANY_ID;
|
import static de.srsoftware.umbrella.core.Constants.*;
|
||||||
import static de.srsoftware.umbrella.core.Constants.STATUS;
|
import static de.srsoftware.umbrella.core.Constants.TABLE_SETTINGS;
|
||||||
import static de.srsoftware.umbrella.core.ResponseCode.HTTP_SERVER_ERROR;
|
import static de.srsoftware.umbrella.core.ResponseCode.HTTP_SERVER_ERROR;
|
||||||
import static de.srsoftware.umbrella.project.Constants.TABLE_PROJECTS;
|
import static de.srsoftware.umbrella.core.Util.LOG;
|
||||||
|
import static de.srsoftware.umbrella.core.model.Project.Status.Open;
|
||||||
|
import static de.srsoftware.umbrella.project.Constants.*;
|
||||||
|
import static java.lang.System.Logger.Level.ERROR;
|
||||||
|
import static java.lang.System.Logger.Level.INFO;
|
||||||
|
import static java.text.MessageFormat.format;
|
||||||
|
|
||||||
|
import de.srsoftware.tools.PasswordHasher;
|
||||||
|
import de.srsoftware.tools.jdbc.Query;
|
||||||
import de.srsoftware.umbrella.core.exceptions.UmbrellaException;
|
import de.srsoftware.umbrella.core.exceptions.UmbrellaException;
|
||||||
import de.srsoftware.umbrella.core.model.Project;
|
import de.srsoftware.umbrella.core.model.Project;
|
||||||
|
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
public class SqliteDb implements ProjectDb {
|
public class SqliteDb implements ProjectDb {
|
||||||
|
private static final System.Logger LOG = System.getLogger("Sqlite4Project");
|
||||||
|
private static final int INITIAL_DB_VERSION = 1;
|
||||||
|
|
||||||
private final Connection db;
|
private final Connection db;
|
||||||
|
|
||||||
public SqliteDb(Connection connection) {
|
public SqliteDb(Connection connection) {
|
||||||
db = connection;
|
db = connection;
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private int createTables() {
|
||||||
|
createProjectTables();
|
||||||
|
return createSettingsTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createProjectTables() {
|
||||||
|
var createTable = """
|
||||||
|
CREATE TABLE IF NOT EXISTS {0} (
|
||||||
|
`{1}` INTEGER PRIMARY KEY,
|
||||||
|
`{2}` INTEGER,
|
||||||
|
`{3}` VARCHAR(255) NOT NULL,
|
||||||
|
`{4}` TEXT,
|
||||||
|
`{5}` INT DEFAULT {6},
|
||||||
|
`{7}` BOOLEAN DEFAULT 0
|
||||||
|
)""";
|
||||||
|
try {
|
||||||
|
var stmt = db.prepareStatement(format(createTable,TABLE_PROJECTS, ID, COMPANY_ID, NAME, DESCRIPTION, STATUS, Open.code(), SHOW_CLOSED));
|
||||||
|
stmt.execute();
|
||||||
|
stmt.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
LOG.log(ERROR,ERROR_FAILED_CREATE_TABLE,TABLE_PROJECTS ,e);
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
long count = 0L;
|
||||||
|
try {
|
||||||
|
ResultSet rs = select("COUNT(*)").from(TABLE_PROJECTS).exec(db);
|
||||||
|
if (rs.next()) count = rs.getLong(1);
|
||||||
|
rs.close();
|
||||||
|
} catch (SQLException ignored) {
|
||||||
|
// go on with table creation
|
||||||
|
}
|
||||||
|
|
||||||
|
createTable = """
|
||||||
|
CREATE TABLE IF NOT EXISTS {0} (
|
||||||
|
{1} INT NOT NULL,
|
||||||
|
{2} INT NOT NULL,
|
||||||
|
{3} INT DEFAULT {3},
|
||||||
|
PRIMARY KEY ({1}, {2})
|
||||||
|
)""";
|
||||||
|
try {
|
||||||
|
var stmt = db.prepareStatement(format(createTable,TABLE_PROJECT_USERS, PROJECT_ID, USER_ID, PERMISSIONS));
|
||||||
|
stmt.execute();
|
||||||
|
stmt.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
LOG.log(ERROR,ERROR_FAILED_CREATE_TABLE,TABLE_PROJECT_USERS,e);
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int createSettingsTable() {
|
||||||
|
var createTable = """
|
||||||
|
CREATE TABLE IF NOT EXISTS {0} ( {1} VARCHAR(255) PRIMARY KEY, {2} VARCHAR(255) NOT NULL);
|
||||||
|
""";
|
||||||
|
try {
|
||||||
|
var stmt = db.prepareStatement(format(createTable,TABLE_SETTINGS, KEY, VALUE));
|
||||||
|
stmt.execute();
|
||||||
|
stmt.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
LOG.log(ERROR,ERROR_FAILED_CREATE_TABLE,TABLE_SETTINGS,e);
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
Integer version = null;
|
||||||
|
try {
|
||||||
|
var rs = Query.select(VALUE).from(TABLE_SETTINGS).where(KEY, equal(DB_VERSION)).exec(db);
|
||||||
|
if (rs.next()) version = rs.getInt(VALUE);
|
||||||
|
rs.close();
|
||||||
|
if (version == null) {
|
||||||
|
version = INITIAL_DB_VERSION;
|
||||||
|
insertInto(TABLE_SETTINGS, KEY, VALUE).values(DB_VERSION,version).execute(db).close();
|
||||||
|
}
|
||||||
|
|
||||||
|
return version;
|
||||||
|
} catch (SQLException e) {
|
||||||
|
LOG.log(ERROR,ERROR_READ_TABLE,DB_VERSION,TABLE_SETTINGS,e);
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init(){
|
||||||
|
var version = createTables();
|
||||||
|
LOG.log(INFO,"Updated project db to version {0}",version);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user