2018-03-15 11:00:24 +01:00
|
|
|
# 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/.
|
|
|
|
|
2020-05-13 19:03:39 +02:00
|
|
|
class StartupHandle extends SettingHandle
|
|
|
|
constructor: (scheme, parent) ->
|
2018-03-12 18:55:40 +01:00
|
|
|
super(scheme, parent)
|
|
|
|
me = @
|
|
|
|
@srvlist = @find "srvlist"
|
|
|
|
@applist = @find "applist"
|
|
|
|
@srvlist.set "buttons", [
|
|
|
|
{
|
|
|
|
text: "+", onbtclick: (e) ->
|
|
|
|
services = []
|
|
|
|
for k, v of me.parent.systemsetting.system.packages
|
|
|
|
if v.services
|
2020-05-13 19:03:39 +02:00
|
|
|
srvs = ({ text: "#{k}/#{x}", iconclass: "fa fa-tasks" } for x in v.services)
|
2018-03-12 18:55:40 +01:00
|
|
|
services = services.concat srvs
|
2020-05-13 19:03:39 +02:00
|
|
|
me.parent.openDialog("SelectionDialog", {
|
|
|
|
title: "__(Add service)",
|
|
|
|
data: services
|
|
|
|
}).then (d) ->
|
|
|
|
me.parent.systemsetting.system.startup.services.push d.text
|
|
|
|
me.refresh()
|
2018-03-12 18:55:40 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
text: "-", onbtclick: (e) ->
|
2020-05-13 19:03:39 +02:00
|
|
|
item = me.srvlist.get "selectedItem"
|
|
|
|
return unless item
|
|
|
|
selidx = $(item).index()
|
|
|
|
me.parent.systemsetting.system.startup.services.splice selidx, 1
|
|
|
|
me.refresh()
|
2018-03-12 18:55:40 +01:00
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
@applist.set "buttons", [
|
|
|
|
{
|
|
|
|
text: "+", onbtclick: (e) ->
|
|
|
|
apps = ( { text: k, iconclass: v.iconclass } for k, v of me.parent.systemsetting.system.packages )
|
2020-05-13 19:03:39 +02:00
|
|
|
me.parent.openDialog("SelectionDialog", {
|
|
|
|
title: "__(Add application)",
|
|
|
|
data: apps
|
|
|
|
}).then (d) ->
|
|
|
|
me.parent.systemsetting.system.startup.apps.push d.text
|
|
|
|
me.refresh()
|
2018-03-12 18:55:40 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
text: "-", onbtclick: (e) ->
|
2020-05-13 19:03:39 +02:00
|
|
|
item = me.applist.get "selectedItem"
|
|
|
|
return unless item
|
|
|
|
selidx = $(item).index()
|
|
|
|
me.parent.systemsetting.system.startup.apps.splice selidx, 1
|
|
|
|
me.refresh()
|
2018-03-12 18:55:40 +01:00
|
|
|
}
|
|
|
|
]
|
2020-05-13 19:03:39 +02:00
|
|
|
@refresh()
|
2018-03-12 18:55:40 +01:00
|
|
|
|
2020-05-13 19:03:39 +02:00
|
|
|
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 )
|
2018-03-12 18:55:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
mkdialog: () ->
|
|
|
|
return @parent._gui.mkdialog {
|
|
|
|
name: "StartupDialog",
|
|
|
|
layout: {
|
|
|
|
tags: [
|
|
|
|
{ tag: "afx-list-view" }
|
|
|
|
],
|
|
|
|
width: 250,
|
|
|
|
height: 200,
|
|
|
|
resizable: false,
|
|
|
|
buttons: [
|
|
|
|
{
|
|
|
|
label: "__(Ok)", onclick: (d) ->
|
|
|
|
sel = (d.find "content0").get "selected"
|
|
|
|
return d.error __("Please select an entry") unless sel
|
|
|
|
d.handler(sel.text) if d.handler
|
|
|
|
d.quit()
|
|
|
|
},
|
|
|
|
{ label: "__(Cancel)", onclick: (d) -> d.quit() }
|
|
|
|
],
|
|
|
|
filldata: (dia) ->
|
|
|
|
|
|
|
|
(dia.find "content0").set "items", dia.data if dia.data
|
|
|
|
}
|
|
|
|
}
|