-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1906aaf
commit 9237ae8
Showing
18 changed files
with
264 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package ficsitcli | ||
|
||
import ( | ||
"github.com/pkg/errors" | ||
|
||
"github.com/satisfactorymodding/SatisfactoryModManager/backend/installfinders" | ||
) | ||
|
||
func (f *FicsitCLI) GetRemoteInstallations() []*installfinders.Installation { | ||
remoteInstallations := []*installfinders.Installation{} | ||
for _, install := range f.installations { | ||
if install.Info.Location == installfinders.LocationTypeRemote { | ||
remoteInstallations = append(remoteInstallations, install.Info) | ||
} | ||
} | ||
return remoteInstallations | ||
} | ||
|
||
func (f *FicsitCLI) AddRemoteServer(path string) error { | ||
installation := f.ficsitCli.Installations.GetInstallation(path) | ||
if installation == nil { | ||
fallbackProfile := "Default" | ||
if f.ficsitCli.Profiles.GetProfile(fallbackProfile) == nil { | ||
// Pick first profile found | ||
for name := range f.ficsitCli.Profiles.Profiles { | ||
fallbackProfile = name | ||
break | ||
} | ||
} | ||
|
||
var err error | ||
installation, err = f.ficsitCli.Installations.AddInstallation(f.ficsitCli, path, fallbackProfile) | ||
if err != nil { | ||
return errors.Wrap(err, "failed to add installation") | ||
} | ||
} | ||
gameVersion, err := installation.GetGameVersion(f.ficsitCli) | ||
if err != nil { | ||
return errors.Wrap(err, "failed to get game version") | ||
} | ||
|
||
platform, err := installation.GetPlatform(f.ficsitCli) | ||
if err != nil { | ||
return errors.Wrap(err, "failed to get platform") | ||
} | ||
var installType installfinders.InstallType | ||
switch platform.TargetName { | ||
case "Windows": | ||
installType = installfinders.InstallTypeWindowsClient | ||
case "WindowsServer": | ||
installType = installfinders.InstallTypeWindowsServer | ||
case "LinuxServer": | ||
installType = installfinders.InstallTypeLinuxServer | ||
} | ||
|
||
branch := installfinders.BranchEarlyAccess // TODO: Do we have a way to detect this for remote installs? | ||
|
||
f.installations = append(f.installations, &InstallationInfo{ | ||
Installation: installation, | ||
Info: &installfinders.Installation{ | ||
Path: installation.Path, | ||
Type: installType, | ||
Location: installfinders.LocationTypeRemote, | ||
Branch: branch, | ||
Version: gameVersion, | ||
Launcher: "Remote", | ||
}, | ||
}) | ||
|
||
f.EmitGlobals() | ||
|
||
return nil | ||
} | ||
|
||
func (f *FicsitCLI) RemoveRemoteServer(path string) error { | ||
for _, install := range f.installations { | ||
if install.Info.Path == path && install.Info.Location != installfinders.LocationTypeRemote { | ||
return errors.New("installation is not remote") | ||
} | ||
} | ||
err := f.ficsitCli.Installations.DeleteInstallation(path) | ||
if err != nil { | ||
return errors.Wrap(err, "failed to delete installation") | ||
} | ||
for i, install := range f.installations { | ||
if install.Info.Path == path { | ||
f.installations = append(f.installations[:i], f.installations[i+1:]...) | ||
break | ||
} | ||
} | ||
f.EmitGlobals() | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
frontend/src/lib/components/left-bar/ServerManager.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<script lang="ts"> | ||
import Button, { Label } from '@smui/button'; | ||
import { mdiServerNetwork, mdiTrashCan } from '@mdi/js'; | ||
import Dialog, { Actions, Content, Title } from '@smui/dialog'; | ||
import DataTable, { Body, Cell, Row } from '@smui/data-table'; | ||
import Select, { Option } from '@smui/select'; | ||
import Textfield from '@smui/textfield'; | ||
import SvgIcon from '$lib/components/SVGIcon.svelte'; | ||
import { remoteServers } from '$lib/store/ficsitCLIStore'; | ||
import { AddRemoteServer, RemoveRemoteServer } from '$lib/generated/wailsjs/go/ficsitcli/FicsitCLI'; | ||
import type { installfinders } from '$lib/generated/wailsjs/go/models'; | ||
let dialogOpen = false; | ||
const allowedProtocols = ['ftp://']; | ||
async function removeServer(server: installfinders.Installation) { | ||
try { | ||
await RemoveRemoteServer(server.path); | ||
} catch (e) { | ||
if(e instanceof Error) { | ||
err = e.message; | ||
} else if (typeof e === 'string') { | ||
err = e; | ||
} else { | ||
err = 'Unknown error'; | ||
} | ||
} | ||
} | ||
let newProtocol = allowedProtocols[0]; | ||
let newServerPath = ''; | ||
let err = ''; | ||
async function addNewRemoteServer() { | ||
if (!newServerPath) { | ||
return; | ||
} | ||
try { | ||
await AddRemoteServer(newProtocol + newServerPath); | ||
newServerPath = ''; | ||
} catch (e) { | ||
if(e instanceof Error) { | ||
err = e.message; | ||
} else if (typeof e === 'string') { | ||
err = e; | ||
} else { | ||
err = 'Unknown error'; | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<Button variant="unelevated" class="w-full mt-2" on:click={() => dialogOpen = true}> | ||
<Label> | ||
Manage Servers | ||
</Label> | ||
<div class="grow" /> | ||
<SvgIcon icon={mdiServerNetwork} class="h-5 w-5" /> | ||
</Button> | ||
|
||
<Dialog | ||
bind:open={dialogOpen} scrimClickAction="" escapeKeyAction="" | ||
surface$style="max-height: calc(100vh - 128px); max-width: calc(100vw - 128px);" | ||
surface$class="!min-w-[800px] min-h-[400px]" | ||
> | ||
<Title>Dedicated Servers</Title> | ||
<Content> | ||
<DataTable table$aria-label="Todo list" style="width: 100%;"> | ||
<Body> | ||
{#each $remoteServers as remoteServer} | ||
<Row> | ||
<Cell>{remoteServer.path}</Cell> | ||
<Cell>{remoteServer.type}</Cell> | ||
<Cell>{remoteServer.version}</Cell> | ||
<Cell> | ||
<Button on:click={() => removeServer(remoteServer)}> | ||
<SvgIcon icon={mdiTrashCan} class="!p-1 !m-0 !w-full !h-full group-hover:!hidden"/> | ||
</Button> | ||
</Cell> | ||
</Row> | ||
{/each} | ||
</Body> | ||
</DataTable> | ||
<div class="mt-4"> | ||
<div class="flex h-10"> | ||
<Select bind:value={newProtocol} class="!h-full w-32"> | ||
{#each allowedProtocols as protocol} | ||
<Option value={protocol}>{protocol}</Option> | ||
{/each} | ||
</Select> | ||
<Textfield bind:value={newServerPath} class="!h-full grow mx-4"/> | ||
<Button on:click={() => addNewRemoteServer()} class="!h-full">Add</Button> | ||
</div> | ||
<p>{err}</p> | ||
</div> | ||
</Content> | ||
<Actions> | ||
<Button on:click={() => dialogOpen = false}>Close</Button> | ||
</Actions> | ||
</Dialog> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.