-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): add package detail page #172
- Loading branch information
1 parent
3e7236a
commit 926a58b
Showing
24 changed files
with
640 additions
and
254 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package pkg_detail_btns | ||
|
||
import ( | ||
"fmt" | ||
"html/template" | ||
"io" | ||
"os" | ||
|
||
"github.com/glasskube/glasskube/api/v1alpha1" | ||
"github.com/glasskube/glasskube/pkg/client" | ||
) | ||
|
||
const TemplateId = "pkg-detail-btns" | ||
|
||
type pkgDetailBtnsInput struct { | ||
ContainerId string | ||
Swap string | ||
PackageName string | ||
Status *client.PackageStatus | ||
Manifest *v1alpha1.PackageManifest | ||
} | ||
|
||
func getId(pkgName string) string { | ||
return fmt.Sprintf("%v-%v", TemplateId, pkgName) | ||
} | ||
|
||
func getSwap(id string) string { | ||
return fmt.Sprintf("outerHTML:#%s", id) | ||
} | ||
|
||
func Render(w io.Writer, tmpl *template.Template, pkgName string, status *client.PackageStatus, manifest *v1alpha1.PackageManifest) { | ||
id := getId(pkgName) | ||
err := tmpl.ExecuteTemplate(w, TemplateId, &pkgDetailBtnsInput{ | ||
ContainerId: id, | ||
Swap: getSwap(id), | ||
PackageName: pkgName, | ||
Status: status, | ||
Manifest: manifest, | ||
}) | ||
if err != nil { | ||
fmt.Fprintf(os.Stderr, "An error occurred rendering %v for %v: \n%v\n"+ | ||
"This is most likely a BUG!", TemplateId, pkgName, err) | ||
} | ||
} | ||
|
||
func ForPkgDetailBtns(pkgName string, status *client.PackageStatus, manifest *v1alpha1.PackageManifest) *pkgDetailBtnsInput { | ||
id := getId(pkgName) | ||
return &pkgDetailBtnsInput{ | ||
ContainerId: id, | ||
Swap: "", | ||
PackageName: pkgName, | ||
Status: status, | ||
Manifest: manifest, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package pkg_overview_btn | ||
|
||
import ( | ||
"fmt" | ||
"html/template" | ||
"io" | ||
"os" | ||
|
||
"github.com/glasskube/glasskube/api/v1alpha1" | ||
"github.com/glasskube/glasskube/pkg/client" | ||
"github.com/glasskube/glasskube/pkg/list" | ||
) | ||
|
||
const TemplateId = "pkg-overview-btn" | ||
|
||
type pkgOverviewBtnInput struct { | ||
ButtonId string | ||
Swap string | ||
PackageName string | ||
Status *client.PackageStatus | ||
Manifest *v1alpha1.PackageManifest | ||
} | ||
|
||
func getButtonId(pkgName string) string { | ||
return fmt.Sprintf("%v-%v", TemplateId, pkgName) | ||
} | ||
|
||
func Render(w io.Writer, tmpl *template.Template, pkgName string, status *client.PackageStatus, manifest *v1alpha1.PackageManifest) { | ||
buttonId := getButtonId(pkgName) | ||
err := tmpl.ExecuteTemplate(w, TemplateId, &pkgOverviewBtnInput{ | ||
ButtonId: buttonId, | ||
Swap: fmt.Sprintf("outerHTML:#%s", buttonId), | ||
PackageName: pkgName, | ||
Status: status, | ||
Manifest: manifest, | ||
}) | ||
if err != nil { | ||
fmt.Fprintf(os.Stderr, "An error occurred rendering %v for %v: \n%v\n"+ | ||
"This is most likely a BUG!", TemplateId, pkgName, err) | ||
} | ||
} | ||
|
||
func ForPkgOverviewBtn(pkgTeaser *list.PackageTeaserWithStatus) *pkgOverviewBtnInput { | ||
buttonId := getButtonId(pkgTeaser.PackageName) | ||
return &pkgOverviewBtnInput{ | ||
ButtonId: buttonId, | ||
Swap: "", | ||
PackageName: pkgTeaser.PackageName, | ||
Status: pkgTeaser.Status, | ||
Manifest: pkgTeaser.InstalledManifest, | ||
} | ||
} |
Oops, something went wrong.