working on tak use list
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -116,6 +116,7 @@ public class Constants {
|
|||||||
public static final String USER = "user";
|
public static final String USER = "user";
|
||||||
public static final String USER_ID = "user_id";
|
public static final String USER_ID = "user_id";
|
||||||
public static final String USER_LIST = "user_list";
|
public static final String USER_LIST = "user_list";
|
||||||
|
public static final String USES = "uses";
|
||||||
public static final String UTF8 = UTF_8.displayName();
|
public static final String UTF8 = UTF_8.displayName();
|
||||||
|
|
||||||
public static final String VALUE = "value";
|
public static final String VALUE = "value";
|
||||||
|
|||||||
@@ -62,7 +62,7 @@
|
|||||||
<Route path="/project/:id/kanban" component={Kanban} />
|
<Route path="/project/:id/kanban" component={Kanban} />
|
||||||
<Route path="/project/:id/view" component={ViewPrj} />
|
<Route path="/project/:id/view" component={ViewPrj} />
|
||||||
<Route path="/search" component={Search} />
|
<Route path="/search" component={Search} />
|
||||||
<Route path="/tags/use/:tag" component={TagUses} />
|
<Route path="/tags/use/:tag" component={TagUses} />
|
||||||
<Route path="/task/:parent_task_id/add_subtask" component={AddTask} />
|
<Route path="/task/:parent_task_id/add_subtask" component={AddTask} />
|
||||||
<Route path="/task/:id/view" component={ViewTask} />
|
<Route path="/task/:id/view" component={ViewTask} />
|
||||||
<Route path="/user" component={User} />
|
<Route path="/user" component={User} />
|
||||||
|
|||||||
@@ -7,19 +7,24 @@
|
|||||||
|
|
||||||
let { tag } = $props();
|
let { tag } = $props();
|
||||||
let error = $state(null);
|
let error = $state(null);
|
||||||
|
let router = useTinyRouter();
|
||||||
let uses = $state(null);
|
let uses = $state(null);
|
||||||
|
|
||||||
async function loadUses(){
|
async function loadUses(){
|
||||||
const url = api(`tags/uses/${tag}`);
|
const url = api(`tags/uses/${tag}`);
|
||||||
const resp = await fetch(api,{credentials:'include'});
|
const resp = await fetch(url,{credentials:'include'});
|
||||||
if (resp.ok){
|
if (resp.ok){
|
||||||
uses = await resp.json;
|
uses = await resp.json();
|
||||||
error = null;
|
error = null;
|
||||||
} else {
|
} else {
|
||||||
error = await resp.text();
|
error = await resp.text();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function go(module,id){
|
||||||
|
router.navigate(`/${module}/${id}/view`);
|
||||||
|
}
|
||||||
|
|
||||||
onMount(loadUses);
|
onMount(loadUses);
|
||||||
</script>
|
</script>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
@@ -27,4 +32,12 @@
|
|||||||
{#if error}
|
{#if error}
|
||||||
<span class="error">{error}</span>
|
<span class="error">{error}</span>
|
||||||
{/if}
|
{/if}
|
||||||
|
{#if uses}
|
||||||
|
{#each Object.entries(uses) as [module,ids]}
|
||||||
|
<h2>{t(module)}</h2>
|
||||||
|
{#each ids as id}
|
||||||
|
<button onclick={() => go(module,id)}>{t(module)} {id}</button>
|
||||||
|
{/each}
|
||||||
|
{/each}
|
||||||
|
{/if}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
@@ -4,6 +4,7 @@ package de.srsoftware.umbrella.tags;
|
|||||||
import static de.srsoftware.tools.jdbc.Condition.equal;
|
import static de.srsoftware.tools.jdbc.Condition.equal;
|
||||||
import static de.srsoftware.tools.jdbc.Condition.isNull;
|
import static de.srsoftware.tools.jdbc.Condition.isNull;
|
||||||
import static de.srsoftware.tools.jdbc.Query.*;
|
import static de.srsoftware.tools.jdbc.Query.*;
|
||||||
|
import static de.srsoftware.tools.jdbc.Query.SelectQuery.ALL;
|
||||||
import static de.srsoftware.umbrella.core.Constants.*;
|
import static de.srsoftware.umbrella.core.Constants.*;
|
||||||
import static de.srsoftware.umbrella.core.Constants.ERROR_FAILED_CREATE_TABLE;
|
import static de.srsoftware.umbrella.core.Constants.ERROR_FAILED_CREATE_TABLE;
|
||||||
import static de.srsoftware.umbrella.core.Constants.USER_ID;
|
import static de.srsoftware.umbrella.core.Constants.USER_ID;
|
||||||
@@ -16,9 +17,7 @@ import de.srsoftware.tools.jdbc.Query;
|
|||||||
import de.srsoftware.umbrella.core.exceptions.UmbrellaException;
|
import de.srsoftware.umbrella.core.exceptions.UmbrellaException;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.Collection;
|
import java.util.*;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class SqliteDb implements TagDB{
|
public class SqliteDb implements TagDB{
|
||||||
private static final int INITIAL_DB_VERSION = 1;
|
private static final int INITIAL_DB_VERSION = 1;
|
||||||
@@ -110,6 +109,23 @@ CREATE TABLE IF NOT EXISTS "{0}" (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, List<Long>> getUses(String tag, long userId) {
|
||||||
|
try {
|
||||||
|
var rs = select(ALL).from(TABLE_TAGS).where(TAG,equal(tag)).where(USER_ID,equal(userId)).exec(db);
|
||||||
|
var result = new HashMap<String,List<Long>>();
|
||||||
|
while (rs.next()){
|
||||||
|
var module = rs.getString(MODULE);
|
||||||
|
var entityId = rs.getLong(ID);
|
||||||
|
result.computeIfAbsent(module, k -> new ArrayList<>()).add(entityId);
|
||||||
|
}
|
||||||
|
rs.close();
|
||||||
|
return result;
|
||||||
|
} catch (SQLException e){
|
||||||
|
throw new UmbrellaException("Failed to load uses of tag \"{0}\"!",tag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void init(){
|
private void init(){
|
||||||
var version = createTables();
|
var version = createTables();
|
||||||
LOG.log(INFO,"Updated task db to version {0}",version);
|
LOG.log(INFO,"Updated task db to version {0}",version);
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
package de.srsoftware.umbrella.tags;
|
package de.srsoftware.umbrella.tags;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public interface TagDB {
|
public interface TagDB {
|
||||||
@@ -9,6 +11,8 @@ public interface TagDB {
|
|||||||
|
|
||||||
void deleteEntity(String module, long entityId);
|
void deleteEntity(String module, long entityId);
|
||||||
|
|
||||||
|
Map<String, List<Long>> getUses(String tag, long id);
|
||||||
|
|
||||||
Set<String> list(long id, String module, long entityId);
|
Set<String> list(long id, String module, long entityId);
|
||||||
|
|
||||||
void save(Collection<Long> userIds, String module, long entityId, Collection<String> tags);
|
void save(Collection<Long> userIds, String module, long entityId, Collection<String> tags);
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ public class TagModule extends BaseHandler implements TagService {
|
|||||||
var module = path.pop();
|
var module = path.pop();
|
||||||
if (module == null) throw unprocessable("Module missing in path.");
|
if (module == null) throw unprocessable("Module missing in path.");
|
||||||
var head = path.pop();
|
var head = path.pop();
|
||||||
|
if (USES.equals(module)) return getTagUses(ex,head,user.get());
|
||||||
long entityId = Long.parseLong(head);
|
long entityId = Long.parseLong(head);
|
||||||
return sendContent(ex, getTags(module,entityId,user.get()));
|
return sendContent(ex, getTags(module,entityId,user.get()));
|
||||||
} catch (NumberFormatException e){
|
} catch (NumberFormatException e){
|
||||||
@@ -77,6 +78,10 @@ public class TagModule extends BaseHandler implements TagService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean getTagUses(HttpExchange ex, String tag, UmbrellaUser user) throws IOException {
|
||||||
|
return sendContent(ex,tagDb.getUses(tag,user.id()));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doOptions(Path path, HttpExchange ex) throws IOException {
|
public boolean doOptions(Path path, HttpExchange ex) throws IOException {
|
||||||
addCors(ex);
|
addCors(ex);
|
||||||
|
|||||||
Reference in New Issue
Block a user