minor fix

This commit is contained in:
Xuan Sang LE 2018-02-11 00:39:08 +01:00
parent 3ed28e4fc1
commit b3e90fbc15
3 changed files with 21 additions and 6 deletions

View File

@ -291,7 +291,6 @@ self.OS.GUI =
dataid: "sys-logout",
iconclass: "fa fa-user-times"
menu.onmenuselect = (d) ->
console.log d
return _API.handler.logout() if d.item.data.dataid is "sys-logout"
_GUI.launch d.item.data.app unless d.item.data.dataid

View File

@ -80,4 +80,4 @@ self.OS.API.handler =
dbquery: (cmd,d, c) ->
path = "#{_REST}/db/#{cmd}"
_API.post path, d, c, (e, s) ->
_courrier.osfail "Fail to query data from database: #{p}", e, s
_courrier.osfail "Fail to query data from database: #{path}", e, s

View File

@ -10,10 +10,12 @@ class Blogger extends this.OS.GUI.BaseApplication
@find("cv-container"),
@find("blog-container")
]
@user = {}
@cvlist = @find "cv-list"
@bloglist = @find "blog-list"
@tabbar.set "onlistselect", (e) ->
($ el).hide() for el in me.containers
me.fetchData e.idx
($ me.containers[e.idx]).show()
@tabbar.set "items", [
@ -24,14 +26,28 @@ class Blogger extends this.OS.GUI.BaseApplication
(@find "bt-user-save").set "onbtclick", (e) ->
me.saveUser()
fetchData: (idx) ->
me = @
switch idx
when 0 #user info
db = new @_api.DB("user")
db.get null, (d) ->
return me.error "Cannot fetch user data" if d.error
me.user = d.result[0]
inputs = me.select "[imput-class='user-input']"
($ v).val me.user[v.name] for v in inputs
else
console.log "Not implemented yet"
saveUser:() ->
me = @
inputs = @select "[imput-class='user-input']"
data = {}
data[v.name] = ($ v).val() for v in inputs
return @notify "Full name must be entered" if not data.fullname or data.fullname is ""
@user[v.name] = ($ v).val() for v in inputs
return @notify "Full name must be entered" if not @user.fullname or @user.fullname is ""
db = new @_api.DB("user")
db.save data, (r) ->
console.log @user
db.save @user, (r) ->
return me.error "Cannot save user data" if r.error
return me.notify "User data updated"