init ssh
This commit is contained in:
@@ -21,6 +21,7 @@ import 'package:toolbox/view/page/server/detail.dart';
|
||||
import 'package:toolbox/view/page/server/edit.dart';
|
||||
import 'package:toolbox/view/page/sftp/view.dart';
|
||||
import 'package:toolbox/view/page/snippet/edit.dart';
|
||||
import 'package:toolbox/view/page/ssh.dart';
|
||||
import 'package:toolbox/view/widget/picker.dart';
|
||||
import 'package:toolbox/view/widget/round_rect_card.dart';
|
||||
|
||||
@@ -160,8 +161,8 @@ class _ServerPageState extends State<ServerPage>
|
||||
context, _s.error, Text(ss.failedInfo ?? ''), []),
|
||||
child: Text(_s.clickSee, style: style))
|
||||
: Text(topRightStr, style: style, textScaleFactor: 1.0),
|
||||
const SizedBox(width: 7),
|
||||
_buildSnippetBtn(spi),
|
||||
const SizedBox(width: 9),
|
||||
_buildSSHBtn(spi),
|
||||
_buildMoreBtn(spi),
|
||||
],
|
||||
)
|
||||
@@ -196,60 +197,13 @@ class _ServerPageState extends State<ServerPage>
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSnippetBtn(ServerPrivateInfo spi) {
|
||||
Widget _buildSSHBtn(ServerPrivateInfo spi) {
|
||||
return GestureDetector(
|
||||
child: const Icon(Icons.play_arrow),
|
||||
onTap: () {
|
||||
final provider = locator<SnippetProvider>();
|
||||
if (provider.snippets.isEmpty) {
|
||||
showRoundDialog(
|
||||
context,
|
||||
_s.attention,
|
||||
Text(_s.noSavedSnippet),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: Text(_s.ok),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () =>
|
||||
AppRoute(const SnippetEditPage(), 'edit snippet')
|
||||
.go(context),
|
||||
child: Text(_s.addOne),
|
||||
)
|
||||
],
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
var snippet = provider.snippets.first;
|
||||
showRoundDialog(
|
||||
context,
|
||||
_s.choose,
|
||||
buildPicker(provider.snippets.map((e) => Text(e.name)).toList(),
|
||||
(idx) => snippet = provider.snippets[idx]),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
Navigator.of(context).pop();
|
||||
final result =
|
||||
await locator<ServerProvider>().runSnippet(spi.id, snippet);
|
||||
showRoundDialog(
|
||||
context,
|
||||
_s.result,
|
||||
Text(result ?? _s.error, style: textSize13),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: Text(_s.ok))
|
||||
],
|
||||
);
|
||||
},
|
||||
child: Text(_s.run),
|
||||
)
|
||||
],
|
||||
);
|
||||
},
|
||||
child: const Icon(
|
||||
Icons.terminal,
|
||||
size: 21,
|
||||
),
|
||||
onTap: () => AppRoute(SSHPage(spi: spi), 'ssh page').go(context),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -271,14 +225,16 @@ class _ServerPageState extends State<ServerPage>
|
||||
),
|
||||
],
|
||||
onSelected: (value) {
|
||||
final item = value as DropdownBtnItem;
|
||||
switch (item) {
|
||||
switch (value as DropdownBtnItem) {
|
||||
case ServerTabMenuItems.pkg:
|
||||
AppRoute(PkgManagePage(spi), 'pkg manage').go(context);
|
||||
break;
|
||||
case ServerTabMenuItems.sftp:
|
||||
AppRoute(SFTPPage(spi), 'SFTP').go(context);
|
||||
break;
|
||||
case ServerTabMenuItems.snippet:
|
||||
_showSnippetDialog(spi.id);
|
||||
break;
|
||||
case ServerTabMenuItems.edit:
|
||||
AppRoute(ServerEditPage(spi: spi), 'Edit server info').go(context);
|
||||
break;
|
||||
@@ -393,6 +349,57 @@ class _ServerPageState extends State<ServerPage>
|
||||
);
|
||||
}
|
||||
|
||||
void _showSnippetDialog(String id) {
|
||||
final provider = locator<SnippetProvider>();
|
||||
if (provider.snippets.isEmpty) {
|
||||
showRoundDialog(
|
||||
context,
|
||||
_s.attention,
|
||||
Text(_s.noSavedSnippet),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: Text(_s.ok),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () =>
|
||||
AppRoute(const SnippetEditPage(), 'edit snippet').go(context),
|
||||
child: Text(_s.addOne),
|
||||
)
|
||||
],
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
var snippet = provider.snippets.first;
|
||||
showRoundDialog(
|
||||
context,
|
||||
_s.choose,
|
||||
buildPicker(provider.snippets.map((e) => Text(e.name)).toList(),
|
||||
(idx) => snippet = provider.snippets[idx]),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
Navigator.of(context).pop();
|
||||
final result =
|
||||
await locator<ServerProvider>().runSnippet(id, snippet);
|
||||
showRoundDialog(
|
||||
context,
|
||||
_s.result,
|
||||
Text(result ?? _s.error, style: textSize13),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: Text(_s.ok))
|
||||
],
|
||||
);
|
||||
},
|
||||
child: Text(_s.run),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user