clean code

This commit is contained in:
Chneemann 2024-06-11 21:08:20 +02:00
parent 37fb795594
commit 91afdbf8f7
10 changed files with 52 additions and 53 deletions

View file

@ -14,7 +14,7 @@
<div class="contentChannel">
@for (channel of getChannelName(currentChannel); track channel) {
<div class="contentHeadline">
<p>{{ "channel-informations.header" | translate }}</p>
<p>{{ "channel-information.header" | translate }}</p>
@if (!openEditNameInput) {
<!--check if user is creator-->
@if(checkCreator(currentChannel)){
@ -60,7 +60,7 @@
@for (channel of getChannelName(currentChannel); track channel) {
<div class="contentHeadline">
<p>{{ "channel-informations.channelInfo" | translate }}</p>
<p>{{ "channel-information.channelInfo" | translate }}</p>
@if (!openEditNameDescription) {
<!--check if user is creator-->
@if(checkCreator(currentChannel)){
@ -88,7 +88,7 @@
@if (channel.description !== "") {
<p>{{ channel.description }}</p>
} @else {
<p>{{ "channel-informations.channelInfo2" | translate }}</p>
<p>{{ "channel-information.channelInfo2" | translate }}</p>
}
</div>
} @else {
@ -103,7 +103,7 @@
}
<div class="line"></div>
<div class="contentHeadline">
<p>{{ "channel-informations.channelMadeBy" | translate }}</p>
<p>{{ "channel-information.channelMadeBy" | translate }}</p>
</div>
<div class="channelCreator">
@if(channel.creator == "Admin") {
@ -112,7 +112,7 @@
<p class="creatorName">{{ user.firstName }} {{ user.lastName }}</p>
} } @if(!checkCreator(currentChannel)){
<p class="warningPTag">
{{ "channel-informations.channelErrorText" | translate }}
{{ "channel-information.channelErrorText" | translate }}
</p>
}
</div>
@ -125,7 +125,7 @@
}"
>
<div class="contentHeadline">
<p>{{ "channel-informations.members" | translate }}</p>
<p>{{ "channel-information.members" | translate }}</p>
</div>
<div class="allUsers">
@for(allMembers of getAllChannelMembers(currentChannel)[0].addedUser;
@ -156,14 +156,14 @@
}"
[user]="user"
[openUserWindowBoolean]="openUserWindowBoolean"
(closeUserWondow)="changeOpenUserWindowBoolean($event)"
(closeUserWindow)="changeOpenUserWindowBoolean($event)"
></app-open-send-prv-message-window>
<div class="leaveChannel">
<button
[disabled]="openEditNameInput || openEditNameDescription"
(click)="leaveChannel(currentChannel, $event)"
>
{{ "channel-informations.leave" | translate }}
{{ "channel-information.leave" | translate }}
</button>
</div>
</div>

View file

@ -0,0 +1,22 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ChannelInformationComponent } from './channel-information.component';
describe('ChannelInformationComponent', () => {
let component: ChannelInformationComponent;
let fixture: ComponentFixture<ChannelInformationComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [ChannelInformationComponent],
}).compileComponents();
fixture = TestBed.createComponent(ChannelInformationComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View file

@ -12,7 +12,7 @@ import { OpenSendPrvMessageWindowComponent } from '../show-channel-member/open-s
import { TranslateModule } from '@ngx-translate/core';
@Component({
selector: 'app-channel-informations',
selector: 'app-channel-information',
standalone: true,
imports: [
CommonModule,
@ -21,10 +21,10 @@ import { TranslateModule } from '@ngx-translate/core';
OpenSendPrvMessageWindowComponent,
TranslateModule,
],
templateUrl: './channel-informations.component.html',
styleUrl: './channel-informations.component.scss',
templateUrl: './channel-information.component.html',
styleUrl: './channel-information.component.scss',
})
export class ChannelInformationsComponent {
export class ChannelInformationComponent {
@Input() currentChannel: string = '';
@Input() viewWidth: number = 0;
@Output() closeEditEmitter: EventEmitter<boolean> =

View file

@ -1,23 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ChannelInformationsComponent } from './channel-informations.component';
describe('ChannelInformationsComponent', () => {
let component: ChannelInformationsComponent;
let fixture: ComponentFixture<ChannelInformationsComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [ChannelInformationsComponent]
})
.compileComponents();
fixture = TestBed.createComponent(ChannelInformationsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View file

@ -1,6 +1,6 @@
<section>
@if (checkCurrentChannel(currentChannel) == 'searchBar') {
<!----- Searchwindow ----->
<!----- Search window ----->
<div class="headerSearchBar">
<p>{{ "main-chat.message" | translate }}</p>
<input
@ -165,13 +165,13 @@
>
</app-chat-content>
}
<!----- Channel informations dialog ----->
<!----- Channel information dialog ----->
@if (openMenu) {
<app-channel-informations
<app-channel-information
[viewWidth]="viewWidth"
(closeEditEmitter)="closeEditEmitter($event)"
[currentChannel]="currentChannel"
></app-channel-informations>
></app-channel-information>
} } } @if (showProfil) {
<app-open-send-prv-message-window
[showProfil]="showProfil"

View file

@ -19,7 +19,7 @@ import { FormsModule } from '@angular/forms';
import { SmallBtnComponent } from '../../shared/components/small-btn/small-btn.component';
import { ShowChannelMemberComponent } from './show-channel-member/show-channel-member.component';
import { SharedService } from '../../service/shared.service';
import { ChannelInformationsComponent } from './channel-informations/channel-informations.component';
import { ChannelInformationComponent } from './channel-information/channel-information.component';
import { filter } from 'rxjs';
import { OpenSendPrvMessageWindowComponent } from './show-channel-member/open-send-prv-message-window/open-send-prv-message-window.component';
import { HighlightPipe } from '../../highlight.pipe';
@ -37,7 +37,7 @@ import { TranslateModule } from '@ngx-translate/core';
FormsModule,
SmallBtnComponent,
ShowChannelMemberComponent,
ChannelInformationsComponent,
ChannelInformationComponent,
OpenSendPrvMessageWindowComponent,
HighlightPipe,
TranslateModule,

View file

@ -19,7 +19,7 @@ export class OpenSendPrvMessageWindowComponent {
@Input() talkToUser!: User[];
@Input() openUserWindowBoolean!: boolean;
@Input() showProfil!: boolean;
@Output() closeUserWondow = new EventEmitter<boolean>();
@Output() closeUserWindow = new EventEmitter<boolean>();
@Output() showProfilWindow = new EventEmitter<boolean>();
isOnline: boolean = false;
@ -37,7 +37,7 @@ export class OpenSendPrvMessageWindowComponent {
closeWindow() {
this.openUserWindowBoolean = false;
this.showProfil = false;
this.closeUserWondow.emit(this.openUserWindowBoolean);
this.closeUserWindow.emit(this.openUserWindowBoolean);
this.showProfilWindow.emit(this.showProfil);
}
@ -47,7 +47,7 @@ export class OpenSendPrvMessageWindowComponent {
*/
closeEverything() {
this.openUserWindowBoolean = false;
this.closeUserWondow.emit(this.openUserWindowBoolean);
this.closeUserWindow.emit(this.openUserWindowBoolean);
this.toggleBoolean.openChannelMemberWindow = false;
this.toggleBoolean.closeChannelMemberWindow = false;
}

View file

@ -77,13 +77,13 @@
</div>
<div
class="showSearchedUsersWindow"
[ngClass]="{ dBlock: showExistenUsers, dNone: !showExistenUsers }"
[ngClass]="{ dBlock: showExistedUsers, dNone: !showExistedUsers }"
>
<div class="positionOfAllUsersBox">
@if(getSearchedUser.length <= 0) {
<span>{{ "show-channel-member.result" | translate }}</span> }
@for(user of getSearchedUser; track user){
@if(!isUserAlreadySelectet(user)) {
@if(!isUserAlreadySelected(user)) {
<div class="userBox" (click)="chooseUser(user)">
<div class="positionImgsBox">
<img src="{{ user.avatar }}" class="addAvatarImg" />
@ -129,5 +129,5 @@
[ngClass]="{ dBlock: openUserWindowBoolean, dNone: !openUserWindowBoolean }"
[user]="user"
[openUserWindowBoolean]="openUserWindowBoolean"
(closeUserWondow)="changeOpenUserWindowBoolean($event)"
(closeUserWindow)="changeOpenUserWindowBoolean($event)"
></app-open-send-prv-message-window>

View file

@ -26,7 +26,7 @@ export class ShowChannelMemberComponent {
@Input() isSecondaryChatOpen: boolean = false;
userName: string = '';
showExistenUsers: boolean = false;
showExistedUsers: boolean = false;
getSearchedUser: User[] = [];
getCurrentChannelName: string = '';
getSelectedUsers: User[] = [];
@ -59,7 +59,7 @@ export class ShowChannelMemberComponent {
*/
filterUsers(searchValue: string) {
if (searchValue != '') {
this.showExistenUsers = true;
this.showExistedUsers = true;
this.getSearchedUser = [];
const searchedUser = searchValue.toLowerCase().trim();
const filteredUsers = this.userService.getUsers().filter((user) => {
@ -99,7 +99,7 @@ export class ShowChannelMemberComponent {
* @param {User} user - The user to check.
* @returns {boolean} Returns true if the user is already selected, otherwise false.
*/
isUserAlreadySelectet(user: User) {
isUserAlreadySelected(user: User) {
return this.getSelectedUsers.some(
(selectedUser) => selectedUser.id === user.id
);
@ -119,7 +119,7 @@ export class ShowChannelMemberComponent {
this.getSelectedUsers.push(user);
}
this.userName = '';
this.showExistenUsers = false;
this.showExistedUsers = false;
}
/**
@ -128,7 +128,7 @@ export class ShowChannelMemberComponent {
*/
spliceCurrentUser(index: number) {
this.getSelectedUsers.splice(index, 1);
this.showExistenUsers = false;
this.showExistedUsers = false;
}
/**
@ -184,7 +184,7 @@ export class ShowChannelMemberComponent {
*/
resetValues() {
this.userName = '';
this.showExistenUsers = false;
this.showExistedUsers = false;
this.getSearchedUser = [];
this.getCurrentChannelName = '';
this.getSelectedUsers = [];