From a63f6b02a6cdc357125e03f4ee3edcc8d9435859 Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Sun, 23 Apr 2023 21:30:56 +0700 Subject: [PATCH 01/28] Switching to autogenerated client for TuuliAPI --- lib/api/api_client.dart | 395 ----- lib/api/model/access_token_model.dart | 7 - lib/api/model/table_field_model.dart | 127 -- lib/api/model/tables_list_model.dart | 42 - lib/api/model/user_model.dart | 27 - lib/api_sub_project/src/api.dart | 84 + lib/api_sub_project/src/api/default_api.dart | 1404 +++++++++++++++++ lib/api_sub_project/src/api_util.dart | 77 + .../src/auth/api_key_auth.dart | 30 + lib/api_sub_project/src/auth/auth.dart | 18 + lib/api_sub_project/src/auth/basic_auth.dart | 42 + lib/api_sub_project/src/auth/bearer_auth.dart | 27 + lib/api_sub_project/src/auth/oauth.dart | 27 + lib/api_sub_project/src/date_serializer.dart | 30 + .../src/model/access_token_response.dart | 106 ++ .../src/model/access_token_response.g.dart | 98 ++ lib/api_sub_project/src/model/auth_model.dart | 122 ++ .../src/model/auth_model.g.dart | 107 ++ ...e_item_in_table_items_table_name_post.dart | 123 ++ ...item_in_table_items_table_name_post.g.dart | 139 ++ .../src/model/column_condition_compat.dart | 179 +++ .../src/model/column_condition_compat.g.dart | 267 ++++ .../src/model/create_asset_response.dart | 125 ++ .../src/model/create_asset_response.g.dart | 107 ++ .../src/model/create_user_definition.dart | 122 ++ .../src/model/create_user_definition.g.dart | 114 ++ lib/api_sub_project/src/model/date.dart | 70 + .../src/model/error_response.dart | 106 ++ .../src/model/error_response.g.dart | 93 ++ .../src/model/http_validation_error.dart | 119 ++ .../src/model/http_validation_error.g.dart | 106 ++ .../src/model/items_field_selector_list.dart | 110 ++ .../model/items_field_selector_list.g.dart | 107 ++ .../src/model/location_inner.dart | 68 + .../src/model/location_inner.g.dart | 93 ++ .../src/model/ok_response.dart | 109 ++ .../src/model/ok_response.g.dart | 87 + .../src/model/table_definition.dart | 170 ++ .../src/model/table_definition.g.dart | 157 ++ .../src/model/table_items_response.dart | 108 ++ .../src/model/table_items_response.g.dart | 109 ++ .../src/model/user_update_definition.dart | 138 ++ .../src/model/user_update_definition.g.dart | 129 ++ .../src/model/validation_error.dart | 145 ++ .../src/model/validation_error.g.dart | 137 ++ lib/api_sub_project/src/serializers.dart | 72 + lib/api_sub_project/src/serializers.g.dart | 48 + lib/api_sub_project/tuuli_api.dart | 28 + pubspec.lock | 328 ++++ pubspec.yaml | 7 + 50 files changed, 5992 insertions(+), 598 deletions(-) delete mode 100644 lib/api/api_client.dart delete mode 100644 lib/api/model/access_token_model.dart delete mode 100644 lib/api/model/table_field_model.dart delete mode 100644 lib/api/model/tables_list_model.dart delete mode 100644 lib/api/model/user_model.dart create mode 100644 lib/api_sub_project/src/api.dart create mode 100644 lib/api_sub_project/src/api/default_api.dart create mode 100644 lib/api_sub_project/src/api_util.dart create mode 100644 lib/api_sub_project/src/auth/api_key_auth.dart create mode 100644 lib/api_sub_project/src/auth/auth.dart create mode 100644 lib/api_sub_project/src/auth/basic_auth.dart create mode 100644 lib/api_sub_project/src/auth/bearer_auth.dart create mode 100644 lib/api_sub_project/src/auth/oauth.dart create mode 100644 lib/api_sub_project/src/date_serializer.dart create mode 100644 lib/api_sub_project/src/model/access_token_response.dart create mode 100644 lib/api_sub_project/src/model/access_token_response.g.dart create mode 100644 lib/api_sub_project/src/model/auth_model.dart create mode 100644 lib/api_sub_project/src/model/auth_model.g.dart create mode 100644 lib/api_sub_project/src/model/body_update_item_in_table_items_table_name_post.dart create mode 100644 lib/api_sub_project/src/model/body_update_item_in_table_items_table_name_post.g.dart create mode 100644 lib/api_sub_project/src/model/column_condition_compat.dart create mode 100644 lib/api_sub_project/src/model/column_condition_compat.g.dart create mode 100644 lib/api_sub_project/src/model/create_asset_response.dart create mode 100644 lib/api_sub_project/src/model/create_asset_response.g.dart create mode 100644 lib/api_sub_project/src/model/create_user_definition.dart create mode 100644 lib/api_sub_project/src/model/create_user_definition.g.dart create mode 100644 lib/api_sub_project/src/model/date.dart create mode 100644 lib/api_sub_project/src/model/error_response.dart create mode 100644 lib/api_sub_project/src/model/error_response.g.dart create mode 100644 lib/api_sub_project/src/model/http_validation_error.dart create mode 100644 lib/api_sub_project/src/model/http_validation_error.g.dart create mode 100644 lib/api_sub_project/src/model/items_field_selector_list.dart create mode 100644 lib/api_sub_project/src/model/items_field_selector_list.g.dart create mode 100644 lib/api_sub_project/src/model/location_inner.dart create mode 100644 lib/api_sub_project/src/model/location_inner.g.dart create mode 100644 lib/api_sub_project/src/model/ok_response.dart create mode 100644 lib/api_sub_project/src/model/ok_response.g.dart create mode 100644 lib/api_sub_project/src/model/table_definition.dart create mode 100644 lib/api_sub_project/src/model/table_definition.g.dart create mode 100644 lib/api_sub_project/src/model/table_items_response.dart create mode 100644 lib/api_sub_project/src/model/table_items_response.g.dart create mode 100644 lib/api_sub_project/src/model/user_update_definition.dart create mode 100644 lib/api_sub_project/src/model/user_update_definition.g.dart create mode 100644 lib/api_sub_project/src/model/validation_error.dart create mode 100644 lib/api_sub_project/src/model/validation_error.g.dart create mode 100644 lib/api_sub_project/src/serializers.dart create mode 100644 lib/api_sub_project/src/serializers.g.dart create mode 100644 lib/api_sub_project/tuuli_api.dart diff --git a/lib/api/api_client.dart b/lib/api/api_client.dart deleted file mode 100644 index 33eaf80..0000000 --- a/lib/api/api_client.dart +++ /dev/null @@ -1,395 +0,0 @@ -import 'dart:async'; -import 'dart:convert'; -import 'package:get/get.dart'; -import 'package:tuuli_app/api/model/access_token_model.dart'; -import 'package:http/browser_client.dart'; -import 'package:http/http.dart'; -import 'package:tuuli_app/api/model/table_field_model.dart'; -import 'package:tuuli_app/api/model/tables_list_model.dart'; -import 'package:tuuli_app/api/model/user_model.dart'; - -class ErrorOrData { - final T? data; - final Exception? error; - - ErrorOrData(this.data, this.error); - - void unfold( - void Function(T data) onData, void Function(Exception error) onError) { - if (data != null) { - onData(data as T); - } else { - onError(error!); - } - } -} - -typedef FutureErrorOrData = Future>; -typedef TableItemsData = Map; -typedef TableItemsDataList = List; - -class ApiClient { - final BrowserClient _client = BrowserClient(); - var _accessToken = ''; - - final Uri baseUrl; - - ApiClient(this.baseUrl); - - ApiClient.fromString(String baseUrl) : this(Uri.parse(baseUrl)); - - void setAccessToken(String accessToken) { - _accessToken = accessToken; - } - - FutureErrorOrData login( - String username, - String password, - ) async { - AccessTokenModel? data; - Exception? error; - - final response = await post('/api/getAccessToken', body: { - 'username': username, - 'password': password, - }, headers: { - 'Content-Type': 'application/json', - }); - if (response.statusCode == 200) { - final body = json.decode(await response.stream.bytesToString()); - if (body['error'] != null) { - error = Exception(body['error']); - } else if (body['access_token'] == null) { - error = Exception('No access token'); - } else { - data = AccessTokenModel(accessToken: body['access_token']); - } - } else if (response.statusCode == 422) { - error = Exception('Invalid request parameters'); - } else { - error = Exception('HTTP ${response.statusCode}'); - } - - return ErrorOrData(data, error); - } - - FutureErrorOrData tablesList() async { - TablesListModel? data; - Exception? error; - - final response = await get('/api/listTables'); - if (response.statusCode == 200) { - final body = json.decode(await response.stream.bytesToString()); - if (body['error'] != null) { - error = Exception(body['error']); - } else if (body['tables'] == null) { - error = Exception('Server error'); - } else { - data = TablesListModel.fromJson(body); - } - } else if (response.statusCode == 422) { - error = Exception('Invalid request parameters'); - } else { - error = Exception('HTTP ${response.statusCode}'); - } - - return ErrorOrData(data, error); - } - - FutureErrorOrData createTable( - String tableName, List columns) async { - bool? ignored; - Exception? error; - - final response = - await post('/api/createTable/${Uri.encodeComponent(tableName)}', body: { - 'columns': - columns.map((e) => e.toColumnDefinition()).toList(growable: false), - }, headers: { - 'Content-Type': 'application/json', - }); - if (response.statusCode == 200) { - final body = json.decode(await response.stream.bytesToString()); - if (body['error'] != null) { - error = Exception(body['error']); - } else { - ignored = true; - } - } else if (response.statusCode == 422) { - error = Exception('Invalid request parameters'); - } else { - error = Exception('HTTP ${response.statusCode}'); - } - - return ErrorOrData(ignored, error); - } - - FutureErrorOrData dropTable(String tableName) async { - bool? ignored; - Exception? error; - - final response = - await post('/api/dropTable/${Uri.encodeComponent(tableName)}'); - if (response.statusCode == 200) { - final body = json.decode(await response.stream.bytesToString()); - if (body['error'] != null) { - error = Exception(body['error']); - } else { - ignored = true; - } - } else if (response.statusCode == 422) { - error = Exception('Invalid request parameters'); - } else { - error = Exception('HTTP ${response.statusCode}'); - } - - return ErrorOrData(ignored, error); - } - - FutureErrorOrData getTableItems(TableModel table) async { - TableItemsDataList? data; - Exception? error; - - final response = await post( - '/items/${Uri.encodeComponent(table.tableName)}', - body: { - "fields": ["*"] - }, - headers: { - 'Content-Type': 'application/json', - }, - ); - if (response.statusCode == 200) { - final body = json.decode(await response.stream.bytesToString()) - as Map; - if (body['error'] != null) { - error = Exception(body['error']); - } else if (body['items'] == null) { - error = Exception('Server error'); - } else { - data = (body['items'] as List) - .map((e) => e as TableItemsData) - .toList(growable: false); - } - } else if (response.statusCode == 422) { - error = Exception('Invalid request parameters'); - } else { - error = Exception('HTTP ${response.statusCode}'); - } - - return ErrorOrData(data, error); - } - - FutureErrorOrData insertItem( - TableModel table, TableItemsData newItem) async { - bool? ignored; - Exception? error; - - final response = await post( - '/items/${Uri.encodeComponent(table.tableName)}/+', - body: newItem.map((key, value) => - MapEntry(key, value is DateTime ? value.toIso8601String() : value)), - headers: { - 'Content-Type': 'application/json', - }, - ); - if (response.statusCode == 200) { - final body = json.decode(await response.stream.bytesToString()); - if (body['error'] != null) { - error = Exception(body['error']); - } else { - ignored = true; - } - } else if (response.statusCode == 422) { - error = Exception('Invalid request parameters'); - } else { - error = Exception('HTTP ${response.statusCode}'); - } - - return ErrorOrData(ignored, error); - } - - FutureErrorOrData updateItem( - TableModel table, TableItemsData newItem, TableItemsData oldItem) async { - bool? ignored; - Exception? error; - - final response = await post( - '/items/${Uri.encodeComponent(table.tableName)}/*', - body: { - "item": newItem.map((key, value) => - MapEntry(key, value is DateTime ? value.toIso8601String() : value)), - "oldItem": oldItem.map((key, value) => - MapEntry(key, value is DateTime ? value.toIso8601String() : value)), - }, - headers: { - 'Content-Type': 'application/json', - }, - ); - if (response.statusCode == 200) { - final body = json.decode(await response.stream.bytesToString()); - if (body['error'] != null) { - error = Exception(body['error']); - } else { - ignored = true; - } - } else if (response.statusCode == 422) { - error = Exception('Invalid request parameters'); - } else { - error = Exception('HTTP ${response.statusCode}'); - } - - return ErrorOrData(ignored, error); - } - - FutureErrorOrData deleteItem(TableModel table, TableItemsData e) async { - bool? ignored; - Exception? error; - - TableField? primaryField = - table.columns.firstWhereOrNull((el) => el.isPrimary); - TableField? uniqueField = - table.columns.firstWhereOrNull((el) => el.isUnique); - - final response = await post( - '/items/${Uri.encodeComponent(table.tableName)}/-', - body: { - "defs": [ - if (primaryField != null) - { - "name": primaryField.fieldName, - "value": e[primaryField.fieldName], - } - else if (uniqueField != null) - { - "name": uniqueField.fieldName, - "value": e[uniqueField.fieldName], - } - else - for (final field in table.columns) - { - "name": field.fieldName, - "value": e[field.fieldName], - } - ], - }, - headers: { - 'Content-Type': 'application/json', - }, - ); - if (response.statusCode == 200) { - final body = json.decode(await response.stream.bytesToString()); - if (body['error'] != null) { - error = Exception(body['error']); - } else { - ignored = true; - } - } else if (response.statusCode == 422) { - error = Exception('Invalid request parameters'); - } else { - error = Exception('HTTP ${response.statusCode}'); - } - - return ErrorOrData(ignored, error); - } - - FutureErrorOrData createUser( - TableModel table, String username, String password) async { - bool? ignored; - Exception? error; - - final response = await post( - '/api/createUser', - body: { - "username": username, - "password": password, - }, - headers: { - 'Content-Type': 'application/json', - }, - ); - if (response.statusCode == 200) { - final body = json.decode(await response.stream.bytesToString()); - if (body['error'] != null) { - error = Exception(body['error']); - } else { - ignored = true; - } - } else if (response.statusCode == 422) { - error = Exception('Invalid request parameters'); - } else { - error = Exception('HTTP ${response.statusCode}'); - } - - return ErrorOrData(ignored, error); - } - - FutureErrorOrData updateUser( - TableModel table, int userId, String password, String accessToken) async { - bool? ignored; - Exception? error; - - final response = await post( - '/api/updateUser', - body: { - "user_id": userId, - "password": password, - "access_token": accessToken, - }, - headers: { - 'Content-Type': 'application/json', - }, - ); - if (response.statusCode == 200) { - final body = json.decode(await response.stream.bytesToString()); - if (body['error'] != null) { - error = Exception(body['error']); - } else { - ignored = true; - } - } else if (response.statusCode == 422) { - error = Exception('Invalid request parameters'); - } else { - error = Exception('HTTP ${response.statusCode}'); - } - - return ErrorOrData(ignored, error); - } - - // REGION: HTTP Methods implementation - - Future get( - String path, { - Map? headers, - }) { - return _request(path, 'GET', headers: headers); - } - - Future post( - String path, { - Map? headers, - dynamic body, - }) { - return _request(path, 'POST', headers: headers, body: body); - } - - Future _request( - String path, - String method, { - Map? headers, - dynamic body, - }) async { - final uri = baseUrl.resolve(path); - final request = Request(method, uri); - if (headers != null) { - request.headers.addAll(headers); - } - if (_accessToken.isNotEmpty) { - request.headers["Access-Token"] = _accessToken; - } - if (body != null) { - request.body = json.encode(body); - } - return _client.send(request); - } -} diff --git a/lib/api/model/access_token_model.dart b/lib/api/model/access_token_model.dart deleted file mode 100644 index 9c9c140..0000000 --- a/lib/api/model/access_token_model.dart +++ /dev/null @@ -1,7 +0,0 @@ -class AccessTokenModel { - final String accessToken; - - const AccessTokenModel({ - required this.accessToken, - }); -} diff --git a/lib/api/model/table_field_model.dart b/lib/api/model/table_field_model.dart deleted file mode 100644 index 03b51bf..0000000 --- a/lib/api/model/table_field_model.dart +++ /dev/null @@ -1,127 +0,0 @@ -import 'package:uuid/uuid.dart'; - -typedef SerialTableField = TableField; -typedef UUIDTableField = TableField; -typedef StringTableField = TableField; -typedef BigIntTableField = TableField; -typedef BoolTableField = TableField; -typedef DateTableField = TableField; -typedef DateTimeTableField = TableField; -typedef FloatTableField = TableField; -typedef IntTableField = TableField; - -final possibleFieldTypes = { - "serial": SerialTableField, - "uuid": UUIDTableField, - "str": StringTableField, - "bigint": BigIntTableField, - "bool": BoolTableField, - "date": DateTableField, - "datetime": DateTimeTableField, - "float": FloatTableField, - "int": IntTableField, -}; - -class TableField { - final String fieldName; - final String fieldType; - final bool isUnique; - final bool isPrimary; - final Type type = T; - - TableField({ - required this.fieldName, - required this.fieldType, - required this.isUnique, - required this.isPrimary, - }); - - bool canBePrimary() { - return fieldType == "serial" || fieldType == "uuid"; - } - - @override - String toString() { - return "TableField<$T>(fieldName: $fieldName, fieldType: $fieldType, isUnique: $isUnique, isPrimary: $isPrimary)"; - } - - String toColumnDefinition() { - return "$fieldName:$fieldType${isPrimary ? ":primary" : ""}${isUnique ? ":unique" : ""}"; - } - - static TableField parseTableField(String definition) { - final parts = definition.split(":"); - final fieldName = parts[0]; - final fieldType = parts[1]; - final isUnique = parts.contains("unique"); - final isPrimary = parts.contains("primary"); - - switch (fieldType) { - case "serial": - return SerialTableField( - fieldName: fieldName, - fieldType: fieldType, - isUnique: isUnique, - isPrimary: isPrimary, - ); - case "uuid": - return UUIDTableField( - fieldName: fieldName, - fieldType: fieldType, - isUnique: isUnique, - isPrimary: isPrimary, - ); - case "str": - return StringTableField( - fieldName: fieldName, - fieldType: fieldType, - isUnique: isUnique, - isPrimary: isPrimary, - ); - case "bigint": - return BigIntTableField( - fieldName: fieldName, - fieldType: fieldType, - isUnique: isUnique, - isPrimary: isPrimary, - ); - case "bool": - return BoolTableField( - fieldName: fieldName, - fieldType: fieldType, - isUnique: isUnique, - isPrimary: isPrimary, - ); - case "date": - return DateTableField( - fieldName: fieldName, - fieldType: fieldType, - isUnique: isUnique, - isPrimary: isPrimary, - ); - case "datetime": - return DateTimeTableField( - fieldName: fieldName, - fieldType: fieldType, - isUnique: isUnique, - isPrimary: isPrimary, - ); - case "float": - return FloatTableField( - fieldName: fieldName, - fieldType: fieldType, - isUnique: isUnique, - isPrimary: isPrimary, - ); - case "int": - return IntTableField( - fieldName: fieldName, - fieldType: fieldType, - isUnique: isUnique, - isPrimary: isPrimary, - ); - default: - throw Exception("Unknown field type: $fieldType"); - } - } -} diff --git a/lib/api/model/tables_list_model.dart b/lib/api/model/tables_list_model.dart deleted file mode 100644 index a9dc1bf..0000000 --- a/lib/api/model/tables_list_model.dart +++ /dev/null @@ -1,42 +0,0 @@ -import 'package:tuuli_app/api/model/table_field_model.dart'; - -class TablesListModel { - final List tables; - - TablesListModel(this.tables); - - factory TablesListModel.fromJson(Map json) => - TablesListModel( - List.from( - json["tables"].map((x) => TableModel.fromJson(x)), - ), - ); -} - -class TableModel { - final String tableId; - final String tableName; - final String columnsDefinition; - final List columns; - final bool system; - final bool hidden; - - TableModel({ - required this.tableId, - required this.tableName, - required this.columnsDefinition, - required this.system, - required this.hidden, - }) : columns = columnsDefinition - .split(",") - .map(TableField.parseTableField) - .toList(growable: false); - - factory TableModel.fromJson(Map json) => TableModel( - tableId: json["table_id"], - tableName: json["table_name"], - columnsDefinition: json["columns"], - system: json["system"], - hidden: json["hidden"], - ); -} diff --git a/lib/api/model/user_model.dart b/lib/api/model/user_model.dart deleted file mode 100644 index 35b88a9..0000000 --- a/lib/api/model/user_model.dart +++ /dev/null @@ -1,27 +0,0 @@ -class UserModel { - final int id; - final String username; - final String? password; - final String? accessToken; - - UserModel({ - required this.id, - required this.username, - this.password, - this.accessToken, - }); - - factory UserModel.fromJson(Map json) => UserModel( - id: json["id"], - username: json["username"], - password: json["password"], - accessToken: json["access_token"], - ); - - Map toJson() => { - "id": id, - "username": username, - "password": password, - "access_token": accessToken, - }; -} diff --git a/lib/api_sub_project/src/api.dart b/lib/api_sub_project/src/api.dart new file mode 100644 index 0000000..791949e --- /dev/null +++ b/lib/api_sub_project/src/api.dart @@ -0,0 +1,84 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// + +import 'package:dio/dio.dart'; +import 'package:built_value/serializer.dart'; +import 'package:tuuli_app/api_sub_project/src/serializers.dart'; +import 'package:tuuli_app/api_sub_project/src/auth/api_key_auth.dart'; +import 'package:tuuli_app/api_sub_project/src/auth/basic_auth.dart'; +import 'package:tuuli_app/api_sub_project/src/auth/bearer_auth.dart'; +import 'package:tuuli_app/api_sub_project/src/auth/oauth.dart'; +import 'package:tuuli_app/api_sub_project/src/api/default_api.dart'; + +class TuuliApi { + static const String basePath = r'http://localhost'; + + final Dio dio; + final Serializers serializers; + + TuuliApi({ + Dio? dio, + Serializers? serializers, + String? basePathOverride, + List? interceptors, + }) : this.serializers = serializers ?? standardSerializers, + this.dio = dio ?? + Dio(BaseOptions( + baseUrl: basePathOverride ?? basePath, + connectTimeout: const Duration(milliseconds: 5000), + receiveTimeout: const Duration(milliseconds: 3000), + )) { + if (interceptors == null) { + this.dio.interceptors.addAll([ + OAuthInterceptor(), + BasicAuthInterceptor(), + BearerAuthInterceptor(), + ApiKeyAuthInterceptor(), + ]); + } else { + this.dio.interceptors.addAll(interceptors); + } + } + + void setOAuthToken(String name, String token) { + if (this.dio.interceptors.any((i) => i is OAuthInterceptor)) { + (this.dio.interceptors.firstWhere((i) => i is OAuthInterceptor) + as OAuthInterceptor) + .tokens[name] = token; + } + } + + void setBearerAuth(String name, String token) { + if (this.dio.interceptors.any((i) => i is BearerAuthInterceptor)) { + (this.dio.interceptors.firstWhere((i) => i is BearerAuthInterceptor) + as BearerAuthInterceptor) + .tokens[name] = token; + } + } + + void setBasicAuth(String name, String username, String password) { + if (this.dio.interceptors.any((i) => i is BasicAuthInterceptor)) { + (this.dio.interceptors.firstWhere((i) => i is BasicAuthInterceptor) + as BasicAuthInterceptor) + .authInfo[name] = BasicAuthInfo(username, password); + } + } + + void setApiKey(String name, String apiKey) { + if (this.dio.interceptors.any((i) => i is ApiKeyAuthInterceptor)) { + (this + .dio + .interceptors + .firstWhere((element) => element is ApiKeyAuthInterceptor) + as ApiKeyAuthInterceptor) + .apiKeys[name] = apiKey; + } + } + + /// Get DefaultApi instance, base route and serializer can be overridden by a given but be careful, + /// by doing that all interceptors will not be executed + DefaultApi getDefaultApi() { + return DefaultApi(dio, serializers); + } +} diff --git a/lib/api_sub_project/src/api/default_api.dart b/lib/api_sub_project/src/api/default_api.dart new file mode 100644 index 0000000..fa09278 --- /dev/null +++ b/lib/api_sub_project/src/api/default_api.dart @@ -0,0 +1,1404 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// + +import 'dart:async'; + +import 'package:built_value/serializer.dart'; +import 'package:dio/dio.dart'; + +import 'package:built_collection/built_collection.dart'; +import 'package:built_value/json_object.dart'; +import 'package:tuuli_app/api_sub_project/src/api_util.dart'; +import 'package:tuuli_app/api_sub_project/src/model/access_token_response.dart'; +import 'package:tuuli_app/api_sub_project/src/model/auth_model.dart'; +import 'package:tuuli_app/api_sub_project/src/model/body_update_item_in_table_items_table_name_post.dart'; +import 'package:tuuli_app/api_sub_project/src/model/column_condition_compat.dart'; +import 'package:tuuli_app/api_sub_project/src/model/create_asset_response.dart'; +import 'package:tuuli_app/api_sub_project/src/model/create_user_definition.dart'; +import 'package:tuuli_app/api_sub_project/src/model/error_response.dart'; +import 'package:tuuli_app/api_sub_project/src/model/http_validation_error.dart'; +import 'package:tuuli_app/api_sub_project/src/model/items_field_selector_list.dart'; +import 'package:tuuli_app/api_sub_project/src/model/ok_response.dart'; +import 'package:tuuli_app/api_sub_project/src/model/table_definition.dart'; +import 'package:tuuli_app/api_sub_project/src/model/table_items_response.dart'; +import 'package:tuuli_app/api_sub_project/src/model/user_update_definition.dart'; + +class DefaultApi { + final Dio _dio; + + final Serializers _serializers; + + const DefaultApi(this._dio, this._serializers); + + /// Create Item + /// + /// + /// Parameters: + /// * [tableName] + /// * [body] + /// * [accessToken] + /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation + /// * [headers] - Can be used to add additional headers to the request + /// * [extras] - Can be used to add flags to the request + /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response + /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress + /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress + /// + /// Returns a [Future] containing a [Response] with a [OkResponse] as data + /// Throws [DioError] if API call or serialization fails + Future> createItemItemsTableNamePost({ + required String tableName, + required JsonObject body, + String? accessToken, + CancelToken? cancelToken, + Map? headers, + Map? extra, + ValidateStatus? validateStatus, + ProgressCallback? onSendProgress, + ProgressCallback? onReceiveProgress, + }) async { + final _path = r'/items/{tableName}/+' + .replaceAll('{' r'tableName' '}', tableName.toString()); + final _options = Options( + method: r'POST', + headers: { + if (accessToken != null) r'access-token': accessToken, + ...?headers, + }, + extra: { + 'secure': >[], + ...?extra, + }, + contentType: 'application/json', + validateStatus: validateStatus, + ); + + dynamic _bodyData; + + try { + _bodyData = body; + } catch (error, stackTrace) { + throw DioError( + requestOptions: _options.compose( + _dio.options, + _path, + ), + type: DioErrorType.unknown, + error: error, + stackTrace: stackTrace, + ); + } + + final _response = await _dio.request( + _path, + data: _bodyData, + options: _options, + cancelToken: cancelToken, + onSendProgress: onSendProgress, + onReceiveProgress: onReceiveProgress, + ); + + OkResponse _responseData; + + try { + const _responseType = FullType(OkResponse); + _responseData = _serializers.deserialize( + _response.data!, + specifiedType: _responseType, + ) as OkResponse; + } catch (error, stackTrace) { + throw DioError( + requestOptions: _response.requestOptions, + response: _response, + type: DioErrorType.unknown, + error: error, + stackTrace: stackTrace, + ); + } + + return Response( + data: _responseData, + headers: _response.headers, + isRedirect: _response.isRedirect, + requestOptions: _response.requestOptions, + redirects: _response.redirects, + statusCode: _response.statusCode, + statusMessage: _response.statusMessage, + extra: _response.extra, + ); + } + + /// Create Table + /// Parameter `columns` should be a list of strings Each string should be in a following format: `column_name:column_type[:column_options]` Where *column_type* should be one of the following: - serial - str - bool - datetime - float - int - int:asset - int:user Also *column_options* can be one of the following: - unique - default Example: ```json [ \"id:serial:primary\", \"name:str:unique\", \"description:str\", \"is_active:bool\", \"price:float\", \"quantity:int\", \"creator_id:int:user\", \"asset_id:int:asset\" ] ``` Notes: 1. you cannot use *unique* and *default* at the same time 2. in current implementation you cannot use *default*, because there is no way to specify default value + /// + /// Parameters: + /// * [tableName] + /// * [requestBody] + /// * [accessToken] + /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation + /// * [headers] - Can be used to add additional headers to the request + /// * [extras] - Can be used to add flags to the request + /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response + /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress + /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress + /// + /// Returns a [Future] containing a [Response] with a [OkResponse] as data + /// Throws [DioError] if API call or serialization fails + Future> createTableApiCreateTableTableNamePost({ + required String tableName, + required BuiltList requestBody, + String? accessToken, + CancelToken? cancelToken, + Map? headers, + Map? extra, + ValidateStatus? validateStatus, + ProgressCallback? onSendProgress, + ProgressCallback? onReceiveProgress, + }) async { + final _path = r'/api/createTable/{tableName}' + .replaceAll('{' r'tableName' '}', tableName.toString()); + final _options = Options( + method: r'POST', + headers: { + if (accessToken != null) r'access-token': accessToken, + ...?headers, + }, + extra: { + 'secure': >[], + ...?extra, + }, + contentType: 'application/json', + validateStatus: validateStatus, + ); + + dynamic _bodyData; + + try { + const _type = FullType(BuiltList, [FullType(String)]); + _bodyData = _serializers.serialize(requestBody, specifiedType: _type); + } catch (error, stackTrace) { + throw DioError( + requestOptions: _options.compose( + _dio.options, + _path, + ), + type: DioErrorType.unknown, + error: error, + stackTrace: stackTrace, + ); + } + + final _response = await _dio.request( + _path, + data: _bodyData, + options: _options, + cancelToken: cancelToken, + onSendProgress: onSendProgress, + onReceiveProgress: onReceiveProgress, + ); + + OkResponse _responseData; + + try { + const _responseType = FullType(OkResponse); + _responseData = _serializers.deserialize( + _response.data!, + specifiedType: _responseType, + ) as OkResponse; + } catch (error, stackTrace) { + throw DioError( + requestOptions: _response.requestOptions, + response: _response, + type: DioErrorType.unknown, + error: error, + stackTrace: stackTrace, + ); + } + + return Response( + data: _responseData, + headers: _response.headers, + isRedirect: _response.isRedirect, + requestOptions: _response.requestOptions, + redirects: _response.redirects, + statusCode: _response.statusCode, + statusMessage: _response.statusMessage, + extra: _response.extra, + ); + } + + /// Create User + /// + /// + /// Parameters: + /// * [createUserDefinition] + /// * [accessToken] + /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation + /// * [headers] - Can be used to add additional headers to the request + /// * [extras] - Can be used to add flags to the request + /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response + /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress + /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress + /// + /// Returns a [Future] containing a [Response] with a [OkResponse] as data + /// Throws [DioError] if API call or serialization fails + Future> createUserApiUsersPost({ + required CreateUserDefinition createUserDefinition, + String? accessToken, + CancelToken? cancelToken, + Map? headers, + Map? extra, + ValidateStatus? validateStatus, + ProgressCallback? onSendProgress, + ProgressCallback? onReceiveProgress, + }) async { + final _path = r'/api/users/+'; + final _options = Options( + method: r'POST', + headers: { + if (accessToken != null) r'access-token': accessToken, + ...?headers, + }, + extra: { + 'secure': >[], + ...?extra, + }, + contentType: 'application/json', + validateStatus: validateStatus, + ); + + dynamic _bodyData; + + try { + const _type = FullType(CreateUserDefinition); + _bodyData = + _serializers.serialize(createUserDefinition, specifiedType: _type); + } catch (error, stackTrace) { + throw DioError( + requestOptions: _options.compose( + _dio.options, + _path, + ), + type: DioErrorType.unknown, + error: error, + stackTrace: stackTrace, + ); + } + + final _response = await _dio.request( + _path, + data: _bodyData, + options: _options, + cancelToken: cancelToken, + onSendProgress: onSendProgress, + onReceiveProgress: onReceiveProgress, + ); + + OkResponse _responseData; + + try { + const _responseType = FullType(OkResponse); + _responseData = _serializers.deserialize( + _response.data!, + specifiedType: _responseType, + ) as OkResponse; + } catch (error, stackTrace) { + throw DioError( + requestOptions: _response.requestOptions, + response: _response, + type: DioErrorType.unknown, + error: error, + stackTrace: stackTrace, + ); + } + + return Response( + data: _responseData, + headers: _response.headers, + isRedirect: _response.isRedirect, + requestOptions: _response.requestOptions, + redirects: _response.redirects, + statusCode: _response.statusCode, + statusMessage: _response.statusMessage, + extra: _response.extra, + ); + } + + /// Delete Item From Table + /// + /// + /// Parameters: + /// * [tableName] + /// * [columnConditionCompat] + /// * [accessToken] + /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation + /// * [headers] - Can be used to add additional headers to the request + /// * [extras] - Can be used to add flags to the request + /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response + /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress + /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress + /// + /// Returns a [Future] containing a [Response] with a [OkResponse] as data + /// Throws [DioError] if API call or serialization fails + Future> deleteItemFromTableItemsTableNamePost({ + required String tableName, + required BuiltList columnConditionCompat, + String? accessToken, + CancelToken? cancelToken, + Map? headers, + Map? extra, + ValidateStatus? validateStatus, + ProgressCallback? onSendProgress, + ProgressCallback? onReceiveProgress, + }) async { + final _path = r'/items/{tableName}/-' + .replaceAll('{' r'tableName' '}', tableName.toString()); + final _options = Options( + method: r'POST', + headers: { + if (accessToken != null) r'access-token': accessToken, + ...?headers, + }, + extra: { + 'secure': >[], + ...?extra, + }, + contentType: 'application/json', + validateStatus: validateStatus, + ); + + dynamic _bodyData; + + try { + const _type = FullType(BuiltList, [FullType(ColumnConditionCompat)]); + _bodyData = + _serializers.serialize(columnConditionCompat, specifiedType: _type); + } catch (error, stackTrace) { + throw DioError( + requestOptions: _options.compose( + _dio.options, + _path, + ), + type: DioErrorType.unknown, + error: error, + stackTrace: stackTrace, + ); + } + + final _response = await _dio.request( + _path, + data: _bodyData, + options: _options, + cancelToken: cancelToken, + onSendProgress: onSendProgress, + onReceiveProgress: onReceiveProgress, + ); + + OkResponse _responseData; + + try { + const _responseType = FullType(OkResponse); + _responseData = _serializers.deserialize( + _response.data!, + specifiedType: _responseType, + ) as OkResponse; + } catch (error, stackTrace) { + throw DioError( + requestOptions: _response.requestOptions, + response: _response, + type: DioErrorType.unknown, + error: error, + stackTrace: stackTrace, + ); + } + + return Response( + data: _responseData, + headers: _response.headers, + isRedirect: _response.isRedirect, + requestOptions: _response.requestOptions, + redirects: _response.redirects, + statusCode: _response.statusCode, + statusMessage: _response.statusMessage, + extra: _response.extra, + ); + } + + /// Drop Table + /// + /// + /// Parameters: + /// * [tableName] + /// * [accessToken] + /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation + /// * [headers] - Can be used to add additional headers to the request + /// * [extras] - Can be used to add flags to the request + /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response + /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress + /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress + /// + /// Returns a [Future] containing a [Response] with a [OkResponse] as data + /// Throws [DioError] if API call or serialization fails + Future> dropTableApiDropTableTableNamePost({ + required String tableName, + String? accessToken, + CancelToken? cancelToken, + Map? headers, + Map? extra, + ValidateStatus? validateStatus, + ProgressCallback? onSendProgress, + ProgressCallback? onReceiveProgress, + }) async { + final _path = r'/api/dropTable/{tableName}' + .replaceAll('{' r'tableName' '}', tableName.toString()); + final _options = Options( + method: r'POST', + headers: { + if (accessToken != null) r'access-token': accessToken, + ...?headers, + }, + extra: { + 'secure': >[], + ...?extra, + }, + validateStatus: validateStatus, + ); + + final _response = await _dio.request( + _path, + options: _options, + cancelToken: cancelToken, + onSendProgress: onSendProgress, + onReceiveProgress: onReceiveProgress, + ); + + OkResponse _responseData; + + try { + const _responseType = FullType(OkResponse); + _responseData = _serializers.deserialize( + _response.data!, + specifiedType: _responseType, + ) as OkResponse; + } catch (error, stackTrace) { + throw DioError( + requestOptions: _response.requestOptions, + response: _response, + type: DioErrorType.unknown, + error: error, + stackTrace: stackTrace, + ); + } + + return Response( + data: _responseData, + headers: _response.headers, + isRedirect: _response.isRedirect, + requestOptions: _response.requestOptions, + redirects: _response.redirects, + statusCode: _response.statusCode, + statusMessage: _response.statusMessage, + extra: _response.extra, + ); + } + + /// Get Access Token + /// + /// + /// Parameters: + /// * [authModel] + /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation + /// * [headers] - Can be used to add additional headers to the request + /// * [extras] - Can be used to add flags to the request + /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response + /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress + /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress + /// + /// Returns a [Future] containing a [Response] with a [AccessTokenResponse] as data + /// Throws [DioError] if API call or serialization fails + Future> getAccessTokenApiGetAccessTokenPost({ + required AuthModel authModel, + CancelToken? cancelToken, + Map? headers, + Map? extra, + ValidateStatus? validateStatus, + ProgressCallback? onSendProgress, + ProgressCallback? onReceiveProgress, + }) async { + final _path = r'/api/getAccessToken'; + final _options = Options( + method: r'POST', + headers: { + ...?headers, + }, + extra: { + 'secure': >[], + ...?extra, + }, + contentType: 'application/json', + validateStatus: validateStatus, + ); + + dynamic _bodyData; + + try { + const _type = FullType(AuthModel); + _bodyData = _serializers.serialize(authModel, specifiedType: _type); + } catch (error, stackTrace) { + throw DioError( + requestOptions: _options.compose( + _dio.options, + _path, + ), + type: DioErrorType.unknown, + error: error, + stackTrace: stackTrace, + ); + } + + final _response = await _dio.request( + _path, + data: _bodyData, + options: _options, + cancelToken: cancelToken, + onSendProgress: onSendProgress, + onReceiveProgress: onReceiveProgress, + ); + + AccessTokenResponse _responseData; + + try { + const _responseType = FullType(AccessTokenResponse); + _responseData = _serializers.deserialize( + _response.data!, + specifiedType: _responseType, + ) as AccessTokenResponse; + } catch (error, stackTrace) { + throw DioError( + requestOptions: _response.requestOptions, + response: _response, + type: DioErrorType.unknown, + error: error, + stackTrace: stackTrace, + ); + } + + return Response( + data: _responseData, + headers: _response.headers, + isRedirect: _response.isRedirect, + requestOptions: _response.requestOptions, + redirects: _response.redirects, + statusCode: _response.statusCode, + statusMessage: _response.statusMessage, + extra: _response.extra, + ); + } + + /// Get Asset + /// + /// + /// Parameters: + /// * [fid] + /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation + /// * [headers] - Can be used to add additional headers to the request + /// * [extras] - Can be used to add flags to the request + /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response + /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress + /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress + /// + /// Returns a [Future] containing a [Response] with a [JsonObject] as data + /// Throws [DioError] if API call or serialization fails + Future> getAssetAssetsFidGet({ + required String fid, + CancelToken? cancelToken, + Map? headers, + Map? extra, + ValidateStatus? validateStatus, + ProgressCallback? onSendProgress, + ProgressCallback? onReceiveProgress, + }) async { + final _path = r'/assets/{fid}'.replaceAll('{' r'fid' '}', fid.toString()); + final _options = Options( + method: r'GET', + headers: { + ...?headers, + }, + extra: { + 'secure': >[], + ...?extra, + }, + validateStatus: validateStatus, + ); + + final _response = await _dio.request( + _path, + options: _options, + cancelToken: cancelToken, + onSendProgress: onSendProgress, + onReceiveProgress: onReceiveProgress, + ); + + JsonObject _responseData; + + try { + const _responseType = FullType(JsonObject); + _responseData = _serializers.deserialize( + _response.data!, + specifiedType: _responseType, + ) as JsonObject; + } catch (error, stackTrace) { + throw DioError( + requestOptions: _response.requestOptions, + response: _response, + type: DioErrorType.unknown, + error: error, + stackTrace: stackTrace, + ); + } + + return Response( + data: _responseData, + headers: _response.headers, + isRedirect: _response.isRedirect, + requestOptions: _response.requestOptions, + redirects: _response.redirects, + statusCode: _response.statusCode, + statusMessage: _response.statusMessage, + extra: _response.extra, + ); + } + + /// Get Items From Table + /// + /// + /// Parameters: + /// * [tableName] + /// * [itemsFieldSelectorList] + /// * [accessToken] + /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation + /// * [headers] - Can be used to add additional headers to the request + /// * [extras] - Can be used to add flags to the request + /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response + /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress + /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress + /// + /// Returns a [Future] containing a [Response] with a [TableItemsResponse] as data + /// Throws [DioError] if API call or serialization fails + Future> getItemsFromTableItemsTableNamePost({ + required String tableName, + required ItemsFieldSelectorList itemsFieldSelectorList, + String? accessToken, + CancelToken? cancelToken, + Map? headers, + Map? extra, + ValidateStatus? validateStatus, + ProgressCallback? onSendProgress, + ProgressCallback? onReceiveProgress, + }) async { + final _path = r'/items/{tableName}' + .replaceAll('{' r'tableName' '}', tableName.toString()); + final _options = Options( + method: r'POST', + headers: { + if (accessToken != null) r'access-token': accessToken, + ...?headers, + }, + extra: { + 'secure': >[], + ...?extra, + }, + contentType: 'application/json', + validateStatus: validateStatus, + ); + + dynamic _bodyData; + + try { + const _type = FullType(ItemsFieldSelectorList); + _bodyData = + _serializers.serialize(itemsFieldSelectorList, specifiedType: _type); + } catch (error, stackTrace) { + throw DioError( + requestOptions: _options.compose( + _dio.options, + _path, + ), + type: DioErrorType.unknown, + error: error, + stackTrace: stackTrace, + ); + } + + final _response = await _dio.request( + _path, + data: _bodyData, + options: _options, + cancelToken: cancelToken, + onSendProgress: onSendProgress, + onReceiveProgress: onReceiveProgress, + ); + + TableItemsResponse _responseData; + + try { + const _responseType = FullType(TableItemsResponse); + _responseData = _serializers.deserialize( + _response.data!, + specifiedType: _responseType, + ) as TableItemsResponse; + } catch (error, stackTrace) { + throw DioError( + requestOptions: _response.requestOptions, + response: _response, + type: DioErrorType.unknown, + error: error, + stackTrace: stackTrace, + ); + } + + return Response( + data: _responseData, + headers: _response.headers, + isRedirect: _response.isRedirect, + requestOptions: _response.requestOptions, + redirects: _response.redirects, + statusCode: _response.statusCode, + statusMessage: _response.statusMessage, + extra: _response.extra, + ); + } + + /// List Tables + /// + /// + /// Parameters: + /// * [accessToken] + /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation + /// * [headers] - Can be used to add additional headers to the request + /// * [extras] - Can be used to add flags to the request + /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response + /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress + /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress + /// + /// Returns a [Future] containing a [Response] with a [BuiltList] as data + /// Throws [DioError] if API call or serialization fails + Future>> listTablesApiListTablesGet({ + String? accessToken, + CancelToken? cancelToken, + Map? headers, + Map? extra, + ValidateStatus? validateStatus, + ProgressCallback? onSendProgress, + ProgressCallback? onReceiveProgress, + }) async { + final _path = r'/api/listTables'; + final _options = Options( + method: r'GET', + headers: { + if (accessToken != null) r'access-token': accessToken, + ...?headers, + }, + extra: { + 'secure': >[], + ...?extra, + }, + validateStatus: validateStatus, + ); + + final _response = await _dio.request( + _path, + options: _options, + cancelToken: cancelToken, + onSendProgress: onSendProgress, + onReceiveProgress: onReceiveProgress, + ); + + BuiltList _responseData; + + try { + const _responseType = FullType(BuiltList, [FullType(TableDefinition)]); + _responseData = _serializers.deserialize( + _response.data!, + specifiedType: _responseType, + ) as BuiltList; + } catch (error, stackTrace) { + throw DioError( + requestOptions: _response.requestOptions, + response: _response, + type: DioErrorType.unknown, + error: error, + stackTrace: stackTrace, + ); + } + + return Response>( + data: _responseData, + headers: _response.headers, + isRedirect: _response.isRedirect, + requestOptions: _response.requestOptions, + redirects: _response.redirects, + statusCode: _response.statusCode, + statusMessage: _response.statusMessage, + extra: _response.extra, + ); + } + + /// Put Asset + /// + /// + /// Parameters: + /// * [asset] + /// * [accessToken] + /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation + /// * [headers] - Can be used to add additional headers to the request + /// * [extras] - Can be used to add flags to the request + /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response + /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress + /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress + /// + /// Returns a [Future] containing a [Response] with a [CreateAssetResponse] as data + /// Throws [DioError] if API call or serialization fails + Future> putAssetAssetsPost({ + required MultipartFile asset, + String? accessToken, + CancelToken? cancelToken, + Map? headers, + Map? extra, + ValidateStatus? validateStatus, + ProgressCallback? onSendProgress, + ProgressCallback? onReceiveProgress, + }) async { + final _path = r'/assets/+'; + final _options = Options( + method: r'POST', + headers: { + if (accessToken != null) r'access-token': accessToken, + ...?headers, + }, + extra: { + 'secure': >[], + ...?extra, + }, + contentType: 'multipart/form-data', + validateStatus: validateStatus, + ); + + dynamic _bodyData; + + try { + _bodyData = FormData.fromMap({ + r'asset': asset, + }); + } catch (error, stackTrace) { + throw DioError( + requestOptions: _options.compose( + _dio.options, + _path, + ), + type: DioErrorType.unknown, + error: error, + stackTrace: stackTrace, + ); + } + + final _response = await _dio.request( + _path, + data: _bodyData, + options: _options, + cancelToken: cancelToken, + onSendProgress: onSendProgress, + onReceiveProgress: onReceiveProgress, + ); + + CreateAssetResponse _responseData; + + try { + const _responseType = FullType(CreateAssetResponse); + _responseData = _serializers.deserialize( + _response.data!, + specifiedType: _responseType, + ) as CreateAssetResponse; + } catch (error, stackTrace) { + throw DioError( + requestOptions: _response.requestOptions, + response: _response, + type: DioErrorType.unknown, + error: error, + stackTrace: stackTrace, + ); + } + + return Response( + data: _responseData, + headers: _response.headers, + isRedirect: _response.isRedirect, + requestOptions: _response.requestOptions, + redirects: _response.redirects, + statusCode: _response.statusCode, + statusMessage: _response.statusMessage, + extra: _response.extra, + ); + } + + /// Remove Asset + /// + /// + /// Parameters: + /// * [assetId] + /// * [checkReferences] + /// * [deleteReferencing] + /// * [accessToken] + /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation + /// * [headers] - Can be used to add additional headers to the request + /// * [extras] - Can be used to add flags to the request + /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response + /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress + /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress + /// + /// Returns a [Future] containing a [Response] with a [OkResponse] as data + /// Throws [DioError] if API call or serialization fails + Future> removeAssetAssetsAssetIdPost({ + required int assetId, + bool? checkReferences = true, + bool? deleteReferencing = false, + String? accessToken, + CancelToken? cancelToken, + Map? headers, + Map? extra, + ValidateStatus? validateStatus, + ProgressCallback? onSendProgress, + ProgressCallback? onReceiveProgress, + }) async { + final _path = r'/assets/{asset_id}/-' + .replaceAll('{' r'asset_id' '}', assetId.toString()); + final _options = Options( + method: r'POST', + headers: { + if (accessToken != null) r'access-token': accessToken, + ...?headers, + }, + extra: { + 'secure': >[], + ...?extra, + }, + validateStatus: validateStatus, + ); + + final _queryParameters = { + if (checkReferences != null) + r'check_references': encodeQueryParameter( + _serializers, checkReferences, const FullType(bool)), + if (deleteReferencing != null) + r'delete_referencing': encodeQueryParameter( + _serializers, deleteReferencing, const FullType(bool)), + }; + + final _response = await _dio.request( + _path, + options: _options, + queryParameters: _queryParameters, + cancelToken: cancelToken, + onSendProgress: onSendProgress, + onReceiveProgress: onReceiveProgress, + ); + + OkResponse _responseData; + + try { + const _responseType = FullType(OkResponse); + _responseData = _serializers.deserialize( + _response.data!, + specifiedType: _responseType, + ) as OkResponse; + } catch (error, stackTrace) { + throw DioError( + requestOptions: _response.requestOptions, + response: _response, + type: DioErrorType.unknown, + error: error, + stackTrace: stackTrace, + ); + } + + return Response( + data: _responseData, + headers: _response.headers, + isRedirect: _response.isRedirect, + requestOptions: _response.requestOptions, + redirects: _response.redirects, + statusCode: _response.statusCode, + statusMessage: _response.statusMessage, + extra: _response.extra, + ); + } + + /// Remove User + /// + /// + /// Parameters: + /// * [userId] + /// * [accessToken] + /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation + /// * [headers] - Can be used to add additional headers to the request + /// * [extras] - Can be used to add flags to the request + /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response + /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress + /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress + /// + /// Returns a [Future] containing a [Response] with a [OkResponse] as data + /// Throws [DioError] if API call or serialization fails + Future> removeUserApiUsersPost({ + required int userId, + String? accessToken, + CancelToken? cancelToken, + Map? headers, + Map? extra, + ValidateStatus? validateStatus, + ProgressCallback? onSendProgress, + ProgressCallback? onReceiveProgress, + }) async { + final _path = r'/api/users/-'; + final _options = Options( + method: r'POST', + headers: { + if (accessToken != null) r'access-token': accessToken, + ...?headers, + }, + extra: { + 'secure': >[], + ...?extra, + }, + validateStatus: validateStatus, + ); + + final _queryParameters = { + r'user_id': + encodeQueryParameter(_serializers, userId, const FullType(int)), + }; + + final _response = await _dio.request( + _path, + options: _options, + queryParameters: _queryParameters, + cancelToken: cancelToken, + onSendProgress: onSendProgress, + onReceiveProgress: onReceiveProgress, + ); + + OkResponse _responseData; + + try { + const _responseType = FullType(OkResponse); + _responseData = _serializers.deserialize( + _response.data!, + specifiedType: _responseType, + ) as OkResponse; + } catch (error, stackTrace) { + throw DioError( + requestOptions: _response.requestOptions, + response: _response, + type: DioErrorType.unknown, + error: error, + stackTrace: stackTrace, + ); + } + + return Response( + data: _responseData, + headers: _response.headers, + isRedirect: _response.isRedirect, + requestOptions: _response.requestOptions, + redirects: _response.redirects, + statusCode: _response.statusCode, + statusMessage: _response.statusMessage, + extra: _response.extra, + ); + } + + /// Update Asset Description + /// + /// + /// Parameters: + /// * [assetId] + /// * [assetDescription] + /// * [accessToken] + /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation + /// * [headers] - Can be used to add additional headers to the request + /// * [extras] - Can be used to add flags to the request + /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response + /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress + /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress + /// + /// Returns a [Future] containing a [Response] with a [OkResponse] as data + /// Throws [DioError] if API call or serialization fails + Future> updateAssetDescriptionAssetsAssetIdPost({ + required int assetId, + required String assetDescription, + String? accessToken, + CancelToken? cancelToken, + Map? headers, + Map? extra, + ValidateStatus? validateStatus, + ProgressCallback? onSendProgress, + ProgressCallback? onReceiveProgress, + }) async { + final _path = r'/assets/{asset_id}/*' + .replaceAll('{' r'asset_id' '}', assetId.toString()); + final _options = Options( + method: r'POST', + headers: { + if (accessToken != null) r'access-token': accessToken, + ...?headers, + }, + extra: { + 'secure': >[], + ...?extra, + }, + validateStatus: validateStatus, + ); + + final _queryParameters = { + r'asset_description': encodeQueryParameter( + _serializers, assetDescription, const FullType(String)), + }; + + final _response = await _dio.request( + _path, + options: _options, + queryParameters: _queryParameters, + cancelToken: cancelToken, + onSendProgress: onSendProgress, + onReceiveProgress: onReceiveProgress, + ); + + OkResponse _responseData; + + try { + const _responseType = FullType(OkResponse); + _responseData = _serializers.deserialize( + _response.data!, + specifiedType: _responseType, + ) as OkResponse; + } catch (error, stackTrace) { + throw DioError( + requestOptions: _response.requestOptions, + response: _response, + type: DioErrorType.unknown, + error: error, + stackTrace: stackTrace, + ); + } + + return Response( + data: _responseData, + headers: _response.headers, + isRedirect: _response.isRedirect, + requestOptions: _response.requestOptions, + redirects: _response.redirects, + statusCode: _response.statusCode, + statusMessage: _response.statusMessage, + extra: _response.extra, + ); + } + + /// Update Item In Table + /// + /// + /// Parameters: + /// * [tableName] + /// * [bodyUpdateItemInTableItemsTableNamePost] + /// * [accessToken] + /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation + /// * [headers] - Can be used to add additional headers to the request + /// * [extras] - Can be used to add flags to the request + /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response + /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress + /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress + /// + /// Returns a [Future] containing a [Response] with a [OkResponse] as data + /// Throws [DioError] if API call or serialization fails + Future> updateItemInTableItemsTableNamePost({ + required String tableName, + required BodyUpdateItemInTableItemsTableNamePost + bodyUpdateItemInTableItemsTableNamePost, + String? accessToken, + CancelToken? cancelToken, + Map? headers, + Map? extra, + ValidateStatus? validateStatus, + ProgressCallback? onSendProgress, + ProgressCallback? onReceiveProgress, + }) async { + final _path = r'/items/{tableName}/*' + .replaceAll('{' r'tableName' '}', tableName.toString()); + final _options = Options( + method: r'POST', + headers: { + if (accessToken != null) r'access-token': accessToken, + ...?headers, + }, + extra: { + 'secure': >[], + ...?extra, + }, + contentType: 'application/json', + validateStatus: validateStatus, + ); + + dynamic _bodyData; + + try { + const _type = FullType(BodyUpdateItemInTableItemsTableNamePost); + _bodyData = _serializers.serialize( + bodyUpdateItemInTableItemsTableNamePost, + specifiedType: _type); + } catch (error, stackTrace) { + throw DioError( + requestOptions: _options.compose( + _dio.options, + _path, + ), + type: DioErrorType.unknown, + error: error, + stackTrace: stackTrace, + ); + } + + final _response = await _dio.request( + _path, + data: _bodyData, + options: _options, + cancelToken: cancelToken, + onSendProgress: onSendProgress, + onReceiveProgress: onReceiveProgress, + ); + + OkResponse _responseData; + + try { + const _responseType = FullType(OkResponse); + _responseData = _serializers.deserialize( + _response.data!, + specifiedType: _responseType, + ) as OkResponse; + } catch (error, stackTrace) { + throw DioError( + requestOptions: _response.requestOptions, + response: _response, + type: DioErrorType.unknown, + error: error, + stackTrace: stackTrace, + ); + } + + return Response( + data: _responseData, + headers: _response.headers, + isRedirect: _response.isRedirect, + requestOptions: _response.requestOptions, + redirects: _response.redirects, + statusCode: _response.statusCode, + statusMessage: _response.statusMessage, + extra: _response.extra, + ); + } + + /// Update User + /// + /// + /// Parameters: + /// * [userUpdateDefinition] + /// * [accessToken] + /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation + /// * [headers] - Can be used to add additional headers to the request + /// * [extras] - Can be used to add flags to the request + /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response + /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress + /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress + /// + /// Returns a [Future] containing a [Response] with a [OkResponse] as data + /// Throws [DioError] if API call or serialization fails + Future> updateUserApiUsersPost({ + required UserUpdateDefinition userUpdateDefinition, + String? accessToken, + CancelToken? cancelToken, + Map? headers, + Map? extra, + ValidateStatus? validateStatus, + ProgressCallback? onSendProgress, + ProgressCallback? onReceiveProgress, + }) async { + final _path = r'/api/users/*'; + final _options = Options( + method: r'POST', + headers: { + if (accessToken != null) r'access-token': accessToken, + ...?headers, + }, + extra: { + 'secure': >[], + ...?extra, + }, + contentType: 'application/json', + validateStatus: validateStatus, + ); + + dynamic _bodyData; + + try { + const _type = FullType(UserUpdateDefinition); + _bodyData = + _serializers.serialize(userUpdateDefinition, specifiedType: _type); + } catch (error, stackTrace) { + throw DioError( + requestOptions: _options.compose( + _dio.options, + _path, + ), + type: DioErrorType.unknown, + error: error, + stackTrace: stackTrace, + ); + } + + final _response = await _dio.request( + _path, + data: _bodyData, + options: _options, + cancelToken: cancelToken, + onSendProgress: onSendProgress, + onReceiveProgress: onReceiveProgress, + ); + + OkResponse _responseData; + + try { + const _responseType = FullType(OkResponse); + _responseData = _serializers.deserialize( + _response.data!, + specifiedType: _responseType, + ) as OkResponse; + } catch (error, stackTrace) { + throw DioError( + requestOptions: _response.requestOptions, + response: _response, + type: DioErrorType.unknown, + error: error, + stackTrace: stackTrace, + ); + } + + return Response( + data: _responseData, + headers: _response.headers, + isRedirect: _response.isRedirect, + requestOptions: _response.requestOptions, + redirects: _response.redirects, + statusCode: _response.statusCode, + statusMessage: _response.statusMessage, + extra: _response.extra, + ); + } +} diff --git a/lib/api_sub_project/src/api_util.dart b/lib/api_sub_project/src/api_util.dart new file mode 100644 index 0000000..ed3bb12 --- /dev/null +++ b/lib/api_sub_project/src/api_util.dart @@ -0,0 +1,77 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// + +import 'dart:convert'; +import 'dart:typed_data'; + +import 'package:built_collection/built_collection.dart'; +import 'package:built_value/serializer.dart'; +import 'package:dio/dio.dart'; + +/// Format the given form parameter object into something that Dio can handle. +/// Returns primitive or String. +/// Returns List/Map if the value is BuildList/BuiltMap. +dynamic encodeFormParameter(Serializers serializers, dynamic value, FullType type) { + if (value == null) { + return ''; + } + if (value is String || value is num || value is bool) { + return value; + } + final serialized = serializers.serialize( + value as Object, + specifiedType: type, + ); + if (serialized is String) { + return serialized; + } + if (value is BuiltList || value is BuiltSet || value is BuiltMap) { + return serialized; + } + return json.encode(serialized); +} + +dynamic encodeQueryParameter( + Serializers serializers, + dynamic value, + FullType type, +) { + if (value == null) { + return ''; + } + if (value is String || value is num || value is bool) { + return value; + } + if (value is Uint8List) { + // Currently not sure how to serialize this + return value; + } + final serialized = serializers.serialize( + value as Object, + specifiedType: type, + ); + if (serialized == null) { + return ''; + } + if (serialized is String) { + return serialized; + } + return serialized; +} + +ListParam encodeCollectionQueryParameter( + Serializers serializers, + dynamic value, + FullType type, { + ListFormat format = ListFormat.multi, +}) { + final serialized = serializers.serialize( + value as Object, + specifiedType: type, + ); + if (value is BuiltList || value is BuiltSet) { + return ListParam(List.of((serialized as Iterable).cast()), format); + } + throw ArgumentError('Invalid value passed to encodeCollectionQueryParameter'); +} diff --git a/lib/api_sub_project/src/auth/api_key_auth.dart b/lib/api_sub_project/src/auth/api_key_auth.dart new file mode 100644 index 0000000..74996b0 --- /dev/null +++ b/lib/api_sub_project/src/auth/api_key_auth.dart @@ -0,0 +1,30 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// + +import 'package:dio/dio.dart'; +import 'package:tuuli_app/api_sub_project/src/auth/auth.dart'; + +class ApiKeyAuthInterceptor extends AuthInterceptor { + final Map apiKeys = {}; + + @override + void onRequest(RequestOptions options, RequestInterceptorHandler handler) { + final authInfo = + getAuthInfo(options, (secure) => secure['type'] == 'apiKey'); + for (final info in authInfo) { + final authName = info['name'] as String; + final authKeyName = info['keyName'] as String; + final authWhere = info['where'] as String; + final apiKey = apiKeys[authName]; + if (apiKey != null) { + if (authWhere == 'query') { + options.queryParameters[authKeyName] = apiKey; + } else { + options.headers[authKeyName] = apiKey; + } + } + } + super.onRequest(options, handler); + } +} diff --git a/lib/api_sub_project/src/auth/auth.dart b/lib/api_sub_project/src/auth/auth.dart new file mode 100644 index 0000000..f7ae9bf --- /dev/null +++ b/lib/api_sub_project/src/auth/auth.dart @@ -0,0 +1,18 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// + +import 'package:dio/dio.dart'; + +abstract class AuthInterceptor extends Interceptor { + /// Get auth information on given route for the given type. + /// Can return an empty list if type is not present on auth data or + /// if route doesn't need authentication. + List> getAuthInfo(RequestOptions route, bool Function(Map secure) handles) { + if (route.extra.containsKey('secure')) { + final auth = route.extra['secure'] as List>; + return auth.where((secure) => handles(secure)).toList(); + } + return []; + } +} diff --git a/lib/api_sub_project/src/auth/basic_auth.dart b/lib/api_sub_project/src/auth/basic_auth.dart new file mode 100644 index 0000000..ad6906b --- /dev/null +++ b/lib/api_sub_project/src/auth/basic_auth.dart @@ -0,0 +1,42 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// + +import 'dart:convert'; + +import 'package:dio/dio.dart'; +import 'package:tuuli_app/api_sub_project/src/auth/auth.dart'; + +class BasicAuthInfo { + final String username; + final String password; + + const BasicAuthInfo(this.username, this.password); +} + +class BasicAuthInterceptor extends AuthInterceptor { + final Map authInfo = {}; + + @override + void onRequest( + RequestOptions options, + RequestInterceptorHandler handler, + ) { + final metadataAuthInfo = getAuthInfo( + options, + (secure) => + (secure['type'] == 'http' && secure['scheme'] == 'basic') || + secure['type'] == 'basic'); + for (final info in metadataAuthInfo) { + final authName = info['name'] as String; + final basicAuthInfo = authInfo[authName]; + if (basicAuthInfo != null) { + final basicAuth = + 'Basic ${base64Encode(utf8.encode('${basicAuthInfo.username}:${basicAuthInfo.password}'))}'; + options.headers['Authorization'] = basicAuth; + break; + } + } + super.onRequest(options, handler); + } +} diff --git a/lib/api_sub_project/src/auth/bearer_auth.dart b/lib/api_sub_project/src/auth/bearer_auth.dart new file mode 100644 index 0000000..fadbc2b --- /dev/null +++ b/lib/api_sub_project/src/auth/bearer_auth.dart @@ -0,0 +1,27 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// + +import 'package:dio/dio.dart'; +import 'package:tuuli_app/api_sub_project/src/auth/auth.dart'; + +class BearerAuthInterceptor extends AuthInterceptor { + final Map tokens = {}; + + @override + void onRequest( + RequestOptions options, + RequestInterceptorHandler handler, + ) { + final authInfo = getAuthInfo(options, + (secure) => secure['type'] == 'http' && secure['scheme'] == 'bearer'); + for (final info in authInfo) { + final token = tokens[info['name']]; + if (token != null) { + options.headers['Authorization'] = 'Bearer ${token}'; + break; + } + } + super.onRequest(options, handler); + } +} diff --git a/lib/api_sub_project/src/auth/oauth.dart b/lib/api_sub_project/src/auth/oauth.dart new file mode 100644 index 0000000..c8b6faa --- /dev/null +++ b/lib/api_sub_project/src/auth/oauth.dart @@ -0,0 +1,27 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// + +import 'package:dio/dio.dart'; +import 'package:tuuli_app/api_sub_project/src/auth/auth.dart'; + +class OAuthInterceptor extends AuthInterceptor { + final Map tokens = {}; + + @override + void onRequest( + RequestOptions options, + RequestInterceptorHandler handler, + ) { + final authInfo = getAuthInfo(options, + (secure) => secure['type'] == 'oauth' || secure['type'] == 'oauth2'); + for (final info in authInfo) { + final token = tokens[info['name']]; + if (token != null) { + options.headers['Authorization'] = 'Bearer ${token}'; + break; + } + } + super.onRequest(options, handler); + } +} diff --git a/lib/api_sub_project/src/date_serializer.dart b/lib/api_sub_project/src/date_serializer.dart new file mode 100644 index 0000000..f6cbf32 --- /dev/null +++ b/lib/api_sub_project/src/date_serializer.dart @@ -0,0 +1,30 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// + +import 'package:built_collection/built_collection.dart'; +import 'package:built_value/serializer.dart'; +import 'package:tuuli_app/api_sub_project/src/model/date.dart'; + +class DateSerializer implements PrimitiveSerializer { + const DateSerializer(); + + @override + Iterable get types => BuiltList.of([Date]); + + @override + String get wireName => 'Date'; + + @override + Date deserialize(Serializers serializers, Object serialized, + {FullType specifiedType = FullType.unspecified}) { + final parsed = DateTime.parse(serialized as String); + return Date(parsed.year, parsed.month, parsed.day); + } + + @override + Object serialize(Serializers serializers, Date date, + {FullType specifiedType = FullType.unspecified}) { + return date.toString(); + } +} diff --git a/lib/api_sub_project/src/model/access_token_response.dart b/lib/api_sub_project/src/model/access_token_response.dart new file mode 100644 index 0000000..c7e4b29 --- /dev/null +++ b/lib/api_sub_project/src/model/access_token_response.dart @@ -0,0 +1,106 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// + +// ignore_for_file: unused_element +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; + +part 'access_token_response.g.dart'; + +/// AccessTokenResponse +/// +/// Properties: +/// * [accessToken] +@BuiltValue() +abstract class AccessTokenResponse implements Built { + @BuiltValueField(wireName: r'access_token') + String get accessToken; + + AccessTokenResponse._(); + + factory AccessTokenResponse([void updates(AccessTokenResponseBuilder b)]) = _$AccessTokenResponse; + + @BuiltValueHook(initializeBuilder: true) + static void _defaults(AccessTokenResponseBuilder b) => b; + + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$AccessTokenResponseSerializer(); +} + +class _$AccessTokenResponseSerializer implements PrimitiveSerializer { + @override + final Iterable types = const [AccessTokenResponse, _$AccessTokenResponse]; + + @override + final String wireName = r'AccessTokenResponse'; + + Iterable _serializeProperties( + Serializers serializers, + AccessTokenResponse object, { + FullType specifiedType = FullType.unspecified, + }) sync* { + yield r'access_token'; + yield serializers.serialize( + object.accessToken, + specifiedType: const FullType(String), + ); + } + + @override + Object serialize( + Serializers serializers, + AccessTokenResponse object, { + FullType specifiedType = FullType.unspecified, + }) { + return _serializeProperties(serializers, object, specifiedType: specifiedType).toList(); + } + + void _deserializeProperties( + Serializers serializers, + Object serialized, { + FullType specifiedType = FullType.unspecified, + required List serializedList, + required AccessTokenResponseBuilder result, + required List unhandled, + }) { + for (var i = 0; i < serializedList.length; i += 2) { + final key = serializedList[i] as String; + final value = serializedList[i + 1]; + switch (key) { + case r'access_token': + final valueDes = serializers.deserialize( + value, + specifiedType: const FullType(String), + ) as String; + result.accessToken = valueDes; + break; + default: + unhandled.add(key); + unhandled.add(value); + break; + } + } + } + + @override + AccessTokenResponse deserialize( + Serializers serializers, + Object serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final result = AccessTokenResponseBuilder(); + final serializedList = (serialized as Iterable).toList(); + final unhandled = []; + _deserializeProperties( + serializers, + serialized, + specifiedType: specifiedType, + serializedList: serializedList, + unhandled: unhandled, + result: result, + ); + return result.build(); + } +} + diff --git a/lib/api_sub_project/src/model/access_token_response.g.dart b/lib/api_sub_project/src/model/access_token_response.g.dart new file mode 100644 index 0000000..8432dd4 --- /dev/null +++ b/lib/api_sub_project/src/model/access_token_response.g.dart @@ -0,0 +1,98 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'access_token_response.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +class _$AccessTokenResponse extends AccessTokenResponse { + @override + final String accessToken; + + factory _$AccessTokenResponse( + [void Function(AccessTokenResponseBuilder)? updates]) => + (new AccessTokenResponseBuilder()..update(updates))._build(); + + _$AccessTokenResponse._({required this.accessToken}) : super._() { + BuiltValueNullFieldError.checkNotNull( + accessToken, r'AccessTokenResponse', 'accessToken'); + } + + @override + AccessTokenResponse rebuild( + void Function(AccessTokenResponseBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + AccessTokenResponseBuilder toBuilder() => + new AccessTokenResponseBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is AccessTokenResponse && accessToken == other.accessToken; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, accessToken.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'AccessTokenResponse') + ..add('accessToken', accessToken)) + .toString(); + } +} + +class AccessTokenResponseBuilder + implements Builder { + _$AccessTokenResponse? _$v; + + String? _accessToken; + String? get accessToken => _$this._accessToken; + set accessToken(String? accessToken) => _$this._accessToken = accessToken; + + AccessTokenResponseBuilder() { + AccessTokenResponse._defaults(this); + } + + AccessTokenResponseBuilder get _$this { + final $v = _$v; + if ($v != null) { + _accessToken = $v.accessToken; + _$v = null; + } + return this; + } + + @override + void replace(AccessTokenResponse other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$AccessTokenResponse; + } + + @override + void update(void Function(AccessTokenResponseBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + AccessTokenResponse build() => _build(); + + _$AccessTokenResponse _build() { + final _$result = _$v ?? + new _$AccessTokenResponse._( + accessToken: BuiltValueNullFieldError.checkNotNull( + accessToken, r'AccessTokenResponse', 'accessToken')); + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/lib/api_sub_project/src/model/auth_model.dart b/lib/api_sub_project/src/model/auth_model.dart new file mode 100644 index 0000000..d1c736e --- /dev/null +++ b/lib/api_sub_project/src/model/auth_model.dart @@ -0,0 +1,122 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// + +// ignore_for_file: unused_element +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; + +part 'auth_model.g.dart'; + +/// AuthModel +/// +/// Properties: +/// * [username] +/// * [password] +@BuiltValue() +abstract class AuthModel implements Built { + @BuiltValueField(wireName: r'username') + String get username; + + @BuiltValueField(wireName: r'password') + String get password; + + AuthModel._(); + + factory AuthModel([void updates(AuthModelBuilder b)]) = _$AuthModel; + + @BuiltValueHook(initializeBuilder: true) + static void _defaults(AuthModelBuilder b) => b; + + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$AuthModelSerializer(); +} + +class _$AuthModelSerializer implements PrimitiveSerializer { + @override + final Iterable types = const [AuthModel, _$AuthModel]; + + @override + final String wireName = r'AuthModel'; + + Iterable _serializeProperties( + Serializers serializers, + AuthModel object, { + FullType specifiedType = FullType.unspecified, + }) sync* { + yield r'username'; + yield serializers.serialize( + object.username, + specifiedType: const FullType(String), + ); + yield r'password'; + yield serializers.serialize( + object.password, + specifiedType: const FullType(String), + ); + } + + @override + Object serialize( + Serializers serializers, + AuthModel object, { + FullType specifiedType = FullType.unspecified, + }) { + return _serializeProperties(serializers, object, specifiedType: specifiedType).toList(); + } + + void _deserializeProperties( + Serializers serializers, + Object serialized, { + FullType specifiedType = FullType.unspecified, + required List serializedList, + required AuthModelBuilder result, + required List unhandled, + }) { + for (var i = 0; i < serializedList.length; i += 2) { + final key = serializedList[i] as String; + final value = serializedList[i + 1]; + switch (key) { + case r'username': + final valueDes = serializers.deserialize( + value, + specifiedType: const FullType(String), + ) as String; + result.username = valueDes; + break; + case r'password': + final valueDes = serializers.deserialize( + value, + specifiedType: const FullType(String), + ) as String; + result.password = valueDes; + break; + default: + unhandled.add(key); + unhandled.add(value); + break; + } + } + } + + @override + AuthModel deserialize( + Serializers serializers, + Object serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final result = AuthModelBuilder(); + final serializedList = (serialized as Iterable).toList(); + final unhandled = []; + _deserializeProperties( + serializers, + serialized, + specifiedType: specifiedType, + serializedList: serializedList, + unhandled: unhandled, + result: result, + ); + return result.build(); + } +} + diff --git a/lib/api_sub_project/src/model/auth_model.g.dart b/lib/api_sub_project/src/model/auth_model.g.dart new file mode 100644 index 0000000..f95dd71 --- /dev/null +++ b/lib/api_sub_project/src/model/auth_model.g.dart @@ -0,0 +1,107 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'auth_model.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +class _$AuthModel extends AuthModel { + @override + final String username; + @override + final String password; + + factory _$AuthModel([void Function(AuthModelBuilder)? updates]) => + (new AuthModelBuilder()..update(updates))._build(); + + _$AuthModel._({required this.username, required this.password}) : super._() { + BuiltValueNullFieldError.checkNotNull(username, r'AuthModel', 'username'); + BuiltValueNullFieldError.checkNotNull(password, r'AuthModel', 'password'); + } + + @override + AuthModel rebuild(void Function(AuthModelBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + AuthModelBuilder toBuilder() => new AuthModelBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is AuthModel && + username == other.username && + password == other.password; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, username.hashCode); + _$hash = $jc(_$hash, password.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'AuthModel') + ..add('username', username) + ..add('password', password)) + .toString(); + } +} + +class AuthModelBuilder implements Builder { + _$AuthModel? _$v; + + String? _username; + String? get username => _$this._username; + set username(String? username) => _$this._username = username; + + String? _password; + String? get password => _$this._password; + set password(String? password) => _$this._password = password; + + AuthModelBuilder() { + AuthModel._defaults(this); + } + + AuthModelBuilder get _$this { + final $v = _$v; + if ($v != null) { + _username = $v.username; + _password = $v.password; + _$v = null; + } + return this; + } + + @override + void replace(AuthModel other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$AuthModel; + } + + @override + void update(void Function(AuthModelBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + AuthModel build() => _build(); + + _$AuthModel _build() { + final _$result = _$v ?? + new _$AuthModel._( + username: BuiltValueNullFieldError.checkNotNull( + username, r'AuthModel', 'username'), + password: BuiltValueNullFieldError.checkNotNull( + password, r'AuthModel', 'password')); + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/lib/api_sub_project/src/model/body_update_item_in_table_items_table_name_post.dart b/lib/api_sub_project/src/model/body_update_item_in_table_items_table_name_post.dart new file mode 100644 index 0000000..45b0d05 --- /dev/null +++ b/lib/api_sub_project/src/model/body_update_item_in_table_items_table_name_post.dart @@ -0,0 +1,123 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// + +// ignore_for_file: unused_element +import 'package:built_collection/built_collection.dart'; +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; + +part 'body_update_item_in_table_items_table_name_post.g.dart'; + +/// BodyUpdateItemInTableItemsTableNamePost +/// +/// Properties: +/// * [item] +/// * [oldItem] +@BuiltValue() +abstract class BodyUpdateItemInTableItemsTableNamePost implements Built { + @BuiltValueField(wireName: r'item') + BuiltMap get item; + + @BuiltValueField(wireName: r'oldItem') + BuiltMap get oldItem; + + BodyUpdateItemInTableItemsTableNamePost._(); + + factory BodyUpdateItemInTableItemsTableNamePost([void updates(BodyUpdateItemInTableItemsTableNamePostBuilder b)]) = _$BodyUpdateItemInTableItemsTableNamePost; + + @BuiltValueHook(initializeBuilder: true) + static void _defaults(BodyUpdateItemInTableItemsTableNamePostBuilder b) => b; + + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$BodyUpdateItemInTableItemsTableNamePostSerializer(); +} + +class _$BodyUpdateItemInTableItemsTableNamePostSerializer implements PrimitiveSerializer { + @override + final Iterable types = const [BodyUpdateItemInTableItemsTableNamePost, _$BodyUpdateItemInTableItemsTableNamePost]; + + @override + final String wireName = r'BodyUpdateItemInTableItemsTableNamePost'; + + Iterable _serializeProperties( + Serializers serializers, + BodyUpdateItemInTableItemsTableNamePost object, { + FullType specifiedType = FullType.unspecified, + }) sync* { + yield r'item'; + yield serializers.serialize( + object.item, + specifiedType: const FullType(BuiltMap, [FullType(String), FullType(String)]), + ); + yield r'oldItem'; + yield serializers.serialize( + object.oldItem, + specifiedType: const FullType(BuiltMap, [FullType(String), FullType(String)]), + ); + } + + @override + Object serialize( + Serializers serializers, + BodyUpdateItemInTableItemsTableNamePost object, { + FullType specifiedType = FullType.unspecified, + }) { + return _serializeProperties(serializers, object, specifiedType: specifiedType).toList(); + } + + void _deserializeProperties( + Serializers serializers, + Object serialized, { + FullType specifiedType = FullType.unspecified, + required List serializedList, + required BodyUpdateItemInTableItemsTableNamePostBuilder result, + required List unhandled, + }) { + for (var i = 0; i < serializedList.length; i += 2) { + final key = serializedList[i] as String; + final value = serializedList[i + 1]; + switch (key) { + case r'item': + final valueDes = serializers.deserialize( + value, + specifiedType: const FullType(BuiltMap, [FullType(String), FullType(String)]), + ) as BuiltMap; + result.item.replace(valueDes); + break; + case r'oldItem': + final valueDes = serializers.deserialize( + value, + specifiedType: const FullType(BuiltMap, [FullType(String), FullType(String)]), + ) as BuiltMap; + result.oldItem.replace(valueDes); + break; + default: + unhandled.add(key); + unhandled.add(value); + break; + } + } + } + + @override + BodyUpdateItemInTableItemsTableNamePost deserialize( + Serializers serializers, + Object serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final result = BodyUpdateItemInTableItemsTableNamePostBuilder(); + final serializedList = (serialized as Iterable).toList(); + final unhandled = []; + _deserializeProperties( + serializers, + serialized, + specifiedType: specifiedType, + serializedList: serializedList, + unhandled: unhandled, + result: result, + ); + return result.build(); + } +} + diff --git a/lib/api_sub_project/src/model/body_update_item_in_table_items_table_name_post.g.dart b/lib/api_sub_project/src/model/body_update_item_in_table_items_table_name_post.g.dart new file mode 100644 index 0000000..9f7fff4 --- /dev/null +++ b/lib/api_sub_project/src/model/body_update_item_in_table_items_table_name_post.g.dart @@ -0,0 +1,139 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'body_update_item_in_table_items_table_name_post.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +class _$BodyUpdateItemInTableItemsTableNamePost + extends BodyUpdateItemInTableItemsTableNamePost { + @override + final BuiltMap item; + @override + final BuiltMap oldItem; + + factory _$BodyUpdateItemInTableItemsTableNamePost( + [void Function(BodyUpdateItemInTableItemsTableNamePostBuilder)? + updates]) => + (new BodyUpdateItemInTableItemsTableNamePostBuilder()..update(updates)) + ._build(); + + _$BodyUpdateItemInTableItemsTableNamePost._( + {required this.item, required this.oldItem}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + item, r'BodyUpdateItemInTableItemsTableNamePost', 'item'); + BuiltValueNullFieldError.checkNotNull( + oldItem, r'BodyUpdateItemInTableItemsTableNamePost', 'oldItem'); + } + + @override + BodyUpdateItemInTableItemsTableNamePost rebuild( + void Function(BodyUpdateItemInTableItemsTableNamePostBuilder) + updates) => + (toBuilder()..update(updates)).build(); + + @override + BodyUpdateItemInTableItemsTableNamePostBuilder toBuilder() => + new BodyUpdateItemInTableItemsTableNamePostBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is BodyUpdateItemInTableItemsTableNamePost && + item == other.item && + oldItem == other.oldItem; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, item.hashCode); + _$hash = $jc(_$hash, oldItem.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper( + r'BodyUpdateItemInTableItemsTableNamePost') + ..add('item', item) + ..add('oldItem', oldItem)) + .toString(); + } +} + +class BodyUpdateItemInTableItemsTableNamePostBuilder + implements + Builder { + _$BodyUpdateItemInTableItemsTableNamePost? _$v; + + MapBuilder? _item; + MapBuilder get item => + _$this._item ??= new MapBuilder(); + set item(MapBuilder? item) => _$this._item = item; + + MapBuilder? _oldItem; + MapBuilder get oldItem => + _$this._oldItem ??= new MapBuilder(); + set oldItem(MapBuilder? oldItem) => _$this._oldItem = oldItem; + + BodyUpdateItemInTableItemsTableNamePostBuilder() { + BodyUpdateItemInTableItemsTableNamePost._defaults(this); + } + + BodyUpdateItemInTableItemsTableNamePostBuilder get _$this { + final $v = _$v; + if ($v != null) { + _item = $v.item.toBuilder(); + _oldItem = $v.oldItem.toBuilder(); + _$v = null; + } + return this; + } + + @override + void replace(BodyUpdateItemInTableItemsTableNamePost other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$BodyUpdateItemInTableItemsTableNamePost; + } + + @override + void update( + void Function(BodyUpdateItemInTableItemsTableNamePostBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + BodyUpdateItemInTableItemsTableNamePost build() => _build(); + + _$BodyUpdateItemInTableItemsTableNamePost _build() { + _$BodyUpdateItemInTableItemsTableNamePost _$result; + try { + _$result = _$v ?? + new _$BodyUpdateItemInTableItemsTableNamePost._( + item: item.build(), oldItem: oldItem.build()); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'item'; + item.build(); + _$failedField = 'oldItem'; + oldItem.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'BodyUpdateItemInTableItemsTableNamePost', + _$failedField, + e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/lib/api_sub_project/src/model/column_condition_compat.dart b/lib/api_sub_project/src/model/column_condition_compat.dart new file mode 100644 index 0000000..3c12118 --- /dev/null +++ b/lib/api_sub_project/src/model/column_condition_compat.dart @@ -0,0 +1,179 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// + +// ignore_for_file: unused_element +import 'package:built_collection/built_collection.dart'; +import 'package:built_value/json_object.dart'; +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; + +part 'column_condition_compat.g.dart'; + +/// ColumnConditionCompat +/// +/// Properties: +/// * [column] +/// * [operator_] +/// * [value] +@BuiltValue() +abstract class ColumnConditionCompat implements Built { + @BuiltValueField(wireName: r'column') + String get column; + + @BuiltValueField(wireName: r'operator') + ColumnConditionCompatOperator_Enum get operator_; + // enum operator_Enum { eq, ne, gt, lt, ge, le, contains, not_contains, starts_with, not_starts_with, ends_with, not_ends_with, }; + + @BuiltValueField(wireName: r'value') + JsonObject? get value; + + ColumnConditionCompat._(); + + factory ColumnConditionCompat([void updates(ColumnConditionCompatBuilder b)]) = _$ColumnConditionCompat; + + @BuiltValueHook(initializeBuilder: true) + static void _defaults(ColumnConditionCompatBuilder b) => b; + + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$ColumnConditionCompatSerializer(); +} + +class _$ColumnConditionCompatSerializer implements PrimitiveSerializer { + @override + final Iterable types = const [ColumnConditionCompat, _$ColumnConditionCompat]; + + @override + final String wireName = r'ColumnConditionCompat'; + + Iterable _serializeProperties( + Serializers serializers, + ColumnConditionCompat object, { + FullType specifiedType = FullType.unspecified, + }) sync* { + yield r'column'; + yield serializers.serialize( + object.column, + specifiedType: const FullType(String), + ); + yield r'operator'; + yield serializers.serialize( + object.operator_, + specifiedType: const FullType(ColumnConditionCompatOperator_Enum), + ); + if (object.value != null) { + yield r'value'; + yield serializers.serialize( + object.value, + specifiedType: const FullType.nullable(JsonObject), + ); + } + } + + @override + Object serialize( + Serializers serializers, + ColumnConditionCompat object, { + FullType specifiedType = FullType.unspecified, + }) { + return _serializeProperties(serializers, object, specifiedType: specifiedType).toList(); + } + + void _deserializeProperties( + Serializers serializers, + Object serialized, { + FullType specifiedType = FullType.unspecified, + required List serializedList, + required ColumnConditionCompatBuilder result, + required List unhandled, + }) { + for (var i = 0; i < serializedList.length; i += 2) { + final key = serializedList[i] as String; + final value = serializedList[i + 1]; + switch (key) { + case r'column': + final valueDes = serializers.deserialize( + value, + specifiedType: const FullType(String), + ) as String; + result.column = valueDes; + break; + case r'operator': + final valueDes = serializers.deserialize( + value, + specifiedType: const FullType(ColumnConditionCompatOperator_Enum), + ) as ColumnConditionCompatOperator_Enum; + result.operator_ = valueDes; + break; + case r'value': + final valueDes = serializers.deserialize( + value, + specifiedType: const FullType.nullable(JsonObject), + ) as JsonObject?; + if (valueDes == null) continue; + result.value = valueDes; + break; + default: + unhandled.add(key); + unhandled.add(value); + break; + } + } + } + + @override + ColumnConditionCompat deserialize( + Serializers serializers, + Object serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final result = ColumnConditionCompatBuilder(); + final serializedList = (serialized as Iterable).toList(); + final unhandled = []; + _deserializeProperties( + serializers, + serialized, + specifiedType: specifiedType, + serializedList: serializedList, + unhandled: unhandled, + result: result, + ); + return result.build(); + } +} + +class ColumnConditionCompatOperator_Enum extends EnumClass { + + @BuiltValueEnumConst(wireName: r'eq') + static const ColumnConditionCompatOperator_Enum eq = _$columnConditionCompatOperatorEnum_eq; + @BuiltValueEnumConst(wireName: r'ne') + static const ColumnConditionCompatOperator_Enum ne = _$columnConditionCompatOperatorEnum_ne; + @BuiltValueEnumConst(wireName: r'gt') + static const ColumnConditionCompatOperator_Enum gt = _$columnConditionCompatOperatorEnum_gt; + @BuiltValueEnumConst(wireName: r'lt') + static const ColumnConditionCompatOperator_Enum lt = _$columnConditionCompatOperatorEnum_lt; + @BuiltValueEnumConst(wireName: r'ge') + static const ColumnConditionCompatOperator_Enum ge = _$columnConditionCompatOperatorEnum_ge; + @BuiltValueEnumConst(wireName: r'le') + static const ColumnConditionCompatOperator_Enum le = _$columnConditionCompatOperatorEnum_le; + @BuiltValueEnumConst(wireName: r'contains') + static const ColumnConditionCompatOperator_Enum contains = _$columnConditionCompatOperatorEnum_contains; + @BuiltValueEnumConst(wireName: r'not_contains') + static const ColumnConditionCompatOperator_Enum notContains = _$columnConditionCompatOperatorEnum_notContains; + @BuiltValueEnumConst(wireName: r'starts_with') + static const ColumnConditionCompatOperator_Enum startsWith = _$columnConditionCompatOperatorEnum_startsWith; + @BuiltValueEnumConst(wireName: r'not_starts_with') + static const ColumnConditionCompatOperator_Enum notStartsWith = _$columnConditionCompatOperatorEnum_notStartsWith; + @BuiltValueEnumConst(wireName: r'ends_with') + static const ColumnConditionCompatOperator_Enum endsWith = _$columnConditionCompatOperatorEnum_endsWith; + @BuiltValueEnumConst(wireName: r'not_ends_with') + static const ColumnConditionCompatOperator_Enum notEndsWith = _$columnConditionCompatOperatorEnum_notEndsWith; + + static Serializer get serializer => _$columnConditionCompatOperatorEnumSerializer; + + const ColumnConditionCompatOperator_Enum._(String name): super(name); + + static BuiltSet get values => _$columnConditionCompatOperatorEnumValues; + static ColumnConditionCompatOperator_Enum valueOf(String name) => _$columnConditionCompatOperatorEnumValueOf(name); +} + diff --git a/lib/api_sub_project/src/model/column_condition_compat.g.dart b/lib/api_sub_project/src/model/column_condition_compat.g.dart new file mode 100644 index 0000000..1e50ab6 --- /dev/null +++ b/lib/api_sub_project/src/model/column_condition_compat.g.dart @@ -0,0 +1,267 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'column_condition_compat.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +const ColumnConditionCompatOperator_Enum + _$columnConditionCompatOperatorEnum_eq = + const ColumnConditionCompatOperator_Enum._('eq'); +const ColumnConditionCompatOperator_Enum + _$columnConditionCompatOperatorEnum_ne = + const ColumnConditionCompatOperator_Enum._('ne'); +const ColumnConditionCompatOperator_Enum + _$columnConditionCompatOperatorEnum_gt = + const ColumnConditionCompatOperator_Enum._('gt'); +const ColumnConditionCompatOperator_Enum + _$columnConditionCompatOperatorEnum_lt = + const ColumnConditionCompatOperator_Enum._('lt'); +const ColumnConditionCompatOperator_Enum + _$columnConditionCompatOperatorEnum_ge = + const ColumnConditionCompatOperator_Enum._('ge'); +const ColumnConditionCompatOperator_Enum + _$columnConditionCompatOperatorEnum_le = + const ColumnConditionCompatOperator_Enum._('le'); +const ColumnConditionCompatOperator_Enum + _$columnConditionCompatOperatorEnum_contains = + const ColumnConditionCompatOperator_Enum._('contains'); +const ColumnConditionCompatOperator_Enum + _$columnConditionCompatOperatorEnum_notContains = + const ColumnConditionCompatOperator_Enum._('notContains'); +const ColumnConditionCompatOperator_Enum + _$columnConditionCompatOperatorEnum_startsWith = + const ColumnConditionCompatOperator_Enum._('startsWith'); +const ColumnConditionCompatOperator_Enum + _$columnConditionCompatOperatorEnum_notStartsWith = + const ColumnConditionCompatOperator_Enum._('notStartsWith'); +const ColumnConditionCompatOperator_Enum + _$columnConditionCompatOperatorEnum_endsWith = + const ColumnConditionCompatOperator_Enum._('endsWith'); +const ColumnConditionCompatOperator_Enum + _$columnConditionCompatOperatorEnum_notEndsWith = + const ColumnConditionCompatOperator_Enum._('notEndsWith'); + +ColumnConditionCompatOperator_Enum _$columnConditionCompatOperatorEnumValueOf( + String name) { + switch (name) { + case 'eq': + return _$columnConditionCompatOperatorEnum_eq; + case 'ne': + return _$columnConditionCompatOperatorEnum_ne; + case 'gt': + return _$columnConditionCompatOperatorEnum_gt; + case 'lt': + return _$columnConditionCompatOperatorEnum_lt; + case 'ge': + return _$columnConditionCompatOperatorEnum_ge; + case 'le': + return _$columnConditionCompatOperatorEnum_le; + case 'contains': + return _$columnConditionCompatOperatorEnum_contains; + case 'notContains': + return _$columnConditionCompatOperatorEnum_notContains; + case 'startsWith': + return _$columnConditionCompatOperatorEnum_startsWith; + case 'notStartsWith': + return _$columnConditionCompatOperatorEnum_notStartsWith; + case 'endsWith': + return _$columnConditionCompatOperatorEnum_endsWith; + case 'notEndsWith': + return _$columnConditionCompatOperatorEnum_notEndsWith; + default: + throw new ArgumentError(name); + } +} + +final BuiltSet + _$columnConditionCompatOperatorEnumValues = new BuiltSet< + ColumnConditionCompatOperator_Enum>(const [ + _$columnConditionCompatOperatorEnum_eq, + _$columnConditionCompatOperatorEnum_ne, + _$columnConditionCompatOperatorEnum_gt, + _$columnConditionCompatOperatorEnum_lt, + _$columnConditionCompatOperatorEnum_ge, + _$columnConditionCompatOperatorEnum_le, + _$columnConditionCompatOperatorEnum_contains, + _$columnConditionCompatOperatorEnum_notContains, + _$columnConditionCompatOperatorEnum_startsWith, + _$columnConditionCompatOperatorEnum_notStartsWith, + _$columnConditionCompatOperatorEnum_endsWith, + _$columnConditionCompatOperatorEnum_notEndsWith, +]); + +Serializer + _$columnConditionCompatOperatorEnumSerializer = + new _$ColumnConditionCompatOperator_EnumSerializer(); + +class _$ColumnConditionCompatOperator_EnumSerializer + implements PrimitiveSerializer { + static const Map _toWire = const { + 'eq': 'eq', + 'ne': 'ne', + 'gt': 'gt', + 'lt': 'lt', + 'ge': 'ge', + 'le': 'le', + 'contains': 'contains', + 'notContains': 'not_contains', + 'startsWith': 'starts_with', + 'notStartsWith': 'not_starts_with', + 'endsWith': 'ends_with', + 'notEndsWith': 'not_ends_with', + }; + static const Map _fromWire = const { + 'eq': 'eq', + 'ne': 'ne', + 'gt': 'gt', + 'lt': 'lt', + 'ge': 'ge', + 'le': 'le', + 'contains': 'contains', + 'not_contains': 'notContains', + 'starts_with': 'startsWith', + 'not_starts_with': 'notStartsWith', + 'ends_with': 'endsWith', + 'not_ends_with': 'notEndsWith', + }; + + @override + final Iterable types = const [ColumnConditionCompatOperator_Enum]; + @override + final String wireName = 'ColumnConditionCompatOperator_Enum'; + + @override + Object serialize( + Serializers serializers, ColumnConditionCompatOperator_Enum object, + {FullType specifiedType = FullType.unspecified}) => + _toWire[object.name] ?? object.name; + + @override + ColumnConditionCompatOperator_Enum deserialize( + Serializers serializers, Object serialized, + {FullType specifiedType = FullType.unspecified}) => + ColumnConditionCompatOperator_Enum.valueOf( + _fromWire[serialized] ?? (serialized is String ? serialized : '')); +} + +class _$ColumnConditionCompat extends ColumnConditionCompat { + @override + final String column; + @override + final ColumnConditionCompatOperator_Enum operator_; + @override + final JsonObject? value; + + factory _$ColumnConditionCompat( + [void Function(ColumnConditionCompatBuilder)? updates]) => + (new ColumnConditionCompatBuilder()..update(updates))._build(); + + _$ColumnConditionCompat._( + {required this.column, required this.operator_, this.value}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + column, r'ColumnConditionCompat', 'column'); + BuiltValueNullFieldError.checkNotNull( + operator_, r'ColumnConditionCompat', 'operator_'); + } + + @override + ColumnConditionCompat rebuild( + void Function(ColumnConditionCompatBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + ColumnConditionCompatBuilder toBuilder() => + new ColumnConditionCompatBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is ColumnConditionCompat && + column == other.column && + operator_ == other.operator_ && + value == other.value; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, column.hashCode); + _$hash = $jc(_$hash, operator_.hashCode); + _$hash = $jc(_$hash, value.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'ColumnConditionCompat') + ..add('column', column) + ..add('operator_', operator_) + ..add('value', value)) + .toString(); + } +} + +class ColumnConditionCompatBuilder + implements Builder { + _$ColumnConditionCompat? _$v; + + String? _column; + String? get column => _$this._column; + set column(String? column) => _$this._column = column; + + ColumnConditionCompatOperator_Enum? _operator_; + ColumnConditionCompatOperator_Enum? get operator_ => _$this._operator_; + set operator_(ColumnConditionCompatOperator_Enum? operator_) => + _$this._operator_ = operator_; + + JsonObject? _value; + JsonObject? get value => _$this._value; + set value(JsonObject? value) => _$this._value = value; + + ColumnConditionCompatBuilder() { + ColumnConditionCompat._defaults(this); + } + + ColumnConditionCompatBuilder get _$this { + final $v = _$v; + if ($v != null) { + _column = $v.column; + _operator_ = $v.operator_; + _value = $v.value; + _$v = null; + } + return this; + } + + @override + void replace(ColumnConditionCompat other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$ColumnConditionCompat; + } + + @override + void update(void Function(ColumnConditionCompatBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + ColumnConditionCompat build() => _build(); + + _$ColumnConditionCompat _build() { + final _$result = _$v ?? + new _$ColumnConditionCompat._( + column: BuiltValueNullFieldError.checkNotNull( + column, r'ColumnConditionCompat', 'column'), + operator_: BuiltValueNullFieldError.checkNotNull( + operator_, r'ColumnConditionCompat', 'operator_'), + value: value); + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/lib/api_sub_project/src/model/create_asset_response.dart b/lib/api_sub_project/src/model/create_asset_response.dart new file mode 100644 index 0000000..ef2943a --- /dev/null +++ b/lib/api_sub_project/src/model/create_asset_response.dart @@ -0,0 +1,125 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// + +// ignore_for_file: unused_element +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; + +part 'create_asset_response.g.dart'; + +/// CreateAssetResponse +/// +/// Properties: +/// * [ok] +/// * [fid] +@BuiltValue() +abstract class CreateAssetResponse implements Built { + @BuiltValueField(wireName: r'ok') + bool? get ok; + + @BuiltValueField(wireName: r'fid') + String get fid; + + CreateAssetResponse._(); + + factory CreateAssetResponse([void updates(CreateAssetResponseBuilder b)]) = _$CreateAssetResponse; + + @BuiltValueHook(initializeBuilder: true) + static void _defaults(CreateAssetResponseBuilder b) => b + ..ok = true; + + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$CreateAssetResponseSerializer(); +} + +class _$CreateAssetResponseSerializer implements PrimitiveSerializer { + @override + final Iterable types = const [CreateAssetResponse, _$CreateAssetResponse]; + + @override + final String wireName = r'CreateAssetResponse'; + + Iterable _serializeProperties( + Serializers serializers, + CreateAssetResponse object, { + FullType specifiedType = FullType.unspecified, + }) sync* { + if (object.ok != null) { + yield r'ok'; + yield serializers.serialize( + object.ok, + specifiedType: const FullType(bool), + ); + } + yield r'fid'; + yield serializers.serialize( + object.fid, + specifiedType: const FullType(String), + ); + } + + @override + Object serialize( + Serializers serializers, + CreateAssetResponse object, { + FullType specifiedType = FullType.unspecified, + }) { + return _serializeProperties(serializers, object, specifiedType: specifiedType).toList(); + } + + void _deserializeProperties( + Serializers serializers, + Object serialized, { + FullType specifiedType = FullType.unspecified, + required List serializedList, + required CreateAssetResponseBuilder result, + required List unhandled, + }) { + for (var i = 0; i < serializedList.length; i += 2) { + final key = serializedList[i] as String; + final value = serializedList[i + 1]; + switch (key) { + case r'ok': + final valueDes = serializers.deserialize( + value, + specifiedType: const FullType(bool), + ) as bool; + result.ok = valueDes; + break; + case r'fid': + final valueDes = serializers.deserialize( + value, + specifiedType: const FullType(String), + ) as String; + result.fid = valueDes; + break; + default: + unhandled.add(key); + unhandled.add(value); + break; + } + } + } + + @override + CreateAssetResponse deserialize( + Serializers serializers, + Object serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final result = CreateAssetResponseBuilder(); + final serializedList = (serialized as Iterable).toList(); + final unhandled = []; + _deserializeProperties( + serializers, + serialized, + specifiedType: specifiedType, + serializedList: serializedList, + unhandled: unhandled, + result: result, + ); + return result.build(); + } +} + diff --git a/lib/api_sub_project/src/model/create_asset_response.g.dart b/lib/api_sub_project/src/model/create_asset_response.g.dart new file mode 100644 index 0000000..adfdeae --- /dev/null +++ b/lib/api_sub_project/src/model/create_asset_response.g.dart @@ -0,0 +1,107 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'create_asset_response.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +class _$CreateAssetResponse extends CreateAssetResponse { + @override + final bool? ok; + @override + final String fid; + + factory _$CreateAssetResponse( + [void Function(CreateAssetResponseBuilder)? updates]) => + (new CreateAssetResponseBuilder()..update(updates))._build(); + + _$CreateAssetResponse._({this.ok, required this.fid}) : super._() { + BuiltValueNullFieldError.checkNotNull(fid, r'CreateAssetResponse', 'fid'); + } + + @override + CreateAssetResponse rebuild( + void Function(CreateAssetResponseBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + CreateAssetResponseBuilder toBuilder() => + new CreateAssetResponseBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is CreateAssetResponse && ok == other.ok && fid == other.fid; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, ok.hashCode); + _$hash = $jc(_$hash, fid.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'CreateAssetResponse') + ..add('ok', ok) + ..add('fid', fid)) + .toString(); + } +} + +class CreateAssetResponseBuilder + implements Builder { + _$CreateAssetResponse? _$v; + + bool? _ok; + bool? get ok => _$this._ok; + set ok(bool? ok) => _$this._ok = ok; + + String? _fid; + String? get fid => _$this._fid; + set fid(String? fid) => _$this._fid = fid; + + CreateAssetResponseBuilder() { + CreateAssetResponse._defaults(this); + } + + CreateAssetResponseBuilder get _$this { + final $v = _$v; + if ($v != null) { + _ok = $v.ok; + _fid = $v.fid; + _$v = null; + } + return this; + } + + @override + void replace(CreateAssetResponse other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$CreateAssetResponse; + } + + @override + void update(void Function(CreateAssetResponseBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + CreateAssetResponse build() => _build(); + + _$CreateAssetResponse _build() { + final _$result = _$v ?? + new _$CreateAssetResponse._( + ok: ok, + fid: BuiltValueNullFieldError.checkNotNull( + fid, r'CreateAssetResponse', 'fid')); + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/lib/api_sub_project/src/model/create_user_definition.dart b/lib/api_sub_project/src/model/create_user_definition.dart new file mode 100644 index 0000000..92e0270 --- /dev/null +++ b/lib/api_sub_project/src/model/create_user_definition.dart @@ -0,0 +1,122 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// + +// ignore_for_file: unused_element +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; + +part 'create_user_definition.g.dart'; + +/// CreateUserDefinition +/// +/// Properties: +/// * [username] +/// * [password] +@BuiltValue() +abstract class CreateUserDefinition implements Built { + @BuiltValueField(wireName: r'username') + String get username; + + @BuiltValueField(wireName: r'password') + String get password; + + CreateUserDefinition._(); + + factory CreateUserDefinition([void updates(CreateUserDefinitionBuilder b)]) = _$CreateUserDefinition; + + @BuiltValueHook(initializeBuilder: true) + static void _defaults(CreateUserDefinitionBuilder b) => b; + + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$CreateUserDefinitionSerializer(); +} + +class _$CreateUserDefinitionSerializer implements PrimitiveSerializer { + @override + final Iterable types = const [CreateUserDefinition, _$CreateUserDefinition]; + + @override + final String wireName = r'CreateUserDefinition'; + + Iterable _serializeProperties( + Serializers serializers, + CreateUserDefinition object, { + FullType specifiedType = FullType.unspecified, + }) sync* { + yield r'username'; + yield serializers.serialize( + object.username, + specifiedType: const FullType(String), + ); + yield r'password'; + yield serializers.serialize( + object.password, + specifiedType: const FullType(String), + ); + } + + @override + Object serialize( + Serializers serializers, + CreateUserDefinition object, { + FullType specifiedType = FullType.unspecified, + }) { + return _serializeProperties(serializers, object, specifiedType: specifiedType).toList(); + } + + void _deserializeProperties( + Serializers serializers, + Object serialized, { + FullType specifiedType = FullType.unspecified, + required List serializedList, + required CreateUserDefinitionBuilder result, + required List unhandled, + }) { + for (var i = 0; i < serializedList.length; i += 2) { + final key = serializedList[i] as String; + final value = serializedList[i + 1]; + switch (key) { + case r'username': + final valueDes = serializers.deserialize( + value, + specifiedType: const FullType(String), + ) as String; + result.username = valueDes; + break; + case r'password': + final valueDes = serializers.deserialize( + value, + specifiedType: const FullType(String), + ) as String; + result.password = valueDes; + break; + default: + unhandled.add(key); + unhandled.add(value); + break; + } + } + } + + @override + CreateUserDefinition deserialize( + Serializers serializers, + Object serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final result = CreateUserDefinitionBuilder(); + final serializedList = (serialized as Iterable).toList(); + final unhandled = []; + _deserializeProperties( + serializers, + serialized, + specifiedType: specifiedType, + serializedList: serializedList, + unhandled: unhandled, + result: result, + ); + return result.build(); + } +} + diff --git a/lib/api_sub_project/src/model/create_user_definition.g.dart b/lib/api_sub_project/src/model/create_user_definition.g.dart new file mode 100644 index 0000000..86be5d8 --- /dev/null +++ b/lib/api_sub_project/src/model/create_user_definition.g.dart @@ -0,0 +1,114 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'create_user_definition.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +class _$CreateUserDefinition extends CreateUserDefinition { + @override + final String username; + @override + final String password; + + factory _$CreateUserDefinition( + [void Function(CreateUserDefinitionBuilder)? updates]) => + (new CreateUserDefinitionBuilder()..update(updates))._build(); + + _$CreateUserDefinition._({required this.username, required this.password}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + username, r'CreateUserDefinition', 'username'); + BuiltValueNullFieldError.checkNotNull( + password, r'CreateUserDefinition', 'password'); + } + + @override + CreateUserDefinition rebuild( + void Function(CreateUserDefinitionBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + CreateUserDefinitionBuilder toBuilder() => + new CreateUserDefinitionBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is CreateUserDefinition && + username == other.username && + password == other.password; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, username.hashCode); + _$hash = $jc(_$hash, password.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'CreateUserDefinition') + ..add('username', username) + ..add('password', password)) + .toString(); + } +} + +class CreateUserDefinitionBuilder + implements Builder { + _$CreateUserDefinition? _$v; + + String? _username; + String? get username => _$this._username; + set username(String? username) => _$this._username = username; + + String? _password; + String? get password => _$this._password; + set password(String? password) => _$this._password = password; + + CreateUserDefinitionBuilder() { + CreateUserDefinition._defaults(this); + } + + CreateUserDefinitionBuilder get _$this { + final $v = _$v; + if ($v != null) { + _username = $v.username; + _password = $v.password; + _$v = null; + } + return this; + } + + @override + void replace(CreateUserDefinition other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$CreateUserDefinition; + } + + @override + void update(void Function(CreateUserDefinitionBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + CreateUserDefinition build() => _build(); + + _$CreateUserDefinition _build() { + final _$result = _$v ?? + new _$CreateUserDefinition._( + username: BuiltValueNullFieldError.checkNotNull( + username, r'CreateUserDefinition', 'username'), + password: BuiltValueNullFieldError.checkNotNull( + password, r'CreateUserDefinition', 'password')); + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/lib/api_sub_project/src/model/date.dart b/lib/api_sub_project/src/model/date.dart new file mode 100644 index 0000000..b21c7f5 --- /dev/null +++ b/lib/api_sub_project/src/model/date.dart @@ -0,0 +1,70 @@ +/// A gregorian calendar date generated by +/// OpenAPI generator to differentiate +/// between [DateTime] and [Date] formats. +class Date implements Comparable { + final int year; + + /// January is 1. + final int month; + + /// First day is 1. + final int day; + + Date(this.year, this.month, this.day); + + /// The current date + static Date now({bool utc = false}) { + var now = DateTime.now(); + if (utc) { + now = now.toUtc(); + } + return now.toDate(); + } + + /// Convert to a [DateTime]. + DateTime toDateTime({bool utc = false}) { + if (utc) { + return DateTime.utc(year, month, day); + } else { + return DateTime(year, month, day); + } + } + + @override + int compareTo(Date other) { + int d = year.compareTo(other.year); + if (d != 0) { + return d; + } + d = month.compareTo(other.month); + if (d != 0) { + return d; + } + return day.compareTo(other.day); + } + + @override + bool operator ==(Object other) => + identical(this, other) || + other is Date && + runtimeType == other.runtimeType && + year == other.year && + month == other.month && + day == other.day; + + @override + int get hashCode => year.hashCode ^ month.hashCode ^ day.hashCode; + + @override + String toString() { + final yyyy = year.toString(); + final mm = month.toString().padLeft(2, '0'); + final dd = day.toString().padLeft(2, '0'); + + return '$yyyy-$mm-$dd'; + } +} + +extension DateTimeToDate on DateTime { + Date toDate() => Date(year, month, day); +} diff --git a/lib/api_sub_project/src/model/error_response.dart b/lib/api_sub_project/src/model/error_response.dart new file mode 100644 index 0000000..a11a492 --- /dev/null +++ b/lib/api_sub_project/src/model/error_response.dart @@ -0,0 +1,106 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// + +// ignore_for_file: unused_element +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; + +part 'error_response.g.dart'; + +/// ErrorResponse +/// +/// Properties: +/// * [error] +@BuiltValue() +abstract class ErrorResponse implements Built { + @BuiltValueField(wireName: r'error') + String get error; + + ErrorResponse._(); + + factory ErrorResponse([void updates(ErrorResponseBuilder b)]) = _$ErrorResponse; + + @BuiltValueHook(initializeBuilder: true) + static void _defaults(ErrorResponseBuilder b) => b; + + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$ErrorResponseSerializer(); +} + +class _$ErrorResponseSerializer implements PrimitiveSerializer { + @override + final Iterable types = const [ErrorResponse, _$ErrorResponse]; + + @override + final String wireName = r'ErrorResponse'; + + Iterable _serializeProperties( + Serializers serializers, + ErrorResponse object, { + FullType specifiedType = FullType.unspecified, + }) sync* { + yield r'error'; + yield serializers.serialize( + object.error, + specifiedType: const FullType(String), + ); + } + + @override + Object serialize( + Serializers serializers, + ErrorResponse object, { + FullType specifiedType = FullType.unspecified, + }) { + return _serializeProperties(serializers, object, specifiedType: specifiedType).toList(); + } + + void _deserializeProperties( + Serializers serializers, + Object serialized, { + FullType specifiedType = FullType.unspecified, + required List serializedList, + required ErrorResponseBuilder result, + required List unhandled, + }) { + for (var i = 0; i < serializedList.length; i += 2) { + final key = serializedList[i] as String; + final value = serializedList[i + 1]; + switch (key) { + case r'error': + final valueDes = serializers.deserialize( + value, + specifiedType: const FullType(String), + ) as String; + result.error = valueDes; + break; + default: + unhandled.add(key); + unhandled.add(value); + break; + } + } + } + + @override + ErrorResponse deserialize( + Serializers serializers, + Object serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final result = ErrorResponseBuilder(); + final serializedList = (serialized as Iterable).toList(); + final unhandled = []; + _deserializeProperties( + serializers, + serialized, + specifiedType: specifiedType, + serializedList: serializedList, + unhandled: unhandled, + result: result, + ); + return result.build(); + } +} + diff --git a/lib/api_sub_project/src/model/error_response.g.dart b/lib/api_sub_project/src/model/error_response.g.dart new file mode 100644 index 0000000..3d1df13 --- /dev/null +++ b/lib/api_sub_project/src/model/error_response.g.dart @@ -0,0 +1,93 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'error_response.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +class _$ErrorResponse extends ErrorResponse { + @override + final String error; + + factory _$ErrorResponse([void Function(ErrorResponseBuilder)? updates]) => + (new ErrorResponseBuilder()..update(updates))._build(); + + _$ErrorResponse._({required this.error}) : super._() { + BuiltValueNullFieldError.checkNotNull(error, r'ErrorResponse', 'error'); + } + + @override + ErrorResponse rebuild(void Function(ErrorResponseBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + ErrorResponseBuilder toBuilder() => new ErrorResponseBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is ErrorResponse && error == other.error; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, error.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'ErrorResponse')..add('error', error)) + .toString(); + } +} + +class ErrorResponseBuilder + implements Builder { + _$ErrorResponse? _$v; + + String? _error; + String? get error => _$this._error; + set error(String? error) => _$this._error = error; + + ErrorResponseBuilder() { + ErrorResponse._defaults(this); + } + + ErrorResponseBuilder get _$this { + final $v = _$v; + if ($v != null) { + _error = $v.error; + _$v = null; + } + return this; + } + + @override + void replace(ErrorResponse other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$ErrorResponse; + } + + @override + void update(void Function(ErrorResponseBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + ErrorResponse build() => _build(); + + _$ErrorResponse _build() { + final _$result = _$v ?? + new _$ErrorResponse._( + error: BuiltValueNullFieldError.checkNotNull( + error, r'ErrorResponse', 'error')); + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/lib/api_sub_project/src/model/http_validation_error.dart b/lib/api_sub_project/src/model/http_validation_error.dart new file mode 100644 index 0000000..3917b2d --- /dev/null +++ b/lib/api_sub_project/src/model/http_validation_error.dart @@ -0,0 +1,119 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// + +// ignore_for_file: unused_element +import 'package:built_collection/built_collection.dart'; +import 'package:tuuli_app/api_sub_project/src/model/validation_error.dart'; +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; + +part 'http_validation_error.g.dart'; + +/// HTTPValidationError +/// +/// Properties: +/// * [detail] +@BuiltValue() +abstract class HTTPValidationError + implements Built { + @BuiltValueField(wireName: r'detail') + BuiltList? get detail; + + HTTPValidationError._(); + + factory HTTPValidationError([void updates(HTTPValidationErrorBuilder b)]) = + _$HTTPValidationError; + + @BuiltValueHook(initializeBuilder: true) + static void _defaults(HTTPValidationErrorBuilder b) => b; + + @BuiltValueSerializer(custom: true) + static Serializer get serializer => + _$HTTPValidationErrorSerializer(); +} + +class _$HTTPValidationErrorSerializer + implements PrimitiveSerializer { + @override + final Iterable types = const [ + HTTPValidationError, + _$HTTPValidationError + ]; + + @override + final String wireName = r'HTTPValidationError'; + + Iterable _serializeProperties( + Serializers serializers, + HTTPValidationError object, { + FullType specifiedType = FullType.unspecified, + }) sync* { + if (object.detail != null) { + yield r'detail'; + yield serializers.serialize( + object.detail, + specifiedType: const FullType(BuiltList, [FullType(ValidationError)]), + ); + } + } + + @override + Object serialize( + Serializers serializers, + HTTPValidationError object, { + FullType specifiedType = FullType.unspecified, + }) { + return _serializeProperties(serializers, object, + specifiedType: specifiedType) + .toList(); + } + + void _deserializeProperties( + Serializers serializers, + Object serialized, { + FullType specifiedType = FullType.unspecified, + required List serializedList, + required HTTPValidationErrorBuilder result, + required List unhandled, + }) { + for (var i = 0; i < serializedList.length; i += 2) { + final key = serializedList[i] as String; + final value = serializedList[i + 1]; + switch (key) { + case r'detail': + final valueDes = serializers.deserialize( + value, + specifiedType: + const FullType(BuiltList, [FullType(ValidationError)]), + ) as BuiltList; + result.detail.replace(valueDes); + break; + default: + unhandled.add(key); + unhandled.add(value); + break; + } + } + } + + @override + HTTPValidationError deserialize( + Serializers serializers, + Object serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final result = HTTPValidationErrorBuilder(); + final serializedList = (serialized as Iterable).toList(); + final unhandled = []; + _deserializeProperties( + serializers, + serialized, + specifiedType: specifiedType, + serializedList: serializedList, + unhandled: unhandled, + result: result, + ); + return result.build(); + } +} diff --git a/lib/api_sub_project/src/model/http_validation_error.g.dart b/lib/api_sub_project/src/model/http_validation_error.g.dart new file mode 100644 index 0000000..40ab1a8 --- /dev/null +++ b/lib/api_sub_project/src/model/http_validation_error.g.dart @@ -0,0 +1,106 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'http_validation_error.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +class _$HTTPValidationError extends HTTPValidationError { + @override + final BuiltList? detail; + + factory _$HTTPValidationError( + [void Function(HTTPValidationErrorBuilder)? updates]) => + (new HTTPValidationErrorBuilder()..update(updates))._build(); + + _$HTTPValidationError._({this.detail}) : super._(); + + @override + HTTPValidationError rebuild( + void Function(HTTPValidationErrorBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + HTTPValidationErrorBuilder toBuilder() => + new HTTPValidationErrorBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is HTTPValidationError && detail == other.detail; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, detail.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'HTTPValidationError') + ..add('detail', detail)) + .toString(); + } +} + +class HTTPValidationErrorBuilder + implements Builder { + _$HTTPValidationError? _$v; + + ListBuilder? _detail; + ListBuilder get detail => + _$this._detail ??= new ListBuilder(); + set detail(ListBuilder? detail) => _$this._detail = detail; + + HTTPValidationErrorBuilder() { + HTTPValidationError._defaults(this); + } + + HTTPValidationErrorBuilder get _$this { + final $v = _$v; + if ($v != null) { + _detail = $v.detail?.toBuilder(); + _$v = null; + } + return this; + } + + @override + void replace(HTTPValidationError other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$HTTPValidationError; + } + + @override + void update(void Function(HTTPValidationErrorBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + HTTPValidationError build() => _build(); + + _$HTTPValidationError _build() { + _$HTTPValidationError _$result; + try { + _$result = _$v ?? new _$HTTPValidationError._(detail: _detail?.build()); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'detail'; + _detail?.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'HTTPValidationError', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/lib/api_sub_project/src/model/items_field_selector_list.dart b/lib/api_sub_project/src/model/items_field_selector_list.dart new file mode 100644 index 0000000..9d04644 --- /dev/null +++ b/lib/api_sub_project/src/model/items_field_selector_list.dart @@ -0,0 +1,110 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// + +// ignore_for_file: unused_element +import 'package:built_collection/built_collection.dart'; +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; + +part 'items_field_selector_list.g.dart'; + +/// ItemsFieldSelectorList +/// +/// Properties: +/// * [fields] +@BuiltValue() +abstract class ItemsFieldSelectorList implements Built { + @BuiltValueField(wireName: r'fields') + BuiltList? get fields; + + ItemsFieldSelectorList._(); + + factory ItemsFieldSelectorList([void updates(ItemsFieldSelectorListBuilder b)]) = _$ItemsFieldSelectorList; + + @BuiltValueHook(initializeBuilder: true) + static void _defaults(ItemsFieldSelectorListBuilder b) => b + ..fields = ListBuilder(); + + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$ItemsFieldSelectorListSerializer(); +} + +class _$ItemsFieldSelectorListSerializer implements PrimitiveSerializer { + @override + final Iterable types = const [ItemsFieldSelectorList, _$ItemsFieldSelectorList]; + + @override + final String wireName = r'ItemsFieldSelectorList'; + + Iterable _serializeProperties( + Serializers serializers, + ItemsFieldSelectorList object, { + FullType specifiedType = FullType.unspecified, + }) sync* { + if (object.fields != null) { + yield r'fields'; + yield serializers.serialize( + object.fields, + specifiedType: const FullType(BuiltList, [FullType(String)]), + ); + } + } + + @override + Object serialize( + Serializers serializers, + ItemsFieldSelectorList object, { + FullType specifiedType = FullType.unspecified, + }) { + return _serializeProperties(serializers, object, specifiedType: specifiedType).toList(); + } + + void _deserializeProperties( + Serializers serializers, + Object serialized, { + FullType specifiedType = FullType.unspecified, + required List serializedList, + required ItemsFieldSelectorListBuilder result, + required List unhandled, + }) { + for (var i = 0; i < serializedList.length; i += 2) { + final key = serializedList[i] as String; + final value = serializedList[i + 1]; + switch (key) { + case r'fields': + final valueDes = serializers.deserialize( + value, + specifiedType: const FullType(BuiltList, [FullType(String)]), + ) as BuiltList; + result.fields.replace(valueDes); + break; + default: + unhandled.add(key); + unhandled.add(value); + break; + } + } + } + + @override + ItemsFieldSelectorList deserialize( + Serializers serializers, + Object serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final result = ItemsFieldSelectorListBuilder(); + final serializedList = (serialized as Iterable).toList(); + final unhandled = []; + _deserializeProperties( + serializers, + serialized, + specifiedType: specifiedType, + serializedList: serializedList, + unhandled: unhandled, + result: result, + ); + return result.build(); + } +} + diff --git a/lib/api_sub_project/src/model/items_field_selector_list.g.dart b/lib/api_sub_project/src/model/items_field_selector_list.g.dart new file mode 100644 index 0000000..18d1543 --- /dev/null +++ b/lib/api_sub_project/src/model/items_field_selector_list.g.dart @@ -0,0 +1,107 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'items_field_selector_list.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +class _$ItemsFieldSelectorList extends ItemsFieldSelectorList { + @override + final BuiltList? fields; + + factory _$ItemsFieldSelectorList( + [void Function(ItemsFieldSelectorListBuilder)? updates]) => + (new ItemsFieldSelectorListBuilder()..update(updates))._build(); + + _$ItemsFieldSelectorList._({this.fields}) : super._(); + + @override + ItemsFieldSelectorList rebuild( + void Function(ItemsFieldSelectorListBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + ItemsFieldSelectorListBuilder toBuilder() => + new ItemsFieldSelectorListBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is ItemsFieldSelectorList && fields == other.fields; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, fields.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'ItemsFieldSelectorList') + ..add('fields', fields)) + .toString(); + } +} + +class ItemsFieldSelectorListBuilder + implements Builder { + _$ItemsFieldSelectorList? _$v; + + ListBuilder? _fields; + ListBuilder get fields => + _$this._fields ??= new ListBuilder(); + set fields(ListBuilder? fields) => _$this._fields = fields; + + ItemsFieldSelectorListBuilder() { + ItemsFieldSelectorList._defaults(this); + } + + ItemsFieldSelectorListBuilder get _$this { + final $v = _$v; + if ($v != null) { + _fields = $v.fields?.toBuilder(); + _$v = null; + } + return this; + } + + @override + void replace(ItemsFieldSelectorList other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$ItemsFieldSelectorList; + } + + @override + void update(void Function(ItemsFieldSelectorListBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + ItemsFieldSelectorList build() => _build(); + + _$ItemsFieldSelectorList _build() { + _$ItemsFieldSelectorList _$result; + try { + _$result = + _$v ?? new _$ItemsFieldSelectorList._(fields: _fields?.build()); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'fields'; + _fields?.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'ItemsFieldSelectorList', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/lib/api_sub_project/src/model/location_inner.dart b/lib/api_sub_project/src/model/location_inner.dart new file mode 100644 index 0000000..5a96d05 --- /dev/null +++ b/lib/api_sub_project/src/model/location_inner.dart @@ -0,0 +1,68 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// + +// ignore_for_file: unused_element +import 'dart:core'; +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; +import 'package:one_of/any_of.dart'; + +part 'location_inner.g.dart'; + +/// LocationInner +@BuiltValue() +abstract class LocationInner implements Built { + /// Any Of [String], [int] + AnyOf get anyOf; + + LocationInner._(); + + factory LocationInner([void updates(LocationInnerBuilder b)]) = _$LocationInner; + + @BuiltValueHook(initializeBuilder: true) + static void _defaults(LocationInnerBuilder b) => b; + + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$LocationInnerSerializer(); +} + +class _$LocationInnerSerializer implements PrimitiveSerializer { + @override + final Iterable types = const [LocationInner, _$LocationInner]; + + @override + final String wireName = r'LocationInner'; + + Iterable _serializeProperties( + Serializers serializers, + LocationInner object, { + FullType specifiedType = FullType.unspecified, + }) sync* { + } + + @override + Object serialize( + Serializers serializers, + LocationInner object, { + FullType specifiedType = FullType.unspecified, + }) { + final anyOf = object.anyOf; + return serializers.serialize(anyOf, specifiedType: FullType(AnyOf, anyOf.valueTypes.map((type) => FullType(type)).toList()))!; + } + + @override + LocationInner deserialize( + Serializers serializers, + Object serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final result = LocationInnerBuilder(); + Object? anyOfDataSrc; + final targetType = const FullType(AnyOf, [FullType(String), FullType(int), ]); + anyOfDataSrc = serialized; + result.anyOf = serializers.deserialize(anyOfDataSrc, specifiedType: targetType) as AnyOf; + return result.build(); + } +} + diff --git a/lib/api_sub_project/src/model/location_inner.g.dart b/lib/api_sub_project/src/model/location_inner.g.dart new file mode 100644 index 0000000..0cbf218 --- /dev/null +++ b/lib/api_sub_project/src/model/location_inner.g.dart @@ -0,0 +1,93 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'location_inner.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +class _$LocationInner extends LocationInner { + @override + final AnyOf anyOf; + + factory _$LocationInner([void Function(LocationInnerBuilder)? updates]) => + (new LocationInnerBuilder()..update(updates))._build(); + + _$LocationInner._({required this.anyOf}) : super._() { + BuiltValueNullFieldError.checkNotNull(anyOf, r'LocationInner', 'anyOf'); + } + + @override + LocationInner rebuild(void Function(LocationInnerBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + LocationInnerBuilder toBuilder() => new LocationInnerBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is LocationInner && anyOf == other.anyOf; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, anyOf.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'LocationInner')..add('anyOf', anyOf)) + .toString(); + } +} + +class LocationInnerBuilder + implements Builder { + _$LocationInner? _$v; + + AnyOf? _anyOf; + AnyOf? get anyOf => _$this._anyOf; + set anyOf(AnyOf? anyOf) => _$this._anyOf = anyOf; + + LocationInnerBuilder() { + LocationInner._defaults(this); + } + + LocationInnerBuilder get _$this { + final $v = _$v; + if ($v != null) { + _anyOf = $v.anyOf; + _$v = null; + } + return this; + } + + @override + void replace(LocationInner other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$LocationInner; + } + + @override + void update(void Function(LocationInnerBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + LocationInner build() => _build(); + + _$LocationInner _build() { + final _$result = _$v ?? + new _$LocationInner._( + anyOf: BuiltValueNullFieldError.checkNotNull( + anyOf, r'LocationInner', 'anyOf')); + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/lib/api_sub_project/src/model/ok_response.dart b/lib/api_sub_project/src/model/ok_response.dart new file mode 100644 index 0000000..9450d1a --- /dev/null +++ b/lib/api_sub_project/src/model/ok_response.dart @@ -0,0 +1,109 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// + +// ignore_for_file: unused_element +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; + +part 'ok_response.g.dart'; + +/// OkResponse +/// +/// Properties: +/// * [ok] +@BuiltValue() +abstract class OkResponse implements Built { + @BuiltValueField(wireName: r'ok') + bool? get ok; + + OkResponse._(); + + factory OkResponse([void updates(OkResponseBuilder b)]) = _$OkResponse; + + @BuiltValueHook(initializeBuilder: true) + static void _defaults(OkResponseBuilder b) => b + ..ok = true; + + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$OkResponseSerializer(); +} + +class _$OkResponseSerializer implements PrimitiveSerializer { + @override + final Iterable types = const [OkResponse, _$OkResponse]; + + @override + final String wireName = r'OkResponse'; + + Iterable _serializeProperties( + Serializers serializers, + OkResponse object, { + FullType specifiedType = FullType.unspecified, + }) sync* { + if (object.ok != null) { + yield r'ok'; + yield serializers.serialize( + object.ok, + specifiedType: const FullType(bool), + ); + } + } + + @override + Object serialize( + Serializers serializers, + OkResponse object, { + FullType specifiedType = FullType.unspecified, + }) { + return _serializeProperties(serializers, object, specifiedType: specifiedType).toList(); + } + + void _deserializeProperties( + Serializers serializers, + Object serialized, { + FullType specifiedType = FullType.unspecified, + required List serializedList, + required OkResponseBuilder result, + required List unhandled, + }) { + for (var i = 0; i < serializedList.length; i += 2) { + final key = serializedList[i] as String; + final value = serializedList[i + 1]; + switch (key) { + case r'ok': + final valueDes = serializers.deserialize( + value, + specifiedType: const FullType(bool), + ) as bool; + result.ok = valueDes; + break; + default: + unhandled.add(key); + unhandled.add(value); + break; + } + } + } + + @override + OkResponse deserialize( + Serializers serializers, + Object serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final result = OkResponseBuilder(); + final serializedList = (serialized as Iterable).toList(); + final unhandled = []; + _deserializeProperties( + serializers, + serialized, + specifiedType: specifiedType, + serializedList: serializedList, + unhandled: unhandled, + result: result, + ); + return result.build(); + } +} + diff --git a/lib/api_sub_project/src/model/ok_response.g.dart b/lib/api_sub_project/src/model/ok_response.g.dart new file mode 100644 index 0000000..10a1287 --- /dev/null +++ b/lib/api_sub_project/src/model/ok_response.g.dart @@ -0,0 +1,87 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'ok_response.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +class _$OkResponse extends OkResponse { + @override + final bool? ok; + + factory _$OkResponse([void Function(OkResponseBuilder)? updates]) => + (new OkResponseBuilder()..update(updates))._build(); + + _$OkResponse._({this.ok}) : super._(); + + @override + OkResponse rebuild(void Function(OkResponseBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + OkResponseBuilder toBuilder() => new OkResponseBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is OkResponse && ok == other.ok; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, ok.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'OkResponse')..add('ok', ok)) + .toString(); + } +} + +class OkResponseBuilder implements Builder { + _$OkResponse? _$v; + + bool? _ok; + bool? get ok => _$this._ok; + set ok(bool? ok) => _$this._ok = ok; + + OkResponseBuilder() { + OkResponse._defaults(this); + } + + OkResponseBuilder get _$this { + final $v = _$v; + if ($v != null) { + _ok = $v.ok; + _$v = null; + } + return this; + } + + @override + void replace(OkResponse other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$OkResponse; + } + + @override + void update(void Function(OkResponseBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + OkResponse build() => _build(); + + _$OkResponse _build() { + final _$result = _$v ?? new _$OkResponse._(ok: ok); + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/lib/api_sub_project/src/model/table_definition.dart b/lib/api_sub_project/src/model/table_definition.dart new file mode 100644 index 0000000..0356392 --- /dev/null +++ b/lib/api_sub_project/src/model/table_definition.dart @@ -0,0 +1,170 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// + +// ignore_for_file: unused_element +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; + +part 'table_definition.g.dart'; + +/// TableDefinition +/// +/// Properties: +/// * [tableId] +/// * [tableName] +/// * [columns] +/// * [system] +/// * [hidden] +@BuiltValue() +abstract class TableDefinition implements Built { + @BuiltValueField(wireName: r'table_id') + String get tableId; + + @BuiltValueField(wireName: r'table_name') + String get tableName; + + @BuiltValueField(wireName: r'columns') + String get columns; + + @BuiltValueField(wireName: r'system') + bool get system; + + @BuiltValueField(wireName: r'hidden') + bool get hidden; + + TableDefinition._(); + + factory TableDefinition([void updates(TableDefinitionBuilder b)]) = _$TableDefinition; + + @BuiltValueHook(initializeBuilder: true) + static void _defaults(TableDefinitionBuilder b) => b; + + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$TableDefinitionSerializer(); +} + +class _$TableDefinitionSerializer implements PrimitiveSerializer { + @override + final Iterable types = const [TableDefinition, _$TableDefinition]; + + @override + final String wireName = r'TableDefinition'; + + Iterable _serializeProperties( + Serializers serializers, + TableDefinition object, { + FullType specifiedType = FullType.unspecified, + }) sync* { + yield r'table_id'; + yield serializers.serialize( + object.tableId, + specifiedType: const FullType(String), + ); + yield r'table_name'; + yield serializers.serialize( + object.tableName, + specifiedType: const FullType(String), + ); + yield r'columns'; + yield serializers.serialize( + object.columns, + specifiedType: const FullType(String), + ); + yield r'system'; + yield serializers.serialize( + object.system, + specifiedType: const FullType(bool), + ); + yield r'hidden'; + yield serializers.serialize( + object.hidden, + specifiedType: const FullType(bool), + ); + } + + @override + Object serialize( + Serializers serializers, + TableDefinition object, { + FullType specifiedType = FullType.unspecified, + }) { + return _serializeProperties(serializers, object, specifiedType: specifiedType).toList(); + } + + void _deserializeProperties( + Serializers serializers, + Object serialized, { + FullType specifiedType = FullType.unspecified, + required List serializedList, + required TableDefinitionBuilder result, + required List unhandled, + }) { + for (var i = 0; i < serializedList.length; i += 2) { + final key = serializedList[i] as String; + final value = serializedList[i + 1]; + switch (key) { + case r'table_id': + final valueDes = serializers.deserialize( + value, + specifiedType: const FullType(String), + ) as String; + result.tableId = valueDes; + break; + case r'table_name': + final valueDes = serializers.deserialize( + value, + specifiedType: const FullType(String), + ) as String; + result.tableName = valueDes; + break; + case r'columns': + final valueDes = serializers.deserialize( + value, + specifiedType: const FullType(String), + ) as String; + result.columns = valueDes; + break; + case r'system': + final valueDes = serializers.deserialize( + value, + specifiedType: const FullType(bool), + ) as bool; + result.system = valueDes; + break; + case r'hidden': + final valueDes = serializers.deserialize( + value, + specifiedType: const FullType(bool), + ) as bool; + result.hidden = valueDes; + break; + default: + unhandled.add(key); + unhandled.add(value); + break; + } + } + } + + @override + TableDefinition deserialize( + Serializers serializers, + Object serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final result = TableDefinitionBuilder(); + final serializedList = (serialized as Iterable).toList(); + final unhandled = []; + _deserializeProperties( + serializers, + serialized, + specifiedType: specifiedType, + serializedList: serializedList, + unhandled: unhandled, + result: result, + ); + return result.build(); + } +} + diff --git a/lib/api_sub_project/src/model/table_definition.g.dart b/lib/api_sub_project/src/model/table_definition.g.dart new file mode 100644 index 0000000..be971e9 --- /dev/null +++ b/lib/api_sub_project/src/model/table_definition.g.dart @@ -0,0 +1,157 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'table_definition.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +class _$TableDefinition extends TableDefinition { + @override + final String tableId; + @override + final String tableName; + @override + final String columns; + @override + final bool system; + @override + final bool hidden; + + factory _$TableDefinition([void Function(TableDefinitionBuilder)? updates]) => + (new TableDefinitionBuilder()..update(updates))._build(); + + _$TableDefinition._( + {required this.tableId, + required this.tableName, + required this.columns, + required this.system, + required this.hidden}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + tableId, r'TableDefinition', 'tableId'); + BuiltValueNullFieldError.checkNotNull( + tableName, r'TableDefinition', 'tableName'); + BuiltValueNullFieldError.checkNotNull( + columns, r'TableDefinition', 'columns'); + BuiltValueNullFieldError.checkNotNull(system, r'TableDefinition', 'system'); + BuiltValueNullFieldError.checkNotNull(hidden, r'TableDefinition', 'hidden'); + } + + @override + TableDefinition rebuild(void Function(TableDefinitionBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + TableDefinitionBuilder toBuilder() => + new TableDefinitionBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is TableDefinition && + tableId == other.tableId && + tableName == other.tableName && + columns == other.columns && + system == other.system && + hidden == other.hidden; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, tableId.hashCode); + _$hash = $jc(_$hash, tableName.hashCode); + _$hash = $jc(_$hash, columns.hashCode); + _$hash = $jc(_$hash, system.hashCode); + _$hash = $jc(_$hash, hidden.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'TableDefinition') + ..add('tableId', tableId) + ..add('tableName', tableName) + ..add('columns', columns) + ..add('system', system) + ..add('hidden', hidden)) + .toString(); + } +} + +class TableDefinitionBuilder + implements Builder { + _$TableDefinition? _$v; + + String? _tableId; + String? get tableId => _$this._tableId; + set tableId(String? tableId) => _$this._tableId = tableId; + + String? _tableName; + String? get tableName => _$this._tableName; + set tableName(String? tableName) => _$this._tableName = tableName; + + String? _columns; + String? get columns => _$this._columns; + set columns(String? columns) => _$this._columns = columns; + + bool? _system; + bool? get system => _$this._system; + set system(bool? system) => _$this._system = system; + + bool? _hidden; + bool? get hidden => _$this._hidden; + set hidden(bool? hidden) => _$this._hidden = hidden; + + TableDefinitionBuilder() { + TableDefinition._defaults(this); + } + + TableDefinitionBuilder get _$this { + final $v = _$v; + if ($v != null) { + _tableId = $v.tableId; + _tableName = $v.tableName; + _columns = $v.columns; + _system = $v.system; + _hidden = $v.hidden; + _$v = null; + } + return this; + } + + @override + void replace(TableDefinition other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$TableDefinition; + } + + @override + void update(void Function(TableDefinitionBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + TableDefinition build() => _build(); + + _$TableDefinition _build() { + final _$result = _$v ?? + new _$TableDefinition._( + tableId: BuiltValueNullFieldError.checkNotNull( + tableId, r'TableDefinition', 'tableId'), + tableName: BuiltValueNullFieldError.checkNotNull( + tableName, r'TableDefinition', 'tableName'), + columns: BuiltValueNullFieldError.checkNotNull( + columns, r'TableDefinition', 'columns'), + system: BuiltValueNullFieldError.checkNotNull( + system, r'TableDefinition', 'system'), + hidden: BuiltValueNullFieldError.checkNotNull( + hidden, r'TableDefinition', 'hidden')); + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/lib/api_sub_project/src/model/table_items_response.dart b/lib/api_sub_project/src/model/table_items_response.dart new file mode 100644 index 0000000..fabf448 --- /dev/null +++ b/lib/api_sub_project/src/model/table_items_response.dart @@ -0,0 +1,108 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// + +// ignore_for_file: unused_element +import 'package:built_collection/built_collection.dart'; +import 'package:built_value/json_object.dart'; +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; + +part 'table_items_response.g.dart'; + +/// TableItemsResponse +/// +/// Properties: +/// * [items] +@BuiltValue() +abstract class TableItemsResponse implements Built { + @BuiltValueField(wireName: r'items') + BuiltList get items; + + TableItemsResponse._(); + + factory TableItemsResponse([void updates(TableItemsResponseBuilder b)]) = _$TableItemsResponse; + + @BuiltValueHook(initializeBuilder: true) + static void _defaults(TableItemsResponseBuilder b) => b; + + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$TableItemsResponseSerializer(); +} + +class _$TableItemsResponseSerializer implements PrimitiveSerializer { + @override + final Iterable types = const [TableItemsResponse, _$TableItemsResponse]; + + @override + final String wireName = r'TableItemsResponse'; + + Iterable _serializeProperties( + Serializers serializers, + TableItemsResponse object, { + FullType specifiedType = FullType.unspecified, + }) sync* { + yield r'items'; + yield serializers.serialize( + object.items, + specifiedType: const FullType(BuiltList, [FullType(JsonObject)]), + ); + } + + @override + Object serialize( + Serializers serializers, + TableItemsResponse object, { + FullType specifiedType = FullType.unspecified, + }) { + return _serializeProperties(serializers, object, specifiedType: specifiedType).toList(); + } + + void _deserializeProperties( + Serializers serializers, + Object serialized, { + FullType specifiedType = FullType.unspecified, + required List serializedList, + required TableItemsResponseBuilder result, + required List unhandled, + }) { + for (var i = 0; i < serializedList.length; i += 2) { + final key = serializedList[i] as String; + final value = serializedList[i + 1]; + switch (key) { + case r'items': + final valueDes = serializers.deserialize( + value, + specifiedType: const FullType(BuiltList, [FullType(JsonObject)]), + ) as BuiltList; + result.items.replace(valueDes); + break; + default: + unhandled.add(key); + unhandled.add(value); + break; + } + } + } + + @override + TableItemsResponse deserialize( + Serializers serializers, + Object serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final result = TableItemsResponseBuilder(); + final serializedList = (serialized as Iterable).toList(); + final unhandled = []; + _deserializeProperties( + serializers, + serialized, + specifiedType: specifiedType, + serializedList: serializedList, + unhandled: unhandled, + result: result, + ); + return result.build(); + } +} + diff --git a/lib/api_sub_project/src/model/table_items_response.g.dart b/lib/api_sub_project/src/model/table_items_response.g.dart new file mode 100644 index 0000000..d104f56 --- /dev/null +++ b/lib/api_sub_project/src/model/table_items_response.g.dart @@ -0,0 +1,109 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'table_items_response.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +class _$TableItemsResponse extends TableItemsResponse { + @override + final BuiltList items; + + factory _$TableItemsResponse( + [void Function(TableItemsResponseBuilder)? updates]) => + (new TableItemsResponseBuilder()..update(updates))._build(); + + _$TableItemsResponse._({required this.items}) : super._() { + BuiltValueNullFieldError.checkNotNull( + items, r'TableItemsResponse', 'items'); + } + + @override + TableItemsResponse rebuild( + void Function(TableItemsResponseBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + TableItemsResponseBuilder toBuilder() => + new TableItemsResponseBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is TableItemsResponse && items == other.items; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, items.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'TableItemsResponse') + ..add('items', items)) + .toString(); + } +} + +class TableItemsResponseBuilder + implements Builder { + _$TableItemsResponse? _$v; + + ListBuilder? _items; + ListBuilder get items => + _$this._items ??= new ListBuilder(); + set items(ListBuilder? items) => _$this._items = items; + + TableItemsResponseBuilder() { + TableItemsResponse._defaults(this); + } + + TableItemsResponseBuilder get _$this { + final $v = _$v; + if ($v != null) { + _items = $v.items.toBuilder(); + _$v = null; + } + return this; + } + + @override + void replace(TableItemsResponse other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$TableItemsResponse; + } + + @override + void update(void Function(TableItemsResponseBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + TableItemsResponse build() => _build(); + + _$TableItemsResponse _build() { + _$TableItemsResponse _$result; + try { + _$result = _$v ?? new _$TableItemsResponse._(items: items.build()); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'items'; + items.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'TableItemsResponse', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/lib/api_sub_project/src/model/user_update_definition.dart b/lib/api_sub_project/src/model/user_update_definition.dart new file mode 100644 index 0000000..c1ba572 --- /dev/null +++ b/lib/api_sub_project/src/model/user_update_definition.dart @@ -0,0 +1,138 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// + +// ignore_for_file: unused_element +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; + +part 'user_update_definition.g.dart'; + +/// UserUpdateDefinition +/// +/// Properties: +/// * [userId] +/// * [password] +/// * [accessToken] +@BuiltValue() +abstract class UserUpdateDefinition implements Built { + @BuiltValueField(wireName: r'user_id') + int get userId; + + @BuiltValueField(wireName: r'password') + String get password; + + @BuiltValueField(wireName: r'access_token') + String get accessToken; + + UserUpdateDefinition._(); + + factory UserUpdateDefinition([void updates(UserUpdateDefinitionBuilder b)]) = _$UserUpdateDefinition; + + @BuiltValueHook(initializeBuilder: true) + static void _defaults(UserUpdateDefinitionBuilder b) => b; + + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$UserUpdateDefinitionSerializer(); +} + +class _$UserUpdateDefinitionSerializer implements PrimitiveSerializer { + @override + final Iterable types = const [UserUpdateDefinition, _$UserUpdateDefinition]; + + @override + final String wireName = r'UserUpdateDefinition'; + + Iterable _serializeProperties( + Serializers serializers, + UserUpdateDefinition object, { + FullType specifiedType = FullType.unspecified, + }) sync* { + yield r'user_id'; + yield serializers.serialize( + object.userId, + specifiedType: const FullType(int), + ); + yield r'password'; + yield serializers.serialize( + object.password, + specifiedType: const FullType(String), + ); + yield r'access_token'; + yield serializers.serialize( + object.accessToken, + specifiedType: const FullType(String), + ); + } + + @override + Object serialize( + Serializers serializers, + UserUpdateDefinition object, { + FullType specifiedType = FullType.unspecified, + }) { + return _serializeProperties(serializers, object, specifiedType: specifiedType).toList(); + } + + void _deserializeProperties( + Serializers serializers, + Object serialized, { + FullType specifiedType = FullType.unspecified, + required List serializedList, + required UserUpdateDefinitionBuilder result, + required List unhandled, + }) { + for (var i = 0; i < serializedList.length; i += 2) { + final key = serializedList[i] as String; + final value = serializedList[i + 1]; + switch (key) { + case r'user_id': + final valueDes = serializers.deserialize( + value, + specifiedType: const FullType(int), + ) as int; + result.userId = valueDes; + break; + case r'password': + final valueDes = serializers.deserialize( + value, + specifiedType: const FullType(String), + ) as String; + result.password = valueDes; + break; + case r'access_token': + final valueDes = serializers.deserialize( + value, + specifiedType: const FullType(String), + ) as String; + result.accessToken = valueDes; + break; + default: + unhandled.add(key); + unhandled.add(value); + break; + } + } + } + + @override + UserUpdateDefinition deserialize( + Serializers serializers, + Object serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final result = UserUpdateDefinitionBuilder(); + final serializedList = (serialized as Iterable).toList(); + final unhandled = []; + _deserializeProperties( + serializers, + serialized, + specifiedType: specifiedType, + serializedList: serializedList, + unhandled: unhandled, + result: result, + ); + return result.build(); + } +} + diff --git a/lib/api_sub_project/src/model/user_update_definition.g.dart b/lib/api_sub_project/src/model/user_update_definition.g.dart new file mode 100644 index 0000000..3db2653 --- /dev/null +++ b/lib/api_sub_project/src/model/user_update_definition.g.dart @@ -0,0 +1,129 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'user_update_definition.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +class _$UserUpdateDefinition extends UserUpdateDefinition { + @override + final int userId; + @override + final String password; + @override + final String accessToken; + + factory _$UserUpdateDefinition( + [void Function(UserUpdateDefinitionBuilder)? updates]) => + (new UserUpdateDefinitionBuilder()..update(updates))._build(); + + _$UserUpdateDefinition._( + {required this.userId, required this.password, required this.accessToken}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + userId, r'UserUpdateDefinition', 'userId'); + BuiltValueNullFieldError.checkNotNull( + password, r'UserUpdateDefinition', 'password'); + BuiltValueNullFieldError.checkNotNull( + accessToken, r'UserUpdateDefinition', 'accessToken'); + } + + @override + UserUpdateDefinition rebuild( + void Function(UserUpdateDefinitionBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + UserUpdateDefinitionBuilder toBuilder() => + new UserUpdateDefinitionBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is UserUpdateDefinition && + userId == other.userId && + password == other.password && + accessToken == other.accessToken; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, userId.hashCode); + _$hash = $jc(_$hash, password.hashCode); + _$hash = $jc(_$hash, accessToken.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'UserUpdateDefinition') + ..add('userId', userId) + ..add('password', password) + ..add('accessToken', accessToken)) + .toString(); + } +} + +class UserUpdateDefinitionBuilder + implements Builder { + _$UserUpdateDefinition? _$v; + + int? _userId; + int? get userId => _$this._userId; + set userId(int? userId) => _$this._userId = userId; + + String? _password; + String? get password => _$this._password; + set password(String? password) => _$this._password = password; + + String? _accessToken; + String? get accessToken => _$this._accessToken; + set accessToken(String? accessToken) => _$this._accessToken = accessToken; + + UserUpdateDefinitionBuilder() { + UserUpdateDefinition._defaults(this); + } + + UserUpdateDefinitionBuilder get _$this { + final $v = _$v; + if ($v != null) { + _userId = $v.userId; + _password = $v.password; + _accessToken = $v.accessToken; + _$v = null; + } + return this; + } + + @override + void replace(UserUpdateDefinition other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$UserUpdateDefinition; + } + + @override + void update(void Function(UserUpdateDefinitionBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + UserUpdateDefinition build() => _build(); + + _$UserUpdateDefinition _build() { + final _$result = _$v ?? + new _$UserUpdateDefinition._( + userId: BuiltValueNullFieldError.checkNotNull( + userId, r'UserUpdateDefinition', 'userId'), + password: BuiltValueNullFieldError.checkNotNull( + password, r'UserUpdateDefinition', 'password'), + accessToken: BuiltValueNullFieldError.checkNotNull( + accessToken, r'UserUpdateDefinition', 'accessToken')); + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/lib/api_sub_project/src/model/validation_error.dart b/lib/api_sub_project/src/model/validation_error.dart new file mode 100644 index 0000000..94c5428 --- /dev/null +++ b/lib/api_sub_project/src/model/validation_error.dart @@ -0,0 +1,145 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// + +// ignore_for_file: unused_element +import 'package:built_collection/built_collection.dart'; +import 'package:tuuli_app/api_sub_project/src/model/location_inner.dart'; +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; + +part 'validation_error.g.dart'; + +/// ValidationError +/// +/// Properties: +/// * [loc] +/// * [msg] +/// * [type] +@BuiltValue() +abstract class ValidationError + implements Built { + @BuiltValueField(wireName: r'loc') + BuiltList get loc; + + @BuiltValueField(wireName: r'msg') + String get msg; + + @BuiltValueField(wireName: r'type') + String get type; + + ValidationError._(); + + factory ValidationError([void updates(ValidationErrorBuilder b)]) = + _$ValidationError; + + @BuiltValueHook(initializeBuilder: true) + static void _defaults(ValidationErrorBuilder b) => b; + + @BuiltValueSerializer(custom: true) + static Serializer get serializer => + _$ValidationErrorSerializer(); +} + +class _$ValidationErrorSerializer + implements PrimitiveSerializer { + @override + final Iterable types = const [ValidationError, _$ValidationError]; + + @override + final String wireName = r'ValidationError'; + + Iterable _serializeProperties( + Serializers serializers, + ValidationError object, { + FullType specifiedType = FullType.unspecified, + }) sync* { + yield r'loc'; + yield serializers.serialize( + object.loc, + specifiedType: const FullType(BuiltList, [FullType(LocationInner)]), + ); + yield r'msg'; + yield serializers.serialize( + object.msg, + specifiedType: const FullType(String), + ); + yield r'type'; + yield serializers.serialize( + object.type, + specifiedType: const FullType(String), + ); + } + + @override + Object serialize( + Serializers serializers, + ValidationError object, { + FullType specifiedType = FullType.unspecified, + }) { + return _serializeProperties(serializers, object, + specifiedType: specifiedType) + .toList(); + } + + void _deserializeProperties( + Serializers serializers, + Object serialized, { + FullType specifiedType = FullType.unspecified, + required List serializedList, + required ValidationErrorBuilder result, + required List unhandled, + }) { + for (var i = 0; i < serializedList.length; i += 2) { + final key = serializedList[i] as String; + final value = serializedList[i + 1]; + switch (key) { + case r'loc': + final valueDes = serializers.deserialize( + value, + specifiedType: const FullType(BuiltList, [FullType(LocationInner)]), + ) as BuiltList; + result.loc.replace(valueDes); + break; + case r'msg': + final valueDes = serializers.deserialize( + value, + specifiedType: const FullType(String), + ) as String; + result.msg = valueDes; + break; + case r'type': + final valueDes = serializers.deserialize( + value, + specifiedType: const FullType(String), + ) as String; + result.type = valueDes; + break; + default: + unhandled.add(key); + unhandled.add(value); + break; + } + } + } + + @override + ValidationError deserialize( + Serializers serializers, + Object serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final result = ValidationErrorBuilder(); + final serializedList = (serialized as Iterable).toList(); + final unhandled = []; + _deserializeProperties( + serializers, + serialized, + specifiedType: specifiedType, + serializedList: serializedList, + unhandled: unhandled, + result: result, + ); + return result.build(); + } +} diff --git a/lib/api_sub_project/src/model/validation_error.g.dart b/lib/api_sub_project/src/model/validation_error.g.dart new file mode 100644 index 0000000..ff3d21b --- /dev/null +++ b/lib/api_sub_project/src/model/validation_error.g.dart @@ -0,0 +1,137 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'validation_error.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +class _$ValidationError extends ValidationError { + @override + final BuiltList loc; + @override + final String msg; + @override + final String type; + + factory _$ValidationError([void Function(ValidationErrorBuilder)? updates]) => + (new ValidationErrorBuilder()..update(updates))._build(); + + _$ValidationError._( + {required this.loc, required this.msg, required this.type}) + : super._() { + BuiltValueNullFieldError.checkNotNull(loc, r'ValidationError', 'loc'); + BuiltValueNullFieldError.checkNotNull(msg, r'ValidationError', 'msg'); + BuiltValueNullFieldError.checkNotNull(type, r'ValidationError', 'type'); + } + + @override + ValidationError rebuild(void Function(ValidationErrorBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + ValidationErrorBuilder toBuilder() => + new ValidationErrorBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is ValidationError && + loc == other.loc && + msg == other.msg && + type == other.type; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, loc.hashCode); + _$hash = $jc(_$hash, msg.hashCode); + _$hash = $jc(_$hash, type.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'ValidationError') + ..add('loc', loc) + ..add('msg', msg) + ..add('type', type)) + .toString(); + } +} + +class ValidationErrorBuilder + implements Builder { + _$ValidationError? _$v; + + ListBuilder? _loc; + ListBuilder get loc => + _$this._loc ??= new ListBuilder(); + set loc(ListBuilder? loc) => _$this._loc = loc; + + String? _msg; + String? get msg => _$this._msg; + set msg(String? msg) => _$this._msg = msg; + + String? _type; + String? get type => _$this._type; + set type(String? type) => _$this._type = type; + + ValidationErrorBuilder() { + ValidationError._defaults(this); + } + + ValidationErrorBuilder get _$this { + final $v = _$v; + if ($v != null) { + _loc = $v.loc.toBuilder(); + _msg = $v.msg; + _type = $v.type; + _$v = null; + } + return this; + } + + @override + void replace(ValidationError other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$ValidationError; + } + + @override + void update(void Function(ValidationErrorBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + ValidationError build() => _build(); + + _$ValidationError _build() { + _$ValidationError _$result; + try { + _$result = _$v ?? + new _$ValidationError._( + loc: loc.build(), + msg: BuiltValueNullFieldError.checkNotNull( + msg, r'ValidationError', 'msg'), + type: BuiltValueNullFieldError.checkNotNull( + type, r'ValidationError', 'type')); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'loc'; + loc.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'ValidationError', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/lib/api_sub_project/src/serializers.dart b/lib/api_sub_project/src/serializers.dart new file mode 100644 index 0000000..238151e --- /dev/null +++ b/lib/api_sub_project/src/serializers.dart @@ -0,0 +1,72 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// + +// ignore_for_file: unused_import + +import 'package:one_of_serializer/any_of_serializer.dart'; +import 'package:one_of_serializer/one_of_serializer.dart'; +import 'package:built_collection/built_collection.dart'; +import 'package:built_value/json_object.dart'; +import 'package:built_value/serializer.dart'; +import 'package:built_value/standard_json_plugin.dart'; +import 'package:built_value/iso_8601_date_time_serializer.dart'; +import 'package:tuuli_app/api_sub_project/src/date_serializer.dart'; +import 'package:tuuli_app/api_sub_project/src/model/date.dart'; + +import 'package:tuuli_app/api_sub_project/src/model/access_token_response.dart'; +import 'package:tuuli_app/api_sub_project/src/model/auth_model.dart'; +import 'package:tuuli_app/api_sub_project/src/model/body_update_item_in_table_items_table_name_post.dart'; +import 'package:tuuli_app/api_sub_project/src/model/column_condition_compat.dart'; +import 'package:tuuli_app/api_sub_project/src/model/create_asset_response.dart'; +import 'package:tuuli_app/api_sub_project/src/model/create_user_definition.dart'; +import 'package:tuuli_app/api_sub_project/src/model/error_response.dart'; +import 'package:tuuli_app/api_sub_project/src/model/http_validation_error.dart'; +import 'package:tuuli_app/api_sub_project/src/model/items_field_selector_list.dart'; +import 'package:tuuli_app/api_sub_project/src/model/location_inner.dart'; +import 'package:tuuli_app/api_sub_project/src/model/ok_response.dart'; +import 'package:tuuli_app/api_sub_project/src/model/table_definition.dart'; +import 'package:tuuli_app/api_sub_project/src/model/table_items_response.dart'; +import 'package:tuuli_app/api_sub_project/src/model/user_update_definition.dart'; +import 'package:tuuli_app/api_sub_project/src/model/validation_error.dart'; + +part 'serializers.g.dart'; + +@SerializersFor([ + AccessTokenResponse, + AuthModel, + BodyUpdateItemInTableItemsTableNamePost, + ColumnConditionCompat, + CreateAssetResponse, + CreateUserDefinition, + ErrorResponse, + HTTPValidationError, + ItemsFieldSelectorList, + LocationInner, + OkResponse, + TableDefinition, + TableItemsResponse, + UserUpdateDefinition, + ValidationError, +]) +Serializers serializers = (_$serializers.toBuilder() + ..addBuilderFactory( + const FullType(BuiltList, [FullType(ColumnConditionCompat)]), + () => ListBuilder(), + ) + ..addBuilderFactory( + const FullType(BuiltList, [FullType(String)]), + () => ListBuilder(), + ) + ..addBuilderFactory( + const FullType(BuiltList, [FullType(TableDefinition)]), + () => ListBuilder(), + ) + ..add(const OneOfSerializer()) + ..add(const AnyOfSerializer()) + ..add(const DateSerializer()) + ..add(Iso8601DateTimeSerializer())) + .build(); + +Serializers standardSerializers = + (serializers.toBuilder()..addPlugin(StandardJsonPlugin())).build(); diff --git a/lib/api_sub_project/src/serializers.g.dart b/lib/api_sub_project/src/serializers.g.dart new file mode 100644 index 0000000..2333d1c --- /dev/null +++ b/lib/api_sub_project/src/serializers.g.dart @@ -0,0 +1,48 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'serializers.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +Serializers _$serializers = (new Serializers().toBuilder() + ..add(AccessTokenResponse.serializer) + ..add(AuthModel.serializer) + ..add(BodyUpdateItemInTableItemsTableNamePost.serializer) + ..add(ColumnConditionCompat.serializer) + ..add(ColumnConditionCompatOperator_Enum.serializer) + ..add(CreateAssetResponse.serializer) + ..add(CreateUserDefinition.serializer) + ..add(ErrorResponse.serializer) + ..add(HTTPValidationError.serializer) + ..add(ItemsFieldSelectorList.serializer) + ..add(LocationInner.serializer) + ..add(OkResponse.serializer) + ..add(TableDefinition.serializer) + ..add(TableItemsResponse.serializer) + ..add(UserUpdateDefinition.serializer) + ..add(ValidationError.serializer) + ..addBuilderFactory( + const FullType(BuiltList, const [const FullType(JsonObject)]), + () => new ListBuilder()) + ..addBuilderFactory( + const FullType(BuiltList, const [const FullType(LocationInner)]), + () => new ListBuilder()) + ..addBuilderFactory( + const FullType(BuiltList, const [const FullType(String)]), + () => new ListBuilder()) + ..addBuilderFactory( + const FullType(BuiltList, const [const FullType(ValidationError)]), + () => new ListBuilder()) + ..addBuilderFactory( + const FullType( + BuiltMap, const [const FullType(String), const FullType(String)]), + () => new MapBuilder()) + ..addBuilderFactory( + const FullType( + BuiltMap, const [const FullType(String), const FullType(String)]), + () => new MapBuilder())) + .build(); + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/lib/api_sub_project/tuuli_api.dart b/lib/api_sub_project/tuuli_api.dart new file mode 100644 index 0000000..edb941b --- /dev/null +++ b/lib/api_sub_project/tuuli_api.dart @@ -0,0 +1,28 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// + +export 'package:tuuli_app/api_sub_project/src/api.dart'; +export 'package:tuuli_app/api_sub_project/src/auth/api_key_auth.dart'; +export 'package:tuuli_app/api_sub_project/src/auth/basic_auth.dart'; +export 'package:tuuli_app/api_sub_project/src/auth/oauth.dart'; +export 'package:tuuli_app/api_sub_project/src/serializers.dart'; +export 'package:tuuli_app/api_sub_project/src/model/date.dart'; + +export 'package:tuuli_app/api_sub_project/src/api/default_api.dart'; + +export 'package:tuuli_app/api_sub_project/src/model/access_token_response.dart'; +export 'package:tuuli_app/api_sub_project/src/model/auth_model.dart'; +export 'package:tuuli_app/api_sub_project/src/model/body_update_item_in_table_items_table_name_post.dart'; +export 'package:tuuli_app/api_sub_project/src/model/column_condition_compat.dart'; +export 'package:tuuli_app/api_sub_project/src/model/create_asset_response.dart'; +export 'package:tuuli_app/api_sub_project/src/model/create_user_definition.dart'; +export 'package:tuuli_app/api_sub_project/src/model/error_response.dart'; +export 'package:tuuli_app/api_sub_project/src/model/http_validation_error.dart'; +export 'package:tuuli_app/api_sub_project/src/model/items_field_selector_list.dart'; +export 'package:tuuli_app/api_sub_project/src/model/location_inner.dart'; +export 'package:tuuli_app/api_sub_project/src/model/ok_response.dart'; +export 'package:tuuli_app/api_sub_project/src/model/table_definition.dart'; +export 'package:tuuli_app/api_sub_project/src/model/table_items_response.dart'; +export 'package:tuuli_app/api_sub_project/src/model/user_update_definition.dart'; +export 'package:tuuli_app/api_sub_project/src/model/validation_error.dart'; diff --git a/pubspec.lock b/pubspec.lock index 3de30a5..bdceca6 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,6 +1,22 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + _fe_analyzer_shared: + dependency: transitive + description: + name: _fe_analyzer_shared + sha256: a36ec4843dc30ea6bf652bf25e3448db6c5e8bcf4aa55f063a5d1dad216d8214 + url: "https://pub.dev" + source: hosted + version: "58.0.0" + analyzer: + dependency: transitive + description: + name: analyzer + sha256: cc4242565347e98424ce9945c819c192ec0838cb9d1f6aa4a97cc96becbc5b27 + url: "https://pub.dev" + source: hosted + version: "5.10.0" animated_background: dependency: "direct main" description: @@ -9,6 +25,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.0" + args: + dependency: transitive + description: + name: args + sha256: "4cab82a83ffef80b262ddedf47a0a8e56ee6fbf7fe21e6e768b02792034dd440" + url: "https://pub.dev" + source: hosted + version: "2.4.0" async: dependency: transitive description: @@ -41,6 +65,78 @@ packages: url: "https://pub.dev" source: hosted version: "3.1.2" + build: + dependency: transitive + description: + name: build + sha256: "3fbda25365741f8251b39f3917fb3c8e286a96fd068a5a242e11c2012d495777" + url: "https://pub.dev" + source: hosted + version: "2.3.1" + build_config: + dependency: transitive + description: + name: build_config + sha256: bf80fcfb46a29945b423bd9aad884590fb1dc69b330a4d4700cac476af1708d1 + url: "https://pub.dev" + source: hosted + version: "1.1.1" + build_daemon: + dependency: transitive + description: + name: build_daemon + sha256: "5f02d73eb2ba16483e693f80bee4f088563a820e47d1027d4cdfe62b5bb43e65" + url: "https://pub.dev" + source: hosted + version: "4.0.0" + build_resolvers: + dependency: transitive + description: + name: build_resolvers + sha256: db49b8609ef8c81cca2b310618c3017c00f03a92af44c04d310b907b2d692d95 + url: "https://pub.dev" + source: hosted + version: "2.2.0" + build_runner: + dependency: "direct dev" + description: + name: build_runner + sha256: "7b25ba738bc74c94187cebeb9cc29d38a32e8279ce950eabd821d3b454a5f03d" + url: "https://pub.dev" + source: hosted + version: "2.4.1" + build_runner_core: + dependency: transitive + description: + name: build_runner_core + sha256: "14febe0f5bac5ae474117a36099b4de6f1dbc52df6c5e55534b3da9591bf4292" + url: "https://pub.dev" + source: hosted + version: "7.2.7" + built_collection: + dependency: "direct main" + description: + name: built_collection + sha256: "376e3dd27b51ea877c28d525560790aee2e6fbb5f20e2f85d5081027d94e2100" + url: "https://pub.dev" + source: hosted + version: "5.1.1" + built_value: + dependency: "direct main" + description: + name: built_value + sha256: "31b7c748fd4b9adf8d25d72a4c4a59ef119f12876cf414f94f8af5131d5fa2b0" + url: "https://pub.dev" + source: hosted + version: "8.4.4" + built_value_generator: + dependency: "direct dev" + description: + name: built_value_generator + sha256: "6c7d31060667a309889e45fd86fcaec6477750d767cf32a7f7ce4b1578d3440c" + url: "https://pub.dev" + source: hosted + version: "8.4.4" characters: dependency: transitive description: @@ -49,6 +145,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.0" + checked_yaml: + dependency: transitive + description: + name: checked_yaml + sha256: "3d1505d91afa809d177efd4eed5bb0eb65805097a1463abdd2add076effae311" + url: "https://pub.dev" + source: hosted + version: "2.0.2" clock: dependency: transitive description: @@ -57,6 +161,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.1.1" + code_builder: + dependency: transitive + description: + name: code_builder + sha256: "0d43dd1288fd145de1ecc9a3948ad4a6d5a82f0a14c4fdd0892260787d975cbe" + url: "https://pub.dev" + source: hosted + version: "4.4.0" collection: dependency: transitive description: @@ -65,6 +177,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.17.1" + convert: + dependency: transitive + description: + name: convert + sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" + url: "https://pub.dev" + source: hosted + version: "3.1.1" crypto: dependency: transitive description: @@ -73,6 +193,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.2" + dart_style: + dependency: transitive + description: + name: dart_style + sha256: "6d691edde054969f0e0f26abb1b30834b5138b963793e56f69d3a9a4435e6352" + url: "https://pub.dev" + source: hosted + version: "2.3.0" data_table_2: dependency: "direct main" description: @@ -81,6 +209,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.4.2" + dio: + dependency: "direct main" + description: + name: dio + sha256: "0894a098594263fe1caaba3520e3016d8a855caeb010a882273189cca10f11e9" + url: "https://pub.dev" + source: hosted + version: "5.1.1" fake_async: dependency: transitive description: @@ -105,6 +241,14 @@ packages: url: "https://pub.dev" source: hosted version: "6.1.4" + fixnum: + dependency: transitive + description: + name: fixnum + sha256: "25517a4deb0c03aa0f32fd12db525856438902d9c16536311e76cdc57b31d7d1" + url: "https://pub.dev" + source: hosted + version: "1.1.0" flutter: dependency: "direct main" description: flutter @@ -131,6 +275,14 @@ packages: description: flutter source: sdk version: "0.0.0" + frontend_server_client: + dependency: transitive + description: + name: frontend_server_client + sha256: "408e3ca148b31c20282ad6f37ebfa6f4bdc8fede5b74bc2f08d9d92b55db3612" + url: "https://pub.dev" + source: hosted + version: "3.2.0" get: dependency: "direct main" description: @@ -147,6 +299,22 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.1" + glob: + dependency: transitive + description: + name: glob + sha256: "4515b5b6ddb505ebdd242a5f2cc5d22d3d6a80013789debfbda7777f47ea308c" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + graphs: + dependency: transitive + description: + name: graphs + sha256: f9e130f3259f52d26f0cfc0e964513796dafed572fa52e45d2f8d6ca14db39b2 + url: "https://pub.dev" + source: hosted + version: "2.2.0" http: dependency: "direct main" description: @@ -155,6 +323,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.13.5" + http_multi_server: + dependency: transitive + description: + name: http_multi_server + sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b" + url: "https://pub.dev" + source: hosted + version: "3.2.1" http_parser: dependency: transitive description: @@ -171,6 +347,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.18.0" + io: + dependency: transitive + description: + name: io + sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e" + url: "https://pub.dev" + source: hosted + version: "1.0.4" js: dependency: transitive description: @@ -179,6 +363,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.6.7" + json_annotation: + dependency: transitive + description: + name: json_annotation + sha256: c33da08e136c3df0190bd5bbe51ae1df4a7d96e7954d1d7249fea2968a72d317 + url: "https://pub.dev" + source: hosted + version: "4.8.0" lints: dependency: transitive description: @@ -187,6 +379,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.1" + logging: + dependency: transitive + description: + name: logging + sha256: "04094f2eb032cbb06c6f6e8d3607edcfcb0455e2bb6cbc010cb01171dcb64e6d" + url: "https://pub.dev" + source: hosted + version: "1.1.1" matcher: dependency: transitive description: @@ -211,6 +411,38 @@ packages: url: "https://pub.dev" source: hosted version: "1.9.0" + mime: + dependency: transitive + description: + name: mime + sha256: e4ff8e8564c03f255408decd16e7899da1733852a9110a58fe6d1b817684a63e + url: "https://pub.dev" + source: hosted + version: "1.0.4" + one_of: + dependency: transitive + description: + name: one_of + sha256: "25fe0fcf181e761c6fcd604caf9d5fdf952321be17584ba81c72c06bdaa511f0" + url: "https://pub.dev" + source: hosted + version: "1.5.0" + one_of_serializer: + dependency: "direct main" + description: + name: one_of_serializer + sha256: "3f3dfb5c1578ba3afef1cb47fcc49e585e797af3f2b6c2cc7ed90aad0c5e7b83" + url: "https://pub.dev" + source: hosted + version: "1.5.0" + package_config: + dependency: transitive + description: + name: package_config + sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd" + url: "https://pub.dev" + source: hosted + version: "2.1.0" path: dependency: transitive description: @@ -283,6 +515,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" + pool: + dependency: transitive + description: + name: pool + sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a" + url: "https://pub.dev" + source: hosted + version: "1.5.1" process: dependency: transitive description: @@ -291,6 +531,30 @@ packages: url: "https://pub.dev" source: hosted version: "4.2.4" + pub_semver: + dependency: transitive + description: + name: pub_semver + sha256: "307de764d305289ff24ad257ad5c5793ce56d04947599ad68b3baa124105fc17" + url: "https://pub.dev" + source: hosted + version: "2.1.3" + pubspec_parse: + dependency: transitive + description: + name: pubspec_parse + sha256: ec85d7d55339d85f44ec2b682a82fea340071e8978257e5a43e69f79e98ef50c + url: "https://pub.dev" + source: hosted + version: "1.2.2" + quiver: + dependency: transitive + description: + name: quiver + sha256: b1c1ac5ce6688d77f65f3375a9abb9319b3cb32486bdc7a1e0fdf004d7ba4e47 + url: "https://pub.dev" + source: hosted + version: "3.2.1" recase: dependency: "direct main" description: @@ -299,11 +563,35 @@ packages: url: "https://pub.dev" source: hosted version: "4.1.0" + shelf: + dependency: transitive + description: + name: shelf + sha256: c24a96135a2ccd62c64b69315a14adc5c3419df63b4d7c05832a346fdb73682c + url: "https://pub.dev" + source: hosted + version: "1.4.0" + shelf_web_socket: + dependency: transitive + description: + name: shelf_web_socket + sha256: a988c0e8d8ffbdb8a28aa7ec8e449c260f3deb808781fe1284d22c5bba7156e8 + url: "https://pub.dev" + source: hosted + version: "1.0.3" sky_engine: dependency: transitive description: flutter source: sdk version: "0.0.99" + source_gen: + dependency: transitive + description: + name: source_gen + sha256: c2bea18c95cfa0276a366270afaa2850b09b4a76db95d546f3d003dcc7011298 + url: "https://pub.dev" + source: hosted + version: "1.2.7" source_span: dependency: transitive description: @@ -328,6 +616,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.1" + stream_transform: + dependency: transitive + description: + name: stream_transform + sha256: "14a00e794c7c11aa145a170587321aedce29769c08d7f58b1d141da75e3b1c6f" + url: "https://pub.dev" + source: hosted + version: "2.1.0" string_scanner: dependency: transitive description: @@ -352,6 +648,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.4.18" + timing: + dependency: transitive + description: + name: timing + sha256: "70a3b636575d4163c477e6de42f247a23b315ae20e86442bebe32d3cabf61c32" + url: "https://pub.dev" + source: hosted + version: "1.0.1" typed_data: dependency: transitive description: @@ -376,6 +680,22 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" + watcher: + dependency: transitive + description: + name: watcher + sha256: "6a7f46926b01ce81bfc339da6a7f20afbe7733eff9846f6d6a5466aa4c6667c0" + url: "https://pub.dev" + source: hosted + version: "1.0.2" + web_socket_channel: + dependency: transitive + description: + name: web_socket_channel + sha256: d88238e5eac9a42bb43ca4e721edba3c08c6354d4a53063afaa568516217621b + url: "https://pub.dev" + source: hosted + version: "2.4.0" win32: dependency: transitive description: @@ -392,6 +712,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.0" + yaml: + dependency: transitive + description: + name: yaml + sha256: "23812a9b125b48d4007117254bca50abb6c712352927eece9e155207b1db2370" + url: "https://pub.dev" + source: hosted + version: "3.1.1" sdks: dart: ">=3.0.0-322.0.dev <4.0.0" flutter: ">=3.7.0" diff --git a/pubspec.yaml b/pubspec.yaml index 3441758..d1c368d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -12,17 +12,24 @@ dependencies: animated_background: ^2.0.0 bottom_sheet: ^3.1.2 + built_collection: ^5.1.1 + built_value: ^8.4.4 data_table_2: ^2.4.2 + dio: ^5.1.1 flutter_fast_forms: ^10.0.0 get: ^4.6.5 get_storage: ^2.1.1 http: ^0.13.5 + one_of_serializer: ^1.5.0 recase: ^4.1.0 uuid: ^3.0.7 dev_dependencies: flutter_test: sdk: flutter + + build_runner: ^2.3.3 + built_value_generator: ^8.4.4 flutter_lints: ^2.0.0 flutter: -- 2.47.3 From 67e14ea836eb10c99f2dac30e2392dac8e7d2104 Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Mon, 24 Apr 2023 11:03:52 +0700 Subject: [PATCH 02/28] ApiController for api-related stuff --- lib/api_controller.dart | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 lib/api_controller.dart diff --git a/lib/api_controller.dart b/lib/api_controller.dart new file mode 100644 index 0000000..ce8b5ad --- /dev/null +++ b/lib/api_controller.dart @@ -0,0 +1,35 @@ +import 'package:dio/dio.dart'; +import 'package:get/get.dart'; +import 'package:get_storage/get_storage.dart'; +import 'package:tuuli_api/tuuli_api.dart'; + +class ApiController extends GetxController { + static ApiController get to => Get.find(); + + final apiStorageBox = GetStorage(); + + final _endPoint = "http://127.0.0.1:8000".obs; + String get endPoint => _endPoint.value; + set endPoint(String value) => _endPoint.value = value; + + String get token => apiStorageBox.read("accessToken") ?? ""; + set token(String value) => apiStorageBox.write("accessToken", value); + + TuuliApi? _apiClientBase; + TuuliApi get apiClientBase { + _apiClientBase ??= TuuliApi( + dio: Dio(BaseOptions( + baseUrl: endPoint, + connectTimeout: 5000.milliseconds, + receiveTimeout: 3000.milliseconds, + receiveDataWhenStatusError: true, + )), + ); + _apiClientBase!.setApiKey("access-token", token); + return _apiClientBase!; + } + + DefaultApi get apiClient { + return apiClientBase.getDefaultApi(); + } +} -- 2.47.3 From 24f4d7de2bdb0c8e7af14d4b6744848875dd7842 Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Mon, 24 Apr 2023 11:04:27 +0700 Subject: [PATCH 03/28] Login page working --- lib/main.dart | 27 ++++---- lib/pages/login_page.dart | 141 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 151 insertions(+), 17 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index ac54169..36f676d 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,26 +1,29 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:get_storage/get_storage.dart'; -import 'package:tuuli_app/api/api_client.dart'; +import 'package:tuuli_app/api_controller.dart'; import 'package:tuuli_app/pages/checkup_page.dart'; import 'package:tuuli_app/pages/home_page.dart'; +import 'package:tuuli_app/pages/home_panels/tables_list_panel.dart'; +import 'package:tuuli_app/pages/home_panels/users_list_panel.dart'; import 'package:tuuli_app/pages/login_page.dart'; import 'package:tuuli_app/pages/not_found_page.dart'; void main() async { await GetStorage.init(); - Get.put( - ApiClient.fromString("http://127.0.0.1:8000"), - permanent: true, - builder: () { - final client = ApiClient.fromString("http://127.0.0.1:8000"); - final accessToken = GetStorage().read("accessToken"); - if (accessToken != null) { - client.setAccessToken(accessToken); - } - return client; - }, + Get.put(ApiController(), permanent: true); + Get.lazyPut( + () => CheckupPageController(), + fenix: true, + ); + Get.lazyPut( + () => LoginPageController(), + fenix: true, + ); + Get.lazyPut( + () => HomePageController(), + fenix: true, ); runApp(const MainApp()); diff --git a/lib/pages/login_page.dart b/lib/pages/login_page.dart index 98a0f67..ebdfc94 100644 --- a/lib/pages/login_page.dart +++ b/lib/pages/login_page.dart @@ -3,9 +3,139 @@ import 'dart:async'; import 'package:animated_background/animated_background.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; -import 'package:get_storage/get_storage.dart'; -import 'package:tuuli_app/api/api_client.dart'; +import 'package:tuuli_api/tuuli_api.dart'; +import 'package:tuuli_app/api_controller.dart'; +class LoginPageController extends GetxController + with GetSingleTickerProviderStateMixin { + final _login = "".obs; + String get login => _login.value; + set login(String value) => _login.value = value; + + final _password = "".obs; + String get password => _password.value; + set password(String value) => _password.value = value; + + final _submitted = false.obs; + bool get submitted => _submitted.value; + set submitted(bool value) => _submitted.value = value; + + bool get isFormValid => login.isNotEmpty && password.isNotEmpty; + + Future submitForm() async { + submitted = true; + if (isFormValid) { + final amb = AuthModelBuilder() + ..username = login + ..password = password; + + try { + final resp = await ApiController.to.apiClient + .getAccessTokenApiGetAccessTokenPost(authModel: amb.build()); + + final respData = resp.data; + if (resp.statusCode == 200 && respData != null) { + final accessToken = respData.accessToken; + Get.find().token = accessToken; + Get.offAllNamed("/home"); + } else { + Get.snackbar( + "Login failed", + resp.statusMessage ?? "Unknown error", + ); + } + } catch (e) { + Get.snackbar( + "Login failed", + "$e", + ); + } + } + submitted = false; + } +} + +class LoginPage extends GetView { + const LoginPage({super.key}); + + @override + Widget build(BuildContext context) { + final screenSize = Get.mediaQuery.size; + final formWidth = screenSize.width <= 600 ? screenSize.width : 300.0; + return Scaffold( + body: Stack( + children: [ + AnimatedBackground( + behaviour: RandomParticleBehaviour(), + vsync: controller, + child: const SizedBox.square( + dimension: 0, + ), + ), + Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + LimitedBox( + maxWidth: formWidth, + child: Obx( + () => Container( + color: Colors.black.withAlpha(100), + padding: const EdgeInsets.all(16), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + TextFormField( + enabled: !controller.submitted, + decoration: const InputDecoration( + labelText: 'Login', + hintText: 'Enter your login', + ), + onChanged: (value) => controller.login = value, + validator: (value) { + if (value == null || value.isEmpty) { + return 'Please enter your Login'; + } + return null; + }, + ), + TextFormField( + obscureText: true, + enabled: !controller.submitted, + decoration: const InputDecoration( + labelText: 'Password', + hintText: 'Enter your password', + ), + onChanged: (value) => controller.password = value, + validator: (value) { + if (value == null || value.isEmpty) { + return 'Please enter your password'; + } + return null; + }, + ), + const SizedBox(height: 16), + ElevatedButton( + onPressed: controller.submitted + ? null + : () => controller.submitForm(), + child: const Text('Login'), + ), + ], + ), + ), + ), + ), + ], + ), + ], + ), + ); + } +} +/* class LoginPage extends StatefulWidget { const LoginPage({super.key}); @@ -19,7 +149,7 @@ class _LoginPageState extends State with TickerProviderStateMixin { final apiClient = Get.find(); var submitted = false; - final loginController = TextEditingController(); + final loginPageController = TextEditingController(); final passwordController = TextEditingController(); @override @@ -53,7 +183,7 @@ class _LoginPageState extends State with TickerProviderStateMixin { crossAxisAlignment: CrossAxisAlignment.stretch, children: [ TextFormField( - controller: loginController, + controller: loginPageController, enabled: !submitted, decoration: const InputDecoration( labelText: 'Login', @@ -113,7 +243,7 @@ class _LoginPageState extends State with TickerProviderStateMixin { ); final response = await apiClient.login( - loginController.text.trim(), + loginPageController.text.trim(), passwordController.text.trim(), ); response.unfold((data) { @@ -148,3 +278,4 @@ class _LoginPageState extends State with TickerProviderStateMixin { }); } } +*/ \ No newline at end of file -- 2.47.3 From 2203913e1a8d56c00f2876cf42923a47ed16a33a Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Mon, 24 Apr 2023 11:06:27 +0700 Subject: [PATCH 04/28] Intended way: api client in another package --- lib/api_sub_project/src/api.dart | 84 - lib/api_sub_project/src/api/default_api.dart | 1404 ----------------- lib/api_sub_project/src/api_util.dart | 77 - .../src/auth/api_key_auth.dart | 30 - lib/api_sub_project/src/auth/auth.dart | 18 - lib/api_sub_project/src/auth/basic_auth.dart | 42 - lib/api_sub_project/src/auth/bearer_auth.dart | 27 - lib/api_sub_project/src/auth/oauth.dart | 27 - lib/api_sub_project/src/date_serializer.dart | 30 - .../src/model/access_token_response.dart | 106 -- .../src/model/access_token_response.g.dart | 98 -- lib/api_sub_project/src/model/auth_model.dart | 122 -- .../src/model/auth_model.g.dart | 107 -- ...e_item_in_table_items_table_name_post.dart | 123 -- ...item_in_table_items_table_name_post.g.dart | 139 -- .../src/model/column_condition_compat.dart | 179 --- .../src/model/column_condition_compat.g.dart | 267 ---- .../src/model/create_asset_response.dart | 125 -- .../src/model/create_asset_response.g.dart | 107 -- .../src/model/create_user_definition.dart | 122 -- .../src/model/create_user_definition.g.dart | 114 -- lib/api_sub_project/src/model/date.dart | 70 - .../src/model/error_response.dart | 106 -- .../src/model/error_response.g.dart | 93 -- .../src/model/http_validation_error.dart | 119 -- .../src/model/http_validation_error.g.dart | 106 -- .../src/model/items_field_selector_list.dart | 110 -- .../model/items_field_selector_list.g.dart | 107 -- .../src/model/location_inner.dart | 68 - .../src/model/location_inner.g.dart | 93 -- .../src/model/ok_response.dart | 109 -- .../src/model/ok_response.g.dart | 87 - .../src/model/table_definition.dart | 170 -- .../src/model/table_definition.g.dart | 157 -- .../src/model/table_items_response.dart | 108 -- .../src/model/table_items_response.g.dart | 109 -- .../src/model/user_update_definition.dart | 138 -- .../src/model/user_update_definition.g.dart | 129 -- .../src/model/validation_error.dart | 145 -- .../src/model/validation_error.g.dart | 137 -- lib/api_sub_project/src/serializers.dart | 72 - lib/api_sub_project/src/serializers.g.dart | 48 - lib/api_sub_project/tuuli_api.dart | 28 - 43 files changed, 5657 deletions(-) delete mode 100644 lib/api_sub_project/src/api.dart delete mode 100644 lib/api_sub_project/src/api/default_api.dart delete mode 100644 lib/api_sub_project/src/api_util.dart delete mode 100644 lib/api_sub_project/src/auth/api_key_auth.dart delete mode 100644 lib/api_sub_project/src/auth/auth.dart delete mode 100644 lib/api_sub_project/src/auth/basic_auth.dart delete mode 100644 lib/api_sub_project/src/auth/bearer_auth.dart delete mode 100644 lib/api_sub_project/src/auth/oauth.dart delete mode 100644 lib/api_sub_project/src/date_serializer.dart delete mode 100644 lib/api_sub_project/src/model/access_token_response.dart delete mode 100644 lib/api_sub_project/src/model/access_token_response.g.dart delete mode 100644 lib/api_sub_project/src/model/auth_model.dart delete mode 100644 lib/api_sub_project/src/model/auth_model.g.dart delete mode 100644 lib/api_sub_project/src/model/body_update_item_in_table_items_table_name_post.dart delete mode 100644 lib/api_sub_project/src/model/body_update_item_in_table_items_table_name_post.g.dart delete mode 100644 lib/api_sub_project/src/model/column_condition_compat.dart delete mode 100644 lib/api_sub_project/src/model/column_condition_compat.g.dart delete mode 100644 lib/api_sub_project/src/model/create_asset_response.dart delete mode 100644 lib/api_sub_project/src/model/create_asset_response.g.dart delete mode 100644 lib/api_sub_project/src/model/create_user_definition.dart delete mode 100644 lib/api_sub_project/src/model/create_user_definition.g.dart delete mode 100644 lib/api_sub_project/src/model/date.dart delete mode 100644 lib/api_sub_project/src/model/error_response.dart delete mode 100644 lib/api_sub_project/src/model/error_response.g.dart delete mode 100644 lib/api_sub_project/src/model/http_validation_error.dart delete mode 100644 lib/api_sub_project/src/model/http_validation_error.g.dart delete mode 100644 lib/api_sub_project/src/model/items_field_selector_list.dart delete mode 100644 lib/api_sub_project/src/model/items_field_selector_list.g.dart delete mode 100644 lib/api_sub_project/src/model/location_inner.dart delete mode 100644 lib/api_sub_project/src/model/location_inner.g.dart delete mode 100644 lib/api_sub_project/src/model/ok_response.dart delete mode 100644 lib/api_sub_project/src/model/ok_response.g.dart delete mode 100644 lib/api_sub_project/src/model/table_definition.dart delete mode 100644 lib/api_sub_project/src/model/table_definition.g.dart delete mode 100644 lib/api_sub_project/src/model/table_items_response.dart delete mode 100644 lib/api_sub_project/src/model/table_items_response.g.dart delete mode 100644 lib/api_sub_project/src/model/user_update_definition.dart delete mode 100644 lib/api_sub_project/src/model/user_update_definition.g.dart delete mode 100644 lib/api_sub_project/src/model/validation_error.dart delete mode 100644 lib/api_sub_project/src/model/validation_error.g.dart delete mode 100644 lib/api_sub_project/src/serializers.dart delete mode 100644 lib/api_sub_project/src/serializers.g.dart delete mode 100644 lib/api_sub_project/tuuli_api.dart diff --git a/lib/api_sub_project/src/api.dart b/lib/api_sub_project/src/api.dart deleted file mode 100644 index 791949e..0000000 --- a/lib/api_sub_project/src/api.dart +++ /dev/null @@ -1,84 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// - -import 'package:dio/dio.dart'; -import 'package:built_value/serializer.dart'; -import 'package:tuuli_app/api_sub_project/src/serializers.dart'; -import 'package:tuuli_app/api_sub_project/src/auth/api_key_auth.dart'; -import 'package:tuuli_app/api_sub_project/src/auth/basic_auth.dart'; -import 'package:tuuli_app/api_sub_project/src/auth/bearer_auth.dart'; -import 'package:tuuli_app/api_sub_project/src/auth/oauth.dart'; -import 'package:tuuli_app/api_sub_project/src/api/default_api.dart'; - -class TuuliApi { - static const String basePath = r'http://localhost'; - - final Dio dio; - final Serializers serializers; - - TuuliApi({ - Dio? dio, - Serializers? serializers, - String? basePathOverride, - List? interceptors, - }) : this.serializers = serializers ?? standardSerializers, - this.dio = dio ?? - Dio(BaseOptions( - baseUrl: basePathOverride ?? basePath, - connectTimeout: const Duration(milliseconds: 5000), - receiveTimeout: const Duration(milliseconds: 3000), - )) { - if (interceptors == null) { - this.dio.interceptors.addAll([ - OAuthInterceptor(), - BasicAuthInterceptor(), - BearerAuthInterceptor(), - ApiKeyAuthInterceptor(), - ]); - } else { - this.dio.interceptors.addAll(interceptors); - } - } - - void setOAuthToken(String name, String token) { - if (this.dio.interceptors.any((i) => i is OAuthInterceptor)) { - (this.dio.interceptors.firstWhere((i) => i is OAuthInterceptor) - as OAuthInterceptor) - .tokens[name] = token; - } - } - - void setBearerAuth(String name, String token) { - if (this.dio.interceptors.any((i) => i is BearerAuthInterceptor)) { - (this.dio.interceptors.firstWhere((i) => i is BearerAuthInterceptor) - as BearerAuthInterceptor) - .tokens[name] = token; - } - } - - void setBasicAuth(String name, String username, String password) { - if (this.dio.interceptors.any((i) => i is BasicAuthInterceptor)) { - (this.dio.interceptors.firstWhere((i) => i is BasicAuthInterceptor) - as BasicAuthInterceptor) - .authInfo[name] = BasicAuthInfo(username, password); - } - } - - void setApiKey(String name, String apiKey) { - if (this.dio.interceptors.any((i) => i is ApiKeyAuthInterceptor)) { - (this - .dio - .interceptors - .firstWhere((element) => element is ApiKeyAuthInterceptor) - as ApiKeyAuthInterceptor) - .apiKeys[name] = apiKey; - } - } - - /// Get DefaultApi instance, base route and serializer can be overridden by a given but be careful, - /// by doing that all interceptors will not be executed - DefaultApi getDefaultApi() { - return DefaultApi(dio, serializers); - } -} diff --git a/lib/api_sub_project/src/api/default_api.dart b/lib/api_sub_project/src/api/default_api.dart deleted file mode 100644 index fa09278..0000000 --- a/lib/api_sub_project/src/api/default_api.dart +++ /dev/null @@ -1,1404 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// - -import 'dart:async'; - -import 'package:built_value/serializer.dart'; -import 'package:dio/dio.dart'; - -import 'package:built_collection/built_collection.dart'; -import 'package:built_value/json_object.dart'; -import 'package:tuuli_app/api_sub_project/src/api_util.dart'; -import 'package:tuuli_app/api_sub_project/src/model/access_token_response.dart'; -import 'package:tuuli_app/api_sub_project/src/model/auth_model.dart'; -import 'package:tuuli_app/api_sub_project/src/model/body_update_item_in_table_items_table_name_post.dart'; -import 'package:tuuli_app/api_sub_project/src/model/column_condition_compat.dart'; -import 'package:tuuli_app/api_sub_project/src/model/create_asset_response.dart'; -import 'package:tuuli_app/api_sub_project/src/model/create_user_definition.dart'; -import 'package:tuuli_app/api_sub_project/src/model/error_response.dart'; -import 'package:tuuli_app/api_sub_project/src/model/http_validation_error.dart'; -import 'package:tuuli_app/api_sub_project/src/model/items_field_selector_list.dart'; -import 'package:tuuli_app/api_sub_project/src/model/ok_response.dart'; -import 'package:tuuli_app/api_sub_project/src/model/table_definition.dart'; -import 'package:tuuli_app/api_sub_project/src/model/table_items_response.dart'; -import 'package:tuuli_app/api_sub_project/src/model/user_update_definition.dart'; - -class DefaultApi { - final Dio _dio; - - final Serializers _serializers; - - const DefaultApi(this._dio, this._serializers); - - /// Create Item - /// - /// - /// Parameters: - /// * [tableName] - /// * [body] - /// * [accessToken] - /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation - /// * [headers] - Can be used to add additional headers to the request - /// * [extras] - Can be used to add flags to the request - /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response - /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress - /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress - /// - /// Returns a [Future] containing a [Response] with a [OkResponse] as data - /// Throws [DioError] if API call or serialization fails - Future> createItemItemsTableNamePost({ - required String tableName, - required JsonObject body, - String? accessToken, - CancelToken? cancelToken, - Map? headers, - Map? extra, - ValidateStatus? validateStatus, - ProgressCallback? onSendProgress, - ProgressCallback? onReceiveProgress, - }) async { - final _path = r'/items/{tableName}/+' - .replaceAll('{' r'tableName' '}', tableName.toString()); - final _options = Options( - method: r'POST', - headers: { - if (accessToken != null) r'access-token': accessToken, - ...?headers, - }, - extra: { - 'secure': >[], - ...?extra, - }, - contentType: 'application/json', - validateStatus: validateStatus, - ); - - dynamic _bodyData; - - try { - _bodyData = body; - } catch (error, stackTrace) { - throw DioError( - requestOptions: _options.compose( - _dio.options, - _path, - ), - type: DioErrorType.unknown, - error: error, - stackTrace: stackTrace, - ); - } - - final _response = await _dio.request( - _path, - data: _bodyData, - options: _options, - cancelToken: cancelToken, - onSendProgress: onSendProgress, - onReceiveProgress: onReceiveProgress, - ); - - OkResponse _responseData; - - try { - const _responseType = FullType(OkResponse); - _responseData = _serializers.deserialize( - _response.data!, - specifiedType: _responseType, - ) as OkResponse; - } catch (error, stackTrace) { - throw DioError( - requestOptions: _response.requestOptions, - response: _response, - type: DioErrorType.unknown, - error: error, - stackTrace: stackTrace, - ); - } - - return Response( - data: _responseData, - headers: _response.headers, - isRedirect: _response.isRedirect, - requestOptions: _response.requestOptions, - redirects: _response.redirects, - statusCode: _response.statusCode, - statusMessage: _response.statusMessage, - extra: _response.extra, - ); - } - - /// Create Table - /// Parameter `columns` should be a list of strings Each string should be in a following format: `column_name:column_type[:column_options]` Where *column_type* should be one of the following: - serial - str - bool - datetime - float - int - int:asset - int:user Also *column_options* can be one of the following: - unique - default Example: ```json [ \"id:serial:primary\", \"name:str:unique\", \"description:str\", \"is_active:bool\", \"price:float\", \"quantity:int\", \"creator_id:int:user\", \"asset_id:int:asset\" ] ``` Notes: 1. you cannot use *unique* and *default* at the same time 2. in current implementation you cannot use *default*, because there is no way to specify default value - /// - /// Parameters: - /// * [tableName] - /// * [requestBody] - /// * [accessToken] - /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation - /// * [headers] - Can be used to add additional headers to the request - /// * [extras] - Can be used to add flags to the request - /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response - /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress - /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress - /// - /// Returns a [Future] containing a [Response] with a [OkResponse] as data - /// Throws [DioError] if API call or serialization fails - Future> createTableApiCreateTableTableNamePost({ - required String tableName, - required BuiltList requestBody, - String? accessToken, - CancelToken? cancelToken, - Map? headers, - Map? extra, - ValidateStatus? validateStatus, - ProgressCallback? onSendProgress, - ProgressCallback? onReceiveProgress, - }) async { - final _path = r'/api/createTable/{tableName}' - .replaceAll('{' r'tableName' '}', tableName.toString()); - final _options = Options( - method: r'POST', - headers: { - if (accessToken != null) r'access-token': accessToken, - ...?headers, - }, - extra: { - 'secure': >[], - ...?extra, - }, - contentType: 'application/json', - validateStatus: validateStatus, - ); - - dynamic _bodyData; - - try { - const _type = FullType(BuiltList, [FullType(String)]); - _bodyData = _serializers.serialize(requestBody, specifiedType: _type); - } catch (error, stackTrace) { - throw DioError( - requestOptions: _options.compose( - _dio.options, - _path, - ), - type: DioErrorType.unknown, - error: error, - stackTrace: stackTrace, - ); - } - - final _response = await _dio.request( - _path, - data: _bodyData, - options: _options, - cancelToken: cancelToken, - onSendProgress: onSendProgress, - onReceiveProgress: onReceiveProgress, - ); - - OkResponse _responseData; - - try { - const _responseType = FullType(OkResponse); - _responseData = _serializers.deserialize( - _response.data!, - specifiedType: _responseType, - ) as OkResponse; - } catch (error, stackTrace) { - throw DioError( - requestOptions: _response.requestOptions, - response: _response, - type: DioErrorType.unknown, - error: error, - stackTrace: stackTrace, - ); - } - - return Response( - data: _responseData, - headers: _response.headers, - isRedirect: _response.isRedirect, - requestOptions: _response.requestOptions, - redirects: _response.redirects, - statusCode: _response.statusCode, - statusMessage: _response.statusMessage, - extra: _response.extra, - ); - } - - /// Create User - /// - /// - /// Parameters: - /// * [createUserDefinition] - /// * [accessToken] - /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation - /// * [headers] - Can be used to add additional headers to the request - /// * [extras] - Can be used to add flags to the request - /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response - /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress - /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress - /// - /// Returns a [Future] containing a [Response] with a [OkResponse] as data - /// Throws [DioError] if API call or serialization fails - Future> createUserApiUsersPost({ - required CreateUserDefinition createUserDefinition, - String? accessToken, - CancelToken? cancelToken, - Map? headers, - Map? extra, - ValidateStatus? validateStatus, - ProgressCallback? onSendProgress, - ProgressCallback? onReceiveProgress, - }) async { - final _path = r'/api/users/+'; - final _options = Options( - method: r'POST', - headers: { - if (accessToken != null) r'access-token': accessToken, - ...?headers, - }, - extra: { - 'secure': >[], - ...?extra, - }, - contentType: 'application/json', - validateStatus: validateStatus, - ); - - dynamic _bodyData; - - try { - const _type = FullType(CreateUserDefinition); - _bodyData = - _serializers.serialize(createUserDefinition, specifiedType: _type); - } catch (error, stackTrace) { - throw DioError( - requestOptions: _options.compose( - _dio.options, - _path, - ), - type: DioErrorType.unknown, - error: error, - stackTrace: stackTrace, - ); - } - - final _response = await _dio.request( - _path, - data: _bodyData, - options: _options, - cancelToken: cancelToken, - onSendProgress: onSendProgress, - onReceiveProgress: onReceiveProgress, - ); - - OkResponse _responseData; - - try { - const _responseType = FullType(OkResponse); - _responseData = _serializers.deserialize( - _response.data!, - specifiedType: _responseType, - ) as OkResponse; - } catch (error, stackTrace) { - throw DioError( - requestOptions: _response.requestOptions, - response: _response, - type: DioErrorType.unknown, - error: error, - stackTrace: stackTrace, - ); - } - - return Response( - data: _responseData, - headers: _response.headers, - isRedirect: _response.isRedirect, - requestOptions: _response.requestOptions, - redirects: _response.redirects, - statusCode: _response.statusCode, - statusMessage: _response.statusMessage, - extra: _response.extra, - ); - } - - /// Delete Item From Table - /// - /// - /// Parameters: - /// * [tableName] - /// * [columnConditionCompat] - /// * [accessToken] - /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation - /// * [headers] - Can be used to add additional headers to the request - /// * [extras] - Can be used to add flags to the request - /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response - /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress - /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress - /// - /// Returns a [Future] containing a [Response] with a [OkResponse] as data - /// Throws [DioError] if API call or serialization fails - Future> deleteItemFromTableItemsTableNamePost({ - required String tableName, - required BuiltList columnConditionCompat, - String? accessToken, - CancelToken? cancelToken, - Map? headers, - Map? extra, - ValidateStatus? validateStatus, - ProgressCallback? onSendProgress, - ProgressCallback? onReceiveProgress, - }) async { - final _path = r'/items/{tableName}/-' - .replaceAll('{' r'tableName' '}', tableName.toString()); - final _options = Options( - method: r'POST', - headers: { - if (accessToken != null) r'access-token': accessToken, - ...?headers, - }, - extra: { - 'secure': >[], - ...?extra, - }, - contentType: 'application/json', - validateStatus: validateStatus, - ); - - dynamic _bodyData; - - try { - const _type = FullType(BuiltList, [FullType(ColumnConditionCompat)]); - _bodyData = - _serializers.serialize(columnConditionCompat, specifiedType: _type); - } catch (error, stackTrace) { - throw DioError( - requestOptions: _options.compose( - _dio.options, - _path, - ), - type: DioErrorType.unknown, - error: error, - stackTrace: stackTrace, - ); - } - - final _response = await _dio.request( - _path, - data: _bodyData, - options: _options, - cancelToken: cancelToken, - onSendProgress: onSendProgress, - onReceiveProgress: onReceiveProgress, - ); - - OkResponse _responseData; - - try { - const _responseType = FullType(OkResponse); - _responseData = _serializers.deserialize( - _response.data!, - specifiedType: _responseType, - ) as OkResponse; - } catch (error, stackTrace) { - throw DioError( - requestOptions: _response.requestOptions, - response: _response, - type: DioErrorType.unknown, - error: error, - stackTrace: stackTrace, - ); - } - - return Response( - data: _responseData, - headers: _response.headers, - isRedirect: _response.isRedirect, - requestOptions: _response.requestOptions, - redirects: _response.redirects, - statusCode: _response.statusCode, - statusMessage: _response.statusMessage, - extra: _response.extra, - ); - } - - /// Drop Table - /// - /// - /// Parameters: - /// * [tableName] - /// * [accessToken] - /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation - /// * [headers] - Can be used to add additional headers to the request - /// * [extras] - Can be used to add flags to the request - /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response - /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress - /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress - /// - /// Returns a [Future] containing a [Response] with a [OkResponse] as data - /// Throws [DioError] if API call or serialization fails - Future> dropTableApiDropTableTableNamePost({ - required String tableName, - String? accessToken, - CancelToken? cancelToken, - Map? headers, - Map? extra, - ValidateStatus? validateStatus, - ProgressCallback? onSendProgress, - ProgressCallback? onReceiveProgress, - }) async { - final _path = r'/api/dropTable/{tableName}' - .replaceAll('{' r'tableName' '}', tableName.toString()); - final _options = Options( - method: r'POST', - headers: { - if (accessToken != null) r'access-token': accessToken, - ...?headers, - }, - extra: { - 'secure': >[], - ...?extra, - }, - validateStatus: validateStatus, - ); - - final _response = await _dio.request( - _path, - options: _options, - cancelToken: cancelToken, - onSendProgress: onSendProgress, - onReceiveProgress: onReceiveProgress, - ); - - OkResponse _responseData; - - try { - const _responseType = FullType(OkResponse); - _responseData = _serializers.deserialize( - _response.data!, - specifiedType: _responseType, - ) as OkResponse; - } catch (error, stackTrace) { - throw DioError( - requestOptions: _response.requestOptions, - response: _response, - type: DioErrorType.unknown, - error: error, - stackTrace: stackTrace, - ); - } - - return Response( - data: _responseData, - headers: _response.headers, - isRedirect: _response.isRedirect, - requestOptions: _response.requestOptions, - redirects: _response.redirects, - statusCode: _response.statusCode, - statusMessage: _response.statusMessage, - extra: _response.extra, - ); - } - - /// Get Access Token - /// - /// - /// Parameters: - /// * [authModel] - /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation - /// * [headers] - Can be used to add additional headers to the request - /// * [extras] - Can be used to add flags to the request - /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response - /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress - /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress - /// - /// Returns a [Future] containing a [Response] with a [AccessTokenResponse] as data - /// Throws [DioError] if API call or serialization fails - Future> getAccessTokenApiGetAccessTokenPost({ - required AuthModel authModel, - CancelToken? cancelToken, - Map? headers, - Map? extra, - ValidateStatus? validateStatus, - ProgressCallback? onSendProgress, - ProgressCallback? onReceiveProgress, - }) async { - final _path = r'/api/getAccessToken'; - final _options = Options( - method: r'POST', - headers: { - ...?headers, - }, - extra: { - 'secure': >[], - ...?extra, - }, - contentType: 'application/json', - validateStatus: validateStatus, - ); - - dynamic _bodyData; - - try { - const _type = FullType(AuthModel); - _bodyData = _serializers.serialize(authModel, specifiedType: _type); - } catch (error, stackTrace) { - throw DioError( - requestOptions: _options.compose( - _dio.options, - _path, - ), - type: DioErrorType.unknown, - error: error, - stackTrace: stackTrace, - ); - } - - final _response = await _dio.request( - _path, - data: _bodyData, - options: _options, - cancelToken: cancelToken, - onSendProgress: onSendProgress, - onReceiveProgress: onReceiveProgress, - ); - - AccessTokenResponse _responseData; - - try { - const _responseType = FullType(AccessTokenResponse); - _responseData = _serializers.deserialize( - _response.data!, - specifiedType: _responseType, - ) as AccessTokenResponse; - } catch (error, stackTrace) { - throw DioError( - requestOptions: _response.requestOptions, - response: _response, - type: DioErrorType.unknown, - error: error, - stackTrace: stackTrace, - ); - } - - return Response( - data: _responseData, - headers: _response.headers, - isRedirect: _response.isRedirect, - requestOptions: _response.requestOptions, - redirects: _response.redirects, - statusCode: _response.statusCode, - statusMessage: _response.statusMessage, - extra: _response.extra, - ); - } - - /// Get Asset - /// - /// - /// Parameters: - /// * [fid] - /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation - /// * [headers] - Can be used to add additional headers to the request - /// * [extras] - Can be used to add flags to the request - /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response - /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress - /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress - /// - /// Returns a [Future] containing a [Response] with a [JsonObject] as data - /// Throws [DioError] if API call or serialization fails - Future> getAssetAssetsFidGet({ - required String fid, - CancelToken? cancelToken, - Map? headers, - Map? extra, - ValidateStatus? validateStatus, - ProgressCallback? onSendProgress, - ProgressCallback? onReceiveProgress, - }) async { - final _path = r'/assets/{fid}'.replaceAll('{' r'fid' '}', fid.toString()); - final _options = Options( - method: r'GET', - headers: { - ...?headers, - }, - extra: { - 'secure': >[], - ...?extra, - }, - validateStatus: validateStatus, - ); - - final _response = await _dio.request( - _path, - options: _options, - cancelToken: cancelToken, - onSendProgress: onSendProgress, - onReceiveProgress: onReceiveProgress, - ); - - JsonObject _responseData; - - try { - const _responseType = FullType(JsonObject); - _responseData = _serializers.deserialize( - _response.data!, - specifiedType: _responseType, - ) as JsonObject; - } catch (error, stackTrace) { - throw DioError( - requestOptions: _response.requestOptions, - response: _response, - type: DioErrorType.unknown, - error: error, - stackTrace: stackTrace, - ); - } - - return Response( - data: _responseData, - headers: _response.headers, - isRedirect: _response.isRedirect, - requestOptions: _response.requestOptions, - redirects: _response.redirects, - statusCode: _response.statusCode, - statusMessage: _response.statusMessage, - extra: _response.extra, - ); - } - - /// Get Items From Table - /// - /// - /// Parameters: - /// * [tableName] - /// * [itemsFieldSelectorList] - /// * [accessToken] - /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation - /// * [headers] - Can be used to add additional headers to the request - /// * [extras] - Can be used to add flags to the request - /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response - /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress - /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress - /// - /// Returns a [Future] containing a [Response] with a [TableItemsResponse] as data - /// Throws [DioError] if API call or serialization fails - Future> getItemsFromTableItemsTableNamePost({ - required String tableName, - required ItemsFieldSelectorList itemsFieldSelectorList, - String? accessToken, - CancelToken? cancelToken, - Map? headers, - Map? extra, - ValidateStatus? validateStatus, - ProgressCallback? onSendProgress, - ProgressCallback? onReceiveProgress, - }) async { - final _path = r'/items/{tableName}' - .replaceAll('{' r'tableName' '}', tableName.toString()); - final _options = Options( - method: r'POST', - headers: { - if (accessToken != null) r'access-token': accessToken, - ...?headers, - }, - extra: { - 'secure': >[], - ...?extra, - }, - contentType: 'application/json', - validateStatus: validateStatus, - ); - - dynamic _bodyData; - - try { - const _type = FullType(ItemsFieldSelectorList); - _bodyData = - _serializers.serialize(itemsFieldSelectorList, specifiedType: _type); - } catch (error, stackTrace) { - throw DioError( - requestOptions: _options.compose( - _dio.options, - _path, - ), - type: DioErrorType.unknown, - error: error, - stackTrace: stackTrace, - ); - } - - final _response = await _dio.request( - _path, - data: _bodyData, - options: _options, - cancelToken: cancelToken, - onSendProgress: onSendProgress, - onReceiveProgress: onReceiveProgress, - ); - - TableItemsResponse _responseData; - - try { - const _responseType = FullType(TableItemsResponse); - _responseData = _serializers.deserialize( - _response.data!, - specifiedType: _responseType, - ) as TableItemsResponse; - } catch (error, stackTrace) { - throw DioError( - requestOptions: _response.requestOptions, - response: _response, - type: DioErrorType.unknown, - error: error, - stackTrace: stackTrace, - ); - } - - return Response( - data: _responseData, - headers: _response.headers, - isRedirect: _response.isRedirect, - requestOptions: _response.requestOptions, - redirects: _response.redirects, - statusCode: _response.statusCode, - statusMessage: _response.statusMessage, - extra: _response.extra, - ); - } - - /// List Tables - /// - /// - /// Parameters: - /// * [accessToken] - /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation - /// * [headers] - Can be used to add additional headers to the request - /// * [extras] - Can be used to add flags to the request - /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response - /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress - /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress - /// - /// Returns a [Future] containing a [Response] with a [BuiltList] as data - /// Throws [DioError] if API call or serialization fails - Future>> listTablesApiListTablesGet({ - String? accessToken, - CancelToken? cancelToken, - Map? headers, - Map? extra, - ValidateStatus? validateStatus, - ProgressCallback? onSendProgress, - ProgressCallback? onReceiveProgress, - }) async { - final _path = r'/api/listTables'; - final _options = Options( - method: r'GET', - headers: { - if (accessToken != null) r'access-token': accessToken, - ...?headers, - }, - extra: { - 'secure': >[], - ...?extra, - }, - validateStatus: validateStatus, - ); - - final _response = await _dio.request( - _path, - options: _options, - cancelToken: cancelToken, - onSendProgress: onSendProgress, - onReceiveProgress: onReceiveProgress, - ); - - BuiltList _responseData; - - try { - const _responseType = FullType(BuiltList, [FullType(TableDefinition)]); - _responseData = _serializers.deserialize( - _response.data!, - specifiedType: _responseType, - ) as BuiltList; - } catch (error, stackTrace) { - throw DioError( - requestOptions: _response.requestOptions, - response: _response, - type: DioErrorType.unknown, - error: error, - stackTrace: stackTrace, - ); - } - - return Response>( - data: _responseData, - headers: _response.headers, - isRedirect: _response.isRedirect, - requestOptions: _response.requestOptions, - redirects: _response.redirects, - statusCode: _response.statusCode, - statusMessage: _response.statusMessage, - extra: _response.extra, - ); - } - - /// Put Asset - /// - /// - /// Parameters: - /// * [asset] - /// * [accessToken] - /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation - /// * [headers] - Can be used to add additional headers to the request - /// * [extras] - Can be used to add flags to the request - /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response - /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress - /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress - /// - /// Returns a [Future] containing a [Response] with a [CreateAssetResponse] as data - /// Throws [DioError] if API call or serialization fails - Future> putAssetAssetsPost({ - required MultipartFile asset, - String? accessToken, - CancelToken? cancelToken, - Map? headers, - Map? extra, - ValidateStatus? validateStatus, - ProgressCallback? onSendProgress, - ProgressCallback? onReceiveProgress, - }) async { - final _path = r'/assets/+'; - final _options = Options( - method: r'POST', - headers: { - if (accessToken != null) r'access-token': accessToken, - ...?headers, - }, - extra: { - 'secure': >[], - ...?extra, - }, - contentType: 'multipart/form-data', - validateStatus: validateStatus, - ); - - dynamic _bodyData; - - try { - _bodyData = FormData.fromMap({ - r'asset': asset, - }); - } catch (error, stackTrace) { - throw DioError( - requestOptions: _options.compose( - _dio.options, - _path, - ), - type: DioErrorType.unknown, - error: error, - stackTrace: stackTrace, - ); - } - - final _response = await _dio.request( - _path, - data: _bodyData, - options: _options, - cancelToken: cancelToken, - onSendProgress: onSendProgress, - onReceiveProgress: onReceiveProgress, - ); - - CreateAssetResponse _responseData; - - try { - const _responseType = FullType(CreateAssetResponse); - _responseData = _serializers.deserialize( - _response.data!, - specifiedType: _responseType, - ) as CreateAssetResponse; - } catch (error, stackTrace) { - throw DioError( - requestOptions: _response.requestOptions, - response: _response, - type: DioErrorType.unknown, - error: error, - stackTrace: stackTrace, - ); - } - - return Response( - data: _responseData, - headers: _response.headers, - isRedirect: _response.isRedirect, - requestOptions: _response.requestOptions, - redirects: _response.redirects, - statusCode: _response.statusCode, - statusMessage: _response.statusMessage, - extra: _response.extra, - ); - } - - /// Remove Asset - /// - /// - /// Parameters: - /// * [assetId] - /// * [checkReferences] - /// * [deleteReferencing] - /// * [accessToken] - /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation - /// * [headers] - Can be used to add additional headers to the request - /// * [extras] - Can be used to add flags to the request - /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response - /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress - /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress - /// - /// Returns a [Future] containing a [Response] with a [OkResponse] as data - /// Throws [DioError] if API call or serialization fails - Future> removeAssetAssetsAssetIdPost({ - required int assetId, - bool? checkReferences = true, - bool? deleteReferencing = false, - String? accessToken, - CancelToken? cancelToken, - Map? headers, - Map? extra, - ValidateStatus? validateStatus, - ProgressCallback? onSendProgress, - ProgressCallback? onReceiveProgress, - }) async { - final _path = r'/assets/{asset_id}/-' - .replaceAll('{' r'asset_id' '}', assetId.toString()); - final _options = Options( - method: r'POST', - headers: { - if (accessToken != null) r'access-token': accessToken, - ...?headers, - }, - extra: { - 'secure': >[], - ...?extra, - }, - validateStatus: validateStatus, - ); - - final _queryParameters = { - if (checkReferences != null) - r'check_references': encodeQueryParameter( - _serializers, checkReferences, const FullType(bool)), - if (deleteReferencing != null) - r'delete_referencing': encodeQueryParameter( - _serializers, deleteReferencing, const FullType(bool)), - }; - - final _response = await _dio.request( - _path, - options: _options, - queryParameters: _queryParameters, - cancelToken: cancelToken, - onSendProgress: onSendProgress, - onReceiveProgress: onReceiveProgress, - ); - - OkResponse _responseData; - - try { - const _responseType = FullType(OkResponse); - _responseData = _serializers.deserialize( - _response.data!, - specifiedType: _responseType, - ) as OkResponse; - } catch (error, stackTrace) { - throw DioError( - requestOptions: _response.requestOptions, - response: _response, - type: DioErrorType.unknown, - error: error, - stackTrace: stackTrace, - ); - } - - return Response( - data: _responseData, - headers: _response.headers, - isRedirect: _response.isRedirect, - requestOptions: _response.requestOptions, - redirects: _response.redirects, - statusCode: _response.statusCode, - statusMessage: _response.statusMessage, - extra: _response.extra, - ); - } - - /// Remove User - /// - /// - /// Parameters: - /// * [userId] - /// * [accessToken] - /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation - /// * [headers] - Can be used to add additional headers to the request - /// * [extras] - Can be used to add flags to the request - /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response - /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress - /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress - /// - /// Returns a [Future] containing a [Response] with a [OkResponse] as data - /// Throws [DioError] if API call or serialization fails - Future> removeUserApiUsersPost({ - required int userId, - String? accessToken, - CancelToken? cancelToken, - Map? headers, - Map? extra, - ValidateStatus? validateStatus, - ProgressCallback? onSendProgress, - ProgressCallback? onReceiveProgress, - }) async { - final _path = r'/api/users/-'; - final _options = Options( - method: r'POST', - headers: { - if (accessToken != null) r'access-token': accessToken, - ...?headers, - }, - extra: { - 'secure': >[], - ...?extra, - }, - validateStatus: validateStatus, - ); - - final _queryParameters = { - r'user_id': - encodeQueryParameter(_serializers, userId, const FullType(int)), - }; - - final _response = await _dio.request( - _path, - options: _options, - queryParameters: _queryParameters, - cancelToken: cancelToken, - onSendProgress: onSendProgress, - onReceiveProgress: onReceiveProgress, - ); - - OkResponse _responseData; - - try { - const _responseType = FullType(OkResponse); - _responseData = _serializers.deserialize( - _response.data!, - specifiedType: _responseType, - ) as OkResponse; - } catch (error, stackTrace) { - throw DioError( - requestOptions: _response.requestOptions, - response: _response, - type: DioErrorType.unknown, - error: error, - stackTrace: stackTrace, - ); - } - - return Response( - data: _responseData, - headers: _response.headers, - isRedirect: _response.isRedirect, - requestOptions: _response.requestOptions, - redirects: _response.redirects, - statusCode: _response.statusCode, - statusMessage: _response.statusMessage, - extra: _response.extra, - ); - } - - /// Update Asset Description - /// - /// - /// Parameters: - /// * [assetId] - /// * [assetDescription] - /// * [accessToken] - /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation - /// * [headers] - Can be used to add additional headers to the request - /// * [extras] - Can be used to add flags to the request - /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response - /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress - /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress - /// - /// Returns a [Future] containing a [Response] with a [OkResponse] as data - /// Throws [DioError] if API call or serialization fails - Future> updateAssetDescriptionAssetsAssetIdPost({ - required int assetId, - required String assetDescription, - String? accessToken, - CancelToken? cancelToken, - Map? headers, - Map? extra, - ValidateStatus? validateStatus, - ProgressCallback? onSendProgress, - ProgressCallback? onReceiveProgress, - }) async { - final _path = r'/assets/{asset_id}/*' - .replaceAll('{' r'asset_id' '}', assetId.toString()); - final _options = Options( - method: r'POST', - headers: { - if (accessToken != null) r'access-token': accessToken, - ...?headers, - }, - extra: { - 'secure': >[], - ...?extra, - }, - validateStatus: validateStatus, - ); - - final _queryParameters = { - r'asset_description': encodeQueryParameter( - _serializers, assetDescription, const FullType(String)), - }; - - final _response = await _dio.request( - _path, - options: _options, - queryParameters: _queryParameters, - cancelToken: cancelToken, - onSendProgress: onSendProgress, - onReceiveProgress: onReceiveProgress, - ); - - OkResponse _responseData; - - try { - const _responseType = FullType(OkResponse); - _responseData = _serializers.deserialize( - _response.data!, - specifiedType: _responseType, - ) as OkResponse; - } catch (error, stackTrace) { - throw DioError( - requestOptions: _response.requestOptions, - response: _response, - type: DioErrorType.unknown, - error: error, - stackTrace: stackTrace, - ); - } - - return Response( - data: _responseData, - headers: _response.headers, - isRedirect: _response.isRedirect, - requestOptions: _response.requestOptions, - redirects: _response.redirects, - statusCode: _response.statusCode, - statusMessage: _response.statusMessage, - extra: _response.extra, - ); - } - - /// Update Item In Table - /// - /// - /// Parameters: - /// * [tableName] - /// * [bodyUpdateItemInTableItemsTableNamePost] - /// * [accessToken] - /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation - /// * [headers] - Can be used to add additional headers to the request - /// * [extras] - Can be used to add flags to the request - /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response - /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress - /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress - /// - /// Returns a [Future] containing a [Response] with a [OkResponse] as data - /// Throws [DioError] if API call or serialization fails - Future> updateItemInTableItemsTableNamePost({ - required String tableName, - required BodyUpdateItemInTableItemsTableNamePost - bodyUpdateItemInTableItemsTableNamePost, - String? accessToken, - CancelToken? cancelToken, - Map? headers, - Map? extra, - ValidateStatus? validateStatus, - ProgressCallback? onSendProgress, - ProgressCallback? onReceiveProgress, - }) async { - final _path = r'/items/{tableName}/*' - .replaceAll('{' r'tableName' '}', tableName.toString()); - final _options = Options( - method: r'POST', - headers: { - if (accessToken != null) r'access-token': accessToken, - ...?headers, - }, - extra: { - 'secure': >[], - ...?extra, - }, - contentType: 'application/json', - validateStatus: validateStatus, - ); - - dynamic _bodyData; - - try { - const _type = FullType(BodyUpdateItemInTableItemsTableNamePost); - _bodyData = _serializers.serialize( - bodyUpdateItemInTableItemsTableNamePost, - specifiedType: _type); - } catch (error, stackTrace) { - throw DioError( - requestOptions: _options.compose( - _dio.options, - _path, - ), - type: DioErrorType.unknown, - error: error, - stackTrace: stackTrace, - ); - } - - final _response = await _dio.request( - _path, - data: _bodyData, - options: _options, - cancelToken: cancelToken, - onSendProgress: onSendProgress, - onReceiveProgress: onReceiveProgress, - ); - - OkResponse _responseData; - - try { - const _responseType = FullType(OkResponse); - _responseData = _serializers.deserialize( - _response.data!, - specifiedType: _responseType, - ) as OkResponse; - } catch (error, stackTrace) { - throw DioError( - requestOptions: _response.requestOptions, - response: _response, - type: DioErrorType.unknown, - error: error, - stackTrace: stackTrace, - ); - } - - return Response( - data: _responseData, - headers: _response.headers, - isRedirect: _response.isRedirect, - requestOptions: _response.requestOptions, - redirects: _response.redirects, - statusCode: _response.statusCode, - statusMessage: _response.statusMessage, - extra: _response.extra, - ); - } - - /// Update User - /// - /// - /// Parameters: - /// * [userUpdateDefinition] - /// * [accessToken] - /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation - /// * [headers] - Can be used to add additional headers to the request - /// * [extras] - Can be used to add flags to the request - /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response - /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress - /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress - /// - /// Returns a [Future] containing a [Response] with a [OkResponse] as data - /// Throws [DioError] if API call or serialization fails - Future> updateUserApiUsersPost({ - required UserUpdateDefinition userUpdateDefinition, - String? accessToken, - CancelToken? cancelToken, - Map? headers, - Map? extra, - ValidateStatus? validateStatus, - ProgressCallback? onSendProgress, - ProgressCallback? onReceiveProgress, - }) async { - final _path = r'/api/users/*'; - final _options = Options( - method: r'POST', - headers: { - if (accessToken != null) r'access-token': accessToken, - ...?headers, - }, - extra: { - 'secure': >[], - ...?extra, - }, - contentType: 'application/json', - validateStatus: validateStatus, - ); - - dynamic _bodyData; - - try { - const _type = FullType(UserUpdateDefinition); - _bodyData = - _serializers.serialize(userUpdateDefinition, specifiedType: _type); - } catch (error, stackTrace) { - throw DioError( - requestOptions: _options.compose( - _dio.options, - _path, - ), - type: DioErrorType.unknown, - error: error, - stackTrace: stackTrace, - ); - } - - final _response = await _dio.request( - _path, - data: _bodyData, - options: _options, - cancelToken: cancelToken, - onSendProgress: onSendProgress, - onReceiveProgress: onReceiveProgress, - ); - - OkResponse _responseData; - - try { - const _responseType = FullType(OkResponse); - _responseData = _serializers.deserialize( - _response.data!, - specifiedType: _responseType, - ) as OkResponse; - } catch (error, stackTrace) { - throw DioError( - requestOptions: _response.requestOptions, - response: _response, - type: DioErrorType.unknown, - error: error, - stackTrace: stackTrace, - ); - } - - return Response( - data: _responseData, - headers: _response.headers, - isRedirect: _response.isRedirect, - requestOptions: _response.requestOptions, - redirects: _response.redirects, - statusCode: _response.statusCode, - statusMessage: _response.statusMessage, - extra: _response.extra, - ); - } -} diff --git a/lib/api_sub_project/src/api_util.dart b/lib/api_sub_project/src/api_util.dart deleted file mode 100644 index ed3bb12..0000000 --- a/lib/api_sub_project/src/api_util.dart +++ /dev/null @@ -1,77 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// - -import 'dart:convert'; -import 'dart:typed_data'; - -import 'package:built_collection/built_collection.dart'; -import 'package:built_value/serializer.dart'; -import 'package:dio/dio.dart'; - -/// Format the given form parameter object into something that Dio can handle. -/// Returns primitive or String. -/// Returns List/Map if the value is BuildList/BuiltMap. -dynamic encodeFormParameter(Serializers serializers, dynamic value, FullType type) { - if (value == null) { - return ''; - } - if (value is String || value is num || value is bool) { - return value; - } - final serialized = serializers.serialize( - value as Object, - specifiedType: type, - ); - if (serialized is String) { - return serialized; - } - if (value is BuiltList || value is BuiltSet || value is BuiltMap) { - return serialized; - } - return json.encode(serialized); -} - -dynamic encodeQueryParameter( - Serializers serializers, - dynamic value, - FullType type, -) { - if (value == null) { - return ''; - } - if (value is String || value is num || value is bool) { - return value; - } - if (value is Uint8List) { - // Currently not sure how to serialize this - return value; - } - final serialized = serializers.serialize( - value as Object, - specifiedType: type, - ); - if (serialized == null) { - return ''; - } - if (serialized is String) { - return serialized; - } - return serialized; -} - -ListParam encodeCollectionQueryParameter( - Serializers serializers, - dynamic value, - FullType type, { - ListFormat format = ListFormat.multi, -}) { - final serialized = serializers.serialize( - value as Object, - specifiedType: type, - ); - if (value is BuiltList || value is BuiltSet) { - return ListParam(List.of((serialized as Iterable).cast()), format); - } - throw ArgumentError('Invalid value passed to encodeCollectionQueryParameter'); -} diff --git a/lib/api_sub_project/src/auth/api_key_auth.dart b/lib/api_sub_project/src/auth/api_key_auth.dart deleted file mode 100644 index 74996b0..0000000 --- a/lib/api_sub_project/src/auth/api_key_auth.dart +++ /dev/null @@ -1,30 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// - -import 'package:dio/dio.dart'; -import 'package:tuuli_app/api_sub_project/src/auth/auth.dart'; - -class ApiKeyAuthInterceptor extends AuthInterceptor { - final Map apiKeys = {}; - - @override - void onRequest(RequestOptions options, RequestInterceptorHandler handler) { - final authInfo = - getAuthInfo(options, (secure) => secure['type'] == 'apiKey'); - for (final info in authInfo) { - final authName = info['name'] as String; - final authKeyName = info['keyName'] as String; - final authWhere = info['where'] as String; - final apiKey = apiKeys[authName]; - if (apiKey != null) { - if (authWhere == 'query') { - options.queryParameters[authKeyName] = apiKey; - } else { - options.headers[authKeyName] = apiKey; - } - } - } - super.onRequest(options, handler); - } -} diff --git a/lib/api_sub_project/src/auth/auth.dart b/lib/api_sub_project/src/auth/auth.dart deleted file mode 100644 index f7ae9bf..0000000 --- a/lib/api_sub_project/src/auth/auth.dart +++ /dev/null @@ -1,18 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// - -import 'package:dio/dio.dart'; - -abstract class AuthInterceptor extends Interceptor { - /// Get auth information on given route for the given type. - /// Can return an empty list if type is not present on auth data or - /// if route doesn't need authentication. - List> getAuthInfo(RequestOptions route, bool Function(Map secure) handles) { - if (route.extra.containsKey('secure')) { - final auth = route.extra['secure'] as List>; - return auth.where((secure) => handles(secure)).toList(); - } - return []; - } -} diff --git a/lib/api_sub_project/src/auth/basic_auth.dart b/lib/api_sub_project/src/auth/basic_auth.dart deleted file mode 100644 index ad6906b..0000000 --- a/lib/api_sub_project/src/auth/basic_auth.dart +++ /dev/null @@ -1,42 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// - -import 'dart:convert'; - -import 'package:dio/dio.dart'; -import 'package:tuuli_app/api_sub_project/src/auth/auth.dart'; - -class BasicAuthInfo { - final String username; - final String password; - - const BasicAuthInfo(this.username, this.password); -} - -class BasicAuthInterceptor extends AuthInterceptor { - final Map authInfo = {}; - - @override - void onRequest( - RequestOptions options, - RequestInterceptorHandler handler, - ) { - final metadataAuthInfo = getAuthInfo( - options, - (secure) => - (secure['type'] == 'http' && secure['scheme'] == 'basic') || - secure['type'] == 'basic'); - for (final info in metadataAuthInfo) { - final authName = info['name'] as String; - final basicAuthInfo = authInfo[authName]; - if (basicAuthInfo != null) { - final basicAuth = - 'Basic ${base64Encode(utf8.encode('${basicAuthInfo.username}:${basicAuthInfo.password}'))}'; - options.headers['Authorization'] = basicAuth; - break; - } - } - super.onRequest(options, handler); - } -} diff --git a/lib/api_sub_project/src/auth/bearer_auth.dart b/lib/api_sub_project/src/auth/bearer_auth.dart deleted file mode 100644 index fadbc2b..0000000 --- a/lib/api_sub_project/src/auth/bearer_auth.dart +++ /dev/null @@ -1,27 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// - -import 'package:dio/dio.dart'; -import 'package:tuuli_app/api_sub_project/src/auth/auth.dart'; - -class BearerAuthInterceptor extends AuthInterceptor { - final Map tokens = {}; - - @override - void onRequest( - RequestOptions options, - RequestInterceptorHandler handler, - ) { - final authInfo = getAuthInfo(options, - (secure) => secure['type'] == 'http' && secure['scheme'] == 'bearer'); - for (final info in authInfo) { - final token = tokens[info['name']]; - if (token != null) { - options.headers['Authorization'] = 'Bearer ${token}'; - break; - } - } - super.onRequest(options, handler); - } -} diff --git a/lib/api_sub_project/src/auth/oauth.dart b/lib/api_sub_project/src/auth/oauth.dart deleted file mode 100644 index c8b6faa..0000000 --- a/lib/api_sub_project/src/auth/oauth.dart +++ /dev/null @@ -1,27 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// - -import 'package:dio/dio.dart'; -import 'package:tuuli_app/api_sub_project/src/auth/auth.dart'; - -class OAuthInterceptor extends AuthInterceptor { - final Map tokens = {}; - - @override - void onRequest( - RequestOptions options, - RequestInterceptorHandler handler, - ) { - final authInfo = getAuthInfo(options, - (secure) => secure['type'] == 'oauth' || secure['type'] == 'oauth2'); - for (final info in authInfo) { - final token = tokens[info['name']]; - if (token != null) { - options.headers['Authorization'] = 'Bearer ${token}'; - break; - } - } - super.onRequest(options, handler); - } -} diff --git a/lib/api_sub_project/src/date_serializer.dart b/lib/api_sub_project/src/date_serializer.dart deleted file mode 100644 index f6cbf32..0000000 --- a/lib/api_sub_project/src/date_serializer.dart +++ /dev/null @@ -1,30 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// - -import 'package:built_collection/built_collection.dart'; -import 'package:built_value/serializer.dart'; -import 'package:tuuli_app/api_sub_project/src/model/date.dart'; - -class DateSerializer implements PrimitiveSerializer { - const DateSerializer(); - - @override - Iterable get types => BuiltList.of([Date]); - - @override - String get wireName => 'Date'; - - @override - Date deserialize(Serializers serializers, Object serialized, - {FullType specifiedType = FullType.unspecified}) { - final parsed = DateTime.parse(serialized as String); - return Date(parsed.year, parsed.month, parsed.day); - } - - @override - Object serialize(Serializers serializers, Date date, - {FullType specifiedType = FullType.unspecified}) { - return date.toString(); - } -} diff --git a/lib/api_sub_project/src/model/access_token_response.dart b/lib/api_sub_project/src/model/access_token_response.dart deleted file mode 100644 index c7e4b29..0000000 --- a/lib/api_sub_project/src/model/access_token_response.dart +++ /dev/null @@ -1,106 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// - -// ignore_for_file: unused_element -import 'package:built_value/built_value.dart'; -import 'package:built_value/serializer.dart'; - -part 'access_token_response.g.dart'; - -/// AccessTokenResponse -/// -/// Properties: -/// * [accessToken] -@BuiltValue() -abstract class AccessTokenResponse implements Built { - @BuiltValueField(wireName: r'access_token') - String get accessToken; - - AccessTokenResponse._(); - - factory AccessTokenResponse([void updates(AccessTokenResponseBuilder b)]) = _$AccessTokenResponse; - - @BuiltValueHook(initializeBuilder: true) - static void _defaults(AccessTokenResponseBuilder b) => b; - - @BuiltValueSerializer(custom: true) - static Serializer get serializer => _$AccessTokenResponseSerializer(); -} - -class _$AccessTokenResponseSerializer implements PrimitiveSerializer { - @override - final Iterable types = const [AccessTokenResponse, _$AccessTokenResponse]; - - @override - final String wireName = r'AccessTokenResponse'; - - Iterable _serializeProperties( - Serializers serializers, - AccessTokenResponse object, { - FullType specifiedType = FullType.unspecified, - }) sync* { - yield r'access_token'; - yield serializers.serialize( - object.accessToken, - specifiedType: const FullType(String), - ); - } - - @override - Object serialize( - Serializers serializers, - AccessTokenResponse object, { - FullType specifiedType = FullType.unspecified, - }) { - return _serializeProperties(serializers, object, specifiedType: specifiedType).toList(); - } - - void _deserializeProperties( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - required List serializedList, - required AccessTokenResponseBuilder result, - required List unhandled, - }) { - for (var i = 0; i < serializedList.length; i += 2) { - final key = serializedList[i] as String; - final value = serializedList[i + 1]; - switch (key) { - case r'access_token': - final valueDes = serializers.deserialize( - value, - specifiedType: const FullType(String), - ) as String; - result.accessToken = valueDes; - break; - default: - unhandled.add(key); - unhandled.add(value); - break; - } - } - } - - @override - AccessTokenResponse deserialize( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final result = AccessTokenResponseBuilder(); - final serializedList = (serialized as Iterable).toList(); - final unhandled = []; - _deserializeProperties( - serializers, - serialized, - specifiedType: specifiedType, - serializedList: serializedList, - unhandled: unhandled, - result: result, - ); - return result.build(); - } -} - diff --git a/lib/api_sub_project/src/model/access_token_response.g.dart b/lib/api_sub_project/src/model/access_token_response.g.dart deleted file mode 100644 index 8432dd4..0000000 --- a/lib/api_sub_project/src/model/access_token_response.g.dart +++ /dev/null @@ -1,98 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'access_token_response.dart'; - -// ************************************************************************** -// BuiltValueGenerator -// ************************************************************************** - -class _$AccessTokenResponse extends AccessTokenResponse { - @override - final String accessToken; - - factory _$AccessTokenResponse( - [void Function(AccessTokenResponseBuilder)? updates]) => - (new AccessTokenResponseBuilder()..update(updates))._build(); - - _$AccessTokenResponse._({required this.accessToken}) : super._() { - BuiltValueNullFieldError.checkNotNull( - accessToken, r'AccessTokenResponse', 'accessToken'); - } - - @override - AccessTokenResponse rebuild( - void Function(AccessTokenResponseBuilder) updates) => - (toBuilder()..update(updates)).build(); - - @override - AccessTokenResponseBuilder toBuilder() => - new AccessTokenResponseBuilder()..replace(this); - - @override - bool operator ==(Object other) { - if (identical(other, this)) return true; - return other is AccessTokenResponse && accessToken == other.accessToken; - } - - @override - int get hashCode { - var _$hash = 0; - _$hash = $jc(_$hash, accessToken.hashCode); - _$hash = $jf(_$hash); - return _$hash; - } - - @override - String toString() { - return (newBuiltValueToStringHelper(r'AccessTokenResponse') - ..add('accessToken', accessToken)) - .toString(); - } -} - -class AccessTokenResponseBuilder - implements Builder { - _$AccessTokenResponse? _$v; - - String? _accessToken; - String? get accessToken => _$this._accessToken; - set accessToken(String? accessToken) => _$this._accessToken = accessToken; - - AccessTokenResponseBuilder() { - AccessTokenResponse._defaults(this); - } - - AccessTokenResponseBuilder get _$this { - final $v = _$v; - if ($v != null) { - _accessToken = $v.accessToken; - _$v = null; - } - return this; - } - - @override - void replace(AccessTokenResponse other) { - ArgumentError.checkNotNull(other, 'other'); - _$v = other as _$AccessTokenResponse; - } - - @override - void update(void Function(AccessTokenResponseBuilder)? updates) { - if (updates != null) updates(this); - } - - @override - AccessTokenResponse build() => _build(); - - _$AccessTokenResponse _build() { - final _$result = _$v ?? - new _$AccessTokenResponse._( - accessToken: BuiltValueNullFieldError.checkNotNull( - accessToken, r'AccessTokenResponse', 'accessToken')); - replace(_$result); - return _$result; - } -} - -// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/lib/api_sub_project/src/model/auth_model.dart b/lib/api_sub_project/src/model/auth_model.dart deleted file mode 100644 index d1c736e..0000000 --- a/lib/api_sub_project/src/model/auth_model.dart +++ /dev/null @@ -1,122 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// - -// ignore_for_file: unused_element -import 'package:built_value/built_value.dart'; -import 'package:built_value/serializer.dart'; - -part 'auth_model.g.dart'; - -/// AuthModel -/// -/// Properties: -/// * [username] -/// * [password] -@BuiltValue() -abstract class AuthModel implements Built { - @BuiltValueField(wireName: r'username') - String get username; - - @BuiltValueField(wireName: r'password') - String get password; - - AuthModel._(); - - factory AuthModel([void updates(AuthModelBuilder b)]) = _$AuthModel; - - @BuiltValueHook(initializeBuilder: true) - static void _defaults(AuthModelBuilder b) => b; - - @BuiltValueSerializer(custom: true) - static Serializer get serializer => _$AuthModelSerializer(); -} - -class _$AuthModelSerializer implements PrimitiveSerializer { - @override - final Iterable types = const [AuthModel, _$AuthModel]; - - @override - final String wireName = r'AuthModel'; - - Iterable _serializeProperties( - Serializers serializers, - AuthModel object, { - FullType specifiedType = FullType.unspecified, - }) sync* { - yield r'username'; - yield serializers.serialize( - object.username, - specifiedType: const FullType(String), - ); - yield r'password'; - yield serializers.serialize( - object.password, - specifiedType: const FullType(String), - ); - } - - @override - Object serialize( - Serializers serializers, - AuthModel object, { - FullType specifiedType = FullType.unspecified, - }) { - return _serializeProperties(serializers, object, specifiedType: specifiedType).toList(); - } - - void _deserializeProperties( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - required List serializedList, - required AuthModelBuilder result, - required List unhandled, - }) { - for (var i = 0; i < serializedList.length; i += 2) { - final key = serializedList[i] as String; - final value = serializedList[i + 1]; - switch (key) { - case r'username': - final valueDes = serializers.deserialize( - value, - specifiedType: const FullType(String), - ) as String; - result.username = valueDes; - break; - case r'password': - final valueDes = serializers.deserialize( - value, - specifiedType: const FullType(String), - ) as String; - result.password = valueDes; - break; - default: - unhandled.add(key); - unhandled.add(value); - break; - } - } - } - - @override - AuthModel deserialize( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final result = AuthModelBuilder(); - final serializedList = (serialized as Iterable).toList(); - final unhandled = []; - _deserializeProperties( - serializers, - serialized, - specifiedType: specifiedType, - serializedList: serializedList, - unhandled: unhandled, - result: result, - ); - return result.build(); - } -} - diff --git a/lib/api_sub_project/src/model/auth_model.g.dart b/lib/api_sub_project/src/model/auth_model.g.dart deleted file mode 100644 index f95dd71..0000000 --- a/lib/api_sub_project/src/model/auth_model.g.dart +++ /dev/null @@ -1,107 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'auth_model.dart'; - -// ************************************************************************** -// BuiltValueGenerator -// ************************************************************************** - -class _$AuthModel extends AuthModel { - @override - final String username; - @override - final String password; - - factory _$AuthModel([void Function(AuthModelBuilder)? updates]) => - (new AuthModelBuilder()..update(updates))._build(); - - _$AuthModel._({required this.username, required this.password}) : super._() { - BuiltValueNullFieldError.checkNotNull(username, r'AuthModel', 'username'); - BuiltValueNullFieldError.checkNotNull(password, r'AuthModel', 'password'); - } - - @override - AuthModel rebuild(void Function(AuthModelBuilder) updates) => - (toBuilder()..update(updates)).build(); - - @override - AuthModelBuilder toBuilder() => new AuthModelBuilder()..replace(this); - - @override - bool operator ==(Object other) { - if (identical(other, this)) return true; - return other is AuthModel && - username == other.username && - password == other.password; - } - - @override - int get hashCode { - var _$hash = 0; - _$hash = $jc(_$hash, username.hashCode); - _$hash = $jc(_$hash, password.hashCode); - _$hash = $jf(_$hash); - return _$hash; - } - - @override - String toString() { - return (newBuiltValueToStringHelper(r'AuthModel') - ..add('username', username) - ..add('password', password)) - .toString(); - } -} - -class AuthModelBuilder implements Builder { - _$AuthModel? _$v; - - String? _username; - String? get username => _$this._username; - set username(String? username) => _$this._username = username; - - String? _password; - String? get password => _$this._password; - set password(String? password) => _$this._password = password; - - AuthModelBuilder() { - AuthModel._defaults(this); - } - - AuthModelBuilder get _$this { - final $v = _$v; - if ($v != null) { - _username = $v.username; - _password = $v.password; - _$v = null; - } - return this; - } - - @override - void replace(AuthModel other) { - ArgumentError.checkNotNull(other, 'other'); - _$v = other as _$AuthModel; - } - - @override - void update(void Function(AuthModelBuilder)? updates) { - if (updates != null) updates(this); - } - - @override - AuthModel build() => _build(); - - _$AuthModel _build() { - final _$result = _$v ?? - new _$AuthModel._( - username: BuiltValueNullFieldError.checkNotNull( - username, r'AuthModel', 'username'), - password: BuiltValueNullFieldError.checkNotNull( - password, r'AuthModel', 'password')); - replace(_$result); - return _$result; - } -} - -// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/lib/api_sub_project/src/model/body_update_item_in_table_items_table_name_post.dart b/lib/api_sub_project/src/model/body_update_item_in_table_items_table_name_post.dart deleted file mode 100644 index 45b0d05..0000000 --- a/lib/api_sub_project/src/model/body_update_item_in_table_items_table_name_post.dart +++ /dev/null @@ -1,123 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// - -// ignore_for_file: unused_element -import 'package:built_collection/built_collection.dart'; -import 'package:built_value/built_value.dart'; -import 'package:built_value/serializer.dart'; - -part 'body_update_item_in_table_items_table_name_post.g.dart'; - -/// BodyUpdateItemInTableItemsTableNamePost -/// -/// Properties: -/// * [item] -/// * [oldItem] -@BuiltValue() -abstract class BodyUpdateItemInTableItemsTableNamePost implements Built { - @BuiltValueField(wireName: r'item') - BuiltMap get item; - - @BuiltValueField(wireName: r'oldItem') - BuiltMap get oldItem; - - BodyUpdateItemInTableItemsTableNamePost._(); - - factory BodyUpdateItemInTableItemsTableNamePost([void updates(BodyUpdateItemInTableItemsTableNamePostBuilder b)]) = _$BodyUpdateItemInTableItemsTableNamePost; - - @BuiltValueHook(initializeBuilder: true) - static void _defaults(BodyUpdateItemInTableItemsTableNamePostBuilder b) => b; - - @BuiltValueSerializer(custom: true) - static Serializer get serializer => _$BodyUpdateItemInTableItemsTableNamePostSerializer(); -} - -class _$BodyUpdateItemInTableItemsTableNamePostSerializer implements PrimitiveSerializer { - @override - final Iterable types = const [BodyUpdateItemInTableItemsTableNamePost, _$BodyUpdateItemInTableItemsTableNamePost]; - - @override - final String wireName = r'BodyUpdateItemInTableItemsTableNamePost'; - - Iterable _serializeProperties( - Serializers serializers, - BodyUpdateItemInTableItemsTableNamePost object, { - FullType specifiedType = FullType.unspecified, - }) sync* { - yield r'item'; - yield serializers.serialize( - object.item, - specifiedType: const FullType(BuiltMap, [FullType(String), FullType(String)]), - ); - yield r'oldItem'; - yield serializers.serialize( - object.oldItem, - specifiedType: const FullType(BuiltMap, [FullType(String), FullType(String)]), - ); - } - - @override - Object serialize( - Serializers serializers, - BodyUpdateItemInTableItemsTableNamePost object, { - FullType specifiedType = FullType.unspecified, - }) { - return _serializeProperties(serializers, object, specifiedType: specifiedType).toList(); - } - - void _deserializeProperties( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - required List serializedList, - required BodyUpdateItemInTableItemsTableNamePostBuilder result, - required List unhandled, - }) { - for (var i = 0; i < serializedList.length; i += 2) { - final key = serializedList[i] as String; - final value = serializedList[i + 1]; - switch (key) { - case r'item': - final valueDes = serializers.deserialize( - value, - specifiedType: const FullType(BuiltMap, [FullType(String), FullType(String)]), - ) as BuiltMap; - result.item.replace(valueDes); - break; - case r'oldItem': - final valueDes = serializers.deserialize( - value, - specifiedType: const FullType(BuiltMap, [FullType(String), FullType(String)]), - ) as BuiltMap; - result.oldItem.replace(valueDes); - break; - default: - unhandled.add(key); - unhandled.add(value); - break; - } - } - } - - @override - BodyUpdateItemInTableItemsTableNamePost deserialize( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final result = BodyUpdateItemInTableItemsTableNamePostBuilder(); - final serializedList = (serialized as Iterable).toList(); - final unhandled = []; - _deserializeProperties( - serializers, - serialized, - specifiedType: specifiedType, - serializedList: serializedList, - unhandled: unhandled, - result: result, - ); - return result.build(); - } -} - diff --git a/lib/api_sub_project/src/model/body_update_item_in_table_items_table_name_post.g.dart b/lib/api_sub_project/src/model/body_update_item_in_table_items_table_name_post.g.dart deleted file mode 100644 index 9f7fff4..0000000 --- a/lib/api_sub_project/src/model/body_update_item_in_table_items_table_name_post.g.dart +++ /dev/null @@ -1,139 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'body_update_item_in_table_items_table_name_post.dart'; - -// ************************************************************************** -// BuiltValueGenerator -// ************************************************************************** - -class _$BodyUpdateItemInTableItemsTableNamePost - extends BodyUpdateItemInTableItemsTableNamePost { - @override - final BuiltMap item; - @override - final BuiltMap oldItem; - - factory _$BodyUpdateItemInTableItemsTableNamePost( - [void Function(BodyUpdateItemInTableItemsTableNamePostBuilder)? - updates]) => - (new BodyUpdateItemInTableItemsTableNamePostBuilder()..update(updates)) - ._build(); - - _$BodyUpdateItemInTableItemsTableNamePost._( - {required this.item, required this.oldItem}) - : super._() { - BuiltValueNullFieldError.checkNotNull( - item, r'BodyUpdateItemInTableItemsTableNamePost', 'item'); - BuiltValueNullFieldError.checkNotNull( - oldItem, r'BodyUpdateItemInTableItemsTableNamePost', 'oldItem'); - } - - @override - BodyUpdateItemInTableItemsTableNamePost rebuild( - void Function(BodyUpdateItemInTableItemsTableNamePostBuilder) - updates) => - (toBuilder()..update(updates)).build(); - - @override - BodyUpdateItemInTableItemsTableNamePostBuilder toBuilder() => - new BodyUpdateItemInTableItemsTableNamePostBuilder()..replace(this); - - @override - bool operator ==(Object other) { - if (identical(other, this)) return true; - return other is BodyUpdateItemInTableItemsTableNamePost && - item == other.item && - oldItem == other.oldItem; - } - - @override - int get hashCode { - var _$hash = 0; - _$hash = $jc(_$hash, item.hashCode); - _$hash = $jc(_$hash, oldItem.hashCode); - _$hash = $jf(_$hash); - return _$hash; - } - - @override - String toString() { - return (newBuiltValueToStringHelper( - r'BodyUpdateItemInTableItemsTableNamePost') - ..add('item', item) - ..add('oldItem', oldItem)) - .toString(); - } -} - -class BodyUpdateItemInTableItemsTableNamePostBuilder - implements - Builder { - _$BodyUpdateItemInTableItemsTableNamePost? _$v; - - MapBuilder? _item; - MapBuilder get item => - _$this._item ??= new MapBuilder(); - set item(MapBuilder? item) => _$this._item = item; - - MapBuilder? _oldItem; - MapBuilder get oldItem => - _$this._oldItem ??= new MapBuilder(); - set oldItem(MapBuilder? oldItem) => _$this._oldItem = oldItem; - - BodyUpdateItemInTableItemsTableNamePostBuilder() { - BodyUpdateItemInTableItemsTableNamePost._defaults(this); - } - - BodyUpdateItemInTableItemsTableNamePostBuilder get _$this { - final $v = _$v; - if ($v != null) { - _item = $v.item.toBuilder(); - _oldItem = $v.oldItem.toBuilder(); - _$v = null; - } - return this; - } - - @override - void replace(BodyUpdateItemInTableItemsTableNamePost other) { - ArgumentError.checkNotNull(other, 'other'); - _$v = other as _$BodyUpdateItemInTableItemsTableNamePost; - } - - @override - void update( - void Function(BodyUpdateItemInTableItemsTableNamePostBuilder)? updates) { - if (updates != null) updates(this); - } - - @override - BodyUpdateItemInTableItemsTableNamePost build() => _build(); - - _$BodyUpdateItemInTableItemsTableNamePost _build() { - _$BodyUpdateItemInTableItemsTableNamePost _$result; - try { - _$result = _$v ?? - new _$BodyUpdateItemInTableItemsTableNamePost._( - item: item.build(), oldItem: oldItem.build()); - } catch (_) { - late String _$failedField; - try { - _$failedField = 'item'; - item.build(); - _$failedField = 'oldItem'; - oldItem.build(); - } catch (e) { - throw new BuiltValueNestedFieldError( - r'BodyUpdateItemInTableItemsTableNamePost', - _$failedField, - e.toString()); - } - rethrow; - } - replace(_$result); - return _$result; - } -} - -// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/lib/api_sub_project/src/model/column_condition_compat.dart b/lib/api_sub_project/src/model/column_condition_compat.dart deleted file mode 100644 index 3c12118..0000000 --- a/lib/api_sub_project/src/model/column_condition_compat.dart +++ /dev/null @@ -1,179 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// - -// ignore_for_file: unused_element -import 'package:built_collection/built_collection.dart'; -import 'package:built_value/json_object.dart'; -import 'package:built_value/built_value.dart'; -import 'package:built_value/serializer.dart'; - -part 'column_condition_compat.g.dart'; - -/// ColumnConditionCompat -/// -/// Properties: -/// * [column] -/// * [operator_] -/// * [value] -@BuiltValue() -abstract class ColumnConditionCompat implements Built { - @BuiltValueField(wireName: r'column') - String get column; - - @BuiltValueField(wireName: r'operator') - ColumnConditionCompatOperator_Enum get operator_; - // enum operator_Enum { eq, ne, gt, lt, ge, le, contains, not_contains, starts_with, not_starts_with, ends_with, not_ends_with, }; - - @BuiltValueField(wireName: r'value') - JsonObject? get value; - - ColumnConditionCompat._(); - - factory ColumnConditionCompat([void updates(ColumnConditionCompatBuilder b)]) = _$ColumnConditionCompat; - - @BuiltValueHook(initializeBuilder: true) - static void _defaults(ColumnConditionCompatBuilder b) => b; - - @BuiltValueSerializer(custom: true) - static Serializer get serializer => _$ColumnConditionCompatSerializer(); -} - -class _$ColumnConditionCompatSerializer implements PrimitiveSerializer { - @override - final Iterable types = const [ColumnConditionCompat, _$ColumnConditionCompat]; - - @override - final String wireName = r'ColumnConditionCompat'; - - Iterable _serializeProperties( - Serializers serializers, - ColumnConditionCompat object, { - FullType specifiedType = FullType.unspecified, - }) sync* { - yield r'column'; - yield serializers.serialize( - object.column, - specifiedType: const FullType(String), - ); - yield r'operator'; - yield serializers.serialize( - object.operator_, - specifiedType: const FullType(ColumnConditionCompatOperator_Enum), - ); - if (object.value != null) { - yield r'value'; - yield serializers.serialize( - object.value, - specifiedType: const FullType.nullable(JsonObject), - ); - } - } - - @override - Object serialize( - Serializers serializers, - ColumnConditionCompat object, { - FullType specifiedType = FullType.unspecified, - }) { - return _serializeProperties(serializers, object, specifiedType: specifiedType).toList(); - } - - void _deserializeProperties( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - required List serializedList, - required ColumnConditionCompatBuilder result, - required List unhandled, - }) { - for (var i = 0; i < serializedList.length; i += 2) { - final key = serializedList[i] as String; - final value = serializedList[i + 1]; - switch (key) { - case r'column': - final valueDes = serializers.deserialize( - value, - specifiedType: const FullType(String), - ) as String; - result.column = valueDes; - break; - case r'operator': - final valueDes = serializers.deserialize( - value, - specifiedType: const FullType(ColumnConditionCompatOperator_Enum), - ) as ColumnConditionCompatOperator_Enum; - result.operator_ = valueDes; - break; - case r'value': - final valueDes = serializers.deserialize( - value, - specifiedType: const FullType.nullable(JsonObject), - ) as JsonObject?; - if (valueDes == null) continue; - result.value = valueDes; - break; - default: - unhandled.add(key); - unhandled.add(value); - break; - } - } - } - - @override - ColumnConditionCompat deserialize( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final result = ColumnConditionCompatBuilder(); - final serializedList = (serialized as Iterable).toList(); - final unhandled = []; - _deserializeProperties( - serializers, - serialized, - specifiedType: specifiedType, - serializedList: serializedList, - unhandled: unhandled, - result: result, - ); - return result.build(); - } -} - -class ColumnConditionCompatOperator_Enum extends EnumClass { - - @BuiltValueEnumConst(wireName: r'eq') - static const ColumnConditionCompatOperator_Enum eq = _$columnConditionCompatOperatorEnum_eq; - @BuiltValueEnumConst(wireName: r'ne') - static const ColumnConditionCompatOperator_Enum ne = _$columnConditionCompatOperatorEnum_ne; - @BuiltValueEnumConst(wireName: r'gt') - static const ColumnConditionCompatOperator_Enum gt = _$columnConditionCompatOperatorEnum_gt; - @BuiltValueEnumConst(wireName: r'lt') - static const ColumnConditionCompatOperator_Enum lt = _$columnConditionCompatOperatorEnum_lt; - @BuiltValueEnumConst(wireName: r'ge') - static const ColumnConditionCompatOperator_Enum ge = _$columnConditionCompatOperatorEnum_ge; - @BuiltValueEnumConst(wireName: r'le') - static const ColumnConditionCompatOperator_Enum le = _$columnConditionCompatOperatorEnum_le; - @BuiltValueEnumConst(wireName: r'contains') - static const ColumnConditionCompatOperator_Enum contains = _$columnConditionCompatOperatorEnum_contains; - @BuiltValueEnumConst(wireName: r'not_contains') - static const ColumnConditionCompatOperator_Enum notContains = _$columnConditionCompatOperatorEnum_notContains; - @BuiltValueEnumConst(wireName: r'starts_with') - static const ColumnConditionCompatOperator_Enum startsWith = _$columnConditionCompatOperatorEnum_startsWith; - @BuiltValueEnumConst(wireName: r'not_starts_with') - static const ColumnConditionCompatOperator_Enum notStartsWith = _$columnConditionCompatOperatorEnum_notStartsWith; - @BuiltValueEnumConst(wireName: r'ends_with') - static const ColumnConditionCompatOperator_Enum endsWith = _$columnConditionCompatOperatorEnum_endsWith; - @BuiltValueEnumConst(wireName: r'not_ends_with') - static const ColumnConditionCompatOperator_Enum notEndsWith = _$columnConditionCompatOperatorEnum_notEndsWith; - - static Serializer get serializer => _$columnConditionCompatOperatorEnumSerializer; - - const ColumnConditionCompatOperator_Enum._(String name): super(name); - - static BuiltSet get values => _$columnConditionCompatOperatorEnumValues; - static ColumnConditionCompatOperator_Enum valueOf(String name) => _$columnConditionCompatOperatorEnumValueOf(name); -} - diff --git a/lib/api_sub_project/src/model/column_condition_compat.g.dart b/lib/api_sub_project/src/model/column_condition_compat.g.dart deleted file mode 100644 index 1e50ab6..0000000 --- a/lib/api_sub_project/src/model/column_condition_compat.g.dart +++ /dev/null @@ -1,267 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'column_condition_compat.dart'; - -// ************************************************************************** -// BuiltValueGenerator -// ************************************************************************** - -const ColumnConditionCompatOperator_Enum - _$columnConditionCompatOperatorEnum_eq = - const ColumnConditionCompatOperator_Enum._('eq'); -const ColumnConditionCompatOperator_Enum - _$columnConditionCompatOperatorEnum_ne = - const ColumnConditionCompatOperator_Enum._('ne'); -const ColumnConditionCompatOperator_Enum - _$columnConditionCompatOperatorEnum_gt = - const ColumnConditionCompatOperator_Enum._('gt'); -const ColumnConditionCompatOperator_Enum - _$columnConditionCompatOperatorEnum_lt = - const ColumnConditionCompatOperator_Enum._('lt'); -const ColumnConditionCompatOperator_Enum - _$columnConditionCompatOperatorEnum_ge = - const ColumnConditionCompatOperator_Enum._('ge'); -const ColumnConditionCompatOperator_Enum - _$columnConditionCompatOperatorEnum_le = - const ColumnConditionCompatOperator_Enum._('le'); -const ColumnConditionCompatOperator_Enum - _$columnConditionCompatOperatorEnum_contains = - const ColumnConditionCompatOperator_Enum._('contains'); -const ColumnConditionCompatOperator_Enum - _$columnConditionCompatOperatorEnum_notContains = - const ColumnConditionCompatOperator_Enum._('notContains'); -const ColumnConditionCompatOperator_Enum - _$columnConditionCompatOperatorEnum_startsWith = - const ColumnConditionCompatOperator_Enum._('startsWith'); -const ColumnConditionCompatOperator_Enum - _$columnConditionCompatOperatorEnum_notStartsWith = - const ColumnConditionCompatOperator_Enum._('notStartsWith'); -const ColumnConditionCompatOperator_Enum - _$columnConditionCompatOperatorEnum_endsWith = - const ColumnConditionCompatOperator_Enum._('endsWith'); -const ColumnConditionCompatOperator_Enum - _$columnConditionCompatOperatorEnum_notEndsWith = - const ColumnConditionCompatOperator_Enum._('notEndsWith'); - -ColumnConditionCompatOperator_Enum _$columnConditionCompatOperatorEnumValueOf( - String name) { - switch (name) { - case 'eq': - return _$columnConditionCompatOperatorEnum_eq; - case 'ne': - return _$columnConditionCompatOperatorEnum_ne; - case 'gt': - return _$columnConditionCompatOperatorEnum_gt; - case 'lt': - return _$columnConditionCompatOperatorEnum_lt; - case 'ge': - return _$columnConditionCompatOperatorEnum_ge; - case 'le': - return _$columnConditionCompatOperatorEnum_le; - case 'contains': - return _$columnConditionCompatOperatorEnum_contains; - case 'notContains': - return _$columnConditionCompatOperatorEnum_notContains; - case 'startsWith': - return _$columnConditionCompatOperatorEnum_startsWith; - case 'notStartsWith': - return _$columnConditionCompatOperatorEnum_notStartsWith; - case 'endsWith': - return _$columnConditionCompatOperatorEnum_endsWith; - case 'notEndsWith': - return _$columnConditionCompatOperatorEnum_notEndsWith; - default: - throw new ArgumentError(name); - } -} - -final BuiltSet - _$columnConditionCompatOperatorEnumValues = new BuiltSet< - ColumnConditionCompatOperator_Enum>(const [ - _$columnConditionCompatOperatorEnum_eq, - _$columnConditionCompatOperatorEnum_ne, - _$columnConditionCompatOperatorEnum_gt, - _$columnConditionCompatOperatorEnum_lt, - _$columnConditionCompatOperatorEnum_ge, - _$columnConditionCompatOperatorEnum_le, - _$columnConditionCompatOperatorEnum_contains, - _$columnConditionCompatOperatorEnum_notContains, - _$columnConditionCompatOperatorEnum_startsWith, - _$columnConditionCompatOperatorEnum_notStartsWith, - _$columnConditionCompatOperatorEnum_endsWith, - _$columnConditionCompatOperatorEnum_notEndsWith, -]); - -Serializer - _$columnConditionCompatOperatorEnumSerializer = - new _$ColumnConditionCompatOperator_EnumSerializer(); - -class _$ColumnConditionCompatOperator_EnumSerializer - implements PrimitiveSerializer { - static const Map _toWire = const { - 'eq': 'eq', - 'ne': 'ne', - 'gt': 'gt', - 'lt': 'lt', - 'ge': 'ge', - 'le': 'le', - 'contains': 'contains', - 'notContains': 'not_contains', - 'startsWith': 'starts_with', - 'notStartsWith': 'not_starts_with', - 'endsWith': 'ends_with', - 'notEndsWith': 'not_ends_with', - }; - static const Map _fromWire = const { - 'eq': 'eq', - 'ne': 'ne', - 'gt': 'gt', - 'lt': 'lt', - 'ge': 'ge', - 'le': 'le', - 'contains': 'contains', - 'not_contains': 'notContains', - 'starts_with': 'startsWith', - 'not_starts_with': 'notStartsWith', - 'ends_with': 'endsWith', - 'not_ends_with': 'notEndsWith', - }; - - @override - final Iterable types = const [ColumnConditionCompatOperator_Enum]; - @override - final String wireName = 'ColumnConditionCompatOperator_Enum'; - - @override - Object serialize( - Serializers serializers, ColumnConditionCompatOperator_Enum object, - {FullType specifiedType = FullType.unspecified}) => - _toWire[object.name] ?? object.name; - - @override - ColumnConditionCompatOperator_Enum deserialize( - Serializers serializers, Object serialized, - {FullType specifiedType = FullType.unspecified}) => - ColumnConditionCompatOperator_Enum.valueOf( - _fromWire[serialized] ?? (serialized is String ? serialized : '')); -} - -class _$ColumnConditionCompat extends ColumnConditionCompat { - @override - final String column; - @override - final ColumnConditionCompatOperator_Enum operator_; - @override - final JsonObject? value; - - factory _$ColumnConditionCompat( - [void Function(ColumnConditionCompatBuilder)? updates]) => - (new ColumnConditionCompatBuilder()..update(updates))._build(); - - _$ColumnConditionCompat._( - {required this.column, required this.operator_, this.value}) - : super._() { - BuiltValueNullFieldError.checkNotNull( - column, r'ColumnConditionCompat', 'column'); - BuiltValueNullFieldError.checkNotNull( - operator_, r'ColumnConditionCompat', 'operator_'); - } - - @override - ColumnConditionCompat rebuild( - void Function(ColumnConditionCompatBuilder) updates) => - (toBuilder()..update(updates)).build(); - - @override - ColumnConditionCompatBuilder toBuilder() => - new ColumnConditionCompatBuilder()..replace(this); - - @override - bool operator ==(Object other) { - if (identical(other, this)) return true; - return other is ColumnConditionCompat && - column == other.column && - operator_ == other.operator_ && - value == other.value; - } - - @override - int get hashCode { - var _$hash = 0; - _$hash = $jc(_$hash, column.hashCode); - _$hash = $jc(_$hash, operator_.hashCode); - _$hash = $jc(_$hash, value.hashCode); - _$hash = $jf(_$hash); - return _$hash; - } - - @override - String toString() { - return (newBuiltValueToStringHelper(r'ColumnConditionCompat') - ..add('column', column) - ..add('operator_', operator_) - ..add('value', value)) - .toString(); - } -} - -class ColumnConditionCompatBuilder - implements Builder { - _$ColumnConditionCompat? _$v; - - String? _column; - String? get column => _$this._column; - set column(String? column) => _$this._column = column; - - ColumnConditionCompatOperator_Enum? _operator_; - ColumnConditionCompatOperator_Enum? get operator_ => _$this._operator_; - set operator_(ColumnConditionCompatOperator_Enum? operator_) => - _$this._operator_ = operator_; - - JsonObject? _value; - JsonObject? get value => _$this._value; - set value(JsonObject? value) => _$this._value = value; - - ColumnConditionCompatBuilder() { - ColumnConditionCompat._defaults(this); - } - - ColumnConditionCompatBuilder get _$this { - final $v = _$v; - if ($v != null) { - _column = $v.column; - _operator_ = $v.operator_; - _value = $v.value; - _$v = null; - } - return this; - } - - @override - void replace(ColumnConditionCompat other) { - ArgumentError.checkNotNull(other, 'other'); - _$v = other as _$ColumnConditionCompat; - } - - @override - void update(void Function(ColumnConditionCompatBuilder)? updates) { - if (updates != null) updates(this); - } - - @override - ColumnConditionCompat build() => _build(); - - _$ColumnConditionCompat _build() { - final _$result = _$v ?? - new _$ColumnConditionCompat._( - column: BuiltValueNullFieldError.checkNotNull( - column, r'ColumnConditionCompat', 'column'), - operator_: BuiltValueNullFieldError.checkNotNull( - operator_, r'ColumnConditionCompat', 'operator_'), - value: value); - replace(_$result); - return _$result; - } -} - -// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/lib/api_sub_project/src/model/create_asset_response.dart b/lib/api_sub_project/src/model/create_asset_response.dart deleted file mode 100644 index ef2943a..0000000 --- a/lib/api_sub_project/src/model/create_asset_response.dart +++ /dev/null @@ -1,125 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// - -// ignore_for_file: unused_element -import 'package:built_value/built_value.dart'; -import 'package:built_value/serializer.dart'; - -part 'create_asset_response.g.dart'; - -/// CreateAssetResponse -/// -/// Properties: -/// * [ok] -/// * [fid] -@BuiltValue() -abstract class CreateAssetResponse implements Built { - @BuiltValueField(wireName: r'ok') - bool? get ok; - - @BuiltValueField(wireName: r'fid') - String get fid; - - CreateAssetResponse._(); - - factory CreateAssetResponse([void updates(CreateAssetResponseBuilder b)]) = _$CreateAssetResponse; - - @BuiltValueHook(initializeBuilder: true) - static void _defaults(CreateAssetResponseBuilder b) => b - ..ok = true; - - @BuiltValueSerializer(custom: true) - static Serializer get serializer => _$CreateAssetResponseSerializer(); -} - -class _$CreateAssetResponseSerializer implements PrimitiveSerializer { - @override - final Iterable types = const [CreateAssetResponse, _$CreateAssetResponse]; - - @override - final String wireName = r'CreateAssetResponse'; - - Iterable _serializeProperties( - Serializers serializers, - CreateAssetResponse object, { - FullType specifiedType = FullType.unspecified, - }) sync* { - if (object.ok != null) { - yield r'ok'; - yield serializers.serialize( - object.ok, - specifiedType: const FullType(bool), - ); - } - yield r'fid'; - yield serializers.serialize( - object.fid, - specifiedType: const FullType(String), - ); - } - - @override - Object serialize( - Serializers serializers, - CreateAssetResponse object, { - FullType specifiedType = FullType.unspecified, - }) { - return _serializeProperties(serializers, object, specifiedType: specifiedType).toList(); - } - - void _deserializeProperties( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - required List serializedList, - required CreateAssetResponseBuilder result, - required List unhandled, - }) { - for (var i = 0; i < serializedList.length; i += 2) { - final key = serializedList[i] as String; - final value = serializedList[i + 1]; - switch (key) { - case r'ok': - final valueDes = serializers.deserialize( - value, - specifiedType: const FullType(bool), - ) as bool; - result.ok = valueDes; - break; - case r'fid': - final valueDes = serializers.deserialize( - value, - specifiedType: const FullType(String), - ) as String; - result.fid = valueDes; - break; - default: - unhandled.add(key); - unhandled.add(value); - break; - } - } - } - - @override - CreateAssetResponse deserialize( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final result = CreateAssetResponseBuilder(); - final serializedList = (serialized as Iterable).toList(); - final unhandled = []; - _deserializeProperties( - serializers, - serialized, - specifiedType: specifiedType, - serializedList: serializedList, - unhandled: unhandled, - result: result, - ); - return result.build(); - } -} - diff --git a/lib/api_sub_project/src/model/create_asset_response.g.dart b/lib/api_sub_project/src/model/create_asset_response.g.dart deleted file mode 100644 index adfdeae..0000000 --- a/lib/api_sub_project/src/model/create_asset_response.g.dart +++ /dev/null @@ -1,107 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'create_asset_response.dart'; - -// ************************************************************************** -// BuiltValueGenerator -// ************************************************************************** - -class _$CreateAssetResponse extends CreateAssetResponse { - @override - final bool? ok; - @override - final String fid; - - factory _$CreateAssetResponse( - [void Function(CreateAssetResponseBuilder)? updates]) => - (new CreateAssetResponseBuilder()..update(updates))._build(); - - _$CreateAssetResponse._({this.ok, required this.fid}) : super._() { - BuiltValueNullFieldError.checkNotNull(fid, r'CreateAssetResponse', 'fid'); - } - - @override - CreateAssetResponse rebuild( - void Function(CreateAssetResponseBuilder) updates) => - (toBuilder()..update(updates)).build(); - - @override - CreateAssetResponseBuilder toBuilder() => - new CreateAssetResponseBuilder()..replace(this); - - @override - bool operator ==(Object other) { - if (identical(other, this)) return true; - return other is CreateAssetResponse && ok == other.ok && fid == other.fid; - } - - @override - int get hashCode { - var _$hash = 0; - _$hash = $jc(_$hash, ok.hashCode); - _$hash = $jc(_$hash, fid.hashCode); - _$hash = $jf(_$hash); - return _$hash; - } - - @override - String toString() { - return (newBuiltValueToStringHelper(r'CreateAssetResponse') - ..add('ok', ok) - ..add('fid', fid)) - .toString(); - } -} - -class CreateAssetResponseBuilder - implements Builder { - _$CreateAssetResponse? _$v; - - bool? _ok; - bool? get ok => _$this._ok; - set ok(bool? ok) => _$this._ok = ok; - - String? _fid; - String? get fid => _$this._fid; - set fid(String? fid) => _$this._fid = fid; - - CreateAssetResponseBuilder() { - CreateAssetResponse._defaults(this); - } - - CreateAssetResponseBuilder get _$this { - final $v = _$v; - if ($v != null) { - _ok = $v.ok; - _fid = $v.fid; - _$v = null; - } - return this; - } - - @override - void replace(CreateAssetResponse other) { - ArgumentError.checkNotNull(other, 'other'); - _$v = other as _$CreateAssetResponse; - } - - @override - void update(void Function(CreateAssetResponseBuilder)? updates) { - if (updates != null) updates(this); - } - - @override - CreateAssetResponse build() => _build(); - - _$CreateAssetResponse _build() { - final _$result = _$v ?? - new _$CreateAssetResponse._( - ok: ok, - fid: BuiltValueNullFieldError.checkNotNull( - fid, r'CreateAssetResponse', 'fid')); - replace(_$result); - return _$result; - } -} - -// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/lib/api_sub_project/src/model/create_user_definition.dart b/lib/api_sub_project/src/model/create_user_definition.dart deleted file mode 100644 index 92e0270..0000000 --- a/lib/api_sub_project/src/model/create_user_definition.dart +++ /dev/null @@ -1,122 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// - -// ignore_for_file: unused_element -import 'package:built_value/built_value.dart'; -import 'package:built_value/serializer.dart'; - -part 'create_user_definition.g.dart'; - -/// CreateUserDefinition -/// -/// Properties: -/// * [username] -/// * [password] -@BuiltValue() -abstract class CreateUserDefinition implements Built { - @BuiltValueField(wireName: r'username') - String get username; - - @BuiltValueField(wireName: r'password') - String get password; - - CreateUserDefinition._(); - - factory CreateUserDefinition([void updates(CreateUserDefinitionBuilder b)]) = _$CreateUserDefinition; - - @BuiltValueHook(initializeBuilder: true) - static void _defaults(CreateUserDefinitionBuilder b) => b; - - @BuiltValueSerializer(custom: true) - static Serializer get serializer => _$CreateUserDefinitionSerializer(); -} - -class _$CreateUserDefinitionSerializer implements PrimitiveSerializer { - @override - final Iterable types = const [CreateUserDefinition, _$CreateUserDefinition]; - - @override - final String wireName = r'CreateUserDefinition'; - - Iterable _serializeProperties( - Serializers serializers, - CreateUserDefinition object, { - FullType specifiedType = FullType.unspecified, - }) sync* { - yield r'username'; - yield serializers.serialize( - object.username, - specifiedType: const FullType(String), - ); - yield r'password'; - yield serializers.serialize( - object.password, - specifiedType: const FullType(String), - ); - } - - @override - Object serialize( - Serializers serializers, - CreateUserDefinition object, { - FullType specifiedType = FullType.unspecified, - }) { - return _serializeProperties(serializers, object, specifiedType: specifiedType).toList(); - } - - void _deserializeProperties( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - required List serializedList, - required CreateUserDefinitionBuilder result, - required List unhandled, - }) { - for (var i = 0; i < serializedList.length; i += 2) { - final key = serializedList[i] as String; - final value = serializedList[i + 1]; - switch (key) { - case r'username': - final valueDes = serializers.deserialize( - value, - specifiedType: const FullType(String), - ) as String; - result.username = valueDes; - break; - case r'password': - final valueDes = serializers.deserialize( - value, - specifiedType: const FullType(String), - ) as String; - result.password = valueDes; - break; - default: - unhandled.add(key); - unhandled.add(value); - break; - } - } - } - - @override - CreateUserDefinition deserialize( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final result = CreateUserDefinitionBuilder(); - final serializedList = (serialized as Iterable).toList(); - final unhandled = []; - _deserializeProperties( - serializers, - serialized, - specifiedType: specifiedType, - serializedList: serializedList, - unhandled: unhandled, - result: result, - ); - return result.build(); - } -} - diff --git a/lib/api_sub_project/src/model/create_user_definition.g.dart b/lib/api_sub_project/src/model/create_user_definition.g.dart deleted file mode 100644 index 86be5d8..0000000 --- a/lib/api_sub_project/src/model/create_user_definition.g.dart +++ /dev/null @@ -1,114 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'create_user_definition.dart'; - -// ************************************************************************** -// BuiltValueGenerator -// ************************************************************************** - -class _$CreateUserDefinition extends CreateUserDefinition { - @override - final String username; - @override - final String password; - - factory _$CreateUserDefinition( - [void Function(CreateUserDefinitionBuilder)? updates]) => - (new CreateUserDefinitionBuilder()..update(updates))._build(); - - _$CreateUserDefinition._({required this.username, required this.password}) - : super._() { - BuiltValueNullFieldError.checkNotNull( - username, r'CreateUserDefinition', 'username'); - BuiltValueNullFieldError.checkNotNull( - password, r'CreateUserDefinition', 'password'); - } - - @override - CreateUserDefinition rebuild( - void Function(CreateUserDefinitionBuilder) updates) => - (toBuilder()..update(updates)).build(); - - @override - CreateUserDefinitionBuilder toBuilder() => - new CreateUserDefinitionBuilder()..replace(this); - - @override - bool operator ==(Object other) { - if (identical(other, this)) return true; - return other is CreateUserDefinition && - username == other.username && - password == other.password; - } - - @override - int get hashCode { - var _$hash = 0; - _$hash = $jc(_$hash, username.hashCode); - _$hash = $jc(_$hash, password.hashCode); - _$hash = $jf(_$hash); - return _$hash; - } - - @override - String toString() { - return (newBuiltValueToStringHelper(r'CreateUserDefinition') - ..add('username', username) - ..add('password', password)) - .toString(); - } -} - -class CreateUserDefinitionBuilder - implements Builder { - _$CreateUserDefinition? _$v; - - String? _username; - String? get username => _$this._username; - set username(String? username) => _$this._username = username; - - String? _password; - String? get password => _$this._password; - set password(String? password) => _$this._password = password; - - CreateUserDefinitionBuilder() { - CreateUserDefinition._defaults(this); - } - - CreateUserDefinitionBuilder get _$this { - final $v = _$v; - if ($v != null) { - _username = $v.username; - _password = $v.password; - _$v = null; - } - return this; - } - - @override - void replace(CreateUserDefinition other) { - ArgumentError.checkNotNull(other, 'other'); - _$v = other as _$CreateUserDefinition; - } - - @override - void update(void Function(CreateUserDefinitionBuilder)? updates) { - if (updates != null) updates(this); - } - - @override - CreateUserDefinition build() => _build(); - - _$CreateUserDefinition _build() { - final _$result = _$v ?? - new _$CreateUserDefinition._( - username: BuiltValueNullFieldError.checkNotNull( - username, r'CreateUserDefinition', 'username'), - password: BuiltValueNullFieldError.checkNotNull( - password, r'CreateUserDefinition', 'password')); - replace(_$result); - return _$result; - } -} - -// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/lib/api_sub_project/src/model/date.dart b/lib/api_sub_project/src/model/date.dart deleted file mode 100644 index b21c7f5..0000000 --- a/lib/api_sub_project/src/model/date.dart +++ /dev/null @@ -1,70 +0,0 @@ -/// A gregorian calendar date generated by -/// OpenAPI generator to differentiate -/// between [DateTime] and [Date] formats. -class Date implements Comparable { - final int year; - - /// January is 1. - final int month; - - /// First day is 1. - final int day; - - Date(this.year, this.month, this.day); - - /// The current date - static Date now({bool utc = false}) { - var now = DateTime.now(); - if (utc) { - now = now.toUtc(); - } - return now.toDate(); - } - - /// Convert to a [DateTime]. - DateTime toDateTime({bool utc = false}) { - if (utc) { - return DateTime.utc(year, month, day); - } else { - return DateTime(year, month, day); - } - } - - @override - int compareTo(Date other) { - int d = year.compareTo(other.year); - if (d != 0) { - return d; - } - d = month.compareTo(other.month); - if (d != 0) { - return d; - } - return day.compareTo(other.day); - } - - @override - bool operator ==(Object other) => - identical(this, other) || - other is Date && - runtimeType == other.runtimeType && - year == other.year && - month == other.month && - day == other.day; - - @override - int get hashCode => year.hashCode ^ month.hashCode ^ day.hashCode; - - @override - String toString() { - final yyyy = year.toString(); - final mm = month.toString().padLeft(2, '0'); - final dd = day.toString().padLeft(2, '0'); - - return '$yyyy-$mm-$dd'; - } -} - -extension DateTimeToDate on DateTime { - Date toDate() => Date(year, month, day); -} diff --git a/lib/api_sub_project/src/model/error_response.dart b/lib/api_sub_project/src/model/error_response.dart deleted file mode 100644 index a11a492..0000000 --- a/lib/api_sub_project/src/model/error_response.dart +++ /dev/null @@ -1,106 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// - -// ignore_for_file: unused_element -import 'package:built_value/built_value.dart'; -import 'package:built_value/serializer.dart'; - -part 'error_response.g.dart'; - -/// ErrorResponse -/// -/// Properties: -/// * [error] -@BuiltValue() -abstract class ErrorResponse implements Built { - @BuiltValueField(wireName: r'error') - String get error; - - ErrorResponse._(); - - factory ErrorResponse([void updates(ErrorResponseBuilder b)]) = _$ErrorResponse; - - @BuiltValueHook(initializeBuilder: true) - static void _defaults(ErrorResponseBuilder b) => b; - - @BuiltValueSerializer(custom: true) - static Serializer get serializer => _$ErrorResponseSerializer(); -} - -class _$ErrorResponseSerializer implements PrimitiveSerializer { - @override - final Iterable types = const [ErrorResponse, _$ErrorResponse]; - - @override - final String wireName = r'ErrorResponse'; - - Iterable _serializeProperties( - Serializers serializers, - ErrorResponse object, { - FullType specifiedType = FullType.unspecified, - }) sync* { - yield r'error'; - yield serializers.serialize( - object.error, - specifiedType: const FullType(String), - ); - } - - @override - Object serialize( - Serializers serializers, - ErrorResponse object, { - FullType specifiedType = FullType.unspecified, - }) { - return _serializeProperties(serializers, object, specifiedType: specifiedType).toList(); - } - - void _deserializeProperties( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - required List serializedList, - required ErrorResponseBuilder result, - required List unhandled, - }) { - for (var i = 0; i < serializedList.length; i += 2) { - final key = serializedList[i] as String; - final value = serializedList[i + 1]; - switch (key) { - case r'error': - final valueDes = serializers.deserialize( - value, - specifiedType: const FullType(String), - ) as String; - result.error = valueDes; - break; - default: - unhandled.add(key); - unhandled.add(value); - break; - } - } - } - - @override - ErrorResponse deserialize( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final result = ErrorResponseBuilder(); - final serializedList = (serialized as Iterable).toList(); - final unhandled = []; - _deserializeProperties( - serializers, - serialized, - specifiedType: specifiedType, - serializedList: serializedList, - unhandled: unhandled, - result: result, - ); - return result.build(); - } -} - diff --git a/lib/api_sub_project/src/model/error_response.g.dart b/lib/api_sub_project/src/model/error_response.g.dart deleted file mode 100644 index 3d1df13..0000000 --- a/lib/api_sub_project/src/model/error_response.g.dart +++ /dev/null @@ -1,93 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'error_response.dart'; - -// ************************************************************************** -// BuiltValueGenerator -// ************************************************************************** - -class _$ErrorResponse extends ErrorResponse { - @override - final String error; - - factory _$ErrorResponse([void Function(ErrorResponseBuilder)? updates]) => - (new ErrorResponseBuilder()..update(updates))._build(); - - _$ErrorResponse._({required this.error}) : super._() { - BuiltValueNullFieldError.checkNotNull(error, r'ErrorResponse', 'error'); - } - - @override - ErrorResponse rebuild(void Function(ErrorResponseBuilder) updates) => - (toBuilder()..update(updates)).build(); - - @override - ErrorResponseBuilder toBuilder() => new ErrorResponseBuilder()..replace(this); - - @override - bool operator ==(Object other) { - if (identical(other, this)) return true; - return other is ErrorResponse && error == other.error; - } - - @override - int get hashCode { - var _$hash = 0; - _$hash = $jc(_$hash, error.hashCode); - _$hash = $jf(_$hash); - return _$hash; - } - - @override - String toString() { - return (newBuiltValueToStringHelper(r'ErrorResponse')..add('error', error)) - .toString(); - } -} - -class ErrorResponseBuilder - implements Builder { - _$ErrorResponse? _$v; - - String? _error; - String? get error => _$this._error; - set error(String? error) => _$this._error = error; - - ErrorResponseBuilder() { - ErrorResponse._defaults(this); - } - - ErrorResponseBuilder get _$this { - final $v = _$v; - if ($v != null) { - _error = $v.error; - _$v = null; - } - return this; - } - - @override - void replace(ErrorResponse other) { - ArgumentError.checkNotNull(other, 'other'); - _$v = other as _$ErrorResponse; - } - - @override - void update(void Function(ErrorResponseBuilder)? updates) { - if (updates != null) updates(this); - } - - @override - ErrorResponse build() => _build(); - - _$ErrorResponse _build() { - final _$result = _$v ?? - new _$ErrorResponse._( - error: BuiltValueNullFieldError.checkNotNull( - error, r'ErrorResponse', 'error')); - replace(_$result); - return _$result; - } -} - -// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/lib/api_sub_project/src/model/http_validation_error.dart b/lib/api_sub_project/src/model/http_validation_error.dart deleted file mode 100644 index 3917b2d..0000000 --- a/lib/api_sub_project/src/model/http_validation_error.dart +++ /dev/null @@ -1,119 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// - -// ignore_for_file: unused_element -import 'package:built_collection/built_collection.dart'; -import 'package:tuuli_app/api_sub_project/src/model/validation_error.dart'; -import 'package:built_value/built_value.dart'; -import 'package:built_value/serializer.dart'; - -part 'http_validation_error.g.dart'; - -/// HTTPValidationError -/// -/// Properties: -/// * [detail] -@BuiltValue() -abstract class HTTPValidationError - implements Built { - @BuiltValueField(wireName: r'detail') - BuiltList? get detail; - - HTTPValidationError._(); - - factory HTTPValidationError([void updates(HTTPValidationErrorBuilder b)]) = - _$HTTPValidationError; - - @BuiltValueHook(initializeBuilder: true) - static void _defaults(HTTPValidationErrorBuilder b) => b; - - @BuiltValueSerializer(custom: true) - static Serializer get serializer => - _$HTTPValidationErrorSerializer(); -} - -class _$HTTPValidationErrorSerializer - implements PrimitiveSerializer { - @override - final Iterable types = const [ - HTTPValidationError, - _$HTTPValidationError - ]; - - @override - final String wireName = r'HTTPValidationError'; - - Iterable _serializeProperties( - Serializers serializers, - HTTPValidationError object, { - FullType specifiedType = FullType.unspecified, - }) sync* { - if (object.detail != null) { - yield r'detail'; - yield serializers.serialize( - object.detail, - specifiedType: const FullType(BuiltList, [FullType(ValidationError)]), - ); - } - } - - @override - Object serialize( - Serializers serializers, - HTTPValidationError object, { - FullType specifiedType = FullType.unspecified, - }) { - return _serializeProperties(serializers, object, - specifiedType: specifiedType) - .toList(); - } - - void _deserializeProperties( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - required List serializedList, - required HTTPValidationErrorBuilder result, - required List unhandled, - }) { - for (var i = 0; i < serializedList.length; i += 2) { - final key = serializedList[i] as String; - final value = serializedList[i + 1]; - switch (key) { - case r'detail': - final valueDes = serializers.deserialize( - value, - specifiedType: - const FullType(BuiltList, [FullType(ValidationError)]), - ) as BuiltList; - result.detail.replace(valueDes); - break; - default: - unhandled.add(key); - unhandled.add(value); - break; - } - } - } - - @override - HTTPValidationError deserialize( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final result = HTTPValidationErrorBuilder(); - final serializedList = (serialized as Iterable).toList(); - final unhandled = []; - _deserializeProperties( - serializers, - serialized, - specifiedType: specifiedType, - serializedList: serializedList, - unhandled: unhandled, - result: result, - ); - return result.build(); - } -} diff --git a/lib/api_sub_project/src/model/http_validation_error.g.dart b/lib/api_sub_project/src/model/http_validation_error.g.dart deleted file mode 100644 index 40ab1a8..0000000 --- a/lib/api_sub_project/src/model/http_validation_error.g.dart +++ /dev/null @@ -1,106 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'http_validation_error.dart'; - -// ************************************************************************** -// BuiltValueGenerator -// ************************************************************************** - -class _$HTTPValidationError extends HTTPValidationError { - @override - final BuiltList? detail; - - factory _$HTTPValidationError( - [void Function(HTTPValidationErrorBuilder)? updates]) => - (new HTTPValidationErrorBuilder()..update(updates))._build(); - - _$HTTPValidationError._({this.detail}) : super._(); - - @override - HTTPValidationError rebuild( - void Function(HTTPValidationErrorBuilder) updates) => - (toBuilder()..update(updates)).build(); - - @override - HTTPValidationErrorBuilder toBuilder() => - new HTTPValidationErrorBuilder()..replace(this); - - @override - bool operator ==(Object other) { - if (identical(other, this)) return true; - return other is HTTPValidationError && detail == other.detail; - } - - @override - int get hashCode { - var _$hash = 0; - _$hash = $jc(_$hash, detail.hashCode); - _$hash = $jf(_$hash); - return _$hash; - } - - @override - String toString() { - return (newBuiltValueToStringHelper(r'HTTPValidationError') - ..add('detail', detail)) - .toString(); - } -} - -class HTTPValidationErrorBuilder - implements Builder { - _$HTTPValidationError? _$v; - - ListBuilder? _detail; - ListBuilder get detail => - _$this._detail ??= new ListBuilder(); - set detail(ListBuilder? detail) => _$this._detail = detail; - - HTTPValidationErrorBuilder() { - HTTPValidationError._defaults(this); - } - - HTTPValidationErrorBuilder get _$this { - final $v = _$v; - if ($v != null) { - _detail = $v.detail?.toBuilder(); - _$v = null; - } - return this; - } - - @override - void replace(HTTPValidationError other) { - ArgumentError.checkNotNull(other, 'other'); - _$v = other as _$HTTPValidationError; - } - - @override - void update(void Function(HTTPValidationErrorBuilder)? updates) { - if (updates != null) updates(this); - } - - @override - HTTPValidationError build() => _build(); - - _$HTTPValidationError _build() { - _$HTTPValidationError _$result; - try { - _$result = _$v ?? new _$HTTPValidationError._(detail: _detail?.build()); - } catch (_) { - late String _$failedField; - try { - _$failedField = 'detail'; - _detail?.build(); - } catch (e) { - throw new BuiltValueNestedFieldError( - r'HTTPValidationError', _$failedField, e.toString()); - } - rethrow; - } - replace(_$result); - return _$result; - } -} - -// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/lib/api_sub_project/src/model/items_field_selector_list.dart b/lib/api_sub_project/src/model/items_field_selector_list.dart deleted file mode 100644 index 9d04644..0000000 --- a/lib/api_sub_project/src/model/items_field_selector_list.dart +++ /dev/null @@ -1,110 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// - -// ignore_for_file: unused_element -import 'package:built_collection/built_collection.dart'; -import 'package:built_value/built_value.dart'; -import 'package:built_value/serializer.dart'; - -part 'items_field_selector_list.g.dart'; - -/// ItemsFieldSelectorList -/// -/// Properties: -/// * [fields] -@BuiltValue() -abstract class ItemsFieldSelectorList implements Built { - @BuiltValueField(wireName: r'fields') - BuiltList? get fields; - - ItemsFieldSelectorList._(); - - factory ItemsFieldSelectorList([void updates(ItemsFieldSelectorListBuilder b)]) = _$ItemsFieldSelectorList; - - @BuiltValueHook(initializeBuilder: true) - static void _defaults(ItemsFieldSelectorListBuilder b) => b - ..fields = ListBuilder(); - - @BuiltValueSerializer(custom: true) - static Serializer get serializer => _$ItemsFieldSelectorListSerializer(); -} - -class _$ItemsFieldSelectorListSerializer implements PrimitiveSerializer { - @override - final Iterable types = const [ItemsFieldSelectorList, _$ItemsFieldSelectorList]; - - @override - final String wireName = r'ItemsFieldSelectorList'; - - Iterable _serializeProperties( - Serializers serializers, - ItemsFieldSelectorList object, { - FullType specifiedType = FullType.unspecified, - }) sync* { - if (object.fields != null) { - yield r'fields'; - yield serializers.serialize( - object.fields, - specifiedType: const FullType(BuiltList, [FullType(String)]), - ); - } - } - - @override - Object serialize( - Serializers serializers, - ItemsFieldSelectorList object, { - FullType specifiedType = FullType.unspecified, - }) { - return _serializeProperties(serializers, object, specifiedType: specifiedType).toList(); - } - - void _deserializeProperties( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - required List serializedList, - required ItemsFieldSelectorListBuilder result, - required List unhandled, - }) { - for (var i = 0; i < serializedList.length; i += 2) { - final key = serializedList[i] as String; - final value = serializedList[i + 1]; - switch (key) { - case r'fields': - final valueDes = serializers.deserialize( - value, - specifiedType: const FullType(BuiltList, [FullType(String)]), - ) as BuiltList; - result.fields.replace(valueDes); - break; - default: - unhandled.add(key); - unhandled.add(value); - break; - } - } - } - - @override - ItemsFieldSelectorList deserialize( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final result = ItemsFieldSelectorListBuilder(); - final serializedList = (serialized as Iterable).toList(); - final unhandled = []; - _deserializeProperties( - serializers, - serialized, - specifiedType: specifiedType, - serializedList: serializedList, - unhandled: unhandled, - result: result, - ); - return result.build(); - } -} - diff --git a/lib/api_sub_project/src/model/items_field_selector_list.g.dart b/lib/api_sub_project/src/model/items_field_selector_list.g.dart deleted file mode 100644 index 18d1543..0000000 --- a/lib/api_sub_project/src/model/items_field_selector_list.g.dart +++ /dev/null @@ -1,107 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'items_field_selector_list.dart'; - -// ************************************************************************** -// BuiltValueGenerator -// ************************************************************************** - -class _$ItemsFieldSelectorList extends ItemsFieldSelectorList { - @override - final BuiltList? fields; - - factory _$ItemsFieldSelectorList( - [void Function(ItemsFieldSelectorListBuilder)? updates]) => - (new ItemsFieldSelectorListBuilder()..update(updates))._build(); - - _$ItemsFieldSelectorList._({this.fields}) : super._(); - - @override - ItemsFieldSelectorList rebuild( - void Function(ItemsFieldSelectorListBuilder) updates) => - (toBuilder()..update(updates)).build(); - - @override - ItemsFieldSelectorListBuilder toBuilder() => - new ItemsFieldSelectorListBuilder()..replace(this); - - @override - bool operator ==(Object other) { - if (identical(other, this)) return true; - return other is ItemsFieldSelectorList && fields == other.fields; - } - - @override - int get hashCode { - var _$hash = 0; - _$hash = $jc(_$hash, fields.hashCode); - _$hash = $jf(_$hash); - return _$hash; - } - - @override - String toString() { - return (newBuiltValueToStringHelper(r'ItemsFieldSelectorList') - ..add('fields', fields)) - .toString(); - } -} - -class ItemsFieldSelectorListBuilder - implements Builder { - _$ItemsFieldSelectorList? _$v; - - ListBuilder? _fields; - ListBuilder get fields => - _$this._fields ??= new ListBuilder(); - set fields(ListBuilder? fields) => _$this._fields = fields; - - ItemsFieldSelectorListBuilder() { - ItemsFieldSelectorList._defaults(this); - } - - ItemsFieldSelectorListBuilder get _$this { - final $v = _$v; - if ($v != null) { - _fields = $v.fields?.toBuilder(); - _$v = null; - } - return this; - } - - @override - void replace(ItemsFieldSelectorList other) { - ArgumentError.checkNotNull(other, 'other'); - _$v = other as _$ItemsFieldSelectorList; - } - - @override - void update(void Function(ItemsFieldSelectorListBuilder)? updates) { - if (updates != null) updates(this); - } - - @override - ItemsFieldSelectorList build() => _build(); - - _$ItemsFieldSelectorList _build() { - _$ItemsFieldSelectorList _$result; - try { - _$result = - _$v ?? new _$ItemsFieldSelectorList._(fields: _fields?.build()); - } catch (_) { - late String _$failedField; - try { - _$failedField = 'fields'; - _fields?.build(); - } catch (e) { - throw new BuiltValueNestedFieldError( - r'ItemsFieldSelectorList', _$failedField, e.toString()); - } - rethrow; - } - replace(_$result); - return _$result; - } -} - -// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/lib/api_sub_project/src/model/location_inner.dart b/lib/api_sub_project/src/model/location_inner.dart deleted file mode 100644 index 5a96d05..0000000 --- a/lib/api_sub_project/src/model/location_inner.dart +++ /dev/null @@ -1,68 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// - -// ignore_for_file: unused_element -import 'dart:core'; -import 'package:built_value/built_value.dart'; -import 'package:built_value/serializer.dart'; -import 'package:one_of/any_of.dart'; - -part 'location_inner.g.dart'; - -/// LocationInner -@BuiltValue() -abstract class LocationInner implements Built { - /// Any Of [String], [int] - AnyOf get anyOf; - - LocationInner._(); - - factory LocationInner([void updates(LocationInnerBuilder b)]) = _$LocationInner; - - @BuiltValueHook(initializeBuilder: true) - static void _defaults(LocationInnerBuilder b) => b; - - @BuiltValueSerializer(custom: true) - static Serializer get serializer => _$LocationInnerSerializer(); -} - -class _$LocationInnerSerializer implements PrimitiveSerializer { - @override - final Iterable types = const [LocationInner, _$LocationInner]; - - @override - final String wireName = r'LocationInner'; - - Iterable _serializeProperties( - Serializers serializers, - LocationInner object, { - FullType specifiedType = FullType.unspecified, - }) sync* { - } - - @override - Object serialize( - Serializers serializers, - LocationInner object, { - FullType specifiedType = FullType.unspecified, - }) { - final anyOf = object.anyOf; - return serializers.serialize(anyOf, specifiedType: FullType(AnyOf, anyOf.valueTypes.map((type) => FullType(type)).toList()))!; - } - - @override - LocationInner deserialize( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final result = LocationInnerBuilder(); - Object? anyOfDataSrc; - final targetType = const FullType(AnyOf, [FullType(String), FullType(int), ]); - anyOfDataSrc = serialized; - result.anyOf = serializers.deserialize(anyOfDataSrc, specifiedType: targetType) as AnyOf; - return result.build(); - } -} - diff --git a/lib/api_sub_project/src/model/location_inner.g.dart b/lib/api_sub_project/src/model/location_inner.g.dart deleted file mode 100644 index 0cbf218..0000000 --- a/lib/api_sub_project/src/model/location_inner.g.dart +++ /dev/null @@ -1,93 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'location_inner.dart'; - -// ************************************************************************** -// BuiltValueGenerator -// ************************************************************************** - -class _$LocationInner extends LocationInner { - @override - final AnyOf anyOf; - - factory _$LocationInner([void Function(LocationInnerBuilder)? updates]) => - (new LocationInnerBuilder()..update(updates))._build(); - - _$LocationInner._({required this.anyOf}) : super._() { - BuiltValueNullFieldError.checkNotNull(anyOf, r'LocationInner', 'anyOf'); - } - - @override - LocationInner rebuild(void Function(LocationInnerBuilder) updates) => - (toBuilder()..update(updates)).build(); - - @override - LocationInnerBuilder toBuilder() => new LocationInnerBuilder()..replace(this); - - @override - bool operator ==(Object other) { - if (identical(other, this)) return true; - return other is LocationInner && anyOf == other.anyOf; - } - - @override - int get hashCode { - var _$hash = 0; - _$hash = $jc(_$hash, anyOf.hashCode); - _$hash = $jf(_$hash); - return _$hash; - } - - @override - String toString() { - return (newBuiltValueToStringHelper(r'LocationInner')..add('anyOf', anyOf)) - .toString(); - } -} - -class LocationInnerBuilder - implements Builder { - _$LocationInner? _$v; - - AnyOf? _anyOf; - AnyOf? get anyOf => _$this._anyOf; - set anyOf(AnyOf? anyOf) => _$this._anyOf = anyOf; - - LocationInnerBuilder() { - LocationInner._defaults(this); - } - - LocationInnerBuilder get _$this { - final $v = _$v; - if ($v != null) { - _anyOf = $v.anyOf; - _$v = null; - } - return this; - } - - @override - void replace(LocationInner other) { - ArgumentError.checkNotNull(other, 'other'); - _$v = other as _$LocationInner; - } - - @override - void update(void Function(LocationInnerBuilder)? updates) { - if (updates != null) updates(this); - } - - @override - LocationInner build() => _build(); - - _$LocationInner _build() { - final _$result = _$v ?? - new _$LocationInner._( - anyOf: BuiltValueNullFieldError.checkNotNull( - anyOf, r'LocationInner', 'anyOf')); - replace(_$result); - return _$result; - } -} - -// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/lib/api_sub_project/src/model/ok_response.dart b/lib/api_sub_project/src/model/ok_response.dart deleted file mode 100644 index 9450d1a..0000000 --- a/lib/api_sub_project/src/model/ok_response.dart +++ /dev/null @@ -1,109 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// - -// ignore_for_file: unused_element -import 'package:built_value/built_value.dart'; -import 'package:built_value/serializer.dart'; - -part 'ok_response.g.dart'; - -/// OkResponse -/// -/// Properties: -/// * [ok] -@BuiltValue() -abstract class OkResponse implements Built { - @BuiltValueField(wireName: r'ok') - bool? get ok; - - OkResponse._(); - - factory OkResponse([void updates(OkResponseBuilder b)]) = _$OkResponse; - - @BuiltValueHook(initializeBuilder: true) - static void _defaults(OkResponseBuilder b) => b - ..ok = true; - - @BuiltValueSerializer(custom: true) - static Serializer get serializer => _$OkResponseSerializer(); -} - -class _$OkResponseSerializer implements PrimitiveSerializer { - @override - final Iterable types = const [OkResponse, _$OkResponse]; - - @override - final String wireName = r'OkResponse'; - - Iterable _serializeProperties( - Serializers serializers, - OkResponse object, { - FullType specifiedType = FullType.unspecified, - }) sync* { - if (object.ok != null) { - yield r'ok'; - yield serializers.serialize( - object.ok, - specifiedType: const FullType(bool), - ); - } - } - - @override - Object serialize( - Serializers serializers, - OkResponse object, { - FullType specifiedType = FullType.unspecified, - }) { - return _serializeProperties(serializers, object, specifiedType: specifiedType).toList(); - } - - void _deserializeProperties( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - required List serializedList, - required OkResponseBuilder result, - required List unhandled, - }) { - for (var i = 0; i < serializedList.length; i += 2) { - final key = serializedList[i] as String; - final value = serializedList[i + 1]; - switch (key) { - case r'ok': - final valueDes = serializers.deserialize( - value, - specifiedType: const FullType(bool), - ) as bool; - result.ok = valueDes; - break; - default: - unhandled.add(key); - unhandled.add(value); - break; - } - } - } - - @override - OkResponse deserialize( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final result = OkResponseBuilder(); - final serializedList = (serialized as Iterable).toList(); - final unhandled = []; - _deserializeProperties( - serializers, - serialized, - specifiedType: specifiedType, - serializedList: serializedList, - unhandled: unhandled, - result: result, - ); - return result.build(); - } -} - diff --git a/lib/api_sub_project/src/model/ok_response.g.dart b/lib/api_sub_project/src/model/ok_response.g.dart deleted file mode 100644 index 10a1287..0000000 --- a/lib/api_sub_project/src/model/ok_response.g.dart +++ /dev/null @@ -1,87 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'ok_response.dart'; - -// ************************************************************************** -// BuiltValueGenerator -// ************************************************************************** - -class _$OkResponse extends OkResponse { - @override - final bool? ok; - - factory _$OkResponse([void Function(OkResponseBuilder)? updates]) => - (new OkResponseBuilder()..update(updates))._build(); - - _$OkResponse._({this.ok}) : super._(); - - @override - OkResponse rebuild(void Function(OkResponseBuilder) updates) => - (toBuilder()..update(updates)).build(); - - @override - OkResponseBuilder toBuilder() => new OkResponseBuilder()..replace(this); - - @override - bool operator ==(Object other) { - if (identical(other, this)) return true; - return other is OkResponse && ok == other.ok; - } - - @override - int get hashCode { - var _$hash = 0; - _$hash = $jc(_$hash, ok.hashCode); - _$hash = $jf(_$hash); - return _$hash; - } - - @override - String toString() { - return (newBuiltValueToStringHelper(r'OkResponse')..add('ok', ok)) - .toString(); - } -} - -class OkResponseBuilder implements Builder { - _$OkResponse? _$v; - - bool? _ok; - bool? get ok => _$this._ok; - set ok(bool? ok) => _$this._ok = ok; - - OkResponseBuilder() { - OkResponse._defaults(this); - } - - OkResponseBuilder get _$this { - final $v = _$v; - if ($v != null) { - _ok = $v.ok; - _$v = null; - } - return this; - } - - @override - void replace(OkResponse other) { - ArgumentError.checkNotNull(other, 'other'); - _$v = other as _$OkResponse; - } - - @override - void update(void Function(OkResponseBuilder)? updates) { - if (updates != null) updates(this); - } - - @override - OkResponse build() => _build(); - - _$OkResponse _build() { - final _$result = _$v ?? new _$OkResponse._(ok: ok); - replace(_$result); - return _$result; - } -} - -// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/lib/api_sub_project/src/model/table_definition.dart b/lib/api_sub_project/src/model/table_definition.dart deleted file mode 100644 index 0356392..0000000 --- a/lib/api_sub_project/src/model/table_definition.dart +++ /dev/null @@ -1,170 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// - -// ignore_for_file: unused_element -import 'package:built_value/built_value.dart'; -import 'package:built_value/serializer.dart'; - -part 'table_definition.g.dart'; - -/// TableDefinition -/// -/// Properties: -/// * [tableId] -/// * [tableName] -/// * [columns] -/// * [system] -/// * [hidden] -@BuiltValue() -abstract class TableDefinition implements Built { - @BuiltValueField(wireName: r'table_id') - String get tableId; - - @BuiltValueField(wireName: r'table_name') - String get tableName; - - @BuiltValueField(wireName: r'columns') - String get columns; - - @BuiltValueField(wireName: r'system') - bool get system; - - @BuiltValueField(wireName: r'hidden') - bool get hidden; - - TableDefinition._(); - - factory TableDefinition([void updates(TableDefinitionBuilder b)]) = _$TableDefinition; - - @BuiltValueHook(initializeBuilder: true) - static void _defaults(TableDefinitionBuilder b) => b; - - @BuiltValueSerializer(custom: true) - static Serializer get serializer => _$TableDefinitionSerializer(); -} - -class _$TableDefinitionSerializer implements PrimitiveSerializer { - @override - final Iterable types = const [TableDefinition, _$TableDefinition]; - - @override - final String wireName = r'TableDefinition'; - - Iterable _serializeProperties( - Serializers serializers, - TableDefinition object, { - FullType specifiedType = FullType.unspecified, - }) sync* { - yield r'table_id'; - yield serializers.serialize( - object.tableId, - specifiedType: const FullType(String), - ); - yield r'table_name'; - yield serializers.serialize( - object.tableName, - specifiedType: const FullType(String), - ); - yield r'columns'; - yield serializers.serialize( - object.columns, - specifiedType: const FullType(String), - ); - yield r'system'; - yield serializers.serialize( - object.system, - specifiedType: const FullType(bool), - ); - yield r'hidden'; - yield serializers.serialize( - object.hidden, - specifiedType: const FullType(bool), - ); - } - - @override - Object serialize( - Serializers serializers, - TableDefinition object, { - FullType specifiedType = FullType.unspecified, - }) { - return _serializeProperties(serializers, object, specifiedType: specifiedType).toList(); - } - - void _deserializeProperties( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - required List serializedList, - required TableDefinitionBuilder result, - required List unhandled, - }) { - for (var i = 0; i < serializedList.length; i += 2) { - final key = serializedList[i] as String; - final value = serializedList[i + 1]; - switch (key) { - case r'table_id': - final valueDes = serializers.deserialize( - value, - specifiedType: const FullType(String), - ) as String; - result.tableId = valueDes; - break; - case r'table_name': - final valueDes = serializers.deserialize( - value, - specifiedType: const FullType(String), - ) as String; - result.tableName = valueDes; - break; - case r'columns': - final valueDes = serializers.deserialize( - value, - specifiedType: const FullType(String), - ) as String; - result.columns = valueDes; - break; - case r'system': - final valueDes = serializers.deserialize( - value, - specifiedType: const FullType(bool), - ) as bool; - result.system = valueDes; - break; - case r'hidden': - final valueDes = serializers.deserialize( - value, - specifiedType: const FullType(bool), - ) as bool; - result.hidden = valueDes; - break; - default: - unhandled.add(key); - unhandled.add(value); - break; - } - } - } - - @override - TableDefinition deserialize( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final result = TableDefinitionBuilder(); - final serializedList = (serialized as Iterable).toList(); - final unhandled = []; - _deserializeProperties( - serializers, - serialized, - specifiedType: specifiedType, - serializedList: serializedList, - unhandled: unhandled, - result: result, - ); - return result.build(); - } -} - diff --git a/lib/api_sub_project/src/model/table_definition.g.dart b/lib/api_sub_project/src/model/table_definition.g.dart deleted file mode 100644 index be971e9..0000000 --- a/lib/api_sub_project/src/model/table_definition.g.dart +++ /dev/null @@ -1,157 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'table_definition.dart'; - -// ************************************************************************** -// BuiltValueGenerator -// ************************************************************************** - -class _$TableDefinition extends TableDefinition { - @override - final String tableId; - @override - final String tableName; - @override - final String columns; - @override - final bool system; - @override - final bool hidden; - - factory _$TableDefinition([void Function(TableDefinitionBuilder)? updates]) => - (new TableDefinitionBuilder()..update(updates))._build(); - - _$TableDefinition._( - {required this.tableId, - required this.tableName, - required this.columns, - required this.system, - required this.hidden}) - : super._() { - BuiltValueNullFieldError.checkNotNull( - tableId, r'TableDefinition', 'tableId'); - BuiltValueNullFieldError.checkNotNull( - tableName, r'TableDefinition', 'tableName'); - BuiltValueNullFieldError.checkNotNull( - columns, r'TableDefinition', 'columns'); - BuiltValueNullFieldError.checkNotNull(system, r'TableDefinition', 'system'); - BuiltValueNullFieldError.checkNotNull(hidden, r'TableDefinition', 'hidden'); - } - - @override - TableDefinition rebuild(void Function(TableDefinitionBuilder) updates) => - (toBuilder()..update(updates)).build(); - - @override - TableDefinitionBuilder toBuilder() => - new TableDefinitionBuilder()..replace(this); - - @override - bool operator ==(Object other) { - if (identical(other, this)) return true; - return other is TableDefinition && - tableId == other.tableId && - tableName == other.tableName && - columns == other.columns && - system == other.system && - hidden == other.hidden; - } - - @override - int get hashCode { - var _$hash = 0; - _$hash = $jc(_$hash, tableId.hashCode); - _$hash = $jc(_$hash, tableName.hashCode); - _$hash = $jc(_$hash, columns.hashCode); - _$hash = $jc(_$hash, system.hashCode); - _$hash = $jc(_$hash, hidden.hashCode); - _$hash = $jf(_$hash); - return _$hash; - } - - @override - String toString() { - return (newBuiltValueToStringHelper(r'TableDefinition') - ..add('tableId', tableId) - ..add('tableName', tableName) - ..add('columns', columns) - ..add('system', system) - ..add('hidden', hidden)) - .toString(); - } -} - -class TableDefinitionBuilder - implements Builder { - _$TableDefinition? _$v; - - String? _tableId; - String? get tableId => _$this._tableId; - set tableId(String? tableId) => _$this._tableId = tableId; - - String? _tableName; - String? get tableName => _$this._tableName; - set tableName(String? tableName) => _$this._tableName = tableName; - - String? _columns; - String? get columns => _$this._columns; - set columns(String? columns) => _$this._columns = columns; - - bool? _system; - bool? get system => _$this._system; - set system(bool? system) => _$this._system = system; - - bool? _hidden; - bool? get hidden => _$this._hidden; - set hidden(bool? hidden) => _$this._hidden = hidden; - - TableDefinitionBuilder() { - TableDefinition._defaults(this); - } - - TableDefinitionBuilder get _$this { - final $v = _$v; - if ($v != null) { - _tableId = $v.tableId; - _tableName = $v.tableName; - _columns = $v.columns; - _system = $v.system; - _hidden = $v.hidden; - _$v = null; - } - return this; - } - - @override - void replace(TableDefinition other) { - ArgumentError.checkNotNull(other, 'other'); - _$v = other as _$TableDefinition; - } - - @override - void update(void Function(TableDefinitionBuilder)? updates) { - if (updates != null) updates(this); - } - - @override - TableDefinition build() => _build(); - - _$TableDefinition _build() { - final _$result = _$v ?? - new _$TableDefinition._( - tableId: BuiltValueNullFieldError.checkNotNull( - tableId, r'TableDefinition', 'tableId'), - tableName: BuiltValueNullFieldError.checkNotNull( - tableName, r'TableDefinition', 'tableName'), - columns: BuiltValueNullFieldError.checkNotNull( - columns, r'TableDefinition', 'columns'), - system: BuiltValueNullFieldError.checkNotNull( - system, r'TableDefinition', 'system'), - hidden: BuiltValueNullFieldError.checkNotNull( - hidden, r'TableDefinition', 'hidden')); - replace(_$result); - return _$result; - } -} - -// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/lib/api_sub_project/src/model/table_items_response.dart b/lib/api_sub_project/src/model/table_items_response.dart deleted file mode 100644 index fabf448..0000000 --- a/lib/api_sub_project/src/model/table_items_response.dart +++ /dev/null @@ -1,108 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// - -// ignore_for_file: unused_element -import 'package:built_collection/built_collection.dart'; -import 'package:built_value/json_object.dart'; -import 'package:built_value/built_value.dart'; -import 'package:built_value/serializer.dart'; - -part 'table_items_response.g.dart'; - -/// TableItemsResponse -/// -/// Properties: -/// * [items] -@BuiltValue() -abstract class TableItemsResponse implements Built { - @BuiltValueField(wireName: r'items') - BuiltList get items; - - TableItemsResponse._(); - - factory TableItemsResponse([void updates(TableItemsResponseBuilder b)]) = _$TableItemsResponse; - - @BuiltValueHook(initializeBuilder: true) - static void _defaults(TableItemsResponseBuilder b) => b; - - @BuiltValueSerializer(custom: true) - static Serializer get serializer => _$TableItemsResponseSerializer(); -} - -class _$TableItemsResponseSerializer implements PrimitiveSerializer { - @override - final Iterable types = const [TableItemsResponse, _$TableItemsResponse]; - - @override - final String wireName = r'TableItemsResponse'; - - Iterable _serializeProperties( - Serializers serializers, - TableItemsResponse object, { - FullType specifiedType = FullType.unspecified, - }) sync* { - yield r'items'; - yield serializers.serialize( - object.items, - specifiedType: const FullType(BuiltList, [FullType(JsonObject)]), - ); - } - - @override - Object serialize( - Serializers serializers, - TableItemsResponse object, { - FullType specifiedType = FullType.unspecified, - }) { - return _serializeProperties(serializers, object, specifiedType: specifiedType).toList(); - } - - void _deserializeProperties( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - required List serializedList, - required TableItemsResponseBuilder result, - required List unhandled, - }) { - for (var i = 0; i < serializedList.length; i += 2) { - final key = serializedList[i] as String; - final value = serializedList[i + 1]; - switch (key) { - case r'items': - final valueDes = serializers.deserialize( - value, - specifiedType: const FullType(BuiltList, [FullType(JsonObject)]), - ) as BuiltList; - result.items.replace(valueDes); - break; - default: - unhandled.add(key); - unhandled.add(value); - break; - } - } - } - - @override - TableItemsResponse deserialize( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final result = TableItemsResponseBuilder(); - final serializedList = (serialized as Iterable).toList(); - final unhandled = []; - _deserializeProperties( - serializers, - serialized, - specifiedType: specifiedType, - serializedList: serializedList, - unhandled: unhandled, - result: result, - ); - return result.build(); - } -} - diff --git a/lib/api_sub_project/src/model/table_items_response.g.dart b/lib/api_sub_project/src/model/table_items_response.g.dart deleted file mode 100644 index d104f56..0000000 --- a/lib/api_sub_project/src/model/table_items_response.g.dart +++ /dev/null @@ -1,109 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'table_items_response.dart'; - -// ************************************************************************** -// BuiltValueGenerator -// ************************************************************************** - -class _$TableItemsResponse extends TableItemsResponse { - @override - final BuiltList items; - - factory _$TableItemsResponse( - [void Function(TableItemsResponseBuilder)? updates]) => - (new TableItemsResponseBuilder()..update(updates))._build(); - - _$TableItemsResponse._({required this.items}) : super._() { - BuiltValueNullFieldError.checkNotNull( - items, r'TableItemsResponse', 'items'); - } - - @override - TableItemsResponse rebuild( - void Function(TableItemsResponseBuilder) updates) => - (toBuilder()..update(updates)).build(); - - @override - TableItemsResponseBuilder toBuilder() => - new TableItemsResponseBuilder()..replace(this); - - @override - bool operator ==(Object other) { - if (identical(other, this)) return true; - return other is TableItemsResponse && items == other.items; - } - - @override - int get hashCode { - var _$hash = 0; - _$hash = $jc(_$hash, items.hashCode); - _$hash = $jf(_$hash); - return _$hash; - } - - @override - String toString() { - return (newBuiltValueToStringHelper(r'TableItemsResponse') - ..add('items', items)) - .toString(); - } -} - -class TableItemsResponseBuilder - implements Builder { - _$TableItemsResponse? _$v; - - ListBuilder? _items; - ListBuilder get items => - _$this._items ??= new ListBuilder(); - set items(ListBuilder? items) => _$this._items = items; - - TableItemsResponseBuilder() { - TableItemsResponse._defaults(this); - } - - TableItemsResponseBuilder get _$this { - final $v = _$v; - if ($v != null) { - _items = $v.items.toBuilder(); - _$v = null; - } - return this; - } - - @override - void replace(TableItemsResponse other) { - ArgumentError.checkNotNull(other, 'other'); - _$v = other as _$TableItemsResponse; - } - - @override - void update(void Function(TableItemsResponseBuilder)? updates) { - if (updates != null) updates(this); - } - - @override - TableItemsResponse build() => _build(); - - _$TableItemsResponse _build() { - _$TableItemsResponse _$result; - try { - _$result = _$v ?? new _$TableItemsResponse._(items: items.build()); - } catch (_) { - late String _$failedField; - try { - _$failedField = 'items'; - items.build(); - } catch (e) { - throw new BuiltValueNestedFieldError( - r'TableItemsResponse', _$failedField, e.toString()); - } - rethrow; - } - replace(_$result); - return _$result; - } -} - -// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/lib/api_sub_project/src/model/user_update_definition.dart b/lib/api_sub_project/src/model/user_update_definition.dart deleted file mode 100644 index c1ba572..0000000 --- a/lib/api_sub_project/src/model/user_update_definition.dart +++ /dev/null @@ -1,138 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// - -// ignore_for_file: unused_element -import 'package:built_value/built_value.dart'; -import 'package:built_value/serializer.dart'; - -part 'user_update_definition.g.dart'; - -/// UserUpdateDefinition -/// -/// Properties: -/// * [userId] -/// * [password] -/// * [accessToken] -@BuiltValue() -abstract class UserUpdateDefinition implements Built { - @BuiltValueField(wireName: r'user_id') - int get userId; - - @BuiltValueField(wireName: r'password') - String get password; - - @BuiltValueField(wireName: r'access_token') - String get accessToken; - - UserUpdateDefinition._(); - - factory UserUpdateDefinition([void updates(UserUpdateDefinitionBuilder b)]) = _$UserUpdateDefinition; - - @BuiltValueHook(initializeBuilder: true) - static void _defaults(UserUpdateDefinitionBuilder b) => b; - - @BuiltValueSerializer(custom: true) - static Serializer get serializer => _$UserUpdateDefinitionSerializer(); -} - -class _$UserUpdateDefinitionSerializer implements PrimitiveSerializer { - @override - final Iterable types = const [UserUpdateDefinition, _$UserUpdateDefinition]; - - @override - final String wireName = r'UserUpdateDefinition'; - - Iterable _serializeProperties( - Serializers serializers, - UserUpdateDefinition object, { - FullType specifiedType = FullType.unspecified, - }) sync* { - yield r'user_id'; - yield serializers.serialize( - object.userId, - specifiedType: const FullType(int), - ); - yield r'password'; - yield serializers.serialize( - object.password, - specifiedType: const FullType(String), - ); - yield r'access_token'; - yield serializers.serialize( - object.accessToken, - specifiedType: const FullType(String), - ); - } - - @override - Object serialize( - Serializers serializers, - UserUpdateDefinition object, { - FullType specifiedType = FullType.unspecified, - }) { - return _serializeProperties(serializers, object, specifiedType: specifiedType).toList(); - } - - void _deserializeProperties( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - required List serializedList, - required UserUpdateDefinitionBuilder result, - required List unhandled, - }) { - for (var i = 0; i < serializedList.length; i += 2) { - final key = serializedList[i] as String; - final value = serializedList[i + 1]; - switch (key) { - case r'user_id': - final valueDes = serializers.deserialize( - value, - specifiedType: const FullType(int), - ) as int; - result.userId = valueDes; - break; - case r'password': - final valueDes = serializers.deserialize( - value, - specifiedType: const FullType(String), - ) as String; - result.password = valueDes; - break; - case r'access_token': - final valueDes = serializers.deserialize( - value, - specifiedType: const FullType(String), - ) as String; - result.accessToken = valueDes; - break; - default: - unhandled.add(key); - unhandled.add(value); - break; - } - } - } - - @override - UserUpdateDefinition deserialize( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final result = UserUpdateDefinitionBuilder(); - final serializedList = (serialized as Iterable).toList(); - final unhandled = []; - _deserializeProperties( - serializers, - serialized, - specifiedType: specifiedType, - serializedList: serializedList, - unhandled: unhandled, - result: result, - ); - return result.build(); - } -} - diff --git a/lib/api_sub_project/src/model/user_update_definition.g.dart b/lib/api_sub_project/src/model/user_update_definition.g.dart deleted file mode 100644 index 3db2653..0000000 --- a/lib/api_sub_project/src/model/user_update_definition.g.dart +++ /dev/null @@ -1,129 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'user_update_definition.dart'; - -// ************************************************************************** -// BuiltValueGenerator -// ************************************************************************** - -class _$UserUpdateDefinition extends UserUpdateDefinition { - @override - final int userId; - @override - final String password; - @override - final String accessToken; - - factory _$UserUpdateDefinition( - [void Function(UserUpdateDefinitionBuilder)? updates]) => - (new UserUpdateDefinitionBuilder()..update(updates))._build(); - - _$UserUpdateDefinition._( - {required this.userId, required this.password, required this.accessToken}) - : super._() { - BuiltValueNullFieldError.checkNotNull( - userId, r'UserUpdateDefinition', 'userId'); - BuiltValueNullFieldError.checkNotNull( - password, r'UserUpdateDefinition', 'password'); - BuiltValueNullFieldError.checkNotNull( - accessToken, r'UserUpdateDefinition', 'accessToken'); - } - - @override - UserUpdateDefinition rebuild( - void Function(UserUpdateDefinitionBuilder) updates) => - (toBuilder()..update(updates)).build(); - - @override - UserUpdateDefinitionBuilder toBuilder() => - new UserUpdateDefinitionBuilder()..replace(this); - - @override - bool operator ==(Object other) { - if (identical(other, this)) return true; - return other is UserUpdateDefinition && - userId == other.userId && - password == other.password && - accessToken == other.accessToken; - } - - @override - int get hashCode { - var _$hash = 0; - _$hash = $jc(_$hash, userId.hashCode); - _$hash = $jc(_$hash, password.hashCode); - _$hash = $jc(_$hash, accessToken.hashCode); - _$hash = $jf(_$hash); - return _$hash; - } - - @override - String toString() { - return (newBuiltValueToStringHelper(r'UserUpdateDefinition') - ..add('userId', userId) - ..add('password', password) - ..add('accessToken', accessToken)) - .toString(); - } -} - -class UserUpdateDefinitionBuilder - implements Builder { - _$UserUpdateDefinition? _$v; - - int? _userId; - int? get userId => _$this._userId; - set userId(int? userId) => _$this._userId = userId; - - String? _password; - String? get password => _$this._password; - set password(String? password) => _$this._password = password; - - String? _accessToken; - String? get accessToken => _$this._accessToken; - set accessToken(String? accessToken) => _$this._accessToken = accessToken; - - UserUpdateDefinitionBuilder() { - UserUpdateDefinition._defaults(this); - } - - UserUpdateDefinitionBuilder get _$this { - final $v = _$v; - if ($v != null) { - _userId = $v.userId; - _password = $v.password; - _accessToken = $v.accessToken; - _$v = null; - } - return this; - } - - @override - void replace(UserUpdateDefinition other) { - ArgumentError.checkNotNull(other, 'other'); - _$v = other as _$UserUpdateDefinition; - } - - @override - void update(void Function(UserUpdateDefinitionBuilder)? updates) { - if (updates != null) updates(this); - } - - @override - UserUpdateDefinition build() => _build(); - - _$UserUpdateDefinition _build() { - final _$result = _$v ?? - new _$UserUpdateDefinition._( - userId: BuiltValueNullFieldError.checkNotNull( - userId, r'UserUpdateDefinition', 'userId'), - password: BuiltValueNullFieldError.checkNotNull( - password, r'UserUpdateDefinition', 'password'), - accessToken: BuiltValueNullFieldError.checkNotNull( - accessToken, r'UserUpdateDefinition', 'accessToken')); - replace(_$result); - return _$result; - } -} - -// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/lib/api_sub_project/src/model/validation_error.dart b/lib/api_sub_project/src/model/validation_error.dart deleted file mode 100644 index 94c5428..0000000 --- a/lib/api_sub_project/src/model/validation_error.dart +++ /dev/null @@ -1,145 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// - -// ignore_for_file: unused_element -import 'package:built_collection/built_collection.dart'; -import 'package:tuuli_app/api_sub_project/src/model/location_inner.dart'; -import 'package:built_value/built_value.dart'; -import 'package:built_value/serializer.dart'; - -part 'validation_error.g.dart'; - -/// ValidationError -/// -/// Properties: -/// * [loc] -/// * [msg] -/// * [type] -@BuiltValue() -abstract class ValidationError - implements Built { - @BuiltValueField(wireName: r'loc') - BuiltList get loc; - - @BuiltValueField(wireName: r'msg') - String get msg; - - @BuiltValueField(wireName: r'type') - String get type; - - ValidationError._(); - - factory ValidationError([void updates(ValidationErrorBuilder b)]) = - _$ValidationError; - - @BuiltValueHook(initializeBuilder: true) - static void _defaults(ValidationErrorBuilder b) => b; - - @BuiltValueSerializer(custom: true) - static Serializer get serializer => - _$ValidationErrorSerializer(); -} - -class _$ValidationErrorSerializer - implements PrimitiveSerializer { - @override - final Iterable types = const [ValidationError, _$ValidationError]; - - @override - final String wireName = r'ValidationError'; - - Iterable _serializeProperties( - Serializers serializers, - ValidationError object, { - FullType specifiedType = FullType.unspecified, - }) sync* { - yield r'loc'; - yield serializers.serialize( - object.loc, - specifiedType: const FullType(BuiltList, [FullType(LocationInner)]), - ); - yield r'msg'; - yield serializers.serialize( - object.msg, - specifiedType: const FullType(String), - ); - yield r'type'; - yield serializers.serialize( - object.type, - specifiedType: const FullType(String), - ); - } - - @override - Object serialize( - Serializers serializers, - ValidationError object, { - FullType specifiedType = FullType.unspecified, - }) { - return _serializeProperties(serializers, object, - specifiedType: specifiedType) - .toList(); - } - - void _deserializeProperties( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - required List serializedList, - required ValidationErrorBuilder result, - required List unhandled, - }) { - for (var i = 0; i < serializedList.length; i += 2) { - final key = serializedList[i] as String; - final value = serializedList[i + 1]; - switch (key) { - case r'loc': - final valueDes = serializers.deserialize( - value, - specifiedType: const FullType(BuiltList, [FullType(LocationInner)]), - ) as BuiltList; - result.loc.replace(valueDes); - break; - case r'msg': - final valueDes = serializers.deserialize( - value, - specifiedType: const FullType(String), - ) as String; - result.msg = valueDes; - break; - case r'type': - final valueDes = serializers.deserialize( - value, - specifiedType: const FullType(String), - ) as String; - result.type = valueDes; - break; - default: - unhandled.add(key); - unhandled.add(value); - break; - } - } - } - - @override - ValidationError deserialize( - Serializers serializers, - Object serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final result = ValidationErrorBuilder(); - final serializedList = (serialized as Iterable).toList(); - final unhandled = []; - _deserializeProperties( - serializers, - serialized, - specifiedType: specifiedType, - serializedList: serializedList, - unhandled: unhandled, - result: result, - ); - return result.build(); - } -} diff --git a/lib/api_sub_project/src/model/validation_error.g.dart b/lib/api_sub_project/src/model/validation_error.g.dart deleted file mode 100644 index ff3d21b..0000000 --- a/lib/api_sub_project/src/model/validation_error.g.dart +++ /dev/null @@ -1,137 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'validation_error.dart'; - -// ************************************************************************** -// BuiltValueGenerator -// ************************************************************************** - -class _$ValidationError extends ValidationError { - @override - final BuiltList loc; - @override - final String msg; - @override - final String type; - - factory _$ValidationError([void Function(ValidationErrorBuilder)? updates]) => - (new ValidationErrorBuilder()..update(updates))._build(); - - _$ValidationError._( - {required this.loc, required this.msg, required this.type}) - : super._() { - BuiltValueNullFieldError.checkNotNull(loc, r'ValidationError', 'loc'); - BuiltValueNullFieldError.checkNotNull(msg, r'ValidationError', 'msg'); - BuiltValueNullFieldError.checkNotNull(type, r'ValidationError', 'type'); - } - - @override - ValidationError rebuild(void Function(ValidationErrorBuilder) updates) => - (toBuilder()..update(updates)).build(); - - @override - ValidationErrorBuilder toBuilder() => - new ValidationErrorBuilder()..replace(this); - - @override - bool operator ==(Object other) { - if (identical(other, this)) return true; - return other is ValidationError && - loc == other.loc && - msg == other.msg && - type == other.type; - } - - @override - int get hashCode { - var _$hash = 0; - _$hash = $jc(_$hash, loc.hashCode); - _$hash = $jc(_$hash, msg.hashCode); - _$hash = $jc(_$hash, type.hashCode); - _$hash = $jf(_$hash); - return _$hash; - } - - @override - String toString() { - return (newBuiltValueToStringHelper(r'ValidationError') - ..add('loc', loc) - ..add('msg', msg) - ..add('type', type)) - .toString(); - } -} - -class ValidationErrorBuilder - implements Builder { - _$ValidationError? _$v; - - ListBuilder? _loc; - ListBuilder get loc => - _$this._loc ??= new ListBuilder(); - set loc(ListBuilder? loc) => _$this._loc = loc; - - String? _msg; - String? get msg => _$this._msg; - set msg(String? msg) => _$this._msg = msg; - - String? _type; - String? get type => _$this._type; - set type(String? type) => _$this._type = type; - - ValidationErrorBuilder() { - ValidationError._defaults(this); - } - - ValidationErrorBuilder get _$this { - final $v = _$v; - if ($v != null) { - _loc = $v.loc.toBuilder(); - _msg = $v.msg; - _type = $v.type; - _$v = null; - } - return this; - } - - @override - void replace(ValidationError other) { - ArgumentError.checkNotNull(other, 'other'); - _$v = other as _$ValidationError; - } - - @override - void update(void Function(ValidationErrorBuilder)? updates) { - if (updates != null) updates(this); - } - - @override - ValidationError build() => _build(); - - _$ValidationError _build() { - _$ValidationError _$result; - try { - _$result = _$v ?? - new _$ValidationError._( - loc: loc.build(), - msg: BuiltValueNullFieldError.checkNotNull( - msg, r'ValidationError', 'msg'), - type: BuiltValueNullFieldError.checkNotNull( - type, r'ValidationError', 'type')); - } catch (_) { - late String _$failedField; - try { - _$failedField = 'loc'; - loc.build(); - } catch (e) { - throw new BuiltValueNestedFieldError( - r'ValidationError', _$failedField, e.toString()); - } - rethrow; - } - replace(_$result); - return _$result; - } -} - -// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/lib/api_sub_project/src/serializers.dart b/lib/api_sub_project/src/serializers.dart deleted file mode 100644 index 238151e..0000000 --- a/lib/api_sub_project/src/serializers.dart +++ /dev/null @@ -1,72 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// - -// ignore_for_file: unused_import - -import 'package:one_of_serializer/any_of_serializer.dart'; -import 'package:one_of_serializer/one_of_serializer.dart'; -import 'package:built_collection/built_collection.dart'; -import 'package:built_value/json_object.dart'; -import 'package:built_value/serializer.dart'; -import 'package:built_value/standard_json_plugin.dart'; -import 'package:built_value/iso_8601_date_time_serializer.dart'; -import 'package:tuuli_app/api_sub_project/src/date_serializer.dart'; -import 'package:tuuli_app/api_sub_project/src/model/date.dart'; - -import 'package:tuuli_app/api_sub_project/src/model/access_token_response.dart'; -import 'package:tuuli_app/api_sub_project/src/model/auth_model.dart'; -import 'package:tuuli_app/api_sub_project/src/model/body_update_item_in_table_items_table_name_post.dart'; -import 'package:tuuli_app/api_sub_project/src/model/column_condition_compat.dart'; -import 'package:tuuli_app/api_sub_project/src/model/create_asset_response.dart'; -import 'package:tuuli_app/api_sub_project/src/model/create_user_definition.dart'; -import 'package:tuuli_app/api_sub_project/src/model/error_response.dart'; -import 'package:tuuli_app/api_sub_project/src/model/http_validation_error.dart'; -import 'package:tuuli_app/api_sub_project/src/model/items_field_selector_list.dart'; -import 'package:tuuli_app/api_sub_project/src/model/location_inner.dart'; -import 'package:tuuli_app/api_sub_project/src/model/ok_response.dart'; -import 'package:tuuli_app/api_sub_project/src/model/table_definition.dart'; -import 'package:tuuli_app/api_sub_project/src/model/table_items_response.dart'; -import 'package:tuuli_app/api_sub_project/src/model/user_update_definition.dart'; -import 'package:tuuli_app/api_sub_project/src/model/validation_error.dart'; - -part 'serializers.g.dart'; - -@SerializersFor([ - AccessTokenResponse, - AuthModel, - BodyUpdateItemInTableItemsTableNamePost, - ColumnConditionCompat, - CreateAssetResponse, - CreateUserDefinition, - ErrorResponse, - HTTPValidationError, - ItemsFieldSelectorList, - LocationInner, - OkResponse, - TableDefinition, - TableItemsResponse, - UserUpdateDefinition, - ValidationError, -]) -Serializers serializers = (_$serializers.toBuilder() - ..addBuilderFactory( - const FullType(BuiltList, [FullType(ColumnConditionCompat)]), - () => ListBuilder(), - ) - ..addBuilderFactory( - const FullType(BuiltList, [FullType(String)]), - () => ListBuilder(), - ) - ..addBuilderFactory( - const FullType(BuiltList, [FullType(TableDefinition)]), - () => ListBuilder(), - ) - ..add(const OneOfSerializer()) - ..add(const AnyOfSerializer()) - ..add(const DateSerializer()) - ..add(Iso8601DateTimeSerializer())) - .build(); - -Serializers standardSerializers = - (serializers.toBuilder()..addPlugin(StandardJsonPlugin())).build(); diff --git a/lib/api_sub_project/src/serializers.g.dart b/lib/api_sub_project/src/serializers.g.dart deleted file mode 100644 index 2333d1c..0000000 --- a/lib/api_sub_project/src/serializers.g.dart +++ /dev/null @@ -1,48 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'serializers.dart'; - -// ************************************************************************** -// BuiltValueGenerator -// ************************************************************************** - -Serializers _$serializers = (new Serializers().toBuilder() - ..add(AccessTokenResponse.serializer) - ..add(AuthModel.serializer) - ..add(BodyUpdateItemInTableItemsTableNamePost.serializer) - ..add(ColumnConditionCompat.serializer) - ..add(ColumnConditionCompatOperator_Enum.serializer) - ..add(CreateAssetResponse.serializer) - ..add(CreateUserDefinition.serializer) - ..add(ErrorResponse.serializer) - ..add(HTTPValidationError.serializer) - ..add(ItemsFieldSelectorList.serializer) - ..add(LocationInner.serializer) - ..add(OkResponse.serializer) - ..add(TableDefinition.serializer) - ..add(TableItemsResponse.serializer) - ..add(UserUpdateDefinition.serializer) - ..add(ValidationError.serializer) - ..addBuilderFactory( - const FullType(BuiltList, const [const FullType(JsonObject)]), - () => new ListBuilder()) - ..addBuilderFactory( - const FullType(BuiltList, const [const FullType(LocationInner)]), - () => new ListBuilder()) - ..addBuilderFactory( - const FullType(BuiltList, const [const FullType(String)]), - () => new ListBuilder()) - ..addBuilderFactory( - const FullType(BuiltList, const [const FullType(ValidationError)]), - () => new ListBuilder()) - ..addBuilderFactory( - const FullType( - BuiltMap, const [const FullType(String), const FullType(String)]), - () => new MapBuilder()) - ..addBuilderFactory( - const FullType( - BuiltMap, const [const FullType(String), const FullType(String)]), - () => new MapBuilder())) - .build(); - -// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/lib/api_sub_project/tuuli_api.dart b/lib/api_sub_project/tuuli_api.dart deleted file mode 100644 index edb941b..0000000 --- a/lib/api_sub_project/tuuli_api.dart +++ /dev/null @@ -1,28 +0,0 @@ -// -// AUTO-GENERATED FILE, DO NOT MODIFY! -// - -export 'package:tuuli_app/api_sub_project/src/api.dart'; -export 'package:tuuli_app/api_sub_project/src/auth/api_key_auth.dart'; -export 'package:tuuli_app/api_sub_project/src/auth/basic_auth.dart'; -export 'package:tuuli_app/api_sub_project/src/auth/oauth.dart'; -export 'package:tuuli_app/api_sub_project/src/serializers.dart'; -export 'package:tuuli_app/api_sub_project/src/model/date.dart'; - -export 'package:tuuli_app/api_sub_project/src/api/default_api.dart'; - -export 'package:tuuli_app/api_sub_project/src/model/access_token_response.dart'; -export 'package:tuuli_app/api_sub_project/src/model/auth_model.dart'; -export 'package:tuuli_app/api_sub_project/src/model/body_update_item_in_table_items_table_name_post.dart'; -export 'package:tuuli_app/api_sub_project/src/model/column_condition_compat.dart'; -export 'package:tuuli_app/api_sub_project/src/model/create_asset_response.dart'; -export 'package:tuuli_app/api_sub_project/src/model/create_user_definition.dart'; -export 'package:tuuli_app/api_sub_project/src/model/error_response.dart'; -export 'package:tuuli_app/api_sub_project/src/model/http_validation_error.dart'; -export 'package:tuuli_app/api_sub_project/src/model/items_field_selector_list.dart'; -export 'package:tuuli_app/api_sub_project/src/model/location_inner.dart'; -export 'package:tuuli_app/api_sub_project/src/model/ok_response.dart'; -export 'package:tuuli_app/api_sub_project/src/model/table_definition.dart'; -export 'package:tuuli_app/api_sub_project/src/model/table_items_response.dart'; -export 'package:tuuli_app/api_sub_project/src/model/user_update_definition.dart'; -export 'package:tuuli_app/api_sub_project/src/model/validation_error.dart'; -- 2.47.3 From 1f1e946018e19f25d3154486a725062e5edf7acf Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Mon, 24 Apr 2023 11:07:39 +0700 Subject: [PATCH 05/28] Add windows for testing purposes --- lib/widgets/table_field_widget.dart | 51 ---- windows/.gitignore | 17 ++ windows/CMakeLists.txt | 102 +++++++ windows/flutter/CMakeLists.txt | 104 +++++++ .../flutter/generated_plugin_registrant.cc | 11 + windows/flutter/generated_plugin_registrant.h | 15 + windows/flutter/generated_plugins.cmake | 23 ++ windows/runner/CMakeLists.txt | 40 +++ windows/runner/Runner.rc | 121 ++++++++ windows/runner/flutter_window.cpp | 66 ++++ windows/runner/flutter_window.h | 33 ++ windows/runner/main.cpp | 43 +++ windows/runner/resource.h | 16 + windows/runner/resources/app_icon.ico | Bin 0 -> 33772 bytes windows/runner/runner.exe.manifest | 20 ++ windows/runner/utils.cpp | 65 ++++ windows/runner/utils.h | 19 ++ windows/runner/win32_window.cpp | 288 ++++++++++++++++++ windows/runner/win32_window.h | 102 +++++++ 19 files changed, 1085 insertions(+), 51 deletions(-) delete mode 100644 lib/widgets/table_field_widget.dart create mode 100644 windows/.gitignore create mode 100644 windows/CMakeLists.txt create mode 100644 windows/flutter/CMakeLists.txt create mode 100644 windows/flutter/generated_plugin_registrant.cc create mode 100644 windows/flutter/generated_plugin_registrant.h create mode 100644 windows/flutter/generated_plugins.cmake create mode 100644 windows/runner/CMakeLists.txt create mode 100644 windows/runner/Runner.rc create mode 100644 windows/runner/flutter_window.cpp create mode 100644 windows/runner/flutter_window.h create mode 100644 windows/runner/main.cpp create mode 100644 windows/runner/resource.h create mode 100644 windows/runner/resources/app_icon.ico create mode 100644 windows/runner/runner.exe.manifest create mode 100644 windows/runner/utils.cpp create mode 100644 windows/runner/utils.h create mode 100644 windows/runner/win32_window.cpp create mode 100644 windows/runner/win32_window.h diff --git a/lib/widgets/table_field_widget.dart b/lib/widgets/table_field_widget.dart deleted file mode 100644 index 040aee6..0000000 --- a/lib/widgets/table_field_widget.dart +++ /dev/null @@ -1,51 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:tuuli_app/api/model/table_field_model.dart'; - -class TableFieldWidget extends StatelessWidget { - final TableField field; - final VoidCallback? onRemove; - - const TableFieldWidget({ - super.key, - required this.field, - this.onRemove, - }); - - @override - Widget build(BuildContext context) { - return Card( - child: Container( - padding: const EdgeInsets.all(8), - margin: const EdgeInsets.all(8), - child: Row( - children: [ - Column( - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - if (field.isPrimary) const Icon(Icons.star), - if (field.isUnique) const Icon(Icons.lock), - Text( - "Field \"${field.fieldName}\"", - style: const TextStyle(fontWeight: FontWeight.bold), - ), - ], - ), - Text("Field type: ${field.fieldType} (baked by ${field.type})"), - ], - ), - if (onRemove != null) const Spacer(), - if (onRemove != null) - IconButton( - icon: const Icon(Icons.delete), - onPressed: onRemove, - ), - ], - ), - ), - ); - } -} diff --git a/windows/.gitignore b/windows/.gitignore new file mode 100644 index 0000000..d492d0d --- /dev/null +++ b/windows/.gitignore @@ -0,0 +1,17 @@ +flutter/ephemeral/ + +# Visual Studio user-specific files. +*.suo +*.user +*.userosscache +*.sln.docstates + +# Visual Studio build-related files. +x64/ +x86/ + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ diff --git a/windows/CMakeLists.txt b/windows/CMakeLists.txt new file mode 100644 index 0000000..ea0f442 --- /dev/null +++ b/windows/CMakeLists.txt @@ -0,0 +1,102 @@ +# Project-level configuration. +cmake_minimum_required(VERSION 3.14) +project(gws_playground LANGUAGES CXX) + +# The name of the executable created for the application. Change this to change +# the on-disk name of your application. +set(BINARY_NAME "gws_playground") + +# Explicitly opt in to modern CMake behaviors to avoid warnings with recent +# versions of CMake. +cmake_policy(SET CMP0063 NEW) + +# Define build configuration option. +get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(IS_MULTICONFIG) + set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" + CACHE STRING "" FORCE) +else() + if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE "Debug" CACHE + STRING "Flutter build mode" FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Profile" "Release") + endif() +endif() +# Define settings for the Profile build mode. +set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") +set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") +set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") +set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") + +# Use Unicode for all projects. +add_definitions(-DUNICODE -D_UNICODE) + +# Compilation settings that should be applied to most targets. +# +# Be cautious about adding new options here, as plugins use this function by +# default. In most cases, you should add new options to specific targets instead +# of modifying this function. +function(APPLY_STANDARD_SETTINGS TARGET) + target_compile_features(${TARGET} PUBLIC cxx_std_17) + target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") + target_compile_options(${TARGET} PRIVATE /EHsc) + target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") + target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") +endfunction() + +# Flutter library and tool build rules. +set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") +add_subdirectory(${FLUTTER_MANAGED_DIR}) + +# Application build; see runner/CMakeLists.txt. +add_subdirectory("runner") + + +# Generated plugin build rules, which manage building the plugins and adding +# them to the application. +include(flutter/generated_plugins.cmake) + + +# === Installation === +# Support files are copied into place next to the executable, so that it can +# run in place. This is done instead of making a separate bundle (as on Linux) +# so that building and running from within Visual Studio will work. +set(BUILD_BUNDLE_DIR "$") +# Make the "install" step default, as it's required to run. +set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) +endif() + +set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") +set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") + +install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +if(PLUGIN_BUNDLED_LIBRARIES) + install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endif() + +# Fully re-copy the assets directory on each build to avoid having stale files +# from a previous install. +set(FLUTTER_ASSET_DIR_NAME "flutter_assets") +install(CODE " + file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") + " COMPONENT Runtime) +install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" + DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) + +# Install the AOT library on non-Debug builds only. +install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + CONFIGURATIONS Profile;Release + COMPONENT Runtime) diff --git a/windows/flutter/CMakeLists.txt b/windows/flutter/CMakeLists.txt new file mode 100644 index 0000000..930d207 --- /dev/null +++ b/windows/flutter/CMakeLists.txt @@ -0,0 +1,104 @@ +# This file controls Flutter-level build steps. It should not be edited. +cmake_minimum_required(VERSION 3.14) + +set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") + +# Configuration provided via flutter tool. +include(${EPHEMERAL_DIR}/generated_config.cmake) + +# TODO: Move the rest of this into files in ephemeral. See +# https://github.com/flutter/flutter/issues/57146. +set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") + +# === Flutter Library === +set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") + +# Published to parent scope for install step. +set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) +set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) +set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) +set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) + +list(APPEND FLUTTER_LIBRARY_HEADERS + "flutter_export.h" + "flutter_windows.h" + "flutter_messenger.h" + "flutter_plugin_registrar.h" + "flutter_texture_registrar.h" +) +list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") +add_library(flutter INTERFACE) +target_include_directories(flutter INTERFACE + "${EPHEMERAL_DIR}" +) +target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") +add_dependencies(flutter flutter_assemble) + +# === Wrapper === +list(APPEND CPP_WRAPPER_SOURCES_CORE + "core_implementations.cc" + "standard_codec.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") +list(APPEND CPP_WRAPPER_SOURCES_PLUGIN + "plugin_registrar.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") +list(APPEND CPP_WRAPPER_SOURCES_APP + "flutter_engine.cc" + "flutter_view_controller.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") + +# Wrapper sources needed for a plugin. +add_library(flutter_wrapper_plugin STATIC + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_PLUGIN} +) +apply_standard_settings(flutter_wrapper_plugin) +set_target_properties(flutter_wrapper_plugin PROPERTIES + POSITION_INDEPENDENT_CODE ON) +set_target_properties(flutter_wrapper_plugin PROPERTIES + CXX_VISIBILITY_PRESET hidden) +target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) +target_include_directories(flutter_wrapper_plugin PUBLIC + "${WRAPPER_ROOT}/include" +) +add_dependencies(flutter_wrapper_plugin flutter_assemble) + +# Wrapper sources needed for the runner. +add_library(flutter_wrapper_app STATIC + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_APP} +) +apply_standard_settings(flutter_wrapper_app) +target_link_libraries(flutter_wrapper_app PUBLIC flutter) +target_include_directories(flutter_wrapper_app PUBLIC + "${WRAPPER_ROOT}/include" +) +add_dependencies(flutter_wrapper_app flutter_assemble) + +# === Flutter tool backend === +# _phony_ is a non-existent file to force this command to run every time, +# since currently there's no way to get a full input/output list from the +# flutter tool. +set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") +set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) +add_custom_command( + OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} + ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} + ${CPP_WRAPPER_SOURCES_APP} + ${PHONY_OUTPUT} + COMMAND ${CMAKE_COMMAND} -E env + ${FLUTTER_TOOL_ENVIRONMENT} + "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" + windows-x64 $ + VERBATIM +) +add_custom_target(flutter_assemble DEPENDS + "${FLUTTER_LIBRARY}" + ${FLUTTER_LIBRARY_HEADERS} + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_PLUGIN} + ${CPP_WRAPPER_SOURCES_APP} +) diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc new file mode 100644 index 0000000..8b6d468 --- /dev/null +++ b/windows/flutter/generated_plugin_registrant.cc @@ -0,0 +1,11 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#include "generated_plugin_registrant.h" + + +void RegisterPlugins(flutter::PluginRegistry* registry) { +} diff --git a/windows/flutter/generated_plugin_registrant.h b/windows/flutter/generated_plugin_registrant.h new file mode 100644 index 0000000..dc139d8 --- /dev/null +++ b/windows/flutter/generated_plugin_registrant.h @@ -0,0 +1,15 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#ifndef GENERATED_PLUGIN_REGISTRANT_ +#define GENERATED_PLUGIN_REGISTRANT_ + +#include + +// Registers Flutter plugins. +void RegisterPlugins(flutter::PluginRegistry* registry); + +#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake new file mode 100644 index 0000000..b93c4c3 --- /dev/null +++ b/windows/flutter/generated_plugins.cmake @@ -0,0 +1,23 @@ +# +# Generated file, do not edit. +# + +list(APPEND FLUTTER_PLUGIN_LIST +) + +list(APPEND FLUTTER_FFI_PLUGIN_LIST +) + +set(PLUGIN_BUNDLED_LIBRARIES) + +foreach(plugin ${FLUTTER_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) + target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) + list(APPEND PLUGIN_BUNDLED_LIBRARIES $) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) +endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/windows/runner/CMakeLists.txt b/windows/runner/CMakeLists.txt new file mode 100644 index 0000000..394917c --- /dev/null +++ b/windows/runner/CMakeLists.txt @@ -0,0 +1,40 @@ +cmake_minimum_required(VERSION 3.14) +project(runner LANGUAGES CXX) + +# Define the application target. To change its name, change BINARY_NAME in the +# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer +# work. +# +# Any new source files that you add to the application should be added here. +add_executable(${BINARY_NAME} WIN32 + "flutter_window.cpp" + "main.cpp" + "utils.cpp" + "win32_window.cpp" + "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" + "Runner.rc" + "runner.exe.manifest" +) + +# Apply the standard set of build settings. This can be removed for applications +# that need different build settings. +apply_standard_settings(${BINARY_NAME}) + +# Add preprocessor definitions for the build version. +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") + +# Disable Windows macros that collide with C++ standard library functions. +target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") + +# Add dependency libraries and include directories. Add any application-specific +# dependencies here. +target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) +target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") +target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") + +# Run the Flutter tool portions of the build. This must not be removed. +add_dependencies(${BINARY_NAME} flutter_assemble) diff --git a/windows/runner/Runner.rc b/windows/runner/Runner.rc new file mode 100644 index 0000000..209de2f --- /dev/null +++ b/windows/runner/Runner.rc @@ -0,0 +1,121 @@ +// Microsoft Visual C++ generated resource script. +// +#pragma code_page(65001) +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (United States) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_APP_ICON ICON "resources\\app_icon.ico" + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +#if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) +#define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD +#else +#define VERSION_AS_NUMBER 1,0,0,0 +#endif + +#if defined(FLUTTER_VERSION) +#define VERSION_AS_STRING FLUTTER_VERSION +#else +#define VERSION_AS_STRING "1.0.0" +#endif + +VS_VERSION_INFO VERSIONINFO + FILEVERSION VERSION_AS_NUMBER + PRODUCTVERSION VERSION_AS_NUMBER + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef _DEBUG + FILEFLAGS VS_FF_DEBUG +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904e4" + BEGIN + VALUE "CompanyName", "com.example" "\0" + VALUE "FileDescription", "gws_playground" "\0" + VALUE "FileVersion", VERSION_AS_STRING "\0" + VALUE "InternalName", "gws_playground" "\0" + VALUE "LegalCopyright", "Copyright (C) 2023 com.example. All rights reserved." "\0" + VALUE "OriginalFilename", "gws_playground.exe" "\0" + VALUE "ProductName", "gws_playground" "\0" + VALUE "ProductVersion", VERSION_AS_STRING "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1252 + END +END + +#endif // English (United States) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED diff --git a/windows/runner/flutter_window.cpp b/windows/runner/flutter_window.cpp new file mode 100644 index 0000000..b25e363 --- /dev/null +++ b/windows/runner/flutter_window.cpp @@ -0,0 +1,66 @@ +#include "flutter_window.h" + +#include + +#include "flutter/generated_plugin_registrant.h" + +FlutterWindow::FlutterWindow(const flutter::DartProject& project) + : project_(project) {} + +FlutterWindow::~FlutterWindow() {} + +bool FlutterWindow::OnCreate() { + if (!Win32Window::OnCreate()) { + return false; + } + + RECT frame = GetClientArea(); + + // The size here must match the window dimensions to avoid unnecessary surface + // creation / destruction in the startup path. + flutter_controller_ = std::make_unique( + frame.right - frame.left, frame.bottom - frame.top, project_); + // Ensure that basic setup of the controller was successful. + if (!flutter_controller_->engine() || !flutter_controller_->view()) { + return false; + } + RegisterPlugins(flutter_controller_->engine()); + SetChildContent(flutter_controller_->view()->GetNativeWindow()); + + flutter_controller_->engine()->SetNextFrameCallback([&]() { + this->Show(); + }); + + return true; +} + +void FlutterWindow::OnDestroy() { + if (flutter_controller_) { + flutter_controller_ = nullptr; + } + + Win32Window::OnDestroy(); +} + +LRESULT +FlutterWindow::MessageHandler(HWND hwnd, UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + // Give Flutter, including plugins, an opportunity to handle window messages. + if (flutter_controller_) { + std::optional result = + flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, + lparam); + if (result) { + return *result; + } + } + + switch (message) { + case WM_FONTCHANGE: + flutter_controller_->engine()->ReloadSystemFonts(); + break; + } + + return Win32Window::MessageHandler(hwnd, message, wparam, lparam); +} diff --git a/windows/runner/flutter_window.h b/windows/runner/flutter_window.h new file mode 100644 index 0000000..6da0652 --- /dev/null +++ b/windows/runner/flutter_window.h @@ -0,0 +1,33 @@ +#ifndef RUNNER_FLUTTER_WINDOW_H_ +#define RUNNER_FLUTTER_WINDOW_H_ + +#include +#include + +#include + +#include "win32_window.h" + +// A window that does nothing but host a Flutter view. +class FlutterWindow : public Win32Window { + public: + // Creates a new FlutterWindow hosting a Flutter view running |project|. + explicit FlutterWindow(const flutter::DartProject& project); + virtual ~FlutterWindow(); + + protected: + // Win32Window: + bool OnCreate() override; + void OnDestroy() override; + LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, + LPARAM const lparam) noexcept override; + + private: + // The project to run. + flutter::DartProject project_; + + // The Flutter instance hosted by this window. + std::unique_ptr flutter_controller_; +}; + +#endif // RUNNER_FLUTTER_WINDOW_H_ diff --git a/windows/runner/main.cpp b/windows/runner/main.cpp new file mode 100644 index 0000000..8cb3dd0 --- /dev/null +++ b/windows/runner/main.cpp @@ -0,0 +1,43 @@ +#include +#include +#include + +#include "flutter_window.h" +#include "utils.h" + +int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, + _In_ wchar_t *command_line, _In_ int show_command) { + // Attach to console when present (e.g., 'flutter run') or create a + // new console when running with a debugger. + if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { + CreateAndAttachConsole(); + } + + // Initialize COM, so that it is available for use in the library and/or + // plugins. + ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); + + flutter::DartProject project(L"data"); + + std::vector command_line_arguments = + GetCommandLineArguments(); + + project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); + + FlutterWindow window(project); + Win32Window::Point origin(10, 10); + Win32Window::Size size(1280, 720); + if (!window.Create(L"gws_playground", origin, size)) { + return EXIT_FAILURE; + } + window.SetQuitOnClose(true); + + ::MSG msg; + while (::GetMessage(&msg, nullptr, 0, 0)) { + ::TranslateMessage(&msg); + ::DispatchMessage(&msg); + } + + ::CoUninitialize(); + return EXIT_SUCCESS; +} diff --git a/windows/runner/resource.h b/windows/runner/resource.h new file mode 100644 index 0000000..66a65d1 --- /dev/null +++ b/windows/runner/resource.h @@ -0,0 +1,16 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by Runner.rc +// +#define IDI_APP_ICON 101 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 102 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/windows/runner/resources/app_icon.ico b/windows/runner/resources/app_icon.ico new file mode 100644 index 0000000000000000000000000000000000000000..c04e20caf6370ebb9253ad831cc31de4a9c965f6 GIT binary patch literal 33772 zcmeHQc|26z|35SKE&G-*mXah&B~fFkXr)DEO&hIfqby^T&>|8^_Ub8Vp#`BLl3lbZ zvPO!8k!2X>cg~Elr=IVxo~J*a`+9wR=A83c-k-DFd(XM&UI1VKCqM@V;DDtJ09WB} zRaHKiW(GT00brH|0EeTeKVbpbGZg?nK6-j827q-+NFM34gXjqWxJ*a#{b_apGN<-L_m3#8Z26atkEn& ze87Bvv^6vVmM+p+cQ~{u%=NJF>#(d;8{7Q{^rWKWNtf14H}>#&y7$lqmY6xmZryI& z($uy?c5-+cPnt2%)R&(KIWEXww>Cnz{OUpT>W$CbO$h1= z#4BPMkFG1Y)x}Ui+WXr?Z!w!t_hjRq8qTaWpu}FH{MsHlU{>;08goVLm{V<&`itk~ zE_Ys=D(hjiy+5=?=$HGii=Y5)jMe9|wWoD_K07(}edAxh`~LBorOJ!Cf@f{_gNCC| z%{*04ViE!#>@hc1t5bb+NO>ncf@@Dv01K!NxH$3Eg1%)|wLyMDF8^d44lV!_Sr}iEWefOaL z8f?ud3Q%Sen39u|%00W<#!E=-RpGa+H8}{ulxVl4mwpjaU+%2pzmi{3HM)%8vb*~-M9rPUAfGCSos8GUXp02|o~0BTV2l#`>>aFV&_P$ejS;nGwSVP8 zMbOaG7<7eKD>c12VdGH;?2@q7535sa7MN*L@&!m?L`ASG%boY7(&L5imY#EQ$KrBB z4@_tfP5m50(T--qv1BJcD&aiH#b-QC>8#7Fx@3yXlonJI#aEIi=8&ChiVpc#N=5le zM*?rDIdcpawoc5kizv$GEjnveyrp3sY>+5_R5;>`>erS%JolimF=A^EIsAK zsPoVyyUHCgf0aYr&alx`<)eb6Be$m&`JYSuBu=p8j%QlNNp$-5C{b4#RubPb|CAIS zGE=9OFLP7?Hgc{?k45)84biT0k&-C6C%Q}aI~q<(7BL`C#<6HyxaR%!dFx7*o^laG z=!GBF^cwK$IA(sn9y6>60Rw{mYRYkp%$jH z*xQM~+bp)G$_RhtFPYx2HTsWk80+p(uqv9@I9)y{b$7NK53rYL$ezbmRjdXS?V}fj zWxX_feWoLFNm3MG7pMUuFPs$qrQWO9!l2B(SIuy2}S|lHNbHzoE+M2|Zxhjq9+Ws8c{*}x^VAib7SbxJ*Q3EnY5lgI9 z=U^f3IW6T=TWaVj+2N%K3<%Un;CF(wUp`TC&Y|ZjyFu6co^uqDDB#EP?DV5v_dw~E zIRK*BoY9y-G_ToU2V_XCX4nJ32~`czdjT!zwme zGgJ0nOk3U4@IE5JwtM}pwimLjk{ln^*4HMU%Fl4~n(cnsLB}Ja-jUM>xIB%aY;Nq8 z)Fp8dv1tkqKanv<68o@cN|%thj$+f;zGSO7H#b+eMAV8xH$hLggtt?O?;oYEgbq@= zV(u9bbd12^%;?nyk6&$GPI%|+<_mEpJGNfl*`!KV;VfmZWw{n{rnZ51?}FDh8we_L z8OI9nE31skDqJ5Oa_ybn7|5@ui>aC`s34p4ZEu6-s!%{uU45$Zd1=p$^^dZBh zu<*pDDPLW+c>iWO$&Z_*{VSQKg7=YEpS3PssPn1U!lSm6eZIho*{@&20e4Y_lRklKDTUCKI%o4Pc<|G^Xgu$J^Q|B87U;`c1zGwf^-zH*VQ^x+i^OUWE0yd z;{FJq)2w!%`x7yg@>uGFFf-XJl4H`YtUG%0slGKOlXV`q?RP>AEWg#x!b{0RicxGhS!3$p7 zij;{gm!_u@D4$Ox%>>bPtLJ> zwKtYz?T_DR1jN>DkkfGU^<#6sGz|~p*I{y`aZ>^Di#TC|Z!7j_O1=Wo8thuit?WxR zh9_S>kw^{V^|g}HRUF=dcq>?q(pHxw!8rx4dC6vbQVmIhmICF#zU!HkHpQ>9S%Uo( zMw{eC+`&pb=GZRou|3;Po1}m46H6NGd$t<2mQh}kaK-WFfmj_66_17BX0|j-E2fe3Jat}ijpc53 zJV$$;PC<5aW`{*^Z6e5##^`Ed#a0nwJDT#Qq~^e8^JTA=z^Kl>La|(UQ!bI@#ge{Dzz@61p-I)kc2?ZxFt^QQ}f%ldLjO*GPj(5)V9IyuUakJX=~GnTgZ4$5!3E=V#t`yOG4U z(gphZB6u2zsj=qNFLYShhg$}lNpO`P9xOSnO*$@@UdMYES*{jJVj|9z-}F^riksLK zbsU+4-{281P9e2UjY6tse^&a)WM1MFw;p#_dHhWI7p&U*9TR0zKdVuQed%6{otTsq z$f~S!;wg#Bd9kez=Br{m|66Wv z#g1xMup<0)H;c2ZO6su_ii&m8j&+jJz4iKnGZ&wxoQX|5a>v&_e#6WA!MB_4asTxLRGQCC5cI(em z%$ZfeqP>!*q5kU>a+BO&ln=4Jm>Ef(QE8o&RgLkk%2}4Tf}U%IFP&uS7}&|Q-)`5< z+e>;s#4cJ-z%&-^&!xsYx777Wt(wZY9(3(avmr|gRe4cD+a8&!LY`1^T?7x{E<=kdY9NYw>A;FtTvQ=Y&1M%lyZPl$ss1oY^Sl8we}n}Aob#6 zl4jERwnt9BlSoWb@3HxYgga(752Vu6Y)k4yk9u~Kw>cA5&LHcrvn1Y-HoIuFWg~}4 zEw4bR`mXZQIyOAzo)FYqg?$5W<;^+XX%Uz61{-L6@eP|lLH%|w?g=rFc;OvEW;^qh z&iYXGhVt(G-q<+_j}CTbPS_=K>RKN0&;dubh0NxJyDOHFF;<1k!{k#7b{|Qok9hac z;gHz}6>H6C6RnB`Tt#oaSrX0p-j-oRJ;_WvS-qS--P*8}V943RT6kou-G=A+7QPGQ z!ze^UGxtW3FC0$|(lY9^L!Lx^?Q8cny(rR`es5U;-xBhphF%_WNu|aO<+e9%6LuZq zt(0PoagJG<%hyuf;te}n+qIl_Ej;czWdc{LX^pS>77s9t*2b4s5dvP_!L^3cwlc)E!(!kGrg~FescVT zZCLeua3f4;d;Tk4iXzt}g}O@nlK3?_o91_~@UMIl?@77Qc$IAlLE95#Z=TES>2E%z zxUKpK{_HvGF;5%Q7n&vA?`{%8ohlYT_?(3A$cZSi)MvIJygXD}TS-3UwyUxGLGiJP znblO~G|*uA^|ac8E-w#}uBtg|s_~s&t>-g0X%zIZ@;o_wNMr_;{KDg^O=rg`fhDZu zFp(VKd1Edj%F zWHPl+)FGj%J1BO3bOHVfH^3d1F{)*PL&sRX`~(-Zy3&9UQX)Z;c51tvaI2E*E7!)q zcz|{vpK7bjxix(k&6=OEIBJC!9lTkUbgg?4-yE{9+pFS)$Ar@vrIf`D0Bnsed(Cf? zObt2CJ>BKOl>q8PyFO6w)+6Iz`LW%T5^R`U_NIW0r1dWv6OY=TVF?N=EfA(k(~7VBW(S;Tu5m4Lg8emDG-(mOSSs=M9Q&N8jc^Y4&9RqIsk(yO_P(mcCr}rCs%1MW1VBrn=0-oQN(Xj!k%iKV zb%ricBF3G4S1;+8lzg5PbZ|$Se$)I=PwiK=cDpHYdov2QO1_a-*dL4KUi|g&oh>(* zq$<`dQ^fat`+VW?m)?_KLn&mp^-@d=&7yGDt<=XwZZC=1scwxO2^RRI7n@g-1o8ps z)&+et_~)vr8aIF1VY1Qrq~Xe``KJrQSnAZ{CSq3yP;V*JC;mmCT6oRLSs7=GA?@6g zUooM}@tKtx(^|aKK8vbaHlUQqwE0}>j&~YlN3H#vKGm@u)xxS?n9XrOWUfCRa< z`20Fld2f&;gg7zpo{Adh+mqNntMc-D$N^yWZAZRI+u1T1zWHPxk{+?vcS1D>08>@6 zLhE@`gt1Y9mAK6Z4p|u(5I%EkfU7rKFSM=E4?VG9tI;a*@?6!ey{lzN5=Y-!$WFSe z&2dtO>^0@V4WRc#L&P%R(?@KfSblMS+N+?xUN$u3K4Ys%OmEh+tq}fnU}i>6YHM?< zlnL2gl~sF!j!Y4E;j3eIU-lfa`RsOL*Tt<%EFC0gPzoHfNWAfKFIKZN8}w~(Yi~=q z>=VNLO2|CjkxP}RkutxjV#4fWYR1KNrPYq5ha9Wl+u>ipsk*I(HS@iLnmGH9MFlTU zaFZ*KSR0px>o+pL7BbhB2EC1%PJ{67_ z#kY&#O4@P=OV#-79y_W>Gv2dxL*@G7%LksNSqgId9v;2xJ zrh8uR!F-eU$NMx@S*+sk=C~Dxr9Qn7TfWnTupuHKuQ$;gGiBcU>GF5sWx(~4IP3`f zWE;YFO*?jGwYh%C3X<>RKHC-DZ!*r;cIr}GLOno^3U4tFSSoJp%oHPiSa%nh=Zgn% z14+8v@ygy0>UgEN1bczD6wK45%M>psM)y^)IfG*>3ItX|TzV*0i%@>L(VN!zdKb8S?Qf7BhjNpziA zR}?={-eu>9JDcl*R=OP9B8N$IcCETXah9SUDhr{yrld{G;PnCWRsPD7!eOOFBTWUQ=LrA_~)mFf&!zJX!Oc-_=kT<}m|K52 z)M=G#;p;Rdb@~h5D{q^K;^fX-m5V}L%!wVC2iZ1uu401Ll}#rocTeK|7FAeBRhNdQ zCc2d^aQnQp=MpOmak60N$OgS}a;p(l9CL`o4r(e-nN}mQ?M&isv-P&d$!8|1D1I(3-z!wi zTgoo)*Mv`gC?~bm?S|@}I|m-E2yqPEvYybiD5azInexpK8?9q*$9Yy9-t%5jU8~ym zgZDx>!@ujQ=|HJnwp^wv-FdD{RtzO9SnyfB{mH_(c!jHL*$>0o-(h(eqe*ZwF6Lvu z{7rkk%PEqaA>o+f{H02tzZ@TWy&su?VNw43! z-X+rN`6llvpUms3ZiSt)JMeztB~>9{J8SPmYs&qohxdYFi!ra8KR$35Zp9oR)eFC4 zE;P31#3V)n`w$fZ|4X-|%MX`xZDM~gJyl2W;O$H25*=+1S#%|53>|LyH za@yh+;325%Gq3;J&a)?%7X%t@WXcWL*BaaR*7UEZad4I8iDt7^R_Fd`XeUo256;sAo2F!HcIQKk;h})QxEsPE5BcKc7WyerTchgKmrfRX z!x#H_%cL#B9TWAqkA4I$R^8{%do3Y*&(;WFmJ zU7Dih{t1<{($VtJRl9|&EB?|cJ)xse!;}>6mSO$o5XIx@V|AA8ZcoD88ZM?C*;{|f zZVmf94_l1OmaICt`2sTyG!$^UeTHx9YuUP!omj(r|7zpm5475|yXI=rR>>fteLI+| z)MoiGho0oEt=*J(;?VY0QzwCqw@cVm?d7Y!z0A@u#H?sCJ*ecvyhj& z-F77lO;SH^dmf?L>3i>?Z*U}Em4ZYV_CjgfvzYsRZ+1B!Uo6H6mbS<-FFL`ytqvb& zE7+)2ahv-~dz(Hs+f})z{*4|{)b=2!RZK;PWwOnO=hG7xG`JU5>bAvUbdYd_CjvtHBHgtGdlO+s^9ca^Bv3`t@VRX2_AD$Ckg36OcQRF zXD6QtGfHdw*hx~V(MV-;;ZZF#dJ-piEF+s27z4X1qi5$!o~xBnvf=uopcn7ftfsZc zy@(PuOk`4GL_n(H9(E2)VUjqRCk9kR?w)v@xO6Jm_Mx})&WGEl=GS0#)0FAq^J*o! zAClhvoTsNP*-b~rN{8Yym3g{01}Ep^^Omf=SKqvN?{Q*C4HNNAcrowIa^mf+3PRy! z*_G-|3i8a;+q;iP@~Of_$(vtFkB8yOyWt2*K)vAn9El>=D;A$CEx6b*XF@4y_6M+2 zpeW`RHoI_p(B{%(&jTHI->hmNmZjHUj<@;7w0mx3&koy!2$@cfX{sN19Y}euYJFn& z1?)+?HCkD0MRI$~uB2UWri})0bru_B;klFdwsLc!ne4YUE;t41JqfG# zZJq6%vbsdx!wYeE<~?>o4V`A3?lN%MnKQ`z=uUivQN^vzJ|C;sdQ37Qn?;lpzg})y z)_2~rUdH}zNwX;Tp0tJ78+&I=IwOQ-fl30R79O8@?Ub8IIA(6I`yHn%lARVL`%b8+ z4$8D-|MZZWxc_)vu6@VZN!HsI$*2NOV&uMxBNzIbRgy%ob_ zhwEH{J9r$!dEix9XM7n&c{S(h>nGm?el;gaX0@|QnzFD@bne`el^CO$yXC?BDJ|Qg z+y$GRoR`?ST1z^e*>;!IS@5Ovb7*RlN>BV_UC!7E_F;N#ky%1J{+iixp(dUJj93aK zzHNN>R-oN7>kykHClPnoPTIj7zc6KM(Pnlb(|s??)SMb)4!sMHU^-ntJwY5Big7xv zb1Ew`Xj;|D2kzGja*C$eS44(d&RMU~c_Y14V9_TLTz0J#uHlsx`S6{nhsA0dWZ#cG zJ?`fO50E>*X4TQLv#nl%3GOk*UkAgt=IY+u0LNXqeln3Z zv$~&Li`ZJOKkFuS)dJRA>)b_Da%Q~axwA_8zNK{BH{#}#m}zGcuckz}riDE-z_Ms> zR8-EqAMcfyGJCtvTpaUVQtajhUS%c@Yj}&6Zz;-M7MZzqv3kA7{SuW$oW#=0az2wQ zg-WG@Vb4|D`pl~Il54N7Hmsauc_ne-a!o5#j3WaBBh@Wuefb!QJIOn5;d)%A#s+5% zuD$H=VNux9bE-}1&bcYGZ+>1Fo;3Z@e&zX^n!?JK*adSbONm$XW9z;Q^L>9U!}Toj2WdafJ%oL#h|yWWwyAGxzfrAWdDTtaKl zK4`5tDpPg5>z$MNv=X0LZ0d6l%D{(D8oT@+w0?ce$DZ6pv>{1&Ok67Ix1 zH}3=IEhPJEhItCC8E=`T`N5(k?G=B4+xzZ?<4!~ ze~z6Wk9!CHTI(0rLJ4{JU?E-puc;xusR?>G?;4vt;q~iI9=kDL=z0Rr%O$vU`30X$ zDZRFyZ`(omOy@u|i6h;wtJlP;+}$|Ak|k2dea7n?U1*$T!sXqqOjq^NxLPMmk~&qI zYg0W?yK8T(6+Ea+$YyspKK?kP$+B`~t3^Pib_`!6xCs32!i@pqXfFV6PmBIR<-QW= zN8L{pt0Vap0x`Gzn#E@zh@H)0FfVfA_Iu4fjYZ+umO1LXIbVc$pY+E234u)ttcrl$ z>s92z4vT%n6cMb>=XT6;l0+9e(|CZG)$@C7t7Z7Ez@a)h)!hyuV&B5K%%)P5?Lk|C zZZSVzdXp{@OXSP0hoU-gF8s8Um(#xzjP2Vem zec#-^JqTa&Y#QJ>-FBxd7tf`XB6e^JPUgagB8iBSEps;92KG`!#mvVcPQ5yNC-GEG zTiHEDYfH+0O15}r^+ z#jxj=@x8iNHWALe!P3R67TwmhItn**0JwnzSV2O&KE8KcT+0hWH^OPD1pwiuyx=b@ zNf5Jh0{9X)8;~Es)$t@%(3!OnbY+`@?i{mGX7Yy}8T_*0a6g;kaFPq;*=px5EhO{Cp%1kI<0?*|h8v!6WnO3cCJRF2-CRrU3JiLJnj@6;L)!0kWYAc_}F{2P))3HmCrz zQ&N&gE70;`!6*eJ4^1IR{f6j4(-l&X!tjHxkbHA^Zhrnhr9g{exN|xrS`5Pq=#Xf& zG%P=#ra-TyVFfgW%cZo5OSIwFL9WtXAlFOa+ubmI5t*3=g#Y zF%;70p5;{ZeFL}&}yOY1N1*Q;*<(kTB!7vM$QokF)yr2FlIU@$Ph58$Bz z0J?xQG=MlS4L6jA22eS42g|9*9pX@$#*sUeM(z+t?hr@r5J&D1rx}2pW&m*_`VDCW zUYY@v-;bAO0HqoAgbbiGGC<=ryf96}3pouhy3XJrX+!!u*O_>Si38V{uJmQ&USptX zKp#l(?>%^7;2%h(q@YWS#9;a!JhKlkR#Vd)ERILlgu!Hr@jA@V;sk4BJ-H#p*4EqC zDGjC*tl=@3Oi6)Bn^QwFpul18fpkbpg0+peH$xyPBqb%`$OUhPKyWb32o7clB*9Z< zN=i~NLjavrLtwgJ01bufP+>p-jR2I95|TpmKpQL2!oV>g(4RvS2pK4*ou%m(h6r3A zX#s&`9LU1ZG&;{CkOK!4fLDTnBys`M!vuz>Q&9OZ0hGQl!~!jSDg|~s*w52opC{sB ze|Cf2luD(*G13LcOAGA!s2FjSK8&IE5#W%J25w!vM0^VyQM!t)inj&RTiJ!wXzFgz z3^IqzB7I0L$llljsGq})thBy9UOyjtFO_*hYM_sgcMk>44jeH0V1FDyELc{S1F-;A zS;T^k^~4biG&V*Irq}O;e}j$$+E_#G?HKIn05iP3j|87TkGK~SqG!-KBg5+mN(aLm z8ybhIM`%C19UX$H$KY6JgXbY$0AT%rEpHC;u`rQ$Y=rxUdsc5*Kvc8jaYaO$^)cI6){P6K0r)I6DY4Wr4&B zLQUBraey#0HV|&c4v7PVo3n$zHj99(TZO^3?Ly%C4nYvJTL9eLBLHsM3WKKD>5!B` zQ=BsR3aR6PD(Fa>327E2HAu5TM~Wusc!)>~(gM)+3~m;92Jd;FnSib=M5d6;;5{%R zb4V7DEJ0V!CP-F*oU?gkc>ksUtAYP&V4ND5J>J2^jt*vcFflQWCrB&fLdT%O59PVJ zhid#toR=FNgD!q3&r8#wEBr`!wzvQu5zX?Q>nlSJ4i@WC*CN*-xU66F^V5crWevQ9gsq$I@z1o(a=k7LL~ z7m_~`o;_Ozha1$8Q}{WBehvAlO4EL60y5}8GDrZ< zXh&F}71JbW2A~8KfEWj&UWV#4+Z4p`b{uAj4&WC zha`}X@3~+Iz^WRlOHU&KngK>#j}+_o@LdBC1H-`gT+krWX3-;!)6?{FBp~%20a}FL zFP9%Emqcwa#(`=G>BBZ0qZDQhmZKJg_g8<=bBFKWr!dyg(YkpE+|R*SGpDVU!+VlU zFC54^DLv}`qa%49T>nNiA9Q7Ips#!Xx90tCU2gvK`(F+GPcL=J^>No{)~we#o@&mUb6c$ zCc*<|NJBk-#+{j9xkQ&ujB zI~`#kN~7W!f*-}wkG~Ld!JqZ@tK}eeSnsS5J1fMFXm|`LJx&}5`@dK3W^7#Wnm+_P zBZkp&j1fa2Y=eIjJ0}gh85jt43kaIXXv?xmo@eHrka!Z|vQv12HN#+!I5E z`(fbuW>gFiJL|uXJ!vKt#z3e3HlVdboH7;e#i3(2<)Fg-I@BR!qY#eof3MFZ&*Y@l zI|KJf&ge@p2Dq09Vu$$Qxb7!}{m-iRk@!)%KL)txi3;~Z4Pb}u@GsW;ELiWeG9V51 znX#}B&4Y2E7-H=OpNE@q{%hFLxwIpBF2t{vPREa8_{linXT;#1vMRWjOzLOP$-hf( z>=?$0;~~PnkqY;~K{EM6Vo-T(0K{A0}VUGmu*hR z{tw3hvBN%N3G3Yw`X5Te+F{J`(3w1s3-+1EbnFQKcrgrX1Jqvs@ADGe%M0s$EbK$$ zK)=y=upBc6SjGYAACCcI=Y*6Fi8_jgwZlLxD26fnQfJmb8^gHRN5(TemhX@0e=vr> zg`W}6U>x6VhoA3DqsGGD9uL1DhB3!OXO=k}59TqD@(0Nb{)Ut_luTioK_>7wjc!5C zIr@w}b`Fez3)0wQfKl&bae7;PcTA7%?f2xucM0G)wt_KO!Ewx>F~;=BI0j=Fb4>pp zv}0R^xM4eti~+^+gE$6b81p(kwzuDti(-K9bc|?+pJEl@H+jSYuxZQV8rl8 zjp@M{#%qItIUFN~KcO9Hed*`$5A-2~pAo~K&<-Q+`9`$CK>rzqAI4w~$F%vs9s{~x zg4BP%Gy*@m?;D6=SRX?888Q6peF@_4Z->8wAH~Cn!R$|Hhq2cIzFYqT_+cDourHbY z0qroxJnrZ4Gh+Ay+F`_c%+KRT>y3qw{)89?=hJ@=KO=@ep)aBJ$c!JHfBMJpsP*3G za7|)VJJ8B;4?n{~ldJF7%jmb`-ftIvNd~ekoufG(`K(3=LNc;HBY& z(lp#q8XAD#cIf}k49zX_i`*fO+#!zKA&%T3j@%)R+#yag067CU%yUEe47>wzGU8^` z1EXFT^@I!{J!F8!X?S6ph8J=gUi5tl93*W>7}_uR<2N2~e}FaG?}KPyugQ=-OGEZs z!GBoyYY+H*ANn4?Z)X4l+7H%`17i5~zRlRIX?t)6_eu=g2Q`3WBhxSUeea+M-S?RL zX9oBGKn%a!H+*hx4d2(I!gsi+@SQK%<{X22M~2tMulJoa)0*+z9=-YO+;DFEm5eE1U9b^B(Z}2^9!Qk`!A$wUE z7$Ar5?NRg2&G!AZqnmE64eh^Anss3i!{}%6@Et+4rr!=}!SBF8eZ2*J3ujCWbl;3; z48H~goPSv(8X61fKKdpP!Z7$88NL^Z?j`!^*I?-P4X^pMxyWz~@$(UeAcTSDd(`vO z{~rc;9|GfMJcApU3k}22a!&)k4{CU!e_ny^Y3cO;tOvOMKEyWz!vG(Kp*;hB?d|R3`2X~=5a6#^o5@qn?J-bI8Ppip{-yG z!k|VcGsq!jF~}7DMr49Wap-s&>o=U^T0!Lcy}!(bhtYsPQy z4|EJe{12QL#=c(suQ89Mhw9<`bui%nx7Nep`C&*M3~vMEACmcRYYRGtANq$F%zh&V zc)cEVeHz*Z1N)L7k-(k3np#{GcDh2Q@ya0YHl*n7fl*ZPAsbU-a94MYYtA#&!c`xGIaV;yzsmrjfieTEtqB_WgZp2*NplHx=$O{M~2#i_vJ{ps-NgK zQsxKK_CBM2PP_je+Xft`(vYfXXgIUr{=PA=7a8`2EHk)Ym2QKIforz# tySWtj{oF3N9@_;i*Fv5S)9x^z=nlWP>jpp-9)52ZmLVA=i*%6g{{fxOO~wEK literal 0 HcmV?d00001 diff --git a/windows/runner/runner.exe.manifest b/windows/runner/runner.exe.manifest new file mode 100644 index 0000000..a42ea76 --- /dev/null +++ b/windows/runner/runner.exe.manifest @@ -0,0 +1,20 @@ + + + + + PerMonitorV2 + + + + + + + + + + + + + + + diff --git a/windows/runner/utils.cpp b/windows/runner/utils.cpp new file mode 100644 index 0000000..b2b0873 --- /dev/null +++ b/windows/runner/utils.cpp @@ -0,0 +1,65 @@ +#include "utils.h" + +#include +#include +#include +#include + +#include + +void CreateAndAttachConsole() { + if (::AllocConsole()) { + FILE *unused; + if (freopen_s(&unused, "CONOUT$", "w", stdout)) { + _dup2(_fileno(stdout), 1); + } + if (freopen_s(&unused, "CONOUT$", "w", stderr)) { + _dup2(_fileno(stdout), 2); + } + std::ios::sync_with_stdio(); + FlutterDesktopResyncOutputStreams(); + } +} + +std::vector GetCommandLineArguments() { + // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. + int argc; + wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); + if (argv == nullptr) { + return std::vector(); + } + + std::vector command_line_arguments; + + // Skip the first argument as it's the binary name. + for (int i = 1; i < argc; i++) { + command_line_arguments.push_back(Utf8FromUtf16(argv[i])); + } + + ::LocalFree(argv); + + return command_line_arguments; +} + +std::string Utf8FromUtf16(const wchar_t* utf16_string) { + if (utf16_string == nullptr) { + return std::string(); + } + int target_length = ::WideCharToMultiByte( + CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, + -1, nullptr, 0, nullptr, nullptr) + -1; // remove the trailing null character + int input_length = (int)wcslen(utf16_string); + std::string utf8_string; + if (target_length <= 0 || target_length > utf8_string.max_size()) { + return utf8_string; + } + utf8_string.resize(target_length); + int converted_length = ::WideCharToMultiByte( + CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, + input_length, utf8_string.data(), target_length, nullptr, nullptr); + if (converted_length == 0) { + return std::string(); + } + return utf8_string; +} diff --git a/windows/runner/utils.h b/windows/runner/utils.h new file mode 100644 index 0000000..3879d54 --- /dev/null +++ b/windows/runner/utils.h @@ -0,0 +1,19 @@ +#ifndef RUNNER_UTILS_H_ +#define RUNNER_UTILS_H_ + +#include +#include + +// Creates a console for the process, and redirects stdout and stderr to +// it for both the runner and the Flutter library. +void CreateAndAttachConsole(); + +// Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string +// encoded in UTF-8. Returns an empty std::string on failure. +std::string Utf8FromUtf16(const wchar_t* utf16_string); + +// Gets the command line arguments passed in as a std::vector, +// encoded in UTF-8. Returns an empty std::vector on failure. +std::vector GetCommandLineArguments(); + +#endif // RUNNER_UTILS_H_ diff --git a/windows/runner/win32_window.cpp b/windows/runner/win32_window.cpp new file mode 100644 index 0000000..60608d0 --- /dev/null +++ b/windows/runner/win32_window.cpp @@ -0,0 +1,288 @@ +#include "win32_window.h" + +#include +#include + +#include "resource.h" + +namespace { + +/// Window attribute that enables dark mode window decorations. +/// +/// Redefined in case the developer's machine has a Windows SDK older than +/// version 10.0.22000.0. +/// See: https://docs.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute +#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE +#define DWMWA_USE_IMMERSIVE_DARK_MODE 20 +#endif + +constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; + +/// Registry key for app theme preference. +/// +/// A value of 0 indicates apps should use dark mode. A non-zero or missing +/// value indicates apps should use light mode. +constexpr const wchar_t kGetPreferredBrightnessRegKey[] = + L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"; +constexpr const wchar_t kGetPreferredBrightnessRegValue[] = L"AppsUseLightTheme"; + +// The number of Win32Window objects that currently exist. +static int g_active_window_count = 0; + +using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd); + +// Scale helper to convert logical scaler values to physical using passed in +// scale factor +int Scale(int source, double scale_factor) { + return static_cast(source * scale_factor); +} + +// Dynamically loads the |EnableNonClientDpiScaling| from the User32 module. +// This API is only needed for PerMonitor V1 awareness mode. +void EnableFullDpiSupportIfAvailable(HWND hwnd) { + HMODULE user32_module = LoadLibraryA("User32.dll"); + if (!user32_module) { + return; + } + auto enable_non_client_dpi_scaling = + reinterpret_cast( + GetProcAddress(user32_module, "EnableNonClientDpiScaling")); + if (enable_non_client_dpi_scaling != nullptr) { + enable_non_client_dpi_scaling(hwnd); + } + FreeLibrary(user32_module); +} + +} // namespace + +// Manages the Win32Window's window class registration. +class WindowClassRegistrar { + public: + ~WindowClassRegistrar() = default; + + // Returns the singleton registrar instance. + static WindowClassRegistrar* GetInstance() { + if (!instance_) { + instance_ = new WindowClassRegistrar(); + } + return instance_; + } + + // Returns the name of the window class, registering the class if it hasn't + // previously been registered. + const wchar_t* GetWindowClass(); + + // Unregisters the window class. Should only be called if there are no + // instances of the window. + void UnregisterWindowClass(); + + private: + WindowClassRegistrar() = default; + + static WindowClassRegistrar* instance_; + + bool class_registered_ = false; +}; + +WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; + +const wchar_t* WindowClassRegistrar::GetWindowClass() { + if (!class_registered_) { + WNDCLASS window_class{}; + window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); + window_class.lpszClassName = kWindowClassName; + window_class.style = CS_HREDRAW | CS_VREDRAW; + window_class.cbClsExtra = 0; + window_class.cbWndExtra = 0; + window_class.hInstance = GetModuleHandle(nullptr); + window_class.hIcon = + LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); + window_class.hbrBackground = 0; + window_class.lpszMenuName = nullptr; + window_class.lpfnWndProc = Win32Window::WndProc; + RegisterClass(&window_class); + class_registered_ = true; + } + return kWindowClassName; +} + +void WindowClassRegistrar::UnregisterWindowClass() { + UnregisterClass(kWindowClassName, nullptr); + class_registered_ = false; +} + +Win32Window::Win32Window() { + ++g_active_window_count; +} + +Win32Window::~Win32Window() { + --g_active_window_count; + Destroy(); +} + +bool Win32Window::Create(const std::wstring& title, + const Point& origin, + const Size& size) { + Destroy(); + + const wchar_t* window_class = + WindowClassRegistrar::GetInstance()->GetWindowClass(); + + const POINT target_point = {static_cast(origin.x), + static_cast(origin.y)}; + HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST); + UINT dpi = FlutterDesktopGetDpiForMonitor(monitor); + double scale_factor = dpi / 96.0; + + HWND window = CreateWindow( + window_class, title.c_str(), WS_OVERLAPPEDWINDOW, + Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), + Scale(size.width, scale_factor), Scale(size.height, scale_factor), + nullptr, nullptr, GetModuleHandle(nullptr), this); + + if (!window) { + return false; + } + + UpdateTheme(window); + + return OnCreate(); +} + +bool Win32Window::Show() { + return ShowWindow(window_handle_, SW_SHOWNORMAL); +} + +// static +LRESULT CALLBACK Win32Window::WndProc(HWND const window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + if (message == WM_NCCREATE) { + auto window_struct = reinterpret_cast(lparam); + SetWindowLongPtr(window, GWLP_USERDATA, + reinterpret_cast(window_struct->lpCreateParams)); + + auto that = static_cast(window_struct->lpCreateParams); + EnableFullDpiSupportIfAvailable(window); + that->window_handle_ = window; + } else if (Win32Window* that = GetThisFromHandle(window)) { + return that->MessageHandler(window, message, wparam, lparam); + } + + return DefWindowProc(window, message, wparam, lparam); +} + +LRESULT +Win32Window::MessageHandler(HWND hwnd, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + switch (message) { + case WM_DESTROY: + window_handle_ = nullptr; + Destroy(); + if (quit_on_close_) { + PostQuitMessage(0); + } + return 0; + + case WM_DPICHANGED: { + auto newRectSize = reinterpret_cast(lparam); + LONG newWidth = newRectSize->right - newRectSize->left; + LONG newHeight = newRectSize->bottom - newRectSize->top; + + SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, + newHeight, SWP_NOZORDER | SWP_NOACTIVATE); + + return 0; + } + case WM_SIZE: { + RECT rect = GetClientArea(); + if (child_content_ != nullptr) { + // Size and position the child window. + MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, + rect.bottom - rect.top, TRUE); + } + return 0; + } + + case WM_ACTIVATE: + if (child_content_ != nullptr) { + SetFocus(child_content_); + } + return 0; + + case WM_DWMCOLORIZATIONCOLORCHANGED: + UpdateTheme(hwnd); + return 0; + } + + return DefWindowProc(window_handle_, message, wparam, lparam); +} + +void Win32Window::Destroy() { + OnDestroy(); + + if (window_handle_) { + DestroyWindow(window_handle_); + window_handle_ = nullptr; + } + if (g_active_window_count == 0) { + WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); + } +} + +Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept { + return reinterpret_cast( + GetWindowLongPtr(window, GWLP_USERDATA)); +} + +void Win32Window::SetChildContent(HWND content) { + child_content_ = content; + SetParent(content, window_handle_); + RECT frame = GetClientArea(); + + MoveWindow(content, frame.left, frame.top, frame.right - frame.left, + frame.bottom - frame.top, true); + + SetFocus(child_content_); +} + +RECT Win32Window::GetClientArea() { + RECT frame; + GetClientRect(window_handle_, &frame); + return frame; +} + +HWND Win32Window::GetHandle() { + return window_handle_; +} + +void Win32Window::SetQuitOnClose(bool quit_on_close) { + quit_on_close_ = quit_on_close; +} + +bool Win32Window::OnCreate() { + // No-op; provided for subclasses. + return true; +} + +void Win32Window::OnDestroy() { + // No-op; provided for subclasses. +} + +void Win32Window::UpdateTheme(HWND const window) { + DWORD light_mode; + DWORD light_mode_size = sizeof(light_mode); + LSTATUS result = RegGetValue(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey, + kGetPreferredBrightnessRegValue, + RRF_RT_REG_DWORD, nullptr, &light_mode, + &light_mode_size); + + if (result == ERROR_SUCCESS) { + BOOL enable_dark_mode = light_mode == 0; + DwmSetWindowAttribute(window, DWMWA_USE_IMMERSIVE_DARK_MODE, + &enable_dark_mode, sizeof(enable_dark_mode)); + } +} diff --git a/windows/runner/win32_window.h b/windows/runner/win32_window.h new file mode 100644 index 0000000..e901dde --- /dev/null +++ b/windows/runner/win32_window.h @@ -0,0 +1,102 @@ +#ifndef RUNNER_WIN32_WINDOW_H_ +#define RUNNER_WIN32_WINDOW_H_ + +#include + +#include +#include +#include + +// A class abstraction for a high DPI-aware Win32 Window. Intended to be +// inherited from by classes that wish to specialize with custom +// rendering and input handling +class Win32Window { + public: + struct Point { + unsigned int x; + unsigned int y; + Point(unsigned int x, unsigned int y) : x(x), y(y) {} + }; + + struct Size { + unsigned int width; + unsigned int height; + Size(unsigned int width, unsigned int height) + : width(width), height(height) {} + }; + + Win32Window(); + virtual ~Win32Window(); + + // Creates a win32 window with |title| that is positioned and sized using + // |origin| and |size|. New windows are created on the default monitor. Window + // sizes are specified to the OS in physical pixels, hence to ensure a + // consistent size this function will scale the inputted width and height as + // as appropriate for the default monitor. The window is invisible until + // |Show| is called. Returns true if the window was created successfully. + bool Create(const std::wstring& title, const Point& origin, const Size& size); + + // Show the current window. Returns true if the window was successfully shown. + bool Show(); + + // Release OS resources associated with window. + void Destroy(); + + // Inserts |content| into the window tree. + void SetChildContent(HWND content); + + // Returns the backing Window handle to enable clients to set icon and other + // window properties. Returns nullptr if the window has been destroyed. + HWND GetHandle(); + + // If true, closing this window will quit the application. + void SetQuitOnClose(bool quit_on_close); + + // Return a RECT representing the bounds of the current client area. + RECT GetClientArea(); + + protected: + // Processes and route salient window messages for mouse handling, + // size change and DPI. Delegates handling of these to member overloads that + // inheriting classes can handle. + virtual LRESULT MessageHandler(HWND window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept; + + // Called when CreateAndShow is called, allowing subclass window-related + // setup. Subclasses should return false if setup fails. + virtual bool OnCreate(); + + // Called when Destroy is called. + virtual void OnDestroy(); + + private: + friend class WindowClassRegistrar; + + // OS callback called by message pump. Handles the WM_NCCREATE message which + // is passed when the non-client area is being created and enables automatic + // non-client DPI scaling so that the non-client area automatically + // responds to changes in DPI. All other messages are handled by + // MessageHandler. + static LRESULT CALLBACK WndProc(HWND const window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept; + + // Retrieves a class instance pointer for |window| + static Win32Window* GetThisFromHandle(HWND const window) noexcept; + + // Update the window frame's theme to match the system theme. + static void UpdateTheme(HWND const window); + + bool quit_on_close_ = false; + + // window handle for top level window. + HWND window_handle_ = nullptr; + + // window handle for hosted content. + HWND child_content_ = nullptr; +}; + +#endif // RUNNER_WIN32_WINDOW_H_ -- 2.47.3 From e950c5c2fa066a53f3c0781033062869f58d9131 Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Mon, 24 Apr 2023 12:57:29 +0700 Subject: [PATCH 06/28] Better behaviour for login page --- lib/pages/login_page.dart | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/lib/pages/login_page.dart b/lib/pages/login_page.dart index ebdfc94..d412533 100644 --- a/lib/pages/login_page.dart +++ b/lib/pages/login_page.dart @@ -1,13 +1,13 @@ import 'dart:async'; import 'package:animated_background/animated_background.dart'; +import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:tuuli_api/tuuli_api.dart'; import 'package:tuuli_app/api_controller.dart'; -class LoginPageController extends GetxController - with GetSingleTickerProviderStateMixin { +class LoginPageController extends GetxController { final _login = "".obs; String get login => _login.value; set login(String value) => _login.value = value; @@ -37,13 +37,31 @@ class LoginPageController extends GetxController if (resp.statusCode == 200 && respData != null) { final accessToken = respData.accessToken; Get.find().token = accessToken; - Get.offAllNamed("/home"); + WidgetsBinding.instance.addPostFrameCallback((_) { + Get.offAllNamed("/home"); + }); } else { Get.snackbar( "Login failed", resp.statusMessage ?? "Unknown error", ); } + } on DioError catch (e) { + final errorData = e.response?.data; + if (errorData != null) { + final error = errorData["error"]; + if (error != null) { + Get.snackbar( + "Login failed", + "$error", + ); + } + } else { + Get.snackbar( + "Login failed", + "$e", + ); + } } catch (e) { Get.snackbar( "Login failed", @@ -65,12 +83,8 @@ class LoginPage extends GetView { return Scaffold( body: Stack( children: [ - AnimatedBackground( - behaviour: RandomParticleBehaviour(), - vsync: controller, - child: const SizedBox.square( - dimension: 0, - ), + const SizedBox.square( + dimension: 0, ), Row( mainAxisAlignment: MainAxisAlignment.start, -- 2.47.3 From 619a43eaede4ee818cbee55c1bd7f564919fc15c Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Mon, 24 Apr 2023 12:57:43 +0700 Subject: [PATCH 07/28] Better behaviour for checkup page as well --- lib/pages/checkup_page.dart | 94 +++++++++++++++++++------------------ 1 file changed, 48 insertions(+), 46 deletions(-) diff --git a/lib/pages/checkup_page.dart b/lib/pages/checkup_page.dart index d25468a..eaddd0f 100644 --- a/lib/pages/checkup_page.dart +++ b/lib/pages/checkup_page.dart @@ -1,65 +1,67 @@ import 'package:animated_background/animated_background.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; -import 'package:get_storage/get_storage.dart'; -import 'package:tuuli_app/api/api_client.dart'; - -class CheckupPage extends StatefulWidget { - const CheckupPage({super.key}); +import 'package:tuuli_app/api_controller.dart'; +class CheckupPageController extends GetxController { @override - State createState() => _CheckupPageState(); + void onInit() { + super.onInit(); + } + + Future checkCredentials() async { + if (ApiController.to.token.isEmpty) { + WidgetsBinding.instance.addPostFrameCallback((_) { + Get.offAllNamed("/login"); + }); + } else { + try { + final resp = + await ApiController.to.apiClient.listTablesApiListTablesGet( + accessToken: ApiController.to.token, + ); + + WidgetsBinding.instance.addPostFrameCallback((_) { + if (resp.statusCode == 200) { + Get.offAllNamed("/home"); + } else { + Get.offAllNamed("/login"); + } + }); + } catch (e) { + WidgetsBinding.instance.addPostFrameCallback((_) { + Get.offAllNamed("/login"); + }); + } + } + } } -class _CheckupPageState extends State - with TickerProviderStateMixin { - @override - void initState() { - super.initState(); - - WidgetsBinding.instance.addPostFrameCallback((_) { - checkCredentials(); - }); - } +class CheckupPage extends GetView { + const CheckupPage({super.key}); @override Widget build(BuildContext context) { return Scaffold( - body: AnimatedBackground( - behaviour: RandomParticleBehaviour(), - vsync: this, - child: Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - 'Checking credentials...', - style: Theme.of(context).textTheme.headlineMedium, - ), - const SizedBox(height: 16), - const SizedBox.square( + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + 'Checking credentials...', + style: Theme.of(context).textTheme.headlineMedium, + ), + const SizedBox(height: 16), + FutureBuilder( + future: controller.checkCredentials(), + builder: (ctx, _) => const SizedBox.square( dimension: 32, child: CircularProgressIndicator(), ), - ], - ), + ), + ], ), ), ); } - - Future checkCredentials() async { - final accessToken = GetStorage().read("accessToken"); - if (accessToken == null) { - Get.offAllNamed("/login"); - } else { - final apiClient = Get.find(); - (await apiClient.tablesList()).unfold((data) { - Get.offAllNamed("/home"); - }, (error) async { - await GetStorage().remove("accessToken"); - Get.offAllNamed("/login"); - }); - } - } } -- 2.47.3 From 6044b787d5c2f1b120d5c5c1fbff90c25c09ab2b Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Mon, 24 Apr 2023 13:05:06 +0700 Subject: [PATCH 08/28] Only api key interceptor used --- lib/api_controller.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/api_controller.dart b/lib/api_controller.dart index ce8b5ad..4dafa6f 100644 --- a/lib/api_controller.dart +++ b/lib/api_controller.dart @@ -24,6 +24,9 @@ class ApiController extends GetxController { receiveTimeout: 3000.milliseconds, receiveDataWhenStatusError: true, )), + interceptors: [ + ApiKeyAuthInterceptor(), + ], ); _apiClientBase!.setApiKey("access-token", token); return _apiClientBase!; -- 2.47.3 From e5622166585032f0ff5bf51e7d67e22b3f3b9221 Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Mon, 24 Apr 2023 13:34:05 +0700 Subject: [PATCH 09/28] More improvements upon checkup page --- lib/main.dart | 2 +- lib/pages/checkup_page.dart | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 36f676d..6528de4 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -37,7 +37,7 @@ class MainApp extends StatelessWidget { return GetMaterialApp( debugShowCheckedModeBanner: false, debugShowMaterialGrid: false, - initialRoute: "/login", + initialRoute: "/", onGenerateRoute: _onGenerateRoute, theme: ThemeData( brightness: Brightness.dark, diff --git a/lib/pages/checkup_page.dart b/lib/pages/checkup_page.dart index eaddd0f..aab6c9a 100644 --- a/lib/pages/checkup_page.dart +++ b/lib/pages/checkup_page.dart @@ -17,9 +17,7 @@ class CheckupPageController extends GetxController { } else { try { final resp = - await ApiController.to.apiClient.listTablesApiListTablesGet( - accessToken: ApiController.to.token, - ); + await ApiController.to.apiClient.listTablesApiListTablesGet(); WidgetsBinding.instance.addPostFrameCallback((_) { if (resp.statusCode == 200) { -- 2.47.3 From f67e947f8b0264fcb057db13a547e7ca6d40c0c8 Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Tue, 25 Apr 2023 15:08:03 +0700 Subject: [PATCH 10/28] User panel fully functional --- .metadata | 15 - lib/models/db_column_definition.dart | 106 ++ lib/models/group_definition.dart | 11 + lib/models/user_definition.dart | 13 + lib/models/user_in_group_definition.dart | 11 + .../create_table_item_bottomsheet.dart | 3 +- .../bottomsheets/create_user_bottomsheet.dart | 3 +- .../bottomsheets/edit_table_bottomsheet.dart | 3 +- .../bottomsheets/open_table_bottomsheet.dart | 3 +- lib/pages/checkup_page.dart | 10 +- lib/pages/home_page.dart | 161 ++- lib/pages/home_panels/tables_list_panel.dart | 299 +++-- lib/pages/home_panels/users_list_panel.dart | 1054 ++++++++++++++--- lib/pages/login_page.dart | 169 +-- pubspec.lock | 118 +- pubspec.yaml | 8 +- 16 files changed, 1346 insertions(+), 641 deletions(-) create mode 100644 lib/models/db_column_definition.dart create mode 100644 lib/models/group_definition.dart create mode 100644 lib/models/user_definition.dart create mode 100644 lib/models/user_in_group_definition.dart diff --git a/.metadata b/.metadata index 1c353fa..5f0d710 100644 --- a/.metadata +++ b/.metadata @@ -15,21 +15,6 @@ migration: - platform: root create_revision: 9ba0d08ebc074bf0da6dfd1fadea39f5c5566198 base_revision: 9ba0d08ebc074bf0da6dfd1fadea39f5c5566198 - - platform: android - create_revision: 9ba0d08ebc074bf0da6dfd1fadea39f5c5566198 - base_revision: 9ba0d08ebc074bf0da6dfd1fadea39f5c5566198 - - platform: ios - create_revision: 9ba0d08ebc074bf0da6dfd1fadea39f5c5566198 - base_revision: 9ba0d08ebc074bf0da6dfd1fadea39f5c5566198 - - platform: linux - create_revision: 9ba0d08ebc074bf0da6dfd1fadea39f5c5566198 - base_revision: 9ba0d08ebc074bf0da6dfd1fadea39f5c5566198 - - platform: macos - create_revision: 9ba0d08ebc074bf0da6dfd1fadea39f5c5566198 - base_revision: 9ba0d08ebc074bf0da6dfd1fadea39f5c5566198 - - platform: web - create_revision: 9ba0d08ebc074bf0da6dfd1fadea39f5c5566198 - base_revision: 9ba0d08ebc074bf0da6dfd1fadea39f5c5566198 - platform: windows create_revision: 9ba0d08ebc074bf0da6dfd1fadea39f5c5566198 base_revision: 9ba0d08ebc074bf0da6dfd1fadea39f5c5566198 diff --git a/lib/models/db_column_definition.dart b/lib/models/db_column_definition.dart new file mode 100644 index 0000000..3443120 --- /dev/null +++ b/lib/models/db_column_definition.dart @@ -0,0 +1,106 @@ +import 'package:tuuli_api/tuuli_api.dart'; + +extension ColumnsParser on TableDefinition { + List get parsedColumns { + return columns + .split(",") + .map((e) { + final parts = e.split(":"); + final name = parts[0]; + switch (parts[1]) { + case "serial": + return PrimarySerialColumnDefinition(name); + case "str": + return TextColumnDefinition( + name, + parts.contains("unique"), + parts.contains("default"), + ); + case "bool": + return BooleanColumnDefinition( + name, + parts.contains("unique"), + parts.contains("default"), + ); + case "datetime": + return TimestampColumnDefinition( + name, + parts.contains("unique"), + parts.contains("default"), + ); + case "float": + return DoubleColumnDefinition( + name, + parts.contains("unique"), + parts.contains("default"), + ); + case "int": + return IntegerColumnDefinition( + name, + parts.contains("unique"), + parts.contains("default"), + ); + case "int-user": + return UserRefColumnDefinition(name); + case "int-asset": + return AssetRefColumnDefinition(name); + } + + return null; + }) + .whereType() + .toList(growable: false); + } +} + +abstract class DBColumnDefinition { + final String name; + final bool unique; + final bool hasDefault; + + DBColumnDefinition({ + required this.name, + required this.unique, + required this.hasDefault, + }); +} + +class PrimarySerialColumnDefinition extends DBColumnDefinition { + PrimarySerialColumnDefinition(String name) + : super(name: name, unique: false, hasDefault: false); +} + +class TextColumnDefinition extends DBColumnDefinition { + TextColumnDefinition(String name, bool unique, bool hasDefault) + : super(name: name, unique: unique, hasDefault: hasDefault); +} + +class BooleanColumnDefinition extends DBColumnDefinition { + BooleanColumnDefinition(String name, bool unique, bool hasDefault) + : super(name: name, unique: unique, hasDefault: hasDefault); +} + +class TimestampColumnDefinition extends DBColumnDefinition { + TimestampColumnDefinition(String name, bool unique, bool hasDefault) + : super(name: name, unique: unique, hasDefault: hasDefault); +} + +class DoubleColumnDefinition extends DBColumnDefinition { + DoubleColumnDefinition(String name, bool unique, bool hasDefault) + : super(name: name, unique: unique, hasDefault: hasDefault); +} + +class IntegerColumnDefinition extends DBColumnDefinition { + IntegerColumnDefinition(String name, bool unique, bool hasDefault) + : super(name: name, unique: unique, hasDefault: hasDefault); +} + +class UserRefColumnDefinition extends DBColumnDefinition { + UserRefColumnDefinition(String name) + : super(name: name, unique: false, hasDefault: false); +} + +class AssetRefColumnDefinition extends DBColumnDefinition { + AssetRefColumnDefinition(String name) + : super(name: name, unique: false, hasDefault: false); +} diff --git a/lib/models/group_definition.dart b/lib/models/group_definition.dart new file mode 100644 index 0000000..22c4a17 --- /dev/null +++ b/lib/models/group_definition.dart @@ -0,0 +1,11 @@ +class GroupDefinition { + final int id; + final String name; + final String description; + + const GroupDefinition({ + required this.id, + required this.name, + required this.description, + }); +} diff --git a/lib/models/user_definition.dart b/lib/models/user_definition.dart new file mode 100644 index 0000000..31aa60a --- /dev/null +++ b/lib/models/user_definition.dart @@ -0,0 +1,13 @@ +class UserDefinition { + final int id; + final String username; + final String password; + final String accessToken; + + const UserDefinition({ + required this.id, + required this.username, + required this.password, + required this.accessToken, + }); +} diff --git a/lib/models/user_in_group_definition.dart b/lib/models/user_in_group_definition.dart new file mode 100644 index 0000000..360ed47 --- /dev/null +++ b/lib/models/user_in_group_definition.dart @@ -0,0 +1,11 @@ +class UserInGroupDefinition { + final int id; + final int userId; + final int groupId; + + const UserInGroupDefinition({ + required this.id, + required this.userId, + required this.groupId, + }); +} diff --git a/lib/pages/bottomsheets/create_table_item_bottomsheet.dart b/lib/pages/bottomsheets/create_table_item_bottomsheet.dart index 45c5621..5fac541 100644 --- a/lib/pages/bottomsheets/create_table_item_bottomsheet.dart +++ b/lib/pages/bottomsheets/create_table_item_bottomsheet.dart @@ -1,4 +1,4 @@ -import 'package:flutter/material.dart'; +/*import 'package:flutter/material.dart'; import 'package:flutter_fast_forms/flutter_fast_forms.dart'; import 'package:get/get.dart'; import 'package:tuuli_app/api/api_client.dart'; @@ -196,3 +196,4 @@ class _CreateTableItemBottomSheetState } } } +*/ \ No newline at end of file diff --git a/lib/pages/bottomsheets/create_user_bottomsheet.dart b/lib/pages/bottomsheets/create_user_bottomsheet.dart index 886ef86..72c8223 100644 --- a/lib/pages/bottomsheets/create_user_bottomsheet.dart +++ b/lib/pages/bottomsheets/create_user_bottomsheet.dart @@ -1,4 +1,4 @@ -import 'package:flutter/material.dart'; +/*import 'package:flutter/material.dart'; import 'package:flutter_fast_forms/flutter_fast_forms.dart'; import 'package:get/get.dart'; import 'package:tuuli_app/api/api_client.dart'; @@ -215,3 +215,4 @@ class _CreateUserBottomSheetState extends State { ); } } +*/ \ No newline at end of file diff --git a/lib/pages/bottomsheets/edit_table_bottomsheet.dart b/lib/pages/bottomsheets/edit_table_bottomsheet.dart index 0bf8b4a..064e38f 100644 --- a/lib/pages/bottomsheets/edit_table_bottomsheet.dart +++ b/lib/pages/bottomsheets/edit_table_bottomsheet.dart @@ -1,4 +1,4 @@ -import 'package:flutter/material.dart'; +/*import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:recase/recase.dart'; import 'package:tuuli_app/api/model/table_field_model.dart'; @@ -240,3 +240,4 @@ class _EditTableBottomSheetState extends State { }); } } +*/ \ No newline at end of file diff --git a/lib/pages/bottomsheets/open_table_bottomsheet.dart b/lib/pages/bottomsheets/open_table_bottomsheet.dart index 44b95db..045c043 100644 --- a/lib/pages/bottomsheets/open_table_bottomsheet.dart +++ b/lib/pages/bottomsheets/open_table_bottomsheet.dart @@ -1,4 +1,4 @@ -import 'package:bottom_sheet/bottom_sheet.dart'; +/*import 'package:bottom_sheet/bottom_sheet.dart'; import 'package:data_table_2/data_table_2.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; @@ -255,3 +255,4 @@ class _OpenTableBottomSheetState extends State { }); } } +*/ \ No newline at end of file diff --git a/lib/pages/checkup_page.dart b/lib/pages/checkup_page.dart index aab6c9a..a4fe508 100644 --- a/lib/pages/checkup_page.dart +++ b/lib/pages/checkup_page.dart @@ -1,23 +1,17 @@ -import 'package:animated_background/animated_background.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:tuuli_app/api_controller.dart'; class CheckupPageController extends GetxController { - @override - void onInit() { - super.onInit(); - } - Future checkCredentials() async { if (ApiController.to.token.isEmpty) { WidgetsBinding.instance.addPostFrameCallback((_) { + ApiController.to.token = ""; Get.offAllNamed("/login"); }); } else { try { - final resp = - await ApiController.to.apiClient.listTablesApiListTablesGet(); + final resp = await ApiController.to.apiClient.listTables(); WidgetsBinding.instance.addPostFrameCallback((_) { if (resp.statusCode == 200) { diff --git a/lib/pages/home_page.dart b/lib/pages/home_page.dart index 26e351c..a6f43d7 100644 --- a/lib/pages/home_page.dart +++ b/lib/pages/home_page.dart @@ -1,8 +1,7 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:get_storage/get_storage.dart'; -import 'package:tuuli_app/api/api_client.dart'; -import 'package:tuuli_app/api/model/tables_list_model.dart'; +import 'package:tuuli_app/api_controller.dart'; import 'package:tuuli_app/c.dart'; import 'package:tuuli_app/pages/home_panels/none_panel.dart'; import 'package:tuuli_app/pages/home_panels/settings_panel.dart'; @@ -16,35 +15,13 @@ enum PageType { settings, } -mixin HomePageStateRef { - void refreshData(); -} +class HomePageController extends GetxController { + final _currentPage = PageType.none.obs; + PageType get currentPage => _currentPage.value; + set currentPage(PageType value) => _currentPage.value = value; -class HomePage extends StatefulWidget { - const HomePage({super.key}); + String get currentPageName => pageNames[currentPage]!; - @override - State createState() => _HomePageState(); -} - -class _HomePageState extends State with HomePageStateRef { - final apiClient = Get.find(); - TablesListModel tables = TablesListModel([]); - - TableModel get usersTable => - tables.tables.firstWhere((element) => element.tableName == "users"); - - bool get isNarrow => - (MediaQuery.of(context).size.width - C.materialDrawerWidth) <= 600; - - @override - void initState() { - super.initState(); - - refreshData(); - } - - var currentPage = PageType.none; final pageNames = { PageType.none: "Home", PageType.tables: "Tables", @@ -52,8 +29,41 @@ class _HomePageState extends State with HomePageStateRef { PageType.settings: "Settings", }; + @override + void onInit() { + super.onInit(); + + Get.lazyPut( + () => TablesListPanelController(), + fenix: true, + ); + Get.lazyPut( + () => UserListPanelController(), + fenix: true, + ); + } + + Future logout() async { + ApiController.to.token = ""; + + await Future.wait([ + Get.delete(), + Get.delete(), + Get.delete(), + ]); + + Get.offAllNamed("/"); + } +} + +class HomePage extends GetView { + const HomePage({super.key}); + + bool get isNarrow => + (Get.mediaQuery.size.width - C.materialDrawerWidth) <= 600; + AppBar get appBar => AppBar( - title: Text(pageNames[currentPage]!), + title: Obx(() => Text(controller.currentPageName)), actions: [ IconButton( icon: const Icon(Icons.home), @@ -62,51 +72,49 @@ class _HomePageState extends State with HomePageStateRef { }, ), IconButton( - icon: const Icon(Icons.refresh), - onPressed: refreshData, + icon: const Icon(Icons.logout), + onPressed: () => controller.logout(), ), ], ); ListView get drawerOptions => ListView( children: [ - ListTile( - leading: const Icon(Icons.table_chart), - title: const Text("Tables"), - onTap: () { - setState(() { - currentPage = PageType.tables; - }); - }, + Obx( + () => ListTile( + leading: const Icon(Icons.table_chart), + title: const Text("Tables"), + onTap: () { + controller.currentPage = PageType.tables; + }, + selected: controller.currentPage == PageType.tables, + ), ), - ListTile( - leading: const Icon(Icons.person), - title: const Text("Users"), - onTap: () { - setState(() { - currentPage = PageType.users; - }); - }, + Obx( + () => ListTile( + leading: const Icon(Icons.person), + title: const Text("Users"), + onTap: () { + controller.currentPage = PageType.users; + }, + selected: controller.currentPage == PageType.users, + ), ), - ListTile( - leading: const Icon(Icons.settings), - title: const Text("Settings"), - onTap: () { - setState(() { - currentPage = PageType.settings; - }); - }, + Obx( + () => ListTile( + leading: const Icon(Icons.settings), + title: const Text("Settings"), + onTap: () { + controller.currentPage = PageType.settings; + }, + selected: controller.currentPage == PageType.settings, + ), ), const Divider(), ListTile( leading: const Icon(Icons.logout), title: const Text("Logout"), - onTap: () { - GetStorage().erase().then((value) { - GetStorage().save(); - Get.offAllNamed("/"); - }); - }, + onTap: () => controller.logout(), ), ], ); @@ -140,12 +148,12 @@ class _HomePageState extends State with HomePageStateRef { ), LimitedBox( maxWidth: MediaQuery.of(context).size.width - C.materialDrawerWidth, - child: Builder(builder: (context) { - switch (currentPage) { + child: Obx(() { + switch (controller.currentPage) { case PageType.tables: - return TablesListPanel(parent: this, tables: tables); + return const TablesListPanel(); case PageType.users: - return UsersListPanel(usersTable: usersTable); + return const UsersListPanel(); case PageType.settings: return const SettingsPanel(); case PageType.none: @@ -158,25 +166,4 @@ class _HomePageState extends State with HomePageStateRef { ), ); } - - @override - void refreshData() { - apiClient.tablesList().then( - (value) => value.unfold( - (tables) { - setState(() { - this.tables = tables; - }); - }, - (error) { - ScaffoldMessenger.of(context).hideCurrentSnackBar(); - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text(error.toString()), - ), - ); - }, - ), - ); - } } diff --git a/lib/pages/home_panels/tables_list_panel.dart b/lib/pages/home_panels/tables_list_panel.dart index 569269f..66e70e9 100644 --- a/lib/pages/home_panels/tables_list_panel.dart +++ b/lib/pages/home_panels/tables_list_panel.dart @@ -1,110 +1,106 @@ -import 'package:bottom_sheet/bottom_sheet.dart'; +import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; +import 'package:tuuli_api/tuuli_api.dart'; +import 'package:tuuli_app/api_controller.dart'; import 'package:recase/recase.dart'; -import 'package:tuuli_app/api/api_client.dart'; -import 'package:tuuli_app/api/model/tables_list_model.dart'; -import 'package:tuuli_app/c.dart'; -import 'package:tuuli_app/pages/bottomsheets/edit_table_bottomsheet.dart'; -import 'package:tuuli_app/pages/bottomsheets/open_table_bottomsheet.dart'; -import 'package:tuuli_app/pages/home_page.dart'; - -class TablesListPanel extends StatefulWidget { - final TablesListModel tables; - final HomePageStateRef parent; - - const TablesListPanel({ - super.key, - required this.tables, - required this.parent, - }); +import 'package:tuuli_app/models/db_column_definition.dart'; +class TablesListPanelController extends GetxController { @override - State createState() => _TablesListPanelState(); + void onInit() { + super.onInit(); + + refreshData(); + } + + final _isLoading = false.obs; + bool get isLoading => _isLoading.value; + + final _tables = [].obs; + List get tables => _tables; + + Future refreshData() async { + _isLoading.value = true; + try { + final resp = await ApiController.to.apiClient.listTables(); + + final respData = resp.data; + if (respData == null) { + throw Exception("No data in response"); + } + + _tables.clear(); + _tables.addAll(respData); + } on DioError catch (e) { + final respData = e.response?.data; + if (respData != null) { + Get.snackbar( + "Error trying to get tables", + "${respData['error']}", + ); + } else { + Get.snackbar( + "Error trying to get tables", + "$e", + ); + } + } catch (e) { + Get.snackbar( + "Error trying to get tables", + "$e", + ); + } + _isLoading.value = false; + } + + Future createNewTable() async {} + + Future openTable(TableDefinition table) async {} } -class _TablesListPanelState extends State { - final apiClient = Get.find(); - - @override - void initState() { - super.initState(); - } +class TablesListPanel extends GetView { + const TablesListPanel({super.key}); @override Widget build(BuildContext context) { - return _buildTableList(); - } - - Widget _buildTableCard(BuildContext ctx, TableModel table) { - return Card( - clipBehavior: Clip.antiAlias, - child: InkWell( - onTap: () => _openTable(table), - child: Container( - margin: const EdgeInsets.all(5), - padding: const EdgeInsets.all(5), - child: Stack( - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Text( - table.tableName.pascalCase, - style: const TextStyle( - fontSize: 18, - fontWeight: FontWeight.bold, - ), - ), - Row( - children: [ - Text( - table.system ? "System" : "Userland", - style: const TextStyle( - fontSize: 12, - ), - ), - ], - ), - Row( - children: [ - Text( - "${table.columns.length} column(s)", - style: const TextStyle( - fontSize: 11, - fontStyle: FontStyle.italic, - ), - ), - ], - ) - ], - ), - ], + return Stack( + children: [ + Column( + children: [ + AppBar( + elevation: 0, + actions: [ + IconButton( + icon: const Icon(Icons.add), + onPressed: () => controller.createNewTable(), + ), + IconButton( + icon: const Icon(Icons.refresh), + onPressed: () => controller.refreshData(), + ), + ], + ), + Expanded( + child: Obx( + () => controller.tables.isEmpty ? whenNoTables : cardGrid), + ), + ], + ), + Obx( + () => Positioned( + right: 16, + bottom: 16, + child: controller.isLoading + ? const CircularProgressIndicator() + : const SizedBox(), ), ), - ), + ], ); } - Widget get newTableCard => Card( - clipBehavior: Clip.antiAlias, - child: InkWell( - onTap: _createNewTable, - child: Container( - margin: const EdgeInsets.all(5), - padding: const EdgeInsets.all(5), - child: const Icon(Icons.add), - ), - ), - ); - - Widget _buildTableList() { - var tableItems = widget.tables.tables - .where((table) => !table.hidden && !table.system) - .toList(growable: false); - - if (tableItems.isEmpty) { - return Center( + Widget get whenNoTables => Center( child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, @@ -113,7 +109,7 @@ class _TablesListPanelState extends State { Text( "No tables found", style: TextStyle( - color: Theme.of(context).disabledColor, + color: Get.theme.disabledColor, fontSize: 24, ), ), @@ -121,81 +117,66 @@ class _TablesListPanelState extends State { Text( "Maybe create one?", style: TextStyle( - color: Theme.of(context).disabledColor, + color: Get.theme.disabledColor, fontSize: 14, ), ), - const SizedBox(height: 16), - ElevatedButton.icon( - onPressed: _createNewTable, - icon: const Icon(Icons.add), - label: const Text("Create table"), - ) ], ), ); - } - return GridView.builder( - shrinkWrap: true, - itemCount: tableItems.length + 1, - itemBuilder: (ctx, i) => - i == 0 ? newTableCard : _buildTableCard(ctx, tableItems[i - 1]), - gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 5, + Widget get cardGrid => GridView.count( + shrinkWrap: true, + crossAxisCount: 3, childAspectRatio: 5 / 2, + children: [...controller.tables.map((e) => _buildTableCard(e))], + ); + + Widget _buildTableCard(TableDefinition table) { + return Card( + clipBehavior: Clip.antiAlias, + child: InkWell( + onTap: () => controller.openTable(table), + child: Container( + margin: const EdgeInsets.all(5), + padding: const EdgeInsets.all(5), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Text( + table.tableName.pascalCase, + maxLines: 1, + style: const TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold, + overflow: TextOverflow.ellipsis, + ), + ), + Row( + children: [ + Text( + table.system ? "System" : "Userland", + style: const TextStyle( + fontSize: 12, + ), + ), + ], + ), + Row( + children: [ + Text( + "${table.parsedColumns.length} column(s)", + style: const TextStyle( + fontSize: 11, + fontStyle: FontStyle.italic, + ), + ), + ], + ) + ], + ), + ), ), ); } - - void _createNewTable() async { - final result = await showFlexibleBottomSheet( - minHeight: 0, - initHeight: 0.75, - maxHeight: 1, - context: context, - builder: (_, __, ___) => const EditTableBottomSheet(), - anchors: [0, 0.5, 1], - isSafeArea: true, - isDismissible: false, - ); - - if (result == null) return; - - await apiClient - .createTable(result.tableName, result.fields) - .then((e) => WidgetsBinding.instance.addPostFrameCallback((_) { - e.unfold((_) { - Get.snackbar( - "Success", - "Table created", - colorText: Colors.white, - ); - }, (error) { - Get.defaultDialog( - title: "Error", - middleText: error.toString(), - textConfirm: "OK", - onConfirm: () => Get.back(), - ); - }); - })); - - widget.parent.refreshData(); - } - - void _openTable(TableModel table) async { - await showFlexibleBottomSheet( - minHeight: 1, - initHeight: 1, - maxHeight: 1, - context: context, - builder: (_, __, ___) => OpenTableBottomSheet(table: table), - anchors: [0, 0.5, 1], - isSafeArea: true, - isDismissible: false, - ); - - widget.parent.refreshData(); - } } diff --git a/lib/pages/home_panels/users_list_panel.dart b/lib/pages/home_panels/users_list_panel.dart index aa316f5..9e8f73c 100644 --- a/lib/pages/home_panels/users_list_panel.dart +++ b/lib/pages/home_panels/users_list_panel.dart @@ -1,225 +1,899 @@ -import 'package:bottom_sheet/bottom_sheet.dart'; +import 'package:built_collection/built_collection.dart'; +import 'package:built_value/json_object.dart'; +import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; -import 'package:tuuli_app/api/api_client.dart'; -import 'package:tuuli_app/api/model/tables_list_model.dart'; -import 'package:tuuli_app/api/model/user_model.dart'; -import 'package:tuuli_app/pages/bottomsheets/create_user_bottomsheet.dart'; +import 'package:styled_widget/styled_widget.dart'; +import 'package:tuuli_api/tuuli_api.dart'; +import 'package:tuuli_app/api_controller.dart'; +import 'package:tuuli_app/models/group_definition.dart'; +import 'package:tuuli_app/models/user_definition.dart'; +import 'package:tuuli_app/models/user_in_group_definition.dart'; -class UsersListPanel extends StatefulWidget { - final TableModel usersTable; - - const UsersListPanel({super.key, required this.usersTable}); - - @override - State createState() => _UsersListPanelState(); +enum UserListPanelTab { + users, + groups, } -class _UsersListPanelState extends State { - final apiClient = Get.find(); - - final users = []; - +class UserListPanelController extends GetxController { @override - void initState() { - super.initState(); + void onInit() { + super.onInit(); - _refreshUsers(); + refreshData(); } - @override - Widget build(BuildContext context) { - return _buildUserList(); + final _currentTab = UserListPanelTab.users.obs; + UserListPanelTab get currentTab => _currentTab.value; + set currentTab(UserListPanelTab value) => _currentTab.value = value; + + final _isLoading = false.obs; + bool get isLoading => _isLoading.value; + + final _users = [].obs; + List get users => _users; + + final _groups = [].obs; + List get groups => _groups; + + final _usersInGroups = >{}.obs; + Map> get usersInGroups => + _usersInGroups; + + Future refreshData() async { + _isLoading.value = true; + + await Future.wait([ + refreshUsers(), + refreshGroups(), + ]); + + await Future.wait([ + for (final group in groups) getGroupUsers(group), + ]); + + _isLoading.value = false; } - Widget _buildUserCard(BuildContext ctx, UserModel user) { - return Card( - clipBehavior: Clip.antiAlias, - child: InkWell( - onTap: () => _openUser(user), - child: Container( - margin: const EdgeInsets.all(5), - padding: const EdgeInsets.all(5), - child: Stack( - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Text( - user.username, - style: const TextStyle( - fontSize: 18, - fontWeight: FontWeight.bold, - ), - ), - Row( - children: [ - Text( - "User id: ${user.id}", - style: const TextStyle( - fontSize: 12, - ), - ), - ], - ), - ], - ), - ], - ), - ), - ), - ); - } - - Widget get newUserCard => Card( - clipBehavior: Clip.antiAlias, - child: InkWell( - onTap: _createNewUser, - child: Container( - margin: const EdgeInsets.all(5), - padding: const EdgeInsets.all(5), - child: const Icon(Icons.add), - ), + Future refreshUsers() async { + try { + final resp = await ApiController.to.apiClient.getItemsFromTable( + tableName: "users", + itemsSelector: const ItemsSelector( + fields: ["id", "username", "password", "access_token"], + where: [], ), ); - Widget _buildUserList() { - if (users.isEmpty) { - return Center( + final respData = resp.data; + if (respData == null) { + throw Exception("No data in response"); + } + + _users.clear(); + _users.addAll(respData.map((e) => UserDefinition( + id: e["id"], + username: e["username"], + password: e["password"], + accessToken: e["access_token"], + ))); + } on DioError catch (e) { + final respData = e.response?.data; + if (respData != null) { + Get.snackbar( + "Error trying to get users", + "${respData['error']}", + ); + } else { + Get.snackbar( + "Error trying to get users", + "$e", + ); + } + } catch (e) { + Get.snackbar( + "Error trying to get users", + "$e", + ); + } + } + + Future refreshGroups() async { + try { + final resp = await ApiController.to.apiClient.getItemsFromTable( + tableName: "user_group", + itemsSelector: const ItemsSelector( + fields: ["id", "name", "description"], + where: [], + )); + + final respData = resp.data; + if (respData == null) { + throw Exception("No data in response"); + } + + _groups.clear(); + _groups.addAll(respData.map((e) => GroupDefinition( + id: e["id"], + name: e["name"], + description: e["description"], + ))); + } on DioError catch (e) { + final respData = e.response?.data; + if (respData != null) { + Get.snackbar( + "Error trying to get groups", + "${respData['error']}", + ); + } else { + Get.snackbar( + "Error trying to get groups", + "$e", + ); + } + } catch (e) { + Get.snackbar( + "Error trying to get groups", + "$e", + ); + } + } + + Future createNewUser({UserDefinition? user}) async { + final username = "".obs; + final password = "".obs; + if (user != null) { + username.value = user.username; + } + final accept = await Get.dialog( + AlertDialog( + title: user == null + ? const Text("Create new user") + : const Text("Edit user"), + content: Column( + mainAxisSize: MainAxisSize.min, + children: [ + TextField( + controller: user != null + ? TextEditingController(text: user.username) + : null, + decoration: const InputDecoration( + labelText: "Username", + ), + readOnly: user != null, + onChanged: (value) => username.value = value, + ), + TextField( + decoration: const InputDecoration( + labelText: "Password", + ), + obscureText: true, + onChanged: (value) => password.value = value, + ), + ], + ), + actions: [ + TextButton( + onPressed: () => Get.back(result: false), + child: const Text("Cancel"), + ), + TextButton( + onPressed: () => Get.back(result: true), + child: user == null ? const Text("Create") : const Text("Save"), + ), + ], + ), + ); + + if (accept != true || username.isEmpty || password.isEmpty) return; + + try { + OkResponse? respData; + if (user == null) { + final resp = await ApiController.to.apiClient.createUser( + createUserDefinition: CreateUserDefinition( + username: username.value.trim(), + password: password.value.trim(), + ), + ); + respData = resp.data; + } else { + final resp = await ApiController.to.apiClient.updateUser( + userUpdateDefinition: UserUpdateDefinition( + userId: user.id, + password: password.value.trim(), + accessToken: user.accessToken, + ), + ); + respData = resp.data; + } + + if (respData == null) { + throw Exception("No data in response"); + } + + refreshData(); + } on DioError catch (e) { + final respData = e.response?.data; + if (respData != null) { + Get.snackbar( + "Error trying to create user", + "${respData['error']}", + ); + } else { + Get.snackbar( + "Error trying to create user", + "$e", + ); + } + } catch (e) { + Get.snackbar( + "Error trying to create user", + "$e", + ); + } + } + + Future createNewGroup() async { + final groupName = "".obs; + final groupDescription = "".obs; + final accept = await Get.dialog( + AlertDialog( + title: const Text("Create new group"), + content: Column( + mainAxisSize: MainAxisSize.min, + children: [ + TextField( + decoration: const InputDecoration( + labelText: "Group name", + ), + onChanged: (value) => groupName.value = value, + ), + TextField( + decoration: const InputDecoration( + labelText: "Group description (optional)", + ), + onChanged: (value) => groupDescription.value = value, + ), + ], + ), + actions: [ + TextButton( + onPressed: () => Get.back(result: false), + child: const Text("Cancel"), + ), + TextButton( + onPressed: () => Get.back(result: true), + child: const Text("Create"), + ), + ], + ), + ); + + if (accept != true || groupName.isEmpty) return; + + try { + final resp = await ApiController.to.apiClient.createItem( + tableName: "user_group", + itemDefinition: { + "name": groupName.trim(), + "description": groupDescription.trim() + }, + ); + + final respData = resp.data; + if (respData == null) { + throw Exception("No data in response"); + } + + Get.snackbar( + "Group created", + "Group $groupName created", + ); + + refreshData(); + } on DioError catch (e) { + final respData = e.response?.data; + if (respData != null) { + Get.snackbar( + "Error trying to create group", + "${respData['error']}", + ); + } else { + Get.snackbar( + "Error trying to create group", + "$e", + ); + } + } catch (e) { + Get.snackbar( + "Error trying to create group", + "$e", + ); + } + } + + Future getGroupUsers(GroupDefinition group) async { + final resp = await ApiController.to.apiClient.getItemsFromTable( + tableName: "user_in_user_group", + itemsSelector: ItemsSelector( + fields: ["id", "user_id", "user_group_id"], + where: [ + ColumnConditionCompat( + column: "user_group_id", + operator_: ColumnConditionCompatOperator.eq, + value: group.id, + ), + ], + ), + ); + + final respData = resp.data; + if (respData == null) { + throw Exception("No data in response"); + } + + final data = respData + .map( + (e) => UserInGroupDefinition( + id: e["id"], + userId: e["user_id"], + groupId: e["user_group_id"], + ), + ) + .map((e) => users.firstWhereOrNull((e1) => e1.id == e.userId)) + .whereType() + .toList(); + + _usersInGroups[group] = data; + } + + Future addUserToGroup(GroupDefinition group) async { + final groupUsers = _usersInGroups[group] ?? []; + final usersNotInGroup = + users.where((e) => groupUsers.contains(e) != true).toList(); + + final selectedUser = await Get.dialog( + AlertDialog( + title: const Text("Select user to add to group"), + content: SizedBox( + width: 400, + height: 400, + child: ListView.builder( + itemCount: usersNotInGroup.length, + itemBuilder: (context, index) { + final user = usersNotInGroup[index]; + return ListTile( + title: Text(user.username), + onTap: () => Get.back(result: user), + ); + }, + ), + ), + actions: [ + TextButton( + onPressed: () => Get.back(result: null), + child: const Text("Cancel"), + ), + ], + ), + ); + + if (selectedUser == null) return; + + try { + final resp = await ApiController.to.apiClient.createItem( + tableName: "user_in_user_group", + itemDefinition: { + "user_id": selectedUser.id, + "user_group_id": group.id, + }, + ); + + final respData = resp.data; + if (respData == null) { + throw Exception("No data in response"); + } + + Get.snackbar( + "User added to group", + "User ${selectedUser.username} added to group ${group.name}", + ); + + refreshData(); + } on DioError catch (e) { + final respData = e.response?.data; + if (respData != null) { + Get.snackbar( + "Error trying to add user to group", + "${respData['error']}", + ); + } else { + Get.snackbar( + "Error trying to add user to group", + "$e", + ); + } + } catch (e) { + Get.snackbar( + "Error trying to add user to group", + "$e", + ); + } + } + + Future removeUserFromGroup( + GroupDefinition group, + UserDefinition user, + ) async { + final accept = await Get.dialog( + AlertDialog( + title: const Text("Remove user from group"), + content: const Text( + "Are you sure you want to remove this user from the group?"), + actions: [ + TextButton( + onPressed: () => Get.back(result: false), + child: const Text("Cancel"), + ), + TextButton( + onPressed: () => Get.back(result: true), + child: const Text("Remove"), + ), + ], + ), + ); + + if (accept != true) return; + + try { + final resp = await ApiController.to.apiClient.deleteItemFromTable( + tableName: "user_in_user_group", + columnConditionCompat: [ + ColumnConditionCompat( + column: "user_group_id", + operator_: ColumnConditionCompatOperator.eq, + value: group.id, + ), + ColumnConditionCompat( + column: "user_id", + operator_: ColumnConditionCompatOperator.eq, + value: user.id, + ), + ], + ); + + final respData = resp.data; + if (respData == null) { + throw Exception("No data in response"); + } + + Get.snackbar( + "User removed from group", + "User ${user.username} removed from group ${group.name}", + ); + + refreshData(); + } on DioError catch (e) { + final respData = e.response?.data; + if (respData != null) { + Get.snackbar( + "Error trying to remove user from group", + "${respData['error']}", + ); + } else { + Get.snackbar( + "Error trying to remove user from group", + "$e", + ); + } + } catch (e) { + Get.snackbar( + "Error trying to remove user from group", + "$e", + ); + } + } + + Future deleteGroup(GroupDefinition group) async { + final accept = await Get.dialog( + AlertDialog( + title: const Text("Delete group"), + content: const Text( + "Are you sure you want to delete this group? This action cannot be undone."), + actions: [ + TextButton( + onPressed: () => Get.back(result: false), + child: const Text("Cancel"), + ), + TextButton( + onPressed: () => Get.back(result: true), + child: const Text("Delete"), + ), + ], + ), + ); + + if (accept != true) return; + + try { + final resp1 = await ApiController.to.apiClient.deleteItemFromTable( + tableName: "user_in_user_group", + columnConditionCompat: [ + ColumnConditionCompat( + column: "user_group_id", + operator_: ColumnConditionCompatOperator.eq, + value: group.id, + ), + ], + ); + + if (resp1.data == null) { + throw Exception("Could not delete users from group"); + } + + final resp2 = await ApiController.to.apiClient.deleteItemFromTable( + tableName: "user_group", + columnConditionCompat: [ + ColumnConditionCompat( + column: "id", + operator_: ColumnConditionCompatOperator.eq, + value: group.id, + ), + ], + ); + + if (resp2.data == null) { + throw Exception("Could not delete group"); + } + + Get.snackbar( + "Group deleted", + "Group ${group.name} deleted", + ); + + refreshData(); + } on DioError catch (e) { + final respData = e.response?.data; + if (respData != null) { + Get.snackbar( + "Error trying to delete group", + "${respData['error']}", + ); + } else { + Get.snackbar( + "Error trying to delete group", + "$e", + ); + } + } catch (e) { + Get.snackbar( + "Error trying to delete group", + "$e", + ); + } + } + + Future editUser(UserDefinition user) async { + createNewUser(user: user); + } + + Future deleteUser(UserDefinition user) async { + final accept = await Get.dialog( + AlertDialog( + title: const Text("Delete user"), + content: const Text( + "Are you sure you want to delete this user? This action cannot be undone.\n" + "Note: This will not remove references to this user in other tables.", + ), + actions: [ + TextButton( + onPressed: () => Get.back(result: false), + child: const Text("Cancel"), + ), + TextButton( + onPressed: () => Get.back(result: true), + child: const Text("Delete"), + ), + ], + ), + ); + + if (accept != true) return; + + try { + final resp1 = await ApiController.to.apiClient.deleteItemFromTable( + tableName: "user_in_user_group", + columnConditionCompat: [ + ColumnConditionCompat( + column: "user_id", + operator_: ColumnConditionCompatOperator.eq, + value: user.id, + ), + ], + ); + + if (resp1.data == null) { + throw Exception("Could not delete users from group"); + } + + final resp2 = await ApiController.to.apiClient.removeUser( + userId: user.id, + ); + + if (resp2.data == null) { + throw Exception("Could not delete group"); + } + + Get.snackbar( + "User deleted", + "User ${user.username} deleted", + ); + + refreshData(); + } on DioError catch (e) { + final respData = e.response?.data; + if (respData != null) { + Get.snackbar( + "Error trying to delete user", + "${respData['error']}", + ); + } else { + Get.snackbar( + "Error trying to delete user", + "$e", + ); + } + } catch (e) { + Get.snackbar( + "Error trying to delete user", + "$e", + ); + } + } +} + +class UsersListPanel extends GetView { + const UsersListPanel({super.key}); + + @override + Widget build(BuildContext context) { + return Stack( + children: [ + Column( + children: [ + AppBar( + elevation: 0, + title: Obx( + () => DropdownButton( + items: const [ + DropdownMenuItem( + value: UserListPanelTab.users, + child: Text("Users"), + ), + DropdownMenuItem( + value: UserListPanelTab.groups, + child: Text("Groups"), + ), + ], + value: controller.currentTab, + onChanged: (value) { + controller.currentTab = value ?? UserListPanelTab.users; + }, + ), + ).marginAll(8), + actions: [ + IconButton( + icon: const Icon(Icons.add), + onPressed: () => + controller.currentTab == UserListPanelTab.users + ? controller.createNewUser() + : controller.createNewGroup(), + ), + IconButton( + icon: const Icon(Icons.refresh), + onPressed: () => controller.refreshData(), + ), + ], + ), + Expanded( + child: Obx(() => controller.currentTab == UserListPanelTab.users + ? usersPanel + : groupsPanel), + ), + ], + ), + Obx( + () => Positioned( + right: 16, + bottom: 16, + child: controller.isLoading + ? const CircularProgressIndicator() + : const SizedBox(), + ), + ), + ], + ); + } + + Widget get usersPanel => Obx(() => + controller.users.isEmpty ? whenNoSomething("No users found") : cardList); + + Widget get groupsPanel => Obx(() => controller.groups.isEmpty + ? whenNoSomething("No groups found") + : groupsList); + + Widget whenNoSomething(message) => Center( child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ Text( - "No users found", + message, style: TextStyle( - color: Theme.of(context).disabledColor, + color: Get.theme.disabledColor, fontSize: 24, ), ), - const SizedBox(height: 4), - Text( - "Maybe create one? Or maybe you don't have permission to view them?", - style: TextStyle( - color: Theme.of(context).disabledColor, - fontSize: 14, - ), - ), - const SizedBox(height: 16), - ElevatedButton.icon( - onPressed: _createNewUser, - icon: const Icon(Icons.add), - label: const Text("Create user"), - ) ], ), ); - } - return GridView.builder( - shrinkWrap: true, - itemCount: users.length + 1, - itemBuilder: (ctx, i) => - i == 0 ? newUserCard : _buildUserCard(ctx, users[i - 1]), - gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 5, - childAspectRatio: 5 / 2, + Widget get cardList => ListView.builder( + shrinkWrap: true, + itemCount: controller.users.length, + itemBuilder: (context, index) => + _buildUserCard(controller.users[index]), + ); + + Widget get groupsList => ListView.builder( + shrinkWrap: true, + itemCount: controller.groups.length, + itemBuilder: (context, index) => + _buildGroupCard(controller.groups[index]), + ); + + Widget _buildUserCard(UserDefinition user) { + return Card( + clipBehavior: Clip.antiAlias, + child: ExpansionTile( + title: Text( + user.username, + maxLines: 1, + style: const TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold, + overflow: TextOverflow.ellipsis, + ), + ), + subtitle: Text( + "ID: ${user.id}", + style: const TextStyle( + fontSize: 12, + ), + ), + childrenPadding: const EdgeInsets.all(8), + children: [ + Row( + children: [ + ElevatedButton.icon( + onPressed: () => controller.editUser(user), + icon: const Icon(Icons.edit_attributes), + label: const Text("Edit user"), + ).paddingAll(8).expanded(), + Obx( + () { + final adminGroup = controller.usersInGroups.keys + .toList() + .firstWhereOrNull((element) => element.id == 2); + if (adminGroup == null) return const SizedBox(); + + final adminList = controller.usersInGroups[adminGroup]; + if (adminList == null) return const SizedBox(); + + final isAdmin = + adminList.any((element) => element.id == user.id); + if (isAdmin) return const SizedBox(); + + return ElevatedButton.icon( + onPressed: () => controller.deleteUser(user), + icon: const Icon(Icons.delete_forever), + label: const Text("Delete user"), + style: ElevatedButton.styleFrom( + backgroundColor: Colors.redAccent, + ), + ).paddingAll(8).expanded(); + }, + ), + ], + ), + ], ), ); } - Future _createNewUser() async { - var result = await showFlexibleBottomSheet( - minHeight: 1, - initHeight: 1, - maxHeight: 1, - context: context, - builder: (_, __, ___) => const CreateUserBottomSheet(), - anchors: [0, 0.5, 1], - isSafeArea: true, - isDismissible: false, + Widget _buildGroupCard(GroupDefinition group) { + return Card( + clipBehavior: Clip.antiAlias, + child: ExpansionTile( + title: Text( + group.name, + maxLines: 1, + style: const TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold, + overflow: TextOverflow.ellipsis, + ), + ), + leading: Row( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisSize: MainAxisSize.min, + children: [ + if (group.id != 1) + IconButton( + icon: const Icon(Icons.person_add), + onPressed: () => controller.addUserToGroup(group), + ), + if (group.id > 2) + IconButton( + icon: const Icon(Icons.delete_forever), + onPressed: () => controller.deleteGroup(group), + ), + ], + ), + subtitle: Text( + group.description, + style: const TextStyle( + fontSize: 12, + ), + ), + children: [ + Obx( + () { + final groupData = controller.usersInGroups[group]; + if (group.id == 1) { + return const ListTile( + title: Text("No users can be added to this group"), + ); + } + if (groupData == null) { + return const Center( + child: CircularProgressIndicator(), + ); + } + if (groupData.isEmpty) { + return const ListTile( + title: Text("No users in group"), + ); + } + return ListView.builder( + shrinkWrap: true, + itemCount: groupData.length, + itemBuilder: (context, index) { + final user = controller.usersInGroups[group]![index]; + final isYou = user.accessToken == ApiController.to.token; + return ListTile( + title: Text(user.username), + subtitle: isYou ? const Text("You") : null, + trailing: isYou && + (group.id == 2 || + group.name.toLowerCase() == "admin") + ? null + : IconButton( + icon: const Icon(Icons.delete), + onPressed: () => controller.removeUserFromGroup( + group, + user, + ), + ), + ); + }, + ); + }, + ), + ], + ), ); - - if (result == null) { - return; - } - - final response = await apiClient.createUser( - widget.usersTable, result.username, result.password); - response.unfold((data) { - ScaffoldMessenger.of(context).hideCurrentSnackBar(); - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: Text("User created"), - ), - ); - _refreshUsers(); - }, (error) { - ScaffoldMessenger.of(context).hideCurrentSnackBar(); - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text("Error: $error"), - ), - ); - }); - } - - Future _openUser(UserModel user) async { - final result = await showFlexibleBottomSheet( - minHeight: 1, - initHeight: 1, - maxHeight: 1, - context: context, - builder: (_, __, ___) => CreateUserBottomSheet(existingUser: user), - anchors: [0, 0.5, 1], - isSafeArea: true, - isDismissible: false, - ); - - if (result == null) { - return; - } - - final response = await apiClient.updateItem(widget.usersTable, { - "username": result.username, - "password": result.password, - "access_token": result.accessToken, - }, { - "id": user.id, - }); - response.unfold((data) { - ScaffoldMessenger.of(context).hideCurrentSnackBar(); - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: Text("User updated"), - ), - ); - _refreshUsers(); - }, (error) { - ScaffoldMessenger.of(context).hideCurrentSnackBar(); - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text("Error: $error"), - ), - ); - }); - } - - Future _refreshUsers() async { - final result = await apiClient.getTableItems(widget.usersTable); - result.unfold((data) { - setState(() { - users.clear(); - users.addAll(data.map((e) => UserModel.fromJson(e))); - }); - }, (error) { - ScaffoldMessenger.of(context).hideCurrentSnackBar(); - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text("Error: $error"), - ), - ); - }); } } diff --git a/lib/pages/login_page.dart b/lib/pages/login_page.dart index d412533..d774e1d 100644 --- a/lib/pages/login_page.dart +++ b/lib/pages/login_page.dart @@ -1,6 +1,5 @@ import 'dart:async'; -import 'package:animated_background/animated_background.dart'; import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; @@ -8,9 +7,9 @@ import 'package:tuuli_api/tuuli_api.dart'; import 'package:tuuli_app/api_controller.dart'; class LoginPageController extends GetxController { - final _login = "".obs; - String get login => _login.value; - set login(String value) => _login.value = value; + final _username = "".obs; + String get username => _username.value; + set username(String value) => _username.value = value; final _password = "".obs; String get password => _password.value; @@ -20,18 +19,18 @@ class LoginPageController extends GetxController { bool get submitted => _submitted.value; set submitted(bool value) => _submitted.value = value; - bool get isFormValid => login.isNotEmpty && password.isNotEmpty; + bool get isFormValid => username.isNotEmpty && password.isNotEmpty; Future submitForm() async { submitted = true; if (isFormValid) { - final amb = AuthModelBuilder() - ..username = login - ..password = password; - try { - final resp = await ApiController.to.apiClient - .getAccessTokenApiGetAccessTokenPost(authModel: amb.build()); + final resp = await ApiController.to.apiClient.getAccessToken( + authModel: AuthModel( + username: username, + password: password, + ), + ); final respData = resp.data; if (resp.statusCode == 200 && respData != null) { @@ -105,9 +104,9 @@ class LoginPage extends GetView { enabled: !controller.submitted, decoration: const InputDecoration( labelText: 'Login', - hintText: 'Enter your login', + hintText: 'Enter your username', ), - onChanged: (value) => controller.login = value, + onChanged: (value) => controller.username = value, validator: (value) { if (value == null || value.isEmpty) { return 'Please enter your Login'; @@ -149,147 +148,3 @@ class LoginPage extends GetView { ); } } -/* -class LoginPage extends StatefulWidget { - const LoginPage({super.key}); - - @override - State createState() => _LoginPageState(); -} - -class _LoginPageState extends State with TickerProviderStateMixin { - final _formKey = GlobalKey(); - - final apiClient = Get.find(); - var submitted = false; - - final loginPageController = TextEditingController(); - final passwordController = TextEditingController(); - - @override - Widget build(BuildContext context) { - final screenSize = MediaQuery.of(context).size; - final formWidth = screenSize.width <= 600 ? screenSize.width : 300.0; - return Scaffold( - body: Stack( - children: [ - AnimatedBackground( - behaviour: RandomParticleBehaviour(), - vsync: this, - child: const SizedBox.square( - dimension: 0, - ), - ), - Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - LimitedBox( - maxWidth: formWidth, - child: Container( - color: Colors.black.withAlpha(100), - padding: const EdgeInsets.all(16), - child: Form( - key: _formKey, - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - TextFormField( - controller: loginPageController, - enabled: !submitted, - decoration: const InputDecoration( - labelText: 'Login', - hintText: 'Enter your login', - ), - validator: (value) { - if (value == null || value.isEmpty) { - return 'Please enter your Login'; - } - return null; - }, - ), - TextFormField( - controller: passwordController, - obscureText: true, - enabled: !submitted, - decoration: const InputDecoration( - labelText: 'Password', - hintText: 'Enter your password', - ), - validator: (value) { - if (value == null || value.isEmpty) { - return 'Please enter your password'; - } - return null; - }, - ), - const SizedBox(height: 16), - ElevatedButton( - onPressed: submitted ? null : _submit, - child: const Text('Login'), - ), - ], - ), - ), - ), - ), - ], - ), - ], - ), - ); - } - - Future _submit() async { - if (!_formKey.currentState!.validate()) { - return; - } - - setState(() { - submitted = true; - }); - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: Text('Trying to login...'), - ), - ); - - final response = await apiClient.login( - loginPageController.text.trim(), - passwordController.text.trim(), - ); - response.unfold((data) { - ScaffoldMessenger.of(context).hideCurrentSnackBar(); - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: Text('Login successful'), - ), - ); - apiClient.setAccessToken(data.accessToken); - GetStorage() - .write("accessToken", data.accessToken) - .then((value) => GetStorage().save()) - .then((value) { - Timer(1.seconds, () { - ScaffoldMessenger.of(context).hideCurrentSnackBar(); - WidgetsBinding.instance.addPostFrameCallback((_) { - Get.offAllNamed("/home"); - }); - }); - }); - }, (error) { - ScaffoldMessenger.of(context).hideCurrentSnackBar(); - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text(error.toString()), - ), - ); - setState(() { - submitted = false; - }); - }); - } -} -*/ \ No newline at end of file diff --git a/pubspec.lock b/pubspec.lock index bdceca6..e24b1d4 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -5,18 +5,18 @@ packages: dependency: transitive description: name: _fe_analyzer_shared - sha256: a36ec4843dc30ea6bf652bf25e3448db6c5e8bcf4aa55f063a5d1dad216d8214 + sha256: "8880b4cfe7b5b17d57c052a5a3a8cc1d4f546261c7cc8fbd717bd53f48db0568" url: "https://pub.dev" source: hosted - version: "58.0.0" + version: "59.0.0" analyzer: dependency: transitive description: name: analyzer - sha256: cc4242565347e98424ce9945c819c192ec0838cb9d1f6aa4a97cc96becbc5b27 + sha256: a89627f49b0e70e068130a36571409726b04dab12da7e5625941d2c8ec278b96 url: "https://pub.dev" source: hosted - version: "5.10.0" + version: "5.11.1" animated_background: dependency: "direct main" description: @@ -275,6 +275,11 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" frontend_server_client: dependency: transitive description: @@ -343,10 +348,10 @@ packages: dependency: transitive description: name: intl - sha256: a3715e3bc90294e971cb7dc063fbf3cd9ee0ebf8604ffeafabd9e6f16abbdbe6 + sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d" url: "https://pub.dev" source: hosted - version: "0.18.0" + version: "0.18.1" io: dependency: transitive description: @@ -371,6 +376,14 @@ packages: url: "https://pub.dev" source: hosted version: "4.8.0" + lint: + dependency: transitive + description: + name: lint + sha256: "4a539aa34ec5721a2c7574ae2ca0336738ea4adc2a34887d54b7596310b33c85" + url: "https://pub.dev" + source: hosted + version: "1.10.0" lints: dependency: transitive description: @@ -463,18 +476,18 @@ packages: dependency: transitive description: name: path_provider_android - sha256: "019f18c9c10ae370b08dce1f3e3b73bc9f58e7f087bb5e921f06529438ac0ae7" + sha256: da97262be945a72270513700a92b39dd2f4a54dad55d061687e2e37a6390366a url: "https://pub.dev" source: hosted - version: "2.0.24" + version: "2.0.25" path_provider_foundation: dependency: transitive description: name: path_provider_foundation - sha256: "818b2dc38b0f178e0ea3f7cf3b28146faab11375985d815942a68eee11c2d0f7" + sha256: ad4c4d011830462633f03eb34445a45345673dfd4faf1ab0b4735fbd93b19183 url: "https://pub.dev" source: hosted - version: "2.2.1" + version: "2.2.2" path_provider_linux: dependency: transitive description: @@ -563,6 +576,62 @@ packages: url: "https://pub.dev" source: hosted version: "4.1.0" + shared_preferences: + dependency: "direct main" + description: + name: shared_preferences + sha256: "858aaa72d8f61637d64e776aca82e1c67e6d9ee07979123c5d17115031c1b13b" + url: "https://pub.dev" + source: hosted + version: "2.1.0" + shared_preferences_android: + dependency: transitive + description: + name: shared_preferences_android + sha256: "7fa90471a6875d26ad78c7e4a675874b2043874586891128dc5899662c97db46" + url: "https://pub.dev" + source: hosted + version: "2.1.2" + shared_preferences_foundation: + dependency: transitive + description: + name: shared_preferences_foundation + sha256: "0c1c16c56c9708aa9c361541a6f0e5cc6fc12a3232d866a687a7b7db30032b07" + url: "https://pub.dev" + source: hosted + version: "2.2.1" + shared_preferences_linux: + dependency: transitive + description: + name: shared_preferences_linux + sha256: "9d387433ca65717bbf1be88f4d5bb18f10508917a8fa2fb02e0fd0d7479a9afa" + url: "https://pub.dev" + source: hosted + version: "2.2.0" + shared_preferences_platform_interface: + dependency: transitive + description: + name: shared_preferences_platform_interface + sha256: fb5cf25c0235df2d0640ac1b1174f6466bd311f621574997ac59018a6664548d + url: "https://pub.dev" + source: hosted + version: "2.2.0" + shared_preferences_web: + dependency: transitive + description: + name: shared_preferences_web + sha256: "74083203a8eae241e0de4a0d597dbedab3b8fef5563f33cf3c12d7e93c655ca5" + url: "https://pub.dev" + source: hosted + version: "2.1.0" + shared_preferences_windows: + dependency: transitive + description: + name: shared_preferences_windows + sha256: "5e588e2efef56916a3b229c3bfe81e6a525665a454519ca51dbcc4236a274173" + url: "https://pub.dev" + source: hosted + version: "2.2.0" shelf: dependency: transitive description: @@ -632,6 +701,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.0" + styled_widget: + dependency: "direct main" + description: + name: styled_widget + sha256: "4d439802919b6ccf10d1488798656da8804633b03012682dd1c8ca70a084aa84" + url: "https://pub.dev" + source: hosted + version: "0.4.1" term_glyph: dependency: transitive description: @@ -656,6 +733,15 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.1" + tuuli_api: + dependency: "direct main" + description: + path: "." + ref: master + resolved-ref: "46d8acd4a54fd716a16f119e4296ee5583b8bc98" + url: "https://glab.nuark.xyz/nuark/tuuli_api.git" + source: git + version: "1.0.0" typed_data: dependency: transitive description: @@ -664,14 +750,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.1" - uuid: - dependency: "direct main" - description: - name: uuid - sha256: "648e103079f7c64a36dc7d39369cabb358d377078a051d6ae2ad3aa539519313" - url: "https://pub.dev" - source: hosted - version: "3.0.7" vector_math: dependency: transitive description: @@ -700,10 +778,10 @@ packages: dependency: transitive description: name: win32 - sha256: c9ebe7ee4ab0c2194e65d3a07d8c54c5d00bb001b76081c4a04cdb8448b59e46 + sha256: a6f0236dbda0f63aa9a25ad1ff9a9d8a4eaaa5012da0dc59d21afdb1dc361ca4 url: "https://pub.dev" source: hosted - version: "3.1.3" + version: "3.1.4" xdg_directories: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index d1c368d..754700c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -22,7 +22,13 @@ dependencies: http: ^0.13.5 one_of_serializer: ^1.5.0 recase: ^4.1.0 - uuid: ^3.0.7 + shared_preferences: ^2.1.0 + styled_widget: ^0.4.1 + + tuuli_api: + git: + url: https://glab.nuark.xyz/nuark/tuuli_api.git + ref: master dev_dependencies: flutter_test: -- 2.47.3 From 61f3184f8596b9a50fa97339678daa8a1e178d18 Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Fri, 28 Apr 2023 02:12:03 +0700 Subject: [PATCH 11/28] Windows internal update --- windows/flutter/generated_plugin_registrant.cc | 6 ++++++ windows/flutter/generated_plugins.cmake | 2 ++ 2 files changed, 8 insertions(+) diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index 8b6d468..94564b6 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -6,6 +6,12 @@ #include "generated_plugin_registrant.h" +#include +#include void RegisterPlugins(flutter::PluginRegistry* registry) { + IrondashEngineContextPluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("IrondashEngineContextPluginCApi")); + SuperNativeExtensionsPluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("SuperNativeExtensionsPluginCApi")); } diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index b93c4c3..607cf1f 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -3,6 +3,8 @@ # list(APPEND FLUTTER_PLUGIN_LIST + irondash_engine_context + super_native_extensions ) list(APPEND FLUTTER_FFI_PLUGIN_LIST -- 2.47.3 From 64a435ccb22d84b14b16992f0285628d16e05b03 Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Fri, 28 Apr 2023 02:12:15 +0700 Subject: [PATCH 12/28] Assets page main functionality --- .../create_table_item_bottomsheet.dart | 199 ------- .../bottomsheets/create_user_bottomsheet.dart | 218 -------- .../bottomsheets/edit_table_bottomsheet.dart | 243 -------- .../bottomsheets/open_table_bottomsheet.dart | 258 --------- lib/pages/home_page.dart | 20 + lib/pages/home_panels/assets_panel.dart | 518 ++++++++++++++++++ pubspec.lock | 76 ++- pubspec.yaml | 3 +- 8 files changed, 606 insertions(+), 929 deletions(-) delete mode 100644 lib/pages/bottomsheets/create_table_item_bottomsheet.dart delete mode 100644 lib/pages/bottomsheets/create_user_bottomsheet.dart delete mode 100644 lib/pages/bottomsheets/edit_table_bottomsheet.dart delete mode 100644 lib/pages/bottomsheets/open_table_bottomsheet.dart create mode 100644 lib/pages/home_panels/assets_panel.dart diff --git a/lib/pages/bottomsheets/create_table_item_bottomsheet.dart b/lib/pages/bottomsheets/create_table_item_bottomsheet.dart deleted file mode 100644 index 5fac541..0000000 --- a/lib/pages/bottomsheets/create_table_item_bottomsheet.dart +++ /dev/null @@ -1,199 +0,0 @@ -/*import 'package:flutter/material.dart'; -import 'package:flutter_fast_forms/flutter_fast_forms.dart'; -import 'package:get/get.dart'; -import 'package:tuuli_app/api/api_client.dart'; -import 'package:tuuli_app/api/model/table_field_model.dart'; -import 'package:tuuli_app/api/model/tables_list_model.dart'; -import 'package:uuid/uuid.dart'; -import 'package:uuid/uuid_util.dart'; - -class CreateTableItemBottomSheet extends StatefulWidget { - final TableModel table; - final TableItemsData? existingItem; - - const CreateTableItemBottomSheet({ - super.key, - required this.table, - this.existingItem, - }); - - @override - State createState() => _CreateTableItemBottomSheetState(); -} - -class _CreateTableItemBottomSheetState - extends State { - final _formKey = GlobalKey(); - - final _values = {}; - - @override - void initState() { - super.initState(); - for (final field in widget.table.columns.where((e) => !e.isPrimary)) { - _values[field.fieldName] = null; - } - widget.existingItem?.forEach((key, value) { - _values[key] = value; - }); - } - - @override - Widget build(BuildContext context) { - return SingleChildScrollView( - child: Padding( - padding: const EdgeInsets.all(16), - child: FastForm( - formKey: _formKey, - children: [ - Text( - widget.existingItem == null ? "Create new item" : "Update item", - style: Theme.of(context).textTheme.headlineSmall, - ), - const SizedBox(height: 16), - for (final field in widget.table.columns.where((e) => !e.isPrimary)) - Card( - margin: const EdgeInsets.all(8), - child: Container( - padding: const EdgeInsets.all(8), - child: _createFormField(field), - ), - ), - const SizedBox(height: 16), - Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - TextButton( - onPressed: () => Navigator.of(context).pop(), - child: const Text("Cancel"), - ), - ElevatedButton( - onPressed: () { - if (_formKey.currentState!.validate()) { - Navigator.of(context).pop(_values); - return; - } - - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: Text("Please fill in all fields"), - ), - ); - }, - child: - Text(widget.existingItem == null ? "Create" : "Update"), - ), - ], - ), - ], - ), - ), - ); - } - - Widget _createFormField(TableField field) { - switch (field.fieldType) { - case "serial": - case "bigint": - // ignore: no_duplicate_case_values - case "int": - return FastTextField( - name: field.fieldName, - labelText: field.fieldName, - validator: (value) { - if (value == null || - value.isEmpty || - double.tryParse(value) is! double) { - return "Please enter a value"; - } - return null; - }, - initialValue: (_values[field.fieldName] ?? "").toString(), - onChanged: (value) { - _values[field.fieldName] = int.tryParse(value ?? ""); - }, - ); - case "uuid": - return FastTextField( - name: field.fieldName, - labelText: field.fieldName, - validator: (value) { - if (value == null || - value.isEmpty || - !Uuid.isValidUUID(fromString: value)) { - return "Please enter a value"; - } - return null; - }, - initialValue: (_values[field.fieldName] ?? "").toString(), - onChanged: (value) { - _values[field.fieldName] = - Uuid.isValidUUID(fromString: value ?? "") ? value : null; - }, - ); - case "str": - return FastTextField( - name: field.fieldName, - labelText: field.fieldName, - validator: (value) { - if (value == null || value.isEmpty) { - return "Please enter a value"; - } - return null; - }, - initialValue: _values[field.fieldName], - onChanged: (value) { - _values[field.fieldName] = value; - }, - ); - case "bool": - return FastCheckbox( - name: field.fieldName, - labelText: field.fieldName, - titleText: field.fieldName, - initialValue: _values[field.fieldName], - onChanged: (value) { - _values[field.fieldName] = value; - }, - ); - case "date": - // ignore: no_duplicate_case_values - case "datetime": - return FastCalendar( - name: field.fieldName, - firstDate: DateTime.now().subtract(const Duration(days: 365 * 200)), - lastDate: DateTime.now().add(const Duration(days: 365 * 200)), - initialValue: DateTime.tryParse(_values[field.fieldName] ?? ""), - validator: (value) { - if (value == null) { - return "Please enter a value"; - } - return null; - }, - onChanged: (value) { - _values[field.fieldName] = value; - }, - ); - case "float": - return FastTextField( - name: field.fieldName, - labelText: field.fieldName, - validator: (value) { - if (value == null || - value.isEmpty || - double.tryParse(value) is! double) { - return "Please enter a value"; - } - return null; - }, - initialValue: (_values[field.fieldName] ?? "").toString(), - onChanged: (value) { - _values[field.fieldName] = double.tryParse(value ?? ""); - }, - ); - default: - return const Text("Unknown field type"); - } - } -} -*/ \ No newline at end of file diff --git a/lib/pages/bottomsheets/create_user_bottomsheet.dart b/lib/pages/bottomsheets/create_user_bottomsheet.dart deleted file mode 100644 index 72c8223..0000000 --- a/lib/pages/bottomsheets/create_user_bottomsheet.dart +++ /dev/null @@ -1,218 +0,0 @@ -/*import 'package:flutter/material.dart'; -import 'package:flutter_fast_forms/flutter_fast_forms.dart'; -import 'package:get/get.dart'; -import 'package:tuuli_app/api/api_client.dart'; -import 'package:tuuli_app/api/model/table_field_model.dart'; -import 'package:tuuli_app/api/model/tables_list_model.dart'; -import 'package:tuuli_app/api/model/user_model.dart'; -import 'package:tuuli_app/utils.dart'; -import 'package:uuid/uuid.dart'; -import 'package:uuid/uuid_util.dart'; - -class CreateUserResult { - final String username; - final String password; - - CreateUserResult(this.username, this.password); -} - -class UpdateUserResult { - final String username; - final String password; - final String accessToken; - - UpdateUserResult(this.username, this.password, this.accessToken); -} - -// TODO: Add a way to change user's group -class CreateUserBottomSheet extends StatefulWidget { - final UserModel? existingUser; - - const CreateUserBottomSheet({ - super.key, - this.existingUser, - }); - - @override - State createState() => _CreateUserBottomSheetState(); -} - -class _CreateUserBottomSheetState extends State { - final _formKey = GlobalKey(); - - String? newUsername; - String? newPassword; - String? newAccessToken; - - bool obscurePassword = true; - bool obscureToken = true; - - @override - void initState() { - super.initState(); - } - - @override - Widget build(BuildContext context) { - return SingleChildScrollView( - child: Padding( - padding: const EdgeInsets.all(16), - child: FastForm( - formKey: _formKey, - children: [ - Text( - widget.existingUser == null ? "Create new user" : "Update user", - style: Theme.of(context).textTheme.headlineSmall, - ), - const SizedBox(height: 16), - Card( - margin: const EdgeInsets.all(8), - child: Container( - padding: const EdgeInsets.all(8), - child: FastTextField( - name: "Username", - labelText: "Username", - validator: (value) { - if (value == null || value.isEmpty) { - return "Please enter a value"; - } - return null; - }, - readOnly: widget.existingUser != null, - initialValue: widget.existingUser?.username, - onChanged: (value) { - newUsername = value; - }, - ), - ), - ), - Card( - margin: const EdgeInsets.all(8), - child: Container( - padding: const EdgeInsets.all(8), - child: Row( - children: [ - Flexible( - child: FastTextField( - name: "Password", - labelText: "Password", - validator: (value) { - if (value == null || value.isEmpty) { - return "Please enter a value"; - } - return null; - }, - obscureText: obscurePassword, - onChanged: (value) { - newPassword = value; - }, - ), - ), - IconButton( - icon: Icon( - obscurePassword - ? Icons.visibility_off - : Icons.visibility, - ), - onPressed: () { - setState(() { - obscurePassword = !obscurePassword; - }); - }, - ), - ], - ), - ), - ), - if (widget.existingUser != null) - Card( - margin: const EdgeInsets.all(8), - child: Container( - padding: const EdgeInsets.all(8), - child: Row( - children: [ - Flexible( - child: FastTextField( - name: "Access token", - labelText: "Access token", - validator: (value) { - if (value == null || value.isEmpty) { - return "Please enter a value"; - } - return null; - }, - obscureText: obscureToken, - initialValue: newAccessToken ?? - widget.existingUser?.accessToken, - readOnly: true, - onChanged: (value) { - newAccessToken = value; - }, - ), - ), - IconButton( - icon: const Icon(Icons.shuffle), - onPressed: () { - setState(() { - newAccessToken = randomHexString(64); - }); - }, - ), - IconButton( - icon: Icon( - obscurePassword - ? Icons.visibility_off - : Icons.visibility, - ), - onPressed: () { - setState(() { - obscureToken = !obscureToken; - }); - }, - ), - ], - ), - ), - ), - const SizedBox(height: 16), - Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - TextButton( - onPressed: () => Navigator.of(context).pop(), - child: const Text("Cancel"), - ), - ElevatedButton( - onPressed: () { - if (_formKey.currentState!.validate()) { - Navigator.of(context).pop(widget.existingUser == null - ? CreateUserResult( - newUsername!, - newPassword!, - ) - : UpdateUserResult( - newUsername!, - newPassword!, - newAccessToken!, - )); - return; - } - - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: Text("Please fill in all fields"), - ), - ); - }, - child: - Text(widget.existingUser == null ? "Create" : "Update"), - ), - ], - ), - ], - ), - ), - ); - } -} -*/ \ No newline at end of file diff --git a/lib/pages/bottomsheets/edit_table_bottomsheet.dart b/lib/pages/bottomsheets/edit_table_bottomsheet.dart deleted file mode 100644 index 064e38f..0000000 --- a/lib/pages/bottomsheets/edit_table_bottomsheet.dart +++ /dev/null @@ -1,243 +0,0 @@ -/*import 'package:flutter/material.dart'; -import 'package:get/get.dart'; -import 'package:recase/recase.dart'; -import 'package:tuuli_app/api/model/table_field_model.dart'; -import 'package:tuuli_app/api/model/tables_list_model.dart'; -import 'package:tuuli_app/widgets/table_field_widget.dart'; - -class EditTableBottomSheetResult { - final String tableName; - final List fields; - - EditTableBottomSheetResult(this.tableName, this.fields); -} - -class EditTableBottomSheet extends StatefulWidget { - final TableModel? table; - - const EditTableBottomSheet({super.key, this.table}); - - @override - State createState() => _EditTableBottomSheetState(); -} - -class _EditTableBottomSheetState extends State { - var tableName = "".obs; - - late final List fields; - - final newFieldName = TextEditingController(); - String? newFieldType; - var newFieldPrimary = false; - var newFieldUnique = false; - - @override - void initState() { - super.initState(); - fields = widget.table?.columns ?? []; - if (widget.table != null) { - tableName.value = widget.table!.tableName; - } - } - - @override - Widget build(BuildContext context) { - return SingleChildScrollView( - child: Padding( - padding: const EdgeInsets.all(16), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Obx( - () => Text( - tableName.isEmpty - ? "Edit table" - : "Edit table \"${tableName.value.pascalCase}\"", - style: Theme.of(context).textTheme.headlineSmall, - ), - ), - const Spacer(), - IconButton( - onPressed: Get.back, - icon: const Icon(Icons.cancel), - ) - ], - ), - if (widget.table == null) const Divider(), - if (widget.table == null) - TextFormField( - decoration: const InputDecoration( - labelText: 'Table name', - hintText: 'Enter table name', - ), - readOnly: widget.table != null, - maxLength: 15, - onChanged: (value) => tableName.value = value, - validator: (value) { - if (value == null || value.isEmpty) { - return 'Please enter table name'; - } - return null; - }, - ), - const Divider(), - Text( - "Fields", - style: Theme.of(context).textTheme.titleLarge, - ), - if (fields.isEmpty) const Text("No fields"), - ...fields - .map((e) => TableFieldWidget( - field: e, - onRemove: () => _removeColumn(e.fieldName), - )) - .toList(growable: false), - if (widget.table == null) const SizedBox(width: 16), - if (widget.table == null) - Card( - child: Container( - padding: const EdgeInsets.all(8), - margin: const EdgeInsets.all(8), - child: Column( - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const Text("Add new field"), - const SizedBox(height: 8), - Row( - children: [ - Flexible( - child: TextFormField( - controller: newFieldName, - decoration: const InputDecoration( - labelText: 'Column name', - hintText: 'Enter column name', - border: OutlineInputBorder(), - ), - ), - ), - const SizedBox(width: 8), - Flexible( - child: DropdownButtonFormField( - decoration: const InputDecoration( - labelText: 'Column type', - hintText: 'Choose column type', - border: OutlineInputBorder(), - ), - items: possibleFieldTypes.keys - .map((e) => DropdownMenuItem( - value: e, - child: Text(e.pascalCase), - )) - .toList(growable: false), - value: newFieldType, - onChanged: (value) => newFieldType = value, - ), - ), - const SizedBox(width: 16), - ToggleButtons( - isSelected: [ - newFieldPrimary, - newFieldUnique, - !newFieldPrimary && !newFieldUnique - ], - onPressed: (index) { - setState(() { - newFieldPrimary = index == 0; - newFieldUnique = index == 1; - }); - }, - children: const [ - Text("Primary"), - Text("Unique"), - Text("Normal"), - ], - ), - const SizedBox(width: 16), - ElevatedButton( - onPressed: _addNewField, - child: const Text("Add field"), - ), - ], - ), - ], - ), - ), - ), - const SizedBox(height: 32), - ElevatedButton( - onPressed: _saveTable, - child: const Text("Save table"), - ), - ], - ), - ), - ); - } - - void _addNewField() { - if (newFieldType == null) { - return; - } - - final fieldName = newFieldName.text; - if (fieldName.isEmpty || - fields.any((element) => element.fieldName == fieldName)) { - Get.defaultDialog( - title: "Error", - middleText: "Field name is empty or already exists", - ); - return; - } - - final field = TableField.parseTableField( - "$fieldName:$newFieldType${newFieldUnique ? ":unique" : ""}${newFieldPrimary ? ":primary" : ""}", - ); - - if (field.isPrimary && !field.canBePrimary()) { - Get.defaultDialog( - title: "Error", - middleText: "Field type \"${field.fieldType}\" can't be primary", - ); - return; - } - - setState(() { - newFieldName.clear(); - newFieldType = null; - newFieldPrimary = false; - newFieldUnique = false; - fields.add(field); - }); - } - - void _saveTable() { - if (tableName.isEmpty) { - Get.defaultDialog( - title: "Error", - middleText: "Table name is empty", - ); - return; - } - - if (fields.isEmpty) { - Get.defaultDialog( - title: "Error", - middleText: "Table must have at least one field", - ); - return; - } - - Get.back(result: EditTableBottomSheetResult(tableName.value, fields)); - } - - void _removeColumn(String name) { - setState(() { - fields.removeWhere((element) => element.fieldName == name); - }); - } -} -*/ \ No newline at end of file diff --git a/lib/pages/bottomsheets/open_table_bottomsheet.dart b/lib/pages/bottomsheets/open_table_bottomsheet.dart deleted file mode 100644 index 045c043..0000000 --- a/lib/pages/bottomsheets/open_table_bottomsheet.dart +++ /dev/null @@ -1,258 +0,0 @@ -/*import 'package:bottom_sheet/bottom_sheet.dart'; -import 'package:data_table_2/data_table_2.dart'; -import 'package:flutter/material.dart'; -import 'package:get/get.dart'; -import 'package:recase/recase.dart'; -import 'package:tuuli_app/api/api_client.dart'; -import 'package:tuuli_app/api/model/tables_list_model.dart'; -import 'package:tuuli_app/pages/bottomsheets/create_table_item_bottomsheet.dart'; - -class OpenTableBottomSheet extends StatefulWidget { - final TableModel table; - - const OpenTableBottomSheet({super.key, required this.table}); - - @override - State createState() => _OpenTableBottomSheetState(); -} - -class _OpenTableBottomSheetState extends State { - final apiClient = Get.find(); - final tableItems = TableItemsDataList.empty(growable: true); - - @override - void initState() { - super.initState(); - - _refreshTableData(); - } - - @override - Widget build(BuildContext context) { - return Padding( - padding: const EdgeInsets.all(16), - child: Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Row( - children: [ - Text( - widget.table.tableName.pascalCase, - style: Theme.of(context).textTheme.headlineSmall, - ), - const Spacer(), - IconButton( - onPressed: _addNewItem, - icon: const Icon(Icons.add), - ), - IconButton( - onPressed: _refreshTableData, - icon: const Icon(Icons.refresh), - ), - IconButton( - onPressed: _dropTable, - icon: const Icon(Icons.delete), - ), - IconButton( - onPressed: Get.back, - icon: const Icon(Icons.cancel), - ), - ], - ), - const Divider(), - Expanded( - child: DataTable2( - columnSpacing: 12, - horizontalMargin: 12, - headingRowColor: - MaterialStateColor.resolveWith((states) => Colors.black), - columns: [ - ...widget.table.columns.map((e) => DataColumn( - label: Text(e.fieldName), - )), - const DataColumn(label: Text("Actions")), - ], - rows: tableItems - .map((e) => DataRow(cells: [ - for (int i = 0; i < widget.table.columns.length; i++) - DataCell( - Text(e[widget.table.columns[i].fieldName] - ?.toString() ?? - "null"), - ), - DataCell( - Row( - children: [ - IconButton( - onPressed: () => _updateExistingItem(e), - icon: const Icon(Icons.edit), - ), - IconButton( - onPressed: () => _deleteItem(e), - icon: const Icon(Icons.delete), - ), - ], - ), - ), - ])) - .toList(growable: false), - empty: const Center(child: Text("No data")), - ), - ), - ], - ), - ), - ); - } - - Future _dropTable() async { - final really = await Get.defaultDialog( - title: "Drop table", - middleText: - "Are you sure you want to drop this table \"${widget.table.tableName}\"?", - textConfirm: "Drop", - onConfirm: () => Get.back(result: true), - onCancel: () {}, - barrierDismissible: false, - ); - - if (really != true) { - return; - } - - final result = await apiClient.dropTable(widget.table.tableName); - result.unfold((data) { - Get.back(); - }, (error) { - Get.snackbar("Error", error.toString()); - }); - } - - Future _refreshTableData() async { - final result = await apiClient.getTableItems(widget.table); - result.unfold((data) { - setState(() { - tableItems.clear(); - tableItems.addAll(data); - }); - }, (error) { - ScaffoldMessenger.of(context).hideCurrentSnackBar(); - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text("Error: $error"), - ), - ); - }); - } - - Future _addNewItem() async { - final newItem = await showFlexibleBottomSheet>( - minHeight: 1, - initHeight: 1, - maxHeight: 1, - context: context, - builder: (_, __, ___) => CreateTableItemBottomSheet(table: widget.table), - anchors: [0, 0.5, 1], - isSafeArea: true, - isDismissible: false, - ); - - if (newItem == null) { - return; - } - - final result = await apiClient.insertItem(widget.table, newItem); - result.unfold((data) { - ScaffoldMessenger.of(context).hideCurrentSnackBar(); - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: Text("Item added"), - ), - ); - _refreshTableData(); - }, (error) { - ScaffoldMessenger.of(context).hideCurrentSnackBar(); - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text("Error: $error"), - ), - ); - }); - } - - Future _updateExistingItem(TableItemsData oldItem) async { - final newItem = await showFlexibleBottomSheet>( - minHeight: 1, - initHeight: 1, - maxHeight: 1, - context: context, - builder: (_, __, ___) => CreateTableItemBottomSheet( - table: widget.table, - existingItem: Map.fromEntries(widget.table.columns - .where((el) => !el.isPrimary) - .map((el) => MapEntry(el.fieldName, oldItem[el.fieldName]))), - ), - anchors: [0, 0.5, 1], - isSafeArea: true, - isDismissible: false, - ); - - if (newItem == null) { - return; - } - - final result = await apiClient.updateItem(widget.table, newItem, oldItem); - result.unfold((data) { - ScaffoldMessenger.of(context).hideCurrentSnackBar(); - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: Text("Item added"), - ), - ); - _refreshTableData(); - }, (error) { - ScaffoldMessenger.of(context).hideCurrentSnackBar(); - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text("Error: $error"), - ), - ); - }); - } - - Future _deleteItem(TableItemsData e) async { - final really = await Get.defaultDialog( - title: "Delete item", - middleText: "Are you sure you want to delete this item?", - textConfirm: "Delete", - onConfirm: () => Get.back(result: true), - onCancel: () {}, - barrierDismissible: false, - ); - - if (really != true) { - return; - } - - final result = await apiClient.deleteItem(widget.table, e); - result.unfold((data) { - ScaffoldMessenger.of(context).hideCurrentSnackBar(); - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: Text("Item deleted"), - ), - ); - _refreshTableData(); - }, (error) { - ScaffoldMessenger.of(context).hideCurrentSnackBar(); - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text("Error: $error"), - ), - ); - }); - } -} -*/ \ No newline at end of file diff --git a/lib/pages/home_page.dart b/lib/pages/home_page.dart index a6f43d7..88f3adb 100644 --- a/lib/pages/home_page.dart +++ b/lib/pages/home_page.dart @@ -3,6 +3,7 @@ import 'package:get/get.dart'; import 'package:get_storage/get_storage.dart'; import 'package:tuuli_app/api_controller.dart'; import 'package:tuuli_app/c.dart'; +import 'package:tuuli_app/pages/home_panels/assets_panel.dart'; import 'package:tuuli_app/pages/home_panels/none_panel.dart'; import 'package:tuuli_app/pages/home_panels/settings_panel.dart'; import 'package:tuuli_app/pages/home_panels/tables_list_panel.dart'; @@ -12,6 +13,7 @@ enum PageType { none, tables, users, + assets, settings, } @@ -26,6 +28,7 @@ class HomePageController extends GetxController { PageType.none: "Home", PageType.tables: "Tables", PageType.users: "Users", + PageType.assets: "Assets", PageType.settings: "Settings", }; @@ -41,6 +44,10 @@ class HomePageController extends GetxController { () => UserListPanelController(), fenix: true, ); + Get.lazyPut( + () => AssetsPagePanelController(), + fenix: true, + ); } Future logout() async { @@ -49,6 +56,7 @@ class HomePageController extends GetxController { await Future.wait([ Get.delete(), Get.delete(), + Get.delete(), Get.delete(), ]); @@ -100,6 +108,16 @@ class HomePage extends GetView { selected: controller.currentPage == PageType.users, ), ), + Obx( + () => ListTile( + leading: const Icon(Icons.dataset_outlined), + title: const Text("Assets"), + onTap: () { + controller.currentPage = PageType.assets; + }, + selected: controller.currentPage == PageType.assets, + ), + ), Obx( () => ListTile( leading: const Icon(Icons.settings), @@ -154,6 +172,8 @@ class HomePage extends GetView { return const TablesListPanel(); case PageType.users: return const UsersListPanel(); + case PageType.assets: + return const AssetsPagePanel(); case PageType.settings: return const SettingsPanel(); case PageType.none: diff --git a/lib/pages/home_panels/assets_panel.dart b/lib/pages/home_panels/assets_panel.dart new file mode 100644 index 0000000..dbd2d70 --- /dev/null +++ b/lib/pages/home_panels/assets_panel.dart @@ -0,0 +1,518 @@ +import 'package:data_table_2/data_table_2.dart'; +import 'package:dio/dio.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_fast_forms/flutter_fast_forms.dart'; +import 'package:get/get.dart' hide MultipartFile; +import 'package:styled_widget/styled_widget.dart'; +import 'package:super_drag_and_drop/super_drag_and_drop.dart'; +import 'package:tuuli_api/tuuli_api.dart'; +import 'package:tuuli_app/api_controller.dart'; +import 'package:http_parser/http_parser.dart'; + +class AssetsPagePanelController extends GetxController { + @override + void onInit() { + super.onInit(); + + refreshData(); + } + + final _isLoading = false.obs; + bool get isLoading => _isLoading.value; + + final _assetsList = [].obs; + List get assetsList => _assetsList.toList(); + + final _tagsList = [].obs; + List get tagsList => _tagsList.toList(); + + final _filterTags = [].obs; + List get filterTags => _filterTags.toList(); + set filterTags(List value) => _filterTags.value = value; + + Future refreshData() async { + _isLoading.value = true; + + await Future.wait([ + refreshAssets(), + refreshTag(), + ]); + + _isLoading.value = false; + } + + Future refreshAssets() async { + try { + final resp = await ApiController.to.apiClient.getAssets(); + + final respData = resp.data; + if (respData == null) { + throw Exception("No data in response"); + } + + _assetsList.clear(); + _assetsList.addAll(respData); + } on DioError catch (e) { + final respData = e.response?.data; + if (respData != null) { + Get.snackbar( + "Error trying to get users", + "${respData['error']}", + ); + } else { + Get.snackbar( + "Error trying to get users", + "$e", + ); + } + } catch (e) { + Get.snackbar( + "Error trying to get users", + "$e", + ); + } + } + + Future refreshTag() async { + try { + final resp = await ApiController.to.apiClient.getAssetsTags(); + + final respData = resp.data; + if (respData == null) { + throw Exception("No data in response"); + } + + _tagsList.clear(); + _tagsList.addAll(respData); + } on DioError catch (e) { + final respData = e.response?.data; + if (respData != null) { + Get.snackbar( + "Error trying to get users", + "${respData['error']}", + ); + } else { + Get.snackbar( + "Error trying to get users", + "$e", + ); + } + } catch (e) { + Get.snackbar( + "Error trying to get users", + "$e", + ); + } + } + + Future openUploadDialog() async { + final file = await Get.dialog( + AlertDialog( + content: DropRegion( + formats: Formats.standardFormats, + hitTestBehavior: HitTestBehavior.opaque, + onDropOver: (event) { + if (event.session.items.length == 1 && + event.session.allowedOperations.contains(DropOperation.copy)) { + return DropOperation.copy; + } + return DropOperation.none; + }, + onPerformDrop: (event) async { + final item = event.session.items.first; + final reader = item.dataReader; + if (reader == null) return; + + reader.getFile( + null, + (dataReader) async { + final data = await dataReader.readAll(); + + final fileName = + dataReader.fileName ?? await reader.getSuggestedName(); + const mimeType = "application/octet-stream"; + + final file = MultipartFile.fromBytes( + data, + filename: fileName, + contentType: MediaType.parse(mimeType), + ); + Get.back(result: file); + }, + onError: (value) { + Get.snackbar("Error", value.toString()); + }, + ); + }, + child: const Text("Drop file here") + .paddingAll(8) + .fittedBox() + .constrained(height: 200, width: 200), + ).border(all: 2, color: Colors.lightBlueAccent), + actions: [ + TextButton( + onPressed: () => Get.back(result: null), + child: const Text("Cancel"), + ) + ], + ), + ); + + if (file == null) return; + + final sendProgress = 0.obs; + final receiveProgress = 0.obs; + final req = ApiController.to.apiClient.putAsset( + asset: file, + onSendProgress: (count, _) { + sendProgress.value = count; + }, + onReceiveProgress: (count, _) { + receiveProgress.value = count; + }, + ); + Get.dialog( + SizedBox( + width: 32, + height: 32, + child: Obx( + () => CircularProgressIndicator( + value: + sendProgress.value == 0 ? null : sendProgress.value.toDouble(), + ), + ), + ).paddingAll(32).card().center(), + barrierDismissible: false, + ); + + try { + final resp = await req; + + final respData = resp.data; + if (respData == null) { + throw Exception("No data in response"); + } + + refreshData(); + } on DioError catch (e) { + final respData = e.response?.data; + if (respData != null) { + Get.snackbar( + "Error trying to get users", + "${respData['error']}", + ); + } else { + Get.snackbar( + "Error trying to get users", + "$e", + ); + } + } catch (e) { + Get.snackbar( + "Error trying to get users", + "$e", + ); + } finally { + Get.back(); + } + } + + Future editAsset(Asset e) async { + final description = e.description.obs; + final tags = e.tags.split(",").obs; + + final confirm = await Get.dialog( + AlertDialog( + title: const Text("Edit asset"), + content: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + TextField( + controller: TextEditingController(text: description.value), + onChanged: (value) => description.value = value, + decoration: const InputDecoration( + labelText: "Description", + ), + ), + TextField( + controller: TextEditingController(text: tags.join(", ")), + onChanged: (value) => tags.value = + value.split(",").map((e) => e.trim()).toList(growable: false), + decoration: const InputDecoration( + labelText: "Tags", + ), + ), + const SizedBox(height: 16), + Obx( + () => Wrap( + children: tags + .where((p0) => p0.isNotEmpty) + .map((tag) => Chip(label: Text(tag))) + .toList(growable: false), + ).paddingAll(8).card(color: Colors.blueGrey.shade200).expanded(), + ), + ], + ).constrained(width: Get.width * 0.5, height: Get.width * 0.5), + actions: [ + TextButton( + onPressed: () => Get.back(result: false), + child: const Text("Cancel"), + ), + TextButton( + onPressed: () => Get.back(result: true), + child: const Text("Confirm"), + ), + ], + ), + ); + + if (confirm != true) return; + + try { + final resp = + await ApiController.to.apiClient.updateAssetDescriptionAndTags( + assetId: e.id, + assetDescription: description.value, + assetTags: tags, + ); + + final respData = resp.data; + if (respData == null) { + throw Exception("No data in response"); + } + + refreshData(); + } on DioError catch (e) { + final respData = e.response?.data; + if (respData != null) { + Get.snackbar( + "Error trying to get users", + "${respData['error']}", + ); + } else { + Get.snackbar( + "Error trying to get users", + "$e", + ); + } + } catch (e) { + Get.snackbar( + "Error trying to get users", + "$e", + ); + } + } + + Future removeAsset(Asset e) async { + final checkReferences = false.obs; + final deleteReferencing = false.obs; + + final confirm = await Get.dialog( + AlertDialog( + title: const Text("Remove asset"), + content: Column( + mainAxisSize: MainAxisSize.min, + children: [ + const Text("You are about to remove an asset."), + Obx( + () => CheckboxListTile( + value: checkReferences.value, + onChanged: (value) => checkReferences.value = value ?? false, + title: const Text("Check references"), + ), + ), + Obx( + () => CheckboxListTile( + value: deleteReferencing.value, + onChanged: (value) => deleteReferencing.value = value ?? false, + title: const Text("Delete referencing"), + ), + ), + ], + ), + actions: [ + TextButton( + onPressed: () => Get.back(result: false), + child: const Text("Cancel"), + ), + TextButton( + onPressed: () => Get.back(result: true), + child: const Text("Remove"), + ), + ], + ), + ); + + if (confirm != true) return; + + try { + final resp = await ApiController.to.apiClient.removeAsset( + assetId: e.id, + checkReferences: checkReferences.value, + deleteReferencing: deleteReferencing.value, + ); + + final respData = resp.data; + if (respData == null) { + throw Exception("No data in response"); + } + + refreshData(); + } on DioError catch (e) { + final respData = e.response?.data; + if (respData != null) { + Get.snackbar( + "Error trying to get users", + "${respData['error']}", + ); + } else { + Get.snackbar( + "Error trying to get users", + "$e", + ); + } + } catch (e) { + Get.snackbar( + "Error trying to get users", + "$e", + ); + } + } +} + +class AssetsPagePanel extends GetView { + const AssetsPagePanel({super.key}); + + @override + Widget build(BuildContext context) { + return Stack( + children: [ + Column( + children: [ + AppBar( + elevation: 0, + title: Row( + children: [ + const Text("Tags:"), + Obx( + () => FastChipsInput( + name: "FastChipsInput", + options: controller.tagsList, + crossAxisAlignment: WrapCrossAlignment.center, + decoration: const InputDecoration( + border: InputBorder.none, + ), + chipBuilder: (chipValue, chipIndex, field) => InputChip( + label: Text(chipValue), + isEnabled: field.widget.enabled, + onDeleted: () => field + .didChange([...field.value!]..remove(chipValue)), + selected: chipIndex == field.selectedChipIndex, + showCheckmark: false, + backgroundColor: Colors.green.shade200, + ), + onChanged: (value) => controller.filterTags = value ?? [], + ), + ).expanded(), + ], + ), + actions: [ + IconButton( + icon: const Icon(Icons.add), + onPressed: () => controller.openUploadDialog(), + ), + IconButton( + icon: const Icon(Icons.refresh), + onPressed: () => controller.refreshData(), + ), + ], + ), + Expanded( + child: assetsPanel, + ), + ], + ), + Obx( + () => Positioned( + right: 16, + bottom: 16, + child: controller.isLoading + ? const CircularProgressIndicator() + : const SizedBox(), + ), + ), + ], + ); + } + + Widget get assetsPanel => Obx( + () => DataTable2( + columns: const [ + DataColumn2(label: Text("ID"), size: ColumnSize.S, numeric: true), + DataColumn2(label: Text("Filename"), size: ColumnSize.M), + DataColumn2(label: Text("Description"), size: ColumnSize.L), + DataColumn2(label: Text("File ID"), size: ColumnSize.M), + DataColumn2(label: Text("Tags"), size: ColumnSize.L), + DataColumn2(label: Text("Actions")), + ], + empty: const Text("No assets found"), + rows: controller.assetsList + .where((element) { + if (controller.filterTags.isEmpty) return true; + + return element.tags + .split(",") + .any(controller.filterTags.contains); + }) + .map((e) => DataRow2( + cells: [ + DataCell(Text(e.id.toString())), + DataCell(Tooltip( + message: e.name, + child: Text( + e.name, + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + )), + DataCell(Tooltip( + message: e.description, + child: Text( + e.description, + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + )), + DataCell(Tooltip( + message: e.fid, + child: Text( + e.fid, + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + )), + DataCell(Tooltip( + message: e.tags, + child: Text( + e.tags, + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + )), + DataCell(Row(children: [ + IconButton( + icon: const Icon(Icons.edit), + onPressed: () => controller.editAsset(e), + ), + IconButton( + icon: const Icon(Icons.delete), + onPressed: () => controller.removeAsset(e), + ), + ])), + ], + )) + .toList(growable: false), + ), + ); +} diff --git a/pubspec.lock b/pubspec.lock index e24b1d4..bb78cf0 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -254,6 +254,14 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_chips_input: + dependency: "direct main" + description: + name: flutter_chips_input + sha256: "9828e45e75f268ff51a08e8d05848776b0a4d8327867d2b347a733030bafe64f" + url: "https://pub.dev" + source: hosted + version: "2.0.0" flutter_fast_forms: dependency: "direct main" description: @@ -360,6 +368,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.4" + irondash_engine_context: + dependency: transitive + description: + name: irondash_engine_context + sha256: "086fbbcaef07b821b304b0371e472c687715f326219b69b18dc5c962dab09b55" + url: "https://pub.dev" + source: hosted + version: "0.1.1" + irondash_message_channel: + dependency: transitive + description: + name: irondash_message_channel + sha256: "081ff9631a2c6782a47ef4fdf9c97206053af1bb174e2a25851692b04f3bc126" + url: "https://pub.dev" + source: hosted + version: "0.1.1" js: dependency: transitive description: @@ -476,10 +500,10 @@ packages: dependency: transitive description: name: path_provider_android - sha256: da97262be945a72270513700a92b39dd2f4a54dad55d061687e2e37a6390366a + sha256: "3e58242edc02624f2c712e3f8bea88e0e341c4ae1abd3a6ff661318a3aefd829" url: "https://pub.dev" source: hosted - version: "2.0.25" + version: "2.0.26" path_provider_foundation: dependency: transitive description: @@ -508,10 +532,10 @@ packages: dependency: transitive description: name: path_provider_windows - sha256: f53720498d5a543f9607db4b0e997c4b5438884de25b0f73098cc2671a51b130 + sha256: d3f80b32e83ec208ac95253e0cd4d298e104fbc63cb29c5c69edaed43b0c69d6 url: "https://pub.dev" source: hosted - version: "2.1.5" + version: "2.1.6" platform: dependency: transitive description: @@ -588,10 +612,10 @@ packages: dependency: transitive description: name: shared_preferences_android - sha256: "7fa90471a6875d26ad78c7e4a675874b2043874586891128dc5899662c97db46" + sha256: "5d7b3bd0400bdd0c03e59a3d3d5314651141a145b58196cd9018b12a2adc0c1b" url: "https://pub.dev" source: hosted - version: "2.1.2" + version: "2.1.3" shared_preferences_foundation: dependency: transitive description: @@ -709,6 +733,30 @@ packages: url: "https://pub.dev" source: hosted version: "0.4.1" + super_clipboard: + dependency: transitive + description: + name: super_clipboard + sha256: "7628464b63fd18df486e87a989ecfd73565f7b01a15ee47a2448283931c3d14d" + url: "https://pub.dev" + source: hosted + version: "0.3.0+2" + super_drag_and_drop: + dependency: "direct main" + description: + name: super_drag_and_drop + sha256: "9a31045fcb264bcfe57e5001b24b68cb8d4880d8d4ecfd594dd4c11a92b1ca56" + url: "https://pub.dev" + source: hosted + version: "0.3.0+2" + super_native_extensions: + dependency: transitive + description: + name: super_native_extensions + sha256: "18ad4c367cea763654d458d9e9aec8c0c00c6b1d542c4f746c94a223e8e4bd0c" + url: "https://pub.dev" + source: hosted + version: "0.3.0+2" term_glyph: dependency: transitive description: @@ -738,10 +786,10 @@ packages: description: path: "." ref: master - resolved-ref: "46d8acd4a54fd716a16f119e4296ee5583b8bc98" + resolved-ref: ab60426db27a2441107e529f527df0e502dae104 url: "https://glab.nuark.xyz/nuark/tuuli_api.git" source: git - version: "1.0.0" + version: "1.0.1" typed_data: dependency: transitive description: @@ -750,6 +798,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.1" + uuid: + dependency: transitive + description: + name: uuid + sha256: "648e103079f7c64a36dc7d39369cabb358d377078a051d6ae2ad3aa539519313" + url: "https://pub.dev" + source: hosted + version: "3.0.7" vector_math: dependency: transitive description: @@ -778,10 +834,10 @@ packages: dependency: transitive description: name: win32 - sha256: a6f0236dbda0f63aa9a25ad1ff9a9d8a4eaaa5012da0dc59d21afdb1dc361ca4 + sha256: dd8f9344bc305ae2923e3d11a2a911d9a4e2c7dd6fe0ed10626d63211a69676e url: "https://pub.dev" source: hosted - version: "3.1.4" + version: "4.1.3" xdg_directories: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 754700c..62182bc 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,6 +16,7 @@ dependencies: built_value: ^8.4.4 data_table_2: ^2.4.2 dio: ^5.1.1 + flutter_chips_input: ^2.0.0 flutter_fast_forms: ^10.0.0 get: ^4.6.5 get_storage: ^2.1.1 @@ -24,7 +25,7 @@ dependencies: recase: ^4.1.0 shared_preferences: ^2.1.0 styled_widget: ^0.4.1 - + super_drag_and_drop: ^0.3.0+2 tuuli_api: git: url: https://glab.nuark.xyz/nuark/tuuli_api.git -- 2.47.3 From e85534201bff9338734efe56cfb708d245be2881 Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Fri, 28 Apr 2023 20:01:34 +0700 Subject: [PATCH 13/28] Launch options --- .vscode/launch.json | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..72f6b2e --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,25 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "tuuli_app", + "request": "launch", + "type": "dart" + }, + { + "name": "tuuli_app (profile mode)", + "request": "launch", + "type": "dart", + "flutterMode": "profile" + }, + { + "name": "tuuli_app (release mode)", + "request": "launch", + "type": "dart", + "flutterMode": "release" + } + ] +} -- 2.47.3 From c3e9338208cd233fc18b4fd4cf9d3088766024c8 Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Fri, 28 Apr 2023 20:01:45 +0700 Subject: [PATCH 14/28] Required lib --- pubspec.lock | 2 +- pubspec.yaml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pubspec.lock b/pubspec.lock index bb78cf0..c4794f3 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -345,7 +345,7 @@ packages: source: hosted version: "3.2.1" http_parser: - dependency: transitive + dependency: "direct main" description: name: http_parser sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" diff --git a/pubspec.yaml b/pubspec.yaml index 62182bc..a33775e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -30,6 +30,7 @@ dependencies: git: url: https://glab.nuark.xyz/nuark/tuuli_api.git ref: master + http_parser: ^4.0.2 dev_dependencies: flutter_test: -- 2.47.3 From 330216e37aed24e1584c350b17742d2d681126c6 Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Fri, 28 Apr 2023 20:01:57 +0700 Subject: [PATCH 15/28] Fixed error messages --- lib/pages/home_panels/assets_panel.dart | 30 ++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/pages/home_panels/assets_panel.dart b/lib/pages/home_panels/assets_panel.dart index dbd2d70..f011029 100644 --- a/lib/pages/home_panels/assets_panel.dart +++ b/lib/pages/home_panels/assets_panel.dart @@ -56,18 +56,18 @@ class AssetsPagePanelController extends GetxController { final respData = e.response?.data; if (respData != null) { Get.snackbar( - "Error trying to get users", + "Error trying to get assets", "${respData['error']}", ); } else { Get.snackbar( - "Error trying to get users", + "Error trying to get assets", "$e", ); } } catch (e) { Get.snackbar( - "Error trying to get users", + "Error trying to get assets", "$e", ); } @@ -88,18 +88,18 @@ class AssetsPagePanelController extends GetxController { final respData = e.response?.data; if (respData != null) { Get.snackbar( - "Error trying to get users", + "Error trying to get tags", "${respData['error']}", ); } else { Get.snackbar( - "Error trying to get users", + "Error trying to get tags", "$e", ); } } catch (e) { Get.snackbar( - "Error trying to get users", + "Error trying to get tags", "$e", ); } @@ -198,18 +198,18 @@ class AssetsPagePanelController extends GetxController { final respData = e.response?.data; if (respData != null) { Get.snackbar( - "Error trying to get users", + "Error trying to put asset", "${respData['error']}", ); } else { Get.snackbar( - "Error trying to get users", + "Error trying to put asset", "$e", ); } } catch (e) { Get.snackbar( - "Error trying to get users", + "Error trying to put asset", "$e", ); } finally { @@ -287,18 +287,18 @@ class AssetsPagePanelController extends GetxController { final respData = e.response?.data; if (respData != null) { Get.snackbar( - "Error trying to get users", + "Error trying to edit asset", "${respData['error']}", ); } else { Get.snackbar( - "Error trying to get users", + "Error trying to edit asset", "$e", ); } } catch (e) { Get.snackbar( - "Error trying to get users", + "Error trying to edit asset", "$e", ); } @@ -363,18 +363,18 @@ class AssetsPagePanelController extends GetxController { final respData = e.response?.data; if (respData != null) { Get.snackbar( - "Error trying to get users", + "Error trying to remove asset", "${respData['error']}", ); } else { Get.snackbar( - "Error trying to get users", + "Error trying to remove asset", "$e", ); } } catch (e) { Get.snackbar( - "Error trying to get users", + "Error trying to remove asset", "$e", ); } -- 2.47.3 From 2d812b20c4d9a961fc7c4c249dfa041f771023ce Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Sat, 29 Apr 2023 01:08:18 +0700 Subject: [PATCH 16/28] Made possible updating security for user groups on tables --- lib/models/table_access.dart | 24 ++ lib/pages/dialogs/group_acl_dialog.dart | 406 ++++++++++++++++++++ lib/pages/home_panels/users_list_panel.dart | 10 + pubspec.lock | 10 +- 4 files changed, 445 insertions(+), 5 deletions(-) create mode 100644 lib/models/table_access.dart create mode 100644 lib/pages/dialogs/group_acl_dialog.dart diff --git a/lib/models/table_access.dart b/lib/models/table_access.dart new file mode 100644 index 0000000..5a9eea2 --- /dev/null +++ b/lib/models/table_access.dart @@ -0,0 +1,24 @@ +enum TableAccess { + read("r"), + write("w"), + readWrite("rw"), + none(""); + + final String def; + + const TableAccess(this.def); + + static TableAccess fromString(String? def) { + switch (def) { + case "r": + return TableAccess.read; + case "w": + return TableAccess.write; + case "rw": + return TableAccess.readWrite; + case "none": + default: + return TableAccess.none; + } + } +} diff --git a/lib/pages/dialogs/group_acl_dialog.dart b/lib/pages/dialogs/group_acl_dialog.dart new file mode 100644 index 0000000..6daa5cb --- /dev/null +++ b/lib/pages/dialogs/group_acl_dialog.dart @@ -0,0 +1,406 @@ +import 'package:data_table_2/data_table_2.dart'; +import 'package:dio/dio.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart' hide Response; +import 'package:recase/recase.dart'; +import 'package:styled_widget/styled_widget.dart'; +import 'package:tuuli_api/tuuli_api.dart'; +import 'package:tuuli_app/api_controller.dart'; +import 'package:tuuli_app/models/group_definition.dart'; +import 'package:tuuli_app/models/table_access.dart'; + +class GroupACLController extends GetxController { + final GroupDefinition group; + + GroupACLController(this.group); + + @override + void onInit() { + super.onInit(); + + refreshData(); + } + + final _tables = [].obs; + List get tables => _tables.toList(); + + final _access = {}.obs; + Map get access => _access; + + final _allowedColumns = {}.obs; + Map get allowedColumns => _allowedColumns; + + Future refreshData() async { + await refreshTables(); + + for (final table in tables) { + await refreshTableAccess(table); + } + } + + Future refreshTables() async { + try { + final resp = await ApiController.to.apiClient.listTables(); + + final respData = resp.data; + if (respData == null) { + throw Exception("No data in response"); + } + + _tables.clear(); + _tables.addAll(respData.where((e) => e.hidden != true)); + } on DioError catch (e) { + final respData = e.response?.data; + if (respData != null) { + Get.snackbar( + "Error trying to get tables", + "${respData['error']}", + ); + } else { + Get.snackbar( + "Error trying to get tables", + "$e", + ); + } + } catch (e) { + Get.snackbar( + "Error trying to get tables", + "$e", + ); + } + } + + Future refreshTableAccess(TableDefinition table) async { + try { + final resp = await ApiController.to.apiClient.getItemsFromTable( + tableName: "table_access", + itemsSelector: ItemsSelector( + fields: ["access_type", "allowed_columns"], + where: [ + ColumnConditionCompat( + column: "user_group_id", + operator_: ColumnConditionCompatOperator.eq, + value: group.id, + ), + ColumnConditionCompat( + column: "table_name", + operator_: ColumnConditionCompatOperator.eq, + value: table.tableName, + ), + ], + ), + ); + + final respData = resp.data; + if (respData == null) { + throw Exception("No data in response"); + } + + if (respData.isNotEmpty) { + _access[table.tableId] = + TableAccess.fromString(respData.first["access_type"]); + _allowedColumns[table.tableId] = respData.first["allowed_columns"]; + } else { + _access[table.tableId] = TableAccess.none; + _allowedColumns[table.tableId] = null; + } + } on DioError catch (e) { + final respData = e.response?.data; + if (respData != null) { + Get.snackbar( + "Error trying to get tables access", + "${respData['error']}", + ); + } else { + Get.snackbar( + "Error trying to get tables access", + "$e", + ); + } + } catch (e) { + Get.snackbar( + "Error trying to get tables access", + "$e", + ); + } + } + + Future updateTableAccess( + TableDefinition table, { + required bool read, + required bool write, + }) async { + final oldTableAccess = _access[table.tableId]; + var newTableAccess = TableAccess.none; + if (read && write) { + newTableAccess = TableAccess.readWrite; + } else if (read) { + newTableAccess = TableAccess.read; + } else if (write) { + newTableAccess = TableAccess.write; + } + + try { + Response resp; + if (newTableAccess == TableAccess.none) { + resp = await ApiController.to.apiClient.deleteItemFromTable( + tableName: "table_access", + columnConditionCompat: [ + ColumnConditionCompat( + column: "user_group_id", + operator_: ColumnConditionCompatOperator.eq, + value: group.id, + ), + ColumnConditionCompat( + column: "table_name", + operator_: ColumnConditionCompatOperator.eq, + value: table.tableName, + ), + ], + ); + } else if (oldTableAccess == TableAccess.none) { + resp = await ApiController.to.apiClient.createItem( + tableName: "table_access", + itemDefinition: { + "user_group_id": group.id, + "table_name": table.tableName, + "access_type": newTableAccess.def, + }, + ); + } else { + resp = await ApiController.to.apiClient.updateItemInTable( + tableName: "table_access", + itemUpdate: ItemUpdate( + item: { + "access_type": newTableAccess.def, + }, + oldItem: { + "user_group_id": group.id, + "table_name": table.tableName, + }, + ), + ); + } + + final respData = resp.data; + if (respData == null) { + throw Exception("No data in response"); + } + + refreshTableAccess(table); + } on DioError catch (e) { + final respData = e.response?.data; + if (respData != null) { + Get.snackbar( + "Error trying to update tables access", + "${respData['error']}", + ); + } else { + Get.snackbar( + "Error trying to update tables access", + "$e", + ); + } + } catch (e) { + Get.snackbar( + "Error trying to update tables access", + "$e", + ); + } + } + + Future changeAllowedColumns(TableDefinition table) async { + final tableColumns = table.columns + .split(",") + .map((e) => e.split(":").first) + .where((e) => e.isNotEmpty) + .toList(); + final currentlyAvailableColumns = + _allowedColumns[table.tableId]!.split(","); + + if (currentlyAvailableColumns.length == 1 && + currentlyAvailableColumns.first == "*") { + currentlyAvailableColumns.clear(); + currentlyAvailableColumns.addAll(tableColumns); + } + + final selectedColumns = {}.obs; + for (final column in tableColumns) { + selectedColumns[column] = currentlyAvailableColumns.contains(column); + } + + final confirm = await Get.dialog( + AlertDialog( + title: const Text("Allowed columns"), + content: Obx( + () => Wrap( + children: [ + ElevatedButton( + onPressed: () { + for (final column in tableColumns) { + selectedColumns[column] = !selectedColumns[column]!; + } + }, + child: const Text("Swap all"), + ), + ...selectedColumns.entries.map((e) { + return CheckboxListTile( + title: Text(e.key), + value: e.value, + onChanged: (value) => selectedColumns[e.key] = value!, + ); + }), + ], + ), + ), + actions: [ + TextButton( + onPressed: () => Get.back(result: false), + child: const Text("Cancel"), + ), + TextButton( + onPressed: () => Get.back(result: true), + child: const Text("Ok"), + ), + ], + ), + ); + + if (confirm != true) return; + + if (selectedColumns.values.every((e) => !e)) { + await Get.dialog( + AlertDialog( + title: const Text("Error"), + content: const Text("At least one column must be selected"), + actions: [ + TextButton( + onPressed: () => Get.back(), + child: const Text("Ok"), + ), + ], + ), + ); + return; + } + + try { + Response resp = + await ApiController.to.apiClient.updateItemInTable( + tableName: "table_access", + itemUpdate: ItemUpdate( + item: { + "allowed_columns": selectedColumns.keys + .where((k) => selectedColumns[k]!) + .join(","), + }, + oldItem: { + "user_group_id": group.id, + "table_name": table.tableName, + }, + ), + ); + + final respData = resp.data; + if (respData == null) { + throw Exception("No data in response"); + } + + refreshTableAccess(table); + } on DioError catch (e) { + final respData = e.response?.data; + if (respData != null) { + Get.snackbar( + "Error trying to update tables access", + "${respData['error']}", + ); + } else { + Get.snackbar( + "Error trying to update tables access", + "$e", + ); + } + } catch (e) { + Get.snackbar( + "Error trying to update tables access", + "$e", + ); + } + } +} + +class GroupACLDialog extends GetView { + const GroupACLDialog({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return AlertDialog( + title: const Text('Group ACL'), + content: Obx( + () => DataTable2( + columns: const [ + DataColumn2(label: Text('Table'), size: ColumnSize.L), + DataColumn2(label: Text('Read'), size: ColumnSize.S), + DataColumn2(label: Text('Write'), size: ColumnSize.S), + DataColumn2(label: Text('Allowed columns'), size: ColumnSize.S), + ], + empty: const Text("No tables"), + rows: controller.access.entries.map((e) { + final table = controller.tables.firstWhere( + (element) => element.tableId == e.key, + ); + final tableAccess = e.value; + final read = tableAccess == TableAccess.read || + tableAccess == TableAccess.readWrite; + final write = tableAccess == TableAccess.write || + tableAccess == TableAccess.readWrite; + return DataRow(cells: [ + DataCell(Text(table.tableName.pascalCase)), + DataCell(Checkbox( + value: read, + onChanged: (value) => controller.updateTableAccess( + table, + read: value ?? false, + write: write, + ), + )), + DataCell(Checkbox( + value: write, + onChanged: (value) => controller.updateTableAccess( + table, + read: read, + write: value ?? false, + ), + )), + controller.allowedColumns[table.tableId] == null + ? DataCell.empty + : DataCell( + Text(controller.allowedColumns[table.tableId]!), + onTap: () => controller.changeAllowedColumns(table), + ), + ]); + }).toList(growable: false), + ).constrained(width: Get.width * 0.9, height: Get.height * 0.9), + ), + actions: [ + TextButton( + onPressed: () { + Get.back(); + }, + child: const Text('Close'), + ), + ], + ); + } + + static Future show(GroupDefinition group) async { + Get.lazyPut(() => GroupACLController(group)); + + await Get.dialog( + const GroupACLDialog(), + barrierDismissible: false, + ); + + Get.delete(); + } +} diff --git a/lib/pages/home_panels/users_list_panel.dart b/lib/pages/home_panels/users_list_panel.dart index 9e8f73c..161ad6f 100644 --- a/lib/pages/home_panels/users_list_panel.dart +++ b/lib/pages/home_panels/users_list_panel.dart @@ -9,6 +9,7 @@ import 'package:tuuli_app/api_controller.dart'; import 'package:tuuli_app/models/group_definition.dart'; import 'package:tuuli_app/models/user_definition.dart'; import 'package:tuuli_app/models/user_in_group_definition.dart'; +import 'package:tuuli_app/pages/dialogs/group_acl_dialog.dart'; enum UserListPanelTab { users, @@ -651,6 +652,10 @@ class UserListPanelController extends GetxController { ); } } + + Future changeGroupSecurity(GroupDefinition group) async { + await GroupACLDialog.show(group); + } } class UsersListPanel extends GetView { @@ -840,6 +845,11 @@ class UsersListPanel extends GetView { icon: const Icon(Icons.delete_forever), onPressed: () => controller.deleteGroup(group), ), + if (group.id != 2) + IconButton( + icon: const Icon(Icons.security), + onPressed: () => controller.changeGroupSecurity(group), + ), ], ), subtitle: Text( diff --git a/pubspec.lock b/pubspec.lock index c4794f3..bb0d9b6 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -500,10 +500,10 @@ packages: dependency: transitive description: name: path_provider_android - sha256: "3e58242edc02624f2c712e3f8bea88e0e341c4ae1abd3a6ff661318a3aefd829" + sha256: "2cec049d282c7f13c594b4a73976b0b4f2d7a1838a6dd5aaf7bd9719196bee86" url: "https://pub.dev" source: hosted - version: "2.0.26" + version: "2.0.27" path_provider_foundation: dependency: transitive description: @@ -612,10 +612,10 @@ packages: dependency: transitive description: name: shared_preferences_android - sha256: "5d7b3bd0400bdd0c03e59a3d3d5314651141a145b58196cd9018b12a2adc0c1b" + sha256: "6478c6bbbecfe9aced34c483171e90d7c078f5883558b30ec3163cf18402c749" url: "https://pub.dev" source: hosted - version: "2.1.3" + version: "2.1.4" shared_preferences_foundation: dependency: transitive description: @@ -786,7 +786,7 @@ packages: description: path: "." ref: master - resolved-ref: ab60426db27a2441107e529f527df0e502dae104 + resolved-ref: "116030611798bdb81a19c2504f1ad7adb6547725" url: "https://glab.nuark.xyz/nuark/tuuli_api.git" source: git version: "1.0.1" -- 2.47.3 From a04eb703f5885063dd23bad95fc1111bbc2227d6 Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Sat, 29 Apr 2023 02:32:38 +0700 Subject: [PATCH 17/28] Table creation implemented --- lib/models/table_column_definition.dart | 88 +++++++ lib/pages/dialogs/create_table_dialog.dart | 251 +++++++++++++++++++ lib/pages/home_panels/tables_list_panel.dart | 8 +- 3 files changed, 346 insertions(+), 1 deletion(-) create mode 100644 lib/models/table_column_definition.dart create mode 100644 lib/pages/dialogs/create_table_dialog.dart diff --git a/lib/models/table_column_definition.dart b/lib/models/table_column_definition.dart new file mode 100644 index 0000000..c1d2975 --- /dev/null +++ b/lib/models/table_column_definition.dart @@ -0,0 +1,88 @@ +abstract class TableColumnDefinition { + final String columnName; + final bool isUnique; + + TableColumnDefinition({ + required this.columnName, + required this.isUnique, + }); + + String get def => throw UnimplementedError("def getter not implemented"); +} + +class SerialPrimaryColumnDefinition extends TableColumnDefinition { + SerialPrimaryColumnDefinition({ + required super.columnName, + }) : super(isUnique: true); + + @override + String get def => "$columnName:serial:primary"; +} + +class TextColumnDefinition extends TableColumnDefinition { + TextColumnDefinition({ + required super.columnName, + required super.isUnique, + }); + + @override + String get def => "$columnName:str${isUnique ? ":unique" : ""}"; +} + +class BooleanColumnDefinition extends TableColumnDefinition { + BooleanColumnDefinition({ + required super.columnName, + required super.isUnique, + }); + + @override + String get def => "$columnName:bool${isUnique ? ":unique" : ""}"; +} + +class TimestampColumnDefinition extends TableColumnDefinition { + TimestampColumnDefinition({ + required super.columnName, + required super.isUnique, + }); + + @override + String get def => "$columnName:datetime${isUnique ? ":unique" : ""}"; +} + +class DoubleColumnDefinition extends TableColumnDefinition { + DoubleColumnDefinition({ + required super.columnName, + required super.isUnique, + }); + + @override + String get def => "$columnName:float${isUnique ? ":unique" : ""}"; +} + +class IntegerColumnDefinition extends TableColumnDefinition { + IntegerColumnDefinition({ + required super.columnName, + required super.isUnique, + }); + + @override + String get def => "$columnName:int${isUnique ? ":unique" : ""}"; +} + +class UserRefColumnDefinition extends TableColumnDefinition { + UserRefColumnDefinition({ + required super.columnName, + }) : super(isUnique: false); + + @override + String get def => "$columnName:int-user"; +} + +class AssetRefColumnDefinition extends TableColumnDefinition { + AssetRefColumnDefinition({ + required super.columnName, + }) : super(isUnique: false); + + @override + String get def => "$columnName:int-asset"; +} diff --git a/lib/pages/dialogs/create_table_dialog.dart b/lib/pages/dialogs/create_table_dialog.dart new file mode 100644 index 0000000..7d9e014 --- /dev/null +++ b/lib/pages/dialogs/create_table_dialog.dart @@ -0,0 +1,251 @@ +import 'package:dio/dio.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_fast_forms/flutter_fast_forms.dart'; +import 'package:get/get.dart'; +import 'package:styled_widget/styled_widget.dart'; +import 'package:tuuli_app/api_controller.dart'; +import 'package:tuuli_app/models/table_column_definition.dart'; + +const typeToNameMatcher = { + SerialPrimaryColumnDefinition: "Serial ID", + TextColumnDefinition: "Text", + BooleanColumnDefinition: "Boolean", + TimestampColumnDefinition: "Date/Time", + DoubleColumnDefinition: "Double", + IntegerColumnDefinition: "Integer", + UserRefColumnDefinition: "User reference", + AssetRefColumnDefinition: "Asset reference", +}; + +class CreateTableController extends GetxController { + final _tableName = "".obs; + String get tableName => _tableName.value; + set tableName(String value) => _tableName.value = value; + + final _columnsDefinition = [].obs; + List get columnsDefinition => _columnsDefinition; + + Future createTable() async { + try { + final resp = await ApiController.to.apiClient.createTable( + tableName: tableName, + columnsDefinition: + _columnsDefinition.map((e) => e.def).toList(growable: false), + ); + + final respData = resp.data; + if (respData == null) { + throw Exception("No data in response"); + } + + Get.back(result: true); + } on DioError catch (e) { + final respData = e.response?.data; + if (respData != null) { + Get.snackbar( + "Error trying to update tables access", + "${respData['error']}", + ); + } else { + Get.snackbar( + "Error trying to update tables access", + "$e", + ); + } + } catch (e) { + Get.snackbar( + "Error trying to update tables access", + "$e", + ); + } + } + + Future createNewColumn() async { + final columnName = "".obs; + final columnType = "".obs; + final columnIsUnique = false.obs; + + final confirm = await Get.dialog( + AlertDialog( + title: const Text("Create new column"), + content: Wrap( + runSpacing: 16, + children: [ + FastTextField( + name: "ColumnName", + decoration: const InputDecoration( + labelText: "Column name", + border: OutlineInputBorder(), + ), + initialValue: columnName.value, + onChanged: (value) => columnName.value = value ?? "", + ), + FastDropdown( + name: "ColumnTypes", + hint: const Text("Select column type"), + items: typeToNameMatcher.keys.toList(growable: false), + itemsBuilder: (items, field) => items + .map( + (e) => DropdownMenuItem( + value: e, + child: Text(typeToNameMatcher[e]!), + ), + ) + .toList(), + onChanged: (value) => + columnType.value = typeToNameMatcher[value] ?? "", + ), + FastCheckbox( + name: "ColumnIsUnique", + titleText: "Is Unique", + initialValue: false, + onChanged: (value) => columnIsUnique.value = value!, + ), + ], + ), + actions: [ + TextButton( + onPressed: () { + Get.back(result: false); + }, + child: const Text('Close'), + ), + TextButton( + onPressed: () { + Get.back(result: true); + }, + child: const Text('Create'), + ), + ], + ), + ); + + if (confirm != true) return; + + TableColumnDefinition? ct; + switch (columnType.value) { + case "Serial ID": + ct = SerialPrimaryColumnDefinition( + columnName: columnName.value, + ); + break; + case "Text": + ct = TextColumnDefinition( + columnName: columnName.value, + isUnique: columnIsUnique.value, + ); + break; + case "Boolean": + ct = BooleanColumnDefinition( + columnName: columnName.value, + isUnique: columnIsUnique.value, + ); + break; + case "Date/Time": + ct = TimestampColumnDefinition( + columnName: columnName.value, + isUnique: columnIsUnique.value, + ); + break; + case "Double": + ct = DoubleColumnDefinition( + columnName: columnName.value, + isUnique: columnIsUnique.value, + ); + break; + case "Integer": + ct = IntegerColumnDefinition( + columnName: columnName.value, + isUnique: columnIsUnique.value, + ); + break; + case "User reference": + ct = UserRefColumnDefinition( + columnName: columnName.value, + ); + break; + case "Asset reference": + ct = AssetRefColumnDefinition( + columnName: columnName.value, + ); + break; + } + if (ct == null) return; + _columnsDefinition.add(ct); + } + + void removeColumn(TableColumnDefinition e) { + _columnsDefinition.remove(e); + } +} + +class CreateTableDialog extends GetView { + const CreateTableDialog({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return AlertDialog( + title: const Text('Creating new table'), + content: Column( + children: [ + TextField( + decoration: const InputDecoration( + labelText: "Table name", + border: OutlineInputBorder(), + ), + onChanged: (value) => controller.tableName = value, + ), + const Divider(), + Obx( + () => ListView( + children: controller.columnsDefinition + .map( + (e) => ListTile( + title: Text(e.columnName), + subtitle: Text(e.def), + trailing: IconButton( + onPressed: () => controller.removeColumn(e), + icon: const Icon(Icons.delete), + ), + ), + ) + .toList(), + ).expanded(), + ), + const Divider(), + [ + ElevatedButton( + onPressed: () => controller.createNewColumn(), + child: const Text("Create column"), + ).expanded() + ].toRow(), + ], + ).constrained(width: Get.width * 0.9, height: Get.height * 0.9), + actions: [ + TextButton( + onPressed: () { + Get.back(); + }, + child: const Text('Close'), + ), + Obx( + () => TextButton( + onPressed: controller.columnsDefinition.isEmpty + ? null + : () => controller.createTable(), + child: const Text('Create'), + ), + ), + ], + ); + } + + static Future show() async { + Get.lazyPut(() => CreateTableController()); + + return Get.dialog( + const CreateTableDialog(), + barrierDismissible: false, + ); + } +} diff --git a/lib/pages/home_panels/tables_list_panel.dart b/lib/pages/home_panels/tables_list_panel.dart index 66e70e9..ddc6770 100644 --- a/lib/pages/home_panels/tables_list_panel.dart +++ b/lib/pages/home_panels/tables_list_panel.dart @@ -5,6 +5,7 @@ import 'package:tuuli_api/tuuli_api.dart'; import 'package:tuuli_app/api_controller.dart'; import 'package:recase/recase.dart'; import 'package:tuuli_app/models/db_column_definition.dart'; +import 'package:tuuli_app/pages/dialogs/create_table_dialog.dart'; class TablesListPanelController extends GetxController { @override @@ -54,7 +55,12 @@ class TablesListPanelController extends GetxController { _isLoading.value = false; } - Future createNewTable() async {} + Future createNewTable() async { + final created = await CreateTableDialog.show(); + if (created == true) { + refreshData(); + } + } Future openTable(TableDefinition table) async {} } -- 2.47.3 From 0c14da73dff8e9ed3d36f98f4e12d56b26dd9500 Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Sun, 30 Apr 2023 00:38:50 +0700 Subject: [PATCH 18/28] Pre-fill tables data so they all wont pop-up from thin air --- lib/pages/dialogs/group_acl_dialog.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/pages/dialogs/group_acl_dialog.dart b/lib/pages/dialogs/group_acl_dialog.dart index 6daa5cb..84a188f 100644 --- a/lib/pages/dialogs/group_acl_dialog.dart +++ b/lib/pages/dialogs/group_acl_dialog.dart @@ -32,6 +32,9 @@ class GroupACLController extends GetxController { Future refreshData() async { await refreshTables(); + for (final table in tables) { + _access[table.tableId] = TableAccess.none; + } for (final table in tables) { await refreshTableAccess(table); -- 2.47.3 From dfbea7cb6c52fb95c0d8673c644d7326a174dac1 Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Sun, 30 Apr 2023 17:14:42 +0700 Subject: [PATCH 19/28] Implemented insertion of new items into table --- lib/pages/dialogs/open_table_dialog.dart | 942 +++++++++++++++++++ lib/pages/home_panels/tables_list_panel.dart | 5 +- lib/utils.dart | 35 + lib/widgets/data_input_dialog.dart | 126 +++ 4 files changed, 1107 insertions(+), 1 deletion(-) create mode 100644 lib/pages/dialogs/open_table_dialog.dart create mode 100644 lib/widgets/data_input_dialog.dart diff --git a/lib/pages/dialogs/open_table_dialog.dart b/lib/pages/dialogs/open_table_dialog.dart new file mode 100644 index 0000000..39c8b49 --- /dev/null +++ b/lib/pages/dialogs/open_table_dialog.dart @@ -0,0 +1,942 @@ +import 'package:data_table_2/data_table_2.dart'; +import 'package:dio/dio.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_fast_forms/flutter_fast_forms.dart'; +import 'package:get/get.dart'; +import 'package:omni_datetime_picker/omni_datetime_picker.dart'; +import 'package:recase/recase.dart'; +import 'package:styled_widget/styled_widget.dart'; +import 'package:tuuli_api/tuuli_api.dart'; +import 'package:tuuli_app/api_controller.dart'; +import 'package:tuuli_app/models/db_column_definition.dart'; +import 'package:tuuli_app/models/user_definition.dart'; +import 'package:tuuli_app/utils.dart'; +import 'package:tuuli_app/widgets/data_input_dialog.dart'; + +class OpenTableController extends GetxController { + final TableDefinition table; + + OpenTableController({required this.table}); + + @override + void onInit() { + super.onInit(); + + refreshTableData(); + } + + final _userCache = {}.obs; + UserDefinition? getUserFromCache(int id) { + return _userCache[id]; + } + + void putUserInCache(UserDefinition user) { + _userCache[user.id] = user; + } + + final _assetsCache = {}.obs; + Asset? getAssetFromCache(int id) { + return _assetsCache[id]; + } + + void putAssetInCache(Asset asset) { + _assetsCache[asset.id] = asset; + } + + final _tableData = >[].obs; + List> get tableData => _tableData; + + final _newRowData = {}.obs; + Map get newRowData => _newRowData; + void setNewRowData(String key, dynamic value) { + _newRowData[key] = value; + } + + void clearNewRowData() { + _newRowData.clear(); + } + + Future refreshTableData() async { + try { + final resp = await ApiController.to.apiClient.getItemsFromTable( + tableName: table.tableName, + itemsSelector: const ItemsSelector( + fields: [ + "*", + ], + where: [], + ), + ); + + final respData = resp.data; + if (respData == null) { + throw Exception("No data in response"); + } + + _tableData.clear(); + _tableData.addAll(respData); + } on DioError catch (e) { + final respData = e.response?.data; + if (respData != null) { + Get.snackbar( + "Error trying to get table data", + "${respData['error']}", + ); + } else { + Get.snackbar( + "Error trying to get table data", + "$e", + ); + } + } catch (e) { + Get.snackbar( + "Error trying to get table data", + "$e", + ); + } + } + + Future showUserPicker() async { + final username = "".obs; + + final user = await Get.dialog( + AlertDialog( + title: const Text("Select user"), + content: Column( + mainAxisSize: MainAxisSize.min, + children: [ + TextField( + onChanged: (value) { + username.value = value; + }, + decoration: const InputDecoration( + labelText: "Username", + ), + ), + Obx( + () => FutureBuilder>( + future: () async { + if (username.value.isEmpty) { + return []; + } + + final resp = + await ApiController.to.apiClient.getItemsFromTable( + tableName: "users", + itemsSelector: ItemsSelector( + fields: [ + "id", + "username", + ], + where: [ + ColumnConditionCompat( + column: "username", + operator_: + ColumnConditionCompatOperator.contains, + value: username.value, + ) + ], + )); + + final respData = resp.data; + if (respData == null) { + throw Exception("No data in response"); + } + + return respData + .map((e) => UserDefinition( + id: e["id"], + username: e["username"], + password: "", + accessToken: "", + )) + .toList(growable: false); + }(), + initialData: const [], + builder: (context, snapshot) { + if (snapshot.hasError) { + return Text("${snapshot.error}"); + } + + if (snapshot.connectionState == ConnectionState.waiting) { + return const CircularProgressIndicator(); + } + + final users = snapshot.data!; + + return SingleChildScrollView( + child: Column( + children: [ + for (final user in users) + ListTile( + title: Text(user.username), + onTap: () { + Get.back(result: user); + }, + ), + ], + ), + ); + }, + ), + ), + ], + ), + actions: [ + TextButton( + onPressed: () { + Get.back(result: false); + }, + child: const Text("Cancel"), + ), + ], + ), + ); + + return user; + } + + Future showAssetPicker() async { + final name = "".obs; + + final asset = await Get.dialog( + AlertDialog( + title: const Text("Select asset"), + content: Column( + mainAxisSize: MainAxisSize.min, + children: [ + TextField( + onChanged: (value) { + name.value = value; + }, + decoration: const InputDecoration( + labelText: "Filename", + ), + ), + Obx( + () => FutureBuilder>( + future: () async { + if (name.value.isEmpty) { + return []; + } + + final resp = + await ApiController.to.apiClient.getItemsFromTable( + tableName: "assets", + itemsSelector: ItemsSelector( + fields: [ + "id", + "name", + "description", + ], + where: [ + ColumnConditionCompat( + column: "name", + operator_: + ColumnConditionCompatOperator.contains, + value: name.value, + ) + ], + )); + + final respData = resp.data; + if (respData == null) { + throw Exception("No data in response"); + } + + return respData + .map((e) => Asset( + id: e["id"], + name: e["name"], + description: e["description"], + fid: "", + tags: "", + )) + .toList(growable: false); + }(), + initialData: const [], + builder: (context, snapshot) { + if (snapshot.hasError) { + return Text("${snapshot.error}"); + } + + if (snapshot.connectionState == ConnectionState.waiting) { + return const CircularProgressIndicator(); + } + + final assets = snapshot.data!; + + return SingleChildScrollView( + child: Column( + children: [ + for (final asset in assets) + ListTile( + title: Text(asset.name), + subtitle: Text(asset.description), + onTap: () { + Get.back(result: asset); + }, + ), + ], + ), + ); + }, + ), + ), + ], + ), + actions: [ + TextButton( + onPressed: () { + Get.back(result: null); + }, + child: const Text("Cancel"), + ), + ], + ), + ); + + return asset; + } + + Future addNewRow() async { + try { + final resp = await ApiController.to.apiClient.createItem( + tableName: table.tableName, + itemDefinition: convertToPayload(newRowData), + ); + + final respData = resp.data; + if (respData == null) { + throw Exception("No data in response"); + } + + clearNewRowData(); + refreshTableData(); + } on DioError catch (e) { + final respData = e.response?.data; + if (respData != null) { + Get.snackbar( + "Error trying to get table data", + "${respData['error']}", + ); + } else { + Get.snackbar( + "Error trying to get table data", + "$e", + ); + } + } catch (e) { + Get.snackbar( + "Error trying to get table data", + "$e", + ); + } + } + + Future updateItem( + Map originalItem, + String columnName, + dynamic data, + ) async { + final idCol = table.parsedColumns + .firstWhereOrNull((e) => e is PrimarySerialColumnDefinition); + try { + final resp = await ApiController.to.apiClient.updateItemInTable( + tableName: table.tableName, + itemUpdate: ItemUpdate( + oldItem: idCol == null + ? convertToPayload(originalItem) + : { + idCol.name: originalItem[idCol.name], + }, + item: convertToPayload({columnName: data}), + ), + ); + + final respData = resp.data; + if (respData == null) { + throw Exception("No data in response"); + } + + refreshTableData(); + } on DioError catch (e) { + final respData = e.response?.data; + if (respData != null) { + Get.snackbar( + "Error trying to update table data", + "${respData['error']}", + ); + } else { + Get.snackbar( + "Error trying to update table data", + "$e", + ); + } + } catch (e) { + Get.snackbar( + "Error trying to update table data", + "$e", + ); + } + } + + Future deleteItem(Map e) async { + final idCol = table.parsedColumns + .firstWhereOrNull((e) => e is PrimarySerialColumnDefinition); + try { + final resp = await ApiController.to.apiClient.deleteItemFromTable( + tableName: table.tableName, + columnConditionCompat: [ + if (idCol != null) + ColumnConditionCompat( + column: idCol.name, + operator_: ColumnConditionCompatOperator.eq, + value: e[idCol.name], + ) + else + ...convertToPayload(e).entries.map( + (e) => ColumnConditionCompat( + column: e.key, + operator_: ColumnConditionCompatOperator.eq, + value: e.value, + ), + ), + ], + ); + + final respData = resp.data; + if (respData == null) { + throw Exception("No data in response"); + } + + refreshTableData(); + } on DioError catch (e) { + final respData = e.response?.data; + if (respData != null) { + Get.snackbar( + "Error trying to update table data", + "${respData['error']}", + ); + } else { + Get.snackbar( + "Error trying to update table data", + "$e", + ); + } + } catch (e) { + Get.snackbar( + "Error trying to update table data", + "$e", + ); + } + } +} + +class OpenTableDialog extends GetView { + const OpenTableDialog({super.key}); + + @override + Widget build(BuildContext context) { + return AlertDialog( + title: Row( + children: [ + Text(controller.table.tableName.pascalCase), + const Spacer(), + IconButton( + onPressed: () => controller.refreshTableData(), + icon: const Icon(Icons.refresh), + ), + IconButton( + onPressed: () { + Get.back(); + }, + icon: const Icon(Icons.close), + ), + ], + ), + content: Obx( + () => DataTable2( + columns: [ + for (final col in controller.table.parsedColumns) + DataColumn( + label: Text( + col.name.pascalCase, + ), + ), + const DataColumn(label: Text("Actions")), + ], + empty: const Text("No data"), + rows: [ + DataRow( + cells: [ + for (final col in controller.table.parsedColumns) + if (col is PrimarySerialColumnDefinition) + const DataCell( + Text( + "AUTO", + ), + ) + else if (col is TextColumnDefinition) + DataCell( + Obx( + () => TextField( + controller: TextEditingController( + text: controller.newRowData[col.name] ?? ""), + decoration: InputDecoration( + label: Text(col.name.pascalCase), + ), + onChanged: (value) => controller.setNewRowData( + col.name, + value, + ), + ), + ), + ) + else if (col is BooleanColumnDefinition) + DataCell( + Obx( + () => Row( + children: [ + Checkbox( + value: controller.newRowData[col.name] ?? false, + onChanged: (value) => controller.setNewRowData( + col.name, + value, + ), + ), + ], + ), + ), + ) + else if (col is TimestampColumnDefinition) + DataCell( + Obx( + () => TextField( + controller: TextEditingController( + text: () { + final dt = controller.newRowData[col.name]; + if (dt == null || dt is! DateTime) { + return ""; + } + + return postgresDateFormat(dt); + }(), + ), + decoration: InputDecoration( + label: Text(col.name.pascalCase), + ), + readOnly: true, + onTap: () async { + final dt = await showOmniDateTimePicker( + context: context, + is24HourMode: true, + isForce2Digits: true, + ); + if (dt != null) { + controller.setNewRowData( + col.name, + dt, + ); + } + }, + ), + ), + ) + else if (col is DoubleColumnDefinition) + DataCell( + Obx( + () => TextField( + controller: TextEditingController( + text: (controller.newRowData[col.name] as double?) + ?.toString() ?? + ""), + decoration: InputDecoration( + label: Text(col.name.pascalCase), + ), + onChanged: (value) => controller.setNewRowData( + col.name, + double.tryParse(value), + ), + ), + ), + ) + else if (col is IntegerColumnDefinition) + DataCell( + Obx( + () => TextField( + controller: TextEditingController( + text: (controller.newRowData[col.name] as int?) + ?.toString() ?? + ""), + decoration: InputDecoration( + label: Text(col.name.pascalCase), + ), + onChanged: (value) => controller.setNewRowData( + col.name, + int.tryParse(value), + ), + ), + ), + ) + else if (col is UserRefColumnDefinition) + DataCell(Obx( + () => TextField( + controller: TextEditingController( + text: (controller.newRowData[col.name] + as UserDefinition?) + ?.username ?? + ""), + decoration: InputDecoration( + label: Text(col.name.pascalCase), + ), + readOnly: true, + onTap: () async { + final user = await controller.showUserPicker(); + if (user == null) return; + + controller.setNewRowData( + col.name, + user, + ); + }, + ), + )) + else if (col is AssetRefColumnDefinition) + DataCell(Obx( + () => TextField( + controller: TextEditingController( + text: (controller.newRowData[col.name] as Asset?) + ?.name ?? + ""), + decoration: InputDecoration( + label: Text(col.name.pascalCase), + ), + readOnly: true, + onTap: () async { + final asset = await controller.showAssetPicker(); + if (asset == null) return; + + controller.setNewRowData( + col.name, + asset, + ); + }, + ), + )) + else + DataCell.empty, + DataCell(Row( + children: [ + IconButton( + onPressed: () { + controller.addNewRow(); + }, + icon: const Icon(Icons.add), + ), + IconButton( + onPressed: () => controller.clearNewRowData(), + icon: const Icon(Icons.clear), + ), + ], + )), + ], + ), + ...controller.tableData.map((e) { + return DataRow( + cells: [ + for (final col in controller.table.parsedColumns) + if (col is PrimarySerialColumnDefinition) + DataCell( + Tooltip( + message: e[col.name].toString(), + child: Text( + e[col.name].toString(), + overflow: TextOverflow.ellipsis, + maxLines: 1, + ), + ), + ) + else if (col is TextColumnDefinition) + DataCell( + Tooltip( + message: e[col.name].toString(), + child: Text( + e[col.name].toString(), + overflow: TextOverflow.ellipsis, + maxLines: 1, + ), + ), + onDoubleTap: () async { + final text = await showStringInputDialog( + originalValue: e[col.name].toString()); + if (text != null) { + await controller.updateItem( + e, + col.name, + text, + ); + } + }, + ) + else if (col is BooleanColumnDefinition) + DataCell( + Checkbox( + value: e[col.name], + onChanged: (v) async { + await controller.updateItem( + e, + col.name, + v ?? false, + ); + }, + ), + ) + else if (col is TimestampColumnDefinition) + DataCell( + () { + final msg = () { + final dt = e[col.name]; + if (dt == null) { + return "#error#"; + } + if (dt is String) { + final rdt = DateTime.parse(dt); + return postgresDateFormat(rdt); + } + + return postgresDateFormat(dt); + }(); + return Tooltip( + message: msg, + child: Text( + msg, + overflow: TextOverflow.ellipsis, + maxLines: 1, + ), + ); + }(), + onDoubleTap: () async { + final dt = await showOmniDateTimePicker( + context: context, + is24HourMode: true, + isForce2Digits: true, + ); + if (dt != null) { + await controller.updateItem( + e, + col.name, + dt, + ); + } + }, + ) + else if (col is DoubleColumnDefinition) + DataCell( + Tooltip( + message: e[col.name].toString(), + child: Text( + e[col.name].toString(), + overflow: TextOverflow.ellipsis, + maxLines: 1, + ), + ), + onDoubleTap: () async { + final dblVal = await showDoubleInputDialog( + originalValue: e[col.name]); + if (dblVal != null) { + await controller.updateItem( + e, + col.name, + dblVal, + ); + } + }, + ) + else if (col is IntegerColumnDefinition) + DataCell( + Tooltip( + message: e[col.name].toString(), + child: Text( + e[col.name].toString(), + overflow: TextOverflow.ellipsis, + maxLines: 1, + ), + ), + onDoubleTap: () async { + final intVal = await showIntInputDialog( + originalValue: e[col.name]); + if (intVal != null) { + await controller.updateItem( + e, + col.name, + intVal, + ); + } + }, + ) + else if (col is UserRefColumnDefinition) + DataCell( + FutureBuilder( + future: () async { + final cachedUser = + controller.getUserFromCache(e[col.name]); + if (cachedUser != null) { + return cachedUser.username; + } + + final user = await ApiController.to.apiClient + .getItemsFromTable( + tableName: "users", + itemsSelector: ItemsSelector( + fields: ["username"], + where: [ + ColumnConditionCompat( + column: "id", + operator_: ColumnConditionCompatOperator.eq, + value: e[col.name], + ), + ], + ), + ); + + final ud = user.data; + if (ud == null || + ud.isEmpty || + ud.first["username"] == null) { + return "#error#"; + } + + controller.putUserInCache(UserDefinition( + id: e[col.name], + username: ud.first["username"], + password: "", + accessToken: "", + )); + + return ud.first["username"].toString(); + }(), + builder: (context, snapshot) { + if (snapshot.connectionState == + ConnectionState.waiting) { + return const CircularProgressIndicator(); + } + + return Tooltip( + message: snapshot.data ?? "#error#", + child: Text( + snapshot.data ?? "#error#", + overflow: TextOverflow.ellipsis, + maxLines: 1, + ), + ); + }, + ), + onDoubleTap: () async { + final user = await controller.showUserPicker(); + if (user != null) { + await controller.updateItem( + e, + col.name, + user.id, + ); + } + }, + ) + else if (col is AssetRefColumnDefinition) + DataCell( + FutureBuilder( + future: () async { + final cachedAsset = + controller.getAssetFromCache(e[col.name]); + if (cachedAsset != null) { + return cachedAsset.name; + } + + final asset = await ApiController.to.apiClient + .getItemsFromTable( + tableName: "assets", + itemsSelector: ItemsSelector( + fields: ["name"], + where: [ + ColumnConditionCompat( + column: "id", + operator_: ColumnConditionCompatOperator.eq, + value: e[col.name], + ), + ], + ), + ); + + final ad = asset.data; + if (ad == null || + ad.isEmpty || + ad.first["name"] == null) { + return "#error#"; + } + + controller.putAssetInCache(Asset( + id: e[col.name], + name: ad.first["name"], + description: "", + fid: "", + tags: "", + )); + + return ad.first["name"].toString(); + }(), + builder: (context, snapshot) { + if (snapshot.connectionState == + ConnectionState.waiting) { + return const CircularProgressIndicator(); + } + + return Tooltip( + message: snapshot.data ?? "#error#", + child: Text( + snapshot.data ?? "#error#", + overflow: TextOverflow.ellipsis, + maxLines: 1, + ), + ); + }, + ), + onDoubleTap: () async { + final asset = await controller.showAssetPicker(); + if (asset != null) { + await controller.updateItem( + e, + col.name, + asset.id, + ); + } + }, + ) + else + DataCell.empty, + DataCell(Row( + children: [ + IconButton( + onPressed: () => controller.deleteItem(e), + icon: const Icon(Icons.delete), + ), + ], + )), + ], + ); + }), + ], + ), + ).constrained(width: Get.width * 0.9, height: Get.height * 0.9), + ); + } + + static Future show(TableDefinition table) async { + Get.lazyPut(() => OpenTableController(table: table)); + + await Get.dialog( + const OpenTableDialog(), + barrierDismissible: false, + ); + } +} diff --git a/lib/pages/home_panels/tables_list_panel.dart b/lib/pages/home_panels/tables_list_panel.dart index ddc6770..109c376 100644 --- a/lib/pages/home_panels/tables_list_panel.dart +++ b/lib/pages/home_panels/tables_list_panel.dart @@ -6,6 +6,7 @@ import 'package:tuuli_app/api_controller.dart'; import 'package:recase/recase.dart'; import 'package:tuuli_app/models/db_column_definition.dart'; import 'package:tuuli_app/pages/dialogs/create_table_dialog.dart'; +import 'package:tuuli_app/pages/dialogs/open_table_dialog.dart'; class TablesListPanelController extends GetxController { @override @@ -62,7 +63,9 @@ class TablesListPanelController extends GetxController { } } - Future openTable(TableDefinition table) async {} + Future openTable(TableDefinition table) async { + await OpenTableDialog.show(table); + } } class TablesListPanel extends GetView { diff --git a/lib/utils.dart b/lib/utils.dart index 8aff8fb..19f90bb 100644 --- a/lib/utils.dart +++ b/lib/utils.dart @@ -1,5 +1,8 @@ import 'dart:math'; +import 'package:tuuli_api/tuuli_api.dart'; +import 'package:tuuli_app/models/user_definition.dart'; + Random _random = Random(); String randomHexString(int length) { @@ -9,3 +12,35 @@ String randomHexString(int length) { } return sb.toString(); } + +String postgresDateFormat(DateTime dt) { + int yearSign = dt.year.sign; + int absYear = dt.year.abs(); + String y = absYear + .toString() + .padLeft((dt.year >= -9999 && dt.year <= 9999) ? 4 : 6, "0"); + if (yearSign == -1) { + y = "-$y"; + } + String m = dt.month.toString().padLeft(2, "0"); + String d = dt.day.toString().padLeft(2, "0"); + String h = dt.hour.toString().padLeft(2, "0"); + String min = dt.minute.toString().padLeft(2, "0"); + String sec = dt.second.toString().padLeft(2, "0"); + + return "$y-$m-$d $h:$min:$sec"; +} + +Map convertToPayload(Map data) { + return data.map((key, value) { + if (value is UserDefinition) { + return MapEntry(key, value.id); + } else if (value is Asset) { + return MapEntry(key, value.id); + } else if (value is DateTime) { + return MapEntry(key, postgresDateFormat(value)); + } + + return MapEntry(key, value); + }); +} diff --git a/lib/widgets/data_input_dialog.dart b/lib/widgets/data_input_dialog.dart new file mode 100644 index 0000000..c406d9c --- /dev/null +++ b/lib/widgets/data_input_dialog.dart @@ -0,0 +1,126 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_fast_forms/flutter_fast_forms.dart'; +import 'package:get/get.dart'; + +Future showStringInputDialog({String? originalValue}) async { + final strVal = (originalValue ?? "").obs; + return await Get.dialog( + AlertDialog( + title: const Text("Enter a string"), + content: TextField( + controller: TextEditingController(text: originalValue), + onChanged: (value) { + strVal.value = value; + }, + ), + actions: [ + TextButton( + onPressed: () { + Get.back(result: null); + }, + child: const Text("Cancel"), + ), + TextButton( + onPressed: () { + Get.back(result: strVal.value); + }, + child: const Text("OK"), + ), + ], + ), + ); +} + +Future showDoubleInputDialog({double? originalValue}) async { + final strVal = (originalValue?.toString() ?? "").obs; + return await Get.dialog( + AlertDialog( + title: const Text("Enter a number"), + content: FastTextField( + name: "Number", + initialValue: originalValue?.toString(), + keyboardType: TextInputType.number, + autovalidateMode: AutovalidateMode.onUserInteraction, + validator: (value) { + if (value == null || value.isEmpty) { + return "Please enter a number"; + } + final parsed = double.tryParse(value); + if (parsed == null) { + return "Please enter a valid number"; + } + return null; + }, + onChanged: (value) { + strVal.value = value ?? ""; + }, + ), + actions: [ + TextButton( + onPressed: () { + Get.back(result: null); + }, + child: const Text("Cancel"), + ), + TextButton( + onPressed: () { + final d = double.tryParse(strVal.value); + if (d != null) { + Get.back(result: d); + } else { + Get.back(result: null); + } + }, + child: const Text("OK"), + ), + ], + ), + ); +} + +Future showIntInputDialog({int? originalValue}) async { + final strVal = (originalValue?.toString() ?? "").obs; + return await Get.dialog( + AlertDialog( + title: const Text("Enter a number"), + content: FastTextField( + name: "Number", + initialValue: originalValue?.toString(), + keyboardType: TextInputType.number, + autovalidateMode: AutovalidateMode.onUserInteraction, + validator: (value) { + if (value == null || value.isEmpty) { + return "Please enter a number"; + } + final parsed = int.tryParse(value); + if (parsed == null) { + return "Please enter a valid number"; + } + return null; + }, + onChanged: (value) { + strVal.value = value ?? ""; + }, + ), + actions: [ + TextButton( + onPressed: () { + Get.back(result: null); + }, + child: const Text("Cancel"), + ), + TextButton( + onPressed: () { + final i = int.tryParse(strVal.value); + if (i != null) { + Get.back(result: i); + } else { + Get.back(result: null); + } + }, + child: const Text("OK"), + ), + ], + ), + ); +} -- 2.47.3 From de719679db2fe97916118ebf080c2e75c4efcf09 Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Sun, 30 Apr 2023 18:22:06 +0700 Subject: [PATCH 20/28] Added asset type resolving and preview for images --- lib/pages/home_panels/assets_panel.dart | 164 ++++++++++++++++++++++++ 1 file changed, 164 insertions(+) diff --git a/lib/pages/home_panels/assets_panel.dart b/lib/pages/home_panels/assets_panel.dart index f011029..82c828d 100644 --- a/lib/pages/home_panels/assets_panel.dart +++ b/lib/pages/home_panels/assets_panel.dart @@ -1,8 +1,13 @@ +import 'dart:convert'; +import 'dart:typed_data'; + import 'package:data_table_2/data_table_2.dart'; import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter_fast_forms/flutter_fast_forms.dart'; import 'package:get/get.dart' hide MultipartFile; +import 'package:mime/mime.dart'; +import 'package:photo_view/photo_view.dart'; import 'package:styled_widget/styled_widget.dart'; import 'package:super_drag_and_drop/super_drag_and_drop.dart'; import 'package:tuuli_api/tuuli_api.dart'; @@ -252,6 +257,95 @@ class AssetsPagePanelController extends GetxController { .toList(growable: false), ).paddingAll(8).card(color: Colors.blueGrey.shade200).expanded(), ), + ElevatedButton( + onPressed: () { + Get.dialog( + Stack( + children: [ + FutureBuilder( + future: () async { + final resp = await ApiController.to.apiClient + .getAsset(fid: e.fid); + + final respData = resp.data; + if (respData == null) { + throw Exception("No data in response"); + } + + return respData; + }(), + builder: (context, snapshot) { + if (snapshot.connectionState == + ConnectionState.waiting) { + return const CircularProgressIndicator(); + } + + if (snapshot.hasError) { + printError(info: snapshot.error.toString()); + return const Icon(Icons.error); + } + + if (snapshot.hasData && snapshot.data == null) { + return const Icon(Icons.error); + } + + final data = snapshot.data!; + final mime = lookupMimeType( + "file", + headerBytes: data, + ); + switch (mime) { + case "image/gif": + case "image/gif": + case "image/jpeg": + case "image/png": + case "image/tiff": + case "image/webp": + return PhotoView( + imageProvider: MemoryImage(data), + enablePanAlways: true, + ); + case "application/pdf": + case "application/postscript": + return const Icon(Icons.picture_as_pdf); + case "application/zip": + case "application/x-rar-compressed": + return const Icon(Icons.archive); + case "audio/x-aiff": + case "audio/x-flac": + case "audio/x-wav": + case "audio/aac": + case "audio/aac": + case "audio/weba": + case "audio/mpeg": + case "audio/mpeg": + case "audio/ogg": + return const Icon(Icons.audiotrack); + case "video/mp4": + return const Icon(Icons.movie); + case "model/gltf-binary": + case "font/woff2": + default: + return const Icon(Icons.device_unknown); + } + }, + ).center(), + Positioned( + top: 8, + right: 8, + child: Material( + color: Colors.transparent, + child: IconButton( + onPressed: () => Get.back(), + icon: const Icon(Icons.close), + ), + ), + ), + ], + ), + ); + }, + child: const Text("View asset")), ], ).constrained(width: Get.width * 0.5, height: Get.width * 0.5), actions: [ @@ -449,6 +543,7 @@ class AssetsPagePanel extends GetView { Widget get assetsPanel => Obx( () => DataTable2( columns: const [ + DataColumn2(label: Text(""), size: ColumnSize.S), DataColumn2(label: Text("ID"), size: ColumnSize.S, numeric: true), DataColumn2(label: Text("Filename"), size: ColumnSize.M), DataColumn2(label: Text("Description"), size: ColumnSize.L), @@ -467,6 +562,75 @@ class AssetsPagePanel extends GetView { }) .map((e) => DataRow2( cells: [ + DataCell( + FutureBuilder( + future: () async { + final resp = await ApiController.to.apiClient + .getAsset(fid: e.fid); + + final respData = resp.data; + if (respData == null) { + throw Exception("No data in response"); + } + + return respData; + }(), + builder: (context, snapshot) { + if (snapshot.connectionState == + ConnectionState.waiting) { + return const CircularProgressIndicator(); + } + + if (snapshot.hasError) { + printError(info: snapshot.error.toString()); + return const Icon(Icons.error); + } + + if (snapshot.hasData && snapshot.data == null) { + return const Icon(Icons.error); + } + + final data = snapshot.data!; + final mime = lookupMimeType( + "file", + headerBytes: data, + ); + switch (mime) { + case "image/gif": + case "image/gif": + case "image/jpeg": + case "image/png": + case "image/tiff": + case "image/webp": + return Image.memory(data).card( + clipBehavior: Clip.antiAlias, + ); + case "application/pdf": + case "application/postscript": + return const Icon(Icons.picture_as_pdf); + case "application/zip": + case "application/x-rar-compressed": + return const Icon(Icons.archive); + case "audio/x-aiff": + case "audio/x-flac": + case "audio/x-wav": + case "audio/aac": + case "audio/aac": + case "audio/weba": + case "audio/mpeg": + case "audio/mpeg": + case "audio/ogg": + return const Icon(Icons.audiotrack); + case "video/mp4": + return const Icon(Icons.movie); + case "model/gltf-binary": + case "font/woff2": + default: + return const Icon(Icons.device_unknown); + } + }, + ), + ), DataCell(Text(e.id.toString())), DataCell(Tooltip( message: e.name, -- 2.47.3 From e8ffece33ca05399ac39b345b2aeaa4494888dba Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Sun, 30 Apr 2023 18:49:09 +0700 Subject: [PATCH 21/28] Update caused by API lib update --- lib/pages/dialogs/open_table_dialog.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/pages/dialogs/open_table_dialog.dart b/lib/pages/dialogs/open_table_dialog.dart index 39c8b49..ceb6cd0 100644 --- a/lib/pages/dialogs/open_table_dialog.dart +++ b/lib/pages/dialogs/open_table_dialog.dart @@ -251,6 +251,7 @@ class OpenTableController extends GetxController { description: e["description"], fid: "", tags: "", + mime: "", )) .toList(growable: false); }(), @@ -881,6 +882,7 @@ class OpenTableDialog extends GetView { description: "", fid: "", tags: "", + mime: "", )); return ad.first["name"].toString(); -- 2.47.3 From 597258e5211d0eed07fa81e71ac9a0ab4856fe16 Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Sun, 30 Apr 2023 18:49:25 +0700 Subject: [PATCH 22/28] Libs update --- pubspec.lock | 30 +++++++++++++++++++++++++++--- pubspec.yaml | 4 ++++ 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/pubspec.lock b/pubspec.lock index bb0d9b6..0936d81 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -449,13 +449,21 @@ packages: source: hosted version: "1.9.0" mime: - dependency: transitive + dependency: "direct main" description: name: mime sha256: e4ff8e8564c03f255408decd16e7899da1733852a9110a58fe6d1b817684a63e url: "https://pub.dev" source: hosted version: "1.0.4" + omni_datetime_picker: + dependency: "direct main" + description: + name: omni_datetime_picker + sha256: c70ca19eba89b7ed3663ae8eab2e7922c12b443826cf06c841a7f0a19e22870d + url: "https://pub.dev" + source: hosted + version: "1.0.7" one_of: dependency: transitive description: @@ -536,6 +544,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.6" + photo_view: + dependency: "direct main" + description: + name: photo_view + sha256: "8036802a00bae2a78fc197af8a158e3e2f7b500561ed23b4c458107685e645bb" + url: "https://pub.dev" + source: hosted + version: "0.14.0" platform: dependency: transitive description: @@ -781,15 +797,23 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.1" + tuple: + dependency: "direct main" + description: + name: tuple + sha256: "0ea99cd2f9352b2586583ab2ce6489d1f95a5f6de6fb9492faaf97ae2060f0aa" + url: "https://pub.dev" + source: hosted + version: "2.0.1" tuuli_api: dependency: "direct main" description: path: "." ref: master - resolved-ref: "116030611798bdb81a19c2504f1ad7adb6547725" + resolved-ref: eedd7a336d42a455a9d46ca203b0d52e920c27bf url: "https://glab.nuark.xyz/nuark/tuuli_api.git" source: git - version: "1.0.1" + version: "1.0.2" typed_data: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index a33775e..5a47417 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -21,11 +21,15 @@ dependencies: get: ^4.6.5 get_storage: ^2.1.1 http: ^0.13.5 + mime: ^1.0.4 + omni_datetime_picker: ^1.0.7 one_of_serializer: ^1.5.0 + photo_view: ^0.14.0 recase: ^4.1.0 shared_preferences: ^2.1.0 styled_widget: ^0.4.1 super_drag_and_drop: ^0.3.0+2 + tuple: ^2.0.1 tuuli_api: git: url: https://glab.nuark.xyz/nuark/tuuli_api.git -- 2.47.3 From 255ff6e801f3d80eb9c7e8555f968989852c6325 Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Mon, 1 May 2023 01:55:04 +0700 Subject: [PATCH 23/28] Some windows shit --- windows/flutter/generated_plugin_registrant.cc | 3 +++ windows/flutter/generated_plugins.cmake | 1 + 2 files changed, 4 insertions(+) diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index 94564b6..842ecd9 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -6,10 +6,13 @@ #include "generated_plugin_registrant.h" +#include #include #include void RegisterPlugins(flutter::PluginRegistry* registry) { + AudioplayersWindowsPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("AudioplayersWindowsPlugin")); IrondashEngineContextPluginCApiRegisterWithRegistrar( registry->GetRegistrarForPlugin("IrondashEngineContextPluginCApi")); SuperNativeExtensionsPluginCApiRegisterWithRegistrar( diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index 607cf1f..a6bba34 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -3,6 +3,7 @@ # list(APPEND FLUTTER_PLUGIN_LIST + audioplayers_windows irondash_engine_context super_native_extensions ) -- 2.47.3 From a4ab10db17353a235e4be33a91abf78e3e7b4f0f Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Mon, 1 May 2023 01:55:25 +0700 Subject: [PATCH 24/28] No more animated background --- lib/pages/not_found_page.dart | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/lib/pages/not_found_page.dart b/lib/pages/not_found_page.dart index 3f46a93..f92fe21 100644 --- a/lib/pages/not_found_page.dart +++ b/lib/pages/not_found_page.dart @@ -1,4 +1,3 @@ -import 'package:animated_background/animated_background.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; @@ -14,14 +13,10 @@ class _NotFoundPageState extends State @override Widget build(BuildContext context) { return Scaffold( - body: AnimatedBackground( - behaviour: RandomParticleBehaviour(), - vsync: this, - child: Center( - child: Text( - 'Page not found', - style: Theme.of(context).textTheme.headlineMedium, - ), + body: Center( + child: Text( + 'Page not found', + style: Theme.of(context).textTheme.headlineMedium, ), ), bottomSheet: Container( -- 2.47.3 From bce8e97368eb25265ac5e85c376df0d5c40c6043 Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Mon, 1 May 2023 01:55:45 +0700 Subject: [PATCH 25/28] Preview for audio and images, better asset table --- lib/pages/home_panels/assets_panel.dart | 212 ++++++------------------ lib/widgets/audio_player_widget.dart | 72 ++++++++ pubspec.lock | 80 ++++++++- pubspec.yaml | 5 +- 4 files changed, 196 insertions(+), 173 deletions(-) create mode 100644 lib/widgets/audio_player_widget.dart diff --git a/lib/pages/home_panels/assets_panel.dart b/lib/pages/home_panels/assets_panel.dart index 82c828d..9b24c1a 100644 --- a/lib/pages/home_panels/assets_panel.dart +++ b/lib/pages/home_panels/assets_panel.dart @@ -1,18 +1,16 @@ -import 'dart:convert'; -import 'dart:typed_data'; - import 'package:data_table_2/data_table_2.dart'; import 'package:dio/dio.dart'; +import 'package:file_icon/file_icon.dart'; import 'package:flutter/material.dart'; import 'package:flutter_fast_forms/flutter_fast_forms.dart'; import 'package:get/get.dart' hide MultipartFile; -import 'package:mime/mime.dart'; import 'package:photo_view/photo_view.dart'; import 'package:styled_widget/styled_widget.dart'; import 'package:super_drag_and_drop/super_drag_and_drop.dart'; import 'package:tuuli_api/tuuli_api.dart'; import 'package:tuuli_app/api_controller.dart'; import 'package:http_parser/http_parser.dart'; +import 'package:tuuli_app/widgets/audio_player_widget.dart'; class AssetsPagePanelController extends GetxController { @override @@ -22,6 +20,8 @@ class AssetsPagePanelController extends GetxController { refreshData(); } + final scrollController = ScrollController(); + final _isLoading = false.obs; bool get isLoading => _isLoading.value; @@ -258,93 +258,7 @@ class AssetsPagePanelController extends GetxController { ).paddingAll(8).card(color: Colors.blueGrey.shade200).expanded(), ), ElevatedButton( - onPressed: () { - Get.dialog( - Stack( - children: [ - FutureBuilder( - future: () async { - final resp = await ApiController.to.apiClient - .getAsset(fid: e.fid); - - final respData = resp.data; - if (respData == null) { - throw Exception("No data in response"); - } - - return respData; - }(), - builder: (context, snapshot) { - if (snapshot.connectionState == - ConnectionState.waiting) { - return const CircularProgressIndicator(); - } - - if (snapshot.hasError) { - printError(info: snapshot.error.toString()); - return const Icon(Icons.error); - } - - if (snapshot.hasData && snapshot.data == null) { - return const Icon(Icons.error); - } - - final data = snapshot.data!; - final mime = lookupMimeType( - "file", - headerBytes: data, - ); - switch (mime) { - case "image/gif": - case "image/gif": - case "image/jpeg": - case "image/png": - case "image/tiff": - case "image/webp": - return PhotoView( - imageProvider: MemoryImage(data), - enablePanAlways: true, - ); - case "application/pdf": - case "application/postscript": - return const Icon(Icons.picture_as_pdf); - case "application/zip": - case "application/x-rar-compressed": - return const Icon(Icons.archive); - case "audio/x-aiff": - case "audio/x-flac": - case "audio/x-wav": - case "audio/aac": - case "audio/aac": - case "audio/weba": - case "audio/mpeg": - case "audio/mpeg": - case "audio/ogg": - return const Icon(Icons.audiotrack); - case "video/mp4": - return const Icon(Icons.movie); - case "model/gltf-binary": - case "font/woff2": - default: - return const Icon(Icons.device_unknown); - } - }, - ).center(), - Positioned( - top: 8, - right: 8, - child: Material( - color: Colors.transparent, - child: IconButton( - onPressed: () => Get.back(), - icon: const Icon(Icons.close), - ), - ), - ), - ], - ), - ); - }, + onPressed: () => previewAsset(e), child: const Text("View asset")), ], ).constrained(width: Get.width * 0.5, height: Get.width * 0.5), @@ -473,6 +387,43 @@ class AssetsPagePanelController extends GetxController { ); } } + + void previewAsset(Asset e) { + Get.dialog( + Stack( + children: [ + if (e.mime.split("/").first == "image") + PhotoView( + imageProvider: + NetworkImage("${ApiController.to.endPoint}/assets/${e.fid}"), + enablePanAlways: true, + ) + else if (e.mime.split("/").first == "audio") + AudioPlayerWidget.create( + title: e.name, + url: "${ApiController.to.endPoint}/assets/${e.fid}", + ) + else + const Text("Unsupported media type") + .fontSize(16) + .paddingAll(8) + .card() + .center(), + Positioned( + top: 8, + right: 8, + child: Material( + color: Colors.transparent, + child: IconButton( + onPressed: () => Get.back(), + icon: const Icon(Icons.close), + ), + ), + ), + ], + ), + ); + } } class AssetsPagePanel extends GetView { @@ -542,9 +493,9 @@ class AssetsPagePanel extends GetView { Widget get assetsPanel => Obx( () => DataTable2( + horizontalScrollController: controller.scrollController, columns: const [ - DataColumn2(label: Text(""), size: ColumnSize.S), - DataColumn2(label: Text("ID"), size: ColumnSize.S, numeric: true), + DataColumn2(label: Text(""), fixedWidth: 16), DataColumn2(label: Text("Filename"), size: ColumnSize.M), DataColumn2(label: Text("Description"), size: ColumnSize.L), DataColumn2(label: Text("File ID"), size: ColumnSize.M), @@ -562,76 +513,7 @@ class AssetsPagePanel extends GetView { }) .map((e) => DataRow2( cells: [ - DataCell( - FutureBuilder( - future: () async { - final resp = await ApiController.to.apiClient - .getAsset(fid: e.fid); - - final respData = resp.data; - if (respData == null) { - throw Exception("No data in response"); - } - - return respData; - }(), - builder: (context, snapshot) { - if (snapshot.connectionState == - ConnectionState.waiting) { - return const CircularProgressIndicator(); - } - - if (snapshot.hasError) { - printError(info: snapshot.error.toString()); - return const Icon(Icons.error); - } - - if (snapshot.hasData && snapshot.data == null) { - return const Icon(Icons.error); - } - - final data = snapshot.data!; - final mime = lookupMimeType( - "file", - headerBytes: data, - ); - switch (mime) { - case "image/gif": - case "image/gif": - case "image/jpeg": - case "image/png": - case "image/tiff": - case "image/webp": - return Image.memory(data).card( - clipBehavior: Clip.antiAlias, - ); - case "application/pdf": - case "application/postscript": - return const Icon(Icons.picture_as_pdf); - case "application/zip": - case "application/x-rar-compressed": - return const Icon(Icons.archive); - case "audio/x-aiff": - case "audio/x-flac": - case "audio/x-wav": - case "audio/aac": - case "audio/aac": - case "audio/weba": - case "audio/mpeg": - case "audio/mpeg": - case "audio/ogg": - return const Icon(Icons.audiotrack); - case "video/mp4": - return const Icon(Icons.movie); - case "model/gltf-binary": - case "font/woff2": - default: - return const Icon(Icons.device_unknown); - } - }, - ), - ), - DataCell(Text(e.id.toString())), + DataCell(FileIcon(e.name)), DataCell(Tooltip( message: e.name, child: Text( @@ -665,6 +547,10 @@ class AssetsPagePanel extends GetView { ), )), DataCell(Row(children: [ + IconButton( + icon: const Icon(Icons.preview), + onPressed: () => controller.previewAsset(e), + ), IconButton( icon: const Icon(Icons.edit), onPressed: () => controller.editAsset(e), diff --git a/lib/widgets/audio_player_widget.dart b/lib/widgets/audio_player_widget.dart new file mode 100644 index 0000000..64c5751 --- /dev/null +++ b/lib/widgets/audio_player_widget.dart @@ -0,0 +1,72 @@ +import 'package:audioplayers/audioplayers.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:styled_widget/styled_widget.dart'; + +class AudioPlayerWidgetController extends GetxController { + final String title; + final String url; + + AudioPlayerWidgetController({ + required this.title, + required this.url, + }); + + @override + void onInit() { + super.onInit(); + + player = AudioPlayer(); + player.play(UrlSource(url)); + + player.onPlayerStateChanged.listen((event) { + _playerState.value = event; + }); + } + + @override + void onClose() { + player.dispose(); + super.onClose(); + } + + late AudioPlayer player; + + final _playerState = PlayerState.stopped.obs; + get playerState => _playerState.value; +} + +class AudioPlayerWidget extends GetView { + const AudioPlayerWidget({super.key}); + + @override + Widget build(BuildContext context) { + return ListTile( + leading: Obx( + () => controller.playerState == PlayerState.playing + ? IconButton( + onPressed: () => controller.player.pause(), + icon: const Icon(Icons.pause), + ) + : IconButton( + onPressed: () => controller.player.resume(), + icon: const Icon(Icons.play_arrow), + ), + ), + title: const Text("Playing"), + subtitle: Text(controller.title), + ).card().paddingAll(16).center(); + } + + static AudioPlayerWidget create( + {required String url, required String title}) { + Get.lazyPut( + () => AudioPlayerWidgetController( + title: title, + url: url, + ), + ); + + return const AudioPlayerWidget(); + } +} diff --git a/pubspec.lock b/pubspec.lock index 0936d81..860577d 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -17,14 +17,6 @@ packages: url: "https://pub.dev" source: hosted version: "5.11.1" - animated_background: - dependency: "direct main" - description: - name: animated_background - sha256: "24b05a6dca2cb0231b011f9e8fd2e9d8060faac08a78cf0643915bb7d6e9b03b" - url: "https://pub.dev" - source: hosted - version: "2.0.0" args: dependency: transitive description: @@ -41,6 +33,62 @@ packages: url: "https://pub.dev" source: hosted version: "2.10.0" + audioplayers: + dependency: "direct main" + description: + name: audioplayers + sha256: "6063c05f987596ba7a3dad9bb9a5d8adfa5e7c07b9bae5301b27c11d0b3a239f" + url: "https://pub.dev" + source: hosted + version: "4.0.1" + audioplayers_android: + dependency: transitive + description: + name: audioplayers_android + sha256: fb6bca878ad175d8f6ddc0e0a2d4226d81fa7c10747c12db420e96c7a096b2cc + url: "https://pub.dev" + source: hosted + version: "3.0.1" + audioplayers_darwin: + dependency: transitive + description: + name: audioplayers_darwin + sha256: c4a56c49347b2e85ac4e1efea218948ca0fba87f04d2a3d3de07ce2410037038 + url: "https://pub.dev" + source: hosted + version: "4.0.1" + audioplayers_linux: + dependency: transitive + description: + name: audioplayers_linux + sha256: "897e24f190232a3fbb88134b062aa83a9240f55789b5e8d17c114283284ef56b" + url: "https://pub.dev" + source: hosted + version: "2.0.1" + audioplayers_platform_interface: + dependency: transitive + description: + name: audioplayers_platform_interface + sha256: "3a90a46198d375fc7d47bc1d3070c8fd8863b6469b7d87ca80f953efb090f976" + url: "https://pub.dev" + source: hosted + version: "5.0.0" + audioplayers_web: + dependency: transitive + description: + name: audioplayers_web + sha256: "4f5dcbfec0bf98ea09e243d5f5b64ea43a4e6710a2f292724bed16cdba3c691e" + url: "https://pub.dev" + source: hosted + version: "3.0.1" + audioplayers_windows: + dependency: transitive + description: + name: audioplayers_windows + sha256: "010f575653c01ccbe9756050b18df83d89426740e04b684f6438aa26c775a965" + url: "https://pub.dev" + source: hosted + version: "2.0.1" boolean_selector: dependency: transitive description: @@ -241,6 +289,14 @@ packages: url: "https://pub.dev" source: hosted version: "6.1.4" + file_icon: + dependency: "direct main" + description: + name: file_icon + sha256: c46b6c24d9595d18995758b90722865baeda407f56308eadd757e1ab913f50a1 + url: "https://pub.dev" + source: hosted + version: "1.0.0" fixnum: dependency: transitive description: @@ -773,6 +829,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.3.0+2" + synchronized: + dependency: transitive + description: + name: synchronized + sha256: "5fcbd27688af6082f5abd611af56ee575342c30e87541d0245f7ff99faa02c60" + url: "https://pub.dev" + source: hosted + version: "3.1.0" term_glyph: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 5a47417..79c95a6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -10,17 +10,19 @@ dependencies: flutter: sdk: flutter - animated_background: ^2.0.0 + audioplayers: ^4.0.1 bottom_sheet: ^3.1.2 built_collection: ^5.1.1 built_value: ^8.4.4 data_table_2: ^2.4.2 dio: ^5.1.1 + file_icon: ^1.0.0 flutter_chips_input: ^2.0.0 flutter_fast_forms: ^10.0.0 get: ^4.6.5 get_storage: ^2.1.1 http: ^0.13.5 + http_parser: ^4.0.2 mime: ^1.0.4 omni_datetime_picker: ^1.0.7 one_of_serializer: ^1.5.0 @@ -34,7 +36,6 @@ dependencies: git: url: https://glab.nuark.xyz/nuark/tuuli_api.git ref: master - http_parser: ^4.0.2 dev_dependencies: flutter_test: -- 2.47.3 From b755d609392b3e02dcd9beabd3215924ae879388 Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Mon, 8 May 2023 12:21:31 +0700 Subject: [PATCH 26/28] Added endpoint field on login page --- lib/api_controller.dart | 5 ++--- lib/pages/login_page.dart | 30 ++++++++++++++++++++++++++---- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/lib/api_controller.dart b/lib/api_controller.dart index 4dafa6f..0c3558d 100644 --- a/lib/api_controller.dart +++ b/lib/api_controller.dart @@ -8,9 +8,8 @@ class ApiController extends GetxController { final apiStorageBox = GetStorage(); - final _endPoint = "http://127.0.0.1:8000".obs; - String get endPoint => _endPoint.value; - set endPoint(String value) => _endPoint.value = value; + String get endPoint => apiStorageBox.read("endPoint") ?? ""; + set endPoint(String value) => apiStorageBox.write("endPoint", value); String get token => apiStorageBox.read("accessToken") ?? ""; set token(String value) => apiStorageBox.write("accessToken", value); diff --git a/lib/pages/login_page.dart b/lib/pages/login_page.dart index d774e1d..d51f9e9 100644 --- a/lib/pages/login_page.dart +++ b/lib/pages/login_page.dart @@ -7,6 +7,10 @@ import 'package:tuuli_api/tuuli_api.dart'; import 'package:tuuli_app/api_controller.dart'; class LoginPageController extends GetxController { + final _endpoint = ApiController.to.endPoint.obs; + String get endpoint => _endpoint.value; + set endpoint(String value) => _endpoint.value = value; + final _username = "".obs; String get username => _username.value; set username(String value) => _username.value = value; @@ -19,12 +23,14 @@ class LoginPageController extends GetxController { bool get submitted => _submitted.value; set submitted(bool value) => _submitted.value = value; - bool get isFormValid => username.isNotEmpty && password.isNotEmpty; + bool get isFormValid => + endpoint.isNotEmpty && username.isNotEmpty && password.isNotEmpty; Future submitForm() async { submitted = true; if (isFormValid) { try { + ApiController.to.endPoint = endpoint; final resp = await ApiController.to.apiClient.getAccessToken( authModel: AuthModel( username: username, @@ -100,6 +106,21 @@ class LoginPage extends GetView { mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, children: [ + TextFormField( + enabled: !controller.submitted, + decoration: const InputDecoration( + labelText: 'Endpoint', + hintText: 'Enter Tuuli Endpoint', + ), + initialValue: ApiController.to.endPoint, + onChanged: (value) => controller.endpoint = value, + validator: (value) { + if (value == null || value.isEmpty) { + return 'Please enter Tuuli Endpoint'; + } + return null; + }, + ), TextFormField( enabled: !controller.submitted, decoration: const InputDecoration( @@ -131,9 +152,10 @@ class LoginPage extends GetView { ), const SizedBox(height: 16), ElevatedButton( - onPressed: controller.submitted - ? null - : () => controller.submitForm(), + onPressed: + !controller.isFormValid || controller.submitted + ? null + : () => controller.submitForm(), child: const Text('Login'), ), ], -- 2.47.3 From 0c1b4eb885b9c022d6d8824a071a10452276497a Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Mon, 8 May 2023 12:26:52 +0700 Subject: [PATCH 27/28] Added tooltip to delete user button if user is admin --- lib/pages/home_panels/users_list_panel.dart | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/pages/home_panels/users_list_panel.dart b/lib/pages/home_panels/users_list_panel.dart index 161ad6f..5624918 100644 --- a/lib/pages/home_panels/users_list_panel.dart +++ b/lib/pages/home_panels/users_list_panel.dart @@ -799,16 +799,28 @@ class UsersListPanel extends GetView { final isAdmin = adminList.any((element) => element.id == user.id); - if (isAdmin) return const SizedBox(); - return ElevatedButton.icon( + final isCurrentUser = + user.accessToken == ApiController.to.token; + if (isCurrentUser) return const SizedBox(); + + final btn = ElevatedButton.icon( onPressed: () => controller.deleteUser(user), icon: const Icon(Icons.delete_forever), label: const Text("Delete user"), style: ElevatedButton.styleFrom( backgroundColor: Colors.redAccent, ), - ).paddingAll(8).expanded(); + ); + + if (isAdmin) { + return Tooltip( + message: "Please note that this user is an admin", + child: btn, + ).paddingAll(8).expanded(); + } + + return btn.paddingAll(8).expanded(); }, ), ], -- 2.47.3 From 68936e398ac5a0222b283fa33637b24915469a70 Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Mon, 8 May 2023 12:48:28 +0700 Subject: [PATCH 28/28] Added delete table button --- lib/pages/home_panels/tables_list_panel.dart | 44 +++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/lib/pages/home_panels/tables_list_panel.dart b/lib/pages/home_panels/tables_list_panel.dart index 109c376..90987bd 100644 --- a/lib/pages/home_panels/tables_list_panel.dart +++ b/lib/pages/home_panels/tables_list_panel.dart @@ -66,6 +66,43 @@ class TablesListPanelController extends GetxController { Future openTable(TableDefinition table) async { await OpenTableDialog.show(table); } + + Future deleteTable(TableDefinition table) async { + try { + final resp = await ApiController.to.apiClient.dropTable( + tableName: table.tableName, + ); + + final respData = resp.data; + if (respData == null) { + throw Exception("No data in response"); + } + + Get.snackbar( + "Table deleted", + "${table.tableName.pascalCase} was deleted", + ); + refreshData(); + } on DioError catch (e) { + final respData = e.response?.data; + if (respData != null) { + Get.snackbar( + "Error trying to delete table", + "${respData['error']}", + ); + } else { + Get.snackbar( + "Error trying to delete table", + "$e", + ); + } + } catch (e) { + Get.snackbar( + "Error trying to delete table", + "$e", + ); + } + } } class TablesListPanel extends GetView { @@ -181,7 +218,12 @@ class TablesListPanel extends GetView { ), ), ], - ) + ), + if (!table.system) + ElevatedButton( + onPressed: () => controller.deleteTable(table), + child: const Text("Delete"), + ).paddingOnly(top: 8) ], ), ), -- 2.47.3