gui

package
v0.18.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 10, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

README

README

About

Netclient. A lightweight client GUI for Netmaker.

Development

Due to addition of the github.com/gravitl/netclient library, you will need root privileges to run the app, even in dev mode. Always skip automatic TS modules generation when building or starting dev mode with -skipbindings because the models of some Go types are not generated. Only generate modules when you are sure. you will have to change the unkown types to any after generation.

Cheatsheet
  • Generate TS modules with export WAILS_EXEC="$(which wails)" && sudo -E PATH=$PATH:$GOROOT/bin $WAILS_EXEC generate module && sudo chown -R "$(whoami)" .
  • Run dev mode with export WAILS_EXEC="$(which wails)" && export NODE_PATH=/home/aceix/.volta/bin && sudo -E PATH=$PATH:$GOROOT/bin:$NODE_PATH $WAILS_EXEC dev -skipbindings

*actual paths might differ for you

If you want to develop in a browser and have access to your Go methods, there is also a dev server that runs on http://localhost:34115. Connect to this in your browser, and you can call your Go code from devtools.

You can configure the project by editing wails.json. More information about the project settings can be found here: https://wails.io/docs/reference/project-config

The frontend directory holds code for the UI. Make any UI changes only in this directory (inluding dependency installs like npm install).

Building

To build a redistributable, production mode package, use wails build -skipbindings (might also need root access).

Documentation

Overview

This file contains methods intended to be called in frontend

this file contains types to serve as wrappers since wails supports only up to two function return values: (data, error) or (data) https://wails.io/docs/howdoesitwork#method-binding:~:text=The%20generated%20methods,passed%20to%20it.

Index

Constants

View Source
const EV_OPEN_NETWORKS_PAGE = "open-networks-page"
View Source
const EV_OPEN_SETTINGS_PAGE = "open-settings-page"
View Source
const NETMAKER_DOCS_LINK = "https://docs.netmaker.org/"

Variables

This section is empty.

Functions

func GetAppMenu

func GetAppMenu(app *App) *menu.Menu

GetAppMenu builds and returns the application menu

func GetFileAsBytes

func GetFileAsBytes(path string) []byte

GetFileAsBytes returns the byte array form files It can be used to return the app icon

func OpenUrlInBrowser

func OpenUrlInBrowser(url string) error

Opens the user's browser with the given URL

Types

type App

type App struct {
	// contains filtered or unexported fields
}

App struct

func NewApp

func NewApp() *App

NewApp creates a new App application struct

func (*App) GoConnectToNetwork

func (app *App) GoConnectToNetwork(networkName string) (any, error)

App.goConnectToNetwork connects to the given network

func (*App) GoDisconnectFromNetwork

func (app *App) GoDisconnectFromNetwork(networkName string) (any, error)

App.goDisconnectFromNetwork disconnects from the given network

func (*App) GoGetKnownNetworks

func (app *App) GoGetKnownNetworks() ([]Network, error)

App.GoGetKnownNetworks returns all known network configs (node, server)

func (*App) GoGetNetclientConfig

func (app *App) GoGetNetclientConfig() (NcConfig, error)

App.GoGetNetclientConfig retrieves the netclient config (params the remain constant regardless the networks nc is connected to)

func (*App) GoGetNetwork

func (app *App) GoGetNetwork(networkName string) (Network, error)

App.GoGetNetwork returns node, server configs for the given network

func (*App) GoGetNodePeers

func (app *App) GoGetNodePeers(node config.Node) ([]wgtypes.PeerConfig, error)

App.GoGetNodePeers returns the peers for the given node

func (*App) GoGetRecentServerNames

func (app *App) GoGetRecentServerNames() ([]string, error)

App.GoGetRecentServerNames returns names of all known (joined) servers

func (*App) GoJoinNetworkByBasicAuth

func (app *App) GoJoinNetworkByBasicAuth(serverName, username, networkName, password string) (any, error)

App.GoJoinNetworkByBasicAuth joins a network by basic auth

func (*App) GoJoinNetworkBySso

func (app *App) GoJoinNetworkBySso(serverName, networkName string) (any, error)

App.GoJoinNetworkBySso joins a network by SSO

func (*App) GoJoinNetworkByToken

func (app *App) GoJoinNetworkByToken(token string) (any, error)

App.GoJoinNetworkByToken joins a network with the given token

func (*App) GoLeaveNetwork

func (app *App) GoLeaveNetwork(networkName string) (any, error)

App.GoLeaveNetwork leaves a known network

func (*App) GoOpenDialogue

func (app *App) GoOpenDialogue(dialogueType runtime.DialogType, msg, title string) (string, error)

App.GoOpenDialogue opens a dialogue box with title and message. Type of dialogue box is based on the type passed

func (*App) GoParseAccessToken

func (app *App) GoParseAccessToken(token string) (*models.AccessToken, error)

App.GoParseAccessToken parses a valid access token and returns the deconstructed parts

func (*App) GoPullLatestNodeConfig

func (app *App) GoPullLatestNodeConfig(network string) (Network, error)

App.GoPullLatestNodeConfig pulls the latest node config from the server and returns the network config

func (*App) GoRegisterWithEnrollmentKey added in v0.18.3

func (app *App) GoRegisterWithEnrollmentKey(key string) (any, error)

func (*App) GoUninstall

func (app *App) GoUninstall() (any, error)

App.GoUninstall uninstalls netclient form the machine

func (*App) GoUpdateNetclientConfig

func (app *App) GoUpdateNetclientConfig(updatedConfig config.Config) (any, error)

App.GoUpdateNetclientConfig updates netclient/host configs

func (*App) GoWriteToClipboard

func (app *App) GoWriteToClipboard(data string) (any, error)

App.GoWriteToClipboard writes given data to clipboard

func (*App) Startup

func (a *App) Startup(ctx context.Context)

App.Startup is called when the app starts. The context is saved so we can call the runtime methods

type NcConfig

type NcConfig struct {
	config.Config
	MacAddressStr string `json:"macaddressstr"`
}

NcConfig is a wrapper of the host/netclient config for GUI

type Network

type Network struct {
	Node   *config.Node   `json:"node"`
	Server *config.Server `json:"server"`
}

Network describes a server netclient is connected to as well as nc itself's representation on a network

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL