Rdp rework for other user login

This commit is contained in:
crschnick 2024-09-25 10:46:39 +00:00
parent 10d5541386
commit d2f3439961
27 changed files with 139 additions and 0 deletions

View file

@ -50,6 +50,10 @@ public interface ExternalRdpClientType extends PrefsChoiceValue {
return input; return input;
} }
if (input.get("username").isEmpty()) {
return input;
}
var pass = configuration.getPassword(); var pass = configuration.getPassword();
if (pass == null) { if (pass == null) {
return input; return input;

View file

@ -0,0 +1,93 @@
package io.xpipe.app.util;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.core.AppStyle;
import io.xpipe.app.core.AppTheme;
import io.xpipe.app.core.window.AppWindowHelper;
import io.xpipe.app.fxcomps.impl.TextFieldComp;
import javafx.animation.AnimationTimer;
import javafx.application.Platform;
import javafx.beans.property.SimpleObjectProperty;
import javafx.scene.control.Alert;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import java.util.Optional;
public class AsktextAlert {
public static Optional<String> query(String prompt) {
if (!PlatformState.initPlatformIfNeeded()) {
return Optional.empty();
}
AppStyle.init();
AppTheme.init();
var prop = new SimpleObjectProperty<String>();
var r = AppWindowHelper.showBlockingAlert(alert -> {
alert.setTitle(AppI18n.get("asktextAlertTitle"));
alert.setHeaderText(prompt);
alert.setAlertType(Alert.AlertType.CONFIRMATION);
var text = new TextFieldComp(prop, false).createStructure();
alert.getDialogPane().setContent(new StackPane(text.get()));
var stage = (Stage) alert.getDialogPane().getScene().getWindow();
stage.setAlwaysOnTop(true);
var anim = new AnimationTimer() {
private long lastRun = 0;
private int regainedFocusCount;
@Override
public void handle(long now) {
if (!stage.isShowing()) {
return;
}
if (regainedFocusCount >= 2) {
return;
}
if (lastRun == 0) {
lastRun = now;
return;
}
long elapsed = (now - lastRun) / 1_000_000;
if (elapsed < 500) {
return;
}
var hasFocus = stage.isFocused();
if (!hasFocus) {
regainedFocusCount++;
}
stage.requestFocus();
lastRun = now;
}
};
alert.setOnShown(event -> {
stage.requestFocus();
anim.start();
// Wait 1 pulse before focus so that the scene can be assigned to text
Platform.runLater(() -> {
text.get().requestFocus();
text.get().end();
});
event.consume();
});
alert.setOnHiding(event -> {
anim.stop();
});
})
.filter(b -> b.getButtonData().isDefaultButton())
.map(t -> {
return prop.getValue() != null ? prop.getValue() : null;
});
return r;
}
}

View file

@ -70,6 +70,12 @@ public class RdpConfig {
.collect(Collectors.joining("\n")); .collect(Collectors.joining("\n"));
} }
public RdpConfig withRemoved(String key) {
var map = new LinkedHashMap<String, TypedValue>(content);
map.remove(key);
return new RdpConfig(map);
}
public Optional<TypedValue> get(String key) { public Optional<TypedValue> get(String key) {
return Optional.ofNullable(content.get(key)); return Optional.ofNullable(content.get(key));
} }

View file

@ -522,3 +522,4 @@ green=Grøn
yellow=Gul yellow=Gul
blue=Blå blue=Blå
red=Rød red=Rød
asktextAlertTitle=Spørg

View file

@ -516,3 +516,4 @@ green=Grün
yellow=Gelb yellow=Gelb
blue=Blau blue=Blau
red=Rot red=Rot
asktextAlertTitle=Eingabeaufforderung

View file

@ -522,3 +522,4 @@ green=Green
yellow=Yellow yellow=Yellow
blue=Blue blue=Blue
red=Red red=Red
asktextAlertTitle=Prompt

View file

@ -503,3 +503,4 @@ green=Verde
yellow=Amarillo yellow=Amarillo
blue=Azul blue=Azul
red=Rojo red=Rojo
asktextAlertTitle=Pregunta

View file

@ -503,3 +503,4 @@ green=Vert
yellow=Jaune yellow=Jaune
blue=Bleu blue=Bleu
red=Rouge red=Rouge
asktextAlertTitle=Invite

View file

@ -503,3 +503,4 @@ green=Verde
yellow=Giallo yellow=Giallo
blue=Blu blue=Blu
red=Rosso red=Rosso
asktextAlertTitle=Prompt

View file

@ -503,3 +503,4 @@ green=グリーン
yellow=黄色 yellow=黄色
blue=ブルー blue=ブルー
red=赤い red=赤い
asktextAlertTitle=プロンプト

View file

@ -503,3 +503,4 @@ green=Groen
yellow=Geel yellow=Geel
blue=Blauw blue=Blauw
red=Rood red=Rood
asktextAlertTitle=Prompt

View file

@ -503,3 +503,4 @@ green=Verde
yellow=Amarelo yellow=Amarelo
blue=Azul blue=Azul
red=Vermelho red=Vermelho
asktextAlertTitle=Prompt

View file

@ -503,3 +503,4 @@ green=Зеленый
yellow=Желтый yellow=Желтый
blue=Синий blue=Синий
red=Красный red=Красный
asktextAlertTitle=Prompt

View file

@ -504,3 +504,4 @@ green=Yeşil
yellow=Sarı yellow=Sarı
blue=Mavi blue=Mavi
red=Kırmızı red=Kırmızı
asktextAlertTitle=İstem

View file

@ -503,3 +503,4 @@ green=绿色
yellow=黄色 yellow=黄色
blue=蓝色 blue=蓝色
red=红色 red=红色
asktextAlertTitle=提示

View file

@ -407,3 +407,5 @@ editConfiguration=Rediger konfiguration
viewInDashboard=Visning i dashboard viewInDashboard=Visning i dashboard
setDefault=Indstil standard setDefault=Indstil standard
removeDefault=Fjern standard removeDefault=Fjern standard
connectAsOtherUser=Opret forbindelse som anden bruger
provideUsername=Giv et alternativt brugernavn til at logge ind med

View file

@ -385,3 +385,5 @@ editConfiguration=Konfiguration bearbeiten
viewInDashboard=Ansicht im Dashboard viewInDashboard=Ansicht im Dashboard
setDefault=Standard einstellen setDefault=Standard einstellen
removeDefault=Standard entfernen removeDefault=Standard entfernen
connectAsOtherUser=Als anderer Benutzer verbinden
provideUsername=Einen alternativen Benutzernamen zum Einloggen angeben

View file

@ -383,3 +383,5 @@ editConfiguration=Edit configuration
viewInDashboard=View in dashboard viewInDashboard=View in dashboard
setDefault=Set default setDefault=Set default
removeDefault=Remove default removeDefault=Remove default
connectAsOtherUser=Connect as other user
provideUsername=Provide alternative username to log in with

View file

@ -381,3 +381,5 @@ editConfiguration=Editar configuración
viewInDashboard=Vista en el panel de control viewInDashboard=Vista en el panel de control
setDefault=Establecer por defecto setDefault=Establecer por defecto
removeDefault=Eliminar por defecto removeDefault=Eliminar por defecto
connectAsOtherUser=Conectarse como otro usuario
provideUsername=Proporcionar un nombre de usuario alternativo con el que iniciar sesión

View file

@ -381,3 +381,5 @@ editConfiguration=Modifier la configuration
viewInDashboard=Vue dans le tableau de bord viewInDashboard=Vue dans le tableau de bord
setDefault=Définir par défaut setDefault=Définir par défaut
removeDefault=Supprimer la valeur par défaut removeDefault=Supprimer la valeur par défaut
connectAsOtherUser=Se connecter en tant qu'autre utilisateur
provideUsername=Fournir un autre nom d'utilisateur pour se connecter

View file

@ -381,3 +381,5 @@ editConfiguration=Modifica la configurazione
viewInDashboard=Vista nel cruscotto viewInDashboard=Vista nel cruscotto
setDefault=Imposta predefinito setDefault=Imposta predefinito
removeDefault=Rimuovi l'impostazione predefinita removeDefault=Rimuovi l'impostazione predefinita
connectAsOtherUser=Connettersi come altro utente
provideUsername=Fornisce un nome utente alternativo con cui accedere

View file

@ -381,3 +381,5 @@ editConfiguration=設定を編集する
viewInDashboard=ダッシュボードで見る viewInDashboard=ダッシュボードで見る
setDefault=デフォルトを設定する setDefault=デフォルトを設定する
removeDefault=デフォルトを削除する removeDefault=デフォルトを削除する
connectAsOtherUser=他のユーザーとして接続する
provideUsername=別のユーザー名でログインする

View file

@ -381,3 +381,5 @@ editConfiguration=Configuratie bewerken
viewInDashboard=Weergave in dashboard viewInDashboard=Weergave in dashboard
setDefault=Standaard instellen setDefault=Standaard instellen
removeDefault=Standaard verwijderen removeDefault=Standaard verwijderen
connectAsOtherUser=Verbinden als andere gebruiker
provideUsername=Geef een alternatieve gebruikersnaam om mee in te loggen

View file

@ -381,3 +381,5 @@ editConfiguration=Edita a configuração
viewInDashboard=Ver no painel de controlo viewInDashboard=Ver no painel de controlo
setDefault=Definir predefinição setDefault=Definir predefinição
removeDefault=Remover predefinição removeDefault=Remover predefinição
connectAsOtherUser=Liga-te como outro utilizador
provideUsername=Fornece um nome de utilizador alternativo para iniciar sessão

View file

@ -381,3 +381,5 @@ editConfiguration=Редактирование конфигурации
viewInDashboard=Вид в приборной панели viewInDashboard=Вид в приборной панели
setDefault=Установить по умолчанию setDefault=Установить по умолчанию
removeDefault=Убрать значение по умолчанию removeDefault=Убрать значение по умолчанию
connectAsOtherUser=Подключиться как другой пользователь
provideUsername=Предоставьте альтернативное имя пользователя для входа в систему

View file

@ -381,3 +381,5 @@ editConfiguration=Yapılandırmayı düzenle
viewInDashboard=Gösterge tablosunda görüntüle viewInDashboard=Gösterge tablosunda görüntüle
setDefault=Varsayılanı ayarla setDefault=Varsayılanı ayarla
removeDefault=Varsayılanı kaldır removeDefault=Varsayılanı kaldır
connectAsOtherUser=Diğer kullanıcı olarak bağlan
provideUsername=Oturum açmak için alternatif kullanıcı adı sağlayın

View file

@ -381,3 +381,5 @@ editConfiguration=编辑配置
viewInDashboard=在仪表板中查看 viewInDashboard=在仪表板中查看
setDefault=设置默认值 setDefault=设置默认值
removeDefault=删除默认值 removeDefault=删除默认值
connectAsOtherUser=以其他用户身份连接
provideUsername=提供其他登录用户名