diff --git a/controllers/clan_controller.go b/controllers/clan_controller.go index e8ab648..23572de 100644 --- a/controllers/clan_controller.go +++ b/controllers/clan_controller.go @@ -31,6 +31,21 @@ func GetAllClans(c *gin.Context) { c.JSON(http.StatusOK, clans) } +// GetAllClanOptions GET /clan_options +func GetAllClanOptions(c *gin.Context) { + var clans []models.Clan + models.DB.Find(&clans) + + var htmlOptions string + htmlOptions = `` + for _, clan := range clans { + htmlOptions += fmt.Sprintf(``, clan.ID, clan.Tag, clan.Name) + } + + c.Header("Content-Type", "text/html") + c.String(http.StatusOK, htmlOptions) +} + // AddClan POST /clan func AddClan(c *gin.Context) { var input AddClanInput diff --git a/isc_data.db b/isc_data.db index 98c0d09..133885f 100644 Binary files a/isc_data.db and b/isc_data.db differ diff --git a/isc_rest.log b/isc_rest.log index 0fdf4c4..84cc2c7 100644 --- a/isc_rest.log +++ b/isc_rest.log @@ -52,3 +52,109 @@ Deleted clan 'safdsdfafd' with tag 'asdfasdfsdf' [GIN] 2024/01/14 - 21:49:32 | 200 | 75.1µs | 127.0.0.1 | GET "/players" [GIN] 2024/01/14 - 21:50:57 | 200 | 1.1241ms | 127.0.0.1 | GET "/" [GIN] 2024/01/14 - 22:05:47 | 200 | 1.1526ms | 127.0.0.1 | GET "/" +[GIN] 2024/01/15 - 09:55:07 | 200 | 2.5532ms | ::1 | GET "/" +[GIN] 2024/01/15 - 09:55:07 | 200 | 31.8818ms | ::1 | GET "/static/index.css" +[GIN] 2024/01/15 - 09:55:07 | 404 | 0s | ::1 | GET "/favicon.ico" +[GIN] 2024/01/15 - 09:55:19 | 200 | 79.4µs | ::1 | GET "/players" +[GIN] 2024/01/15 - 09:56:19 | 200 | 1.0013ms | ::1 | GET "/" +[GIN] 2024/01/15 - 09:56:19 | 200 | 548.6µs | ::1 | GET "/static/index.js" +[GIN] 2024/01/15 - 09:56:20 | 200 | 187.6µs | ::1 | GET "/players" +[GIN] 2024/01/15 - 09:56:22 | 200 | 687.1µs | ::1 | GET "/players" +[GIN] 2024/01/15 - 09:56:23 | 200 | 1.0003ms | ::1 | GET "/" +[GIN] 2024/01/15 - 09:59:53 | 200 | 0s | ::1 | GET "/players" +[GIN] 2024/01/15 - 10:00:08 | 200 | 848.8µs | ::1 | GET "/players" +[GIN] 2024/01/15 - 10:02:47 | 200 | 1.295ms | ::1 | GET "/" +[GIN] 2024/01/15 - 10:02:47 | 304 | 0s | ::1 | GET "/static/index.js" +[GIN] 2024/01/15 - 10:02:52 | 200 | 785.3µs | ::1 | GET "/" +[GIN] 2024/01/15 - 10:03:16 | 200 | 1.4718ms | ::1 | GET "/" +[GIN] 2024/01/15 - 10:03:17 | 200 | 2.6971ms | ::1 | GET "/" +[GIN] 2024/01/15 - 10:03:18 | 200 | 0s | ::1 | GET "/" +[GIN] 2024/01/15 - 10:03:23 | 200 | 695µs | ::1 | GET "/players" +[GIN] 2024/01/15 - 10:07:23 | 200 | 999.7µs | ::1 | GET "/" +[GIN] 2024/01/15 - 10:07:23 | 304 | 0s | ::1 | GET "/static/index.js" +[GIN] 2024/01/15 - 10:07:26 | 200 | 966µs | ::1 | GET "/" +[GIN] 2024/01/15 - 10:07:35 | 200 | 1.1975ms | ::1 | GET "/" +[GIN] 2024/01/15 - 10:07:58 | 200 | 921.1µs | ::1 | GET "/" +[GIN] 2024/01/15 - 10:08:18 | 200 | 504µs | ::1 | GET "/" +[GIN] 2024/01/15 - 10:08:20 | 200 | 738.1µs | ::1 | GET "/" +[GIN] 2024/01/15 - 10:08:20 | 200 | 32.1015ms | ::1 | GET "/static/index.css" +[GIN] 2024/01/15 - 10:08:20 | 200 | 32.1015ms | ::1 | GET "/static/index.js" +[GIN] 2024/01/15 - 10:08:21 | 404 | 0s | ::1 | GET "/favicon.ico" +[GIN] 2024/01/15 - 10:08:23 | 200 | 1.0003ms | ::1 | GET "/" +[GIN] 2024/01/15 - 10:09:12 | 200 | 393.6µs | ::1 | GET "/clans" +[GIN] 2024/01/15 - 10:09:24 | 200 | 386.1µs | ::1 | GET "/" +[GIN] 2024/01/15 - 10:09:36 | 200 | 249.7µs | ::1 | GET "/clans" +[GIN] 2024/01/15 - 10:09:38 | 200 | 728.4µs | ::1 | GET "/clans" +[GIN] 2024/01/15 - 10:09:39 | 200 | 510.8µs | ::1 | GET "/clans" +[GIN] 2024/01/15 - 10:09:50 | 200 | 938.7µs | ::1 | GET "/clans" +[GIN] 2024/01/15 - 10:09:55 | 200 | 101.5µs | ::1 | GET "/clans" +[GIN] 2024/01/15 - 10:09:59 | 200 | 552.2µs | ::1 | GET "/clans" +[GIN] 2024/01/15 - 10:14:57 | 200 | 1.3826ms | ::1 | GET "/" +[GIN] 2024/01/15 - 10:14:57 | 304 | 0s | ::1 | GET "/static/index.js" +[GIN] 2024/01/15 - 10:15:03 | 200 | 614.5µs | ::1 | GET "/" +[GIN] 2024/01/15 - 10:15:14 | 200 | 345.9µs | ::1 | GET "/clan_options" +[GIN] 2024/01/15 - 10:15:46 | 200 | 1.5371ms | ::1 | GET "/" +[GIN] 2024/01/15 - 10:15:46 | 200 | 32.727ms | ::1 | GET "/static/index.css" +[GIN] 2024/01/15 - 10:15:46 | 200 | 32.727ms | ::1 | GET "/static/index.js" +[GIN] 2024/01/15 - 10:15:47 | 404 | 0s | ::1 | GET "/favicon.ico" +[GIN] 2024/01/15 - 10:15:53 | 200 | 142.4µs | ::1 | GET "/clan_options" +[GIN] 2024/01/15 - 10:16:11 | 200 | 1.0272ms | ::1 | GET "/" +[GIN] 2024/01/15 - 10:16:16 | 200 | 849.7µs | ::1 | GET "/clan_options" +[GIN] 2024/01/15 - 10:18:18 | 200 | 427.3µs | ::1 | GET "/" +[GIN] 2024/01/15 - 10:18:18 | 304 | 301.7µs | ::1 | GET "/static/index.js" +[GIN] 2024/01/15 - 10:18:18 | 200 | 541.7µs | ::1 | GET "/clan_options" +[GIN] 2024/01/15 - 10:18:25 | 200 | 1.4775ms | ::1 | GET "/" +[GIN] 2024/01/15 - 10:18:25 | 200 | 937.3µs | ::1 | GET "/clan_options" +[GIN] 2024/01/15 - 10:19:03 | 200 | 1.0007ms | ::1 | GET "/" +[GIN] 2024/01/15 - 10:19:03 | 200 | 603.9µs | ::1 | GET "/clan_options" +[GIN] 2024/01/15 - 10:19:03 | 200 | 71.5µs | ::1 | GET "/clan_options" +[GIN] 2024/01/15 - 10:19:08 | 200 | 999.9µs | ::1 | GET "/" +[GIN] 2024/01/15 - 10:19:08 | 200 | 831.5µs | ::1 | GET "/clan_options" +[GIN] 2024/01/15 - 10:19:08 | 200 | 1.254ms | ::1 | GET "/clan_options" +[GIN] 2024/01/15 - 10:19:08 | 200 | 1.9087ms | ::1 | GET "/" +[GIN] 2024/01/15 - 10:19:08 | 200 | 211.1µs | ::1 | GET "/clan_options" +[GIN] 2024/01/15 - 10:19:08 | 200 | 403µs | ::1 | GET "/clan_options" +[GIN] 2024/01/15 - 10:19:09 | 200 | 607.6µs | ::1 | GET "/" +[GIN] 2024/01/15 - 10:19:09 | 200 | 226.1µs | ::1 | GET "/clan_options" +[GIN] 2024/01/15 - 10:19:09 | 200 | 146.4µs | ::1 | GET "/clan_options" +[GIN] 2024/01/15 - 10:19:13 | 200 | 1.3485ms | ::1 | GET "/" +[GIN] 2024/01/15 - 10:19:13 | 200 | 938.6µs | ::1 | GET "/clan_options" +[GIN] 2024/01/15 - 10:19:13 | 200 | 1.0501ms | ::1 | GET "/clan_options" +[GIN] 2024/01/15 - 10:26:17 | 200 | 516.5µs | ::1 | GET "/" +[GIN] 2024/01/15 - 10:26:17 | 304 | 581.2µs | ::1 | GET "/static/index.js" +[GIN] 2024/01/15 - 10:26:18 | 200 | 552µs | ::1 | GET "/clan_options" +[GIN] 2024/01/15 - 10:26:18 | 200 | 379.7µs | ::1 | GET "/clan_options" +Added clan 'testinger' with tag 'asd' +[GIN] 2024/01/15 - 10:26:24 | 200 | 2.1851ms | ::1 | POST "/clan" +[GIN] 2024/01/15 - 10:26:24 | 200 | 551.3µs | ::1 | GET "/players" +[GIN] 2024/01/15 - 10:27:54 | 200 | 1.4677ms | ::1 | GET "/" +[GIN] 2024/01/15 - 10:27:54 | 200 | 520.6µs | ::1 | GET "/clan_options" +[GIN] 2024/01/15 - 10:27:54 | 200 | 471µs | ::1 | GET "/clan_options" +[GIN] 2024/01/15 - 10:27:57 | 200 | 764.4µs | ::1 | GET "/players" +Deleted clan 'testinger' with tag 'asd' +[GIN] 2024/01/15 - 10:27:58 | 200 | 1.8567ms | ::1 | DELETE "/clan/14" +[GIN] 2024/01/15 - 10:27:58 | 200 | 940.8µs | ::1 | GET "/players" +[GIN] 2024/01/15 - 10:27:59 | 200 | 950.2µs | ::1 | GET "/players" +Deleted clan 'ewerqer' with tag 'werwqer' +[GIN] 2024/01/15 - 10:28:01 | 200 | 18.0168ms | ::1 | DELETE "/clan/13" +[GIN] 2024/01/15 - 10:28:01 | 200 | 112µs | ::1 | GET "/players" +Deleted clan 'ewerqer' with tag 'werwqer' +[GIN] 2024/01/15 - 10:28:01 | 200 | 31.2637ms | ::1 | DELETE "/clan/13" +[GIN] 2024/01/15 - 10:28:01 | 200 | 999.4µs | ::1 | GET "/players" +[GIN] 2024/01/15 - 10:28:03 | 200 | 1.2154ms | ::1 | GET "/" +[GIN] 2024/01/15 - 10:28:03 | 200 | 519µs | ::1 | GET "/clan_options" +[GIN] 2024/01/15 - 10:28:03 | 200 | 1.103ms | ::1 | GET "/clan_options" +Added clan '12333' with tag '12333' +[GIN] 2024/01/15 - 10:28:08 | 200 | 2.6491ms | ::1 | POST "/clan" +[GIN] 2024/01/15 - 10:28:08 | 200 | 966.7µs | ::1 | GET "/players" +[GIN] 2024/01/15 - 10:30:21 | 200 | 1.0749ms | ::1 | GET "/" +[GIN] 2024/01/15 - 10:30:21 | 304 | 362.4µs | ::1 | GET "/static/index.js" +[GIN] 2024/01/15 - 10:30:21 | 200 | 993.8µs | ::1 | GET "/clan_options" +[GIN] 2024/01/15 - 10:30:21 | 200 | 167.3µs | ::1 | GET "/clan_options" +[GIN] 2024/01/15 - 10:30:24 | 200 | 962.3µs | ::1 | GET "/players" +Added clan 'zrdz' with tag 'zrdz' +[GIN] 2024/01/15 - 10:30:28 | 200 | 1.3631ms | ::1 | POST "/clan" +[GIN] 2024/01/15 - 10:30:28 | 200 | 0s | ::1 | GET "/players" +Added clan 'zrdz' with tag 'zrdz' +[GIN] 2024/01/15 - 10:30:28 | 200 | 7.0468ms | ::1 | POST "/clan" +[GIN] 2024/01/15 - 10:30:28 | 200 | 489.7µs | ::1 | GET "/players" diff --git a/main.go b/main.go index b1f2692..cbf1b94 100644 --- a/main.go +++ b/main.go @@ -61,6 +61,7 @@ func main() { }) router.GET("/clans", controllers.GetAllClans) + router.GET("/clan_options", controllers.GetAllClanOptions) router.GET("/clan/:id", controllers.GetClanByID) router.POST("/clan", controllers.AddClan) router.PATCH("/clan/:id", controllers.UpdateClanByID) diff --git a/static/index.js b/static/index.js new file mode 100644 index 0000000..bb2c1fd --- /dev/null +++ b/static/index.js @@ -0,0 +1,25 @@ +function setupClanButtons(dropdownId, delBtnId, editBtnId) { + const dropdown = document.getElementById(dropdownId); + const deleteButton = document.getElementById(delBtnId); + const editButton = document.getElementById(editBtnId); + + dropdown.addEventListener('change', function () { + deleteButton.disabled = !this.value; + editButton.disabled = !this.value; + }); +} + +function getClanLists(event) { + const button = event.relatedTarget; + const clanListId = button.getAttribute('data-bs-list'); + const clanList = document.querySelector(clanListId); + + let otherClanListId; + if (clanListId === '#home-clan') + otherClanListId = '#opponent-clan' + else + otherClanListId = '#home-clan' + const otherClanList = document.querySelector(otherClanListId); + + return [clanList, otherClanList]; +} \ No newline at end of file diff --git a/templates/components/header.html b/templates/components/header.html index 6eee6f3..ec06537 100644 --- a/templates/components/header.html +++ b/templates/components/header.html @@ -4,6 +4,7 @@ Infantry Skill Calculator + diff --git a/templates/components/home_clan_bar.html b/templates/components/home_clan_bar.html index 6226a64..c217087 100644 --- a/templates/components/home_clan_bar.html +++ b/templates/components/home_clan_bar.html @@ -8,9 +8,7 @@