package org.ccalm.weather;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class MainController {
	
	@CrossOrigin
	@GetMapping("/")
    @ResponseBody
	public String getIndex(Model model) {
		return "The weather list is working! <br><a href=\"./geodatalist/\">/geodatalist/</a>";
	}

	@CrossOrigin
	@GetMapping("/geodatalist")
    @ResponseBody
	public String getGeoDataList(Model model) {
		String html="";
		html+="<a href=\"./AirTemperatureDates\">AirTemperatureDates</a><br><form action=\"./AirTemperature\" method=\"get\"><label for=\"fname\">Date:</label><input type=\"text\" name=\"date\" value=\"20210826\"><input type=\"submit\" value=\"Submit\"></form><br>";
		html+="<a href=\"./PrecipitationDates\">PrecipitationDates</a><br><form action=\"./Precipitation\" method=\"get\"><label for=\"fname\">Date:</label><input type=\"text\" name=\"date\" value=\"20210826\"><input type=\"submit\" value=\"Submit\"></form><br>";
		html+="<a href=\"./SoilDates\">SoilDates</a><br><form action=\"./DownloadSoil\" method=\"get\"><label for=\"fname\">Date:</label><input type=\"text\" name=\"date\" value=\"20210826\"><label for=\"forecast\">Forecast:</label><input type=\"text\" name=\"forecast\" value=\"000\"><input type=\"submit\" value=\"Submit\"></form><br>";
		return html;
	}
	
}