mirror of
https://github.com/lxsang/antos-frontend.git
synced 2025-07-19 15:29:51 +02:00
add server side api
This commit is contained in:
@ -18,7 +18,8 @@
|
||||
class BaseApplication extends this.OS.GUI.BaseModel
|
||||
constructor: (name, args) ->
|
||||
super name, args
|
||||
_OS.setting.applications[@name] = {} if not _OS.setting.applications[@name]
|
||||
if (not _OS.setting.applications[@name]) or (Array.isArray OS.setting.applications[@name])
|
||||
_OS.setting.applications[@name] = {}
|
||||
@setting = _OS.setting.applications[@name]
|
||||
@keycomb =
|
||||
ALT: {}
|
||||
|
@ -43,7 +43,15 @@ class BaseModel
|
||||
mt = @meta()
|
||||
return mt.path if mt and mt.path
|
||||
return null
|
||||
|
||||
|
||||
# call a server side script
|
||||
call: (cmd, func) ->
|
||||
@_api.apigateway cmd, false, func
|
||||
|
||||
# get a stream
|
||||
stream: () ->
|
||||
return @_api.apigateway null, true, null
|
||||
|
||||
init: ->
|
||||
#implement by sub class
|
||||
onexit: (e) ->
|
||||
|
@ -337,6 +337,8 @@ self.OS.API =
|
||||
}, f
|
||||
setting: (f) ->
|
||||
_API.handler.setting f
|
||||
apigateway: (d, ws, c) ->
|
||||
return _API.handler.apigateway d, ws, c
|
||||
search: (text) ->
|
||||
r = []
|
||||
|
||||
|
@ -18,9 +18,8 @@
|
||||
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}"
|
||||
|
||||
self.OS.API.TERMURI = "wss://lxsang.me/wterm"
|
||||
|
||||
_REST = self.OS.API.REST
|
||||
_HOST = self.OS.API.HOST
|
||||
self.OS.API.handler =
|
||||
# get file, require authentification
|
||||
get: "#{_REST}/VFS/get"
|
||||
@ -82,6 +81,19 @@ self.OS.API.handler =
|
||||
|
||||
scanapp: (p, c ) ->
|
||||
path = "#{_REST}/system/application"
|
||||
|
||||
apigateway: (d, ws, c) ->
|
||||
if ws
|
||||
path = "#{_HOST}/system/apigateway?ws=1"
|
||||
proto = if window.location.protocol is "https:" then "wss://" else "ws://"
|
||||
socket = new WebSocket proto + path
|
||||
if c then c(socket)
|
||||
return socket
|
||||
else
|
||||
path = "#{_REST}/system/apigateway?ws=0"
|
||||
_API.post path, d, c, (e, s) ->
|
||||
_courrier.osfail __("Fail to invoke gateway api"), e, s
|
||||
|
||||
auth: (c) ->
|
||||
p = "#{_REST}/user/auth"
|
||||
_API.post p, {}, c, (e, s) ->
|
||||
|
@ -25,6 +25,7 @@
|
||||
repeat: "repeat"
|
||||
} unless _OS.setting.appearance.wp
|
||||
_OS.setting.appearance.wps = [] unless _OS.setting.appearance.wps
|
||||
_OS.setting.applications = {} unless _OS.setting.applications
|
||||
_OS.setting.user = conf.user
|
||||
_OS.setting.VFS = conf.VFS if conf.VFS
|
||||
_OS.setting.desktop.path = "home://.desktop" unless _OS.setting.desktop.path
|
||||
|
Reference in New Issue
Block a user