webui: search, download of download working, .gitignore: added linux compile + log files

This commit is contained in:
zeners 2016-01-08 22:16:06 +01:00
parent 7413b32e2d
commit c9d6cb6a07
8 changed files with 302 additions and 44 deletions

8
.gitignore vendored
View File

@ -6,3 +6,11 @@ ui_*.h
Makefile.*
*~
Thumbs.db
Makefile
*/Makefile
*.a
*.prl
*.log
*.so
retroshare-gui/src/RetroShare06
retroshare-nogui/src/RetroShare06-nogui

View File

@ -31,7 +31,7 @@ function progressBar(file){
function cntrlBtn(file, act) {
return(
m("button",{
m("div.btn",{
onclick: function(){
rs.request("transfers/control_download",{action: act, id: file.id});
}
@ -44,35 +44,42 @@ function cntrlBtn(file, act) {
module.exports = {
view: function(){
var paths = rs("transfers/downloads");
var filestreamer_url = "/fstream/";
if (paths === undefined) {
return m("div", "Downloads ... please wait ...");
}
return m("div", [
m("div","Downloads (" + paths.length +")"),
m("hr[style=color:silver]"),
m('table[cellspacing=2][style=padding:2px !important;margin:2px !important;border-spacing: 2px]', [
m("tr[style=font-weight:bold]",[
m("th[style=padding:2px]","name"),
m("th[style=padding:2px]","size"),
m("th[style=padding:2px]","progress"),
m("th[style=padding:2px]","transfer rate"),
m("th[style=padding:2px]","status"),
m("th[style=padding:2px]","progress"),
m("th[style=padding:2px]","action")
m("h2","Downloads (" + paths.length +")"),
m('table', [
m("tr",[
m("th","name"),
m("th","size"),
m("th","progress"),
m("th","transfer rate"),
m("th","status"),
m("th","progress"),
m("th","action")
]),
paths.map(function (file){
var ctrlBtn = m("div","");
var progress = file.transfered / file.size * 100;
return m("tr",[
m("td[style=padding:2px;style=padding: 0.3em;border-style: solid;border-width: 0.1em;border-color: #0F0]", file.name),
m("td[style=padding:2px;style=padding: 0.3em;border-style: solid;border-width: 0.1em;border-color: #0F0]", makeFriendlyUnit(file.size)),
m("td[style=text-align:right;padding:2px;style=padding: 0.3em;border-style: solid;border-width: 0.1em;border-color: #0F0]", progress.toPrecision(3) + "%"),
m("td[style=text-align:right;padding:2px;style=padding: 0.3em;border-style: solid;border-width: 0.1em;border-color: #0F0]", makeFriendlyUnit(file.transfer_rate*1e3)+"/s"),
m("td[style=padding:2px;style=padding: 0.3em;border-style: solid;border-width: 0.1em;border-color: #0F0]", file.download_status),
m("td[style=padding:2px;style=padding: 0.3em;border-style: solid;border-width: 0.1em;border-color: #0F0]", progressBar(file)),
m("td[style=padding:2px;style=padding: 0.3em;border-style: solid;border-width: 0.1em;border-color: #0F0]", [
m("td",[
m("a.filelink",
{
target: "blank",
href: filestreamer_url + file.hash + "/" + encodeURIComponent(file.name)
},
file.name
)
]),
m("td", makeFriendlyUnit(file.size)),
m("td", progress.toPrecision(3) + "%"),
m("td", makeFriendlyUnit(file.transfer_rate*1e3)+"/s"),
m("td", file.download_status),
m("td", progressBar(file)),
m("td", [
cntrlBtn(file, file.download_status==="paused"?"start":"pause"),
m("span"," "),
cntrlBtn(file, "cancel")]
)
])

View File

@ -0,0 +1,144 @@
body {
background-color: black;
color: lime;
font-family: monospace;
margin: 0em;
/*padding: 1.5em;*/
padding: 2mm;
font-size: 1.1em;
}
#overlay{
z-index: 10;
position: fixed;
top:0;
left:0;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.8);
}
.paddingbox{
padding:2mm;
}
.nav{
list-style-type: none;
padding: 0em;
margin: 0em;
}
.nav li{
display: inline;
padding: 0.1em;
margin-right: 1em;
border-width: 0.1em;
border-color: blue;
border-bottom-style: solid;
cursor: pointer;
}
td{
padding: 0.3em;
border-style: solid;
border-width: 0.1em;
border-color: lime;
}
hr {
color: lime;
}
.menu{
border-style: solid;
border-color: lime;
border-width: 0.1em;
cursor: pointer;
padding: 0.0em;
}
.btn{
border-style: solid;
border-color: lime;
border-width: 0.1em;
cursor: pointer;
padding: 0.1em;
}
.btn2, .box{
border-style: solid;
/*border-color: lime;*/
border-color: limeGreen;
/*border-width: 1px;*/
border-radius: 3mm;
padding: 2mm;
font-size: 10mm;
cursor: pointer;
margin-bottom: 2mm;
}
.btn2:hover{
background-color: midnightblue;
}
.filelink{
color: inherit;
}
input, textarea{
color: lime;
font-family: monospace;
background-color: black;
border-color: lime;
font-size: 10mm;
border-radius: 3mm;
border-width: 1mm;
padding: 2mm;
margin-bottom: 2mm;
margin-right: 2mm;
/* make the button the whole screen width */
width: 100%;
/* make the text input fit small screens*/
box-sizing: border-box;
}
input:hover{
background-color: midnightblue;
}
.checkbox {
width: auto;
}
.flexbox{
display: -webkit-box; /* OLD - iOS 6-, Safari 3.1-6 */
display: -moz-box; /* OLD - Firefox 19- (buggy but mostly works) */
display: -ms-flexbox; /* TWEENER - IE 10 */
display: -webkit-flex; /* NEW - Chrome */
display: flex; /* NEW, Spec - Opera 12.1, Firefox 20+ */
}
.flexwidemember{
-webkit-box-flex: 1; /* OLD - iOS 6-, Safari 3.1-6 */
-moz-box-flex: 1; /* OLD - Firefox 19- */
width: 20%; /* For old syntax, otherwise collapses. */
-webkit-flex: 1; /* Chrome */
-ms-flex: 1; /* IE 10 */
flex: 1; /* NEW, Spec - Opera 12.1, Firefox 20+ */
}
#logo_splash{
-webkit-animation-fill-mode: forwards; /* Chrome, Safari, Opera */
animation-fill-mode: forwards;
-webkit-animation-name: logo_splash; /* Chrome, Safari, Opera */
-webkit-animation-duration: 3s; /* Chrome, Safari, Opera */
animation-name: logo_splash;
animation-duration: 3s;
text-align: center;
}
/* Chrome, Safari, Opera */
@-webkit-keyframes logo_splash {
from {opacity: 0;}
to {opacity: 1;}
}
/* Standard syntax */
@keyframes logo_splash {
from {opacity: 0;}
to {opacity: 1;}
}

View File

@ -1,9 +1,12 @@
@import "reset"
/*@import "reset" */
html, body, #main
height: 100%
body
font-family: "Sans-serif"
/*body */
/* font-family: "Sans-serif" */
@import "chat"
@import "green-black"

View File

@ -9,30 +9,45 @@ function goback(){
m.redraw();
}
module.exports = {view: function(){
if (m.route() != "/") {
return m("div", {onclick:function(){m.route("/");}}, "home");
function buildmenu(menu, tagname, runstate, ignore){
if ((menu.runstate === undefined || runstate.match(menu.runstate))
&& (!ignore.match(menu.name))) {
if (menu.action === undefined) {
return m(tagname , {
onclick: function(){
m.route(
menu.path != undefined ? menu.path : "/" + menu.name
)
}
}, menu.name);
} else {
return m(tagname, {onclick: function(){menu.action(rs,m)}}, menu.name);
}
}
}
module.exports = {view: function(){
var runstate = rs("control/runstate");
if (runstate === undefined || runstate.runstate === undefined || runstate.runstate == null)
return m("h2","menu: waiting for server ...");
return m("div.nav","menu: waiting for server ...");
if (m.route() != "/")
return m("span",[
m("span"," | "),
mnodes.nodes.map(function(menu){
var item = buildmenu(menu,"span.menu", runstate.runstate, "");
if (item != null){
return [
item,
m("span"," | ")
]
}
})
]);
return m("div", [
m("h2","menu:"),
m("h2","home"),
m("hr"),
mnodes.nodes.map(function(menu){
if (menu.runstate === undefined || runstate.runstate.match(menu.runstate)){
if (menu.action === undefined) {
return m("div", {
onclick: function(){
m.route(
menu.path != undefined ? menu.path : "/" + menu.name
)
}
}, menu.name);
} else {
return m("div", {onclick: function(){menu.action(rs,m)}}, menu.name);
}
}
return buildmenu(menu,"div.btn2", runstate.runstate, "home");
})
]);
}

View File

@ -12,6 +12,10 @@ module.exports = { nodes: [
name: "peers",
runstate: "running_ok.*",
},
{
name: "search",
runstate: "running_ok.*",
},
{
name: "downloads",
runstate: "running_ok.*",

View File

@ -158,15 +158,19 @@ function requestFail(path, response, value) {
console.log("Error on " + path + (response == null ? ", value " + value : ", response " + response));
}
function rs(path, args, callback){
function rs(path, args, callback, options){
if(cache[path] === undefined){
if (options === undefined){
options = {};
}
var req = {
data: args,
statetoken: undefined,
requested: false,
allow: options.allow === undefined ? "ok" : options.allow,
then: function(response){
console.log(path + ": response: " + response.returncode);
if (response.returncode != "ok") {
if (!allow.match(response.returncode)) {
requestFail(path, response, null);
} else if (callback != undefined && callback != null) {
callback(response.data, response.statetoken);

View File

@ -0,0 +1,73 @@
var m = require("mithril");
var rs = require("retroshare");
var state = {};
var searchText = "";
function updateText(newText) {
searchText = newText;
}
function dosearch(){
console.log("searching for: "+searchText);
rs.request(
"filesearch/create_search", {
distant: true,
search_string: searchText
},
onCreateSearchResponse
);
}
function onCreateSearchResponse(resp){
state={search_id: resp.search_id};
//tracking searchresults
rs("filesearch/"+state.search_id,{},null,{allow:"not_set|ok"});
//todo: route search/id, caching search-resultlists
}
module.exports = {
view: function(){
var results = [];
if (state.search_id != undefined){
var searchresult = rs("filesearch/"+state.search_id);
if (searchresult != undefined) {
results = searchresult;
}
}
return m("div",[
m("p","turtle file search"),
m("div", [
m("input[type=text]", {onchange:m.withAttr("value", updateText)}),
m("input[type=button][value=search]",{onclick:dosearch})
]),
m("table", [
m("tr" ,[
m("th","name"),
m("th","size"),
m("th",""),
]),
results.map(function(file){
return m("tr",[
m("th",file.name),
m("th",file.size),
m("th",[
m("span.btn", {
onclick:function(){
rs.request("transfers/control_download", {
action: "begin",
name: file.name,
size: file.size,
hash: file.hash,
});
}
},
"download")
]),
])
})
])
])
}
}