|
|
@ -5,6 +5,7 @@ import { Activitylist } from 'src/app/models/activity';
|
|
|
|
import {DatasharingService} from '../../services/datasharing.service';
|
|
|
|
import {DatasharingService} from '../../services/datasharing.service';
|
|
|
|
import {ActivityService} from 'src/app/services/activity/activity.service';
|
|
|
|
import {ActivityService} from 'src/app/services/activity/activity.service';
|
|
|
|
import {User} from 'src/app/models/user';
|
|
|
|
import {User} from 'src/app/models/user';
|
|
|
|
|
|
|
|
import {IErrorResponse} from '../../models/interfaces/IErrorResponse';
|
|
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
@Component({
|
|
|
|
selector: 'home-feed',
|
|
|
|
selector: 'home-feed',
|
|
|
@ -17,21 +18,25 @@ export class FeedComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
|
|
checked = false; // if the "I protected the environment."-box is checked
|
|
|
|
checked = false; // if the "I protected the environment."-box is checked
|
|
|
|
view = 'new';
|
|
|
|
view = 'new';
|
|
|
|
empty: any;
|
|
|
|
textInputValue: string;
|
|
|
|
// id of the green activity
|
|
|
|
// id of the green activity
|
|
|
|
value: any;
|
|
|
|
value: any;
|
|
|
|
|
|
|
|
|
|
|
|
parentSelectedPostList: Array<Post>;
|
|
|
|
parentSelectedPostList: Post[];
|
|
|
|
actionlist: Activitylist = new Activitylist();
|
|
|
|
actionlist: Activitylist = new Activitylist();
|
|
|
|
|
|
|
|
|
|
|
|
loggedIn = false;
|
|
|
|
loggedIn = false;
|
|
|
|
user: User;
|
|
|
|
user: User;
|
|
|
|
|
|
|
|
errorOccurred: boolean;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private errorMessage: string;
|
|
|
|
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
constructor(
|
|
|
|
private feedService: FeedService,
|
|
|
|
private feedService: FeedService,
|
|
|
|
private data: DatasharingService,
|
|
|
|
private data: DatasharingService,
|
|
|
|
private activityService: ActivityService
|
|
|
|
private activityService: ActivityService
|
|
|
|
) { }
|
|
|
|
) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
ngOnInit() {
|
|
|
|
this.data.currentUserInfo.subscribe(user => {
|
|
|
|
this.data.currentUserInfo.subscribe(user => {
|
|
|
@ -60,15 +65,23 @@ export class FeedComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
|
|
createPost(pElement, activityId: string) {
|
|
|
|
createPost(pElement, activityId: string) {
|
|
|
|
if (pElement && activityId && this.checked) {
|
|
|
|
if (pElement && activityId && this.checked) {
|
|
|
|
this.feedService.createPostActivity(pElement.value, activityId);
|
|
|
|
this.feedService.createPostActivity(pElement.value, activityId).subscribe(() => {
|
|
|
|
pElement.value = '';
|
|
|
|
pElement.value = '';
|
|
|
|
this.empty = '';
|
|
|
|
this.textInputValue = '';
|
|
|
|
this.view = 'new';
|
|
|
|
this.view = 'new';
|
|
|
|
|
|
|
|
}, (error: IErrorResponse) => {
|
|
|
|
|
|
|
|
this.errorOccurred = true;
|
|
|
|
|
|
|
|
this.errorMessage = error.error.errors[0].message;
|
|
|
|
|
|
|
|
});
|
|
|
|
} else if (pElement) {
|
|
|
|
} else if (pElement) {
|
|
|
|
this.feedService.createPost(pElement.value);
|
|
|
|
this.feedService.createPost(pElement.value).subscribe(() => {
|
|
|
|
pElement.value = '';
|
|
|
|
pElement.value = '';
|
|
|
|
this.empty = '';
|
|
|
|
this.textInputValue = '';
|
|
|
|
this.view = 'new';
|
|
|
|
this.view = 'new';
|
|
|
|
|
|
|
|
}, (error: IErrorResponse) => {
|
|
|
|
|
|
|
|
this.errorOccurred = true;
|
|
|
|
|
|
|
|
this.errorMessage = error.error.errors[0].message;
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -84,4 +97,11 @@ export class FeedComponent implements OnInit {
|
|
|
|
showMostLiked() {
|
|
|
|
showMostLiked() {
|
|
|
|
this.feedService.getPosts('TOP');
|
|
|
|
this.feedService.getPosts('TOP');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Returns the error message if one exists
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
getErrorMessage() {
|
|
|
|
|
|
|
|
return this.errorMessage;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|