package de.nbscloud.webcontainer.shared.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.ui.Model;

@Configuration
@ConfigurationProperties(prefix = "nbs-cloud.web-container.shared")
@PropertySource("classpath:/config/shared-application.properties")
public class WebContainerSharedConfig {
    private String version;
    private boolean darkMode;

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public boolean isDarkMode() {
        return darkMode;
    }

    public void setDarkMode(boolean darkMode) {
        this.darkMode = darkMode;
    }

    public void addDefaults(Model model) {
        addDarkMode(model);
        addVersionAttribute(model);
    }

    private final void addVersionAttribute(Model model) {
        model.addAttribute("nbsVersion", this.version);
    }

    private final void addDarkMode(Model model) {
        model.addAttribute("darkMode", this.darkMode);
    }
}
