func (c *TerminalController) Get() {
	c.TplName = "inventory/replicationcontroller/docker_terminal.html"
	guimessage := guimessagedisplay.GetGUIMessage(c)

	// Authorization for web page display
	c.Data["layoutMenu"] = c.GetSession("layoutMenu")

	cloudoneGUIHost, cloudoneGUIPort := dashboard.GetServerHostAndPortFromUserRequest(c.Ctx.Input)

	hostIP := c.GetString("hostIP")
	containerID := c.GetString("containerID")

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

	c.Data["cloudoneGUIHost"] = cloudoneGUIHost
	c.Data["cloudoneGUIPort"] = cloudoneGUIPort

	c.Data["hostIP"] = hostIP
	c.Data["containerID"] = containerID

	c.Data["token"] = token

	guimessage.OutputMessage(c.Data)
}
Example #2
0
func (c *LogController) Get() {
	c.TplName = "repository/imageinformation/log.html"
	guimessage := guimessagedisplay.GetGUIMessage(c)

	// Authorization for web page display
	c.Data["layoutMenu"] = c.GetSession("layoutMenu")

	cloudoneGUIHost, cloudoneGUIPort := dashboard.GetServerHostAndPortFromUserRequest(c.Ctx.Input)

	imageInformation := c.GetString("imageInformation")

	if _, err := os.Stat(GetProcessingOutMessageFilePathAndName(imageInformation)); os.IsNotExist(err) {
		// does not exist
		guimessage.AddInfo("No ongoing building process.")
		c.Ctx.Redirect(302, "/gui/repository/imageinformation/list")
		guimessage.RedirectMessage(c)
		return
	}

	c.Data["cloudoneGUIHost"] = cloudoneGUIHost
	c.Data["cloudoneGUIPort"] = cloudoneGUIPort
	c.Data["imageInformation"] = imageInformation

	guimessage.OutputMessage(c.Data)
}
Example #3
0
// @Title get
// @Description get related information
// @Success 200 {string} {}
// @Failure 404 error reason
// @router /information [get]
func (c *IndexController) Get() {
	cloudoneGUIProtocol := beego.AppConfig.String("cloudoneGUIProtocol")
	cloudoneGUIHost, cloudoneGUIPort := dashboard.GetServerHostAndPortFromUserRequest(c.Ctx.Input)

	c.Data["json"] = make(map[string]interface{})
	c.Data["json"].(map[string]interface{})["cloudoneGUIProtocol"] = cloudoneGUIProtocol
	c.Data["json"].(map[string]interface{})["cloudoneGUIHost"] = cloudoneGUIHost
	c.Data["json"].(map[string]interface{})["cloudoneGUIPort"] = cloudoneGUIPort
	c.ServeJSON()
}
Example #4
0
func (c *IndexController) Get() {
	c.TplName = "monitor/container/index.html"
	guimessage := guimessagedisplay.GetGUIMessage(c)

	// Authorization for web page display
	c.Data["layoutMenu"] = c.GetSession("layoutMenu")

	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)

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

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

	jsonMapSlice := make([]interface{}, 0)

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

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

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

	if err != nil {
		// Error
		guimessage.AddDanger(guimessagedisplay.GetErrorMessage(err))
	} else {
		replicationControllerNameSlice := make([]string, 0)
		replicationControllerNameSlice = append(replicationControllerNameSlice, allKeyword)

		for _, jsonMap := range jsonMapSlice {
			name, _ := jsonMap.(map[string]interface{})["Name"].(string)
			if name != "" {
				replicationControllerNameSlice = append(replicationControllerNameSlice, name)
			}
		}

		c.Data["cloudoneGUIProtocol"] = cloudoneGUIProtocol
		c.Data["cloudoneGUIHost"] = cloudoneGUIHost
		c.Data["cloudoneGUIPort"] = cloudoneGUIPort
		c.Data["replicationControllerNameSlice"] = replicationControllerNameSlice
	}

	guimessage.OutputMessage(c.Data)
}
Example #5
0
// @Title get
// @Description get related information
// @Success 200 {string} {}
// @Failure 404 error reason
// @router /selectinformation [get]
func (c *IndexController) Get() {
	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)

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

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

	jsonMapSlice := make([]interface{}, 0)

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

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

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

	if err != nil {
		// Error
		c.Data["json"] = make(map[string]interface{})
		c.Data["json"].(map[string]interface{})["error"] = err.Error()
		c.Ctx.Output.Status = 404
		c.ServeJSON()
		return
	} else {
		replicationControllerNameSlice := make([]string, 0)
		replicationControllerNameSlice = append(replicationControllerNameSlice, allKeyword)

		for _, jsonMap := range jsonMapSlice {
			name, _ := jsonMap.(map[string]interface{})["Name"].(string)
			if name != "" {
				replicationControllerNameSlice = append(replicationControllerNameSlice, name)
			}
		}

		c.Data["json"] = make(map[string]interface{})
		c.Data["json"].(map[string]interface{})["cloudoneGUIProtocol"] = cloudoneGUIProtocol
		c.Data["json"].(map[string]interface{})["cloudoneGUIHost"] = cloudoneGUIHost
		c.Data["json"].(map[string]interface{})["cloudoneGUIPort"] = cloudoneGUIPort
		c.Data["json"].(map[string]interface{})["replicationControllerNameSlice"] = replicationControllerNameSlice
		c.ServeJSON()
	}
}
Example #6
0
func (c *IndexController) Get() {
	c.TplName = "monitor/node/index.html"
	guimessage := guimessagedisplay.GetGUIMessage(c)

	// Authorization for web page display
	c.Data["layoutMenu"] = c.GetSession("layoutMenu")

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

	c.Data["cloudoneGUIProtocol"] = cloudoneGUIProtocol
	c.Data["cloudoneGUIHost"] = cloudoneGUIHost
	c.Data["cloudoneGUIPort"] = cloudoneGUIPort

	guimessage.OutputMessage(c.Data)
}
Example #7
0
func (c *IndexController) Get() {
	guimessage := guimessagedisplay.GetGUIMessage(c)
	c.TplName = "dashboard/bluegreen/index.html"

	// Authorization for web page display
	c.Data["layoutMenu"] = c.GetSession("layoutMenu")
	// Dashboard tab menu
	user, _ := c.GetSession("user").(*rbac.User)
	c.Data["dashboardTabMenu"] = identity.GetDashboardTabMenu(user, "bluegreen")

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

	c.Data["cloudoneGUIProtocol"] = cloudoneGUIProtocol
	c.Data["cloudoneGUIHost"] = cloudoneGUIHost
	c.Data["cloudoneGUIPort"] = cloudoneGUIPort

	guimessage.OutputMessage(c.Data)
}
Example #8
0
func (c *IndexController) Get() {
	c.TplName = "system/upgrade/index.html"
	guimessage := guimessagedisplay.GetGUIMessage(c)

	// Authorization for web page display
	c.Data["layoutMenu"] = c.GetSession("layoutMenu")

	cloudoneGUIHost, cloudoneGUIPort := dashboard.GetServerHostAndPortFromUserRequest(c.Ctx.Input)

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

	c.Data["cloudoneGUIHost"] = cloudoneGUIHost
	c.Data["cloudoneGUIPort"] = cloudoneGUIPort

	c.Data["token"] = token

	guimessage.OutputMessage(c.Data)
}
Example #9
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)
}