package templates
import (
"fmt"
"strconv"
"git.preston-baxter.com/Preston_PLB/capstone/frontend-service/db/models"
)
func hasVendor(name string, vendors []models.VendorAccount) bool {
for _, vendor := range vendors {
if vendor.Name == name {
return true
}
}
return false
}
func hasPco(vendors []models.VendorAccount) bool {
return hasVendor(models.PCO_VENDOR_NAME, vendors)
}
func hasYoutube(vendors []models.VendorAccount) bool {
return hasVendor(models.YOUTUBE_VENDOR_NAME, vendors)
}
templ DashboardPage(user *models.User, vendorAccounts []models.VendorAccount, actionMappings []models.ActionMapping) {
@Head("Dashboard")
@DashboardNav(user)
@DashboardContent(user, vendorAccounts, actionMappings)
@DashboardFooter()
@DashboardScript()
@toggleDropdown()
}
templ DashboardNav(user *models.User) {
}
templ DashboardNavItem(icon, name, link string, enabled bool) {
{ name }
}
//Break this up
templ DashboardContentNav(user *models.User) {
}
templ DashboardCardLoader(kind string) {
}
templ DashboardCard(title, primaryVal, secondaryVal, subtitle string) {
{ secondaryVal }
{ subtitle }
}
templ DashboardVendorDropDown() {
}
templ DashboardVendorWidget(vendors []models.VendorAccount) {
Vendors
@DashboardVendorDropDown()
Name
|
Status
|
if len(vendors) == 0 {
No accounts are available. Click + to add one
|
} else {
for _, vendor := range vendors {
{ vendor.Name }
|
if vendor.OauthCredentials != nil && vendor.OauthCredentials.AccessToken != "" {
Active
} else {
}
|
}
}
}
templ DashboardActionModalForm(vendors []models.VendorAccount) {
}
templ DashboardActionModal(vendors []models.VendorAccount) {
Modal Title
@DashboardActionModalForm(vendors)
}
templ DashboardActionDropDown() {
}
templ DashboardActionEditButton(action *models.ActionMapping) {
}
templ DashboardActionsWidget(actions []models.ActionMapping) {
Vendors
@DashboardActionDropDown()
Id
|
Event Source
|
Event Action
|
Action
|
if len(actions) == 0 {
No actions are available. Click + to add one
|
} else {
for index, action := range actions {
{ strconv.Itoa(index) }
|
{ action.SourceEvent.Key }
|
{ action.Action.VendorName }: { action.Action.Type }
|
@DashboardActionEditButton(&action)
|
}
}
}
templ DashboardContent(user *models.User, vendorAccounts []models.VendorAccount, actions []models.ActionMapping) {
@DashboardContentNav(user)
@DashboardCardLoader("events_received")
@DashboardCardLoader("streams_scheduled")
@DashboardVendorWidget(vendorAccounts)
@DashboardActionsWidget(actions)
}
templ DashboardScript() {
}