Add path to every view
This commit is contained in:
parent
e4d1a4f823
commit
353c80b6bc
@ -14,7 +14,7 @@ class HomeAssistant {
|
|||||||
HomeAssistantUI ui;
|
HomeAssistantUI ui;
|
||||||
Map _instanceConfig = {};
|
Map _instanceConfig = {};
|
||||||
String _userName;
|
String _userName;
|
||||||
String _lovelaceDashbordUrl;
|
String currentDashboardPath;
|
||||||
HSVColor savedColor;
|
HSVColor savedColor;
|
||||||
int savedPlayerPosition;
|
int savedPlayerPosition;
|
||||||
String sendToPlayerId;
|
String sendToPlayerId;
|
||||||
@ -29,8 +29,6 @@ class HomeAssistant {
|
|||||||
var _rawUserInfo;
|
var _rawUserInfo;
|
||||||
var _rawPanels;
|
var _rawPanels;
|
||||||
|
|
||||||
set lovelaceDashboardUrl(String val) => _lovelaceDashbordUrl = val;
|
|
||||||
|
|
||||||
List<Panel> panels = [];
|
List<Panel> panels = [];
|
||||||
|
|
||||||
Duration fetchTimeout = Duration(seconds: 30);
|
Duration fetchTimeout = Duration(seconds: 30);
|
||||||
@ -194,9 +192,9 @@ class HomeAssistant {
|
|||||||
} else {
|
} else {
|
||||||
Completer completer = Completer();
|
Completer completer = Completer();
|
||||||
var additionalData;
|
var additionalData;
|
||||||
if (AppSettings().haVersion >= 107 && _lovelaceDashbordUrl != HomeAssistant.DEFAULT_DASHBOARD) {
|
if (AppSettings().haVersion >= 107 && currentDashboardPath != HomeAssistant.DEFAULT_DASHBOARD) {
|
||||||
additionalData = {
|
additionalData = {
|
||||||
'url_path': _lovelaceDashbordUrl
|
'url_path': currentDashboardPath
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
ConnectionManager().sendSocketMessage(
|
ConnectionManager().sendSocketMessage(
|
||||||
|
@ -99,7 +99,7 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver, Ticker
|
|||||||
_subscribe().then((_) {
|
_subscribe().then((_) {
|
||||||
ConnectionManager().init(loadSettings: true, forceReconnect: true).then((__){
|
ConnectionManager().init(loadSettings: true, forceReconnect: true).then((__){
|
||||||
SharedPreferences.getInstance().then((prefs) {
|
SharedPreferences.getInstance().then((prefs) {
|
||||||
HomeAssistant().lovelaceDashboardUrl = prefs.getString('lovelace_dashboard_url') ?? HomeAssistant.DEFAULT_DASHBOARD;
|
HomeAssistant().currentDashboardPath = prefs.getString('lovelace_dashboard_url') ?? HomeAssistant.DEFAULT_DASHBOARD;
|
||||||
_fetchData(useCache: true);
|
_fetchData(useCache: true);
|
||||||
LocationManager();
|
LocationManager();
|
||||||
StartupUserMessagesManager().checkMessagesToShow();
|
StartupUserMessagesManager().checkMessagesToShow();
|
||||||
@ -603,7 +603,7 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver, Ticker
|
|||||||
context: context,
|
context: context,
|
||||||
items: serviceMenuItems
|
items: serviceMenuItems
|
||||||
).then((String val) {
|
).then((String val) {
|
||||||
HomeAssistant().lovelaceDashboardUrl = HomeAssistant.DEFAULT_DASHBOARD;
|
HomeAssistant().currentDashboardPath = HomeAssistant.DEFAULT_DASHBOARD;
|
||||||
if (val == "reload") {
|
if (val == "reload") {
|
||||||
|
|
||||||
_quickLoad();
|
_quickLoad();
|
||||||
|
@ -31,7 +31,8 @@ class Panel {
|
|||||||
if (componentName.startsWith('haclient')) {
|
if (componentName.startsWith('haclient')) {
|
||||||
Navigator.of(context).pushNamed(urlPath);
|
Navigator.of(context).pushNamed(urlPath);
|
||||||
} else if (componentName == 'lovelace') {
|
} else if (componentName == 'lovelace') {
|
||||||
HomeAssistant().lovelaceDashboardUrl = this.urlPath;
|
HomeAssistant().currentDashboardPath = this.urlPath;
|
||||||
|
Logger.d('Switching to dashboard: ${this.urlPath}');
|
||||||
HomeAssistant().autoUi = false;
|
HomeAssistant().autoUi = false;
|
||||||
SharedPreferences.getInstance().then((prefs) {
|
SharedPreferences.getInstance().then((prefs) {
|
||||||
prefs.setString('lovelace_dashboard_url', this.urlPath);
|
prefs.setString('lovelace_dashboard_url', this.urlPath);
|
||||||
|
@ -16,7 +16,7 @@ class HomeAssistantUI {
|
|||||||
int viewCounter = 0;
|
int viewCounter = 0;
|
||||||
Logger.d("--Views count: ${rawLovelaceConfig['views'].length}");
|
Logger.d("--Views count: ${rawLovelaceConfig['views'].length}");
|
||||||
rawLovelaceConfig["views"].forEach((rawView){
|
rawLovelaceConfig["views"].forEach((rawView){
|
||||||
Logger.d("----view id: ${rawView['id']}");
|
Logger.d("----view: ${rawView['path'] ?? viewCounter}");
|
||||||
HAView view = HAView(
|
HAView view = HAView(
|
||||||
count: viewCounter,
|
count: viewCounter,
|
||||||
rawData: rawView
|
rawData: rawView
|
||||||
|
@ -6,6 +6,7 @@ class HAView {
|
|||||||
Entity linkedEntity;
|
Entity linkedEntity;
|
||||||
String name;
|
String name;
|
||||||
String id;
|
String id;
|
||||||
|
String path;
|
||||||
String iconName;
|
String iconName;
|
||||||
final int count;
|
final int count;
|
||||||
bool isPanel;
|
bool isPanel;
|
||||||
@ -15,6 +16,7 @@ class HAView {
|
|||||||
name = rawData['title'];
|
name = rawData['title'];
|
||||||
iconName = rawData['icon'];
|
iconName = rawData['icon'];
|
||||||
isPanel = rawData['panel'] ?? false;
|
isPanel = rawData['panel'] ?? false;
|
||||||
|
path = rawData['path'] ?? '$count';
|
||||||
|
|
||||||
if (rawData['badges'] != null && !isPanel) {
|
if (rawData['badges'] != null && !isPanel) {
|
||||||
badges = CardData.parse({
|
badges = CardData.parse({
|
||||||
|
Reference in New Issue
Block a user