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

master
Trivernis 5 years ago committed by Gitea
commit 454e9b6502

@ -66,6 +66,7 @@ import {MatTooltipModule} from '@angular/material/tooltip';
import {MatExpansionModule} from '@angular/material/expansion'; import {MatExpansionModule} from '@angular/material/expansion';
import {MatDatepickerModule} from '@angular/material/datepicker'; import {MatDatepickerModule} from '@angular/material/datepicker';
import {MatNativeDateModule} from '@angular/material/'; import {MatNativeDateModule} from '@angular/material/';
import {MatSnackBarModule} from '@angular/material/snack-bar';
// import logo from 'src/assets/gv-new-logo.svg'; // import logo from 'src/assets/gv-new-logo.svg';
import logo from '!!raw-loader!./gv-new-logo-white.svg'; import logo from '!!raw-loader!./gv-new-logo-white.svg';
@ -150,7 +151,8 @@ const appRoutes: Routes = [
MatDialogModule, MatDialogModule,
MatTooltipModule, MatTooltipModule,
MatExpansionModule, MatExpansionModule,
MatDatepickerModule MatDatepickerModule,
MatSnackBarModule,
], ],
entryComponents: [ DialogCreateGroupComponent, DialogCreateEventComponent ], entryComponents: [ DialogCreateGroupComponent, DialogCreateEventComponent ],
providers: [], providers: [],

@ -6,7 +6,7 @@
<div class="hover-box" matTooltip="upload new picture" *ngIf="ownProfile" (click)="fileInput.click()"> <div class="hover-box" matTooltip="upload new picture" *ngIf="ownProfile" (click)="fileInput.click()">
<img class="profile-picture" [src]="userProfile.profilePicture"/> <img class="profile-picture" [src]="userProfile.profilePicture"/>
<mat-icon id="icon">camera_alt</mat-icon> <mat-icon id="icon">camera_alt</mat-icon>
<input #fileInput type="file" (change)="onFileInput($event)" style="display:none;" /> <input #fileInput type="file" accept="image/*" (change)="onFileInput($event)" style="display:none;" />
</div> </div>
<div *ngIf="!ownProfile"> <div *ngIf="!ownProfile">
<img class="profile-picture" [src]="userProfile.profilePicture"/> <img class="profile-picture" [src]="userProfile.profilePicture"/>
@ -48,7 +48,7 @@
<div class="hover-box" matTooltip="upload new picture" *ngIf="ownProfile" (click)="fileInput.click()"> <div class="hover-box" matTooltip="upload new picture" *ngIf="ownProfile" (click)="fileInput.click()">
<img class="profile-picture" [src]="userProfile.profilePicture"/> <img class="profile-picture" [src]="userProfile.profilePicture"/>
<mat-icon id="icon">camera_alt</mat-icon> <mat-icon id="icon">camera_alt</mat-icon>
<input #fileInput type="file" (change)="onFileInput($event)" style="display:none;" /> <input #fileInput type="file" accept="image/*" (change)="onFileInput($event)" style="display:none;" />
</div> </div>
<div *ngIf="!ownProfile"> <div *ngIf="!ownProfile">
<img class="profile-picture" [src]="userProfile.profilePicture"/> <img class="profile-picture" [src]="userProfile.profilePicture"/>

@ -6,6 +6,9 @@ import { RequestService } from 'src/app/services/request/request.service';
import { DatasharingService } from '../../services/datasharing.service'; import { DatasharingService } from '../../services/datasharing.service';
import { ProfileService } from 'src/app/services/profile/profile.service'; import { ProfileService } from 'src/app/services/profile/profile.service';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { environment } from 'src/environments/environment';
import {MatSnackBar} from '@angular/material/snack-bar';
import { reduce } from 'rxjs/operators';
@Component({ @Component({
selector: 'app-profile', selector: 'app-profile',
@ -26,6 +29,7 @@ export class ProfileComponent implements OnInit {
constructor( constructor(
private http: HttpClient, private http: HttpClient,
private _snackBar: MatSnackBar,
private router: Router, private router: Router,
private requestService: RequestService, private requestService: RequestService,
private data: DatasharingService, private data: DatasharingService,
@ -72,11 +76,14 @@ export class ProfileComponent implements OnInit {
const formData: any = new FormData(); const formData: any = new FormData();
formData.append('profilePicture', event.target.files[0]); formData.append('profilePicture', event.target.files[0]);
this.http.post('https://greenvironment.net/upload', formData).subscribe( this.http.post(environment.greenvironmentUrl + '/upload', formData).subscribe(
async (response: Response) => { (response: any) => {
this.userProfile.profilePicture = 'https://greenvironment.net/' + (await response.json()).filename; this.userProfile.profilePicture = environment.greenvironmentUrl + response.fileName;
}, },
(error) => console.log(error) (error) => {
); this._snackBar.open('failed to upload picture', 'okay', {
duration: 3000
});
});
} }
} }

@ -82,7 +82,7 @@ export class ProfileService {
profile.friendCount = response.data.getUser.friendCount; profile.friendCount = response.data.getUser.friendCount;
profile.groupCount = response.data.getUser.groupCount; profile.groupCount = response.data.getUser.groupCount;
if (response.data.getUser.profilePicture) { if (response.data.getUser.profilePicture) {
profile.profilePicture = 'https://greenvironment.net/' + response.data.getUser.profilePicture; profile.profilePicture = environment.greenvironmentUrl + response.data.getUser.profilePicture;
} else { } else {
profile.profilePicture = 'assets/images/account_circle-24px.svg'; profile.profilePicture = 'assets/images/account_circle-24px.svg';
} }

@ -1,4 +1,5 @@
export const environment = { export const environment = {
production: true, production: true,
graphQLUrl: '/graphql' graphQLUrl: '/graphql',
greenvironmentUrl: '',
}; };

@ -4,7 +4,8 @@
export const environment = { export const environment = {
production: false, production: false,
graphQLUrl: 'https://greenvironment.net/graphql' graphQLUrl: 'https://greenvironment.net/graphql',
greenvironmentUrl: 'https://greenvironment.net/',
}; };
/* /*

Loading…
Cancel
Save