Merge branch 'julius-dev' of Software_Engineering_I/greenvironment-frontend into master

master
Trivernis 5 years ago committed by Gitea
commit efdae2a4dd

13
Jenkinsfile vendored

@ -2,12 +2,20 @@ pipeline {
agent any agent any
stages { stages {
stage('Dependencies') {
steps {
echo 'Installing Dependencies...'
nodejs(nodeJSInstallationName: 'Node 12.x') {
sh 'npm i @angular/cli'
sh 'npm i'
sh 'tslint "src/**/*.ts"'
}
}
}
stage('Stylecheck') { stage('Stylecheck') {
steps { steps {
echo 'Checking Style...' echo 'Checking Style...'
nodejs(nodeJSInstallationName: 'Node 12.x') { nodejs(nodeJSInstallationName: 'Node 12.x') {
sh 'npm i'
sh 'npm i typescript tslint'
sh 'tslint "src/**/*.ts"' sh 'tslint "src/**/*.ts"'
} }
} }
@ -16,7 +24,6 @@ pipeline {
steps { steps {
echo 'Building...' echo 'Building...'
nodejs(nodeJSInstallationName: 'Node 12.x') { nodejs(nodeJSInstallationName: 'Node 12.x') {
sh 'npm i @angular/cli'
sh 'ng build --prod' sh 'ng build --prod'
} }
} }

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

@ -26,7 +26,11 @@ export class AppScaffoldComponent implements OnInit {
dropdownShown = false; 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() { ngOnInit() {
this.data.currentUserInfo.subscribe(user => { this.data.currentUserInfo.subscribe(user => {

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

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

@ -18,7 +18,13 @@ import { OverlayContainer} from '@angular/cdk/overlay';
}) })
export class MainNavigationComponent implements OnInit { 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(); this.overlay = overlayContainer.getContainerElement();
} }
loggedIn = false; loggedIn = false;

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

@ -7,7 +7,12 @@ import { GroupInfo } from 'src/app/models/groupinfo';
styleUrls: ['./groups.component.sass'] styleUrls: ['./groups.component.sass']
}) })
export class GroupsComponent implements OnInit { 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() { } constructor() { }
ngOnInit() { ngOnInit() {

@ -9,13 +9,14 @@ export class Levellist {
{level: 6, name: 'Intergallactic Superhero', points: 600 }, {level: 6, name: 'Intergallactic Superhero', points: 600 },
]; ];
getLevelName(lev: number): any { getLevelName(level: number): any {
let name = 'not defined'; 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; name = rank.name;
} }
}); }
return name; return name;
} }

@ -10,7 +10,17 @@ export class Post {
userVote: string; userVote: string;
author: Author; 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.id = pId;
this.content = pContent; this.content = pContent;
this.htmlContent = pHtmlContent; this.htmlContent = pHtmlContent;

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

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

@ -117,29 +117,41 @@ export class FeedService {
return this.http.post(url, this.getBodyForGetAllPostsByUserId(userId)); 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) { getBodyForGetAllPostsByUserId(pUserId: number) {
const body = {query: `query ($userId: ID!) { 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: { }`, variables: {
userId: pUserId userId: pUserId
}}; }};
return body return body;
} }
getBodyForGetAllPosts() { getBodyForGetAllPosts() {
const body = {query: `query { 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> { public renderAllPosts(pResponse: any): Array<Post> {

@ -47,7 +47,7 @@ export class LoginService {
user.chatIDs = response.data.login.chats; user.chatIDs = response.data.login.chats;
user.requestIDs = response.data.login.requests; 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 { public buildJson(registration: Registration): any {
const body = {query: `mutation($username: String, $email: String, $pwHash: String) { 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: { }`, variables: {
email: registration.email, email: registration.email,
pwHash: registration.passwordHash, pwHash: registration.passwordHash,

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

Loading…
Cancel
Save