package datamodel import ( "html/template" "github.com/GoAdminGroup/go-admin/context" tmpl "github.com/GoAdminGroup/go-admin/template" "github.com/GoAdminGroup/go-admin/template/chartjs" "github.com/GoAdminGroup/go-admin/template/icon" "github.com/GoAdminGroup/go-admin/template/types" "github.com/GoAdminGroup/themes/adminlte/components/chart_legend" "github.com/GoAdminGroup/themes/adminlte/components/description" "github.com/GoAdminGroup/themes/adminlte/components/infobox" "github.com/GoAdminGroup/themes/adminlte/components/productlist" "github.com/GoAdminGroup/themes/adminlte/components/progress_group" "github.com/GoAdminGroup/themes/adminlte/components/smallbox" ) // GetContent return the content of index page. func GetContent(ctx *context.Context) (types.Panel, error) { components := tmpl.Default(ctx) colComp := components.Col() /************************** * Info Box /**************************/ infobox1 := infobox.New(). SetText("CPU TRAFFIC"). SetColor("aqua"). SetNumber("100"). SetIcon("ion-ios-gear-outline"). GetContent() infobox2 := infobox.New(). SetText("Likes"). SetColor("red"). SetNumber("1030.00$"). SetIcon(icon.GooglePlus). GetContent() infobox3 := infobox.New(). SetText("Sales"). SetColor("green"). SetNumber("760"). SetIcon("ion-ios-cart-outline"). GetContent() infobox4 := infobox.New(). SetText("New Members"). SetColor("yellow"). SetNumber("2,349"). SetIcon("ion-ios-people-outline"). // svg is ok GetContent() var size = types.Size(6, 3, 0).XS(12) infoboxCol1 := colComp.SetSize(size).SetContent(infobox1).GetContent() infoboxCol2 := colComp.SetSize(size).SetContent(infobox2).GetContent() infoboxCol3 := colComp.SetSize(size).SetContent(infobox3).GetContent() infoboxCol4 := colComp.SetSize(size).SetContent(infobox4).GetContent() row1 := components.Row().SetContent(infoboxCol1 + infoboxCol2 + infoboxCol3 + infoboxCol4).GetContent() /************************** * Box /**************************/ table := components.Table().SetInfoList([]map[string]types.InfoItem{ { "Order ID": {Content: "OR9842"}, "Item": {Content: "Call of Duty IV"}, "Status": {Content: "shipped"}, "Popularity": {Content: "90%"}, }, { "Order ID": {Content: "OR9842"}, "Item": {Content: "Call of Duty IV"}, "Status": {Content: "shipped"}, "Popularity": {Content: "90%"}, }, { "Order ID": {Content: "OR9842"}, "Item": {Content: "Call of Duty IV"}, "Status": {Content: "shipped"}, "Popularity": {Content: "90%"}, }, { "Order ID": {Content: "OR9842"}, "Item": {Content: "Call of Duty IV"}, "Status": {Content: "shipped"}, "Popularity": {Content: "90%"}, }, }).SetThead(types.Thead{ {Head: "Order ID"}, {Head: "Item"}, {Head: "Status"}, {Head: "Popularity"}, }).GetContent() boxInfo := components.Box(). WithHeadBorder(). SetHeader("Latest Orders"). SetHeadColor("#f7f7f7"). SetBody(table). SetFooter(`
`). GetContent() tableCol := colComp.SetSize(types.SizeMD(8)).SetContent(row1 + boxInfo).GetContent() /************************** * Product List /**************************/ productList := productlist.New().SetData([]map[string]string{ { "img": "http://adminlte.io/themes/AdminLTE/dist/img/default-50x50.gif", "title": "GoAdmin", "has_tabel": "true", "labeltype": "warning", "label": "free", "description": `a framework help you build the dataviz system`, }, { "img": "http://adminlte.io/themes/AdminLTE/dist/img/default-50x50.gif", "title": "GoAdmin", "has_tabel": "true", "labeltype": "warning", "label": "free", "description": `a framework help you build the dataviz system`, }, { "img": "http://adminlte.io/themes/AdminLTE/dist/img/default-50x50.gif", "title": "GoAdmin", "has_tabel": "true", "labeltype": "warning", "label": "free", "description": `a framework help you build the dataviz system`, }, { "img": "http://adminlte.io/themes/AdminLTE/dist/img/default-50x50.gif", "title": "GoAdmin", "has_tabel": "true", "labeltype": "warning", "label": "free", "description": `a framework help you build the dataviz system`, }, }).GetContent() boxWarning := components.Box().SetTheme("warning").WithHeadBorder().SetHeader("Recently Added Products"). SetBody(productList). SetFooter(`View All Products`). GetContent() newsCol := colComp.SetSize(types.SizeMD(4)).SetContent(boxWarning).GetContent() row5 := components.Row().SetContent(tableCol + newsCol).GetContent() /************************** * Box /**************************/ line := chartjs.Line() lineChart := line. SetID("salechart"). SetHeight(180). SetTitle("Sales: 1 Jan, 2019 - 30 Jul, 2019"). SetLabels([]string{"January", "February", "March", "April", "May", "June", "July"}). AddDataSet("Electronics"). DSData([]float64{65, 59, 80, 81, 56, 55, 40}). DSFill(false). DSBorderColor("rgb(210, 214, 222)"). DSLineTension(0.1). AddDataSet("Digital Goods"). DSData([]float64{28, 48, 40, 19, 86, 27, 90}). DSFill(false). DSBorderColor("rgba(60,141,188,1)"). DSLineTension(0.1). GetContent() title := `Goal Completion
` progressGroup := progress_group.New(). SetTitle("Add Products to Cart"). SetColor("#76b2d4"). SetDenominator(200). SetMolecular(160). SetPercent(80). GetContent() progressGroup1 := progress_group.New(). SetTitle("Complete Purchase"). SetColor("#f17c6e"). SetDenominator(400). SetMolecular(310). SetPercent(80). GetContent() progressGroup2 := progress_group.New(). SetTitle("Visit Premium Page"). SetColor("#ace0ae"). SetDenominator(800). SetMolecular(490). SetPercent(80). GetContent() progressGroup3 := progress_group.New(). SetTitle("Send Inquiries"). SetColor("#fdd698"). SetDenominator(500). SetMolecular(250). SetPercent(50). GetContent() boxInternalCol1 := colComp.SetContent(lineChart).SetSize(types.SizeMD(8)).GetContent() boxInternalCol2 := colComp. SetContent(template.HTML(title) + progressGroup + progressGroup1 + progressGroup2 + progressGroup3). SetSize(types.SizeMD(4)). GetContent() boxInternalRow := components.Row().SetContent(boxInternalCol1 + boxInternalCol2).GetContent() description1 := description.New(). SetPercent("17"). SetNumber("¥140,100"). SetTitle("TOTAL REVENUE"). SetArrow("up"). SetColor("green"). SetBorder("right"). GetContent() description2 := description.New(). SetPercent("2"). SetNumber("440,560"). SetTitle("TOTAL REVENUE"). SetArrow("down"). SetColor("red"). SetBorder("right"). GetContent() description3 := description.New(). SetPercent("12"). SetNumber("¥140,050"). SetTitle("TOTAL REVENUE"). SetArrow("up"). SetColor("green"). SetBorder("right"). GetContent() description4 := description.New(). SetPercent("1"). SetNumber("30943"). SetTitle("TOTAL REVENUE"). SetArrow("up"). SetColor("green"). GetContent() size2 := types.SizeXS(6).SM(3) boxInternalCol3 := colComp.SetContent(description1).SetSize(size2).GetContent() boxInternalCol4 := colComp.SetContent(description2).SetSize(size2).GetContent() boxInternalCol5 := colComp.SetContent(description3).SetSize(size2).GetContent() boxInternalCol6 := colComp.SetContent(description4).SetSize(size2).GetContent() boxInternalRow2 := components.Row().SetContent(boxInternalCol3 + boxInternalCol4 + boxInternalCol5 + boxInternalCol6).GetContent() box := components.Box().WithHeadBorder().SetHeader("Monthly Recap Report"). SetBody(boxInternalRow). SetFooter(boxInternalRow2). GetContent() boxcol := colComp.SetContent(box).SetSize(types.SizeMD(12)).GetContent() row2 := components.Row().SetContent(boxcol).GetContent() /************************** * Small Box /**************************/ smallbox1 := smallbox.New().SetColor("blue").SetIcon("ion-ios-gear-outline").SetUrl("/").SetTitle("new users").SetValue("345¥").GetContent() smallbox2 := smallbox.New().SetColor("yellow").SetIcon("ion-ios-cart-outline").SetUrl("/").SetTitle("new users").SetValue("80%").GetContent() smallbox3 := smallbox.New().SetColor("red").SetIcon("fa-user").SetUrl("/").SetTitle("new users").SetValue("645¥").GetContent() smallbox4 := smallbox.New().SetColor("green").SetIcon("ion-ios-cart-outline").SetUrl("/").SetTitle("new users").SetValue("889¥").GetContent() col1 := colComp.SetSize(size).SetContent(smallbox1).GetContent() col2 := colComp.SetSize(size).SetContent(smallbox2).GetContent() col3 := colComp.SetSize(size).SetContent(smallbox3).GetContent() col4 := colComp.SetSize(size).SetContent(smallbox4).GetContent() row3 := components.Row().SetContent(col1 + col2 + col3 + col4).GetContent() /************************** * Pie Chart /**************************/ pie := chartjs.Pie(). SetHeight(170). SetLabels([]string{"Navigator", "Opera", "Safari", "FireFox", "IE", "Chrome"}). SetID("pieChart"). AddDataSet("Chrome"). DSData([]float64{100, 300, 600, 400, 500, 700}). DSBackgroundColor([]chartjs.Color{ "rgb(255, 205, 86)", "rgb(54, 162, 235)", "rgb(255, 99, 132)", "rgb(255, 205, 86)", "rgb(54, 162, 235)", "rgb(255, 99, 132)", }). GetContent() legend := chart_legend.New().SetData([]map[string]string{ { "label": " Chrome", "color": "red", }, { "label": " IE", "color": "Green", }, { "label": " FireFox", "color": "yellow", }, { "label": " Sarafri", "color": "blue", }, { "label": " Opera", "color": "light-blue", }, { "label": " Navigator", "color": "gray", }, }).GetContent() boxDanger := components.Box().SetTheme("danger").WithHeadBorder().SetHeader("Browser Usage"). SetBody(components.Row(). SetContent(colComp.SetSize(types.SizeMD(8)). SetContent(pie). GetContent() + colComp.SetSize(types.SizeMD(4)). SetContent(legend). GetContent()).GetContent()). SetFooter(``). GetContent() tabs := components.Tabs().SetData([]map[string]template.HTML{ { "title": "tabs1", "content": template.HTML(`How to use:Exactly like the original bootstrap tabs except you should use
the custom wrapper .nav-tabs-custom
to achieve this style.