mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 23:34:24 +01:00
new: picker & opt. rm -r
This commit is contained in:
@@ -265,18 +265,24 @@ class _ServerPageState extends State<ServerPage>
|
||||
tooltip: 'Suspend',
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () => _askFor(func: () => srv.client?.execWithPwd(
|
||||
ShellFunc.shutdown.exec,
|
||||
context: context,
|
||||
), msg: 'Shutdown ${srv.spi.name}',),
|
||||
onPressed: () => _askFor(
|
||||
func: () => srv.client?.execWithPwd(
|
||||
ShellFunc.shutdown.exec,
|
||||
context: context,
|
||||
),
|
||||
msg: 'Shutdown ${srv.spi.name}',
|
||||
),
|
||||
icon: const Icon(Icons.power_off),
|
||||
tooltip: 'Shutdown',
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () => _askFor(func: () => srv.client?.execWithPwd(
|
||||
ShellFunc.reboot.exec,
|
||||
context: context,
|
||||
), msg: 'Reboot ${srv.spi.name}',),
|
||||
onPressed: () => _askFor(
|
||||
func: () => srv.client?.execWithPwd(
|
||||
ShellFunc.reboot.exec,
|
||||
context: context,
|
||||
),
|
||||
msg: 'Reboot ${srv.spi.name}',
|
||||
),
|
||||
icon: const Icon(Icons.restart_alt),
|
||||
tooltip: 'Reboot',
|
||||
),
|
||||
|
||||
@@ -234,7 +234,7 @@ class _SettingPageState extends State<SettingPage> {
|
||||
// Use hardware keyboard on desktop, so there is no need to set it
|
||||
if (isMobile) _buildKeyboardType(),
|
||||
_buildSSHVirtKeys(),
|
||||
_buildSftpRmrfDir(),
|
||||
_buildSftpRmrDir(),
|
||||
].map((e) => RoundRectCard(e)).toList(),
|
||||
);
|
||||
}
|
||||
@@ -997,11 +997,11 @@ class _SettingPageState extends State<SettingPage> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSftpRmrfDir() {
|
||||
Widget _buildSftpRmrDir() {
|
||||
return ListTile(
|
||||
title: const Text('rm -rf'),
|
||||
subtitle: Text(l10n.sftpRmrfDirSummary, style: UIs.textGrey),
|
||||
trailing: StoreSwitch(prop: _setting.sftpRmrfDir),
|
||||
title: const Text('rm -r'),
|
||||
subtitle: Text(l10n.sftpRmrDirSummary, style: UIs.textGrey),
|
||||
trailing: StoreSwitch(prop: _setting.sftpRmrDir),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -127,13 +127,10 @@ class _SnippetListPageState extends State<SnippetListPage> {
|
||||
}
|
||||
|
||||
Future<void> _runSnippet(Snippet snippet) async {
|
||||
final servers = await showDialog<List<Server>>(
|
||||
context: context,
|
||||
builder: (_) => TagPicker<Server>(
|
||||
final servers = await context.showPickDialog<Server>(
|
||||
items: Pros.server.servers.toList(),
|
||||
tags: Pros.server.tags.toSet(),
|
||||
),
|
||||
);
|
||||
name: (e) => e.spi.name,
|
||||
);
|
||||
if (servers == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,9 @@ import 'package:toolbox/core/extension/context/dialog.dart';
|
||||
import 'package:toolbox/core/extension/context/locale.dart';
|
||||
import 'package:toolbox/core/extension/context/snackbar.dart';
|
||||
import 'package:toolbox/core/utils/platform/base.dart';
|
||||
import 'package:toolbox/data/model/server/snippet.dart';
|
||||
import 'package:toolbox/data/provider/virtual_keyboard.dart';
|
||||
import 'package:toolbox/data/res/provider.dart';
|
||||
import 'package:toolbox/data/res/store.dart';
|
||||
import 'package:xterm/core.dart';
|
||||
import 'package:xterm/ui.dart' hide TerminalThemes;
|
||||
@@ -253,10 +255,13 @@ class _SSHPageState extends State<SSHPage> {
|
||||
}
|
||||
break;
|
||||
case VirtualKeyFunc.snippet:
|
||||
context.showSnippetDialog((s) {
|
||||
_terminal.textInput(s.script);
|
||||
_terminal.keyInput(TerminalKey.enter);
|
||||
});
|
||||
final s = await context.showPickSingleDialog<Snippet>(
|
||||
items: Pros.snippet.snippets,
|
||||
name: (p0) => p0.name,
|
||||
);
|
||||
if (s == null) return;
|
||||
_terminal.textInput(s.script);
|
||||
_terminal.keyInput(TerminalKey.enter);
|
||||
break;
|
||||
case VirtualKeyFunc.file:
|
||||
// get $PWD from SSH session
|
||||
|
||||
@@ -5,12 +5,12 @@ import 'package:toolbox/core/extension/context/common.dart';
|
||||
import 'package:toolbox/core/extension/context/dialog.dart';
|
||||
import 'package:toolbox/core/extension/context/locale.dart';
|
||||
import 'package:toolbox/core/extension/context/snackbar.dart';
|
||||
import 'package:toolbox/data/model/server/server_private_info.dart';
|
||||
import 'package:toolbox/data/model/sftp/req.dart';
|
||||
import 'package:toolbox/data/res/misc.dart';
|
||||
import 'package:toolbox/data/res/provider.dart';
|
||||
import 'package:toolbox/view/widget/input_field.dart';
|
||||
import 'package:toolbox/view/widget/omit_start_text.dart';
|
||||
import 'package:toolbox/view/widget/picker.dart';
|
||||
import 'package:toolbox/view/widget/round_rect_card.dart';
|
||||
|
||||
import '../../../core/extension/numx.dart';
|
||||
@@ -273,24 +273,15 @@ class _LocalStoragePageState extends State<LocalStoragePage> {
|
||||
title: Text(l10n.upload),
|
||||
onTap: () async {
|
||||
context.pop();
|
||||
final ids = Pros.server.serverOrder;
|
||||
var idx = 0;
|
||||
await context.showRoundDialog(
|
||||
title: Text(l10n.server),
|
||||
child: Picker(
|
||||
items: ids.map((e) => Text(e)).toList(),
|
||||
onSelected: (idx_) => idx = idx_,
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => context.pop(), child: Text(l10n.ok)),
|
||||
],
|
||||
|
||||
final spi = await context.showPickSingleDialog<ServerPrivateInfo>(
|
||||
items: Pros.server.serverOrder
|
||||
.map((e) => Pros.server.pick(id: e)?.spi)
|
||||
.toList(),
|
||||
name: (e) => e.name,
|
||||
);
|
||||
final id = ids[idx];
|
||||
final spi = Pros.server.pick(id: id)?.spi;
|
||||
if (spi == null) {
|
||||
return;
|
||||
}
|
||||
if (spi == null) return;
|
||||
|
||||
final remotePath = await AppRoute.sftp(
|
||||
spi: spi,
|
||||
isSelect: true,
|
||||
@@ -298,6 +289,7 @@ class _LocalStoragePageState extends State<LocalStoragePage> {
|
||||
if (remotePath == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Pros.sftp.add(SftpReq(
|
||||
spi,
|
||||
'$remotePath/$fileName',
|
||||
@@ -346,7 +338,7 @@ class _LocalStoragePageState extends State<LocalStoragePage> {
|
||||
final fileName = file.path.split('/').last;
|
||||
context.showRoundDialog(
|
||||
title: Text(l10n.delete),
|
||||
child: Text(l10n.sureDelete(fileName)),
|
||||
child: Text(l10n.askContinue('${l10n.delete}: $fileName')),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => context.pop(),
|
||||
|
||||
@@ -409,13 +409,16 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
|
||||
void _delete(SftpName file) {
|
||||
context.pop();
|
||||
final isDir = file.attr.isDirectory;
|
||||
final useRmrf = Stores.setting.sftpRmrfDir.fetch();
|
||||
final dirText = (isDir && !useRmrf) ? '\n${l10n.dirEmpty}' : '';
|
||||
final text = l10n.askContinue(
|
||||
'${l10n.delete} ${l10n.files}(${file.filename})\n$dirText');
|
||||
final child = Text(text);
|
||||
final useRmr = Stores.setting.sftpRmrDir.fetch();
|
||||
final text = () {
|
||||
if (isDir && !useRmr) {
|
||||
return l10n.askContinue(
|
||||
'${l10n.dirEmpty}\n${l10n.delete} ${l10n.files}(${file.filename})');
|
||||
}
|
||||
return l10n.askContinue('${l10n.delete} ${l10n.files}(${file.filename})');
|
||||
}();
|
||||
context.showRoundDialog(
|
||||
child: child,
|
||||
child: Text(text),
|
||||
title: Text(l10n.attention),
|
||||
actions: [
|
||||
TextButton(
|
||||
@@ -428,8 +431,8 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
|
||||
context.showLoadingDialog();
|
||||
final remotePath = _getRemotePath(file);
|
||||
try {
|
||||
if (useRmrf) {
|
||||
await _client!.run('rm -rf "$remotePath"');
|
||||
if (useRmr) {
|
||||
await _client!.run('rm -r "$remotePath"');
|
||||
} else if (file.attr.isDirectory) {
|
||||
await _status.client!.rmdir(remotePath);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user