diff --git a/NOTICE.md b/NOTICE.md
new file mode 100644
index 0000000..3b7d25c
--- /dev/null
+++ b/NOTICE.md
@@ -0,0 +1,2 @@
+## 图标来自
+[品牌图标](https://brands.iconhelper.cn/)
\ No newline at end of file
diff --git a/README.md b/README.md
index 7a322d1..24c897a 100644
--- a/README.md
+++ b/README.md
@@ -5,6 +5,9 @@ Flutter Paas Dashboard
## 其他语言文档
- [English Doc](README_en.md)
+# 安装
+- [Install Doc](install.md)
+
# 开发环境准备
```bash
flutter config --enable-macos-desktop
diff --git a/install.md b/install.md
new file mode 100644
index 0000000..382900f
--- /dev/null
+++ b/install.md
@@ -0,0 +1,5 @@
+## 安装步骤
+### windows
+下载最新的release压缩包,[下载地址](https://github.com/paashzj/paas_dashboard_flutter/releases)
+解压压缩文件
+运行**pass_dashboard_flutter.exe** 即可
diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb
index 2a9d90c..40a21d4 100644
--- a/lib/l10n/intl_en.arb
+++ b/lib/l10n/intl_en.arb
@@ -1,4 +1,5 @@
{
+ "@@locale": "en",
"aboutAuthor": "About author",
"appName": "Paas Dashboard",
"basic": "Basic",
diff --git a/lib/l10n/intl_zh.arb b/lib/l10n/intl_zh.arb
index e89ddcf..e22a2d9 100644
--- a/lib/l10n/intl_zh.arb
+++ b/lib/l10n/intl_zh.arb
@@ -1,4 +1,5 @@
{
+ "@@locale": "zh",
"aboutAuthor": "关于作者",
"appName": "Paas 仪表盘",
"basic": "基础信息",
diff --git a/lib/main.dart b/lib/main.dart
index 8ad1a04..ba9363d 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -7,9 +7,11 @@ import 'package:paas_dashboard_flutter/ui/bk/bk_page.dart';
import 'package:paas_dashboard_flutter/ui/general/author_screen.dart';
import 'package:paas_dashboard_flutter/ui/general/settings_screen.dart';
import 'package:paas_dashboard_flutter/ui/home/home_page.dart';
+import 'package:paas_dashboard_flutter/ui/kubernetes/k8s_page.dart';
import 'package:paas_dashboard_flutter/ui/pulsar/pulsar_page.dart';
import 'package:paas_dashboard_flutter/vm/bk/bk_instance_list_view_model.dart';
import 'package:paas_dashboard_flutter/vm/general/settings_view_model.dart';
+import 'package:paas_dashboard_flutter/vm/kubernetes/k8s_instance_list_view_model.dart';
import 'package:paas_dashboard_flutter/vm/pulsar/pulsar_instance_list_view_model.dart';
import 'package:paas_dashboard_flutter/vm/pulsar/pulsar_instance_view_model.dart';
import 'package:paas_dashboard_flutter/vm/pulsar/pulsar_namespace_view_model.dart';
@@ -61,6 +63,10 @@ class MyApp extends StatelessWidget {
create: (context) => BkInstanceListViewModel(),
child: BkPage(),
),
+ PageRouteConst.Kubernetes: (context) => ChangeNotifierProvider(
+ create: (context) => K8sInstanceListViewModel(),
+ child: K8sPage(),
+ ),
PageRouteConst.Pulsar: (context) => ChangeNotifierProvider(
create: (context) => PulsarInstanceListViewModel(),
child: PulsarPage(),
diff --git a/lib/module/ssh/ssh_step.dart b/lib/module/ssh/ssh_step.dart
new file mode 100644
index 0000000..1830638
--- /dev/null
+++ b/lib/module/ssh/ssh_step.dart
@@ -0,0 +1,8 @@
+class SshStep {
+ final String username;
+ final String password;
+ String? suUser;
+ String? suPassword;
+
+ SshStep(this.username, this.password);
+}
diff --git a/lib/persistent/persistent.dart b/lib/persistent/persistent.dart
index e9dd812..0abc82c 100644
--- a/lib/persistent/persistent.dart
+++ b/lib/persistent/persistent.dart
@@ -1,8 +1,10 @@
import 'package:flutter/foundation.dart' show kIsWeb;
+import 'package:paas_dashboard_flutter/module/ssh/ssh_step.dart';
import 'package:paas_dashboard_flutter/persistent/persistent_api.dart';
import 'package:paas_dashboard_flutter/persistent/persistent_db.dart';
import 'package:paas_dashboard_flutter/persistent/persistent_memory.dart';
import 'package:paas_dashboard_flutter/persistent/po/bk_instance_po.dart';
+import 'package:paas_dashboard_flutter/persistent/po/k8s_instance_po.dart';
import 'package:paas_dashboard_flutter/persistent/po/pulsar_instance_po.dart';
class Persistent {
@@ -44,6 +46,18 @@ class Persistent {
return (await getApi()).bookkeeperInstances();
}
+ static Future saveKubernetesSsh(String name, List sshSteps) async {
+ return (await getApi()).saveKubernetesSsh(name, sshSteps);
+ }
+
+ static Future deleteKubernetes(int id) async {
+ return (await getApi()).deleteKubernetes(id);
+ }
+
+ static Future> kubernetesInstances() async {
+ return (await getApi()).kubernetesInstances();
+ }
+
static bool supportDb() {
return !kIsWeb;
}
diff --git a/lib/persistent/persistent_api.dart b/lib/persistent/persistent_api.dart
index 4b59028..3d39bb8 100644
--- a/lib/persistent/persistent_api.dart
+++ b/lib/persistent/persistent_api.dart
@@ -1,4 +1,6 @@
+import 'package:paas_dashboard_flutter/module/ssh/ssh_step.dart';
import 'package:paas_dashboard_flutter/persistent/po/bk_instance_po.dart';
+import 'package:paas_dashboard_flutter/persistent/po/k8s_instance_po.dart';
import 'package:paas_dashboard_flutter/persistent/po/pulsar_instance_po.dart';
abstract class PersistentApi {
@@ -13,4 +15,10 @@ abstract class PersistentApi {
Future deleteBookkeeper(int id);
Future> bookkeeperInstances();
+
+ Future saveKubernetesSsh(String name, List sshSteps);
+
+ Future deleteKubernetes(int id);
+
+ Future> kubernetesInstances();
}
diff --git a/lib/persistent/persistent_db.dart b/lib/persistent/persistent_db.dart
index 7ecb01a..7c89603 100644
--- a/lib/persistent/persistent_db.dart
+++ b/lib/persistent/persistent_db.dart
@@ -1,8 +1,10 @@
import 'dart:developer';
import 'dart:io';
+import 'package:paas_dashboard_flutter/module/ssh/ssh_step.dart';
import 'package:paas_dashboard_flutter/persistent/persistent_api.dart';
import 'package:paas_dashboard_flutter/persistent/po/bk_instance_po.dart';
+import 'package:paas_dashboard_flutter/persistent/po/k8s_instance_po.dart';
import 'package:paas_dashboard_flutter/persistent/po/pulsar_instance_po.dart';
import 'package:path/path.dart';
import 'package:sqflite/sqflite.dart';
@@ -59,6 +61,19 @@ class PersistentDb implements PersistentApi {
await db.execute(
'INSERT INTO bookkeeper_instances(name, host, port) VALUES ("example", "localhost", 8080)',
);
+ await db.execute(
+ 'CREATE TABLE zookeeper_instances(id INTEGER PRIMARY KEY, name TEXT, host TEXT, port INTEGER)',
+ );
+ await db.execute(
+ 'INSERT INTO zookeeper_instances(name, host, port) VALUES ("example", "localhost", 8080)',
+ );
+ // type: api、host
+ await db.execute(
+ 'CREATE TABLE kubernetes_instances(id INTEGER PRIMARY KEY, name TEXT, type TEXT, content TEXT)',
+ );
+ await db.execute(
+ 'INSERT INTO kubernetes_instances(name, type, content) VALUES ("example", "host", "{}")',
+ );
}
@override
@@ -113,4 +128,22 @@ class PersistentDb implements PersistentApi {
});
}
+ @override
+ Future saveKubernetesSsh(String name, List sshSteps) {
+ // TODO: implement saveKubernetesSsh
+ throw UnimplementedError();
+ }
+
+ @override
+ Future deleteKubernetes(int id) {
+ // TODO: implement deleteKubernetes
+ throw UnimplementedError();
+ }
+
+ @override
+ Future> kubernetesInstances() {
+ // TODO: implement k8sInstances
+ throw UnimplementedError();
+ }
+
}
diff --git a/lib/persistent/persistent_memory.dart b/lib/persistent/persistent_memory.dart
index 8fa5486..128b15d 100644
--- a/lib/persistent/persistent_memory.dart
+++ b/lib/persistent/persistent_memory.dart
@@ -1,5 +1,7 @@
+import 'package:paas_dashboard_flutter/module/ssh/ssh_step.dart';
import 'package:paas_dashboard_flutter/persistent/persistent_api.dart';
import 'package:paas_dashboard_flutter/persistent/po/bk_instance_po.dart';
+import 'package:paas_dashboard_flutter/persistent/po/k8s_instance_po.dart';
import 'package:paas_dashboard_flutter/persistent/po/pulsar_instance_po.dart';
class PersistentMemory implements PersistentApi {
@@ -36,4 +38,21 @@ class PersistentMemory implements PersistentApi {
Future> bookkeeperInstances() async {
return [new BkInstancePo(0, "example", "localhost", 8080)];
}
+
+ @override
+ Future saveKubernetesSsh(String name, List sshSteps) {
+ // TODO: implement saveKubernetesSsh
+ throw UnimplementedError();
+ }
+
+ @override
+ Future deleteKubernetes(int id) {
+ // TODO: implement deleteKubernetes
+ throw UnimplementedError();
+ }
+
+ @override
+ Future> kubernetesInstances() async{
+ return [new K8sInstancePo(0, "example")];
+ }
}
diff --git a/lib/persistent/po/bk_instance_po.dart b/lib/persistent/po/bk_instance_po.dart
index 51d475c..10d059d 100644
--- a/lib/persistent/po/bk_instance_po.dart
+++ b/lib/persistent/po/bk_instance_po.dart
@@ -17,7 +17,7 @@ class BkInstancePo extends HttpEndpoint {
@override
String toString() {
- return 'BookKeeperInstance{id: $id, name: $name, host: $host, port: port}';
+ return 'BookKeeperInstance{id: $id, name: $name, host: $host, port: $port}';
}
}
diff --git a/lib/persistent/po/http_endpoint.dart b/lib/persistent/po/http_endpoint.dart
index 5cfe64d..8115a7e 100644
--- a/lib/persistent/po/http_endpoint.dart
+++ b/lib/persistent/po/http_endpoint.dart
@@ -7,6 +7,6 @@ class HttpEndpoint {
@override
String toString() {
- return 'HttpEndpoint{name: $name, host: $host, port: port}';
+ return 'HttpEndpoint{name: $name, host: $host, port: $port}';
}
}
\ No newline at end of file
diff --git a/lib/persistent/po/k8s_instance_po.dart b/lib/persistent/po/k8s_instance_po.dart
new file mode 100644
index 0000000..bb72d00
--- /dev/null
+++ b/lib/persistent/po/k8s_instance_po.dart
@@ -0,0 +1,19 @@
+
+class K8sInstancePo {
+ final int id;
+ final String name;
+
+ K8sInstancePo(this.id, this.name);
+
+ Map toMap() {
+ return {
+ 'id': id,
+ 'name': name,
+ };
+ }
+
+ @override
+ String toString() {
+ return 'BookKeeperInstance{id: $id, name: $name}';
+ }
+}
diff --git a/lib/route/page_route_const.dart b/lib/route/page_route_const.dart
index c62d466..cb982cc 100644
--- a/lib/route/page_route_const.dart
+++ b/lib/route/page_route_const.dart
@@ -3,6 +3,7 @@ class PageRouteConst {
static const String Author = '/author';
static const String Settings = '/settings';
static const String Bookkeeper = '/bookkeeper';
+ static const String Kubernetes = '/kubernetes';
static const String Pulsar = '/pulsar';
static const String PulsarInstance = '/pulsar/instance';
static const String PulsarTenant = '/pulsar/instance/tenant';
diff --git a/lib/ui/kubernetes/k8s_page.dart b/lib/ui/kubernetes/k8s_page.dart
new file mode 100644
index 0000000..f8cd377
--- /dev/null
+++ b/lib/ui/kubernetes/k8s_page.dart
@@ -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 createState() {
+ return new _K8sPageState();
+ }
+}
+
+class _K8sPageState extends State {
+ @override
+ void initState() {
+ super.initState();
+ Provider.of(context, listen: false)
+ .fetchBkInstances();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final vm = Provider.of(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);
+ }
+}
diff --git a/lib/vm/kubernetes/k8s_instance_list_view_model.dart b/lib/vm/kubernetes/k8s_instance_list_view_model.dart
new file mode 100644
index 0000000..c9415f2
--- /dev/null
+++ b/lib/vm/kubernetes/k8s_instance_list_view_model.dart
@@ -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 instances = [];
+
+ Future fetchBkInstances() async {
+ final results = await Persistent.kubernetesInstances();
+ this.instances = results.map((e) => K8sInstanceViewModel(e)).toList();
+ notifyListeners();
+ }
+
+ Future createBk(String name, String host, int port) async {
+ Persistent.saveBookkeeper(name, host, port);
+ fetchBkInstances();
+ }
+
+ Future deleteBk(int id) async {
+ Persistent.deleteBookkeeper(id);
+ fetchBkInstances();
+ }
+
+}
diff --git a/lib/vm/kubernetes/k8s_instance_view_model.dart b/lib/vm/kubernetes/k8s_instance_view_model.dart
new file mode 100644
index 0000000..c6b00a0
--- /dev/null
+++ b/lib/vm/kubernetes/k8s_instance_view_model.dart
@@ -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;
+ }
+}