Exemplo n.º 1
0
func RenderSettingsPage() string {
	page := html_page.CreateHtmlPage()

	list := html_page.CreateHtmlList()
	list.AddElement(html_page.CreateHtmlLink("/settings/set-project-root", "Set project root folder"))
	list.AddElement(html_page.CreateHtmlLink("/settings/edit-sonar-project-properties", "Edit sonar-project.properties"))
	list.AddElement(html_page.CreateHtmlLink("/settings/users", "Manage users"))
	list.AddElement(html_page.CreateHtmlLink("/settings/analize", "Configure analize"))

	page.Body.AddElement(list)

	return page.Render()
}
Exemplo n.º 2
0
func RenderUsersPage(users []User) string {
	page := html_page.CreateHtmlPage()

	page.Body.AddElement(html_page.CreateHtmlLink("/settings/users/create", "Create New User"))

	list := html_page.CreateHtmlList()
	for _, u := range users {
		destinationUrl := "/settings/users/edit"
		params := map[string]string{
			"user": u.Login,
		}
		list.AddElement(html_page.CreateHtmlLink(prepareUrlWithParams(destinationUrl, params), u.Login))
	}

	page.Body.AddElement(list)

	return page.Render()
}
Exemplo n.º 3
0
func RenderFilesListPage(fileBasePath string, files []os.FileInfo) string {
	page := html_page.CreateHtmlPage()

	list := html_page.CreateHtmlList()
	page.Body.AddElement(list)

	// Link to parent directory
	parentDirFullName := fileBasePath + string(os.PathSeparator) + ".."
	list.AddElement(html_page.CreateHtmlLink(prepareDirNavigateLink(parentDirFullName), ".."))

	sonarProjectPropertiesFileFound := false
	for _, file := range files {

		if "sonar-project.properties" == file.Name() {
			sonarProjectPropertiesFileFound = true
		}

		if file.IsDir() {
			fullName := fileBasePath + string(os.PathSeparator) + file.Name()
			list.AddElement(html_page.CreateHtmlLink(prepareDirNavigateLink(fullName), file.Name()))
		} else {
			list.AddElement(html_page.CreatePlainHtmlElement(file.Name()))
		}
	}

	if sonarProjectPropertiesFileFound {
		destinationUrl := "/settings/set-project-root"
		params := map[string]string{
			"action": "set",
			"path":   fileBasePath,
		}
		page.Body.AddElement(html_page.CreateHtmlLink(prepareUrlWithParams(destinationUrl, params), "SET CURRENT DIRECTORY"))
	} else {
		destinationUrl := "/settings/set-project-root"
		params := map[string]string{
			"action": "createfile",
			"path":   fileBasePath,
		}
		page.Body.AddElement(html_page.CreateHtmlLink(prepareUrlWithParams(destinationUrl, params), "Create sonar-project.properties"))
	}

	return page.Render()
}
Exemplo n.º 4
0
func RenderMainPage(analyzeRunning bool, user *User) string {
	page := html_page.CreateHtmlPage()
	if user != nil {
		page.Header = user.Login
		fmt.Print(user.Login)
	} else {
		page.Header = ANONIMOUS_USER_LOGIN
	}

	if analyzeRunning {
		page.Body.AddElement(html_page.CreatePlainHtmlElement("Analyze in process..."))
	}

	list := html_page.CreateHtmlList()
	page.Body.AddElement(list)

	if !analyzeRunning && user != nil && user.Rights.CanRunAlanize {
		list.AddElement(html_page.CreateHtmlLink("/analyze/run", "Run analyze"))
	}
	list.AddElement(html_page.CreateHtmlLink("/analyze/log", "See last run log"))

	return page.Render()
}