add database support

This commit is contained in:
Xuan Sang LE
2018-02-05 19:05:41 +01:00
parent 37c10daaad
commit 107e85e612
11 changed files with 165 additions and 8 deletions

View File

@ -0,0 +1,11 @@
coffee_files = main.coffee
jsfiles =
cssfiles = main.css
copyfiles = scheme.html package.json
PKG_NAME=Blogger
include ../pkg.mk

View File

@ -0,0 +1,39 @@
class Blogger extends this.OS.GUI.BaseApplication
constructor: (args) ->
super "Blogger", args
main: () ->
me = @
@tabbar = @find "tabbar"
@containers = [
@find("user-container"),
@find("cv-container"),
@find("blog-container")
]
@cvlist = @find "cv-list"
@bloglist = @find "blog-list"
@tabbar.set "onlistselect", (e) ->
($ el).hide() for el in me.containers
($ me.containers[e.idx]).show()
@tabbar.set "items", [
{ iconclass: "fa fa-user-circle", selected: true },
{ iconclass: "fa fa-info-circle" },
{ iconclass: "fa fa-book" }
]
(@find "bt-user-save").set "onbtclick", (e) ->
me.saveUser()
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 ""
db = new @_api.DB("user")
db.save data, (r) ->
return me.error "Cannot save user data" if r.error
return me.notify "User data updated"
Blogger.singleton = true
this.OS.register "Blogger", Blogger

View File

@ -0,0 +1,25 @@
afx-app-window[data-id="blogger-win"] afx-list-view[data-id="tabbar"] {
padding: 0;
margin: 0;
background-color: #333333;
}
afx-app-window[data-id="blogger-win"] afx-list-view[data-id="tabbar"] li {
background-color: #333333;
font-size: 20px;
color: #929292;
}
afx-app-window[data-id="blogger-win"] afx-list-view[data-id="tabbar"] li.selected{
color:white;
}
afx-app-window[data-id="blogger-win"] afx-hbox[data-id="user-container"] {
padding: 10px;
}
afx-app-window[data-id="blogger-win"] afx-hbox[data-id="user-container"] afx-hbox{
margin-bottom: 5px;
margin-top: 5px;
}
afx-app-window[data-id="blogger-win"] afx-hbox[data-id="user-container"] afx-label{
font-weight: bold;
}

View File

@ -0,0 +1,13 @@
{
"app":"Blogger",
"name":"Blogging application",
"description":"Backend manager for blogging",
"info":{
"author": "Xuan Sang LE",
"email": "xsang.le@gmail.com"
},
"version":"0.1a",
"category":"Internet",
"iconclass":"fa fa-book",
"mimes":["none"]
}

View File

@ -0,0 +1,49 @@
<afx-app-window data-id = "blogger-win" apptitle="MarketPlace" width="500" height="400">
<afx-hbox >
<afx-list-view data-id="tabbar" data-width="30"></afx-list-view>
<afx-vbox>
<afx-hbox data-id="user-container" data-height="grow">
<afx-vbox>
<afx-hbox data-height = "30">
<afx-label data-width= "70" text = "Full name:"></afx-label>
<input type = "text" name="fullname" imput-class = "user-input"/>
</afx-hbox>
<afx-hbox data-height = "30">
<afx-label text = "Address:" data-width= "70"></afx-label>
<input type = "text" name="address" imput-class = "user-input"/>
</afx-hbox>
<afx-hbox data-height = "30">
<afx-label text = "Phone:" data-width= "70"></afx-label>
<input type = "text" name="Phone" imput-class = "user-input"/>
</afx-hbox>
<afx-hbox data-height = "30">
<afx-label text = "Email:" data-width= "70"></afx-label>
<input type = "text" name="email" imput-class = "user-input"/>
</afx-hbox>
<afx-hbox data-height = "30">
<afx-label text = "Url:" data-width= "70"></afx-label>
<input type = "text" name="url" imput-class = "user-input"/>
</afx-hbox>
<afx-label data-height = "30" text = "Short biblio:"/>
<textarea rows="10" name="shortbiblio" imput-class = "user-input"/>
<afx-hbox data-height = "30">
<div></div>
<afx-button iconclass = "fa fa-save" data-id = "bt-user-save" data-width="55" text = "Save"/>
</afx-hbox>
</afx-vbox>
</afx-hbox>
<afx-hbox data-id="cv-container" data-height="grow">
<afx-list-view data-id = "cv-list" data-width="100" ></afx-list-view>
<afx-vbox>
info here
</afx-vbox>
</afx-hbox>
<afx-hbox data-id = "blog-container" data-height="grow">
<afx-list-view data-id = "blog-list" data-width="100"></afx-list-view>
<afx-vbox>
blog here
</afx-vbox>
</afx-hbox>
</afx-vbox>
</afx-hbox>
</afx-app-window>