aboutsummaryrefslogtreecommitdiff
path: root/html/dialog.js
blob: fbea65719d40746166ff670e5fbc56da65a65e46 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/**
 * This file is part of Haketilo.
 *
 * Function: Showing and error/info/confirmation dialog.
 *
 * Copyright (C) 2022 Wojtek Kosior
 *
 * 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.
 *
 * As additional permission under GNU GPL version 3 section 7, you
 * may distribute forms of that code without the copy of the GNU
 * GPL normally required by section 4, provided you include this
 * license notice and, in case of non-source distribution, a URL
 * through which recipients can access the Corresponding Source.
 * If you modify file(s) with this exception, you may extend this
 * exception to your version of the file(s), but you are not
 * obligated to do so. If you do not wish to do so, delete this
 * exception statement from your version.
 *
 * As a special exception to the GPL, any HTML file which merely
 * makes function calls to this code, and for that purpose
 * includes it by reference shall be deemed a separate work for
 * copyright law purposes. If you modify this code, you may extend
 * this exception to your version of the code, but you are not
 * obligated to do so. If you do not wish to do so, delete this
 * exception statement from your version.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 *
 * I, Wojtek Kosior, thereby promise not to sue for violation of this file's
 * license. Although I request that you do not make use of this code in a
 * proprietary program, I am not going to enforce this in court.
 */

#FROM html/DOM_helpers.js IMPORT clone_template, Showable

function make(on_dialog_show, on_dialog_hide)
{
    const dialog_context = clone_template("dialog");
    dialog_context.queue = [];

    Showable.call(dialog_context, on_dialog_show, on_dialog_hide);

    for (const [id, val] of [["yes", true], ["no", false], ["ok", undefined]]) {
	const but = dialog_context[`${id}_but`];
	but.haketilo_dialog_result = val;
	but.addEventListener("click", e => close_dialog(dialog_context, e));
    }

    return dialog_context;
}
#EXPORT make

function close_dialog(dialog_context, event)
{
    if ((event && event.target.parentElement.classList.contains("hide")) ||
       dialog_context.queue.length === 0)
	return;

    const [[shown_buts_id, msg, resolve]] = dialog_context.queue.splice(0, 1);

    if (dialog_context.queue.length > 0) {
	process_queue_item(dialog_context);
    } else {
	dialog_context.hide();
    }

    resolve(event ? event.target.haketilo_dialog_result : undefined);
}
#EXPORT  close_dialog  AS close

function process_queue_item(dialog_context)
{
    const [shown_buts_id, msg, resolve] = dialog_context.queue[0];

    [...dialog_context.msg.childNodes].forEach(n => n.remove());
    dialog_context.msg.append(...msg);
    for (const buts_id of ["ask_buts", "conf_buts"]) {
	const action = buts_id === shown_buts_id ? "remove" : "add";
	dialog_context[buts_id].classList[action]("hide");
    }
}

async function show_dialog(dialog_context, shown_buts_id, msg)
{
    let resolve;
    const result_prom = new Promise(cb => resolve = cb);
    dialog_context.queue.push([shown_buts_id, msg, resolve]);

    if (dialog_context.show())
	process_queue_item(dialog_context);

    return await result_prom;
}

const error = (ctx, ...msg) => show_dialog(ctx, "conf_buts", msg);
#EXPORT error

/* info() and error() are the same for now, we might later change that. */
const info = error;
#EXPORT info

const ask = (ctx, ...msg) => show_dialog(ctx, "ask_buts", msg);
#EXPORT ask

const loader = (ctx, ...msg) => show_dialog(ctx, null, msg);
#EXPORT loader
try?, inetd-entry-node, inetd-entry-name, inetd-entry-socket-type, inetd-entry-protocol, inetd-entry-wait?, inetd-entry-user, inetd-entry-program and inetd-entry-arguments. Signed-off-by: Ludovic Courtès <ludo@gnu.org> 2023-05-11services: dhcp-client-configuration: Add 'shepherd-requirement' field.Sergey Trofimov * gnu/services/networking.scm (<dhcp-client-configuration>) [shepherd-requirement]: New field. (dhcp-client-shepherd-service): Honor it. (dhcp-client-configuration-shepherd-requirement): Export accessor. * doc/guix.texi (Networking Setup): Document it. Signed-off-by: Ludovic Courtès <ludo@gnu.org> 2023-04-25services: tor: Deprecate 'tor-hidden-service' procedure.Bruno Victal Due to (now renamed) 'hidden-service' record type not being exported, the only way Onion services (formely hidden services) could have worked is through the now deprecated 'tor-hidden-service' procedure. This commit updates the Tor service documentation, corrects some inconsistently named accessors in <tor-configuration> record-type, renames and refactors tor-hidden-service-configuration to tor-onion-service-configuration using define-configuration and also exports it, allowing Onion services to be configured directly within a <tor-configuration> record. Lastly, it also deprecates the 'tor-hidden-service' procedure. * doc/guix.texi (Networking Services): Substitute mentions of “Hidden services” with “Onion Services”. Add a Tor Onion service configuration example. Document <tor-onion-service-configuration>. Remove mention of 'tor-hidden-service' procedure. * gnu/services/networking.scm: Export tor-configuration-tor, tor-configuration-config-file, tor-configuration-hidden-services, tor-configuration-socks-socket-type, tor-configuration-control-socket-path, tor-onion-service-configuration, tor-onion-service-configuration?, tor-onion-service-configuration-name, tor-onion-service-configuration-mapping. (<tor-configuration>)[control-socket?]: Rename accessor. (<hidden-service>): Replace with … (<tor-onion-service-configuration>): … this. (tor-configuration->torrc): Update record-type name. (tor-activation): Ditto. (tor-hidden-service-type): Remove variable. (tor-hidden-service): Deprecate procedure. Signed-off-by: Ludovic Courtès <ludo@gnu.org> 2023-04-07services: ntp-service-type: Remove deprecated server as strings support.Bruno Victal * gnu/services/networking.scm (<ntp-configuration>)[servers]: Rename accessor to ntp-configuration-servers. (ntp-configuration-servers): Remove helper procedure. (ntp-shepherd-service): Remove helper procedure usage. * tests/networking.scm: Remove obsolete test. Signed-off-by: Ludovic Courtès <ludo@gnu.org> 2023-03-27services: ntpd: Add 'configuration' action.Ludovic Courtès * gnu/services/networking.scm (ntp-shepherd-service): Add 'actions' field. 2023-03-27services: network-manager: Add 'configuration' action.Ludovic Courtès * gnu/services/networking.scm (network-manager-shepherd-service): Add 'actions' field. 2023-03-23services: network-manager: Set LINUX_MODULE_DIRECTORY environment variable.Maxim Cournoyer Fixes <https://issues.guix.gnu.org/62409>. * gnu/services/networking.scm (network-manager-shepherd-service): Set the LINUX_MODULE_DIRECTORY environment variable. 2023-03-20services: network-manager: Add missing shadowing of 'iwd?' field.Andrew Tropin * gnu/services/networking.scm (network-manager-shepherd-service): Add missing shadowing of 'iwd?' field by using let* instead of let. 2023-03-10services: connman: Set service canonical-name to connman.Bruno Victal * gnu/services/networking.scm (connman-shepherd-service): Make 'networking a virtual service and set 'connman as its canonical name. Signed-off-by: Ludovic Courtès <ludo@gnu.org> 2023-03-10services: network-manager: Set service canonical-name to NetworkManager.Bruno Victal According to the semantics in [1], 'networking should be a "virtual service" and NetworkManager its canonical-name. This does not influence existing services and they should continue to use the 'networking symbol. One visible change is that 'herd status' doesn't show 'networking' anymore, instead listing 'NetworkManager' in its place but both symbols are can be used to start and stop the same service. Note: Though the symbol NetworkManager doesn't really conform with the overall kebab-case used throughout Guix, this is intentional as we really want to make it clear that that the symbol NetworkManager really refers to the software called NetworkManager, since it's a canonical name here. (rather than risk misleading the user to interpret the symbol network-manager as a symbol for some unspecific network management software) [1]: https://www.gnu.org/software/shepherd/manual/html_node/Jump-Start.html * gnu/services/networking.scm (network-manager-shepherd-service): Make 'networking a virtual service and set 'NetworkManager as its canonical name. Signed-off-by: Ludovic Courtès <ludo@gnu.org> 2023-03-10services: network-manager: Await for NetworkManager to finish starting up.Bruno Victal This is similar to its NetworkManager-wait-online.service systemd counterpart, with the main difference being that we handle it all in 'networking symbol, rather than introduce a new 'networking-online symbol. (see discussion #47253) As a result of this change, with opensmtpd-service-type as an example, manual 'herd restart smtpd' after system bootups are no longer required when opensmtpd is configured with a smtpd.conf containing non-loopback interfaces. (this issue is described in more detail at #60300) Fixes <https://issues.guix.gnu.org/60300>. * gnu/services/networking.scm (network-manager-shepherd-service): Await for NetworkManager to finish starting up. Signed-off-by: Ludovic Courtès <ludo@gnu.org> 2023-03-10services: connman: Deprecate 'iwd?' field.Bruno Victal * gnu/services/networking.scm (<connman-configuration>) [iwd?]: Use helper to warn deprecated field. (connman-shepherd-service): Make iwd? a local variable independent from the deprecated field. * doc/guix.texi (Networking Setup): Remove mention of iwd? field. Signed-off-by: Ludovic Courtès <ludo@gnu.org> 2023-03-10services: connman: Add 'shepherd-requirement' field.Bruno Victal * gnu/services/networking.scm (<connman-configuration>) [shepherd-requirement]: New field. (connman-shepherd-service): Honor it. (connman-configuration-shepherd-requirement): Export accessor. * doc/guix.texi (Networking Setup): Document it. Signed-off-by: Ludovic Courtès <ludo@gnu.org> 2023-03-10services: connman: Use match-record and export accessors.Bruno Victal * gnu/services/networking.scm (connman-shepherd-service): Use match-record. (connman-configuration-connman, connman-configuration-disable-vpn?) (connman-configuration-iwd?): Export accessors. Signed-off-by: Ludovic Courtès <ludo@gnu.org> 2023-03-10services: network-manager: Deprecate 'iwd?' field.Bruno Victal * gnu/services/networking.scm (warn-iwd?-field-deprecation): New procedure, helper for deprecated field. (<network-manager-configuration>)[iwd?]: Use helper to warn deprecated field. (network-manager-shepherd-service): Make iwd? a local variable independent from the deprecated field. * doc/guix.texi (Networking Setup): Remove mention of iwd? field. Signed-off-by: Ludovic Courtès <ludo@gnu.org> 2023-03-10services: network-manager: Add 'shepherd-requirement' field.Bruno Victal Note: This also makes wpa-supplicant an optional requirement. * gnu/services/networking.scm (<network-manager-configuration>) [shepherd-requirement]: New field. (network-manager-shepherd-service): Honor it. (network-manager-configuration-shepherd-requirement): Export accessor. * doc/guix.texi (Networking Setup): Document it. Signed-off-by: Ludovic Courtès <ludo@gnu.org> 2023-02-09services: Add block-facebook-hosts-service-type.Bruno Victal Deprecates %facebook-host-aliases in favour of using hosts-service-type service extensions. * gnu/services/networking.scm (block-facebook-hosts-service-type): New variable. (%facebook-host-aliases): Deprecate variable. * doc/guix.texi: Document it. Signed-off-by: Ludovic Courtès <ludo@gnu.org> 2023-01-16services: connman: Add iwd backend support.Declan Tsien * gnu/services/networking.scm (connman-configuration)[iwd?]: New field. (connman-shepherd-service): Add iwd? logic, remove wpa-supplicant requirement. * doc/guix.texi: Add information about connman-configuration iwd? option. Co-authored-by: Andrew Tropin <andrew@trop.in> Signed-off-by: Andrew Tropin <andrew@trop.in> 2022-12-02services: networking: Avoid 'match' on records.Ludovic Courtès * gnu/services/networking.scm (dhcp-client-shepherd-service): Use accessors instead of 'match'. (inetd-shepherd-service): Likewise. (tor-shepherd-service): Likewise. (network-manager-service-type): Likewise. (modem-manager-service-type): Likewise. (wpa-supplicant-service-type): Likewise. (openvswitch-activation): Likewise. (openvswitch-shepherd-service): Likewise. (dhcpd-shepherd-service): Use 'match-record' instead of 'match'. (dhcpd-activation): Likewise. (ntp-server->string): Likewise. (ntp-shepherd-service): Likewise. (tor-configuration->torrc): Likewise. (network-manager-activation): Likewise. (network-manager-environment): Likewise. (network-manager-shepherd-service): Likewise. (usb-modeswitch-configuration->udev-rules): Likewise. (wpa-supplicant-shepherd-service): Likewise. (iptables-shepherd-service): Likewise. (nftables-shepherd-service): Likewise. (keepalived-shepherd-service): Likewise. 2022-12-01services: network-manager: Add iwd backend support.Andrew Tropin * gnu/services/networking.scm (network-manager-configuration)[iwd?]: New field. (network-manager-shepherd-service): Add iwd to requirements if needed. * doc/guix.texi: Add information about iwd? option. 2022-11-18services: tor: Remove unnecessary modules from shepherd environment.Ludovic Courtès This is a followup to fb868cd7794f15e21298e5bdea996fbf0dad17ca. * gnu/services/networking.scm (tor-shepherd-service): Remove unused 'with-imported-modules' and 'modules' field. 2022-11-18services: Add Shepherd 'configuration' action to various services.Ludovic Courtès * gnu/services/avahi.scm (avahi-shepherd-service): Add 'actions' field. * gnu/services/base.scm (nscd-actions): Add call to 'shepherd-configuration-action'. * gnu/services/desktop.scm (upower-shepherd-service): Add 'actions' field. (elogind-shepherd-service): Likewise. * gnu/services/dict.scm (dicod-shepherd-service): Likewise. * gnu/services/networking.scm (openntpd-shepherd-service): Likewise. (tor-shepherd-service): Likewise. * gnu/services/ssh.scm (openssh-shepherd-service): Likewise. * gnu/services/web.scm (nginx-shepherd-service): Likewise. * gnu/services/xorg.scm (gdm-shepherd-service): Likewise. * gnu/tests/base.scm (run-basic-test)["nscd configuration action"]: New test. * doc/guix.texi (Services): Document it. 2022-10-06services: dhcp-client: Implement and use a configuration record.Alexey Abramov * gnu/services/networking.scm (dhcp-client-configuration): New record configuration. (dhcp-client-shepherd-service): Implement a shepher service. Provide a deprication message for legacy configurations. (dhcp-client-service-type): Use dhcp-client-shepherd-service. * doc/guix.texi (Networking Setup): Update. * po/guix/POTFILES.in: Add 'gnu/services/networking.scm'. Co-authored-by: Ludovic Courtès <ludo@gnu.org>