master
Kherel 2021-08-29 11:50:24 +02:00
parent 1a8a4e7270
commit 94a0e22b15
26 changed files with 116 additions and 303 deletions

View File

@ -215,7 +215,9 @@
"empty": "No jobs",
"createUser": "Create",
"serviceTurnOff": "Turn off",
"serviceTurnOn": "Turn on"
"serviceTurnOn": "Turn on",
"jobAdded": "Job added"
},
"validations": {
"required": "Required",

View File

@ -215,7 +215,8 @@
"empty": "Пусто",
"createUser": "Создать запись",
"serviceTurnOff": "Остановить",
"serviceTurnOn": "Запустить"
"serviceTurnOn": "Запустить",
"jobAdded": "Задача добавленна"
},
"validations": {
"required": "обязательное поле",

View File

@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>8.0</string>
<string>9.0</string>
</dict>
</plist>

View File

@ -22,15 +22,13 @@ class HiveConfig {
await Hive.openBox<User>(BNames.users);
var cipher = HiveAesCipher(await getEncriptedKey());
await Hive.openBox(BNames.appConfig, encryptionCipher: cipher);
}
static Future<Uint8List> getEncriptedKey() async {
final FlutterSecureStorage secureStorage = FlutterSecureStorage();
var containsEncryptionKey =
await secureStorage.containsKey(key: BNames.key);
if (!containsEncryptionKey) {
final secureStorage = FlutterSecureStorage();
var hasEncryptionKey = await secureStorage.containsKey(key: BNames.key);
if (!hasEncryptionKey) {
var key = Hive.generateSecureKey();
await secureStorage.write(key: BNames.key, value: base64UrlEncode(key));
}

View File

@ -73,7 +73,6 @@ class HetznerApi extends ApiMap {
required User rootUser,
required String domainName,
}) async {
var client = await getClient();
Response dbCreateResponse = await client.post(
@ -87,12 +86,12 @@ class HetznerApi extends ApiMap {
"format": "ext4"
},
);
var dbPassword = StringGenerators.dbPassword();
var dbId = dbCreateResponse.data['volume']['id'];
var data = jsonDecode(
'''{"name":"$domainName","server_type":"cx11","start_after_create":false,"image":"ubuntu-20.04", "volumes":[$dbId], "networks":[], "user_data":"#cloud-config\\nruncmd:\\n- curl https://git.selfprivacy.org/ilchub/selfprivacy-nixos-infect/raw/branch/master/nixos-infect | PROVIDER=hetzner NIX_CHANNEL=nixos-21.05 DOMAIN=$domainName LUSER=${rootUser.login} PASSWORD=${rootUser.password} HASHED_PASSWORD=${rootUser.hashPassword.hash} SALT=${rootUser.hashPassword.salt} CF_TOKEN=$cloudFlareKey DB_PASSWORD=$dbPassword bash 2>&1 | tee /tmp/infect.log","labels":{},"automount":true, "location": "fsn1"}''');
'''{"name":"$domainName","server_type":"cx11","start_after_create":false,"image":"ubuntu-20.04", "volumes":[$dbId], "networks":[], ssh_keys:[kherel], "user_data":"#cloud-config\\nruncmd:\\n- curl https://git.selfprivacy.org/ilchub/selfprivacy-nixos-infect/raw/branch/development/nixos-infect | PROVIDER=hetzner NIX_CHANNEL=nixos-21.05 DOMAIN=$domainName LUSER=${rootUser.login} PASSWORD=${rootUser.password} CF_TOKEN=$cloudFlareKey DB_PASSWORD=$dbPassword bash 2>&1 | tee /tmp/infect.log","labels":{},"automount":true, "location": "fsn1"}''');
Response serverCreateResponse = await client.post(
'/servers',

View File

@ -1,3 +1,4 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:selfprivacy/config/get_it_config.dart';
import 'package:selfprivacy/logic/api_maps/server.dart';
@ -6,6 +7,7 @@ import 'package:selfprivacy/logic/models/jobs/job.dart';
import 'package:equatable/equatable.dart';
import 'package:selfprivacy/logic/models/user.dart';
export 'package:provider/provider.dart';
import 'package:easy_localization/easy_localization.dart';
part 'jobs_state.dart';
@ -21,6 +23,10 @@ class JobsCubit extends Cubit<JobsState> {
newJobsList.addAll((state as JobsStateWithJobs).jobList);
}
newJobsList.add(job);
getIt<NavigationService>().showSnackBar(SnackBar(
content: Text('jobs.jobAdded'.tr()),
duration: const Duration(seconds: 2),
));
emit(JobsStateWithJobs(newJobsList));
}

View File

@ -0,0 +1,10 @@
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
part 'services_state.dart';
class ServicesCubit extends Cubit<ServicesState> {
ServicesCubit() : super(ServicesInitial());
}

View File

@ -0,0 +1,10 @@
part of 'services_cubit.dart';
abstract class ServicesState extends Equatable {
const ServicesState();
@override
List<Object> get props => [];
}
class ServicesInitial extends ServicesState {}

View File

@ -2,7 +2,10 @@ import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
class NavigationService {
final GlobalKey<ScaffoldMessengerState> scaffoldMessengerKey =
GlobalKey<ScaffoldMessengerState>();
final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
NavigatorState? get navigator => navigatorKey.currentState;
void showPopUpDialog(AlertDialog dialog) {
@ -13,4 +16,10 @@ class NavigationService {
builder: (_) => dialog,
);
}
void showSnackBar(SnackBar snackBar) {
final state = scaffoldMessengerKey.currentState!;
state.showSnackBar(snackBar);
}
}

View File

@ -16,11 +16,11 @@ import 'config/localization.dart';
import 'logic/cubit/app_settings/app_settings_cubit.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await HiveConfig.init();
Bloc.observer = SimpleBlocObserver();
Wakelock.enable();
await getItSetup();
WidgetsFlutterBinding.ensureInitialized();
await EasyLocalization.ensureInitialized();
runApp(MyApp());
@ -37,6 +37,8 @@ class MyApp extends StatelessWidget {
return AnnotatedRegion<SystemUiOverlayStyle>(
value: SystemUiOverlayStyle.light, // Manually changnig appbar color
child: MaterialApp(
scaffoldMessengerKey:
getIt.get<NavigationService>().scaffoldMessengerKey,
navigatorKey: getIt.get<NavigationService>().navigatorKey,
localizationsDelegates: context.localizationDelegates,
supportedLocales: context.supportedLocales,

View File

@ -0,0 +1,24 @@
import 'package:flutter/material.dart';
import 'package:selfprivacy/config/brand_colors.dart';
class BrandSwitch extends StatelessWidget {
const BrandSwitch({
Key? key,
required this.onChanged,
required this.value,
}) : super(key: key);
final ValueChanged<bool> onChanged;
final bool value;
@override
Widget build(BuildContext context) {
return Switch(
activeColor: BrandColors.green1,
activeTrackColor: BrandColors.green2,
value: value,
onChanged: onChanged,
);
}
}

View File

@ -7,6 +7,7 @@ import 'package:selfprivacy/ui/components/action_button/action_button.dart';
import 'package:selfprivacy/ui/components/brand_alert/brand_alert.dart';
import 'package:selfprivacy/ui/components/brand_divider/brand_divider.dart';
import 'package:selfprivacy/ui/components/brand_header/brand_header.dart';
import 'package:selfprivacy/ui/components/brand_switch/brand_switch.dart';
import 'package:selfprivacy/ui/components/brand_text/brand_text.dart';
import 'package:selfprivacy/utils/named_font_weight.dart';
import 'package:easy_localization/easy_localization.dart';
@ -52,9 +53,7 @@ class _AppSettingsPageState extends State<AppSettingsPage> {
),
),
SizedBox(width: 5),
Switch(
activeColor: BrandColors.green1,
activeTrackColor: BrandColors.green2,
BrandSwitch(
value: Theme.of(context).brightness == Brightness.dark,
onChanged: (value) => context
.read<AppSettingsCubit>()

View File

@ -51,7 +51,7 @@ class CpuChart extends StatelessWidget {
interval: 20,
rotateAngle: 90.0,
showTitles: true,
getTextStyles: (value) => const TextStyle(
getTextStyles: (_, __) => const TextStyle(
fontSize: 10,
color: Colors.purple,
fontWeight: FontWeight.bold,
@ -60,7 +60,7 @@ class CpuChart extends StatelessWidget {
return bottomTitle(value.toInt());
}),
leftTitles: SideTitles(
getTextStyles: (value) => progressTextStyleLight.copyWith(
getTextStyles: (_, __) => progressTextStyleLight.copyWith(
color: Theme.of(context).brightness == Brightness.dark
? BrandColors.gray4
: null,

View File

@ -71,7 +71,7 @@ class NetworkChart extends StatelessWidget {
interval: 20,
rotateAngle: 90.0,
showTitles: true,
getTextStyles: (value) => const TextStyle(
getTextStyles: (_, __) => const TextStyle(
fontSize: 10,
color: Colors.purple,
fontWeight: FontWeight.bold,
@ -87,7 +87,7 @@ class NetworkChart extends StatelessWidget {
].reduce(max) *
1.2 /
10,
getTextStyles: (value) => progressTextStyleLight.copyWith(
getTextStyles: (_, __) => progressTextStyleLight.copyWith(
color: Theme.of(context).brightness == Brightness.dark
? BrandColors.gray4
: null,

View File

@ -8,7 +8,6 @@ import 'package:selfprivacy/logic/models/state_types.dart';
import 'package:selfprivacy/ui/components/brand_button/brand_button.dart';
import 'package:selfprivacy/ui/components/brand_cards/brand_cards.dart';
import 'package:selfprivacy/ui/components/brand_header/brand_header.dart';
import 'package:selfprivacy/ui/components/brand_icons/brand_icons.dart';
import 'package:selfprivacy/ui/components/brand_text/brand_text.dart';
import 'package:selfprivacy/ui/components/icon_status_mask/icon_status_mask.dart';
import 'package:selfprivacy/ui/components/not_ready_card/not_ready_card.dart';
@ -64,10 +63,6 @@ class _Card extends StatelessWidget {
final ServiceTypes serviceType;
@override
Widget build(BuildContext context) {
String title;
IconData iconData;
String subtitle;
var isReady = context.watch<AppConfigCubit>().state.isFullyInitilized;
var changeTab = context.read<ChangeTab>().onPress;
return GestureDetector(
@ -366,252 +361,3 @@ class _ServiceDetails extends StatelessWidget {
}
}
}
// class _ServiceDetails extends StatelessWidget {
// const _ServiceDetails({
// Key? key,
// required this.serviceType,
// required this.icon,
// required this.status,
// required this.title,
// required this.changeTab,
// }) : super(key: key);
// final ServiceTypes serviceType;
// final IconData icon;
// final StateType status;
// final String title;
// final ValueChanged<int> changeTab;
// @override
// Widget build(BuildContext context) {
// late Widget child;
// var config = context.watch<AppConfigCubit>().state;
// var domainName = UiHelpers.getDomainName(config);
// var linksStyle = body1Style.copyWith(
// fontSize: 15,
// color: Theme.of(context).brightness == Brightness.dark
// ? Colors.white
// : BrandColors.black,
// fontWeight: FontWeight.bold,
// decoration: TextDecoration.underline,
// // height: 1.1,
// );
// var textStyle = body1Style.copyWith(
// color: Theme.of(context).brightness == Brightness.dark
// ? Colors.white
// : BrandColors.black,
// );
// switch (serviceType) {
// case ServiceTypes.mail:
// child = RichText(
// text: TextSpan(
// children: [
// TextSpan(
// text: 'services.mail.bottom_sheet.1'.tr(args: [domainName]),
// style: textStyle,
// ),
// WidgetSpan(
// child: Padding(
// padding: EdgeInsets.only(bottom: 0.8, left: 5),
// child: GestureDetector(
// child: Text(
// 'services.mail.bottom_sheet.2'.tr(),
// style: linksStyle,
// ),
// onTap: () {
// Navigator.of(context).pop();
// changeTab(2);
// },
// ),
// ),
// ),
// ],
// ));
// break;
// case ServiceTypes.messenger:
// child = RichText(
// text: TextSpan(
// children: [
// TextSpan(
// text: 'services.messenger.bottom_sheet.1'.tr(args: [domainName]),
// style: textStyle,
// )
// ],
// ));
// break;
// case ServiceTypes.passwordManager:
// child = RichText(
// text: TextSpan(
// children: [
// TextSpan(
// text: 'services.password_manager.bottom_sheet.1'
// .tr(args: [domainName]),
// style: textStyle,
// ),
// WidgetSpan(
// child: Padding(
// padding: EdgeInsets.only(bottom: 0.8, left: 5),
// child: GestureDetector(
// onTap: () => _launchURL('https://password.$domainName'),
// child: Text(
// 'password.$domainName',
// style: linksStyle,
// ),
// ),
// ),
// ),
// ],
// ));
// break;
// case ServiceTypes.video:
// child = RichText(
// text: TextSpan(
// children: [
// TextSpan(
// text: 'services.video.bottom_sheet.1'.tr(args: [domainName]),
// style: textStyle,
// ),
// WidgetSpan(
// child: Padding(
// padding: EdgeInsets.only(bottom: 0.8, left: 5),
// child: GestureDetector(
// onTap: () => _launchURL('https://meet.$domainName'),
// child: Text(
// 'meet.$domainName',
// style: linksStyle,
// ),
// ),
// ),
// ),
// ],
// ));
// break;
// case ServiceTypes.cloud:
// child = RichText(
// text: TextSpan(
// children: [
// TextSpan(
// text: 'services.cloud.bottom_sheet.1'.tr(args: [domainName]),
// style: textStyle,
// ),
// WidgetSpan(
// child: Padding(
// padding: EdgeInsets.only(bottom: 0.8, left: 5),
// child: GestureDetector(
// onTap: () => _launchURL('https://cloud.$domainName'),
// child: Text(
// 'cloud.$domainName',
// style: linksStyle,
// ),
// ),
// ),
// ),
// ],
// ));
// break;
// case ServiceTypes.socialNetwork:
// child = RichText(
// text: TextSpan(
// children: [
// TextSpan(
// text: 'services.social_network.bottom_sheet.1'
// .tr(args: [domainName]),
// style: textStyle,
// ),
// WidgetSpan(
// child: Padding(
// padding: EdgeInsets.only(bottom: 0.8, left: 5),
// child: GestureDetector(
// onTap: () => _launchURL('https://social.$domainName'),
// child: Text(
// 'social.$domainName',
// style: linksStyle,
// ),
// ),
// ),
// ),
// ],
// ));
// break;
// case ServiceTypes.git:
// child = RichText(
// text: TextSpan(
// children: [
// TextSpan(
// text: 'services.git.bottom_sheet.1'.tr(args: [domainName]),
// style: textStyle,
// ),
// WidgetSpan(
// child: Padding(
// padding: EdgeInsets.only(bottom: 0.8, left: 5),
// child: GestureDetector(
// onTap: () => _launchURL('https://git.$domainName'),
// child: Text(
// 'git.$domainName',
// style: linksStyle,
// ),
// ),
// ),
// ),
// ],
// ));
// break;
// }
// return BrandModalSheet(
// child: Navigator(
// key: navigatorKey,
// initialRoute: '/',
// onGenerateRoute: (_) {
// return materialRoute(
// Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Padding(
// padding: brandPagePadding1,
// child: Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// SizedBox(height: 13),
// IconStatusMask(
// status: status,
// child: Icon(icon, size: 40, color: Colors.white),
// ),
// SizedBox(height: 10),
// BrandText.h1(title),
// SizedBox(height: 10),
// child,
// ],
// ),
// )
// ],
// ),
// );
// },
// ),
// );
// }
// void _launchURL(url) async {
// var _possible = await canLaunch(url);
// if (_possible) {
// try {
// await launch(
// url,
// forceSafariVC: true,
// enableJavaScript: true,
// );
// } catch (e) {
// print(e);
// }
// } else {
// throw 'Could not launch $url';
// }
// }
// }

View File

@ -42,14 +42,14 @@ packages:
name: basic_utils
url: "https://pub.dartlang.org"
source: hosted
version: "3.4.0"
version: "3.5.0"
bloc:
dependency: transitive
description:
name: bloc
url: "https://pub.dartlang.org"
source: hosted
version: "7.0.0"
version: "7.1.0"
boolean_selector:
dependency: transitive
description:
@ -63,21 +63,21 @@ packages:
name: build
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.3"
version: "2.1.0"
build_config:
dependency: transitive
description:
name: build_config
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.7"
version: "1.0.0"
build_daemon:
dependency: transitive
description:
name: build_daemon
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.10"
version: "3.0.0"
build_resolvers:
dependency: transitive
description:
@ -91,14 +91,14 @@ packages:
name: build_runner
url: "https://pub.dartlang.org"
source: hosted
version: "1.12.2"
version: "2.1.1"
build_runner_core:
dependency: transitive
description:
name: build_runner_core
url: "https://pub.dartlang.org"
source: hosted
version: "6.1.12"
version: "7.1.0"
built_collection:
dependency: transitive
description:
@ -154,7 +154,7 @@ packages:
name: code_builder
url: "https://pub.dartlang.org"
source: hosted
version: "3.7.0"
version: "4.1.0"
collection:
dependency: transitive
description:
@ -259,7 +259,7 @@ packages:
name: extended_masked_text
url: "https://pub.dartlang.org"
source: hosted
version: "2.3.0"
version: "2.3.1"
fake_async:
dependency: transitive
description:
@ -294,7 +294,7 @@ packages:
name: fl_chart
url: "https://pub.dartlang.org"
source: hosted
version: "0.35.0"
version: "0.40.0"
flutter:
dependency: "direct main"
description: flutter
@ -306,14 +306,14 @@ packages:
name: flutter_bloc
url: "https://pub.dartlang.org"
source: hosted
version: "7.1.0"
version: "7.2.0"
flutter_launcher_icons:
dependency: "direct dev"
description:
name: flutter_launcher_icons
url: "https://pub.dartlang.org"
source: hosted
version: "0.9.1"
version: "0.9.2"
flutter_localizations:
dependency: transitive
description: flutter
@ -325,7 +325,7 @@ packages:
name: flutter_markdown
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.4"
version: "0.6.5"
flutter_secure_storage:
dependency: "direct main"
description:
@ -343,13 +343,20 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
frontend_server_client:
dependency: transitive
description:
name: frontend_server_client
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.2"
get_it:
dependency: "direct main"
description:
name: get_it
url: "https://pub.dartlang.org"
source: hosted
version: "6.1.1"
version: "7.2.0"
glob:
dependency: transitive
description:
@ -363,7 +370,7 @@ packages:
name: graphs
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
version: "2.0.0"
hive:
dependency: "direct main"
description:
@ -594,7 +601,7 @@ packages:
name: platform
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.0"
version: "3.0.2"
plugin_platform_interface:
dependency: transitive
description:
@ -608,7 +615,7 @@ packages:
name: pointycastle
url: "https://pub.dartlang.org"
source: hosted
version: "3.3.0"
version: "3.3.2"
pool:
dependency: transitive
description:
@ -636,7 +643,7 @@ packages:
name: provider
url: "https://pub.dartlang.org"
source: hosted
version: "5.0.0"
version: "6.0.0"
pub_semver:
dependency: transitive
description:
@ -664,7 +671,7 @@ packages:
name: share_plus_linux
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.3"
version: "2.0.4"
share_plus_macos:
dependency: transitive
description:
@ -699,7 +706,7 @@ packages:
name: shared_preferences
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.6"
version: "2.0.7"
shared_preferences_linux:
dependency: transitive
description:
@ -727,7 +734,7 @@ packages:
name: shared_preferences_web
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
version: "2.0.2"
shared_preferences_windows:
dependency: transitive
description:
@ -879,7 +886,7 @@ packages:
name: unicons
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.2"
version: "2.0.1"
url_launcher:
dependency: "direct main"
description:
@ -914,14 +921,14 @@ packages:
name: url_launcher_web
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.2"
version: "2.0.4"
url_launcher_windows:
dependency: transitive
description:
name: url_launcher_windows
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
version: "2.0.2"
vector_math:
dependency: transitive
description:
@ -998,7 +1005,7 @@ packages:
name: win32
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.5"
version: "2.2.7"
xdg_directories:
dependency: transitive
description:

View File

@ -17,11 +17,11 @@ dependencies:
easy_localization: ^3.0.0
either_option: ^2.0.1-dev.1
equatable: ^2.0.3
fl_chart: ^0.35.0
fl_chart: ^0.40.0
flutter_bloc: ^7.1.0
flutter_markdown: ^0.6.0
flutter_secure_storage: ^4.1.0
get_it: ^6.0.0
get_it: ^7.2.0
hive: ^2.0.0
hive_flutter: ^1.0.0
ionicons: ^0.1.2
@ -30,9 +30,9 @@ dependencies:
nanoid: ^1.0.0
package_info: ^2.0.0
pretty_dio_logger: ^1.1.1
provider: ^5.0.0
provider: ^6.0.0
share_plus: ^2.1.4
unicons: ^1.0.2
unicons: ^2.0.1
url_launcher: ^6.0.2
wakelock: ^0.5.0+2
basic_utils: ^3.4.0
@ -40,7 +40,7 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
build_runner: ^1.11.5
build_runner: ^2.1.1
flutter_launcher_icons: ^0.9.0
hive_generator: ^1.0.0
json_serializable: ^4.0.2