diff --git a/assets/asset-corporate-portal/css/sas.bundle.css b/assets/asset-corporate-portal/css/sas.bundle.css index ccd2a7d..a941405 100644 --- a/assets/asset-corporate-portal/css/sas.bundle.css +++ b/assets/asset-corporate-portal/css/sas.bundle.css @@ -4000,19 +4000,6 @@ a.text-white:focus { box-shadow: 0px 9px 16px 0px rgba(var(--dangerrgb), var(--opacity03)) !important; } -/* ### NAV*/ -.nav-tabs .nav-link.active, -.nav-tabs .nav-item.show .nav-link { - color: var(--primary) !important; - background-color: #ffffff; - border-color: #e4e6ef #e4e6ef #ffffff; -} -.nav-pills .nav-link.active, -.nav-pills .show > .nav-link { - color: #ffffff; - background-color: var(--primary) !important; -} -/* ### BUTTON HOVER TEXT */ /* ## PRIMARY */ .btn.btn-hover-text-primary:not(:disabled):not(.disabled):active:not(.btn-text), .btn.btn-hover-text-primary:not(:disabled):not(.disabled).active, @@ -4057,7 +4044,63 @@ a.text-white:focus { .show .btn.btn-hover-text-danger.btn-dropdown { color: var(--danger) !important; } +/* ### NAV & BREADCRUMB*/ +.breadcrumb { + display: -webkit-box; + display: -ms-flexbox; + display: flex; + -ms-flex-wrap: wrap; + flex-wrap: wrap; + padding: 0px 0px !important; + padding-left: 0 !important; + margin-bottom: 1rem; + list-style: none; + background-color: var(--white) !important; + border-radius: 0.42rem; +} + +.breadcrumb-item a { + color: var(--text-black) !important; + font-family: Poppins !important; + font-size: 13px !important; + font-style: normal !important; + font-weight: 500 !important; + line-height: 21px !important; +} + +.breadcrumb-item.active { + color: var(--text-disabled) !important; + font-family: Poppins !important; + font-size: 13px !important; + font-style: normal !important; + font-weight: 500 !important; + line-height: 21px !important; +} +.nav-tabs { + border-bottom: 0px solid #000000 !important; +} +.nav-link { + color: var(--text-grey) !important; + font-family: Public Sans !important; + font-size: 14px !important; + font-style: normal !important; + font-weight: 600 !important; + line-height: 22px !important; + text-align: center !important; +} + +.nav-link.active { + color: var(--text-black) !important; /* Warna teks untuk tab yang aktif */ + border-bottom: 2px solid var(--primary) !important; /* Garis bawah untuk tab yang aktif */ + font-family: Public Sans !important; + font-size: 14px !important; + font-style: normal !important; + font-weight: 600 !important; + line-height: 22px !important; + text-align: center !important; +} +/* ### BUTTON HOVER TEXT */ /* ### */ /* ## PRIMARY */ /* ## SECONDARY */ diff --git a/assets/mcu/kelainan-global.html b/assets/mcu/kelainan-global.html new file mode 100644 index 0000000..5bcf212 --- /dev/null +++ b/assets/mcu/kelainan-global.html @@ -0,0 +1,338 @@ + + + + + + + + + KELAINAN GLOBAL | MCU004 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+

Data Persentase Kelainan Global

+
+ +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/mcu/kelainan-global.php b/assets/mcu/kelainan-global.php deleted file mode 100644 index ba59a12..0000000 --- a/assets/mcu/kelainan-global.php +++ /dev/null @@ -1,301 +0,0 @@ - - - - - - - - - KELAINAN GLOBAL | MCU004 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
-

Data Persentase Kelainan Global

-
- -
-
-
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/cmd/main.go b/cmd/main.go index c98a1d7..1e2565a 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -62,8 +62,12 @@ func main() { if err != nil { app.Logger.Fatalf("failed to create store: %s", err) } + bchart, err := db.NewBarChartStore(dbName) + if err != nil { + app.Logger.Fatalf("failed to create store: %s", err) + } - lpchart := services.NewServicesPiechart(services.Piechart{}, LpchartStore) + lpchart := services.NewServicesPiechart(services.Piechart{}, services.Barchart{}, LpchartStore, bchart) lphsx := handlers.NewPiechartHandler(lpchart) handlers.SetupRoutesPieChart(app, lphsx) diff --git a/db/chart.store.go b/db/chart.store.go index 904c8e3..f44f54c 100644 --- a/db/chart.store.go +++ b/db/chart.store.go @@ -9,6 +9,9 @@ import ( type PieChartStore struct { Db *sql.DB } +type BarChartStore struct { + Db *sql.DB +} func NewPieChartStore(dbName string) (PieChartStore, error) { Db, err := getConnection(dbName) @@ -24,3 +27,17 @@ func NewPieChartStore(dbName string) (PieChartStore, error) { Db, }, nil } +func NewBarChartStore(dbName string) (BarChartStore, error) { + Db, err := getConnection(dbName) + if err != nil { + return BarChartStore{}, err + } + + if err := createMigrations(dbName, Db); err != nil { + return BarChartStore{}, err + } + + return BarChartStore{ + Db, + }, nil +} diff --git a/handlers/chart.handlers.go b/handlers/chart.handlers.go index 3a0e382..ac6455c 100644 --- a/handlers/chart.handlers.go +++ b/handlers/chart.handlers.go @@ -10,6 +10,7 @@ import ( "github.com/a-h/templ" "github.com/emarifer/go-templ-project-structure/services" + kelainanglobal "github.com/emarifer/go-templ-project-structure/views/mcu/kelainan_global" "github.com/emarifer/go-templ-project-structure/views/piechart" "github.com/emarifer/go-templ-project-structure/views/xsample" @@ -18,6 +19,7 @@ import ( type PiechartService interface { GetPieChart(string, int) (string, services.Piechart, error) + GetBarChart(code string, id int) (string, services.Barchart, error) } func NewPiechartHandler(us PiechartService) *PiechartHandler { @@ -60,6 +62,47 @@ func (uh *PiechartHandler) ShowPieChart(c echo.Context) error { helo := piechart.ShowPieChart("Chart", piechart.MainPieChart(randomID, string(jsonData)), piechart.CssPieChart(), piechart.JsPieChart()) return uh.View(c, helo) } +func (uh *PiechartHandler) ShowBarChart(c echo.Context) error { + // helo := piechart.MainPieChart("main_001") + var code = "mcu004" + title, udata, err := uh.PiechartService.GetBarChart(code, 1) + if err != nil { + // fmt.Println(err) + return err + } + var code2 = "mcu005" + title2, udata2, err := uh.PiechartService.GetBarChart(code2, 1) + if err != nil { + // fmt.Println(err) + return err + } + + jsonData, err := json.MarshalIndent(udata, "", " ") + if err != nil { + fmt.Println("Error:", err) + return err + } + jsonData2, err := json.MarshalIndent(udata2, "", " ") + if err != nil { + fmt.Println("Error:", err) + return err + } + + // randomID := md5.Sum([]byte(title + time.Now().String())) + seed := title + time.Now().String() + hash := md5.Sum([]byte(seed)) + randomID := hex.EncodeToString(hash[:]) + randomID = strings.ReplaceAll(randomID, "-", "") + + seed2 := title2 + time.Now().String() + hash2 := md5.Sum([]byte(seed2)) + randomID2 := hex.EncodeToString(hash2[:]) + randomID2 = strings.ReplaceAll(randomID2, "-", "") + + // randomID := hex.EncodeToString(md5.Sum([]byte(title + time.Now().String()))) + helo := kelainanglobal.ShowKelainanGlobal("Kelainan global", kelainanglobal.MainKelainanGlobal(randomID, string(jsonData), randomID2, string(jsonData2)), kelainanglobal.CssKelainanGlobal(), kelainanglobal.JsKelainanGlobal()) + return uh.View(c, helo) +} func (uh *PiechartHandler) View(c echo.Context, cmp templ.Component) error { c.Response().Header().Set(echo.HeaderContentType, echo.MIMETextHTML) diff --git a/handlers/routes.go b/handlers/routes.go index 7a1b452..2cbb1c9 100644 --- a/handlers/routes.go +++ b/handlers/routes.go @@ -22,6 +22,7 @@ func SetupRoutesLandingPage(app *echo.Echo, h *LandingPageHandler) { func SetupRoutesPieChart(app *echo.Echo, h *PiechartHandler) { Lp := app.Group("/pie_chart") Lp.GET("/", h.ShowPieChart) + Lp.GET("/bar", h.ShowBarChart) } func SetupRoutesProject(app *echo.Echo) { diff --git a/services/chart.services.go b/services/chart.services.go index 2c0b74b..1bd6957 100644 --- a/services/chart.services.go +++ b/services/chart.services.go @@ -6,10 +6,12 @@ import ( "github.com/emarifer/go-templ-project-structure/db" ) -func NewServicesPiechart(u Piechart, uStore db.PieChartStore) *ServicesPiechart { +func NewServicesPiechart(u Piechart, b Barchart, uStore db.PieChartStore, bStore db.BarChartStore) *ServicesPiechart { return &ServicesPiechart{ Piechart: u, + Barchart: b, + BarChartStore: bStore, PieChartStore: uStore, } } @@ -122,6 +124,8 @@ type Piechart struct { type ServicesPiechart struct { Piechart Piechart + Barchart Barchart + BarChartStore db.BarChartStore PieChartStore db.PieChartStore } @@ -329,6 +333,122 @@ func GetPieChartMcu006(code string, id int) (string, Piechart, error) { return title, option, nil } +// Kelainan MCU - MCU004 +func GetBarChartMcu004(code string, id int) (string, Barchart, error) { + title := "Kelainan MCU" + option := Barchart{} + option.Title = struct { + Text string "json:\"text\"" + }{title} + option.Dataset = struct { + Source [][]interface{} "json:\"source\"" + }{[][]interface{}{ + {"score", "amount", "product", "percentage"}, + {200, 447, "Body Mass Index"}, + {150, 314, "Pemeriksaan Mata"}, + {125, 314, "Fungsi Lemak"}, + {100, 254, "Autospirometri"}, + {90, 200, "Hematologi"}, + {80, 180, "ECG"}, + {75, 160, "Hiperuricemia"}, + {70, 125, "Tekanan Darah"}, + {60, 118, "Urine Lengkap"}, + {50, 87, "Fungsi Hati"}, + }} + option.Grid.ContainLabel = true + option.XAxis.Name = "amount" + option.YAxis.Type = "category" + option.VisualMap.Orient = "horizontal" + option.VisualMap.Left = "center" + option.VisualMap.Min = 10 + option.VisualMap.Max = 100 + option.VisualMap.Show = false + option.VisualMap.Dimension = 0 + option.VisualMap.InRange.Color = []string{"#42aaf5", "#00eaf2", "#035bff"} + option.Series = []struct { + Label struct { + Position string "json:\"position\"" + Show bool "json:\"show\"" + Formatter string "json:\"formatter\"" + } "json:\"label\"" + Type string "json:\"type\"" + Encode struct { + X string "json:\"x\"" + Y string "json:\"y\"" + } "json:\"encode\"" + }{ + {Label: struct { + Position string "json:\"position\"" + Show bool "json:\"show\"" + Formatter string "json:\"formatter\"" + }{Position: "right", Show: true, Formatter: "{@[3]} %"}, + Type: "bar", Encode: struct { + X string "json:\"x\"" + Y string "json:\"y\"" + }{X: "amount", Y: "product"}}, + } + + return title, option, nil + +} + +// Kelainan MCU - MCU004 +func GetBarChartMcu005(code string, id int) (string, Barchart, error) { + title := "Kelainan Fisik" + option := Barchart{} + option.Title = struct { + Text string "json:\"text\"" + }{title} + option.Dataset = struct { + Source [][]interface{} "json:\"source\"" + }{[][]interface{}{ + {"score", "amount", "product", "percentage"}, + {200, 400, "Obesitas Stage 1"}, + {150, 300, "Pre Hipertensi"}, + {133, 250, "Kelainan Refraksi"}, + {125, 180, "Overweight"}, + {100, 125, "Obesitas Stage 2"}, + {80, 100, "Hipertensi grade 1"}, + {70, 80, "Kel. Refrakti terkoreksi"}, + {60, 70, "Kel. Refrakti tidak terkoreksi"}, + {55, 55, "Hipertensi grade 2"}, + }} + option.Grid.ContainLabel = true + option.XAxis.Name = "amount" + option.YAxis.Type = "category" + option.VisualMap.Orient = "horizontal" + option.VisualMap.Left = "center" + option.VisualMap.Min = 10 + option.VisualMap.Max = 100 + option.VisualMap.Show = false + option.VisualMap.Dimension = 0 + option.VisualMap.InRange.Color = []string{"#42aaf5", "#00eaf2", "#035bff"} + option.Series = []struct { + Label struct { + Position string "json:\"position\"" + Show bool "json:\"show\"" + Formatter string "json:\"formatter\"" + } "json:\"label\"" + Type string "json:\"type\"" + Encode struct { + X string "json:\"x\"" + Y string "json:\"y\"" + } "json:\"encode\"" + }{ + {Label: struct { + Position string "json:\"position\"" + Show bool "json:\"show\"" + Formatter string "json:\"formatter\"" + }{Position: "right", Show: true, Formatter: "{@[3]} %"}, + Type: "bar", Encode: struct { + X string "json:\"x\"" + Y string "json:\"y\"" + }{X: "amount", Y: "product"}}, + } + + return title, option, nil + +} func (su *ServicesPiechart) GetPieChart(code string, id int) (string, Piechart, error) { if code == "mcu001" { return GetPieChartMcu001(code, id) @@ -340,3 +460,14 @@ func (su *ServicesPiechart) GetPieChart(code string, id int) (string, Piechart, return "", Piechart{}, fmt.Errorf("code " + code + " not found") } +func (su *ServicesPiechart) GetBarChart(code string, id int) (string, Barchart, error) { + + if code == "mcu004" { + return GetBarChartMcu004(code, id) + } + if code == "mcu005" { + return GetBarChartMcu005(code, id) + } + + return "", Barchart{}, fmt.Errorf("code " + code + " not found") +} diff --git a/views/mcu/kelainan_global/kelainan_global.templ b/views/mcu/kelainan_global/kelainan_global.templ new file mode 100644 index 0000000..f391b28 --- /dev/null +++ b/views/mcu/kelainan_global/kelainan_global.templ @@ -0,0 +1,131 @@ +package kelainanglobal + +import ( + "github.com/emarifer/go-templ-project-structure/views/layout" + chart "github.com/emarifer/go-templ-project-structure/views/component/chart" +) + +templ MainKelainanGlobal(divMcu string, dataMcu string, divFisik string, dataFisik string) { +
+ @HeaderKelainanGlobal() +
+ +
+

Data Persentase Kelainan Global

+
+
+
+ @chart.ShowChart(divMcu, dataMcu) +
+
+ @chart.ShowChart(divFisik, dataFisik) +
+
+ +
+
+} + +templ CssKelainanGlobal() { + + + + +} + +templ JsKelainanGlobal() { + // echart + +} + +templ HeaderKelainanGlobal() { + +
+
+

+ PT. Sadhana Abiyasa Sampoerna +

+ +
+
+ +
+ + + +
+
+
+ +
+ +
+} + +templ ShowKelainanGlobal(title string, cmp templ.Component, css templ.Component, js templ.Component) { + @layout.PlaygroundLayout(title, css, js) { + @cmp + } +} diff --git a/views/mcu/kelainan_global/kelainan_global_templ.go b/views/mcu/kelainan_global/kelainan_global_templ.go new file mode 100644 index 0000000..448a8d3 --- /dev/null +++ b/views/mcu/kelainan_global/kelainan_global_templ.go @@ -0,0 +1,175 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.2.663 +package kelainanglobal + +//lint:file-ignore SA4006 This context is only used if a nested component is present. + +import "github.com/a-h/templ" +import "context" +import "io" +import "bytes" + +import ( + chart "github.com/emarifer/go-templ-project-structure/views/component/chart" + "github.com/emarifer/go-templ-project-structure/views/layout" +) + +func MainKelainanGlobal(divMcu string, dataMcu string, divFisik string, dataFisik string) templ.Component { + return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) { + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer) + if !templ_7745c5c3_IsBuffer { + templ_7745c5c3_Buffer = templ.GetBuffer() + defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var1 := templ.GetChildren(ctx) + if templ_7745c5c3_Var1 == nil { + templ_7745c5c3_Var1 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = HeaderKelainanGlobal().Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

Data Persentase Kelainan Global

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = chart.ShowChart(divMcu, dataMcu).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = chart.ShowChart(divFisik, dataFisik).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if !templ_7745c5c3_IsBuffer { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W) + } + return templ_7745c5c3_Err + }) +} + +func CssKelainanGlobal() templ.Component { + return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) { + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer) + if !templ_7745c5c3_IsBuffer { + templ_7745c5c3_Buffer = templ.GetBuffer() + defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var2 := templ.GetChildren(ctx) + if templ_7745c5c3_Var2 == nil { + templ_7745c5c3_Var2 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if !templ_7745c5c3_IsBuffer { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W) + } + return templ_7745c5c3_Err + }) +} + +func JsKelainanGlobal() templ.Component { + return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) { + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer) + if !templ_7745c5c3_IsBuffer { + templ_7745c5c3_Buffer = templ.GetBuffer() + defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var3 := templ.GetChildren(ctx) + if templ_7745c5c3_Var3 == nil { + templ_7745c5c3_Var3 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if !templ_7745c5c3_IsBuffer { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W) + } + return templ_7745c5c3_Err + }) +} + +func HeaderKelainanGlobal() templ.Component { + return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) { + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer) + if !templ_7745c5c3_IsBuffer { + templ_7745c5c3_Buffer = templ.GetBuffer() + defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var4 := templ.GetChildren(ctx) + if templ_7745c5c3_Var4 == nil { + templ_7745c5c3_Var4 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

PT. Sadhana Abiyasa Sampoerna\r

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if !templ_7745c5c3_IsBuffer { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W) + } + return templ_7745c5c3_Err + }) +} + +func ShowKelainanGlobal(title string, cmp templ.Component, css templ.Component, js templ.Component) templ.Component { + return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) { + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer) + if !templ_7745c5c3_IsBuffer { + templ_7745c5c3_Buffer = templ.GetBuffer() + defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var5 := templ.GetChildren(ctx) + if templ_7745c5c3_Var5 == nil { + templ_7745c5c3_Var5 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + templ_7745c5c3_Var6 := templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) { + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer) + if !templ_7745c5c3_IsBuffer { + templ_7745c5c3_Buffer = templ.GetBuffer() + defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) + } + templ_7745c5c3_Err = cmp.Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if !templ_7745c5c3_IsBuffer { + _, templ_7745c5c3_Err = io.Copy(templ_7745c5c3_W, templ_7745c5c3_Buffer) + } + return templ_7745c5c3_Err + }) + templ_7745c5c3_Err = layout.PlaygroundLayout(title, css, js).Render(templ.WithChildren(ctx, templ_7745c5c3_Var6), templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if !templ_7745c5c3_IsBuffer { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W) + } + return templ_7745c5c3_Err + }) +}