index.go 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. package pages
  2. import (
  3. "github.com/GoAdminGroup/go-admin/context"
  4. "github.com/GoAdminGroup/go-admin/modules/config"
  5. template2 "github.com/GoAdminGroup/go-admin/template"
  6. "github.com/GoAdminGroup/go-admin/template/chartjs"
  7. "github.com/GoAdminGroup/go-admin/template/types"
  8. "github.com/GoAdminGroup/themes/sword/components/card"
  9. "github.com/GoAdminGroup/themes/sword/components/chart_legend"
  10. "github.com/GoAdminGroup/themes/sword/components/description"
  11. "github.com/GoAdminGroup/themes/sword/components/progress_group"
  12. "html/template"
  13. )
  14. func GetDashBoard(ctx *context.Context) (types.Panel, error) {
  15. components := template2.Get(config.GetTheme())
  16. colComp := components.Col()
  17. /**************************
  18. * Info Box
  19. /**************************/
  20. cardcard := card.New().
  21. SetTitle("TOTAL REVENUE").
  22. SetSubTitle("¥ 113,340").
  23. SetAction(template.HTML(`<i aria-label="图标: info-circle-o" class="anticon anticon-info-circle-o"><svg viewBox="64 64 896 896" focusable="false" class="" data-icon="info-circle" width="1em" height="1em" fill="currentColor" aria-hidden="true"><path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"></path><path d="M464 336a48 48 0 1 0 96 0 48 48 0 1 0-96 0zm72 112h-48c-4.4 0-8 3.6-8 8v272c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V456c0-4.4-3.6-8-8-8z"></path></svg></i>`)).
  24. SetContent(template.HTML(`<div><div title="" style="margin-right: 16px;"><span><span>Week Compare</span><span style="margin-left: 8px;">12%</span></span><span style="color: #f5222d;margin-left: 4px;top: 1px;"><i style="font-size: 12px;" aria-label="图标: caret-up" class="anticon anticon-caret-up"><svg viewBox="0 0 1024 1024" focusable="false" class="" data-icon="caret-up" width="1em" height="1em" fill="currentColor" aria-hidden="true"><path d="M858.9 689L530.5 308.2c-9.4-10.9-27.5-10.9-37 0L165.1 689c-12.2 14.2-1.2 35 18.5 35h656.8c19.7 0 30.7-20.8 18.5-35z"></path></svg></i></span></div><div class="antd-pro-pages-dashboard-analysis-components-trend-index-trendItem" title=""><span><span>Day Compare</span><span style="margin-left: 8px;">11%</span></span><span style="color: #52c41a;margin-left: 4px;top: 1px;"><i style="font-size: 12px;" aria-label="图标: caret-down" class="anticon anticon-caret-down"><svg viewBox="0 0 1024 1024" focusable="false" class="" data-icon="caret-down" width="1em" height="1em" fill="currentColor" aria-hidden="true"><path d="M840.4 300H183.6c-19.7 0-30.7 20.8-18.5 35l328.4 380.8c9.4 10.9 27.5 10.9 37 0L858.9 335c12.2-14.2 1.2-35-18.5-35z"></path></svg></i></span></div></div>`)).
  25. SetFooter(template.HTML(`TOTAL DAY REVENUE <strong style="margin-left:8px;">$11,325</strong>`))
  26. infobox := cardcard.GetContent()
  27. infobox2 := cardcard.GetContent()
  28. infobox3 := cardcard.GetContent()
  29. infobox4 := cardcard.GetContent()
  30. var size = map[string]string{"md": "3", "sm": "6", "xs": "12"}
  31. infoboxCol1 := colComp.SetSize(size).SetContent(infobox).GetContent()
  32. infoboxCol2 := colComp.SetSize(size).SetContent(infobox2).GetContent()
  33. infoboxCol3 := colComp.SetSize(size).SetContent(infobox3).GetContent()
  34. infoboxCol4 := colComp.SetSize(size).SetContent(infobox4).GetContent()
  35. row1 := components.Row().SetContent(infoboxCol1 + infoboxCol2 + infoboxCol3 + infoboxCol4).GetContent()
  36. /**************************
  37. * Box
  38. /**************************/
  39. lineChart := chartjs.Line().
  40. SetID("salechart").
  41. SetHeight(180).
  42. SetTitle("Sales: 1 Jan, 2019 - 30 Jul, 2019").
  43. SetLabels([]string{"January", "February", "March", "April", "May", "June", "July"}).
  44. AddDataSet("Electronics").
  45. DSData([]float64{65, 59, 80, 81, 56, 55, 40}).
  46. DSFill(false).
  47. DSBorderColor("rgb(210, 214, 222)").
  48. DSLineTension(0.1).
  49. AddDataSet("Digital Goods").
  50. DSData([]float64{28, 48, 40, 19, 86, 27, 90}).
  51. DSFill(false).
  52. DSBorderColor("rgba(60,141,188,1)").
  53. DSLineTension(0.1).
  54. GetContent()
  55. title := `<p class="text-center"><strong>Goal Completion</strong></p>`
  56. progressGroup := progress_group.New().
  57. SetTitle("Add Products to Cart").
  58. SetColor("#76b2d4").
  59. SetDenominator(200).
  60. SetMolecular(160).
  61. SetPercent(80).
  62. GetContent()
  63. progressGroup1 := progress_group.New().
  64. SetTitle("Complete Purchase").
  65. SetColor("#f17c6e").
  66. SetDenominator(400).
  67. SetMolecular(310).
  68. SetPercent(80).
  69. GetContent()
  70. progressGroup2 := progress_group.New().
  71. SetTitle("Visit Premium Page").
  72. SetColor("#ace0ae").
  73. SetDenominator(800).
  74. SetMolecular(490).
  75. SetPercent(80).
  76. GetContent()
  77. progressGroup3 := progress_group.New().
  78. SetTitle("Send Inquiries").
  79. SetColor("#fdd698").
  80. SetDenominator(500).
  81. SetMolecular(250).
  82. SetPercent(50).
  83. GetContent()
  84. boxInternalCol1 := colComp.SetContent(lineChart).SetSize(types.SizeMD(8)).GetContent()
  85. boxInternalCol2 := colComp.
  86. SetContent(template.HTML(title) + progressGroup + progressGroup1 + progressGroup2 + progressGroup3).
  87. SetSize(types.SizeMD(4)).
  88. GetContent()
  89. boxInternalRow := components.Row().SetContent(boxInternalCol1 + boxInternalCol2).GetContent()
  90. description1 := description.New().
  91. SetPercent("17").
  92. SetNumber("¥140,100").
  93. SetTitle("TOTAL REVENUE").
  94. SetArrow("up").
  95. SetColor("green").
  96. SetBorder("right").
  97. GetContent()
  98. description2 := description.New().
  99. SetPercent("2").
  100. SetNumber("440,560").
  101. SetTitle("TOTAL REVENUE").
  102. SetArrow("down").
  103. SetColor("red").
  104. SetBorder("right").
  105. GetContent()
  106. description3 := description.New().
  107. SetPercent("12").
  108. SetNumber("¥140,050").
  109. SetTitle("TOTAL REVENUE").
  110. SetArrow("up").
  111. SetColor("green").
  112. SetBorder("right").
  113. GetContent()
  114. description4 := description.New().
  115. SetPercent("1").
  116. SetNumber("30943").
  117. SetTitle("TOTAL REVENUE").
  118. SetArrow("up").
  119. SetColor("green").
  120. GetContent()
  121. size2 := map[string]string{"sm": "3", "xs": "6"}
  122. boxInternalCol3 := colComp.SetContent(description1).SetSize(size2).GetContent()
  123. boxInternalCol4 := colComp.SetContent(description2).SetSize(size2).GetContent()
  124. boxInternalCol5 := colComp.SetContent(description3).SetSize(size2).GetContent()
  125. boxInternalCol6 := colComp.SetContent(description4).SetSize(size2).GetContent()
  126. boxInternalRow2 := components.Row().SetContent(boxInternalCol3 + boxInternalCol4 + boxInternalCol5 + boxInternalCol6).GetContent()
  127. box := components.Box().WithHeadBorder().SetHeader("Monthly Recap Report").
  128. SetBody(boxInternalRow).
  129. SetFooter(boxInternalRow2).
  130. GetContent()
  131. boxcol := colComp.SetContent(box).SetSize(types.SizeMD(12)).GetContent()
  132. row2 := components.Row().SetContent(boxcol).GetContent()
  133. /**************************
  134. * Pie Chart
  135. /**************************/
  136. pie := chartjs.Pie().
  137. SetHeight(170).
  138. SetLabels([]string{"Navigator", "Opera", "Safari", "FireFox", "IE", "Chrome"}).
  139. SetID("pieChart").
  140. AddDataSet("Chrome").
  141. DSData([]float64{100, 300, 600, 400, 500, 700}).
  142. DSBackgroundColor([]chartjs.Color{
  143. "rgb(255, 205, 86)", "rgb(54, 162, 235)", "rgb(255, 99, 132)", "rgb(255, 205, 86)", "rgb(54, 162, 235)", "rgb(255, 99, 132)",
  144. }).
  145. GetContent()
  146. legend := chart_legend.New().SetData([]map[string]string{
  147. {
  148. "label": " Chrome",
  149. "color": "red",
  150. }, {
  151. "label": " IE",
  152. "color": "Green",
  153. }, {
  154. "label": " FireFox",
  155. "color": "yellow",
  156. }, {
  157. "label": " Sarafri",
  158. "color": "blue",
  159. }, {
  160. "label": " Opera",
  161. "color": "light-blue",
  162. }, {
  163. "label": " Navigator",
  164. "color": "gray",
  165. },
  166. }).GetContent()
  167. boxDanger := components.Box().SetTheme("danger").WithHeadBorder().SetHeader("Browser Usage").
  168. SetBody(components.Row().
  169. SetContent(colComp.SetSize(types.SizeMD(8)).
  170. SetContent(pie).
  171. GetContent() + colComp.SetSize(types.SizeMD(4)).
  172. SetContent(legend).
  173. GetContent()).GetContent()).
  174. SetFooter(`<p class="text-center"><a href="javascript:void(0)" class="uppercase">View All Users</a></p>`).
  175. GetContent()
  176. tabs := components.Tabs().SetData([]map[string]template.HTML{
  177. {
  178. "title": "tabs1",
  179. "content": template.HTML(`<b>How to use:</b>
  180. <p>Exactly like the original bootstrap tabs except you should use
  181. the custom wrapper <code>.nav-tabs-custom</code> to achieve this style.</p>
  182. A wonderful serenity has taken possession of my entire soul,
  183. like these sweet mornings of spring which I enjoy with my whole heart.
  184. I am alone, and feel the charm of existence in this spot,
  185. which was created for the bliss of souls like mine. I am so happy,
  186. my dear friend, so absorbed in the exquisite sense of mere tranquil existence,
  187. that I neglect my talents. I should be incapable of drawing a single stroke
  188. at the present moment; and yet I feel that I never was a greater artist than now.`),
  189. }, {
  190. "title": "tabs2",
  191. "content": template.HTML(`
  192. The European languages are members of the same family. Their separate existence is a myth.
  193. For science, music, sport, etc, Europe uses the same vocabulary. The languages only differ
  194. in their grammar, their pronunciation and their most common words. Everyone realizes why a
  195. new common language would be desirable: one could refuse to pay expensive translators. To
  196. achieve this, it would be necessary to have uniform grammar, pronunciation and more common
  197. words. If several languages coalesce, the grammar of the resulting language is more simple
  198. and regular than that of the individual languages.
  199. `),
  200. }, {
  201. "title": "tabs3",
  202. "content": template.HTML(`
  203. Lorem Ipsum is simply dummy text of the printing and typesetting industry.
  204. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,
  205. when an unknown printer took a galley of type and scrambled it to make a type specimen book.
  206. It has survived not only five centuries, but also the leap into electronic typesetting,
  207. remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset
  208. sheets containing Lorem Ipsum passages, and more recently with desktop publishing software
  209. like Aldus PageMaker including versions of Lorem Ipsum.
  210. `),
  211. },
  212. }).GetContent()
  213. buttonTest := `<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal" data-whatever="@mdo">Open modal for @mdo</button>`
  214. popupForm := `<form>
  215. <div class="form-group">
  216. <label for="recipient-name" class="col-form-label">Recipient:</label>
  217. <input type="text" class="form-control" id="recipient-name">
  218. </div>
  219. <div class="form-group">
  220. <label for="message-text" class="col-form-label">Message:</label>
  221. <textarea class="form-control" id="message-text"></textarea>
  222. </div>
  223. </form>`
  224. popup := components.Popup().SetID("exampleModal").
  225. SetFooter("Save Change").
  226. SetTitle("this is a popup").
  227. SetBody(template.HTML(popupForm)).
  228. GetContent()
  229. col5 := colComp.SetSize(types.SizeMD(8)).SetContent(tabs + template.HTML(buttonTest)).GetContent()
  230. col6 := colComp.SetSize(types.SizeMD(4)).SetContent(boxDanger + popup).GetContent()
  231. row4 := components.Row().SetContent(col5 + col6).GetContent()
  232. return types.Panel{
  233. Content: row1 + row2 + row4,
  234. Title: "Dashboard",
  235. Description: "dashboard example",
  236. }, nil
  237. }