mirror of
https://github.com/lxsang/antos-frontend.git
synced 2024-12-27 17:58:22 +01:00
add database support
This commit is contained in:
parent
37c10daaad
commit
107e85e612
3
Makefile
3
Makefile
@ -8,6 +8,7 @@ coffees= src/core/core.coffee\
|
|||||||
src/core/api.coffee\
|
src/core/api.coffee\
|
||||||
src/core/handlers/RemoteHandler.coffee\
|
src/core/handlers/RemoteHandler.coffee\
|
||||||
src/core/vfs.coffee\
|
src/core/vfs.coffee\
|
||||||
|
src/core/db.coffee\
|
||||||
src/core/gui.coffee\
|
src/core/gui.coffee\
|
||||||
src/core/BaseModel.coffee\
|
src/core/BaseModel.coffee\
|
||||||
src/core/BaseApplication.coffee\
|
src/core/BaseApplication.coffee\
|
||||||
@ -20,7 +21,7 @@ coffees= src/core/core.coffee\
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
packages = CoreServices NotePad wTerm ActivityMonitor DummyApp Files MarkOn MarketPlace
|
packages = CoreServices NotePad wTerm ActivityMonitor DummyApp Files MarkOn MarketPlace Blogger
|
||||||
|
|
||||||
main: build_coffees build_tags build_themes schemes libs build_packages
|
main: build_coffees build_tags build_themes schemes libs build_packages
|
||||||
- cp src/index.html $(BUILDDIR)/
|
- cp src/index.html $(BUILDDIR)/
|
||||||
|
@ -69,4 +69,5 @@ class BaseModel
|
|||||||
|
|
||||||
find: (id) -> ($ "[data-id='#{id}']", @scheme)[0] if @scheme
|
find: (id) -> ($ "[data-id='#{id}']", @scheme)[0] if @scheme
|
||||||
|
|
||||||
|
select: (sel) -> $ sel, @scheme if @scheme
|
||||||
this.OS.GUI.BaseModel = BaseModel
|
this.OS.GUI.BaseModel = BaseModel
|
13
src/core/db.coffee
Normal file
13
src/core/db.coffee
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
class DB
|
||||||
|
constructor: (@table) ->
|
||||||
|
|
||||||
|
save: (d, f) ->
|
||||||
|
_API.handler.dbquery "save", { table: @table, data: d }, f
|
||||||
|
delete: (id, f) ->
|
||||||
|
_API.handler.dbquery "delete", { table: @table, id: id }, f
|
||||||
|
get: (id, f) ->
|
||||||
|
_API.handler.dbquery "get", { table: @table, id: id }, f
|
||||||
|
find: (cond, f) ->
|
||||||
|
_API.handler.dbquery "select", { table: @table, cond: cond }, f
|
||||||
|
|
||||||
|
self.OS.API.DB = DB
|
@ -76,3 +76,8 @@ self.OS.API.handler =
|
|||||||
_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) ->
|
||||||
_courrier.osfail "Fail to make request: #{p}", e, s
|
_courrier.osfail "Fail to make request: #{p}", e, s
|
||||||
|
|
||||||
|
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
|
@ -1,5 +1,5 @@
|
|||||||
<afx-hbox style = "display:block;">
|
<afx-hbox style = "display:block;">
|
||||||
<div ref = "container" class="afx-vbox-container">
|
<div ref = "container" class="afx-hbox-container">
|
||||||
<yield/>
|
<yield/>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
@ -35,8 +35,6 @@
|
|||||||
.each(function(e)
|
.each(function(e)
|
||||||
{
|
{
|
||||||
this.observable = self.root.observable
|
this.observable = self.root.observable
|
||||||
$(this)
|
|
||||||
.css("flex-grow","1")
|
|
||||||
//.css("height",avaiheight + "px")
|
//.css("height",avaiheight + "px")
|
||||||
var dw = $(this).attr("data-width")
|
var dw = $(this).attr("data-width")
|
||||||
if(dw)
|
if(dw)
|
||||||
@ -47,6 +45,8 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
$(this)
|
||||||
|
.css("flex-grow","1")
|
||||||
auto_width.push(this)
|
auto_width.push(this)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<afx-vbox style = "display:block;">
|
<afx-vbox style = "display:block;">
|
||||||
<div ref = "container" class="afx-hbox-container">
|
<div ref = "container" class="afx-vbox-container">
|
||||||
<yield/>
|
<yield/>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
@ -38,8 +38,6 @@
|
|||||||
.each(function(e)
|
.each(function(e)
|
||||||
{
|
{
|
||||||
this.observable = self.root.observable
|
this.observable = self.root.observable
|
||||||
$(this)
|
|
||||||
.css("flex-grow","1")
|
|
||||||
//.css("border","1px solid black")
|
//.css("border","1px solid black")
|
||||||
var dw = $(this).attr("data-height")
|
var dw = $(this).attr("data-height")
|
||||||
if(dw)
|
if(dw)
|
||||||
@ -50,6 +48,8 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
$(this)
|
||||||
|
.css("flex-grow","1")
|
||||||
auto_height.push(this)
|
auto_height.push(this)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
11
src/packages/Blogger/Makefile
Normal file
11
src/packages/Blogger/Makefile
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
coffee_files = main.coffee
|
||||||
|
|
||||||
|
jsfiles =
|
||||||
|
|
||||||
|
cssfiles = main.css
|
||||||
|
|
||||||
|
copyfiles = scheme.html package.json
|
||||||
|
|
||||||
|
|
||||||
|
PKG_NAME=Blogger
|
||||||
|
include ../pkg.mk
|
39
src/packages/Blogger/main.coffee
Normal file
39
src/packages/Blogger/main.coffee
Normal 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
|
25
src/packages/Blogger/main.css
Normal file
25
src/packages/Blogger/main.css
Normal 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;
|
||||||
|
}
|
13
src/packages/Blogger/package.json
Normal file
13
src/packages/Blogger/package.json
Normal 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"]
|
||||||
|
}
|
49
src/packages/Blogger/scheme.html
Normal file
49
src/packages/Blogger/scheme.html
Normal 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>
|
Loading…
Reference in New Issue
Block a user