Merge branch 'max_dev' of Software_Engineering_I/greenvironment-frontend into master

master
Max_ES 5 years ago committed by Gitea
commit cf9e6fcdcc

@ -25,7 +25,7 @@
<textarea matInput #content type="text" (input)="onTextInputChange()" [(ngModel)]="textInputValue" [disabled]="posting"
mat-autosize="true" matAutosizeMaxRows="3" placeholder="post something"></textarea>
</mat-form-field>
<input style="display: none" id="input-file" type="file" accept="video/*,image/*" (change)="onFileInputChange($event)" #name>
<input style="display: none" id="fileInput" type="file" accept="video/*,image/*" (change)="onFileInputChange($event)" #fileInput>
<div class="input">
<div class="left">
<p id="check">
@ -34,7 +34,7 @@
</p>
</div>
<div class="right">
<button mat-button mat-icon-button (click)="name.click()"
<button mat-button mat-icon-button (click)="fileInput.click()"
matTooltip="upload a picture or video (up to 10MB)"
matTooltipShowDelay="200"
[disabled]="posting">

@ -1,4 +1,4 @@
import {Component, OnInit, ViewChild} from '@angular/core';
import {Component, OnInit, ViewChild, ElementRef} from '@angular/core';
import {Post} from 'src/app/models/post';
import {FeedService, Sort} from 'src/app/services/feed/feed.service';
import {Activitylist} from 'src/app/models/activity';
@ -17,7 +17,7 @@ export class FeedComponent implements OnInit {
loadingNew = true;
loadingMostLiked = true;
// file upload variables
@ViewChild('name', {static: false}) fileInput;
@ViewChild('fileInput', {static: false}) fileInput: ElementRef;
public uploading = false;
public profilePictureUrl: BehaviorSubject<string | null>;
private file;
@ -64,8 +64,11 @@ export class FeedComponent implements OnInit {
this.loadingMostLiked = this.loadingNew = available;
});
this.feedService.posting.subscribe(posting => {
const temp = this.posting;
this.posting = posting;
if (temp !== this.posting && !this.posting) {
this.resetPostInput();
}
});
}
@ -78,7 +81,6 @@ export class FeedComponent implements OnInit {
if (postElement && activityId && this.checked) {
this.posting = true;
this.feedService.createPostActivity(postElement.value, activityId, this.file).subscribe(() => {
postElement.value = '';
}, (error: IErrorResponse) => {
this.errorOccurred = true;
this.posting = false;
@ -87,7 +89,6 @@ export class FeedComponent implements OnInit {
} else if (postElement) {
this.posting = true;
this.feedService.createPost(postElement.value, this.file).subscribe((result) => {
postElement.value = '';
}, (error: IErrorResponse) => {
console.log(error);
this.posting = false;

@ -22,10 +22,12 @@
</mat-card-subtitle>
</mat-card-header>
<mat-card-content>
<mat-spinner *ngIf="post.mediaLoading" style="margin:0 auto; margin-top: 2em;" diameter="50"></mat-spinner>
<div class="postMedia" [hidden]="post.mediaLoading">
<mat-spinner *ngIf="post.mediaLoading && post.mediaType === 'IMAGE'" style="margin:0 auto; margin-top: 2em;" diameter="50"></mat-spinner>
<div class="postMedia">
<div [hidden]="post.mediaLoading">
<img *ngIf="post.mediaType === 'IMAGE'" [src]="post.mediaUrl" (load)="onLoad(this.post)" alt="post image"/>
<video *ngIf="post.mediaType === 'VIDEO'" (load)="onLoad(this.post)" controls>
</div>
<video *ngIf="post.mediaType === 'VIDEO'" controls>
<source [src]="post.mediaUrl" type="video/webm">
</video>
</div>

Loading…
Cancel
Save