package de.nbscloud.dashboard.controller;

import de.nbscloud.webcontainer.registry.AppRegistry;
import de.nbscloud.webcontainer.shared.config.WebContainerSharedConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpServletRequest;

@Controller
public class DashboardController {

    @Autowired
    private WebContainerSharedConfig webContainerSharedConfig;
    @Autowired
    private AppRegistry appRegistry;

    @GetMapping("/dashboard")
    public String start(Model model, HttpServletRequest httpServletRequest, String sortOrder)  {
        model.addAttribute("apps", this.appRegistry.getAll());
        this.webContainerSharedConfig.addDefaults(model);

        return "dashboard/index";
    }
}
