Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature review #184

Merged
merged 11 commits into from
Nov 26, 2023
21 changes: 11 additions & 10 deletions lib/api/events.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ extension EventsExtension on API {
.cast<Map>()
.map((eventObject) {
final published = DateTime.parse(eventObject['published']).toLocal();
final event = Event.factory(
final event = Event(
server: server,
id: () {
final idObject = eventObject['id'].toString();
Expand Down Expand Up @@ -143,21 +143,22 @@ extension EventsExtension on API {
.map((e) {
if (!e.containsKey('content')) debugPrint(e.toString());
return Event(
server,
int.parse(e['id']['raw']),
int.parse((e['category']['term'] as String).split('/').first),
e['title']['\$t'],
e['published'] == null || e['published']['\$t'] == null
server: server,
id: int.parse(e['id']['raw']),
deviceID:
int.parse((e['category']['term'] as String).split('/').first),
title: e['title']['\$t'],
published: e['published'] == null || e['published']['\$t'] == null
? DateTime.now().toLocal()
: DateTime.parse(e['published']['\$t']).toLocal(),
e['updated'] == null || e['updated']['\$t'] == null
updated: e['updated'] == null || e['updated']['\$t'] == null
? DateTime.now().toLocal()
: DateTime.parse(e['updated']['\$t']).toLocal(),
e['category']['term'],
!e.containsKey('content')
category: e['category']['term'],
mediaID: !e.containsKey('content')
? null
: int.parse(e['content']['media_id']),
!e.containsKey('content')
mediaURL: !e.containsKey('content')
? null
: Uri.parse(
e['content'][r'$t'].replaceAll(
Expand Down
9 changes: 3 additions & 6 deletions lib/firebase_messaging_background_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,9 @@ Future<void> _backgroundClickAction(ReceivedAction action) async {
final server = ServersProvider.instance.servers
.firstWhere((server) => server.serverUUID == serverUUID);
final device = Device(
name!,
int.tryParse(id ?? '0') ?? 0,
true,
0,
0,
server,
name: name!,
id: int.tryParse(id ?? '0') ?? 0,
server: server,
);
final player = UnityPlayers.forDevice(device);
// No [DeviceFullscreenViewer] route is ever pushed due to notification click into the navigator.
Expand Down
6 changes: 4 additions & 2 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
"welcome": "Welcome",
"welcomeDescription": "Welcome to the Bluecherry Surveillance DVR!\nLet's connect to your DVR server quickly.",
"configure": "Configure a DVR Server",
"configureDescription": "Setup a connection to your remote DVR server",
"configureDescription": "Setup a connection to your remote DVR server. You can connect to any number of servers from anywhere in the world.",
"hostname": "Hostname",
"hostnameExample": "demo.bluecherry.app",
"port": "Port",
"rtspPort": "RTSP Port",
"serverName": "Server Name",
Expand All @@ -17,11 +18,12 @@
"useDefault": "Use Default",
"connect": "Connect",
"connectAutomaticallyAtStartup": "Connect automatically at startup",
"connectAutomaticallyAtStartupDescription": "If enabled, the server will be automatically connected when the app starts.",
"skip": "Skip",
"cancel": "Cancel",
"letsGo": "Let's Go!",
"finish": "Finish",
"letsGoDescription": "Here's some tips on how to get started",
"letsGoDescription": "Here's some tips on how to get started:",
"projectName": "Bluecherry",
"projectDescription": "Powerful Video Surveillance Software",
"website": "Website",
Expand Down
6 changes: 4 additions & 2 deletions lib/l10n/app_fr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
"welcome": "Bienvenue",
"welcomeDescription": "Bienvenue sur le DVR de surveillance Bluecherry !\nConnectons-nous rapidement à votre serveur DVR.",
"configure": "Configurer un serveur DVR",
"configureDescription": "Configurons une connexion à votre serveur DVR distant",
"configureDescription": "Configurons une connexion à votre serveur DVR distant. You can connect to any number of servers from anywhere in the world.",
"hostname": "Nom d'hôte",
"hostnameExample": "demo.bluecherry.app",
"port": "Port",
"rtspPort": "RTSP Port",
"serverName": "Server Name",
Expand All @@ -17,11 +18,12 @@
"useDefault": "Par défaut",
"connect": "Connecter",
"connectAutomaticallyAtStartup": "Connecter automatiquement au démarrage",
"connectAutomaticallyAtStartupDescription": "If enabled, the app will automatically connect to the server when it starts.",
"skip": "Sauter",
"cancel": "Annuler",
"letsGo": "C'EST PARTI!",
"finish": "Terminé",
"letsGoDescription": "Voici quelques astuces pour bien commencer",
"letsGoDescription": "Voici quelques astuces pour bien commencer:",
"projectName": "Bluecherry",
"projectDescription": "Puissant logiciel de surveillance vidéo",
"website": "Site internet",
Expand Down
6 changes: 4 additions & 2 deletions lib/l10n/app_pl.arb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
"welcome": "Witamy",
"welcomeDescription": "Witamy w systemie monitoringu Blueberry!\nPodłącz się do serwera DVR.",
"configure": "Konfiguracja serwera DVR",
"configureDescription": "Ustawienia połączenia ze zdalnym serwerem DVR",
"configureDescription": "Ustawienia połączenia ze zdalnym serwerem DVR. You can connect to any number of servers from anywhere in the world.",
"hostname": "Nazwa hosta",
"hostnameExample": "demo.bluecherry.app",
"port": "Port",
"rtspPort": "RTSP Port",
"serverName": "Server Name",
Expand All @@ -17,11 +18,12 @@
"useDefault": "Użyj wartości domyślnych",
"connect": "Połącz",
"connectAutomaticallyAtStartup": "Połącz automatycznie przy uruchomieniu",
"connectAutomaticallyAtStartupDescription": "If enabled, the app will automatically connect to the server when it starts.",
"skip": "Pomiń",
"cancel": "Anuluj",
"letsGo": "Do dzieła!",
"finish": "Zakończ",
"letsGoDescription": "Kilka porad jak zacząć",
"letsGoDescription": "Kilka porad jak zacząć:",
"projectName": "Bluecherry",
"projectDescription": "Oprogramowanie do monitoringu wizyjnego",
"website": "Strona domowa",
Expand Down
6 changes: 4 additions & 2 deletions lib/l10n/app_pt.arb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
"welcome": "Bem vindo!",
"welcomeDescription": "Sea bem vindo ao Bluecherry Surveillance DVR!\nVamos conectar ao seu servidor DVR em um instante!",
"configure": "Configure um Servidor DVR",
"configureDescription": "Configure uma conexão com seu servidor DVR remoto",
"configureDescription": "Configure uma conexão com seu servidor DVR remoto. Você pode se conectar a quantos servidores quiser de qualquer lugar do mundo.",
"hostname": "Hostname",
"hostnameExample": "demo.bluecherry.app",
"port": "Porta",
"rtspPort": "Porta RTSP",
"serverName": "Nome do servidor",
Expand All @@ -17,11 +18,12 @@
"useDefault": "Usar Padrão",
"connect": "Conectar",
"connectAutomaticallyAtStartup": "Conectar automaticamente ao iniciar",
"connectAutomaticallyAtStartupDescription": "Se ativado, o servidor será conectado automaticamente quando o aplicativo for iniciado.",
"skip": "Pular",
"cancel": "Cancelar",
"letsGo": "Vamos lá!",
"finish": "Concluir",
"letsGoDescription": "Aqui algumas dicas de como começar",
"letsGoDescription": "Aqui algumas dicas de como começar:",
"projectName": "Bluecherry",
"projectDescription": "Powerful Video Surveillance Software",
"website": "Website",
Expand Down
51 changes: 26 additions & 25 deletions lib/models/device.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,13 @@ class Device {
final ExternalDeviceData? externalData;

/// Creates a device.
Device(
this.name,
this.id,
this.status,
Device({
required this.name,
required this.id,
this.status = true,
this.resolutionX,
this.resolutionY,
this.server, {
required this.server,
this.hasPTZ = false,
this.url,
this.matrixType = MatrixType.t16,
Expand All @@ -130,6 +130,7 @@ class Device {
this.externalData,
});

/// Creates a device with fake values.
Device.dump({
this.name = 'device',
this.id = -1,
Expand Down Expand Up @@ -170,12 +171,12 @@ class Device {

factory Device.fromServerJson(Map map, Server server) {
return Device(
map['device_name'],
int.tryParse(map['id']) ?? 0,
map['status'] == 'OK',
int.tryParse(map['resolutionX']),
int.tryParse(map['resolutionY']),
server,
name: map['device_name'],
id: int.tryParse(map['id']) ?? 0,
status: map['status'] == 'OK',
resolutionX: int.tryParse(map['resolutionX']),
resolutionY: int.tryParse(map['resolutionY']),
server: server,
hasPTZ: map['ptz_control_protocol'] != null,
);
}
Expand Down Expand Up @@ -243,7 +244,7 @@ class Device {
).toString());
}

Future<String?> getHLSUrl([Device? device]) async {
Future<String> getHLSUrl([Device? device]) async {
// return hlsURL;
device ??= this;
var data = {
Expand Down Expand Up @@ -276,7 +277,7 @@ class Device {
debugPrint('Request failed with status: ${response.statusCode}');
}

return null;
return hlsURL;
}

/// Returns the full name of this device, including the server name.
Expand Down Expand Up @@ -340,12 +341,12 @@ class Device {
ExternalDeviceData? externalData,
}) =>
Device(
name ?? this.name,
id ?? this.id,
status ?? this.status,
resolutionX ?? this.resolutionX,
resolutionY ?? this.resolutionY,
server ?? this.server,
name: name ?? this.name,
id: id ?? this.id,
status: status ?? this.status,
resolutionX: resolutionX ?? this.resolutionX,
resolutionY: resolutionY ?? this.resolutionY,
server: server ?? this.server,
hasPTZ: hasPTZ ?? this.hasPTZ,
url: url ?? this.url,
matrixType: matrixType ?? this.matrixType,
Expand Down Expand Up @@ -374,15 +375,15 @@ class Device {

factory Device.fromJson(Map<String, dynamic> json) {
return Device(
json['name'],
int.tryParse(json['id']?.toString() ??
name: json['name'],
id: int.tryParse(json['id']?.toString() ??
json['uri']?.toString().replaceAll('live/', '') ??
'') ??
0,
json['status'],
json['resolutionX'],
json['resolutionY'],
Server.fromJson(json['server'] as Map<String, dynamic>),
status: json['status'] ?? false,
resolutionX: json['resolutionX'],
resolutionY: json['resolutionY'],
server: Server.fromJson(json['server'] as Map<String, dynamic>),
hasPTZ: json['hasPTZ'] ?? false,
url: json['url'],
matrixType: MatrixType.values[json['matrixType'] ?? 0],
Expand Down
Loading