mirror of
https://github.com/antos-rde/antosdk-apps.git
synced 2024-11-08 06:28:29 +01:00
91 lines
3.7 KiB
CoffeeScript
91 lines
3.7 KiB
CoffeeScript
class ConnectionDialog extends this.OS.GUI.BasicDialog
|
|
constructor: () ->
|
|
super "ConnectionDialog", {
|
|
tags: [
|
|
{ tag: "afx-label", att: 'text="__(VNC server)" data-height="23" class="header"' },
|
|
{ tag: "input", att: 'data-height="30"' },
|
|
{ tag: "afx-label", att: 'text="__(Bits per pixel)" data-height="23" class="header"' },
|
|
{ tag: "afx-list-view", att: 'dropdown="true" data-height="30"' },
|
|
{ tag: "afx-label", att: 'text="__(Compression)" data-height="23" class="header"' },
|
|
{ tag: "afx-list-view", att: 'dropdown="true" data-height="30"' },
|
|
{ tag: "afx-label", att: 'text="__(JPEG quality)" data-height="23" class="header"' },
|
|
{ tag: "afx-slider", att: 'max="100" data-height="30"' },
|
|
{ tag: "div", att: ' data-height="5"' }
|
|
],
|
|
width: 350,
|
|
height: 280,
|
|
resizable: false,
|
|
buttons: [
|
|
{
|
|
label: "__(Connect)",
|
|
onclick: (d) ->
|
|
return unless d.handler
|
|
data =
|
|
server: (d.find "content1").value
|
|
bbp: ((d.find "content3").get "selected").value,
|
|
flag: ((d.find "content5").get "selected").value,
|
|
quality:((d.find "content7").get "value")
|
|
d.handler data
|
|
d.quit()
|
|
},
|
|
{ label: "__(Cancel)", onclick: (d) -> d.quit() }
|
|
],
|
|
filldata: (d) ->
|
|
(d.find "content1").value = "/opt/www/vnc.conf"
|
|
(d.find "content3").set "items", [
|
|
{ text: "16 bits", value: 16 },
|
|
{ text: "32 bits", value: 32, selected:true}]
|
|
(d.find "content5").set "items", [
|
|
{text: "No compression", value:0},
|
|
{text: "JPEG", value:1},
|
|
{text: "zLib", value:2},
|
|
{text: "JPEG & zLib", value:3, selected:true}
|
|
]
|
|
(d.find "content7").set "value", 40
|
|
}
|
|
|
|
class RemoteDesktop extends this.OS.GUI.BaseApplication
|
|
constructor: ( args ) ->
|
|
super "RemoteDesktop", args
|
|
|
|
main: () ->
|
|
me = @
|
|
@canvas = @find "screen"
|
|
@container = @find "container"
|
|
@client = new WVNC {
|
|
element: me.canvas,
|
|
ws: 'wss://localhost:9192/wvnc',
|
|
worker: "#{me._api.handler.get}/#{me.meta().path}/decoder.js"
|
|
}
|
|
@client.onerror = (m) ->
|
|
me.error m
|
|
me.showConnectionDialog()
|
|
@client.onresize = ()->
|
|
me.setScale()
|
|
@client.onpassword = ()->
|
|
return new Promise (r,e)->
|
|
me.openDialog "PromptDialog", (d) ->
|
|
r(d)
|
|
, __("VNC password"), { label: __("VNC password"), value: "demopass", type: "password" }
|
|
@on "resize", (e)-> me.setScale()
|
|
@on "focus", (e) -> $(me.canvas).focus()
|
|
@client.init().then () ->
|
|
me.showConnectionDialog()
|
|
|
|
setScale: () ->
|
|
return unless @client and @client.resolution
|
|
w = $(@container).width()
|
|
h = $(@container).height()
|
|
sx = w / @client.resolution.w
|
|
sy = h / @client.resolution.h
|
|
if sx > sy then @client.setScale sy else @client.setScale sx
|
|
|
|
showConnectionDialog: () ->
|
|
me = @
|
|
@openDialog new ConnectionDialog, (d) ->
|
|
me.client.connect d.server, d
|
|
, __("Connection")
|
|
|
|
cleanup: () ->
|
|
@client.disconnect() if @client
|
|
this.OS.register "RemoteDesktop", RemoteDesktop |