Remove everything and add build

Signed-off-by: Nikolai Rodionov <allanger@badhouseplants.net>
This commit is contained in:
2026-05-01 22:36:52 +02:00
parent abdac78d5e
commit 7206de96db
10 changed files with 95 additions and 292 deletions

View File

@@ -1,21 +1,16 @@
---
when:
event:
- push
steps:
build:
image: git.badhouseplants.net/badhouseplants/badhouseplants-builder:ff4a98f2acb557ad443f279627036bebf06bc4f1
name: Build shoebill operator image
- name: Build and push a container image
image: gitea.badhouseplants.net/badhouseplants/container-builder:latest
environment:
REGISTRY_TOKEN:
from_secret: GITEA_REGISTRY_TOKEN
privileged: true
commands:
- |
if [[ "${CI_COMMIT_TAG}" ]]; then
export CUSTOM_TAG="${CI_COMMIT_TAG}";
fi
- build-container
secrets:
- gitea_token
backend_options:
kubernetes:
resources:
@@ -23,7 +18,6 @@ steps:
memory: 500Mi
cpu: 200m
limits:
memory: 1000Mi
cpu: 1000m
memory: 500Mi
securityContext:
privileged: true

View File

@@ -5,7 +5,7 @@ RUN apt-get install -y curl tar xz-utils git
# define variables
ARG FLUTTER_SDK=/usr/local/flutter
RUN mkdir -p ${FLUTTER_SDK}
ARG FLUTTER_VERSION=3.19.5
ARG FLUTTER_VERSION=3.41.7
ARG APP=/app/
RUN curl -l -o /tmp/flutter.tar.xz https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_${FLUTTER_VERSION}-stable.tar.xz

View File

@@ -1,42 +0,0 @@
import 'package:grpc/grpc_web.dart';
import 'package:softplayer_dart_proto/src/accounts/v1/accounts_v1.pb.dart';
import 'package:softplayer_dart_proto/src/accounts/v1/accounts_v1.pbgrpc.dart';
class AccountLocalData {
AccountLocalData({
required this.uuid,
required this.token,
});
String uuid;
String token;
}
class AccountsGrpc {
final GrpcWebClientChannel channel;
late AccountsServiceClient accountsStub;
AccountsGrpc({
required this.channel,
});
void init() {
accountsStub = AccountsServiceClient(channel);
}
Future<AccountLocalData> signUp(
String username, String email, String password) async {
final request = SignUpRequest(
data: AccountData(
name: username,
email: email,
),
password: AccountPassword(
password: password,
));
try {
final response = await accountsStub.signUp(request);
return AccountLocalData(uuid: "test", token: "test");
} catch (e) {
rethrow;
}
}
}

View File

@@ -1,21 +0,0 @@
import 'dart:html';
class SoftplayerCreds {
final String uuid;
final String token;
SoftplayerCreds({
required this.token,
required this.uuid,
});
}
class SoftplayerCredsHelpers {
String localStorageEntry(String key) => window.localStorage[key]!;
SoftplayerCreds fromLocalStorage() => SoftplayerCreds(
token: localStorageEntry("token"), uuid: localStorageEntry("uuid"));
void cleanupLocalStorate() {
window.localStorage.remove("token");
window.localStorage.remove("uuid");
}
}

View File

@@ -0,0 +1,25 @@
import 'dart:developer';
import 'package:grpc/grpc_web.dart';
import 'package:softplayer_dart_proto/src/test/v1/test_v1.pb.dart';
import 'package:softplayer_dart_proto/src/test/v1/test_v1.pbgrpc.dart';
class TestAuthGrpc {
final GrpcWebClientChannel channel;
late TestAuthServiceClient serviceStub;
TestAuthGrpc({required this.channel});
void init() {
serviceStub = TestAuthServiceClient(channel);
}
Future<void> pong() async {
final request = PongRequest();
try {
final response = await serviceStub.pong(request);
log(response.toString());
} catch (e) {
rethrow;
}
}
}

View File

@@ -0,0 +1,25 @@
import 'dart:developer';
import 'package:grpc/grpc_web.dart';
import 'package:softplayer_dart_proto/src/test/v1/test_v1.pb.dart';
import 'package:softplayer_dart_proto/src/test/v1/test_v1.pbgrpc.dart';
class TestNoAuthGrpc {
final GrpcWebClientChannel channel;
late TestNoAuthServiceClient serviceStub;
TestNoAuthGrpc({required this.channel});
void init() {
serviceStub = TestNoAuthServiceClient(channel);
}
Future<void> ping() async {
final request = PingRequest();
try {
final response = await serviceStub.ping(request);
log(response.toString());
} catch (e) {
rethrow;
}
}
}

View File

@@ -1,174 +0,0 @@
import 'package:web/web.dart' as web;
import 'package:flutter/material.dart';
import 'package:grpc/grpc_web.dart';
import 'package:softplayer_web/api/grpc/accounts.dart';
class LoginForm extends StatefulWidget {
const LoginForm({
super.key,
required this.grpcChannel,
required this.notifyParent,
});
final Function() notifyParent;
final GrpcWebClientChannel grpcChannel;
@override
State<StatefulWidget> createState() => _LoginFormState();
}
enum Action { singIn, signUp, resetPassword }
class _LoginFormState extends State<LoginForm> {
final _formKey = GlobalKey<FormState>();
final usernameCtrl = TextEditingController();
final passwordCtrl = TextEditingController();
final passwordVerifyCtrl = TextEditingController();
final emailCtrl = TextEditingController();
final codeCtrl = TextEditingController();
late AccountsGrpc accountsGrpc;
Action action = Action.singIn;
bool codeEnabled = false;
static const dialogName = "Login";
void submitSignUp() {
// Validate returns true if the form is valid, or false otherwise.
if (_formKey.currentState!.validate()) {
final username = usernameCtrl.text;
final password = passwordCtrl.text;
final email = emailCtrl.text;
accountsGrpc.signUp(username, email, password).then((rs) {
web.window.localStorage.setItem("token", rs.token);
web.window.localStorage.setItem("uuid", rs.uuid);
widget.notifyParent();
Navigator.of(context, rootNavigator: true).pop();
}).catchError((e) {
GrpcError error = e;
String msg;
if (error.message != null) {
msg = error.message!;
} else {
msg = error.toString();
}
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(msg),
backgroundColor: Colors.red,
showCloseIcon: true,
behavior: SnackBarBehavior.floating,
));
passwordCtrl.clear();
});
}
}
List<Widget> signUpActions() => [
TextButton(
onPressed: () => setState(() {
action = Action.singIn;
}),
child: const Text('Sign In'),
),
TextButton(
onPressed: submitSignUp,
child: const Text('OK'),
),
];
List<Widget> resetPasswordActions() => [
TextButton(
onPressed: () => setState(() {
action = Action.singIn;
}),
child: const Text('Sign In'),
),
TextButton(
onPressed: () => setState(() {
action = Action.signUp;
}),
child: const Text('Sing Up'),
),
];
Widget signUpForm() => SizedBox(
width: 420,
height: 280,
child: Form(
key: _formKey,
child: Center(
child: Column(children: [
TextFormField(
onFieldSubmitted: (value) => submitSignUp(),
autofocus: true,
controller: usernameCtrl,
decoration: const InputDecoration(
hintText: "Enter your username",
icon: Icon(Icons.account_circle),
label: Text("Username"),
),
cursorWidth: 1,
cursorHeight: 18,
cursorRadius: const Radius.circular(10),
),
TextFormField(
onFieldSubmitted: (value) => submitSignUp(),
controller: emailCtrl,
autofocus: true,
decoration: const InputDecoration(
hintText: "Enter your email",
icon: Icon(Icons.email),
label: Text("Email"),
),
cursorWidth: 1,
cursorHeight: 18,
cursorRadius: const Radius.circular(10),
),
TextFormField(
onFieldSubmitted: (value) => submitSignUp(),
controller: passwordCtrl,
obscureText: true,
decoration: const InputDecoration(
hintText: "Enter your password",
icon: Icon(Icons.password),
label: Text("Password")),
cursorWidth: 1,
cursorHeight: 18,
cursorRadius: const Radius.circular(10),
),
TextFormField(
onFieldSubmitted: (value) => submitSignUp(),
controller: passwordVerifyCtrl,
obscureText: true,
decoration: const InputDecoration(
hintText: "Verify your password",
icon: Icon(Icons.password),
label: Text("Confirm Password")),
cursorWidth: 1,
cursorHeight: 18,
cursorRadius: const Radius.circular(10),
),
]))));
@override
void initState() {
super.initState();
accountsGrpc = AccountsGrpc(channel: widget.grpcChannel);
accountsGrpc.init();
}
@override
Widget build(BuildContext context) => AlertDialog(
title: const Text(dialogName),
// content: action == Action.singIn ? signInForm() : signUpForm(),
content: () {
switch (action) {
default:
return signUpForm();
}
}(),
actions: () {
switch (action) {
default:
return signUpActions();
}
}());
}

View File

@@ -1,75 +1,71 @@
import 'dart:developer';
import 'package:softplayer_web/api/grpc/test_auth.dart';
import 'package:softplayer_web/api/grpc/test_no_auth.dart';
import 'package:web/web.dart' as web;
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:flutter/material.dart';
import 'package:grpc/grpc_web.dart';
import 'package:softplayer_web/api/grpc/accounts.dart';
import 'package:softplayer_web/components/login_form.dart';
void main() async {
await dotenv.load(fileName: ".env");
String backendURL = dotenv.env['SOFTPLAYER_BACKEND_URL']!;
GrpcWebClientChannel grpcChannel =
GrpcWebClientChannel.xhr(Uri.parse(backendURL));
GrpcWebClientChannel grpcChannel = GrpcWebClientChannel.xhr(
Uri.parse(backendURL),
);
runApp(MyApp(channel: grpcChannel));
}
class MyApp extends StatelessWidget {
MyApp({super.key, required this.channel});
const MyApp({super.key, required this.channel});
final GrpcWebClientChannel channel;
late final AccountsGrpc accountsGrpc = AccountsGrpc(channel: channel);
@override
Widget build(BuildContext context) {
accountsGrpc.init();
return MaterialApp(
debugShowCheckedModeBanner: false,
debugShowCheckedModeBanner: true,
title: 'Softplayer',
home: RootWidget(channel: channel),
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
);
}
}
class RootWidget extends StatefulWidget {
final GrpcWebClientChannel channel;
const RootWidget({super.key, required this.channel});
RootWidget({super.key, required this.channel});
late final AccountsGrpc accountsGrpc = AccountsGrpc(channel: channel);
@override
@override
State<StatefulWidget> createState() => _StateRootWidget();
}
class _StateRootWidget extends State<RootWidget> {
refresh() {
setState(() {});
}
bool isSignedIn() {
return web.window.localStorage.getItem("token") != null;
}
final GlobalKey<ScaffoldState> _key = GlobalKey(); // Create a key
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
width: double.infinity,
height: double.infinity,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/login_background.jpg"),
fit: BoxFit.cover,
),
body: Container(
width: double.infinity,
height: double.infinity,
child: Column(
children: [
ElevatedButton(
onPressed: () async {
TestAuthGrpc grpc = TestAuthGrpc(channel: widget.channel);
grpc.init();
await grpc.pong();
},
child: Text("pong"),
),
child: LoginForm(
grpcChannel: widget.channel,
notifyParent: refresh,
)));
ElevatedButton(
onPressed: () async {
TestNoAuthGrpc grpc = TestNoAuthGrpc(channel: widget.channel);
grpc.init();
await grpc.ping();
},
child: Text("ping"),
),
],
),
),
);
}
}

View File

@@ -276,8 +276,8 @@ packages:
dependency: "direct main"
description:
path: "."
ref: "3e742ade989e461c42ea20fb757eb2b90577c65e"
resolved-ref: "3e742ade989e461c42ea20fb757eb2b90577c65e"
ref: "743c0a79dd75562ddf6a0e9b68d0acfbc275dea3"
resolved-ref: "743c0a79dd75562ddf6a0e9b68d0acfbc275dea3"
url: "https://gitea.badhouseplants.net/softplayer/softplayer-dart-proto.git"
source: git
version: "1.0.0"

View File

@@ -5,7 +5,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1
environment:
sdk: ">=3.3.0 <4.0.0"
sdk: ^3.11.5
dependencies:
flutter:
@@ -13,7 +13,7 @@ dependencies:
softplayer_dart_proto:
git:
url: https://gitea.badhouseplants.net/softplayer/softplayer-dart-proto.git
ref: 3e742ade989e461c42ea20fb757eb2b90577c65e
ref: 743c0a79dd75562ddf6a0e9b68d0acfbc275dea3
cupertino_icons: ^1.0.9
grpc: 5.1.0
http: ^1.6.0