예제 #1
0
func RenderLoginPage(loginError *error) string {
	page := html_page.CreateHtmlPage()

	if loginError != nil {
		errorText := (*loginError).Error()
		page.Body.AddElement(html_page.CreatePlainHtmlElement(errorText))
	}

	form := html_page.CreateHtmlForm("/login", "loginCredentials")
	layout := html_page.CreateTwoColumnTableLayout()

	loginLabel := html_page.CreatePlainHtmlElement("Login")
	loginInput := html_page.CreateHtmlInputElement(html_page.INPUT_TEXT, "login")
	layout.AddRow(loginLabel, loginInput)

	passwordLabel := html_page.CreatePlainHtmlElement("Password")
	passwordInput := html_page.CreateHtmlInputElement(html_page.INPUT_TEXT, "password")
	layout.AddRow(passwordLabel, passwordInput)

	form.AddElement(layout)
	submitButton := html_page.CreateHtmlInputElement(html_page.INPUT_SUBMIT, "submit")
	submitButton.Value = "Submit"
	form.AddElement(submitButton)

	page.Body.AddElement(form)

	return page.Render()
}
예제 #2
0
func RenderSonarRunnedPage(alreadyRunned bool) string {
	page := html_page.CreateHtmlPage()

	if alreadyRunned {
		page.Body.AddElement(html_page.CreatePlainHtmlElement("<h1>Sonar runner is already running</h1>"))
	} else {
		page.Body.AddElement(html_page.CreatePlainHtmlElement("<h1>Sonar runner runned</h1>"))
	}

	return page.Render()
}
예제 #3
0
func RenderAnalyzeLogPage(logText string) string {
	page := html_page.CreateHtmlPage()

	page.Body.AddElement(html_page.CreatePlainHtmlElement(strings.Replace(logText, "\n", "<br />\n", -1)))

	return page.Render()
}
예제 #4
0
func RenderErrorPage(errorMessage string) string {
	page := html_page.CreateHtmlPage()

	page.Body.AddElement(html_page.CreatePlainHtmlElement(errorMessage))

	return page.Render()
}
예제 #5
0
func RenderHelpPage() string {
	page := html_page.CreateHtmlPage()

	page.Body.AddElement(html_page.CreatePlainHtmlElement("Help"))

	return page.Render()
}
예제 #6
0
func RenderSuccessPage(successMessage string) string {
	page := html_page.CreateHtmlPage()

	page.Body.AddElement(html_page.CreatePlainHtmlElement(successMessage))

	return page.Render()
}
예제 #7
0
func RenderEditUserPage(user *User) string {

	if user == nil {
		user = new(User)
	}

	page := html_page.CreateHtmlPage()

	form := html_page.CreateHtmlForm("/settings/users/submitEdit", "userEdir")

	layout := html_page.CreateTwoColumnTableLayout()
	loginLabel := html_page.CreatePlainHtmlElement("Login")
	loginInput := html_page.CreateHtmlInputElement(html_page.INPUT_TEXT, "login")
	loginInput.Value = user.Login
	if user.Login != "" {
		loginInput.NotEditable = true
	}
	layout.AddRow(loginLabel, loginInput)

	passwordLabel := html_page.CreatePlainHtmlElement("Password")
	passwordInput := html_page.CreateHtmlInputElement(html_page.INPUT_TEXT, "password")
	passwordInput.Value = user.Password
	layout.AddRow(passwordLabel, passwordInput)

	canEditConfigsLabel := html_page.CreatePlainHtmlElement("Can edit configs")
	canEditConfigsCheckbox := html_page.CreateHtmlInputElement(html_page.INPUT_CHECKBOX, "canEditConfigsCheckbox")
	canEditConfigsCheckbox.Value = strconv.FormatBool(user.Rights.CanEditConfigs)
	layout.AddRow(canEditConfigsLabel, canEditConfigsCheckbox)

	canRunAlanizeLabel := html_page.CreatePlainHtmlElement("Can run analize")
	canRunAlanizeCheckbox := html_page.CreateHtmlInputElement(html_page.INPUT_CHECKBOX, "canRunAlanizeCheckbox")
	canRunAlanizeCheckbox.Value = strconv.FormatBool(user.Rights.CanRunAlanize)
	layout.AddRow(canRunAlanizeLabel, canRunAlanizeCheckbox)

	form.AddElement(layout)
	submitButton := html_page.CreateHtmlInputElement(html_page.INPUT_SUBMIT, "submit")
	submitButton.Value = "Submit"
	form.AddElement(submitButton)

	page.Body.AddElement(form)

	return page.Render()
}
예제 #8
0
func RenderStatusPage(mysqlRunning bool, sonarqubeRunning bool) string {
	cells := make(map[string]string)
	cells["MySQL running"] = strconv.FormatBool(mysqlRunning)
	cells["SonarQube running"] = strconv.FormatBool(sonarqubeRunning)

	page := html_page.CreateHtmlPage()
	table := RenderTable(cells)
	page.Body.AddElement(html_page.CreatePlainHtmlElement(table))

	return page.Render()
}
예제 #9
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()
}
예제 #10
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()
}