mirror of
https://github.com/lxsang/antos-frontend.git
synced 2025-07-21 00:09:45 +02:00
add database support
This commit is contained in:
@ -69,4 +69,5 @@ class BaseModel
|
||||
|
||||
find: (id) -> ($ "[data-id='#{id}']", @scheme)[0] if @scheme
|
||||
|
||||
select: (sel) -> $ sel, @scheme if @scheme
|
||||
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
|
@ -75,4 +75,9 @@ self.OS.API.handler =
|
||||
_API.post p, _OS.setting, (d) ->
|
||||
_courrier.oserror "Cannot save system setting", d.error if d.error
|
||||
, (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;">
|
||||
<div ref = "container" class="afx-vbox-container">
|
||||
<div ref = "container" class="afx-hbox-container">
|
||||
<yield/>
|
||||
</div>
|
||||
<script>
|
||||
@ -35,8 +35,6 @@
|
||||
.each(function(e)
|
||||
{
|
||||
this.observable = self.root.observable
|
||||
$(this)
|
||||
.css("flex-grow","1")
|
||||
//.css("height",avaiheight + "px")
|
||||
var dw = $(this).attr("data-width")
|
||||
if(dw)
|
||||
@ -47,6 +45,8 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
$(this)
|
||||
.css("flex-grow","1")
|
||||
auto_width.push(this)
|
||||
}
|
||||
})
|
||||
|
@ -1,5 +1,5 @@
|
||||
<afx-vbox style = "display:block;">
|
||||
<div ref = "container" class="afx-hbox-container">
|
||||
<div ref = "container" class="afx-vbox-container">
|
||||
<yield/>
|
||||
</div>
|
||||
<script>
|
||||
@ -38,8 +38,6 @@
|
||||
.each(function(e)
|
||||
{
|
||||
this.observable = self.root.observable
|
||||
$(this)
|
||||
.css("flex-grow","1")
|
||||
//.css("border","1px solid black")
|
||||
var dw = $(this).attr("data-height")
|
||||
if(dw)
|
||||
@ -50,6 +48,8 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
$(this)
|
||||
.css("flex-grow","1")
|
||||
auto_height.push(this)
|
||||
}
|
||||
})
|
||||
|
Reference in New Issue
Block a user