mirror of
https://github.com/lxsang/antos-frontend.git
synced 2025-07-29 04:09:45 +02:00
Add features:
- allow pinning apps in Setting - pinned apps in system pannel - Services manager in Setting - Fix and impprove some CSS bug
This commit is contained in:
167
src/packages/Setting/AppAndServiceHandle.ts
Normal file
167
src/packages/Setting/AppAndServiceHandle.ts
Normal file
@ -0,0 +1,167 @@
|
||||
/*
|
||||
* 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/.
|
||||
namespace OS {
|
||||
const App = OS.application.Setting;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @class AppAndServiceHandle
|
||||
* @extends {App.SettingHandle}
|
||||
*/
|
||||
class AppAndServiceHandle extends App.SettingHandle {
|
||||
private srvlist: GUI.tag.ListViewTag;
|
||||
private applist: GUI.tag.ListViewTag;
|
||||
|
||||
/**
|
||||
*Creates an instance of AppAndServiceHandle.
|
||||
* @param {HTMLElement} scheme
|
||||
* @param {OS.application.Setting} parent
|
||||
* @memberof AppAndServiceHandle
|
||||
*/
|
||||
constructor(scheme: HTMLElement, parent: OS.application.Setting) {
|
||||
super(scheme, parent);
|
||||
this.srvlist = this.find("sys-srvlist") as GUI.tag.ListViewTag;
|
||||
this.applist = this.find("sys-applist") as GUI.tag.ListViewTag;
|
||||
let services = [];
|
||||
for (var k in setting.system.packages) {
|
||||
const v = setting.system.packages[k];
|
||||
if (v.services) {
|
||||
const srvs = v.services.map((x) => {
|
||||
return {
|
||||
text: `${k}/${x}`,
|
||||
iconclass: "fa fa-tasks",
|
||||
}
|
||||
}
|
||||
);
|
||||
services = services.concat(srvs);
|
||||
}
|
||||
}
|
||||
this.srvlist.data = services;
|
||||
this.srvlist.buttons = [
|
||||
{
|
||||
text: "Start",
|
||||
onbtclick: () => {
|
||||
const item = this.srvlist.selectedItem;
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
GUI
|
||||
.pushService(item.data.text)
|
||||
.catch((e) => this.parent.error(e.toString(), e));
|
||||
},
|
||||
},
|
||||
{
|
||||
text: "Stop",
|
||||
onbtclick: () => {
|
||||
const item = this.srvlist.selectedItem;
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
const arr = item.data.text.split("/");
|
||||
const srv = arr[1];
|
||||
PM.killAll(srv, true);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
this.applist.buttons = [
|
||||
{
|
||||
text: "+",
|
||||
onbtclick: () => {
|
||||
const apps = (() => {
|
||||
const result = [];
|
||||
for (let k in setting.system.packages) {
|
||||
const v = setting.system.packages[k];
|
||||
if(v.app)
|
||||
{
|
||||
result.push({
|
||||
text: v.name,
|
||||
app: k,
|
||||
iconclass: v.iconclass,
|
||||
});
|
||||
}
|
||||
}
|
||||
return result.sort((a,b) =>{
|
||||
if(a.text >b.text) return 1;
|
||||
if(a.text < b.text) return -1;
|
||||
return 0;
|
||||
});
|
||||
})();
|
||||
this.parent
|
||||
.openDialog("SelectionDialog", {
|
||||
title: "__(Add application)",
|
||||
data: apps,
|
||||
})
|
||||
.then((d) => {
|
||||
if (!setting.system.startup.pinned) {
|
||||
setting.system.startup.pinned = [];
|
||||
}
|
||||
if (!setting.system.startup.pinned.includes(d.app)) {
|
||||
setting.system.startup.pinned.push(d.app);
|
||||
return this.refresh();
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
{
|
||||
text: "-",
|
||||
onbtclick: () => {
|
||||
const item = this.applist.selectedItem;
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
const selidx = $(item).index();
|
||||
setting.system.startup.pinned.splice(selidx, 1);
|
||||
return this.refresh();
|
||||
},
|
||||
},
|
||||
];
|
||||
this.refresh();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @private
|
||||
* @memberof AppAndServiceHandle
|
||||
*/
|
||||
private refresh(): void {
|
||||
let v;
|
||||
if (!setting.system.startup.pinned) {
|
||||
return;
|
||||
}
|
||||
this.applist.data = (() => {
|
||||
const result1 = [];
|
||||
for (v of Array.from(setting.system.startup.pinned)) {
|
||||
result1.push({ text: v, iconclass: "fa fa-adn" });
|
||||
}
|
||||
return result1;
|
||||
})();
|
||||
announcer.ostrigger("app-pinned", this.applist.data);
|
||||
}
|
||||
}
|
||||
App.AppAndServiceHandle = AppAndServiceHandle;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
module_files = main.js AppearanceHandle.js VFSHandle.js LocaleHandle.js StartupHandle.js
|
||||
module_files = main.js AppearanceHandle.js AppAndServiceHandle.js VFSHandle.js LocaleHandle.js StartupHandle.js
|
||||
|
||||
libfiles =
|
||||
|
||||
|
@ -66,8 +66,11 @@ namespace OS {
|
||||
data: services,
|
||||
})
|
||||
.then((d) => {
|
||||
setting.system.startup.services.push(d.text);
|
||||
return this.refresh();
|
||||
if(!setting.system.startup.services.includes(d.text))
|
||||
{
|
||||
setting.system.startup.services.push(d.text);
|
||||
return this.refresh();
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
@ -93,12 +96,20 @@ namespace OS {
|
||||
const result = [];
|
||||
for (let k in setting.system.packages) {
|
||||
const v = setting.system.packages[k];
|
||||
result.push({
|
||||
text: k,
|
||||
iconclass: v.iconclass,
|
||||
});
|
||||
if(v.app)
|
||||
{
|
||||
result.push({
|
||||
text: v.name,
|
||||
app: k,
|
||||
iconclass: v.iconclass,
|
||||
});
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return result.sort((a,b) =>{
|
||||
if(a.text >b.text) return 1;
|
||||
if(a.text < b.text) return -1;
|
||||
return 0;
|
||||
});
|
||||
})();
|
||||
this.parent
|
||||
.openDialog("SelectionDialog", {
|
||||
@ -106,8 +117,11 @@ namespace OS {
|
||||
data: apps,
|
||||
})
|
||||
.then((d) => {
|
||||
setting.system.startup.apps.push(d.text);
|
||||
return this.refresh();
|
||||
if(!setting.system.startup.apps.includes(d.app))
|
||||
{
|
||||
setting.system.startup.apps.push(d.app);
|
||||
return this.refresh();
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
@ -138,7 +152,7 @@ namespace OS {
|
||||
this.srvlist.data = (() => {
|
||||
const result = [];
|
||||
for (v of setting.system.startup.services) {
|
||||
result.push({ text: v });
|
||||
result.push({ text: v});
|
||||
}
|
||||
return result;
|
||||
})();
|
||||
|
@ -50,6 +50,11 @@ afx-app-window[data-id = "setting-window"] afx-hbox[data-id="locale"] afx-list-v
|
||||
}
|
||||
/*STARTUP*/
|
||||
afx-app-window[data-id = "setting-window"] afx-hbox[data-id="startup"] afx-list-view
|
||||
{
|
||||
border: 1px solid #cbcbcb;
|
||||
}
|
||||
|
||||
afx-app-window[data-id = "setting-window"] afx-hbox[data-id="app-services"] afx-list-view
|
||||
{
|
||||
border: 1px solid #cbcbcb;
|
||||
}
|
@ -81,6 +81,7 @@ namespace OS {
|
||||
static LocaleHandle: typeof SettingHandle;
|
||||
static StartupHandle: typeof SettingHandle;
|
||||
static SettingHandle: typeof SettingHandle;
|
||||
static AppAndServiceHandle: typeof SettingHandle;
|
||||
|
||||
/**
|
||||
*Creates an instance of Setting.
|
||||
@ -103,6 +104,7 @@ namespace OS {
|
||||
new Setting.VFSHandle(this.find("vfs"), this);
|
||||
new Setting.LocaleHandle(this.find("locale"), this);
|
||||
new Setting.StartupHandle(this.find("startup"), this);
|
||||
new Setting.AppAndServiceHandle(this.find("app-services"), this);
|
||||
|
||||
(this.find("btnsave") as GUI.tag.ButtonTag ).onbtclick = (e) => {
|
||||
this._api
|
||||
|
@ -6,7 +6,7 @@
|
||||
"author": "Xuan Sang LE",
|
||||
"email": "xsang.le@gmail.com"
|
||||
},
|
||||
"version":"0.0.1-a",
|
||||
"version":"0.1.1-a",
|
||||
"category":"System",
|
||||
"iconclass":"fa fa-wrench",
|
||||
"mimes":["none"]
|
||||
|
@ -1,6 +1,6 @@
|
||||
<afx-app-window data-id = "setting-window" apptitle="Setting" width="600" height="400">
|
||||
<afx-app-window data-id = "setting-window" apptitle="Setting" width="650" height="400">
|
||||
<afx-vbox>
|
||||
<afx-tab-container data-id = "container" dir = "row" tabbarwidth= "120">
|
||||
<afx-tab-container data-id = "container" dir = "row" tabbarwidth= "150">
|
||||
|
||||
<afx-hbox tabname="__(Appearance)" data-id="appearance" iconclass = "fa fa-paint-brush">
|
||||
<div data-width="10"></div>
|
||||
@ -77,9 +77,22 @@
|
||||
<div data-width="10"></div>
|
||||
</afx-hbox>
|
||||
|
||||
<afx-hbox data-id="app-services" tabname = "__(Apps. and Services)" iconclass = "fa fa-adn">
|
||||
<div data-width="10"></div>
|
||||
<afx-vbox>
|
||||
<afx-label text = "__(Services)" iconclass = "fa fa-tasks" class = "header" data-height="23"></afx-label>
|
||||
<afx-list-view data-id="sys-srvlist"></afx-list-view>
|
||||
<div data-height="5"></div>
|
||||
<afx-label text = "__(Pinned applications)" iconclass = "fa fa-adn" class = "header" data-height="23"></afx-label>
|
||||
<afx-list-view data-id="sys-applist"></afx-list-view>
|
||||
<div data-height="10"></div>
|
||||
</afx-vbox>
|
||||
<div data-width="10"></div>
|
||||
</afx-hbox>
|
||||
|
||||
</afx-tab-container>
|
||||
<afx-hbox data-height="35">
|
||||
<div data-width = "120" class = "footer"></div>
|
||||
<div data-width = "150" class = "footer"></div>
|
||||
<div style="text-align:right" >
|
||||
<afx-button text="__(Save)" data-id="btnsave" iconclass="fa fa-save" style="margin-right:10px;" ></afx-button>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user