mirror of
https://github.com/lxsang/antos-frontend.git
synced 2024-12-26 09:28:21 +01:00
add more docs
This commit is contained in:
parent
023e61c01e
commit
4a941f0467
@ -1,9 +1,3 @@
|
||||
/*
|
||||
* 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
|
||||
@ -22,7 +16,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
//along with this program. If not, see https://www.gnu.org/licenses/.
|
||||
|
||||
this.onload = function () {
|
||||
Ant.onload = function () {
|
||||
$(document).on(
|
||||
"webkitfullscreenchange mozfullscreenchange fullscreenchange MSFullscreenChange",
|
||||
() => (Ant.OS.GUI.fullscreen = !Ant.OS.GUI.fullscreen)
|
||||
|
@ -448,6 +448,14 @@ namespace OS {
|
||||
/**
|
||||
* A Calendar dialog allows user to select a date
|
||||
*
|
||||
* Input data:
|
||||
*
|
||||
* ```typescript
|
||||
* {
|
||||
* title: string // window title
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @export
|
||||
* @class CalendarDialog
|
||||
* @extends {BasicDialog}
|
||||
@ -456,14 +464,6 @@ namespace OS {
|
||||
/**
|
||||
* Creates an instance of CalendarDialog.
|
||||
*
|
||||
* Input data:
|
||||
*
|
||||
* ```typescript
|
||||
* {
|
||||
* title: string // window title
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* Callback data: a Date object represent the selected date
|
||||
*
|
||||
*
|
||||
|
@ -27,6 +27,9 @@ namespace OS {
|
||||
* to access to service visual contents such as: options,
|
||||
* task performing based on user interaction, etc.
|
||||
*
|
||||
* Services are singleton processes, there is only
|
||||
* one process of a service at a time
|
||||
*
|
||||
* @export
|
||||
* @abstract
|
||||
* @class BaseService
|
||||
|
317
src/core/gui.ts
317
src/core/gui.ts
@ -17,41 +17,118 @@
|
||||
// along with this program. If not, see https://www.gnu.org/licenses/.
|
||||
namespace OS {
|
||||
/**
|
||||
*
|
||||
* This namespace is dedicated to all APIs related to AntOS UI system,
|
||||
* these API are called AFX APIs which handle:
|
||||
* - The mouse and keyboard interaction with the UI system
|
||||
* - UI rendering
|
||||
* - Custom tags definition
|
||||
* - Load/unload system, applications and services UI
|
||||
* - System dialogs definition
|
||||
*/
|
||||
export namespace GUI {
|
||||
/**
|
||||
*
|
||||
* AntOS keyboard shortcut type definition
|
||||
*
|
||||
* @export
|
||||
* @interface ShortcutType
|
||||
*/
|
||||
export interface ShortcutType {
|
||||
/**
|
||||
* Placeholder for all shortcut callbacks attached to `ALT` key, eg.
|
||||
* ```typescript
|
||||
* ALT.c = function() {..}
|
||||
* // this function will be called when the hotkey `ALT-C` is triggered
|
||||
* ```
|
||||
*
|
||||
* @memberof ShortcutType
|
||||
*/
|
||||
ALT: GenericObject<(e: JQuery.MouseDownEvent) => void>;
|
||||
|
||||
/**
|
||||
* Placeholder for all shortcut callbacks attached to `CTRL` key, eg.
|
||||
* ```typescript
|
||||
* CTRL.c = function() {..}
|
||||
* // this function will be called when the hotkey `CTRL-C` is triggered
|
||||
* ```
|
||||
*
|
||||
* @memberof ShortcutType
|
||||
*/
|
||||
CTRL: GenericObject<(e: JQuery.MouseDownEvent) => void>;
|
||||
|
||||
/**
|
||||
* Placeholder for all shortcut callbacks attached to `SHIFT` key, eg.
|
||||
* ```typescript
|
||||
* SHIFT.c = function() {..}
|
||||
* // this function will be called when the hotkey `SHIFT-C` is triggered
|
||||
* ```
|
||||
*
|
||||
* @memberof ShortcutType
|
||||
*/
|
||||
SHIFT: GenericObject<(e: JQuery.MouseDownEvent) => void>;
|
||||
/**
|
||||
* Placeholder for all shortcut callbacks attached to `META` key, eg.
|
||||
* ```typescript
|
||||
* META[" "] = function() {..}
|
||||
* // this function will be called when the hotkey `META-[space]` is triggered
|
||||
* ```
|
||||
*
|
||||
* @memberof ShortcutType
|
||||
*/
|
||||
META: GenericObject<(e: JQuery.MouseDownEvent) => void>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Basic item type definition which is usually used by some UI element
|
||||
* such as list view, tree view, menu and grid view
|
||||
*
|
||||
*
|
||||
* @export
|
||||
* @interface BasicItemType
|
||||
*/
|
||||
export interface BasicItemType {
|
||||
/**
|
||||
* Item text
|
||||
*
|
||||
* @type {(string | FormattedString)}
|
||||
* @memberof BasicItemType
|
||||
*/
|
||||
text: string | FormattedString;
|
||||
|
||||
/**
|
||||
* Item children, usually used by tree view or menu item
|
||||
* This property is keep for compatibility purposes only.
|
||||
* Otherwise, the [[nodes]] property should be used
|
||||
*
|
||||
* @type {BasicItemType[]}
|
||||
* @memberof BasicItemType
|
||||
*/
|
||||
children?: BasicItemType[];
|
||||
/**
|
||||
* Item children, usually used by tree view or menu item
|
||||
*
|
||||
* @type {BasicItemType[]}
|
||||
* @memberof BasicItemType
|
||||
*/
|
||||
nodes?: BasicItemType[];
|
||||
[propName: string]: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Element id of the virtual desktop, used by JQuery
|
||||
*/
|
||||
export var workspace: string = "#desktop";
|
||||
|
||||
/**
|
||||
* Indicate whether the system is in fullscreen mode
|
||||
*/
|
||||
export var fullscreen = false;
|
||||
|
||||
/**
|
||||
* Reference to the current system dialog, only one dialog
|
||||
* is allowed at a time. A dialog may have sub dialog
|
||||
*/
|
||||
export var dialog: BaseDialog;
|
||||
|
||||
/**
|
||||
* Placeholder for system shortcuts
|
||||
*/
|
||||
var shortcut: ShortcutType = {
|
||||
ALT: {},
|
||||
CTRL: {},
|
||||
@ -60,12 +137,18 @@ namespace OS {
|
||||
};
|
||||
|
||||
/**
|
||||
* Convert an application html scheme to
|
||||
* UI elements, then insert this UI scheme to the DOM tree.
|
||||
*
|
||||
* This function renders the UI of the application before calling the
|
||||
* application's [[main]] function
|
||||
*
|
||||
* @export
|
||||
* @param {string} html
|
||||
* @param {BaseModel} app
|
||||
* @param {string} html html scheme string
|
||||
* @param {BaseModel} app reference to the target application
|
||||
* @param {(Element | string)} parent
|
||||
* The parent HTML element where the application is rendered.
|
||||
* This is usually the reference to the virtual desktop element.
|
||||
*/
|
||||
export function htmlToScheme(
|
||||
html: string,
|
||||
@ -85,12 +168,13 @@ namespace OS {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Load an application scheme file then render
|
||||
* it with [[htmlToScheme]]
|
||||
*
|
||||
* @export
|
||||
* @param {string} path
|
||||
* @param {BaseModel} app
|
||||
* @param {(HTMLElement | string)} parent
|
||||
* @param {string} path VFS path to the scheme file
|
||||
* @param {BaseModel} app the target application
|
||||
* @param {(HTMLElement | string)} parent The parent HTML element where the application is rendered.
|
||||
*/
|
||||
export function loadScheme(
|
||||
path: string,
|
||||
@ -111,7 +195,7 @@ namespace OS {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Clear the current system theme
|
||||
*
|
||||
* @export
|
||||
*/
|
||||
@ -120,11 +204,12 @@ namespace OS {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Load a theme based on its name, then refresh the
|
||||
* system UI theme
|
||||
*
|
||||
* @export
|
||||
* @param {string} name
|
||||
* @param {boolean} force
|
||||
* @param {string} name name of the theme e.g. `antos_dark`
|
||||
* @param {boolean} force force to clear the system theme before applying the new one
|
||||
*/
|
||||
export function loadTheme(name: string, force: boolean): void {
|
||||
if (force) {
|
||||
@ -135,11 +220,14 @@ namespace OS {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Open a system dialog.
|
||||
*
|
||||
* @export
|
||||
* @param {(string | BaseDialog)} d
|
||||
* @param {GenericObject<any>} data
|
||||
* @param {(BaseDialog | string)} d a dialog object or a dialog class name
|
||||
* @param {GenericObject<any>} [data] input data of the dialog, refer to each
|
||||
* dialog definition for the format of the input data
|
||||
* @returns {Promise<any>} A promise on the callback data of the dialog, refer
|
||||
* to each dialog definition for the format of the callback data
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export function openDialog(
|
||||
@ -170,10 +258,11 @@ namespace OS {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Find a list of applications that support a specific mime
|
||||
* type in the system packages meta-data
|
||||
*
|
||||
* @export
|
||||
* @param {string} mime
|
||||
* @param {string} mime the mime type
|
||||
* @returns {API.PackageMetaType[]}
|
||||
*/
|
||||
export function appsByMime(mime: string): API.PackageMetaType[] {
|
||||
@ -223,17 +312,16 @@ namespace OS {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Find all applications that have services attached to it.
|
||||
* This function allows to collect all the services available
|
||||
* on the system. These services may or may not be running.
|
||||
*
|
||||
* @export
|
||||
* @returns {{
|
||||
* [index: string]: API.PackageMetaType;
|
||||
* }}
|
||||
* @returns {GenericObject<API.PackageMetaType>} result in forme of:
|
||||
* `service_name:service-meta-data` key-value pairs
|
||||
*/
|
||||
export function appsWithServices(): {
|
||||
[index: string]: API.PackageMetaType;
|
||||
} {
|
||||
const o: { [index: string]: API.PackageMetaType } = {};
|
||||
export function appsWithServices(): GenericObject<API.PackageMetaType> {
|
||||
const o: GenericObject<API.PackageMetaType> = {};
|
||||
for (let k in setting.system.packages) {
|
||||
const v = setting.system.packages[k];
|
||||
if (v && v.services && v.services.length > 0) {
|
||||
@ -244,10 +332,21 @@ namespace OS {
|
||||
}
|
||||
|
||||
/**
|
||||
* Find an launch an application using input application argument
|
||||
* such as VFS file meta-data.
|
||||
*
|
||||
* Based on the input application argument, the function will try
|
||||
* to find all applications that is compatible with that argument.
|
||||
* Three cases possible:
|
||||
* - There is no application that can handle the argument, a message will
|
||||
* be notified to user.
|
||||
* - There is one application that can handle the argument, the application
|
||||
* will be launched with the argument
|
||||
* - There are many applications that can handle the arguments, a selection
|
||||
* dialog will be popped up and allows user to select an application to launch.
|
||||
*
|
||||
* @export
|
||||
* @param {AppArgumentsType} it
|
||||
* @param {AppArgumentsType} it application argument
|
||||
* @returns {void}
|
||||
*/
|
||||
export function openWith(it: AppArgumentsType): void {
|
||||
@ -283,11 +382,15 @@ namespace OS {
|
||||
}
|
||||
|
||||
/**
|
||||
* Kil all processes related to an application, reload the application
|
||||
* prototype definition and launch a new process of this application.
|
||||
*
|
||||
* This function is used only for debug purpose or used by
|
||||
* AntOSDK during in-browser application development
|
||||
*
|
||||
* @export
|
||||
* @param {string} app
|
||||
* @param {AppArgumentsType[]} args
|
||||
* @param {string} app the application class name
|
||||
* @param {AppArgumentsType[]} args application arguments
|
||||
* @returns {void}
|
||||
*/
|
||||
export function forceLaunch(
|
||||
@ -301,9 +404,13 @@ namespace OS {
|
||||
return launch(app, args);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Kill an running processes of an application, then
|
||||
* unregister the application prototype definition
|
||||
* from the [[application]] namespace.
|
||||
*
|
||||
* This process is similar to uninstall the application
|
||||
* from the current system state
|
||||
*
|
||||
* @export
|
||||
* @param {string} app
|
||||
@ -317,9 +424,14 @@ namespace OS {
|
||||
}
|
||||
|
||||
/**
|
||||
* Load an application if the application is not registered yet
|
||||
* in the system.
|
||||
*
|
||||
* This function fist loads and registers the application prototype
|
||||
* definition in the [[application]] namespace, then update
|
||||
* the system packages meta-data
|
||||
*
|
||||
* @param {string} app
|
||||
* @param {string} app application class name
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
function loadApp(app: string): Promise<string> {
|
||||
@ -371,7 +483,10 @@ namespace OS {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a service process.
|
||||
*
|
||||
* Services are singleton processes, there is only
|
||||
* one process of a service at a time
|
||||
*
|
||||
* @export
|
||||
* @param {string} ph
|
||||
@ -417,10 +532,10 @@ namespace OS {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Synchronously start a list of services
|
||||
*
|
||||
* @export
|
||||
* @param {string[]} srvs
|
||||
* @param {string[]} srvs list of service class names
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
export function pushServices(srvs: string[]): Promise<any> {
|
||||
@ -445,19 +560,22 @@ namespace OS {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Launch an application with arguments
|
||||
*
|
||||
* @export
|
||||
* @param {string} app
|
||||
* @param {AppArgumentsType[]} args
|
||||
* @param {string} app application class name
|
||||
* @param {AppArgumentsType[]} args application arguments
|
||||
*/
|
||||
export function launch(app: string, args: AppArgumentsType[]): void {
|
||||
if (!application[app]) {
|
||||
// first load it
|
||||
loadApp(app)
|
||||
.then((a) =>
|
||||
PM.createProcess(app, application[app], args)
|
||||
.catch((e) =>
|
||||
PM.createProcess(
|
||||
app,
|
||||
application[app],
|
||||
args
|
||||
).catch((e) =>
|
||||
announcer.osfail(
|
||||
__("Unable to launch: {0}", app),
|
||||
e
|
||||
@ -487,11 +605,11 @@ namespace OS {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Dock an application to the system application dock
|
||||
*
|
||||
* @export
|
||||
* @param {BaseApplication} app
|
||||
* @param {API.PackageMetaType} meta
|
||||
* @param {BaseApplication} app reference to the application process
|
||||
* @param {API.PackageMetaType} meta Application meta-data
|
||||
* @returns {void}
|
||||
*/
|
||||
export function dock(
|
||||
@ -525,12 +643,12 @@ namespace OS {
|
||||
"[data-id = 'appmenu']",
|
||||
"#syspanel"
|
||||
)[0] as tag.MenuTag;
|
||||
dock.newapp(data);
|
||||
dock.newapp(data);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Toggle system fullscreen
|
||||
*
|
||||
* @export
|
||||
*/
|
||||
@ -566,7 +684,8 @@ namespace OS {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Remove an application process from the system application
|
||||
* dock. This action will also exit the process
|
||||
*
|
||||
* @export
|
||||
* @param {BaseApplication} app
|
||||
@ -577,10 +696,10 @@ namespace OS {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Attach a running service process to the system tray
|
||||
*
|
||||
* @export
|
||||
* @param {BaseService} srv
|
||||
* @param {BaseService} srv reference to the running service process
|
||||
* @returns {void}
|
||||
*/
|
||||
export function attachservice(srv: application.BaseService): void {
|
||||
@ -589,10 +708,10 @@ namespace OS {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Detach a running process from the system tray
|
||||
*
|
||||
* @export
|
||||
* @param {BaseService} srv
|
||||
* @param {BaseService} srv reference to the running service process
|
||||
* @returns {void}
|
||||
*/
|
||||
export function detachservice(srv: application.BaseService): void {
|
||||
@ -600,20 +719,21 @@ namespace OS {
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind a context menu event to an AntOS element.
|
||||
*
|
||||
* This will find the fist element which defines a handle
|
||||
* named [[contextMenuHandle]] and bind the context menu
|
||||
* event to it.
|
||||
*
|
||||
* @param {JQuery.MouseEventBase} event
|
||||
* @param {JQuery.MouseEventBase} event mouse event
|
||||
* @returns {void}
|
||||
*/
|
||||
function bindContextMenu(event: JQuery.MouseEventBase): void {
|
||||
var handle = function (e: HTMLElement) {
|
||||
if (e.contextmenuHandle) {
|
||||
const m = $("#contextmenu")[0] as tag.MenuTag;
|
||||
m.onmenuselect = () => {}
|
||||
return e.contextmenuHandle(
|
||||
event,
|
||||
m
|
||||
);
|
||||
m.onmenuselect = () => {};
|
||||
return e.contextmenuHandle(event, m);
|
||||
} else {
|
||||
const p = $(e).parent().get(0);
|
||||
if (p !== $("#workspace").get(0)) {
|
||||
@ -626,11 +746,12 @@ namespace OS {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Register a hot key and its handle in the
|
||||
* system shortcut
|
||||
*
|
||||
* @export
|
||||
* @param {string} k
|
||||
* @param {(e: JQuery.MouseDownEvent) => void} f
|
||||
* @param {string} k the hotkey e.g. `ALT-C`
|
||||
* @param {(e: JQuery.MouseDownEvent) => void} f handle function
|
||||
* @returns {void}
|
||||
*/
|
||||
export function bindKey(
|
||||
@ -650,10 +771,10 @@ namespace OS {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Load and apply system wallpaper from the setting object
|
||||
*
|
||||
* @export
|
||||
* @param {setting.WPSettingType} obj
|
||||
* @param {setting.WPSettingType} obj wallpaper setting object
|
||||
*/
|
||||
export function wallpaper(obj?: setting.WPSettingType): void {
|
||||
if (obj) {
|
||||
@ -667,11 +788,11 @@ namespace OS {
|
||||
}
|
||||
|
||||
/**
|
||||
* Show tooltip at the current mouse position
|
||||
*
|
||||
*
|
||||
* @param {JQuery<HTMLElement>} el
|
||||
* @param {string} text
|
||||
* @param {JQuery.MouseEventBase} e
|
||||
* @param {JQuery<HTMLElement>} el The target element that has the tooltip attribute
|
||||
* @param {string} text The text to be displayed
|
||||
* @param {JQuery.MouseEventBase} e mouse event
|
||||
* @returns {void}
|
||||
*/
|
||||
function showTooltip(
|
||||
@ -720,7 +841,7 @@ namespace OS {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Refresh the content of the virtual desktop
|
||||
*
|
||||
* @param {tag.FloatListTag} desktop
|
||||
*/
|
||||
@ -764,8 +885,12 @@ namespace OS {
|
||||
}
|
||||
|
||||
/**
|
||||
* Init the virtual desktop on boot:
|
||||
*
|
||||
*
|
||||
* - Register listener for system hotkey
|
||||
* - Bind the system context menu handle
|
||||
* - Init and load the content of the virtual desktop
|
||||
* - Init the system tooltip event handle
|
||||
*/
|
||||
function initDM(): void {
|
||||
const scheme = $.parseHTML(schemes.ws);
|
||||
@ -806,9 +931,8 @@ namespace OS {
|
||||
}
|
||||
shortcut[fnk][c](event);
|
||||
return event.preventDefault();
|
||||
})
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
// system menu and dock
|
||||
$("#syspanel")[0].uify(undefined);
|
||||
$("#sysdock")[0].uify(undefined);
|
||||
@ -840,11 +964,15 @@ namespace OS {
|
||||
return e.calibrate();
|
||||
};
|
||||
|
||||
desktop.onlistselect = function (d: TagEventType<tag.ListItemEventData>) {
|
||||
desktop.onlistselect = function (
|
||||
d: TagEventType<tag.ListItemEventData>
|
||||
) {
|
||||
($("#sysdock")[0] as tag.AppDockTag).selectedApp = null;
|
||||
};
|
||||
|
||||
desktop.onlistdbclick = function (d: TagEventType<tag.ListItemEventData>) {
|
||||
desktop.onlistdbclick = function (
|
||||
d: TagEventType<tag.ListItemEventData>
|
||||
) {
|
||||
($("#sysdock")[0] as tag.AppDockTag).selectedApp = null;
|
||||
const it = desktop.selectedItem;
|
||||
return openWith(it.data as AppArgumentsType);
|
||||
@ -889,8 +1017,10 @@ namespace OS {
|
||||
})()
|
||||
);
|
||||
m.items = menu;
|
||||
m.onmenuselect = function (evt: TagEventType<tag.MenuEventData>) {
|
||||
if(!evt.data || !evt.data.item) return;
|
||||
m.onmenuselect = function (
|
||||
evt: TagEventType<tag.MenuEventData>
|
||||
) {
|
||||
if (!evt.data || !evt.data.item) return;
|
||||
const item = evt.data.item.data;
|
||||
switch (item.dataid) {
|
||||
case "desktop-open":
|
||||
@ -934,7 +1064,7 @@ namespace OS {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Refresh the virtual desktop
|
||||
*
|
||||
* @export
|
||||
*/
|
||||
@ -943,7 +1073,9 @@ namespace OS {
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the login screen and perform the login operation.
|
||||
*
|
||||
* Once login successfully, the [[startAntOS]] will be called
|
||||
*
|
||||
* @export
|
||||
*/
|
||||
@ -978,6 +1110,15 @@ namespace OS {
|
||||
}
|
||||
|
||||
/**
|
||||
* Start AntOS after a successful login.
|
||||
*
|
||||
* This function performs the following operations:
|
||||
*
|
||||
* - System cleanup
|
||||
* - Apply system setting
|
||||
* - Load desktop wallpaper and the current theme from the system setting
|
||||
* - Load system package meta-data
|
||||
* - Load and apply system locale and language
|
||||
*
|
||||
*
|
||||
* @export
|
||||
@ -1029,32 +1170,38 @@ namespace OS {
|
||||
pushServices(
|
||||
(() => {
|
||||
const result = [];
|
||||
for (let v of
|
||||
setting.system.startup.services
|
||||
) {
|
||||
for (let v of setting.system.startup.services) {
|
||||
result.push(v);
|
||||
}
|
||||
return result;
|
||||
})()
|
||||
).then(function(){
|
||||
).then(function () {
|
||||
setting.system.startup.apps.map((a) => {
|
||||
launch(a, []);
|
||||
});
|
||||
})
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
//GUI.launch "DummyApp"
|
||||
// initDM
|
||||
API.setLocale(setting.system.locale).then(() => initDM());
|
||||
Ant.OS.announcer.observable.on("error", function(d) {
|
||||
console.log(d.data.e)
|
||||
Ant.OS.announcer.observable.on("error", function (d) {
|
||||
console.log(d.data.e);
|
||||
});
|
||||
Ant.OS.announcer.observable.on("fail", function(d) {
|
||||
console.log(d.data.e)
|
||||
Ant.OS.announcer.observable.on("fail", function (d) {
|
||||
console.log(d.data.e);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* HTML schemes used by the system:
|
||||
* - The login screen scheme
|
||||
* - The workspace including:
|
||||
* - System panel
|
||||
* - Virtual desktop
|
||||
* - Context menu
|
||||
* - System tooltip
|
||||
*/
|
||||
export const schemes: GenericObject<string> = {};
|
||||
schemes.ws = `\
|
||||
<afx-sys-panel id = "syspanel"></afx-sys-panel>
|
||||
|
@ -217,7 +217,7 @@ namespace OS {
|
||||
* @param {string} t return data type:
|
||||
* - jsonp: the response is an json object
|
||||
* - script: the response is a javascript code
|
||||
* - xm, html: the response is a XML/HTML object
|
||||
* - xml, html: the response is a XML/HTML object
|
||||
* - text: plain text
|
||||
*
|
||||
* @returns {Promise<any>} A promise on a [[RequestResult]]
|
||||
|
@ -1,19 +1,38 @@
|
||||
namespace OS {
|
||||
/**
|
||||
* This namespace dedicated to all operations related to system
|
||||
* process management
|
||||
*/
|
||||
export namespace PM {
|
||||
export type ProcessType = application.BaseApplication | application.BaseService;
|
||||
/**
|
||||
* A process is either an instance of an application or a service
|
||||
*/
|
||||
export type ProcessType =
|
||||
| application.BaseApplication
|
||||
| application.BaseService;
|
||||
/**
|
||||
* Alias to all classes that extends [[BaseModel]]
|
||||
*/
|
||||
export type ModelTypeClass = {
|
||||
new <T extends BaseModel>(args: AppArgumentsType[]): T;
|
||||
};
|
||||
/**
|
||||
* Process id allocator, when a new process is created, the value of
|
||||
* this variable is increased
|
||||
*/
|
||||
export var pidalloc: number = 0;
|
||||
/**
|
||||
* All running processes is stored in this variables
|
||||
*/
|
||||
export var processes: GenericObject<BaseModel[]> = {};
|
||||
/**
|
||||
*
|
||||
* Create a new process of application or service
|
||||
*
|
||||
* @export
|
||||
* @param {string} app
|
||||
* @param {ProcessTypeClass} cls
|
||||
* @param {GUI.AppArgumentsType[]} [args]
|
||||
* @returns {Promise<ProcessType>}
|
||||
* @param {string} app class name string
|
||||
* @param {ProcessTypeClass} cls prototype class
|
||||
* @param {GUI.AppArgumentsType[]} [args] process arguments
|
||||
* @returns {Promise<ProcessType>} a promise on the created process
|
||||
*/
|
||||
export function createProcess(
|
||||
app: string,
|
||||
@ -68,7 +87,7 @@ namespace OS {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Get the reference to a process using its id
|
||||
*
|
||||
* @export
|
||||
* @param {number} pid
|
||||
@ -94,10 +113,10 @@ namespace OS {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Kill a process
|
||||
*
|
||||
* @export
|
||||
* @param {OS.GUI.BaseModel} app
|
||||
* @param {OS.GUI.BaseModel} app reference to the process
|
||||
* @returns {void}
|
||||
*/
|
||||
export function kill(app: BaseModel): void {
|
||||
@ -119,11 +138,11 @@ namespace OS {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Kill all process of an application or service
|
||||
*
|
||||
* @export
|
||||
* @param {string} app
|
||||
* @param {boolean} force
|
||||
* @param {string} app process class name
|
||||
* @param {boolean} force force exit all process
|
||||
* @returns {void}
|
||||
*/
|
||||
export function killAll(app: string, force: boolean): void {
|
||||
|
@ -1,9 +1,3 @@
|
||||
/*
|
||||
* 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
|
||||
@ -23,134 +17,375 @@
|
||||
//along with this program. If not, see https://www.gnu.org/licenses/.
|
||||
|
||||
namespace OS {
|
||||
/**
|
||||
* This namespace is dedicated to everything related to the
|
||||
* global system settings
|
||||
*/
|
||||
export namespace setting {
|
||||
|
||||
/**
|
||||
*
|
||||
* User setting type definition
|
||||
*
|
||||
* @export
|
||||
* @interface UserSettingType
|
||||
*/
|
||||
export interface UserSettingType {
|
||||
/**
|
||||
* User full name
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof UserSettingType
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* User name
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof UserSettingType
|
||||
*/
|
||||
username: string;
|
||||
|
||||
/**
|
||||
* User id
|
||||
*
|
||||
* @type {number}
|
||||
* @memberof UserSettingType
|
||||
*/
|
||||
id: number;
|
||||
|
||||
/**
|
||||
* User groups
|
||||
*
|
||||
* @type {{ [index: number]: string }}
|
||||
* @memberof UserSettingType
|
||||
*/
|
||||
group?: { [index: number]: string };
|
||||
[propName: string]: any;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Virtual desktop setting data type
|
||||
*
|
||||
* @export
|
||||
* @interface DesktopSettingType
|
||||
*/
|
||||
export interface DesktopSettingType {
|
||||
/**
|
||||
* Desktop VFS path
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof DesktopSettingType
|
||||
*/
|
||||
path: string;
|
||||
menu: any[];
|
||||
|
||||
/**
|
||||
* Desktop menu, can be added automatically by applications
|
||||
*
|
||||
* @type {GUI.BasicItemType[]}
|
||||
* @memberof DesktopSettingType
|
||||
*/
|
||||
menu: GUI.BasicItemType[];
|
||||
|
||||
/**
|
||||
* Show desktop hidden files
|
||||
*
|
||||
* @type {boolean}
|
||||
* @memberof DesktopSettingType
|
||||
*/
|
||||
showhidden: boolean;
|
||||
[propName: string]: any;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Wallpaper setting data type
|
||||
*
|
||||
* @export
|
||||
* @interface WPSettingType
|
||||
*/
|
||||
export interface WPSettingType {
|
||||
/**
|
||||
* Repeat wallpaper:
|
||||
* - `repeat`
|
||||
* - `repeat-x`
|
||||
* - `repeat-y`
|
||||
* - `no-repeat`
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof WPSettingType
|
||||
*/
|
||||
repeat: string;
|
||||
|
||||
/**
|
||||
* Wallpaper size
|
||||
* - `contain`
|
||||
* - `cover`
|
||||
* - `auto`
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof WPSettingType
|
||||
*/
|
||||
size: string;
|
||||
|
||||
/**
|
||||
* VFS path to the wallpaper image
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof WPSettingType
|
||||
*/
|
||||
url: string;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Theme setting data type
|
||||
*
|
||||
* @export
|
||||
* @interface ThemeSettingType
|
||||
*/
|
||||
export interface ThemeSettingType {
|
||||
/**
|
||||
* Theme name, this value is used for looking
|
||||
* theme file in system asset
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof ThemeSettingType
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* Theme user-friendly text
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof ThemeSettingType
|
||||
*/
|
||||
text: string;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Appearance setting data type
|
||||
*
|
||||
* @export
|
||||
* @interface AppearanceSettingType
|
||||
*/
|
||||
export interface AppearanceSettingType {
|
||||
/**
|
||||
* Current theme name
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof AppearanceSettingType
|
||||
*/
|
||||
theme: string;
|
||||
|
||||
/**
|
||||
* All themes available in the system
|
||||
*
|
||||
* @type {ThemeSettingType[]}
|
||||
* @memberof AppearanceSettingType
|
||||
*/
|
||||
themes: ThemeSettingType[];
|
||||
|
||||
/**
|
||||
* Current wallpaper setting
|
||||
*
|
||||
* @type {WPSettingType}
|
||||
* @memberof AppearanceSettingType
|
||||
*/
|
||||
wp: WPSettingType;
|
||||
|
||||
/**
|
||||
* All wallpapers available in the system
|
||||
*
|
||||
* @type {string[]}
|
||||
* @memberof AppearanceSettingType
|
||||
*/
|
||||
wps: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* VFS Mount points setting data type
|
||||
*
|
||||
* @export
|
||||
* @interface VFSMountPointSettingType
|
||||
*/
|
||||
export interface VFSMountPointSettingType {
|
||||
/**
|
||||
* Path to the mount point
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof VFSMountPointSettingType
|
||||
*/
|
||||
path: string;
|
||||
|
||||
/**
|
||||
* User friendly mount point name
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof VFSMountPointSettingType
|
||||
*/
|
||||
text: string;
|
||||
[propName: string]: any;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* VFS setting data type
|
||||
*
|
||||
* @export
|
||||
* @interface VFSSettingType
|
||||
*/
|
||||
export interface VFSSettingType {
|
||||
/**
|
||||
* mount points setting
|
||||
*
|
||||
* @type {VFSMountPointSettingType[]}
|
||||
* @memberof VFSSettingType
|
||||
*/
|
||||
mountpoints: VFSMountPointSettingType[];
|
||||
[propName: string]: any;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Global system setting data type
|
||||
*
|
||||
* @export
|
||||
* @interface SystemSettingType
|
||||
*/
|
||||
export interface SystemSettingType {
|
||||
/**
|
||||
* System error report URL
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof SystemSettingType
|
||||
*/
|
||||
error_report: string;
|
||||
|
||||
/**
|
||||
* Current system locale e.g. `en_GB`
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof SystemSettingType
|
||||
*/
|
||||
locale: string;
|
||||
menu: any[];
|
||||
|
||||
/**
|
||||
* System menus
|
||||
*
|
||||
* @type {API.PackageMetaType[]}
|
||||
* @memberof API.PackageMetaType
|
||||
*/
|
||||
menu: API.PackageMetaType[];
|
||||
|
||||
/**
|
||||
* Packages meta-data
|
||||
*
|
||||
* @type {{ [index: string]: API.PackageMetaType }}
|
||||
* @memberof SystemSettingType
|
||||
*/
|
||||
packages: { [index: string]: API.PackageMetaType };
|
||||
|
||||
/**
|
||||
* Path to the installed packages
|
||||
*
|
||||
* @type {{
|
||||
* user: string;
|
||||
* system: string;
|
||||
* }}
|
||||
* @memberof SystemSettingType
|
||||
*/
|
||||
pkgpaths: {
|
||||
/**
|
||||
* User specific packages install location
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
user: string;
|
||||
|
||||
/**
|
||||
* System packages install location
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
system: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Package repositories setting.
|
||||
* This configuration is used by [[MarketPlace]]
|
||||
* for package management
|
||||
*
|
||||
* @type {{
|
||||
* text: string;
|
||||
* url: string;
|
||||
* }[]}
|
||||
* @memberof SystemSettingType
|
||||
*/
|
||||
repositories: {
|
||||
/**
|
||||
* Repository name
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
text: string;
|
||||
|
||||
/**
|
||||
* Repository uri
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
url: string;
|
||||
}[];
|
||||
|
||||
/**
|
||||
* Startup applications and services
|
||||
*
|
||||
* @type {{
|
||||
* apps: string[];
|
||||
* services: string[];
|
||||
* }}
|
||||
* @memberof SystemSettingType
|
||||
*/
|
||||
startup: {
|
||||
/**
|
||||
* List of application names
|
||||
*
|
||||
* @type {string[]}
|
||||
*/
|
||||
apps: string[];
|
||||
|
||||
/**
|
||||
* List of service names
|
||||
*
|
||||
* @type {string[]}
|
||||
*/
|
||||
services: string[];
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* User settings
|
||||
*/
|
||||
export var user: UserSettingType;
|
||||
|
||||
/**
|
||||
* Application settings
|
||||
*/
|
||||
export var applications: GenericObject<any> = {};
|
||||
|
||||
/**
|
||||
* Desktop settings
|
||||
*/
|
||||
export var desktop: DesktopSettingType;
|
||||
|
||||
/**
|
||||
* Appearance settings
|
||||
*/
|
||||
export var appearance: AppearanceSettingType;
|
||||
|
||||
/**
|
||||
* VFS settings
|
||||
*/
|
||||
export var VFS: VFSSettingType;
|
||||
|
||||
/**
|
||||
* System settings
|
||||
*/
|
||||
export var system: SystemSettingType;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Reset the system settings to default values
|
||||
*
|
||||
* @export
|
||||
*/
|
||||
@ -158,7 +393,7 @@ namespace OS {
|
||||
setting.desktop = {
|
||||
path: "home://.desktop",
|
||||
menu: [],
|
||||
showhidden: false
|
||||
showhidden: false,
|
||||
};
|
||||
setting.user = {
|
||||
name: undefined,
|
||||
@ -240,15 +475,15 @@ namespace OS {
|
||||
repositories: [],
|
||||
startup: {
|
||||
apps: [],
|
||||
services: [
|
||||
"Syslog/PushNotification", "Syslog/Calendar"
|
||||
],
|
||||
services: ["Syslog/PushNotification", "Syslog/Calendar"],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Apply the input parameter object to system settings.
|
||||
* This object could be an object loaded from
|
||||
* setting JSON file saved on the server.
|
||||
*
|
||||
* @export
|
||||
* @param {*} conf
|
||||
@ -288,7 +523,7 @@ namespace OS {
|
||||
}
|
||||
}
|
||||
|
||||
//search for app
|
||||
// Register handle for application search
|
||||
API.onsearch("__(Applications)", function (t) {
|
||||
const ar = [];
|
||||
const term = new RegExp(t, "i");
|
||||
|
639
src/core/vfs.ts
639
src/core/vfs.ts
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user