mirror of
https://github.com/lxsang/antos-frontend.git
synced 2025-07-27 03:09:45 +02:00
AntOSDK first working version, now application can be built from browser
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
coffee_files = main.coffee
|
||||
coffee_files = main.coffee dialog.coffee
|
||||
|
||||
jsfiles = coffeescript.js
|
||||
|
||||
|
109
src/packages/AntOSDK/dialog.coffee
Normal file
109
src/packages/AntOSDK/dialog.coffee
Normal file
@ -0,0 +1,109 @@
|
||||
class BuildDialog extends this.OS.GUI.BasicDialog
|
||||
constructor: () ->
|
||||
super "BuildDialog", {
|
||||
tags: [
|
||||
{ tag: "afx-label", att: 'text="__(Coffees)" data-height="23" class="header"' },
|
||||
{ tag: "afx-list-view" }
|
||||
{ tag: "afx-label", att: 'text="__(Javascripts)" data-height="23" class="header"' },
|
||||
{ tag: "afx-list-view" }
|
||||
{ tag: "afx-label", att: 'text="__(Css)" data-height="23" class="header"' },
|
||||
{ tag: "afx-list-view" }
|
||||
{ tag: "afx-label", att: 'text="__(Copied files)" data-height="23" class="header"' },
|
||||
{ tag: "afx-list-view" }
|
||||
{ tag: "div", att: ' data-height="5"' }
|
||||
],
|
||||
width: 350,
|
||||
height: 450,
|
||||
resizable: true,
|
||||
buttons: [
|
||||
{
|
||||
label: "__(Save)", onclick: (d) ->
|
||||
data =
|
||||
coffees: (v.text for v in (d.find "content1").get "items")
|
||||
javascripts: (v.text for v in (d.find "content3").get "items")
|
||||
css: (v.text for v in (d.find "content5").get "items")
|
||||
copies: (v.text for v in (d.find "content7").get "items")
|
||||
d.handler data if d.handler
|
||||
d.quit()
|
||||
},
|
||||
{ label: "__(Cancel)", onclick: (d) -> d.quit() }
|
||||
],
|
||||
filldata: (d) ->
|
||||
lv = d.find "content1"
|
||||
lv.set "items", ({ text: v } for v in d.parent.prjfile.cache.coffees)
|
||||
lv.set "buttons", [
|
||||
{
|
||||
text: "+",
|
||||
onbtclick: (e) ->
|
||||
d.selectFile ["text/coffeescript"], (f) ->
|
||||
lv.push { text: f }, true if f
|
||||
},
|
||||
{
|
||||
text: "-",
|
||||
onbtclick: (e) ->
|
||||
sel = lv.get "selected"
|
||||
return unless sel
|
||||
lv.remove sel, true
|
||||
}
|
||||
]
|
||||
|
||||
lv1 = d.find "content3"
|
||||
lv1.set "items", ({ text: v } for v in d.parent.prjfile.cache.javascripts)
|
||||
lv1.set "buttons", [
|
||||
{
|
||||
text: "+",
|
||||
onbtclick: (e) ->
|
||||
d.selectFile ["application/javascript"], (f) ->
|
||||
lv1.push { text: f }, true if f
|
||||
},
|
||||
{
|
||||
text: "-",
|
||||
onbtclick: (e) ->
|
||||
sel = lv1.get "selected"
|
||||
return unless sel
|
||||
lv1.remove sel, true
|
||||
}
|
||||
]
|
||||
|
||||
lv2 = d.find "content5"
|
||||
lv2.set "items", ({ text: v } for v in d.parent.prjfile.cache.css)
|
||||
lv2.set "buttons", [
|
||||
{
|
||||
text: "+",
|
||||
onbtclick: (e) ->
|
||||
d.selectFile ["text/css"], (f) ->
|
||||
lv2.push { text: f }, true if f
|
||||
},
|
||||
{
|
||||
text: "-",
|
||||
onbtclick: (e) ->
|
||||
sel = lv2.get "selected"
|
||||
return unless sel
|
||||
lv2.remove sel, true
|
||||
}
|
||||
]
|
||||
|
||||
lv3 = d.find "content7"
|
||||
lv3.set "items", ({ text: v } for v in d.parent.prjfile.cache.copies)
|
||||
lv3.set "buttons", [
|
||||
{
|
||||
text: "+",
|
||||
onbtclick: (e) ->
|
||||
d.selectFile [".*"], (f) ->
|
||||
lv3.push { text: f }, true if f
|
||||
},
|
||||
{
|
||||
text: "-",
|
||||
onbtclick: (e) ->
|
||||
sel = lv3.get "selected"
|
||||
return unless sel
|
||||
lv3.remove sel, true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
selectFile: (mimes, f) ->
|
||||
me = @
|
||||
@openDialog "FileDiaLog", (d, n, p) ->
|
||||
f p.replace me.parent.prjfile.cache.root + "/", ""
|
||||
, "__(Select a file)", { mimes: mimes, type: "file", root: @parent.prjfile.cache.root }
|
@ -145,8 +145,10 @@ class AntOSDK extends this.OS.GUI.BaseApplication
|
||||
@bindKey "CTRL-S", () -> me.actionFile "#{me.name}-Save"
|
||||
@bindKey "ALT-W", () -> me.actionFile "#{me.name}-Saveas"
|
||||
@bindKey "CTRL-R", () -> me.bnR()
|
||||
@bindKey "ALT-B", () -> me.actionBuild "#{me.name}-Build"
|
||||
@bindKey "ALT-C", () -> me.actionBuild "#{me.name}-Build"
|
||||
@bindKey "ALT-P", () -> me.buildAndRelease()
|
||||
@bindKey "ALT-Y", () ->
|
||||
me.actionBuild "#{me.name}-Options"
|
||||
@openProject @prjfile if @prjfile
|
||||
@trigger "calibrate"
|
||||
|
||||
@ -428,8 +430,8 @@ class AntOSDK extends this.OS.GUI.BaseApplication
|
||||
child: [
|
||||
{ text: "__(Build and Run)", dataid: "#{@name}-Run", shortcut: "C-R" },
|
||||
{ text: "__(Build release)", dataid: "#{@name}-Release", shortcut: "A-P" },
|
||||
{ text: "__(Build)", dataid: "#{@name}-Build", shortcut: "A-B" },
|
||||
{ text: "__(Build Options)", dataid: "#{@name}-Options", shortcut: "A-C" }
|
||||
{ text: "__(Build)", dataid: "#{@name}-Build", shortcut: "A-C" },
|
||||
{ text: "__(Build Options)", dataid: "#{@name}-Options", shortcut: "A-Y" }
|
||||
],
|
||||
onmenuselect: (e) -> me.actionBuild e.item.data.dataid
|
||||
}
|
||||
@ -438,6 +440,7 @@ class AntOSDK extends this.OS.GUI.BaseApplication
|
||||
|
||||
actionFile: (e) ->
|
||||
me = @
|
||||
return unless @prjfile
|
||||
saveas = () ->
|
||||
me.openDialog "FileDiaLog", (d, n) ->
|
||||
file = "#{d}/#{n}".asFileHandler()
|
||||
@ -487,10 +490,17 @@ class AntOSDK extends this.OS.GUI.BaseApplication
|
||||
return fn() unless @isDirty()
|
||||
@ask "__(Unsaved project)", "__(Ignore unsaved project ?)", () ->
|
||||
fn()
|
||||
when "#{@name}-Save"
|
||||
return unless @prjfile
|
||||
@prjfile.write "object", (r) ->
|
||||
return me.error __("Cannot save project: {0}", r.error) if r.error
|
||||
me.notify __("project saved")
|
||||
me.prjfile.dirty = false
|
||||
|
||||
|
||||
actionBuild: (e) ->
|
||||
me = @
|
||||
return unless @prjfile
|
||||
switch e
|
||||
when "#{@name}-Run" then me.bnR()
|
||||
when "#{@name}-Build"
|
||||
@ -498,7 +508,11 @@ class AntOSDK extends this.OS.GUI.BaseApplication
|
||||
me.log "ERROR", ex.toString()
|
||||
when "#{@name}-Release"
|
||||
me.buildAndRelease()
|
||||
|
||||
when "#{@name}-Options"
|
||||
me.openDialog new BuildDialog(), (d) ->
|
||||
me.prjfile.cache[k] = v for k, v of d
|
||||
me.prjfile.dirty = true
|
||||
, "__(Add files to build target)"
|
||||
|
||||
isDirty: () ->
|
||||
return false unless @tabarea
|
||||
@ -512,9 +526,10 @@ class AntOSDK extends this.OS.GUI.BaseApplication
|
||||
me = @
|
||||
evt.preventDefault()
|
||||
dirties = ( v for v in @tabarea.get "items" when v.dirty )
|
||||
@ask "__(Quit)", __("Ignore all {0} unsaved files ?", dirties.length), () ->
|
||||
m = __("Ignore: {0} unsaved files {1}?", dirties.length, if @prjfile.dirty then "__(and unsaved project)" else "")
|
||||
@ask "__(Quit)", m, () ->
|
||||
v.dirty = false for v in dirties
|
||||
@prjfile.dirty = false
|
||||
me.prjfile.dirty = false
|
||||
me.quit()
|
||||
|
||||
log: (t, m) ->
|
||||
|
@ -110,4 +110,11 @@ afx-tab-bar[data-id="tabarea"] afx-list-view{
|
||||
afx-tab-bar[data-id="tabarea"] afx-list-view > div.list-container > ul > li.selected {
|
||||
background-color: #f6F6F6;
|
||||
border-radius: 0;
|
||||
}
|
||||
afx-app-window[data-id="BuildDialog"] afx-label.header {
|
||||
font-weight: bold;
|
||||
margin: 0;
|
||||
}
|
||||
afx-app-window[data-id="BuildDialog"] afx-list-view {
|
||||
border: 1px solid #a6A6A6;
|
||||
}
|
@ -60,9 +60,6 @@ class BloggerCategoryDialog extends this.OS.GUI.BasicDialog
|
||||
(d.find "bt0").trigger() if e.which is 13
|
||||
}
|
||||
|
||||
|
||||
this.OS.register "BloggerCategoryDialog", BloggerCategoryDialog
|
||||
|
||||
# This dialog is use for cv section editing
|
||||
|
||||
class BloggerCVSectionDiaglog extends this.OS.GUI.BaseDialog
|
||||
@ -102,5 +99,4 @@ class BloggerCVSectionDiaglog extends this.OS.GUI.BaseDialog
|
||||
container = @find "editor-container"
|
||||
children = ($ container).children()
|
||||
cheight = ($ container).height() - 30
|
||||
($ children[1]).css("height", cheight + "px")
|
||||
this.OS.register "BloggerCVSectionDiaglog", BloggerCVSectionDiaglog
|
||||
($ children[1]).css("height", cheight + "px")
|
@ -52,7 +52,7 @@ class Blogger extends this.OS.GUI.BaseApplication
|
||||
me.saveUser()
|
||||
|
||||
(@find "cv-cat-add").set "onbtclick", (e) ->
|
||||
me.openDialog "BloggerCategoryDialog",
|
||||
me.openDialog new BloggerCategoryDialog(),
|
||||
(d) ->
|
||||
c =
|
||||
name: d.value,
|
||||
@ -68,7 +68,7 @@ class Blogger extends this.OS.GUI.BaseApplication
|
||||
(@find "cv-cat-edit").set "onbtclick", (e) ->
|
||||
cat = me.cvlist.get "selectedItem"
|
||||
return unless cat
|
||||
me.openDialog "BloggerCategoryDialog", (d) ->
|
||||
me.openDialog new BloggerCategoryDialog(), (d) ->
|
||||
c =
|
||||
id: cat.id,
|
||||
publish: cat.publish,
|
||||
@ -93,7 +93,7 @@ class Blogger extends this.OS.GUI.BaseApplication
|
||||
(@find "cv-sec-add").set "onbtclick", (e) ->
|
||||
cat = me.cvlist.get "selectedItem"
|
||||
return me.notify __("Please select a category") unless cat and cat.id isnt 0
|
||||
me.openDialog "BloggerCVSectionDiaglog", (d) ->
|
||||
me.openDialog new BloggerCVSectionDiaglog(), (d) ->
|
||||
d.cid = Number cat.id
|
||||
d.start = Number d.start
|
||||
d.end = Number d.end
|
||||
@ -108,7 +108,7 @@ class Blogger extends this.OS.GUI.BaseApplication
|
||||
sec = (me.find "cv-sec-list").get "selected"
|
||||
return me.notify __("Please select a section to move") unless sec
|
||||
|
||||
me.openDialog "BloggerCategoryDialog", (d) ->
|
||||
me.openDialog new BloggerCategoryDialog(), (d) ->
|
||||
c =
|
||||
id: sec.id,
|
||||
cid: d.p.id
|
||||
@ -123,7 +123,7 @@ class Blogger extends this.OS.GUI.BaseApplication
|
||||
sec = (me.find "cv-sec-list").get "selected"
|
||||
return me.notify __("Please select a section to edit") unless sec
|
||||
|
||||
me.openDialog "BloggerCVSectionDiaglog", (d) ->
|
||||
me.openDialog new BloggerCVSectionDiaglog(), (d) ->
|
||||
d.cid = Number sec.cid
|
||||
d.start = Number d.start
|
||||
d.end = Number d.end
|
||||
|
@ -62,6 +62,9 @@ afx-app-window[data-id="blogger-win"] afx-list-view[ data-id = "cv-sec-list"] >
|
||||
background-color: transparent;
|
||||
border-radius: 5px;
|
||||
}
|
||||
afx-app-window[data-id="blogger-win"] afx-list-view[ data-id = "cv-sec-list"] > div.list-container > ul > li.selected ul.complex-content li{
|
||||
color: #414339;
|
||||
}
|
||||
afx-app-window[data-id="blogger-win"] afx-list-view[ data-id = "cv-sec-list"] .cv-content{
|
||||
text-align: justify;
|
||||
}
|
||||
|
@ -242,7 +242,7 @@ class Files extends this.OS.GUI.BaseApplication
|
||||
@notify __("File {0} cut", file.filename)
|
||||
|
||||
when "#{@name}-copy"
|
||||
return unless file
|
||||
return unless file or file.type is "dir"
|
||||
@clipboard =
|
||||
cut: false
|
||||
file: file.path.asFileHandler()
|
||||
@ -257,8 +257,14 @@ class Files extends this.OS.GUI.BaseApplication
|
||||
me.clipboard = undefined
|
||||
me.error __("Fail to paste: {0}", r.error) if r.error
|
||||
else
|
||||
@notify __("Copy not yet implemented")
|
||||
@clipboard = undefined
|
||||
@clipboard.file.read (d) ->
|
||||
blob = new Blob [d], { type: me.clipboard.file.info.mime }
|
||||
fp = "#{me.currdir.path}/#{me.clipboard.file.basename}".asFileHandler()
|
||||
fp.cache = blob
|
||||
fp.write me.clipboard.file.info.mime, (r) ->
|
||||
me.clipboard = undefined
|
||||
me.error __("Fail to paste: {0}", r.error) if r.error
|
||||
, "binary"
|
||||
else
|
||||
@_api.handler.setting()
|
||||
|
||||
|
@ -90,5 +90,4 @@ RepositoryDialog.scheme = """
|
||||
</div>
|
||||
</afx-vbox>
|
||||
</afx-app-window>
|
||||
"""
|
||||
this.OS.register "RepositoryDialog", RepositoryDialog
|
||||
"""
|
@ -52,7 +52,7 @@ class MarketPlace extends this.OS.GUI.BaseApplication
|
||||
@btremove.set "onbtclick", (e) ->
|
||||
me.uninstall e
|
||||
@bindKey "CTRL-R", () ->
|
||||
me.openDialog "RepositoryDialog"
|
||||
me.openDialog new RepositoryDialog()
|
||||
fetchApps: (url) ->
|
||||
me = @
|
||||
@_api.get url, ( d ) ->
|
||||
@ -93,7 +93,7 @@ class MarketPlace extends this.OS.GUI.BaseApplication
|
||||
{ text: "__(Options)", child: [
|
||||
{ text: "__(Repositories)", shortcut: "C-R" }
|
||||
] , onmenuselect: (e) ->
|
||||
me.openDialog "RepositoryDialog"
|
||||
me.openDialog new RepositoryDialog()
|
||||
}
|
||||
]
|
||||
|
||||
|
Reference in New Issue
Block a user