also rename t/k/v to e/a/v in ui

feat/vaults
Tomáš Mládek 2021-03-15 22:31:18 +01:00
parent ce36c97f2a
commit 2c5a824d4a
3 changed files with 21 additions and 21 deletions

View File

@ -1,7 +1,7 @@
<template> <template>
<router-link :to="{name: 'Inspect', params: {'address': result.target}}" class="search-result"> <router-link :to="{name: 'Inspect', params: {'address': result.entity}}" class="search-result">
<div class="search-result-container"> <div class="search-result-container">
<div class="search-result-key">{{ result.key }}</div> <div class="search-result-attribute">{{ result.attribute }}</div>
<div class="search-result-value">{{ result.value.c }}</div> <div class="search-result-value">{{ result.value.c }}</div>
</div> </div>
</router-link> </router-link>
@ -40,7 +40,7 @@ export default defineComponent({
margin: .5rem 0; margin: .5rem 0;
} }
.search-result-key { .search-result-attribute {
font-weight: bold; font-weight: bold;
} }
} }

View File

@ -2,8 +2,8 @@ export type Address = string;
export type VALUE_TYPE = "Value" | "Address" | "Invalid"; export type VALUE_TYPE = "Value" | "Address" | "Invalid";
export interface IEntry { export interface IEntry {
target: Address, entity: Address,
key: string, attribute: string,
value: {t: VALUE_TYPE, c: string} value: {t: VALUE_TYPE, c: string}
} }

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="inspect"> <div class="inspect">
<h2> <h2>
<Address :address="address" :is-file="backlinks.some(([_, e]) => e.key === 'FILE_IS')"/> <Address :address="address" :is-file="backlinks.some(([_, e]) => e.attribute === 'FILE_IS')"/>
</h2> </h2>
<div v-if="!error"> <div v-if="!error">
<template v-if="attributes.length"> <template v-if="attributes.length">
@ -9,14 +9,14 @@
<table> <table>
<tr> <tr>
<th></th> <th></th>
<th>Key name</th> <th>Attribute name</th>
<th>Value</th> <th>Value</th>
</tr> </tr>
<tr v-for="[id, entry] in attributes"> <tr v-for="[id, entry] in attributes" :key=id>
<td> <td>
<sl-icon-button name="x-circle" @click="removeEntry(id)"/> <sl-icon-button name="x-circle" @click="removeEntry(id)"/>
</td> </td>
<td>{{ entry.key }}</td> <td>{{ entry.attribute }}</td>
<td> <td>
<Address link v-if="entry.value.t === 'Address'" :address="entry.value.c"/> <Address link v-if="entry.value.t === 'Address'" :address="entry.value.c"/>
<template v-else> <template v-else>
@ -29,7 +29,7 @@
<sl-icon-button name="plus-circle" @click="addEntry()"/> <sl-icon-button name="plus-circle" @click="addEntry()"/>
</td> </td>
<td> <td>
<sl-input v-sl-model:newEntryKey/> <sl-input v-sl-model:newEntryAttribute/>
</td> </td>
<td> <td>
<sl-input v-sl-model:newEntryValue/> <sl-input v-sl-model:newEntryValue/>
@ -41,15 +41,15 @@
<h3>Referred to ({{ backlinks.length }})</h3> <h3>Referred to ({{ backlinks.length }})</h3>
<table> <table>
<tr> <tr>
<th>Targets</th> <th>Entities</th>
<th>Key names</th> <th>Attribute names</th>
</tr> </tr>
<tr v-for="[id, entry] in backlinks"> <tr v-for="[id, entry] in backlinks">
<td> <td>
<Address link :address="entry.target"/> <Address link :address="entry.entity"/>
</td> </td>
<td> <td>
{{ entry.key }} {{ entry.attribute }}
</td> </td>
</tr> </tr>
</table> </table>
@ -81,7 +81,7 @@ export default defineComponent({
}, },
data: () => { data: () => {
return { return {
newEntryKey: "", newEntryAttribute: "",
newEntryValue: "" newEntryValue: ""
}; };
}, },
@ -92,16 +92,16 @@ export default defineComponent({
return entries return entries
.sort(([_, a], [__, b]) => a.value.c.localeCompare(b.value.c)) .sort(([_, a], [__, b]) => a.value.c.localeCompare(b.value.c))
.sort(([_, a], [__, b]) => a.value.t.localeCompare(b.value.t)) .sort(([_, a], [__, b]) => a.value.t.localeCompare(b.value.t))
.sort(([_, a], [__, b]) => a.key.localeCompare(b.key)); .sort(([_, a], [__, b]) => a.attribute.localeCompare(b.attribute));
} else { } else {
return []; return [];
} }
}, },
attributes(): [string, IEntry][] { attributes(): [string, IEntry][] {
return this.objectEntries.filter(([_, e]) => e.target === this.address); return this.objectEntries.filter(([_, e]) => e.entity === this.address);
}, },
backlinks(): [string, IEntry][] { backlinks(): [string, IEntry][] {
return this.objectEntries.filter(([_, e]) => e.target !== this.address); return this.objectEntries.filter(([_, e]) => e.entity !== this.address);
} }
}, },
methods: { methods: {
@ -116,8 +116,8 @@ export default defineComponent({
method: "PUT", method: "PUT",
headers: {"Content-Type": "application/json"}, headers: {"Content-Type": "application/json"},
body: JSON.stringify({ body: JSON.stringify({
target: this.address, entity: this.address,
key: this.newEntryKey, attribute: this.newEntryAttribute,
value: { value: {
t: "Value", t: "Value",
c: this.newEntryValue c: this.newEntryValue
@ -127,7 +127,7 @@ export default defineComponent({
await this.mutate(); await this.mutate();
this.newEntryKey = ""; this.newEntryAttribute = "";
this.newEntryValue = ""; this.newEntryValue = "";
} }
}, },