Skip to content

Commit 20adcce

Browse files
committed
Remove default tags, add configurable featured line
1 parent 1e6e241 commit 20adcce

File tree

9 files changed

+145
-43
lines changed

9 files changed

+145
-43
lines changed

sist2-vue/src/Sist2Api.ts

-24
Original file line numberDiff line numberDiff line change
@@ -191,30 +191,6 @@ class Sist2Api {
191191
setHitTags(hit: EsHit): void {
192192
const tags = [] as Tag[];
193193

194-
const mimeCategory = hit._source.mime == null ? null : hit._source.mime.split("/")[0];
195-
196-
switch (mimeCategory) {
197-
case "image":
198-
case "video":
199-
if ("videoc" in hit._source && hit._source.videoc) {
200-
tags.push({
201-
style: "video",
202-
text: hit._source.videoc.replace(" ", ""),
203-
userTag: false
204-
} as Tag);
205-
}
206-
break
207-
case "audio":
208-
if ("audioc" in hit._source && hit._source.audioc) {
209-
tags.push({
210-
style: "audio",
211-
text: hit._source.audioc,
212-
userTag: false
213-
} as Tag);
214-
}
215-
break;
216-
}
217-
218194
// User tags
219195
if ("tag" in hit._source) {
220196
hit._source.tag.forEach(tag => {

sist2-vue/src/components/DocCard.vue

+7-5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@
2727
<DocFileTitle :doc="doc"></DocFileTitle>
2828
</div>
2929

30+
<!-- Featured line -->
31+
<div style="display: flex">
32+
<FeaturedFieldsLine :doc="doc"></FeaturedFieldsLine>
33+
</div>
34+
3035
<!-- Tags -->
3136
<div class="card-text">
3237
<TagContainer :hit="doc"></TagContainer>
@@ -43,10 +48,11 @@ import DocFileTitle from "@/components/DocFileTitle.vue";
4348
import DocInfoModal from "@/components/DocInfoModal.vue";
4449
import ContentDiv from "@/components/ContentDiv.vue";
4550
import FullThumbnail from "@/components/FullThumbnail";
51+
import FeaturedFieldsLine from "@/components/FeaturedFieldsLine";
4652
4753
4854
export default {
49-
components: {FullThumbnail, ContentDiv, DocInfoModal, DocFileTitle, TagContainer},
55+
components: {FeaturedFieldsLine, FullThumbnail, ContentDiv, DocInfoModal, DocFileTitle, TagContainer},
5056
props: ["doc", "width"],
5157
data() {
5258
return {
@@ -133,8 +139,4 @@ export default {
133139
.sub-document .fit {
134140
padding: 4px 4px 0 4px;
135141
}
136-
137-
.featured-line {
138-
font-size: 92%;
139-
}
140142
</style>

sist2-vue/src/components/DocListItem.vue

+7-1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@
5050
<span v-if="doc._source.author && doc._source.pages" class="mx-1">-</span>
5151
<span v-if="doc._source.author">{{ doc._source.author }}</span>
5252
</div>
53+
54+
<!-- Featured line -->
55+
<div style="display: flex">
56+
<FeaturedFieldsLine :doc="doc"></FeaturedFieldsLine>
57+
</div>
5358
</div>
5459
</div>
5560
</b-list-group-item>
@@ -61,10 +66,11 @@ import DocFileTitle from "@/components/DocFileTitle";
6166
import DocInfoModal from "@/components/DocInfoModal";
6267
import ContentDiv from "@/components/ContentDiv";
6368
import FileIcon from "@/components/icons/FileIcon";
69+
import FeaturedFieldsLine from "@/components/FeaturedFieldsLine";
6470
6571
export default {
6672
name: "DocListItem",
67-
components: {FileIcon, ContentDiv, DocInfoModal, DocFileTitle, TagContainer},
73+
components: {FileIcon, ContentDiv, DocInfoModal, DocFileTitle, TagContainer, FeaturedFieldsLine},
6874
props: ["doc"],
6975
data() {
7076
return {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<template>
2+
<div class="featured-line" v-html="featuredLineHtml"></div>
3+
</template>
4+
5+
<script>
6+
import {humanDate, humanFileSize} from "@/util";
7+
8+
function scopedEval(context, expr) {
9+
const evaluator = Function.apply(null, [...Object.keys(context), "expr", "return eval(expr)"]);
10+
return evaluator.apply(null, [...Object.values(context), expr]);
11+
}
12+
13+
14+
export default {
15+
name: "FeaturedFieldsLine",
16+
props: ["doc"],
17+
computed: {
18+
featuredLineHtml() {
19+
const scope = {doc: this.doc._source, humanDate: humanDate, humanFileSize: humanFileSize};
20+
21+
return this.$store.getters.optFeaturedFields
22+
.replaceAll(/\$\{([^}]*)}/g, (match, g1) => {
23+
return scopedEval(scope, g1);
24+
});
25+
}
26+
}
27+
}
28+
</script>
29+
30+
<style scoped>
31+
32+
.featured-line {
33+
font-size: 90%;
34+
font-family: 'Source Sans Pro', 'Helvetica Neue', Arial, sans-serif;
35+
color: #424242;
36+
padding-left: 2px;
37+
}
38+
39+
.theme-black .featured-line {
40+
color: #bebebe;
41+
}
42+
</style>

sist2-vue/src/components/TagContainer.vue

+4-3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040

4141

4242
<template v-for="tag in hit._tags">
43+
<!-- User tag-->
4344
<div v-if="tag.userTag" :key="tag.rawText" style="display: inline-block">
4445
<span
4546
:id="hit._id+tag.rawText"
@@ -51,7 +52,7 @@
5152
>{{ tag.text.split(".").pop() }}</span>
5253

5354
<b-popover :target="hit._id+tag.rawText" triggers="focus blur" placement="top">
54-
<b-button variant="danger" @click="onTagDeleteClick(tag, $event)">{{$t("deleteTag")}}</b-button>
55+
<b-button variant="danger" @click="onTagDeleteClick(tag, $event)">{{ $t("deleteTag") }}</b-button>
5556
</b-popover>
5657
</div>
5758

@@ -66,7 +67,7 @@
6667
<small v-if="showAddButton" class="badge add-tag-button" @click="tagAdd()">{{$t("addTag")}}</small>
6768

6869
<!-- Size tag-->
69-
<small v-else class="text-muted badge-size">{{
70+
<small v-else class="text-muted badge-size" style="padding-left: 2px">{{
7071
humanFileSize(hit._source.size)
7172
}}</small>
7273
</div>
@@ -211,7 +212,7 @@ export default Vue.extend({
211212
212213
return matches.sort().map(match => {
213214
return {
214-
title: match.split(".").slice(0,-1).join("."),
215+
title: match.split(".").slice(0, -1).join("."),
215216
id: match
216217
}
217218
});

sist2-vue/src/i18n/messages.ts

+20-8
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default {
88
advanced: "Advanced search",
99
fuzzy: "Fuzzy"
1010
},
11-
addTag: "Add",
11+
addTag: "Tag",
1212
deleteTag: "Delete",
1313
download: "Download",
1414
and: "and",
@@ -17,6 +17,7 @@ export default {
1717
mimeTypes: "Media types",
1818
tags: "Tags",
1919
tagFilter: "Filter tags",
20+
forExample: "For example:",
2021
help: {
2122
simpleSearch: "Simple search",
2223
advancedSearch: "Advanced search",
@@ -75,7 +76,9 @@ export default {
7576
useDatePicker: "Use a Date Picker component rather than a slider",
7677
vidPreviewInterval: "Video preview frame duration in ms",
7778
simpleLightbox: "Disable animations in image viewer",
78-
showTagPickerFilter: "Display the tag filter bar"
79+
showTagPickerFilter: "Display the tag filter bar",
80+
featuredFields: "Featured fields Javascript template string. Will appear in the search results.",
81+
featuredFieldsList: "Available variables"
7982
},
8083
queryMode: {
8184
simple: "Simple",
@@ -178,7 +181,7 @@ export default {
178181
advanced: "Erweiterte Suche",
179182
fuzzy: "Fuzzy"
180183
},
181-
addTag: "Hinzufügen",
184+
addTag: "Tag",
182185
deleteTag: "Löschen",
183186
download: "Herunterladen",
184187
and: "und",
@@ -187,6 +190,7 @@ export default {
187190
mimeTypes: "Medientypen",
188191
tags: "Tags",
189192
tagFilter: "Tags filtern",
193+
forExample: "Zum Beispiel:",
190194
help: {
191195
simpleSearch: "Einfache Suche",
192196
advancedSearch: "Erweiterte Suche",
@@ -245,7 +249,9 @@ export default {
245249
useDatePicker: "Benutze Datumswähler statt Schieber",
246250
vidPreviewInterval: "Videovorschau Framedauer in ms",
247251
simpleLightbox: "Schalte Animationen im Image-Viewer ab",
248-
showTagPickerFilter: "Zeige die Tag-Filter-Leiste"
252+
showTagPickerFilter: "Zeige die Tag-Filter-Leiste",
253+
featuredFields: "Ausgewählte Felder Javascript Vorlage String. Wird in den Suchergebnissen angezeigt.",
254+
featuredFieldsList: "Verfügbare Variablen"
249255
},
250256
queryMode: {
251257
simple: "Einfach",
@@ -348,7 +354,7 @@ export default {
348354
advanced: "Recherche avancée",
349355
fuzzy: "Approximatif"
350356
},
351-
addTag: "Ajouter",
357+
addTag: "Taguer",
352358
deleteTag: "Supprimer",
353359
download: "Télécharger",
354360
and: "et",
@@ -357,6 +363,7 @@ export default {
357363
mimeTypes: "Types de médias",
358364
tags: "Tags",
359365
tagFilter: "Filtrer les tags",
366+
forExample: "Par exemple:",
360367
help: {
361368
simpleSearch: "Recherche simple",
362369
advancedSearch: "Recherche avancée",
@@ -416,7 +423,9 @@ export default {
416423
useDatePicker: "Afficher un composant « Date Picker » plutôt qu'un slider",
417424
vidPreviewInterval: "Durée des images d'aperçu video en millisecondes",
418425
simpleLightbox: "Désactiver les animations du visualiseur d'images",
419-
showTagPickerFilter: "Afficher le filtre dans l'onglet Tags"
426+
showTagPickerFilter: "Afficher le filtre dans l'onglet Tags",
427+
featuredFields: "Expression Javascript pour les variables mises en évidence. Sera affiché dans les résultats de recherche.",
428+
featuredFieldsList: "Variables disponibles"
420429
},
421430
queryMode: {
422431
simple: "Simple",
@@ -520,7 +529,7 @@ export default {
520529
advanced: "高级搜索",
521530
fuzzy: "模糊搜索"
522531
},
523-
addTag: "添加",
532+
addTag: "签条",
524533
deleteTag: "删除",
525534
download: "下载",
526535
and: "与",
@@ -529,6 +538,7 @@ export default {
529538
mimeTypes: "文件类型",
530539
tags: "标签",
531540
tagFilter: "筛选标签",
541+
forExample: "例如:",
532542
help: {
533543
simpleSearch: "简易搜索",
534544
advancedSearch: "高级搜索",
@@ -587,7 +597,9 @@ export default {
587597
useDatePicker: "使用日期选择器组件而不是滑块",
588598
vidPreviewInterval: "视频预览帧的持续时间,以毫秒为单位",
589599
simpleLightbox: "在图片查看器中,禁用动画",
590-
showTagPickerFilter: "显示标签过滤栏"
600+
showTagPickerFilter: "显示标签过滤栏",
601+
featuredFields: "特色领域的Javascript模板字符串。将出现在搜索结果中。",
602+
featuredFieldsList: "可利用的变量"
591603
},
592604
queryMode: {
593605
simple: "简单",

sist2-vue/src/store/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export default new Vuex.Store({
3333
optHideDuplicates: true,
3434
optTheme: "light",
3535
optDisplay: "grid",
36+
optFeaturedFields: "",
3637

3738
optSize: 60,
3839
optHighlight: true,
@@ -158,6 +159,7 @@ export default new Vuex.Store({
158159
setOptQueryMode: (state, val) => state.optQueryMode = val,
159160
setOptResultSize: (state, val) => state.optSize = val,
160161
setOptTagOrOperator: (state, val) => state.optTagOrOperator = val,
162+
setOptFeaturedFields: (state, val) => state.optFeaturedFields = val,
161163

162164
setOptTreemapType: (state, val) => state.optTreemapType = val,
163165
setOptTreemapTiling: (state, val) => state.optTreemapTiling = val,
@@ -413,5 +415,6 @@ export default new Vuex.Store({
413415
optVidPreviewInterval: state => state.optVidPreviewInterval,
414416
optSimpleLightbox: state => state.optSimpleLightbox,
415417
optShowTagPickerFilter: state => state.optShowTagPickerFilter,
418+
optFeaturedFields: state => state.optFeaturedFields,
416419
}
417420
})

sist2-vue/src/views/Configuration.vue

+61-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616

1717
<b-card>
1818

19-
<label><LanguageIcon/><span style="vertical-align: middle">&nbsp;{{ $t("opt.lang") }}</span></label>
19+
<label>
20+
<LanguageIcon/>
21+
<span style="vertical-align: middle">&nbsp;{{ $t("opt.lang") }}</span></label>
2022
<b-form-select :options="langOptions" :value="optLang" @input="setOptLang"></b-form-select>
2123

2224
<label>{{ $t("opt.theme") }}</label>
@@ -55,6 +57,62 @@
5557
$t("opt.showTagPickerFilter")
5658
}}
5759
</b-form-checkbox>
60+
61+
<br/>
62+
<label>{{ $t("opt.featuredFields") }}</label>
63+
64+
<br>
65+
<b-button v-b-toggle.collapse-1 variant="secondary" class="dropdown-toggle">{{
66+
$t("opt.featuredFieldsList")
67+
}}
68+
</b-button>
69+
<b-collapse id="collapse-1" class="mt-2">
70+
<ul>
71+
<li><code>doc.checksum</code></li>
72+
<li><code>doc.path</code></li>
73+
<li><code>doc.mime</code></li>
74+
<li><code>doc.videoc</code></li>
75+
<li><code>doc.audioc</code></li>
76+
<li><code>doc.pages</code></li>
77+
<li><code>doc.mtime</code></li>
78+
<li><code>doc.font_name</code></li>
79+
<li><code>doc.album</code></li>
80+
<li><code>doc.artist</code></li>
81+
<li><code>doc.title</code></li>
82+
<li><code>doc.genre</code></li>
83+
<li><code>doc.album_artist</code></li>
84+
<li><code>doc.exif_make</code></li>
85+
<li><code>doc.exif_model</code></li>
86+
<li><code>doc.exif_software</code></li>
87+
<li><code>doc.exif_exposure_time</code></li>
88+
<li><code>doc.exif_fnumber</code></li>
89+
<li><code>doc.exif_iso_speed_ratings</code></li>
90+
<li><code>doc.exif_focal_length</code></li>
91+
<li><code>doc.exif_user_comment</code></li>
92+
<li><code>doc.exif_user_comment</code></li>
93+
<li><code>doc.exif_gps_longitude_ref</code></li>
94+
<li><code>doc.exif_gps_longitude_dms</code></li>
95+
<li><code>doc.exif_gps_longitude_dec</code></li>
96+
<li><code>doc.exif_gps_latitude_ref</code></li>
97+
<li><code>doc.exif_gps_latitude_dec</code></li>
98+
<li><code>humanDate()</code></li>
99+
<li><code>humanFileSize()</code></li>
100+
</ul>
101+
102+
<p>{{ $t("forExample") }}</p>
103+
104+
<ul>
105+
<li>
106+
<code>&lt;b&gt;${humanDate(doc.mtime)}&lt;/b&gt; • ${doc.videoc || ''}</code>
107+
</li>
108+
<li>
109+
<code>${doc.pages ? (doc.pages + ' pages') : ''}</code>
110+
</li>
111+
</ul>
112+
</b-collapse>
113+
<br/>
114+
<br/>
115+
<b-textarea rows="3" :value="optFeaturedFields" @input="setOptFeaturedFields"></b-textarea>
58116
</b-card>
59117

60118
<br/>
@@ -252,6 +310,7 @@ export default {
252310
"optVidPreviewInterval",
253311
"optSimpleLightbox",
254312
"optShowTagPickerFilter",
313+
"optFeaturedFields",
255314
]),
256315
clientWidth() {
257316
return window.innerWidth;
@@ -295,6 +354,7 @@ export default {
295354
"setOptVidPreviewInterval",
296355
"setOptSimpleLightbox",
297356
"setOptShowTagPickerFilter",
357+
"setOptFeaturedFields",
298358
]),
299359
onResetClick() {
300360
localStorage.removeItem("sist2_configuration");

0 commit comments

Comments
 (0)