Welcome to mirror list, hosted at ThFree Co, Russian Federation.

OctoPrintInfoBox.go « uiWidgets - github.com/Z-Bolt/OctoScreen.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 34ae63d089d4a94463daf55575fe4ad516a49477 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package uiWidgets

import (
	"fmt"

	"github.com/mcuadros/go-octoprint"
	"github.com/Z-Bolt/OctoScreen/utils"
)


type OctoPrintInfoBox struct {
	*SystemInfoBox
}

func CreateOctoPrintInfoBox(
	client				*octoprint.Client,
	logoWidth			int,
) *OctoPrintInfoBox {
	logoHeight := int(float64(logoWidth) * 1.25)
	logoImage := utils.MustImageFromFileWithSize("logos/logo-octoprint.png", logoWidth, logoHeight)

	versionResponse, err := (&octoprint.VersionRequest{}).Do(client)
	if err != nil {
		panic(err)
	}

	base := CreateSystemInfoBox(
		client,
		logoImage,
		"OctoPrint",
		versionResponse.Server,
		fmt.Sprintf("(API   %s)", versionResponse.API),
	)

	instance := &OctoPrintInfoBox {
		SystemInfoBox:			base,
	}

	return instance
}