Skip to content

Commit

Permalink
Merge branch 'ashurov-dev' into result-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
AshurovG committed Dec 15, 2024
2 parents 079c026 + 699e4d5 commit 3073056
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 33 deletions.
95 changes: 95 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
upstream facade_app {
server 127.0.0.1:8080;
}

upstream grafana {
server 127.0.0.1:3000;
}

server {
server_name cassette-world.ru www.cassette-world.ru;
client_max_body_size 10M;

location /static/ {
proxy_pass https://cassette.hb.ru-msk.vkcloud-storage.ru/static/;

proxy_set_header Host cassette.hb.ru-msk.vkcloud-storage.ru;
proxy_redirect off;
add_header Cache-Control "public, max-age=31536000";
autoindex on;
}

location /images/ {
alias /home/ubuntu/images/;
add_header Cache-Control "public, max-age=31536000";
autoindex on;
}

location /assets/ {
alias /home/ubuntu/frontend/2024_2_GOATS/public/assets/;
add_header Cache-Control "public, max-age=31536000";
autoindex on;
}

location = /api/room/join {
proxy_pass http://facade_app; # Ваш WebSocket-сервер
proxy_http_version 1.1; # WebSocket требует HTTP/1.1
proxy_set_header Upgrade $http_upgrade; # WebSocket-заголовки
proxy_set_header Connection "Upgrade"; # WebSocket-заголовки
proxy_set_header Host $host; # Проброс оригинального Host
proxy_cache_bypass $http_upgrade; # Отключение кеша для WebSocket
}


location ~ ^/api/ {
proxy_pass http://facade_app;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}

location /grafana {
proxy_pass http://grafana;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

location / {
root /home/ubuntu/frontend/2024_2_GOATS/dist;
index index.html;
try_files $uri $uri/ /index.html;
}

listen 443 ssl http2; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/cassette-world.ru/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/cassette-world.ru/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot


}


server {
if ($host = www.cassette-world.ru) {
return 301 https://$host$request_uri;
} # managed by Certbot


if ($host = cassette-world.ru) {
return 301 https://$host$request_uri;
} # managed by Certbot


listen 80;
server_name cassette-world.ru www.cassette-world.ru;
return 404; # managed by Certbot




}
14 changes: 13 additions & 1 deletion public/components/CoWatchBlock/CoWatchBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import template from './CoWatchBlock.hbs';
import { userStore } from 'store/UserStore';
import { Actions } from 'flux/Actions';
import { CreateRoomModal } from 'components/CreateRoomModal/CreateRoomModal';
import { router } from 'modules/Router';
import { Notifier } from 'components/Notifier/Notifier';

export class CoWatchBlock {
#parent: HTMLElement;
Expand Down Expand Up @@ -45,7 +47,17 @@ export class CoWatchBlock {
if (subscribtionButton) {
subscribtionButton.addEventListener('click', (event) => {
event.preventDefault();
Actions.buySubscription({ subscriptionForm, subscriptionFormLabel });
if (userStore.getUser().username) {
Actions.buySubscription({ subscriptionForm, subscriptionFormLabel });
} else {
const notifier = new Notifier(
'error',
'Сначала необходимо войти в аккаунт',
3000,
);
notifier.render();
router.go('/auth');
}
});
}
}
Expand Down
4 changes: 2 additions & 2 deletions public/components/UsersList/UsersList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ export class UsersList {

constructor(parent: HTMLElement, users: UserNew[]) {
this.#parent = parent;
this.#users = this.getUniqueUsers(users);
this.#users = this.#getUniqueUsers(users);
}

getUniqueUsers(users: UserNew[]) {
#getUniqueUsers(users: UserNew[]) {
const seenUsernames = new Set<string>();
const uniqueUsers: UserNew[] = [];

Expand Down
13 changes: 7 additions & 6 deletions public/store/AuthPageStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { router } from 'modules/Router';
import { userStore } from 'store/UserStore';
import { throwBackendError, removeBackendError } from 'modules/BackendErrors';
import { roomPageStore } from './RoomPageStore';
import { User } from 'types/user';

class AuthPageStore {
constructor() {
Expand All @@ -21,11 +20,13 @@ class AuthPageStore {
);

const userAuthListener = userStore.isUserAuthEmmiter$.addListener(() => {
if (router.getCurrentPath() === '/auth') {
if (roomPageStore.getGlobalRoomId() && userStore.getUser().username) {
roomPageStore.setIsModalConfirm(false);
router.go('/room', roomPageStore.getGlobalRoomId());
}
if (
router.getCurrentPath() === '/auth' &&
roomPageStore.getGlobalRoomId() &&
userStore.getUser().username
) {
roomPageStore.setIsModalConfirm(false);
router.go('/room', roomPageStore.getGlobalRoomId());
}
});

Expand Down
16 changes: 0 additions & 16 deletions public/store/FavoritesPageStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,6 @@ class FavoritesPageStore {
#movies: Movie[] | null = null;

constructor() {
// const unsubscribe = userStore.isUserAuthEmmiter$.addListener(
// async (status) => {
// if (status && router.getCurrentPath() === `/favorites`) {
// await this.getFavorites();
// favoritePage.render();
// }
// },
// );

const unsubscribe = userStore.isUserLoadingEmmiter$.addListener(() => {
if (router.getCurrentPath() === '/favorites') {
this.renderFavoritesPage();
Expand Down Expand Up @@ -105,13 +96,6 @@ class FavoritesPageStore {
async reduce(action: any) {
switch (action.type) {
case ActionTypes.RENDER_FAVORITES_PAGE:
// this.#movies = null;
// favoritePage.render();
// if (userStore.getUser().username) {
// await this.getFavorites();
// favoritePage.render();
// }

this.renderFavoritesPage(); // TK
break;
case ActionTypes.ADD_TO_FAVORITES:
Expand Down
6 changes: 1 addition & 5 deletions public/store/RoomPageStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,7 @@ class RoomPageStore {
}
break;
case 'change_movie':
if (
this.#room &&
messageData['movie'] &&
messageData['movie'].id !== this.#room.movie.id
) {
if (this.#room && messageData['movie'].id !== this.#room.movie.id) {
this.#room.movie = serializeMovieDetailed(messageData['movie']);
if (this.#room.movie.seasons && this.#room.movie.seasons.length) {
roomPage.renderVideo(
Expand Down
3 changes: 0 additions & 3 deletions public/store/UserStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,6 @@ class UserStore {
path: 'auth/session',
});

// TODO: Убрать после тестирование
// response.user_data.subscription_expiration_date = '2025-1-2';
// response.user_data.subscription_status = true;
response.user_data.email = response.user_data.email.replace(
/&#34;/g,
'"',
Expand Down

0 comments on commit 3073056

Please sign in to comment.