fix remote handler & terminal

This commit is contained in:
Xuan Sang LE 2018-02-02 22:18:33 +01:00
parent 6ea5857de2
commit 982793ea0c
4 changed files with 22 additions and 20 deletions

View File

@ -1,6 +1,6 @@
BUILDDIR = build/htdocs BUILDDIR = build/htdocs/os
BLUE=\033[1;34m BLUE=\033[1;34m
NC=\033[0m NC=\033[0m

View File

@ -1,74 +1,77 @@
self.OS.API.handler = self.OS.API.HOST = "127.0.0.1:9195"
get: "lua-api/fs/get" self.OS.API.REST = "http://#{self.OS.API.HOST}/lua-api"
_REST = self.OS.API.REST
self.OS.API.handler =
get: "#{_REST}/fs/get/"
scandir: (p, c ) -> scandir: (p, c ) ->
path = "lua-api/fs/scandir" path = "#{_REST}/fs/scandir"
_API.post path, { path: p }, c, (e, s) -> _API.post path, { path: p }, c, (e, s) ->
_courrier.osfail "Fail to scan directory: #{p}", e, s _courrier.osfail "Fail to scan directory: #{p}", e, s
mkdir: (p, c ) -> mkdir: (p, c ) ->
path = "lua-api/fs/mkdir" path = "#{_REST}/fs/mkdir"
_API.post path, { path: p }, c, (e, s) -> _API.post path, { path: p }, c, (e, s) ->
_courrier.osfail "Fail to create directory: #{p}", e, s _courrier.osfail "Fail to create directory: #{p}", e, s
fileinfo: (p, c) -> fileinfo: (p, c) ->
path = "lua-api/fs/fileinfo" path = "#{_REST}/fs/fileinfo"
_API.post path, { path: p }, c, (e, s) -> _API.post path, { path: p }, c, (e, s) ->
_courrier.osfail "Fail to get file metadata: #{p}", e, s _courrier.osfail "Fail to get file metadata: #{p}", e, s
readfile: (p, c, t) -> readfile: (p, c, t) ->
path = "lua-api/fs/get/" path = "#{_REST}/fs/get/"
_API.get path + p, c, (e, s) -> _API.get path + p, c, (e, s) ->
_courrier.osfail "Fail to read file: #{p}", e, s _courrier.osfail "Fail to read file: #{p}", e, s
, t , t
move: (s, d, c) -> move: (s, d, c) ->
path = "lua-api/fs/move" path = "#{_REST}/fs/move"
_API.post path, { src: s, dest: d }, c, (e, s) -> _API.post path, { src: s, dest: d }, c, (e, s) ->
_courrier.osfail "Fail to move file: #{s} -> #{d}", e, s _courrier.osfail "Fail to move file: #{s} -> #{d}", e, s
delete: (p , c) -> delete: (p , c) ->
path = "lua-api/fs/delete" path = "#{_REST}/fs/delete"
_API.post path, { path: p }, c, (e, s) -> _API.post path, { path: p }, c, (e, s) ->
_courrier.osfail "Fail to delete: #{p}", e, s _courrier.osfail "Fail to delete: #{p}", e, s
fileblob: (p, c) -> fileblob: (p, c) ->
path = "lua-api/fs/get/" path = "#{_REST}/fs/get/"
_API.blob path + p, c, (e, s) -> _API.blob path + p, c, (e, s) ->
_courrier.osfail "Fail to read file: #{p}", e, s _courrier.osfail "Fail to read file: #{p}", e, s
packages: (d, c) -> packages: (d, c) ->
path = "lua-api/system/packages" path = "#{_REST}/system/packages"
_API.post path, d, c, (e, s) -> _API.post path, d, c, (e, s) ->
_courrier.osfail "Fail to #{d.command} package", e, s _courrier.osfail "Fail to #{d.command} package", e, s
upload: (d, c) -> upload: (d, c) ->
path = "lua-api/fs/upload" path = "#{_REST}/fs/upload"
_API.upload path, d, c, (e, s) -> _API.upload path, d, c, (e, s) ->
_courrier.osfail "Fail to upload file to: #{d}", e, s _courrier.osfail "Fail to upload file to: #{d}", e, s
write: (p, d , c) -> write: (p, d , c) ->
path = "lua-api/fs/write" path = "#{_REST}/fs/write"
_API.post path, { path: p, data: d }, c, (e, s) -> _API.post path, { path: p, data: d }, c, (e, s) ->
_courrier.osfail "Fail to write to file: #{p}", e, s _courrier.osfail "Fail to write to file: #{p}", e, s
scanapp: (p, c ) -> scanapp: (p, c ) ->
path = "lua-api/system/application" path = "#{_REST}/system/application"
auth: (c) -> auth: (c) ->
p = "lua-api/system/auth" p = "#{_REST}/system/auth"
_API.post p, {}, c, () -> _API.post p, {}, c, () ->
alert "Resource not found: #{p}" alert "Resource not found: #{p}"
login: (d, c) -> login: (d, c) ->
p = "lua-api/system/login" p = "#{_REST}/system/login"
_API.post p, d, c, () -> _API.post p, d, c, () ->
alert "Resource not found: #{p}" alert "Resource not found: #{p}"
logout: () -> logout: () ->
p = "lua-api/system/logout" p = "#{_REST}/system/logout"
_API.post p, {}, (d) -> _API.post p, {}, (d) ->
_OS.boot() _OS.boot()
, () -> , () ->
alert "Resource not found #{p}" alert "Resource not found #{p}"
setting: () -> setting: () ->
p = "lua-api/system/settings" p = "#{_REST}/system/settings"
_API.post p, _OS.setting, (d) -> _API.post p, _OS.setting, (d) ->
_courrier.oserror "Cannot save system setting", d.error if d.error _courrier.oserror "Cannot save system setting", d.error if d.error
, (e, s) -> , (e, s) ->

View File

@ -57,7 +57,7 @@ class wTerm extends this.OS.GUI.BaseApplication
me = @ me = @
@term.clear() @term.clear()
@term.focus() @term.focus()
@socket = new WebSocket "ws://" + window.location.host + "/wterm" @socket = new WebSocket "ws://" + @_api.HOST + "/wterm"
@socket.onopen = () -> @socket.onopen = () ->
#el.style.display = "none" #el.style.display = "none"
me.resizeContent (($ me.mterm).width()) , (($ me.mterm).height()) me.resizeContent (($ me.mterm).width()) , (($ me.mterm).height())

View File

@ -5129,4 +5129,3 @@ module.exports = Terminal;
},{"./BufferSet":2,"./CompositionHelper":4,"./EscapeSequences":5,"./EventEmitter":6,"./InputHandler":7,"./Linkifier":8,"./Parser":9,"./Renderer":10,"./SelectionManager":11,"./Viewport":13,"./handlers/Clipboard":14,"./utils/Browser":15,"./utils/BufferLine":16,"./utils/CharMeasure":17,"./utils/Mouse":21}]},{},[22])(22) },{"./BufferSet":2,"./CompositionHelper":4,"./EscapeSequences":5,"./EventEmitter":6,"./InputHandler":7,"./Linkifier":8,"./Parser":9,"./Renderer":10,"./SelectionManager":11,"./Viewport":13,"./handlers/Clipboard":14,"./utils/Browser":15,"./utils/BufferLine":16,"./utils/CharMeasure":17,"./utils/Mouse":21}]},{},[22])(22)
}); });
//# sourceMappingURL=xterm.js.map