package com.eactive.testmaster.client.controller;

import com.eactive.testmaster.server.entity.Server;
import com.eactive.testmaster.server.repository.ServerRepository;
import java.util.List;
import org.springframework.security.access.annotation.Secured;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;

@Controller
public class ApiClientPageController {

    private final ServerRepository serverRepository;

    public ApiClientPageController(ServerRepository serverRepository) {
        this.serverRepository = serverRepository;
    }

    @GetMapping("/mgmt/api_tester.do")
    @Secured("ROLE_API_TESTER")
    public String testView(ModelMap model) {

        List<Server> servers = serverRepository.findAllByEnabledIs(true);
        model.addAttribute("servers", servers);

        return "page/tester/apiTester";
    }

}
