diff --git a/src/ui/ab.tis b/src/ui/ab.tis new file mode 100644 index 000000000..5aaa9b881 --- /dev/null +++ b/src/ui/ab.tis @@ -0,0 +1,171 @@ +var svg_tile = ; +var svg_list = ; + +function getSessionsStyleOption(type) { + return (type || "recent") + "-sessions-style"; +} + +function getSessionsStyle(type) { + var v = handler.get_option(getSessionsStyleOption(type)); + if (!v) v = type == "ab" ? "list" : "tile"; + return v; +} + +function stupidUpdate(me) { + /* hidden is workaround of stupid sciter bug */ + me.hidden = true; + me.update(); + self.timer(60ms, function() { + me.hidden = false; + me.update(); + }); +} + +class SessionStyle: Reactor.Component { + this var type = ""; + + function this(params) { + this.type = (params || {}).type; + } + + function render() { + var sessionsStyle = getSessionsStyle(this.type); + return
+ {svg_tile} + {svg_list} +
; + } + + event click $(span.inactive) { + var option = getSessionsStyleOption(this.type); + var sessionsStyle = getSessionsStyle(this.type); + handler.set_option(option, sessionsStyle == "tile" ? "list" : "tile"); + stupidUpdate(app); + } +} + +class SessionList: Reactor.Component { + this var sessions = []; + this var type = ""; + this var style; + + function this(params) { + this.sessions = params.sessions; + this.type = params.type; + this.style = getSessionsStyle(params.type); + } + + function render() { + var sessions = this.sessions; + if (sessions.length == 0) return ; + var me = this; + sessions = sessions.map(function(x) { return me.getSession(x); }); + return
+ + +
  • {translate('Connect')}
  • +
  • {translate('Transfer File')}
  • +
  • {translate('TCP Tunneling')}
  • + {false && !handler.using_public_server() &&
  • {svg_checkmark}{translate('Always connect via relay')}
  • } +
  • RDP
  • +
  • {translate('Rename')}
  • +
  • {translate('Remove')}
  • + {is_win &&
  • {translate('Create Desktop Shortcut')}
  • } + +
    + {sessions} +
    ; + } + + function getSession(s) { + var id = s[0] || s.id || ""; + var username = s[1] || s.username || ""; + var hostname = s[2] || s.hostname || ""; + var platform = s[3] || s.platform || ""; + var alias = s[4] || s.alias || ""; + if (this.style == "list") { + return
    +
    + {platformSvg(platform, "white")} +
    +
    +
    +
    {alias ? alias : formatId(id)}
    +
    {username}@{hostname}
    +
    +
    +
    + {svg_menu} +
    +
    ; + } + return
    +
    + {platformSvg(platform, "white")} +
    {username}@{hostname}
    +
    +
    +
    {alias ? alias : formatId(id)}
    + {svg_menu} +
    +
    ; + } + + event dblclick $(div.remote-session-link) (evt, me) { + createNewConnect(me.id, "connect"); + } + + event click $(#menu) (_, me) { + var id = me.parent.parent.id; + var platform = me.parent.parent.attributes["platform"]; + $(#rdp).style.set{ + display: (platform == "Windows" && is_win) ? "block" : "none", + }; + // https://sciter.com/forums/topic/replacecustomize-context-menu/ + var menu = $(menu#remote-context); + menu.attributes["remote-id"] = id; + var el = $(li#force-always-relay); + if (el) { + var force = handler.get_peer_option(id, "force-always-relay"); + el.attributes.toggleClass("selected", force == "Y"); + el.attributes.toggleClass("line-through", force != "Y"); + } + me.popup(menu); + } + + event click $(menu#remote-context li) (evt, me) { + var action = me.id; + var id = me.parent.attributes["remote-id"]; + if (action == "connect") { + createNewConnect(id, "connect"); + } else if (action == "transfer") { + createNewConnect(id, "file-transfer"); + } else if (action == "remove") { + if (!this.type) { + handler.remove_peer(id); + app.update(); + } + } else if (action == "shortcut") { + handler.create_shortcut(id); + } else if (action == "rdp") { + createNewConnect(id, "rdp"); + } else if (action == "tunnel") { + createNewConnect(id, "port-forward"); + } else if (action == "rename") { + var old_name = handler.get_peer_option(id, "alias"); + handler.msgbox("custom-rename", "Rename", "
    \ +
    \ +
    \ + ", function(res=null) { + if (!res) return; + var name = (res.name || "").trim(); + if (name != old_name) { + handler.set_peer_option(id, "alias", name); + } + try { + self.select('#' + id).select('#alias').text = name || id; + } catch (e) {} + }); + } + } +} diff --git a/src/ui/header.tis b/src/ui/header.tis index 5307fd5d8..257231bca 100644 --- a/src/ui/header.tis +++ b/src/ui/header.tis @@ -397,7 +397,7 @@ function startChat() { height: h, client: true, parameters: { msgs: chat_msgs, callback: sendMsg, icon: icon }, - caption: handler.get_id(), + caption: get_id(), }; var html = handler.get_chatbox(); if (html) params.html = html; diff --git a/src/ui/index.css b/src/ui/index.css index 5ed7008e7..6e69bddd7 100644 --- a/src/ui/index.css +++ b/src/ui/index.css @@ -132,11 +132,30 @@ div.recent-sessions-content { flow: horizontal-flow; } -div.recent-sessions-title { +div#sessions-bar { color: color(light-text); padding-top: 0.5em; border-top: color(border) solid 1px; margin-bottom: 1em; + position: relative; + flow: horizontal; +} + +div#sessions-bar span { + display: inline-block; + padding: 0.5em 1em; + cursor: pointer; +} + +div#sessions-bar svg { + size: 14px; +} + +div#sessions-bar span.active { + cursor: default; + border-radius: 3px; + background: white; + color: black; } div.remote-session { @@ -148,7 +167,7 @@ div.remote-session { border: none; } -div.remote-session:hover { +div.remote-session:hover, div.remote-session-list:hover { outline: color(button) solid 2px -2px; } @@ -176,6 +195,41 @@ div.remote-session .platform svg { background: none; } +div.remote-session-list { + background: white; + width: 240px; + flow: horizontal; +} + +div.remote-session-list .platform { + size: 42px; +} + +div.remote-session-list .platform svg { + width: 30px; + height: 30px; + background: none; + padding: 6px; +} + +div.remote-session-list .name { + size: *; + padding-left: 1em; +} + +div.remote-session-list .name >div { + margin-top: *; + margin-bottom: *; + width: *; +} + +div.remote-session-list .name .username { + margin-top: 3px; + font-size: 0.8em; + color: color(lighter-text); + overflow: hidden; +} + div.remote-session .text { background: white; position: absolute; @@ -200,20 +254,22 @@ svg#menu { color: color(light-text); } -svg#menu:active { +.remote-session-list svg#menu { + margin-right: 0; +} + +svg#menu:hover { color: black; border-radius: 1em; background: color(gray-bg); } -svg#edit:active { - opacity: 0.5; +svg#edit:hover { + color: black; } svg#edit { display: inline-block; - margin-top: 0.25em; - margin-bottom: 0; } div.install-me, div.trust-me { diff --git a/src/ui/index.html b/src/ui/index.html index c51c64d84..fc24b564a 100644 --- a/src/ui/index.html +++ b/src/ui/index.html @@ -7,6 +7,7 @@ diff --git a/src/ui/index.tis b/src/ui/index.tis index 542835b20..962eeacc7 100644 --- a/src/ui/index.tis +++ b/src/ui/index.tis @@ -54,78 +54,16 @@ class RecentSessions: Reactor.Component { function render() { var sessions = handler.get_recent_sessions(); if (sessions.length == 0) return ; - sessions = sessions.map(this.getSession); return
    -
    {translate("Recent Sessions")}
    -
    - {sessions} +
    +
    + {translate("Recent Sessions")}
    + {!app.hidden && } +
    + {!app.hidden && }
    ; } - - function getSession(s) { - var id = s[0]; - var username = s[1]; - var hostname = s[2]; - var platform = s[3]; - var alias = s[4]; - return
    -
    - {platformSvg(platform, "white")} -
    {username}@{hostname}
    -
    -
    -
    {alias ? alias : formatId(id)}
    - {svg_menu} -
    -
    ; - } - - event dblclick $(div.remote-session) (evt, me) { - createNewConnect(me.id, "connect"); - } - - event click $(#menu) (_, me) { - var id = me.parent.parent.id; - var platform = me.parent.parent.attributes["platform"]; - $(#rdp).style.set{ - display: (platform == "Windows" && is_win) ? "block" : "none", - }; - // https://sciter.com/forums/topic/replacecustomize-context-menu/ - var menu = $(menu#remote-context); - menu.attributes["remote-id"] = id; - me.popup(menu); - } -} - -event click $(menu#remote-context li) (evt, me) { - var action = me.id; - var id = me.parent.attributes["remote-id"]; - if (action == "connect") { - createNewConnect(id, "connect"); - } else if (action == "transfer") { - createNewConnect(id, "file-transfer"); - } else if (action == "remove") { - handler.remove_peer(id); - app.recent_sessions.update(); - } else if (action == "shortcut") { - handler.create_shortcut(id); - } else if (action == "rdp") { - createNewConnect(id, "rdp"); - } else if (action == "tunnel") { - createNewConnect(id, "port-forward"); - } else if (action == "rename") { - var old_name = handler.get_peer_option(id, "alias"); - handler.msgbox("custom-rename", "Rename", "
    \ -
    \ -
    \ - ", function(res=null) { - if (!res) return; - var name = (res.name || "").trim(); - if (name != old_name) handler.set_peer_option(id, "alias", name); - self.select('#' + id).select('#alias').text = name || id; - }); - } } function createNewConnect(id, type) { @@ -320,17 +258,6 @@ class App: Reactor.Component var is_can_screen_recording = handler.is_can_screen_recording(false); return
    - - -
  • {translate('Connect')}
  • -
  • {translate('Transfer File')}
  • -
  • {translate('TCP Tunneling')}
  • -
  • RDP
  • -
  • {translate('Rename')}
  • -
  • {translate('Remove')}
  • - {is_win &&
  • {translate('Create Desktop Shortcut')}
  • } - -
  • Refresh random password