Esempio n. 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()
}
Esempio n. 2
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()
}