qJake / HADotNet.CommandCenter

📱 A web-based, wall-mountable command center for Home Assistant.
https://hacc.dev
Apache License 2.0
158 stars 11 forks source link

Allow wildcard includes in config.json to parse additional page json files #134

Open siege9929 opened 1 year ago

siege9929 commented 1 year ago

Describe the new functionality

Allow includes in the config.json file so that we can create one json file per page. It's often easier for me to manually create pages via copying sections and editing a few variables, especially when I have an interface that includes common elements on every page like a row of nav buttons. If the config file allowed wildcard includes, I could copy a page json file, edit a few things, and have a new page with predefined tiles.

Additionally, it could be nice to add an option for a layout section of tiles that spans multiple pages, so I only have to set them up and edit them one time, instead of once per page. Again this would be nice for a nav bar or a header.

What will it look like in the Admin area?

No change

What will it look like on the dashboard?

No change.

github-actions[bot] commented 1 year ago

Hey there, looks like this is your first time submitting a bug or enhancement to HACC! Thanks for helping make HACC a better app! 🎉

qJake commented 1 year ago

Would you be able to provide a sample (JSON markup or similar) of what this would look like?

siege9929 commented 1 year ago

Sure! Something like this. In the main config.json, add a section to "pages" listing files or directories of files to include:

"pages": [
    {
        "files": [
            "./page1.json",
            "./data/page2.json"
        ],
        "directories": [
            "./page1/",
            "./data/page2/"
        ]
    },
    ... other pages below
]

Each of the files directly included or included in the directories would contain one or more sections that would normally be inside the "pages" section, so a file would look like this:

{
    "name": "default",
    "description": "Default Page",
    "isDefaultPage": true,
    "autoReturnSeconds": 0,
    "tiles": [
        {
            "name": "Tile",
            "sizeX": 2,
            "sizeY": 2,
            "type": "state"
        }
    ]
}

Spanning multiple pages is less important to me, but I suppose you could define a page section with a "span" key where you could list page names that it appears on.