-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support Kubernetes instance list (#20)
- Loading branch information
Showing
18 changed files
with
230 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
## 图标来自 | ||
[品牌图标](https://brands.iconhelper.cn/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
## 安装步骤 | ||
### windows | ||
下载最新的release压缩包,[下载地址](https://github.com/paashzj/paas_dashboard_flutter/releases) <br/> | ||
解压压缩文件 <br/> | ||
运行**pass_dashboard_flutter.exe** 即可 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{ | ||
"@@locale": "en", | ||
"aboutAuthor": "About author", | ||
"appName": "Paas Dashboard", | ||
"basic": "Basic", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{ | ||
"@@locale": "zh", | ||
"aboutAuthor": "关于作者", | ||
"appName": "Paas 仪表盘", | ||
"basic": "基础信息", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class SshStep { | ||
final String username; | ||
final String password; | ||
String? suUser; | ||
String? suPassword; | ||
|
||
SshStep(this.username, this.password); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
class K8sInstancePo { | ||
final int id; | ||
final String name; | ||
|
||
K8sInstancePo(this.id, this.name); | ||
|
||
Map<String, dynamic> toMap() { | ||
return { | ||
'id': id, | ||
'name': name, | ||
}; | ||
} | ||
|
||
@override | ||
String toString() { | ||
return 'BookKeeperInstance{id: $id, name: $name}'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:paas_dashboard_flutter/generated/l10n.dart'; | ||
import 'package:paas_dashboard_flutter/vm/kubernetes/k8s_instance_list_view_model.dart'; | ||
import 'package:provider/provider.dart'; | ||
|
||
class K8sPage extends StatefulWidget { | ||
@override | ||
State<StatefulWidget> createState() { | ||
return new _K8sPageState(); | ||
} | ||
} | ||
|
||
class _K8sPageState extends State<K8sPage> { | ||
@override | ||
void initState() { | ||
super.initState(); | ||
Provider.of<K8sInstanceListViewModel>(context, listen: false) | ||
.fetchBkInstances(); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final vm = Provider.of<K8sInstanceListViewModel>(context); | ||
var refreshButton = TextButton( | ||
onPressed: () { | ||
setState(() { | ||
vm.fetchBkInstances(); | ||
}); | ||
}, | ||
child: Text(S.of(context).refresh)); | ||
var body = ListView( | ||
children: [ | ||
Container( | ||
height: 50, | ||
child: ListView( | ||
scrollDirection: Axis.horizontal, | ||
shrinkWrap: true, | ||
children: [refreshButton], | ||
), | ||
), | ||
Center( | ||
child: Text('Kubernetes Instance List'), | ||
), | ||
SingleChildScrollView( | ||
child: DataTable( | ||
showCheckboxColumn: false, | ||
columns: [ | ||
DataColumn(label: Text('Id')), | ||
DataColumn(label: Text('Name')), | ||
], | ||
rows: vm.instances | ||
.map((itemRow) => | ||
DataRow(onSelectChanged: (bool? selected) {}, cells: [ | ||
DataCell(Text(itemRow.id.toString())), | ||
DataCell(Text(itemRow.name)), | ||
])) | ||
.toList(), | ||
), | ||
), | ||
], | ||
); | ||
return Scaffold( | ||
appBar: AppBar( | ||
title: Text('Kubernetes Dashboard'), | ||
), | ||
body: body); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:paas_dashboard_flutter/persistent/persistent.dart'; | ||
|
||
import 'k8s_instance_view_model.dart'; | ||
|
||
class K8sInstanceListViewModel extends ChangeNotifier { | ||
List<K8sInstanceViewModel> instances = <K8sInstanceViewModel>[]; | ||
|
||
Future<void> fetchBkInstances() async { | ||
final results = await Persistent.kubernetesInstances(); | ||
this.instances = results.map((e) => K8sInstanceViewModel(e)).toList(); | ||
notifyListeners(); | ||
} | ||
|
||
Future<void> createBk(String name, String host, int port) async { | ||
Persistent.saveBookkeeper(name, host, port); | ||
fetchBkInstances(); | ||
} | ||
|
||
Future<void> deleteBk(int id) async { | ||
Persistent.deleteBookkeeper(id); | ||
fetchBkInstances(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import 'package:paas_dashboard_flutter/persistent/po/k8s_instance_po.dart'; | ||
|
||
class K8sInstanceViewModel { | ||
final K8sInstancePo k8sInstancePo; | ||
|
||
K8sInstanceViewModel(this.k8sInstancePo); | ||
|
||
int get id { | ||
return this.k8sInstancePo.id; | ||
} | ||
|
||
String get name { | ||
return this.k8sInstancePo.name; | ||
} | ||
} |