package routers

import (
	"oc-search/controllers"
	"os"

	"github.com/beego/beego/v2/core/logs"
	beego "github.com/beego/beego/v2/server/web"
)

func init() {

	// Remove old swagger comments
	err := os.Remove("routers/commentsRouter_controllers.go")
	if err != nil {
		logs.Warning("Couldn't remove comments file: " + err.Error())
	}

	beego.Router("/", &controllers.MainController{})
	beego.Router("/search", &controllers.SearchController{})

	beego.Router("/login", &controllers.LoginController{})
	beego.Router("/oidc", &controllers.OidcController{}, "get:Connect")
	beego.Router("/oidc-callback", &controllers.OidcController{}, "*:Callback")
	beego.Router("/user", &controllers.UserController{})
	beego.Router("/workflow", &controllers.WorkflowController{})
	beego.Router("/workflow/open", &controllers.WorkflowController{}, "*:Open")
	beego.Router("/workflow/save", &controllers.WorkflowController{}, "*:Save")
	beego.Router("/workflow/export", &controllers.WorkflowController{}, "*:Export")
	beego.Router("/schedule", &controllers.ScheduleController{})
	beego.Router("/map", &controllers.MapController{})
	beego.Router("/datacenter", &controllers.DatacenterController{})

	// beego.Router("/workspace", &controllers.WorkspaceController{})

	// Details of the resources
	beego.AddNamespace(
		beego.NewNamespace(
			"/details", beego.NSInclude(&controllers.DetailsController{}),
		),
		beego.NewNamespace(
			"/workspace", beego.NSInclude(&controllers.WorkspaceController{}),
		),
	)
	// beego.Router("/details/?:id", &controllers.DetailsController{})

	// Feed data
	beego.Router("/partner", &controllers.PartnerController{})
	beego.Router("/item", &controllers.ItemController{})
	beego.Router("/item/add", &controllers.ItemController{}, "*:Add")

}
