online stats replacement, design changes.
This commit is contained in:
parent
ff0fbe06ac
commit
162d287e78
@ -80,9 +80,7 @@ public class LongPoll {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private LongPollResult process(Long userId, LongPollConfig config) {
|
private LongPollResult process(Long userId, LongPollConfig config) {
|
||||||
userService.updateOnline(userId);
|
Integer onlineCount = map.size();
|
||||||
|
|
||||||
Integer onlineCount = userService.countByIsOnline();
|
|
||||||
List<Chat> results;
|
List<Chat> results;
|
||||||
List<UserResult> users = new ArrayList<>();
|
List<UserResult> users = new ArrayList<>();
|
||||||
List<RoomResult> clientRooms = config.getRooms();
|
List<RoomResult> clientRooms = config.getRooms();
|
||||||
@ -92,6 +90,7 @@ public class LongPoll {
|
|||||||
|
|
||||||
results = chatService.getAfterLastChatId(config.getLast_chat_id());
|
results = chatService.getAfterLastChatId(config.getLast_chat_id());
|
||||||
|
|
||||||
|
// Chat part
|
||||||
if( !results.isEmpty() ) {
|
if( !results.isEmpty() ) {
|
||||||
users = results.stream()
|
users = results.stream()
|
||||||
.map(Chat::getUserId)
|
.map(Chat::getUserId)
|
||||||
@ -118,6 +117,8 @@ public class LongPoll {
|
|||||||
c.setMessage(message);
|
c.setMessage(message);
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Rooms part
|
||||||
if( !clientRooms.isEmpty() ) {
|
if( !clientRooms.isEmpty() ) {
|
||||||
List<RoomResult> rooms = roomService.getAllActive().stream()
|
List<RoomResult> rooms = roomService.getAllActive().stream()
|
||||||
.map( r -> new RoomResult(r.getId(), r.getPlayerCount(), roomPlayerService.findByRoomId(r.getId()).stream()
|
.map( r -> new RoomResult(r.getId(), r.getPlayerCount(), roomPlayerService.findByRoomId(r.getId()).stream()
|
||||||
@ -156,6 +157,7 @@ public class LongPoll {
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Friends part
|
||||||
if( !clientFriends.isEmpty() ) {
|
if( !clientFriends.isEmpty() ) {
|
||||||
List<UserResult> userResults = friendService.getFriendsOfUserId(userId)
|
List<UserResult> userResults = friendService.getFriendsOfUserId(userId)
|
||||||
.stream()
|
.stream()
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
package com.alterdekim.game.component;
|
|
||||||
|
|
||||||
import com.alterdekim.game.service.UserServiceImpl;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
@Slf4j
|
|
||||||
public class OnlineStatus {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private UserServiceImpl userService;
|
|
||||||
|
|
||||||
@Scheduled(fixedRate = 50000)
|
|
||||||
private void resetOnlineStatus() {
|
|
||||||
userService.setAllOffline();
|
|
||||||
}
|
|
||||||
}
|
|
@ -28,9 +28,6 @@ public class User {
|
|||||||
@Column(nullable=false)
|
@Column(nullable=false)
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
@Column(columnDefinition = "boolean default false")
|
|
||||||
private Boolean isOnline;
|
|
||||||
|
|
||||||
@ManyToMany(fetch = FetchType.EAGER, cascade=CascadeType.ALL)
|
@ManyToMany(fetch = FetchType.EAGER, cascade=CascadeType.ALL)
|
||||||
@JoinTable(
|
@JoinTable(
|
||||||
name="users_roles",
|
name="users_roles",
|
||||||
|
@ -11,16 +11,4 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
@Repository
|
@Repository
|
||||||
public interface UserRepository extends JpaRepository<User, Long> {
|
public interface UserRepository extends JpaRepository<User, Long> {
|
||||||
User findByUsername(String username);
|
User findByUsername(String username);
|
||||||
|
|
||||||
@Transactional
|
|
||||||
@Modifying
|
|
||||||
@Query(value = "UPDATE User u SET u.isOnline = true WHERE u.id = :uuid")
|
|
||||||
void setOnline(@Param(value = "uuid") Long id);
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
@Modifying
|
|
||||||
@Query(value = "UPDATE User u SET u.isOnline = false")
|
|
||||||
void setAllOffline();
|
|
||||||
|
|
||||||
Integer countByIsOnline(boolean isOnline);
|
|
||||||
}
|
}
|
||||||
|
@ -69,17 +69,5 @@ public class UserServiceImpl implements UserService {
|
|||||||
role.setName("ROLE_ADMIN");
|
role.setName("ROLE_ADMIN");
|
||||||
return roleRepository.save(role);
|
return roleRepository.save(role);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateOnline(Long userId) {
|
|
||||||
userRepository.setOnline(userId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAllOffline() {
|
|
||||||
userRepository.setAllOffline();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer countByIsOnline() {
|
|
||||||
return userRepository.countByIsOnline(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
padding-bottom: .1px;
|
padding-bottom: .1px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
min-height: 1px;
|
min-height: 1px;
|
||||||
background-color: #fff;
|
background-color: var(--dive-white);
|
||||||
}
|
}
|
||||||
|
|
||||||
.container {
|
.container {
|
||||||
@ -60,7 +60,7 @@
|
|||||||
|
|
||||||
.mission-one {
|
.mission-one {
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
border-top: 1px solid #e9eaec;
|
border-top: 1px solid var(--dive-light-grey-second);
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,7 +108,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.title > span {
|
.title > span {
|
||||||
color: #a7adb5;
|
color: var(--dive-light-blue-grey);
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,14 +129,14 @@
|
|||||||
.carousel-title-text {
|
.carousel-title-text {
|
||||||
font-size: 19px;
|
font-size: 19px;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
color: #fff;
|
color: var(--dive-white);
|
||||||
}
|
}
|
||||||
|
|
||||||
.carousel-body-text {
|
.carousel-body-text {
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
line-height: 20px;
|
line-height: 20px;
|
||||||
color: #fff;
|
color: var(--dive-white);
|
||||||
}
|
}
|
||||||
|
|
||||||
.carousel-item-body {
|
.carousel-item-body {
|
||||||
@ -157,19 +157,19 @@
|
|||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
color: #989aa4;
|
color: var(--dive-light-blue-grey-second);
|
||||||
transform: translateY(1px);
|
transform: translateY(1px);
|
||||||
}
|
}
|
||||||
|
|
||||||
.chat-history-user {
|
.chat-history-user {
|
||||||
padding: 0 6px;
|
padding: 0 6px;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
background-color: #b9bac1;
|
background-color: var(--dive-light-blue-grey-third);
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.chat-history-user>._nick {
|
.chat-history-user>._nick {
|
||||||
color: #fff;
|
color: var(--dive-white);
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,7 +197,7 @@
|
|||||||
flex-flow: column nowrap;
|
flex-flow: column nowrap;
|
||||||
position: relative;
|
position: relative;
|
||||||
border-top: 1px solid;
|
border-top: 1px solid;
|
||||||
border-color: #e6e6e6;
|
border-color: var(--dive-light-grey);
|
||||||
}
|
}
|
||||||
|
|
||||||
.games-room-one-body {
|
.games-room-one-body {
|
||||||
@ -240,12 +240,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.games-room-one-body-members-one-nick > a {
|
.games-room-one-body-members-one-nick > a {
|
||||||
color: #656d78;
|
color: var(--dive-weird-blue-grey);
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.games-room-one-body-members-one-nick > span {
|
.games-room-one-body-members-one-nick > span {
|
||||||
color: #656d78;
|
color: var(--dive-weird-blue-grey);
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
@ -295,7 +295,7 @@ body.modal-open > :not(.modal) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.game-creation-modal-modes {
|
.game-creation-modal-modes {
|
||||||
background-color: #f7f7f7;
|
background-color: var(--dive-light-grey-third);
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
border-radius: 5px 0 0 5px;
|
border-radius: 5px 0 0 5px;
|
||||||
padding: 10px 15px 10px 10px;
|
padding: 10px 15px 10px 10px;
|
||||||
@ -313,7 +313,7 @@ body.modal-open > :not(.modal) {
|
|||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
padding: 20px 0;
|
padding: 20px 0;
|
||||||
width: 375px;
|
width: 375px;
|
||||||
background-color: #fff;
|
background-color: var(--dive-white);
|
||||||
box-shadow: 0 0 25px rgba(0,0,0,.1);
|
box-shadow: 0 0 25px rgba(0,0,0,.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,11 +327,11 @@ body.modal-open > :not(.modal) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.game-creation-modal-modes-one._regular._selected {
|
.game-creation-modal-modes-one._regular._selected {
|
||||||
background: #8cc152;
|
background: var(--dive-grass-green);
|
||||||
}
|
}
|
||||||
|
|
||||||
.game-creation-modal-modes-one._selected {
|
.game-creation-modal-modes-one._selected {
|
||||||
color: #fff;
|
color: var(--dive-white);
|
||||||
}
|
}
|
||||||
|
|
||||||
.game-creation-modal-modes-one {
|
.game-creation-modal-modes-one {
|
||||||
@ -379,8 +379,8 @@ body.modal-open > :not(.modal) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.form-check-input:checked {
|
.form-check-input:checked {
|
||||||
background-color: #37bc9d;
|
background-color: var(--dive-primary-color);
|
||||||
border-color: #37bc9d;
|
border-color: var(--dive-primary-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
#players-count-range, .players-range-value {
|
#players-count-range, .players-range-value {
|
||||||
@ -389,7 +389,7 @@ body.modal-open > :not(.modal) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.form-range::-webkit-slider-thumb {
|
.form-range::-webkit-slider-thumb {
|
||||||
background-color: #37bc9d;
|
background-color: var(--dive-primary-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.reply-button {
|
.reply-button {
|
||||||
@ -409,6 +409,6 @@ body.modal-open > :not(.modal) {
|
|||||||
|
|
||||||
.friend-one > ion-icon {
|
.friend-one > ion-icon {
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
color: #37bc9d;
|
color: var(--dive-primary-color);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
@ -1,30 +1,30 @@
|
|||||||
.navbar-brand-custom {
|
.navbar-brand-custom {
|
||||||
color: #ffffff;
|
color: var(--dive-white);
|
||||||
}
|
}
|
||||||
|
|
||||||
.navbar-brand-custom:hover {
|
.navbar-brand-custom:hover {
|
||||||
color: #ffffff;
|
color: var(--dive-white);
|
||||||
}
|
}
|
||||||
|
|
||||||
.navbar {
|
.navbar {
|
||||||
background-color: #37bc9d;
|
background-color: var(--dive-primary-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-outline-primary {
|
.btn-outline-primary {
|
||||||
border-color: transparent;
|
border-color: transparent;
|
||||||
color: #fff;
|
color: var(--dive-white);
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-primary {
|
.btn-primary {
|
||||||
background-color: rgba(255,255,255,.85);
|
background-color: rgba(255,255,255,.85);
|
||||||
color: #37bc9d;
|
color: var(--dive-primary-color);
|
||||||
border-color: rgba(255,255,255,.85);
|
border-color: rgba(255,255,255,.85);
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-primary:hover {
|
.btn-primary:hover {
|
||||||
background-color: #ffffff;
|
background-color: var(--dive-white);
|
||||||
border-color: #ffffff;
|
border-color: var(--dive-white);
|
||||||
color: #37bc9d;
|
color: var(--dive-primary-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-outline-primary:hover {
|
.btn-outline-primary:hover {
|
||||||
@ -34,26 +34,26 @@
|
|||||||
|
|
||||||
.page-title {
|
.page-title {
|
||||||
font: 700 3.5em Montserrat;
|
font: 700 3.5em Montserrat;
|
||||||
color: #fff;
|
color: var(--dive-white);
|
||||||
}
|
}
|
||||||
|
|
||||||
.page-title-small {
|
.page-title-small {
|
||||||
margin-top: .7em;
|
margin-top: .7em;
|
||||||
font: 500 1.32em/1.4em Montserrat;
|
font: 500 1.32em/1.4em Montserrat;
|
||||||
color: #fff;
|
color: var(--dive-white);
|
||||||
}
|
}
|
||||||
|
|
||||||
.main-billboard {
|
.main-billboard {
|
||||||
background-color: #37bc9d;
|
background-color: var(--dive-primary-color);
|
||||||
height: 700px;
|
height: 700px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
padding-top: 50px;
|
padding-top: 50px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.main-button {
|
.main-button {
|
||||||
color: #5b5d67;
|
color: var(--dive-dark-grey-second);
|
||||||
background-color: #fff;
|
background-color: var(--dive-white);
|
||||||
border-color: #fff;
|
border-color: var(--dive-white);
|
||||||
font: 600 1.5rem Montserrat;
|
font: 600 1.5rem Montserrat;
|
||||||
padding: 0 0.9em;
|
padding: 0 0.9em;
|
||||||
height: 2.1em;
|
height: 2.1em;
|
||||||
@ -62,7 +62,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.main-button:hover {
|
.main-button:hover {
|
||||||
color: #5b5d67;
|
color: var(--dive-dark-grey-second);
|
||||||
background-color: rgba(255, 255, 255, 0.85);
|
background-color: rgba(255, 255, 255, 0.85);
|
||||||
border-color: rgba(255, 255, 255, 0.85);
|
border-color: rgba(255, 255, 255, 0.85);
|
||||||
font: 600 1.5rem Montserrat;
|
font: 600 1.5rem Montserrat;
|
||||||
@ -82,7 +82,7 @@
|
|||||||
margin-bottom: 1.25em;
|
margin-bottom: 1.25em;
|
||||||
margin-left: 0px;
|
margin-left: 0px;
|
||||||
font: 700 3.25em Montserrat;
|
font: 700 3.25em Montserrat;
|
||||||
color: #26272b;
|
color: var(--dive-dark-grey-third);
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,17 +1,34 @@
|
|||||||
|
:root {
|
||||||
|
--dive-white: #fff;
|
||||||
|
--dive-grey: #f4f4f5;
|
||||||
|
--dive-dark-grey: #e6e9ed;
|
||||||
|
--dive-dark-grey-second: #5b5d67;
|
||||||
|
--dive-dark-grey-third: #26272b;
|
||||||
|
--dive-light-blue-grey: #a7adb5;
|
||||||
|
--dive-light-blue-grey-second: #989aa4;
|
||||||
|
--dive-light-blue-grey-third: #b9bac1;
|
||||||
|
--dive-light-grey: #e6e6e6;
|
||||||
|
--dive-weird-blue-grey: #656d78;
|
||||||
|
--dive-light-grey-second: #e9eaec;
|
||||||
|
--dive-light-grey-third: #f7f7f7;
|
||||||
|
--dive-grass-green: #8cc152;
|
||||||
|
--dive-primary-color: #37bc9d;
|
||||||
|
}
|
||||||
|
|
||||||
.navbar {
|
.navbar {
|
||||||
background-color: #fff;
|
background-color: var(--dive-white);
|
||||||
}
|
}
|
||||||
|
|
||||||
html, body {
|
html, body {
|
||||||
font-family: 'Montserrat', sans-serif;
|
font-family: 'Montserrat', sans-serif;
|
||||||
background-color: #f4f4f5;
|
background-color: var(--dive-grey);
|
||||||
font-size: 0.875rem;
|
font-size: 0.875rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
footer {
|
footer {
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
background-color: #e6e9ed;
|
background-color: var(--dive-dark-grey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -25,21 +42,28 @@ footer {
|
|||||||
|
|
||||||
.btn-outline-primary {
|
.btn-outline-primary {
|
||||||
border-color: transparent;
|
border-color: transparent;
|
||||||
color: #5b5d67;
|
color: var(--dive-dark-grey-second);
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-primary {
|
.btn-primary {
|
||||||
background-color: #37bc9d;
|
background-color: var(--dive-primary-color);
|
||||||
color: #fff;
|
color: var(--dive-white);
|
||||||
border-color: #37bc9d;
|
border-color: var(--dive-primary-color);
|
||||||
--bs-btn-active-bg: #37bc9d;
|
--bs-btn-active-bg: var(--dive-primary-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-primary:active {
|
.btn-primary:active {
|
||||||
background-color: #37bc9d;
|
background-color: var(--dive-primary-color);
|
||||||
color: #fff;
|
color: var(--dive-white);
|
||||||
border-color: #37bc9d;
|
border-color: var(--dive-primary-color);
|
||||||
--bs-btn-active-bg: #37bc9d;
|
--bs-btn-active-bg: var(--dive-primary-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-outline-primary:active {
|
||||||
|
background-color: var(--dive-primary-color);
|
||||||
|
color: var(--dive-white);
|
||||||
|
border-color: var(--dive-primary-color);
|
||||||
|
--bs-btn-active-bg: var(--dive-primary-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-primary:hover {
|
.btn-primary:hover {
|
||||||
|
@ -28,9 +28,18 @@
|
|||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a href="/profile/" class="navbar-btn">
|
<div class="dropdown">
|
||||||
<img class="navbar-profile-img" src="https://avatars.githubusercontent.com/u/102559365?v=4"/>
|
<a class="navbar-btn dropdown-toggle" id="dropdownMenuButton1" data-bs-toggle="dropdown" aria-expanded="false">
|
||||||
</a>
|
<img class="navbar-profile-img" src="https://avatars.githubusercontent.com/u/102559365?v=4">
|
||||||
|
</a>
|
||||||
|
<ul class="dropdown-menu" aria-labelledby="dropdownMenuButton1">
|
||||||
|
<li><a class="dropdown-item">username</a></li>
|
||||||
|
<li><hr class="dropdown-divider"></li>
|
||||||
|
<li><a class="dropdown-item" href="/profile/">Profile</a></li>
|
||||||
|
<li><a class="dropdown-item" href="/settings/">Settings</a></li>
|
||||||
|
<li><a class="dropdown-item" href="/logout">Logout</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</th:block>
|
</th:block>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user