Skip to content

feat(web, server): Ability to use config file instead of admin UI - #3836

Merged
jrasm91 merged 29 commits into
immich-app:mainfrom
danieldietzler:main
Aug 25, 2023
Merged

jrasm91 merged 29 commits into
immich-app:mainfrom
danieldietzler:main

Conversation

@danieldietzler

@danieldietzler danieldietzler commented Aug 22, 2023 •

Copy link
Copy Markdown
Member

This PR closes #3774, providing the ability to use a JSON config file instead of the admin UI.

Currently, the admin UI and the config file are mutually exclusive while the config file always takes precedence. So, if a config file is specified, changes in the admin UI are not possible anymore.
To get people started with this quickly, there is a new copy to clipboard button that allows to copy the entire config as a formatted JSON string.

If also added documentation for the new env variable, but I wasn't sure where to put the documentation for the config file.

Screenshot 2023-08-23 at 11 39 01 Screenshot 2023-08-23 at 11 34 31

@vercel

vercel Bot commented Aug 22, 2023 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
immich ⬜️ Ignored (Inspect) Visit Preview Aug 25, 2023 5:01pm

@danieldietzler danieldietzler changed the title feat(web, server): Use a config file instead of the admin UI feat(web, server): Ability to use config file instead of admin UI Aug 22, 2023

@mertalev mertalev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for picking this up!

Comment thread server/src/domain/system-config/dto/system-config.dto.ts Outdated
Comment thread server/src/domain/system-config/system-config.core.ts Outdated
Comment thread web/src/routes/admin/system-settings/+page.svelte Outdated
Comment thread server/src/domain/auth/auth.service.spec.ts Outdated
Comment thread server/src/domain/system-config/dto/system-config.dto.ts Outdated
@jrasm91

jrasm91 commented Aug 22, 2023

Copy link
Copy Markdown
Member

This looks really good. Looking at it now, I'm wondering if maybe it would be better to move the read config file method to the config repository instead of the storage repository, since that would reduce a lot of unnecessary changes in this PR.

@danieldietzler

danieldietzler commented Aug 22, 2023 •

Copy link
Copy Markdown
Member Author

Yeah, that was quite an adventure... :D
I asked about this beforehand (in the issue) and this was suggested. This is my first suggestion, so I am really new to the code base and don't know where methods make the most sense. (Sorry, I did not notice it was you @jrasm91... @mertalev and you have quite a similar profile pic and I did not read the names)

So, if you'd say that it would make more sense in the config repository, I sure can change it! This would make this PR a lot slimmer and simpler ;)
Alternatively, we can also wait for others to chime in, maybe there are some people who have opinions on this.

@danieldietzler

Copy link
Copy Markdown
Member Author

At least I got to know the code base a bit by this ^^

@jrasm91

jrasm91 commented Aug 22, 2023

Copy link
Copy Markdown
Member

Yeah, I don't think there are strong preferences either way. I'm probably the primary developer in this area of the codebase and I'm good either way. I think it would be simpler myself and thought of it after posting my comment yesterday. Usually it is nice to keep related functions together, so reading a file naturally could belong with all the other file operations in the storage repository, but in this case that makes that change quite unwieldy and I don't see much benefit requiring it to be there. I usually prefer simplicity and moving it to the config repository would make it considerably simpler.

@danieldietzler

Copy link
Copy Markdown
Member Author

On the other hand, now that I've refactored the method to read files in general, if there should be some other use case at some time where reading files would be needed again, the logic would then already be in the right place. So, it would make the life of future devs easier :)

@jrasm91

jrasm91 commented Aug 22, 2023

Copy link
Copy Markdown
Member

True although, it is trivial to add that again if needed 😛

@danieldietzler

danieldietzler commented Aug 22, 2023 •

Copy link
Copy Markdown
Member Author

Sure, but this would result in duplicate code unless you streamline the config file process then, at which point you would have a bit more to do.

@bo0tzz bo0tzz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for picking this up!

I wasn't sure where to put the documentation for the config file.

This would probably suit a new page under docs/docs/install, after the env vars page.

Comment thread server/src/domain/system-config/system-config.core.ts Outdated
Comment thread server/src/domain/system-config/dto/system-config.dto.ts Outdated
@bo0tzz

bo0tzz commented Aug 22, 2023

Copy link
Copy Markdown
Member

As for the file reading discussion: Reading a file from disk is a relatively trivial event, so I don't think we need to anticipate much future need there. It's probably best to just take the simplest approach/with the least changes needed.

@mertalev mertalev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's good once isConfigFile and validation are sorted out.

Comment thread server/src/domain/system-config/dto/system-config.dto.ts Outdated
Comment thread server/src/domain/system-config/system-config.core.ts Outdated
@alextran1502

Copy link
Copy Markdown
Member

Hello, can you please include a screenshot of the UI elements?

@danieldietzler

Copy link
Copy Markdown
Member Author

Why did the intl version change just from running make api? I don't think I should change the version in the pubspec.yaml, right?

@mertalev

Copy link
Copy Markdown
Member

Not sure, but your openapi-generator version might be different than what's on main. I'd run npm ci in server and try again.

@jrasm91

jrasm91 commented Aug 25, 2023

Copy link
Copy Markdown
Member

I think this is actually pinned in a patch file that probably isn't getting applied properly.

@danieldietzler

Copy link
Copy Markdown
Member Author

Not sure, but your openapi-generator version might be different than what's on main. I'd run npm ci in server and try again.

That unfortunately did not do the trick.

@danieldietzler

danieldietzler commented Aug 25, 2023 •

Copy link
Copy Markdown
Member Author

I think this is actually pinned in a patch file that probably isn't getting applied properly.

Sorry, but I can't seem to find any patch file that would be related to this. Also, they are generated and should not be touched either, right?
What do you propose I try, or are you debugging yourself already and trying to fix the issue?

Comment thread server/src/domain/server-info/server-info.dto.ts Outdated
@jrasm91

jrasm91 commented Aug 25, 2023

Copy link
Copy Markdown
Member

Added a few things:

  • Renamed to IMMICH_CONFIG_FILE
  • Show a notification after clicking copy to clipboard
  • Add a button to export to json
  • Validate the file (after merging it with the default configuration). This also throws errors for unknown keys
  • Always show copy/export buttons, even when config is disabled.

@jrasm91
jrasm91 removed the request for review from mertalev August 25, 2023 16:19
@danieldietzler

Copy link
Copy Markdown
Member Author

Thanks a lot! :)

@jrasm91
jrasm91 merged commit 59bb727 into immich-app:main Aug 25, 2023
@bo0tzz

bo0tzz commented Aug 25, 2023

Copy link
Copy Markdown
Member

Thank you for the PR!

martabal pushed a commit that referenced this pull request Sep 11, 2023
)

* implement method to read config file

* getConfig returns config file if present

* return isConfigFile for http requests

* disable elements if config file is used, show message if config file is set, copy existing config to clipboard

* fix allowing partial configuration files

* add new env variable to docs

* fix tests

* minor refactoring, address review

* adapt config type in frontend

* remove unnecessary imports

* move config file reading to system-config repo

* add documentation

* fix code formatting in system settings page

* add validator for config file

* fix formatting in docs

* update generated files

* throw error when trying to update config. e.g. via cli or api

* switch to feature flags for isConfigFile

* refactoring

* refactor: config file

* chore: open api

* feat: always show copy/export buttons

* fix: default flags

* refactor: copy to clipboard

---------

Co-authored-by: Jason Rasmussen <jrasm91@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Config file support

5 participants