webui: List forums, sort friends

This commit is contained in:
zeners 2016-02-20 18:03:27 +01:00
parent 34957b857a
commit fdb93c3f8d
7 changed files with 160 additions and 58 deletions

View File

@ -34,11 +34,11 @@ TODO
[ ] make stylesheets or find reusable sass/css components
google material design has nice rules for color, spacing and everything: https://www.google.de/design/spec/material-design/introduction.html
[ ] find icons, maybe use google material design iconfont
[ ] use urls/mithril routing for the menu. urls could replace state stored in rs.content
[ ] drag and drop private key upload and import
[X] use urls/mithril routing for the menu. urls could replace state stored in rs.content
[X] drag and drop private key upload and import
[ ] link from peer location to chat (use urls and mithril routing)
[ ] add/remove friend, own cert
[ ] downloads, search
[X] add/remove friend, own cert
[X] downloads, search
[ ] make reusable infinite list controller, the js part to load data from Pagination.h (tweak Pagination.h to make everything work)
should provide forward, backward and follow-list-end
[ ] backend: view/create identities
@ -49,4 +49,4 @@ should provide forward, backward and follow-list-end
[ ] backend: edit shared folders
[ ] backend: view shared files
[ ] redirect if a url is not usable in the current runstate (e.g. redirect from login page to home page, after login)
[ ] sort friendslist
[X] sort friendslist

View File

@ -117,7 +117,13 @@ function lobby(lobbyid){
module.exports = {
frame: function(content, right){
return m(".chat.container", [
m(".chat.header", "headerbar"),
m(".chat.header", [
m(
"h2",
{style:{margin:"0px"}},
"chat"
)
]),
m(".chat.left", [
m("div.chat.header[style=position:relative]","lobbies:"),
m("br"),
@ -136,7 +142,11 @@ module.exports = {
);
};
return this.frame(
m("div", "please select lobby"),
m(
"div",
{style: {margin:"10px"}},
"please select lobby"
),
m("div","right"));
}
}

View File

@ -0,0 +1,64 @@
"use strict";
var m = require("mithril");
var rs = require("retroshare");
module.exports = {view: function(){
return m("div",[
m("h2","forums"),
m("hr"),
/*
m("div.btn2", {
onclick: function (){
m.route("/addforum");
}
},"< create new forum >"),
*/
m("ul",
rs.list("forums",
function(item){
return m("li",[
m("h2",item.name),
m("div",{style:{margin:"10px"}},
[
item.description != ""
? [
m("span", "Description: "
+ item.description),
m("br")]
: [],
m("span","messages visible: "
+ item.visible_msg_count),
]
),
/*
item.subscribed
? [
m(
"span.btn2",
{style:{padding:"0px"}},
"unsubscribe"
),
" ",
m(
"span.btn2",
{style:{padding:"0px", margin:"10px"}},
"enter"
),
m("hr", {style: {color:"silver"}}),
]
: [
m(
"span.btn2",
{style:{padding:"0px", margin:"10px"}},
"subscribe"
),
]
*/
]);
},
rs.sort("name")
)
)
]);
}}

View File

@ -15,7 +15,8 @@ module.exports = {view: function(){
m("ul",
rs.list("identity/own", function(item){
return m("li",[m("h2",item.name)]);
})
},
rs.sort("name"))
)
]);
}}

View File

@ -63,6 +63,10 @@ module.exports = { nodes: [
runstate: "running_ok.*",
counter: rs.counting("transfers/downloads")
},
{
name: "forums",
runstate: "running_ok.*",
},
{
name: "chat",
runstate: "running_ok.*",

View File

@ -14,6 +14,7 @@ module.exports = {view: function(){
m("h3","waiting_server"),
]);
};
peers = peers.sort(rs.sort("name"));
//building peerlist (prebuild for counting)
var online = 0;

View File

@ -280,16 +280,19 @@ rs.counting = function(path, counterfnkt) {
}
return "";
}
}
};
// listing data-elements
rs.list = function(path, buildfktn){
rs.list = function(path, buildfktn, sortfktn){
var list = rs(path);
if (list === undefined|| list == null) {
return "< waiting for server ... >"
};
if (sortfktn != undefined && sortfktn != null) {
list=list.sort(sortfktn);
}
return list.map(buildfktn);
}
};
//remember additional data (feature of last resort)
rs.memory = function(path, args){
@ -304,3 +307,22 @@ rs.memory = function(path, args){
return item.memory;
};
//return sorting-function for string, based on property name
//using: list.sort(rs.sort("name"));
// -----
//innersort: cascading sorting - using:
//list.sort(rs.sort("type",rs.sort("name")))
rs.sort = function(name, innersort){
return function(a,b){
if (a[name].toLowerCase() == b[name].toLowerCase()) {
if (innersort === undefined) {
return 0
}
return innersort(a,b);
} else if (a[name].toLowerCase() < b[name].toLowerCase()) {
return -1
} else {
return 1
}
}
}