change REST path on remote handle

This commit is contained in:
Xuan Sang LE 2018-09-12 18:28:32 +02:00
parent 4378723fff
commit b6100b2d07
3 changed files with 22 additions and 19 deletions

View File

@ -167,7 +167,7 @@ self.OS.GUI =
css = "#{path}/main.css"
css.asFileHandler().onready (d) ->
stamp = (new Date).timestamp()
el = $ '<link>', { rel: 'stylesheet', type: 'text/css', 'href': "#{_API.handler.get}/#{css}?r=#{stamp}" }
el = $ '<link>', { rel: 'stylesheet', type: 'text/css', 'href': "#{_API.handler.get}/#{css}?stamp=#{stamp}" }
.appendTo 'head'
_OS.APP[app].style = el[0] if _OS.APP[app]
ok app

View File

@ -16,50 +16,52 @@
# You should have received a copy of the GNU General Public License
#along with this program. If not, see https://www.gnu.org/licenses/.
self.OS.API.HOST = self.location.hostname+ (if self.location.port then":#{self.location.port}" else "")
self.OS.API.REST = "#{self.location.protocol}//#{self.OS.API.HOST}/lua-api/os"
self.OS.API.REST = "#{self.location.protocol}//#{self.OS.API.HOST}"
self.OS.API.TERMURI = "wss://lxsang.me/wterm"
_REST = self.OS.API.REST
self.OS.API.handler =
# get file, require authentification
get: "#{_REST}/fs/get"
get: "#{_REST}/VFS/get"
# get shared file with publish
shared: "#{_REST}/fs/shared"
shared: "#{_REST}/VFS/shared"
scandir: (p, c ) ->
path = "#{_REST}/fs/scandir"
path = "#{_REST}/VFS/scandir"
_API.post path, { path: p }, c, (e, s) ->
_courrier.osfail __("Fail to scan directory: {0}", p), e, s
mkdir: (p, c ) ->
path = "#{_REST}/fs/mkdir"
path = "#{_REST}/VFS/mkdir"
_API.post path, { path: p }, c, (e, s) ->
_courrier.osfail __("Fail to create directory: {0}", p), e, s
sharefile: (p, pub , c) ->
path = "#{_REST}/fs/publish"
path = "#{_REST}/VFS/publish"
_API.post path, { path: p , publish: pub }, c, (e, s) ->
_courrier.osfail __("Fail to publish file: {0}", p), e, s
fileinfo: (p, c) ->
path = "#{_REST}/fs/fileinfo"
path = "#{_REST}/VFS/fileinfo"
_API.post path, { path: p }, c, (e, s) ->
_courrier.osfail __("Fail to get file meta data: {0}", p), e, s
readfile: (p, c, t) ->
path = "#{_REST}/fs/get/"
path = "#{_REST}/VFS/get/"
_API.get path + p, c, (e, s) ->
_courrier.osfail __("Fail to read file: {0}", p), e, s
, t
move: (s, d, c) ->
path = "#{_REST}/fs/move"
path = "#{_REST}/VFS/move"
_API.post path, { src: s, dest: d }, c, (e, s) ->
_courrier.osfail __("Fail to move file: {0} -> {1}", s, d), e, s
delete: (p , c) ->
path = "#{_REST}/fs/delete"
path = "#{_REST}/VFS/delete"
_API.post path, { path: p }, c, (e, s) ->
_courrier.osfail __("Fail to delete: {0}", p), e, s
fileblob: (p, c) ->
path = "#{_REST}/fs/get/"
path = "#{_REST}/VFS/get/"
_API.blob path + p, c, (e, s) ->
_courrier.osfail "Fail to read file: #{p}", e, s
@ -69,28 +71,28 @@ self.OS.API.handler =
_courrier.osfail __("Fail to {0} package", d.command), e, s
upload: (d, c) ->
path = "#{_REST}/fs/upload"
path = "#{_REST}/VFS/upload"
_API.upload path, d, c, (e, s) ->
_courrier.osfail __("Fail to upload file to: {0}", d), e, s
write: (p, d , c) ->
path = "#{_REST}/fs/write"
path = "#{_REST}/VFS/write"
_API.post path, { path: p, data: d }, c, (e, s) ->
_courrier.osfail __("Fail to write to file: {0}", p), e, s
scanapp: (p, c ) ->
path = "#{_REST}/system/application"
auth: (c) ->
p = "#{_REST}/system/auth"
p = "#{_REST}/user/auth"
_API.post p, {}, c, (e, s) ->
console.log e, s
alert __("Resource not found: {0}", p)
login: (d, c) ->
p = "#{_REST}/system/login"
p = "#{_REST}/user/login"
_API.post p, d, c, () ->
alert __("Resource not found: {0}", p)
logout: () ->
p = "#{_REST}/system/logout"
p = "#{_REST}/user/logout"
_API.post p, {}, (d) ->
_OS.boot()
, () ->
@ -106,6 +108,6 @@ self.OS.API.handler =
f({ error: m }) if f
dbquery: (cmd, d, c) ->
path = "#{_REST}/db/#{cmd}"
path = "#{_REST}/VDB/#{cmd}"
_API.post path, d, c, (e, s) ->
_courrier.osfail __("Fail to query data from database: {0}", path), e, s

View File

@ -76,7 +76,8 @@ class wTerm extends this.OS.GUI.BaseApplication
@term.clear()
@term.focus()
proto = if window.location.protocol is "https:" then "wss://" else "ws://"
@socket = new WebSocket proto + @_api.HOST + "/wterm"
#@socket = new WebSocket proto + @_api.HOST + "/wterm"
@socket = new WebSocket @_api.TERMURI
@socket.onopen = () ->
#el.style.display = "none"
me.resizeContent (($ me.mterm).width()) , (($ me.mterm).height())