示例#1
0
func (c *ListController) Get() {
	c.TplName = "filesystem/glusterfs/volume/list.html"
	guimessage := guimessagedisplay.GetGUIMessage(c)

	// Authorization for web page display
	c.Data["layoutMenu"] = c.GetSession("layoutMenu")
	// Authorization for Button
	user, _ := c.GetSession("user").(*rbac.User)
	identity.SetPrivilegeHiddenTag(c.Data, "hiddenTagGuiFileSystemGlusterfsClusterList", user, "GET", "/gui/filesystem/glusterfs/cluster/list")
	identity.SetPrivilegeHiddenTag(c.Data, "hiddenTagGuifFileSystemGlusterfsVolumeCreate", user, "GET", "/gui/filesystem/glusterfs/volume/create")
	// Tag won't work in loop so need to be placed in data
	hasHiddenTagGuiFileSystemGlusterfsVolumeReset := user.HasPermission(identity.GetConponentName(), "GET", "/gui/filesystem/glusterfs/volume/reset")
	hasHiddenTagGuiFileSystemGlusterfsVolumeDelete := user.HasPermission(identity.GetConponentName(), "GET", "/gui/filesystem/glusterfs/volume/delete")

	cloudoneProtocol := beego.AppConfig.String("cloudoneProtocol")
	cloudoneHost := beego.AppConfig.String("cloudoneHost")
	cloudonePort := beego.AppConfig.String("cloudonePort")

	clusterName := c.GetString("clusterName")

	url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
		"/api/v1/glusterfs/clusters/" + clusterName + "/volumes/"

	glusterfsVolumeSlice := make([]GlusterfsVolume, 0)

	tokenHeaderMap, _ := c.GetSession("tokenHeaderMap").(map[string]string)

	_, err := restclient.RequestGetWithStructure(url, &glusterfsVolumeSlice, tokenHeaderMap)

	if identity.IsTokenInvalidAndRedirect(c, c.Ctx, err) {
		return
	}

	if err != nil {
		// Error
		guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
	} else {
		for i := 0; i < len(glusterfsVolumeSlice); i++ {
			glusterfsVolumeSlice[i].ClusterName = clusterName

			if hasHiddenTagGuiFileSystemGlusterfsVolumeReset {
				glusterfsVolumeSlice[i].HiddenTagGuiFileSystemGlusterfsVolumeReset = "<div class='btn-group'>"
			} else {
				glusterfsVolumeSlice[i].HiddenTagGuiFileSystemGlusterfsVolumeReset = "<div hidden>"
			}
			if hasHiddenTagGuiFileSystemGlusterfsVolumeDelete {
				glusterfsVolumeSlice[i].HiddenTagGuiFileSystemGlusterfsVolumeDelete = "<div class='btn-group'>"
			} else {
				glusterfsVolumeSlice[i].HiddenTagGuiFileSystemGlusterfsVolumeDelete = "<div hidden>"
			}
		}

		c.Data["glusterfsVolumeSlice"] = glusterfsVolumeSlice
		c.Data["clusterName"] = clusterName
	}

	guimessage.OutputMessage(c.Data)
}
示例#2
0
func (c *ListController) Get() {
	c.TplName = "repository/thirdparty/list.html"
	guimessage := guimessagedisplay.GetGUIMessage(c)

	// Authorization for web page display
	c.Data["layoutMenu"] = c.GetSession("layoutMenu")
	// Authorization for Button
	user, _ := c.GetSession("user").(*rbac.User)
	identity.SetPrivilegeHiddenTag(c.Data, "hiddenTagGuiRepositoryThirdPartyEdit", user, "GET", "/gui/repository/thirdparty/edit")
	// Tag won't work in loop so need to be placed in data
	hasGuiRepositoryThirdPartyLaunch := user.HasPermission(identity.GetConponentName(), "GET", "/gui/repository/thirdparty/launch")
	hasGuiRepositoryThirdPartyEdit := user.HasPermission(identity.GetConponentName(), "GET", "/gui/repository/thirdparty/edit")
	hasGuiRepositoryThirdPartyDelete := user.HasPermission(identity.GetConponentName(), "GET", "/gui/repository/thirdparty/delete")

	cloudoneProtocol := beego.AppConfig.String("cloudoneProtocol")
	cloudoneHost := beego.AppConfig.String("cloudoneHost")
	cloudonePort := beego.AppConfig.String("cloudonePort")

	url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
		"/api/v1/clusterapplications/"

	thirdPartyApplicationSlice := make([]ThirdPartyApplication, 0)

	tokenHeaderMap, _ := c.GetSession("tokenHeaderMap").(map[string]string)

	_, err := restclient.RequestGetWithStructure(url, &thirdPartyApplicationSlice, tokenHeaderMap)

	if identity.IsTokenInvalidAndRedirect(c, c.Ctx, err) {
		return
	}

	if err != nil {
		// Error
		guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
	} else {
		for i := 0; i < len(thirdPartyApplicationSlice); i++ {
			if hasGuiRepositoryThirdPartyLaunch {
				thirdPartyApplicationSlice[i].HiddenTagGuiRepositoryThirdPartyLaunch = "<div class='btn-group'>"
			} else {
				thirdPartyApplicationSlice[i].HiddenTagGuiRepositoryThirdPartyLaunch = "<div hidden>"
			}
			if hasGuiRepositoryThirdPartyEdit {
				thirdPartyApplicationSlice[i].HiddenTagGuiRepositoryThirdPartyEdit = "<div class='btn-group'>"
			} else {
				thirdPartyApplicationSlice[i].HiddenTagGuiRepositoryThirdPartyEdit = "<div hidden>"
			}
			if hasGuiRepositoryThirdPartyDelete {
				thirdPartyApplicationSlice[i].HiddenTagGuiRepositoryThirdPartyDelete = "<div class='btn-group'>"
			} else {
				thirdPartyApplicationSlice[i].HiddenTagGuiRepositoryThirdPartyDelete = "<div hidden>"
			}
		}

		sort.Sort(ByThirdPartyApplication(thirdPartyApplicationSlice))
		c.Data["thirdPartyApplicationSlice"] = thirdPartyApplicationSlice
	}

	guimessage.OutputMessage(c.Data)
}
示例#3
0
func (c *ListController) Get() {
	c.TplName = "system/privateregistry/image/list.html"
	guimessage := guimessagedisplay.GetGUIMessage(c)

	serverName := c.GetString("serverName")
	repositoryName := c.GetString("repositoryName")

	c.Data["serverName"] = serverName

	// Authorization for web page display
	c.Data["layoutMenu"] = c.GetSession("layoutMenu")
	// Authorization for Button
	user, _ := c.GetSession("user").(*rbac.User)
	identity.SetPrivilegeHiddenTag(c.Data, "hiddenTagGuiSystemPrivateRegistryRepositoryList", user, "GET", "/gui/system/privateregistry/repository/list")
	// Tag won't work in loop so need to be placed in data
	hasGuiSystemPrivateRegistryImageDelete := user.HasPermission(identity.GetConponentName(), "GET", "/gui/system/privateregistry/image/delete")

	cloudoneProtocol := beego.AppConfig.String("cloudoneProtocol")
	cloudoneHost := beego.AppConfig.String("cloudoneHost")
	cloudonePort := beego.AppConfig.String("cloudonePort")

	url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
		"/api/v1/privateregistries/servers/" + serverName + "/repositories/" + repositoryName + "/tags/"

	tagSlice := make([]string, 0)

	tokenHeaderMap, _ := c.GetSession("tokenHeaderMap").(map[string]string)

	_, err := restclient.RequestGetWithStructure(url, &tagSlice, tokenHeaderMap)

	if identity.IsTokenInvalidAndRedirect(c, c.Ctx, err) {
		return
	}

	if err != nil {
		// Error
		guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
	} else {
		imageSlice := make([]Image, 0)
		for _, tag := range tagSlice {
			imageSlice = append(imageSlice, Image{tag, serverName, repositoryName, ""})
		}

		for i := 0; i < len(imageSlice); i++ {
			if hasGuiSystemPrivateRegistryImageDelete {
				imageSlice[i].HiddenTagGuiSystemPrivateRegistryImageDelete = "<div class='btn-group'>"
			} else {
				imageSlice[i].HiddenTagGuiSystemPrivateRegistryImageDelete = "<div hidden>"
			}
		}

		sort.Sort(ByImage(imageSlice))
		c.Data["imageSlice"] = imageSlice
	}

	guimessage.OutputMessage(c.Data)
}
示例#4
0
func (c *ListController) Get() {
	c.TplName = "system/rbac/role/list.html"
	guimessage := guimessagedisplay.GetGUIMessage(c)

	// Authorization for web page display
	c.Data["layoutMenu"] = c.GetSession("layoutMenu")
	// System RBAC tab menu
	user, _ := c.GetSession("user").(*rbac.User)
	c.Data["systemRBACTabMenu"] = identity.GetSystemRBACTabMenu(user, "role")
	// Authorization for Button
	identity.SetPrivilegeHiddenTag(c.Data, "hiddenTagGuiSystemRBACRoleEdit", user, "GET", "/gui/system/rbac/role/edit")
	// Tag won't work in loop so need to be placed in data
	hasGuiSystemRBACRoleEdit := user.HasPermission(identity.GetConponentName(), "GET", "/gui/system/rbac/role/edit")
	hasGuiSystemRBACRoleDelete := user.HasPermission(identity.GetConponentName(), "GET", "/gui/system/rbac/role/delete")

	cloudoneProtocol := beego.AppConfig.String("cloudoneProtocol")
	cloudoneHost := beego.AppConfig.String("cloudoneHost")
	cloudonePort := beego.AppConfig.String("cloudonePort")

	url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
		"/api/v1/authorizations/roles"

	simplifiedRoleSlice := make([]SimplifiedRole, 0)

	tokenHeaderMap, _ := c.GetSession("tokenHeaderMap").(map[string]string)

	_, err := restclient.RequestGetWithStructure(url, &simplifiedRoleSlice, tokenHeaderMap)

	if identity.IsTokenInvalidAndRedirect(c, c.Ctx, err) {
		return
	}

	if err != nil {
		// Error
		guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
	} else {
		for i := 0; i < len(simplifiedRoleSlice); i++ {
			if hasGuiSystemRBACRoleEdit {
				simplifiedRoleSlice[i].HiddenTagGuiSystemRBACRoleEdit = "<div class='btn-group'>"
			} else {
				simplifiedRoleSlice[i].HiddenTagGuiSystemRBACRoleEdit = "<div hidden>"
			}
			if hasGuiSystemRBACRoleDelete {
				simplifiedRoleSlice[i].HiddenTagGuiSystemRBACRoleDelete = "<div class='btn-group'>"
			} else {
				simplifiedRoleSlice[i].HiddenTagGuiSystemRBACRoleDelete = "<div hidden>"
			}
		}

		sort.Sort(BySimplifiedRole(simplifiedRoleSlice))
		c.Data["simplifiedRoleSlice"] = simplifiedRoleSlice
	}

	guimessage.OutputMessage(c.Data)
}
示例#5
0
func (c *ListController) Get() {
	c.TplName = "repository/imagerecord/list.html"
	guimessage := guimessagedisplay.GetGUIMessage(c)

	// Authorization for web page display
	c.Data["layoutMenu"] = c.GetSession("layoutMenu")
	// Authorization for Button
	user, _ := c.GetSession("user").(*rbac.User)
	identity.SetPrivilegeHiddenTag(c.Data, "hiddenTagGuiRepositoryImageInformationList", user, "GET", "/gui/repository/imageinformation/list")
	// Tag won't work in loop so need to be placed in data
	hasGuiRepositoryImageRecordLog := user.HasPermission(identity.GetConponentName(), "GET", "/gui/repository/imagerecord/log")
	hasGuiRepositoryImageRecordDelete := user.HasPermission(identity.GetConponentName(), "GET", "/gui/repository/imagerecord/delete")

	cloudoneProtocol := beego.AppConfig.String("cloudoneProtocol")
	cloudoneHost := beego.AppConfig.String("cloudoneHost")
	cloudonePort := beego.AppConfig.String("cloudonePort")

	name := c.GetString("name")

	url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
		"/api/v1/imagerecords/" + name

	imageRecordSlice := make([]ImageRecord, 0)

	tokenHeaderMap, _ := c.GetSession("tokenHeaderMap").(map[string]string)

	returnedJsonMap, err := restclient.RequestGetWithStructure(url, &imageRecordSlice, tokenHeaderMap)

	if identity.IsTokenInvalidAndRedirect(c, c.Ctx, err) {
		return
	}

	if err != nil {
		errorJsonMap, _ := returnedJsonMap.(map[string]interface{})
		errorMessage, _ := errorJsonMap["ErrorMessage"].(string)
		if strings.HasPrefix(errorMessage, "100: Key not found") {

		} else {
			// Error
			guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
		}
	}

	for i := 0; i < len(imageRecordSlice); i++ {
		if imageRecordSlice[i].Failure {
			imageRecordSlice[i].FieldFailureStyleColor = "red"
		}
		if hasGuiRepositoryImageRecordLog {
			imageRecordSlice[i].HiddenTagGuiRepositoryImageRecordLog = "<div class='btn-group'>"
		} else {
			imageRecordSlice[i].HiddenTagGuiRepositoryImageRecordLog = "<div hidden>"
		}
		if hasGuiRepositoryImageRecordDelete {
			imageRecordSlice[i].HiddenTagGuiRepositoryImageRecordDelete = "<div class='btn-group'>"
		} else {
			imageRecordSlice[i].HiddenTagGuiRepositoryImageRecordDelete = "<div hidden>"
		}
	}

	sort.Sort(ByImageRecord(imageRecordSlice))
	c.Data["imageRecordSlice"] = imageRecordSlice

	guimessage.OutputMessage(c.Data)
}
示例#6
0
func (c *ListController) Get() {
	c.TplName = "inventory/replicationcontroller/list.html"
	guimessage := guimessagedisplay.GetGUIMessage(c)

	// Authorization for web page display
	c.Data["layoutMenu"] = c.GetSession("layoutMenu")
	// Authorization for Button
	user, _ := c.GetSession("user").(*rbac.User)
	identity.SetPrivilegeHiddenTag(c.Data, "hiddenTagGuiInventoryReplicationControllerEdit", user, "GET", "/gui/inventory/replicationcontroller/edit")
	// Tag won't work in loop so need to be placed in data
	hasGuiInventoryReplicationControllerSize := user.HasPermission(identity.GetConponentName(), "GET", "/gui/inventory/replicationcontroller/size")
	hasGuiInventoryReplicationControllerDelete := user.HasPermission(identity.GetConponentName(), "GET", "/gui/inventory/replicationcontroller/delete")
	hasGuiInventoryReplicationControllerPodlog := user.HasPermission(identity.GetConponentName(), "GET", "/gui/inventory/replicationcontroller/pod/log")
	hasGuiInventoryReplicationControllerPodDelete := user.HasPermission(identity.GetConponentName(), "GET", "/gui/inventory/replicationcontroller/pod/delete")
	hasGuiInventoryReplicationControllerDockerterminal := user.HasPermission(identity.GetConponentName(), "GET", "/gui/inventory/replicationcontroller/dockerterminal")

	cloudoneProtocol := beego.AppConfig.String("cloudoneProtocol")
	cloudoneHost := beego.AppConfig.String("cloudoneHost")
	cloudonePort := beego.AppConfig.String("cloudonePort")

	namespace, _ := c.GetSession("namespace").(string)

	url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
		"/api/v1/replicationcontrollers/" + namespace

	replicationControllerAndRelatedPodSlice := make([]ReplicationControllerAndRelatedPod, 0)

	tokenHeaderMap, _ := c.GetSession("tokenHeaderMap").(map[string]string)

	_, err := restclient.RequestGetWithStructure(url, &replicationControllerAndRelatedPodSlice, tokenHeaderMap)

	if identity.IsTokenInvalidAndRedirect(c, c.Ctx, err) {
		return
	}

	if err != nil {
		// Error
		guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
	} else {
		for i := 0; i < len(replicationControllerAndRelatedPodSlice); i++ {
			replicationControllerAndRelatedPodSlice[i].Display =
				displayMap[replicationControllerAndRelatedPodSlice[i].Name]

			if hasGuiInventoryReplicationControllerSize {
				replicationControllerAndRelatedPodSlice[i].HiddenTagGuiInventoryReplicationControllerSize = "<div class='btn-group'>"
			} else {
				replicationControllerAndRelatedPodSlice[i].HiddenTagGuiInventoryReplicationControllerSize = "<div hidden>"
			}
			if hasGuiInventoryReplicationControllerDelete {
				replicationControllerAndRelatedPodSlice[i].HiddenTagGuiInventoryReplicationControllerDelete = "<div class='btn-group'>"
			} else {
				replicationControllerAndRelatedPodSlice[i].HiddenTagGuiInventoryReplicationControllerDelete = "<div hidden>"
			}
			if hasGuiInventoryReplicationControllerPodlog {
				replicationControllerAndRelatedPodSlice[i].HiddenTagGuiInventoryReplicationControllerPodlog = "<div class='btn-group'>"
			} else {
				replicationControllerAndRelatedPodSlice[i].HiddenTagGuiInventoryReplicationControllerPodlog = "<div hidden>"
			}
			if hasGuiInventoryReplicationControllerPodDelete {
				replicationControllerAndRelatedPodSlice[i].HiddenTagGuiInventoryReplicationControllerPodDelete = "<div class='btn-group'>"
			} else {
				replicationControllerAndRelatedPodSlice[i].HiddenTagGuiInventoryReplicationControllerPodDelete = "<div hidden>"
			}
			if hasGuiInventoryReplicationControllerDockerterminal {
				replicationControllerAndRelatedPodSlice[i].HiddenTagGuiInventoryReplicationControllerDockerterminal = "<div class='btn-group'>"
			} else {
				replicationControllerAndRelatedPodSlice[i].HiddenTagGuiInventoryReplicationControllerDockerterminal = "<div hidden>"
			}
		}
		c.Data["replicationControllerAndRelatedPodSlice"] = replicationControllerAndRelatedPodSlice
	}

	guimessage.OutputMessage(c.Data)
}
示例#7
0
func (c *ListController) Get() {
	c.TplName = "notification/notifier/list.html"
	guimessage := guimessagedisplay.GetGUIMessage(c)

	// Authorization for web page display
	c.Data["layoutMenu"] = c.GetSession("layoutMenu")
	// Authorization for Button
	user, _ := c.GetSession("user").(*rbac.User)
	identity.SetPrivilegeHiddenTag(c.Data, "hiddenTagGuiNotificationNotifierEdit", user, "GET", "/gui/notification/notifier/edit")
	// Tag won't work in loop so need to be placed in data
	hasGuiNotificationNotifierEdit := user.HasPermission(identity.GetConponentName(), "GET", "/gui/notification/notifier/edit")
	hasGuiNotificationNotifierDelete := user.HasPermission(identity.GetConponentName(), "GET", "/gui/notification/notifier/delete")

	cloudoneProtocol := beego.AppConfig.String("cloudoneProtocol")
	cloudoneHost := beego.AppConfig.String("cloudoneHost")
	cloudonePort := beego.AppConfig.String("cloudonePort")

	url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
		"/api/v1/notifiers/"

	replicationControllerNotifierSlice := make([]ReplicationControllerNotifier, 0)

	tokenHeaderMap, _ := c.GetSession("tokenHeaderMap").(map[string]string)

	_, err := restclient.RequestGetWithStructure(url, &replicationControllerNotifierSlice, tokenHeaderMap)

	if identity.IsTokenInvalidAndRedirect(c, c.Ctx, err) {
		return
	}

	if err != nil {
		// Error
		guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
	} else {
		namespace, _ := c.GetSession("namespace").(string)

		filteredReplicationControllerNotifierSlice := make([]ReplicationControllerNotifier, 0)

		for i := 0; i < len(replicationControllerNotifierSlice); i++ {
			if hasGuiNotificationNotifierEdit {
				replicationControllerNotifierSlice[i].HiddenTagGuiNotificationNotifierEdit = "<div class='btn-group'>"
			} else {
				replicationControllerNotifierSlice[i].HiddenTagGuiNotificationNotifierEdit = "<div hidden>"
			}
			if hasGuiNotificationNotifierDelete {
				replicationControllerNotifierSlice[i].HiddenTagGuiNotificationNotifierDelete = "<div class='btn-group'>"
			} else {
				replicationControllerNotifierSlice[i].HiddenTagGuiNotificationNotifierDelete = "<div hidden>"
			}

			if replicationControllerNotifierSlice[i].Namespace == namespace {
				filteredReplicationControllerNotifierSlice = append(filteredReplicationControllerNotifierSlice, replicationControllerNotifierSlice[i])
			}
		}

		sort.Sort(ByReplicationControllerNotifier(filteredReplicationControllerNotifierSlice))
		c.Data["replicationControllerNotifierSlice"] = filteredReplicationControllerNotifierSlice
	}

	guimessage.OutputMessage(c.Data)
}
示例#8
0
func (c *ListController) Get() {
	c.TplName = "inventory/service/list.html"
	guimessage := guimessagedisplay.GetGUIMessage(c)

	// Authorization for web page display
	c.Data["layoutMenu"] = c.GetSession("layoutMenu")
	// Authorization for Button
	user, _ := c.GetSession("user").(*rbac.User)
	identity.SetPrivilegeHiddenTag(c.Data, "hiddenTagGuiInventoryServiceEdit", user, "GET", "/gui/inventory/service/edit")
	// Tag won't work in loop so need to be placed in data
	hasGuiInventoryServiceDelete := user.HasPermission(identity.GetConponentName(), "GET", "/gui/inventory/service/delete")

	cloudoneProtocol := beego.AppConfig.String("cloudoneProtocol")
	cloudoneHost := beego.AppConfig.String("cloudoneHost")
	cloudonePort := beego.AppConfig.String("cloudonePort")

	serverHost := c.Ctx.Input.Host()

	namespace := c.GetSession("namespace").(string)

	url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
		"/api/v1/services/" + namespace

	serviceSlice := make([]Service, 0)

	tokenHeaderMap, _ := c.GetSession("tokenHeaderMap").(map[string]string)

	_, err := restclient.RequestGetWithStructure(url, &serviceSlice, tokenHeaderMap)

	if identity.IsTokenInvalidAndRedirect(c, c.Ctx, err) {
		return
	}

	if err != nil {
		// Error
		guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
	} else {
		for i := 0; i < len(serviceSlice); i++ {
			serviceSlice[i].Display = displayMap[serviceSlice[i].Name]

			for j := 0; j < len(serviceSlice[i].PortSlice); j++ {
				// < 0 not used, == 0 auto-generated, > 0 port number
				if serviceSlice[i].PortSlice[j].NodePort < 0 {
					serviceSlice[i].PortSlice[j].NodePortText = ""
					serviceSlice[i].PortSlice[j].HiddenTagNodePort = "hidden"
				} else {
					serviceSlice[i].PortSlice[j].NodePortText = strconv.Itoa(serviceSlice[i].PortSlice[j].NodePort)
					serviceSlice[i].PortSlice[j].NodePortURL = "http://" + serverHost + ":" + strconv.Itoa(serviceSlice[i].PortSlice[j].NodePort)
				}
			}

			if hasGuiInventoryServiceDelete {
				serviceSlice[i].HiddenTagGuiInventoryServiceDelete = "<div class='btn-group'>"
			} else {
				serviceSlice[i].HiddenTagGuiInventoryServiceDelete = "<div hidden>"
			}
		}

		c.Data["serviceSlice"] = serviceSlice
	}

	guimessage.OutputMessage(c.Data)
}
示例#9
0
func (c *ListController) Get() {
	c.TplName = "system/rbac/user/list.html"
	guimessage := guimessagedisplay.GetGUIMessage(c)

	// Authorization for web page display
	c.Data["layoutMenu"] = c.GetSession("layoutMenu")
	// System RBAC tab menu
	user, _ := c.GetSession("user").(*rbac.User)
	c.Data["systemRBACTabMenu"] = identity.GetSystemRBACTabMenu(user, "user")
	// Authorization for Button
	identity.SetPrivilegeHiddenTag(c.Data, "hiddenTagGuiSystemRBACUserEdit", user, "GET", "/gui/system/rbac/user/edit")
	// Tag won't work in loop so need to be placed in data
	hasGuiSystemRBACUserEdit := user.HasPermission(identity.GetConponentName(), "GET", "/gui/system/rbac/user/edit")
	hasGuiSystemRBACUserDelete := user.HasPermission(identity.GetConponentName(), "GET", "/gui/system/rbac/user/delete")

	cloudoneProtocol := beego.AppConfig.String("cloudoneProtocol")
	cloudoneHost := beego.AppConfig.String("cloudoneHost")
	cloudonePort := beego.AppConfig.String("cloudonePort")

	url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
		"/api/v1/authorizations/users"

	userSlice := make([]rbac.User, 0)

	tokenHeaderMap, _ := c.GetSession("tokenHeaderMap").(map[string]string)

	_, err := restclient.RequestGetWithStructure(url, &userSlice, tokenHeaderMap)

	if identity.IsTokenInvalidAndRedirect(c, c.Ctx, err) {
		return
	}

	if err != nil {
		// Error
		guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
	} else {
		url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort + "/api/v1/namespaces"

		namespaceNameSlice := make([]string, 0)

		_, err = restclient.RequestGetWithStructure(url, &namespaceNameSlice, tokenHeaderMap)

		if identity.IsTokenInvalidAndRedirect(c, c.Ctx, err) {
			return
		}

		if err != nil {
			guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
		} else {
			simplifiedUserSlice := make([]SimplifiedUser, 0)
			for _, user := range userSlice {
				roleNameSlice := make([]string, 0)
				for _, role := range user.RoleSlice {
					roleNameSlice = append(roleNameSlice, role.Name)
				}

				namespaceSlice := make([]string, 0)
				for _, resource := range user.ResourceSlice {
					// Use component * only since they are the same in all components in the simplified version
					if resource.Component == "*" {
						if resource.Path == "*" || resource.Path == "/namespaces/" {
							namespaceSlice = make([]string, 0)
							namespaceSlice = append(namespaceSlice, "*")
							break
						} else if strings.HasPrefix(resource.Path, "/namespaces/") {
							splitSlice := strings.Split(resource.Path, "/")
							namespace := splitSlice[2]
							namespaceSlice = append(namespaceSlice, namespace)
						}
					}
				}

				expiredTimeText := ""
				if user.ExpiredTime != nil {
					expiredTimeText = user.ExpiredTime.String()
				}

				simplifiedUser := SimplifiedUser{
					user.Name,
					user.Disabled,
					expiredTimeText,
					roleNameSlice,
					namespaceSlice,
					user.Description,
					"",
					"",
				}

				if hasGuiSystemRBACUserEdit {
					simplifiedUser.HiddenTagGuiSystemRBACUserEdit = "<div class='btn-group'>"
				} else {
					simplifiedUser.HiddenTagGuiSystemRBACUserEdit = "<div hidden>"
				}
				if hasGuiSystemRBACUserDelete {
					simplifiedUser.HiddenTagGuiSystemRBACUserDelete = "<div class='btn-group'>"
				} else {
					simplifiedUser.HiddenTagGuiSystemRBACUserDelete = "<div hidden>"
				}

				simplifiedUserSlice = append(simplifiedUserSlice, simplifiedUser)
			}

			sort.Sort(BySimplifiedUser(simplifiedUserSlice))
			c.Data["simplifiedUserSlice"] = simplifiedUserSlice
		}
	}

	guimessage.OutputMessage(c.Data)
}
示例#10
0
func (c *ListController) Get() {
	c.TplName = "repository/imageinformation/list.html"
	guimessage := guimessagedisplay.GetGUIMessage(c)

	// Authorization for web page display
	c.Data["layoutMenu"] = c.GetSession("layoutMenu")
	// Authorization for Button
	user, _ := c.GetSession("user").(*rbac.User)
	identity.SetPrivilegeHiddenTag(c.Data, "hiddenTagGuiRepositoryImageInformationCreate", user, "GET", "/gui/repository/imageinformation/create")
	// Tag won't work in loop so need to be placed in data
	hasGuiRepositoryImageRecordList := user.HasPermission(identity.GetConponentName(), "GET", "/gui/repository/imagerecord/list")
	hasGuiRepositoryImageInformationUpgrade := user.HasPermission(identity.GetConponentName(), "GET", "/gui/repository/imageinformation/upgrade")
	hasGuiRepositoryImageInformationLog := user.HasPermission(identity.GetConponentName(), "GET", "/gui/repository/imageinformation/log")
	hasGuiDeployDeployCreate := user.HasPermission(identity.GetConponentName(), "GET", "/gui/deploy/deploy/create")
	hasGuiDeployDeployBlueGreenSelect := user.HasPermission(identity.GetConponentName(), "GET", "/gui/deploy/deploybluegreen/select")
	hasGuiRepositoryImageInformationDelete := user.HasPermission(identity.GetConponentName(), "GET", "/gui/repository/imageinformation/delete")

	cloudoneProtocol := beego.AppConfig.String("cloudoneProtocol")
	cloudoneHost := beego.AppConfig.String("cloudoneHost")
	cloudonePort := beego.AppConfig.String("cloudonePort")

	cloudoneGUIProtocol := beego.AppConfig.String("cloudoneGUIProtocol")
	cloudoneGUIHost, cloudoneGUIPort := dashboard.GetServerHostAndPortFromUserRequest(c.Ctx.Input)

	url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
		"/api/v1/imageinformations/"

	imageInformationSlice := make([]ImageInformation, 0)

	tokenHeaderMap, _ := c.GetSession("tokenHeaderMap").(map[string]string)

	_, err := restclient.RequestGetWithStructure(url, &imageInformationSlice, tokenHeaderMap)

	if identity.IsTokenInvalidAndRedirect(c, c.Ctx, err) {
		return
	}

	if err != nil {
		// Error
		guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
	} else {
		for i := 0; i < len(imageInformationSlice); i++ {
			if hasGuiRepositoryImageRecordList {
				imageInformationSlice[i].HiddenTagGuiRepositoryImageRecordList = "<div class='btn-group'>"
			} else {
				imageInformationSlice[i].HiddenTagGuiRepositoryImageRecordList = "<div hidden>"
			}
			if hasGuiRepositoryImageInformationUpgrade {
				imageInformationSlice[i].HiddenTagGuiRepositoryImageInformationUpgrade = "<div class='btn-group'>"
			} else {
				imageInformationSlice[i].HiddenTagGuiRepositoryImageInformationUpgrade = "<div hidden>"
			}
			if hasGuiRepositoryImageInformationLog {
				imageInformationSlice[i].HiddenTagGuiRepositoryImageInformationLog = "<div class='btn-group'>"
			} else {
				imageInformationSlice[i].HiddenTagGuiRepositoryImageInformationLog = "<div hidden>"
			}
			if hasGuiDeployDeployCreate {
				imageInformationSlice[i].HiddenTagGuiDeployDeployCreate = "<div class='btn-group'>"
			} else {
				imageInformationSlice[i].HiddenTagGuiDeployDeployCreate = "<div hidden>"
			}
			if hasGuiDeployDeployBlueGreenSelect {
				imageInformationSlice[i].HiddenTagGuiDeployDeployBlueGreenSelect = "<div class='btn-group'>"
			} else {
				imageInformationSlice[i].HiddenTagGuiDeployDeployBlueGreenSelect = "<div hidden>"
			}
			if hasGuiRepositoryImageInformationDelete {
				imageInformationSlice[i].HiddenTagGuiRepositoryImageInformationDelete = "<div class='btn-group'>"
			} else {
				imageInformationSlice[i].HiddenTagGuiRepositoryImageInformationDelete = "<div hidden>"
			}

			// Add git webhook information
			if imageInformationSlice[i].Kind == "git" {
				githubWebhookUrl := cloudoneGUIProtocol + "://" + cloudoneGUIHost + ":" + strconv.Itoa(cloudoneGUIPort) + "/api/v1/webhook/github?user="******"&imageInformation=" + imageInformationSlice[i].Name
				imageInformationSlice[i].BuildParameter["githubWebhookUrl"] = githubWebhookUrl
			}
		}

		sort.Sort(ByImageInformation(imageInformationSlice))
		c.Data["imageInformationSlice"] = imageInformationSlice
	}

	guimessage.OutputMessage(c.Data)
}
示例#11
0
func (c *ListController) Get() {
	c.TplName = "system/namespace/list.html"
	guimessage := guimessagedisplay.GetGUIMessage(c)

	// Authorization for web page display
	c.Data["layoutMenu"] = c.GetSession("layoutMenu")
	// Authorization for Button
	user, _ := c.GetSession("user").(*rbac.User)
	identity.SetPrivilegeHiddenTag(c.Data, "hiddenTagGuiSystemNamespaceEdit", user, "GET", "/gui/system/namespace/edit")
	// Tag won't work in loop so need to be placed in data
	hasGuiSystemNamespaceSelect := user.HasPermission(identity.GetConponentName(), "GET", "/gui/system/namespace/select")
	hasGuiSystemNamespaceBookmark := user.HasPermission(identity.GetConponentName(), "GET", "/gui/system/namespace/bookmark")
	hasGuiSystemNamespaceDelete := user.HasPermission(identity.GetConponentName(), "GET", "/gui/system/namespace/delete")

	cloudoneProtocol := beego.AppConfig.String("cloudoneProtocol")
	cloudoneHost := beego.AppConfig.String("cloudoneHost")
	cloudonePort := beego.AppConfig.String("cloudonePort")

	url := cloudoneProtocol + "://" + cloudoneHost + ":" + cloudonePort +
		"/api/v1/namespaces"

	nameSlice := make([]string, 0)

	tokenHeaderMap, _ := c.GetSession("tokenHeaderMap").(map[string]string)

	_, err := restclient.RequestGetWithStructure(url, &nameSlice, tokenHeaderMap)

	if identity.IsTokenInvalidAndRedirect(c, c.Ctx, err) {
		return
	}

	if err != nil {
		// Error
		guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
	} else {
		selectedNamespace := c.GetSession("namespace")

		metaDataMap := user.MetaDataMap
		if metaDataMap == nil {
			metaDataMap = make(map[string]string)
		}
		loginNamespace := metaDataMap["loginNamespace"]

		namespaceSlice := make([]Namespace, 0)
		for _, name := range nameSlice {
			namespace := Namespace{name, false, false, "", "", "", ""}
			if name == selectedNamespace {
				namespace.Selected = true
			}
			namespace.Display = displayMap[name]

			if len(loginNamespace) > 0 && loginNamespace == namespace.Name {
				namespace.Bookmarked = true
			}

			if hasGuiSystemNamespaceSelect {
				namespace.HiddenTagGuiSystemNamespaceSelect = "<div class='btn-group'>"
			} else {
				namespace.HiddenTagGuiSystemNamespaceSelect = "<div hidden>"
			}
			if hasGuiSystemNamespaceBookmark {
				namespace.HiddenTagGuiSystemNamespaceBookmark = "<div class='btn-group'>"
			} else {
				namespace.HiddenTagGuiSystemNamespaceBookmark = "<div hidden>"
			}
			if hasGuiSystemNamespaceDelete {
				namespace.HiddenTagGuiSystemNamespaceDelete = "<div class='btn-group'>"
			} else {
				namespace.HiddenTagGuiSystemNamespaceDelete = "<div hidden>"
			}

			if user.HasResource(identity.GetConponentName(), "/namespaces/"+namespace.Name) {
				namespaceSlice = append(namespaceSlice, namespace)
			}
		}

		sort.Sort(ByNamespace(namespaceSlice))
		c.Data["namespaceSlice"] = namespaceSlice
	}

	guimessage.OutputMessage(c.Data)
}