From 0e6aa33f8ac7b893dae969ec9bfab6daab69e95c Mon Sep 17 00:00:00 2001 From: Bofh Date: Mon, 5 Dec 2022 18:52:23 +0100 Subject: [PATCH] Created minimal UI for profiles loaded in filter --- css/base.php | 20 ++++++++ img/noavatar.png | Bin 0 -> 2897 bytes js/templates/instance/filter-users.html | 38 ++++++++++++--- views/instance.php | 59 +++++++++++++++++++++++- 4 files changed, 108 insertions(+), 9 deletions(-) create mode 100644 img/noavatar.png diff --git a/css/base.php b/css/base.php index f58f3fd..dce2c22 100644 --- a/css/base.php +++ b/css/base.php @@ -51,6 +51,7 @@ body { border-radius: .5em; box-shadow: 0px 0px .5em #0000004f; } +.gray { color: gray } .btn { padding: 1em 3em; border: 1px solid #00000059; @@ -104,6 +105,13 @@ a { color: inherit; } +.software .only { + display: none; +} +.software.mastodon .only.mastodon { + display: inherit !important; +} + /* specific styles */ #window-home { @@ -195,6 +203,18 @@ a { padding: .6em; } } +#window-instance #users-all .item img { + width: 5em; + height: 5em; +} +#window-instance #users-all .item .props { + max-width: 20em; + font-size: .9em; + margin-top: .5em; +} +#window-instance #users-all .item .props > span { + margin-right: 1em; +} #window-instance_config { background: ; diff --git a/img/noavatar.png b/img/noavatar.png new file mode 100644 index 0000000000000000000000000000000000000000..781370782ecf61f63f882639a74c3d1fc7474772 GIT binary patch literal 2897 zcmaKu`9BkmAIBY&nK?r4`zUJ0hh&7d*&I#eoHLP(h^P^{Z$*)njA=1M$mBj&Ls}tc zhn!mzLxqnapYZMT{R2MF$K(BYzaH<`3FB zpJ@YAV^a&g!!z`usfJe{syoKYTZW%?jaRmh*3l-&O+$AnJ(-WYlZ)Ep9<-D+3_N)D z=9`;J6b}!m(H4bpxyidq|BIK02f(9GPQ0vDGR60&|Gy{=;I96Nz^VXS%HUEN7{?y9 zYCQhnG%2R&{neyrJ6FlQdU(p}KlV*$ozYFZ+yTtw!R|uw?j>OG8WDftb_Uczh(mfE zVg*8f0O|CfhJwy{ER94(t~mzA#e1SMhaXu?c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iZaAozrG?cIk6ZD(EY2nQ zn%LR%HM<%nyeGA|ccP<`>H??DNj)ly$aqIdi-+u2D~*pUWQZ>}iqAxk45bUSJNXt& zJU3JIEurZj%{{blK@M7J^T`fR#-8+4B={(OlD;W%eBvLv1eEP#1 z&r1=5YgZ1XOMX1*V4^H&-^xWiQ+mG|qbtAY-F$l4)JzFGf;&oD&(gW6WyI?GHAoTB zDkU_|vam+a{Wo_=TsJ1#L_S7Dw=AtH1FN5h%o#!P>xHd8MdbidGYm{fHW-ywVJxCo zTWJhpl~hKLj|ptlr@_AR#mmY-^P&&2a;h9U(}mfo>97h8ru$klgLp({>1DP|W7Pq; zFFS>XH`ntoneG-jw&Rh}TQnP4BP!Y_npN573K zv3_~i?#PEqcLH=HZKyQURtFu}1DDz76PGUla!tTVoY`pAK8<3 zr)L#aTZ@%(1*zN^=EQb6T1m8%$sSF;GE;N^Xz5_{Pu`kd4RM|)cOKkYT3GFzf4xKC zcFhMc`^8R4KS#L+8($f&-u(W!jxyu`xF;!6wE@!(XvGhvPk0evqgknwow^$Q8>#Cs zY($y)-58C`t>UfDCvZD@b`;F@kWj!Df5CZEl!v_wGiO{g+?wWst?XsW+?I?%Jw4%E zwtl>XHmelDAt_@YVPY8VBLwL}ZTsTTtCJrNLUr4dIY+@SoDbRxn`tN%^1sc zz}6~#phQ>&w+}v$_hWJdO77PeDM>SdKXeH;&?JL1%WUtts&++=Lqy^n0OKE zi(sw->u{gpZ6Wb{6KnCNS(!DDIS2E$s&%P1Yj;s5_P83)aWU0nYY0ZNhf^(pyX*?$AJXnRyW@?y&W0G3~6ApigX literal 0 HcmV?d00001 diff --git a/js/templates/instance/filter-users.html b/js/templates/instance/filter-users.html index 3c44c2b..5a44866 100644 --- a/js/templates/instance/filter-users.html +++ b/js/templates/instance/filter-users.html @@ -1,3 +1,34 @@ + +

Results:

+
+

+
+ + + {current_page} / {total_pages} +
+
+
+
+
+ +
+ {name} +
+ @{acct} +
+ {statuses}
statuses
+ {following}
following
+ {followers}
followers
+
+
+
+
{mastodon:fields}
+
+
+
+
+

*New filter:

@@ -73,10 +104,3 @@
-
-
-
-
- {name} -
-
diff --git a/views/instance.php b/views/instance.php index 60d455c..9093987 100644 --- a/views/instance.php +++ b/views/instance.php @@ -103,7 +103,7 @@ window.view.instance = { } //else // TODO: load the filter by API }, - execute: function() { + execute: function(page, items_per_page) { const btn = E.elemid('btncollapse-filters-current'); if (btn.innerText.trim() === 'hide') btn.click(); const btn2 = E.elemid('btncollapse-filters-all'); @@ -114,7 +114,62 @@ window.view.instance = { var payload = data; payload.instance = hargs.instance; payload = JSON_to_URLEncoded(payload); - http.get(`api/v1/database/${hargs.software}/accounts/search?${payload}`, data, function(js) { + + page = page === undefined ? 1 : page; + items_per_page = items_per_page === undefined ? 10 : items_per_page; + if (page === 'null') return; + if (page < 0) page = 0; + page--; + + http.get(`api/v1/database/${hargs.software}/accounts/search?${payload}&paging=${page},${items_per_page}`, data, function(js) { + console.log(typeof js); + if (js === undefined) return; // TODO: handle error here + E.template('users-all', function(TPL) { + var html = ''; + for (var i = 0; i < js['data'].length; i++) { + var tpl = TPL; + const it = js['data'][i]; + tpl = tpl.replaceAll('{software}', hargs.software); + tpl = tpl.replaceAll('{name}', html2text(it.acct)); + tpl = tpl.replaceAll('{acct}', html2text(it.acct)); + if (it.avatar === null) + it.avatar = 'img/noavatar.png'; + tpl = tpl.replaceAll('{avatar}', it.avatar); + tpl = tpl.replaceAll('{statuses}', it.statuses); + tpl = tpl.replaceAll('{following}', it.following); + tpl = tpl.replaceAll('{followers}', it.followers); + if (hargs.software === 'mastodon' && it.fields !== undefined) { + var _fields = ''; + for (var j = 0; j < it.fields.length; j++) { + var t = ''; + t = t.replaceAll('{name}', it.fields[j].name); + t = t.replaceAll('{value}', it.fields[j].value); + t = t.replaceAll('{verified}', it.fields[j].verified_at !== undefined ? 'verified' : ''); + _fields += t; + } + _fields += '
{name}{value}
'; + tpl = tpl.replaceAll('{mastodon:fields}', _fields); + } + html += tpl; + } + return html; + }); + E.template('paging', function(TPL) { + var html = ''; + var tpl = TPL; + js['paging']['total_pages']++; page++; + var prevpage = page; + if (page > 0) prevpage--; + var nextpage = page+1; + if (page > js['paging']['total_pages']) + nextpage = js['paging']['total_pages']; + tpl = tpl.replaceAll('{current_page}', page); + tpl = tpl.replaceAll('{prev_page}', prevpage); + tpl = tpl.replaceAll('{next_page}', nextpage); + tpl = tpl.replaceAll('{items_per_page}', items_per_page); + tpl = tpl.replaceAll('{total_pages}', js['paging']['total_pages']); + return tpl; + }); console.log(js); }); },