-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sprint 3 #9
Merged
Merged
Sprint 3 #9
Changes from all commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
25b2278
added utils
LevanovaElena c587c0a
added router
LevanovaElena eeffb58
added routing
LevanovaElena ed5486c
added routing
LevanovaElena 7186ddc
added api auth
LevanovaElena ad2820b
added auth users with page
LevanovaElena 75dc9a7
added store user?fixed errors
LevanovaElena b8f21ad
added user settings api
LevanovaElena 5fb87de
added modal controller
LevanovaElena eb466a2
added change avatar modal
LevanovaElena 7dcce83
fixed error
LevanovaElena 84eb9a7
added modal-prompt, api chats, service chats
LevanovaElena 0897b32
added menu-message, menu-item
LevanovaElena 3cdd611
added menu-chat
LevanovaElena 095fbe9
added deleting and adding user
LevanovaElena c33a645
added alert for errors
LevanovaElena e57d93e
refactoring,added state,fixed errors
LevanovaElena eb7944d
add socket
LevanovaElena 64f89f8
added messages in chat
LevanovaElena 74e6eb7
fixed errors
LevanovaElena e1b69a4
fixed errors
LevanovaElena 657712e
fixed errors
LevanovaElena 3fb6e52
fixed linter errors
LevanovaElena 73e4f94
fixed linter errors
LevanovaElena 4bfcb0d
fixed linter errors
LevanovaElena a1d7810
fixed test errors
LevanovaElena 3322fbd
fixed test errors
LevanovaElena 98c75a6
fixed test errors
LevanovaElena b8ff43b
fixed test errors
LevanovaElena b86f931
fixed errors
LevanovaElena 97bd231
added modal for load avatar for chat
LevanovaElena 7c2c87b
added modal for load file for send message
LevanovaElena 9b15d6b
fixed eslint
LevanovaElena d96e2ec
fixed submit
LevanovaElena 11e5c68
added states to profile
LevanovaElena 51e7237
delete routes:/setting-password and /settings-edit
LevanovaElena 709002e
delete routes:/login, fixed errors
LevanovaElena 0fa47e7
fixed json
LevanovaElena c133d5c
fixed json
LevanovaElena 8faf80f
fixed json
LevanovaElena 0ea94be
added submit message
LevanovaElena 9848919
fixed errors
LevanovaElena deb2c3b
fixed errors
LevanovaElena File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* /index.html 200 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import HTTPTransport from "../core/http.ts"; | ||
import {IAuthData, IUser} from "../models/IUser.ts"; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
export class AuthApi { | ||
private httpTransport = new HTTPTransport(); | ||
private readonly baseUrl: string | null = null; | ||
|
||
constructor(baseUrl?: string) { | ||
if (baseUrl) this.baseUrl = baseUrl; | ||
} | ||
|
||
public signUp(userData: IUser) { | ||
return this.httpTransport.post(this.baseUrl + '/signup', {data: userData}); | ||
} | ||
|
||
public signIn(userData: IAuthData) { | ||
return this.httpTransport.post(this.baseUrl + '/signin', {data: userData}); | ||
} | ||
public getAuthUser() { | ||
return this.httpTransport.get(this.baseUrl + '/user'); | ||
} | ||
public logOut() { | ||
return this.httpTransport.post(this.baseUrl + '/logout'); | ||
} | ||
} | ||
|
||
export default AuthApi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import HTTPTransport from "../core/http.ts"; | ||
import {IChatUsersData} from "../models/IChat.ts"; | ||
|
||
export class ChatApi { | ||
private httpTransport = new HTTPTransport(); | ||
private readonly baseUrl: string = '/chats'; | ||
|
||
constructor(baseUrl?: string) { | ||
if (baseUrl) this.baseUrl = baseUrl; | ||
} | ||
|
||
public getChats() { | ||
return this.httpTransport.get(this.baseUrl); | ||
} | ||
|
||
public createChat(title: string) { | ||
return this.httpTransport.post(this.baseUrl, {data: {title: title}}); | ||
} | ||
|
||
public addChatUsers(userData: IChatUsersData) { | ||
return this.httpTransport.put(this.baseUrl + '/users', {data: userData}); | ||
} | ||
|
||
public deleteChatUsers(userData: IChatUsersData) { | ||
return this.httpTransport.delete(this.baseUrl + '/users', {data: userData}); | ||
} | ||
|
||
public getChatUsers(id: string) { | ||
return this.httpTransport.get(this.baseUrl + `/${id}/users`); | ||
} | ||
|
||
public getChatToken(id: string) { | ||
return this.httpTransport.post(this.baseUrl + `/token/${id}`); | ||
} | ||
|
||
public updateChatAvatar(file: FormData, chatId: number) { | ||
file.append('chatId', String(chatId)); | ||
return this.httpTransport.put(this.baseUrl + '/avatar', {data: file}); | ||
} | ||
} | ||
|
||
export default ChatApi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import HTTPTransport from "../core/http.ts"; | ||
|
||
export class ResourcesApi { | ||
private httpTransport = new HTTPTransport(); | ||
private readonly baseUrl: string = '/resources'; | ||
|
||
constructor(baseUrl?: string) { | ||
if (baseUrl) this.baseUrl = baseUrl; | ||
} | ||
|
||
public uploadResource(file: FormData) { | ||
return this.httpTransport.post(this.baseUrl, {data: file}); | ||
} | ||
} | ||
|
||
export default ResourcesApi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
//'wss://ya-praktikum.tech/ws/chats/<USER_ID>/<CHAT_ID>/<TOKEN_VALUE>' | ||
class SocketIO { | ||
private STATES = ['CONNECTING', 'OPEN', 'CLOSING', 'CLOSED']; | ||
private readonly socket: WebSocket | null = null; | ||
|
||
constructor(url: string, user_id?: string, chat_id?: string, token?: string) { | ||
let _url = url; | ||
if (user_id) _url = _url + '/' + user_id; | ||
if (chat_id) _url = _url + '/' + chat_id; | ||
if (token) _url = _url + '/' + token; | ||
this.socket = this.init(_url) | ||
} | ||
|
||
private init = (url: string) => { | ||
return new WebSocket(url); | ||
} | ||
|
||
public getState = () => { | ||
if (!this.socket) return this.STATES[3]; | ||
return this.STATES[this.socket.readyState]; | ||
} | ||
public open = (callBack: () => void) => { | ||
this.socket?.addEventListener('open', callBack); | ||
} | ||
|
||
public close = (callBack: (event: CloseEvent) => void) => { | ||
const funk = (event: CloseEvent) => { | ||
callBack(event); | ||
|
||
} | ||
this.socket?.addEventListener('close', funk); | ||
} | ||
|
||
public message = (callBack: (event: MessageEvent) => void) => { | ||
const funk = (event: MessageEvent) => { | ||
callBack(event); | ||
} | ||
this.socket?.addEventListener('message', funk); | ||
} | ||
|
||
public error(callBack: (event: Event) => void) { | ||
this.socket?.addEventListener('error', callBack); | ||
} | ||
|
||
public sendMessage = (message: string) => { | ||
const _message = JSON.stringify( | ||
{ | ||
content: message, | ||
type: "message" | ||
}) | ||
this.socket?.send(_message); | ||
} | ||
public sendFile = (idResource: string) => { | ||
const _message = JSON.stringify( | ||
{ | ||
content: idResource, | ||
type: "file" | ||
}) | ||
this.socket?.send(_message); | ||
} | ||
public sendRequestForgetMessage = (limit: number = 0) => { | ||
const _message = JSON.stringify( | ||
{ | ||
content: String(limit), | ||
type: "get old" | ||
}) | ||
this.socket?.send(_message); | ||
} | ||
|
||
public ping = () => { | ||
this.socket?.send(JSON.stringify({ | ||
type: "ping" | ||
})); | ||
} | ||
|
||
|
||
} | ||
|
||
export default SocketIO; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import HTTPTransport from "../core/http.ts"; | ||
import {IPasswords, IUser} from "../models/IUser.ts"; | ||
|
||
export class UserSettingsApi { | ||
private httpTransport = new HTTPTransport(); | ||
private readonly baseUrl: string | null = null; | ||
|
||
constructor(baseUrl?: string) { | ||
if (baseUrl) this.baseUrl = baseUrl; | ||
} | ||
|
||
public changeUserProfile(userData: IUser) { | ||
return this.httpTransport.put(this.baseUrl + '/profile', {data: userData}); | ||
} | ||
|
||
public changeUserAvatar(file: FormData) { | ||
return this.httpTransport.put(this.baseUrl + '/profile/avatar', {data: file}); | ||
} | ||
|
||
public changeUserPassword(data: IPasswords) { | ||
return this.httpTransport.put(this.baseUrl + '/password', {data: data}); | ||
} | ||
|
||
public searchUser(login: string) { | ||
return this.httpTransport.post(this.baseUrl + '/search', {data:{login: login}}); | ||
} | ||
} | ||
|
||
export default UserSettingsApi |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
.alert { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
padding: 10px; | ||
min-height: 100px; | ||
z-index:1000; | ||
|
||
.alert__message { | ||
text-align: center; | ||
font-size: 1.2em; | ||
} | ||
|
||
.alert__close { | ||
position: absolute; | ||
right: 0; | ||
top:0; | ||
} | ||
} | ||
|
||
.dialog-alert { | ||
border: none; | ||
width: 340px; | ||
inset: 0; | ||
position: fixed; | ||
margin: auto; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import {IProps, Block} from "../../core/block.ts"; | ||
import alertController from "../../core/alert-controller.ts"; | ||
|
||
interface IModalProps extends IProps { | ||
message: string, | ||
okClick?: (event: Event) => void, | ||
} | ||
|
||
export class Alert extends Block { | ||
constructor(props: IModalProps) { | ||
props.okClick=()=>{ | ||
alertController.closeModal(); | ||
} | ||
|
||
super({ | ||
...props | ||
}) | ||
} | ||
|
||
public get props() { | ||
return this._props as IModalProps; | ||
} | ||
|
||
protected render(): string { | ||
const {message = ''} = this.props; | ||
return (` | ||
<div class="alert"> | ||
<p class="alert__message"> | ||
${message} | ||
</p> | ||
<div class="alert__close"> | ||
{{{ Button onClick=okClick type='close'}}}</div> | ||
</div> | ||
`) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import './alert.pcss'; | ||
export { Alert as default } from './alert.ts'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enter
страница перезагружается. Это нужно предотвращать во время сабмита формы. И при попытке добавить новый чат это происходит