You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@warble.apache.org by hu...@apache.org on 2018/06/26 23:46:23 UTC

[incubator-warble-server] 01/02: allow editing the node location field in the UI

This is an automated email from the ASF dual-hosted git repository.

humbedooh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-warble-server.git

commit c0e4b8bf6956808b3750edfd8929de064c0b64b3
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Tue Jun 26 18:46:13 2018 -0500

    allow editing the node location field in the UI
---
 ui/js/coffee/warble_clientlist.coffee | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/ui/js/coffee/warble_clientlist.coffee b/ui/js/coffee/warble_clientlist.coffee
index 2b0ecee..4119d0c 100644
--- a/ui/js/coffee/warble_clientlist.coffee
+++ b/ui/js/coffee/warble_clientlist.coffee
@@ -49,6 +49,27 @@ modifyNode = (id, stats) ->
 deleteNode = (id, stats) ->
     xdelete('node/modify', {id: id}, {}, location.reload())
 
+nodeLocation = (id, obj) ->
+    if not document.getElementById("tnodeloc_#{id}")
+        loc = obj.innerText
+        obj.innerHTML = ""
+        ip = mk('input', {data: loc, id: "tnodeloc_#{id}", type: 'text', onkeydown: "saveNodeLocation(#{id}, this, event);"})
+        app(obj, ip)
+        ip.focus()
+    
+
+saveNodeLocation = (id, obj, e) ->
+    if e.key == 'Enter'
+        nloc = obj.value
+        post('node/modify', { id: id, location: nloc}, {id: id, location: nloc}, savedNodeLocation)
+    else if e.key == 'Escape'
+        savedNodeLocation({}, {id: id, location: obj.getAttribute('data')})
+
+savedNodeLocation = (json, state) ->
+    obj = document.getElementById("nodeloc_#{state.id}")
+    obj.innerHTML = ""
+    app(obj, txt(state.location))
+    
 clientlist = (json, state) ->
     
     slist = mk('div')
@@ -98,10 +119,13 @@ clientlist = (json, state) ->
             app(d, t)
             
             # node location
-            t = mk('td')
+            t = mk('td', {id: "nodeloc_#{source.id}", onclick: "nodeLocation(#{source.id}, this, event);"})
             app(t, txt(source.location||"(unknown)"))
             app(d, t)
             
+            
+            
+            
             # node verified?
             t = mk('td')
             t.style.color = if source.verified then "#393" else '#942'


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@warble.apache.org
For additional commands, e-mail: commits-help@warble.apache.org