switch to es6 from coffeescript

This commit is contained in:
Xuan Sang LE
2020-05-24 13:17:59 +02:00
parent f11509120e
commit 759cd1fc6f
122 changed files with 10658 additions and 8702 deletions

View File

@ -1,104 +0,0 @@
# Copyright 2017-2018 Xuan Sang LE <xsang.le AT gmail DOT com>
# AnTOS Web desktop is is licensed under the GNU General Public
# License v3.0, see the LICENCE file for more information
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
# You should have received a copy of the GNU General Public License
#along with this program. If not, see https://www.gnu.org/licenses/.
class AppearanceHandle extends SettingHandle
constructor:(scheme, parent) ->
super(scheme, parent)
@wplist = @find "wplist"
@wpreview = @find "wp-preview"
@wpsize = @find "wpsize"
@wprepeat = @find "wprepeat"
@themelist = @find "theme-list"
@syswp = undefined
@wplist.set "onlistselect", (e) =>
data = e.data.item.get("data")
$(@wpreview)
.css("background-image", "url(#{data.path.asFileHandle().getlink()})" )
.css("background-size", "cover")
@parent.systemsetting.appearance.wp.url = data.path
@parent._gui.wallpaper()
@wplist.set "buttons", [
{
text: "+", onbtclick: (e) =>
@parent.openDialog("FileDialog", {
title: __("Select image file"),
mimes: ["image/.*"]
}).then (d) =>
@parent.systemsetting.appearance.wps.push d.file.path
@wplist.set "data", @getwplist()
}
]
@wpsize.set "onlistselect", (e) =>
@parent.systemsetting.appearance.wp.size = e.data.item.get("data").text
@parent._gui.wallpaper()
sizes = [
{ text: "cover", selected: @parent.systemsetting.appearance.wp.size is "cover" },
{ text: "auto", selected: @parent.systemsetting.appearance.wp.size is "auto" },
{ text: "contain", selected: @parent.systemsetting.appearance.wp.size is "contain" }
]
@wpsize.set "data", sizes
repeats = [
{ text: "repeat", selected: @parent.systemsetting.appearance.wp.repeat is "repeat" },
{ text: "repeat-x", selected: @parent.systemsetting.appearance.wp.repeat is "repeat-x" },
{ text: "repeat-y", selected: @parent.systemsetting.appearance.wp.repeat is "repeat-y" },
{ text: "no-repeat", selected: @parent.systemsetting.appearance.wp.repeat is "no-repeat" }
]
@wprepeat.set "onlistselect", (e) =>
@parent.systemsetting.appearance.wp.repeat = e.data.item.get("data").text
@parent._gui.wallpaper()
@wprepeat.set "data", repeats
currtheme = @parent.systemsetting.appearance.theme
v.selected = v.name is currtheme for v in @parent.systemsetting.appearance.themes
@themelist.set "data" , @parent.systemsetting.appearance.themes
@themelist.set "onlistselect", (e) =>
data = e.data.item.get("data") if e and e.data
return unless data
return if data.name is @parent.systemsetting.appearance.theme
@parent.systemsetting.appearance.theme = data.name
@parent._gui.loadTheme data.name, true
if not @syswp
path = "os://resources/themes/system/wp"
path.asFileHandle().read()
.then (d) =>
return @parent.error __("Cannot read wallpaper list from {0}", path) if d.error
for v in d.result
v.text = v.filename
v.iconclass = "fa fa-file-image-o"
@syswp = d.result
@wplist.set "data", @getwplist()
.catch (e) => @parent.error __("Unable to read: {0}", path), e
else
@wplist.set "data", @getwplist()
getwplist: () ->
list = []
for v in @parent.systemsetting.appearance.wps
file = v.asFileHandle()
list.push
text: file.basename,
path: file.path
selected: file.path is @parent.systemsetting.appearance.wp.url,
iconclass: "fa fa-file-image-o"
list = list.concat @syswp
v.selected = v.path is @parent.systemsetting.appearance.wp.url for v in list
return list

View File

@ -0,0 +1,126 @@
/*
* decaffeinate suggestions:
* DS101: Remove unnecessary use of Array.from
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
// Copyright 2017-2018 Xuan Sang LE <xsang.le AT gmail DOT com>
// AnTOS Web desktop is is licensed under the GNU General Public
// License v3.0, see the LICENCE file for more information
// This program is free software: you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// You should have received a copy of the GNU General Public License
//along with this program. If not, see https://www.gnu.org/licenses/.
class AppearanceHandle extends SettingHandle {
constructor(scheme, parent) {
let v;
super(scheme, parent);
this.wplist = this.find("wplist");
this.wpreview = this.find("wp-preview");
this.wpsize = this.find("wpsize");
this.wprepeat = this.find("wprepeat");
this.themelist = this.find("theme-list");
this.syswp = undefined;
this.wplist.set("onlistselect", e => {
const data = e.data.item.get("data");
$(this.wpreview)
.css("background-image", `url(${data.path.asFileHandle().getlink()})` )
.css("background-size", "cover");
this.parent.systemsetting.appearance.wp.url = data.path;
return this.parent._gui.wallpaper();
});
this.wplist.set("buttons", [
{
text: "+", onbtclick: e => {
return this.parent.openDialog("FileDialog", {
title: __("Select image file"),
mimes: ["image/.*"]
}).then(d => {
this.parent.systemsetting.appearance.wps.push(d.file.path);
return this.wplist.set("data", this.getwplist());
});
}
}
]);
this.wpsize.set("onlistselect", e => {
this.parent.systemsetting.appearance.wp.size = e.data.item.get("data").text;
return this.parent._gui.wallpaper();
});
const sizes = [
{ text: "cover", selected: this.parent.systemsetting.appearance.wp.size === "cover" },
{ text: "auto", selected: this.parent.systemsetting.appearance.wp.size === "auto" },
{ text: "contain", selected: this.parent.systemsetting.appearance.wp.size === "contain" }
];
this.wpsize.set("data", sizes);
const repeats = [
{ text: "repeat", selected: this.parent.systemsetting.appearance.wp.repeat === "repeat" },
{ text: "repeat-x", selected: this.parent.systemsetting.appearance.wp.repeat === "repeat-x" },
{ text: "repeat-y", selected: this.parent.systemsetting.appearance.wp.repeat === "repeat-y" },
{ text: "no-repeat", selected: this.parent.systemsetting.appearance.wp.repeat === "no-repeat" }
];
this.wprepeat.set("onlistselect", e => {
this.parent.systemsetting.appearance.wp.repeat = e.data.item.get("data").text;
return this.parent._gui.wallpaper();
});
this.wprepeat.set("data", repeats);
const currtheme = this.parent.systemsetting.appearance.theme;
for (v of Array.from(this.parent.systemsetting.appearance.themes)) { v.selected = v.name === currtheme; }
this.themelist.set("data" , this.parent.systemsetting.appearance.themes);
this.themelist.set("onlistselect", e => {
let data;
if (e && e.data) { data = e.data.item.get("data"); }
if (!data) { return; }
if (data.name === this.parent.systemsetting.appearance.theme) { return; }
this.parent.systemsetting.appearance.theme = data.name;
return this.parent._gui.loadTheme(data.name, true);
});
if (!this.syswp) {
const path = "os://resources/themes/system/wp";
path.asFileHandle().read()
.then(d => {
if (d.error) { return this.parent.error(__("Cannot read wallpaper list from {0}", path)); }
for (v of Array.from(d.result)) {
v.text = v.filename;
v.iconclass = "fa fa-file-image-o";
}
this.syswp = d.result;
return this.wplist.set("data", this.getwplist());
}).catch(e => this.parent.error(__("Unable to read: {0}", path), e));
} else {
this.wplist.set("data", this.getwplist());
}
}
getwplist() {
let v;
let list = [];
for (v of Array.from(this.parent.systemsetting.appearance.wps)) {
const file = v.asFileHandle();
list.push({
text: file.basename,
path: file.path,
selected: file.path === this.parent.systemsetting.appearance.wp.url,
iconclass: "fa fa-file-image-o"
});
}
list = list.concat(this.syswp);
for (v of Array.from(list)) { v.selected = v.path === this.parent.systemsetting.appearance.wp.url; }
return list;
}
}

View File

@ -1,38 +0,0 @@
# Copyright 2017-2018 Xuan Sang LE <xsang.le AT gmail DOT com>
# AnTOS Web desktop is is licensed under the GNU General Public
# License v3.0, see the LICENCE file for more information
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
# You should have received a copy of the GNU General Public License
#along with this program. If not, see https://www.gnu.org/licenses/.
class LocaleHandle extends SettingHandle
constructor: (scheme, parent) ->
super(scheme, parent)
@lglist = @find "lglist"
@localelist = undefined
@lglist.set "onlistselect", (e) =>
@parent._api.setLocale e.data.item.get("data").text
if not @localelist
path = "os://resources/languages"
path.asFileHandle().read()
.then (d) =>
return @parent.error __("Cannot fetch system locales: {0}", d.error) if d.derror
for v in d.result
v.text = v.filename.replace /\.json$/g, ""
v.selected = v.text is @parent.systemsetting.system.locale
@localelist = d.result
@lglist.set "data", @localelist
.catch (e) => @parent.error __("Unable to read: {0}", path), e
else
@lglist.set "data", @localelist

View File

@ -0,0 +1,49 @@
/*
* decaffeinate suggestions:
* DS101: Remove unnecessary use of Array.from
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
// Copyright 2017-2018 Xuan Sang LE <xsang.le AT gmail DOT com>
// AnTOS Web desktop is is licensed under the GNU General Public
// License v3.0, see the LICENCE file for more information
// This program is free software: you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// You should have received a copy of the GNU General Public License
//along with this program. If not, see https://www.gnu.org/licenses/.
class LocaleHandle extends SettingHandle {
constructor(scheme, parent) {
super(scheme, parent);
this.lglist = this.find("lglist");
this.localelist = undefined;
this.lglist.set("onlistselect", e => {
return this.parent._api.setLocale(e.data.item.get("data").text);
});
if (!this.localelist) {
const path = "os://resources/languages";
path.asFileHandle().read()
.then(d => {
if (d.derror) { return this.parent.error(__("Cannot fetch system locales: {0}", d.error)); }
for (let v of Array.from(d.result)) {
v.text = v.filename.replace(/\.json$/g, "");
v.selected = v.text === this.parent.systemsetting.system.locale;
}
this.localelist = d.result;
return this.lglist.set("data", this.localelist);
}).catch(e => this.parent.error(__("Unable to read: {0}", path), e));
} else {
this.lglist.set("data", this.localelist);
}
}
}

View File

@ -1,6 +1,6 @@
coffee_files = main.coffee AppearanceHandle.coffee VFSHandle.coffee LocaleHandle.coffee StartupHandle.coffee
module_files = main.js AppearanceHandle.js VFSHandle.js LocaleHandle.js StartupHandle.js
jsfiles =
libfiles =
cssfiles = main.css

View File

@ -1,73 +0,0 @@
# Copyright 2017-2018 Xuan Sang LE <xsang.le AT gmail DOT com>
# AnTOS Web desktop is is licensed under the GNU General Public
# License v3.0, see the LICENCE file for more information
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
# You should have received a copy of the GNU General Public License
#along with this program. If not, see https://www.gnu.org/licenses/.
class StartupHandle extends SettingHandle
constructor: (scheme, parent) ->
super(scheme, parent)
@srvlist = @find "srvlist"
@applist = @find "applist"
@srvlist.set "buttons", [
{
text: "+", onbtclick: (e) =>
services = []
for k, v of @parent.systemsetting.system.packages
if v.services
srvs = ({ text: "#{k}/#{x}", iconclass: "fa fa-tasks" } for x in v.services)
services = services.concat srvs
@parent.openDialog("SelectionDialog", {
title: "__(Add service)",
data: services
}).then (d) =>
@parent.systemsetting.system.startup.services.push d.text
@refresh()
},
{
text: "-", onbtclick: (e) =>
item = @srvlist.get "selectedItem"
return unless item
selidx = $(item).index()
@parent.systemsetting.system.startup.services.splice selidx, 1
@refresh()
}
]
@applist.set "buttons", [
{
text: "+", onbtclick: (e) =>
apps = ( { text: k, iconclass: v.iconclass } for k, v of @parent.systemsetting.system.packages )
@parent.openDialog("SelectionDialog", {
title: "__(Add application)",
data: apps
}).then (d) =>
@parent.systemsetting.system.startup.apps.push d.text
@refresh()
},
{
text: "-", onbtclick: (e) =>
item = @applist.get "selectedItem"
return unless item
selidx = $(item).index()
@parent.systemsetting.system.startup.apps.splice selidx, 1
@refresh()
}
]
@refresh()
refresh: () ->
@srvlist.set "data", ( { text:v } for v in @parent.systemsetting.system.startup.services )
@applist.set "data", ( { text:v } for v in @parent.systemsetting.system.startup.apps )

View File

@ -0,0 +1,110 @@
/*
* decaffeinate suggestions:
* DS101: Remove unnecessary use of Array.from
* DS102: Remove unnecessary code created because of implicit returns
* DS205: Consider reworking code to avoid use of IIFEs
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
// Copyright 2017-2018 Xuan Sang LE <xsang.le AT gmail DOT com>
// AnTOS Web desktop is is licensed under the GNU General Public
// License v3.0, see the LICENCE file for more information
// This program is free software: you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// You should have received a copy of the GNU General Public License
//along with this program. If not, see https://www.gnu.org/licenses/.
class StartupHandle extends SettingHandle {
constructor(scheme, parent) {
super(scheme, parent);
this.srvlist = this.find("srvlist");
this.applist = this.find("applist");
this.srvlist.set("buttons", [
{
text: "+", onbtclick: e => {
let services = [];
for (var k in this.parent.systemsetting.system.packages) {
const v = this.parent.systemsetting.system.packages[k];
if (v.services) {
const srvs = (Array.from(v.services).map((x) => ({ text: `${k}/${x}`, iconclass: "fa fa-tasks" })));
services = services.concat(srvs);
}
}
return this.parent.openDialog("SelectionDialog", {
title: "__(Add service)",
data: services
}).then(d => {
this.parent.systemsetting.system.startup.services.push(d.text);
return this.refresh();
});
}
},
{
text: "-", onbtclick: e => {
const item = this.srvlist.get("selectedItem");
if (!item) { return; }
const selidx = $(item).index();
this.parent.systemsetting.system.startup.services.splice(selidx, 1);
return this.refresh();
}
}
]);
this.applist.set("buttons", [
{
text: "+", onbtclick: e => {
const apps = ((() => {
const result = [];
for (let k in this.parent.systemsetting.system.packages) {
const v = this.parent.systemsetting.system.packages[k];
result.push({ text: k, iconclass: v.iconclass });
}
return result;
})());
return this.parent.openDialog("SelectionDialog", {
title: "__(Add application)",
data: apps
}).then(d => {
this.parent.systemsetting.system.startup.apps.push(d.text);
return this.refresh();
});
}
},
{
text: "-", onbtclick: e => {
const item = this.applist.get("selectedItem");
if (!item) { return; }
const selidx = $(item).index();
this.parent.systemsetting.system.startup.apps.splice(selidx, 1);
return this.refresh();
}
}
]);
this.refresh();
}
refresh() {
let v;
this.srvlist.set("data", ((() => {
const result = [];
for (v of Array.from(this.parent.systemsetting.system.startup.services)) { result.push({ text:v });
}
return result;
})()));
return this.applist.set("data", ((() => {
const result1 = [];
for (v of Array.from(this.parent.systemsetting.system.startup.apps)) { result1.push({ text:v });
}
return result1;
})()));
}
}

View File

@ -1,148 +0,0 @@
# Copyright 2017-2018 Xuan Sang LE <xsang.le AT gmail DOT com>
# AnTOS Web desktop is is licensed under the GNU General Public
# License v3.0, see the LICENCE file for more information
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
# You should have received a copy of the GNU General Public License
#along with this program. If not, see https://www.gnu.org/licenses/.
class VFSSettingDialog extends this.OS.GUI.BasicDialog
constructor: () ->
super "VFSSettingDialog", VFSSettingDialog.scheme
main: () ->
super.main()
$(@find("txtPath")).click (e) =>
@openDialog("FileDialog", {
title: "__(Select a directory)",
mimes: ["dir"],
hidden: true
})
.then (d) =>
(@find "txtPath").value = d.file.path
@find("btnOk").set "onbtclick", (e) =>
data = {
path: (@find "txtPath").value,
name: (@find "txtName").value
}
return @error __("Please enter mount point name") unless data.name and data.name isnt ""
return @error __("Please select a directory") unless data.path and data.path isnt ""
@handle(data) if @handle
@quit()
(@find "btnCancel").set "onbtclick", (e) =>
@quit()
return unless @data
(@find "txtName").value = @data.text if @data.text
(@find "txtPath").value = @data.path if @data.path
VFSSettingDialog.scheme = """
<afx-app-window width='250' height='180' apptitle = "__(Mount Points)">
<afx-vbox>
<afx-hbox>
<div data-width = "10" />
<afx-vbox>
<div data-height="10" />
<afx-label data-height="30" text = "__(Name)" />
<input type = "text" data-id= "txtName" />
<div data-height="3" />
<afx-label data-height="30" text = "__(Path)" />
<input type = "text" data-id= "txtPath" />
<div data-height="10" />
<afx-hbox data-height="30">
<div />
<afx-button data-id = "btnOk" text = "__(Ok)" data-width = "40" />
<afx-button data-id = "btnCancel" text = "__(Cancel)" data-width = "50" />
</afx-hbox>
</afx-vbox>
<div data-width = "10" />
</afx-hbox>
</afx-vbox>
</afx-app-window>
"""
class VFSHandle extends SettingHandle
constructor: (scheme, parent) ->
super(scheme, parent)
@mplist = @find "mplist"
@dpath = @find "dpath"
@ppath = @find "ppath"
@mplist.set "buttons", [
{
text: "+",
onbtclick: (e) =>
@parent.openDialog(new VFSSettingDialog(), {
title: "__(Add mount point)"
})
.then (d) =>
@parent.systemsetting.VFS.mountpoints.push {
text: d.name, path: d.path, iconclass: "fa fa-folder", type: "fs"
}
@refresh()
},
{
text: "-",
onbtclick: (e) =>
item = @mplist.get "selectedItem"
return unless item
selidx = $(item).index()
@parent.openDialog("YesNoDialog", {
title: "__(Remove)",
text: __("Remove: {0}?", item.get("data").text)
}).then (d) =>
return unless d
@parent.systemsetting.VFS.mountpoints.splice selidx, 1
@refresh()
},
{
text: "",
iconclass: "fa fa-pencil",
onbtclick: (e) =>
sel = @mplist.get "selectedItem"
return unless sel
@parent.openDialog(new VFSSettingDialog(), {
title: "__(Edit mount point)",
text: sel.get("data").text,
path: sel.get("data").path
}).then (d) =>
sel.get("data").text = d.name
sel.get("data").path = d.path
@refresh()
}
]
(@find "btndpath").set 'onbtclick', (e) =>
@parent.openDialog("FileDialog", {
title: "__(Select a directory)",
mimes: ["dir"],
hidden: true
}).then (d) =>
@parent.systemsetting.desktop.path = d.file.path
@parent._gui.refreshDesktop()
@refresh()
(@find "btnppath").set 'onbtclick', (e) =>
@parent.openDialog("FileDialog", {
title: "__(Select a directory)",
mimes: ["dir"],
hidden: true
}).then (d) =>
@parent.systemsetting.system.pkgpaths.user = d.file.path
@refresh()
@refresh()
refresh: () ->
@mplist.set "data", @parent.systemsetting.VFS.mountpoints
@dpath.set "text", @parent.systemsetting.desktop.path
@ppath.set "text", @parent.systemsetting.system.pkgpaths.user

View File

@ -0,0 +1,173 @@
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
// Copyright 2017-2018 Xuan Sang LE <xsang.le AT gmail DOT com>
// AnTOS Web desktop is is licensed under the GNU General Public
// License v3.0, see the LICENCE file for more information
// This program is free software: you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// You should have received a copy of the GNU General Public License
//along with this program. If not, see https://www.gnu.org/licenses/.
class VFSSettingDialog extends this.OS.GUI.BasicDialog {
constructor() {
super("VFSSettingDialog", VFSSettingDialog.scheme);
}
main() {
super.main();
$(this.find("txtPath")).click(e => {
return this.openDialog("FileDialog", {
title: "__(Select a directory)",
mimes: ["dir"],
hidden: true
})
.then(d => {
return (this.find("txtPath")).value = d.file.path;
});
});
this.find("btnOk").set("onbtclick", e => {
const data = {
path: (this.find("txtPath")).value,
name: (this.find("txtName")).value
};
if (!data.name || (data.name === "")) { return this.error(__("Please enter mount point name")); }
if (!data.path || (data.path === "")) { return this.error(__("Please select a directory")); }
if (this.handle) { this.handle(data); }
return this.quit();
});
(this.find("btnCancel")).set("onbtclick", e => {
return this.quit();
});
if (!this.data) { return; }
if (this.data.text) { (this.find("txtName")).value = this.data.text; }
if (this.data.path) { return (this.find("txtPath")).value = this.data.path; }
}
}
VFSSettingDialog.scheme = `\
<afx-app-window width='250' height='180' apptitle = "__(Mount Points)">
<afx-vbox>
<afx-hbox>
<div data-width = "10" />
<afx-vbox>
<div data-height="10" />
<afx-label data-height="30" text = "__(Name)" />
<input type = "text" data-id= "txtName" />
<div data-height="3" />
<afx-label data-height="30" text = "__(Path)" />
<input type = "text" data-id= "txtPath" />
<div data-height="10" />
<afx-hbox data-height="30">
<div />
<afx-button data-id = "btnOk" text = "__(Ok)" data-width = "40" />
<afx-button data-id = "btnCancel" text = "__(Cancel)" data-width = "50" />
</afx-hbox>
</afx-vbox>
<div data-width = "10" />
</afx-hbox>
</afx-vbox>
</afx-app-window>\
`;
class VFSHandle extends SettingHandle {
constructor(scheme, parent) {
super(scheme, parent);
this.mplist = this.find("mplist");
this.dpath = this.find("dpath");
this.ppath = this.find("ppath");
this.mplist.set("buttons", [
{
text: "+",
onbtclick: e => {
return this.parent.openDialog(new VFSSettingDialog(), {
title: "__(Add mount point)"
})
.then(d => {
this.parent.systemsetting.VFS.mountpoints.push({
text: d.name, path: d.path, iconclass: "fa fa-folder", type: "fs"
});
return this.refresh();
});
}
},
{
text: "-",
onbtclick: e => {
const item = this.mplist.get("selectedItem");
if (!item) { return; }
const selidx = $(item).index();
return this.parent.openDialog("YesNoDialog", {
title: "__(Remove)",
text: __("Remove: {0}?", item.get("data").text)
}).then(d => {
if (!d) { return; }
this.parent.systemsetting.VFS.mountpoints.splice(selidx, 1);
return this.refresh();
});
}
},
{
text: "",
iconclass: "fa fa-pencil",
onbtclick: e => {
const sel = this.mplist.get("selectedItem");
if (!sel) { return; }
return this.parent.openDialog(new VFSSettingDialog(), {
title: "__(Edit mount point)",
text: sel.get("data").text,
path: sel.get("data").path
}).then(d => {
sel.get("data").text = d.name;
sel.get("data").path = d.path;
return this.refresh();
});
}
}
]);
(this.find("btndpath")).set('onbtclick', e => {
return this.parent.openDialog("FileDialog", {
title: "__(Select a directory)",
mimes: ["dir"],
hidden: true
}).then(d => {
this.parent.systemsetting.desktop.path = d.file.path;
this.parent._gui.refreshDesktop();
return this.refresh();
});
});
(this.find("btnppath")).set('onbtclick', e => {
return this.parent.openDialog("FileDialog", {
title: "__(Select a directory)",
mimes: ["dir"],
hidden: true
}).then(d => {
this.parent.systemsetting.system.pkgpaths.user = d.file.path;
return this.refresh();
});
});
this.refresh();
}
refresh() {
this.mplist.set("data", this.parent.systemsetting.VFS.mountpoints);
this.dpath.set("text", this.parent.systemsetting.desktop.path);
return this.ppath.set("text", this.parent.systemsetting.system.pkgpaths.user);
}
}

View File

@ -1,46 +0,0 @@
# Copyright 2017-2018 Xuan Sang LE <xsang.le AT gmail DOT com>
# AnTOS Web desktop is is licensed under the GNU General Public
# License v3.0, see the LICENCE file for more information
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
# You should have received a copy of the GNU General Public License
#along with this program. If not, see https://www.gnu.org/licenses/.
class SettingHandle
constructor: (@scheme, @parent) ->
find: (id) -> ($ "[data-id='#{id}']", @scheme)[0] if @scheme
render: () ->
class Setting extends this.OS.GUI.BaseApplication
constructor: (args) ->
super "Setting", args
main: () ->
@container = @find "container"
new AppearanceHandle @find("appearance"), @
new VFSHandle @find("vfs"), @
new LocaleHandle @find("locale"), @
new StartupHandle @find("startup"), @
(@find "btnsave").set "onbtclick", (e) =>
@_api.setting()
.then (d) =>
return @error __("Cannot save system setting: {0}", d.error) if d.error
@notify __("System setting saved")
.catch (e) =>
@error __("Cannot save system setting: {0}", e.toString()), e
Setting.singleton = true
this.OS.register "Setting", Setting

View File

@ -0,0 +1,61 @@
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* DS208: Avoid top-level this
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
// Copyright 2017-2018 Xuan Sang LE <xsang.le AT gmail DOT com>
// AnTOS Web desktop is is licensed under the GNU General Public
// License v3.0, see the LICENCE file for more information
// This program is free software: you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// You should have received a copy of the GNU General Public License
//along with this program. If not, see https://www.gnu.org/licenses/.
class SettingHandle {
constructor(scheme, parent) {
this.scheme = scheme;
this.parent = parent;
}
find(id) { if (this.scheme) { return ($(`[data-id='${id}']`, this.scheme))[0]; } }
render() {}
}
class Setting extends this.OS.GUI.BaseApplication {
constructor(args) {
super("Setting", args);
}
main() {
this.container = this.find("container");
new AppearanceHandle(this.find("appearance"), this);
new VFSHandle(this.find("vfs"), this);
new LocaleHandle(this.find("locale"), this);
new StartupHandle(this.find("startup"), this);
return (this.find("btnsave")).set("onbtclick", e => {
return this._api.setting()
.then(d => {
if (d.error) { return this.error(__("Cannot save system setting: {0}", d.error)); }
return this.notify(__("System setting saved"));
}).catch(e => {
return this.error(__("Cannot save system setting: {0}", e.toString()), e);
});
});
}
}
Setting.singleton = true;
this.OS.register("Setting", Setting);