Health check
This commit is contained in:
parent
39ce7acb7f
commit
000111ff2d
|
|
@ -295,13 +295,15 @@ abstract class CompanyEntity extends Object
|
|||
|
||||
bool get hasCustomSurcharge =>
|
||||
hasCustomField(CustomFieldType.surcharge1) ||
|
||||
hasCustomField(CustomFieldType.surcharge2) ||
|
||||
hasCustomField(CustomFieldType.surcharge3) ||
|
||||
hasCustomField(CustomFieldType.surcharge4);
|
||||
hasCustomField(CustomFieldType.surcharge2) ||
|
||||
hasCustomField(CustomFieldType.surcharge3) ||
|
||||
hasCustomField(CustomFieldType.surcharge4);
|
||||
|
||||
String getCustomFieldLabel(String field) {
|
||||
if (customFields.containsKey(field)) {
|
||||
return customFields[field].split('|').first;
|
||||
return customFields[field]
|
||||
.split('|')
|
||||
.first;
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
|
|
@ -309,7 +311,9 @@ abstract class CompanyEntity extends Object
|
|||
|
||||
String getCustomFieldType(String field) {
|
||||
if ((customFields[field] ?? '').contains('|')) {
|
||||
final value = customFields[field].split('|').last;
|
||||
final value = customFields[field]
|
||||
.split('|')
|
||||
.last;
|
||||
if ([kFieldTypeSingleLineText, kFieldTypeDate, kFieldTypeSwitch]
|
||||
.contains(value)) {
|
||||
return value;
|
||||
|
|
@ -346,7 +350,9 @@ abstract class CompanyEntity extends Object
|
|||
}
|
||||
|
||||
// TODO make sure to clear everything
|
||||
CompanyEntity get coreCompany => rebuild((b) => b
|
||||
CompanyEntity get coreCompany =>
|
||||
rebuild((b) =>
|
||||
b
|
||||
..clients.clear()
|
||||
..products.clear()
|
||||
..invoices.clear()
|
||||
|
|
@ -357,8 +363,8 @@ abstract class CompanyEntity extends Object
|
|||
..projects.clear()
|
||||
..vendors.clear()
|
||||
..expenses.clear()
|
||||
//..designs.clear()
|
||||
//..companyGateways.clear()
|
||||
//..designs.clear()
|
||||
//..companyGateways.clear()
|
||||
);
|
||||
|
||||
bool isModuleEnabled(EntityType entityType) {
|
||||
|
|
@ -374,7 +380,7 @@ abstract class CompanyEntity extends Object
|
|||
}
|
||||
|
||||
if ((entityType == EntityType.invoice ||
|
||||
entityType == EntityType.payment) &&
|
||||
entityType == EntityType.payment) &&
|
||||
enabledModules & kModuleInvoices == 0) {
|
||||
return false;
|
||||
} else if (entityType == EntityType.credit &&
|
||||
|
|
@ -492,6 +498,7 @@ abstract class GatewayEntity extends Object
|
|||
FormatNumberType get listDisplayAmountType => null;
|
||||
}
|
||||
|
||||
|
||||
abstract class UserCompanyEntity
|
||||
implements Built<UserCompanyEntity, UserCompanyEntityBuilder> {
|
||||
factory UserCompanyEntity() {
|
||||
|
|
@ -503,9 +510,10 @@ abstract class UserCompanyEntity
|
|||
user: UserEntity(),
|
||||
token: TokenEntity(),
|
||||
account: AccountEntity(),
|
||||
notifications: BuiltMap<String, BuiltList<String>>().rebuild((b) => b
|
||||
notifications: BuiltMap<String, BuiltList<String>>().rebuild((b) =>
|
||||
b
|
||||
..[kNotificationChannelEmail] =
|
||||
BuiltList<String>(<String>[kNotificationsAll])),
|
||||
BuiltList<String>(<String>[kNotificationsAll])),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -575,7 +583,7 @@ abstract class UserCompanyEntity
|
|||
|
||||
bool receivesAllNotifications(String channel) =>
|
||||
notifications.containsKey(channel) &&
|
||||
notifications[channel].contains(kNotificationsAll);
|
||||
notifications[channel].contains(kNotificationsAll);
|
||||
|
||||
bool canView(EntityType entityType) => can(UserPermission.view, entityType);
|
||||
|
||||
|
|
@ -780,9 +788,9 @@ abstract class SettingsEntity
|
|||
groupSettings?.customMessagePaidInvoice ??
|
||||
companySettings?.customMessagePaidInvoice,
|
||||
customMessageUnapprovedQuote:
|
||||
clientSettings?.customMessageUnapprovedQuote ??
|
||||
groupSettings?.customMessageUnapprovedQuote ??
|
||||
companySettings?.customMessageUnapprovedQuote,
|
||||
clientSettings?.customMessageUnapprovedQuote ??
|
||||
groupSettings?.customMessageUnapprovedQuote ??
|
||||
companySettings?.customMessageUnapprovedQuote,
|
||||
lockSentInvoices: clientSettings?.lockSentInvoices ??
|
||||
groupSettings?.lockSentInvoices ??
|
||||
companySettings?.lockSentInvoices,
|
||||
|
|
@ -988,7 +996,7 @@ abstract class SettingsEntity
|
|||
groupSettings?.requireQuoteSignature ??
|
||||
companySettings?.requireQuoteSignature,
|
||||
name:
|
||||
clientSettings?.name ?? groupSettings?.name ?? companySettings?.name,
|
||||
clientSettings?.name ?? groupSettings?.name ?? companySettings?.name,
|
||||
companyLogo: clientSettings?.companyLogo ??
|
||||
groupSettings?.companyLogo ??
|
||||
companySettings?.companyLogo,
|
||||
|
|
@ -1002,7 +1010,7 @@ abstract class SettingsEntity
|
|||
groupSettings?.address2 ??
|
||||
companySettings?.address2,
|
||||
city:
|
||||
clientSettings?.city ?? groupSettings?.city ?? companySettings?.city,
|
||||
clientSettings?.city ?? groupSettings?.city ?? companySettings?.city,
|
||||
state: clientSettings?.state ??
|
||||
groupSettings?.state ??
|
||||
companySettings?.state,
|
||||
|
|
@ -1885,7 +1893,7 @@ abstract class SettingsEntity
|
|||
abstract class CompanyItemResponse
|
||||
implements Built<CompanyItemResponse, CompanyItemResponseBuilder> {
|
||||
factory CompanyItemResponse([void updates(CompanyItemResponseBuilder b)]) =
|
||||
_$CompanyItemResponse;
|
||||
_$CompanyItemResponse;
|
||||
|
||||
CompanyItemResponse._();
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,65 @@
|
|||
import 'package:built_value/built_value.dart';
|
||||
import 'package:built_value/serializer.dart';
|
||||
|
||||
part 'health_check.g.dart';
|
||||
|
||||
abstract class HealthCheckResponse
|
||||
implements Built<HealthCheckResponse, HealthCheckResponseBuilder> {
|
||||
factory HealthCheckResponse() {
|
||||
return _$HealthCheckResponse._();
|
||||
}
|
||||
|
||||
HealthCheckResponse._();
|
||||
|
||||
@override
|
||||
@memoized
|
||||
int get hashCode;
|
||||
|
||||
@BuiltValueField(wireName: 'system_health')
|
||||
bool get systemHealth;
|
||||
|
||||
//BuiltList<dynamic> get extensions;
|
||||
|
||||
@BuiltValueField(wireName: 'php_version')
|
||||
HealthCheckPHPResponse get phpVersion;
|
||||
|
||||
@BuiltValueField(wireName: 'env_writable')
|
||||
bool get envWritable;
|
||||
|
||||
@BuiltValueField(wireName: 'simple_db_check')
|
||||
bool get dbCheck;
|
||||
|
||||
@BuiltValueField(wireName: 'npm_status')
|
||||
String get npmStatus;
|
||||
|
||||
@BuiltValueField(wireName: 'node_status')
|
||||
String get nodeStatus;
|
||||
|
||||
static Serializer<HealthCheckResponse> get serializer =>
|
||||
_$healthCheckResponseSerializer;
|
||||
}
|
||||
|
||||
abstract class HealthCheckPHPResponse
|
||||
implements Built<HealthCheckPHPResponse, HealthCheckPHPResponseBuilder> {
|
||||
factory HealthCheckPHPResponse() {
|
||||
return _$HealthCheckPHPResponse._();
|
||||
}
|
||||
|
||||
HealthCheckPHPResponse._();
|
||||
|
||||
@override
|
||||
@memoized
|
||||
int get hashCode;
|
||||
|
||||
@BuiltValueField(wireName: 'minimum_php_version')
|
||||
double get minimumPHPVersion;
|
||||
|
||||
@BuiltValueField(wireName: 'current_php_version')
|
||||
String get currentPHPVersion;
|
||||
|
||||
@BuiltValueField(wireName: 'is_okay')
|
||||
bool get isOkay;
|
||||
|
||||
static Serializer<HealthCheckPHPResponse> get serializer =>
|
||||
_$healthCheckPHPResponseSerializer;
|
||||
}
|
||||
|
|
@ -0,0 +1,453 @@
|
|||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'health_check.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// BuiltValueGenerator
|
||||
// **************************************************************************
|
||||
|
||||
Serializer<HealthCheckResponse> _$healthCheckResponseSerializer =
|
||||
new _$HealthCheckResponseSerializer();
|
||||
Serializer<HealthCheckPHPResponse> _$healthCheckPHPResponseSerializer =
|
||||
new _$HealthCheckPHPResponseSerializer();
|
||||
|
||||
class _$HealthCheckResponseSerializer
|
||||
implements StructuredSerializer<HealthCheckResponse> {
|
||||
@override
|
||||
final Iterable<Type> types = const [
|
||||
HealthCheckResponse,
|
||||
_$HealthCheckResponse
|
||||
];
|
||||
@override
|
||||
final String wireName = 'HealthCheckResponse';
|
||||
|
||||
@override
|
||||
Iterable<Object> serialize(
|
||||
Serializers serializers, HealthCheckResponse object,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = <Object>[
|
||||
'system_health',
|
||||
serializers.serialize(object.systemHealth,
|
||||
specifiedType: const FullType(bool)),
|
||||
'php_version',
|
||||
serializers.serialize(object.phpVersion,
|
||||
specifiedType: const FullType(HealthCheckPHPResponse)),
|
||||
'env_writable',
|
||||
serializers.serialize(object.envWritable,
|
||||
specifiedType: const FullType(bool)),
|
||||
'simple_db_check',
|
||||
serializers.serialize(object.dbCheck,
|
||||
specifiedType: const FullType(bool)),
|
||||
'npm_status',
|
||||
serializers.serialize(object.npmStatus,
|
||||
specifiedType: const FullType(String)),
|
||||
'node_status',
|
||||
serializers.serialize(object.nodeStatus,
|
||||
specifiedType: const FullType(String)),
|
||||
];
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@override
|
||||
HealthCheckResponse deserialize(
|
||||
Serializers serializers, Iterable<Object> serialized,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = new HealthCheckResponseBuilder();
|
||||
|
||||
final iterator = serialized.iterator;
|
||||
while (iterator.moveNext()) {
|
||||
final key = iterator.current as String;
|
||||
iterator.moveNext();
|
||||
final dynamic value = iterator.current;
|
||||
switch (key) {
|
||||
case 'system_health':
|
||||
result.systemHealth = serializers.deserialize(value,
|
||||
specifiedType: const FullType(bool)) as bool;
|
||||
break;
|
||||
case 'php_version':
|
||||
result.phpVersion.replace(serializers.deserialize(value,
|
||||
specifiedType: const FullType(HealthCheckPHPResponse))
|
||||
as HealthCheckPHPResponse);
|
||||
break;
|
||||
case 'env_writable':
|
||||
result.envWritable = serializers.deserialize(value,
|
||||
specifiedType: const FullType(bool)) as bool;
|
||||
break;
|
||||
case 'simple_db_check':
|
||||
result.dbCheck = serializers.deserialize(value,
|
||||
specifiedType: const FullType(bool)) as bool;
|
||||
break;
|
||||
case 'npm_status':
|
||||
result.npmStatus = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String;
|
||||
break;
|
||||
case 'node_status':
|
||||
result.nodeStatus = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result.build();
|
||||
}
|
||||
}
|
||||
|
||||
class _$HealthCheckPHPResponseSerializer
|
||||
implements StructuredSerializer<HealthCheckPHPResponse> {
|
||||
@override
|
||||
final Iterable<Type> types = const [
|
||||
HealthCheckPHPResponse,
|
||||
_$HealthCheckPHPResponse
|
||||
];
|
||||
@override
|
||||
final String wireName = 'HealthCheckPHPResponse';
|
||||
|
||||
@override
|
||||
Iterable<Object> serialize(
|
||||
Serializers serializers, HealthCheckPHPResponse object,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = <Object>[
|
||||
'minimum_php_version',
|
||||
serializers.serialize(object.minimumPHPVersion,
|
||||
specifiedType: const FullType(double)),
|
||||
'current_php_version',
|
||||
serializers.serialize(object.currentPHPVersion,
|
||||
specifiedType: const FullType(String)),
|
||||
'is_okay',
|
||||
serializers.serialize(object.isOkay, specifiedType: const FullType(bool)),
|
||||
];
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@override
|
||||
HealthCheckPHPResponse deserialize(
|
||||
Serializers serializers, Iterable<Object> serialized,
|
||||
{FullType specifiedType = FullType.unspecified}) {
|
||||
final result = new HealthCheckPHPResponseBuilder();
|
||||
|
||||
final iterator = serialized.iterator;
|
||||
while (iterator.moveNext()) {
|
||||
final key = iterator.current as String;
|
||||
iterator.moveNext();
|
||||
final dynamic value = iterator.current;
|
||||
switch (key) {
|
||||
case 'minimum_php_version':
|
||||
result.minimumPHPVersion = serializers.deserialize(value,
|
||||
specifiedType: const FullType(double)) as double;
|
||||
break;
|
||||
case 'current_php_version':
|
||||
result.currentPHPVersion = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String;
|
||||
break;
|
||||
case 'is_okay':
|
||||
result.isOkay = serializers.deserialize(value,
|
||||
specifiedType: const FullType(bool)) as bool;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result.build();
|
||||
}
|
||||
}
|
||||
|
||||
class _$HealthCheckResponse extends HealthCheckResponse {
|
||||
@override
|
||||
final bool systemHealth;
|
||||
@override
|
||||
final HealthCheckPHPResponse phpVersion;
|
||||
@override
|
||||
final bool envWritable;
|
||||
@override
|
||||
final bool dbCheck;
|
||||
@override
|
||||
final String npmStatus;
|
||||
@override
|
||||
final String nodeStatus;
|
||||
|
||||
factory _$HealthCheckResponse(
|
||||
[void Function(HealthCheckResponseBuilder) updates]) =>
|
||||
(new HealthCheckResponseBuilder()..update(updates)).build();
|
||||
|
||||
_$HealthCheckResponse._(
|
||||
{this.systemHealth,
|
||||
this.phpVersion,
|
||||
this.envWritable,
|
||||
this.dbCheck,
|
||||
this.npmStatus,
|
||||
this.nodeStatus})
|
||||
: super._() {
|
||||
if (systemHealth == null) {
|
||||
throw new BuiltValueNullFieldError('HealthCheckResponse', 'systemHealth');
|
||||
}
|
||||
if (phpVersion == null) {
|
||||
throw new BuiltValueNullFieldError('HealthCheckResponse', 'phpVersion');
|
||||
}
|
||||
if (envWritable == null) {
|
||||
throw new BuiltValueNullFieldError('HealthCheckResponse', 'envWritable');
|
||||
}
|
||||
if (dbCheck == null) {
|
||||
throw new BuiltValueNullFieldError('HealthCheckResponse', 'dbCheck');
|
||||
}
|
||||
if (npmStatus == null) {
|
||||
throw new BuiltValueNullFieldError('HealthCheckResponse', 'npmStatus');
|
||||
}
|
||||
if (nodeStatus == null) {
|
||||
throw new BuiltValueNullFieldError('HealthCheckResponse', 'nodeStatus');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
HealthCheckResponse rebuild(
|
||||
void Function(HealthCheckResponseBuilder) updates) =>
|
||||
(toBuilder()..update(updates)).build();
|
||||
|
||||
@override
|
||||
HealthCheckResponseBuilder toBuilder() =>
|
||||
new HealthCheckResponseBuilder()..replace(this);
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (identical(other, this)) return true;
|
||||
return other is HealthCheckResponse &&
|
||||
systemHealth == other.systemHealth &&
|
||||
phpVersion == other.phpVersion &&
|
||||
envWritable == other.envWritable &&
|
||||
dbCheck == other.dbCheck &&
|
||||
npmStatus == other.npmStatus &&
|
||||
nodeStatus == other.nodeStatus;
|
||||
}
|
||||
|
||||
int __hashCode;
|
||||
@override
|
||||
int get hashCode {
|
||||
return __hashCode ??= $jf($jc(
|
||||
$jc(
|
||||
$jc(
|
||||
$jc($jc($jc(0, systemHealth.hashCode), phpVersion.hashCode),
|
||||
envWritable.hashCode),
|
||||
dbCheck.hashCode),
|
||||
npmStatus.hashCode),
|
||||
nodeStatus.hashCode));
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return (newBuiltValueToStringHelper('HealthCheckResponse')
|
||||
..add('systemHealth', systemHealth)
|
||||
..add('phpVersion', phpVersion)
|
||||
..add('envWritable', envWritable)
|
||||
..add('dbCheck', dbCheck)
|
||||
..add('npmStatus', npmStatus)
|
||||
..add('nodeStatus', nodeStatus))
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
class HealthCheckResponseBuilder
|
||||
implements Builder<HealthCheckResponse, HealthCheckResponseBuilder> {
|
||||
_$HealthCheckResponse _$v;
|
||||
|
||||
bool _systemHealth;
|
||||
bool get systemHealth => _$this._systemHealth;
|
||||
set systemHealth(bool systemHealth) => _$this._systemHealth = systemHealth;
|
||||
|
||||
HealthCheckPHPResponseBuilder _phpVersion;
|
||||
HealthCheckPHPResponseBuilder get phpVersion =>
|
||||
_$this._phpVersion ??= new HealthCheckPHPResponseBuilder();
|
||||
set phpVersion(HealthCheckPHPResponseBuilder phpVersion) =>
|
||||
_$this._phpVersion = phpVersion;
|
||||
|
||||
bool _envWritable;
|
||||
bool get envWritable => _$this._envWritable;
|
||||
set envWritable(bool envWritable) => _$this._envWritable = envWritable;
|
||||
|
||||
bool _dbCheck;
|
||||
bool get dbCheck => _$this._dbCheck;
|
||||
set dbCheck(bool dbCheck) => _$this._dbCheck = dbCheck;
|
||||
|
||||
String _npmStatus;
|
||||
String get npmStatus => _$this._npmStatus;
|
||||
set npmStatus(String npmStatus) => _$this._npmStatus = npmStatus;
|
||||
|
||||
String _nodeStatus;
|
||||
String get nodeStatus => _$this._nodeStatus;
|
||||
set nodeStatus(String nodeStatus) => _$this._nodeStatus = nodeStatus;
|
||||
|
||||
HealthCheckResponseBuilder();
|
||||
|
||||
HealthCheckResponseBuilder get _$this {
|
||||
if (_$v != null) {
|
||||
_systemHealth = _$v.systemHealth;
|
||||
_phpVersion = _$v.phpVersion?.toBuilder();
|
||||
_envWritable = _$v.envWritable;
|
||||
_dbCheck = _$v.dbCheck;
|
||||
_npmStatus = _$v.npmStatus;
|
||||
_nodeStatus = _$v.nodeStatus;
|
||||
_$v = null;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@override
|
||||
void replace(HealthCheckResponse other) {
|
||||
if (other == null) {
|
||||
throw new ArgumentError.notNull('other');
|
||||
}
|
||||
_$v = other as _$HealthCheckResponse;
|
||||
}
|
||||
|
||||
@override
|
||||
void update(void Function(HealthCheckResponseBuilder) updates) {
|
||||
if (updates != null) updates(this);
|
||||
}
|
||||
|
||||
@override
|
||||
_$HealthCheckResponse build() {
|
||||
_$HealthCheckResponse _$result;
|
||||
try {
|
||||
_$result = _$v ??
|
||||
new _$HealthCheckResponse._(
|
||||
systemHealth: systemHealth,
|
||||
phpVersion: phpVersion.build(),
|
||||
envWritable: envWritable,
|
||||
dbCheck: dbCheck,
|
||||
npmStatus: npmStatus,
|
||||
nodeStatus: nodeStatus);
|
||||
} catch (_) {
|
||||
String _$failedField;
|
||||
try {
|
||||
_$failedField = 'phpVersion';
|
||||
phpVersion.build();
|
||||
} catch (e) {
|
||||
throw new BuiltValueNestedFieldError(
|
||||
'HealthCheckResponse', _$failedField, e.toString());
|
||||
}
|
||||
rethrow;
|
||||
}
|
||||
replace(_$result);
|
||||
return _$result;
|
||||
}
|
||||
}
|
||||
|
||||
class _$HealthCheckPHPResponse extends HealthCheckPHPResponse {
|
||||
@override
|
||||
final double minimumPHPVersion;
|
||||
@override
|
||||
final String currentPHPVersion;
|
||||
@override
|
||||
final bool isOkay;
|
||||
|
||||
factory _$HealthCheckPHPResponse(
|
||||
[void Function(HealthCheckPHPResponseBuilder) updates]) =>
|
||||
(new HealthCheckPHPResponseBuilder()..update(updates)).build();
|
||||
|
||||
_$HealthCheckPHPResponse._(
|
||||
{this.minimumPHPVersion, this.currentPHPVersion, this.isOkay})
|
||||
: super._() {
|
||||
if (minimumPHPVersion == null) {
|
||||
throw new BuiltValueNullFieldError(
|
||||
'HealthCheckPHPResponse', 'minimumPHPVersion');
|
||||
}
|
||||
if (currentPHPVersion == null) {
|
||||
throw new BuiltValueNullFieldError(
|
||||
'HealthCheckPHPResponse', 'currentPHPVersion');
|
||||
}
|
||||
if (isOkay == null) {
|
||||
throw new BuiltValueNullFieldError('HealthCheckPHPResponse', 'isOkay');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
HealthCheckPHPResponse rebuild(
|
||||
void Function(HealthCheckPHPResponseBuilder) updates) =>
|
||||
(toBuilder()..update(updates)).build();
|
||||
|
||||
@override
|
||||
HealthCheckPHPResponseBuilder toBuilder() =>
|
||||
new HealthCheckPHPResponseBuilder()..replace(this);
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (identical(other, this)) return true;
|
||||
return other is HealthCheckPHPResponse &&
|
||||
minimumPHPVersion == other.minimumPHPVersion &&
|
||||
currentPHPVersion == other.currentPHPVersion &&
|
||||
isOkay == other.isOkay;
|
||||
}
|
||||
|
||||
int __hashCode;
|
||||
@override
|
||||
int get hashCode {
|
||||
return __hashCode ??= $jf($jc(
|
||||
$jc($jc(0, minimumPHPVersion.hashCode), currentPHPVersion.hashCode),
|
||||
isOkay.hashCode));
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return (newBuiltValueToStringHelper('HealthCheckPHPResponse')
|
||||
..add('minimumPHPVersion', minimumPHPVersion)
|
||||
..add('currentPHPVersion', currentPHPVersion)
|
||||
..add('isOkay', isOkay))
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
class HealthCheckPHPResponseBuilder
|
||||
implements Builder<HealthCheckPHPResponse, HealthCheckPHPResponseBuilder> {
|
||||
_$HealthCheckPHPResponse _$v;
|
||||
|
||||
double _minimumPHPVersion;
|
||||
double get minimumPHPVersion => _$this._minimumPHPVersion;
|
||||
set minimumPHPVersion(double minimumPHPVersion) =>
|
||||
_$this._minimumPHPVersion = minimumPHPVersion;
|
||||
|
||||
String _currentPHPVersion;
|
||||
String get currentPHPVersion => _$this._currentPHPVersion;
|
||||
set currentPHPVersion(String currentPHPVersion) =>
|
||||
_$this._currentPHPVersion = currentPHPVersion;
|
||||
|
||||
bool _isOkay;
|
||||
bool get isOkay => _$this._isOkay;
|
||||
set isOkay(bool isOkay) => _$this._isOkay = isOkay;
|
||||
|
||||
HealthCheckPHPResponseBuilder();
|
||||
|
||||
HealthCheckPHPResponseBuilder get _$this {
|
||||
if (_$v != null) {
|
||||
_minimumPHPVersion = _$v.minimumPHPVersion;
|
||||
_currentPHPVersion = _$v.currentPHPVersion;
|
||||
_isOkay = _$v.isOkay;
|
||||
_$v = null;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@override
|
||||
void replace(HealthCheckPHPResponse other) {
|
||||
if (other == null) {
|
||||
throw new ArgumentError.notNull('other');
|
||||
}
|
||||
_$v = other as _$HealthCheckPHPResponse;
|
||||
}
|
||||
|
||||
@override
|
||||
void update(void Function(HealthCheckPHPResponseBuilder) updates) {
|
||||
if (updates != null) updates(this);
|
||||
}
|
||||
|
||||
@override
|
||||
_$HealthCheckPHPResponse build() {
|
||||
final _$result = _$v ??
|
||||
new _$HealthCheckPHPResponse._(
|
||||
minimumPHPVersion: minimumPHPVersion,
|
||||
currentPHPVersion: currentPHPVersion,
|
||||
isOkay: isOkay);
|
||||
replace(_$result);
|
||||
return _$result;
|
||||
}
|
||||
}
|
||||
|
||||
// ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,lines_longer_than_80_chars,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new
|
||||
|
|
@ -7,6 +7,7 @@ import 'package:invoiceninja_flutter/data/models/company_model.dart';
|
|||
import 'package:invoiceninja_flutter/data/models/gateway_token_model.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/expense_model.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/group_model.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/health_check.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/invoice_model.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/entities.dart';
|
||||
|
|
@ -141,6 +142,7 @@ part 'serializers.g.dart';
|
|||
GatewayTokenItemResponse,
|
||||
UserCompanyItemResponse,
|
||||
DesignPreviewRequest,
|
||||
HealthCheckResponse,
|
||||
])
|
||||
final Serializers serializers =
|
||||
(_$serializers.toBuilder()..addPlugin(StandardJsonPlugin())).build();
|
||||
|
|
|
|||
|
|
@ -78,6 +78,8 @@ Serializers _$serializers = (new Serializers().toBuilder()
|
|||
..add(GroupListResponse.serializer)
|
||||
..add(GroupState.serializer)
|
||||
..add(GroupUIState.serializer)
|
||||
..add(HealthCheckPHPResponse.serializer)
|
||||
..add(HealthCheckResponse.serializer)
|
||||
..add(HistoryRecord.serializer)
|
||||
..add(IndustryEntity.serializer)
|
||||
..add(IndustryItemResponse.serializer)
|
||||
|
|
|
|||
|
|
@ -589,6 +589,8 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
|
|||
|
||||
bool get isStaging => cleanApiUrl(authState.url) == kAppStagingUrl;
|
||||
|
||||
bool get isProduction => cleanApiUrl(authState.url) == kAppProductionUrl;
|
||||
|
||||
bool get isWhiteLabeled => isSelfHosted || account.plan == kPlanWhiteLabel;
|
||||
|
||||
/* TODO re-enable
|
||||
|
|
|
|||
|
|
@ -0,0 +1,93 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_redux/flutter_redux.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/health_check.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/serializers.dart';
|
||||
import 'package:invoiceninja_flutter/data/web_client.dart';
|
||||
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/form_card.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/loading_indicator.dart';
|
||||
import 'package:invoiceninja_flutter/utils/localization.dart';
|
||||
|
||||
class HealthCheckDialog extends StatefulWidget {
|
||||
@override
|
||||
_HealthCheckDialogState createState() => _HealthCheckDialogState();
|
||||
}
|
||||
|
||||
class _HealthCheckDialogState extends State<HealthCheckDialog> {
|
||||
HealthCheckResponse _response;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
print('## INIT STATE');
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
print('## didChangeDependencies');
|
||||
|
||||
if (_response == null) {
|
||||
runCheck();
|
||||
}
|
||||
super.didChangeDependencies();
|
||||
}
|
||||
|
||||
void runCheck() {
|
||||
print('## RUN CHECK');
|
||||
|
||||
setState(() {
|
||||
_response = null;
|
||||
});
|
||||
|
||||
final webClient = WebClient();
|
||||
final state = StoreProvider.of<AppState>(context).state;
|
||||
final credentials = state.credentials;
|
||||
final url = '${credentials.url}/health_check';
|
||||
|
||||
webClient.get(url, credentials.token).then((dynamic response) {
|
||||
print('## response: $response');
|
||||
setState(() {
|
||||
//_response = json.decode(response);
|
||||
_response = serializers.deserializeWith(
|
||||
HealthCheckResponse.serializer, response);
|
||||
});
|
||||
}).catchError((dynamic error) {
|
||||
print('## error: $error');
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final localization = AppLocalization.of(context);
|
||||
|
||||
return AlertDialog(
|
||||
content: _response == null
|
||||
? LoadingIndicator()
|
||||
: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ListTile(
|
||||
title: Text('System Health'),
|
||||
subtitle: Text(_response.systemHealth ? 'Passed' : 'Failed'),
|
||||
trailing: Icon(_response.systemHealth
|
||||
? Icons.check_circle_outline
|
||||
: Icons.error_outline),
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: _response == null
|
||||
? []
|
||||
: [
|
||||
FlatButton(
|
||||
child: Text(localization.refresh.toUpperCase()),
|
||||
onPressed: () => runCheck(),
|
||||
),
|
||||
FlatButton(
|
||||
child: Text(localization.close.toUpperCase()),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -3,11 +3,14 @@ import 'package:flutter/foundation.dart';
|
|||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:invoiceninja_flutter/data/web_client.dart';
|
||||
import 'package:invoiceninja_flutter/redux/app/app_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/ui/pref_state.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/buttons/elevated_button.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/dialogs/alert_dialog.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/dialogs/error_dialog.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/dialogs/health_check_dialog.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/forms/app_dropdown_button.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/resources/cached_image.dart';
|
||||
import 'package:invoiceninja_flutter/ui/system/update_dialog.dart';
|
||||
|
|
@ -745,7 +748,7 @@ void _showAbout(BuildContext context) async {
|
|||
applicationLegalese: '© ${DateTime.now().year} Invoice Ninja',
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 24.0),
|
||||
padding: const EdgeInsets.only(top: 24),
|
||||
child: RichText(
|
||||
text: TextSpan(
|
||||
children: <TextSpan>[
|
||||
|
|
@ -771,6 +774,21 @@ void _showAbout(BuildContext context) async {
|
|||
),
|
||||
),
|
||||
),
|
||||
//if (!state.isProduction) // TODO enable this check
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 24),
|
||||
child: AppButton(
|
||||
label: localization.healthCheck.toUpperCase(),
|
||||
iconData: FontAwesomeIcons.shieldAlt,
|
||||
onPressed: () {
|
||||
showDialog<HealthCheckDialog>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return HealthCheckDialog();
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
|
|
|||
2146
lib/utils/i18n.dart
2146
lib/utils/i18n.dart
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue