dynamic image url for searchresults

This commit is contained in:
cgfhtw
2024-10-14 11:20:46 +02:00
parent 7174f9cbe0
commit 322544c7fb
6 changed files with 19 additions and 36 deletions
+12 -3
View File
@@ -74,7 +74,10 @@ $config['person'] = [
"p.person_id",
"(p.vorname || ' ' || p.nachname) AS name",
"ARRAY( SELECT kontakt FROM public.tbl_kontakt WHERE kontakttyp = 'email' AND person_id=p.person_id ) AS email",
"p.foto"
"CASE
WHEN p.foto IS NOT NULL THEN 'data:image/jpeg' || CONVERT_FROM(DECODE('3b','hex'), 'UTF8') || 'base64,' || p.foto
ELSE NULL END
AS photo_url"
],
'resultjoin' => "
JOIN public.tbl_person p USING (person_id)
@@ -200,7 +203,10 @@ $config['student'] = [
"p.person_id",
"(p.vorname || ' ' || p.nachname) AS name",
"ARRAY( SELECT kontakt FROM public.tbl_kontakt WHERE kontakttyp = 'email' AND person_id=p.person_id ) AS email",
"p.foto"
"CASE
WHEN p.foto IS NOT NULL THEN 'data:image/jpeg' || CONVERT_FROM(DECODE('3b','hex'), 'UTF8') || 'base64,' || p.foto
ELSE NULL END
AS photo_url"
],
'resultjoin' => "
JOIN public.tbl_student s USING (student_uid)
@@ -298,7 +304,10 @@ $config['prestudent'] = [
"b.uid",
"(p.vorname || ' ' || p.nachname) AS name",
"ARRAY( SELECT kontakt FROM public.tbl_kontakt WHERE kontakttyp = 'email' AND person_id=p.person_id ) AS email",
"p.foto",
"CASE
WHEN p.foto IS NOT NULL THEN 'data:image/jpeg' || CONVERT_FROM(DECODE('3b','hex'), 'UTF8') || 'base64,' || p.foto
ELSE NULL END
AS photo_url",
"UPPER(sg.typ || sg.kurzbz) AS stg_kuerzel",
"sg.bezeichnung",
"(
-1
View File
@@ -228,7 +228,6 @@ class SearchBarLib
GROUP BY " . $table_config['primarykey'] . "
)";
$other_selects =
$selects[] = "
SELECT
" . $this->_ci->db->escape($type) . " AS type,
@@ -20,8 +20,9 @@ export default {
if (person.length)
return person.pop();
const { person_id, name, foto, photo_url, email } = this.res.list[0];
return { person_id, name, foto, photo_url, email };
// TODO(chris): first one might have not one of these but a later one
const { person_id, name, photo_url, email } = this.res.list[0];
return { person_id, name, photo_url, email };
},
employee() {
const ma = this.res.list.filter(item => [
@@ -34,11 +35,6 @@ export default {
const students = this.res.list.filter(item => item.type == 'prestudent');
return students.length ? students : null;
},
foto() {
if (this.person.foto)
return 'data:image/jpeg;base64,' + this.person.foto;
return this.person.photo_url;
},
emails() {
if (Array.isArray(this.person.email))
return this.person.email;
@@ -51,7 +47,7 @@ export default {
:res="person"
:actions="actions"
:title="person.name"
:image="foto"
:image="this.person.photo_url"
image-fallback="fas fa-user-circle fa-7x"
@actionexecuted="$emit('actionexecuted')"
>
@@ -9,20 +9,13 @@ export default {
res: Object,
actions: Object
},
computed: {
foto() {
if (this.res.foto)
return 'data:image/jpeg;base64,' + this.res.foto;
return null;
}
},
template: `
<template-frame
class="searchbar-result-student"
:res="res"
:actions="actions"
:title="res.name"
:image="foto"
:image="res.photo_url"
image-fallback="fas fa-user-circle fa-7x"
@actionexecuted="$emit('actionexecuted')"
>
@@ -9,20 +9,13 @@ export default {
res: Object,
actions: Object
},
computed: {
foto() {
if (this.res.foto)
return 'data:image/jpeg;base64,' + this.res.foto;
return null;
}
},
template: `
<template-frame
class="searchbar-result-prestudent"
:res="res"
:actions="actions"
:title="res.name + ' (' + res.status + ' ' + res.stg_kuerzel + ')'"
:image="foto"
:image="res.photo_url"
image-fallback="fas fa-user-circle fa-7x"
@actionexecuted="$emit('actionexecuted')"
>
@@ -9,20 +9,13 @@ export default {
res: Object,
actions: Object
},
computed: {
foto() {
if (this.res.foto)
return 'data:image/jpeg;base64,' + this.res.foto;
return null;
}
},
template: `
<template-frame
class="searchbar-result-student"
:res="res"
:actions="actions"
:title="res.name"
:image="foto"
:image="res.photo_url"
image-fallback="fas fa-user-circle fa-7x"
@actionexecuted="$emit('actionexecuted')"
>