mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2026-02-15 04:34:34 +01:00
Compare commits
26 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0c7b72fb2c | ||
|
|
a869b97502 | ||
|
|
eadd343205 | ||
|
|
1bac986fe0 | ||
|
|
a94be6c2c3 | ||
|
|
fc8e9b4bb1 | ||
|
|
ec4b633889 | ||
|
|
e51804fa70 | ||
|
|
2466341999 | ||
|
|
929061213f | ||
|
|
6b52679942 | ||
|
|
efc0315c93 | ||
|
|
8e4c2a7cde | ||
|
|
4ec7f5895e | ||
|
|
ee22cdb55f | ||
|
|
b1b0d9a18f | ||
|
|
56e67f4725 | ||
|
|
3b7fdf36fb | ||
|
|
5291d316a2 | ||
|
|
4c369546da | ||
|
|
12a243d139 | ||
|
|
a97b3cf43e | ||
|
|
53a7c0d8ff | ||
|
|
9cb705f8dd | ||
|
|
8270674b7d | ||
|
|
24fd4b782d |
22
.github/workflows/analysis.yml
vendored
22
.github/workflows/analysis.yml
vendored
@@ -17,17 +17,29 @@ jobs:
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- uses: subosito/flutter-action@v2
|
||||
with:
|
||||
channel: 'stable' # or: 'beta', 'dev' or 'master'
|
||||
channel: 'stable'
|
||||
cache: true
|
||||
cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:'
|
||||
|
||||
- name: Cache pub dependencies
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
${{ env.PUB_CACHE }}
|
||||
~/.pub-cache
|
||||
${{ runner.tool_cache }}/flutter
|
||||
key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pub-
|
||||
|
||||
- name: Install dependencies
|
||||
run: flutter pub get
|
||||
|
||||
# Uncomment this step to verify the use of 'dart format' on each commit.
|
||||
- name: Verify formatting
|
||||
run: dart format --output=none .
|
||||
|
||||
# Consider passing '--fatal-infos' for slightly stricter analysis.
|
||||
- name: Analyze project source
|
||||
run: dart analyze
|
||||
|
||||
13
.github/workflows/release.yml
vendored
13
.github/workflows/release.yml
vendored
@@ -9,6 +9,11 @@ on:
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
# Set by fl_build
|
||||
# env:
|
||||
# APP_NAME: ServerBox
|
||||
# BUILD_NUMBER: ${{ github.ref_name }}
|
||||
|
||||
jobs:
|
||||
releaseAndroid:
|
||||
name: Release android
|
||||
@@ -20,7 +25,7 @@ jobs:
|
||||
uses: subosito/flutter-action@v2
|
||||
with:
|
||||
channel: "stable"
|
||||
flutter-version: "3.35.1"
|
||||
flutter-version: "3.35.3"
|
||||
- uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: "zulu"
|
||||
@@ -98,16 +103,12 @@ jobs:
|
||||
# uses: actions/checkout@v4
|
||||
# - name: Install Flutter
|
||||
# uses: subosito/flutter-action@v2
|
||||
# with:
|
||||
# channel: 'stable'
|
||||
# flutter-version: '3.32.1'
|
||||
# - name: Build
|
||||
# run: dart run fl_build -p ios,mac
|
||||
# run: dart run fl_build -p ios
|
||||
# - name: Create Release
|
||||
# uses: softprops/action-gh-release@v2
|
||||
# with:
|
||||
# files: |
|
||||
# ${{ env.APP_NAME }}_universal_macos.zip
|
||||
# ${{ env.APP_NAME }}_universal.ipa
|
||||
# env:
|
||||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
95
CLAUDE.md
Normal file
95
CLAUDE.md
Normal file
@@ -0,0 +1,95 @@
|
||||
# CLAUDE.md
|
||||
|
||||
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
||||
|
||||
## Commands
|
||||
|
||||
### Development
|
||||
|
||||
- `flutter run` - Run the app in development mode
|
||||
- `dart run fl_build -p PLATFORM` - Build the app for specific platform (see fl_build package)
|
||||
- `dart run build_runner build --delete-conflicting-outputs` - Generate code for models with annotations (json_serializable, freezed, hive, riverpod)
|
||||
- Every time you change model files, run this command to regenerate code (Hive adapters, Riverpod providers, etc.)
|
||||
- Generated files include: `*.g.dart`, `*.freezed.dart` files
|
||||
|
||||
### Testing
|
||||
|
||||
- `flutter test` - Run unit tests
|
||||
- `flutter test test/battery_test.dart` - Run specific test file
|
||||
|
||||
## Architecture
|
||||
|
||||
This is a Flutter application for managing Linux servers with the following key architectural components:
|
||||
|
||||
### Project Structure
|
||||
|
||||
- `lib/core/` - Core utilities, extensions, and routing
|
||||
- `lib/data/` - Data layer with models, providers, and storage
|
||||
- `model/` - Data models organized by feature (server, container, ssh, etc.)
|
||||
- `provider/` - Riverpod providers for state management
|
||||
- `store/` - Local storage implementations using Hive
|
||||
- `lib/view/` - UI layer with pages and widgets
|
||||
- `lib/generated/` - Generated localization files
|
||||
- `lib/hive/` - Hive adapters for local storage
|
||||
|
||||
### Key Technologies
|
||||
|
||||
- **State Management**: Riverpod with code generation (riverpod_annotation)
|
||||
- **Local Storage**: Hive for persistent data with generated adapters
|
||||
- **SSH/SFTP**: Custom dartssh2 fork for server connections
|
||||
- **Terminal**: Custom xterm.dart fork for SSH terminal interface
|
||||
- **Networking**: dio for HTTP requests
|
||||
- **Charts**: fl_chart for server status visualization
|
||||
- **Localization**: Flutter's built-in i18n with ARB files
|
||||
- **Code Generation**: Uses build_runner with json_serializable, freezed, hive_generator, riverpod_generator
|
||||
|
||||
### Data Models
|
||||
|
||||
- Server management models in `lib/data/model/server/`
|
||||
- Container/Docker models in `lib/data/model/container/`
|
||||
- SSH and SFTP models in respective directories
|
||||
- Most models use freezed for immutability and json_annotation for serialization
|
||||
|
||||
### Features
|
||||
|
||||
- Server status monitoring (CPU, memory, disk, network)
|
||||
- SSH terminal with virtual keyboard
|
||||
- SFTP file browser
|
||||
- Docker container management
|
||||
- Process and systemd service management
|
||||
- Server snippets and custom commands
|
||||
- Multi-language support (12+ languages)
|
||||
- Cross-platform support (iOS, Android, macOS, Linux, Windows)
|
||||
|
||||
### State Management Pattern
|
||||
|
||||
- Uses Riverpod providers for dependency injection and state management
|
||||
- Uses Freezed for immutable state models
|
||||
- Providers are organized by feature in `lib/data/provider/`
|
||||
- State is often persisted using Hive stores in `lib/data/store/`
|
||||
|
||||
### Build System
|
||||
|
||||
- Uses custom `fl_build` package for cross-platform building
|
||||
- `make.dart` script handles pre/post build tasks (metadata generation)
|
||||
- Supports building for multiple platforms with platform-specific configurations
|
||||
- Many dependencies are custom forks hosted on GitHub (dartssh2, xterm, fl_lib, etc.)
|
||||
|
||||
### Important Notes
|
||||
|
||||
- **Never run code formatting commands** - The codebase has specific formatting that should not be changed
|
||||
- **Always run code generation** after modifying models with annotations (freezed, json_serializable, hive, riverpod)
|
||||
- Generated files (`*.g.dart`, `*.freezed.dart`) should not be manually edited
|
||||
- AGAIN, NEVER run code formatting commands.
|
||||
- USE dependency injection via GetIt for services like Stores, Services and etc.
|
||||
- Generate all l10n files using `flutter gen-l10n` command after modifying ARB files.
|
||||
- USE `hive_ce` not `hive` package for Hive integration.
|
||||
- Which no need to config `HiveField` and `HiveType` manually.
|
||||
- USE widgets and utilities from `fl_lib` package for common functionalities.
|
||||
- Such as `CustomAppBar`, `context.showRoundDialog`, `Input`, `Btnx.cancelOk`, etc.
|
||||
- You can use context7 MCP to search `lppcg fl_lib KEYWORD` to find relevant widgets and utilities.
|
||||
- USE `libL10n` and `l10n` for localization strings.
|
||||
- `libL10n` is from `fl_lib` package, and `l10n` is from this project.
|
||||
- Before adding new strings, check if it already exists in `libL10n`.
|
||||
- Prioritize using strings from `libL10n` to avoid duplication, even if the meaning is not 100% exact, just use the substitution of `libL10n`.
|
||||
- Split UI into Widget build, Actions, Utils. use `extension on` to achieve this
|
||||
3
devtools_options.yaml
Normal file
3
devtools_options.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
description: This file stores settings for Dart & Flutter DevTools.
|
||||
documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states
|
||||
extensions:
|
||||
1
flutter_server_box.wiki
Submodule
1
flutter_server_box.wiki
Submodule
Submodule flutter_server_box.wiki added at f440010313
@@ -748,7 +748,7 @@
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
||||
CURRENT_PROJECT_VERSION = 1220;
|
||||
CURRENT_PROJECT_VERSION = 1246;
|
||||
DEVELOPMENT_TEAM = BA88US33G6;
|
||||
ENABLE_BITCODE = NO;
|
||||
INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist";
|
||||
@@ -758,7 +758,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0.1220;
|
||||
MARKETING_VERSION = 1.0.1246;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||
@@ -884,7 +884,7 @@
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
||||
CURRENT_PROJECT_VERSION = 1220;
|
||||
CURRENT_PROJECT_VERSION = 1246;
|
||||
DEVELOPMENT_TEAM = BA88US33G6;
|
||||
ENABLE_BITCODE = NO;
|
||||
INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist";
|
||||
@@ -894,7 +894,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0.1220;
|
||||
MARKETING_VERSION = 1.0.1246;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||
@@ -912,7 +912,7 @@
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
||||
CURRENT_PROJECT_VERSION = 1220;
|
||||
CURRENT_PROJECT_VERSION = 1246;
|
||||
DEVELOPMENT_TEAM = BA88US33G6;
|
||||
ENABLE_BITCODE = NO;
|
||||
INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist";
|
||||
@@ -922,7 +922,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0.1220;
|
||||
MARKETING_VERSION = 1.0.1246;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||
@@ -943,7 +943,7 @@
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1220;
|
||||
CURRENT_PROJECT_VERSION = 1246;
|
||||
DEVELOPMENT_TEAM = BA88US33G6;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
@@ -956,7 +956,7 @@
|
||||
"@executable_path/Frameworks",
|
||||
"@executable_path/../../Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0.1220;
|
||||
MARKETING_VERSION = 1.0.1246;
|
||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||
MTL_FAST_MATH = YES;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget;
|
||||
@@ -982,7 +982,7 @@
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1220;
|
||||
CURRENT_PROJECT_VERSION = 1246;
|
||||
DEVELOPMENT_TEAM = BA88US33G6;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
@@ -995,7 +995,7 @@
|
||||
"@executable_path/Frameworks",
|
||||
"@executable_path/../../Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0.1220;
|
||||
MARKETING_VERSION = 1.0.1246;
|
||||
MTL_FAST_MATH = YES;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
@@ -1018,7 +1018,7 @@
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1220;
|
||||
CURRENT_PROJECT_VERSION = 1246;
|
||||
DEVELOPMENT_TEAM = BA88US33G6;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
@@ -1031,7 +1031,7 @@
|
||||
"@executable_path/Frameworks",
|
||||
"@executable_path/../../Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0.1220;
|
||||
MARKETING_VERSION = 1.0.1246;
|
||||
MTL_FAST_MATH = YES;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
@@ -1054,7 +1054,7 @@
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1220;
|
||||
CURRENT_PROJECT_VERSION = 1246;
|
||||
DEVELOPMENT_ASSET_PATHS = "";
|
||||
DEVELOPMENT_TEAM = BA88US33G6;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
@@ -1066,7 +1066,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0.1220;
|
||||
MARKETING_VERSION = 1.0.1246;
|
||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||
MTL_FAST_MATH = YES;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.WatchEnd;
|
||||
@@ -1095,7 +1095,7 @@
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1220;
|
||||
CURRENT_PROJECT_VERSION = 1246;
|
||||
DEVELOPMENT_ASSET_PATHS = "";
|
||||
DEVELOPMENT_TEAM = BA88US33G6;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
@@ -1107,7 +1107,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0.1220;
|
||||
MARKETING_VERSION = 1.0.1246;
|
||||
MTL_FAST_MATH = YES;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.WatchEnd;
|
||||
PRODUCT_NAME = ServerBox;
|
||||
@@ -1133,7 +1133,7 @@
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1220;
|
||||
CURRENT_PROJECT_VERSION = 1246;
|
||||
DEVELOPMENT_ASSET_PATHS = "";
|
||||
DEVELOPMENT_TEAM = BA88US33G6;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
@@ -1145,7 +1145,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0.1220;
|
||||
MARKETING_VERSION = 1.0.1246;
|
||||
MTL_FAST_MATH = YES;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.WatchEnd;
|
||||
PRODUCT_NAME = ServerBox;
|
||||
|
||||
@@ -2,10 +2,10 @@ import 'package:fl_lib/fl_lib.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:server_box/data/model/app/scripts/cmd_types.dart';
|
||||
import 'package:server_box/data/model/server/dist.dart';
|
||||
import 'package:server_box/data/model/server/server.dart';
|
||||
import 'package:server_box/data/provider/server/single.dart';
|
||||
import 'package:server_box/data/res/store.dart';
|
||||
|
||||
extension LogoExt on Server {
|
||||
extension LogoExt on ServerState {
|
||||
String? getLogoUrl(BuildContext context) {
|
||||
var logoUrl = spi.custom?.logoUrl ?? Stores.setting.serverLogoUrl.fetch().selfNotEmptyOrNull;
|
||||
if (logoUrl == null) {
|
||||
@@ -14,11 +14,7 @@ final class BakSyncer extends SyncIface {
|
||||
@override
|
||||
Future<void> saveToFile() async {
|
||||
final pwd = await SecureStoreProps.bakPwd.read();
|
||||
if (pwd == null || pwd.isEmpty) {
|
||||
// Enforce password for non-clipboard backups
|
||||
throw Exception('Backup password not set');
|
||||
}
|
||||
await BackupV2.backup(null, pwd);
|
||||
await BackupV2.backup(null, pwd?.isEmpty == true ? null : pwd);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -78,7 +78,7 @@ Future<SSHClient> genClient(
|
||||
Loggers.app.warning('genClient', e);
|
||||
if (spi.alterUrl == null) rethrow;
|
||||
try {
|
||||
final res = spi.fromStringUrl();
|
||||
final res = spi.parseAlterUrl();
|
||||
alterUser = res.$2;
|
||||
return await SSHSocket.connect(res.$1, res.$3, timeout: timeout);
|
||||
} catch (e) {
|
||||
|
||||
84
lib/core/utils/server_dedup.dart
Normal file
84
lib/core/utils/server_dedup.dart
Normal file
@@ -0,0 +1,84 @@
|
||||
import 'package:server_box/data/model/server/server_private_info.dart';
|
||||
import 'package:server_box/data/store/server.dart';
|
||||
|
||||
class ServerDeduplication {
|
||||
/// Remove duplicate servers from the import list based on existing servers
|
||||
/// Returns the deduplicated list
|
||||
static List<Spi> deduplicateServers(List<Spi> importedServers) {
|
||||
final existingServers = ServerStore.instance.fetch();
|
||||
final deduplicated = <Spi>[];
|
||||
|
||||
for (final imported in importedServers) {
|
||||
if (!_isDuplicate(imported, existingServers)) {
|
||||
deduplicated.add(imported);
|
||||
}
|
||||
}
|
||||
|
||||
return deduplicated;
|
||||
}
|
||||
|
||||
/// Check if an imported server is a duplicate of an existing server
|
||||
static bool _isDuplicate(Spi imported, List<Spi> existing) {
|
||||
for (final existingSpi in existing) {
|
||||
if (imported.isSameAs(existingSpi)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Resolve name conflicts by appending suffixes
|
||||
static List<Spi> resolveNameConflicts(List<Spi> importedServers) {
|
||||
final existingServers = ServerStore.instance.fetch();
|
||||
final existingNames = existingServers.map((s) => s.name).toSet();
|
||||
final processedNames = <String>{};
|
||||
final result = <Spi>[];
|
||||
|
||||
for (final server in importedServers) {
|
||||
String newName = server.name;
|
||||
int suffix = 1;
|
||||
|
||||
// Check against both existing servers and already processed servers
|
||||
while (existingNames.contains(newName) || processedNames.contains(newName)) {
|
||||
newName = '${server.name} ($suffix)';
|
||||
suffix++;
|
||||
}
|
||||
|
||||
processedNames.add(newName);
|
||||
|
||||
if (newName != server.name) {
|
||||
result.add(server.copyWith(name: newName));
|
||||
} else {
|
||||
result.add(server);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// Get summary of import operation
|
||||
static ImportSummary getImportSummary(List<Spi> originalList, List<Spi> deduplicatedList) {
|
||||
final duplicateCount = originalList.length - deduplicatedList.length;
|
||||
return ImportSummary(
|
||||
total: originalList.length,
|
||||
duplicates: duplicateCount,
|
||||
toImport: deduplicatedList.length,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ImportSummary {
|
||||
final int total;
|
||||
final int duplicates;
|
||||
final int toImport;
|
||||
|
||||
const ImportSummary({
|
||||
required this.total,
|
||||
required this.duplicates,
|
||||
required this.toImport,
|
||||
});
|
||||
|
||||
bool get hasDuplicates => duplicates > 0;
|
||||
bool get hasItemsToImport => toImport > 0;
|
||||
}
|
||||
188
lib/core/utils/ssh_config.dart
Normal file
188
lib/core/utils/ssh_config.dart
Normal file
@@ -0,0 +1,188 @@
|
||||
import 'dart:io';
|
||||
import 'package:fl_lib/fl_lib.dart';
|
||||
import 'package:server_box/data/model/server/server_private_info.dart';
|
||||
|
||||
/// Utility class to parse SSH config files under `~/.ssh/config`
|
||||
abstract final class SSHConfig {
|
||||
static const String _defaultPath = '~/.ssh/config';
|
||||
|
||||
static String? get _homePath {
|
||||
final homePath = isWindows ? Platform.environment['USERPROFILE'] : Platform.environment['HOME'];
|
||||
if (homePath == null || homePath.isEmpty) {
|
||||
return null;
|
||||
}
|
||||
return homePath;
|
||||
}
|
||||
|
||||
/// Get possible SSH config file paths, with macOS-specific handling
|
||||
static List<String> get _possibleConfigPaths {
|
||||
final paths = <String>[];
|
||||
final homePath = _homePath;
|
||||
|
||||
if (homePath != null) {
|
||||
// Standard path
|
||||
paths.add('$homePath/.ssh/config');
|
||||
|
||||
// On macOS, also try the actual user home directory
|
||||
if (isMacOS) {
|
||||
// Try to get the real user home directory
|
||||
final username = Platform.environment['USER'];
|
||||
if (username != null) {
|
||||
paths.add('/Users/$username/.ssh/config');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return paths;
|
||||
}
|
||||
|
||||
/// Parse SSH config file and return a list of Spi objects
|
||||
static Future<List<Spi>> parseConfig([String? configPath]) async {
|
||||
final (file, exists) = configExists(configPath);
|
||||
if (!exists || file == null) {
|
||||
Loggers.app.info('SSH config file does not exist at path: ${configPath ?? _defaultPath}');
|
||||
return [];
|
||||
}
|
||||
|
||||
final content = await file.readAsString();
|
||||
return _parseSSHConfig(content);
|
||||
}
|
||||
|
||||
/// Parse SSH config content
|
||||
static List<Spi> _parseSSHConfig(String content) {
|
||||
final servers = <Spi>[];
|
||||
final lines = content.split('\n');
|
||||
|
||||
String? currentHost;
|
||||
String? hostname;
|
||||
String? user;
|
||||
int port = 22;
|
||||
String? identityFile;
|
||||
String? jumpHost;
|
||||
|
||||
void addServer() {
|
||||
if (currentHost != null && currentHost != '*' && hostname != null) {
|
||||
final spi = Spi(
|
||||
id: ShortId.generate(),
|
||||
name: currentHost,
|
||||
ip: hostname,
|
||||
port: port,
|
||||
user: user ?? 'root', // Default user is 'root'
|
||||
keyId: identityFile,
|
||||
jumpId: jumpHost,
|
||||
);
|
||||
servers.add(spi);
|
||||
}
|
||||
}
|
||||
|
||||
for (final line in lines) {
|
||||
final trimmed = line.trim();
|
||||
if (trimmed.isEmpty || trimmed.startsWith('#')) continue;
|
||||
|
||||
// Handle inline comments
|
||||
final commentIndex = trimmed.indexOf('#');
|
||||
final cleanLine = commentIndex != -1 ? trimmed.substring(0, commentIndex).trim() : trimmed;
|
||||
if (cleanLine.isEmpty) continue;
|
||||
|
||||
final parts = cleanLine.split(RegExp(r'\s+'));
|
||||
if (parts.length < 2) continue;
|
||||
|
||||
final key = parts[0].toLowerCase();
|
||||
var value = parts.sublist(1).join(' ');
|
||||
|
||||
// Remove quotes from values
|
||||
if ((value.startsWith('"') && value.endsWith('"')) || (value.startsWith("'") && value.endsWith("'"))) {
|
||||
value = value.substring(1, value.length - 1);
|
||||
}
|
||||
|
||||
switch (key) {
|
||||
case 'host':
|
||||
// Save previous host config
|
||||
addServer();
|
||||
|
||||
// Reset for new host
|
||||
final originalValue = parts.sublist(1).join(' ');
|
||||
final isQuoted =
|
||||
(originalValue.startsWith('"') && originalValue.endsWith('"')) ||
|
||||
(originalValue.startsWith("'") && originalValue.endsWith("'"));
|
||||
|
||||
currentHost = value;
|
||||
// Skip hosts with multiple patterns (contains spaces but not quoted)
|
||||
if (currentHost.contains(' ') && !isQuoted) {
|
||||
currentHost = null; // Mark as invalid to skip
|
||||
}
|
||||
hostname = null;
|
||||
user = null;
|
||||
port = 22;
|
||||
identityFile = null;
|
||||
jumpHost = null;
|
||||
break;
|
||||
|
||||
case 'hostname':
|
||||
hostname = value;
|
||||
break;
|
||||
|
||||
case 'user':
|
||||
user = value;
|
||||
break;
|
||||
|
||||
case 'port':
|
||||
port = int.tryParse(value) ?? 22;
|
||||
break;
|
||||
|
||||
case 'identityfile':
|
||||
identityFile = value; // Store the path directly
|
||||
break;
|
||||
|
||||
case 'proxyjump':
|
||||
case 'proxycommand':
|
||||
jumpHost = _extractJumpHost(value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Add the last server
|
||||
addServer();
|
||||
|
||||
return servers;
|
||||
}
|
||||
|
||||
/// Extract jump host from ProxyJump or ProxyCommand
|
||||
static String? _extractJumpHost(String value) {
|
||||
// For ProxyJump, the format is usually: user@host:port
|
||||
// For ProxyCommand, it's more complex and might need custom parsing
|
||||
if (value.contains('@')) {
|
||||
return value.split(' ').first;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Check if SSH config file exists, trying multiple possible paths
|
||||
static (File?, bool) configExists([String? configPath]) {
|
||||
if (configPath != null) {
|
||||
// If specific path is provided, use it directly
|
||||
final homePath = _homePath;
|
||||
if (homePath == null) {
|
||||
Loggers.app.warning('Cannot determine home directory for SSH config parsing.');
|
||||
return (null, false);
|
||||
}
|
||||
final expandedPath = configPath.replaceFirst('~', homePath);
|
||||
dprint('Checking SSH config at path: $expandedPath');
|
||||
final file = File(expandedPath);
|
||||
return (file, file.existsSync());
|
||||
}
|
||||
|
||||
// Try multiple possible paths
|
||||
for (final path in _possibleConfigPaths) {
|
||||
dprint('Checking SSH config at path: $path');
|
||||
final file = File(path);
|
||||
if (file.existsSync()) {
|
||||
dprint('Found SSH config at: $path');
|
||||
return (file, true);
|
||||
}
|
||||
}
|
||||
|
||||
dprint('SSH config file not found in any of the expected locations');
|
||||
return (null, false);
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,9 @@ import 'dart:io';
|
||||
import 'package:fl_lib/fl_lib.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:server_box/data/provider/private_key.dart';
|
||||
import 'package:server_box/data/provider/server/all.dart';
|
||||
import 'package:server_box/data/provider/snippet.dart';
|
||||
import 'package:server_box/data/res/misc.dart';
|
||||
import 'package:server_box/data/res/store.dart';
|
||||
|
||||
@@ -44,17 +47,17 @@ abstract class BackupV2 with _$BackupV2 implements Mergeable {
|
||||
Future<void> merge({bool force = false}) async {
|
||||
_loggerV2.info('Merging...');
|
||||
|
||||
// Merge each store
|
||||
await Mergeable.mergeStore(backupData: spis, store: Stores.server, force: force);
|
||||
await Mergeable.mergeStore(backupData: snippets, store: Stores.snippet, force: force);
|
||||
await Mergeable.mergeStore(backupData: keys, store: Stores.key, force: force);
|
||||
// Merge each store and check if changes were made
|
||||
final serverChanged = await Mergeable.mergeStore(backupData: spis, store: Stores.server, force: force);
|
||||
final snippetChanged = await Mergeable.mergeStore(backupData: snippets, store: Stores.snippet, force: force);
|
||||
final keyChanged = await Mergeable.mergeStore(backupData: keys, store: Stores.key, force: force);
|
||||
await Mergeable.mergeStore(backupData: container, store: Stores.container, force: force);
|
||||
await Mergeable.mergeStore(backupData: history, store: Stores.history, force: force);
|
||||
await Mergeable.mergeStore(backupData: settings, store: Stores.setting, force: force);
|
||||
|
||||
// Reload providers and notify listeners
|
||||
Provider.reload();
|
||||
RNodes.app.notify();
|
||||
if (serverChanged) GlobalRef.gRef?.read(serversNotifierProvider.notifier).reload();
|
||||
if (snippetChanged) GlobalRef.gRef?.read(snippetNotifierProvider.notifier).reload();
|
||||
if (keyChanged) GlobalRef.gRef?.read(privateKeyNotifierProvider.notifier).reload();
|
||||
|
||||
_loggerV2.info('Merge completed');
|
||||
}
|
||||
|
||||
@@ -11,27 +11,10 @@ class BackupService {
|
||||
/// Perform backup operation with the given source
|
||||
static Future<void> backup(BuildContext context, BackupSource source) async {
|
||||
try {
|
||||
String? password;
|
||||
final saved = await SecureStoreProps.bakPwd.read();
|
||||
final password = saved?.isEmpty == true ? null : saved;
|
||||
|
||||
if (source is ClipboardBackupSource) {
|
||||
// Clipboard backup: allow optional password
|
||||
password = await _getClipboardPassword(context);
|
||||
if (password == null) return; // canceled
|
||||
} else {
|
||||
// All other backups require pre-set bakPwd (SecureStore)
|
||||
final saved = await SecureStoreProps.bakPwd.read();
|
||||
if (saved == null || saved.isEmpty) {
|
||||
// Prompt to set before proceeding
|
||||
password = await _showPasswordDialog(context, hint: l10n.backupPasswordTip);
|
||||
if (password == null || password.isEmpty) return; // Not set
|
||||
await SecureStoreProps.bakPwd.write(password);
|
||||
context.showSnackBar(l10n.backupPasswordSet);
|
||||
} else {
|
||||
password = saved;
|
||||
}
|
||||
}
|
||||
|
||||
final path = await BackupV2.backup(null, password.isEmpty ? null : password);
|
||||
final path = await BackupV2.backup(null, password?.isEmpty == true ? null : password);
|
||||
await source.saveContent(path);
|
||||
|
||||
if (source is ClipboardBackupSource) {
|
||||
@@ -56,34 +39,6 @@ class BackupService {
|
||||
await restoreFromText(context, text);
|
||||
}
|
||||
|
||||
/// Handle password dialog for backup operations
|
||||
static Future<String?> _getClipboardPassword(BuildContext context) async {
|
||||
// Use saved bakPwd as default for clipboard flow if exists, but allow empty/custom
|
||||
final savedPassword = await SecureStoreProps.bakPwd.read();
|
||||
String? password;
|
||||
|
||||
if (savedPassword != null && savedPassword.isNotEmpty) {
|
||||
final useCustom = await context.showRoundDialog<bool>(
|
||||
title: l10n.backupPassword,
|
||||
child: Text(l10n.backupPasswordTip),
|
||||
actions: [
|
||||
Btn.cancel(),
|
||||
TextButton(onPressed: () => context.pop(false), child: Text(l10n.backupPasswordSet)),
|
||||
TextButton(onPressed: () => context.pop(true), child: Text(libL10n.custom)),
|
||||
],
|
||||
);
|
||||
if (useCustom == null) return null;
|
||||
if (useCustom) {
|
||||
password = await _showPasswordDialog(context, initial: savedPassword);
|
||||
} else {
|
||||
password = savedPassword;
|
||||
}
|
||||
} else {
|
||||
password = await _showPasswordDialog(context);
|
||||
}
|
||||
return password;
|
||||
}
|
||||
|
||||
/// Handle restore from text with decryption support
|
||||
static Future<void> restoreFromText(BuildContext context, String text) async {
|
||||
// Check if backup is encrypted
|
||||
|
||||
@@ -4,7 +4,7 @@ import 'package:server_box/core/extension/context/locale.dart';
|
||||
enum SSHErrType { unknown, connect, auth, noPrivateKey, chdir, segements, writeScript, getStatus }
|
||||
|
||||
class SSHErr extends Err<SSHErrType> {
|
||||
SSHErr({required super.type, super.message});
|
||||
const SSHErr({required super.type, super.message});
|
||||
|
||||
@override
|
||||
String? get solution => switch (type) {
|
||||
@@ -29,7 +29,7 @@ enum ContainerErrType {
|
||||
}
|
||||
|
||||
class ContainerErr extends Err<ContainerErrType> {
|
||||
ContainerErr({required super.type, super.message});
|
||||
const ContainerErr({required super.type, super.message});
|
||||
|
||||
@override
|
||||
String? get solution => null;
|
||||
@@ -38,7 +38,7 @@ class ContainerErr extends Err<ContainerErrType> {
|
||||
enum ICloudErrType { generic, notFound, multipleFiles }
|
||||
|
||||
class ICloudErr extends Err<ICloudErrType> {
|
||||
ICloudErr({required super.type, super.message});
|
||||
const ICloudErr({required super.type, super.message});
|
||||
|
||||
@override
|
||||
String? get solution => null;
|
||||
@@ -47,7 +47,7 @@ class ICloudErr extends Err<ICloudErrType> {
|
||||
enum WebdavErrType { generic, notFound }
|
||||
|
||||
class WebdavErr extends Err<WebdavErrType> {
|
||||
WebdavErr({required super.type, super.message});
|
||||
const WebdavErr({required super.type, super.message});
|
||||
|
||||
@override
|
||||
String? get solution => null;
|
||||
@@ -56,7 +56,7 @@ class WebdavErr extends Err<WebdavErrType> {
|
||||
enum PveErrType { unknown, net, loginFailed }
|
||||
|
||||
class PveErr extends Err<PveErrType> {
|
||||
PveErr({required super.type, super.message});
|
||||
const PveErr({required super.type, super.message});
|
||||
|
||||
@override
|
||||
String? get solution => null;
|
||||
|
||||
@@ -55,8 +55,8 @@ enum StatusCmdType implements ShellCmdType {
|
||||
uptime('uptime'),
|
||||
conn('cat /proc/net/snmp'),
|
||||
disk(
|
||||
'lsblk --bytes --json --output '
|
||||
'FSTYPE,PATH,NAME,KNAME,MOUNTPOINT,FSSIZE,FSUSED,FSAVAIL,FSUSE%,UUID',
|
||||
'(lsblk --bytes --json --output '
|
||||
'FSTYPE,PATH,NAME,KNAME,MOUNTPOINT,FSSIZE,FSUSED,FSAVAIL,FSUSE%,UUID 2>/dev/null && echo "LSBLK_SUCCESS") || df -k'
|
||||
),
|
||||
mem("cat /proc/meminfo | grep -E 'Mem|Swap'"),
|
||||
tempType('cat /sys/class/thermal/thermal_zone*/type'),
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import 'package:server_box/data/model/app/scripts/script_builders.dart';
|
||||
import 'package:server_box/data/model/app/scripts/script_consts.dart';
|
||||
import 'package:server_box/data/model/server/system.dart';
|
||||
import 'package:server_box/data/provider/server.dart';
|
||||
|
||||
/// Shell functions available in the ServerBox application
|
||||
enum ShellFunc {
|
||||
@@ -26,8 +25,8 @@ enum ShellFunc {
|
||||
};
|
||||
|
||||
/// Execute this shell function on the specified server
|
||||
String exec(String id, {SystemType? systemType}) {
|
||||
final scriptPath = ShellFuncManager.getScriptPath(id, systemType: systemType);
|
||||
String exec(String id, {SystemType? systemType, required String? customDir}) {
|
||||
final scriptPath = ShellFuncManager.getScriptPath(id, systemType: systemType, customDir: customDir);
|
||||
final isWindows = systemType == SystemType.windows;
|
||||
final builder = ScriptBuilderFactory.getBuilder(isWindows);
|
||||
|
||||
@@ -51,11 +50,10 @@ class ShellFuncManager {
|
||||
/// Get the script directory for the given [id].
|
||||
///
|
||||
/// Checks for custom script directory first, then falls back to default.
|
||||
static String getScriptDir(String id, {SystemType? systemType}) {
|
||||
final customScriptDir = ServerProvider.pick(id: id)?.value.spi.custom?.scriptDir;
|
||||
static String getScriptDir(String id, {SystemType? systemType, required String? customDir}) {
|
||||
final isWindows = systemType == SystemType.windows;
|
||||
|
||||
if (customScriptDir != null) return _normalizeDir(customScriptDir, isWindows);
|
||||
if (customDir != null) return _normalizeDir(customDir, isWindows);
|
||||
return ScriptPaths.getScriptDir(id, isWindows: isWindows);
|
||||
}
|
||||
|
||||
@@ -66,11 +64,10 @@ class ShellFuncManager {
|
||||
}
|
||||
|
||||
/// Get the full script path for the given [id]
|
||||
static String getScriptPath(String id, {SystemType? systemType}) {
|
||||
final customScriptDir = ServerProvider.pick(id: id)?.value.spi.custom?.scriptDir;
|
||||
if (customScriptDir != null) {
|
||||
static String getScriptPath(String id, {SystemType? systemType, required String? customDir}) {
|
||||
if (customDir != null) {
|
||||
final isWindows = systemType == SystemType.windows;
|
||||
final normalizedDir = _normalizeDir(customScriptDir, isWindows);
|
||||
final normalizedDir = _normalizeDir(customDir, isWindows);
|
||||
final fileName = isWindows ? ScriptConstants.scriptFileWindows : ScriptConstants.scriptFile;
|
||||
final separator = isWindows ? ScriptConstants.windowsPathSeparator : ScriptConstants.unixPathSeparator;
|
||||
return '$normalizedDir$separator$fileName';
|
||||
@@ -81,8 +78,8 @@ class ShellFuncManager {
|
||||
}
|
||||
|
||||
/// Get the installation shell command for the script
|
||||
static String getInstallShellCmd(String id, {SystemType? systemType}) {
|
||||
final scriptDir = getScriptDir(id, systemType: systemType);
|
||||
static String getInstallShellCmd(String id, {SystemType? systemType, required String? customDir}) {
|
||||
final scriptDir = getScriptDir(id, systemType: systemType, customDir: customDir);
|
||||
final isWindows = systemType == SystemType.windows;
|
||||
final normalizedDir = _normalizeDir(scriptDir, isWindows);
|
||||
final builder = ScriptBuilderFactory.getBuilder(isWindows);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:fl_lib/fl_lib.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hive_ce_flutter/adapters.dart';
|
||||
import 'package:icons_plus/icons_plus.dart';
|
||||
import 'package:server_box/core/extension/context/locale.dart';
|
||||
import 'package:server_box/view/page/server/tab/tab.dart';
|
||||
@@ -8,10 +9,17 @@ import 'package:server_box/view/page/snippet/list.dart';
|
||||
import 'package:server_box/view/page/ssh/tab.dart';
|
||||
import 'package:server_box/view/page/storage/local.dart';
|
||||
|
||||
part 'tab.g.dart';
|
||||
|
||||
@HiveType(typeId: 103)
|
||||
enum AppTab {
|
||||
@HiveField(0)
|
||||
server,
|
||||
@HiveField(1)
|
||||
ssh,
|
||||
@HiveField(2)
|
||||
file,
|
||||
@HiveField(3)
|
||||
snippet
|
||||
//settings,
|
||||
;
|
||||
@@ -93,4 +101,35 @@ enum AppTab {
|
||||
static List<NavigationRailDestination> get navRailDestinations {
|
||||
return AppTab.values.map((e) => e.navRailDestination).toList();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// Helper function to parse AppTab list from stored object
|
||||
static List<AppTab> parseAppTabsFromObj(dynamic val) {
|
||||
if (val is List) {
|
||||
final tabs = <AppTab>[];
|
||||
for (final e in val) {
|
||||
final tab = _parseAppTabFromElement(e);
|
||||
if (tab != null) {
|
||||
tabs.add(tab);
|
||||
}
|
||||
}
|
||||
if (tabs.isNotEmpty) return tabs;
|
||||
}
|
||||
return AppTab.values;
|
||||
}
|
||||
|
||||
/// Helper function to parse a single AppTab from various element types
|
||||
static AppTab? _parseAppTabFromElement(dynamic e) {
|
||||
if (e is AppTab) {
|
||||
return e;
|
||||
} else if (e is String) {
|
||||
return AppTab.values.firstWhereOrNull((t) => t.name == e);
|
||||
} else if (e is int) {
|
||||
if (e >= 0 && e < AppTab.values.length) {
|
||||
return AppTab.values[e];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
52
lib/data/model/app/tab.g.dart
Normal file
52
lib/data/model/app/tab.g.dart
Normal file
@@ -0,0 +1,52 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'tab.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// TypeAdapterGenerator
|
||||
// **************************************************************************
|
||||
|
||||
class AppTabAdapter extends TypeAdapter<AppTab> {
|
||||
@override
|
||||
final typeId = 103;
|
||||
|
||||
@override
|
||||
AppTab read(BinaryReader reader) {
|
||||
switch (reader.readByte()) {
|
||||
case 0:
|
||||
return AppTab.server;
|
||||
case 1:
|
||||
return AppTab.ssh;
|
||||
case 2:
|
||||
return AppTab.file;
|
||||
case 3:
|
||||
return AppTab.snippet;
|
||||
default:
|
||||
return AppTab.server;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void write(BinaryWriter writer, AppTab obj) {
|
||||
switch (obj) {
|
||||
case AppTab.server:
|
||||
writer.writeByte(0);
|
||||
case AppTab.ssh:
|
||||
writer.writeByte(1);
|
||||
case AppTab.file:
|
||||
writer.writeByte(2);
|
||||
case AppTab.snippet:
|
||||
writer.writeByte(3);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => typeId.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is AppTabAdapter &&
|
||||
runtimeType == other.runtimeType &&
|
||||
typeId == other.typeId;
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import 'dart:convert';
|
||||
|
||||
import 'package:fl_lib/fl_lib.dart';
|
||||
import 'package:server_box/core/extension/context/locale.dart';
|
||||
import 'package:server_box/data/model/container/status.dart';
|
||||
import 'package:server_box/data/model/container/type.dart';
|
||||
import 'package:server_box/data/res/misc.dart';
|
||||
|
||||
@@ -10,7 +11,7 @@ sealed class ContainerPs {
|
||||
final String? image = null;
|
||||
String? get name;
|
||||
String? get cmd;
|
||||
bool get running;
|
||||
ContainerStatus get status;
|
||||
|
||||
String? cpu;
|
||||
String? mem;
|
||||
@@ -51,7 +52,7 @@ final class PodmanPs implements ContainerPs {
|
||||
String? get cmd => command?.firstOrNull;
|
||||
|
||||
@override
|
||||
bool get running => exited != true;
|
||||
ContainerStatus get status => ContainerStatus.fromPodmanExited(exited);
|
||||
|
||||
@override
|
||||
void parseStats(String s) {
|
||||
@@ -121,10 +122,7 @@ final class DockerPs implements ContainerPs {
|
||||
String? get cmd => null;
|
||||
|
||||
@override
|
||||
bool get running {
|
||||
if (state?.contains('Exited') == true) return false;
|
||||
return true;
|
||||
}
|
||||
ContainerStatus get status => ContainerStatus.fromDockerState(state);
|
||||
|
||||
@override
|
||||
void parseStats(String s) {
|
||||
|
||||
70
lib/data/model/container/status.dart
Normal file
70
lib/data/model/container/status.dart
Normal file
@@ -0,0 +1,70 @@
|
||||
import 'package:fl_lib/fl_lib.dart';
|
||||
import 'package:server_box/core/extension/context/locale.dart';
|
||||
|
||||
/// Represents the various states a container can be in.
|
||||
/// Supports both Docker and Podman container status parsing.
|
||||
enum ContainerStatus {
|
||||
running,
|
||||
exited,
|
||||
created,
|
||||
paused,
|
||||
restarting,
|
||||
removing,
|
||||
dead,
|
||||
unknown;
|
||||
|
||||
/// Check if the container is actively running
|
||||
bool get isRunning => this == ContainerStatus.running;
|
||||
|
||||
/// Check if the container can be started
|
||||
bool get canStart =>
|
||||
this == ContainerStatus.exited ||
|
||||
this == ContainerStatus.created ||
|
||||
this == ContainerStatus.dead;
|
||||
|
||||
/// Check if the container can be stopped
|
||||
bool get canStop =>
|
||||
this == ContainerStatus.running || this == ContainerStatus.paused;
|
||||
|
||||
/// Check if the container can be restarted
|
||||
bool get canRestart =>
|
||||
this != ContainerStatus.removing && this != ContainerStatus.unknown;
|
||||
|
||||
/// Parse Docker container status string to ContainerStatus
|
||||
static ContainerStatus fromDockerState(String? state) {
|
||||
if (state == null || state.isEmpty) return ContainerStatus.unknown;
|
||||
|
||||
final lowerState = state.toLowerCase();
|
||||
|
||||
if (lowerState.startsWith('up')) return ContainerStatus.running;
|
||||
if (lowerState.contains('exited')) return ContainerStatus.exited;
|
||||
if (lowerState.contains('created')) return ContainerStatus.created;
|
||||
if (lowerState.contains('paused')) return ContainerStatus.paused;
|
||||
if (lowerState.contains('restarting')) return ContainerStatus.restarting;
|
||||
if (lowerState.contains('removing')) return ContainerStatus.removing;
|
||||
if (lowerState.contains('dead')) return ContainerStatus.dead;
|
||||
|
||||
return ContainerStatus.unknown;
|
||||
}
|
||||
|
||||
/// Parse Podman container status from exited boolean
|
||||
static ContainerStatus fromPodmanExited(bool? exited) {
|
||||
if (exited == true) return ContainerStatus.exited;
|
||||
if (exited == false) return ContainerStatus.running;
|
||||
return ContainerStatus.unknown;
|
||||
}
|
||||
|
||||
/// Get display string for the status
|
||||
String get displayName {
|
||||
return switch (this) {
|
||||
ContainerStatus.running => l10n.running,
|
||||
ContainerStatus.exited => libL10n.exit,
|
||||
ContainerStatus.created => 'Created',
|
||||
ContainerStatus.paused => 'Paused',
|
||||
ContainerStatus.restarting => 'Restarting',
|
||||
ContainerStatus.removing => 'Removing',
|
||||
ContainerStatus.dead => 'Dead',
|
||||
ContainerStatus.unknown => libL10n.unknown,
|
||||
};
|
||||
}
|
||||
}
|
||||
79
lib/data/model/server/connection_stat.dart
Normal file
79
lib/data/model/server/connection_stat.dart
Normal file
@@ -0,0 +1,79 @@
|
||||
import 'package:fl_lib/fl_lib.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:hive_ce/hive.dart';
|
||||
|
||||
part 'connection_stat.freezed.dart';
|
||||
part 'connection_stat.g.dart';
|
||||
|
||||
@freezed
|
||||
@HiveType(typeId: 100)
|
||||
abstract class ConnectionStat with _$ConnectionStat {
|
||||
const factory ConnectionStat({
|
||||
@HiveField(0) required String serverId,
|
||||
@HiveField(1) required String serverName,
|
||||
@HiveField(2) required DateTime timestamp,
|
||||
@HiveField(3) required ConnectionResult result,
|
||||
@HiveField(4) @Default('') String errorMessage,
|
||||
@HiveField(5) required int durationMs,
|
||||
}) = _ConnectionStat;
|
||||
|
||||
factory ConnectionStat.fromJson(Map<String, dynamic> json) =>
|
||||
_$ConnectionStatFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
@HiveType(typeId: 101)
|
||||
abstract class ServerConnectionStats with _$ServerConnectionStats {
|
||||
const factory ServerConnectionStats({
|
||||
@HiveField(0) required String serverId,
|
||||
@HiveField(1) required String serverName,
|
||||
@HiveField(2) required int totalAttempts,
|
||||
@HiveField(3) required int successCount,
|
||||
@HiveField(4) required int failureCount,
|
||||
@HiveField(5) @Default(null) DateTime? lastSuccessTime,
|
||||
@HiveField(6) @Default(null) DateTime? lastFailureTime,
|
||||
@HiveField(7) @Default([]) List<ConnectionStat> recentConnections,
|
||||
@HiveField(8) required double successRate,
|
||||
}) = _ServerConnectionStats;
|
||||
|
||||
factory ServerConnectionStats.fromJson(Map<String, dynamic> json) =>
|
||||
_$ServerConnectionStatsFromJson(json);
|
||||
}
|
||||
|
||||
@HiveType(typeId: 102)
|
||||
enum ConnectionResult {
|
||||
@HiveField(0)
|
||||
@JsonValue('success')
|
||||
success,
|
||||
@HiveField(1)
|
||||
@JsonValue('timeout')
|
||||
timeout,
|
||||
@HiveField(2)
|
||||
@JsonValue('auth_failed')
|
||||
authFailed,
|
||||
@HiveField(3)
|
||||
@JsonValue('network_error')
|
||||
networkError,
|
||||
@HiveField(4)
|
||||
@JsonValue('unknown_error')
|
||||
unknownError,
|
||||
}
|
||||
|
||||
extension ConnectionResultExtension on ConnectionResult {
|
||||
String get displayName {
|
||||
switch (this) {
|
||||
case ConnectionResult.success:
|
||||
return libL10n.success;
|
||||
case ConnectionResult.timeout:
|
||||
return '${libL10n.error}(timeout)';
|
||||
case ConnectionResult.authFailed:
|
||||
return '${libL10n.error}(auth)';
|
||||
case ConnectionResult.networkError:
|
||||
return '${libL10n.error}(${libL10n.network})';
|
||||
case ConnectionResult.unknownError:
|
||||
return '${libL10n.error}(${libL10n.unknown})';
|
||||
}
|
||||
}
|
||||
|
||||
bool get isSuccess => this == ConnectionResult.success;
|
||||
}
|
||||
585
lib/data/model/server/connection_stat.freezed.dart
Normal file
585
lib/data/model/server/connection_stat.freezed.dart
Normal file
@@ -0,0 +1,585 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'connection_stat.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
/// @nodoc
|
||||
mixin _$ConnectionStat {
|
||||
|
||||
@HiveField(0) String get serverId;@HiveField(1) String get serverName;@HiveField(2) DateTime get timestamp;@HiveField(3) ConnectionResult get result;@HiveField(4) String get errorMessage;@HiveField(5) int get durationMs;
|
||||
/// Create a copy of ConnectionStat
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$ConnectionStatCopyWith<ConnectionStat> get copyWith => _$ConnectionStatCopyWithImpl<ConnectionStat>(this as ConnectionStat, _$identity);
|
||||
|
||||
/// Serializes this ConnectionStat to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is ConnectionStat&&(identical(other.serverId, serverId) || other.serverId == serverId)&&(identical(other.serverName, serverName) || other.serverName == serverName)&&(identical(other.timestamp, timestamp) || other.timestamp == timestamp)&&(identical(other.result, result) || other.result == result)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.durationMs, durationMs) || other.durationMs == durationMs));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,serverId,serverName,timestamp,result,errorMessage,durationMs);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ConnectionStat(serverId: $serverId, serverName: $serverName, timestamp: $timestamp, result: $result, errorMessage: $errorMessage, durationMs: $durationMs)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $ConnectionStatCopyWith<$Res> {
|
||||
factory $ConnectionStatCopyWith(ConnectionStat value, $Res Function(ConnectionStat) _then) = _$ConnectionStatCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
@HiveField(0) String serverId,@HiveField(1) String serverName,@HiveField(2) DateTime timestamp,@HiveField(3) ConnectionResult result,@HiveField(4) String errorMessage,@HiveField(5) int durationMs
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$ConnectionStatCopyWithImpl<$Res>
|
||||
implements $ConnectionStatCopyWith<$Res> {
|
||||
_$ConnectionStatCopyWithImpl(this._self, this._then);
|
||||
|
||||
final ConnectionStat _self;
|
||||
final $Res Function(ConnectionStat) _then;
|
||||
|
||||
/// Create a copy of ConnectionStat
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? serverId = null,Object? serverName = null,Object? timestamp = null,Object? result = null,Object? errorMessage = null,Object? durationMs = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
serverId: null == serverId ? _self.serverId : serverId // ignore: cast_nullable_to_non_nullable
|
||||
as String,serverName: null == serverName ? _self.serverName : serverName // ignore: cast_nullable_to_non_nullable
|
||||
as String,timestamp: null == timestamp ? _self.timestamp : timestamp // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,result: null == result ? _self.result : result // ignore: cast_nullable_to_non_nullable
|
||||
as ConnectionResult,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,durationMs: null == durationMs ? _self.durationMs : durationMs // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [ConnectionStat].
|
||||
extension ConnectionStatPatterns on ConnectionStat {
|
||||
/// A variant of `map` that fallback to returning `orElse`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _ConnectionStat value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _ConnectionStat() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// Callbacks receives the raw object, upcasted.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case final Subclass2 value:
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _ConnectionStat value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _ConnectionStat():
|
||||
return $default(_that);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `map` that fallback to returning `null`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _ConnectionStat value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _ConnectionStat() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function(@HiveField(0) String serverId, @HiveField(1) String serverName, @HiveField(2) DateTime timestamp, @HiveField(3) ConnectionResult result, @HiveField(4) String errorMessage, @HiveField(5) int durationMs)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ConnectionStat() when $default != null:
|
||||
return $default(_that.serverId,_that.serverName,_that.timestamp,_that.result,_that.errorMessage,_that.durationMs);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function(@HiveField(0) String serverId, @HiveField(1) String serverName, @HiveField(2) DateTime timestamp, @HiveField(3) ConnectionResult result, @HiveField(4) String errorMessage, @HiveField(5) int durationMs) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ConnectionStat():
|
||||
return $default(_that.serverId,_that.serverName,_that.timestamp,_that.result,_that.errorMessage,_that.durationMs);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function(@HiveField(0) String serverId, @HiveField(1) String serverName, @HiveField(2) DateTime timestamp, @HiveField(3) ConnectionResult result, @HiveField(4) String errorMessage, @HiveField(5) int durationMs)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ConnectionStat() when $default != null:
|
||||
return $default(_that.serverId,_that.serverName,_that.timestamp,_that.result,_that.errorMessage,_that.durationMs);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _ConnectionStat implements ConnectionStat {
|
||||
const _ConnectionStat({@HiveField(0) required this.serverId, @HiveField(1) required this.serverName, @HiveField(2) required this.timestamp, @HiveField(3) required this.result, @HiveField(4) this.errorMessage = '', @HiveField(5) required this.durationMs});
|
||||
factory _ConnectionStat.fromJson(Map<String, dynamic> json) => _$ConnectionStatFromJson(json);
|
||||
|
||||
@override@HiveField(0) final String serverId;
|
||||
@override@HiveField(1) final String serverName;
|
||||
@override@HiveField(2) final DateTime timestamp;
|
||||
@override@HiveField(3) final ConnectionResult result;
|
||||
@override@JsonKey()@HiveField(4) final String errorMessage;
|
||||
@override@HiveField(5) final int durationMs;
|
||||
|
||||
/// Create a copy of ConnectionStat
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$ConnectionStatCopyWith<_ConnectionStat> get copyWith => __$ConnectionStatCopyWithImpl<_ConnectionStat>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$ConnectionStatToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ConnectionStat&&(identical(other.serverId, serverId) || other.serverId == serverId)&&(identical(other.serverName, serverName) || other.serverName == serverName)&&(identical(other.timestamp, timestamp) || other.timestamp == timestamp)&&(identical(other.result, result) || other.result == result)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.durationMs, durationMs) || other.durationMs == durationMs));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,serverId,serverName,timestamp,result,errorMessage,durationMs);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ConnectionStat(serverId: $serverId, serverName: $serverName, timestamp: $timestamp, result: $result, errorMessage: $errorMessage, durationMs: $durationMs)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$ConnectionStatCopyWith<$Res> implements $ConnectionStatCopyWith<$Res> {
|
||||
factory _$ConnectionStatCopyWith(_ConnectionStat value, $Res Function(_ConnectionStat) _then) = __$ConnectionStatCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
@HiveField(0) String serverId,@HiveField(1) String serverName,@HiveField(2) DateTime timestamp,@HiveField(3) ConnectionResult result,@HiveField(4) String errorMessage,@HiveField(5) int durationMs
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$ConnectionStatCopyWithImpl<$Res>
|
||||
implements _$ConnectionStatCopyWith<$Res> {
|
||||
__$ConnectionStatCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _ConnectionStat _self;
|
||||
final $Res Function(_ConnectionStat) _then;
|
||||
|
||||
/// Create a copy of ConnectionStat
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? serverId = null,Object? serverName = null,Object? timestamp = null,Object? result = null,Object? errorMessage = null,Object? durationMs = null,}) {
|
||||
return _then(_ConnectionStat(
|
||||
serverId: null == serverId ? _self.serverId : serverId // ignore: cast_nullable_to_non_nullable
|
||||
as String,serverName: null == serverName ? _self.serverName : serverName // ignore: cast_nullable_to_non_nullable
|
||||
as String,timestamp: null == timestamp ? _self.timestamp : timestamp // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,result: null == result ? _self.result : result // ignore: cast_nullable_to_non_nullable
|
||||
as ConnectionResult,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,durationMs: null == durationMs ? _self.durationMs : durationMs // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// @nodoc
|
||||
mixin _$ServerConnectionStats {
|
||||
|
||||
@HiveField(0) String get serverId;@HiveField(1) String get serverName;@HiveField(2) int get totalAttempts;@HiveField(3) int get successCount;@HiveField(4) int get failureCount;@HiveField(5) DateTime? get lastSuccessTime;@HiveField(6) DateTime? get lastFailureTime;@HiveField(7) List<ConnectionStat> get recentConnections;@HiveField(8) double get successRate;
|
||||
/// Create a copy of ServerConnectionStats
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$ServerConnectionStatsCopyWith<ServerConnectionStats> get copyWith => _$ServerConnectionStatsCopyWithImpl<ServerConnectionStats>(this as ServerConnectionStats, _$identity);
|
||||
|
||||
/// Serializes this ServerConnectionStats to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is ServerConnectionStats&&(identical(other.serverId, serverId) || other.serverId == serverId)&&(identical(other.serverName, serverName) || other.serverName == serverName)&&(identical(other.totalAttempts, totalAttempts) || other.totalAttempts == totalAttempts)&&(identical(other.successCount, successCount) || other.successCount == successCount)&&(identical(other.failureCount, failureCount) || other.failureCount == failureCount)&&(identical(other.lastSuccessTime, lastSuccessTime) || other.lastSuccessTime == lastSuccessTime)&&(identical(other.lastFailureTime, lastFailureTime) || other.lastFailureTime == lastFailureTime)&&const DeepCollectionEquality().equals(other.recentConnections, recentConnections)&&(identical(other.successRate, successRate) || other.successRate == successRate));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,serverId,serverName,totalAttempts,successCount,failureCount,lastSuccessTime,lastFailureTime,const DeepCollectionEquality().hash(recentConnections),successRate);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ServerConnectionStats(serverId: $serverId, serverName: $serverName, totalAttempts: $totalAttempts, successCount: $successCount, failureCount: $failureCount, lastSuccessTime: $lastSuccessTime, lastFailureTime: $lastFailureTime, recentConnections: $recentConnections, successRate: $successRate)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $ServerConnectionStatsCopyWith<$Res> {
|
||||
factory $ServerConnectionStatsCopyWith(ServerConnectionStats value, $Res Function(ServerConnectionStats) _then) = _$ServerConnectionStatsCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
@HiveField(0) String serverId,@HiveField(1) String serverName,@HiveField(2) int totalAttempts,@HiveField(3) int successCount,@HiveField(4) int failureCount,@HiveField(5) DateTime? lastSuccessTime,@HiveField(6) DateTime? lastFailureTime,@HiveField(7) List<ConnectionStat> recentConnections,@HiveField(8) double successRate
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$ServerConnectionStatsCopyWithImpl<$Res>
|
||||
implements $ServerConnectionStatsCopyWith<$Res> {
|
||||
_$ServerConnectionStatsCopyWithImpl(this._self, this._then);
|
||||
|
||||
final ServerConnectionStats _self;
|
||||
final $Res Function(ServerConnectionStats) _then;
|
||||
|
||||
/// Create a copy of ServerConnectionStats
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? serverId = null,Object? serverName = null,Object? totalAttempts = null,Object? successCount = null,Object? failureCount = null,Object? lastSuccessTime = freezed,Object? lastFailureTime = freezed,Object? recentConnections = null,Object? successRate = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
serverId: null == serverId ? _self.serverId : serverId // ignore: cast_nullable_to_non_nullable
|
||||
as String,serverName: null == serverName ? _self.serverName : serverName // ignore: cast_nullable_to_non_nullable
|
||||
as String,totalAttempts: null == totalAttempts ? _self.totalAttempts : totalAttempts // ignore: cast_nullable_to_non_nullable
|
||||
as int,successCount: null == successCount ? _self.successCount : successCount // ignore: cast_nullable_to_non_nullable
|
||||
as int,failureCount: null == failureCount ? _self.failureCount : failureCount // ignore: cast_nullable_to_non_nullable
|
||||
as int,lastSuccessTime: freezed == lastSuccessTime ? _self.lastSuccessTime : lastSuccessTime // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime?,lastFailureTime: freezed == lastFailureTime ? _self.lastFailureTime : lastFailureTime // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime?,recentConnections: null == recentConnections ? _self.recentConnections : recentConnections // ignore: cast_nullable_to_non_nullable
|
||||
as List<ConnectionStat>,successRate: null == successRate ? _self.successRate : successRate // ignore: cast_nullable_to_non_nullable
|
||||
as double,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [ServerConnectionStats].
|
||||
extension ServerConnectionStatsPatterns on ServerConnectionStats {
|
||||
/// A variant of `map` that fallback to returning `orElse`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _ServerConnectionStats value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _ServerConnectionStats() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// Callbacks receives the raw object, upcasted.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case final Subclass2 value:
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _ServerConnectionStats value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _ServerConnectionStats():
|
||||
return $default(_that);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `map` that fallback to returning `null`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _ServerConnectionStats value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _ServerConnectionStats() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function(@HiveField(0) String serverId, @HiveField(1) String serverName, @HiveField(2) int totalAttempts, @HiveField(3) int successCount, @HiveField(4) int failureCount, @HiveField(5) DateTime? lastSuccessTime, @HiveField(6) DateTime? lastFailureTime, @HiveField(7) List<ConnectionStat> recentConnections, @HiveField(8) double successRate)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ServerConnectionStats() when $default != null:
|
||||
return $default(_that.serverId,_that.serverName,_that.totalAttempts,_that.successCount,_that.failureCount,_that.lastSuccessTime,_that.lastFailureTime,_that.recentConnections,_that.successRate);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function(@HiveField(0) String serverId, @HiveField(1) String serverName, @HiveField(2) int totalAttempts, @HiveField(3) int successCount, @HiveField(4) int failureCount, @HiveField(5) DateTime? lastSuccessTime, @HiveField(6) DateTime? lastFailureTime, @HiveField(7) List<ConnectionStat> recentConnections, @HiveField(8) double successRate) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ServerConnectionStats():
|
||||
return $default(_that.serverId,_that.serverName,_that.totalAttempts,_that.successCount,_that.failureCount,_that.lastSuccessTime,_that.lastFailureTime,_that.recentConnections,_that.successRate);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function(@HiveField(0) String serverId, @HiveField(1) String serverName, @HiveField(2) int totalAttempts, @HiveField(3) int successCount, @HiveField(4) int failureCount, @HiveField(5) DateTime? lastSuccessTime, @HiveField(6) DateTime? lastFailureTime, @HiveField(7) List<ConnectionStat> recentConnections, @HiveField(8) double successRate)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ServerConnectionStats() when $default != null:
|
||||
return $default(_that.serverId,_that.serverName,_that.totalAttempts,_that.successCount,_that.failureCount,_that.lastSuccessTime,_that.lastFailureTime,_that.recentConnections,_that.successRate);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _ServerConnectionStats implements ServerConnectionStats {
|
||||
const _ServerConnectionStats({@HiveField(0) required this.serverId, @HiveField(1) required this.serverName, @HiveField(2) required this.totalAttempts, @HiveField(3) required this.successCount, @HiveField(4) required this.failureCount, @HiveField(5) this.lastSuccessTime = null, @HiveField(6) this.lastFailureTime = null, @HiveField(7) final List<ConnectionStat> recentConnections = const [], @HiveField(8) required this.successRate}): _recentConnections = recentConnections;
|
||||
factory _ServerConnectionStats.fromJson(Map<String, dynamic> json) => _$ServerConnectionStatsFromJson(json);
|
||||
|
||||
@override@HiveField(0) final String serverId;
|
||||
@override@HiveField(1) final String serverName;
|
||||
@override@HiveField(2) final int totalAttempts;
|
||||
@override@HiveField(3) final int successCount;
|
||||
@override@HiveField(4) final int failureCount;
|
||||
@override@JsonKey()@HiveField(5) final DateTime? lastSuccessTime;
|
||||
@override@JsonKey()@HiveField(6) final DateTime? lastFailureTime;
|
||||
final List<ConnectionStat> _recentConnections;
|
||||
@override@JsonKey()@HiveField(7) List<ConnectionStat> get recentConnections {
|
||||
if (_recentConnections is EqualUnmodifiableListView) return _recentConnections;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_recentConnections);
|
||||
}
|
||||
|
||||
@override@HiveField(8) final double successRate;
|
||||
|
||||
/// Create a copy of ServerConnectionStats
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$ServerConnectionStatsCopyWith<_ServerConnectionStats> get copyWith => __$ServerConnectionStatsCopyWithImpl<_ServerConnectionStats>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$ServerConnectionStatsToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ServerConnectionStats&&(identical(other.serverId, serverId) || other.serverId == serverId)&&(identical(other.serverName, serverName) || other.serverName == serverName)&&(identical(other.totalAttempts, totalAttempts) || other.totalAttempts == totalAttempts)&&(identical(other.successCount, successCount) || other.successCount == successCount)&&(identical(other.failureCount, failureCount) || other.failureCount == failureCount)&&(identical(other.lastSuccessTime, lastSuccessTime) || other.lastSuccessTime == lastSuccessTime)&&(identical(other.lastFailureTime, lastFailureTime) || other.lastFailureTime == lastFailureTime)&&const DeepCollectionEquality().equals(other._recentConnections, _recentConnections)&&(identical(other.successRate, successRate) || other.successRate == successRate));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,serverId,serverName,totalAttempts,successCount,failureCount,lastSuccessTime,lastFailureTime,const DeepCollectionEquality().hash(_recentConnections),successRate);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ServerConnectionStats(serverId: $serverId, serverName: $serverName, totalAttempts: $totalAttempts, successCount: $successCount, failureCount: $failureCount, lastSuccessTime: $lastSuccessTime, lastFailureTime: $lastFailureTime, recentConnections: $recentConnections, successRate: $successRate)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$ServerConnectionStatsCopyWith<$Res> implements $ServerConnectionStatsCopyWith<$Res> {
|
||||
factory _$ServerConnectionStatsCopyWith(_ServerConnectionStats value, $Res Function(_ServerConnectionStats) _then) = __$ServerConnectionStatsCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
@HiveField(0) String serverId,@HiveField(1) String serverName,@HiveField(2) int totalAttempts,@HiveField(3) int successCount,@HiveField(4) int failureCount,@HiveField(5) DateTime? lastSuccessTime,@HiveField(6) DateTime? lastFailureTime,@HiveField(7) List<ConnectionStat> recentConnections,@HiveField(8) double successRate
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$ServerConnectionStatsCopyWithImpl<$Res>
|
||||
implements _$ServerConnectionStatsCopyWith<$Res> {
|
||||
__$ServerConnectionStatsCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _ServerConnectionStats _self;
|
||||
final $Res Function(_ServerConnectionStats) _then;
|
||||
|
||||
/// Create a copy of ServerConnectionStats
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? serverId = null,Object? serverName = null,Object? totalAttempts = null,Object? successCount = null,Object? failureCount = null,Object? lastSuccessTime = freezed,Object? lastFailureTime = freezed,Object? recentConnections = null,Object? successRate = null,}) {
|
||||
return _then(_ServerConnectionStats(
|
||||
serverId: null == serverId ? _self.serverId : serverId // ignore: cast_nullable_to_non_nullable
|
||||
as String,serverName: null == serverName ? _self.serverName : serverName // ignore: cast_nullable_to_non_nullable
|
||||
as String,totalAttempts: null == totalAttempts ? _self.totalAttempts : totalAttempts // ignore: cast_nullable_to_non_nullable
|
||||
as int,successCount: null == successCount ? _self.successCount : successCount // ignore: cast_nullable_to_non_nullable
|
||||
as int,failureCount: null == failureCount ? _self.failureCount : failureCount // ignore: cast_nullable_to_non_nullable
|
||||
as int,lastSuccessTime: freezed == lastSuccessTime ? _self.lastSuccessTime : lastSuccessTime // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime?,lastFailureTime: freezed == lastFailureTime ? _self.lastFailureTime : lastFailureTime // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime?,recentConnections: null == recentConnections ? _self._recentConnections : recentConnections // ignore: cast_nullable_to_non_nullable
|
||||
as List<ConnectionStat>,successRate: null == successRate ? _self.successRate : successRate // ignore: cast_nullable_to_non_nullable
|
||||
as double,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
233
lib/data/model/server/connection_stat.g.dart
Normal file
233
lib/data/model/server/connection_stat.g.dart
Normal file
@@ -0,0 +1,233 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'connection_stat.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// TypeAdapterGenerator
|
||||
// **************************************************************************
|
||||
|
||||
class ConnectionStatAdapter extends TypeAdapter<ConnectionStat> {
|
||||
@override
|
||||
final typeId = 100;
|
||||
|
||||
@override
|
||||
ConnectionStat read(BinaryReader reader) {
|
||||
final numOfFields = reader.readByte();
|
||||
final fields = <int, dynamic>{
|
||||
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
|
||||
};
|
||||
return ConnectionStat(
|
||||
serverId: fields[0] as String,
|
||||
serverName: fields[1] as String,
|
||||
timestamp: fields[2] as DateTime,
|
||||
result: fields[3] as ConnectionResult,
|
||||
errorMessage: fields[4] == null ? '' : fields[4] as String,
|
||||
durationMs: (fields[5] as num).toInt(),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void write(BinaryWriter writer, ConnectionStat obj) {
|
||||
writer
|
||||
..writeByte(6)
|
||||
..writeByte(0)
|
||||
..write(obj.serverId)
|
||||
..writeByte(1)
|
||||
..write(obj.serverName)
|
||||
..writeByte(2)
|
||||
..write(obj.timestamp)
|
||||
..writeByte(3)
|
||||
..write(obj.result)
|
||||
..writeByte(4)
|
||||
..write(obj.errorMessage)
|
||||
..writeByte(5)
|
||||
..write(obj.durationMs);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => typeId.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is ConnectionStatAdapter &&
|
||||
runtimeType == other.runtimeType &&
|
||||
typeId == other.typeId;
|
||||
}
|
||||
|
||||
class ServerConnectionStatsAdapter extends TypeAdapter<ServerConnectionStats> {
|
||||
@override
|
||||
final typeId = 101;
|
||||
|
||||
@override
|
||||
ServerConnectionStats read(BinaryReader reader) {
|
||||
final numOfFields = reader.readByte();
|
||||
final fields = <int, dynamic>{
|
||||
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
|
||||
};
|
||||
return ServerConnectionStats(
|
||||
serverId: fields[0] as String,
|
||||
serverName: fields[1] as String,
|
||||
totalAttempts: (fields[2] as num).toInt(),
|
||||
successCount: (fields[3] as num).toInt(),
|
||||
failureCount: (fields[4] as num).toInt(),
|
||||
lastSuccessTime: fields[5] == null ? null : fields[5] as DateTime?,
|
||||
lastFailureTime: fields[6] == null ? null : fields[6] as DateTime?,
|
||||
recentConnections: fields[7] == null
|
||||
? []
|
||||
: (fields[7] as List).cast<ConnectionStat>(),
|
||||
successRate: (fields[8] as num).toDouble(),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void write(BinaryWriter writer, ServerConnectionStats obj) {
|
||||
writer
|
||||
..writeByte(9)
|
||||
..writeByte(0)
|
||||
..write(obj.serverId)
|
||||
..writeByte(1)
|
||||
..write(obj.serverName)
|
||||
..writeByte(2)
|
||||
..write(obj.totalAttempts)
|
||||
..writeByte(3)
|
||||
..write(obj.successCount)
|
||||
..writeByte(4)
|
||||
..write(obj.failureCount)
|
||||
..writeByte(5)
|
||||
..write(obj.lastSuccessTime)
|
||||
..writeByte(6)
|
||||
..write(obj.lastFailureTime)
|
||||
..writeByte(7)
|
||||
..write(obj.recentConnections)
|
||||
..writeByte(8)
|
||||
..write(obj.successRate);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => typeId.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is ServerConnectionStatsAdapter &&
|
||||
runtimeType == other.runtimeType &&
|
||||
typeId == other.typeId;
|
||||
}
|
||||
|
||||
class ConnectionResultAdapter extends TypeAdapter<ConnectionResult> {
|
||||
@override
|
||||
final typeId = 102;
|
||||
|
||||
@override
|
||||
ConnectionResult read(BinaryReader reader) {
|
||||
switch (reader.readByte()) {
|
||||
case 0:
|
||||
return ConnectionResult.success;
|
||||
case 1:
|
||||
return ConnectionResult.timeout;
|
||||
case 2:
|
||||
return ConnectionResult.authFailed;
|
||||
case 3:
|
||||
return ConnectionResult.networkError;
|
||||
case 4:
|
||||
return ConnectionResult.unknownError;
|
||||
default:
|
||||
return ConnectionResult.success;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void write(BinaryWriter writer, ConnectionResult obj) {
|
||||
switch (obj) {
|
||||
case ConnectionResult.success:
|
||||
writer.writeByte(0);
|
||||
case ConnectionResult.timeout:
|
||||
writer.writeByte(1);
|
||||
case ConnectionResult.authFailed:
|
||||
writer.writeByte(2);
|
||||
case ConnectionResult.networkError:
|
||||
writer.writeByte(3);
|
||||
case ConnectionResult.unknownError:
|
||||
writer.writeByte(4);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => typeId.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is ConnectionResultAdapter &&
|
||||
runtimeType == other.runtimeType &&
|
||||
typeId == other.typeId;
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_ConnectionStat _$ConnectionStatFromJson(Map<String, dynamic> json) =>
|
||||
_ConnectionStat(
|
||||
serverId: json['serverId'] as String,
|
||||
serverName: json['serverName'] as String,
|
||||
timestamp: DateTime.parse(json['timestamp'] as String),
|
||||
result: $enumDecode(_$ConnectionResultEnumMap, json['result']),
|
||||
errorMessage: json['errorMessage'] as String? ?? '',
|
||||
durationMs: (json['durationMs'] as num).toInt(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$ConnectionStatToJson(_ConnectionStat instance) =>
|
||||
<String, dynamic>{
|
||||
'serverId': instance.serverId,
|
||||
'serverName': instance.serverName,
|
||||
'timestamp': instance.timestamp.toIso8601String(),
|
||||
'result': _$ConnectionResultEnumMap[instance.result]!,
|
||||
'errorMessage': instance.errorMessage,
|
||||
'durationMs': instance.durationMs,
|
||||
};
|
||||
|
||||
const _$ConnectionResultEnumMap = {
|
||||
ConnectionResult.success: 'success',
|
||||
ConnectionResult.timeout: 'timeout',
|
||||
ConnectionResult.authFailed: 'auth_failed',
|
||||
ConnectionResult.networkError: 'network_error',
|
||||
ConnectionResult.unknownError: 'unknown_error',
|
||||
};
|
||||
|
||||
_ServerConnectionStats _$ServerConnectionStatsFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _ServerConnectionStats(
|
||||
serverId: json['serverId'] as String,
|
||||
serverName: json['serverName'] as String,
|
||||
totalAttempts: (json['totalAttempts'] as num).toInt(),
|
||||
successCount: (json['successCount'] as num).toInt(),
|
||||
failureCount: (json['failureCount'] as num).toInt(),
|
||||
lastSuccessTime: json['lastSuccessTime'] == null
|
||||
? null
|
||||
: DateTime.parse(json['lastSuccessTime'] as String),
|
||||
lastFailureTime: json['lastFailureTime'] == null
|
||||
? null
|
||||
: DateTime.parse(json['lastFailureTime'] as String),
|
||||
recentConnections:
|
||||
(json['recentConnections'] as List<dynamic>?)
|
||||
?.map((e) => ConnectionStat.fromJson(e as Map<String, dynamic>))
|
||||
.toList() ??
|
||||
const [],
|
||||
successRate: (json['successRate'] as num).toDouble(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$ServerConnectionStatsToJson(
|
||||
_ServerConnectionStats instance,
|
||||
) => <String, dynamic>{
|
||||
'serverId': instance.serverId,
|
||||
'serverName': instance.serverName,
|
||||
'totalAttempts': instance.totalAttempts,
|
||||
'successCount': instance.successCount,
|
||||
'failureCount': instance.failureCount,
|
||||
'lastSuccessTime': instance.lastSuccessTime?.toIso8601String(),
|
||||
'lastFailureTime': instance.lastFailureTime?.toIso8601String(),
|
||||
'recentConnections': instance.recentConnections,
|
||||
'successRate': instance.successRate,
|
||||
};
|
||||
@@ -20,11 +20,11 @@ ServerCustom _$ServerCustomFromJson(Map<String, dynamic> json) => ServerCustom(
|
||||
|
||||
Map<String, dynamic> _$ServerCustomToJson(ServerCustom instance) =>
|
||||
<String, dynamic>{
|
||||
'pveAddr': ?instance.pveAddr,
|
||||
if (instance.pveAddr case final value?) 'pveAddr': value,
|
||||
'pveIgnoreCert': instance.pveIgnoreCert,
|
||||
'cmds': ?instance.cmds,
|
||||
'preferTempDev': ?instance.preferTempDev,
|
||||
'logoUrl': ?instance.logoUrl,
|
||||
'netDev': ?instance.netDev,
|
||||
'scriptDir': ?instance.scriptDir,
|
||||
if (instance.cmds case final value?) 'cmds': value,
|
||||
if (instance.preferTempDev case final value?) 'preferTempDev': value,
|
||||
if (instance.logoUrl case final value?) 'logoUrl': value,
|
||||
if (instance.netDev case final value?) 'netDev': value,
|
||||
if (instance.scriptDir case final value?) 'scriptDir': value,
|
||||
};
|
||||
|
||||
@@ -44,22 +44,49 @@ class Disk with EquatableMixin {
|
||||
static List<Disk> parse(String raw) {
|
||||
final list = <Disk>[];
|
||||
raw = raw.trim();
|
||||
try {
|
||||
if (raw.startsWith('{')) {
|
||||
// Parse JSON output from lsblk command
|
||||
final Map<String, dynamic> jsonData = json.decode(raw);
|
||||
final List<dynamic> blockdevices = jsonData['blockdevices'] ?? [];
|
||||
|
||||
if (raw.isEmpty) {
|
||||
dprint('Empty disk info data received');
|
||||
return list;
|
||||
}
|
||||
|
||||
for (final device in blockdevices) {
|
||||
// Process each device
|
||||
_processTopLevelDevice(device, list);
|
||||
try {
|
||||
// Check if we have lsblk JSON output with success marker
|
||||
if (raw.startsWith('{')) {
|
||||
// Extract JSON part (excluding the success marker if present)
|
||||
final jsonEnd = raw.indexOf('\nLSBLK_SUCCESS');
|
||||
final jsonPart = jsonEnd > 0 ? raw.substring(0, jsonEnd) : raw;
|
||||
|
||||
try {
|
||||
final Map<String, dynamic> jsonData = json.decode(jsonPart);
|
||||
final List<dynamic> blockdevices = jsonData['blockdevices'] ?? [];
|
||||
|
||||
for (final device in blockdevices) {
|
||||
// Process each device
|
||||
_processTopLevelDevice(device, list);
|
||||
}
|
||||
|
||||
// If we successfully parsed JSON and have valid disks, return them
|
||||
if (list.isNotEmpty) {
|
||||
return list;
|
||||
}
|
||||
} on FormatException catch (e) {
|
||||
Loggers.app.warning('JSON parsing failed, falling back to df -k output: $e');
|
||||
} catch (e) {
|
||||
Loggers.app.warning('Error processing JSON disk data, falling back to df -k output: $e', e);
|
||||
}
|
||||
} else {
|
||||
// Fallback to the old parsing method in case of non-JSON output
|
||||
}
|
||||
|
||||
// Check if we have df -k output (fallback case)
|
||||
if (raw.contains('Filesystem') && raw.contains('Mounted on')) {
|
||||
return _parseWithOldMethod(raw);
|
||||
}
|
||||
|
||||
// If we reach here, both parsing methods failed
|
||||
Loggers.app.warning('Unable to parse disk info with any method');
|
||||
|
||||
} catch (e) {
|
||||
Loggers.app.warning('Failed to parse disk info: $e', e);
|
||||
Loggers.app.warning('Failed to parse disk info with both methods: $e', e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
@@ -88,6 +115,32 @@ class Disk with EquatableMixin {
|
||||
}
|
||||
}
|
||||
|
||||
/// Parse filesystem fields from device data
|
||||
static ({BigInt size, BigInt used, BigInt avail, int usedPercent}) _parseFilesystemFields(Map<String, dynamic> device) {
|
||||
// Helper function to parse size strings safely
|
||||
BigInt parseSize(String? sizeStr) {
|
||||
if (sizeStr == null || sizeStr.isEmpty || sizeStr == 'null' || sizeStr == '0') {
|
||||
return BigInt.zero;
|
||||
}
|
||||
return (BigInt.tryParse(sizeStr) ?? BigInt.zero) ~/ BigInt.from(1024);
|
||||
}
|
||||
|
||||
// Helper function to parse percentage strings
|
||||
int parsePercent(String? percentStr) {
|
||||
if (percentStr == null || percentStr.isEmpty || percentStr == 'null') {
|
||||
return 0;
|
||||
}
|
||||
return int.tryParse(percentStr.replaceAll('%', '')) ?? 0;
|
||||
}
|
||||
|
||||
return (
|
||||
size: parseSize(device['fssize']?.toString()),
|
||||
used: parseSize(device['fsused']?.toString()),
|
||||
avail: parseSize(device['fsavail']?.toString()),
|
||||
usedPercent: parsePercent(device['fsuse%']?.toString()),
|
||||
);
|
||||
}
|
||||
|
||||
/// Process a single device without recursively processing its children
|
||||
static Disk? _processSingleDevice(Map<String, dynamic> device) {
|
||||
final fstype = device['fstype']?.toString();
|
||||
@@ -102,20 +155,7 @@ class Disk with EquatableMixin {
|
||||
return null;
|
||||
}
|
||||
|
||||
final sizeStr = device['fssize']?.toString() ?? '0';
|
||||
final size = (BigInt.tryParse(sizeStr) ?? BigInt.zero) ~/ BigInt.from(1024);
|
||||
|
||||
final usedStr = device['fsused']?.toString() ?? '0';
|
||||
final used = (BigInt.tryParse(usedStr) ?? BigInt.zero) ~/ BigInt.from(1024);
|
||||
|
||||
final availStr = device['fsavail']?.toString() ?? '0';
|
||||
final avail = (BigInt.tryParse(availStr) ?? BigInt.zero) ~/ BigInt.from(1024);
|
||||
|
||||
// Parse fsuse% which is usually in the format "45%"
|
||||
String usePercentStr = device['fsuse%']?.toString() ?? '0';
|
||||
usePercentStr = usePercentStr.replaceAll('%', '');
|
||||
final usedPercent = int.tryParse(usePercentStr) ?? 0;
|
||||
|
||||
final fsFields = _parseFilesystemFields(device);
|
||||
final name = device['name']?.toString();
|
||||
final kname = device['kname']?.toString();
|
||||
final uuid = device['uuid']?.toString();
|
||||
@@ -124,10 +164,10 @@ class Disk with EquatableMixin {
|
||||
path: path,
|
||||
fsTyp: fstype,
|
||||
mount: mountpoint,
|
||||
usedPercent: usedPercent,
|
||||
used: used,
|
||||
size: size,
|
||||
avail: avail,
|
||||
usedPercent: fsFields.usedPercent,
|
||||
used: fsFields.used,
|
||||
size: fsFields.size,
|
||||
avail: fsFields.avail,
|
||||
name: name,
|
||||
kname: kname,
|
||||
uuid: uuid,
|
||||
@@ -155,20 +195,7 @@ class Disk with EquatableMixin {
|
||||
|
||||
// Handle common filesystem cases or parent devices with children
|
||||
if ((fstype != null && _shouldCalc(fstype, mount)) || (childDisks.isNotEmpty && path.isNotEmpty)) {
|
||||
final sizeStr = device['fssize']?.toString() ?? '0';
|
||||
final size = (BigInt.tryParse(sizeStr) ?? BigInt.zero) ~/ BigInt.from(1024);
|
||||
|
||||
final usedStr = device['fsused']?.toString() ?? '0';
|
||||
final used = (BigInt.tryParse(usedStr) ?? BigInt.zero) ~/ BigInt.from(1024);
|
||||
|
||||
final availStr = device['fsavail']?.toString() ?? '0';
|
||||
final avail = (BigInt.tryParse(availStr) ?? BigInt.zero) ~/ BigInt.from(1024);
|
||||
|
||||
// Parse fsuse% which is usually in the format "45%"
|
||||
String usePercentStr = device['fsuse%']?.toString() ?? '0';
|
||||
usePercentStr = usePercentStr.replaceAll('%', '');
|
||||
final usedPercent = int.tryParse(usePercentStr) ?? 0;
|
||||
|
||||
final fsFields = _parseFilesystemFields(device);
|
||||
final name = device['name']?.toString();
|
||||
final kname = device['kname']?.toString();
|
||||
final uuid = device['uuid']?.toString();
|
||||
@@ -177,10 +204,10 @@ class Disk with EquatableMixin {
|
||||
path: path,
|
||||
fsTyp: fstype,
|
||||
mount: mount,
|
||||
usedPercent: usedPercent,
|
||||
used: used,
|
||||
size: size,
|
||||
avail: avail,
|
||||
usedPercent: fsFields.usedPercent,
|
||||
used: fsFields.used,
|
||||
size: fsFields.size,
|
||||
avail: fsFields.avail,
|
||||
name: name,
|
||||
kname: kname,
|
||||
uuid: uuid,
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:dartssh2/dartssh2.dart';
|
||||
import 'package:fl_lib/fl_lib.dart';
|
||||
import 'package:server_box/data/model/app/scripts/cmd_types.dart';
|
||||
import 'package:server_box/data/model/server/amd.dart';
|
||||
@@ -11,25 +10,9 @@ import 'package:server_box/data/model/server/memory.dart';
|
||||
import 'package:server_box/data/model/server/net_speed.dart';
|
||||
import 'package:server_box/data/model/server/nvdia.dart';
|
||||
import 'package:server_box/data/model/server/sensors.dart';
|
||||
import 'package:server_box/data/model/server/server_private_info.dart';
|
||||
import 'package:server_box/data/model/server/system.dart';
|
||||
import 'package:server_box/data/model/server/temp.dart';
|
||||
|
||||
class Server {
|
||||
Spi spi;
|
||||
ServerStatus status;
|
||||
SSHClient? client;
|
||||
ServerConn conn;
|
||||
|
||||
Server(this.spi, this.status, this.conn, {this.client});
|
||||
|
||||
bool get needGenClient => conn < ServerConn.connecting;
|
||||
|
||||
bool get canViewDetails => conn == ServerConn.finished;
|
||||
|
||||
String get id => spi.id;
|
||||
}
|
||||
|
||||
class ServerStatus {
|
||||
Cpus cpu;
|
||||
Memory mem;
|
||||
|
||||
@@ -4,10 +4,8 @@ import 'package:fl_lib/fl_lib.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:server_box/data/model/app/error.dart';
|
||||
import 'package:server_box/data/model/server/custom.dart';
|
||||
import 'package:server_box/data/model/server/server.dart';
|
||||
import 'package:server_box/data/model/server/system.dart';
|
||||
import 'package:server_box/data/model/server/wol_cfg.dart';
|
||||
import 'package:server_box/data/provider/server.dart';
|
||||
import 'package:server_box/data/store/server.dart';
|
||||
|
||||
part 'server_private_info.freezed.dart';
|
||||
@@ -58,6 +56,7 @@ abstract class Spi with _$Spi {
|
||||
@override
|
||||
String toString() => 'Spi<$oldId>';
|
||||
|
||||
/// Parse the [id], if it's null or empty, generate a new one.
|
||||
static String parseId(Object? id) {
|
||||
if (id == null || id is! String || id.isEmpty) return ShortId.generate();
|
||||
return id;
|
||||
@@ -85,23 +84,26 @@ extension Spix on Spi {
|
||||
return newSpi.id;
|
||||
}
|
||||
|
||||
/// Json encode to string.
|
||||
String toJsonString() => json.encode(toJson());
|
||||
|
||||
VNode<Server>? get server => ServerProvider.pick(spi: this);
|
||||
VNode<Server>? get jumpServer => ServerProvider.pick(id: jumpId);
|
||||
|
||||
bool shouldReconnect(Spi old) {
|
||||
return user != old.user ||
|
||||
ip != old.ip ||
|
||||
port != old.port ||
|
||||
pwd != old.pwd ||
|
||||
keyId != old.keyId ||
|
||||
alterUrl != old.alterUrl ||
|
||||
jumpId != old.jumpId ||
|
||||
custom?.cmds != old.custom?.cmds;
|
||||
/// Returns true if the connection info is the same as [other].
|
||||
bool isSameAs(Spi other) {
|
||||
return user == other.user &&
|
||||
ip == other.ip &&
|
||||
port == other.port &&
|
||||
pwd == other.pwd &&
|
||||
keyId == other.keyId &&
|
||||
jumpId == other.jumpId;
|
||||
}
|
||||
|
||||
(String ip, String usr, int port) fromStringUrl() {
|
||||
/// Returns true if the connection should be re-established.
|
||||
bool shouldReconnect(Spi old) {
|
||||
return !isSameAs(old) || alterUrl != old.alterUrl || custom?.cmds != old.custom?.cmds;
|
||||
}
|
||||
|
||||
/// Parse the [alterUrl] to (ip, user, port).
|
||||
(String ip, String usr, int port) parseAlterUrl() {
|
||||
if (alterUrl == null) {
|
||||
throw SSHErr(type: SSHErrType.connect, message: 'alterUrl is null');
|
||||
}
|
||||
@@ -146,5 +148,6 @@ extension Spix on Spi {
|
||||
id: 'id',
|
||||
);
|
||||
|
||||
/// Returns true if the user is 'root'.
|
||||
bool get isRoot => user == 'root';
|
||||
}
|
||||
|
||||
@@ -41,18 +41,19 @@ Map<String, dynamic> _$SpiToJson(_Spi instance) => <String, dynamic>{
|
||||
'ip': instance.ip,
|
||||
'port': instance.port,
|
||||
'user': instance.user,
|
||||
'pwd': ?instance.pwd,
|
||||
'pubKeyId': ?instance.keyId,
|
||||
'tags': ?instance.tags,
|
||||
'alterUrl': ?instance.alterUrl,
|
||||
if (instance.pwd case final value?) 'pwd': value,
|
||||
if (instance.keyId case final value?) 'pubKeyId': value,
|
||||
if (instance.tags case final value?) 'tags': value,
|
||||
if (instance.alterUrl case final value?) 'alterUrl': value,
|
||||
'autoConnect': instance.autoConnect,
|
||||
'jumpId': ?instance.jumpId,
|
||||
'custom': ?instance.custom,
|
||||
'wolCfg': ?instance.wolCfg,
|
||||
'envs': ?instance.envs,
|
||||
if (instance.jumpId case final value?) 'jumpId': value,
|
||||
if (instance.custom case final value?) 'custom': value,
|
||||
if (instance.wolCfg case final value?) 'wolCfg': value,
|
||||
if (instance.envs case final value?) 'envs': value,
|
||||
'id': instance.id,
|
||||
'customSystemType': ?_$SystemTypeEnumMap[instance.customSystemType],
|
||||
'disabledCmdTypes': ?instance.disabledCmdTypes,
|
||||
if (_$SystemTypeEnumMap[instance.customSystemType] case final value?)
|
||||
'customSystemType': value,
|
||||
if (instance.disabledCmdTypes case final value?) 'disabledCmdTypes': value,
|
||||
};
|
||||
|
||||
const _$SystemTypeEnumMap = {
|
||||
|
||||
@@ -104,6 +104,11 @@ Future<ServerStatus> _getLinuxStatus(ServerStatusUpdateReq req) async {
|
||||
|
||||
try {
|
||||
req.ss.disk = Disk.parse(StatusCmdType.disk.findInMap(parsedOutput));
|
||||
} catch (e, s) {
|
||||
Loggers.app.warning(e, s);
|
||||
}
|
||||
|
||||
try {
|
||||
req.ss.diskUsage = DiskUsage.parse(req.ss.disk);
|
||||
} catch (e, s) {
|
||||
Loggers.app.warning(e, s);
|
||||
@@ -294,7 +299,9 @@ String? _parseSysVer(String raw) {
|
||||
String? _parseHostName(String raw) {
|
||||
if (raw.isEmpty) return null;
|
||||
if (raw.contains(ScriptConstants.scriptFile)) return null;
|
||||
return raw;
|
||||
final trimmed = raw.trim();
|
||||
if (trimmed.isEmpty) return null;
|
||||
return trimmed;
|
||||
}
|
||||
|
||||
// Windows status parsing implementation
|
||||
|
||||
@@ -16,5 +16,5 @@ Map<String, dynamic> _$WakeOnLanCfgToJson(WakeOnLanCfg instance) =>
|
||||
<String, dynamic>{
|
||||
'mac': instance.mac,
|
||||
'ip': instance.ip,
|
||||
'pwd': ?instance.pwd,
|
||||
if (instance.pwd case final value?) 'pwd': value,
|
||||
};
|
||||
|
||||
@@ -6,57 +6,20 @@ part of 'app.dart';
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
@ProviderFor(AppStates)
|
||||
const appStatesProvider = AppStatesProvider._();
|
||||
|
||||
final class AppStatesProvider extends $NotifierProvider<AppStates, AppState> {
|
||||
const AppStatesProvider._()
|
||||
: super(
|
||||
from: null,
|
||||
argument: null,
|
||||
retry: null,
|
||||
name: r'appStatesProvider',
|
||||
isAutoDispose: false,
|
||||
dependencies: null,
|
||||
$allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
@override
|
||||
String debugGetCreateSourceHash() => _$appStatesHash();
|
||||
|
||||
@$internal
|
||||
@override
|
||||
AppStates create() => AppStates();
|
||||
|
||||
/// {@macro riverpod.override_with_value}
|
||||
Override overrideWithValue(AppState value) {
|
||||
return $ProviderOverride(
|
||||
origin: this,
|
||||
providerOverride: $SyncValueProvider<AppState>(value),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
String _$appStatesHash() => r'ef96f10f6fff0f3dd6d3128ebf070ad79cbc8bc9';
|
||||
|
||||
abstract class _$AppStates extends $Notifier<AppState> {
|
||||
AppState build();
|
||||
@$mustCallSuper
|
||||
@override
|
||||
void runBuild() {
|
||||
final created = build();
|
||||
final ref = this.ref as $Ref<AppState, AppState>;
|
||||
final element =
|
||||
ref.element
|
||||
as $ClassProviderElement<
|
||||
AnyNotifier<AppState, AppState>,
|
||||
AppState,
|
||||
Object?,
|
||||
Object?
|
||||
>;
|
||||
element.handleValue(ref, created);
|
||||
}
|
||||
}
|
||||
/// See also [AppStates].
|
||||
@ProviderFor(AppStates)
|
||||
final appStatesProvider = NotifierProvider<AppStates, AppState>.internal(
|
||||
AppStates.new,
|
||||
name: r'appStatesProvider',
|
||||
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$appStatesHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
typedef _$AppStates = Notifier<AppState>;
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package
|
||||
|
||||
@@ -4,6 +4,8 @@ import 'dart:convert';
|
||||
import 'package:dartssh2/dartssh2.dart';
|
||||
import 'package:fl_lib/fl_lib.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import 'package:server_box/core/extension/ssh_client.dart';
|
||||
import 'package:server_box/data/model/app/error.dart';
|
||||
import 'package:server_box/data/model/app/scripts/script_consts.dart';
|
||||
@@ -12,63 +14,61 @@ import 'package:server_box/data/model/container/ps.dart';
|
||||
import 'package:server_box/data/model/container/type.dart';
|
||||
import 'package:server_box/data/res/store.dart';
|
||||
|
||||
part 'container.freezed.dart';
|
||||
part 'container.g.dart';
|
||||
|
||||
final _dockerNotFound = RegExp(r"command not found|Unknown command|Command '\w+' not found");
|
||||
|
||||
class ContainerProvider extends ChangeNotifier {
|
||||
final SSHClient? client;
|
||||
final String userName;
|
||||
final String hostId;
|
||||
final BuildContext context;
|
||||
List<ContainerPs>? items;
|
||||
List<ContainerImg>? images;
|
||||
String? version;
|
||||
ContainerErr? error;
|
||||
String? runLog;
|
||||
ContainerType type;
|
||||
var sudoCompleter = Completer<bool>();
|
||||
bool isBusy = false;
|
||||
@freezed
|
||||
abstract class ContainerState with _$ContainerState {
|
||||
const factory ContainerState({
|
||||
@Default(null) List<ContainerPs>? items,
|
||||
@Default(null) List<ContainerImg>? images,
|
||||
@Default(null) String? version,
|
||||
@Default(null) ContainerErr? error,
|
||||
@Default(null) String? runLog,
|
||||
@Default(ContainerType.docker) ContainerType type,
|
||||
@Default(false) bool isBusy,
|
||||
}) = _ContainerState;
|
||||
}
|
||||
|
||||
ContainerProvider({
|
||||
required this.client,
|
||||
required this.userName,
|
||||
required this.hostId,
|
||||
required this.context,
|
||||
}) : type = Stores.container.getType(hostId) {
|
||||
refresh();
|
||||
@riverpod
|
||||
class ContainerNotifier extends _$ContainerNotifier {
|
||||
var sudoCompleter = Completer<bool>();
|
||||
|
||||
@override
|
||||
ContainerState build(SSHClient? client, String userName, String hostId, BuildContext context) {
|
||||
final type = Stores.container.getType(hostId);
|
||||
final initialState = ContainerState(type: type);
|
||||
|
||||
// Async initialization
|
||||
Future.microtask(() => refresh());
|
||||
|
||||
return initialState;
|
||||
}
|
||||
|
||||
Future<void> setType(ContainerType type) async {
|
||||
this.type = type;
|
||||
state = state.copyWith(
|
||||
type: type,
|
||||
error: null,
|
||||
runLog: null,
|
||||
items: null,
|
||||
images: null,
|
||||
version: null,
|
||||
);
|
||||
Stores.container.setType(type, hostId);
|
||||
error = runLog = items = images = version = null;
|
||||
sudoCompleter = Completer<bool>();
|
||||
notifyListeners();
|
||||
await refresh();
|
||||
}
|
||||
|
||||
// Future<bool> _checkDockerInstalled(SSHClient client) async {
|
||||
// final session = await client.execute("docker");
|
||||
// await session.done;
|
||||
// // debugPrint('docker code: ${session.exitCode}');
|
||||
// return session.exitCode == 0;
|
||||
// }
|
||||
|
||||
// String _removeSudoPrompts(String value) {
|
||||
// final regex = RegExp(r"\[sudo\] password for \w+:");
|
||||
// if (value.startsWith(regex)) {
|
||||
// return value.replaceFirstMapped(regex, (match) => "");
|
||||
// }
|
||||
// return value;
|
||||
// }
|
||||
|
||||
void _requiresSudo() async {
|
||||
/// Podman is rootless
|
||||
if (type == ContainerType.podman) return sudoCompleter.complete(false);
|
||||
if (state.type == ContainerType.podman) return sudoCompleter.complete(false);
|
||||
if (!Stores.setting.containerTrySudo.fetch()) {
|
||||
return sudoCompleter.complete(false);
|
||||
}
|
||||
|
||||
final res = await client?.run(_wrap(ContainerCmdType.images.exec(type)));
|
||||
final res = await client?.run(_wrap(ContainerCmdType.images.exec(state.type)));
|
||||
if (res?.string.toLowerCase().contains('permission denied') ?? false) {
|
||||
return sudoCompleter.complete(true);
|
||||
}
|
||||
@@ -76,8 +76,8 @@ class ContainerProvider extends ChangeNotifier {
|
||||
}
|
||||
|
||||
Future<void> refresh({bool isAuto = false}) async {
|
||||
if (isBusy) return;
|
||||
isBusy = true;
|
||||
if (state.isBusy) return;
|
||||
state = state.copyWith(isBusy: true);
|
||||
|
||||
if (!sudoCompleter.isCompleted) _requiresSudo();
|
||||
|
||||
@@ -85,11 +85,14 @@ class ContainerProvider extends ChangeNotifier {
|
||||
|
||||
/// If sudo is required and auto refresh is enabled, skip the refresh.
|
||||
/// Or this will ask for pwd again and again.
|
||||
if (sudo && isAuto) return;
|
||||
if (sudo && isAuto) {
|
||||
state = state.copyWith(isBusy: false);
|
||||
return;
|
||||
}
|
||||
final includeStats = Stores.setting.containerParseStat.fetch();
|
||||
|
||||
var raw = '';
|
||||
final cmd = _wrap(ContainerCmdType.execAll(type, sudo: sudo, includeStats: includeStats));
|
||||
final cmd = _wrap(ContainerCmdType.execAll(state.type, sudo: sudo, includeStats: includeStats));
|
||||
final code = await client?.execWithPwd(
|
||||
cmd,
|
||||
context: context,
|
||||
@@ -97,75 +100,79 @@ class ContainerProvider extends ChangeNotifier {
|
||||
id: hostId,
|
||||
);
|
||||
|
||||
isBusy = false;
|
||||
state = state.copyWith(isBusy: false);
|
||||
|
||||
if (!context.mounted) return;
|
||||
|
||||
/// Code 127 means command not found
|
||||
if (code == 127 || raw.contains(_dockerNotFound)) {
|
||||
error = ContainerErr(type: ContainerErrType.notInstalled);
|
||||
notifyListeners();
|
||||
state = state.copyWith(error: ContainerErr(type: ContainerErrType.notInstalled));
|
||||
return;
|
||||
}
|
||||
|
||||
// Check result segments count
|
||||
final segments = raw.split(ScriptConstants.separator);
|
||||
if (segments.length != ContainerCmdType.values.length) {
|
||||
error = ContainerErr(
|
||||
type: ContainerErrType.segmentsNotMatch,
|
||||
message: 'Container segments: ${segments.length}',
|
||||
state = state.copyWith(
|
||||
error: ContainerErr(
|
||||
type: ContainerErrType.segmentsNotMatch,
|
||||
message: 'Container segments: ${segments.length}',
|
||||
),
|
||||
);
|
||||
Loggers.app.warning('Container segments: ${segments.length}\n$raw');
|
||||
notifyListeners();
|
||||
return;
|
||||
}
|
||||
|
||||
// Parse version
|
||||
final verRaw = ContainerCmdType.version.find(segments);
|
||||
try {
|
||||
version = json.decode(verRaw)['Client']['Version'];
|
||||
final version = json.decode(verRaw)['Client']['Version'];
|
||||
state = state.copyWith(version: version, error: null);
|
||||
} catch (e, trace) {
|
||||
error = ContainerErr(type: ContainerErrType.invalidVersion, message: '$e');
|
||||
state = state.copyWith(
|
||||
error: ContainerErr(type: ContainerErrType.invalidVersion, message: '$e'),
|
||||
);
|
||||
Loggers.app.warning('Container version failed', e, trace);
|
||||
} finally {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Parse ps
|
||||
final psRaw = ContainerCmdType.ps.find(segments);
|
||||
try {
|
||||
final lines = psRaw.split('\n');
|
||||
if (type == ContainerType.docker) {
|
||||
if (state.type == ContainerType.docker) {
|
||||
/// Due to the fetched data is not in json format, skip table header
|
||||
lines.removeWhere((element) => element.contains('CONTAINER ID'));
|
||||
}
|
||||
lines.removeWhere((element) => element.isEmpty);
|
||||
items = lines.map((e) => ContainerPs.fromRaw(e, type)).toList();
|
||||
final items = lines.map((e) => ContainerPs.fromRaw(e, state.type)).toList();
|
||||
state = state.copyWith(items: items);
|
||||
} catch (e, trace) {
|
||||
error = ContainerErr(type: ContainerErrType.parsePs, message: '$e');
|
||||
state = state.copyWith(
|
||||
error: ContainerErr(type: ContainerErrType.parsePs, message: '$e'),
|
||||
);
|
||||
Loggers.app.warning('Container ps failed', e, trace);
|
||||
} finally {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Parse images
|
||||
final imageRaw = ContainerCmdType.images.find(segments).trim();
|
||||
final isEntireJson = imageRaw.startsWith('[') && imageRaw.endsWith(']');
|
||||
try {
|
||||
List<ContainerImg> images;
|
||||
if (isEntireJson) {
|
||||
images = (json.decode(imageRaw) as List)
|
||||
.map((e) => ContainerImg.fromRawJson(json.encode(e), type))
|
||||
.map((e) => ContainerImg.fromRawJson(json.encode(e), state.type))
|
||||
.toList();
|
||||
} else {
|
||||
final lines = imageRaw.split('\n');
|
||||
lines.removeWhere((element) => element.isEmpty);
|
||||
images = lines.map((e) => ContainerImg.fromRawJson(e, type)).toList();
|
||||
images = lines.map((e) => ContainerImg.fromRawJson(e, state.type)).toList();
|
||||
}
|
||||
state = state.copyWith(images: images);
|
||||
} catch (e, trace) {
|
||||
error = ContainerErr(type: ContainerErrType.parseImages, message: '$e');
|
||||
state = state.copyWith(
|
||||
error: ContainerErr(type: ContainerErrType.parseImages, message: '$e'),
|
||||
);
|
||||
Loggers.app.warning('Container images failed', e, trace);
|
||||
} finally {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Parse stats
|
||||
@@ -173,7 +180,7 @@ class ContainerProvider extends ChangeNotifier {
|
||||
try {
|
||||
final statsLines = statsRaw.split('\n');
|
||||
statsLines.removeWhere((element) => element.isEmpty);
|
||||
for (var item in items!) {
|
||||
for (var item in state.items!) {
|
||||
final id = item.id;
|
||||
if (id == null) continue;
|
||||
final statsLine = statsLines.firstWhereOrNull(
|
||||
@@ -185,10 +192,10 @@ class ContainerProvider extends ChangeNotifier {
|
||||
item.parseStats(statsLine);
|
||||
}
|
||||
} catch (e, trace) {
|
||||
error = ContainerErr(type: ContainerErrType.parseStats, message: '$e');
|
||||
state = state.copyWith(
|
||||
error: ContainerErr(type: ContainerErrType.parseStats, message: '$e'),
|
||||
);
|
||||
Loggers.app.warning('Parse docker stats: $statsRaw', e, trace);
|
||||
} finally {
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,25 +230,23 @@ class ContainerProvider extends ChangeNotifier {
|
||||
}
|
||||
|
||||
Future<ContainerErr?> run(String cmd, {bool autoRefresh = true}) async {
|
||||
cmd = switch (type) {
|
||||
cmd = switch (state.type) {
|
||||
ContainerType.docker => 'docker $cmd',
|
||||
ContainerType.podman => 'podman $cmd',
|
||||
};
|
||||
|
||||
runLog = '';
|
||||
state = state.copyWith(runLog: '');
|
||||
final errs = <String>[];
|
||||
final code = await client?.execWithPwd(
|
||||
_wrap((await sudoCompleter.future) ? 'sudo -S $cmd' : cmd),
|
||||
context: context,
|
||||
onStdout: (data, _) {
|
||||
runLog = '$runLog$data';
|
||||
notifyListeners();
|
||||
state = state.copyWith(runLog: '${state.runLog}$data');
|
||||
},
|
||||
onStderr: (data, _) => errs.add(data),
|
||||
id: hostId,
|
||||
);
|
||||
runLog = null;
|
||||
notifyListeners();
|
||||
state = state.copyWith(runLog: null);
|
||||
|
||||
if (code != 0) {
|
||||
return ContainerErr(type: ContainerErrType.unknown, message: errs.join('\n').trim());
|
||||
@@ -262,6 +267,7 @@ class ContainerProvider extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const _jsonFmt = '--format "{{json .}}"';
|
||||
|
||||
enum ContainerCmdType {
|
||||
|
||||
305
lib/data/provider/container.freezed.dart
Normal file
305
lib/data/provider/container.freezed.dart
Normal file
@@ -0,0 +1,305 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'container.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$ContainerState {
|
||||
|
||||
List<ContainerPs>? get items; List<ContainerImg>? get images; String? get version; ContainerErr? get error; String? get runLog; ContainerType get type; bool get isBusy;
|
||||
/// Create a copy of ContainerState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$ContainerStateCopyWith<ContainerState> get copyWith => _$ContainerStateCopyWithImpl<ContainerState>(this as ContainerState, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is ContainerState&&const DeepCollectionEquality().equals(other.items, items)&&const DeepCollectionEquality().equals(other.images, images)&&(identical(other.version, version) || other.version == version)&&(identical(other.error, error) || other.error == error)&&(identical(other.runLog, runLog) || other.runLog == runLog)&&(identical(other.type, type) || other.type == type)&&(identical(other.isBusy, isBusy) || other.isBusy == isBusy));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(items),const DeepCollectionEquality().hash(images),version,error,runLog,type,isBusy);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ContainerState(items: $items, images: $images, version: $version, error: $error, runLog: $runLog, type: $type, isBusy: $isBusy)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $ContainerStateCopyWith<$Res> {
|
||||
factory $ContainerStateCopyWith(ContainerState value, $Res Function(ContainerState) _then) = _$ContainerStateCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
List<ContainerPs>? items, List<ContainerImg>? images, String? version, ContainerErr? error, String? runLog, ContainerType type, bool isBusy
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$ContainerStateCopyWithImpl<$Res>
|
||||
implements $ContainerStateCopyWith<$Res> {
|
||||
_$ContainerStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final ContainerState _self;
|
||||
final $Res Function(ContainerState) _then;
|
||||
|
||||
/// Create a copy of ContainerState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? items = freezed,Object? images = freezed,Object? version = freezed,Object? error = freezed,Object? runLog = freezed,Object? type = null,Object? isBusy = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
items: freezed == items ? _self.items : items // ignore: cast_nullable_to_non_nullable
|
||||
as List<ContainerPs>?,images: freezed == images ? _self.images : images // ignore: cast_nullable_to_non_nullable
|
||||
as List<ContainerImg>?,version: freezed == version ? _self.version : version // ignore: cast_nullable_to_non_nullable
|
||||
as String?,error: freezed == error ? _self.error : error // ignore: cast_nullable_to_non_nullable
|
||||
as ContainerErr?,runLog: freezed == runLog ? _self.runLog : runLog // ignore: cast_nullable_to_non_nullable
|
||||
as String?,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable
|
||||
as ContainerType,isBusy: null == isBusy ? _self.isBusy : isBusy // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [ContainerState].
|
||||
extension ContainerStatePatterns on ContainerState {
|
||||
/// A variant of `map` that fallback to returning `orElse`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _ContainerState value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _ContainerState() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// Callbacks receives the raw object, upcasted.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case final Subclass2 value:
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _ContainerState value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _ContainerState():
|
||||
return $default(_that);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `map` that fallback to returning `null`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _ContainerState value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _ContainerState() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( List<ContainerPs>? items, List<ContainerImg>? images, String? version, ContainerErr? error, String? runLog, ContainerType type, bool isBusy)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ContainerState() when $default != null:
|
||||
return $default(_that.items,_that.images,_that.version,_that.error,_that.runLog,_that.type,_that.isBusy);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( List<ContainerPs>? items, List<ContainerImg>? images, String? version, ContainerErr? error, String? runLog, ContainerType type, bool isBusy) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ContainerState():
|
||||
return $default(_that.items,_that.images,_that.version,_that.error,_that.runLog,_that.type,_that.isBusy);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( List<ContainerPs>? items, List<ContainerImg>? images, String? version, ContainerErr? error, String? runLog, ContainerType type, bool isBusy)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ContainerState() when $default != null:
|
||||
return $default(_that.items,_that.images,_that.version,_that.error,_that.runLog,_that.type,_that.isBusy);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _ContainerState implements ContainerState {
|
||||
const _ContainerState({final List<ContainerPs>? items = null, final List<ContainerImg>? images = null, this.version = null, this.error = null, this.runLog = null, this.type = ContainerType.docker, this.isBusy = false}): _items = items,_images = images;
|
||||
|
||||
|
||||
final List<ContainerPs>? _items;
|
||||
@override@JsonKey() List<ContainerPs>? get items {
|
||||
final value = _items;
|
||||
if (value == null) return null;
|
||||
if (_items is EqualUnmodifiableListView) return _items;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(value);
|
||||
}
|
||||
|
||||
final List<ContainerImg>? _images;
|
||||
@override@JsonKey() List<ContainerImg>? get images {
|
||||
final value = _images;
|
||||
if (value == null) return null;
|
||||
if (_images is EqualUnmodifiableListView) return _images;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(value);
|
||||
}
|
||||
|
||||
@override@JsonKey() final String? version;
|
||||
@override@JsonKey() final ContainerErr? error;
|
||||
@override@JsonKey() final String? runLog;
|
||||
@override@JsonKey() final ContainerType type;
|
||||
@override@JsonKey() final bool isBusy;
|
||||
|
||||
/// Create a copy of ContainerState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$ContainerStateCopyWith<_ContainerState> get copyWith => __$ContainerStateCopyWithImpl<_ContainerState>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ContainerState&&const DeepCollectionEquality().equals(other._items, _items)&&const DeepCollectionEquality().equals(other._images, _images)&&(identical(other.version, version) || other.version == version)&&(identical(other.error, error) || other.error == error)&&(identical(other.runLog, runLog) || other.runLog == runLog)&&(identical(other.type, type) || other.type == type)&&(identical(other.isBusy, isBusy) || other.isBusy == isBusy));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(_items),const DeepCollectionEquality().hash(_images),version,error,runLog,type,isBusy);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ContainerState(items: $items, images: $images, version: $version, error: $error, runLog: $runLog, type: $type, isBusy: $isBusy)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$ContainerStateCopyWith<$Res> implements $ContainerStateCopyWith<$Res> {
|
||||
factory _$ContainerStateCopyWith(_ContainerState value, $Res Function(_ContainerState) _then) = __$ContainerStateCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
List<ContainerPs>? items, List<ContainerImg>? images, String? version, ContainerErr? error, String? runLog, ContainerType type, bool isBusy
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$ContainerStateCopyWithImpl<$Res>
|
||||
implements _$ContainerStateCopyWith<$Res> {
|
||||
__$ContainerStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _ContainerState _self;
|
||||
final $Res Function(_ContainerState) _then;
|
||||
|
||||
/// Create a copy of ContainerState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? items = freezed,Object? images = freezed,Object? version = freezed,Object? error = freezed,Object? runLog = freezed,Object? type = null,Object? isBusy = null,}) {
|
||||
return _then(_ContainerState(
|
||||
items: freezed == items ? _self._items : items // ignore: cast_nullable_to_non_nullable
|
||||
as List<ContainerPs>?,images: freezed == images ? _self._images : images // ignore: cast_nullable_to_non_nullable
|
||||
as List<ContainerImg>?,version: freezed == version ? _self.version : version // ignore: cast_nullable_to_non_nullable
|
||||
as String?,error: freezed == error ? _self.error : error // ignore: cast_nullable_to_non_nullable
|
||||
as ContainerErr?,runLog: freezed == runLog ? _self.runLog : runLog // ignore: cast_nullable_to_non_nullable
|
||||
as String?,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable
|
||||
as ContainerType,isBusy: null == isBusy ? _self.isBusy : isBusy // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
228
lib/data/provider/container.g.dart
Normal file
228
lib/data/provider/container.g.dart
Normal file
@@ -0,0 +1,228 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'container.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$containerNotifierHash() => r'fea65e66499234b0a59bffff8d69c4ab8c93b2fd';
|
||||
|
||||
/// Copied from Dart SDK
|
||||
class _SystemHash {
|
||||
_SystemHash._();
|
||||
|
||||
static int combine(int hash, int value) {
|
||||
// ignore: parameter_assignments
|
||||
hash = 0x1fffffff & (hash + value);
|
||||
// ignore: parameter_assignments
|
||||
hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10));
|
||||
return hash ^ (hash >> 6);
|
||||
}
|
||||
|
||||
static int finish(int hash) {
|
||||
// ignore: parameter_assignments
|
||||
hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3));
|
||||
// ignore: parameter_assignments
|
||||
hash = hash ^ (hash >> 11);
|
||||
return 0x1fffffff & (hash + ((0x00003fff & hash) << 15));
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _$ContainerNotifier
|
||||
extends BuildlessAutoDisposeNotifier<ContainerState> {
|
||||
late final SSHClient? client;
|
||||
late final String userName;
|
||||
late final String hostId;
|
||||
late final BuildContext context;
|
||||
|
||||
ContainerState build(
|
||||
SSHClient? client,
|
||||
String userName,
|
||||
String hostId,
|
||||
BuildContext context,
|
||||
);
|
||||
}
|
||||
|
||||
/// See also [ContainerNotifier].
|
||||
@ProviderFor(ContainerNotifier)
|
||||
const containerNotifierProvider = ContainerNotifierFamily();
|
||||
|
||||
/// See also [ContainerNotifier].
|
||||
class ContainerNotifierFamily extends Family<ContainerState> {
|
||||
/// See also [ContainerNotifier].
|
||||
const ContainerNotifierFamily();
|
||||
|
||||
/// See also [ContainerNotifier].
|
||||
ContainerNotifierProvider call(
|
||||
SSHClient? client,
|
||||
String userName,
|
||||
String hostId,
|
||||
BuildContext context,
|
||||
) {
|
||||
return ContainerNotifierProvider(client, userName, hostId, context);
|
||||
}
|
||||
|
||||
@override
|
||||
ContainerNotifierProvider getProviderOverride(
|
||||
covariant ContainerNotifierProvider provider,
|
||||
) {
|
||||
return call(
|
||||
provider.client,
|
||||
provider.userName,
|
||||
provider.hostId,
|
||||
provider.context,
|
||||
);
|
||||
}
|
||||
|
||||
static const Iterable<ProviderOrFamily>? _dependencies = null;
|
||||
|
||||
@override
|
||||
Iterable<ProviderOrFamily>? get dependencies => _dependencies;
|
||||
|
||||
static const Iterable<ProviderOrFamily>? _allTransitiveDependencies = null;
|
||||
|
||||
@override
|
||||
Iterable<ProviderOrFamily>? get allTransitiveDependencies =>
|
||||
_allTransitiveDependencies;
|
||||
|
||||
@override
|
||||
String? get name => r'containerNotifierProvider';
|
||||
}
|
||||
|
||||
/// See also [ContainerNotifier].
|
||||
class ContainerNotifierProvider
|
||||
extends AutoDisposeNotifierProviderImpl<ContainerNotifier, ContainerState> {
|
||||
/// See also [ContainerNotifier].
|
||||
ContainerNotifierProvider(
|
||||
SSHClient? client,
|
||||
String userName,
|
||||
String hostId,
|
||||
BuildContext context,
|
||||
) : this._internal(
|
||||
() => ContainerNotifier()
|
||||
..client = client
|
||||
..userName = userName
|
||||
..hostId = hostId
|
||||
..context = context,
|
||||
from: containerNotifierProvider,
|
||||
name: r'containerNotifierProvider',
|
||||
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$containerNotifierHash,
|
||||
dependencies: ContainerNotifierFamily._dependencies,
|
||||
allTransitiveDependencies:
|
||||
ContainerNotifierFamily._allTransitiveDependencies,
|
||||
client: client,
|
||||
userName: userName,
|
||||
hostId: hostId,
|
||||
context: context,
|
||||
);
|
||||
|
||||
ContainerNotifierProvider._internal(
|
||||
super._createNotifier, {
|
||||
required super.name,
|
||||
required super.dependencies,
|
||||
required super.allTransitiveDependencies,
|
||||
required super.debugGetCreateSourceHash,
|
||||
required super.from,
|
||||
required this.client,
|
||||
required this.userName,
|
||||
required this.hostId,
|
||||
required this.context,
|
||||
}) : super.internal();
|
||||
|
||||
final SSHClient? client;
|
||||
final String userName;
|
||||
final String hostId;
|
||||
final BuildContext context;
|
||||
|
||||
@override
|
||||
ContainerState runNotifierBuild(covariant ContainerNotifier notifier) {
|
||||
return notifier.build(client, userName, hostId, context);
|
||||
}
|
||||
|
||||
@override
|
||||
Override overrideWith(ContainerNotifier Function() create) {
|
||||
return ProviderOverride(
|
||||
origin: this,
|
||||
override: ContainerNotifierProvider._internal(
|
||||
() => create()
|
||||
..client = client
|
||||
..userName = userName
|
||||
..hostId = hostId
|
||||
..context = context,
|
||||
from: from,
|
||||
name: null,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
debugGetCreateSourceHash: null,
|
||||
client: client,
|
||||
userName: userName,
|
||||
hostId: hostId,
|
||||
context: context,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
AutoDisposeNotifierProviderElement<ContainerNotifier, ContainerState>
|
||||
createElement() {
|
||||
return _ContainerNotifierProviderElement(this);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return other is ContainerNotifierProvider &&
|
||||
other.client == client &&
|
||||
other.userName == userName &&
|
||||
other.hostId == hostId &&
|
||||
other.context == context;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
var hash = _SystemHash.combine(0, runtimeType.hashCode);
|
||||
hash = _SystemHash.combine(hash, client.hashCode);
|
||||
hash = _SystemHash.combine(hash, userName.hashCode);
|
||||
hash = _SystemHash.combine(hash, hostId.hashCode);
|
||||
hash = _SystemHash.combine(hash, context.hashCode);
|
||||
|
||||
return _SystemHash.finish(hash);
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated('Will be removed in 3.0. Use Ref instead')
|
||||
// ignore: unused_element
|
||||
mixin ContainerNotifierRef on AutoDisposeNotifierProviderRef<ContainerState> {
|
||||
/// The parameter `client` of this provider.
|
||||
SSHClient? get client;
|
||||
|
||||
/// The parameter `userName` of this provider.
|
||||
String get userName;
|
||||
|
||||
/// The parameter `hostId` of this provider.
|
||||
String get hostId;
|
||||
|
||||
/// The parameter `context` of this provider.
|
||||
BuildContext get context;
|
||||
}
|
||||
|
||||
class _ContainerNotifierProviderElement
|
||||
extends
|
||||
AutoDisposeNotifierProviderElement<ContainerNotifier, ContainerState>
|
||||
with ContainerNotifierRef {
|
||||
_ContainerNotifierProviderElement(super.provider);
|
||||
|
||||
@override
|
||||
SSHClient? get client => (origin as ContainerNotifierProvider).client;
|
||||
@override
|
||||
String get userName => (origin as ContainerNotifierProvider).userName;
|
||||
@override
|
||||
String get hostId => (origin as ContainerNotifierProvider).hostId;
|
||||
@override
|
||||
BuildContext get context => (origin as ContainerNotifierProvider).context;
|
||||
}
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package
|
||||
@@ -1,45 +1,61 @@
|
||||
import 'package:fl_lib/fl_lib.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import 'package:server_box/core/sync.dart';
|
||||
import 'package:server_box/data/model/server/private_key_info.dart';
|
||||
import 'package:server_box/data/res/store.dart';
|
||||
|
||||
class PrivateKeyProvider extends Provider {
|
||||
const PrivateKeyProvider._();
|
||||
static const instance = PrivateKeyProvider._();
|
||||
part 'private_key.freezed.dart';
|
||||
part 'private_key.g.dart';
|
||||
|
||||
static final pkis = <PrivateKeyInfo>[].vn;
|
||||
@freezed
|
||||
abstract class PrivateKeyState with _$PrivateKeyState {
|
||||
const factory PrivateKeyState({@Default(<PrivateKeyInfo>[]) List<PrivateKeyInfo> keys}) = _PrivateKeyState;
|
||||
}
|
||||
|
||||
@Riverpod(keepAlive: true)
|
||||
class PrivateKeyNotifier extends _$PrivateKeyNotifier {
|
||||
@override
|
||||
void load() {
|
||||
super.load();
|
||||
pkis.value = Stores.key.fetch();
|
||||
PrivateKeyState build() {
|
||||
return _load();
|
||||
}
|
||||
|
||||
static void add(PrivateKeyInfo info) {
|
||||
pkis.value.add(info);
|
||||
pkis.notify();
|
||||
void reload() {
|
||||
final newState = _load();
|
||||
if (newState == state) return;
|
||||
state = newState;
|
||||
}
|
||||
|
||||
PrivateKeyState _load() {
|
||||
final keys = Stores.key.fetch();
|
||||
return stateOrNull?.copyWith(keys: keys) ?? PrivateKeyState(keys: keys);
|
||||
}
|
||||
|
||||
void add(PrivateKeyInfo info) {
|
||||
final newKeys = [...state.keys, info];
|
||||
state = state.copyWith(keys: newKeys);
|
||||
Stores.key.put(info);
|
||||
bakSync.sync(milliDelay: 1000);
|
||||
}
|
||||
|
||||
static void delete(PrivateKeyInfo info) {
|
||||
pkis.value.removeWhere((e) => e.id == info.id);
|
||||
pkis.notify();
|
||||
void delete(PrivateKeyInfo info) {
|
||||
final newKeys = state.keys.where((e) => e.id != info.id).toList();
|
||||
state = state.copyWith(keys: newKeys);
|
||||
Stores.key.delete(info);
|
||||
bakSync.sync(milliDelay: 1000);
|
||||
}
|
||||
|
||||
static void update(PrivateKeyInfo old, PrivateKeyInfo newInfo) {
|
||||
final idx = pkis.value.indexWhere((e) => e.id == old.id);
|
||||
void update(PrivateKeyInfo old, PrivateKeyInfo newInfo) {
|
||||
final keys = [...state.keys];
|
||||
final idx = keys.indexWhere((e) => e.id == old.id);
|
||||
if (idx == -1) {
|
||||
pkis.value.add(newInfo);
|
||||
keys.add(newInfo);
|
||||
Stores.key.put(newInfo);
|
||||
Stores.key.delete(old);
|
||||
} else {
|
||||
pkis.value[idx] = newInfo;
|
||||
keys[idx] = newInfo;
|
||||
Stores.key.put(newInfo);
|
||||
}
|
||||
pkis.notify();
|
||||
state = state.copyWith(keys: keys);
|
||||
bakSync.sync(milliDelay: 1000);
|
||||
}
|
||||
}
|
||||
|
||||
277
lib/data/provider/private_key.freezed.dart
Normal file
277
lib/data/provider/private_key.freezed.dart
Normal file
@@ -0,0 +1,277 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'private_key.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$PrivateKeyState {
|
||||
|
||||
List<PrivateKeyInfo> get keys;
|
||||
/// Create a copy of PrivateKeyState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$PrivateKeyStateCopyWith<PrivateKeyState> get copyWith => _$PrivateKeyStateCopyWithImpl<PrivateKeyState>(this as PrivateKeyState, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is PrivateKeyState&&const DeepCollectionEquality().equals(other.keys, keys));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(keys));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'PrivateKeyState(keys: $keys)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $PrivateKeyStateCopyWith<$Res> {
|
||||
factory $PrivateKeyStateCopyWith(PrivateKeyState value, $Res Function(PrivateKeyState) _then) = _$PrivateKeyStateCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
List<PrivateKeyInfo> keys
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$PrivateKeyStateCopyWithImpl<$Res>
|
||||
implements $PrivateKeyStateCopyWith<$Res> {
|
||||
_$PrivateKeyStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final PrivateKeyState _self;
|
||||
final $Res Function(PrivateKeyState) _then;
|
||||
|
||||
/// Create a copy of PrivateKeyState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? keys = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
keys: null == keys ? _self.keys : keys // ignore: cast_nullable_to_non_nullable
|
||||
as List<PrivateKeyInfo>,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [PrivateKeyState].
|
||||
extension PrivateKeyStatePatterns on PrivateKeyState {
|
||||
/// A variant of `map` that fallback to returning `orElse`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _PrivateKeyState value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _PrivateKeyState() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// Callbacks receives the raw object, upcasted.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case final Subclass2 value:
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _PrivateKeyState value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _PrivateKeyState():
|
||||
return $default(_that);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `map` that fallback to returning `null`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _PrivateKeyState value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _PrivateKeyState() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( List<PrivateKeyInfo> keys)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _PrivateKeyState() when $default != null:
|
||||
return $default(_that.keys);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( List<PrivateKeyInfo> keys) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _PrivateKeyState():
|
||||
return $default(_that.keys);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( List<PrivateKeyInfo> keys)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _PrivateKeyState() when $default != null:
|
||||
return $default(_that.keys);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _PrivateKeyState implements PrivateKeyState {
|
||||
const _PrivateKeyState({final List<PrivateKeyInfo> keys = const <PrivateKeyInfo>[]}): _keys = keys;
|
||||
|
||||
|
||||
final List<PrivateKeyInfo> _keys;
|
||||
@override@JsonKey() List<PrivateKeyInfo> get keys {
|
||||
if (_keys is EqualUnmodifiableListView) return _keys;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_keys);
|
||||
}
|
||||
|
||||
|
||||
/// Create a copy of PrivateKeyState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$PrivateKeyStateCopyWith<_PrivateKeyState> get copyWith => __$PrivateKeyStateCopyWithImpl<_PrivateKeyState>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _PrivateKeyState&&const DeepCollectionEquality().equals(other._keys, _keys));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(_keys));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'PrivateKeyState(keys: $keys)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$PrivateKeyStateCopyWith<$Res> implements $PrivateKeyStateCopyWith<$Res> {
|
||||
factory _$PrivateKeyStateCopyWith(_PrivateKeyState value, $Res Function(_PrivateKeyState) _then) = __$PrivateKeyStateCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
List<PrivateKeyInfo> keys
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$PrivateKeyStateCopyWithImpl<$Res>
|
||||
implements _$PrivateKeyStateCopyWith<$Res> {
|
||||
__$PrivateKeyStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _PrivateKeyState _self;
|
||||
final $Res Function(_PrivateKeyState) _then;
|
||||
|
||||
/// Create a copy of PrivateKeyState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? keys = null,}) {
|
||||
return _then(_PrivateKeyState(
|
||||
keys: null == keys ? _self._keys : keys // ignore: cast_nullable_to_non_nullable
|
||||
as List<PrivateKeyInfo>,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
27
lib/data/provider/private_key.g.dart
Normal file
27
lib/data/provider/private_key.g.dart
Normal file
@@ -0,0 +1,27 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'private_key.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$privateKeyNotifierHash() =>
|
||||
r'12edd05dca29d1cbc9e2a3e047c3d417d22f7bb7';
|
||||
|
||||
/// See also [PrivateKeyNotifier].
|
||||
@ProviderFor(PrivateKeyNotifier)
|
||||
final privateKeyNotifierProvider =
|
||||
NotifierProvider<PrivateKeyNotifier, PrivateKeyState>.internal(
|
||||
PrivateKeyNotifier.new,
|
||||
name: r'privateKeyNotifierProvider',
|
||||
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$privateKeyNotifierHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
typedef _$PrivateKeyNotifier = Notifier<PrivateKeyState>;
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package
|
||||
82
lib/data/provider/providers.dart
Normal file
82
lib/data/provider/providers.dart
Normal file
@@ -0,0 +1,82 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import 'package:server_box/data/provider/app.dart';
|
||||
import 'package:server_box/data/provider/private_key.dart';
|
||||
import 'package:server_box/data/provider/server/all.dart';
|
||||
import 'package:server_box/data/provider/sftp.dart';
|
||||
import 'package:server_box/data/provider/snippet.dart';
|
||||
|
||||
/// !library;
|
||||
/// ref.useNotifier, ref.readProvider, ref.watchProvider
|
||||
///
|
||||
/// Usage:
|
||||
/// - `providers.read.server` -> `ref.read(serversNotifierProvider)`
|
||||
/// - `providers.use.snippet` -> `ref.read(snippetsNotifierProvider.notifier)`
|
||||
|
||||
extension RiverpodNotifiers on ConsumerState {
|
||||
T useNotifier<T extends Notifier<Object?>>(NotifierProvider<T, Object?> provider) {
|
||||
return ref.read(provider.notifier);
|
||||
}
|
||||
|
||||
T readProvider<T>(ProviderBase<T> provider) {
|
||||
return ref.read(provider);
|
||||
}
|
||||
|
||||
T watchProvider<T>(ProviderBase<T> provider) {
|
||||
return ref.watch(provider);
|
||||
}
|
||||
|
||||
MyProviders get providers => MyProviders(ref);
|
||||
}
|
||||
|
||||
final class MyProviders {
|
||||
final WidgetRef ref;
|
||||
const MyProviders(this.ref);
|
||||
|
||||
ReadMyProvider get read => ReadMyProvider(ref);
|
||||
WatchMyProvider get watch => WatchMyProvider(ref);
|
||||
UseNotifierMyProvider get use => UseNotifierMyProvider(ref);
|
||||
}
|
||||
|
||||
final class ReadMyProvider {
|
||||
final WidgetRef ref;
|
||||
const ReadMyProvider(this.ref);
|
||||
|
||||
T call<T>(ProviderBase<T> provider) => ref.read(provider);
|
||||
|
||||
// Specific provider getters
|
||||
ServersState get server => ref.read(serversNotifierProvider);
|
||||
SnippetState get snippet => ref.read(snippetNotifierProvider);
|
||||
AppState get app => ref.read(appStatesProvider);
|
||||
PrivateKeyState get privateKey => ref.read(privateKeyNotifierProvider);
|
||||
SftpState get sftp => ref.read(sftpNotifierProvider);
|
||||
}
|
||||
|
||||
final class WatchMyProvider {
|
||||
final WidgetRef ref;
|
||||
const WatchMyProvider(this.ref);
|
||||
|
||||
T call<T>(ProviderBase<T> provider) => ref.watch(provider);
|
||||
|
||||
// Specific provider getters
|
||||
ServersState get server => ref.watch(serversNotifierProvider);
|
||||
SnippetState get snippet => ref.watch(snippetNotifierProvider);
|
||||
AppState get app => ref.watch(appStatesProvider);
|
||||
PrivateKeyState get privateKey => ref.watch(privateKeyNotifierProvider);
|
||||
SftpState get sftp => ref.watch(sftpNotifierProvider);
|
||||
}
|
||||
|
||||
final class UseNotifierMyProvider {
|
||||
final WidgetRef ref;
|
||||
const UseNotifierMyProvider(this.ref);
|
||||
|
||||
T call<T extends Notifier<Object?>>(NotifierProvider<T, Object?> provider) =>
|
||||
ref.read(provider.notifier);
|
||||
|
||||
// Specific provider notifier getters
|
||||
ServersNotifier get server => ref.read(serversNotifierProvider.notifier);
|
||||
SnippetNotifier get snippet => ref.read(snippetNotifierProvider.notifier);
|
||||
AppStates get app => ref.read(appStatesProvider.notifier);
|
||||
PrivateKeyNotifier get privateKey => ref.read(privateKeyNotifierProvider.notifier);
|
||||
SftpNotifier get sftp => ref.read(sftpNotifierProvider.notifier);
|
||||
}
|
||||
@@ -7,71 +7,90 @@ import 'package:dio/dio.dart';
|
||||
import 'package:dio/io.dart';
|
||||
import 'package:fl_lib/fl_lib.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import 'package:server_box/core/extension/context/locale.dart';
|
||||
import 'package:server_box/data/model/app/error.dart';
|
||||
import 'package:server_box/data/model/server/pve.dart';
|
||||
import 'package:server_box/data/model/server/server_private_info.dart';
|
||||
import 'package:server_box/data/provider/server/single.dart';
|
||||
|
||||
part 'pve.freezed.dart';
|
||||
part 'pve.g.dart';
|
||||
|
||||
typedef PveCtrlFunc = Future<bool> Function(String node, String id);
|
||||
|
||||
final class PveProvider extends ChangeNotifier {
|
||||
final Spi spi;
|
||||
@freezed
|
||||
abstract class PveState with _$PveState {
|
||||
const factory PveState({
|
||||
@Default(null) PveErr? error,
|
||||
@Default(null) PveRes? data,
|
||||
@Default(null) String? release,
|
||||
@Default(false) bool isBusy,
|
||||
@Default(false) bool isConnected,
|
||||
}) = _PveState;
|
||||
}
|
||||
|
||||
@riverpod
|
||||
class PveNotifier extends _$PveNotifier {
|
||||
late final Spi spi;
|
||||
late String addr;
|
||||
late final SSHClient _client;
|
||||
late final ServerSocket _serverSocket;
|
||||
final List<SSHForwardChannel> _forwards = [];
|
||||
int _localPort = 0;
|
||||
late final Dio session;
|
||||
late final bool _ignoreCert;
|
||||
|
||||
PveProvider({required this.spi}) {
|
||||
final client = spi.server?.value.client;
|
||||
@override
|
||||
PveState build(Spi spiParam) {
|
||||
spi = spiParam;
|
||||
final serverState = ref.watch(serverNotifierProvider(spi.id));
|
||||
final client = serverState.client;
|
||||
if (client == null) {
|
||||
throw Exception('Server client is null');
|
||||
return const PveState(error: PveErr(type: PveErrType.net, message: 'Server client is null'));
|
||||
}
|
||||
_client = client;
|
||||
final addr = spi.custom?.pveAddr;
|
||||
if (addr == null) {
|
||||
err.value = 'PVE address is null';
|
||||
return;
|
||||
return PveState(error: PveErr(type: PveErrType.net, message: 'PVE address is null'));
|
||||
}
|
||||
this.addr = addr;
|
||||
_init();
|
||||
_ignoreCert = spi.custom?.pveIgnoreCert ?? false;
|
||||
_initSession();
|
||||
// Async initialization
|
||||
Future.microtask(() => _init());
|
||||
return const PveState();
|
||||
}
|
||||
|
||||
final err = ValueNotifier<String?>(null);
|
||||
final connected = Completer<void>();
|
||||
void _initSession() {
|
||||
session = Dio()
|
||||
..httpClientAdapter = IOHttpClientAdapter(
|
||||
createHttpClient: () {
|
||||
final client = HttpClient();
|
||||
client.connectionFactory = cf;
|
||||
if (_ignoreCert) {
|
||||
client.badCertificateCallback = (_, _, _) => true;
|
||||
}
|
||||
return client;
|
||||
},
|
||||
validateCertificate: _ignoreCert ? (_, _, _) => true : null,
|
||||
);
|
||||
}
|
||||
|
||||
late final _ignoreCert = spi.custom?.pveIgnoreCert ?? false;
|
||||
late final session = Dio()
|
||||
..httpClientAdapter = IOHttpClientAdapter(
|
||||
createHttpClient: () {
|
||||
final client = HttpClient();
|
||||
client.connectionFactory = cf;
|
||||
if (_ignoreCert) {
|
||||
client.badCertificateCallback = (_, _, _) => true;
|
||||
}
|
||||
return client;
|
||||
},
|
||||
validateCertificate: _ignoreCert ? (_, _, _) => true : null,
|
||||
);
|
||||
|
||||
final data = ValueNotifier<PveRes?>(null);
|
||||
|
||||
bool get onlyOneNode => data.value?.nodes.length == 1;
|
||||
String? release;
|
||||
bool isBusy = false;
|
||||
bool get onlyOneNode => state.data?.nodes.length == 1;
|
||||
|
||||
Future<void> _init() async {
|
||||
try {
|
||||
await _forward();
|
||||
await _login();
|
||||
await _getRelease();
|
||||
state = state.copyWith(isConnected: true);
|
||||
} on PveErr {
|
||||
err.value = l10n.pveLoginFailed;
|
||||
state = state.copyWith(error: PveErr(type: PveErrType.loginFailed, message: l10n.pveLoginFailed));
|
||||
} catch (e, s) {
|
||||
Loggers.app.warning('PVE init failed', e, s);
|
||||
err.value = e.toString();
|
||||
} finally {
|
||||
connected.complete();
|
||||
state = state.copyWith(error: PveErr(type: PveErrType.unknown, message: e.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,72 +165,81 @@ final class PveProvider extends ChangeNotifier {
|
||||
final resp = await session.get('$addr/api2/extjs/version');
|
||||
final version = resp.data['data']['release'] as String?;
|
||||
if (version != null) {
|
||||
release = version;
|
||||
state = state.copyWith(release: version);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> list() async {
|
||||
await connected.future;
|
||||
if (isBusy) return;
|
||||
isBusy = true;
|
||||
if (!state.isConnected || state.isBusy) return;
|
||||
state = state.copyWith(isBusy: true);
|
||||
try {
|
||||
final resp = await session.get('$addr/api2/json/cluster/resources');
|
||||
final res = resp.data['data'] as List;
|
||||
final result = await Computer.shared.start(PveRes.parse, (
|
||||
res,
|
||||
data.value,
|
||||
state.data,
|
||||
));
|
||||
data.value = result;
|
||||
state = state.copyWith(data: result, error: null);
|
||||
} catch (e) {
|
||||
Loggers.app.warning('PVE list failed', e);
|
||||
err.value = e.toString();
|
||||
state = state.copyWith(error: PveErr(type: PveErrType.unknown, message: e.toString()));
|
||||
} finally {
|
||||
isBusy = false;
|
||||
state = state.copyWith(isBusy: false);
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> reboot(String node, String id) async {
|
||||
await connected.future;
|
||||
if (!state.isConnected) return false;
|
||||
final resp = await session.post(
|
||||
'$addr/api2/json/nodes/$node/$id/status/reboot',
|
||||
);
|
||||
return _isCtrlSuc(resp);
|
||||
final success = _isCtrlSuc(resp);
|
||||
if (success) await list(); // Refresh data
|
||||
return success;
|
||||
}
|
||||
|
||||
Future<bool> start(String node, String id) async {
|
||||
await connected.future;
|
||||
if (!state.isConnected) return false;
|
||||
final resp = await session.post(
|
||||
'$addr/api2/json/nodes/$node/$id/status/start',
|
||||
);
|
||||
return _isCtrlSuc(resp);
|
||||
final success = _isCtrlSuc(resp);
|
||||
if (success) await list(); // Refresh data
|
||||
return success;
|
||||
}
|
||||
|
||||
Future<bool> stop(String node, String id) async {
|
||||
await connected.future;
|
||||
if (!state.isConnected) return false;
|
||||
final resp = await session.post(
|
||||
'$addr/api2/json/nodes/$node/$id/status/stop',
|
||||
);
|
||||
return _isCtrlSuc(resp);
|
||||
final success = _isCtrlSuc(resp);
|
||||
if (success) await list(); // Refresh data
|
||||
return success;
|
||||
}
|
||||
|
||||
Future<bool> shutdown(String node, String id) async {
|
||||
await connected.future;
|
||||
if (!state.isConnected) return false;
|
||||
final resp = await session.post(
|
||||
'$addr/api2/json/nodes/$node/$id/status/shutdown',
|
||||
);
|
||||
return _isCtrlSuc(resp);
|
||||
final success = _isCtrlSuc(resp);
|
||||
if (success) await list(); // Refresh data
|
||||
return success;
|
||||
}
|
||||
|
||||
bool _isCtrlSuc(Response resp) {
|
||||
return resp.statusCode == 200;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> dispose() async {
|
||||
super.dispose();
|
||||
await _serverSocket.close();
|
||||
try {
|
||||
await _serverSocket.close();
|
||||
} catch (_) {}
|
||||
for (final forward in _forwards) {
|
||||
forward.close();
|
||||
try {
|
||||
forward.close();
|
||||
} catch (_) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
283
lib/data/provider/pve.freezed.dart
Normal file
283
lib/data/provider/pve.freezed.dart
Normal file
@@ -0,0 +1,283 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'pve.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$PveState {
|
||||
|
||||
PveErr? get error; PveRes? get data; String? get release; bool get isBusy; bool get isConnected;
|
||||
/// Create a copy of PveState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$PveStateCopyWith<PveState> get copyWith => _$PveStateCopyWithImpl<PveState>(this as PveState, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is PveState&&(identical(other.error, error) || other.error == error)&&(identical(other.data, data) || other.data == data)&&(identical(other.release, release) || other.release == release)&&(identical(other.isBusy, isBusy) || other.isBusy == isBusy)&&(identical(other.isConnected, isConnected) || other.isConnected == isConnected));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,error,data,release,isBusy,isConnected);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'PveState(error: $error, data: $data, release: $release, isBusy: $isBusy, isConnected: $isConnected)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $PveStateCopyWith<$Res> {
|
||||
factory $PveStateCopyWith(PveState value, $Res Function(PveState) _then) = _$PveStateCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
PveErr? error, PveRes? data, String? release, bool isBusy, bool isConnected
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$PveStateCopyWithImpl<$Res>
|
||||
implements $PveStateCopyWith<$Res> {
|
||||
_$PveStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final PveState _self;
|
||||
final $Res Function(PveState) _then;
|
||||
|
||||
/// Create a copy of PveState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? error = freezed,Object? data = freezed,Object? release = freezed,Object? isBusy = null,Object? isConnected = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
error: freezed == error ? _self.error : error // ignore: cast_nullable_to_non_nullable
|
||||
as PveErr?,data: freezed == data ? _self.data : data // ignore: cast_nullable_to_non_nullable
|
||||
as PveRes?,release: freezed == release ? _self.release : release // ignore: cast_nullable_to_non_nullable
|
||||
as String?,isBusy: null == isBusy ? _self.isBusy : isBusy // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isConnected: null == isConnected ? _self.isConnected : isConnected // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [PveState].
|
||||
extension PveStatePatterns on PveState {
|
||||
/// A variant of `map` that fallback to returning `orElse`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _PveState value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _PveState() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// Callbacks receives the raw object, upcasted.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case final Subclass2 value:
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _PveState value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _PveState():
|
||||
return $default(_that);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `map` that fallback to returning `null`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _PveState value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _PveState() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( PveErr? error, PveRes? data, String? release, bool isBusy, bool isConnected)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _PveState() when $default != null:
|
||||
return $default(_that.error,_that.data,_that.release,_that.isBusy,_that.isConnected);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( PveErr? error, PveRes? data, String? release, bool isBusy, bool isConnected) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _PveState():
|
||||
return $default(_that.error,_that.data,_that.release,_that.isBusy,_that.isConnected);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( PveErr? error, PveRes? data, String? release, bool isBusy, bool isConnected)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _PveState() when $default != null:
|
||||
return $default(_that.error,_that.data,_that.release,_that.isBusy,_that.isConnected);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _PveState implements PveState {
|
||||
const _PveState({this.error = null, this.data = null, this.release = null, this.isBusy = false, this.isConnected = false});
|
||||
|
||||
|
||||
@override@JsonKey() final PveErr? error;
|
||||
@override@JsonKey() final PveRes? data;
|
||||
@override@JsonKey() final String? release;
|
||||
@override@JsonKey() final bool isBusy;
|
||||
@override@JsonKey() final bool isConnected;
|
||||
|
||||
/// Create a copy of PveState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$PveStateCopyWith<_PveState> get copyWith => __$PveStateCopyWithImpl<_PveState>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _PveState&&(identical(other.error, error) || other.error == error)&&(identical(other.data, data) || other.data == data)&&(identical(other.release, release) || other.release == release)&&(identical(other.isBusy, isBusy) || other.isBusy == isBusy)&&(identical(other.isConnected, isConnected) || other.isConnected == isConnected));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,error,data,release,isBusy,isConnected);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'PveState(error: $error, data: $data, release: $release, isBusy: $isBusy, isConnected: $isConnected)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$PveStateCopyWith<$Res> implements $PveStateCopyWith<$Res> {
|
||||
factory _$PveStateCopyWith(_PveState value, $Res Function(_PveState) _then) = __$PveStateCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
PveErr? error, PveRes? data, String? release, bool isBusy, bool isConnected
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$PveStateCopyWithImpl<$Res>
|
||||
implements _$PveStateCopyWith<$Res> {
|
||||
__$PveStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _PveState _self;
|
||||
final $Res Function(_PveState) _then;
|
||||
|
||||
/// Create a copy of PveState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? error = freezed,Object? data = freezed,Object? release = freezed,Object? isBusy = null,Object? isConnected = null,}) {
|
||||
return _then(_PveState(
|
||||
error: freezed == error ? _self.error : error // ignore: cast_nullable_to_non_nullable
|
||||
as PveErr?,data: freezed == data ? _self.data : data // ignore: cast_nullable_to_non_nullable
|
||||
as PveRes?,release: freezed == release ? _self.release : release // ignore: cast_nullable_to_non_nullable
|
||||
as String?,isBusy: null == isBusy ? _self.isBusy : isBusy // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isConnected: null == isConnected ? _self.isConnected : isConnected // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
160
lib/data/provider/pve.g.dart
Normal file
160
lib/data/provider/pve.g.dart
Normal file
@@ -0,0 +1,160 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'pve.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$pveNotifierHash() => r'b5da7240db1b9ee7d61f238cebca45821b7a3445';
|
||||
|
||||
/// Copied from Dart SDK
|
||||
class _SystemHash {
|
||||
_SystemHash._();
|
||||
|
||||
static int combine(int hash, int value) {
|
||||
// ignore: parameter_assignments
|
||||
hash = 0x1fffffff & (hash + value);
|
||||
// ignore: parameter_assignments
|
||||
hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10));
|
||||
return hash ^ (hash >> 6);
|
||||
}
|
||||
|
||||
static int finish(int hash) {
|
||||
// ignore: parameter_assignments
|
||||
hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3));
|
||||
// ignore: parameter_assignments
|
||||
hash = hash ^ (hash >> 11);
|
||||
return 0x1fffffff & (hash + ((0x00003fff & hash) << 15));
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _$PveNotifier extends BuildlessAutoDisposeNotifier<PveState> {
|
||||
late final Spi spiParam;
|
||||
|
||||
PveState build(Spi spiParam);
|
||||
}
|
||||
|
||||
/// See also [PveNotifier].
|
||||
@ProviderFor(PveNotifier)
|
||||
const pveNotifierProvider = PveNotifierFamily();
|
||||
|
||||
/// See also [PveNotifier].
|
||||
class PveNotifierFamily extends Family<PveState> {
|
||||
/// See also [PveNotifier].
|
||||
const PveNotifierFamily();
|
||||
|
||||
/// See also [PveNotifier].
|
||||
PveNotifierProvider call(Spi spiParam) {
|
||||
return PveNotifierProvider(spiParam);
|
||||
}
|
||||
|
||||
@override
|
||||
PveNotifierProvider getProviderOverride(
|
||||
covariant PveNotifierProvider provider,
|
||||
) {
|
||||
return call(provider.spiParam);
|
||||
}
|
||||
|
||||
static const Iterable<ProviderOrFamily>? _dependencies = null;
|
||||
|
||||
@override
|
||||
Iterable<ProviderOrFamily>? get dependencies => _dependencies;
|
||||
|
||||
static const Iterable<ProviderOrFamily>? _allTransitiveDependencies = null;
|
||||
|
||||
@override
|
||||
Iterable<ProviderOrFamily>? get allTransitiveDependencies =>
|
||||
_allTransitiveDependencies;
|
||||
|
||||
@override
|
||||
String? get name => r'pveNotifierProvider';
|
||||
}
|
||||
|
||||
/// See also [PveNotifier].
|
||||
class PveNotifierProvider
|
||||
extends AutoDisposeNotifierProviderImpl<PveNotifier, PveState> {
|
||||
/// See also [PveNotifier].
|
||||
PveNotifierProvider(Spi spiParam)
|
||||
: this._internal(
|
||||
() => PveNotifier()..spiParam = spiParam,
|
||||
from: pveNotifierProvider,
|
||||
name: r'pveNotifierProvider',
|
||||
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$pveNotifierHash,
|
||||
dependencies: PveNotifierFamily._dependencies,
|
||||
allTransitiveDependencies: PveNotifierFamily._allTransitiveDependencies,
|
||||
spiParam: spiParam,
|
||||
);
|
||||
|
||||
PveNotifierProvider._internal(
|
||||
super._createNotifier, {
|
||||
required super.name,
|
||||
required super.dependencies,
|
||||
required super.allTransitiveDependencies,
|
||||
required super.debugGetCreateSourceHash,
|
||||
required super.from,
|
||||
required this.spiParam,
|
||||
}) : super.internal();
|
||||
|
||||
final Spi spiParam;
|
||||
|
||||
@override
|
||||
PveState runNotifierBuild(covariant PveNotifier notifier) {
|
||||
return notifier.build(spiParam);
|
||||
}
|
||||
|
||||
@override
|
||||
Override overrideWith(PveNotifier Function() create) {
|
||||
return ProviderOverride(
|
||||
origin: this,
|
||||
override: PveNotifierProvider._internal(
|
||||
() => create()..spiParam = spiParam,
|
||||
from: from,
|
||||
name: null,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
debugGetCreateSourceHash: null,
|
||||
spiParam: spiParam,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
AutoDisposeNotifierProviderElement<PveNotifier, PveState> createElement() {
|
||||
return _PveNotifierProviderElement(this);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return other is PveNotifierProvider && other.spiParam == spiParam;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
var hash = _SystemHash.combine(0, runtimeType.hashCode);
|
||||
hash = _SystemHash.combine(hash, spiParam.hashCode);
|
||||
|
||||
return _SystemHash.finish(hash);
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated('Will be removed in 3.0. Use Ref instead')
|
||||
// ignore: unused_element
|
||||
mixin PveNotifierRef on AutoDisposeNotifierProviderRef<PveState> {
|
||||
/// The parameter `spiParam` of this provider.
|
||||
Spi get spiParam;
|
||||
}
|
||||
|
||||
class _PveNotifierProviderElement
|
||||
extends AutoDisposeNotifierProviderElement<PveNotifier, PveState>
|
||||
with PveNotifierRef {
|
||||
_PveNotifierProviderElement(super.provider);
|
||||
|
||||
@override
|
||||
Spi get spiParam => (origin as PveNotifierProvider).spiParam;
|
||||
}
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package
|
||||
@@ -1,505 +0,0 @@
|
||||
import 'dart:async';
|
||||
|
||||
// import 'dart:io';
|
||||
|
||||
import 'package:computer/computer.dart';
|
||||
import 'package:dartssh2/dartssh2.dart';
|
||||
import 'package:fl_lib/fl_lib.dart';
|
||||
import 'package:server_box/core/extension/ssh_client.dart';
|
||||
import 'package:server_box/core/sync.dart';
|
||||
import 'package:server_box/core/utils/server.dart';
|
||||
import 'package:server_box/core/utils/ssh_auth.dart';
|
||||
import 'package:server_box/data/helper/system_detector.dart';
|
||||
import 'package:server_box/data/model/app/error.dart';
|
||||
import 'package:server_box/data/model/app/scripts/script_consts.dart';
|
||||
import 'package:server_box/data/model/app/scripts/shell_func.dart';
|
||||
import 'package:server_box/data/model/server/server.dart';
|
||||
import 'package:server_box/data/model/server/server_private_info.dart';
|
||||
import 'package:server_box/data/model/server/server_status_update_req.dart';
|
||||
import 'package:server_box/data/model/server/system.dart';
|
||||
import 'package:server_box/data/model/server/try_limiter.dart';
|
||||
import 'package:server_box/data/res/status.dart';
|
||||
import 'package:server_box/data/res/store.dart';
|
||||
import 'package:server_box/data/ssh/session_manager.dart';
|
||||
|
||||
class ServerProvider extends Provider {
|
||||
const ServerProvider._();
|
||||
static const instance = ServerProvider._();
|
||||
|
||||
static final Map<String, VNode<Server>> servers = {};
|
||||
static final serverOrder = <String>[].vn;
|
||||
static final _tags = <String>{}.vn;
|
||||
static VNode<Set<String>> get tags => _tags;
|
||||
|
||||
static Timer? _timer;
|
||||
|
||||
static final _manualDisconnectedIds = <String>{};
|
||||
|
||||
static final _serverIdsUpdating = <String, Future<void>?>{};
|
||||
|
||||
@override
|
||||
Future<void> load() async {
|
||||
super.load();
|
||||
// #147
|
||||
// Clear all servers because of restarting app will cause duplicate servers
|
||||
final oldServers = Map<String, VNode<Server>>.from(servers);
|
||||
servers.clear();
|
||||
serverOrder.value.clear();
|
||||
|
||||
final spis = Stores.server.fetch();
|
||||
for (int idx = 0; idx < spis.length; idx++) {
|
||||
final spi = spis[idx];
|
||||
final originServer = oldServers[spi.id];
|
||||
|
||||
/// #258
|
||||
/// If not [shouldReconnect], then keep the old state.
|
||||
if (originServer != null && !originServer.value.spi.shouldReconnect(spi)) {
|
||||
originServer.value.spi = spi;
|
||||
servers[spi.id] = originServer;
|
||||
} else {
|
||||
final newServer = genServer(spi);
|
||||
servers[spi.id] = newServer.vn;
|
||||
}
|
||||
}
|
||||
final serverOrder_ = Stores.setting.serverOrder.fetch();
|
||||
if (serverOrder_.isNotEmpty) {
|
||||
spis.reorder(order: serverOrder_, finder: (n, id) => n.id == id);
|
||||
serverOrder.value.addAll(spis.map((e) => e.id));
|
||||
} else {
|
||||
serverOrder.value.addAll(servers.keys);
|
||||
}
|
||||
// Must use [equals] to compare [Order] here.
|
||||
if (!serverOrder.value.equals(serverOrder_)) {
|
||||
Stores.setting.serverOrder.put(serverOrder.value);
|
||||
}
|
||||
_updateTags();
|
||||
// Must notify here, or the UI will not be updated.
|
||||
serverOrder.notify();
|
||||
}
|
||||
|
||||
/// Get a [Server] by [spi] or [id].
|
||||
///
|
||||
/// Priority: [spi] > [id]
|
||||
static VNode<Server>? pick({Spi? spi, String? id}) {
|
||||
if (spi != null) {
|
||||
return servers[spi.id];
|
||||
}
|
||||
if (id != null) {
|
||||
return servers[id];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static void _updateTags() {
|
||||
final tags = <String>{};
|
||||
for (final s in servers.values) {
|
||||
final spiTags = s.value.spi.tags;
|
||||
if (spiTags == null) continue;
|
||||
for (final t in spiTags) {
|
||||
tags.add(t);
|
||||
}
|
||||
}
|
||||
_tags.value = tags;
|
||||
}
|
||||
|
||||
static Server genServer(Spi spi) {
|
||||
return Server(spi, InitStatus.status, ServerConn.disconnected);
|
||||
}
|
||||
|
||||
/// if [spi] is specificed then only refresh this server
|
||||
/// [onlyFailed] only refresh failed servers
|
||||
static Future<void> refresh({Spi? spi, bool onlyFailed = false}) async {
|
||||
if (spi != null) {
|
||||
_manualDisconnectedIds.remove(spi.id);
|
||||
await _getData(spi);
|
||||
return;
|
||||
}
|
||||
|
||||
await Future.wait(
|
||||
servers.values.map((val) async {
|
||||
final s = val.value;
|
||||
if (onlyFailed) {
|
||||
if (s.conn != ServerConn.failed) return;
|
||||
TryLimiter.reset(s.spi.id);
|
||||
}
|
||||
|
||||
if (_manualDisconnectedIds.contains(s.spi.id)) return;
|
||||
|
||||
if (s.conn == ServerConn.disconnected && !s.spi.autoConnect) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if already updating, and if so, wait for it to complete
|
||||
final existingUpdate = _serverIdsUpdating[s.spi.id];
|
||||
if (existingUpdate != null) {
|
||||
// Already updating, wait for the existing update to complete
|
||||
try {
|
||||
await existingUpdate;
|
||||
} catch (e) {
|
||||
// Ignore errors from the existing update, we'll try our own
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Start a new update operation
|
||||
final updateFuture = _updateServer(s.spi);
|
||||
_serverIdsUpdating[s.spi.id] = updateFuture;
|
||||
|
||||
try {
|
||||
await updateFuture;
|
||||
} finally {
|
||||
_serverIdsUpdating.remove(s.spi.id);
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
static Future<void> _updateServer(Spi spi) async {
|
||||
await _getData(spi);
|
||||
}
|
||||
|
||||
static Future<void> startAutoRefresh() async {
|
||||
var duration = Stores.setting.serverStatusUpdateInterval.fetch();
|
||||
stopAutoRefresh();
|
||||
if (duration == 0) return;
|
||||
if (duration < 0 || duration > 10 || duration == 1) {
|
||||
duration = 3;
|
||||
Loggers.app.warning('Invalid duration: $duration, use default 3');
|
||||
}
|
||||
_timer = Timer.periodic(Duration(seconds: duration), (_) async {
|
||||
await refresh();
|
||||
});
|
||||
}
|
||||
|
||||
static void stopAutoRefresh() {
|
||||
if (_timer != null) {
|
||||
_timer!.cancel();
|
||||
_timer = null;
|
||||
}
|
||||
}
|
||||
|
||||
static bool get isAutoRefreshOn => _timer != null;
|
||||
|
||||
static void setDisconnected() {
|
||||
for (final s in servers.values) {
|
||||
s.value.conn = ServerConn.disconnected;
|
||||
s.notify();
|
||||
|
||||
// Update SSH session status to disconnected
|
||||
final sessionId = 'ssh_${s.value.spi.id}';
|
||||
TermSessionManager.updateStatus(sessionId, TermSessionStatus.disconnected);
|
||||
}
|
||||
//TryLimiter.clear();
|
||||
}
|
||||
|
||||
static void closeServer({String? id}) {
|
||||
if (id == null) {
|
||||
for (final s in servers.values) {
|
||||
_closeOneServer(s.value.spi.id);
|
||||
}
|
||||
return;
|
||||
}
|
||||
_closeOneServer(id);
|
||||
}
|
||||
|
||||
static void _closeOneServer(String id) {
|
||||
final s = servers[id];
|
||||
if (s == null) {
|
||||
Loggers.app.warning('Server with id $id not found');
|
||||
return;
|
||||
}
|
||||
final item = s.value;
|
||||
item.client?.close();
|
||||
item.client = null;
|
||||
item.conn = ServerConn.disconnected;
|
||||
_manualDisconnectedIds.add(id);
|
||||
s.notify();
|
||||
|
||||
// Remove SSH session when server is manually closed
|
||||
final sessionId = 'ssh_$id';
|
||||
TermSessionManager.remove(sessionId);
|
||||
}
|
||||
|
||||
static void addServer(Spi spi) {
|
||||
servers[spi.id] = genServer(spi).vn;
|
||||
Stores.server.put(spi);
|
||||
serverOrder.value.add(spi.id);
|
||||
serverOrder.notify();
|
||||
Stores.setting.serverOrder.put(serverOrder.value);
|
||||
_updateTags();
|
||||
refresh(spi: spi);
|
||||
bakSync.sync(milliDelay: 1000);
|
||||
}
|
||||
|
||||
static void delServer(String id) {
|
||||
servers.remove(id);
|
||||
serverOrder.value.remove(id);
|
||||
serverOrder.notify();
|
||||
Stores.setting.serverOrder.put(serverOrder.value);
|
||||
Stores.server.delete(id);
|
||||
_updateTags();
|
||||
|
||||
// Remove SSH session when server is deleted
|
||||
final sessionId = 'ssh_$id';
|
||||
TermSessionManager.remove(sessionId);
|
||||
|
||||
bakSync.sync(milliDelay: 1000);
|
||||
}
|
||||
|
||||
static void deleteAll() {
|
||||
// Remove all SSH sessions before clearing servers
|
||||
for (final id in servers.keys) {
|
||||
final sessionId = 'ssh_$id';
|
||||
TermSessionManager.remove(sessionId);
|
||||
}
|
||||
|
||||
servers.clear();
|
||||
serverOrder.value.clear();
|
||||
serverOrder.notify();
|
||||
Stores.setting.serverOrder.put(serverOrder.value);
|
||||
Stores.server.clear();
|
||||
_updateTags();
|
||||
bakSync.sync(milliDelay: 1000);
|
||||
}
|
||||
|
||||
static Future<void> updateServer(Spi old, Spi newSpi) async {
|
||||
if (old != newSpi) {
|
||||
Stores.server.update(old, newSpi);
|
||||
servers[old.id]?.value.spi = newSpi;
|
||||
|
||||
if (newSpi.id != old.id) {
|
||||
servers[newSpi.id] = servers[old.id]!;
|
||||
servers.remove(old.id);
|
||||
serverOrder.value.update(old.id, newSpi.id);
|
||||
Stores.setting.serverOrder.put(serverOrder.value);
|
||||
serverOrder.notify();
|
||||
|
||||
// Update SSH session ID when server ID changes
|
||||
final oldSessionId = 'ssh_${old.id}';
|
||||
TermSessionManager.remove(oldSessionId);
|
||||
// Session will be re-added when reconnecting if necessary
|
||||
}
|
||||
|
||||
// Only reconnect if neccessary
|
||||
if (newSpi.shouldReconnect(old)) {
|
||||
// Use [newSpi.id] instead of [old.id] because [old.id] may be changed
|
||||
TryLimiter.reset(newSpi.id);
|
||||
refresh(spi: newSpi);
|
||||
}
|
||||
}
|
||||
_updateTags();
|
||||
bakSync.sync(milliDelay: 1000);
|
||||
}
|
||||
|
||||
static void _setServerState(VNode<Server> s, ServerConn ss) {
|
||||
s.value.conn = ss;
|
||||
s.notify();
|
||||
}
|
||||
|
||||
static Future<void> _getData(Spi spi) async {
|
||||
final sid = spi.id;
|
||||
final s = servers[sid];
|
||||
|
||||
if (s == null) return;
|
||||
|
||||
final sv = s.value;
|
||||
if (!TryLimiter.canTry(sid)) {
|
||||
if (sv.conn != ServerConn.failed) {
|
||||
_setServerState(s, ServerConn.failed);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
sv.status.err = null;
|
||||
|
||||
if (sv.needGenClient || (sv.client?.isClosed ?? true)) {
|
||||
_setServerState(s, ServerConn.connecting);
|
||||
|
||||
final wol = spi.wolCfg;
|
||||
if (wol != null) {
|
||||
try {
|
||||
await wol.wake();
|
||||
} catch (e) {
|
||||
// TryLimiter.inc(sid);
|
||||
// s.status.err = SSHErr(
|
||||
// type: SSHErrType.connect,
|
||||
// message: 'Wake on lan failed: $e',
|
||||
// );
|
||||
// _setServerState(s, ServerConn.failed);
|
||||
Loggers.app.warning('Wake on lan failed', e);
|
||||
// return;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
final time1 = DateTime.now();
|
||||
sv.client = await genClient(
|
||||
spi,
|
||||
timeout: Duration(seconds: Stores.setting.timeout.fetch()),
|
||||
onKeyboardInteractive: (_) => KeybordInteractive.defaultHandle(spi),
|
||||
);
|
||||
final time2 = DateTime.now();
|
||||
final spentTime = time2.difference(time1).inMilliseconds;
|
||||
if (spi.jumpId == null) {
|
||||
Loggers.app.info('Connected to ${spi.name} in $spentTime ms.');
|
||||
} else {
|
||||
Loggers.app.info('Jump to ${spi.name} in $spentTime ms.');
|
||||
}
|
||||
|
||||
// Add SSH session to TermSessionManager
|
||||
final sessionId = 'ssh_${spi.id}';
|
||||
TermSessionManager.add(
|
||||
id: sessionId,
|
||||
spi: spi,
|
||||
startTimeMs: time1.millisecondsSinceEpoch,
|
||||
disconnect: () => _closeOneServer(spi.id),
|
||||
status: TermSessionStatus.connecting,
|
||||
);
|
||||
TermSessionManager.setActive(sessionId, hasTerminal: false);
|
||||
} catch (e) {
|
||||
TryLimiter.inc(sid);
|
||||
sv.status.err = SSHErr(type: SSHErrType.connect, message: e.toString());
|
||||
_setServerState(s, ServerConn.failed);
|
||||
|
||||
// Remove SSH session on connection failure
|
||||
final sessionId = 'ssh_${spi.id}';
|
||||
TermSessionManager.remove(sessionId);
|
||||
|
||||
/// In order to keep privacy, print [spi.name] instead of [spi.id]
|
||||
Loggers.app.warning('Connect to ${spi.name} failed', e);
|
||||
return;
|
||||
}
|
||||
|
||||
_setServerState(s, ServerConn.connected);
|
||||
|
||||
// Update SSH session status to connected
|
||||
final sessionId = 'ssh_${spi.id}';
|
||||
TermSessionManager.updateStatus(sessionId, TermSessionStatus.connected);
|
||||
|
||||
try {
|
||||
// Detect system type using helper
|
||||
final detectedSystemType = await SystemDetector.detect(sv.client!, spi);
|
||||
sv.status.system = detectedSystemType;
|
||||
|
||||
final (_, writeScriptResult) = await sv.client!.exec((session) async {
|
||||
final scriptRaw = ShellFuncManager.allScript(
|
||||
spi.custom?.cmds,
|
||||
systemType: detectedSystemType,
|
||||
disabledCmdTypes: spi.disabledCmdTypes,
|
||||
).uint8List;
|
||||
session.stdin.add(scriptRaw);
|
||||
session.stdin.close();
|
||||
}, entry: ShellFuncManager.getInstallShellCmd(spi.id, systemType: detectedSystemType));
|
||||
if (writeScriptResult.isNotEmpty && detectedSystemType != SystemType.windows) {
|
||||
ShellFuncManager.switchScriptDir(spi.id, systemType: detectedSystemType);
|
||||
throw writeScriptResult;
|
||||
}
|
||||
} on SSHAuthAbortError catch (e) {
|
||||
TryLimiter.inc(sid);
|
||||
final err = SSHErr(type: SSHErrType.auth, message: e.toString());
|
||||
sv.status.err = err;
|
||||
Loggers.app.warning(err);
|
||||
_setServerState(s, ServerConn.failed);
|
||||
|
||||
// Update SSH session status to disconnected
|
||||
final sessionId = 'ssh_${spi.id}';
|
||||
TermSessionManager.updateStatus(sessionId, TermSessionStatus.disconnected);
|
||||
return;
|
||||
} on SSHAuthFailError catch (e) {
|
||||
TryLimiter.inc(sid);
|
||||
final err = SSHErr(type: SSHErrType.auth, message: e.toString());
|
||||
sv.status.err = err;
|
||||
Loggers.app.warning(err);
|
||||
_setServerState(s, ServerConn.failed);
|
||||
|
||||
// Update SSH session status to disconnected
|
||||
final sessionId = 'ssh_${spi.id}';
|
||||
TermSessionManager.updateStatus(sessionId, TermSessionStatus.disconnected);
|
||||
return;
|
||||
} catch (e) {
|
||||
// If max try times < 2 and can't write script, this will stop the status getting and etc.
|
||||
// TryLimiter.inc(sid);
|
||||
final err = SSHErr(type: SSHErrType.writeScript, message: e.toString());
|
||||
sv.status.err = err;
|
||||
Loggers.app.warning(err);
|
||||
_setServerState(s, ServerConn.failed);
|
||||
|
||||
// Update SSH session status to disconnected
|
||||
final sessionId = 'ssh_${spi.id}';
|
||||
TermSessionManager.updateStatus(sessionId, TermSessionStatus.disconnected);
|
||||
}
|
||||
}
|
||||
|
||||
if (sv.conn == ServerConn.connecting) return;
|
||||
|
||||
/// Keep [finished] state, or the UI will be refreshed to [loading] state
|
||||
/// instead of the '$Temp | $Uptime'.
|
||||
/// eg: '32C | 7 days'
|
||||
if (sv.conn != ServerConn.finished) {
|
||||
_setServerState(s, ServerConn.loading);
|
||||
}
|
||||
|
||||
List<String>? segments;
|
||||
String? raw;
|
||||
|
||||
try {
|
||||
raw = await sv.client?.run(ShellFunc.status.exec(spi.id, systemType: sv.status.system)).string;
|
||||
//dprint('Get status from ${spi.name}:\n$raw');
|
||||
segments = raw?.split(ScriptConstants.separator).map((e) => e.trim()).toList();
|
||||
if (raw == null || raw.isEmpty || segments == null || segments.isEmpty) {
|
||||
if (Stores.setting.keepStatusWhenErr.fetch()) {
|
||||
// Keep previous server status when err occurs
|
||||
if (sv.conn != ServerConn.failed && sv.status.more.isNotEmpty) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
TryLimiter.inc(sid);
|
||||
sv.status.err = SSHErr(type: SSHErrType.segements, message: 'Seperate segments failed, raw:\n$raw');
|
||||
_setServerState(s, ServerConn.failed);
|
||||
|
||||
// Update SSH session status to disconnected on segments error
|
||||
final sessionId = 'ssh_${spi.id}';
|
||||
TermSessionManager.updateStatus(sessionId, TermSessionStatus.disconnected);
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
TryLimiter.inc(sid);
|
||||
sv.status.err = SSHErr(type: SSHErrType.getStatus, message: e.toString());
|
||||
_setServerState(s, ServerConn.failed);
|
||||
Loggers.app.warning('Get status from ${spi.name} failed', e);
|
||||
|
||||
// Update SSH session status to disconnected on status error
|
||||
final sessionId = 'ssh_${spi.id}';
|
||||
TermSessionManager.updateStatus(sessionId, TermSessionStatus.disconnected);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// Parse script output into command-specific map
|
||||
final parsedOutput = ScriptConstants.parseScriptOutput(raw);
|
||||
|
||||
final req = ServerStatusUpdateReq(
|
||||
ss: sv.status,
|
||||
parsedOutput: parsedOutput,
|
||||
system: sv.status.system,
|
||||
customCmds: spi.custom?.cmds ?? {},
|
||||
);
|
||||
sv.status = await Computer.shared.start(getStatus, req, taskName: 'StatusUpdateReq<${sv.id}>');
|
||||
} catch (e, trace) {
|
||||
TryLimiter.inc(sid);
|
||||
sv.status.err = SSHErr(type: SSHErrType.getStatus, message: 'Parse failed: $e\n\n$raw');
|
||||
_setServerState(s, ServerConn.failed);
|
||||
Loggers.app.warning('Server status', e, trace);
|
||||
|
||||
// Update SSH session status to disconnected on parse error
|
||||
final sessionId = 'ssh_${spi.id}';
|
||||
TermSessionManager.updateStatus(sessionId, TermSessionStatus.disconnected);
|
||||
return;
|
||||
}
|
||||
|
||||
/// Call this every time for setting [Server.isBusy] to false
|
||||
_setServerState(s, ServerConn.finished);
|
||||
// reset try times only after prepared successfully
|
||||
TryLimiter.reset(sid);
|
||||
}
|
||||
}
|
||||
278
lib/data/provider/server/all.dart
Normal file
278
lib/data/provider/server/all.dart
Normal file
@@ -0,0 +1,278 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:fl_lib/fl_lib.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import 'package:server_box/core/sync.dart';
|
||||
import 'package:server_box/data/model/server/server.dart';
|
||||
import 'package:server_box/data/model/server/server_private_info.dart';
|
||||
import 'package:server_box/data/model/server/try_limiter.dart';
|
||||
import 'package:server_box/data/provider/server/single.dart';
|
||||
import 'package:server_box/data/res/store.dart';
|
||||
import 'package:server_box/data/ssh/session_manager.dart';
|
||||
|
||||
part 'all.freezed.dart';
|
||||
part 'all.g.dart';
|
||||
|
||||
@freezed
|
||||
abstract class ServersState with _$ServersState {
|
||||
const factory ServersState({
|
||||
@Default({}) Map<String, Spi> servers,
|
||||
@Default([]) List<String> serverOrder,
|
||||
@Default(<String>{}) Set<String> tags,
|
||||
@Default(<String>{}) Set<String> manualDisconnectedIds,
|
||||
Timer? autoRefreshTimer,
|
||||
}) = _ServersState;
|
||||
}
|
||||
|
||||
@Riverpod(keepAlive: true)
|
||||
class ServersNotifier extends _$ServersNotifier {
|
||||
@override
|
||||
ServersState build() {
|
||||
return _load();
|
||||
}
|
||||
|
||||
Future<void> reload() async {
|
||||
final newState = _load();
|
||||
if (newState == state) return;
|
||||
state = newState;
|
||||
await refresh();
|
||||
}
|
||||
|
||||
ServersState _load() {
|
||||
final spis = Stores.server.fetch();
|
||||
final newServers = <String, Spi>{};
|
||||
final newServerOrder = <String>[];
|
||||
|
||||
for (final spi in spis) {
|
||||
newServers[spi.id] = spi;
|
||||
}
|
||||
|
||||
final serverOrder_ = Stores.setting.serverOrder.fetch();
|
||||
if (serverOrder_.isNotEmpty) {
|
||||
spis.reorder(order: serverOrder_, finder: (n, id) => n.id == id);
|
||||
newServerOrder.addAll(spis.map((e) => e.id));
|
||||
} else {
|
||||
newServerOrder.addAll(newServers.keys);
|
||||
}
|
||||
|
||||
// Must use [equals] to compare [Order] here.
|
||||
if (!newServerOrder.equals(serverOrder_)) {
|
||||
Stores.setting.serverOrder.put(newServerOrder);
|
||||
}
|
||||
|
||||
final newTags = _calculateTags(newServers);
|
||||
|
||||
return stateOrNull?.copyWith(servers: newServers, serverOrder: newServerOrder, tags: newTags) ??
|
||||
ServersState(servers: newServers, serverOrder: newServerOrder, tags: newTags);
|
||||
}
|
||||
|
||||
Set<String> _calculateTags(Map<String, Spi> servers) {
|
||||
final tags = <String>{};
|
||||
for (final spi in servers.values) {
|
||||
final spiTags = spi.tags;
|
||||
if (spiTags == null) continue;
|
||||
for (final t in spiTags) {
|
||||
tags.add(t);
|
||||
}
|
||||
}
|
||||
return tags;
|
||||
}
|
||||
|
||||
/// Get a [Spi] by [spi] or [id].
|
||||
///
|
||||
/// Priority: [spi] > [id]
|
||||
Spi? pick({Spi? spi, String? id}) {
|
||||
if (spi != null) {
|
||||
return state.servers[spi.id];
|
||||
}
|
||||
if (id != null) {
|
||||
return state.servers[id];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// if [spi] is specificed then only refresh this server
|
||||
/// [onlyFailed] only refresh failed servers
|
||||
Future<void> refresh({Spi? spi, bool onlyFailed = false}) async {
|
||||
if (spi != null) {
|
||||
final newManualDisconnected = Set<String>.from(state.manualDisconnectedIds)..remove(spi.id);
|
||||
state = state.copyWith(manualDisconnectedIds: newManualDisconnected);
|
||||
final serverNotifier = ref.read(serverNotifierProvider(spi.id).notifier);
|
||||
await serverNotifier.refresh();
|
||||
return;
|
||||
}
|
||||
|
||||
await Future.wait(
|
||||
state.servers.entries.map((entry) async {
|
||||
final serverId = entry.key;
|
||||
final spi = entry.value;
|
||||
|
||||
if (onlyFailed) {
|
||||
final serverState = ref.read(serverNotifierProvider(serverId));
|
||||
if (serverState.conn != ServerConn.failed) return;
|
||||
TryLimiter.reset(serverId);
|
||||
}
|
||||
|
||||
if (state.manualDisconnectedIds.contains(serverId)) return;
|
||||
|
||||
final serverState = ref.read(serverNotifierProvider(serverId));
|
||||
if (serverState.conn == ServerConn.disconnected && !spi.autoConnect) {
|
||||
return;
|
||||
}
|
||||
|
||||
final serverNotifier = ref.read(serverNotifierProvider(serverId).notifier);
|
||||
await serverNotifier.refresh();
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> startAutoRefresh() async {
|
||||
var duration = Stores.setting.serverStatusUpdateInterval.fetch();
|
||||
stopAutoRefresh();
|
||||
if (duration == 0) return;
|
||||
if (duration < 0 || duration > 10 || duration == 1) {
|
||||
duration = 3;
|
||||
Loggers.app.warning('Invalid duration: $duration, use default 3');
|
||||
}
|
||||
final timer = Timer.periodic(Duration(seconds: duration), (_) async {
|
||||
await refresh();
|
||||
});
|
||||
state = state.copyWith(autoRefreshTimer: timer);
|
||||
}
|
||||
|
||||
void stopAutoRefresh() {
|
||||
final timer = state.autoRefreshTimer;
|
||||
if (timer != null) {
|
||||
timer.cancel();
|
||||
state = state.copyWith(autoRefreshTimer: null);
|
||||
}
|
||||
}
|
||||
|
||||
bool get isAutoRefreshOn => state.autoRefreshTimer != null;
|
||||
|
||||
void setDisconnected() {
|
||||
for (final serverId in state.servers.keys) {
|
||||
final serverNotifier = ref.read(serverNotifierProvider(serverId).notifier);
|
||||
serverNotifier.updateConnection(ServerConn.disconnected);
|
||||
|
||||
// Update SSH session status to disconnected
|
||||
final sessionId = 'ssh_$serverId';
|
||||
TermSessionManager.updateStatus(sessionId, TermSessionStatus.disconnected);
|
||||
}
|
||||
//TryLimiter.clear();
|
||||
}
|
||||
|
||||
void closeServer({String? id}) {
|
||||
if (id == null) {
|
||||
for (final serverId in state.servers.keys) {
|
||||
closeOneServer(serverId);
|
||||
}
|
||||
return;
|
||||
}
|
||||
closeOneServer(id);
|
||||
}
|
||||
|
||||
void closeOneServer(String id) {
|
||||
final spi = state.servers[id];
|
||||
if (spi == null) {
|
||||
Loggers.app.warning('Server with id $id not found');
|
||||
return;
|
||||
}
|
||||
|
||||
final serverNotifier = ref.read(serverNotifierProvider(id).notifier);
|
||||
serverNotifier.closeConnection();
|
||||
|
||||
final newManualDisconnected = Set<String>.from(state.manualDisconnectedIds)..add(id);
|
||||
state = state.copyWith(manualDisconnectedIds: newManualDisconnected);
|
||||
|
||||
// Remove SSH session when server is manually closed
|
||||
final sessionId = 'ssh_$id';
|
||||
TermSessionManager.remove(sessionId);
|
||||
}
|
||||
|
||||
void addServer(Spi spi) {
|
||||
final newServers = Map<String, Spi>.from(state.servers);
|
||||
newServers[spi.id] = spi;
|
||||
|
||||
final newOrder = List<String>.from(state.serverOrder)..add(spi.id);
|
||||
final newTags = _calculateTags(newServers);
|
||||
|
||||
state = state.copyWith(servers: newServers, serverOrder: newOrder, tags: newTags);
|
||||
|
||||
Stores.server.put(spi);
|
||||
Stores.setting.serverOrder.put(newOrder);
|
||||
refresh(spi: spi);
|
||||
bakSync.sync(milliDelay: 1000);
|
||||
}
|
||||
|
||||
void delServer(String id) {
|
||||
final newServers = Map<String, Spi>.from(state.servers);
|
||||
newServers.remove(id);
|
||||
|
||||
final newOrder = List<String>.from(state.serverOrder)..remove(id);
|
||||
final newTags = _calculateTags(newServers);
|
||||
|
||||
state = state.copyWith(servers: newServers, serverOrder: newOrder, tags: newTags);
|
||||
|
||||
Stores.setting.serverOrder.put(newOrder);
|
||||
Stores.server.delete(id);
|
||||
|
||||
// Remove SSH session when server is deleted
|
||||
final sessionId = 'ssh_$id';
|
||||
TermSessionManager.remove(sessionId);
|
||||
|
||||
bakSync.sync(milliDelay: 1000);
|
||||
}
|
||||
|
||||
void deleteAll() {
|
||||
// Remove all SSH sessions before clearing servers
|
||||
for (final id in state.servers.keys) {
|
||||
final sessionId = 'ssh_$id';
|
||||
TermSessionManager.remove(sessionId);
|
||||
}
|
||||
|
||||
state = const ServersState();
|
||||
|
||||
Stores.setting.serverOrder.put([]);
|
||||
Stores.server.clear();
|
||||
bakSync.sync(milliDelay: 1000);
|
||||
}
|
||||
|
||||
Future<void> updateServer(Spi old, Spi newSpi) async {
|
||||
if (old != newSpi) {
|
||||
Stores.server.update(old, newSpi);
|
||||
|
||||
final newServers = Map<String, Spi>.from(state.servers);
|
||||
final newOrder = List<String>.from(state.serverOrder);
|
||||
|
||||
if (newSpi.id != old.id) {
|
||||
newServers[newSpi.id] = newSpi;
|
||||
newServers.remove(old.id);
|
||||
newOrder.update(old.id, newSpi.id);
|
||||
Stores.setting.serverOrder.put(newOrder);
|
||||
|
||||
// Update SSH session ID when server ID changes
|
||||
final oldSessionId = 'ssh_${old.id}';
|
||||
TermSessionManager.remove(oldSessionId);
|
||||
// Session will be re-added when reconnecting if necessary
|
||||
} else {
|
||||
newServers[old.id] = newSpi;
|
||||
// Update SPI in the corresponding IndividualServerNotifier
|
||||
final serverNotifier = ref.read(serverNotifierProvider(old.id).notifier);
|
||||
serverNotifier.updateSpi(newSpi);
|
||||
}
|
||||
|
||||
final newTags = _calculateTags(newServers);
|
||||
state = state.copyWith(servers: newServers, serverOrder: newOrder, tags: newTags);
|
||||
|
||||
// Only reconnect if neccessary
|
||||
if (newSpi.shouldReconnect(old)) {
|
||||
// Use [newSpi.id] instead of [old.id] because [old.id] may be changed
|
||||
TryLimiter.reset(newSpi.id);
|
||||
refresh(spi: newSpi);
|
||||
}
|
||||
}
|
||||
bakSync.sync(milliDelay: 1000);
|
||||
}
|
||||
}
|
||||
307
lib/data/provider/server/all.freezed.dart
Normal file
307
lib/data/provider/server/all.freezed.dart
Normal file
@@ -0,0 +1,307 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'all.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$ServersState {
|
||||
|
||||
Map<String, Spi> get servers; List<String> get serverOrder; Set<String> get tags; Set<String> get manualDisconnectedIds; Timer? get autoRefreshTimer;
|
||||
/// Create a copy of ServersState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$ServersStateCopyWith<ServersState> get copyWith => _$ServersStateCopyWithImpl<ServersState>(this as ServersState, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is ServersState&&const DeepCollectionEquality().equals(other.servers, servers)&&const DeepCollectionEquality().equals(other.serverOrder, serverOrder)&&const DeepCollectionEquality().equals(other.tags, tags)&&const DeepCollectionEquality().equals(other.manualDisconnectedIds, manualDisconnectedIds)&&(identical(other.autoRefreshTimer, autoRefreshTimer) || other.autoRefreshTimer == autoRefreshTimer));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(servers),const DeepCollectionEquality().hash(serverOrder),const DeepCollectionEquality().hash(tags),const DeepCollectionEquality().hash(manualDisconnectedIds),autoRefreshTimer);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ServersState(servers: $servers, serverOrder: $serverOrder, tags: $tags, manualDisconnectedIds: $manualDisconnectedIds, autoRefreshTimer: $autoRefreshTimer)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $ServersStateCopyWith<$Res> {
|
||||
factory $ServersStateCopyWith(ServersState value, $Res Function(ServersState) _then) = _$ServersStateCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
Map<String, Spi> servers, List<String> serverOrder, Set<String> tags, Set<String> manualDisconnectedIds, Timer? autoRefreshTimer
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$ServersStateCopyWithImpl<$Res>
|
||||
implements $ServersStateCopyWith<$Res> {
|
||||
_$ServersStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final ServersState _self;
|
||||
final $Res Function(ServersState) _then;
|
||||
|
||||
/// Create a copy of ServersState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? servers = null,Object? serverOrder = null,Object? tags = null,Object? manualDisconnectedIds = null,Object? autoRefreshTimer = freezed,}) {
|
||||
return _then(_self.copyWith(
|
||||
servers: null == servers ? _self.servers : servers // ignore: cast_nullable_to_non_nullable
|
||||
as Map<String, Spi>,serverOrder: null == serverOrder ? _self.serverOrder : serverOrder // ignore: cast_nullable_to_non_nullable
|
||||
as List<String>,tags: null == tags ? _self.tags : tags // ignore: cast_nullable_to_non_nullable
|
||||
as Set<String>,manualDisconnectedIds: null == manualDisconnectedIds ? _self.manualDisconnectedIds : manualDisconnectedIds // ignore: cast_nullable_to_non_nullable
|
||||
as Set<String>,autoRefreshTimer: freezed == autoRefreshTimer ? _self.autoRefreshTimer : autoRefreshTimer // ignore: cast_nullable_to_non_nullable
|
||||
as Timer?,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [ServersState].
|
||||
extension ServersStatePatterns on ServersState {
|
||||
/// A variant of `map` that fallback to returning `orElse`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _ServersState value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _ServersState() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// Callbacks receives the raw object, upcasted.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case final Subclass2 value:
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _ServersState value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _ServersState():
|
||||
return $default(_that);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `map` that fallback to returning `null`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _ServersState value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _ServersState() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( Map<String, Spi> servers, List<String> serverOrder, Set<String> tags, Set<String> manualDisconnectedIds, Timer? autoRefreshTimer)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ServersState() when $default != null:
|
||||
return $default(_that.servers,_that.serverOrder,_that.tags,_that.manualDisconnectedIds,_that.autoRefreshTimer);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( Map<String, Spi> servers, List<String> serverOrder, Set<String> tags, Set<String> manualDisconnectedIds, Timer? autoRefreshTimer) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ServersState():
|
||||
return $default(_that.servers,_that.serverOrder,_that.tags,_that.manualDisconnectedIds,_that.autoRefreshTimer);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( Map<String, Spi> servers, List<String> serverOrder, Set<String> tags, Set<String> manualDisconnectedIds, Timer? autoRefreshTimer)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ServersState() when $default != null:
|
||||
return $default(_that.servers,_that.serverOrder,_that.tags,_that.manualDisconnectedIds,_that.autoRefreshTimer);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _ServersState implements ServersState {
|
||||
const _ServersState({final Map<String, Spi> servers = const {}, final List<String> serverOrder = const [], final Set<String> tags = const <String>{}, final Set<String> manualDisconnectedIds = const <String>{}, this.autoRefreshTimer}): _servers = servers,_serverOrder = serverOrder,_tags = tags,_manualDisconnectedIds = manualDisconnectedIds;
|
||||
|
||||
|
||||
final Map<String, Spi> _servers;
|
||||
@override@JsonKey() Map<String, Spi> get servers {
|
||||
if (_servers is EqualUnmodifiableMapView) return _servers;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableMapView(_servers);
|
||||
}
|
||||
|
||||
final List<String> _serverOrder;
|
||||
@override@JsonKey() List<String> get serverOrder {
|
||||
if (_serverOrder is EqualUnmodifiableListView) return _serverOrder;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_serverOrder);
|
||||
}
|
||||
|
||||
final Set<String> _tags;
|
||||
@override@JsonKey() Set<String> get tags {
|
||||
if (_tags is EqualUnmodifiableSetView) return _tags;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableSetView(_tags);
|
||||
}
|
||||
|
||||
final Set<String> _manualDisconnectedIds;
|
||||
@override@JsonKey() Set<String> get manualDisconnectedIds {
|
||||
if (_manualDisconnectedIds is EqualUnmodifiableSetView) return _manualDisconnectedIds;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableSetView(_manualDisconnectedIds);
|
||||
}
|
||||
|
||||
@override final Timer? autoRefreshTimer;
|
||||
|
||||
/// Create a copy of ServersState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$ServersStateCopyWith<_ServersState> get copyWith => __$ServersStateCopyWithImpl<_ServersState>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ServersState&&const DeepCollectionEquality().equals(other._servers, _servers)&&const DeepCollectionEquality().equals(other._serverOrder, _serverOrder)&&const DeepCollectionEquality().equals(other._tags, _tags)&&const DeepCollectionEquality().equals(other._manualDisconnectedIds, _manualDisconnectedIds)&&(identical(other.autoRefreshTimer, autoRefreshTimer) || other.autoRefreshTimer == autoRefreshTimer));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(_servers),const DeepCollectionEquality().hash(_serverOrder),const DeepCollectionEquality().hash(_tags),const DeepCollectionEquality().hash(_manualDisconnectedIds),autoRefreshTimer);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ServersState(servers: $servers, serverOrder: $serverOrder, tags: $tags, manualDisconnectedIds: $manualDisconnectedIds, autoRefreshTimer: $autoRefreshTimer)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$ServersStateCopyWith<$Res> implements $ServersStateCopyWith<$Res> {
|
||||
factory _$ServersStateCopyWith(_ServersState value, $Res Function(_ServersState) _then) = __$ServersStateCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
Map<String, Spi> servers, List<String> serverOrder, Set<String> tags, Set<String> manualDisconnectedIds, Timer? autoRefreshTimer
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$ServersStateCopyWithImpl<$Res>
|
||||
implements _$ServersStateCopyWith<$Res> {
|
||||
__$ServersStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _ServersState _self;
|
||||
final $Res Function(_ServersState) _then;
|
||||
|
||||
/// Create a copy of ServersState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? servers = null,Object? serverOrder = null,Object? tags = null,Object? manualDisconnectedIds = null,Object? autoRefreshTimer = freezed,}) {
|
||||
return _then(_ServersState(
|
||||
servers: null == servers ? _self._servers : servers // ignore: cast_nullable_to_non_nullable
|
||||
as Map<String, Spi>,serverOrder: null == serverOrder ? _self._serverOrder : serverOrder // ignore: cast_nullable_to_non_nullable
|
||||
as List<String>,tags: null == tags ? _self._tags : tags // ignore: cast_nullable_to_non_nullable
|
||||
as Set<String>,manualDisconnectedIds: null == manualDisconnectedIds ? _self._manualDisconnectedIds : manualDisconnectedIds // ignore: cast_nullable_to_non_nullable
|
||||
as Set<String>,autoRefreshTimer: freezed == autoRefreshTimer ? _self.autoRefreshTimer : autoRefreshTimer // ignore: cast_nullable_to_non_nullable
|
||||
as Timer?,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
26
lib/data/provider/server/all.g.dart
Normal file
26
lib/data/provider/server/all.g.dart
Normal file
@@ -0,0 +1,26 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'all.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$serversNotifierHash() => r'2b29ad3027a203c7a20bfd0142d384a503cbbcaa';
|
||||
|
||||
/// See also [ServersNotifier].
|
||||
@ProviderFor(ServersNotifier)
|
||||
final serversNotifierProvider =
|
||||
NotifierProvider<ServersNotifier, ServersState>.internal(
|
||||
ServersNotifier.new,
|
||||
name: r'serversNotifierProvider',
|
||||
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$serversNotifierHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
typedef _$ServersNotifier = Notifier<ServersState>;
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package
|
||||
394
lib/data/provider/server/single.dart
Normal file
394
lib/data/provider/server/single.dart
Normal file
@@ -0,0 +1,394 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:computer/computer.dart';
|
||||
import 'package:dartssh2/dartssh2.dart';
|
||||
import 'package:fl_lib/fl_lib.dart';
|
||||
import 'package:flutter_gbk2utf8/flutter_gbk2utf8.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import 'package:server_box/core/extension/ssh_client.dart';
|
||||
import 'package:server_box/core/utils/server.dart';
|
||||
import 'package:server_box/core/utils/ssh_auth.dart';
|
||||
import 'package:server_box/data/helper/system_detector.dart';
|
||||
import 'package:server_box/data/model/app/error.dart';
|
||||
import 'package:server_box/data/model/app/scripts/script_consts.dart';
|
||||
import 'package:server_box/data/model/app/scripts/shell_func.dart';
|
||||
import 'package:server_box/data/model/server/connection_stat.dart';
|
||||
import 'package:server_box/data/model/server/server.dart';
|
||||
import 'package:server_box/data/model/server/server_private_info.dart';
|
||||
import 'package:server_box/data/model/server/server_status_update_req.dart';
|
||||
import 'package:server_box/data/model/server/system.dart';
|
||||
import 'package:server_box/data/model/server/try_limiter.dart';
|
||||
import 'package:server_box/data/provider/server/all.dart';
|
||||
import 'package:server_box/data/res/status.dart';
|
||||
import 'package:server_box/data/res/store.dart';
|
||||
import 'package:server_box/data/ssh/session_manager.dart';
|
||||
|
||||
part 'single.g.dart';
|
||||
part 'single.freezed.dart';
|
||||
|
||||
// Individual server state, including connection and status information
|
||||
@freezed
|
||||
abstract class ServerState with _$ServerState {
|
||||
const factory ServerState({
|
||||
required Spi spi,
|
||||
required ServerStatus status,
|
||||
@Default(ServerConn.disconnected) ServerConn conn,
|
||||
SSHClient? client,
|
||||
Future<void>? updateFuture,
|
||||
}) = _ServerState;
|
||||
}
|
||||
|
||||
// Individual server state management
|
||||
@Riverpod(keepAlive: true)
|
||||
class ServerNotifier extends _$ServerNotifier {
|
||||
@override
|
||||
ServerState build(String serverId) {
|
||||
final serverNotifier = ref.read(serversNotifierProvider);
|
||||
final spi = serverNotifier.servers[serverId];
|
||||
if (spi == null) {
|
||||
throw StateError('Server $serverId not found');
|
||||
}
|
||||
|
||||
return ServerState(spi: spi, status: InitStatus.status);
|
||||
}
|
||||
|
||||
// Update connection status
|
||||
void updateConnection(ServerConn conn) {
|
||||
state = state.copyWith(conn: conn);
|
||||
}
|
||||
|
||||
// Update server status
|
||||
void updateStatus(ServerStatus status) {
|
||||
state = state.copyWith(status: status);
|
||||
}
|
||||
|
||||
// Update SSH client
|
||||
void updateClient(SSHClient? client) {
|
||||
state = state.copyWith(client: client);
|
||||
}
|
||||
|
||||
// Update SPI configuration
|
||||
void updateSpi(Spi spi) {
|
||||
state = state.copyWith(spi: spi);
|
||||
}
|
||||
|
||||
// Close connection
|
||||
void closeConnection() {
|
||||
final client = state.client;
|
||||
client?.close();
|
||||
state = state.copyWith(client: null, conn: ServerConn.disconnected);
|
||||
}
|
||||
|
||||
// Refresh server status
|
||||
Future<void> refresh() async {
|
||||
if (state.updateFuture != null) {
|
||||
await state.updateFuture;
|
||||
return;
|
||||
}
|
||||
|
||||
final updateFuture = _updateServer();
|
||||
state = state.copyWith(updateFuture: updateFuture);
|
||||
|
||||
try {
|
||||
await updateFuture;
|
||||
} finally {
|
||||
state = state.copyWith(updateFuture: null);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _updateServer() async {
|
||||
await _getData();
|
||||
}
|
||||
|
||||
Future<void> _getData() async {
|
||||
final spi = state.spi;
|
||||
final sid = spi.id;
|
||||
|
||||
if (!TryLimiter.canTry(sid)) {
|
||||
if (state.conn != ServerConn.failed) {
|
||||
updateConnection(ServerConn.failed);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
final newStatus = state.status..err = null; // Clear previous error
|
||||
updateStatus(newStatus);
|
||||
|
||||
if (state.conn < ServerConn.connecting || (state.client?.isClosed ?? true)) {
|
||||
updateConnection(ServerConn.connecting);
|
||||
|
||||
// Wake on LAN
|
||||
final wol = spi.wolCfg;
|
||||
if (wol != null) {
|
||||
try {
|
||||
await wol.wake();
|
||||
} catch (e) {
|
||||
Loggers.app.warning('Wake on lan failed', e);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
final time1 = DateTime.now();
|
||||
final client = await genClient(
|
||||
spi,
|
||||
timeout: Duration(seconds: Stores.setting.timeout.fetch()),
|
||||
onKeyboardInteractive: (_) => KeybordInteractive.defaultHandle(spi),
|
||||
);
|
||||
updateClient(client);
|
||||
|
||||
final time2 = DateTime.now();
|
||||
final spentTime = time2.difference(time1).inMilliseconds;
|
||||
if (spi.jumpId == null) {
|
||||
Loggers.app.info('Connected to ${spi.name} in $spentTime ms.');
|
||||
} else {
|
||||
Loggers.app.info('Jump to ${spi.name} in $spentTime ms.');
|
||||
}
|
||||
|
||||
// Record successful connection
|
||||
Stores.connectionStats.recordConnection(ConnectionStat(
|
||||
serverId: spi.id,
|
||||
serverName: spi.name,
|
||||
timestamp: time1,
|
||||
result: ConnectionResult.success,
|
||||
durationMs: spentTime,
|
||||
));
|
||||
|
||||
final sessionId = 'ssh_${spi.id}';
|
||||
TermSessionManager.add(
|
||||
id: sessionId,
|
||||
spi: spi,
|
||||
startTimeMs: time1.millisecondsSinceEpoch,
|
||||
disconnect: () => ref.read(serversNotifierProvider.notifier).closeOneServer(spi.id),
|
||||
status: TermSessionStatus.connecting,
|
||||
);
|
||||
TermSessionManager.setActive(sessionId, hasTerminal: false);
|
||||
} catch (e) {
|
||||
TryLimiter.inc(sid);
|
||||
|
||||
// Determine connection failure type
|
||||
ConnectionResult failureResult;
|
||||
if (e.toString().contains('timeout') || e.toString().contains('Timeout')) {
|
||||
failureResult = ConnectionResult.timeout;
|
||||
} else if (e.toString().contains('auth') || e.toString().contains('Authentication')) {
|
||||
failureResult = ConnectionResult.authFailed;
|
||||
} else if (e.toString().contains('network') || e.toString().contains('Network')) {
|
||||
failureResult = ConnectionResult.networkError;
|
||||
} else {
|
||||
failureResult = ConnectionResult.unknownError;
|
||||
}
|
||||
|
||||
// Record failed connection
|
||||
Stores.connectionStats.recordConnection(ConnectionStat(
|
||||
serverId: spi.id,
|
||||
serverName: spi.name,
|
||||
timestamp: DateTime.now(),
|
||||
result: failureResult,
|
||||
errorMessage: e.toString(),
|
||||
durationMs: 0,
|
||||
));
|
||||
|
||||
final newStatus = state.status..err = SSHErr(type: SSHErrType.connect, message: e.toString());
|
||||
updateStatus(newStatus);
|
||||
updateConnection(ServerConn.failed);
|
||||
|
||||
// Remove SSH session when connection fails
|
||||
final sessionId = 'ssh_${spi.id}';
|
||||
TermSessionManager.remove(sessionId);
|
||||
|
||||
Loggers.app.warning('Connect to ${spi.name} failed', e);
|
||||
return;
|
||||
}
|
||||
|
||||
updateConnection(ServerConn.connected);
|
||||
|
||||
// Update SSH session status to connected
|
||||
final sessionId = 'ssh_${spi.id}';
|
||||
TermSessionManager.updateStatus(sessionId, TermSessionStatus.connected);
|
||||
|
||||
try {
|
||||
// Detect system type
|
||||
final detectedSystemType = await SystemDetector.detect(state.client!, spi);
|
||||
final newStatus = state.status..system = detectedSystemType;
|
||||
updateStatus(newStatus);
|
||||
|
||||
final (_, writeScriptResult) = await state.client!.exec(
|
||||
(session) async {
|
||||
final scriptRaw = ShellFuncManager.allScript(
|
||||
spi.custom?.cmds,
|
||||
systemType: detectedSystemType,
|
||||
disabledCmdTypes: spi.disabledCmdTypes,
|
||||
).uint8List;
|
||||
session.stdin.add(scriptRaw);
|
||||
session.stdin.close();
|
||||
},
|
||||
entry: ShellFuncManager.getInstallShellCmd(
|
||||
spi.id,
|
||||
systemType: detectedSystemType,
|
||||
customDir: spi.custom?.scriptDir,
|
||||
),
|
||||
);
|
||||
if (writeScriptResult.isNotEmpty && detectedSystemType != SystemType.windows) {
|
||||
ShellFuncManager.switchScriptDir(spi.id, systemType: detectedSystemType);
|
||||
throw writeScriptResult;
|
||||
}
|
||||
} on SSHAuthAbortError catch (e) {
|
||||
TryLimiter.inc(sid);
|
||||
final err = SSHErr(type: SSHErrType.auth, message: e.toString());
|
||||
final newStatus = state.status..err = err;
|
||||
updateStatus(newStatus);
|
||||
Loggers.app.warning(err);
|
||||
updateConnection(ServerConn.failed);
|
||||
|
||||
final sessionId = 'ssh_${spi.id}';
|
||||
TermSessionManager.updateStatus(sessionId, TermSessionStatus.disconnected);
|
||||
return;
|
||||
} on SSHAuthFailError catch (e) {
|
||||
TryLimiter.inc(sid);
|
||||
final err = SSHErr(type: SSHErrType.auth, message: e.toString());
|
||||
final newStatus = state.status..err = err;
|
||||
updateStatus(newStatus);
|
||||
Loggers.app.warning(err);
|
||||
updateConnection(ServerConn.failed);
|
||||
|
||||
final sessionId = 'ssh_${spi.id}';
|
||||
TermSessionManager.updateStatus(sessionId, TermSessionStatus.disconnected);
|
||||
return;
|
||||
} catch (e) {
|
||||
final err = SSHErr(type: SSHErrType.writeScript, message: e.toString());
|
||||
final newStatus = state.status..err = err;
|
||||
updateStatus(newStatus);
|
||||
Loggers.app.warning(err);
|
||||
updateConnection(ServerConn.failed);
|
||||
|
||||
final sessionId = 'ssh_${spi.id}';
|
||||
TermSessionManager.updateStatus(sessionId, TermSessionStatus.disconnected);
|
||||
}
|
||||
}
|
||||
|
||||
if (state.conn == ServerConn.connecting) return;
|
||||
|
||||
// Keep finished status to prevent UI from refreshing to loading state
|
||||
if (state.conn != ServerConn.finished) {
|
||||
updateConnection(ServerConn.loading);
|
||||
}
|
||||
|
||||
List<String>? segments;
|
||||
String? raw;
|
||||
|
||||
try {
|
||||
final execResult = await state.client?.run(
|
||||
ShellFunc.status.exec(spi.id, systemType: state.status.system, customDir: spi.custom?.scriptDir),
|
||||
);
|
||||
if (execResult != null) {
|
||||
String? rawStr;
|
||||
bool needGbk = false;
|
||||
try {
|
||||
rawStr = utf8.decode(execResult, allowMalformed: true);
|
||||
// If there are unparseable characters, try fallback to GBK decoding
|
||||
if (rawStr.contains('<EFBFBD>')) {
|
||||
Loggers.app.warning('UTF8 decoding failed, use GBK decoding');
|
||||
needGbk = true;
|
||||
}
|
||||
} catch (e) {
|
||||
Loggers.app.warning('UTF8 decoding failed, use GBK decoding', e);
|
||||
needGbk = true;
|
||||
}
|
||||
if (needGbk) {
|
||||
try {
|
||||
rawStr = gbk.decode(execResult);
|
||||
} catch (e2) {
|
||||
Loggers.app.warning('GBK decoding failed', e2);
|
||||
rawStr = null;
|
||||
}
|
||||
}
|
||||
if (rawStr == null) {
|
||||
Loggers.app.warning('Decoding failed, execResult: $execResult');
|
||||
}
|
||||
raw = rawStr;
|
||||
} else {
|
||||
raw = execResult.toString();
|
||||
}
|
||||
|
||||
if (raw == null || raw.isEmpty) {
|
||||
TryLimiter.inc(sid);
|
||||
final newStatus = state.status
|
||||
..err = SSHErr(type: SSHErrType.segements, message: 'decode or split failed, raw:\n$raw');
|
||||
updateStatus(newStatus);
|
||||
updateConnection(ServerConn.failed);
|
||||
|
||||
final sessionId = 'ssh_${spi.id}';
|
||||
TermSessionManager.updateStatus(sessionId, TermSessionStatus.disconnected);
|
||||
return;
|
||||
}
|
||||
|
||||
segments = raw.split(ScriptConstants.separator).map((e) => e.trim()).toList();
|
||||
if (raw.isEmpty || segments.isEmpty) {
|
||||
if (Stores.setting.keepStatusWhenErr.fetch()) {
|
||||
// Keep previous server status when error occurs
|
||||
if (state.conn != ServerConn.failed && state.status.more.isNotEmpty) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
TryLimiter.inc(sid);
|
||||
final newStatus = state.status
|
||||
..err = SSHErr(type: SSHErrType.segements, message: 'Seperate segments failed, raw:\n$raw');
|
||||
updateStatus(newStatus);
|
||||
updateConnection(ServerConn.failed);
|
||||
|
||||
final sessionId = 'ssh_${spi.id}';
|
||||
TermSessionManager.updateStatus(sessionId, TermSessionStatus.disconnected);
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
TryLimiter.inc(sid);
|
||||
final newStatus = state.status..err = SSHErr(type: SSHErrType.getStatus, message: e.toString());
|
||||
updateStatus(newStatus);
|
||||
updateConnection(ServerConn.failed);
|
||||
Loggers.app.warning('Get status from ${spi.name} failed', e);
|
||||
|
||||
final sessionId = 'ssh_${spi.id}';
|
||||
TermSessionManager.updateStatus(sessionId, TermSessionStatus.disconnected);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// Parse script output into command-specific mappings
|
||||
final parsedOutput = ScriptConstants.parseScriptOutput(raw);
|
||||
|
||||
final req = ServerStatusUpdateReq(
|
||||
ss: state.status,
|
||||
parsedOutput: parsedOutput,
|
||||
system: state.status.system,
|
||||
customCmds: spi.custom?.cmds ?? {},
|
||||
);
|
||||
final newStatus = await Computer.shared.start(getStatus, req, taskName: 'StatusUpdateReq<${spi.id}>');
|
||||
updateStatus(newStatus);
|
||||
} catch (e, trace) {
|
||||
TryLimiter.inc(sid);
|
||||
final newStatus = state.status
|
||||
..err = SSHErr(type: SSHErrType.getStatus, message: 'Parse failed: $e\n\n$raw');
|
||||
updateStatus(newStatus);
|
||||
updateConnection(ServerConn.failed);
|
||||
Loggers.app.warning('Server status', e, trace);
|
||||
|
||||
final sessionId = 'ssh_${spi.id}';
|
||||
TermSessionManager.updateStatus(sessionId, TermSessionStatus.disconnected);
|
||||
return;
|
||||
}
|
||||
|
||||
// Set Server.isBusy to false each time this method is called
|
||||
updateConnection(ServerConn.finished);
|
||||
// Reset retry count only after successful preparation
|
||||
TryLimiter.reset(sid);
|
||||
}
|
||||
}
|
||||
|
||||
extension IndividualServerStateExtension on ServerState {
|
||||
bool get needGenClient => conn < ServerConn.connecting;
|
||||
|
||||
bool get canViewDetails => conn == ServerConn.finished;
|
||||
|
||||
String get id => spi.id;
|
||||
}
|
||||
301
lib/data/provider/server/single.freezed.dart
Normal file
301
lib/data/provider/server/single.freezed.dart
Normal file
@@ -0,0 +1,301 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'single.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$ServerState {
|
||||
|
||||
Spi get spi; ServerStatus get status; ServerConn get conn; SSHClient? get client; Future<void>? get updateFuture;
|
||||
/// Create a copy of ServerState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$ServerStateCopyWith<ServerState> get copyWith => _$ServerStateCopyWithImpl<ServerState>(this as ServerState, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is ServerState&&(identical(other.spi, spi) || other.spi == spi)&&(identical(other.status, status) || other.status == status)&&(identical(other.conn, conn) || other.conn == conn)&&(identical(other.client, client) || other.client == client)&&(identical(other.updateFuture, updateFuture) || other.updateFuture == updateFuture));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,spi,status,conn,client,updateFuture);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ServerState(spi: $spi, status: $status, conn: $conn, client: $client, updateFuture: $updateFuture)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $ServerStateCopyWith<$Res> {
|
||||
factory $ServerStateCopyWith(ServerState value, $Res Function(ServerState) _then) = _$ServerStateCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
Spi spi, ServerStatus status, ServerConn conn, SSHClient? client, Future<void>? updateFuture
|
||||
});
|
||||
|
||||
|
||||
$SpiCopyWith<$Res> get spi;
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$ServerStateCopyWithImpl<$Res>
|
||||
implements $ServerStateCopyWith<$Res> {
|
||||
_$ServerStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final ServerState _self;
|
||||
final $Res Function(ServerState) _then;
|
||||
|
||||
/// Create a copy of ServerState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? spi = null,Object? status = null,Object? conn = null,Object? client = freezed,Object? updateFuture = freezed,}) {
|
||||
return _then(_self.copyWith(
|
||||
spi: null == spi ? _self.spi : spi // ignore: cast_nullable_to_non_nullable
|
||||
as Spi,status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
|
||||
as ServerStatus,conn: null == conn ? _self.conn : conn // ignore: cast_nullable_to_non_nullable
|
||||
as ServerConn,client: freezed == client ? _self.client : client // ignore: cast_nullable_to_non_nullable
|
||||
as SSHClient?,updateFuture: freezed == updateFuture ? _self.updateFuture : updateFuture // ignore: cast_nullable_to_non_nullable
|
||||
as Future<void>?,
|
||||
));
|
||||
}
|
||||
/// Create a copy of ServerState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$SpiCopyWith<$Res> get spi {
|
||||
|
||||
return $SpiCopyWith<$Res>(_self.spi, (value) {
|
||||
return _then(_self.copyWith(spi: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [ServerState].
|
||||
extension ServerStatePatterns on ServerState {
|
||||
/// A variant of `map` that fallback to returning `orElse`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _ServerState value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _ServerState() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// Callbacks receives the raw object, upcasted.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case final Subclass2 value:
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _ServerState value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _ServerState():
|
||||
return $default(_that);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `map` that fallback to returning `null`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _ServerState value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _ServerState() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( Spi spi, ServerStatus status, ServerConn conn, SSHClient? client, Future<void>? updateFuture)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ServerState() when $default != null:
|
||||
return $default(_that.spi,_that.status,_that.conn,_that.client,_that.updateFuture);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( Spi spi, ServerStatus status, ServerConn conn, SSHClient? client, Future<void>? updateFuture) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ServerState():
|
||||
return $default(_that.spi,_that.status,_that.conn,_that.client,_that.updateFuture);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( Spi spi, ServerStatus status, ServerConn conn, SSHClient? client, Future<void>? updateFuture)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ServerState() when $default != null:
|
||||
return $default(_that.spi,_that.status,_that.conn,_that.client,_that.updateFuture);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _ServerState implements ServerState {
|
||||
const _ServerState({required this.spi, required this.status, this.conn = ServerConn.disconnected, this.client, this.updateFuture});
|
||||
|
||||
|
||||
@override final Spi spi;
|
||||
@override final ServerStatus status;
|
||||
@override@JsonKey() final ServerConn conn;
|
||||
@override final SSHClient? client;
|
||||
@override final Future<void>? updateFuture;
|
||||
|
||||
/// Create a copy of ServerState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$ServerStateCopyWith<_ServerState> get copyWith => __$ServerStateCopyWithImpl<_ServerState>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ServerState&&(identical(other.spi, spi) || other.spi == spi)&&(identical(other.status, status) || other.status == status)&&(identical(other.conn, conn) || other.conn == conn)&&(identical(other.client, client) || other.client == client)&&(identical(other.updateFuture, updateFuture) || other.updateFuture == updateFuture));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,spi,status,conn,client,updateFuture);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ServerState(spi: $spi, status: $status, conn: $conn, client: $client, updateFuture: $updateFuture)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$ServerStateCopyWith<$Res> implements $ServerStateCopyWith<$Res> {
|
||||
factory _$ServerStateCopyWith(_ServerState value, $Res Function(_ServerState) _then) = __$ServerStateCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
Spi spi, ServerStatus status, ServerConn conn, SSHClient? client, Future<void>? updateFuture
|
||||
});
|
||||
|
||||
|
||||
@override $SpiCopyWith<$Res> get spi;
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$ServerStateCopyWithImpl<$Res>
|
||||
implements _$ServerStateCopyWith<$Res> {
|
||||
__$ServerStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _ServerState _self;
|
||||
final $Res Function(_ServerState) _then;
|
||||
|
||||
/// Create a copy of ServerState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? spi = null,Object? status = null,Object? conn = null,Object? client = freezed,Object? updateFuture = freezed,}) {
|
||||
return _then(_ServerState(
|
||||
spi: null == spi ? _self.spi : spi // ignore: cast_nullable_to_non_nullable
|
||||
as Spi,status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
|
||||
as ServerStatus,conn: null == conn ? _self.conn : conn // ignore: cast_nullable_to_non_nullable
|
||||
as ServerConn,client: freezed == client ? _self.client : client // ignore: cast_nullable_to_non_nullable
|
||||
as SSHClient?,updateFuture: freezed == updateFuture ? _self.updateFuture : updateFuture // ignore: cast_nullable_to_non_nullable
|
||||
as Future<void>?,
|
||||
));
|
||||
}
|
||||
|
||||
/// Create a copy of ServerState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$SpiCopyWith<$Res> get spi {
|
||||
|
||||
return $SpiCopyWith<$Res>(_self.spi, (value) {
|
||||
return _then(_self.copyWith(spi: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// dart format on
|
||||
163
lib/data/provider/server/single.g.dart
Normal file
163
lib/data/provider/server/single.g.dart
Normal file
@@ -0,0 +1,163 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'single.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$serverNotifierHash() => r'524647748cc3810c17e5c1cd29e360f3936f5014';
|
||||
|
||||
/// Copied from Dart SDK
|
||||
class _SystemHash {
|
||||
_SystemHash._();
|
||||
|
||||
static int combine(int hash, int value) {
|
||||
// ignore: parameter_assignments
|
||||
hash = 0x1fffffff & (hash + value);
|
||||
// ignore: parameter_assignments
|
||||
hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10));
|
||||
return hash ^ (hash >> 6);
|
||||
}
|
||||
|
||||
static int finish(int hash) {
|
||||
// ignore: parameter_assignments
|
||||
hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3));
|
||||
// ignore: parameter_assignments
|
||||
hash = hash ^ (hash >> 11);
|
||||
return 0x1fffffff & (hash + ((0x00003fff & hash) << 15));
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _$ServerNotifier
|
||||
extends BuildlessAutoDisposeNotifier<ServerState> {
|
||||
late final String serverId;
|
||||
|
||||
ServerState build(String serverId);
|
||||
}
|
||||
|
||||
/// See also [ServerNotifier].
|
||||
@ProviderFor(ServerNotifier)
|
||||
const serverNotifierProvider = ServerNotifierFamily();
|
||||
|
||||
/// See also [ServerNotifier].
|
||||
class ServerNotifierFamily extends Family<ServerState> {
|
||||
/// See also [ServerNotifier].
|
||||
const ServerNotifierFamily();
|
||||
|
||||
/// See also [ServerNotifier].
|
||||
ServerNotifierProvider call(String serverId) {
|
||||
return ServerNotifierProvider(serverId);
|
||||
}
|
||||
|
||||
@override
|
||||
ServerNotifierProvider getProviderOverride(
|
||||
covariant ServerNotifierProvider provider,
|
||||
) {
|
||||
return call(provider.serverId);
|
||||
}
|
||||
|
||||
static const Iterable<ProviderOrFamily>? _dependencies = null;
|
||||
|
||||
@override
|
||||
Iterable<ProviderOrFamily>? get dependencies => _dependencies;
|
||||
|
||||
static const Iterable<ProviderOrFamily>? _allTransitiveDependencies = null;
|
||||
|
||||
@override
|
||||
Iterable<ProviderOrFamily>? get allTransitiveDependencies =>
|
||||
_allTransitiveDependencies;
|
||||
|
||||
@override
|
||||
String? get name => r'serverNotifierProvider';
|
||||
}
|
||||
|
||||
/// See also [ServerNotifier].
|
||||
class ServerNotifierProvider
|
||||
extends AutoDisposeNotifierProviderImpl<ServerNotifier, ServerState> {
|
||||
/// See also [ServerNotifier].
|
||||
ServerNotifierProvider(String serverId)
|
||||
: this._internal(
|
||||
() => ServerNotifier()..serverId = serverId,
|
||||
from: serverNotifierProvider,
|
||||
name: r'serverNotifierProvider',
|
||||
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$serverNotifierHash,
|
||||
dependencies: ServerNotifierFamily._dependencies,
|
||||
allTransitiveDependencies:
|
||||
ServerNotifierFamily._allTransitiveDependencies,
|
||||
serverId: serverId,
|
||||
);
|
||||
|
||||
ServerNotifierProvider._internal(
|
||||
super._createNotifier, {
|
||||
required super.name,
|
||||
required super.dependencies,
|
||||
required super.allTransitiveDependencies,
|
||||
required super.debugGetCreateSourceHash,
|
||||
required super.from,
|
||||
required this.serverId,
|
||||
}) : super.internal();
|
||||
|
||||
final String serverId;
|
||||
|
||||
@override
|
||||
ServerState runNotifierBuild(covariant ServerNotifier notifier) {
|
||||
return notifier.build(serverId);
|
||||
}
|
||||
|
||||
@override
|
||||
Override overrideWith(ServerNotifier Function() create) {
|
||||
return ProviderOverride(
|
||||
origin: this,
|
||||
override: ServerNotifierProvider._internal(
|
||||
() => create()..serverId = serverId,
|
||||
from: from,
|
||||
name: null,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
debugGetCreateSourceHash: null,
|
||||
serverId: serverId,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
AutoDisposeNotifierProviderElement<ServerNotifier, ServerState>
|
||||
createElement() {
|
||||
return _ServerNotifierProviderElement(this);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return other is ServerNotifierProvider && other.serverId == serverId;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
var hash = _SystemHash.combine(0, runtimeType.hashCode);
|
||||
hash = _SystemHash.combine(hash, serverId.hashCode);
|
||||
|
||||
return _SystemHash.finish(hash);
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated('Will be removed in 3.0. Use Ref instead')
|
||||
// ignore: unused_element
|
||||
mixin ServerNotifierRef on AutoDisposeNotifierProviderRef<ServerState> {
|
||||
/// The parameter `serverId` of this provider.
|
||||
String get serverId;
|
||||
}
|
||||
|
||||
class _ServerNotifierProviderElement
|
||||
extends AutoDisposeNotifierProviderElement<ServerNotifier, ServerState>
|
||||
with ServerNotifierRef {
|
||||
_ServerNotifierProviderElement(super.provider);
|
||||
|
||||
@override
|
||||
String get serverId => (origin as ServerNotifierProvider).serverId;
|
||||
}
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package
|
||||
@@ -1,41 +1,69 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:fl_lib/fl_lib.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import 'package:server_box/data/model/sftp/worker.dart';
|
||||
|
||||
class SftpProvider extends Provider {
|
||||
const SftpProvider._();
|
||||
static const instance = SftpProvider._();
|
||||
part 'sftp.freezed.dart';
|
||||
part 'sftp.g.dart';
|
||||
|
||||
static final status = <SftpReqStatus>[].vn;
|
||||
@freezed
|
||||
abstract class SftpState with _$SftpState {
|
||||
const factory SftpState({
|
||||
@Default(<SftpReqStatus>[]) List<SftpReqStatus> requests,
|
||||
}) = _SftpState;
|
||||
}
|
||||
|
||||
static SftpReqStatus? get(int id) {
|
||||
return status.value.singleWhere((element) => element.id == id);
|
||||
@Riverpod(keepAlive: true)
|
||||
class SftpNotifier extends _$SftpNotifier {
|
||||
@override
|
||||
SftpState build() {
|
||||
return const SftpState();
|
||||
}
|
||||
|
||||
static int add(SftpReq req, {Completer? completer}) {
|
||||
final reqStat = SftpReqStatus(notifyListeners: status.notify, completer: completer, req: req);
|
||||
status.value.add(reqStat);
|
||||
status.notify();
|
||||
SftpReqStatus? get(int id) {
|
||||
try {
|
||||
return state.requests.singleWhere((element) => element.id == id);
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
int add(SftpReq req, {Completer? completer}) {
|
||||
final reqStat = SftpReqStatus(
|
||||
notifyListeners: _notifyListeners,
|
||||
completer: completer,
|
||||
req: req,
|
||||
);
|
||||
state = state.copyWith(
|
||||
requests: [...state.requests, reqStat],
|
||||
);
|
||||
return reqStat.id;
|
||||
}
|
||||
|
||||
static void dispose() {
|
||||
for (final item in status.value) {
|
||||
void dispose() {
|
||||
for (final item in state.requests) {
|
||||
item.dispose();
|
||||
}
|
||||
status.value.clear();
|
||||
status.notify();
|
||||
state = state.copyWith(requests: []);
|
||||
}
|
||||
|
||||
static void cancel(int id) {
|
||||
final idx = status.value.indexWhere((e) => e.id == id);
|
||||
if (idx < 0 || idx >= status.value.length) {
|
||||
void cancel(int id) {
|
||||
final idx = state.requests.indexWhere((e) => e.id == id);
|
||||
if (idx < 0 || idx >= state.requests.length) {
|
||||
dprint('SftpProvider.cancel: id $id not found');
|
||||
return;
|
||||
}
|
||||
status.value[idx].dispose();
|
||||
status.value.removeAt(idx);
|
||||
status.notify();
|
||||
final item = state.requests[idx];
|
||||
item.dispose();
|
||||
final newRequests = List<SftpReqStatus>.from(state.requests)
|
||||
..removeAt(idx);
|
||||
state = state.copyWith(requests: newRequests);
|
||||
}
|
||||
|
||||
void _notifyListeners() {
|
||||
// Force state update to notify listeners
|
||||
state = state.copyWith();
|
||||
}
|
||||
}
|
||||
|
||||
277
lib/data/provider/sftp.freezed.dart
Normal file
277
lib/data/provider/sftp.freezed.dart
Normal file
@@ -0,0 +1,277 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'sftp.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$SftpState {
|
||||
|
||||
List<SftpReqStatus> get requests;
|
||||
/// Create a copy of SftpState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$SftpStateCopyWith<SftpState> get copyWith => _$SftpStateCopyWithImpl<SftpState>(this as SftpState, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is SftpState&&const DeepCollectionEquality().equals(other.requests, requests));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(requests));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SftpState(requests: $requests)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $SftpStateCopyWith<$Res> {
|
||||
factory $SftpStateCopyWith(SftpState value, $Res Function(SftpState) _then) = _$SftpStateCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
List<SftpReqStatus> requests
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$SftpStateCopyWithImpl<$Res>
|
||||
implements $SftpStateCopyWith<$Res> {
|
||||
_$SftpStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final SftpState _self;
|
||||
final $Res Function(SftpState) _then;
|
||||
|
||||
/// Create a copy of SftpState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? requests = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
requests: null == requests ? _self.requests : requests // ignore: cast_nullable_to_non_nullable
|
||||
as List<SftpReqStatus>,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [SftpState].
|
||||
extension SftpStatePatterns on SftpState {
|
||||
/// A variant of `map` that fallback to returning `orElse`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _SftpState value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _SftpState() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// Callbacks receives the raw object, upcasted.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case final Subclass2 value:
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _SftpState value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _SftpState():
|
||||
return $default(_that);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `map` that fallback to returning `null`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _SftpState value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _SftpState() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( List<SftpReqStatus> requests)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _SftpState() when $default != null:
|
||||
return $default(_that.requests);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( List<SftpReqStatus> requests) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _SftpState():
|
||||
return $default(_that.requests);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( List<SftpReqStatus> requests)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _SftpState() when $default != null:
|
||||
return $default(_that.requests);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _SftpState implements SftpState {
|
||||
const _SftpState({final List<SftpReqStatus> requests = const <SftpReqStatus>[]}): _requests = requests;
|
||||
|
||||
|
||||
final List<SftpReqStatus> _requests;
|
||||
@override@JsonKey() List<SftpReqStatus> get requests {
|
||||
if (_requests is EqualUnmodifiableListView) return _requests;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_requests);
|
||||
}
|
||||
|
||||
|
||||
/// Create a copy of SftpState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$SftpStateCopyWith<_SftpState> get copyWith => __$SftpStateCopyWithImpl<_SftpState>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _SftpState&&const DeepCollectionEquality().equals(other._requests, _requests));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(_requests));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SftpState(requests: $requests)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$SftpStateCopyWith<$Res> implements $SftpStateCopyWith<$Res> {
|
||||
factory _$SftpStateCopyWith(_SftpState value, $Res Function(_SftpState) _then) = __$SftpStateCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
List<SftpReqStatus> requests
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$SftpStateCopyWithImpl<$Res>
|
||||
implements _$SftpStateCopyWith<$Res> {
|
||||
__$SftpStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _SftpState _self;
|
||||
final $Res Function(_SftpState) _then;
|
||||
|
||||
/// Create a copy of SftpState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? requests = null,}) {
|
||||
return _then(_SftpState(
|
||||
requests: null == requests ? _self._requests : requests // ignore: cast_nullable_to_non_nullable
|
||||
as List<SftpReqStatus>,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
25
lib/data/provider/sftp.g.dart
Normal file
25
lib/data/provider/sftp.g.dart
Normal file
@@ -0,0 +1,25 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'sftp.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$sftpNotifierHash() => r'f8412a4bd1f2bc5919ec31a3eba1c27e9a578f41';
|
||||
|
||||
/// See also [SftpNotifier].
|
||||
@ProviderFor(SftpNotifier)
|
||||
final sftpNotifierProvider = NotifierProvider<SftpNotifier, SftpState>.internal(
|
||||
SftpNotifier.new,
|
||||
name: r'sftpNotifierProvider',
|
||||
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$sftpNotifierHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
typedef _$SftpNotifier = Notifier<SftpState>;
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package
|
||||
@@ -1,80 +1,105 @@
|
||||
import 'package:fl_lib/fl_lib.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import 'package:server_box/core/sync.dart';
|
||||
import 'package:server_box/data/model/server/snippet.dart';
|
||||
import 'package:server_box/data/res/store.dart';
|
||||
|
||||
class SnippetProvider extends Provider {
|
||||
const SnippetProvider._();
|
||||
static const instance = SnippetProvider._();
|
||||
part 'snippet.freezed.dart';
|
||||
part 'snippet.g.dart';
|
||||
|
||||
static final snippets = <Snippet>[].vn;
|
||||
static final tags = <String>{}.vn;
|
||||
@freezed
|
||||
abstract class SnippetState with _$SnippetState {
|
||||
const factory SnippetState({
|
||||
@Default(<Snippet>[]) List<Snippet> snippets,
|
||||
@Default(<String>{}) Set<String> tags,
|
||||
}) = _SnippetState;
|
||||
}
|
||||
|
||||
@Riverpod(keepAlive: true)
|
||||
class SnippetNotifier extends _$SnippetNotifier {
|
||||
@override
|
||||
void load() {
|
||||
super.load();
|
||||
final snippets_ = Stores.snippet.fetch();
|
||||
SnippetState build() {
|
||||
return _load();
|
||||
}
|
||||
|
||||
void reload() {
|
||||
final newState = _load();
|
||||
if (newState == state) return;
|
||||
state = newState;
|
||||
}
|
||||
|
||||
SnippetState _load() {
|
||||
final snippets = Stores.snippet.fetch();
|
||||
final order = Stores.setting.snippetOrder.fetch();
|
||||
|
||||
List<Snippet> orderedSnippets = snippets;
|
||||
if (order.isNotEmpty) {
|
||||
final surplus = snippets_.reorder(
|
||||
order: order,
|
||||
finder: (n, name) => n.name == name,
|
||||
);
|
||||
final surplus = snippets.reorder(order: order, finder: (n, name) => n.name == name);
|
||||
order.removeWhere((e) => surplus.any((ele) => ele == e));
|
||||
if (order != Stores.setting.snippetOrder.fetch()) {
|
||||
Stores.setting.snippetOrder.put(order);
|
||||
}
|
||||
orderedSnippets = snippets;
|
||||
}
|
||||
snippets.value = snippets_;
|
||||
_updateTags();
|
||||
|
||||
final newTags = _computeTags(orderedSnippets);
|
||||
return stateOrNull?.copyWith(snippets: orderedSnippets, tags: newTags) ??
|
||||
SnippetState(snippets: orderedSnippets, tags: newTags);
|
||||
}
|
||||
|
||||
static void _updateTags() {
|
||||
final tags_ = <String>{};
|
||||
for (final s in snippets.value) {
|
||||
Set<String> _computeTags(List<Snippet> snippets) {
|
||||
final tags = <String>{};
|
||||
for (final s in snippets) {
|
||||
final t = s.tags;
|
||||
if (t != null) {
|
||||
tags_.addAll(t);
|
||||
tags.addAll(t);
|
||||
}
|
||||
}
|
||||
tags.value = tags_;
|
||||
return tags;
|
||||
}
|
||||
|
||||
static void add(Snippet snippet) {
|
||||
snippets.value.add(snippet);
|
||||
snippets.notify();
|
||||
void add(Snippet snippet) {
|
||||
final newSnippets = [...state.snippets, snippet];
|
||||
final newTags = _computeTags(newSnippets);
|
||||
state = state.copyWith(snippets: newSnippets, tags: newTags);
|
||||
Stores.snippet.put(snippet);
|
||||
_updateTags();
|
||||
bakSync.sync(milliDelay: 1000);
|
||||
}
|
||||
|
||||
static void del(Snippet snippet) {
|
||||
snippets.value.remove(snippet);
|
||||
snippets.notify();
|
||||
void del(Snippet snippet) {
|
||||
final newSnippets = state.snippets.where((s) => s != snippet).toList();
|
||||
final newTags = _computeTags(newSnippets);
|
||||
state = state.copyWith(snippets: newSnippets, tags: newTags);
|
||||
Stores.snippet.delete(snippet);
|
||||
_updateTags();
|
||||
bakSync.sync(milliDelay: 1000);
|
||||
}
|
||||
|
||||
static void update(Snippet old, Snippet newOne) {
|
||||
snippets.value.remove(old);
|
||||
snippets.value.add(newOne);
|
||||
snippets.notify();
|
||||
void update(Snippet old, Snippet newOne) {
|
||||
final newSnippets = state.snippets.map((s) => s == old ? newOne : s).toList();
|
||||
final newTags = _computeTags(newSnippets);
|
||||
state = state.copyWith(snippets: newSnippets, tags: newTags);
|
||||
Stores.snippet.delete(old);
|
||||
Stores.snippet.put(newOne);
|
||||
_updateTags();
|
||||
bakSync.sync(milliDelay: 1000);
|
||||
}
|
||||
|
||||
static void renameTag(String old, String newOne) {
|
||||
for (final s in snippets.value) {
|
||||
void renameTag(String old, String newOne) {
|
||||
final updatedSnippets = <Snippet>[];
|
||||
for (final s in state.snippets) {
|
||||
if (s.tags?.contains(old) ?? false) {
|
||||
s.tags?.remove(old);
|
||||
s.tags?.add(newOne);
|
||||
Stores.snippet.put(s);
|
||||
final newTags = Set<String>.from(s.tags!);
|
||||
newTags.remove(old);
|
||||
newTags.add(newOne);
|
||||
final updatedSnippet = s.copyWith(tags: newTags.toList());
|
||||
updatedSnippets.add(updatedSnippet);
|
||||
Stores.snippet.put(updatedSnippet);
|
||||
} else {
|
||||
updatedSnippets.add(s);
|
||||
}
|
||||
}
|
||||
_updateTags();
|
||||
final newTags = _computeTags(updatedSnippets);
|
||||
state = state.copyWith(snippets: updatedSnippets, tags: newTags);
|
||||
bakSync.sync(milliDelay: 1000);
|
||||
}
|
||||
}
|
||||
|
||||
286
lib/data/provider/snippet.freezed.dart
Normal file
286
lib/data/provider/snippet.freezed.dart
Normal file
@@ -0,0 +1,286 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'snippet.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$SnippetState {
|
||||
|
||||
List<Snippet> get snippets; Set<String> get tags;
|
||||
/// Create a copy of SnippetState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$SnippetStateCopyWith<SnippetState> get copyWith => _$SnippetStateCopyWithImpl<SnippetState>(this as SnippetState, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is SnippetState&&const DeepCollectionEquality().equals(other.snippets, snippets)&&const DeepCollectionEquality().equals(other.tags, tags));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(snippets),const DeepCollectionEquality().hash(tags));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SnippetState(snippets: $snippets, tags: $tags)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $SnippetStateCopyWith<$Res> {
|
||||
factory $SnippetStateCopyWith(SnippetState value, $Res Function(SnippetState) _then) = _$SnippetStateCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
List<Snippet> snippets, Set<String> tags
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$SnippetStateCopyWithImpl<$Res>
|
||||
implements $SnippetStateCopyWith<$Res> {
|
||||
_$SnippetStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final SnippetState _self;
|
||||
final $Res Function(SnippetState) _then;
|
||||
|
||||
/// Create a copy of SnippetState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? snippets = null,Object? tags = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
snippets: null == snippets ? _self.snippets : snippets // ignore: cast_nullable_to_non_nullable
|
||||
as List<Snippet>,tags: null == tags ? _self.tags : tags // ignore: cast_nullable_to_non_nullable
|
||||
as Set<String>,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [SnippetState].
|
||||
extension SnippetStatePatterns on SnippetState {
|
||||
/// A variant of `map` that fallback to returning `orElse`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _SnippetState value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _SnippetState() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// Callbacks receives the raw object, upcasted.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case final Subclass2 value:
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _SnippetState value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _SnippetState():
|
||||
return $default(_that);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `map` that fallback to returning `null`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _SnippetState value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _SnippetState() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( List<Snippet> snippets, Set<String> tags)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _SnippetState() when $default != null:
|
||||
return $default(_that.snippets,_that.tags);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( List<Snippet> snippets, Set<String> tags) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _SnippetState():
|
||||
return $default(_that.snippets,_that.tags);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( List<Snippet> snippets, Set<String> tags)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _SnippetState() when $default != null:
|
||||
return $default(_that.snippets,_that.tags);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _SnippetState implements SnippetState {
|
||||
const _SnippetState({final List<Snippet> snippets = const <Snippet>[], final Set<String> tags = const <String>{}}): _snippets = snippets,_tags = tags;
|
||||
|
||||
|
||||
final List<Snippet> _snippets;
|
||||
@override@JsonKey() List<Snippet> get snippets {
|
||||
if (_snippets is EqualUnmodifiableListView) return _snippets;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_snippets);
|
||||
}
|
||||
|
||||
final Set<String> _tags;
|
||||
@override@JsonKey() Set<String> get tags {
|
||||
if (_tags is EqualUnmodifiableSetView) return _tags;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableSetView(_tags);
|
||||
}
|
||||
|
||||
|
||||
/// Create a copy of SnippetState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$SnippetStateCopyWith<_SnippetState> get copyWith => __$SnippetStateCopyWithImpl<_SnippetState>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _SnippetState&&const DeepCollectionEquality().equals(other._snippets, _snippets)&&const DeepCollectionEquality().equals(other._tags, _tags));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(_snippets),const DeepCollectionEquality().hash(_tags));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SnippetState(snippets: $snippets, tags: $tags)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$SnippetStateCopyWith<$Res> implements $SnippetStateCopyWith<$Res> {
|
||||
factory _$SnippetStateCopyWith(_SnippetState value, $Res Function(_SnippetState) _then) = __$SnippetStateCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
List<Snippet> snippets, Set<String> tags
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$SnippetStateCopyWithImpl<$Res>
|
||||
implements _$SnippetStateCopyWith<$Res> {
|
||||
__$SnippetStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _SnippetState _self;
|
||||
final $Res Function(_SnippetState) _then;
|
||||
|
||||
/// Create a copy of SnippetState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? snippets = null,Object? tags = null,}) {
|
||||
return _then(_SnippetState(
|
||||
snippets: null == snippets ? _self._snippets : snippets // ignore: cast_nullable_to_non_nullable
|
||||
as List<Snippet>,tags: null == tags ? _self._tags : tags // ignore: cast_nullable_to_non_nullable
|
||||
as Set<String>,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
26
lib/data/provider/snippet.g.dart
Normal file
26
lib/data/provider/snippet.g.dart
Normal file
@@ -0,0 +1,26 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'snippet.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$snippetNotifierHash() => r'8285c7edf905a4aaa41cd8b65b0a6755c8b97fc9';
|
||||
|
||||
/// See also [SnippetNotifier].
|
||||
@ProviderFor(SnippetNotifier)
|
||||
final snippetNotifierProvider =
|
||||
NotifierProvider<SnippetNotifier, SnippetState>.internal(
|
||||
SnippetNotifier.new,
|
||||
name: r'snippetNotifierProvider',
|
||||
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$snippetNotifierHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
typedef _$SnippetNotifier = Notifier<SnippetState>;
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package
|
||||
@@ -1,45 +1,57 @@
|
||||
import 'package:fl_lib/fl_lib.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import 'package:server_box/core/extension/ssh_client.dart';
|
||||
import 'package:server_box/data/model/app/scripts/script_consts.dart';
|
||||
import 'package:server_box/data/model/server/server.dart';
|
||||
import 'package:server_box/data/model/server/server_private_info.dart';
|
||||
import 'package:server_box/data/model/server/systemd.dart';
|
||||
import 'package:server_box/data/provider/server.dart';
|
||||
import 'package:server_box/data/provider/server/single.dart';
|
||||
|
||||
final class SystemdProvider {
|
||||
late final VNode<Server> _si;
|
||||
part 'systemd.freezed.dart';
|
||||
part 'systemd.g.dart';
|
||||
|
||||
SystemdProvider.init(Spi spi) {
|
||||
_si = ServerProvider.pick(spi: spi)!;
|
||||
getUnits();
|
||||
}
|
||||
@freezed
|
||||
abstract class SystemdState with _$SystemdState {
|
||||
const factory SystemdState({
|
||||
@Default(false) bool isBusy,
|
||||
@Default(<SystemdUnit>[]) List<SystemdUnit> units,
|
||||
@Default(SystemdScopeFilter.all) SystemdScopeFilter scopeFilter,
|
||||
}) = _SystemdState;
|
||||
}
|
||||
|
||||
final isBusy = false.vn;
|
||||
final units = <SystemdUnit>[].vn;
|
||||
final scopeFilter = SystemdScopeFilter.all.vn;
|
||||
@riverpod
|
||||
class SystemdNotifier extends _$SystemdNotifier {
|
||||
late final ServerState _si;
|
||||
|
||||
void dispose() {
|
||||
isBusy.dispose();
|
||||
units.dispose();
|
||||
scopeFilter.dispose();
|
||||
@override
|
||||
SystemdState build(Spi spi) {
|
||||
final si = ref.read(serverNotifierProvider(spi.id));
|
||||
_si = si;
|
||||
// Async initialization
|
||||
Future.microtask(() => getUnits());
|
||||
return const SystemdState();
|
||||
}
|
||||
|
||||
List<SystemdUnit> get filteredUnits {
|
||||
switch (scopeFilter.value) {
|
||||
switch (state.scopeFilter) {
|
||||
case SystemdScopeFilter.all:
|
||||
return units.value;
|
||||
return state.units;
|
||||
case SystemdScopeFilter.system:
|
||||
return units.value.where((unit) => unit.scope == SystemdUnitScope.system).toList();
|
||||
return state.units.where((unit) => unit.scope == SystemdUnitScope.system).toList();
|
||||
case SystemdScopeFilter.user:
|
||||
return units.value.where((unit) => unit.scope == SystemdUnitScope.user).toList();
|
||||
return state.units.where((unit) => unit.scope == SystemdUnitScope.user).toList();
|
||||
}
|
||||
}
|
||||
|
||||
void setScopeFilter(SystemdScopeFilter filter) {
|
||||
state = state.copyWith(scopeFilter: filter);
|
||||
}
|
||||
|
||||
Future<void> getUnits() async {
|
||||
isBusy.value = true;
|
||||
state = state.copyWith(isBusy: true);
|
||||
|
||||
try {
|
||||
final client = _si.value.client;
|
||||
final client = _si.client;
|
||||
final result = await client!.execForOutput(_getUnitsCmd);
|
||||
final units = result.split('\n');
|
||||
|
||||
@@ -57,12 +69,11 @@ final class SystemdProvider {
|
||||
|
||||
final parsedUserUnits = await _parseUnitObj(userUnits, SystemdUnitScope.user);
|
||||
final parsedSystemUnits = await _parseUnitObj(systemUnits, SystemdUnitScope.system);
|
||||
this.units.value = [...parsedUserUnits, ...parsedSystemUnits];
|
||||
state = state.copyWith(units: [...parsedUserUnits, ...parsedSystemUnits], isBusy: false);
|
||||
} catch (e, s) {
|
||||
dprint('Parse systemd', e, s);
|
||||
state = state.copyWith(isBusy: false);
|
||||
}
|
||||
|
||||
isBusy.value = false;
|
||||
}
|
||||
|
||||
Future<List<SystemdUnit>> _parseUnitObj(List<String> unitNames, SystemdUnitScope scope) async {
|
||||
@@ -75,7 +86,7 @@ for unit in ${unitNames_.join(' ')}; do
|
||||
echo -n "\n${ScriptConstants.separator}\n"
|
||||
done
|
||||
''';
|
||||
final client = _si.value.client!;
|
||||
final client = _si.client!;
|
||||
final result = await client.execForOutput(script);
|
||||
final units = result.split(ScriptConstants.separator);
|
||||
|
||||
|
||||
283
lib/data/provider/systemd.freezed.dart
Normal file
283
lib/data/provider/systemd.freezed.dart
Normal file
@@ -0,0 +1,283 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'systemd.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$SystemdState {
|
||||
|
||||
bool get isBusy; List<SystemdUnit> get units; SystemdScopeFilter get scopeFilter;
|
||||
/// Create a copy of SystemdState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$SystemdStateCopyWith<SystemdState> get copyWith => _$SystemdStateCopyWithImpl<SystemdState>(this as SystemdState, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is SystemdState&&(identical(other.isBusy, isBusy) || other.isBusy == isBusy)&&const DeepCollectionEquality().equals(other.units, units)&&(identical(other.scopeFilter, scopeFilter) || other.scopeFilter == scopeFilter));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,isBusy,const DeepCollectionEquality().hash(units),scopeFilter);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SystemdState(isBusy: $isBusy, units: $units, scopeFilter: $scopeFilter)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $SystemdStateCopyWith<$Res> {
|
||||
factory $SystemdStateCopyWith(SystemdState value, $Res Function(SystemdState) _then) = _$SystemdStateCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
bool isBusy, List<SystemdUnit> units, SystemdScopeFilter scopeFilter
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$SystemdStateCopyWithImpl<$Res>
|
||||
implements $SystemdStateCopyWith<$Res> {
|
||||
_$SystemdStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final SystemdState _self;
|
||||
final $Res Function(SystemdState) _then;
|
||||
|
||||
/// Create a copy of SystemdState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? isBusy = null,Object? units = null,Object? scopeFilter = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
isBusy: null == isBusy ? _self.isBusy : isBusy // ignore: cast_nullable_to_non_nullable
|
||||
as bool,units: null == units ? _self.units : units // ignore: cast_nullable_to_non_nullable
|
||||
as List<SystemdUnit>,scopeFilter: null == scopeFilter ? _self.scopeFilter : scopeFilter // ignore: cast_nullable_to_non_nullable
|
||||
as SystemdScopeFilter,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [SystemdState].
|
||||
extension SystemdStatePatterns on SystemdState {
|
||||
/// A variant of `map` that fallback to returning `orElse`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _SystemdState value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _SystemdState() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// Callbacks receives the raw object, upcasted.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case final Subclass2 value:
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _SystemdState value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _SystemdState():
|
||||
return $default(_that);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `map` that fallback to returning `null`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _SystemdState value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _SystemdState() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool isBusy, List<SystemdUnit> units, SystemdScopeFilter scopeFilter)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _SystemdState() when $default != null:
|
||||
return $default(_that.isBusy,_that.units,_that.scopeFilter);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool isBusy, List<SystemdUnit> units, SystemdScopeFilter scopeFilter) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _SystemdState():
|
||||
return $default(_that.isBusy,_that.units,_that.scopeFilter);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool isBusy, List<SystemdUnit> units, SystemdScopeFilter scopeFilter)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _SystemdState() when $default != null:
|
||||
return $default(_that.isBusy,_that.units,_that.scopeFilter);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _SystemdState implements SystemdState {
|
||||
const _SystemdState({this.isBusy = false, final List<SystemdUnit> units = const <SystemdUnit>[], this.scopeFilter = SystemdScopeFilter.all}): _units = units;
|
||||
|
||||
|
||||
@override@JsonKey() final bool isBusy;
|
||||
final List<SystemdUnit> _units;
|
||||
@override@JsonKey() List<SystemdUnit> get units {
|
||||
if (_units is EqualUnmodifiableListView) return _units;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_units);
|
||||
}
|
||||
|
||||
@override@JsonKey() final SystemdScopeFilter scopeFilter;
|
||||
|
||||
/// Create a copy of SystemdState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$SystemdStateCopyWith<_SystemdState> get copyWith => __$SystemdStateCopyWithImpl<_SystemdState>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _SystemdState&&(identical(other.isBusy, isBusy) || other.isBusy == isBusy)&&const DeepCollectionEquality().equals(other._units, _units)&&(identical(other.scopeFilter, scopeFilter) || other.scopeFilter == scopeFilter));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,isBusy,const DeepCollectionEquality().hash(_units),scopeFilter);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SystemdState(isBusy: $isBusy, units: $units, scopeFilter: $scopeFilter)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$SystemdStateCopyWith<$Res> implements $SystemdStateCopyWith<$Res> {
|
||||
factory _$SystemdStateCopyWith(_SystemdState value, $Res Function(_SystemdState) _then) = __$SystemdStateCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
bool isBusy, List<SystemdUnit> units, SystemdScopeFilter scopeFilter
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$SystemdStateCopyWithImpl<$Res>
|
||||
implements _$SystemdStateCopyWith<$Res> {
|
||||
__$SystemdStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _SystemdState _self;
|
||||
final $Res Function(_SystemdState) _then;
|
||||
|
||||
/// Create a copy of SystemdState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? isBusy = null,Object? units = null,Object? scopeFilter = null,}) {
|
||||
return _then(_SystemdState(
|
||||
isBusy: null == isBusy ? _self.isBusy : isBusy // ignore: cast_nullable_to_non_nullable
|
||||
as bool,units: null == units ? _self._units : units // ignore: cast_nullable_to_non_nullable
|
||||
as List<SystemdUnit>,scopeFilter: null == scopeFilter ? _self.scopeFilter : scopeFilter // ignore: cast_nullable_to_non_nullable
|
||||
as SystemdScopeFilter,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
163
lib/data/provider/systemd.g.dart
Normal file
163
lib/data/provider/systemd.g.dart
Normal file
@@ -0,0 +1,163 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'systemd.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$systemdNotifierHash() => r'98466bd176518545be49cae52f8dbe12af3a88a6';
|
||||
|
||||
/// Copied from Dart SDK
|
||||
class _SystemHash {
|
||||
_SystemHash._();
|
||||
|
||||
static int combine(int hash, int value) {
|
||||
// ignore: parameter_assignments
|
||||
hash = 0x1fffffff & (hash + value);
|
||||
// ignore: parameter_assignments
|
||||
hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10));
|
||||
return hash ^ (hash >> 6);
|
||||
}
|
||||
|
||||
static int finish(int hash) {
|
||||
// ignore: parameter_assignments
|
||||
hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3));
|
||||
// ignore: parameter_assignments
|
||||
hash = hash ^ (hash >> 11);
|
||||
return 0x1fffffff & (hash + ((0x00003fff & hash) << 15));
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _$SystemdNotifier
|
||||
extends BuildlessAutoDisposeNotifier<SystemdState> {
|
||||
late final Spi spi;
|
||||
|
||||
SystemdState build(Spi spi);
|
||||
}
|
||||
|
||||
/// See also [SystemdNotifier].
|
||||
@ProviderFor(SystemdNotifier)
|
||||
const systemdNotifierProvider = SystemdNotifierFamily();
|
||||
|
||||
/// See also [SystemdNotifier].
|
||||
class SystemdNotifierFamily extends Family<SystemdState> {
|
||||
/// See also [SystemdNotifier].
|
||||
const SystemdNotifierFamily();
|
||||
|
||||
/// See also [SystemdNotifier].
|
||||
SystemdNotifierProvider call(Spi spi) {
|
||||
return SystemdNotifierProvider(spi);
|
||||
}
|
||||
|
||||
@override
|
||||
SystemdNotifierProvider getProviderOverride(
|
||||
covariant SystemdNotifierProvider provider,
|
||||
) {
|
||||
return call(provider.spi);
|
||||
}
|
||||
|
||||
static const Iterable<ProviderOrFamily>? _dependencies = null;
|
||||
|
||||
@override
|
||||
Iterable<ProviderOrFamily>? get dependencies => _dependencies;
|
||||
|
||||
static const Iterable<ProviderOrFamily>? _allTransitiveDependencies = null;
|
||||
|
||||
@override
|
||||
Iterable<ProviderOrFamily>? get allTransitiveDependencies =>
|
||||
_allTransitiveDependencies;
|
||||
|
||||
@override
|
||||
String? get name => r'systemdNotifierProvider';
|
||||
}
|
||||
|
||||
/// See also [SystemdNotifier].
|
||||
class SystemdNotifierProvider
|
||||
extends AutoDisposeNotifierProviderImpl<SystemdNotifier, SystemdState> {
|
||||
/// See also [SystemdNotifier].
|
||||
SystemdNotifierProvider(Spi spi)
|
||||
: this._internal(
|
||||
() => SystemdNotifier()..spi = spi,
|
||||
from: systemdNotifierProvider,
|
||||
name: r'systemdNotifierProvider',
|
||||
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$systemdNotifierHash,
|
||||
dependencies: SystemdNotifierFamily._dependencies,
|
||||
allTransitiveDependencies:
|
||||
SystemdNotifierFamily._allTransitiveDependencies,
|
||||
spi: spi,
|
||||
);
|
||||
|
||||
SystemdNotifierProvider._internal(
|
||||
super._createNotifier, {
|
||||
required super.name,
|
||||
required super.dependencies,
|
||||
required super.allTransitiveDependencies,
|
||||
required super.debugGetCreateSourceHash,
|
||||
required super.from,
|
||||
required this.spi,
|
||||
}) : super.internal();
|
||||
|
||||
final Spi spi;
|
||||
|
||||
@override
|
||||
SystemdState runNotifierBuild(covariant SystemdNotifier notifier) {
|
||||
return notifier.build(spi);
|
||||
}
|
||||
|
||||
@override
|
||||
Override overrideWith(SystemdNotifier Function() create) {
|
||||
return ProviderOverride(
|
||||
origin: this,
|
||||
override: SystemdNotifierProvider._internal(
|
||||
() => create()..spi = spi,
|
||||
from: from,
|
||||
name: null,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
debugGetCreateSourceHash: null,
|
||||
spi: spi,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
AutoDisposeNotifierProviderElement<SystemdNotifier, SystemdState>
|
||||
createElement() {
|
||||
return _SystemdNotifierProviderElement(this);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return other is SystemdNotifierProvider && other.spi == spi;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
var hash = _SystemHash.combine(0, runtimeType.hashCode);
|
||||
hash = _SystemHash.combine(hash, spi.hashCode);
|
||||
|
||||
return _SystemHash.finish(hash);
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated('Will be removed in 3.0. Use Ref instead')
|
||||
// ignore: unused_element
|
||||
mixin SystemdNotifierRef on AutoDisposeNotifierProviderRef<SystemdState> {
|
||||
/// The parameter `spi` of this provider.
|
||||
Spi get spi;
|
||||
}
|
||||
|
||||
class _SystemdNotifierProviderElement
|
||||
extends AutoDisposeNotifierProviderElement<SystemdNotifier, SystemdState>
|
||||
with SystemdNotifierRef {
|
||||
_SystemdNotifierProviderElement(super.provider);
|
||||
|
||||
@override
|
||||
Spi get spi => (origin as SystemdNotifierProvider).spi;
|
||||
}
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package
|
||||
@@ -1,56 +1,63 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import 'package:server_box/data/res/store.dart';
|
||||
import 'package:xterm/core.dart';
|
||||
|
||||
class VirtKeyProvider extends TerminalInputHandler with ChangeNotifier {
|
||||
VirtKeyProvider();
|
||||
part 'virtual_keyboard.g.dart';
|
||||
part 'virtual_keyboard.freezed.dart';
|
||||
|
||||
bool _ctrl = false;
|
||||
bool get ctrl => _ctrl;
|
||||
set ctrl(bool value) {
|
||||
if (value != _ctrl) {
|
||||
_ctrl = value;
|
||||
notifyListeners();
|
||||
@freezed
|
||||
abstract class VirtKeyState with _$VirtKeyState {
|
||||
const factory VirtKeyState({
|
||||
@Default(false) final bool ctrl,
|
||||
@Default(false) final bool alt,
|
||||
@Default(false) final bool shift,
|
||||
}) = _VirtKeyState;
|
||||
}
|
||||
|
||||
@riverpod
|
||||
class VirtKeyboard extends _$VirtKeyboard implements TerminalInputHandler {
|
||||
@override
|
||||
VirtKeyState build() {
|
||||
return const VirtKeyState();
|
||||
}
|
||||
|
||||
bool get ctrl => state.ctrl;
|
||||
bool get alt => state.alt;
|
||||
bool get shift => state.shift;
|
||||
|
||||
void setCtrl(bool value) {
|
||||
if (value != state.ctrl) {
|
||||
state = state.copyWith(ctrl: value);
|
||||
}
|
||||
}
|
||||
|
||||
bool _alt = false;
|
||||
bool get alt => _alt;
|
||||
set alt(bool value) {
|
||||
if (value != _alt) {
|
||||
_alt = value;
|
||||
notifyListeners();
|
||||
void setAlt(bool value) {
|
||||
if (value != state.alt) {
|
||||
state = state.copyWith(alt: value);
|
||||
}
|
||||
}
|
||||
|
||||
bool _shift = false;
|
||||
bool get shift => _shift;
|
||||
set shift(bool value) {
|
||||
if (value != _shift) {
|
||||
_shift = value;
|
||||
notifyListeners();
|
||||
void setShift(bool value) {
|
||||
if (value != state.shift) {
|
||||
state = state.copyWith(shift: value);
|
||||
}
|
||||
}
|
||||
|
||||
void reset(TerminalKeyboardEvent e) {
|
||||
if (e.ctrl) {
|
||||
ctrl = false;
|
||||
}
|
||||
if (e.alt) {
|
||||
alt = false;
|
||||
}
|
||||
if (e.shift) {
|
||||
shift = false;
|
||||
}
|
||||
notifyListeners();
|
||||
state = state.copyWith(
|
||||
ctrl: e.ctrl ? false : state.ctrl,
|
||||
alt: e.alt ? false : state.alt,
|
||||
shift: e.shift ? false : state.shift,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
String? call(TerminalKeyboardEvent event) {
|
||||
final e = event.copyWith(
|
||||
ctrl: event.ctrl || ctrl,
|
||||
alt: event.alt || alt,
|
||||
shift: event.shift || shift,
|
||||
ctrl: event.ctrl || state.ctrl,
|
||||
alt: event.alt || state.alt,
|
||||
shift: event.shift || state.shift,
|
||||
);
|
||||
if (Stores.setting.sshVirtualKeyAutoOff.fetch()) {
|
||||
reset(e);
|
||||
|
||||
277
lib/data/provider/virtual_keyboard.freezed.dart
Normal file
277
lib/data/provider/virtual_keyboard.freezed.dart
Normal file
@@ -0,0 +1,277 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'virtual_keyboard.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$VirtKeyState {
|
||||
|
||||
bool get ctrl; bool get alt; bool get shift;
|
||||
/// Create a copy of VirtKeyState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$VirtKeyStateCopyWith<VirtKeyState> get copyWith => _$VirtKeyStateCopyWithImpl<VirtKeyState>(this as VirtKeyState, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is VirtKeyState&&(identical(other.ctrl, ctrl) || other.ctrl == ctrl)&&(identical(other.alt, alt) || other.alt == alt)&&(identical(other.shift, shift) || other.shift == shift));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,ctrl,alt,shift);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'VirtKeyState(ctrl: $ctrl, alt: $alt, shift: $shift)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $VirtKeyStateCopyWith<$Res> {
|
||||
factory $VirtKeyStateCopyWith(VirtKeyState value, $Res Function(VirtKeyState) _then) = _$VirtKeyStateCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
bool ctrl, bool alt, bool shift
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$VirtKeyStateCopyWithImpl<$Res>
|
||||
implements $VirtKeyStateCopyWith<$Res> {
|
||||
_$VirtKeyStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final VirtKeyState _self;
|
||||
final $Res Function(VirtKeyState) _then;
|
||||
|
||||
/// Create a copy of VirtKeyState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? ctrl = null,Object? alt = null,Object? shift = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
ctrl: null == ctrl ? _self.ctrl : ctrl // ignore: cast_nullable_to_non_nullable
|
||||
as bool,alt: null == alt ? _self.alt : alt // ignore: cast_nullable_to_non_nullable
|
||||
as bool,shift: null == shift ? _self.shift : shift // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [VirtKeyState].
|
||||
extension VirtKeyStatePatterns on VirtKeyState {
|
||||
/// A variant of `map` that fallback to returning `orElse`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _VirtKeyState value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _VirtKeyState() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// Callbacks receives the raw object, upcasted.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case final Subclass2 value:
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _VirtKeyState value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _VirtKeyState():
|
||||
return $default(_that);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `map` that fallback to returning `null`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _VirtKeyState value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _VirtKeyState() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool ctrl, bool alt, bool shift)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _VirtKeyState() when $default != null:
|
||||
return $default(_that.ctrl,_that.alt,_that.shift);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool ctrl, bool alt, bool shift) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _VirtKeyState():
|
||||
return $default(_that.ctrl,_that.alt,_that.shift);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool ctrl, bool alt, bool shift)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _VirtKeyState() when $default != null:
|
||||
return $default(_that.ctrl,_that.alt,_that.shift);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _VirtKeyState implements VirtKeyState {
|
||||
const _VirtKeyState({this.ctrl = false, this.alt = false, this.shift = false});
|
||||
|
||||
|
||||
@override@JsonKey() final bool ctrl;
|
||||
@override@JsonKey() final bool alt;
|
||||
@override@JsonKey() final bool shift;
|
||||
|
||||
/// Create a copy of VirtKeyState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$VirtKeyStateCopyWith<_VirtKeyState> get copyWith => __$VirtKeyStateCopyWithImpl<_VirtKeyState>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _VirtKeyState&&(identical(other.ctrl, ctrl) || other.ctrl == ctrl)&&(identical(other.alt, alt) || other.alt == alt)&&(identical(other.shift, shift) || other.shift == shift));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,ctrl,alt,shift);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'VirtKeyState(ctrl: $ctrl, alt: $alt, shift: $shift)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$VirtKeyStateCopyWith<$Res> implements $VirtKeyStateCopyWith<$Res> {
|
||||
factory _$VirtKeyStateCopyWith(_VirtKeyState value, $Res Function(_VirtKeyState) _then) = __$VirtKeyStateCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
bool ctrl, bool alt, bool shift
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$VirtKeyStateCopyWithImpl<$Res>
|
||||
implements _$VirtKeyStateCopyWith<$Res> {
|
||||
__$VirtKeyStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _VirtKeyState _self;
|
||||
final $Res Function(_VirtKeyState) _then;
|
||||
|
||||
/// Create a copy of VirtKeyState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? ctrl = null,Object? alt = null,Object? shift = null,}) {
|
||||
return _then(_VirtKeyState(
|
||||
ctrl: null == ctrl ? _self.ctrl : ctrl // ignore: cast_nullable_to_non_nullable
|
||||
as bool,alt: null == alt ? _self.alt : alt // ignore: cast_nullable_to_non_nullable
|
||||
as bool,shift: null == shift ? _self.shift : shift // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
26
lib/data/provider/virtual_keyboard.g.dart
Normal file
26
lib/data/provider/virtual_keyboard.g.dart
Normal file
@@ -0,0 +1,26 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'virtual_keyboard.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$virtKeyboardHash() => r'1327d412bfb0dd261f3b555f353a8852b4f753e5';
|
||||
|
||||
/// See also [VirtKeyboard].
|
||||
@ProviderFor(VirtKeyboard)
|
||||
final virtKeyboardProvider =
|
||||
AutoDisposeNotifierProvider<VirtKeyboard, VirtKeyState>.internal(
|
||||
VirtKeyboard.new,
|
||||
name: r'virtKeyboardProvider',
|
||||
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$virtKeyboardHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
typedef _$VirtKeyboard = AutoDisposeNotifier<VirtKeyState>;
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package
|
||||
@@ -3,6 +3,6 @@
|
||||
|
||||
abstract class BuildData {
|
||||
static const String name = "ServerBox";
|
||||
static const int build = 1220;
|
||||
static const int script = 68;
|
||||
static const int build = 1246;
|
||||
static const int script = 69;
|
||||
}
|
||||
|
||||
@@ -124,6 +124,8 @@ abstract final class GithubIds {
|
||||
'CreeperKong',
|
||||
'zxf945',
|
||||
'cnen2018',
|
||||
'xiaomeng9597',
|
||||
'mingzhao2019',
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import 'package:fl_lib/fl_lib.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:server_box/data/store/connection_stats.dart';
|
||||
import 'package:server_box/data/store/container.dart';
|
||||
import 'package:server_box/data/store/history.dart';
|
||||
import 'package:server_box/data/store/private_key.dart';
|
||||
@@ -6,25 +8,37 @@ import 'package:server_box/data/store/server.dart';
|
||||
import 'package:server_box/data/store/setting.dart';
|
||||
import 'package:server_box/data/store/snippet.dart';
|
||||
|
||||
final GetIt getIt = GetIt.instance;
|
||||
|
||||
abstract final class Stores {
|
||||
static final setting = SettingStore.instance;
|
||||
static final server = ServerStore.instance;
|
||||
static final container = ContainerStore.instance;
|
||||
static final key = PrivateKeyStore.instance;
|
||||
static final snippet = SnippetStore.instance;
|
||||
static final history = HistoryStore.instance;
|
||||
static SettingStore get setting => getIt<SettingStore>();
|
||||
static ServerStore get server => getIt<ServerStore>();
|
||||
static ContainerStore get container => getIt<ContainerStore>();
|
||||
static PrivateKeyStore get key => getIt<PrivateKeyStore>();
|
||||
static SnippetStore get snippet => getIt<SnippetStore>();
|
||||
static HistoryStore get history => getIt<HistoryStore>();
|
||||
static ConnectionStatsStore get connectionStats => getIt<ConnectionStatsStore>();
|
||||
|
||||
/// All stores that need backup
|
||||
static final List<HiveStore> _allBackup = [
|
||||
SettingStore.instance,
|
||||
ServerStore.instance,
|
||||
ContainerStore.instance,
|
||||
PrivateKeyStore.instance,
|
||||
SnippetStore.instance,
|
||||
HistoryStore.instance,
|
||||
];
|
||||
static List<HiveStore> get _allBackup => [
|
||||
setting,
|
||||
server,
|
||||
container,
|
||||
key,
|
||||
snippet,
|
||||
history,
|
||||
connectionStats,
|
||||
];
|
||||
|
||||
static Future<void> init() async {
|
||||
getIt.registerLazySingleton<SettingStore>(() => SettingStore.instance);
|
||||
getIt.registerLazySingleton<ServerStore>(() => ServerStore.instance);
|
||||
getIt.registerLazySingleton<ContainerStore>(() => ContainerStore.instance);
|
||||
getIt.registerLazySingleton<PrivateKeyStore>(() => PrivateKeyStore.instance);
|
||||
getIt.registerLazySingleton<SnippetStore>(() => SnippetStore.instance);
|
||||
getIt.registerLazySingleton<HistoryStore>(() => HistoryStore.instance);
|
||||
getIt.registerLazySingleton<ConnectionStatsStore>(() => ConnectionStatsStore.instance);
|
||||
|
||||
await Future.wait(_allBackup.map((store) => store.init()));
|
||||
}
|
||||
|
||||
|
||||
190
lib/data/store/connection_stats.dart
Normal file
190
lib/data/store/connection_stats.dart
Normal file
@@ -0,0 +1,190 @@
|
||||
import 'package:fl_lib/fl_lib.dart';
|
||||
import 'package:server_box/data/model/server/connection_stat.dart';
|
||||
|
||||
class ConnectionStatsStore extends HiveStore {
|
||||
ConnectionStatsStore._() : super('connection_stats');
|
||||
|
||||
static final instance = ConnectionStatsStore._();
|
||||
|
||||
// Record a connection attempt
|
||||
void recordConnection(ConnectionStat stat) {
|
||||
final key = '${stat.serverId}_${ShortId.generate()}';
|
||||
set(key, stat);
|
||||
_cleanOldRecords(stat.serverId);
|
||||
}
|
||||
|
||||
// Clean records older than 30 days for a specific server
|
||||
void _cleanOldRecords(String serverId) {
|
||||
final cutoffTime = DateTime.now().subtract(const Duration(days: 30));
|
||||
final allKeys = keys().toList();
|
||||
final keysToDelete = <String>[];
|
||||
|
||||
for (final key in allKeys) {
|
||||
if (key.startsWith(serverId)) {
|
||||
final parts = key.split('_');
|
||||
if (parts.length >= 2) {
|
||||
final timestamp = int.tryParse(parts.last);
|
||||
if (timestamp != null) {
|
||||
final recordTime = DateTime.fromMillisecondsSinceEpoch(timestamp);
|
||||
if (recordTime.isBefore(cutoffTime)) {
|
||||
keysToDelete.add(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (final key in keysToDelete) {
|
||||
remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
// Get connection stats for a specific server
|
||||
ServerConnectionStats getServerStats(String serverId, String serverName) {
|
||||
final allStats = getConnectionHistory(serverId);
|
||||
|
||||
if (allStats.isEmpty) {
|
||||
return ServerConnectionStats(
|
||||
serverId: serverId,
|
||||
serverName: serverName,
|
||||
totalAttempts: 0,
|
||||
successCount: 0,
|
||||
failureCount: 0,
|
||||
recentConnections: [],
|
||||
successRate: 0.0,
|
||||
);
|
||||
}
|
||||
|
||||
final totalAttempts = allStats.length;
|
||||
final successCount = allStats.where((s) => s.result.isSuccess).length;
|
||||
final failureCount = totalAttempts - successCount;
|
||||
final successRate = totalAttempts > 0 ? (successCount / totalAttempts) : 0.0;
|
||||
|
||||
final successTimes = allStats
|
||||
.where((s) => s.result.isSuccess)
|
||||
.map((s) => s.timestamp)
|
||||
.toList();
|
||||
final failureTimes = allStats
|
||||
.where((s) => !s.result.isSuccess)
|
||||
.map((s) => s.timestamp)
|
||||
.toList();
|
||||
|
||||
DateTime? lastSuccessTime;
|
||||
DateTime? lastFailureTime;
|
||||
|
||||
if (successTimes.isNotEmpty) {
|
||||
successTimes.sort((a, b) => b.compareTo(a));
|
||||
lastSuccessTime = successTimes.first;
|
||||
}
|
||||
|
||||
if (failureTimes.isNotEmpty) {
|
||||
failureTimes.sort((a, b) => b.compareTo(a));
|
||||
lastFailureTime = failureTimes.first;
|
||||
}
|
||||
|
||||
// Get recent connections (last 20)
|
||||
final recentConnections = allStats.take(20).toList();
|
||||
|
||||
return ServerConnectionStats(
|
||||
serverId: serverId,
|
||||
serverName: serverName,
|
||||
totalAttempts: totalAttempts,
|
||||
successCount: successCount,
|
||||
failureCount: failureCount,
|
||||
lastSuccessTime: lastSuccessTime,
|
||||
lastFailureTime: lastFailureTime,
|
||||
recentConnections: recentConnections,
|
||||
successRate: successRate,
|
||||
);
|
||||
}
|
||||
|
||||
// Get connection history for a specific server
|
||||
List<ConnectionStat> getConnectionHistory(String serverId) {
|
||||
final allKeys = keys().where((key) => key.startsWith(serverId)).toList();
|
||||
final stats = <ConnectionStat>[];
|
||||
|
||||
for (final key in allKeys) {
|
||||
final stat = get<ConnectionStat>(
|
||||
key,
|
||||
fromObj: (val) {
|
||||
if (val is ConnectionStat) return val;
|
||||
if (val is Map<dynamic, dynamic>) {
|
||||
final map = val.toStrDynMap;
|
||||
if (map == null) return null;
|
||||
try {
|
||||
return ConnectionStat.fromJson(map as Map<String, dynamic>);
|
||||
} catch (e) {
|
||||
dprint('Parsing ConnectionStat from JSON', e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
);
|
||||
if (stat != null) {
|
||||
stats.add(stat);
|
||||
}
|
||||
}
|
||||
|
||||
// Sort by timestamp, newest first
|
||||
stats.sort((a, b) => b.timestamp.compareTo(a.timestamp));
|
||||
return stats;
|
||||
}
|
||||
|
||||
// Get all servers' stats
|
||||
List<ServerConnectionStats> getAllServerStats() {
|
||||
final serverIds = <String>{};
|
||||
final serverNames = <String, String>{};
|
||||
|
||||
// Get all unique server IDs
|
||||
for (final key in keys()) {
|
||||
final parts = key.split('_');
|
||||
if (parts.length >= 2) {
|
||||
final serverId = parts[0];
|
||||
serverIds.add(serverId);
|
||||
|
||||
// Try to get server name from the stored stat
|
||||
final stat = get<ConnectionStat>(
|
||||
key,
|
||||
fromObj: (val) {
|
||||
if (val is ConnectionStat) return val;
|
||||
if (val is Map<dynamic, dynamic>) {
|
||||
final map = val.toStrDynMap;
|
||||
if (map == null) return null;
|
||||
try {
|
||||
return ConnectionStat.fromJson(map as Map<String, dynamic>);
|
||||
} catch (e) {
|
||||
dprint('Parsing ConnectionStat from JSON', e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
);
|
||||
if (stat != null) {
|
||||
serverNames[serverId] = stat.serverName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final allStats = <ServerConnectionStats>[];
|
||||
for (final serverId in serverIds) {
|
||||
final serverName = serverNames[serverId] ?? serverId;
|
||||
final stats = getServerStats(serverId, serverName);
|
||||
allStats.add(stats);
|
||||
}
|
||||
|
||||
return allStats;
|
||||
}
|
||||
|
||||
// Clear all connection stats
|
||||
void clearAll() {
|
||||
box.clear();
|
||||
}
|
||||
|
||||
// Clear stats for a specific server
|
||||
void clearServerStats(String serverId) {
|
||||
final keysToDelete = keys().where((key) => key.startsWith(serverId)).toList();
|
||||
for (final key in keysToDelete) {
|
||||
remove(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import 'package:fl_lib/fl_lib.dart';
|
||||
import 'package:server_box/data/model/app/menu/server_func.dart';
|
||||
import 'package:server_box/data/model/app/net_view.dart';
|
||||
import 'package:server_box/data/model/app/server_detail_card.dart';
|
||||
import 'package:server_box/data/model/app/tab.dart';
|
||||
import 'package:server_box/data/model/ssh/virtual_key.dart';
|
||||
import 'package:server_box/data/res/default.dart';
|
||||
|
||||
@@ -22,10 +23,7 @@ class SettingStore extends HiveStore {
|
||||
// late final launchPage = property('launchPage', Defaults.launchPageIdx);
|
||||
|
||||
/// Disk view: amount / IO
|
||||
late final serverTabPreferDiskAmount = propertyDefault(
|
||||
'serverTabPreferDiskAmount',
|
||||
false,
|
||||
);
|
||||
late final serverTabPreferDiskAmount = propertyDefault('serverTabPreferDiskAmount', false);
|
||||
|
||||
/// Bigger for bigger font size
|
||||
/// 1.0 means 100%
|
||||
@@ -70,20 +68,14 @@ class SettingStore extends HiveStore {
|
||||
late final locale = propertyDefault('locale', '');
|
||||
|
||||
// SSH virtual key (ctrl | alt) auto turn off
|
||||
late final sshVirtualKeyAutoOff = propertyDefault(
|
||||
'sshVirtualKeyAutoOff',
|
||||
true,
|
||||
);
|
||||
late final sshVirtualKeyAutoOff = propertyDefault('sshVirtualKeyAutoOff', true);
|
||||
|
||||
late final editorFontSize = propertyDefault('editorFontSize', 12.5);
|
||||
|
||||
// Editor theme
|
||||
late final editorTheme = propertyDefault('editorTheme', Defaults.editorTheme);
|
||||
|
||||
late final editorDarkTheme = propertyDefault(
|
||||
'editorDarkTheme',
|
||||
Defaults.editorDarkTheme,
|
||||
);
|
||||
late final editorDarkTheme = propertyDefault('editorDarkTheme', Defaults.editorDarkTheme);
|
||||
|
||||
late final fullScreen = propertyDefault('fullScreen', false);
|
||||
|
||||
@@ -113,29 +105,20 @@ class SettingStore extends HiveStore {
|
||||
);
|
||||
|
||||
// Only valid on iOS
|
||||
late final autoUpdateHomeWidget = propertyDefault(
|
||||
'autoUpdateHomeWidget',
|
||||
isIOS,
|
||||
);
|
||||
late final autoUpdateHomeWidget = propertyDefault('autoUpdateHomeWidget', isIOS);
|
||||
|
||||
late final autoCheckAppUpdate = propertyDefault('autoCheckAppUpdate', true);
|
||||
|
||||
/// Display server tab function buttons on the bottom of each server card if [true]
|
||||
///
|
||||
/// Otherwise, display them on the top of server detail page
|
||||
late final moveServerFuncs = propertyDefault(
|
||||
'moveOutServerTabFuncBtns',
|
||||
false,
|
||||
);
|
||||
late final moveServerFuncs = propertyDefault('moveOutServerTabFuncBtns', false);
|
||||
|
||||
/// Whether use `rm -r` to delete directory on SFTP
|
||||
late final sftpRmrDir = propertyDefault('sftpRmrDir', false);
|
||||
|
||||
/// Whether use system's primary color as the app's primary color
|
||||
late final useSystemPrimaryColor = propertyDefault(
|
||||
'useSystemPrimaryColor',
|
||||
false,
|
||||
);
|
||||
late final useSystemPrimaryColor = propertyDefault('useSystemPrimaryColor', false);
|
||||
|
||||
/// Only valid on iOS / Android / Windows
|
||||
late final useBioAuth = propertyDefault('useBioAuth', false);
|
||||
@@ -151,10 +134,7 @@ class SettingStore extends HiveStore {
|
||||
late final sftpOpenLastPath = propertyDefault('sftpOpenLastPath', true);
|
||||
|
||||
/// Show folders first in SFTP file browser
|
||||
late final sftpShowFoldersFirst = propertyDefault(
|
||||
'sftpShowFoldersFirst',
|
||||
true,
|
||||
);
|
||||
late final sftpShowFoldersFirst = propertyDefault('sftpShowFoldersFirst', true);
|
||||
|
||||
/// Show tip of suspend
|
||||
late final showSuspendTip = propertyDefault('showSuspendTip', true);
|
||||
@@ -162,10 +142,7 @@ class SettingStore extends HiveStore {
|
||||
/// Whether collapse UI items by default
|
||||
late final collapseUIDefault = propertyDefault('collapseUIDefault', true);
|
||||
|
||||
late final serverFuncBtns = listProperty(
|
||||
'serverBtns',
|
||||
defaultValue: ServerFuncBtn.defaultIdxs,
|
||||
);
|
||||
late final serverFuncBtns = listProperty('serverBtns', defaultValue: ServerFuncBtn.defaultIdxs);
|
||||
|
||||
/// Docker is more popular than podman, set to `false` to use docker
|
||||
late final usePodman = propertyDefault('usePodman', false);
|
||||
@@ -180,16 +157,10 @@ class SettingStore extends HiveStore {
|
||||
late final containerParseStat = propertyDefault('containerParseStat', true);
|
||||
|
||||
/// Auto refresh container status
|
||||
late final containerAutoRefresh = propertyDefault(
|
||||
'containerAutoRefresh',
|
||||
true,
|
||||
);
|
||||
late final containerAutoRefresh = propertyDefault('containerAutoRefresh', true);
|
||||
|
||||
/// Use double column servers page on Desktop
|
||||
late final doubleColumnServersPage = propertyDefault(
|
||||
'doubleColumnServersPage',
|
||||
true,
|
||||
);
|
||||
late final doubleColumnServersPage = propertyDefault('doubleColumnServersPage', true);
|
||||
|
||||
/// Ignore local network device (eg: br-xxx, ovs-system...)
|
||||
/// when building traffic view on server tab
|
||||
@@ -244,8 +215,7 @@ class SettingStore extends HiveStore {
|
||||
/// Record the position and size of the window.
|
||||
late final windowState = property<WindowState>(
|
||||
'windowState',
|
||||
fromObj: (raw) =>
|
||||
WindowState.fromJson(jsonDecode(raw as String) as Map<String, dynamic>),
|
||||
fromObj: (raw) => WindowState.fromJson(jsonDecode(raw as String) as Map<String, dynamic>),
|
||||
toObj: (state) => state == null ? null : jsonEncode(state.toJson()),
|
||||
);
|
||||
|
||||
@@ -258,10 +228,7 @@ class SettingStore extends HiveStore {
|
||||
late final sftpEditor = propertyDefault('sftpEditor', '');
|
||||
|
||||
/// Preferred terminal emulator command on desktop
|
||||
late final desktopTerminal = propertyDefault(
|
||||
'desktopTerminal',
|
||||
'x-terminal-emulator',
|
||||
);
|
||||
late final desktopTerminal = propertyDefault('desktopTerminal', 'x-terminal-emulator');
|
||||
|
||||
/// Run foreground service on Android, if the SSH terminal is running
|
||||
late final fgService = propertyDefault('fgService', false);
|
||||
@@ -277,4 +244,17 @@ class SettingStore extends HiveStore {
|
||||
|
||||
/// The backup password
|
||||
late final backupasswd = SecureProp('bakPasswd');
|
||||
|
||||
/// Whether to read SSH config from ~/.ssh/config on first time
|
||||
late final firstTimeReadSSHCfg = propertyDefault('firstTimeReadSSHCfg', true);
|
||||
|
||||
/// Tabs at home page
|
||||
late final homeTabs = listProperty(
|
||||
'homeTabs',
|
||||
defaultValue: AppTab.values,
|
||||
fromObj: AppTab.parseAppTabsFromObj,
|
||||
toObj: (val) {
|
||||
return val?.map((e) => e.name).toList() ?? [];
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -185,17 +185,17 @@ abstract class AppLocalizations {
|
||||
/// **'Automatic home widget update'**
|
||||
String get autoUpdateHomeWidget;
|
||||
|
||||
/// No description provided for @backupTip.
|
||||
/// No description provided for @backupEncrypted.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'The exported data can be encrypted with password. \nPlease keep it safe.'**
|
||||
String get backupTip;
|
||||
/// **'Backup is encrypted'**
|
||||
String get backupEncrypted;
|
||||
|
||||
/// No description provided for @backupVersionNotMatch.
|
||||
/// No description provided for @backupNotEncrypted.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Backup version is not match.'**
|
||||
String get backupVersionNotMatch;
|
||||
/// **'Backup is not encrypted'**
|
||||
String get backupNotEncrypted;
|
||||
|
||||
/// No description provided for @backupPassword.
|
||||
///
|
||||
@@ -203,6 +203,18 @@ abstract class AppLocalizations {
|
||||
/// **'Backup password'**
|
||||
String get backupPassword;
|
||||
|
||||
/// No description provided for @backupPasswordRemoved.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Backup password removed'**
|
||||
String get backupPasswordRemoved;
|
||||
|
||||
/// No description provided for @backupPasswordSet.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Backup password set'**
|
||||
String get backupPasswordSet;
|
||||
|
||||
/// No description provided for @backupPasswordTip.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
@@ -215,29 +227,17 @@ abstract class AppLocalizations {
|
||||
/// **'Incorrect backup password'**
|
||||
String get backupPasswordWrong;
|
||||
|
||||
/// No description provided for @backupEncrypted.
|
||||
/// No description provided for @backupTip.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Backup is encrypted'**
|
||||
String get backupEncrypted;
|
||||
/// **'The exported data can be encrypted with password. \nPlease keep it safe.'**
|
||||
String get backupTip;
|
||||
|
||||
/// No description provided for @backupNotEncrypted.
|
||||
/// No description provided for @backupVersionNotMatch.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Backup is not encrypted'**
|
||||
String get backupNotEncrypted;
|
||||
|
||||
/// No description provided for @backupPasswordSet.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Backup password set'**
|
||||
String get backupPasswordSet;
|
||||
|
||||
/// No description provided for @backupPasswordRemoved.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Backup password removed'**
|
||||
String get backupPasswordRemoved;
|
||||
/// **'Backup version is not match.'**
|
||||
String get backupVersionNotMatch;
|
||||
|
||||
/// No description provided for @battery.
|
||||
///
|
||||
@@ -1202,6 +1202,84 @@ abstract class AppLocalizations {
|
||||
/// **'Spent time: {time}'**
|
||||
String spentTime(Object time);
|
||||
|
||||
/// No description provided for @sshConfigAllExist.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'All servers already exist ({duplicateCount} duplicates found)'**
|
||||
String sshConfigAllExist(Object duplicateCount);
|
||||
|
||||
/// No description provided for @sshConfigDuplicatesSkipped.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'{duplicateCount} duplicates will be skipped'**
|
||||
String sshConfigDuplicatesSkipped(Object duplicateCount);
|
||||
|
||||
/// No description provided for @sshConfigFound.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'We found SSH configuration on your system.'**
|
||||
String get sshConfigFound;
|
||||
|
||||
/// No description provided for @sshConfigFoundServers.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Found {totalCount} servers'**
|
||||
String sshConfigFoundServers(Object totalCount);
|
||||
|
||||
/// No description provided for @sshConfigImport.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'SSH Config Import'**
|
||||
String get sshConfigImport;
|
||||
|
||||
/// No description provided for @sshConfigImportHelp.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Only basic information can be imported, for example: IP/Port.'**
|
||||
String get sshConfigImportHelp;
|
||||
|
||||
/// No description provided for @sshConfigImportPermission.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Would you like to give permission to read ~/.ssh/config and automatically import server settings?'**
|
||||
String get sshConfigImportPermission;
|
||||
|
||||
/// No description provided for @sshConfigImportTip.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Prompt to read ~/.ssh/config on first server creation'**
|
||||
String get sshConfigImportTip;
|
||||
|
||||
/// No description provided for @sshConfigImported.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Imported {count} servers from SSH config'**
|
||||
String sshConfigImported(Object count);
|
||||
|
||||
/// No description provided for @sshConfigManualSelect.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Would you like to select the SSH config file manually?'**
|
||||
String get sshConfigManualSelect;
|
||||
|
||||
/// No description provided for @sshConfigNoServers.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'No servers found in SSH config'**
|
||||
String get sshConfigNoServers;
|
||||
|
||||
/// No description provided for @sshConfigPermissionDenied.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Cannot access SSH config file due to macOS permissions.'**
|
||||
String get sshConfigPermissionDenied;
|
||||
|
||||
/// No description provided for @sshConfigServersToImport.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'{importCount} servers will be imported'**
|
||||
String sshConfigServersToImport(Object importCount);
|
||||
|
||||
/// No description provided for @sshTermHelp.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
@@ -1543,6 +1621,126 @@ abstract class AppLocalizations {
|
||||
/// In en, this message translates to:
|
||||
/// **'After connecting to the server, a script will be written to `~/.config/server_box` \n | `/tmp/server_box` to monitor the system status. You can review the script content.'**
|
||||
String get writeScriptTip;
|
||||
|
||||
/// No description provided for @connectionStats.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Connection Statistics'**
|
||||
String get connectionStats;
|
||||
|
||||
/// No description provided for @connectionStatsDesc.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'View server connection success rate and history'**
|
||||
String get connectionStatsDesc;
|
||||
|
||||
/// No description provided for @noConnectionStatsData.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'No connection statistics data'**
|
||||
String get noConnectionStatsData;
|
||||
|
||||
/// No description provided for @totalAttempts.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Total'**
|
||||
String get totalAttempts;
|
||||
|
||||
/// No description provided for @lastSuccess.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Last Success'**
|
||||
String get lastSuccess;
|
||||
|
||||
/// No description provided for @lastFailure.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Last Failure'**
|
||||
String get lastFailure;
|
||||
|
||||
/// No description provided for @recentConnections.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Recent Connections'**
|
||||
String get recentConnections;
|
||||
|
||||
/// No description provided for @viewDetails.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'View Details'**
|
||||
String get viewDetails;
|
||||
|
||||
/// No description provided for @connectionDetails.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Connection Details'**
|
||||
String get connectionDetails;
|
||||
|
||||
/// No description provided for @clearThisServerStats.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Clear This Server Statistics'**
|
||||
String get clearThisServerStats;
|
||||
|
||||
/// No description provided for @clearAllStatsTitle.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Clear All Statistics'**
|
||||
String get clearAllStatsTitle;
|
||||
|
||||
/// No description provided for @clearAllStatsContent.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Are you sure you want to clear all server connection statistics? This action cannot be undone.'**
|
||||
String get clearAllStatsContent;
|
||||
|
||||
/// No description provided for @clearServerStatsTitle.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Clear {serverName} Statistics'**
|
||||
String clearServerStatsTitle(String serverName);
|
||||
|
||||
/// No description provided for @clearServerStatsContent.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Are you sure you want to clear connection statistics for server \"{serverName}\"? This action cannot be undone.'**
|
||||
String clearServerStatsContent(String serverName);
|
||||
|
||||
/// No description provided for @homeTabs.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Home Tabs'**
|
||||
String get homeTabs;
|
||||
|
||||
/// No description provided for @homeTabsCustomizeDesc.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Customize which tabs appear on the home page and their order'**
|
||||
String get homeTabsCustomizeDesc;
|
||||
|
||||
/// No description provided for @reset.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Reset'**
|
||||
String get reset;
|
||||
|
||||
/// No description provided for @availableTabs.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Available Tabs'**
|
||||
String get availableTabs;
|
||||
|
||||
/// No description provided for @atLeastOneTab.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'At least one tab must be selected'**
|
||||
String get atLeastOneTab;
|
||||
|
||||
/// No description provided for @serverTabRequired.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Server tab cannot be removed'**
|
||||
String get serverTabRequired;
|
||||
}
|
||||
|
||||
class _AppLocalizationsDelegate
|
||||
|
||||
@@ -46,16 +46,20 @@ class AppLocalizationsDe extends AppLocalizations {
|
||||
String get autoUpdateHomeWidget => 'Home-Widget automatisch aktualisieren';
|
||||
|
||||
@override
|
||||
String get backupTip =>
|
||||
'Die exportierten Daten können mit einem Passwort verschlüsselt werden. \nBitte sicher aufbewahren.';
|
||||
String get backupEncrypted => 'Backup ist verschlüsselt';
|
||||
|
||||
@override
|
||||
String get backupVersionNotMatch =>
|
||||
'Die Backup-Version stimmt nicht überein.';
|
||||
String get backupNotEncrypted => 'Backup ist nicht verschlüsselt';
|
||||
|
||||
@override
|
||||
String get backupPassword => 'Backup-Passwort';
|
||||
|
||||
@override
|
||||
String get backupPasswordRemoved => 'Backup-Passwort entfernt';
|
||||
|
||||
@override
|
||||
String get backupPasswordSet => 'Backup-Passwort gesetzt';
|
||||
|
||||
@override
|
||||
String get backupPasswordTip =>
|
||||
'Setzen Sie ein Passwort, um Backup-Dateien zu verschlüsseln. Leer lassen, um Verschlüsselung zu deaktivieren.';
|
||||
@@ -64,16 +68,12 @@ class AppLocalizationsDe extends AppLocalizations {
|
||||
String get backupPasswordWrong => 'Falsches Backup-Passwort';
|
||||
|
||||
@override
|
||||
String get backupEncrypted => 'Backup ist verschlüsselt';
|
||||
String get backupTip =>
|
||||
'Die exportierten Daten können mit einem Passwort verschlüsselt werden. \nBitte sicher aufbewahren.';
|
||||
|
||||
@override
|
||||
String get backupNotEncrypted => 'Backup ist nicht verschlüsselt';
|
||||
|
||||
@override
|
||||
String get backupPasswordSet => 'Backup-Passwort gesetzt';
|
||||
|
||||
@override
|
||||
String get backupPasswordRemoved => 'Backup-Passwort entfernt';
|
||||
String get backupVersionNotMatch =>
|
||||
'Die Backup-Version stimmt nicht überein.';
|
||||
|
||||
@override
|
||||
String get battery => 'Batterie';
|
||||
@@ -606,6 +606,62 @@ class AppLocalizationsDe extends AppLocalizations {
|
||||
return 'Benötigte Zeit: $time';
|
||||
}
|
||||
|
||||
@override
|
||||
String sshConfigAllExist(Object duplicateCount) {
|
||||
return 'Alle Server existieren bereits ($duplicateCount Duplikate gefunden)';
|
||||
}
|
||||
|
||||
@override
|
||||
String sshConfigDuplicatesSkipped(Object duplicateCount) {
|
||||
return '$duplicateCount Duplikate werden übersprungen';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshConfigFound =>
|
||||
'Wir haben SSH-Konfiguration auf Ihrem System gefunden.';
|
||||
|
||||
@override
|
||||
String sshConfigFoundServers(Object totalCount) {
|
||||
return '$totalCount Server gefunden';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshConfigImport => 'SSH-Konfiguration importieren';
|
||||
|
||||
@override
|
||||
String get sshConfigImportHelp =>
|
||||
'Es können nur Basisinformationen importiert werden, zum Beispiel: IP/Port.';
|
||||
|
||||
@override
|
||||
String get sshConfigImportPermission =>
|
||||
'Möchten Sie die Berechtigung erteilen, ~/.ssh/config zu lesen und Server-Einstellungen automatisch zu importieren?';
|
||||
|
||||
@override
|
||||
String get sshConfigImportTip =>
|
||||
'Bei der ersten Server-Erstellung zum Lesen von ~/.ssh/config auffordern';
|
||||
|
||||
@override
|
||||
String sshConfigImported(Object count) {
|
||||
return '$count Server aus SSH-Konfiguration importiert';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshConfigManualSelect =>
|
||||
'Möchten Sie die SSH-Konfigurationsdatei manuell auswählen?';
|
||||
|
||||
@override
|
||||
String get sshConfigNoServers =>
|
||||
'Keine Server in der SSH-Konfiguration gefunden';
|
||||
|
||||
@override
|
||||
String get sshConfigPermissionDenied =>
|
||||
'Aufgrund der macOS-Berechtigungen kann nicht auf die SSH-Konfigurationsdatei zugegriffen werden.';
|
||||
|
||||
@override
|
||||
String sshConfigServersToImport(Object importCount) {
|
||||
return '$importCount Server werden importiert';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshTermHelp =>
|
||||
'Wenn das Terminal scrollbar ist, kann durch horizontales Ziehen Text ausgewählt werden. Durch Klicken auf die Tastentaste wird die Tastatur ein- oder ausgeschaltet. Das Dateisymbol öffnet den aktuellen Pfad SFTP. Die Zwischenablage-Schaltfläche kopiert den Inhalt, wenn Text ausgewählt ist, und fügt Inhalte aus der Zwischenablage in das Terminal ein, wenn kein Text ausgewählt ist und Inhalte in der Zwischenablage vorhanden sind. Das Codesymbol fügt Code-Schnipsel ins Terminal ein und führt sie aus.';
|
||||
@@ -795,4 +851,71 @@ class AppLocalizationsDe extends AppLocalizations {
|
||||
@override
|
||||
String get writeScriptTip =>
|
||||
'Nach der Verbindung mit dem Server wird ein Skript in `~/.config/server_box` \n | `/tmp/server_box` geschrieben, um den Systemstatus zu überwachen. Sie können den Skriptinhalt überprüfen.';
|
||||
|
||||
@override
|
||||
String get connectionStats => 'Verbindungsstatistiken';
|
||||
|
||||
@override
|
||||
String get connectionStatsDesc =>
|
||||
'Server-Verbindungserfolgsrate und Verlauf anzeigen';
|
||||
|
||||
@override
|
||||
String get noConnectionStatsData => 'Keine Verbindungsstatistikdaten';
|
||||
|
||||
@override
|
||||
String get totalAttempts => 'Gesamt';
|
||||
|
||||
@override
|
||||
String get lastSuccess => 'Letzter Erfolg';
|
||||
|
||||
@override
|
||||
String get lastFailure => 'Letzter Fehler';
|
||||
|
||||
@override
|
||||
String get recentConnections => 'Kürzliche Verbindungen';
|
||||
|
||||
@override
|
||||
String get viewDetails => 'Details anzeigen';
|
||||
|
||||
@override
|
||||
String get connectionDetails => 'Verbindungsdetails';
|
||||
|
||||
@override
|
||||
String get clearThisServerStats => 'Statistiken dieses Servers löschen';
|
||||
|
||||
@override
|
||||
String get clearAllStatsTitle => 'Alle Statistiken löschen';
|
||||
|
||||
@override
|
||||
String get clearAllStatsContent =>
|
||||
'Sind Sie sicher, dass Sie alle Server-Verbindungsstatistiken löschen möchten? Diese Aktion kann nicht rückgängig gemacht werden.';
|
||||
|
||||
@override
|
||||
String clearServerStatsTitle(String serverName) {
|
||||
return '$serverName Statistiken löschen';
|
||||
}
|
||||
|
||||
@override
|
||||
String clearServerStatsContent(String serverName) {
|
||||
return 'Sind Sie sicher, dass Sie die Verbindungsstatistiken für Server \"$serverName\" löschen möchten? Diese Aktion kann nicht rückgängig gemacht werden.';
|
||||
}
|
||||
|
||||
@override
|
||||
String get homeTabs => 'Home-Tabs';
|
||||
|
||||
@override
|
||||
String get homeTabsCustomizeDesc =>
|
||||
'Passen Sie an, welche Tabs auf der Startseite angezeigt werden und ihre Reihenfolge';
|
||||
|
||||
@override
|
||||
String get reset => 'Zurücksetzen';
|
||||
|
||||
@override
|
||||
String get availableTabs => 'Verfügbare Tabs';
|
||||
|
||||
@override
|
||||
String get atLeastOneTab => 'Mindestens ein Tab muss ausgewählt sein';
|
||||
|
||||
@override
|
||||
String get serverTabRequired => 'Server-Tab kann nicht entfernt werden';
|
||||
}
|
||||
|
||||
@@ -46,15 +46,20 @@ class AppLocalizationsEn extends AppLocalizations {
|
||||
String get autoUpdateHomeWidget => 'Automatic home widget update';
|
||||
|
||||
@override
|
||||
String get backupTip =>
|
||||
'The exported data can be encrypted with password. \nPlease keep it safe.';
|
||||
String get backupEncrypted => 'Backup is encrypted';
|
||||
|
||||
@override
|
||||
String get backupVersionNotMatch => 'Backup version is not match.';
|
||||
String get backupNotEncrypted => 'Backup is not encrypted';
|
||||
|
||||
@override
|
||||
String get backupPassword => 'Backup password';
|
||||
|
||||
@override
|
||||
String get backupPasswordRemoved => 'Backup password removed';
|
||||
|
||||
@override
|
||||
String get backupPasswordSet => 'Backup password set';
|
||||
|
||||
@override
|
||||
String get backupPasswordTip =>
|
||||
'Set a password to encrypt backup files. Leave empty to disable encryption.';
|
||||
@@ -63,16 +68,11 @@ class AppLocalizationsEn extends AppLocalizations {
|
||||
String get backupPasswordWrong => 'Incorrect backup password';
|
||||
|
||||
@override
|
||||
String get backupEncrypted => 'Backup is encrypted';
|
||||
String get backupTip =>
|
||||
'The exported data can be encrypted with password. \nPlease keep it safe.';
|
||||
|
||||
@override
|
||||
String get backupNotEncrypted => 'Backup is not encrypted';
|
||||
|
||||
@override
|
||||
String get backupPasswordSet => 'Backup password set';
|
||||
|
||||
@override
|
||||
String get backupPasswordRemoved => 'Backup password removed';
|
||||
String get backupVersionNotMatch => 'Backup version is not match.';
|
||||
|
||||
@override
|
||||
String get battery => 'Battery';
|
||||
@@ -602,6 +602,60 @@ class AppLocalizationsEn extends AppLocalizations {
|
||||
return 'Spent time: $time';
|
||||
}
|
||||
|
||||
@override
|
||||
String sshConfigAllExist(Object duplicateCount) {
|
||||
return 'All servers already exist ($duplicateCount duplicates found)';
|
||||
}
|
||||
|
||||
@override
|
||||
String sshConfigDuplicatesSkipped(Object duplicateCount) {
|
||||
return '$duplicateCount duplicates will be skipped';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshConfigFound => 'We found SSH configuration on your system.';
|
||||
|
||||
@override
|
||||
String sshConfigFoundServers(Object totalCount) {
|
||||
return 'Found $totalCount servers';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshConfigImport => 'SSH Config Import';
|
||||
|
||||
@override
|
||||
String get sshConfigImportHelp =>
|
||||
'Only basic information can be imported, for example: IP/Port.';
|
||||
|
||||
@override
|
||||
String get sshConfigImportPermission =>
|
||||
'Would you like to give permission to read ~/.ssh/config and automatically import server settings?';
|
||||
|
||||
@override
|
||||
String get sshConfigImportTip =>
|
||||
'Prompt to read ~/.ssh/config on first server creation';
|
||||
|
||||
@override
|
||||
String sshConfigImported(Object count) {
|
||||
return 'Imported $count servers from SSH config';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshConfigManualSelect =>
|
||||
'Would you like to select the SSH config file manually?';
|
||||
|
||||
@override
|
||||
String get sshConfigNoServers => 'No servers found in SSH config';
|
||||
|
||||
@override
|
||||
String get sshConfigPermissionDenied =>
|
||||
'Cannot access SSH config file due to macOS permissions.';
|
||||
|
||||
@override
|
||||
String sshConfigServersToImport(Object importCount) {
|
||||
return '$importCount servers will be imported';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshTermHelp =>
|
||||
'When the terminal is scrollable, dragging horizontally can select text. Clicking the keyboard button turns the keyboard on/off. The file icon opens the current path SFTP. The clipboard button copies the content when text is selected, and pastes content from the clipboard into the terminal when no text is selected and there is content on the clipboard. The code icon pastes code snippets into the terminal and executes them.';
|
||||
@@ -789,4 +843,71 @@ class AppLocalizationsEn extends AppLocalizations {
|
||||
@override
|
||||
String get writeScriptTip =>
|
||||
'After connecting to the server, a script will be written to `~/.config/server_box` \n | `/tmp/server_box` to monitor the system status. You can review the script content.';
|
||||
|
||||
@override
|
||||
String get connectionStats => 'Connection Statistics';
|
||||
|
||||
@override
|
||||
String get connectionStatsDesc =>
|
||||
'View server connection success rate and history';
|
||||
|
||||
@override
|
||||
String get noConnectionStatsData => 'No connection statistics data';
|
||||
|
||||
@override
|
||||
String get totalAttempts => 'Total';
|
||||
|
||||
@override
|
||||
String get lastSuccess => 'Last Success';
|
||||
|
||||
@override
|
||||
String get lastFailure => 'Last Failure';
|
||||
|
||||
@override
|
||||
String get recentConnections => 'Recent Connections';
|
||||
|
||||
@override
|
||||
String get viewDetails => 'View Details';
|
||||
|
||||
@override
|
||||
String get connectionDetails => 'Connection Details';
|
||||
|
||||
@override
|
||||
String get clearThisServerStats => 'Clear This Server Statistics';
|
||||
|
||||
@override
|
||||
String get clearAllStatsTitle => 'Clear All Statistics';
|
||||
|
||||
@override
|
||||
String get clearAllStatsContent =>
|
||||
'Are you sure you want to clear all server connection statistics? This action cannot be undone.';
|
||||
|
||||
@override
|
||||
String clearServerStatsTitle(String serverName) {
|
||||
return 'Clear $serverName Statistics';
|
||||
}
|
||||
|
||||
@override
|
||||
String clearServerStatsContent(String serverName) {
|
||||
return 'Are you sure you want to clear connection statistics for server \"$serverName\"? This action cannot be undone.';
|
||||
}
|
||||
|
||||
@override
|
||||
String get homeTabs => 'Home Tabs';
|
||||
|
||||
@override
|
||||
String get homeTabsCustomizeDesc =>
|
||||
'Customize which tabs appear on the home page and their order';
|
||||
|
||||
@override
|
||||
String get reset => 'Reset';
|
||||
|
||||
@override
|
||||
String get availableTabs => 'Available Tabs';
|
||||
|
||||
@override
|
||||
String get atLeastOneTab => 'At least one tab must be selected';
|
||||
|
||||
@override
|
||||
String get serverTabRequired => 'Server tab cannot be removed';
|
||||
}
|
||||
|
||||
@@ -46,16 +46,20 @@ class AppLocalizationsEs extends AppLocalizations {
|
||||
'Actualizar automáticamente el widget del escritorio';
|
||||
|
||||
@override
|
||||
String get backupTip =>
|
||||
'Los datos exportados pueden ser encriptados con contraseña. \nPor favor guárdalos en un lugar seguro.';
|
||||
String get backupEncrypted => 'El respaldo está encriptado';
|
||||
|
||||
@override
|
||||
String get backupVersionNotMatch =>
|
||||
'La versión de la copia de seguridad no coincide, no se puede restaurar';
|
||||
String get backupNotEncrypted => 'El respaldo no está encriptado';
|
||||
|
||||
@override
|
||||
String get backupPassword => 'Contraseña de respaldo';
|
||||
|
||||
@override
|
||||
String get backupPasswordRemoved => 'Contraseña de respaldo eliminada';
|
||||
|
||||
@override
|
||||
String get backupPasswordSet => 'Contraseña de respaldo establecida';
|
||||
|
||||
@override
|
||||
String get backupPasswordTip =>
|
||||
'Establece una contraseña para encriptar archivos de respaldo. Déjalo vacío para desactivar la encriptación.';
|
||||
@@ -64,16 +68,12 @@ class AppLocalizationsEs extends AppLocalizations {
|
||||
String get backupPasswordWrong => 'Contraseña de respaldo incorrecta';
|
||||
|
||||
@override
|
||||
String get backupEncrypted => 'El respaldo está encriptado';
|
||||
String get backupTip =>
|
||||
'Los datos exportados pueden ser encriptados con contraseña. \nPor favor guárdalos en un lugar seguro.';
|
||||
|
||||
@override
|
||||
String get backupNotEncrypted => 'El respaldo no está encriptado';
|
||||
|
||||
@override
|
||||
String get backupPasswordSet => 'Contraseña de respaldo establecida';
|
||||
|
||||
@override
|
||||
String get backupPasswordRemoved => 'Contraseña de respaldo eliminada';
|
||||
String get backupVersionNotMatch =>
|
||||
'La versión de la copia de seguridad no coincide, no se puede restaurar';
|
||||
|
||||
@override
|
||||
String get battery => 'Batería';
|
||||
@@ -609,6 +609,61 @@ class AppLocalizationsEs extends AppLocalizations {
|
||||
return 'Tiempo gastado: $time';
|
||||
}
|
||||
|
||||
@override
|
||||
String sshConfigAllExist(Object duplicateCount) {
|
||||
return 'Todos los servidores ya existen (se encontraron $duplicateCount duplicados)';
|
||||
}
|
||||
|
||||
@override
|
||||
String sshConfigDuplicatesSkipped(Object duplicateCount) {
|
||||
return 'Se omitirán $duplicateCount duplicados';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshConfigFound => 'Encontramos configuración SSH en tu sistema';
|
||||
|
||||
@override
|
||||
String sshConfigFoundServers(Object totalCount) {
|
||||
return 'Se encontraron $totalCount servidores';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshConfigImport => 'Importar Configuración SSH';
|
||||
|
||||
@override
|
||||
String get sshConfigImportHelp =>
|
||||
'Solo se pueden importar datos básicos, por ejemplo: IP/Puerto.';
|
||||
|
||||
@override
|
||||
String get sshConfigImportPermission =>
|
||||
'¿Te gustaría dar permiso para leer ~/.ssh/config e importar automáticamente la configuración de servidores?';
|
||||
|
||||
@override
|
||||
String get sshConfigImportTip =>
|
||||
'Sugerencia para leer ~/.ssh/config al crear el primer servidor';
|
||||
|
||||
@override
|
||||
String sshConfigImported(Object count) {
|
||||
return 'Se importaron $count servidores desde la configuración SSH';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshConfigManualSelect =>
|
||||
'¿Te gustaría seleccionar manualmente el archivo de configuración SSH?';
|
||||
|
||||
@override
|
||||
String get sshConfigNoServers =>
|
||||
'No se encontraron servidores en la configuración SSH';
|
||||
|
||||
@override
|
||||
String get sshConfigPermissionDenied =>
|
||||
'No se puede acceder al archivo de configuración SSH debido a los permisos de macOS.';
|
||||
|
||||
@override
|
||||
String sshConfigServersToImport(Object importCount) {
|
||||
return 'Se importarán $importCount servidores';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshTermHelp =>
|
||||
'Cuando el terminal es desplazable, arrastrar horizontalmente puede seleccionar texto. Hacer clic en el botón del teclado enciende/apaga el teclado. El icono de archivo abre el SFTP de la ruta actual. El botón del portapapeles copia el contenido cuando se selecciona texto y pega el contenido del portapapeles en el terminal cuando no se selecciona texto y hay contenido en el portapapeles. El icono de código pega fragmentos de código en el terminal y los ejecuta.';
|
||||
@@ -797,4 +852,72 @@ class AppLocalizationsEs extends AppLocalizations {
|
||||
@override
|
||||
String get writeScriptTip =>
|
||||
'Después de conectarse al servidor, se escribirá un script en `~/.config/server_box` \n | `/tmp/server_box` para monitorear el estado del sistema. Puedes revisar el contenido del script.';
|
||||
|
||||
@override
|
||||
String get connectionStats => 'Estadísticas de conexión';
|
||||
|
||||
@override
|
||||
String get connectionStatsDesc =>
|
||||
'Ver la tasa de éxito de conexión del servidor e historial';
|
||||
|
||||
@override
|
||||
String get noConnectionStatsData =>
|
||||
'No hay datos de estadísticas de conexión';
|
||||
|
||||
@override
|
||||
String get totalAttempts => 'Total';
|
||||
|
||||
@override
|
||||
String get lastSuccess => 'Último éxito';
|
||||
|
||||
@override
|
||||
String get lastFailure => 'Último fallo';
|
||||
|
||||
@override
|
||||
String get recentConnections => 'Conexiones recientes';
|
||||
|
||||
@override
|
||||
String get viewDetails => 'Ver detalles';
|
||||
|
||||
@override
|
||||
String get connectionDetails => 'Detalles de conexión';
|
||||
|
||||
@override
|
||||
String get clearThisServerStats => 'Limpiar estadísticas de este servidor';
|
||||
|
||||
@override
|
||||
String get clearAllStatsTitle => 'Limpiar todas las estadísticas';
|
||||
|
||||
@override
|
||||
String get clearAllStatsContent =>
|
||||
'¿Estás seguro de que quieres limpiar todas las estadísticas de conexión del servidor? Esta acción no se puede deshacer.';
|
||||
|
||||
@override
|
||||
String clearServerStatsTitle(String serverName) {
|
||||
return 'Limpiar estadísticas de $serverName';
|
||||
}
|
||||
|
||||
@override
|
||||
String clearServerStatsContent(String serverName) {
|
||||
return '¿Estás seguro de que quieres limpiar las estadísticas de conexión del servidor \"$serverName\"? Esta acción no se puede deshacer.';
|
||||
}
|
||||
|
||||
@override
|
||||
String get homeTabs => 'Pestañas de inicio';
|
||||
|
||||
@override
|
||||
String get homeTabsCustomizeDesc =>
|
||||
'Personaliza qué pestañas aparecen en la página de inicio y su orden';
|
||||
|
||||
@override
|
||||
String get reset => 'Restablecer';
|
||||
|
||||
@override
|
||||
String get availableTabs => 'Pestañas disponibles';
|
||||
|
||||
@override
|
||||
String get atLeastOneTab => 'Al menos una pestaña debe estar seleccionada';
|
||||
|
||||
@override
|
||||
String get serverTabRequired => 'Server tab cannot be removed';
|
||||
}
|
||||
|
||||
@@ -46,16 +46,20 @@ class AppLocalizationsFr extends AppLocalizations {
|
||||
'Mise à jour automatique du widget d\'accueil';
|
||||
|
||||
@override
|
||||
String get backupTip =>
|
||||
'Les données exportées peuvent être chiffrées avec un mot de passe. \nVeuillez les garder en sécurité.';
|
||||
String get backupEncrypted => 'La sauvegarde est chiffrée';
|
||||
|
||||
@override
|
||||
String get backupVersionNotMatch =>
|
||||
'La version de sauvegarde ne correspond pas.';
|
||||
String get backupNotEncrypted => 'La sauvegarde n\'est pas chiffrée';
|
||||
|
||||
@override
|
||||
String get backupPassword => 'Mot de passe de sauvegarde';
|
||||
|
||||
@override
|
||||
String get backupPasswordRemoved => 'Mot de passe de sauvegarde supprimé';
|
||||
|
||||
@override
|
||||
String get backupPasswordSet => 'Mot de passe de sauvegarde défini';
|
||||
|
||||
@override
|
||||
String get backupPasswordTip =>
|
||||
'Définissez un mot de passe pour chiffrer les fichiers de sauvegarde. Laissez vide pour désactiver le chiffrement.';
|
||||
@@ -64,16 +68,12 @@ class AppLocalizationsFr extends AppLocalizations {
|
||||
String get backupPasswordWrong => 'Mot de passe de sauvegarde incorrect';
|
||||
|
||||
@override
|
||||
String get backupEncrypted => 'La sauvegarde est chiffrée';
|
||||
String get backupTip =>
|
||||
'Les données exportées peuvent être chiffrées avec un mot de passe. \nVeuillez les garder en sécurité.';
|
||||
|
||||
@override
|
||||
String get backupNotEncrypted => 'La sauvegarde n\'est pas chiffrée';
|
||||
|
||||
@override
|
||||
String get backupPasswordSet => 'Mot de passe de sauvegarde défini';
|
||||
|
||||
@override
|
||||
String get backupPasswordRemoved => 'Mot de passe de sauvegarde supprimé';
|
||||
String get backupVersionNotMatch =>
|
||||
'La version de sauvegarde ne correspond pas.';
|
||||
|
||||
@override
|
||||
String get battery => 'Batterie';
|
||||
@@ -610,6 +610,62 @@ class AppLocalizationsFr extends AppLocalizations {
|
||||
return 'Temps écoulé : $time';
|
||||
}
|
||||
|
||||
@override
|
||||
String sshConfigAllExist(Object duplicateCount) {
|
||||
return 'Tous les serveurs existent déjà ($duplicateCount doublons trouvés)';
|
||||
}
|
||||
|
||||
@override
|
||||
String sshConfigDuplicatesSkipped(Object duplicateCount) {
|
||||
return '$duplicateCount doublons seront ignorés';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshConfigFound =>
|
||||
'Nous avons trouvé une configuration SSH sur votre système.';
|
||||
|
||||
@override
|
||||
String sshConfigFoundServers(Object totalCount) {
|
||||
return '$totalCount serveurs trouvés';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshConfigImport => 'Importation de configuration SSH';
|
||||
|
||||
@override
|
||||
String get sshConfigImportHelp =>
|
||||
'Seules les informations de base peuvent être importées, par exemple : IP/Port.';
|
||||
|
||||
@override
|
||||
String get sshConfigImportPermission =>
|
||||
'Souhaitez-vous donner la permission de lire ~/.ssh/config et d\'importer automatiquement les paramètres du serveur ?';
|
||||
|
||||
@override
|
||||
String get sshConfigImportTip =>
|
||||
'Proposer de lire ~/.ssh/config lors de la première création de serveur';
|
||||
|
||||
@override
|
||||
String sshConfigImported(Object count) {
|
||||
return '$count serveurs importés depuis la configuration SSH';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshConfigManualSelect =>
|
||||
'Souhaitez-vous sélectionner manuellement le fichier de configuration SSH ?';
|
||||
|
||||
@override
|
||||
String get sshConfigNoServers =>
|
||||
'Aucun serveur trouvé dans la configuration SSH';
|
||||
|
||||
@override
|
||||
String get sshConfigPermissionDenied =>
|
||||
'Impossible d\'accéder au fichier de configuration SSH en raison des permissions macOS.';
|
||||
|
||||
@override
|
||||
String sshConfigServersToImport(Object importCount) {
|
||||
return '$importCount serveurs seront importés';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshTermHelp =>
|
||||
'Lorsque le terminal est défilable, faire glisser horizontalement permet de sélectionner du texte. En cliquant sur le bouton du clavier, vous activez/désactivez le clavier. L\'icône de fichier ouvre le chemin actuel SFTP. Le bouton du presse-papiers copie le contenu lorsque du texte est sélectionné, et colle le contenu du presse-papiers dans le terminal lorsqu\'aucun texte n\'est sélectionné et qu\'il y a du contenu dans le presse-papiers. L\'icône de code colle des extraits de code dans le terminal et les exécute.';
|
||||
@@ -798,5 +854,73 @@ class AppLocalizationsFr extends AppLocalizations {
|
||||
|
||||
@override
|
||||
String get writeScriptTip =>
|
||||
'Après la connexion au serveur, un script sera écrit dans `~/.config/server_box` \n | `/tmp/server_box` pour surveiller l’état du système. Vous pouvez examiner le contenu du script.';
|
||||
'Après la connexion au serveur, un script sera écrit dans `~/.config/server_box` \n | `/tmp/server_box` pour surveiller l\'état du système. Vous pouvez examiner le contenu du script.';
|
||||
|
||||
@override
|
||||
String get connectionStats => 'Statistiques de connexion';
|
||||
|
||||
@override
|
||||
String get connectionStatsDesc =>
|
||||
'Voir le taux de réussite de connexion du serveur et l\'historique';
|
||||
|
||||
@override
|
||||
String get noConnectionStatsData =>
|
||||
'Aucune donnée de statistiques de connexion';
|
||||
|
||||
@override
|
||||
String get totalAttempts => 'Total';
|
||||
|
||||
@override
|
||||
String get lastSuccess => 'Dernier succès';
|
||||
|
||||
@override
|
||||
String get lastFailure => 'Dernier échec';
|
||||
|
||||
@override
|
||||
String get recentConnections => 'Connexions récentes';
|
||||
|
||||
@override
|
||||
String get viewDetails => 'Voir les détails';
|
||||
|
||||
@override
|
||||
String get connectionDetails => 'Détails de connexion';
|
||||
|
||||
@override
|
||||
String get clearThisServerStats => 'Effacer les statistiques de ce serveur';
|
||||
|
||||
@override
|
||||
String get clearAllStatsTitle => 'Effacer toutes les statistiques';
|
||||
|
||||
@override
|
||||
String get clearAllStatsContent =>
|
||||
'Êtes-vous sûr de vouloir effacer toutes les statistiques de connexion des serveurs ? Cette action ne peut pas être annulée.';
|
||||
|
||||
@override
|
||||
String clearServerStatsTitle(String serverName) {
|
||||
return 'Effacer les statistiques de $serverName';
|
||||
}
|
||||
|
||||
@override
|
||||
String clearServerStatsContent(String serverName) {
|
||||
return 'Êtes-vous sûr de vouloir effacer les statistiques de connexion du serveur \"$serverName\" ? Cette action ne peut pas être annulée.';
|
||||
}
|
||||
|
||||
@override
|
||||
String get homeTabs => 'Onglets d\'accueil';
|
||||
|
||||
@override
|
||||
String get homeTabsCustomizeDesc =>
|
||||
'Personnalisez les onglets qui apparaissent sur la page d\'accueil et leur ordre';
|
||||
|
||||
@override
|
||||
String get reset => 'Réinitialiser';
|
||||
|
||||
@override
|
||||
String get availableTabs => 'Onglets disponibles';
|
||||
|
||||
@override
|
||||
String get atLeastOneTab => 'Au moins un onglet doit être sélectionné';
|
||||
|
||||
@override
|
||||
String get serverTabRequired => 'Server tab cannot be removed';
|
||||
}
|
||||
|
||||
@@ -46,15 +46,20 @@ class AppLocalizationsId extends AppLocalizations {
|
||||
String get autoUpdateHomeWidget => 'Widget Rumah Pembaruan Otomatis';
|
||||
|
||||
@override
|
||||
String get backupTip =>
|
||||
'Data yang diekspor dapat dienkripsi dengan kata sandi. \nHarap jaga keamanannya.';
|
||||
String get backupEncrypted => 'Cadangan telah dienkripsi';
|
||||
|
||||
@override
|
||||
String get backupVersionNotMatch => 'Versi cadangan tidak cocok.';
|
||||
String get backupNotEncrypted => 'Cadangan tidak dienkripsi';
|
||||
|
||||
@override
|
||||
String get backupPassword => 'Kata sandi cadangan';
|
||||
|
||||
@override
|
||||
String get backupPasswordRemoved => 'Kata sandi cadangan dihapus';
|
||||
|
||||
@override
|
||||
String get backupPasswordSet => 'Kata sandi cadangan ditetapkan';
|
||||
|
||||
@override
|
||||
String get backupPasswordTip =>
|
||||
'Setel kata sandi untuk mengenkripsi file cadangan. Biarkan kosong untuk menonaktifkan enkripsi.';
|
||||
@@ -63,16 +68,11 @@ class AppLocalizationsId extends AppLocalizations {
|
||||
String get backupPasswordWrong => 'Kata sandi cadangan salah';
|
||||
|
||||
@override
|
||||
String get backupEncrypted => 'Cadangan telah dienkripsi';
|
||||
String get backupTip =>
|
||||
'Data yang diekspor dapat dienkripsi dengan kata sandi. \nHarap jaga keamanannya.';
|
||||
|
||||
@override
|
||||
String get backupNotEncrypted => 'Cadangan tidak dienkripsi';
|
||||
|
||||
@override
|
||||
String get backupPasswordSet => 'Kata sandi cadangan ditetapkan';
|
||||
|
||||
@override
|
||||
String get backupPasswordRemoved => 'Kata sandi cadangan dihapus';
|
||||
String get backupVersionNotMatch => 'Versi cadangan tidak cocok.';
|
||||
|
||||
@override
|
||||
String get battery => 'Baterai';
|
||||
@@ -603,6 +603,61 @@ class AppLocalizationsId extends AppLocalizations {
|
||||
return 'Menghabiskan waktu: $time';
|
||||
}
|
||||
|
||||
@override
|
||||
String sshConfigAllExist(Object duplicateCount) {
|
||||
return 'Semua server sudah ada (ditemukan $duplicateCount duplikat)';
|
||||
}
|
||||
|
||||
@override
|
||||
String sshConfigDuplicatesSkipped(Object duplicateCount) {
|
||||
return '$duplicateCount duplikat akan dilewati';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshConfigFound => 'Kami menemukan konfigurasi SSH di sistem Anda';
|
||||
|
||||
@override
|
||||
String sshConfigFoundServers(Object totalCount) {
|
||||
return 'Ditemukan $totalCount server';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshConfigImport => 'Impor Konfigurasi SSH';
|
||||
|
||||
@override
|
||||
String get sshConfigImportHelp =>
|
||||
'Hanya informasi dasar yang dapat diimpor, misalnya: IP/Port.';
|
||||
|
||||
@override
|
||||
String get sshConfigImportPermission =>
|
||||
'Apakah Anda ingin memberikan izin untuk membaca ~/.ssh/config dan secara otomatis mengimpor pengaturan server?';
|
||||
|
||||
@override
|
||||
String get sshConfigImportTip =>
|
||||
'Prompt untuk membaca ~/.ssh/config saat pembuatan server pertama';
|
||||
|
||||
@override
|
||||
String sshConfigImported(Object count) {
|
||||
return 'Berhasil mengimpor $count server dari konfigurasi SSH';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshConfigManualSelect =>
|
||||
'Apakah Anda ingin memilih file konfigurasi SSH secara manual?';
|
||||
|
||||
@override
|
||||
String get sshConfigNoServers =>
|
||||
'Tidak ada server yang ditemukan dalam konfigurasi SSH';
|
||||
|
||||
@override
|
||||
String get sshConfigPermissionDenied =>
|
||||
'Tidak dapat mengakses file konfigurasi SSH karena izin macOS.';
|
||||
|
||||
@override
|
||||
String sshConfigServersToImport(Object importCount) {
|
||||
return '$importCount server akan diimpor';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshTermHelp =>
|
||||
'Ketika terminal dapat digulirkan, menggeser secara horizontal dapat memilih teks. Mengklik tombol keyboard mengaktifkan/menonaktifkan keyboard. Ikon file membuka SFTP jalur saat ini. Tombol papan klip menyalin konten saat teks dipilih, dan menempelkan konten dari papan klip ke terminal saat tidak ada teks yang dipilih dan ada konten di papan klip. Ikon kode menempelkan potongan kode ke terminal dan mengeksekusinya.';
|
||||
@@ -788,4 +843,71 @@ class AppLocalizationsId extends AppLocalizations {
|
||||
@override
|
||||
String get writeScriptTip =>
|
||||
'Setelah terhubung ke server, sebuah skrip akan ditulis ke `~/.config/server_box` \n | `/tmp/server_box` untuk memantau status sistem. Anda dapat meninjau konten skrip tersebut.';
|
||||
|
||||
@override
|
||||
String get connectionStats => 'Statistik Koneksi';
|
||||
|
||||
@override
|
||||
String get connectionStatsDesc =>
|
||||
'Lihat tingkat keberhasilan koneksi server dan riwayat';
|
||||
|
||||
@override
|
||||
String get noConnectionStatsData => 'Tidak ada data statistik koneksi';
|
||||
|
||||
@override
|
||||
String get totalAttempts => 'Total';
|
||||
|
||||
@override
|
||||
String get lastSuccess => 'Sukses Terakhir';
|
||||
|
||||
@override
|
||||
String get lastFailure => 'Gagal Terakhir';
|
||||
|
||||
@override
|
||||
String get recentConnections => 'Koneksi Terkini';
|
||||
|
||||
@override
|
||||
String get viewDetails => 'Lihat Detail';
|
||||
|
||||
@override
|
||||
String get connectionDetails => 'Detail Koneksi';
|
||||
|
||||
@override
|
||||
String get clearThisServerStats => 'Hapus Statistik Server Ini';
|
||||
|
||||
@override
|
||||
String get clearAllStatsTitle => 'Hapus Semua Statistik';
|
||||
|
||||
@override
|
||||
String get clearAllStatsContent =>
|
||||
'Apakah Anda yakin ingin menghapus semua statistik koneksi server? Tindakan ini tidak dapat dibatalkan.';
|
||||
|
||||
@override
|
||||
String clearServerStatsTitle(String serverName) {
|
||||
return 'Hapus Statistik $serverName';
|
||||
}
|
||||
|
||||
@override
|
||||
String clearServerStatsContent(String serverName) {
|
||||
return 'Apakah Anda yakin ingin menghapus statistik koneksi untuk server \"$serverName\"? Tindakan ini tidak dapat dibatalkan.';
|
||||
}
|
||||
|
||||
@override
|
||||
String get homeTabs => 'Tab Beranda';
|
||||
|
||||
@override
|
||||
String get homeTabsCustomizeDesc =>
|
||||
'Sesuaikan tab mana yang muncul di halaman beranda dan urutannya';
|
||||
|
||||
@override
|
||||
String get reset => 'Reset';
|
||||
|
||||
@override
|
||||
String get availableTabs => 'Tab Tersedia';
|
||||
|
||||
@override
|
||||
String get atLeastOneTab => 'Setidaknya satu tab harus dipilih';
|
||||
|
||||
@override
|
||||
String get serverTabRequired => 'Server tab cannot be removed';
|
||||
}
|
||||
|
||||
@@ -43,14 +43,20 @@ class AppLocalizationsJa extends AppLocalizations {
|
||||
String get autoUpdateHomeWidget => 'ホームウィジェットを自動更新';
|
||||
|
||||
@override
|
||||
String get backupTip => 'エクスポートされたデータはパスワードで暗号化できます。 \n適切に保管してください。';
|
||||
String get backupEncrypted => 'バックアップは暗号化されています';
|
||||
|
||||
@override
|
||||
String get backupVersionNotMatch => 'バックアップバージョンが一致しないため、復元できません';
|
||||
String get backupNotEncrypted => 'バックアップは暗号化されていません';
|
||||
|
||||
@override
|
||||
String get backupPassword => 'バックアップパスワード';
|
||||
|
||||
@override
|
||||
String get backupPasswordRemoved => 'バックアップパスワードが削除されました';
|
||||
|
||||
@override
|
||||
String get backupPasswordSet => 'バックアップパスワードが設定されました';
|
||||
|
||||
@override
|
||||
String get backupPasswordTip =>
|
||||
'バックアップファイルを暗号化するためのパスワードを設定してください。暗号化を無効にするには空白のままにしてください。';
|
||||
@@ -59,16 +65,10 @@ class AppLocalizationsJa extends AppLocalizations {
|
||||
String get backupPasswordWrong => 'バックアップパスワードが間違っています';
|
||||
|
||||
@override
|
||||
String get backupEncrypted => 'バックアップは暗号化されています';
|
||||
String get backupTip => 'エクスポートされたデータはパスワードで暗号化できます。 \n適切に保管してください。';
|
||||
|
||||
@override
|
||||
String get backupNotEncrypted => 'バックアップは暗号化されていません';
|
||||
|
||||
@override
|
||||
String get backupPasswordSet => 'バックアップパスワードが設定されました';
|
||||
|
||||
@override
|
||||
String get backupPasswordRemoved => 'バックアップパスワードが削除されました';
|
||||
String get backupVersionNotMatch => 'バックアップバージョンが一致しないため、復元できません';
|
||||
|
||||
@override
|
||||
String get battery => 'バッテリー';
|
||||
@@ -587,6 +587,56 @@ class AppLocalizationsJa extends AppLocalizations {
|
||||
return '費した時間: $time';
|
||||
}
|
||||
|
||||
@override
|
||||
String sshConfigAllExist(Object duplicateCount) {
|
||||
return 'すべてのサーバーがすでに存在します($duplicateCount個の重複が見つかりました)';
|
||||
}
|
||||
|
||||
@override
|
||||
String sshConfigDuplicatesSkipped(Object duplicateCount) {
|
||||
return '$duplicateCount個の重複がスキップされます';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshConfigFound => 'システムにSSH設定が見つかりました。';
|
||||
|
||||
@override
|
||||
String sshConfigFoundServers(Object totalCount) {
|
||||
return '$totalCount個のサーバーが見つかりました';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshConfigImport => 'SSH設定のインポート';
|
||||
|
||||
@override
|
||||
String get sshConfigImportHelp => 'インポートできるのは基本情報のみです。例:IP/ポート。';
|
||||
|
||||
@override
|
||||
String get sshConfigImportPermission =>
|
||||
'~/.ssh/configを読み取ってサーバー設定を自動的にインポートする権限を与えますか?';
|
||||
|
||||
@override
|
||||
String get sshConfigImportTip => '初回サーバー作成時に~/.ssh/configの読み取りを促す';
|
||||
|
||||
@override
|
||||
String sshConfigImported(Object count) {
|
||||
return 'SSH設定から$count個のサーバーをインポートしました';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshConfigManualSelect => 'SSH設定ファイルを手動で選択しますか?';
|
||||
|
||||
@override
|
||||
String get sshConfigNoServers => 'SSH設定でサーバーが見つかりませんでした';
|
||||
|
||||
@override
|
||||
String get sshConfigPermissionDenied => 'macOSの権限により、SSH設定ファイルにアクセスできません。';
|
||||
|
||||
@override
|
||||
String sshConfigServersToImport(Object importCount) {
|
||||
return '$importCount個のサーバーがインポートされます';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshTermHelp =>
|
||||
'ターミナルがスクロール可能な場合、横にドラッグするとテキストを選択できます。キーボードボタンをクリックするとキーボードのオン/オフが切り替わります。ファイルアイコンは現在のパスSFTPを開きます。クリップボードボタンは、テキストが選択されているときに内容をコピーし、テキストが選択されておらずクリップボードに内容がある場合には、その内容をターミナルに貼り付けます。コードアイコンは、コードスニペットをターミナルに貼り付けて実行します。';
|
||||
@@ -768,4 +818,68 @@ class AppLocalizationsJa extends AppLocalizations {
|
||||
@override
|
||||
String get writeScriptTip =>
|
||||
'サーバーに接続すると、システムの状態を監視するためのスクリプトが `~/.config/server_box` \n | `/tmp/server_box` に書き込まれます。スクリプトの内容を確認できます。';
|
||||
|
||||
@override
|
||||
String get connectionStats => '接続統計';
|
||||
|
||||
@override
|
||||
String get connectionStatsDesc => 'サーバー接続成功率と履歴を表示';
|
||||
|
||||
@override
|
||||
String get noConnectionStatsData => '接続統計データがありません';
|
||||
|
||||
@override
|
||||
String get totalAttempts => '総計';
|
||||
|
||||
@override
|
||||
String get lastSuccess => '最後の成功';
|
||||
|
||||
@override
|
||||
String get lastFailure => '最後の失敗';
|
||||
|
||||
@override
|
||||
String get recentConnections => '最近の接続';
|
||||
|
||||
@override
|
||||
String get viewDetails => '詳細を表示';
|
||||
|
||||
@override
|
||||
String get connectionDetails => '接続の詳細';
|
||||
|
||||
@override
|
||||
String get clearThisServerStats => 'このサーバーの統計をクリア';
|
||||
|
||||
@override
|
||||
String get clearAllStatsTitle => 'すべての統計をクリア';
|
||||
|
||||
@override
|
||||
String get clearAllStatsContent => 'すべてのサーバー接続統計を削除してもよろしいですか?この操作は元に戻せません。';
|
||||
|
||||
@override
|
||||
String clearServerStatsTitle(String serverName) {
|
||||
return '$serverNameの統計をクリア';
|
||||
}
|
||||
|
||||
@override
|
||||
String clearServerStatsContent(String serverName) {
|
||||
return 'サーバー\"$serverName\"の接続統計を削除してもよろしいですか?この操作は元に戻せません。';
|
||||
}
|
||||
|
||||
@override
|
||||
String get homeTabs => 'ホームタブ';
|
||||
|
||||
@override
|
||||
String get homeTabsCustomizeDesc => 'ホームページに表示するタブとその順序をカスタマイズします';
|
||||
|
||||
@override
|
||||
String get reset => 'リセット';
|
||||
|
||||
@override
|
||||
String get availableTabs => '利用可能なタブ';
|
||||
|
||||
@override
|
||||
String get atLeastOneTab => '少なくとも1つのタブを選択する必要があります';
|
||||
|
||||
@override
|
||||
String get serverTabRequired => 'サーバータブは削除できません';
|
||||
}
|
||||
|
||||
@@ -46,15 +46,20 @@ class AppLocalizationsNl extends AppLocalizations {
|
||||
String get autoUpdateHomeWidget => 'Automatische update van home-widget';
|
||||
|
||||
@override
|
||||
String get backupTip =>
|
||||
'De geëxporteerde gegevens kunnen worden versleuteld met een wachtwoord. \nBewaar deze aub veilig.';
|
||||
String get backupEncrypted => 'Back-up is versleuteld';
|
||||
|
||||
@override
|
||||
String get backupVersionNotMatch => 'Back-upversie komt niet overeen.';
|
||||
String get backupNotEncrypted => 'Back-up is niet versleuteld';
|
||||
|
||||
@override
|
||||
String get backupPassword => 'Back-up wachtwoord';
|
||||
|
||||
@override
|
||||
String get backupPasswordRemoved => 'Back-up wachtwoord verwijderd';
|
||||
|
||||
@override
|
||||
String get backupPasswordSet => 'Back-up wachtwoord ingesteld';
|
||||
|
||||
@override
|
||||
String get backupPasswordTip =>
|
||||
'Stel een wachtwoord in om back-upbestanden te versleutelen. Laat leeg om versleuteling uit te schakelen.';
|
||||
@@ -63,16 +68,11 @@ class AppLocalizationsNl extends AppLocalizations {
|
||||
String get backupPasswordWrong => 'Onjuist back-up wachtwoord';
|
||||
|
||||
@override
|
||||
String get backupEncrypted => 'Back-up is versleuteld';
|
||||
String get backupTip =>
|
||||
'De geëxporteerde gegevens kunnen worden versleuteld met een wachtwoord. \nBewaar deze aub veilig.';
|
||||
|
||||
@override
|
||||
String get backupNotEncrypted => 'Back-up is niet versleuteld';
|
||||
|
||||
@override
|
||||
String get backupPasswordSet => 'Back-up wachtwoord ingesteld';
|
||||
|
||||
@override
|
||||
String get backupPasswordRemoved => 'Back-up wachtwoord verwijderd';
|
||||
String get backupVersionNotMatch => 'Back-upversie komt niet overeen.';
|
||||
|
||||
@override
|
||||
String get battery => 'Batterij';
|
||||
@@ -605,6 +605,61 @@ class AppLocalizationsNl extends AppLocalizations {
|
||||
return 'Gebruikte tijd: $time';
|
||||
}
|
||||
|
||||
@override
|
||||
String sshConfigAllExist(Object duplicateCount) {
|
||||
return 'Alle servers bestaan al ($duplicateCount duplicaten gevonden)';
|
||||
}
|
||||
|
||||
@override
|
||||
String sshConfigDuplicatesSkipped(Object duplicateCount) {
|
||||
return '$duplicateCount duplicaten worden overgeslagen';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshConfigFound =>
|
||||
'We hebben SSH-configuratie op uw systeem gevonden';
|
||||
|
||||
@override
|
||||
String sshConfigFoundServers(Object totalCount) {
|
||||
return '$totalCount servers gevonden';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshConfigImport => 'SSH Configuratie Importeren';
|
||||
|
||||
@override
|
||||
String get sshConfigImportHelp =>
|
||||
'Alleen basisinformatie kan worden geïmporteerd, bijvoorbeeld: IP/Poort.';
|
||||
|
||||
@override
|
||||
String get sshConfigImportPermission =>
|
||||
'Wilt u toestemming geven om ~/.ssh/config te lezen en automatisch serverinstellingen te importeren?';
|
||||
|
||||
@override
|
||||
String get sshConfigImportTip =>
|
||||
'Prompt om ~/.ssh/config te lezen bij het aanmaken van de eerste server';
|
||||
|
||||
@override
|
||||
String sshConfigImported(Object count) {
|
||||
return '$count servers geïmporteerd uit SSH-configuratie';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshConfigManualSelect =>
|
||||
'Wilt u het SSH-configuratiebestand handmatig selecteren?';
|
||||
|
||||
@override
|
||||
String get sshConfigNoServers => 'Geen servers gevonden in SSH-configuratie';
|
||||
|
||||
@override
|
||||
String get sshConfigPermissionDenied =>
|
||||
'Kan geen toegang krijgen tot SSH-configuratiebestand vanwege macOS-rechten.';
|
||||
|
||||
@override
|
||||
String sshConfigServersToImport(Object importCount) {
|
||||
return '$importCount servers worden geïmporteerd';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshTermHelp =>
|
||||
'Wanneer het terminal scrollbaar is, kan horizontaal slepen tekst selecteren. Klikken op de toetsenbordknop schakelt het toetsenbord aan/uit. Het bestandsicoon opent de huidige pad SFTP. De klembordknop kopieert de inhoud wanneer tekst is geselecteerd en plakt inhoud van het klembord in de terminal wanneer geen tekst is geselecteerd en er inhoud op het klembord staat. Het code-icoon plakt codefragmenten in de terminal en voert ze uit.';
|
||||
@@ -794,4 +849,72 @@ class AppLocalizationsNl extends AppLocalizations {
|
||||
@override
|
||||
String get writeScriptTip =>
|
||||
'Na het verbinden met de server wordt een script geschreven naar `~/.config/server_box` \n | `/tmp/server_box` om de systeemstatus te monitoren. U kunt de inhoud van het script controleren.';
|
||||
|
||||
@override
|
||||
String get connectionStats => 'Verbindingsstatistieken';
|
||||
|
||||
@override
|
||||
String get connectionStatsDesc =>
|
||||
'Bekijk server verbindingssucces ratio en geschiedenis';
|
||||
|
||||
@override
|
||||
String get noConnectionStatsData => 'Geen verbindingsstatistiekgegevens';
|
||||
|
||||
@override
|
||||
String get totalAttempts => 'Totaal';
|
||||
|
||||
@override
|
||||
String get lastSuccess => 'Laatst succesvol';
|
||||
|
||||
@override
|
||||
String get lastFailure => 'Laatst gefaald';
|
||||
|
||||
@override
|
||||
String get recentConnections => 'Recente verbindingen';
|
||||
|
||||
@override
|
||||
String get viewDetails => 'Details bekijken';
|
||||
|
||||
@override
|
||||
String get connectionDetails => 'Verbindingsdetails';
|
||||
|
||||
@override
|
||||
String get clearThisServerStats => 'Statistieken van deze server wissen';
|
||||
|
||||
@override
|
||||
String get clearAllStatsTitle => 'Alle statistieken wissen';
|
||||
|
||||
@override
|
||||
String get clearAllStatsContent =>
|
||||
'Weet u zeker dat u alle serververbindingsstatistieken wilt wissen? Deze actie kan niet ongedaan worden gemaakt.';
|
||||
|
||||
@override
|
||||
String clearServerStatsTitle(String serverName) {
|
||||
return 'Statistieken van $serverName wissen';
|
||||
}
|
||||
|
||||
@override
|
||||
String clearServerStatsContent(String serverName) {
|
||||
return 'Weet u zeker dat u de verbindingsstatistieken voor server \"$serverName\" wilt wissen? Deze actie kan niet ongedaan worden gemaakt.';
|
||||
}
|
||||
|
||||
@override
|
||||
String get homeTabs => 'Home-tabbladen';
|
||||
|
||||
@override
|
||||
String get homeTabsCustomizeDesc =>
|
||||
'Pas aan welke tabbladen op de startpagina worden weergegeven en hun volgorde';
|
||||
|
||||
@override
|
||||
String get reset => 'Resetten';
|
||||
|
||||
@override
|
||||
String get availableTabs => 'Beschikbare tabbladen';
|
||||
|
||||
@override
|
||||
String get atLeastOneTab =>
|
||||
'Er moet minimaal één tabblad worden geselecteerd';
|
||||
|
||||
@override
|
||||
String get serverTabRequired => 'Server tab cannot be removed';
|
||||
}
|
||||
|
||||
@@ -46,16 +46,20 @@ class AppLocalizationsPt extends AppLocalizations {
|
||||
'Atualização automática do widget da tela inicial';
|
||||
|
||||
@override
|
||||
String get backupTip =>
|
||||
'Os dados exportados podem ser criptografados com senha. \nPor favor, guarde-os com segurança.';
|
||||
String get backupEncrypted => 'Backup está criptografado';
|
||||
|
||||
@override
|
||||
String get backupVersionNotMatch =>
|
||||
'Versão de backup não compatível, não é possível restaurar';
|
||||
String get backupNotEncrypted => 'Backup não está criptografado';
|
||||
|
||||
@override
|
||||
String get backupPassword => 'Senha de backup';
|
||||
|
||||
@override
|
||||
String get backupPasswordRemoved => 'Senha de backup removida';
|
||||
|
||||
@override
|
||||
String get backupPasswordSet => 'Senha de backup definida';
|
||||
|
||||
@override
|
||||
String get backupPasswordTip =>
|
||||
'Defina uma senha para criptografar arquivos de backup. Deixe vazio para desabilitar a criptografia.';
|
||||
@@ -64,16 +68,12 @@ class AppLocalizationsPt extends AppLocalizations {
|
||||
String get backupPasswordWrong => 'Senha de backup incorreta';
|
||||
|
||||
@override
|
||||
String get backupEncrypted => 'Backup está criptografado';
|
||||
String get backupTip =>
|
||||
'Os dados exportados podem ser criptografados com senha. \nPor favor, guarde-os com segurança.';
|
||||
|
||||
@override
|
||||
String get backupNotEncrypted => 'Backup não está criptografado';
|
||||
|
||||
@override
|
||||
String get backupPasswordSet => 'Senha de backup definida';
|
||||
|
||||
@override
|
||||
String get backupPasswordRemoved => 'Senha de backup removida';
|
||||
String get backupVersionNotMatch =>
|
||||
'Versão de backup não compatível, não é possível restaurar';
|
||||
|
||||
@override
|
||||
String get battery => 'Bateria';
|
||||
@@ -604,6 +604,61 @@ class AppLocalizationsPt extends AppLocalizations {
|
||||
return 'Tempo gasto: $time';
|
||||
}
|
||||
|
||||
@override
|
||||
String sshConfigAllExist(Object duplicateCount) {
|
||||
return 'Todos os servidores já existem (encontradas $duplicateCount duplicatas)';
|
||||
}
|
||||
|
||||
@override
|
||||
String sshConfigDuplicatesSkipped(Object duplicateCount) {
|
||||
return '$duplicateCount duplicatas serão ignoradas';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshConfigFound => 'Encontramos configuração SSH no seu sistema';
|
||||
|
||||
@override
|
||||
String sshConfigFoundServers(Object totalCount) {
|
||||
return 'Encontrados $totalCount servidores';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshConfigImport => 'Importar Configuração SSH';
|
||||
|
||||
@override
|
||||
String get sshConfigImportHelp =>
|
||||
'Só é possível importar informações básicas, por exemplo: IP/Porta.';
|
||||
|
||||
@override
|
||||
String get sshConfigImportPermission =>
|
||||
'Gostaria de dar permissão para ler ~/.ssh/config e importar automaticamente as configurações do servidor?';
|
||||
|
||||
@override
|
||||
String get sshConfigImportTip =>
|
||||
'Sugestão para ler ~/.ssh/config na criação do primeiro servidor';
|
||||
|
||||
@override
|
||||
String sshConfigImported(Object count) {
|
||||
return 'Importados $count servidores da configuração SSH';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshConfigManualSelect =>
|
||||
'Gostaria de selecionar manualmente o arquivo de configuração SSH?';
|
||||
|
||||
@override
|
||||
String get sshConfigNoServers =>
|
||||
'Nenhum servidor encontrado na configuração SSH';
|
||||
|
||||
@override
|
||||
String get sshConfigPermissionDenied =>
|
||||
'Não é possível acessar o arquivo de configuração SSH devido às permissões do macOS.';
|
||||
|
||||
@override
|
||||
String sshConfigServersToImport(Object importCount) {
|
||||
return '$importCount servidores serão importados';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshTermHelp =>
|
||||
'Quando o terminal é rolável, arrastar horizontalmente pode selecionar texto. Clicar no botão do teclado ativa/desativa o teclado. O ícone de arquivo abre o SFTP do caminho atual. O botão da área de transferência copia o conteúdo quando o texto é selecionado e cola o conteúdo da área de transferência no terminal quando nenhum texto é selecionado e há conteúdo na área de transferência. O ícone de código cola trechos de código no terminal e os executa.';
|
||||
@@ -791,4 +846,71 @@ class AppLocalizationsPt extends AppLocalizations {
|
||||
@override
|
||||
String get writeScriptTip =>
|
||||
'Após conectar ao servidor, um script será escrito em `~/.config/server_box` \n | `/tmp/server_box` para monitorar o status do sistema. Você pode revisar o conteúdo do script.';
|
||||
|
||||
@override
|
||||
String get connectionStats => 'Estatísticas de conexão';
|
||||
|
||||
@override
|
||||
String get connectionStatsDesc =>
|
||||
'Ver taxa de sucesso de conexão do servidor e histórico';
|
||||
|
||||
@override
|
||||
String get noConnectionStatsData => 'Não há dados de estatísticas de conexão';
|
||||
|
||||
@override
|
||||
String get totalAttempts => 'Total';
|
||||
|
||||
@override
|
||||
String get lastSuccess => 'Último sucesso';
|
||||
|
||||
@override
|
||||
String get lastFailure => 'Última falha';
|
||||
|
||||
@override
|
||||
String get recentConnections => 'Conexões recentes';
|
||||
|
||||
@override
|
||||
String get viewDetails => 'Ver detalhes';
|
||||
|
||||
@override
|
||||
String get connectionDetails => 'Detalhes da conexão';
|
||||
|
||||
@override
|
||||
String get clearThisServerStats => 'Limpar estatísticas deste servidor';
|
||||
|
||||
@override
|
||||
String get clearAllStatsTitle => 'Limpar todas as estatísticas';
|
||||
|
||||
@override
|
||||
String get clearAllStatsContent =>
|
||||
'Tem certeza de que deseja limpar todas as estatísticas de conexão do servidor? Esta ação não pode ser desfeita.';
|
||||
|
||||
@override
|
||||
String clearServerStatsTitle(String serverName) {
|
||||
return 'Limpar estatísticas de $serverName';
|
||||
}
|
||||
|
||||
@override
|
||||
String clearServerStatsContent(String serverName) {
|
||||
return 'Tem certeza de que deseja limpar as estatísticas de conexão para o servidor \"$serverName\"? Esta ação não pode ser desfeita.';
|
||||
}
|
||||
|
||||
@override
|
||||
String get homeTabs => 'Abas iniciais';
|
||||
|
||||
@override
|
||||
String get homeTabsCustomizeDesc =>
|
||||
'Personalize quais abas aparecem na página inicial e sua ordem';
|
||||
|
||||
@override
|
||||
String get reset => 'Redefinir';
|
||||
|
||||
@override
|
||||
String get availableTabs => 'Abas disponíveis';
|
||||
|
||||
@override
|
||||
String get atLeastOneTab => 'Pelo menos uma aba deve ser selecionada';
|
||||
|
||||
@override
|
||||
String get serverTabRequired => 'Server tab cannot be removed';
|
||||
}
|
||||
|
||||
@@ -46,16 +46,20 @@ class AppLocalizationsRu extends AppLocalizations {
|
||||
'Автоматическое обновление виджета на главном экране';
|
||||
|
||||
@override
|
||||
String get backupTip =>
|
||||
'Экспортированные данные могут быть зашифрованы паролем. \nПожалуйста, храните их в безопасности.';
|
||||
String get backupEncrypted => 'Резервная копия зашифрована';
|
||||
|
||||
@override
|
||||
String get backupVersionNotMatch =>
|
||||
'Версия резервной копии не совпадает, восстановление невозможно';
|
||||
String get backupNotEncrypted => 'Резервная копия не зашифрована';
|
||||
|
||||
@override
|
||||
String get backupPassword => 'Пароль резервной копии';
|
||||
|
||||
@override
|
||||
String get backupPasswordRemoved => 'Пароль резервной копии удален';
|
||||
|
||||
@override
|
||||
String get backupPasswordSet => 'Пароль резервной копии установлен';
|
||||
|
||||
@override
|
||||
String get backupPasswordTip =>
|
||||
'Установите пароль для шифрования файлов резервных копий. Оставьте пустым, чтобы отключить шифрование.';
|
||||
@@ -64,16 +68,12 @@ class AppLocalizationsRu extends AppLocalizations {
|
||||
String get backupPasswordWrong => 'Неверный пароль резервной копии';
|
||||
|
||||
@override
|
||||
String get backupEncrypted => 'Резервная копия зашифрована';
|
||||
String get backupTip =>
|
||||
'Экспортированные данные могут быть зашифрованы паролем. \nПожалуйста, храните их в безопасности.';
|
||||
|
||||
@override
|
||||
String get backupNotEncrypted => 'Резервная копия не зашифрована';
|
||||
|
||||
@override
|
||||
String get backupPasswordSet => 'Пароль резервной копии установлен';
|
||||
|
||||
@override
|
||||
String get backupPasswordRemoved => 'Пароль резервной копии удален';
|
||||
String get backupVersionNotMatch =>
|
||||
'Версия резервной копии не совпадает, восстановление невозможно';
|
||||
|
||||
@override
|
||||
String get battery => 'Батарея';
|
||||
@@ -607,6 +607,60 @@ class AppLocalizationsRu extends AppLocalizations {
|
||||
return 'Затрачено времени: $time';
|
||||
}
|
||||
|
||||
@override
|
||||
String sshConfigAllExist(Object duplicateCount) {
|
||||
return 'Все серверы уже существуют (найдено $duplicateCount дубликатов)';
|
||||
}
|
||||
|
||||
@override
|
||||
String sshConfigDuplicatesSkipped(Object duplicateCount) {
|
||||
return '$duplicateCount дубликатов будут пропущены';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshConfigFound => 'Мы нашли SSH-конфигурацию в вашей системе';
|
||||
|
||||
@override
|
||||
String sshConfigFoundServers(Object totalCount) {
|
||||
return 'Найдено $totalCount серверов';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshConfigImport => 'Импорт SSH Конфигурации';
|
||||
|
||||
@override
|
||||
String get sshConfigImportHelp =>
|
||||
'Можно импортировать только базовую информацию, например: IP/порт.';
|
||||
|
||||
@override
|
||||
String get sshConfigImportPermission =>
|
||||
'Хотите ли вы дать разрешение на чтение ~/.ssh/config и автоматический импорт настроек сервера?';
|
||||
|
||||
@override
|
||||
String get sshConfigImportTip =>
|
||||
'Предложение прочитать ~/.ssh/config при создании первого сервера';
|
||||
|
||||
@override
|
||||
String sshConfigImported(Object count) {
|
||||
return 'Импортировано $count серверов из SSH-конфигурации';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshConfigManualSelect =>
|
||||
'Хотели бы вы вручную выбрать файл конфигурации SSH?';
|
||||
|
||||
@override
|
||||
String get sshConfigNoServers => 'Серверы не найдены в SSH-конфигурации';
|
||||
|
||||
@override
|
||||
String get sshConfigPermissionDenied =>
|
||||
'Невозможно получить доступ к файлу конфигурации SSH из-за разрешений macOS.';
|
||||
|
||||
@override
|
||||
String sshConfigServersToImport(Object importCount) {
|
||||
return '$importCount серверов будут импортированы';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshTermHelp =>
|
||||
'Когда терминал можно прокручивать, горизонтальное перетаскивание позволяет выделить текст. Нажатие на кнопку клавиатуры включает/выключает клавиатуру. Иконка файла открывает текущий путь SFTP. Кнопка буфера обмена копирует содержимое, когда текст выделен, и вставляет содержимое из буфера обмена в терминал, когда текст не выделен, а в буфере есть содержимое. Иконка кода вставляет фрагменты кода в терминал и выполняет их.';
|
||||
@@ -794,4 +848,71 @@ class AppLocalizationsRu extends AppLocalizations {
|
||||
@override
|
||||
String get writeScriptTip =>
|
||||
'После подключения к серверу скрипт будет записан в `~/.config/server_box` \n | `/tmp/server_box` для мониторинга состояния системы. Вы можете проверить содержимое скрипта.';
|
||||
|
||||
@override
|
||||
String get connectionStats => 'Статистика соединений';
|
||||
|
||||
@override
|
||||
String get connectionStatsDesc =>
|
||||
'Просмотр коэффициента успешности подключения к серверу и истории';
|
||||
|
||||
@override
|
||||
String get noConnectionStatsData => 'Нет данных статистики соединений';
|
||||
|
||||
@override
|
||||
String get totalAttempts => 'Общее';
|
||||
|
||||
@override
|
||||
String get lastSuccess => 'Последний успех';
|
||||
|
||||
@override
|
||||
String get lastFailure => 'Последний сбой';
|
||||
|
||||
@override
|
||||
String get recentConnections => 'Недавние соединения';
|
||||
|
||||
@override
|
||||
String get viewDetails => 'Просмотр деталей';
|
||||
|
||||
@override
|
||||
String get connectionDetails => 'Детали соединения';
|
||||
|
||||
@override
|
||||
String get clearThisServerStats => 'Очистить статистику этого сервера';
|
||||
|
||||
@override
|
||||
String get clearAllStatsTitle => 'Очистить всю статистику';
|
||||
|
||||
@override
|
||||
String get clearAllStatsContent =>
|
||||
'Вы уверены, что хотите очистить всю статистику соединений сервера? Это действие не может быть отменено.';
|
||||
|
||||
@override
|
||||
String clearServerStatsTitle(String serverName) {
|
||||
return 'Очистить статистику $serverName';
|
||||
}
|
||||
|
||||
@override
|
||||
String clearServerStatsContent(String serverName) {
|
||||
return 'Вы уверены, что хотите очистить статистику соединений для сервера \"$serverName\"? Это действие не может быть отменено.';
|
||||
}
|
||||
|
||||
@override
|
||||
String get homeTabs => 'Вкладки дома';
|
||||
|
||||
@override
|
||||
String get homeTabsCustomizeDesc =>
|
||||
'Настройте, какие вкладки появляются на главной странице и их порядок';
|
||||
|
||||
@override
|
||||
String get reset => 'Сброс';
|
||||
|
||||
@override
|
||||
String get availableTabs => 'Доступные вкладки';
|
||||
|
||||
@override
|
||||
String get atLeastOneTab => 'Должна быть выбрана хотя бы одна вкладка';
|
||||
|
||||
@override
|
||||
String get serverTabRequired => 'Server tab cannot be removed';
|
||||
}
|
||||
|
||||
@@ -45,15 +45,20 @@ class AppLocalizationsTr extends AppLocalizations {
|
||||
String get autoUpdateHomeWidget => 'Ana ekran bileşenini otomatik güncelle';
|
||||
|
||||
@override
|
||||
String get backupTip =>
|
||||
'Dışa aktarılan veriler parola ile şifrelenebilir. \nLütfen güvenli bir şekilde saklayın.';
|
||||
String get backupEncrypted => 'Yedekleme şifrelenmiş';
|
||||
|
||||
@override
|
||||
String get backupVersionNotMatch => 'Yedekleme sürümü eşleşmiyor.';
|
||||
String get backupNotEncrypted => 'Yedekleme şifreli değil';
|
||||
|
||||
@override
|
||||
String get backupPassword => 'Yedekleme parolası';
|
||||
|
||||
@override
|
||||
String get backupPasswordRemoved => 'Yedekleme parolası kaldırıldı';
|
||||
|
||||
@override
|
||||
String get backupPasswordSet => 'Yedekleme parolası ayarlandı';
|
||||
|
||||
@override
|
||||
String get backupPasswordTip =>
|
||||
'Yedekleme dosyalarını şifrelemek için bir parola belirleyin. Şifrelemeyi devre dışı bırakmak için boş bırakın.';
|
||||
@@ -62,16 +67,11 @@ class AppLocalizationsTr extends AppLocalizations {
|
||||
String get backupPasswordWrong => 'Yanlış yedekleme parolası';
|
||||
|
||||
@override
|
||||
String get backupEncrypted => 'Yedekleme şifrelenmiş';
|
||||
String get backupTip =>
|
||||
'Dışa aktarılan veriler parola ile şifrelenebilir. \nLütfen güvenli bir şekilde saklayın.';
|
||||
|
||||
@override
|
||||
String get backupNotEncrypted => 'Yedekleme şifreli değil';
|
||||
|
||||
@override
|
||||
String get backupPasswordSet => 'Yedekleme parolası ayarlandı';
|
||||
|
||||
@override
|
||||
String get backupPasswordRemoved => 'Yedekleme parolası kaldırıldı';
|
||||
String get backupVersionNotMatch => 'Yedekleme sürümü eşleşmiyor.';
|
||||
|
||||
@override
|
||||
String get battery => 'Pil';
|
||||
@@ -603,6 +603,60 @@ class AppLocalizationsTr extends AppLocalizations {
|
||||
return 'Harcanan süre: $time';
|
||||
}
|
||||
|
||||
@override
|
||||
String sshConfigAllExist(Object duplicateCount) {
|
||||
return 'Tüm sunucular zaten mevcut ($duplicateCount kopya bulundu)';
|
||||
}
|
||||
|
||||
@override
|
||||
String sshConfigDuplicatesSkipped(Object duplicateCount) {
|
||||
return '$duplicateCount kopya atlanacak';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshConfigFound => 'Sisteminizde SSH yapılandırması bulduk';
|
||||
|
||||
@override
|
||||
String sshConfigFoundServers(Object totalCount) {
|
||||
return '$totalCount sunucu bulundu';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshConfigImport => 'SSH Yapılandırma İçe Aktarma';
|
||||
|
||||
@override
|
||||
String get sshConfigImportHelp =>
|
||||
'Yalnızca temel bilgiler içe aktarılabilir, örneğin: IP/Port.';
|
||||
|
||||
@override
|
||||
String get sshConfigImportPermission =>
|
||||
'~/.ssh/config dosyasını okumak ve sunucu ayarlarını otomatik olarak içe aktarmak için izin vermek ister misiniz?';
|
||||
|
||||
@override
|
||||
String get sshConfigImportTip =>
|
||||
'İlk sunucu oluşturulurken ~/.ssh/config okuma istemi';
|
||||
|
||||
@override
|
||||
String sshConfigImported(Object count) {
|
||||
return 'SSH yapılandırmasından $count sunucu içe aktarıldı';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshConfigManualSelect =>
|
||||
'SSH yapılandırma dosyasını manuel olarak seçmek ister misiniz?';
|
||||
|
||||
@override
|
||||
String get sshConfigNoServers => 'SSH yapılandırmasında sunucu bulunamadı';
|
||||
|
||||
@override
|
||||
String get sshConfigPermissionDenied =>
|
||||
'macOS izinleri nedeniyle SSH yapılandırma dosyasına erişilemiyor.';
|
||||
|
||||
@override
|
||||
String sshConfigServersToImport(Object importCount) {
|
||||
return '$importCount sunucu içe aktarılacak';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshTermHelp =>
|
||||
'Terminal kaydırılabilir olduğunda, yatay olarak sürüklemek metni seçebilir. Klavye düğmesine tıklamak klavyeyi açar/kapar. Dosya simgesi mevcut yolu SFTP\'de açar. Pano düğmesi, metin seçiliyken içeriği kopyalar ve metin seçili değilken panoda içerik varsa terminale yapıştırır. Kod simgesi, kod parçacıklarını terminale yapıştırır ve yürütür.';
|
||||
@@ -789,4 +843,71 @@ class AppLocalizationsTr extends AppLocalizations {
|
||||
@override
|
||||
String get writeScriptTip =>
|
||||
'Sunucuya bağlandıktan sonra, sistem durumunu izlemek için `~/.config/server_box` \n | `/tmp/server_box` dizinine bir betik yazılacak. Betik içeriğini inceleyebilirsiniz.';
|
||||
|
||||
@override
|
||||
String get connectionStats => 'Bağlantı İstatistikleri';
|
||||
|
||||
@override
|
||||
String get connectionStatsDesc =>
|
||||
'Sunucu bağlantı başarı oranını ve geçmişi görüntüle';
|
||||
|
||||
@override
|
||||
String get noConnectionStatsData => 'Bağlantı istatistik verisi yok';
|
||||
|
||||
@override
|
||||
String get totalAttempts => 'Toplam';
|
||||
|
||||
@override
|
||||
String get lastSuccess => 'Son Başarı';
|
||||
|
||||
@override
|
||||
String get lastFailure => 'Son Başarısızlık';
|
||||
|
||||
@override
|
||||
String get recentConnections => 'Son Bağlantılar';
|
||||
|
||||
@override
|
||||
String get viewDetails => 'Detayları Görüntüle';
|
||||
|
||||
@override
|
||||
String get connectionDetails => 'Bağlantı Detayları';
|
||||
|
||||
@override
|
||||
String get clearThisServerStats => 'Bu Sunucu İstatistiklerini Temizle';
|
||||
|
||||
@override
|
||||
String get clearAllStatsTitle => 'Tüm İstatistikleri Temizle';
|
||||
|
||||
@override
|
||||
String get clearAllStatsContent =>
|
||||
'Tüm sunucu bağlantı istatistiklerini temizlemek istediğinizden emin misiniz? Bu işlem geri alınamaz.';
|
||||
|
||||
@override
|
||||
String clearServerStatsTitle(String serverName) {
|
||||
return '$serverName İstatistiklerini Temizle';
|
||||
}
|
||||
|
||||
@override
|
||||
String clearServerStatsContent(String serverName) {
|
||||
return '\"$serverName\" sunucusu için bağlantı istatistiklerini temizlemek istediğinizden emin misiniz? Bu işlem geri alınamaz.';
|
||||
}
|
||||
|
||||
@override
|
||||
String get homeTabs => 'Ana Sayfa Sekmeleri';
|
||||
|
||||
@override
|
||||
String get homeTabsCustomizeDesc =>
|
||||
'Ana sayfada görünecek sekmeleri ve sıralarını özelleştirin';
|
||||
|
||||
@override
|
||||
String get reset => 'Sıfırla';
|
||||
|
||||
@override
|
||||
String get availableTabs => 'Mevcut Sekmeler';
|
||||
|
||||
@override
|
||||
String get atLeastOneTab => 'En az bir sekme seçilmelidir';
|
||||
|
||||
@override
|
||||
String get serverTabRequired => 'Server tab cannot be removed';
|
||||
}
|
||||
|
||||
@@ -46,16 +46,20 @@ class AppLocalizationsUk extends AppLocalizations {
|
||||
'Автоматичне оновлення віджетів на головному екрані';
|
||||
|
||||
@override
|
||||
String get backupTip =>
|
||||
'Експортовані дані можуть бути зашифровані паролем. \nБудь ласка, зберігайте їх у безпеці.';
|
||||
String get backupEncrypted => 'Резервна копія зашифрована';
|
||||
|
||||
@override
|
||||
String get backupVersionNotMatch =>
|
||||
'Версія резервного копіювання не збіглася.';
|
||||
String get backupNotEncrypted => 'Резервна копія не зашифрована';
|
||||
|
||||
@override
|
||||
String get backupPassword => 'Пароль резервного копіювання';
|
||||
|
||||
@override
|
||||
String get backupPasswordRemoved => 'Пароль резервного копіювання видалено';
|
||||
|
||||
@override
|
||||
String get backupPasswordSet => 'Пароль резервного копіювання встановлено';
|
||||
|
||||
@override
|
||||
String get backupPasswordTip =>
|
||||
'Встановіть пароль для шифрування файлів резервного копіювання. Залиште порожнім для відключення шифрування.';
|
||||
@@ -64,16 +68,12 @@ class AppLocalizationsUk extends AppLocalizations {
|
||||
String get backupPasswordWrong => 'Неправильний пароль резервного копіювання';
|
||||
|
||||
@override
|
||||
String get backupEncrypted => 'Резервна копія зашифрована';
|
||||
String get backupTip =>
|
||||
'Експортовані дані можуть бути зашифровані паролем. \nБудь ласка, зберігайте їх у безпеці.';
|
||||
|
||||
@override
|
||||
String get backupNotEncrypted => 'Резервна копія не зашифрована';
|
||||
|
||||
@override
|
||||
String get backupPasswordSet => 'Пароль резервного копіювання встановлено';
|
||||
|
||||
@override
|
||||
String get backupPasswordRemoved => 'Пароль резервного копіювання видалено';
|
||||
String get backupVersionNotMatch =>
|
||||
'Версія резервного копіювання не збіглася.';
|
||||
|
||||
@override
|
||||
String get battery => 'Акумулятор';
|
||||
@@ -608,6 +608,60 @@ class AppLocalizationsUk extends AppLocalizations {
|
||||
return 'Витрачений час: $time';
|
||||
}
|
||||
|
||||
@override
|
||||
String sshConfigAllExist(Object duplicateCount) {
|
||||
return 'Всі сервери вже існують (знайдено $duplicateCount дублікатів)';
|
||||
}
|
||||
|
||||
@override
|
||||
String sshConfigDuplicatesSkipped(Object duplicateCount) {
|
||||
return '$duplicateCount дублікатів буде пропущено';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshConfigFound => 'Ми знайшли SSH-конфігурацію у вашій системі';
|
||||
|
||||
@override
|
||||
String sshConfigFoundServers(Object totalCount) {
|
||||
return 'Знайдено $totalCount серверів';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshConfigImport => 'Імпорт SSH Конфігурації';
|
||||
|
||||
@override
|
||||
String get sshConfigImportHelp =>
|
||||
'Можна імпортувати лише базову інформацію, наприклад: IP/порт.';
|
||||
|
||||
@override
|
||||
String get sshConfigImportPermission =>
|
||||
'Чи хочете ви надати дозвіл на читання ~/.ssh/config та автоматичний імпорт налаштувань сервера?';
|
||||
|
||||
@override
|
||||
String get sshConfigImportTip =>
|
||||
'Пропозиція прочитати ~/.ssh/config при створенні першого сервера';
|
||||
|
||||
@override
|
||||
String sshConfigImported(Object count) {
|
||||
return 'Імпортовано $count серверів з SSH-конфігурації';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshConfigManualSelect =>
|
||||
'Чи хочете ви вручну вибрати файл конфігурації SSH?';
|
||||
|
||||
@override
|
||||
String get sshConfigNoServers => 'Сервери не знайдені в SSH-конфігурації';
|
||||
|
||||
@override
|
||||
String get sshConfigPermissionDenied =>
|
||||
'Неможливо отримати доступ до файлу конфігурації SSH через дозволи macOS.';
|
||||
|
||||
@override
|
||||
String sshConfigServersToImport(Object importCount) {
|
||||
return '$importCount серверів буде імпортовано';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshTermHelp =>
|
||||
'Коли термінал прокрутний, горизонтальне проведення вибирає текст. Натискання кнопки клавіатури вмикає/вимикає клавіатуру. Іконка файлу відкриває поточний шлях SFTP. Кнопка буфера обміну копіює вміст, коли текст вибрано, і вставляє вміст з буфера обміну в термінал, коли текст не вибрано і є вміст у буфері обміну. Іконка коду вставляє фрагменти коду в термінал і виконує їх.';
|
||||
@@ -795,4 +849,71 @@ class AppLocalizationsUk extends AppLocalizations {
|
||||
@override
|
||||
String get writeScriptTip =>
|
||||
'Після підключення до сервера скрипт буде записано у `~/.config/server_box` \n | `/tmp/server_box` для моніторингу стану системи. Ви можете переглянути вміст скрипта.';
|
||||
|
||||
@override
|
||||
String get connectionStats => 'Статистика з\'єднань';
|
||||
|
||||
@override
|
||||
String get connectionStatsDesc =>
|
||||
'Переглянути коефіцієнт успішності підключення до сервера та історію';
|
||||
|
||||
@override
|
||||
String get noConnectionStatsData => 'Немає даних статистики з\'єднань';
|
||||
|
||||
@override
|
||||
String get totalAttempts => 'Загальна кількість';
|
||||
|
||||
@override
|
||||
String get lastSuccess => 'Останній успіх';
|
||||
|
||||
@override
|
||||
String get lastFailure => 'Остання помилка';
|
||||
|
||||
@override
|
||||
String get recentConnections => 'Останні з\'єднання';
|
||||
|
||||
@override
|
||||
String get viewDetails => 'Переглянути деталі';
|
||||
|
||||
@override
|
||||
String get connectionDetails => 'Деталі з\'єднання';
|
||||
|
||||
@override
|
||||
String get clearThisServerStats => 'Очистити статистику цього сервера';
|
||||
|
||||
@override
|
||||
String get clearAllStatsTitle => 'Очистити всю статистику';
|
||||
|
||||
@override
|
||||
String get clearAllStatsContent =>
|
||||
'Ви впевнені, що хочете очистити всю статистику з\'єднань сервера? Цю дію не можна скасувати.';
|
||||
|
||||
@override
|
||||
String clearServerStatsTitle(String serverName) {
|
||||
return 'Очистити статистику $serverName';
|
||||
}
|
||||
|
||||
@override
|
||||
String clearServerStatsContent(String serverName) {
|
||||
return 'Ви впевнені, що хочете очистити статистику з\'єднань для сервера \"$serverName\"? Цю дію не можна скасувати.';
|
||||
}
|
||||
|
||||
@override
|
||||
String get homeTabs => 'Домашні вкладки';
|
||||
|
||||
@override
|
||||
String get homeTabsCustomizeDesc =>
|
||||
'Налаштуйте, які вкладки відображаються на головній сторінці та їх порядок';
|
||||
|
||||
@override
|
||||
String get reset => 'Скинути';
|
||||
|
||||
@override
|
||||
String get availableTabs => 'Доступні вкладки';
|
||||
|
||||
@override
|
||||
String get atLeastOneTab => 'Потрібно вибрати принаймні одну вкладку';
|
||||
|
||||
@override
|
||||
String get serverTabRequired => 'Server tab cannot be removed';
|
||||
}
|
||||
|
||||
@@ -42,14 +42,20 @@ class AppLocalizationsZh extends AppLocalizations {
|
||||
String get autoUpdateHomeWidget => '自动更新桌面小部件';
|
||||
|
||||
@override
|
||||
String get backupTip => '导出数据可通过密码加密,请妥善保管。';
|
||||
String get backupEncrypted => '备份已加密';
|
||||
|
||||
@override
|
||||
String get backupVersionNotMatch => '备份版本不兼容,无法恢复';
|
||||
String get backupNotEncrypted => '备份未加密';
|
||||
|
||||
@override
|
||||
String get backupPassword => '备份密码';
|
||||
|
||||
@override
|
||||
String get backupPasswordRemoved => '备份密码已移除';
|
||||
|
||||
@override
|
||||
String get backupPasswordSet => '备份密码已设置';
|
||||
|
||||
@override
|
||||
String get backupPasswordTip => '设置密码以加密备份文件。留空则禁用加密。';
|
||||
|
||||
@@ -57,16 +63,10 @@ class AppLocalizationsZh extends AppLocalizations {
|
||||
String get backupPasswordWrong => '备份密码错误';
|
||||
|
||||
@override
|
||||
String get backupEncrypted => '备份已加密';
|
||||
String get backupTip => '导出数据可通过密码加密,请妥善保管。';
|
||||
|
||||
@override
|
||||
String get backupNotEncrypted => '备份未加密';
|
||||
|
||||
@override
|
||||
String get backupPasswordSet => '备份密码已设置';
|
||||
|
||||
@override
|
||||
String get backupPasswordRemoved => '备份密码已移除';
|
||||
String get backupVersionNotMatch => '备份版本不兼容,无法恢复';
|
||||
|
||||
@override
|
||||
String get battery => '电池';
|
||||
@@ -578,6 +578,55 @@ class AppLocalizationsZh extends AppLocalizations {
|
||||
return '耗时:$time';
|
||||
}
|
||||
|
||||
@override
|
||||
String sshConfigAllExist(Object duplicateCount) {
|
||||
return '所有服务器已存在(发现 $duplicateCount 个重复项)';
|
||||
}
|
||||
|
||||
@override
|
||||
String sshConfigDuplicatesSkipped(Object duplicateCount) {
|
||||
return '$duplicateCount 个重复项将被跳过';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshConfigFound => '我们在您的系统中发现了 SSH 配置。';
|
||||
|
||||
@override
|
||||
String sshConfigFoundServers(Object totalCount) {
|
||||
return '发现 $totalCount 个服务器';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshConfigImport => 'SSH 配置导入';
|
||||
|
||||
@override
|
||||
String get sshConfigImportHelp => '只能导入基础信息,例如:IP/端口';
|
||||
|
||||
@override
|
||||
String get sshConfigImportPermission => '是否允许读取 ~/.ssh/config 并自动导入服务器设置?';
|
||||
|
||||
@override
|
||||
String get sshConfigImportTip => '首次创建服务器时提示读取 ~/.ssh/config';
|
||||
|
||||
@override
|
||||
String sshConfigImported(Object count) {
|
||||
return '从 SSH 配置导入了 $count 个服务器';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshConfigManualSelect => '是否要手动选择 SSH 配置文件?';
|
||||
|
||||
@override
|
||||
String get sshConfigNoServers => 'SSH 配置中未找到服务器';
|
||||
|
||||
@override
|
||||
String get sshConfigPermissionDenied => '由于 macOS 权限限制,无法访问 SSH 配置文件。';
|
||||
|
||||
@override
|
||||
String sshConfigServersToImport(Object importCount) {
|
||||
return '$importCount 个服务器将被导入';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshTermHelp =>
|
||||
'在终端可滚动时,横向拖动可以选中文字。点击键盘按钮可以开启/关闭键盘。文件图标会打开当前路径 SFTP。剪切板按钮会在有选中文字时复制内容,在未选中并且剪切板有内容时粘贴内容到终端。代码图标会粘贴代码片段到终端并执行。';
|
||||
@@ -754,6 +803,70 @@ class AppLocalizationsZh extends AppLocalizations {
|
||||
@override
|
||||
String get writeScriptTip =>
|
||||
'在连接服务器后,会向 `~/.config/server_box` \n | `/tmp/server_box` 写入脚本来监测系统状态,你可以审查脚本内容。';
|
||||
|
||||
@override
|
||||
String get connectionStats => '连接统计';
|
||||
|
||||
@override
|
||||
String get connectionStatsDesc => '查看服务器连接成功率和历史记录';
|
||||
|
||||
@override
|
||||
String get noConnectionStatsData => '暂无连接统计数据';
|
||||
|
||||
@override
|
||||
String get totalAttempts => '总次数';
|
||||
|
||||
@override
|
||||
String get lastSuccess => '最后成功';
|
||||
|
||||
@override
|
||||
String get lastFailure => '最后失败';
|
||||
|
||||
@override
|
||||
String get recentConnections => '最近连接记录';
|
||||
|
||||
@override
|
||||
String get viewDetails => '查看详情';
|
||||
|
||||
@override
|
||||
String get connectionDetails => '连接详情';
|
||||
|
||||
@override
|
||||
String get clearThisServerStats => '清空此服务器统计';
|
||||
|
||||
@override
|
||||
String get clearAllStatsTitle => '清空所有统计';
|
||||
|
||||
@override
|
||||
String get clearAllStatsContent => '确定要清空所有服务器的连接统计数据吗?此操作无法撤销。';
|
||||
|
||||
@override
|
||||
String clearServerStatsTitle(String serverName) {
|
||||
return '清空 $serverName 统计';
|
||||
}
|
||||
|
||||
@override
|
||||
String clearServerStatsContent(String serverName) {
|
||||
return '确定要清空服务器 \"$serverName\" 的连接统计数据吗?此操作无法撤销。';
|
||||
}
|
||||
|
||||
@override
|
||||
String get homeTabs => '主页标签';
|
||||
|
||||
@override
|
||||
String get homeTabsCustomizeDesc => '自定义主页上显示的标签及其顺序';
|
||||
|
||||
@override
|
||||
String get reset => '重置';
|
||||
|
||||
@override
|
||||
String get availableTabs => '可用标签';
|
||||
|
||||
@override
|
||||
String get atLeastOneTab => '至少需要选择一个标签';
|
||||
|
||||
@override
|
||||
String get serverTabRequired => '服务器标签不能被移除';
|
||||
}
|
||||
|
||||
/// The translations for Chinese, as used in Taiwan (`zh_TW`).
|
||||
@@ -794,14 +907,20 @@ class AppLocalizationsZhTw extends AppLocalizationsZh {
|
||||
String get autoUpdateHomeWidget => '自動更新桌面小工具';
|
||||
|
||||
@override
|
||||
String get backupTip => '匯出的資料可透過密碼加密,請妥善保管。';
|
||||
String get backupEncrypted => '備份已加密';
|
||||
|
||||
@override
|
||||
String get backupVersionNotMatch => '備份版本不相容,無法還原';
|
||||
String get backupNotEncrypted => '備份未加密';
|
||||
|
||||
@override
|
||||
String get backupPassword => '備份密碼';
|
||||
|
||||
@override
|
||||
String get backupPasswordRemoved => '備份密碼已移除';
|
||||
|
||||
@override
|
||||
String get backupPasswordSet => '備份密碼已設定';
|
||||
|
||||
@override
|
||||
String get backupPasswordTip => '設定密碼來加密備份檔案。留空則停用加密。';
|
||||
|
||||
@@ -809,16 +928,10 @@ class AppLocalizationsZhTw extends AppLocalizationsZh {
|
||||
String get backupPasswordWrong => '備份密碼錯誤';
|
||||
|
||||
@override
|
||||
String get backupEncrypted => '備份已加密';
|
||||
String get backupTip => '匯出的資料可透過密碼加密,請妥善保管。';
|
||||
|
||||
@override
|
||||
String get backupNotEncrypted => '備份未加密';
|
||||
|
||||
@override
|
||||
String get backupPasswordSet => '備份密碼已設定';
|
||||
|
||||
@override
|
||||
String get backupPasswordRemoved => '備份密碼已移除';
|
||||
String get backupVersionNotMatch => '備份版本不相容,無法還原';
|
||||
|
||||
@override
|
||||
String get battery => '電池';
|
||||
@@ -1330,6 +1443,55 @@ class AppLocalizationsZhTw extends AppLocalizationsZh {
|
||||
return '耗時:$time';
|
||||
}
|
||||
|
||||
@override
|
||||
String sshConfigAllExist(Object duplicateCount) {
|
||||
return '所有伺服器均已存在(發現$duplicateCount個重複項)';
|
||||
}
|
||||
|
||||
@override
|
||||
String sshConfigDuplicatesSkipped(Object duplicateCount) {
|
||||
return '將跳過$duplicateCount個重複項';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshConfigFound => '我們在您的系統中發現了SSH設定';
|
||||
|
||||
@override
|
||||
String sshConfigFoundServers(Object totalCount) {
|
||||
return '發現$totalCount個伺服器';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshConfigImport => '匯入SSH設定';
|
||||
|
||||
@override
|
||||
String get sshConfigImportHelp => '只能匯入基礎資訊,例如:IP/端口。';
|
||||
|
||||
@override
|
||||
String get sshConfigImportPermission => '您是否希望允許讀取 ~/.ssh/config 並自動匯入伺服器設定?';
|
||||
|
||||
@override
|
||||
String get sshConfigImportTip => '在建立第一個伺服器時提示讀取 ~/.ssh/config';
|
||||
|
||||
@override
|
||||
String sshConfigImported(Object count) {
|
||||
return '已從SSH設定匯入$count個伺服器';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshConfigManualSelect => '是否要手動選擇 SSH 設定檔案?';
|
||||
|
||||
@override
|
||||
String get sshConfigNoServers => 'SSH設定中未找到伺服器';
|
||||
|
||||
@override
|
||||
String get sshConfigPermissionDenied => '由於 macOS 權限限制,無法存取 SSH 設定檔案。';
|
||||
|
||||
@override
|
||||
String sshConfigServersToImport(Object importCount) {
|
||||
return '將匯入$importCount個伺服器';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sshTermHelp =>
|
||||
'在終端機可捲動時,橫向拖動可以選中文字。點擊鍵盤按鈕可以開啟/關閉鍵盤。檔案圖示會打開目前路徑 SFTP。剪貼簿按鈕會在有選中文字時複製內容,在未選中並且剪貼簿有內容時貼上內容到終端機。程式碼圖示會貼上程式碼片段到終端機並執行。';
|
||||
@@ -1506,4 +1668,68 @@ class AppLocalizationsZhTw extends AppLocalizationsZh {
|
||||
@override
|
||||
String get writeScriptTip =>
|
||||
'連線到伺服器後,將會在 `~/.config/server_box` \n | `/tmp/server_box` 中寫入一個腳本來監測系統狀態。你可以審查腳本內容。';
|
||||
|
||||
@override
|
||||
String get connectionStats => '連線統計';
|
||||
|
||||
@override
|
||||
String get connectionStatsDesc => '檢視伺服器連線成功率和歷史記錄';
|
||||
|
||||
@override
|
||||
String get noConnectionStatsData => '暫無連線統計資料';
|
||||
|
||||
@override
|
||||
String get totalAttempts => '總次數';
|
||||
|
||||
@override
|
||||
String get lastSuccess => '最後成功';
|
||||
|
||||
@override
|
||||
String get lastFailure => '最後失敗';
|
||||
|
||||
@override
|
||||
String get recentConnections => '最近連線記錄';
|
||||
|
||||
@override
|
||||
String get viewDetails => '檢視詳情';
|
||||
|
||||
@override
|
||||
String get connectionDetails => '連線詳情';
|
||||
|
||||
@override
|
||||
String get clearThisServerStats => '清空此伺服器統計';
|
||||
|
||||
@override
|
||||
String get clearAllStatsTitle => '清空所有統計';
|
||||
|
||||
@override
|
||||
String get clearAllStatsContent => '確定要清空所有伺服器的連線統計資料嗎?此操作無法撤銷。';
|
||||
|
||||
@override
|
||||
String clearServerStatsTitle(String serverName) {
|
||||
return '清空 $serverName 統計';
|
||||
}
|
||||
|
||||
@override
|
||||
String clearServerStatsContent(String serverName) {
|
||||
return '確定要清空伺服器 \"$serverName\" 的連線統計資料嗎?此操作無法撤銷。';
|
||||
}
|
||||
|
||||
@override
|
||||
String get homeTabs => '主頁標籤';
|
||||
|
||||
@override
|
||||
String get homeTabsCustomizeDesc => '自訂主頁上顯示的標籤及其順序';
|
||||
|
||||
@override
|
||||
String get reset => '重置';
|
||||
|
||||
@override
|
||||
String get availableTabs => '可用標籤';
|
||||
|
||||
@override
|
||||
String get atLeastOneTab => '至少需要選擇一個標籤';
|
||||
|
||||
@override
|
||||
String get serverTabRequired => '服務器標籤不能被移除';
|
||||
}
|
||||
|
||||
@@ -3,12 +3,18 @@
|
||||
// Check in to version control
|
||||
|
||||
import 'package:hive_ce/hive.dart';
|
||||
import 'package:server_box/data/model/app/tab.dart';
|
||||
import 'package:server_box/data/model/server/connection_stat.dart';
|
||||
import 'package:server_box/hive/hive_adapters.dart';
|
||||
|
||||
extension HiveRegistrar on HiveInterface {
|
||||
void registerAdapters() {
|
||||
registerAdapter(AppTabAdapter());
|
||||
registerAdapter(ConnectionResultAdapter());
|
||||
registerAdapter(ConnectionStatAdapter());
|
||||
registerAdapter(NetViewTypeAdapter());
|
||||
registerAdapter(PrivateKeyInfoAdapter());
|
||||
registerAdapter(ServerConnectionStatsAdapter());
|
||||
registerAdapter(ServerCustomAdapter());
|
||||
registerAdapter(ServerFuncBtnAdapter());
|
||||
registerAdapter(SnippetAdapter());
|
||||
@@ -21,8 +27,12 @@ extension HiveRegistrar on HiveInterface {
|
||||
|
||||
extension IsolatedHiveRegistrar on IsolatedHiveInterface {
|
||||
void registerAdapters() {
|
||||
registerAdapter(AppTabAdapter());
|
||||
registerAdapter(ConnectionResultAdapter());
|
||||
registerAdapter(ConnectionStatAdapter());
|
||||
registerAdapter(NetViewTypeAdapter());
|
||||
registerAdapter(PrivateKeyInfoAdapter());
|
||||
registerAdapter(ServerConnectionStatsAdapter());
|
||||
registerAdapter(ServerCustomAdapter());
|
||||
registerAdapter(ServerFuncBtnAdapter());
|
||||
registerAdapter(SnippetAdapter());
|
||||
|
||||
@@ -121,7 +121,7 @@ final class _IntroPage extends StatelessWidget {
|
||||
IntroPage.title(text: l10n.backupPassword, big: true),
|
||||
SizedBox(height: padTop * 0.5),
|
||||
Text(
|
||||
'${l10n.backupTip}\n\n${l10n.backupPasswordTip}',
|
||||
l10n.backupTip,
|
||||
style: const TextStyle(fontSize: 16),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
@@ -148,10 +148,7 @@ final class _IntroPage extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
TextButton(onPressed: () => ctx.pop(false), child: Text(libL10n.cancel)),
|
||||
TextButton(onPressed: () => ctx.pop(true), child: Text(libL10n.ok)),
|
||||
],
|
||||
actions: Btnx.cancelOk,
|
||||
);
|
||||
if (result == true) {
|
||||
final pwd = controller.text.trim();
|
||||
|
||||
@@ -11,15 +11,15 @@
|
||||
"autoConnect": "Automatisch verbinden",
|
||||
"autoRun": "Automatischer Start",
|
||||
"autoUpdateHomeWidget": "Home-Widget automatisch aktualisieren",
|
||||
"backupTip": "Die exportierten Daten können mit einem Passwort verschlüsselt werden. \nBitte sicher aufbewahren.",
|
||||
"backupVersionNotMatch": "Die Backup-Version stimmt nicht überein.",
|
||||
"backupPassword": "Backup-Passwort",
|
||||
"backupPasswordTip": "Setzen Sie ein Passwort, um Backup-Dateien zu verschlüsseln. Leer lassen, um Verschlüsselung zu deaktivieren.",
|
||||
"backupPasswordWrong": "Falsches Backup-Passwort",
|
||||
"backupEncrypted": "Backup ist verschlüsselt",
|
||||
"backupNotEncrypted": "Backup ist nicht verschlüsselt",
|
||||
"backupPasswordSet": "Backup-Passwort gesetzt",
|
||||
"backupPassword": "Backup-Passwort",
|
||||
"backupPasswordRemoved": "Backup-Passwort entfernt",
|
||||
"backupPasswordSet": "Backup-Passwort gesetzt",
|
||||
"backupPasswordTip": "Setzen Sie ein Passwort, um Backup-Dateien zu verschlüsseln. Leer lassen, um Verschlüsselung zu deaktivieren.",
|
||||
"backupPasswordWrong": "Falsches Backup-Passwort",
|
||||
"backupTip": "Die exportierten Daten können mit einem Passwort verschlüsselt werden. \nBitte sicher aufbewahren.",
|
||||
"backupVersionNotMatch": "Die Backup-Version stimmt nicht überein.",
|
||||
"battery": "Batterie",
|
||||
"bgRun": "Hintergrundaktualisierung",
|
||||
"bgRunTip": "Dieser Schalter bedeutet nur, dass die App versuchen wird, im Hintergrund zu laufen. Ob sie im Hintergrund laufen kann, hängt davon ab, ob die Berechtigungen aktiviert sind oder nicht. Bei nativem Android deaktivieren Sie bitte \"Batterieoptimierung\" in dieser App, und bei miui ändern Sie bitte die Energiesparrichtlinie auf \"Unbegrenzt\".",
|
||||
@@ -180,6 +180,19 @@
|
||||
"specifyDevTip": "Zum Beispiel bezieht sich die Standard-Netzwerkverkehrsstatistik auf alle Geräte. Hier können Sie ein bestimmtes Gerät angeben.",
|
||||
"speed": "Tempo",
|
||||
"spentTime": "Benötigte Zeit: {time}",
|
||||
"sshConfigAllExist": "Alle Server existieren bereits ({duplicateCount} Duplikate gefunden)",
|
||||
"sshConfigDuplicatesSkipped": "{duplicateCount} Duplikate werden übersprungen",
|
||||
"sshConfigFound": "Wir haben SSH-Konfiguration auf Ihrem System gefunden.",
|
||||
"sshConfigFoundServers": "{totalCount} Server gefunden",
|
||||
"sshConfigImport": "SSH-Konfiguration importieren",
|
||||
"sshConfigImportHelp": "Es können nur Basisinformationen importiert werden, zum Beispiel: IP/Port.",
|
||||
"sshConfigImportPermission": "Möchten Sie die Berechtigung erteilen, ~/.ssh/config zu lesen und Server-Einstellungen automatisch zu importieren?",
|
||||
"sshConfigImportTip": "Bei der ersten Server-Erstellung zum Lesen von ~/.ssh/config auffordern",
|
||||
"sshConfigImported": "{count} Server aus SSH-Konfiguration importiert",
|
||||
"sshConfigManualSelect": "Möchten Sie die SSH-Konfigurationsdatei manuell auswählen?",
|
||||
"sshConfigNoServers": "Keine Server in der SSH-Konfiguration gefunden",
|
||||
"sshConfigPermissionDenied": "Aufgrund der macOS-Berechtigungen kann nicht auf die SSH-Konfigurationsdatei zugegriffen werden.",
|
||||
"sshConfigServersToImport": "{importCount} Server werden importiert",
|
||||
"sshTermHelp": "Wenn das Terminal scrollbar ist, kann durch horizontales Ziehen Text ausgewählt werden. Durch Klicken auf die Tastentaste wird die Tastatur ein- oder ausgeschaltet. Das Dateisymbol öffnet den aktuellen Pfad SFTP. Die Zwischenablage-Schaltfläche kopiert den Inhalt, wenn Text ausgewählt ist, und fügt Inhalte aus der Zwischenablage in das Terminal ein, wenn kein Text ausgewählt ist und Inhalte in der Zwischenablage vorhanden sind. Das Codesymbol fügt Code-Schnipsel ins Terminal ein und führt sie aus.",
|
||||
"sshTip": "Diese Funktion befindet sich jetzt in der Experimentierphase.\n\nBitte melde Bugs auf {url} oder mach mit bei der Entwicklung.",
|
||||
"sshVirtualKeyAutoOff": "Automatische Umschaltung der virtuellen Tasten",
|
||||
@@ -236,5 +249,39 @@
|
||||
"wolTip": "Nach der Konfiguration von WOL (Wake-on-LAN) wird jedes Mal, wenn der Server verbunden wird, eine WOL-Anfrage gesendet.",
|
||||
"write": "Schreiben",
|
||||
"writeScriptFailTip": "Das Schreiben des Skripts ist fehlgeschlagen, möglicherweise aufgrund fehlender Berechtigungen oder das Verzeichnis existiert nicht.",
|
||||
"writeScriptTip": "Nach der Verbindung mit dem Server wird ein Skript in `~/.config/server_box` \n | `/tmp/server_box` geschrieben, um den Systemstatus zu überwachen. Sie können den Skriptinhalt überprüfen."
|
||||
}
|
||||
"writeScriptTip": "Nach der Verbindung mit dem Server wird ein Skript in `~/.config/server_box` \n | `/tmp/server_box` geschrieben, um den Systemstatus zu überwachen. Sie können den Skriptinhalt überprüfen.",
|
||||
"connectionStats": "Verbindungsstatistiken",
|
||||
"connectionStatsDesc": "Server-Verbindungserfolgsrate und Verlauf anzeigen",
|
||||
"noConnectionStatsData": "Keine Verbindungsstatistikdaten",
|
||||
"totalAttempts": "Gesamt",
|
||||
"lastSuccess": "Letzter Erfolg",
|
||||
"lastFailure": "Letzter Fehler",
|
||||
"recentConnections": "Kürzliche Verbindungen",
|
||||
"viewDetails": "Details anzeigen",
|
||||
"connectionDetails": "Verbindungsdetails",
|
||||
"clearThisServerStats": "Statistiken dieses Servers löschen",
|
||||
"clearAllStatsTitle": "Alle Statistiken löschen",
|
||||
"clearAllStatsContent": "Sind Sie sicher, dass Sie alle Server-Verbindungsstatistiken löschen möchten? Diese Aktion kann nicht rückgängig gemacht werden.",
|
||||
"clearServerStatsTitle": "{serverName} Statistiken löschen",
|
||||
"@clearServerStatsTitle": {
|
||||
"placeholders": {
|
||||
"serverName": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"clearServerStatsContent": "Sind Sie sicher, dass Sie die Verbindungsstatistiken für Server \"{serverName}\" löschen möchten? Diese Aktion kann nicht rückgängig gemacht werden.",
|
||||
"@clearServerStatsContent": {
|
||||
"placeholders": {
|
||||
"serverName": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"homeTabs": "Home-Tabs",
|
||||
"homeTabsCustomizeDesc": "Passen Sie an, welche Tabs auf der Startseite angezeigt werden und ihre Reihenfolge",
|
||||
"reset": "Zurücksetzen",
|
||||
"availableTabs": "Verfügbare Tabs",
|
||||
"atLeastOneTab": "Mindestens ein Tab muss ausgewählt sein",
|
||||
"serverTabRequired": "Server-Tab kann nicht entfernt werden"
|
||||
}
|
||||
|
||||
@@ -11,15 +11,15 @@
|
||||
"autoConnect": "Auto connect",
|
||||
"autoRun": "Auto run",
|
||||
"autoUpdateHomeWidget": "Automatic home widget update",
|
||||
"backupTip": "The exported data can be encrypted with password. \nPlease keep it safe.",
|
||||
"backupVersionNotMatch": "Backup version is not match.",
|
||||
"backupPassword": "Backup password",
|
||||
"backupPasswordTip": "Set a password to encrypt backup files. Leave empty to disable encryption.",
|
||||
"backupPasswordWrong": "Incorrect backup password",
|
||||
"backupEncrypted": "Backup is encrypted",
|
||||
"backupNotEncrypted": "Backup is not encrypted",
|
||||
"backupPasswordSet": "Backup password set",
|
||||
"backupPassword": "Backup password",
|
||||
"backupPasswordRemoved": "Backup password removed",
|
||||
"backupPasswordSet": "Backup password set",
|
||||
"backupPasswordTip": "Set a password to encrypt backup files. Leave empty to disable encryption.",
|
||||
"backupPasswordWrong": "Incorrect backup password",
|
||||
"backupTip": "The exported data can be encrypted with password. \nPlease keep it safe.",
|
||||
"backupVersionNotMatch": "Backup version is not match.",
|
||||
"battery": "Battery",
|
||||
"bgRun": "Run in background",
|
||||
"bgRunTip": "This switch only means the program will try to run in the background. Whether it can run in the background depends on whether the permission is enabled or not. For AOSP-based Android ROMs, please disable \"Battery Optimization\" in this app. For MIUI / HyperOS, please change the power saving policy to \"Unlimited\".",
|
||||
@@ -180,6 +180,19 @@
|
||||
"specifyDevTip": "For example, network traffic statistics are by default for all devices. You can specify a particular device here.",
|
||||
"speed": "Speed",
|
||||
"spentTime": "Spent time: {time}",
|
||||
"sshConfigAllExist": "All servers already exist ({duplicateCount} duplicates found)",
|
||||
"sshConfigDuplicatesSkipped": "{duplicateCount} duplicates will be skipped",
|
||||
"sshConfigFound": "We found SSH configuration on your system.",
|
||||
"sshConfigFoundServers": "Found {totalCount} servers",
|
||||
"sshConfigImport": "SSH Config Import",
|
||||
"sshConfigImportHelp": "Only basic information can be imported, for example: IP/Port.",
|
||||
"sshConfigImportPermission": "Would you like to give permission to read ~/.ssh/config and automatically import server settings?",
|
||||
"sshConfigImportTip": "Prompt to read ~/.ssh/config on first server creation",
|
||||
"sshConfigImported": "Imported {count} servers from SSH config",
|
||||
"sshConfigManualSelect": "Would you like to select the SSH config file manually?",
|
||||
"sshConfigNoServers": "No servers found in SSH config",
|
||||
"sshConfigPermissionDenied": "Cannot access SSH config file due to macOS permissions.",
|
||||
"sshConfigServersToImport": "{importCount} servers will be imported",
|
||||
"sshTermHelp": "When the terminal is scrollable, dragging horizontally can select text. Clicking the keyboard button turns the keyboard on/off. The file icon opens the current path SFTP. The clipboard button copies the content when text is selected, and pastes content from the clipboard into the terminal when no text is selected and there is content on the clipboard. The code icon pastes code snippets into the terminal and executes them.",
|
||||
"sshTip": "This function is now in the experimental stage.\n\nPlease report bugs on {url} or join our development.",
|
||||
"sshVirtualKeyAutoOff": "Auto switching of virtual keys",
|
||||
@@ -236,5 +249,39 @@
|
||||
"wolTip": "After configuring WOL (Wake-on-LAN), a WOL request is sent each time the server is connected.",
|
||||
"write": "Write",
|
||||
"writeScriptFailTip": "Writing to the script failed, possibly due to lack of permissions or the directory does not exist.",
|
||||
"writeScriptTip": "After connecting to the server, a script will be written to `~/.config/server_box` \n | `/tmp/server_box` to monitor the system status. You can review the script content."
|
||||
"writeScriptTip": "After connecting to the server, a script will be written to `~/.config/server_box` \n | `/tmp/server_box` to monitor the system status. You can review the script content.",
|
||||
"connectionStats": "Connection Statistics",
|
||||
"connectionStatsDesc": "View server connection success rate and history",
|
||||
"noConnectionStatsData": "No connection statistics data",
|
||||
"totalAttempts": "Total",
|
||||
"lastSuccess": "Last Success",
|
||||
"lastFailure": "Last Failure",
|
||||
"recentConnections": "Recent Connections",
|
||||
"viewDetails": "View Details",
|
||||
"connectionDetails": "Connection Details",
|
||||
"clearThisServerStats": "Clear This Server Statistics",
|
||||
"clearAllStatsTitle": "Clear All Statistics",
|
||||
"clearAllStatsContent": "Are you sure you want to clear all server connection statistics? This action cannot be undone.",
|
||||
"clearServerStatsTitle": "Clear {serverName} Statistics",
|
||||
"@clearServerStatsTitle": {
|
||||
"placeholders": {
|
||||
"serverName": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"clearServerStatsContent": "Are you sure you want to clear connection statistics for server \"{serverName}\"? This action cannot be undone.",
|
||||
"@clearServerStatsContent": {
|
||||
"placeholders": {
|
||||
"serverName": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"homeTabs": "Home Tabs",
|
||||
"homeTabsCustomizeDesc": "Customize which tabs appear on the home page and their order",
|
||||
"reset": "Reset",
|
||||
"availableTabs": "Available Tabs",
|
||||
"atLeastOneTab": "At least one tab must be selected",
|
||||
"serverTabRequired": "Server tab cannot be removed"
|
||||
}
|
||||
@@ -11,15 +11,15 @@
|
||||
"autoConnect": "Conexión automática",
|
||||
"autoRun": "Ejecución automática",
|
||||
"autoUpdateHomeWidget": "Actualizar automáticamente el widget del escritorio",
|
||||
"backupTip": "Los datos exportados pueden ser encriptados con contraseña. \nPor favor guárdalos en un lugar seguro.",
|
||||
"backupVersionNotMatch": "La versión de la copia de seguridad no coincide, no se puede restaurar",
|
||||
"backupPassword": "Contraseña de respaldo",
|
||||
"backupPasswordTip": "Establece una contraseña para encriptar archivos de respaldo. Déjalo vacío para desactivar la encriptación.",
|
||||
"backupPasswordWrong": "Contraseña de respaldo incorrecta",
|
||||
"backupEncrypted": "El respaldo está encriptado",
|
||||
"backupNotEncrypted": "El respaldo no está encriptado",
|
||||
"backupPasswordSet": "Contraseña de respaldo establecida",
|
||||
"backupPassword": "Contraseña de respaldo",
|
||||
"backupPasswordRemoved": "Contraseña de respaldo eliminada",
|
||||
"backupPasswordSet": "Contraseña de respaldo establecida",
|
||||
"backupPasswordTip": "Establece una contraseña para encriptar archivos de respaldo. Déjalo vacío para desactivar la encriptación.",
|
||||
"backupPasswordWrong": "Contraseña de respaldo incorrecta",
|
||||
"backupTip": "Los datos exportados pueden ser encriptados con contraseña. \nPor favor guárdalos en un lugar seguro.",
|
||||
"backupVersionNotMatch": "La versión de la copia de seguridad no coincide, no se puede restaurar",
|
||||
"battery": "Batería",
|
||||
"bgRun": "Ejecución en segundo plano",
|
||||
"bgRunTip": "Este interruptor solo indica que la aplicación intentará correr en segundo plano, si puede hacerlo o no depende de si tiene el permiso correspondiente. En Android puro, por favor desactiva la “optimización de batería” para esta app, en MIUI por favor cambia la estrategia de ahorro de energía a “Sin restricciones”.",
|
||||
@@ -180,6 +180,19 @@
|
||||
"specifyDevTip": "Por ejemplo, las estadísticas de tráfico de red son por defecto para todos los dispositivos. Aquí puede especificar un dispositivo en particular.",
|
||||
"speed": "Velocidad",
|
||||
"spentTime": "Tiempo gastado: {time}",
|
||||
"sshConfigAllExist": "Todos los servidores ya existen (se encontraron {duplicateCount} duplicados)",
|
||||
"sshConfigDuplicatesSkipped": "Se omitirán {duplicateCount} duplicados",
|
||||
"sshConfigFound": "Encontramos configuración SSH en tu sistema",
|
||||
"sshConfigFoundServers": "Se encontraron {totalCount} servidores",
|
||||
"sshConfigImport": "Importar Configuración SSH",
|
||||
"sshConfigImportHelp": "Solo se pueden importar datos básicos, por ejemplo: IP/Puerto.",
|
||||
"sshConfigImportPermission": "¿Te gustaría dar permiso para leer ~/.ssh/config e importar automáticamente la configuración de servidores?",
|
||||
"sshConfigImportTip": "Sugerencia para leer ~/.ssh/config al crear el primer servidor",
|
||||
"sshConfigImported": "Se importaron {count} servidores desde la configuración SSH",
|
||||
"sshConfigManualSelect": "¿Te gustaría seleccionar manualmente el archivo de configuración SSH?",
|
||||
"sshConfigNoServers": "No se encontraron servidores en la configuración SSH",
|
||||
"sshConfigPermissionDenied": "No se puede acceder al archivo de configuración SSH debido a los permisos de macOS.",
|
||||
"sshConfigServersToImport": "Se importarán {importCount} servidores",
|
||||
"sshTermHelp": "Cuando el terminal es desplazable, arrastrar horizontalmente puede seleccionar texto. Hacer clic en el botón del teclado enciende/apaga el teclado. El icono de archivo abre el SFTP de la ruta actual. El botón del portapapeles copia el contenido cuando se selecciona texto y pega el contenido del portapapeles en el terminal cuando no se selecciona texto y hay contenido en el portapapeles. El icono de código pega fragmentos de código en el terminal y los ejecuta.",
|
||||
"sshTip": "Esta función está en fase de pruebas.\n\nPor favor, informa los problemas en {url}, o únete a nuestro desarrollo.",
|
||||
"sshVirtualKeyAutoOff": "Desactivación automática de teclas virtuales",
|
||||
@@ -236,5 +249,39 @@
|
||||
"wolTip": "Después de configurar WOL (Wake-on-LAN), se envía una solicitud de WOL cada vez que se conecta el servidor.",
|
||||
"write": "Escribir",
|
||||
"writeScriptFailTip": "La escritura en el script falló, posiblemente por falta de permisos o porque el directorio no existe.",
|
||||
"writeScriptTip": "Después de conectarse al servidor, se escribirá un script en `~/.config/server_box` \n | `/tmp/server_box` para monitorear el estado del sistema. Puedes revisar el contenido del script."
|
||||
}
|
||||
"writeScriptTip": "Después de conectarse al servidor, se escribirá un script en `~/.config/server_box` \n | `/tmp/server_box` para monitorear el estado del sistema. Puedes revisar el contenido del script.",
|
||||
"connectionStats": "Estadísticas de conexión",
|
||||
"connectionStatsDesc": "Ver la tasa de éxito de conexión del servidor e historial",
|
||||
"noConnectionStatsData": "No hay datos de estadísticas de conexión",
|
||||
"totalAttempts": "Total",
|
||||
"lastSuccess": "Último éxito",
|
||||
"lastFailure": "Último fallo",
|
||||
"recentConnections": "Conexiones recientes",
|
||||
"viewDetails": "Ver detalles",
|
||||
"connectionDetails": "Detalles de conexión",
|
||||
"clearThisServerStats": "Limpiar estadísticas de este servidor",
|
||||
"clearAllStatsTitle": "Limpiar todas las estadísticas",
|
||||
"clearAllStatsContent": "¿Estás seguro de que quieres limpiar todas las estadísticas de conexión del servidor? Esta acción no se puede deshacer.",
|
||||
"clearServerStatsTitle": "Limpiar estadísticas de {serverName}",
|
||||
"@clearServerStatsTitle": {
|
||||
"placeholders": {
|
||||
"serverName": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"clearServerStatsContent": "¿Estás seguro de que quieres limpiar las estadísticas de conexión del servidor \"{serverName}\"? Esta acción no se puede deshacer.",
|
||||
"@clearServerStatsContent": {
|
||||
"placeholders": {
|
||||
"serverName": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"homeTabs": "Pestañas de inicio",
|
||||
"homeTabsCustomizeDesc": "Personaliza qué pestañas aparecen en la página de inicio y su orden",
|
||||
"reset": "Restablecer",
|
||||
"availableTabs": "Pestañas disponibles",
|
||||
"atLeastOneTab": "Al menos una pestaña debe estar seleccionada",
|
||||
"serverTabRequired": "Server tab cannot be removed"
|
||||
}
|
||||
|
||||
@@ -11,15 +11,15 @@
|
||||
"autoConnect": "Connexion automatique",
|
||||
"autoRun": "Exécution automatique",
|
||||
"autoUpdateHomeWidget": "Mise à jour automatique du widget d'accueil",
|
||||
"backupTip": "Les données exportées peuvent être chiffrées avec un mot de passe. \nVeuillez les garder en sécurité.",
|
||||
"backupVersionNotMatch": "La version de sauvegarde ne correspond pas.",
|
||||
"backupPassword": "Mot de passe de sauvegarde",
|
||||
"backupPasswordTip": "Définissez un mot de passe pour chiffrer les fichiers de sauvegarde. Laissez vide pour désactiver le chiffrement.",
|
||||
"backupPasswordWrong": "Mot de passe de sauvegarde incorrect",
|
||||
"backupEncrypted": "La sauvegarde est chiffrée",
|
||||
"backupNotEncrypted": "La sauvegarde n'est pas chiffrée",
|
||||
"backupPasswordSet": "Mot de passe de sauvegarde défini",
|
||||
"backupPassword": "Mot de passe de sauvegarde",
|
||||
"backupPasswordRemoved": "Mot de passe de sauvegarde supprimé",
|
||||
"backupPasswordSet": "Mot de passe de sauvegarde défini",
|
||||
"backupPasswordTip": "Définissez un mot de passe pour chiffrer les fichiers de sauvegarde. Laissez vide pour désactiver le chiffrement.",
|
||||
"backupPasswordWrong": "Mot de passe de sauvegarde incorrect",
|
||||
"backupTip": "Les données exportées peuvent être chiffrées avec un mot de passe. \nVeuillez les garder en sécurité.",
|
||||
"backupVersionNotMatch": "La version de sauvegarde ne correspond pas.",
|
||||
"battery": "Batterie",
|
||||
"bgRun": "Exécution en arrière-plan",
|
||||
"bgRunTip": "Cette option signifie seulement que le programme essaiera de s'exécuter en arrière-plan, que cela soit possible dépend de l'autorisation activée ou non. Pour Android natif, veuillez désactiver l'« Optimisation de la batterie » dans cette application, et pour MIUI, veuillez changer la politique d'économie d'énergie en « Illimité ».",
|
||||
@@ -180,6 +180,19 @@
|
||||
"specifyDevTip": "Par exemple, les statistiques de trafic réseau concernent par défaut tous les appareils. Vous pouvez spécifier ici un appareil particulier.",
|
||||
"speed": "Vitesse",
|
||||
"spentTime": "Temps écoulé : {time}",
|
||||
"sshConfigAllExist": "Tous les serveurs existent déjà ({duplicateCount} doublons trouvés)",
|
||||
"sshConfigDuplicatesSkipped": "{duplicateCount} doublons seront ignorés",
|
||||
"sshConfigFound": "Nous avons trouvé une configuration SSH sur votre système.",
|
||||
"sshConfigFoundServers": "{totalCount} serveurs trouvés",
|
||||
"sshConfigImport": "Importation de configuration SSH",
|
||||
"sshConfigImportHelp": "Seules les informations de base peuvent être importées, par exemple : IP/Port.",
|
||||
"sshConfigImportPermission": "Souhaitez-vous donner la permission de lire ~/.ssh/config et d'importer automatiquement les paramètres du serveur ?",
|
||||
"sshConfigImportTip": "Proposer de lire ~/.ssh/config lors de la première création de serveur",
|
||||
"sshConfigImported": "{count} serveurs importés depuis la configuration SSH",
|
||||
"sshConfigManualSelect": "Souhaitez-vous sélectionner manuellement le fichier de configuration SSH ?",
|
||||
"sshConfigNoServers": "Aucun serveur trouvé dans la configuration SSH",
|
||||
"sshConfigPermissionDenied": "Impossible d'accéder au fichier de configuration SSH en raison des permissions macOS.",
|
||||
"sshConfigServersToImport": "{importCount} serveurs seront importés",
|
||||
"sshTermHelp": "Lorsque le terminal est défilable, faire glisser horizontalement permet de sélectionner du texte. En cliquant sur le bouton du clavier, vous activez/désactivez le clavier. L'icône de fichier ouvre le chemin actuel SFTP. Le bouton du presse-papiers copie le contenu lorsque du texte est sélectionné, et colle le contenu du presse-papiers dans le terminal lorsqu'aucun texte n'est sélectionné et qu'il y a du contenu dans le presse-papiers. L'icône de code colle des extraits de code dans le terminal et les exécute.",
|
||||
"sshTip": "Cette fonctionnalité est actuellement à l'étape expérimentale.\n\nVeuillez signaler les bugs sur {url} ou rejoindre notre développement.",
|
||||
"sshVirtualKeyAutoOff": "Activation automatique des touches virtuelles",
|
||||
@@ -236,5 +249,39 @@
|
||||
"wolTip": "Après avoir configuré le WOL (Wake-on-LAN), une requête WOL est envoyée chaque fois que le serveur est connecté.",
|
||||
"write": "Écrire",
|
||||
"writeScriptFailTip": "Échec de l'écriture dans le script, probablement en raison d'un manque de permissions ou que le répertoire n'existe pas.",
|
||||
"writeScriptTip": "Après la connexion au serveur, un script sera écrit dans `~/.config/server_box` \n | `/tmp/server_box` pour surveiller l’état du système. Vous pouvez examiner le contenu du script."
|
||||
}
|
||||
"writeScriptTip": "Après la connexion au serveur, un script sera écrit dans `~/.config/server_box` \n | `/tmp/server_box` pour surveiller l'état du système. Vous pouvez examiner le contenu du script.",
|
||||
"connectionStats": "Statistiques de connexion",
|
||||
"connectionStatsDesc": "Voir le taux de réussite de connexion du serveur et l'historique",
|
||||
"noConnectionStatsData": "Aucune donnée de statistiques de connexion",
|
||||
"totalAttempts": "Total",
|
||||
"lastSuccess": "Dernier succès",
|
||||
"lastFailure": "Dernier échec",
|
||||
"recentConnections": "Connexions récentes",
|
||||
"viewDetails": "Voir les détails",
|
||||
"connectionDetails": "Détails de connexion",
|
||||
"clearThisServerStats": "Effacer les statistiques de ce serveur",
|
||||
"clearAllStatsTitle": "Effacer toutes les statistiques",
|
||||
"clearAllStatsContent": "Êtes-vous sûr de vouloir effacer toutes les statistiques de connexion des serveurs ? Cette action ne peut pas être annulée.",
|
||||
"clearServerStatsTitle": "Effacer les statistiques de {serverName}",
|
||||
"@clearServerStatsTitle": {
|
||||
"placeholders": {
|
||||
"serverName": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"clearServerStatsContent": "Êtes-vous sûr de vouloir effacer les statistiques de connexion du serveur \"{serverName}\" ? Cette action ne peut pas être annulée.",
|
||||
"@clearServerStatsContent": {
|
||||
"placeholders": {
|
||||
"serverName": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"homeTabs": "Onglets d'accueil",
|
||||
"homeTabsCustomizeDesc": "Personnalisez les onglets qui apparaissent sur la page d'accueil et leur ordre",
|
||||
"reset": "Réinitialiser",
|
||||
"availableTabs": "Onglets disponibles",
|
||||
"atLeastOneTab": "Au moins un onglet doit être sélectionné",
|
||||
"serverTabRequired": "Server tab cannot be removed"
|
||||
}
|
||||
|
||||
@@ -11,15 +11,15 @@
|
||||
"autoConnect": "Hubungkan otomatis",
|
||||
"autoRun": "Berjalan Otomatis",
|
||||
"autoUpdateHomeWidget": "Widget Rumah Pembaruan Otomatis",
|
||||
"backupTip": "Data yang diekspor dapat dienkripsi dengan kata sandi. \nHarap jaga keamanannya.",
|
||||
"backupVersionNotMatch": "Versi cadangan tidak cocok.",
|
||||
"backupPassword": "Kata sandi cadangan",
|
||||
"backupPasswordTip": "Setel kata sandi untuk mengenkripsi file cadangan. Biarkan kosong untuk menonaktifkan enkripsi.",
|
||||
"backupPasswordWrong": "Kata sandi cadangan salah",
|
||||
"backupEncrypted": "Cadangan telah dienkripsi",
|
||||
"backupNotEncrypted": "Cadangan tidak dienkripsi",
|
||||
"backupPasswordSet": "Kata sandi cadangan ditetapkan",
|
||||
"backupPassword": "Kata sandi cadangan",
|
||||
"backupPasswordRemoved": "Kata sandi cadangan dihapus",
|
||||
"backupPasswordSet": "Kata sandi cadangan ditetapkan",
|
||||
"backupPasswordTip": "Setel kata sandi untuk mengenkripsi file cadangan. Biarkan kosong untuk menonaktifkan enkripsi.",
|
||||
"backupPasswordWrong": "Kata sandi cadangan salah",
|
||||
"backupTip": "Data yang diekspor dapat dienkripsi dengan kata sandi. \nHarap jaga keamanannya.",
|
||||
"backupVersionNotMatch": "Versi cadangan tidak cocok.",
|
||||
"battery": "Baterai",
|
||||
"bgRun": "Jalankan di Backgroud",
|
||||
"bgRunTip": "Sakelar ini hanya berarti aplikasi akan mencoba berjalan di latar belakang, apakah aplikasi dapat berjalan di latar belakang tergantung pada apakah izin diaktifkan atau tidak. Untuk Android asli, nonaktifkan \"Pengoptimalan Baterai\" di aplikasi ini, dan untuk miui, ubah kebijakan penghematan daya ke \"Tidak Terbatas\".",
|
||||
@@ -180,6 +180,19 @@
|
||||
"specifyDevTip": "Misalnya, statistik lalu lintas jaringan secara default adalah untuk semua perangkat. Anda dapat menentukan perangkat tertentu di sini.",
|
||||
"speed": "Kecepatan",
|
||||
"spentTime": "Menghabiskan waktu: {time}",
|
||||
"sshConfigAllExist": "Semua server sudah ada (ditemukan {duplicateCount} duplikat)",
|
||||
"sshConfigDuplicatesSkipped": "{duplicateCount} duplikat akan dilewati",
|
||||
"sshConfigFound": "Kami menemukan konfigurasi SSH di sistem Anda",
|
||||
"sshConfigFoundServers": "Ditemukan {totalCount} server",
|
||||
"sshConfigImport": "Impor Konfigurasi SSH",
|
||||
"sshConfigImportHelp": "Hanya informasi dasar yang dapat diimpor, misalnya: IP/Port.",
|
||||
"sshConfigImportPermission": "Apakah Anda ingin memberikan izin untuk membaca ~/.ssh/config dan secara otomatis mengimpor pengaturan server?",
|
||||
"sshConfigImportTip": "Prompt untuk membaca ~/.ssh/config saat pembuatan server pertama",
|
||||
"sshConfigImported": "Berhasil mengimpor {count} server dari konfigurasi SSH",
|
||||
"sshConfigManualSelect": "Apakah Anda ingin memilih file konfigurasi SSH secara manual?",
|
||||
"sshConfigNoServers": "Tidak ada server yang ditemukan dalam konfigurasi SSH",
|
||||
"sshConfigPermissionDenied": "Tidak dapat mengakses file konfigurasi SSH karena izin macOS.",
|
||||
"sshConfigServersToImport": "{importCount} server akan diimpor",
|
||||
"sshTermHelp": "Ketika terminal dapat digulirkan, menggeser secara horizontal dapat memilih teks. Mengklik tombol keyboard mengaktifkan/menonaktifkan keyboard. Ikon file membuka SFTP jalur saat ini. Tombol papan klip menyalin konten saat teks dipilih, dan menempelkan konten dari papan klip ke terminal saat tidak ada teks yang dipilih dan ada konten di papan klip. Ikon kode menempelkan potongan kode ke terminal dan mengeksekusinya.",
|
||||
"sshTip": "Fungsi ini sekarang dalam tahap eksperimen.\n\nHarap laporkan bug di {url} atau bergabunglah dengan pengembangan kami.",
|
||||
"sshVirtualKeyAutoOff": "Switching Otomatis Kunci Virtual",
|
||||
@@ -236,5 +249,39 @@
|
||||
"wolTip": "Setelah mengonfigurasi WOL (Wake-on-LAN), permintaan WOL dikirim setiap kali server terhubung.",
|
||||
"write": "Tulis",
|
||||
"writeScriptFailTip": "Penulisan ke skrip gagal, mungkin karena tidak ada izin atau direktori tidak ada.",
|
||||
"writeScriptTip": "Setelah terhubung ke server, sebuah skrip akan ditulis ke `~/.config/server_box` \n | `/tmp/server_box` untuk memantau status sistem. Anda dapat meninjau konten skrip tersebut."
|
||||
}
|
||||
"writeScriptTip": "Setelah terhubung ke server, sebuah skrip akan ditulis ke `~/.config/server_box` \n | `/tmp/server_box` untuk memantau status sistem. Anda dapat meninjau konten skrip tersebut.",
|
||||
"connectionStats": "Statistik Koneksi",
|
||||
"connectionStatsDesc": "Lihat tingkat keberhasilan koneksi server dan riwayat",
|
||||
"noConnectionStatsData": "Tidak ada data statistik koneksi",
|
||||
"totalAttempts": "Total",
|
||||
"lastSuccess": "Sukses Terakhir",
|
||||
"lastFailure": "Gagal Terakhir",
|
||||
"recentConnections": "Koneksi Terkini",
|
||||
"viewDetails": "Lihat Detail",
|
||||
"connectionDetails": "Detail Koneksi",
|
||||
"clearThisServerStats": "Hapus Statistik Server Ini",
|
||||
"clearAllStatsTitle": "Hapus Semua Statistik",
|
||||
"clearAllStatsContent": "Apakah Anda yakin ingin menghapus semua statistik koneksi server? Tindakan ini tidak dapat dibatalkan.",
|
||||
"clearServerStatsTitle": "Hapus Statistik {serverName}",
|
||||
"@clearServerStatsTitle": {
|
||||
"placeholders": {
|
||||
"serverName": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"clearServerStatsContent": "Apakah Anda yakin ingin menghapus statistik koneksi untuk server \"{serverName}\"? Tindakan ini tidak dapat dibatalkan.",
|
||||
"@clearServerStatsContent": {
|
||||
"placeholders": {
|
||||
"serverName": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"homeTabs": "Tab Beranda",
|
||||
"homeTabsCustomizeDesc": "Sesuaikan tab mana yang muncul di halaman beranda dan urutannya",
|
||||
"reset": "Reset",
|
||||
"availableTabs": "Tab Tersedia",
|
||||
"atLeastOneTab": "Setidaknya satu tab harus dipilih",
|
||||
"serverTabRequired": "Server tab cannot be removed"
|
||||
}
|
||||
|
||||
@@ -11,15 +11,15 @@
|
||||
"autoConnect": "自動接続",
|
||||
"autoRun": "自動実行",
|
||||
"autoUpdateHomeWidget": "ホームウィジェットを自動更新",
|
||||
"backupTip": "エクスポートされたデータはパスワードで暗号化できます。 \n適切に保管してください。",
|
||||
"backupVersionNotMatch": "バックアップバージョンが一致しないため、復元できません",
|
||||
"backupPassword": "バックアップパスワード",
|
||||
"backupPasswordTip": "バックアップファイルを暗号化するためのパスワードを設定してください。暗号化を無効にするには空白のままにしてください。",
|
||||
"backupPasswordWrong": "バックアップパスワードが間違っています",
|
||||
"backupEncrypted": "バックアップは暗号化されています",
|
||||
"backupNotEncrypted": "バックアップは暗号化されていません",
|
||||
"backupPasswordSet": "バックアップパスワードが設定されました",
|
||||
"backupPassword": "バックアップパスワード",
|
||||
"backupPasswordRemoved": "バックアップパスワードが削除されました",
|
||||
"backupPasswordSet": "バックアップパスワードが設定されました",
|
||||
"backupPasswordTip": "バックアップファイルを暗号化するためのパスワードを設定してください。暗号化を無効にするには空白のままにしてください。",
|
||||
"backupPasswordWrong": "バックアップパスワードが間違っています",
|
||||
"backupTip": "エクスポートされたデータはパスワードで暗号化できます。 \n適切に保管してください。",
|
||||
"backupVersionNotMatch": "バックアップバージョンが一致しないため、復元できません",
|
||||
"battery": "バッテリー",
|
||||
"bgRun": "バックグラウンド実行",
|
||||
"bgRunTip": "このスイッチはプログラムがバックグラウンドで実行を試みることを意味しますが、実際にバックグラウンドで実行できるかどうかは、権限が有効になっているかに依存します。AOSPベースのAndroid ROMでは、このアプリの「バッテリー最適化」をオフにしてください。MIUIでは、省エネモードを「無制限」に変更してください。",
|
||||
@@ -180,6 +180,19 @@
|
||||
"specifyDevTip": "例えば、ネットワークトラフィック統計はデフォルトですべてのデバイスに対するものです。ここで特定のデバイスを指定できます。",
|
||||
"speed": "速度",
|
||||
"spentTime": "費した時間: {time}",
|
||||
"sshConfigAllExist": "すべてのサーバーがすでに存在します({duplicateCount}個の重複が見つかりました)",
|
||||
"sshConfigDuplicatesSkipped": "{duplicateCount}個の重複がスキップされます",
|
||||
"sshConfigFound": "システムにSSH設定が見つかりました。",
|
||||
"sshConfigFoundServers": "{totalCount}個のサーバーが見つかりました",
|
||||
"sshConfigImport": "SSH設定のインポート",
|
||||
"sshConfigImportHelp": "インポートできるのは基本情報のみです。例:IP/ポート。",
|
||||
"sshConfigImportPermission": "~/.ssh/configを読み取ってサーバー設定を自動的にインポートする権限を与えますか?",
|
||||
"sshConfigImportTip": "初回サーバー作成時に~/.ssh/configの読み取りを促す",
|
||||
"sshConfigImported": "SSH設定から{count}個のサーバーをインポートしました",
|
||||
"sshConfigManualSelect": "SSH設定ファイルを手動で選択しますか?",
|
||||
"sshConfigNoServers": "SSH設定でサーバーが見つかりませんでした",
|
||||
"sshConfigPermissionDenied": "macOSの権限により、SSH設定ファイルにアクセスできません。",
|
||||
"sshConfigServersToImport": "{importCount}個のサーバーがインポートされます",
|
||||
"sshTermHelp": "ターミナルがスクロール可能な場合、横にドラッグするとテキストを選択できます。キーボードボタンをクリックするとキーボードのオン/オフが切り替わります。ファイルアイコンは現在のパスSFTPを開きます。クリップボードボタンは、テキストが選択されているときに内容をコピーし、テキストが選択されておらずクリップボードに内容がある場合には、その内容をターミナルに貼り付けます。コードアイコンは、コードスニペットをターミナルに貼り付けて実行します。",
|
||||
"sshTip": "この機能は現在テスト段階にあります。\n\n問題がある場合は、{url}でフィードバックしてください。",
|
||||
"sshVirtualKeyAutoOff": "仮想キーの自動オフ",
|
||||
@@ -236,5 +249,39 @@
|
||||
"wolTip": "WOL(Wake-on-LAN)を設定した後、サーバーに接続するたびにWOLリクエストが送信されます。",
|
||||
"write": "書き込み",
|
||||
"writeScriptFailTip": "スクリプトの書き込みに失敗しました。権限がないかディレクトリが存在しない可能性があります。",
|
||||
"writeScriptTip": "サーバーに接続すると、システムの状態を監視するためのスクリプトが `~/.config/server_box` \n | `/tmp/server_box` に書き込まれます。スクリプトの内容を確認できます。"
|
||||
}
|
||||
"writeScriptTip": "サーバーに接続すると、システムの状態を監視するためのスクリプトが `~/.config/server_box` \n | `/tmp/server_box` に書き込まれます。スクリプトの内容を確認できます。",
|
||||
"connectionStats": "接続統計",
|
||||
"connectionStatsDesc": "サーバー接続成功率と履歴を表示",
|
||||
"noConnectionStatsData": "接続統計データがありません",
|
||||
"totalAttempts": "総計",
|
||||
"lastSuccess": "最後の成功",
|
||||
"lastFailure": "最後の失敗",
|
||||
"recentConnections": "最近の接続",
|
||||
"viewDetails": "詳細を表示",
|
||||
"connectionDetails": "接続の詳細",
|
||||
"clearThisServerStats": "このサーバーの統計をクリア",
|
||||
"clearAllStatsTitle": "すべての統計をクリア",
|
||||
"clearAllStatsContent": "すべてのサーバー接続統計を削除してもよろしいですか?この操作は元に戻せません。",
|
||||
"clearServerStatsTitle": "{serverName}の統計をクリア",
|
||||
"@clearServerStatsTitle": {
|
||||
"placeholders": {
|
||||
"serverName": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"clearServerStatsContent": "サーバー\"{serverName}\"の接続統計を削除してもよろしいですか?この操作は元に戻せません。",
|
||||
"@clearServerStatsContent": {
|
||||
"placeholders": {
|
||||
"serverName": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"homeTabs": "ホームタブ",
|
||||
"homeTabsCustomizeDesc": "ホームページに表示するタブとその順序をカスタマイズします",
|
||||
"reset": "リセット",
|
||||
"availableTabs": "利用可能なタブ",
|
||||
"atLeastOneTab": "少なくとも1つのタブを選択する必要があります",
|
||||
"serverTabRequired": "サーバータブは削除できません"
|
||||
}
|
||||
|
||||
@@ -11,15 +11,15 @@
|
||||
"autoConnect": "Automatisch verbinden",
|
||||
"autoRun": "Automatisch uitvoeren",
|
||||
"autoUpdateHomeWidget": "Automatische update van home-widget",
|
||||
"backupTip": "De geëxporteerde gegevens kunnen worden versleuteld met een wachtwoord. \nBewaar deze aub veilig.",
|
||||
"backupVersionNotMatch": "Back-upversie komt niet overeen.",
|
||||
"backupPassword": "Back-up wachtwoord",
|
||||
"backupPasswordTip": "Stel een wachtwoord in om back-upbestanden te versleutelen. Laat leeg om versleuteling uit te schakelen.",
|
||||
"backupPasswordWrong": "Onjuist back-up wachtwoord",
|
||||
"backupEncrypted": "Back-up is versleuteld",
|
||||
"backupNotEncrypted": "Back-up is niet versleuteld",
|
||||
"backupPasswordSet": "Back-up wachtwoord ingesteld",
|
||||
"backupPassword": "Back-up wachtwoord",
|
||||
"backupPasswordRemoved": "Back-up wachtwoord verwijderd",
|
||||
"backupPasswordSet": "Back-up wachtwoord ingesteld",
|
||||
"backupPasswordTip": "Stel een wachtwoord in om back-upbestanden te versleutelen. Laat leeg om versleuteling uit te schakelen.",
|
||||
"backupPasswordWrong": "Onjuist back-up wachtwoord",
|
||||
"backupTip": "De geëxporteerde gegevens kunnen worden versleuteld met een wachtwoord. \nBewaar deze aub veilig.",
|
||||
"backupVersionNotMatch": "Back-upversie komt niet overeen.",
|
||||
"battery": "Batterij",
|
||||
"bgRun": "Uitvoeren op de achtergrond",
|
||||
"bgRunTip": "Deze schakelaar betekent alleen dat het programma zal proberen op de achtergrond uit te voeren, of het in de achtergrond kan worden uitgevoerd, hangt af van of de toestemming is ingeschakeld of niet. Voor native Android, schakel \"Batterijoptimalisatie\" uit in deze app, en voor miui, wijzig de energiebesparingsbeleid naar \"Onbeperkt\".",
|
||||
@@ -180,6 +180,19 @@
|
||||
"specifyDevTip": "Bijvoorbeeld, netwerkverkeersstatistieken zijn standaard voor alle apparaten. Hier kunt u een specifiek apparaat opgeven.",
|
||||
"speed": "Snelheid",
|
||||
"spentTime": "Gebruikte tijd: {time}",
|
||||
"sshConfigAllExist": "Alle servers bestaan al ({duplicateCount} duplicaten gevonden)",
|
||||
"sshConfigDuplicatesSkipped": "{duplicateCount} duplicaten worden overgeslagen",
|
||||
"sshConfigFound": "We hebben SSH-configuratie op uw systeem gevonden",
|
||||
"sshConfigFoundServers": "{totalCount} servers gevonden",
|
||||
"sshConfigImport": "SSH Configuratie Importeren",
|
||||
"sshConfigImportHelp": "Alleen basisinformatie kan worden geïmporteerd, bijvoorbeeld: IP/Poort.",
|
||||
"sshConfigImportPermission": "Wilt u toestemming geven om ~/.ssh/config te lezen en automatisch serverinstellingen te importeren?",
|
||||
"sshConfigImportTip": "Prompt om ~/.ssh/config te lezen bij het aanmaken van de eerste server",
|
||||
"sshConfigImported": "{count} servers geïmporteerd uit SSH-configuratie",
|
||||
"sshConfigManualSelect": "Wilt u het SSH-configuratiebestand handmatig selecteren?",
|
||||
"sshConfigNoServers": "Geen servers gevonden in SSH-configuratie",
|
||||
"sshConfigPermissionDenied": "Kan geen toegang krijgen tot SSH-configuratiebestand vanwege macOS-rechten.",
|
||||
"sshConfigServersToImport": "{importCount} servers worden geïmporteerd",
|
||||
"sshTermHelp": "Wanneer het terminal scrollbaar is, kan horizontaal slepen tekst selecteren. Klikken op de toetsenbordknop schakelt het toetsenbord aan/uit. Het bestandsicoon opent de huidige pad SFTP. De klembordknop kopieert de inhoud wanneer tekst is geselecteerd en plakt inhoud van het klembord in de terminal wanneer geen tekst is geselecteerd en er inhoud op het klembord staat. Het code-icoon plakt codefragmenten in de terminal en voert ze uit.",
|
||||
"sshTip": "Deze functie bevindt zich momenteel in de experimentele fase.\n\nMeld alstublieft bugs op {url} of sluit je aan bij onze ontwikkeling.",
|
||||
"sshVirtualKeyAutoOff": "Automatisch schakelen van virtuele toetsen",
|
||||
@@ -236,5 +249,39 @@
|
||||
"wolTip": "Na het configureren van WOL (Wake-on-LAN), wordt elke keer dat de server wordt verbonden een WOL-verzoek verzonden.",
|
||||
"write": "Schrijven",
|
||||
"writeScriptFailTip": "Het schrijven naar het script is mislukt, mogelijk door gebrek aan rechten of omdat de map niet bestaat.",
|
||||
"writeScriptTip": "Na het verbinden met de server wordt een script geschreven naar `~/.config/server_box` \n | `/tmp/server_box` om de systeemstatus te monitoren. U kunt de inhoud van het script controleren."
|
||||
}
|
||||
"writeScriptTip": "Na het verbinden met de server wordt een script geschreven naar `~/.config/server_box` \n | `/tmp/server_box` om de systeemstatus te monitoren. U kunt de inhoud van het script controleren.",
|
||||
"connectionStats": "Verbindingsstatistieken",
|
||||
"connectionStatsDesc": "Bekijk server verbindingssucces ratio en geschiedenis",
|
||||
"noConnectionStatsData": "Geen verbindingsstatistiekgegevens",
|
||||
"totalAttempts": "Totaal",
|
||||
"lastSuccess": "Laatst succesvol",
|
||||
"lastFailure": "Laatst gefaald",
|
||||
"recentConnections": "Recente verbindingen",
|
||||
"viewDetails": "Details bekijken",
|
||||
"connectionDetails": "Verbindingsdetails",
|
||||
"clearThisServerStats": "Statistieken van deze server wissen",
|
||||
"clearAllStatsTitle": "Alle statistieken wissen",
|
||||
"clearAllStatsContent": "Weet u zeker dat u alle serververbindingsstatistieken wilt wissen? Deze actie kan niet ongedaan worden gemaakt.",
|
||||
"clearServerStatsTitle": "Statistieken van {serverName} wissen",
|
||||
"@clearServerStatsTitle": {
|
||||
"placeholders": {
|
||||
"serverName": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"clearServerStatsContent": "Weet u zeker dat u de verbindingsstatistieken voor server \"{serverName}\" wilt wissen? Deze actie kan niet ongedaan worden gemaakt.",
|
||||
"@clearServerStatsContent": {
|
||||
"placeholders": {
|
||||
"serverName": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"homeTabs": "Home-tabbladen",
|
||||
"homeTabsCustomizeDesc": "Pas aan welke tabbladen op de startpagina worden weergegeven en hun volgorde",
|
||||
"reset": "Resetten",
|
||||
"availableTabs": "Beschikbare tabbladen",
|
||||
"atLeastOneTab": "Er moet minimaal één tabblad worden geselecteerd",
|
||||
"serverTabRequired": "Server tab cannot be removed"
|
||||
}
|
||||
|
||||
@@ -11,15 +11,15 @@
|
||||
"autoConnect": "Conexão automática",
|
||||
"autoRun": "Execução automática",
|
||||
"autoUpdateHomeWidget": "Atualização automática do widget da tela inicial",
|
||||
"backupTip": "Os dados exportados podem ser criptografados com senha. \nPor favor, guarde-os com segurança.",
|
||||
"backupVersionNotMatch": "Versão de backup não compatível, não é possível restaurar",
|
||||
"backupPassword": "Senha de backup",
|
||||
"backupPasswordTip": "Defina uma senha para criptografar arquivos de backup. Deixe vazio para desabilitar a criptografia.",
|
||||
"backupPasswordWrong": "Senha de backup incorreta",
|
||||
"backupEncrypted": "Backup está criptografado",
|
||||
"backupNotEncrypted": "Backup não está criptografado",
|
||||
"backupPasswordSet": "Senha de backup definida",
|
||||
"backupPassword": "Senha de backup",
|
||||
"backupPasswordRemoved": "Senha de backup removida",
|
||||
"backupPasswordSet": "Senha de backup definida",
|
||||
"backupPasswordTip": "Defina uma senha para criptografar arquivos de backup. Deixe vazio para desabilitar a criptografia.",
|
||||
"backupPasswordWrong": "Senha de backup incorreta",
|
||||
"backupTip": "Os dados exportados podem ser criptografados com senha. \nPor favor, guarde-os com segurança.",
|
||||
"backupVersionNotMatch": "Versão de backup não compatível, não é possível restaurar",
|
||||
"battery": "Bateria",
|
||||
"bgRun": "Execução em segundo plano",
|
||||
"bgRunTip": "Este interruptor indica que o programa tentará rodar em segundo plano, mas a capacidade de fazer isso depende das permissões concedidas. No Android nativo, desative a 'Otimização de bateria' para este app, no MIUI, altere a estratégia de economia de energia para 'Sem restrições'.",
|
||||
@@ -180,6 +180,19 @@
|
||||
"specifyDevTip": "Por exemplo, as estatísticas de tráfego de rede são por padrão para todos os dispositivos. Você pode especificar um dispositivo específico aqui.",
|
||||
"speed": "Velocidade",
|
||||
"spentTime": "Tempo gasto: {time}",
|
||||
"sshConfigAllExist": "Todos os servidores já existem (encontradas {duplicateCount} duplicatas)",
|
||||
"sshConfigDuplicatesSkipped": "{duplicateCount} duplicatas serão ignoradas",
|
||||
"sshConfigFound": "Encontramos configuração SSH no seu sistema",
|
||||
"sshConfigFoundServers": "Encontrados {totalCount} servidores",
|
||||
"sshConfigImport": "Importar Configuração SSH",
|
||||
"sshConfigImportHelp": "Só é possível importar informações básicas, por exemplo: IP/Porta.",
|
||||
"sshConfigImportPermission": "Gostaria de dar permissão para ler ~/.ssh/config e importar automaticamente as configurações do servidor?",
|
||||
"sshConfigImportTip": "Sugestão para ler ~/.ssh/config na criação do primeiro servidor",
|
||||
"sshConfigImported": "Importados {count} servidores da configuração SSH",
|
||||
"sshConfigManualSelect": "Gostaria de selecionar manualmente o arquivo de configuração SSH?",
|
||||
"sshConfigNoServers": "Nenhum servidor encontrado na configuração SSH",
|
||||
"sshConfigPermissionDenied": "Não é possível acessar o arquivo de configuração SSH devido às permissões do macOS.",
|
||||
"sshConfigServersToImport": "{importCount} servidores serão importados",
|
||||
"sshTermHelp": "Quando o terminal é rolável, arrastar horizontalmente pode selecionar texto. Clicar no botão do teclado ativa/desativa o teclado. O ícone de arquivo abre o SFTP do caminho atual. O botão da área de transferência copia o conteúdo quando o texto é selecionado e cola o conteúdo da área de transferência no terminal quando nenhum texto é selecionado e há conteúdo na área de transferência. O ícone de código cola trechos de código no terminal e os executa.",
|
||||
"sshTip": "Esta funcionalidade está em fase de teste.\n\nPor favor, reporte problemas em {url} ou junte-se a nós no desenvolvimento.",
|
||||
"sshVirtualKeyAutoOff": "Desativação automática das teclas virtuais",
|
||||
@@ -236,5 +249,39 @@
|
||||
"wolTip": "Após configurar o WOL (Wake-on-LAN), um pedido de WOL é enviado cada vez que o servidor é conectado.",
|
||||
"write": "Escrita",
|
||||
"writeScriptFailTip": "Falha ao escrever no script, possivelmente devido à falta de permissões ou o diretório não existe.",
|
||||
"writeScriptTip": "Após conectar ao servidor, um script será escrito em `~/.config/server_box` \n | `/tmp/server_box` para monitorar o status do sistema. Você pode revisar o conteúdo do script."
|
||||
}
|
||||
"writeScriptTip": "Após conectar ao servidor, um script será escrito em `~/.config/server_box` \n | `/tmp/server_box` para monitorar o status do sistema. Você pode revisar o conteúdo do script.",
|
||||
"connectionStats": "Estatísticas de conexão",
|
||||
"connectionStatsDesc": "Ver taxa de sucesso de conexão do servidor e histórico",
|
||||
"noConnectionStatsData": "Não há dados de estatísticas de conexão",
|
||||
"totalAttempts": "Total",
|
||||
"lastSuccess": "Último sucesso",
|
||||
"lastFailure": "Última falha",
|
||||
"recentConnections": "Conexões recentes",
|
||||
"viewDetails": "Ver detalhes",
|
||||
"connectionDetails": "Detalhes da conexão",
|
||||
"clearThisServerStats": "Limpar estatísticas deste servidor",
|
||||
"clearAllStatsTitle": "Limpar todas as estatísticas",
|
||||
"clearAllStatsContent": "Tem certeza de que deseja limpar todas as estatísticas de conexão do servidor? Esta ação não pode ser desfeita.",
|
||||
"clearServerStatsTitle": "Limpar estatísticas de {serverName}",
|
||||
"@clearServerStatsTitle": {
|
||||
"placeholders": {
|
||||
"serverName": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"clearServerStatsContent": "Tem certeza de que deseja limpar as estatísticas de conexão para o servidor \"{serverName}\"? Esta ação não pode ser desfeita.",
|
||||
"@clearServerStatsContent": {
|
||||
"placeholders": {
|
||||
"serverName": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"homeTabs": "Abas iniciais",
|
||||
"homeTabsCustomizeDesc": "Personalize quais abas aparecem na página inicial e sua ordem",
|
||||
"reset": "Redefinir",
|
||||
"availableTabs": "Abas disponíveis",
|
||||
"atLeastOneTab": "Pelo menos uma aba deve ser selecionada",
|
||||
"serverTabRequired": "Server tab cannot be removed"
|
||||
}
|
||||
|
||||
@@ -11,15 +11,15 @@
|
||||
"autoConnect": "Автоматическое подключение",
|
||||
"autoRun": "Автозапуск",
|
||||
"autoUpdateHomeWidget": "Автоматическое обновление виджета на главном экране",
|
||||
"backupTip": "Экспортированные данные могут быть зашифрованы паролем. \nПожалуйста, храните их в безопасности.",
|
||||
"backupVersionNotMatch": "Версия резервной копии не совпадает, восстановление невозможно",
|
||||
"backupPassword": "Пароль резервной копии",
|
||||
"backupPasswordTip": "Установите пароль для шифрования файлов резервных копий. Оставьте пустым, чтобы отключить шифрование.",
|
||||
"backupPasswordWrong": "Неверный пароль резервной копии",
|
||||
"backupEncrypted": "Резервная копия зашифрована",
|
||||
"backupNotEncrypted": "Резервная копия не зашифрована",
|
||||
"backupPasswordSet": "Пароль резервной копии установлен",
|
||||
"backupPassword": "Пароль резервной копии",
|
||||
"backupPasswordRemoved": "Пароль резервной копии удален",
|
||||
"backupPasswordSet": "Пароль резервной копии установлен",
|
||||
"backupPasswordTip": "Установите пароль для шифрования файлов резервных копий. Оставьте пустым, чтобы отключить шифрование.",
|
||||
"backupPasswordWrong": "Неверный пароль резервной копии",
|
||||
"backupTip": "Экспортированные данные могут быть зашифрованы паролем. \nПожалуйста, храните их в безопасности.",
|
||||
"backupVersionNotMatch": "Версия резервной копии не совпадает, восстановление невозможно",
|
||||
"battery": "Батарея",
|
||||
"bgRun": "Работа в фоновом режиме",
|
||||
"bgRunTip": "Этот переключатель означает, что программа будет пытаться работать в фоновом режиме, но фактическое выполнение зависит от того, включено ли разрешение. Для нативного Android отключите «Оптимизацию батареи» для этого приложения, для MIUI измените контроль активности на «Нет ограничений».",
|
||||
@@ -180,6 +180,19 @@
|
||||
"specifyDevTip": "Например, статистика сетевого трафика по умолчанию относится ко всем устройствам. Здесь вы можете указать конкретное устройство.",
|
||||
"speed": "Скорость",
|
||||
"spentTime": "Затрачено времени: {time}",
|
||||
"sshConfigAllExist": "Все серверы уже существуют (найдено {duplicateCount} дубликатов)",
|
||||
"sshConfigDuplicatesSkipped": "{duplicateCount} дубликатов будут пропущены",
|
||||
"sshConfigFound": "Мы нашли SSH-конфигурацию в вашей системе",
|
||||
"sshConfigFoundServers": "Найдено {totalCount} серверов",
|
||||
"sshConfigImport": "Импорт SSH Конфигурации",
|
||||
"sshConfigImportHelp": "Можно импортировать только базовую информацию, например: IP/порт.",
|
||||
"sshConfigImportPermission": "Хотите ли вы дать разрешение на чтение ~/.ssh/config и автоматический импорт настроек сервера?",
|
||||
"sshConfigImportTip": "Предложение прочитать ~/.ssh/config при создании первого сервера",
|
||||
"sshConfigImported": "Импортировано {count} серверов из SSH-конфигурации",
|
||||
"sshConfigManualSelect": "Хотели бы вы вручную выбрать файл конфигурации SSH?",
|
||||
"sshConfigNoServers": "Серверы не найдены в SSH-конфигурации",
|
||||
"sshConfigPermissionDenied": "Невозможно получить доступ к файлу конфигурации SSH из-за разрешений macOS.",
|
||||
"sshConfigServersToImport": "{importCount} серверов будут импортированы",
|
||||
"sshTermHelp": "Когда терминал можно прокручивать, горизонтальное перетаскивание позволяет выделить текст. Нажатие на кнопку клавиатуры включает/выключает клавиатуру. Иконка файла открывает текущий путь SFTP. Кнопка буфера обмена копирует содержимое, когда текст выделен, и вставляет содержимое из буфера обмена в терминал, когда текст не выделен, а в буфере есть содержимое. Иконка кода вставляет фрагменты кода в терминал и выполняет их.",
|
||||
"sshTip": "Эта функция находится в стадии тестирования.\n\nПожалуйста, отправляйте отчеты о проблемах на {url} или присоединяйтесь к нашей разработке.",
|
||||
"sshVirtualKeyAutoOff": "Автоматическое переключение виртуальных клавиш",
|
||||
@@ -236,5 +249,39 @@
|
||||
"wolTip": "После настройки WOL (Wake-on-LAN) при каждом подключении к серверу отправляется запрос WOL.",
|
||||
"write": "Запись",
|
||||
"writeScriptFailTip": "Запись скрипта не удалась, возможно, из-за отсутствия прав или потому что, директории не существует.",
|
||||
"writeScriptTip": "После подключения к серверу скрипт будет записан в `~/.config/server_box` \n | `/tmp/server_box` для мониторинга состояния системы. Вы можете проверить содержимое скрипта."
|
||||
}
|
||||
"writeScriptTip": "После подключения к серверу скрипт будет записан в `~/.config/server_box` \n | `/tmp/server_box` для мониторинга состояния системы. Вы можете проверить содержимое скрипта.",
|
||||
"connectionStats": "Статистика соединений",
|
||||
"connectionStatsDesc": "Просмотр коэффициента успешности подключения к серверу и истории",
|
||||
"noConnectionStatsData": "Нет данных статистики соединений",
|
||||
"totalAttempts": "Общее",
|
||||
"lastSuccess": "Последний успех",
|
||||
"lastFailure": "Последний сбой",
|
||||
"recentConnections": "Недавние соединения",
|
||||
"viewDetails": "Просмотр деталей",
|
||||
"connectionDetails": "Детали соединения",
|
||||
"clearThisServerStats": "Очистить статистику этого сервера",
|
||||
"clearAllStatsTitle": "Очистить всю статистику",
|
||||
"clearAllStatsContent": "Вы уверены, что хотите очистить всю статистику соединений сервера? Это действие не может быть отменено.",
|
||||
"clearServerStatsTitle": "Очистить статистику {serverName}",
|
||||
"@clearServerStatsTitle": {
|
||||
"placeholders": {
|
||||
"serverName": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"clearServerStatsContent": "Вы уверены, что хотите очистить статистику соединений для сервера \"{serverName}\"? Это действие не может быть отменено.",
|
||||
"@clearServerStatsContent": {
|
||||
"placeholders": {
|
||||
"serverName": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"homeTabs": "Вкладки дома",
|
||||
"homeTabsCustomizeDesc": "Настройте, какие вкладки появляются на главной странице и их порядок",
|
||||
"reset": "Сброс",
|
||||
"availableTabs": "Доступные вкладки",
|
||||
"atLeastOneTab": "Должна быть выбрана хотя бы одна вкладка",
|
||||
"serverTabRequired": "Server tab cannot be removed"
|
||||
}
|
||||
|
||||
@@ -11,15 +11,15 @@
|
||||
"autoConnect": "Otomatik bağlan",
|
||||
"autoRun": "Otomatik çalıştır",
|
||||
"autoUpdateHomeWidget": "Ana ekran bileşenini otomatik güncelle",
|
||||
"backupTip": "Dışa aktarılan veriler parola ile şifrelenebilir. \nLütfen güvenli bir şekilde saklayın.",
|
||||
"backupVersionNotMatch": "Yedekleme sürümü eşleşmiyor.",
|
||||
"backupPassword": "Yedekleme parolası",
|
||||
"backupPasswordTip": "Yedekleme dosyalarını şifrelemek için bir parola belirleyin. Şifrelemeyi devre dışı bırakmak için boş bırakın.",
|
||||
"backupPasswordWrong": "Yanlış yedekleme parolası",
|
||||
"backupEncrypted": "Yedekleme şifrelenmiş",
|
||||
"backupNotEncrypted": "Yedekleme şifreli değil",
|
||||
"backupPasswordSet": "Yedekleme parolası ayarlandı",
|
||||
"backupPassword": "Yedekleme parolası",
|
||||
"backupPasswordRemoved": "Yedekleme parolası kaldırıldı",
|
||||
"backupPasswordSet": "Yedekleme parolası ayarlandı",
|
||||
"backupPasswordTip": "Yedekleme dosyalarını şifrelemek için bir parola belirleyin. Şifrelemeyi devre dışı bırakmak için boş bırakın.",
|
||||
"backupPasswordWrong": "Yanlış yedekleme parolası",
|
||||
"backupTip": "Dışa aktarılan veriler parola ile şifrelenebilir. \nLütfen güvenli bir şekilde saklayın.",
|
||||
"backupVersionNotMatch": "Yedekleme sürümü eşleşmiyor.",
|
||||
"battery": "Pil",
|
||||
"bgRun": "Arka planda çalıştır",
|
||||
"bgRunTip": "Bu anahtar yalnızca programın arka planda çalışmayı deneyeceği anlamına gelir. Arka planda çalışıp çalışamayacağı, iznin etkinleştirilip etkinleştirilmediğine bağlıdır. AOSP tabanlı Android ROM'lar için lütfen bu uygulamada \"Pil Optimizasyonu\"nu devre dışı bırakın. MIUI / HyperOS için lütfen güç tasarrufu politikasını \"Sınırsız\" olarak değiştirin.",
|
||||
@@ -180,6 +180,19 @@
|
||||
"specifyDevTip": "Örneğin, ağ trafiği istatistikleri varsayılan olarak tüm cihazlar içindir. Burada belirli bir cihaz belirtebilirsiniz.",
|
||||
"speed": "Hız",
|
||||
"spentTime": "Harcanan süre: {time}",
|
||||
"sshConfigAllExist": "Tüm sunucular zaten mevcut ({duplicateCount} kopya bulundu)",
|
||||
"sshConfigDuplicatesSkipped": "{duplicateCount} kopya atlanacak",
|
||||
"sshConfigFound": "Sisteminizde SSH yapılandırması bulduk",
|
||||
"sshConfigFoundServers": "{totalCount} sunucu bulundu",
|
||||
"sshConfigImport": "SSH Yapılandırma İçe Aktarma",
|
||||
"sshConfigImportHelp": "Yalnızca temel bilgiler içe aktarılabilir, örneğin: IP/Port.",
|
||||
"sshConfigImportPermission": "~/.ssh/config dosyasını okumak ve sunucu ayarlarını otomatik olarak içe aktarmak için izin vermek ister misiniz?",
|
||||
"sshConfigImportTip": "İlk sunucu oluşturulurken ~/.ssh/config okuma istemi",
|
||||
"sshConfigImported": "SSH yapılandırmasından {count} sunucu içe aktarıldı",
|
||||
"sshConfigManualSelect": "SSH yapılandırma dosyasını manuel olarak seçmek ister misiniz?",
|
||||
"sshConfigNoServers": "SSH yapılandırmasında sunucu bulunamadı",
|
||||
"sshConfigPermissionDenied": "macOS izinleri nedeniyle SSH yapılandırma dosyasına erişilemiyor.",
|
||||
"sshConfigServersToImport": "{importCount} sunucu içe aktarılacak",
|
||||
"sshTermHelp": "Terminal kaydırılabilir olduğunda, yatay olarak sürüklemek metni seçebilir. Klavye düğmesine tıklamak klavyeyi açar/kapar. Dosya simgesi mevcut yolu SFTP'de açar. Pano düğmesi, metin seçiliyken içeriği kopyalar ve metin seçili değilken panoda içerik varsa terminale yapıştırır. Kod simgesi, kod parçacıklarını terminale yapıştırır ve yürütür.",
|
||||
"sshTip": "Bu işlev şu anda deneysel aşamada.\n\nLütfen hataları {url} adresinde bildirin veya geliştirmemize katılın.",
|
||||
"sshVirtualKeyAutoOff": "Sanal tuşların otomatik geçişi",
|
||||
@@ -236,5 +249,39 @@
|
||||
"wolTip": "WOL (Wake-on-LAN) yapılandırıldıktan sonra, sunucuya her bağlanıldığında bir WOL isteği gönderilir.",
|
||||
"write": "Yaz",
|
||||
"writeScriptFailTip": "Betik yazma başarısız oldu, muhtemelen izin eksikliği veya dizin mevcut değil.",
|
||||
"writeScriptTip": "Sunucuya bağlandıktan sonra, sistem durumunu izlemek için `~/.config/server_box` \n | `/tmp/server_box` dizinine bir betik yazılacak. Betik içeriğini inceleyebilirsiniz."
|
||||
}
|
||||
"writeScriptTip": "Sunucuya bağlandıktan sonra, sistem durumunu izlemek için `~/.config/server_box` \n | `/tmp/server_box` dizinine bir betik yazılacak. Betik içeriğini inceleyebilirsiniz.",
|
||||
"connectionStats": "Bağlantı İstatistikleri",
|
||||
"connectionStatsDesc": "Sunucu bağlantı başarı oranını ve geçmişi görüntüle",
|
||||
"noConnectionStatsData": "Bağlantı istatistik verisi yok",
|
||||
"totalAttempts": "Toplam",
|
||||
"lastSuccess": "Son Başarı",
|
||||
"lastFailure": "Son Başarısızlık",
|
||||
"recentConnections": "Son Bağlantılar",
|
||||
"viewDetails": "Detayları Görüntüle",
|
||||
"connectionDetails": "Bağlantı Detayları",
|
||||
"clearThisServerStats": "Bu Sunucu İstatistiklerini Temizle",
|
||||
"clearAllStatsTitle": "Tüm İstatistikleri Temizle",
|
||||
"clearAllStatsContent": "Tüm sunucu bağlantı istatistiklerini temizlemek istediğinizden emin misiniz? Bu işlem geri alınamaz.",
|
||||
"clearServerStatsTitle": "{serverName} İstatistiklerini Temizle",
|
||||
"@clearServerStatsTitle": {
|
||||
"placeholders": {
|
||||
"serverName": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"clearServerStatsContent": "\"{serverName}\" sunucusu için bağlantı istatistiklerini temizlemek istediğinizden emin misiniz? Bu işlem geri alınamaz.",
|
||||
"@clearServerStatsContent": {
|
||||
"placeholders": {
|
||||
"serverName": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"homeTabs": "Ana Sayfa Sekmeleri",
|
||||
"homeTabsCustomizeDesc": "Ana sayfada görünecek sekmeleri ve sıralarını özelleştirin",
|
||||
"reset": "Sıfırla",
|
||||
"availableTabs": "Mevcut Sekmeler",
|
||||
"atLeastOneTab": "En az bir sekme seçilmelidir",
|
||||
"serverTabRequired": "Server tab cannot be removed"
|
||||
}
|
||||
|
||||
@@ -11,15 +11,15 @@
|
||||
"autoConnect": "Авто підключення",
|
||||
"autoRun": "Авто запуск",
|
||||
"autoUpdateHomeWidget": "Автоматичне оновлення віджетів на головному екрані",
|
||||
"backupTip": "Експортовані дані можуть бути зашифровані паролем. \nБудь ласка, зберігайте їх у безпеці.",
|
||||
"backupVersionNotMatch": "Версія резервного копіювання не збіглася.",
|
||||
"backupPassword": "Пароль резервного копіювання",
|
||||
"backupPasswordTip": "Встановіть пароль для шифрування файлів резервного копіювання. Залиште порожнім для відключення шифрування.",
|
||||
"backupPasswordWrong": "Неправильний пароль резервного копіювання",
|
||||
"backupEncrypted": "Резервна копія зашифрована",
|
||||
"backupNotEncrypted": "Резервна копія не зашифрована",
|
||||
"backupPasswordSet": "Пароль резервного копіювання встановлено",
|
||||
"backupPassword": "Пароль резервного копіювання",
|
||||
"backupPasswordRemoved": "Пароль резервного копіювання видалено",
|
||||
"backupPasswordSet": "Пароль резервного копіювання встановлено",
|
||||
"backupPasswordTip": "Встановіть пароль для шифрування файлів резервного копіювання. Залиште порожнім для відключення шифрування.",
|
||||
"backupPasswordWrong": "Неправильний пароль резервного копіювання",
|
||||
"backupTip": "Експортовані дані можуть бути зашифровані паролем. \nБудь ласка, зберігайте їх у безпеці.",
|
||||
"backupVersionNotMatch": "Версія резервного копіювання не збіглася.",
|
||||
"battery": "Акумулятор",
|
||||
"bgRun": "Запуск у фоновому режимі",
|
||||
"bgRunTip": "Цей перемикач лише вказує на те, що програма намагатиметься працювати у фоновому режимі. Чи може вона працювати у фоновому режимі, залежить від прав доступу. Для AOSP-орієнтованих Android ROM, будь ласка, вимкніть \"Оптимізацію акумулятора\" в цьому додатку. Для MIUI / HyperOS, будь ласка, змініть політику економії енергії на \"Нескінченна\".",
|
||||
@@ -180,6 +180,19 @@
|
||||
"specifyDevTip": "Наприклад, статистика мережевого трафіку за замовчуванням є для всіх пристроїв. Ви можете вказати певний пристрій тут.",
|
||||
"speed": "Швидкість",
|
||||
"spentTime": "Витрачений час: {time}",
|
||||
"sshConfigAllExist": "Всі сервери вже існують (знайдено {duplicateCount} дублікатів)",
|
||||
"sshConfigDuplicatesSkipped": "{duplicateCount} дублікатів буде пропущено",
|
||||
"sshConfigFound": "Ми знайшли SSH-конфігурацію у вашій системі",
|
||||
"sshConfigFoundServers": "Знайдено {totalCount} серверів",
|
||||
"sshConfigImport": "Імпорт SSH Конфігурації",
|
||||
"sshConfigImportHelp": "Можна імпортувати лише базову інформацію, наприклад: IP/порт.",
|
||||
"sshConfigImportPermission": "Чи хочете ви надати дозвіл на читання ~/.ssh/config та автоматичний імпорт налаштувань сервера?",
|
||||
"sshConfigImportTip": "Пропозиція прочитати ~/.ssh/config при створенні першого сервера",
|
||||
"sshConfigImported": "Імпортовано {count} серверів з SSH-конфігурації",
|
||||
"sshConfigManualSelect": "Чи хочете ви вручну вибрати файл конфігурації SSH?",
|
||||
"sshConfigNoServers": "Сервери не знайдені в SSH-конфігурації",
|
||||
"sshConfigPermissionDenied": "Неможливо отримати доступ до файлу конфігурації SSH через дозволи macOS.",
|
||||
"sshConfigServersToImport": "{importCount} серверів буде імпортовано",
|
||||
"sshTermHelp": "Коли термінал прокрутний, горизонтальне проведення вибирає текст. Натискання кнопки клавіатури вмикає/вимикає клавіатуру. Іконка файлу відкриває поточний шлях SFTP. Кнопка буфера обміну копіює вміст, коли текст вибрано, і вставляє вміст з буфера обміну в термінал, коли текст не вибрано і є вміст у буфері обміну. Іконка коду вставляє фрагменти коду в термінал і виконує їх.",
|
||||
"sshTip": "Ця функція наразі в експериментальній стадії. Будь ласка, повідомте про помилки за адресою {url} або приєднуйтеся до нашої розробки.",
|
||||
"sshVirtualKeyAutoOff": "Автоматичне переключення віртуальних клавіш",
|
||||
@@ -236,5 +249,39 @@
|
||||
"wolTip": "Після налаштування WOL (Wake-on-LAN), при кожному підключенні до сервера відправляється запит WOL.",
|
||||
"write": "Записати",
|
||||
"writeScriptFailTip": "Запис у скрипт не вдався, можливо, через брак дозволів або каталог не існує.",
|
||||
"writeScriptTip": "Після підключення до сервера скрипт буде записано у `~/.config/server_box` \n | `/tmp/server_box` для моніторингу стану системи. Ви можете переглянути вміст скрипта."
|
||||
}
|
||||
"writeScriptTip": "Після підключення до сервера скрипт буде записано у `~/.config/server_box` \n | `/tmp/server_box` для моніторингу стану системи. Ви можете переглянути вміст скрипта.",
|
||||
"connectionStats": "Статистика з'єднань",
|
||||
"connectionStatsDesc": "Переглянути коефіцієнт успішності підключення до сервера та історію",
|
||||
"noConnectionStatsData": "Немає даних статистики з'єднань",
|
||||
"totalAttempts": "Загальна кількість",
|
||||
"lastSuccess": "Останній успіх",
|
||||
"lastFailure": "Остання помилка",
|
||||
"recentConnections": "Останні з'єднання",
|
||||
"viewDetails": "Переглянути деталі",
|
||||
"connectionDetails": "Деталі з'єднання",
|
||||
"clearThisServerStats": "Очистити статистику цього сервера",
|
||||
"clearAllStatsTitle": "Очистити всю статистику",
|
||||
"clearAllStatsContent": "Ви впевнені, що хочете очистити всю статистику з'єднань сервера? Цю дію не можна скасувати.",
|
||||
"clearServerStatsTitle": "Очистити статистику {serverName}",
|
||||
"@clearServerStatsTitle": {
|
||||
"placeholders": {
|
||||
"serverName": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"clearServerStatsContent": "Ви впевнені, що хочете очистити статистику з'єднань для сервера \"{serverName}\"? Цю дію не можна скасувати.",
|
||||
"@clearServerStatsContent": {
|
||||
"placeholders": {
|
||||
"serverName": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"homeTabs": "Домашні вкладки",
|
||||
"homeTabsCustomizeDesc": "Налаштуйте, які вкладки відображаються на головній сторінці та їх порядок",
|
||||
"reset": "Скинути",
|
||||
"availableTabs": "Доступні вкладки",
|
||||
"atLeastOneTab": "Потрібно вибрати принаймні одну вкладку",
|
||||
"serverTabRequired": "Server tab cannot be removed"
|
||||
}
|
||||
|
||||
@@ -11,15 +11,15 @@
|
||||
"autoConnect": "自动连接",
|
||||
"autoRun": "自动运行",
|
||||
"autoUpdateHomeWidget": "自动更新桌面小部件",
|
||||
"backupTip": "导出数据可通过密码加密,请妥善保管。",
|
||||
"backupVersionNotMatch": "备份版本不兼容,无法恢复",
|
||||
"backupPassword": "备份密码",
|
||||
"backupPasswordTip": "设置密码以加密备份文件。留空则禁用加密。",
|
||||
"backupPasswordWrong": "备份密码错误",
|
||||
"backupEncrypted": "备份已加密",
|
||||
"backupNotEncrypted": "备份未加密",
|
||||
"backupPasswordSet": "备份密码已设置",
|
||||
"backupPassword": "备份密码",
|
||||
"backupPasswordRemoved": "备份密码已移除",
|
||||
"backupPasswordSet": "备份密码已设置",
|
||||
"backupPasswordTip": "设置密码以加密备份文件。留空则禁用加密。",
|
||||
"backupPasswordWrong": "备份密码错误",
|
||||
"backupTip": "导出数据可通过密码加密,请妥善保管。",
|
||||
"backupVersionNotMatch": "备份版本不兼容,无法恢复",
|
||||
"battery": "电池",
|
||||
"bgRun": "后台运行",
|
||||
"bgRunTip": "此开关只代表程序会尝试在后台运行,具体能否后台运行取决于是否开启了权限。原生 Android 请关闭本 App 的“电池优化”,MIUI / HyperOS 请将省电策略改为“无限制”。",
|
||||
@@ -180,6 +180,19 @@
|
||||
"specifyDevTip": "例如网络流量统计默认是所有设备,你可以在这里指定特定的设备",
|
||||
"speed": "速度",
|
||||
"spentTime": "耗时:{time}",
|
||||
"sshConfigAllExist": "所有服务器已存在(发现 {duplicateCount} 个重复项)",
|
||||
"sshConfigDuplicatesSkipped": "{duplicateCount} 个重复项将被跳过",
|
||||
"sshConfigFound": "我们在您的系统中发现了 SSH 配置。",
|
||||
"sshConfigFoundServers": "发现 {totalCount} 个服务器",
|
||||
"sshConfigImport": "SSH 配置导入",
|
||||
"sshConfigImportHelp": "只能导入基础信息,例如:IP/端口",
|
||||
"sshConfigImportPermission": "是否允许读取 ~/.ssh/config 并自动导入服务器设置?",
|
||||
"sshConfigImportTip": "首次创建服务器时提示读取 ~/.ssh/config",
|
||||
"sshConfigImported": "从 SSH 配置导入了 {count} 个服务器",
|
||||
"sshConfigManualSelect": "是否要手动选择 SSH 配置文件?",
|
||||
"sshConfigNoServers": "SSH 配置中未找到服务器",
|
||||
"sshConfigPermissionDenied": "由于 macOS 权限限制,无法访问 SSH 配置文件。",
|
||||
"sshConfigServersToImport": "{importCount} 个服务器将被导入",
|
||||
"sshTermHelp": "在终端可滚动时,横向拖动可以选中文字。点击键盘按钮可以开启/关闭键盘。文件图标会打开当前路径 SFTP。剪切板按钮会在有选中文字时复制内容,在未选中并且剪切板有内容时粘贴内容到终端。代码图标会粘贴代码片段到终端并执行。",
|
||||
"sshTip": "该功能目前处于测试阶段。\n\n请在 {url} 反馈问题,或者加入我们开发。",
|
||||
"sshVirtualKeyAutoOff": "虚拟按键自动切换",
|
||||
@@ -236,5 +249,39 @@
|
||||
"wolTip": "配置 WOL 后,每次连接服务器时将自动发送唤醒请求",
|
||||
"write": "写",
|
||||
"writeScriptFailTip": "写入脚本失败,可能是没有权限/目录不存在等",
|
||||
"writeScriptTip": "在连接服务器后,会向 `~/.config/server_box` \n | `/tmp/server_box` 写入脚本来监测系统状态,你可以审查脚本内容。"
|
||||
"writeScriptTip": "在连接服务器后,会向 `~/.config/server_box` \n | `/tmp/server_box` 写入脚本来监测系统状态,你可以审查脚本内容。",
|
||||
"connectionStats": "连接统计",
|
||||
"connectionStatsDesc": "查看服务器连接成功率和历史记录",
|
||||
"noConnectionStatsData": "暂无连接统计数据",
|
||||
"totalAttempts": "总次数",
|
||||
"lastSuccess": "最后成功",
|
||||
"lastFailure": "最后失败",
|
||||
"recentConnections": "最近连接记录",
|
||||
"viewDetails": "查看详情",
|
||||
"connectionDetails": "连接详情",
|
||||
"clearThisServerStats": "清空此服务器统计",
|
||||
"clearAllStatsTitle": "清空所有统计",
|
||||
"clearAllStatsContent": "确定要清空所有服务器的连接统计数据吗?此操作无法撤销。",
|
||||
"clearServerStatsTitle": "清空 {serverName} 统计",
|
||||
"@clearServerStatsTitle": {
|
||||
"placeholders": {
|
||||
"serverName": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"clearServerStatsContent": "确定要清空服务器 \"{serverName}\" 的连接统计数据吗?此操作无法撤销。",
|
||||
"@clearServerStatsContent": {
|
||||
"placeholders": {
|
||||
"serverName": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"homeTabs": "主页标签",
|
||||
"homeTabsCustomizeDesc": "自定义主页上显示的标签及其顺序",
|
||||
"reset": "重置",
|
||||
"availableTabs": "可用标签",
|
||||
"atLeastOneTab": "至少需要选择一个标签",
|
||||
"serverTabRequired": "服务器标签不能被移除"
|
||||
}
|
||||
@@ -11,15 +11,15 @@
|
||||
"autoConnect": "自動連線",
|
||||
"autoRun": "自動執行",
|
||||
"autoUpdateHomeWidget": "自動更新桌面小工具",
|
||||
"backupTip": "匯出的資料可透過密碼加密,請妥善保管。",
|
||||
"backupVersionNotMatch": "備份版本不相容,無法還原",
|
||||
"backupPassword": "備份密碼",
|
||||
"backupPasswordTip": "設定密碼來加密備份檔案。留空則停用加密。",
|
||||
"backupPasswordWrong": "備份密碼錯誤",
|
||||
"backupEncrypted": "備份已加密",
|
||||
"backupNotEncrypted": "備份未加密",
|
||||
"backupPasswordSet": "備份密碼已設定",
|
||||
"backupPassword": "備份密碼",
|
||||
"backupPasswordRemoved": "備份密碼已移除",
|
||||
"backupPasswordSet": "備份密碼已設定",
|
||||
"backupPasswordTip": "設定密碼來加密備份檔案。留空則停用加密。",
|
||||
"backupPasswordWrong": "備份密碼錯誤",
|
||||
"backupTip": "匯出的資料可透過密碼加密,請妥善保管。",
|
||||
"backupVersionNotMatch": "備份版本不相容,無法還原",
|
||||
"battery": "電池",
|
||||
"bgRun": "背景執行",
|
||||
"bgRunTip": "此開關僅代表程式會嘗試於背景執行,能否成功取決於系統權限。在原生 Android 上,請關閉本應用的「電池最佳化」;在 MIUI / HyperOS 上,請將省電策略調整為「無限制」。",
|
||||
@@ -180,6 +180,19 @@
|
||||
"specifyDevTip": "例如網路流量統計預設是所有裝置,你可以在這裡指定特定的裝置。",
|
||||
"speed": "速度",
|
||||
"spentTime": "耗時:{time}",
|
||||
"sshConfigAllExist": "所有伺服器均已存在(發現{duplicateCount}個重複項)",
|
||||
"sshConfigDuplicatesSkipped": "將跳過{duplicateCount}個重複項",
|
||||
"sshConfigFound": "我們在您的系統中發現了SSH設定",
|
||||
"sshConfigFoundServers": "發現{totalCount}個伺服器",
|
||||
"sshConfigImport": "匯入SSH設定",
|
||||
"sshConfigImportHelp": "只能匯入基礎資訊,例如:IP/端口。",
|
||||
"sshConfigImportPermission": "您是否希望允許讀取 ~/.ssh/config 並自動匯入伺服器設定?",
|
||||
"sshConfigImportTip": "在建立第一個伺服器時提示讀取 ~/.ssh/config",
|
||||
"sshConfigImported": "已從SSH設定匯入{count}個伺服器",
|
||||
"sshConfigManualSelect": "是否要手動選擇 SSH 設定檔案?",
|
||||
"sshConfigNoServers": "SSH設定中未找到伺服器",
|
||||
"sshConfigPermissionDenied": "由於 macOS 權限限制,無法存取 SSH 設定檔案。",
|
||||
"sshConfigServersToImport": "將匯入{importCount}個伺服器",
|
||||
"sshTermHelp": "在終端機可捲動時,橫向拖動可以選中文字。點擊鍵盤按鈕可以開啟/關閉鍵盤。檔案圖示會打開目前路徑 SFTP。剪貼簿按鈕會在有選中文字時複製內容,在未選中並且剪貼簿有內容時貼上內容到終端機。程式碼圖示會貼上程式碼片段到終端機並執行。",
|
||||
"sshTip": "該功能目前處於測試階段。\n\n請在 {url} 回饋問題,或者加入我們開發。",
|
||||
"sshVirtualKeyAutoOff": "虛擬按鍵自動切換",
|
||||
@@ -236,5 +249,39 @@
|
||||
"wolTip": "設定 WOL 後,每次連線伺服器時將自動發送喚醒請求",
|
||||
"write": "寫入",
|
||||
"writeScriptFailTip": "寫入腳本失敗,可能是沒有權限/目錄不存在等。",
|
||||
"writeScriptTip": "連線到伺服器後,將會在 `~/.config/server_box` \n | `/tmp/server_box` 中寫入一個腳本來監測系統狀態。你可以審查腳本內容。"
|
||||
}
|
||||
"writeScriptTip": "連線到伺服器後,將會在 `~/.config/server_box` \n | `/tmp/server_box` 中寫入一個腳本來監測系統狀態。你可以審查腳本內容。",
|
||||
"connectionStats": "連線統計",
|
||||
"connectionStatsDesc": "檢視伺服器連線成功率和歷史記錄",
|
||||
"noConnectionStatsData": "暫無連線統計資料",
|
||||
"totalAttempts": "總次數",
|
||||
"lastSuccess": "最後成功",
|
||||
"lastFailure": "最後失敗",
|
||||
"recentConnections": "最近連線記錄",
|
||||
"viewDetails": "檢視詳情",
|
||||
"connectionDetails": "連線詳情",
|
||||
"clearThisServerStats": "清空此伺服器統計",
|
||||
"clearAllStatsTitle": "清空所有統計",
|
||||
"clearAllStatsContent": "確定要清空所有伺服器的連線統計資料嗎?此操作無法撤銷。",
|
||||
"clearServerStatsTitle": "清空 {serverName} 統計",
|
||||
"@clearServerStatsTitle": {
|
||||
"placeholders": {
|
||||
"serverName": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"clearServerStatsContent": "確定要清空伺服器 \"{serverName}\" 的連線統計資料嗎?此操作無法撤銷。",
|
||||
"@clearServerStatsContent": {
|
||||
"placeholders": {
|
||||
"serverName": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
},
|
||||
"homeTabs": "主頁標籤",
|
||||
"homeTabsCustomizeDesc": "自訂主頁上顯示的標籤及其順序",
|
||||
"reset": "重置",
|
||||
"availableTabs": "可用標籤",
|
||||
"atLeastOneTab": "至少需要選擇一個標籤",
|
||||
"serverTabRequired": "服務器標籤不能被移除"
|
||||
}
|
||||
|
||||
@@ -6,16 +6,12 @@ import 'package:computer/computer.dart';
|
||||
import 'package:fl_lib/fl_lib.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_displaymode/flutter_displaymode.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:hive_ce_flutter/hive_flutter.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:server_box/app.dart';
|
||||
import 'package:server_box/core/sync.dart';
|
||||
import 'package:server_box/data/model/app/menu/server_func.dart';
|
||||
import 'package:server_box/data/model/app/server_detail_card.dart';
|
||||
import 'package:server_box/data/provider/private_key.dart';
|
||||
import 'package:server_box/data/provider/server.dart';
|
||||
import 'package:server_box/data/provider/sftp.dart';
|
||||
import 'package:server_box/data/provider/snippet.dart';
|
||||
import 'package:server_box/data/res/build_data.dart';
|
||||
import 'package:server_box/data/res/store.dart';
|
||||
import 'package:server_box/data/ssh/session_manager.dart';
|
||||
@@ -25,7 +21,7 @@ import 'package:server_box/hive/hive_registrar.g.dart';
|
||||
Future<void> main() async {
|
||||
_runInZone(() async {
|
||||
await _initApp();
|
||||
runApp(const MyApp());
|
||||
runApp(ProviderScope(child: const MyApp()));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -65,12 +61,6 @@ Future<void> _initData() async {
|
||||
// DO DB migration before load any provider.
|
||||
await _doDbMigrate();
|
||||
|
||||
// DO NOT change the order of these providers.
|
||||
PrivateKeyProvider.instance.load();
|
||||
SnippetProvider.instance.load();
|
||||
ServerProvider.instance.load();
|
||||
SftpProvider.instance.load();
|
||||
|
||||
if (Stores.setting.betaTest.fetch()) AppUpdate.chan = AppUpdateChan.beta;
|
||||
|
||||
FontUtils.loadFrom(Stores.setting.fontPath.fetch());
|
||||
@@ -94,8 +84,6 @@ void _doPlatformRelated() async {
|
||||
|
||||
final serversCount = Stores.server.keys().length;
|
||||
Computer.shared.turnOn(workersCount: (serversCount / 3).round() + 1); // Plus 1 to avoid 0.
|
||||
|
||||
bakSync.sync();
|
||||
}
|
||||
|
||||
// It may contains some async heavy funcs.
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'dart:io';
|
||||
import 'package:computer/computer.dart';
|
||||
import 'package:fl_lib/fl_lib.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:icons_plus/icons_plus.dart';
|
||||
import 'package:server_box/core/extension/context/locale.dart';
|
||||
import 'package:server_box/core/sync.dart';
|
||||
@@ -17,16 +18,16 @@ import 'package:server_box/data/res/misc.dart';
|
||||
import 'package:server_box/data/res/store.dart';
|
||||
import 'package:webdav_client_plus/webdav_client_plus.dart';
|
||||
|
||||
class BackupPage extends StatefulWidget {
|
||||
class BackupPage extends ConsumerStatefulWidget {
|
||||
const BackupPage({super.key});
|
||||
|
||||
@override
|
||||
State<BackupPage> createState() => _BackupPageState();
|
||||
ConsumerState<BackupPage> createState() => _BackupPageState();
|
||||
|
||||
static const route = AppRouteNoArg(page: BackupPage.new, path: '/backup');
|
||||
}
|
||||
|
||||
final class _BackupPageState extends State<BackupPage> with AutomaticKeepAliveClientMixin {
|
||||
final class _BackupPageState extends ConsumerState<BackupPage> with AutomaticKeepAliveClientMixin {
|
||||
final webdavLoading = false.vn;
|
||||
final gistLoading = false.vn;
|
||||
|
||||
@@ -130,14 +131,6 @@ final class _BackupPageState extends State<BackupPage> with AutomaticKeepAliveCl
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> _ensureBakPwd(BuildContext context) async {
|
||||
final saved = await SecureStoreProps.bakPwd.read();
|
||||
if (saved != null && saved.isNotEmpty) return true;
|
||||
await _onTapSetBakPwd(context);
|
||||
final after = await SecureStoreProps.bakPwd.read();
|
||||
return after != null && after.isNotEmpty;
|
||||
}
|
||||
|
||||
Widget get _buildTip {
|
||||
return CardX(
|
||||
child: ListTile(
|
||||
@@ -367,7 +360,13 @@ final class _BackupPageState extends State<BackupPage> with AutomaticKeepAliveCl
|
||||
onTap: () async {
|
||||
final data = await context.showImportDialog(title: l10n.snippet, modelDef: Snippet.example.toJson());
|
||||
if (data == null) return;
|
||||
final str = String.fromCharCodes(data);
|
||||
String str;
|
||||
try {
|
||||
str = utf8.decode(data);
|
||||
} on FormatException catch (e, s) {
|
||||
context.showErrDialog(e, s, libL10n.error);
|
||||
return;
|
||||
}
|
||||
final (list, _) = await context.showLoadingDialog(
|
||||
fn: () => Computer.shared.start((s) {
|
||||
return json.decode(s) as List;
|
||||
@@ -401,8 +400,9 @@ final class _BackupPageState extends State<BackupPage> with AutomaticKeepAliveCl
|
||||
child: SingleChildScrollView(child: Text(libL10n.askContinue('${libL10n.import} [$snippetNames]'))),
|
||||
actions: Btn.ok(
|
||||
onTap: () {
|
||||
final notifier = ref.read(snippetNotifierProvider.notifier);
|
||||
for (final snippet in snippets) {
|
||||
SnippetProvider.add(snippet);
|
||||
notifier.add(snippet);
|
||||
}
|
||||
context.pop();
|
||||
context.pop();
|
||||
@@ -413,6 +413,11 @@ final class _BackupPageState extends State<BackupPage> with AutomaticKeepAliveCl
|
||||
).cardx;
|
||||
}
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
}
|
||||
|
||||
extension on _BackupPageState {
|
||||
Future<void> _onTapWebdavDl(BuildContext context) async {
|
||||
webdavLoading.value = true;
|
||||
try {
|
||||
@@ -441,7 +446,7 @@ final class _BackupPageState extends State<BackupPage> with AutomaticKeepAliveCl
|
||||
final ok = await _ensureBakPwd(context);
|
||||
if (!ok) return;
|
||||
final savedPassword = await SecureStoreProps.bakPwd.read();
|
||||
await BackupV2.backup(bakName, savedPassword);
|
||||
await BackupV2.backup(bakName, savedPassword?.isEmpty == true ? null : savedPassword);
|
||||
await Webdav.shared.upload(relativePath: bakName);
|
||||
Loggers.app.info('Upload webdav backup success');
|
||||
} catch (e, s) {
|
||||
@@ -480,7 +485,7 @@ final class _BackupPageState extends State<BackupPage> with AutomaticKeepAliveCl
|
||||
final ok = await _ensureBakPwd(context);
|
||||
if (!ok) return;
|
||||
final savedPassword = await SecureStoreProps.bakPwd.read();
|
||||
await BackupV2.backup(bakName, savedPassword);
|
||||
await BackupV2.backup(bakName, savedPassword?.isEmpty == true ? null : savedPassword);
|
||||
await GistRs.shared.upload(relativePath: bakName);
|
||||
Loggers.app.info('Upload gist backup success');
|
||||
} catch (e, s) {
|
||||
@@ -589,7 +594,13 @@ final class _BackupPageState extends State<BackupPage> with AutomaticKeepAliveCl
|
||||
void _onBulkImportServers(BuildContext context) async {
|
||||
final data = await context.showImportDialog(title: l10n.server, modelDef: Spix.example.toJson());
|
||||
if (data == null) return;
|
||||
final text = String.fromCharCodes(data);
|
||||
String text;
|
||||
try {
|
||||
text = utf8.decode(data);
|
||||
} on FormatException catch (e, s) {
|
||||
context.showErrDialog(e, s, libL10n.error);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
final (spis, err) = await context.showLoadingDialog(
|
||||
@@ -607,8 +618,15 @@ final class _BackupPageState extends State<BackupPage> with AutomaticKeepAliveCl
|
||||
if (sure == true) {
|
||||
final (suc, err) = await context.showLoadingDialog(
|
||||
fn: () async {
|
||||
final usedIds = <String>{};
|
||||
for (var spi in spis) {
|
||||
Stores.server.put(spi);
|
||||
// Ensure each server has a unique ID
|
||||
|
||||
// Only generate a new ID if the imported one is empty or already used in importing stage
|
||||
final isIdUsed = spi.id.isNotEmpty || usedIds.contains(spi.id);
|
||||
final spiWithId = isIdUsed ? spi.copyWith(id: ShortId.generate()) : spi;
|
||||
Stores.server.put(spiWithId);
|
||||
usedIds.add(spiWithId.id);
|
||||
}
|
||||
return true;
|
||||
},
|
||||
@@ -622,6 +640,29 @@ final class _BackupPageState extends State<BackupPage> with AutomaticKeepAliveCl
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
Future<bool> _ensureBakPwd(BuildContext context) async {
|
||||
final saved = await SecureStoreProps.bakPwd.read();
|
||||
if (saved != null && saved.isNotEmpty) return true;
|
||||
|
||||
// Show dialog asking if user wants to set password or continue without
|
||||
final result = await context.showRoundDialog<bool>(
|
||||
title: l10n.backupPassword,
|
||||
child: Text(l10n.backupPasswordTip, style: UIs.textGrey),
|
||||
actions: [
|
||||
TextButton(onPressed: () => context.pop(true), child: Text(libL10n.cancel)),
|
||||
TextButton(onPressed: () => context.pop(false), child: Text(libL10n.setting)),
|
||||
],
|
||||
);
|
||||
|
||||
if (result == true) {
|
||||
// Continue without password
|
||||
return true;
|
||||
} else if (result == false) {
|
||||
// User wants to set password
|
||||
await _onTapSetBakPwd(context);
|
||||
return true; // Allow continuing even if password setting was cancelled
|
||||
}
|
||||
|
||||
return false; // User cancelled the dialog
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
part of 'container.dart';
|
||||
|
||||
extension on _ContainerPageState {
|
||||
/// The notifier for the container state.
|
||||
ContainerNotifier get _containerNotifier => ref.read(_provider.notifier);
|
||||
|
||||
/// Watch the current state of the container.
|
||||
ContainerState get _containerState => ref.watch(_provider);
|
||||
|
||||
Future<void> _showAddFAB() async {
|
||||
final imageCtrl = TextEditingController();
|
||||
final nameCtrl = TextEditingController();
|
||||
@@ -79,7 +85,7 @@ extension on _ContainerPageState {
|
||||
onPressed: () async {
|
||||
context.pop();
|
||||
|
||||
final (result, err) = await context.showLoadingDialog(fn: () => _container.run(cmd));
|
||||
final (result, err) = await context.showLoadingDialog(fn: () => _containerNotifier.run(cmd));
|
||||
if (err != null || result != null) {
|
||||
final e = result?.message ?? err?.toString();
|
||||
context.showRoundDialog(title: libL10n.error, child: Text(e.toString()));
|
||||
@@ -111,7 +117,7 @@ extension on _ContainerPageState {
|
||||
void _onSaveDockerHost(String val) {
|
||||
context.pop();
|
||||
Stores.container.put(widget.args.spi.id, val.trim());
|
||||
_container.refresh();
|
||||
_containerNotifier.refresh();
|
||||
}
|
||||
|
||||
void _showImageRmDialog(ContainerImg e) {
|
||||
@@ -121,7 +127,7 @@ extension on _ContainerPageState {
|
||||
actions: Btn.ok(
|
||||
onTap: () async {
|
||||
context.pop();
|
||||
final result = await _container.run('rmi ${e.id} -f');
|
||||
final result = await _containerNotifier.run('rmi ${e.id} -f');
|
||||
if (result != null) {
|
||||
context.showSnackBar(result.message ?? 'null');
|
||||
}
|
||||
@@ -163,7 +169,9 @@ extension on _ContainerPageState {
|
||||
onTap: () async {
|
||||
context.pop();
|
||||
|
||||
final (result, err) = await context.showLoadingDialog(fn: () => _container.delete(id, force));
|
||||
final (result, err) = await context.showLoadingDialog(
|
||||
fn: () => _containerNotifier.delete(id, force),
|
||||
);
|
||||
if (err != null || result != null) {
|
||||
final e = result?.message ?? err?.toString();
|
||||
context.showRoundDialog(title: libL10n.error, child: Text(e ?? 'null'));
|
||||
@@ -173,21 +181,21 @@ extension on _ContainerPageState {
|
||||
);
|
||||
break;
|
||||
case ContainerMenu.start:
|
||||
final (result, err) = await context.showLoadingDialog(fn: () => _container.start(id));
|
||||
final (result, err) = await context.showLoadingDialog(fn: () => _containerNotifier.start(id));
|
||||
if (err != null || result != null) {
|
||||
final e = result?.message ?? err?.toString();
|
||||
context.showRoundDialog(title: libL10n.error, child: Text(e ?? 'null'));
|
||||
}
|
||||
break;
|
||||
case ContainerMenu.stop:
|
||||
final (result, err) = await context.showLoadingDialog(fn: () => _container.stop(id));
|
||||
final (result, err) = await context.showLoadingDialog(fn: () => _containerNotifier.stop(id));
|
||||
if (err != null || result != null) {
|
||||
final e = result?.message ?? err?.toString();
|
||||
context.showRoundDialog(title: libL10n.error, child: Text(e ?? 'null'));
|
||||
}
|
||||
break;
|
||||
case ContainerMenu.restart:
|
||||
final (result, err) = await context.showLoadingDialog(fn: () => _container.restart(id));
|
||||
final (result, err) = await context.showLoadingDialog(fn: () => _containerNotifier.restart(id));
|
||||
if (err != null || result != null) {
|
||||
final e = result?.message ?? err?.toString();
|
||||
context.showRoundDialog(title: libL10n.error, child: Text(e ?? 'null'));
|
||||
@@ -197,7 +205,7 @@ extension on _ContainerPageState {
|
||||
final args = SshPageArgs(
|
||||
spi: widget.args.spi,
|
||||
initCmd:
|
||||
'${switch (_container.type) {
|
||||
'${switch (_containerState.type) {
|
||||
ContainerType.podman => 'podman',
|
||||
ContainerType.docker => 'docker',
|
||||
}} logs -f --tail 100 ${dItem.id}',
|
||||
@@ -208,7 +216,7 @@ extension on _ContainerPageState {
|
||||
final args = SshPageArgs(
|
||||
spi: widget.args.spi,
|
||||
initCmd:
|
||||
'${switch (_container.type) {
|
||||
'${switch (_containerState.type) {
|
||||
ContainerType.podman => 'podman',
|
||||
ContainerType.docker => 'docker',
|
||||
}} exec -it ${dItem.id} sh',
|
||||
@@ -222,7 +230,7 @@ extension on _ContainerPageState {
|
||||
if (Stores.setting.containerAutoRefresh.fetch()) {
|
||||
Timer.periodic(Duration(seconds: Stores.setting.serverStatusUpdateInterval.fetch()), (timer) {
|
||||
if (mounted) {
|
||||
_container.refresh(isAuto: true);
|
||||
_containerNotifier.refresh(isAuto: true);
|
||||
} else {
|
||||
timer.cancel();
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@ import 'dart:async';
|
||||
|
||||
import 'package:fl_lib/fl_lib.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:icons_plus/icons_plus.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:server_box/core/extension/context/locale.dart';
|
||||
import 'package:server_box/core/route.dart';
|
||||
import 'package:server_box/data/model/app/error.dart';
|
||||
@@ -12,81 +12,79 @@ import 'package:server_box/data/model/app/menu/container.dart';
|
||||
import 'package:server_box/data/model/container/image.dart';
|
||||
import 'package:server_box/data/model/container/ps.dart';
|
||||
import 'package:server_box/data/model/container/type.dart';
|
||||
import 'package:server_box/data/model/server/server_private_info.dart';
|
||||
import 'package:server_box/data/provider/container.dart';
|
||||
import 'package:server_box/data/provider/server/single.dart';
|
||||
import 'package:server_box/data/res/store.dart';
|
||||
import 'package:server_box/view/page/ssh/page/page.dart';
|
||||
|
||||
part 'actions.dart';
|
||||
part 'types.dart';
|
||||
|
||||
class ContainerPage extends StatefulWidget {
|
||||
class ContainerPage extends ConsumerStatefulWidget {
|
||||
final SpiRequiredArgs args;
|
||||
const ContainerPage({required this.args, super.key});
|
||||
|
||||
@override
|
||||
State<ContainerPage> createState() => _ContainerPageState();
|
||||
ConsumerState<ContainerPage> createState() => _ContainerPageState();
|
||||
|
||||
static const route = AppRouteArg(page: ContainerPage.new, path: '/container');
|
||||
}
|
||||
|
||||
class _ContainerPageState extends State<ContainerPage> {
|
||||
class _ContainerPageState extends ConsumerState<ContainerPage> {
|
||||
final _textController = TextEditingController();
|
||||
late final _container = ContainerProvider(
|
||||
client: widget.args.spi.server?.value.client,
|
||||
userName: widget.args.spi.user,
|
||||
hostId: widget.args.spi.id,
|
||||
context: context,
|
||||
);
|
||||
late final ContainerNotifierProvider _provider;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
_textController.dispose();
|
||||
_container.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
final serverState = ref.read(serverNotifierProvider(widget.args.spi.id));
|
||||
_provider = containerNotifierProvider(
|
||||
serverState.client,
|
||||
widget.args.spi.user,
|
||||
widget.args.spi.id,
|
||||
context,
|
||||
);
|
||||
_initAutoRefresh();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ChangeNotifierProvider(
|
||||
create: (_) => _container,
|
||||
builder: (_, _) => Consumer<ContainerProvider>(
|
||||
builder: (_, _, _) {
|
||||
return Scaffold(
|
||||
appBar: _buildAppBar,
|
||||
body: SafeArea(child: _buildMain),
|
||||
floatingActionButton: _container.error == null ? _buildFAB : null,
|
||||
);
|
||||
},
|
||||
),
|
||||
final err = ref.watch(_provider.select((p) => p.error));
|
||||
|
||||
return Scaffold(
|
||||
appBar: _buildAppBar(),
|
||||
body: SafeArea(child: _buildMain()),
|
||||
floatingActionButton: err == null ? _buildFAB() : null,
|
||||
);
|
||||
}
|
||||
|
||||
CustomAppBar get _buildAppBar {
|
||||
CustomAppBar _buildAppBar() {
|
||||
return CustomAppBar(
|
||||
centerTitle: true,
|
||||
title: TwoLineText(up: l10n.container, down: widget.args.spi.name),
|
||||
actions: [
|
||||
IconButton(
|
||||
onPressed: () => context.showLoadingDialog(fn: () => _container.refresh()),
|
||||
onPressed: () => context.showLoadingDialog(fn: () => _containerNotifier.refresh()),
|
||||
icon: const Icon(Icons.refresh),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget get _buildFAB {
|
||||
Widget _buildFAB() {
|
||||
return FloatingActionButton(onPressed: () async => await _showAddFAB(), child: const Icon(Icons.add));
|
||||
}
|
||||
|
||||
Widget get _buildMain {
|
||||
if (_container.error != null && _container.items == null) {
|
||||
Widget _buildMain() {
|
||||
final containerState = _containerState;
|
||||
|
||||
if (containerState.error != null && containerState.items == null) {
|
||||
return SizedBox.expand(
|
||||
child: Column(
|
||||
children: [
|
||||
@@ -95,7 +93,7 @@ class _ContainerPageState extends State<ContainerPage> {
|
||||
UIs.height13,
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 23),
|
||||
child: Text(_container.error.toString()),
|
||||
child: Text(containerState.error.toString()),
|
||||
),
|
||||
const Spacer(),
|
||||
UIs.height13,
|
||||
@@ -104,27 +102,27 @@ class _ContainerPageState extends State<ContainerPage> {
|
||||
).paddingSymmetric(horizontal: 13),
|
||||
);
|
||||
}
|
||||
if (_container.items == null || _container.images == null) {
|
||||
if (containerState.items == null || containerState.images == null) {
|
||||
return UIs.centerLoading;
|
||||
}
|
||||
|
||||
return AutoMultiList(
|
||||
children: <Widget>[
|
||||
_buildLoading(),
|
||||
_buildVersion(),
|
||||
_buildPs(),
|
||||
_buildImage(),
|
||||
_buildEmptyStateMessage(),
|
||||
_buildLoading(containerState),
|
||||
_buildVersion(containerState),
|
||||
_buildPs(containerState),
|
||||
_buildImage(containerState),
|
||||
_buildEmptyStateMessage(containerState),
|
||||
_buildPruneBtns,
|
||||
_buildSettingsBtns,
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildEmptyStateMessage() {
|
||||
final emptyImgs = _container.images?.isEmpty ?? true;
|
||||
final emptyPs = _container.items?.isEmpty ?? true;
|
||||
if (emptyPs && emptyImgs && _container.runLog == null) {
|
||||
Widget _buildEmptyStateMessage(ContainerState containerState) {
|
||||
final emptyImgs = containerState.images?.isEmpty ?? true;
|
||||
final emptyPs = containerState.items?.isEmpty ?? true;
|
||||
if (emptyPs && emptyImgs && containerState.runLog == null) {
|
||||
return CardX(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(17, 17, 17, 7),
|
||||
@@ -135,13 +133,13 @@ class _ContainerPageState extends State<ContainerPage> {
|
||||
return UIs.placeholder;
|
||||
}
|
||||
|
||||
Widget _buildImage() {
|
||||
Widget _buildImage(ContainerState containerState) {
|
||||
return ExpandTile(
|
||||
leading: const Icon(MingCute.clapperboard_line),
|
||||
title: Text(l10n.imagesList),
|
||||
subtitle: Text(l10n.dockerImagesFmt(_container.images!.length), style: UIs.textGrey),
|
||||
initiallyExpanded: (_container.images?.length ?? 0) <= 3,
|
||||
children: _container.images?.map(_buildImageItem).toList() ?? [],
|
||||
subtitle: Text(l10n.dockerImagesFmt(containerState.images?.length ?? 'null'), style: UIs.textGrey),
|
||||
initiallyExpanded: (containerState.images?.length ?? 0) <= 3,
|
||||
children: containerState.images?.map(_buildImageItem).toList() ?? [],
|
||||
).cardx;
|
||||
}
|
||||
|
||||
@@ -161,36 +159,36 @@ class _ContainerPageState extends State<ContainerPage> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildLoading() {
|
||||
if (_container.runLog == null) return UIs.placeholder;
|
||||
Widget _buildLoading(ContainerState containerState) {
|
||||
if (containerState.runLog == null) return UIs.placeholder;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(17),
|
||||
child: Column(
|
||||
children: [
|
||||
const Center(child: CircularProgressIndicator()),
|
||||
UIs.height13,
|
||||
Text(_container.runLog ?? '...'),
|
||||
Text(containerState.runLog ?? '...'),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildVersion() {
|
||||
Widget _buildVersion(ContainerState containerState) {
|
||||
return CardX(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(17),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [Text(_container.type.name.capitalize), Text(_container.version ?? l10n.unknown)],
|
||||
children: [Text(containerState.type.name.capitalize), Text(containerState.version ?? l10n.unknown)],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPs() {
|
||||
final items = _container.items;
|
||||
Widget _buildPs(ContainerState containerState) {
|
||||
final items = containerState.items;
|
||||
if (items == null) return UIs.placeholder;
|
||||
final running = items.where((e) => e.running).length;
|
||||
final running = items.where((e) => e.status.isRunning).length;
|
||||
final stopped = items.length - running;
|
||||
final subtitle = stopped > 0
|
||||
? l10n.dockerStatusRunningAndStoppedFmt(running, stopped)
|
||||
@@ -221,8 +219,8 @@ class _ContainerPageState extends State<ContainerPage> {
|
||||
),
|
||||
Text(
|
||||
'${item.image ?? l10n.unknown} - ${switch (item) {
|
||||
final PodmanPs ps => ps.running ? l10n.running : l10n.stopped,
|
||||
final DockerPs ps => ps.state,
|
||||
final PodmanPs ps => ps.status.displayName,
|
||||
final DockerPs ps => ps.state ?? ps.status.displayName,
|
||||
}}',
|
||||
style: UIs.text13Grey,
|
||||
),
|
||||
@@ -279,7 +277,7 @@ class _ContainerPageState extends State<ContainerPage> {
|
||||
|
||||
Widget _buildMoreBtn(ContainerPs dItem) {
|
||||
return PopupMenu(
|
||||
items: ContainerMenu.items(dItem.running).map((e) => PopMenu.build(e, e.icon, e.toStr)).toList(),
|
||||
items: ContainerMenu.items(dItem.status.isRunning).map((e) => PopMenu.build(e, e.icon, e.toStr)).toList(),
|
||||
onSelected: (item) => _onTapMoreBtn(item, dItem),
|
||||
);
|
||||
}
|
||||
@@ -309,16 +307,17 @@ class _ContainerPageState extends State<ContainerPage> {
|
||||
|
||||
Widget _buildPruneBtn(_PruneTypes type) {
|
||||
final title = type.name.capitalize;
|
||||
final containerNotifier = _containerNotifier;
|
||||
return ListTile(
|
||||
onTap: () async {
|
||||
await _showPruneDialog(
|
||||
title: title,
|
||||
message: type.tip,
|
||||
onConfirm: switch (type) {
|
||||
_PruneTypes.images => _container.pruneImages,
|
||||
_PruneTypes.containers => _container.pruneContainers,
|
||||
_PruneTypes.volumes => _container.pruneVolumes,
|
||||
_PruneTypes.system => _container.pruneSystem,
|
||||
_PruneTypes.images => containerNotifier.pruneImages,
|
||||
_PruneTypes.containers => containerNotifier.pruneContainers,
|
||||
_PruneTypes.volumes => containerNotifier.pruneVolumes,
|
||||
_PruneTypes.system => containerNotifier.pruneSystem,
|
||||
},
|
||||
);
|
||||
},
|
||||
@@ -330,22 +329,26 @@ class _ContainerPageState extends State<ContainerPage> {
|
||||
Widget get _buildSettingsBtns {
|
||||
final len = _SettingsMenuItems.values.length;
|
||||
if (len == 0) return UIs.placeholder;
|
||||
final containerState = _containerState;
|
||||
|
||||
return ExpandTile(
|
||||
leading: const Icon(Icons.settings),
|
||||
title: Text(libL10n.setting),
|
||||
initiallyExpanded: _container.error != null,
|
||||
children: _SettingsMenuItems.values.map(_buildSettingTile).toList(),
|
||||
initiallyExpanded: containerState.error != null,
|
||||
children: _SettingsMenuItems.values.map((item) => _buildSettingTile(item, containerState)).toList(),
|
||||
).cardx;
|
||||
}
|
||||
|
||||
Widget _buildSettingTile(_SettingsMenuItems item) {
|
||||
Widget _buildSettingTile(_SettingsMenuItems item, ContainerState containerState) {
|
||||
final String title;
|
||||
switch (item) {
|
||||
case _SettingsMenuItems.editDockerHost:
|
||||
title = '${libL10n.edit} DOCKER_HOST';
|
||||
break;
|
||||
case _SettingsMenuItems.switchProvider:
|
||||
title = _container.type == ContainerType.podman ? l10n.switchTo('Docker') : l10n.switchTo('Podman');
|
||||
title = containerState.type == ContainerType.podman
|
||||
? l10n.switchTo('Docker')
|
||||
: l10n.switchTo('Podman');
|
||||
break;
|
||||
}
|
||||
return ListTile(
|
||||
@@ -355,9 +358,11 @@ class _ContainerPageState extends State<ContainerPage> {
|
||||
_showEditHostDialog();
|
||||
break;
|
||||
case _SettingsMenuItems.switchProvider:
|
||||
_container.setType(
|
||||
_container.type == ContainerType.docker ? ContainerType.podman : ContainerType.docker,
|
||||
);
|
||||
ref
|
||||
.read(_provider.notifier)
|
||||
.setType(
|
||||
containerState.type == ContainerType.docker ? ContainerType.podman : ContainerType.docker,
|
||||
);
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1,26 +1,28 @@
|
||||
import 'package:fl_lib/fl_lib.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:responsive_framework/responsive_framework.dart';
|
||||
import 'package:server_box/core/chan.dart';
|
||||
import 'package:server_box/core/sync.dart';
|
||||
import 'package:server_box/data/model/app/tab.dart';
|
||||
import 'package:server_box/data/provider/server.dart';
|
||||
import 'package:server_box/data/provider/server/all.dart';
|
||||
import 'package:server_box/data/res/build_data.dart';
|
||||
import 'package:server_box/data/res/store.dart';
|
||||
import 'package:server_box/data/res/url.dart';
|
||||
import 'package:server_box/view/page/setting/entry.dart';
|
||||
import 'package:wakelock_plus/wakelock_plus.dart';
|
||||
|
||||
class HomePage extends StatefulWidget {
|
||||
class HomePage extends ConsumerStatefulWidget {
|
||||
const HomePage({super.key});
|
||||
|
||||
@override
|
||||
State<HomePage> createState() => _HomePageState();
|
||||
ConsumerState<HomePage> createState() => _HomePageState();
|
||||
|
||||
static const route = AppRouteNoArg(page: HomePage.new, path: '/');
|
||||
}
|
||||
|
||||
class _HomePageState extends State<HomePage>
|
||||
with AutomaticKeepAliveClientMixin, AfterLayoutMixin, WidgetsBindingObserver {
|
||||
class _HomePageState extends ConsumerState<HomePage>
|
||||
with AutomaticKeepAliveClientMixin, AfterLayoutMixin, WidgetsBindingObserver, GlobalRef {
|
||||
late final PageController _pageController;
|
||||
|
||||
final _selectIndex = ValueNotifier(0);
|
||||
@@ -29,11 +31,15 @@ class _HomePageState extends State<HomePage>
|
||||
bool _shouldAuth = false;
|
||||
DateTime? _pausedTime;
|
||||
|
||||
late final _notifier = ref.read(serversNotifierProvider.notifier);
|
||||
late final _provider = ref.read(serversNotifierProvider);
|
||||
late List<AppTab> _tabs = Stores.setting.homeTabs.fetch();
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
WidgetsBinding.instance.removeObserver(this);
|
||||
ServerProvider.closeServer();
|
||||
Future(() => _notifier.closeServer());
|
||||
_pageController.dispose();
|
||||
WakelockPlus.disable();
|
||||
|
||||
@@ -46,13 +52,30 @@ class _HomePageState extends State<HomePage>
|
||||
SystemUIs.switchStatusBar(hide: false);
|
||||
WidgetsBinding.instance.addObserver(this);
|
||||
// avoid index out of range
|
||||
if (_selectIndex.value >= AppTab.values.length || _selectIndex.value < 0) {
|
||||
if (_selectIndex.value >= _tabs.length || _selectIndex.value < 0) {
|
||||
_selectIndex.value = 0;
|
||||
}
|
||||
_pageController = PageController(initialPage: _selectIndex.value);
|
||||
if (Stores.setting.generalWakeLock.fetch()) {
|
||||
WakelockPlus.enable();
|
||||
}
|
||||
|
||||
// Listen to homeTabs changes
|
||||
Stores.setting.homeTabs.listenable().addListener(() {
|
||||
final newTabs = Stores.setting.homeTabs.fetch();
|
||||
if (mounted && newTabs != _tabs) {
|
||||
setState(() {
|
||||
_tabs = newTabs;
|
||||
// Ensure current page index is valid
|
||||
if (_selectIndex.value >= _tabs.length) {
|
||||
_selectIndex.value = _tabs.length - 1;
|
||||
}
|
||||
if (_selectIndex.value < 0 && _tabs.isNotEmpty) {
|
||||
_selectIndex.value = 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -76,8 +99,9 @@ class _HomePageState extends State<HomePage>
|
||||
_goAuth();
|
||||
}
|
||||
}
|
||||
if (!ServerProvider.isAutoRefreshOn) {
|
||||
ServerProvider.startAutoRefresh();
|
||||
final serverNotifier = _notifier;
|
||||
if (_provider.autoRefreshTimer == null) {
|
||||
serverNotifier.startAutoRefresh();
|
||||
}
|
||||
MethodChans.updateHomeWidget();
|
||||
break;
|
||||
@@ -92,7 +116,7 @@ class _HomePageState extends State<HomePage>
|
||||
// }
|
||||
} else {
|
||||
//Pros.server.setDisconnected();
|
||||
ServerProvider.stopAutoRefresh();
|
||||
_notifier.stopAutoRefresh();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -113,9 +137,9 @@ class _HomePageState extends State<HomePage>
|
||||
Expanded(
|
||||
child: PageView.builder(
|
||||
controller: _pageController,
|
||||
itemCount: AppTab.values.length,
|
||||
itemCount: _tabs.length,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemBuilder: (_, index) => AppTab.values[index].page,
|
||||
itemBuilder: (_, index) => _tabs[index].page,
|
||||
onPageChanged: (value) {
|
||||
FocusScope.of(context).unfocus();
|
||||
if (!_switchingPage) {
|
||||
@@ -140,7 +164,7 @@ class _HomePageState extends State<HomePage>
|
||||
animationDuration: const Duration(milliseconds: 250),
|
||||
onDestinationSelected: _onDestinationSelected,
|
||||
labelBehavior: NavigationDestinationLabelBehavior.onlyShowSelected,
|
||||
destinations: AppTab.navDestinations,
|
||||
destinations: _tabs.map((tab) => tab.navDestination).toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -159,7 +183,7 @@ class _HomePageState extends State<HomePage>
|
||||
trailing: extended ? const SizedBox(height: 20) : null,
|
||||
labelType: extended ? NavigationRailLabelType.none : NavigationRailLabelType.all,
|
||||
selectedIndex: idx,
|
||||
destinations: AppTab.navRailDestinations,
|
||||
destinations: _tabs.map((tab) => tab.navRailDestination).toList(),
|
||||
onDestinationSelected: _onDestinationSelected,
|
||||
),
|
||||
),
|
||||
@@ -194,7 +218,9 @@ class _HomePageState extends State<HomePage>
|
||||
AppUpdateIface.doUpdate(build: BuildData.build, url: Urls.updateCfg, context: context);
|
||||
}
|
||||
MethodChans.updateHomeWidget();
|
||||
await ServerProvider.refresh();
|
||||
await _notifier.refresh();
|
||||
|
||||
bakSync.sync(milliDelay: 1000);
|
||||
}
|
||||
|
||||
// Future<void> _reqNotiPerm() async {
|
||||
@@ -202,7 +228,6 @@ class _HomePageState extends State<HomePage>
|
||||
// final suc = await PermUtils.request(Permission.notification);
|
||||
// if (!suc) {
|
||||
// final noNotiPerm = Stores.setting.noNotiPerm;
|
||||
// if (noNotiPerm.fetch()) return;
|
||||
// context.showRoundDialog(
|
||||
// title: l10n.error,
|
||||
// child: Text(l10n.noNotiPerm),
|
||||
@@ -212,6 +237,7 @@ class _HomePageState extends State<HomePage>
|
||||
// noNotiPerm.put(true);
|
||||
// context.pop();
|
||||
// },
|
||||
// if (noNotiPerm.fetch()) return;
|
||||
// child: Text(l10n.ok),
|
||||
// ),
|
||||
// ],
|
||||
@@ -228,6 +254,7 @@ class _HomePageState extends State<HomePage>
|
||||
|
||||
void _onDestinationSelected(int index) {
|
||||
if (_selectIndex.value == index) return;
|
||||
if (index < 0 || index >= _tabs.length) return;
|
||||
_selectIndex.value = index;
|
||||
_switchingPage = true;
|
||||
_pageController.animateToPage(
|
||||
|
||||
@@ -2,23 +2,25 @@ import 'dart:async';
|
||||
|
||||
import 'package:fl_lib/fl_lib.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:server_box/core/extension/context/locale.dart';
|
||||
import 'package:server_box/data/model/server/ping_result.dart';
|
||||
import 'package:server_box/data/provider/server.dart';
|
||||
import 'package:server_box/data/provider/server/all.dart';
|
||||
import 'package:server_box/data/provider/server/single.dart';
|
||||
|
||||
/// Only permit ipv4 / ipv6 / domain chars
|
||||
final targetReg = RegExp(r'[a-zA-Z0-9\.-_:]+');
|
||||
|
||||
class PingPage extends StatefulWidget {
|
||||
class PingPage extends ConsumerStatefulWidget {
|
||||
const PingPage({super.key});
|
||||
|
||||
@override
|
||||
State<PingPage> createState() => _PingPageState();
|
||||
ConsumerState<PingPage> createState() => _PingPageState();
|
||||
|
||||
static const route = AppRouteNoArg(page: PingPage.new, path: '/ping');
|
||||
}
|
||||
|
||||
class _PingPageState extends State<PingPage> with AutomaticKeepAliveClientMixin {
|
||||
class _PingPageState extends ConsumerState<PingPage> with AutomaticKeepAliveClientMixin {
|
||||
late TextEditingController _textEditingController;
|
||||
final _results = ValueNotifier(<PingResult>[]);
|
||||
bool get isInit => _results.value.isEmpty;
|
||||
@@ -129,7 +131,7 @@ class _PingPageState extends State<PingPage> with AutomaticKeepAliveClientMixin
|
||||
return;
|
||||
}
|
||||
|
||||
if (ServerProvider.serverOrder.value.isEmpty) {
|
||||
if (ref.read(serversNotifierProvider).serverOrder.isEmpty) {
|
||||
context.showSnackBar(l10n.pingNoServer);
|
||||
return;
|
||||
}
|
||||
@@ -141,13 +143,13 @@ class _PingPageState extends State<PingPage> with AutomaticKeepAliveClientMixin
|
||||
}
|
||||
|
||||
await Future.wait(
|
||||
ServerProvider.servers.values.map((v) async {
|
||||
final e = v.value;
|
||||
if (e.client == null) {
|
||||
ref.read(serversNotifierProvider).servers.values.map((spi) async {
|
||||
final serverState = ref.read(serverNotifierProvider(spi.id));
|
||||
if (serverState.client == null) {
|
||||
return;
|
||||
}
|
||||
final result = await e.client!.run('ping -c 3 $target').string;
|
||||
_results.value.add(PingResult.parse(e.spi.name, result));
|
||||
final result = await serverState.client!.run('ping -c 3 $target').string;
|
||||
_results.value.add(PingResult.parse(spi.name, result));
|
||||
// [ValueNotifier] only notify when value is changed
|
||||
// But we just add a element to list without changing the list itself
|
||||
// So we need to notify manually
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:computer/computer.dart';
|
||||
import 'package:fl_lib/fl_lib.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:server_box/core/extension/context/locale.dart';
|
||||
import 'package:server_box/core/utils/server.dart';
|
||||
import 'package:server_box/data/model/server/private_key_info.dart';
|
||||
@@ -17,17 +18,17 @@ final class PrivateKeyEditPageArgs {
|
||||
const PrivateKeyEditPageArgs({this.pki});
|
||||
}
|
||||
|
||||
class PrivateKeyEditPage extends StatefulWidget {
|
||||
class PrivateKeyEditPage extends ConsumerStatefulWidget {
|
||||
final PrivateKeyEditPageArgs? args;
|
||||
const PrivateKeyEditPage({super.key, this.args});
|
||||
|
||||
@override
|
||||
State<PrivateKeyEditPage> createState() => _PrivateKeyEditPageState();
|
||||
ConsumerState<PrivateKeyEditPage> createState() => _PrivateKeyEditPageState();
|
||||
|
||||
static const route = AppRoute(page: PrivateKeyEditPage.new, path: '/private_key/edit');
|
||||
}
|
||||
|
||||
class _PrivateKeyEditPageState extends State<PrivateKeyEditPage> {
|
||||
class _PrivateKeyEditPageState extends ConsumerState<PrivateKeyEditPage> {
|
||||
final _nameController = TextEditingController();
|
||||
final _keyController = TextEditingController();
|
||||
final _pwdController = TextEditingController();
|
||||
@@ -39,6 +40,8 @@ class _PrivateKeyEditPageState extends State<PrivateKeyEditPage> {
|
||||
|
||||
final _loading = ValueNotifier<Widget?>(null);
|
||||
|
||||
late final _notifier = ref.read(privateKeyNotifierProvider.notifier);
|
||||
|
||||
PrivateKeyInfo? get pki => widget.args?.pki;
|
||||
|
||||
@override
|
||||
@@ -94,7 +97,7 @@ class _PrivateKeyEditPageState extends State<PrivateKeyEditPage> {
|
||||
child: Text(libL10n.askContinue('${libL10n.delete} ${l10n.privateKey}(${pki.id})')),
|
||||
actions: Btn.ok(
|
||||
onTap: () {
|
||||
PrivateKeyProvider.delete(pki);
|
||||
_notifier.delete(pki);
|
||||
context.pop();
|
||||
context.pop();
|
||||
},
|
||||
@@ -196,9 +199,9 @@ class _PrivateKeyEditPageState extends State<PrivateKeyEditPage> {
|
||||
final pki = PrivateKeyInfo(id: name, key: decrypted);
|
||||
final originPki = this.pki;
|
||||
if (originPki != null) {
|
||||
PrivateKeyProvider.update(originPki, pki);
|
||||
_notifier.update(originPki, pki);
|
||||
} else {
|
||||
PrivateKeyProvider.add(pki);
|
||||
_notifier.add(pki);
|
||||
}
|
||||
} catch (e) {
|
||||
context.showSnackBar(e.toString());
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user