Applied style fixes

- fixed all tslint errors/warnings
master
Trivernis 5 years ago
parent fc15558644
commit c3ed16b239

@ -34,7 +34,7 @@ export class AppComponent implements OnInit {
console.log(this.userInfo);
this.data.changeChatIDs(user.chatIDs);
});
if (this.loggedIn != true) {
if (this.loggedIn !== true) {
this.selfservice.checkIfLoggedIn();
}
}

@ -26,7 +26,11 @@ export class AppScaffoldComponent implements OnInit {
dropdownShown = false;
constructor(private data: DatasharingService, private selfservice: SelfService, private http: Http, private router: Router) { }
constructor(
private data: DatasharingService,
private selfservice: SelfService,
private http: Http,
private router: Router) { }
ngOnInit() {
this.data.currentUserInfo.subscribe(user => {

@ -34,8 +34,8 @@ export class FeedComponent implements OnInit {
this.data.currentUserInfo.subscribe(user => {
this.user = user;
this.loggedIn = user.loggedIn;
if(this.loggedIn) this.userId = user.userID;
console.log("the userId is " + this.userId);
if (this.loggedIn) { this.userId = user.userID; }
console.log('the userId is ' + this.userId);
});
this.feedService.getAllPostsRawByUserId(this.userId).subscribe(response => {
this.feedNew = this.feedService.renderAllPosts(response.json());

@ -11,14 +11,15 @@ import * as sha512 from 'js-sha512';
styleUrls: ['./login.component.sass']
})
export class LoginComponent implements OnInit {
login: Login;
hide = true;
errorOccurred: boolean = false;
errorMessage: string;
constructor(private loginService: LoginService, private router: Router) {
this.login = {passwordHash: null, email: null};
}
login: Login;
hide = true;
errorOccurred = false;
errorMessage: string;
email = new FormControl('', [Validators.required, Validators.email]);
public getErrorMessage() {
return this.errorMessage;
@ -33,7 +34,7 @@ export class LoginComponent implements OnInit {
onClickSubmit(pEmail: string, pPasswordHash: string) {
console.log('try to login with mail adress:' + pEmail);
this.errorOccurred = false;
this.errorMessage = " ";
this.errorMessage = ' ';
this.login.email = pEmail.trim();
this.login.passwordHash = sha512.sha512(pPasswordHash);
console.log(this.login.passwordHash);
@ -42,7 +43,6 @@ export class LoginComponent implements OnInit {
this.loginService.login(this.login, error => this.loginError(error.json()));
}
email = new FormControl('', [Validators.required, Validators.email]);
ngOnInit() {}
}

@ -18,7 +18,13 @@ import { OverlayContainer} from '@angular/cdk/overlay';
})
export class MainNavigationComponent implements OnInit {
constructor(public overlayContainer: OverlayContainer, private data: DatasharingService, private selfservice: SelfService, private breakpointObserver: BreakpointObserver, private http: Http, private router: Router) {
constructor(
public overlayContainer: OverlayContainer,
private data: DatasharingService,
private selfservice: SelfService,
private breakpointObserver: BreakpointObserver,
private http: Http, private router: Router
) {
this.overlay = overlayContainer.getContainerElement();
}
loggedIn = false;

@ -40,7 +40,7 @@ export class RegisterComponent implements OnInit {
}
passwordSame(pwd: string, pwd2: string) {
if (pwd == pwd2) {
if (pwd === pwd2) {
console.log('password same');
return true;
} else {

@ -7,7 +7,12 @@ import { GroupInfo } from 'src/app/models/groupinfo';
styleUrls: ['./groups.component.sass']
})
export class GroupsComponent implements OnInit {
groups: Array<GroupInfo> = [new GroupInfo(1, 'Group 1', []), new GroupInfo(1, 'Group 2', []), new GroupInfo(1, 'Group 3', []), new GroupInfo(1, 'Group 4', [])];
// TODO: replace with actual logic that loads the groups from the backend
groups: Array<GroupInfo> = [
new GroupInfo(1, 'Group 1', []),
new GroupInfo(1, 'Group 2', []),
new GroupInfo(1, 'Group 3', []),
new GroupInfo(1, 'Group 4', [])];
constructor() { }
ngOnInit() {

@ -9,13 +9,14 @@ export class Levellist {
{level: 6, name: 'Intergallactic Superhero', points: 600 },
];
getLevelName(lev: number): any {
getLevelName(level: number): any {
let name = 'not defined';
this.levels.forEach(rank => {
if (lev == rank.level) {
for (const rank of this.levels) {
if (level === rank.level) {
name = rank.name;
}
});
}
return name;
}

@ -10,7 +10,17 @@ export class Post {
userVote: string;
author: Author;
constructor(pId: number, pContent: string, pHtmlContent: string, pUpvotes: number, pDownvotes: number, pUserVote: string, pDate: string, pAuthor: Author) {
// TODO: constructor properties need normal names
constructor(
pId: number,
pContent: string,
pHtmlContent: string,
pUpvotes: number,
pDownvotes: number,
pUserVote: string,
pDate: string,
pAuthor: Author
) {
this.id = pId;
this.content = pContent;
this.htmlContent = pHtmlContent;

@ -1,15 +1,15 @@
export class User {
loggedIn : boolean
userID : number
username : string
handle : string
email : string
points : number
level : number
loggedIn: boolean;
userID: number;
username: string;
handle: string;
email: string;
points: number;
level: number;
friendIDs : number[]
groupIDs : number[]
chatIDs : number[]
friendIDs: number[];
groupIDs: number[];
chatIDs: number[];
requestIDs : number[]
requestIDs: number[];
}

@ -89,8 +89,12 @@ export class ChatService {
this.http.post(url, this.getBodyForNewChat(pUserID));
}
/**
* TODO: Needs to be used somewhere or it will be removed
*/
public requestAllChatPartners(): Array<FriendInfo> {
const url = environment.graphQLUrl;
// tslint:disable-next-line:prefer-const
let chatPartners: Array<FriendInfo>;
let temp;
@ -107,7 +111,7 @@ export class ChatService {
let memberName: string;
let memberLevel: number;
for (const member of chat.members) {
if (member.id != this.ownID) {
if (member.id !== this.ownID) {
memberID = member.id;
memberName = member.name;
memberLevel = member.level;
@ -154,7 +158,7 @@ export class ChatService {
public renderMessages(pResponse: any): Array<Chatmessage> {
const messages = new Array<Chatmessage>();
for (const message of pResponse.data.getChat.messages) {
if (message.author.id == this.ownID) {
if (message.author.id === this.ownID) {
messages.push(new Chatmessage(message.content, message.createdAt, true));
} else {
messages.push(new Chatmessage(message.content, message.createdAt, false));
@ -169,14 +173,14 @@ export class ChatService {
let memberID: number;
let memberName: string;
for (const member of chat.members) {
if (member.id != this.ownID) {
if (member.id !== this.ownID) {
memberID = member.id;
memberName = member.name;
}
}
const messages = new Array<Chatmessage>();
for (const message of chat.messages) {
if (message.author.id == this.ownID) {
if (message.author.id === this.ownID) {
messages.push(new Chatmessage(message.content, message.createdAt, true));
} else {
messages.push(new Chatmessage(message.content, message.createdAt, false));
@ -192,14 +196,14 @@ export class ChatService {
let memberId: number;
let memberName: string;
for (const member of pResponse.data.getChat.members) {
if (member.id != this.ownID) {
if (member.id !== this.ownID) {
memberId = member.id;
memberName = member.name;
}
}
const messages = new Array<Chatmessage>();
for (const message of pResponse.data.getChat.messages) {
if (message.author.id == this.ownID) {
if (message.author.id === this.ownID) {
messages.push(new Chatmessage(message.content, message.createdAt, true));
} else {
messages.push(new Chatmessage(message.content, message.createdAt, false));

@ -117,29 +117,41 @@ export class FeedService {
return this.http.post(url, this.getBodyForGetAllPostsByUserId(userId));
}
/*getBodyForGetAllPostsByUserId(pUserId: number) {
const body = {query: `query ($userId: ID) {
getPosts (first: 1000, offset: 0, userId: $userId) {id, content, htmlContent, upvotes, downvotes, userVote, author{name, handle, id}, createdAt}
}`, variables: {
userId: pUserId
}};
return body
}*/
getBodyForGetAllPostsByUserId(pUserId: number) {
const body = {query: `query ($userId: ID!) {
getPosts (first: 1000, offset: 0) {id, content, htmlContent, upvotes, downvotes, userVote(userId: $userId), author{name, handle, id}, createdAt}
getPosts (first: 1000, offset: 0) {
id,
content,
htmlContent,
upvotes,
downvotes,
userVote(userId: $userId),
author{
name,
handle,
id},
createdAt}
}`, variables: {
userId: pUserId
}};
return body
return body;
}
getBodyForGetAllPosts() {
const body = {query: `query {
getPosts (first: 1000, offset: 0) {id, content, htmlContent, upvotes, downvotes, author{name, handle, id}, createdAt}
getPosts (first: 1000, offset: 0) {
id,
content,
htmlContent,
upvotes,
downvotes,
author{
name,
handle,
id},
createdAt}
}`
}
return body
};
return body;
}
public renderAllPosts(pResponse: any): Array<Post> {

@ -47,7 +47,7 @@ export class LoginService {
user.chatIDs = response.data.login.chats;
user.requestIDs = response.data.login.requests;
this.data.changeUserInfo(user)
this.data.changeUserInfo(user);
}

@ -56,7 +56,16 @@ export class RegisterService {
public buildJson(registration: Registration): any {
const body = {query: `mutation($username: String, $email: String, $pwHash: String) {
register(username: $username, email: $email, passwordHash: $pwHash) {id, name, handle, points, level, friends{id}, groups{id},chats{id}}
register(username: $username, email: $email, passwordHash: $pwHash) {
id,
name,
handle,
points,
level,
friends{id},
groups{id},
chats{id}
}
}`, variables: {
email: registration.email,
pwHash: registration.passwordHash,

@ -10,7 +10,6 @@
"component-selector": [
true,
"element",
"app",
"kebab-case"
],
"indent": {

Loading…
Cancel
Save