Skip to content

Commit 2d6404c

Browse files
committed
multi server login is now officially a supported feature
1 parent 9386f95 commit 2d6404c

File tree

18 files changed

+356
-206
lines changed

18 files changed

+356
-206
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ A web version (for IOS, ...) can be found [here](https://computerelite.github.io
1313
# Features
1414
ShockAlarm is a powerful tool for controlling your Shockers via OpenShock. It allows you to fully manage your shockers, logs, shares, hubs, share links, tokens and sessions.
1515

16-
There is advanced functionaity like controling multiple shockers at the same time, specifying a random interval for intensity, duration and a delay (if you're into that), live controls with patterns and alarms.
16+
There is advanced functionaity like controling multiple shockers at the same time, specifying a random interval for intensity, duration and a delay, live controls with patterns and alarms.
1717

1818
It's fully material you themed just like the standard Android apps you're already used to and provides a responsive ui with a nice design.
1919

2020
Furthermore it fixes some layout flaws of the official OpenShock Frontend like having shared and own shockers in seperate tabs (which is annoying). On top it also has lots of info buttons you can press to get more insight on what something does.
2121

22+
You can also log in on multiple OpenShock instances at once. ShockAlarm will show all shockers from all instances seamlessly at a glance!
23+
2224
# Installation on Android
2325
## Through Obtainium (recommended as you get the updates the fastest)
2426
[<img src="https://github.com/user-attachments/assets/713d71c5-3dec-4ec4-a3f2-8d28d025a9c6"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
**Changelog:**
2+
- Change send interval from 50ms to whatever the hub requests
3+
- Fixed logs not loading on second entering
4+
- Added refined support for multi server login

lib/components/live_controls.dart

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ class _LiveControlsState extends State<LiveControls> {
224224
isPlaying: isPlaying,
225225
pattern: pattern,
226226
logEvent: (duration, intensity) => widget.liveEventDone?.call(type, duration, intensity),
227-
respondInterval: 50,
227+
respondInterval: getRequestedTps(), // 10 tps from LCG
228228
intensityLimit: widget.intensityLimit,
229229
)
230230
],
@@ -287,6 +287,14 @@ class _LiveControlsState extends State<LiveControls> {
287287
],
288288
));
289289
}
290+
291+
double getRequestedTps() {
292+
int highestTps = 4;
293+
AlarmListManager.getInstance().liveControlGatewayConnections.values.forEach((element) {
294+
if(element.tps > highestTps) highestTps = element.tps;
295+
});
296+
return 1000 / highestTps;
297+
}
290298
}
291299

292300
class PatternPreview extends StatelessWidget {

lib/components/shocker_details.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@ import 'dart:math';
22

33
import 'package:flutter/material.dart';
44
import 'package:shock_alarm_app/dialogs/ErrorDialog.dart';
5+
import 'package:shock_alarm_app/stores/alarm_store.dart';
56

67
import '../services/openshock.dart';
78

89
class ShockerDetails extends StatefulWidget {
910
OpenShockShocker shocker;
11+
int? apiTokenId;
1012
List<OpenShockDevice> devices;
1113

12-
ShockerDetails({required this.shocker, required this.devices});
14+
ShockerDetails({required this.shocker, required this.devices, this.apiTokenId});
1315
@override
1416
ShockerDetailsState createState() => ShockerDetailsState();
1517
}
@@ -42,7 +44,7 @@ class ShockerDetailsState extends State<ShockerDetails> {
4244
},
4345
initialSelection: widget.shocker.device,
4446
dropdownMenuEntries: [
45-
for (OpenShockDevice device in widget.devices)
47+
for (OpenShockDevice device in widget.devices.where((x) => widget.apiTokenId == null || (x.apiTokenReference?.id ?? 0) == widget.apiTokenId))
4648
DropdownMenuEntry(label: device.name, value: device.id),
4749
]),
4850
DropdownMenu<String>(

lib/components/shocker_item.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class ShockerItem extends StatefulWidget {
4747
context: context,
4848
builder: (context) => AlertDialog.adaptive(
4949
title: Text("Edit shocker"),
50-
content: ShockerDetails(shocker: s, devices: devices),
50+
content: ShockerDetails(shocker: s, devices: devices, apiTokenId: shocker.apiTokenId,),
5151
actions: [
5252
TextButton(
5353
onPressed: () {

lib/components/token_item.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class TokenItemState extends State<TokenItem> {
101101
token.name,
102102
style: t.textTheme.headlineSmall?.copyWith(fontWeight: FontWeight.bold),
103103
),
104-
Text(token.tokenType==TokenType.openshock? "OpenShock" : "AlarmServer")
104+
Text("${token.tokenType==TokenType.openshock? "OpenShock" : "AlarmServer"} (${token.server.replaceAll("http://", "").replaceAll("https://", "")})", style: t.textTheme.labelSmall,),
105105
],
106106
),
107107
Row(

lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import 'package:android_alarm_manager_plus/android_alarm_manager_plus.dart';
1414
const String issues_url = "https://github.com/ComputerElite/ShockAlarmApp/issues";
1515

1616
String GetUserAgent() {
17-
return "ShockAlarm/0.2.3";
17+
return "ShockAlarm/0.2.4";
1818
}
1919

2020
bool isAndroid() {

lib/screens/home.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ class ScreenSelectorState extends State<ScreenSelector> {
171171
if (index != -1) {
172172
_selectedIndex = min(index, screens.length);
173173
} else {
174-
if (manager.getAnyUserToken() == null) _selectedIndex = 3;
174+
if (!manager.hasValidAccount()) _selectedIndex = 3;
175175
if (!supportsAlarms) _selectedIndex -= 1;
176176
}
177177
setState(() {});
@@ -243,7 +243,7 @@ class ScreenSelectorState extends State<ScreenSelector> {
243243

244244
@override
245245
Widget build(BuildContext context) {
246-
manager.startAnyWS();
246+
manager.startAllWS();
247247
return Scaffold(
248248
body: Padding(
249249
padding: const EdgeInsets.only(

lib/screens/logs.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,12 @@ class LogScreenState extends State<LogScreen> {
3434
initialLoading = true;
3535
manager.reloadShockerLogs = () {
3636
List<ShockerLog> newLogs = [];
37-
for (var shocker in shockers)
37+
for (var shocker in shockers) {
3838
newLogs.addAll(manager.shockerLog[shocker.id] ?? []);
39+
}
3940
newLogs.sort((a, b) => b.createdOn.compareTo(a.createdOn));
4041
setState(() {
42+
initialLoading = false;
4143
logs = newLogs;
4244
});
4345
if(reloadShockerLogs != null) {
@@ -46,6 +48,8 @@ class LogScreenState extends State<LogScreen> {
4648
};
4749
if(needsToLoadLogsOnStart()) {
4850
loadLogs();
51+
} else {
52+
manager.reloadShockerLogs?.call();
4953
}
5054
}
5155

lib/screens/share_link_edit.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class ShareLinkEditScreenState extends State<ShareLinkEditScreen> {
4949
List<Shocker> ownShockers = await AlarmListManager.getInstance()
5050
.shockers
5151
.where((element) =>
52-
element.isOwn && !existingShockers.contains(element.id))
52+
element.isOwn && !existingShockers.contains(element.id) && element.apiTokenId == widget.shareLink.tokenId )
5353
.toList();
5454
Shocker? selectedShocker = null;
5555
OpenShockShareLimits limits = OpenShockShareLimits();

0 commit comments

Comments
 (0)