mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-10-06 13:03:29 +13:00
Rework
This commit is contained in:
parent
ecb8a68937
commit
b4800bdecd
8 changed files with 101 additions and 10 deletions
|
@ -89,7 +89,17 @@ public interface OsType {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTempDirectory(ShellControl pc) throws Exception {
|
public String getTempDirectory(ShellControl pc) throws Exception {
|
||||||
return pc.executeSimpleStringCommand(pc.getShellDialect().getPrintEnvironmentVariableCommand("TEMP"));
|
var def = pc.executeSimpleStringCommand(pc.getShellDialect().getPrintEnvironmentVariableCommand("TEMP"));
|
||||||
|
if (!def.isBlank() && pc.getShellDialect().directoryExists(pc, def).executeAndCheck()) {
|
||||||
|
return def;
|
||||||
|
}
|
||||||
|
|
||||||
|
var fallback = pc.executeSimpleStringCommand(pc.getShellDialect().getPrintEnvironmentVariableCommand("LOCALAPPDATA"));
|
||||||
|
if (!fallback.isBlank() && pc.getShellDialect().directoryExists(pc, fallback).executeAndCheck()) {
|
||||||
|
return fallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
return def;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -116,7 +126,7 @@ public interface OsType {
|
||||||
.trim();
|
.trim();
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
// Just in case this fails somehow
|
// Just in case this fails somehow
|
||||||
return "Windows ?";
|
return "Windows";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,7 +112,7 @@ public interface NetworkTunnelStore extends DataStore {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getLocalPort() {
|
public int getLocalPort() {
|
||||||
return local;
|
return remotePort;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
2
dist/changelogs/10.0.md
vendored
2
dist/changelogs/10.0.md
vendored
|
@ -34,6 +34,8 @@ If you have existing scripts, they will have to be manually adjusted by setting
|
||||||
|
|
||||||
The docker integration has been updated to support docker contexts. The UI has also been streamlined to make common actions more easily accessible.
|
The docker integration has been updated to support docker contexts. The UI has also been streamlined to make common actions more easily accessible.
|
||||||
|
|
||||||
|
There's also now support for Windows containers running on HyperV.
|
||||||
|
|
||||||
Note that old docker container connections will be removed as they are incompatible with the new version.
|
Note that old docker container connections will be removed as they are incompatible with the new version.
|
||||||
|
|
||||||
## Better connection organization
|
## Better connection organization
|
||||||
|
|
|
@ -24,6 +24,10 @@ public abstract class AbstractServiceStore extends JacksonizedValue implements S
|
||||||
Validators.nonNull(remotePort);
|
Validators.nonNull(remotePort);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean requiresTunnel() {
|
||||||
|
return getHost().getStore().requiresTunnel();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NetworkTunnelSession newSession() throws Exception {
|
public NetworkTunnelSession newSession() throws Exception {
|
||||||
var l = localPort != null ? localPort : HostHelper.findRandomOpenPortOnAllLocalInterfaces();
|
var l = localPort != null ? localPort : HostHelper.findRandomOpenPortOnAllLocalInterfaces();
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
package io.xpipe.ext.base.service;
|
package io.xpipe.ext.base.service;
|
||||||
|
|
||||||
|
import io.xpipe.app.comp.base.SystemStateComp;
|
||||||
import io.xpipe.app.comp.store.StoreEntryComp;
|
import io.xpipe.app.comp.store.StoreEntryComp;
|
||||||
import io.xpipe.app.comp.store.StoreEntryWrapper;
|
import io.xpipe.app.comp.store.StoreEntryWrapper;
|
||||||
import io.xpipe.app.comp.store.StoreSection;
|
import io.xpipe.app.comp.store.StoreSection;
|
||||||
import io.xpipe.app.ext.DataStoreProvider;
|
import io.xpipe.app.ext.DataStoreProvider;
|
||||||
import io.xpipe.app.ext.SingletonSessionStoreProvider;
|
import io.xpipe.app.ext.SingletonSessionStoreProvider;
|
||||||
|
import io.xpipe.app.fxcomps.Comp;
|
||||||
import io.xpipe.app.storage.DataStorage;
|
import io.xpipe.app.storage.DataStorage;
|
||||||
import io.xpipe.app.storage.DataStoreEntry;
|
import io.xpipe.app.storage.DataStoreEntry;
|
||||||
import io.xpipe.app.util.DataStoreFormatter;
|
import io.xpipe.app.util.DataStoreFormatter;
|
||||||
|
@ -23,6 +25,24 @@ public abstract class AbstractServiceStoreProvider implements SingletonSessionSt
|
||||||
return DataStorage.get().getOrCreateNewSyntheticEntry(s.getHost().get(), "Services", ServiceGroupStore.builder().parent(s.getHost()).build());
|
return DataStorage.get().getOrCreateNewSyntheticEntry(s.getHost().get(), "Services", ServiceGroupStore.builder().parent(s.getHost()).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Comp<?> stateDisplay(StoreEntryWrapper w) {
|
||||||
|
return new SystemStateComp(Bindings.createObjectBinding(
|
||||||
|
() -> {
|
||||||
|
AbstractServiceStore s = w.getEntry().getStore().asNeeded();
|
||||||
|
if (!s.requiresTunnel()) {
|
||||||
|
return SystemStateComp.State.SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!s.isSessionEnabled()) {
|
||||||
|
return SystemStateComp.State.OTHER;
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.isSessionRunning() ? SystemStateComp.State.SUCCESS : SystemStateComp.State.FAILURE;
|
||||||
|
},
|
||||||
|
w.getCache()));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StoreEntryComp customEntryComp(StoreSection sec, boolean preferLarge) {
|
public StoreEntryComp customEntryComp(StoreSection sec, boolean preferLarge) {
|
||||||
var toggle = createToggleComp(sec);
|
var toggle = createToggleComp(sec);
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
package io.xpipe.ext.base.service;
|
||||||
|
|
||||||
|
import io.xpipe.app.core.AppI18n;
|
||||||
|
import io.xpipe.app.ext.ActionProvider;
|
||||||
|
import io.xpipe.app.storage.DataStoreEntryRef;
|
||||||
|
import io.xpipe.app.util.ClipboardHelper;
|
||||||
|
import javafx.beans.value.ObservableValue;
|
||||||
|
import lombok.Value;
|
||||||
|
|
||||||
|
public class ServiceCopyUrlAction implements ActionProvider {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LeafDataStoreCallSite<?> getLeafDataStoreCallSite() {
|
||||||
|
return new LeafDataStoreCallSite<AbstractServiceStore>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isMajor(DataStoreEntryRef<AbstractServiceStore> o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canLinkTo() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ActionProvider.Action createAction(DataStoreEntryRef<AbstractServiceStore> store) {
|
||||||
|
return new Action(store.getStore());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<AbstractServiceStore> getApplicableClass() {
|
||||||
|
return AbstractServiceStore.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ObservableValue<String> getName(DataStoreEntryRef<AbstractServiceStore> store) {
|
||||||
|
return AppI18n.observable("copyUrl");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getIcon(DataStoreEntryRef<AbstractServiceStore> store) {
|
||||||
|
return "mdi2c-content-copy";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Value
|
||||||
|
static class Action implements ActionProvider.Action {
|
||||||
|
|
||||||
|
AbstractServiceStore serviceStore;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute() throws Exception {
|
||||||
|
serviceStore.startSessionIfNeeded();
|
||||||
|
var l = serviceStore.getSession().getLocalPort();
|
||||||
|
ClipboardHelper.copyUrl("localhost:" + l);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,11 +9,6 @@ import lombok.Value;
|
||||||
|
|
||||||
public class ServiceOpenAction implements ActionProvider {
|
public class ServiceOpenAction implements ActionProvider {
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getId() {
|
|
||||||
return "openWebsite";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LeafDataStoreCallSite<?> getLeafDataStoreCallSite() {
|
public LeafDataStoreCallSite<?> getLeafDataStoreCallSite() {
|
||||||
return new LeafDataStoreCallSite<AbstractServiceStore>() {
|
return new LeafDataStoreCallSite<AbstractServiceStore>() {
|
||||||
|
@ -45,7 +40,7 @@ public class ServiceOpenAction implements ActionProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getIcon(DataStoreEntryRef<AbstractServiceStore> store) {
|
public String getIcon(DataStoreEntryRef<AbstractServiceStore> store) {
|
||||||
return "mdi2w-web";
|
return "mdi2s-search-web";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ open module io.xpipe.ext.base {
|
||||||
UnzipAction,
|
UnzipAction,
|
||||||
JavapAction,
|
JavapAction,
|
||||||
JarAction;
|
JarAction;
|
||||||
provides ActionProvider with ServiceOpenAction,
|
provides ActionProvider with ServiceOpenAction, ServiceCopyUrlAction,
|
||||||
CloneStoreAction, RefreshChildrenStoreAction, ScanStoreAction, LaunchStoreAction,
|
CloneStoreAction, RefreshChildrenStoreAction, ScanStoreAction, LaunchStoreAction,
|
||||||
XPipeUrlAction,
|
XPipeUrlAction,
|
||||||
EditStoreAction, DeleteChildrenStoreAction,
|
EditStoreAction, DeleteChildrenStoreAction,
|
||||||
|
|
Loading…
Reference in a new issue