From a0df67687cd447babab335c3ab53ddbfe0d23928 Mon Sep 17 00:00:00 2001 From: sfill70 Date: Thu, 15 Sep 2022 14:33:08 +0300 Subject: [PATCH 01/10] the first commit --- .../com/game/controller/PlayerController.java | 9 +- .../com/game/repository/PlayerRepository.java | 3 +- src/main/webapp/css/my.css | 9 + src/main/webapp/html/my.html | 173 +++++++++++++++++- 4 files changed, 189 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/game/controller/PlayerController.java b/src/main/java/com/game/controller/PlayerController.java index 362efdbb..909007ed 100644 --- a/src/main/java/com/game/controller/PlayerController.java +++ b/src/main/java/com/game/controller/PlayerController.java @@ -44,7 +44,8 @@ public Integer getAllCount() { @PostMapping public ResponseEntity createPlayer(@RequestBody PlayerInfo info) { - if (StringUtils.isEmpty(info.name) || info.name.length() > 12) return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null); + if (StringUtils.isEmpty(info.name) || info.name.length() > 12) + return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null); if (info.title.length() > 30) return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null); if (isNull(info.race)) return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null); if (isNull(info.profession)) return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null); @@ -64,8 +65,10 @@ public ResponseEntity createPlayer(@RequestBody PlayerInfo info) { public ResponseEntity updatePlayer(@PathVariable("ID") long id, @RequestBody PlayerInfo info) { if (id <= 0) return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null); - if (nonNull(info.name) && (info.name.length() > 12 || info.name.isEmpty())) return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null); - if (nonNull(info.title) && info.title.length() > 30) return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null); + if (nonNull(info.name) && (info.name.length() > 12 || info.name.isEmpty())) + return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null); + if (nonNull(info.title) && info.title.length() > 30) + return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null); Player player = playerService.updatePlayer(id, info.name, info.title, info.race, info.profession, info.banned); if (isNull(player)) { diff --git a/src/main/java/com/game/repository/PlayerRepository.java b/src/main/java/com/game/repository/PlayerRepository.java index f5de068e..8951e949 100644 --- a/src/main/java/com/game/repository/PlayerRepository.java +++ b/src/main/java/com/game/repository/PlayerRepository.java @@ -58,11 +58,12 @@ public class PlayerRepository { }}; public List getAll(int pageNumber, int pageSize) { - return storage.stream() + ListplayerList = storage.stream() .sorted(Comparator.comparingLong(Player::getId)) .skip((long) pageNumber * pageSize) .limit(pageSize) .collect(Collectors.toList()); + return playerList; } diff --git a/src/main/webapp/css/my.css b/src/main/webapp/css/my.css index e69de29b..714fa4dd 100644 --- a/src/main/webapp/css/my.css +++ b/src/main/webapp/css/my.css @@ -0,0 +1,9 @@ +th, td { + border: 1px solid black; + padding: 3px; +} + +.click_active{ + color: red; +} + diff --git a/src/main/webapp/html/my.html b/src/main/webapp/html/my.html index eb66ac55..50ff63a7 100644 --- a/src/main/webapp/html/my.html +++ b/src/main/webapp/html/my.html @@ -4,8 +4,179 @@ - +

RPG admin panel

+ + + + + + + + + + + + + + + + + +
#NameTitleRaceProfessionBirthdayBannedLevelEditDelete
+
+ Pages: +
+

TeXt

+ + + \ No newline at end of file From 869ba15cd975e40bf5f3500e9e694974a11c86c9 Mon Sep 17 00:00:00 2001 From: sfill70 Date: Thu, 15 Sep 2022 14:38:51 +0300 Subject: [PATCH 02/10] edit --- src/main/webapp/html/my.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/webapp/html/my.html b/src/main/webapp/html/my.html index 50ff63a7..98303187 100644 --- a/src/main/webapp/html/my.html +++ b/src/main/webapp/html/my.html @@ -89,7 +89,7 @@

TeXt

let identifier = "#paging_button_" + page_number; $(identifier) - .attr('class', "click_active") + .attr('class', "click_active"); /* $(identifier).css("color","red");*/ } From c457b38aa614560f550fd0ba0a8436ca47799df6 Mon Sep 17 00:00:00 2001 From: sfill70 Date: Fri, 16 Sep 2022 14:02:37 +0300 Subject: [PATCH 03/10] add func save() --- src/main/webapp/html/my.html | 78 ++++++++++++++++++++++++++++++------ 1 file changed, 65 insertions(+), 13 deletions(-) diff --git a/src/main/webapp/html/my.html b/src/main/webapp/html/my.html index 98303187..a1f804bd 100644 --- a/src/main/webapp/html/my.html +++ b/src/main/webapp/html/my.html @@ -62,7 +62,7 @@

TeXt

+ item.profession + "" + new Date(item.birthday).toLocaleDateString() + "" + item.banned + "" - + item.Level + "" + + item.level + "" + "" + "" @@ -119,7 +119,6 @@

TeXt

} function edit_account(id, pageNumber) { - // let url = "/rest/edit/" + id; let identifier_edit = '#button_edit_' + id; let identifier_delete = '#button_delete_' + id; $(identifier_delete).remove(); @@ -130,25 +129,37 @@

TeXt

td_name.innerHTML = ""; let td_title = document.getElementById("title" + id); - td_title.innerHTML = "" + td_title.innerHTML = "" + //Другой способо получения элемента let current_tr_element = $(identifier_edit).parent().parent(); let children = current_tr_element.children(); let td_race = children[3]; - getDropdownListRace(td_race, id) + td_race.innerHTML = getDropdownListRace(td_race, id); + // getDropdownListRace(td_race, id); + /* let race_id = '#race_select_' + id; + let race_current_value = td_race.innerHTML; + td_race.innerHTML = getDropdownListRace(td_race, id); + $(race_id).val(race_current_value).change();*/ let td_profession = children[4]; - getDropdownListProfession(td_profession, id) + td_profession.innerHTML = getDropdownListProfession(td_profession, id); let td_banned = children[6]; - getDropdownListBanned(td_banned,id) - // console.log(td_name); + td_banned.innerHTML = getDropdownListBanned(td_banned, id); + + let property_save_tag = "save_account(" + id + "," + pageNumber + ")"; + $(identifier_edit).attr("onclick", property_save_tag); } function getDropdownListRace(element, id) { - element.innerHTML = "" + + "" + "" + "" + - "" + + "" + "" + "" + "" + @@ -157,9 +168,12 @@

TeXt

} function getDropdownListProfession(element, id) { - element.innerHTML = "" + + "" + "" + - "" + + "" + "" + "" + "" + @@ -169,12 +183,50 @@

TeXt

} function getDropdownListBanned(element, id) { - element.innerHTML = "" + + "" + + "" + "" + ""; } + function save_account(id, pageNumber) { + let name_input = document.getElementById("input_name_" + id); + let title_input = document.getElementById("input_title_" + id); + let race_input = document.getElementById("race_select_" + id); + let profession_input = document.getElementById("profession_select_" + id); + let banned_input = document.getElementById("banned_select_" + id); + + let name = name_input.value; + let title = title_input.value; + let race = race_input.value; + let profession = profession_input.value; + let banned = banned_input.value; + // console.log(name + "-" + "-" + title + "-" + race + "-" + profession); + + let url = "/rest/players/" + id; + + $.ajax({ + url: url, + type: 'POST', + dataType: 'json', + contentType: "application/json;charset=UTF-8", + async: false, + data: JSON.stringify({ + "name": name, + "title": title, + "race": race, + "profession": profession, + "banned": banned + }), + success: function () { + show_list(pageNumber); + } + }); + } + From 92cbc28e3a2079bebc6d89dc3586252518f12cf7 Mon Sep 17 00:00:00 2001 From: sfill70 Date: Sun, 18 Sep 2022 13:15:05 +0300 Subject: [PATCH 04/10] add func create() --- src/main/webapp/css/my.css | 44 +++++++++ src/main/webapp/html/my.html | 178 +++++++++++++++++++++++++++-------- 2 files changed, 182 insertions(+), 40 deletions(-) diff --git a/src/main/webapp/css/my.css b/src/main/webapp/css/my.css index 714fa4dd..19aa59e8 100644 --- a/src/main/webapp/css/my.css +++ b/src/main/webapp/css/my.css @@ -7,3 +7,47 @@ th, td { color: red; } +img { + cursor: pointer; +} + + +.align-left{ + text-align: left; +} + + +.align-right{ + text-align: right; +} + + +select{ + width: auto; +} + + +input[type="date"]{ + width: auto; +} + +.label_create{ + width: 300px; +} + +.about-dialog{ + background-color: #555; + color: white; + opacity: 0.8; + width: max-content; + +} + +.create-button { + background-color: #555; + color: white; + opacity: 0.8; +} + + + diff --git a/src/main/webapp/html/my.html b/src/main/webapp/html/my.html index a1f804bd..b9b83026 100644 --- a/src/main/webapp/html/my.html +++ b/src/main/webapp/html/my.html @@ -33,7 +33,69 @@

RPG admin panel

Pages:
-

TeXt

+ +

Create new account

+
+ + + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + + +
+ + + + From ad5bf5c9b74b4ea568e84086d769a010f201ecd7 Mon Sep 17 00:00:00 2001 From: sfill70 Date: Sun, 18 Sep 2022 13:57:02 +0300 Subject: [PATCH 05/10] add css --- src/main/webapp/css/my.css | 59 +++++++++++++++++++++++------------- src/main/webapp/html/my.html | 20 ++++++------ 2 files changed, 48 insertions(+), 31 deletions(-) diff --git a/src/main/webapp/css/my.css b/src/main/webapp/css/my.css index 19aa59e8..f69f5d78 100644 --- a/src/main/webapp/css/my.css +++ b/src/main/webapp/css/my.css @@ -3,51 +3,68 @@ th, td { padding: 3px; } -.click_active{ + +.click_active { color: red; } -img { +/*label*/ +.label_create{ + display: inline-block; + user-select: none; + background-color: #555; + color: white; + /*background-color: #FFFFFF; + border: 1px solid #e0e0e0;*/ + border: 1px solid black; + padding: 3px; + font-size: 16px; cursor: pointer; + position: relative; + height: auto; + top: 1px; + width: calc(10% - 1px); + box-sizing: border-box; } - -.align-left{ - text-align: left; +.create-button { + background-color: #555; + color: white; + opacity: 0.8; + width: calc(4% - 1px); + height: 40px; + border: 3px solid black; + padding: 3px; + font-size: 20px; + font-style: italic; } -.align-right{ - text-align: right; -} - -select{ +/*select{ width: auto; } input[type="date"]{ width: auto; -} +}*/ -.label_create{ - width: 300px; -} - -.about-dialog{ +/*.label_create{ background-color: #555; color: white; opacity: 0.8; - width: max-content; + height: 300px; +}*/ -} - -.create-button { +/*.about-dialog{ background-color: #555; color: white; opacity: 0.8; -} + width: max-content; + +}*/ + diff --git a/src/main/webapp/html/my.html b/src/main/webapp/html/my.html index b9b83026..466e41eb 100644 --- a/src/main/webapp/html/my.html +++ b/src/main/webapp/html/my.html @@ -37,14 +37,14 @@

RPG admin panel

Create new account


- +
- +
- - + + @@ -61,7 +61,7 @@

Create new account

+
- +
- +
- +
- +
- - + + From 2c9729a1e2b678c69f7f7d002604afc6a089f7f0 Mon Sep 17 00:00:00 2001 From: sfill70 Date: Sun, 18 Sep 2022 14:30:59 +0300 Subject: [PATCH 06/10] edit css --- src/main/webapp/css/my.css | 50 +++++++++++++++++------------------- src/main/webapp/html/my.html | 4 +-- 2 files changed, 25 insertions(+), 29 deletions(-) diff --git a/src/main/webapp/css/my.css b/src/main/webapp/css/my.css index f69f5d78..76fbcd6d 100644 --- a/src/main/webapp/css/my.css +++ b/src/main/webapp/css/my.css @@ -8,14 +8,35 @@ th, td { color: red; } +#table_players { + width: 95%; + margin-bottom: 20px; + border: 1px solid #dddddd; + border-collapse: collapse; +} +#table_players th { + font-weight: bold; + padding: 5px; + background: #deb887; + border: 2px solid #8b0000; +} +#table_players td { + border: 2px solid #555555; + padding: 5px; +} +#table_players tbody tr:nth-child(odd){ + background: #a9a9a9; +} +#table_players tr:nth-child(even){ + background: #dddddd; +} + /*label*/ .label_create{ display: inline-block; user-select: none; background-color: #555; color: white; - /*background-color: #FFFFFF; - border: 1px solid #e0e0e0;*/ border: 1px solid black; padding: 3px; font-size: 16px; @@ -41,30 +62,5 @@ th, td { -/*select{ - width: auto; -} - - -input[type="date"]{ - width: auto; -}*/ - -/*.label_create{ - background-color: #555; - color: white; - opacity: 0.8; - height: 300px; -}*/ - -/*.about-dialog{ - background-color: #555; - color: white; - opacity: 0.8; - width: max-content; - -}*/ - - diff --git a/src/main/webapp/html/my.html b/src/main/webapp/html/my.html index 466e41eb..3eccb0a8 100644 --- a/src/main/webapp/html/my.html +++ b/src/main/webapp/html/my.html @@ -7,7 +7,7 @@

RPG admin panel

- +
- + From 8fdc7c035828c230d750b7e002ad92763ddf01de Mon Sep 17 00:00:00 2001 From: sfill70 Date: Sun, 18 Sep 2022 15:17:56 +0300 Subject: [PATCH 07/10] edit css 2 --- src/main/webapp/css/my.css | 5 +++++ src/main/webapp/html/my.html | 19 ++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/main/webapp/css/my.css b/src/main/webapp/css/my.css index 76fbcd6d..f9d3a83f 100644 --- a/src/main/webapp/css/my.css +++ b/src/main/webapp/css/my.css @@ -1,3 +1,8 @@ +.html_body{ + margin-left:2%; + background: #f5f5dc; +} + th, td { border: 1px solid black; padding: 3px; diff --git a/src/main/webapp/html/my.html b/src/main/webapp/html/my.html index 3eccb0a8..b5414b53 100644 --- a/src/main/webapp/html/my.html +++ b/src/main/webapp/html/my.html @@ -3,8 +3,16 @@ RPG + + + + + + + - + +

RPG admin panel

@@ -95,7 +103,16 @@

Create new account

+
+ + + + - + - + - + - + @@ -44,77 +53,111 @@

RPG admin panel

Create new account


- - - -
- - +Creating a new account using a modal window, the form below will not be available
- - +
- -
- - +Creating a new account using the form below
- -
- - +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ +

- - -
- + + +
+
+ +