Merge branch 'master' into julius-dev
commit
510ec83e34
@ -0,0 +1,29 @@
|
||||
@import '../../../../styles/greenvironment-material-theme'
|
||||
|
||||
.dialogFormField
|
||||
width: 100%
|
||||
|
||||
#error
|
||||
margin-top: 1em
|
||||
|
||||
#progress-bar
|
||||
margin-top: 1em
|
||||
|
||||
.confirmationButton
|
||||
background-color: $primary-color
|
||||
|
||||
.uploadDialogContent
|
||||
overflow: hidden
|
||||
text-align: center
|
||||
|
||||
#inputPreview
|
||||
max-width: 75%
|
||||
max-height: 100%
|
||||
width: auto
|
||||
clip-path: circle()
|
||||
mask-mode: luminance
|
||||
|
||||
#inputPreviewWrapper
|
||||
margin: auto
|
||||
text-align: center
|
||||
max-height: 512px
|
@ -0,0 +1,85 @@
|
||||
import {Component} from '@angular/core';
|
||||
import {MatDialogRef} from '@angular/material/dialog';
|
||||
import {GroupService} from '../../../services/group/group.service';
|
||||
import {environment} from '../../../../environments/environment';
|
||||
import {BehaviorSubject} from 'rxjs';
|
||||
|
||||
@Component({
|
||||
selector: 'group-file-upload-dialog',
|
||||
templateUrl: 'fileUploadDialog.component.html',
|
||||
styleUrls: ['./fileUpload.component.sass'],
|
||||
})
|
||||
export class DialogGroupFileUploadComponent {
|
||||
public errorOccurred = false;
|
||||
public uploading = false;
|
||||
private errorMessage: string;
|
||||
public profilePictureUrl: BehaviorSubject<string | null>;
|
||||
private file;
|
||||
public localFileUrl;
|
||||
groupId: number;
|
||||
|
||||
constructor(public dialogRef: MatDialogRef<DialogGroupFileUploadComponent>, private groupService: GroupService) {
|
||||
this.profilePictureUrl = new BehaviorSubject<string | null>(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for the error message
|
||||
*/
|
||||
getErrorMessage() {
|
||||
return this.errorMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired when the cancel button of the dialog is pressed
|
||||
*/
|
||||
onCancelClicked() {
|
||||
this.dialogRef.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired when the ok button was pressed
|
||||
*/
|
||||
onOkClicked() {
|
||||
if (this.file) {
|
||||
this.errorOccurred = false;
|
||||
this.uploading = true;
|
||||
this.groupService.changeProfilePicture(this.file, this.groupId).subscribe((response) => {
|
||||
this.uploading = false;
|
||||
if (response.success) {
|
||||
this.profilePictureUrl.next(environment.greenvironmentUrl + response.fileName);
|
||||
this.dialogRef.close();
|
||||
} else {
|
||||
this.errorMessage = response.error;
|
||||
this.errorOccurred = true;
|
||||
}
|
||||
}, (error) => {
|
||||
this.uploading = false;
|
||||
this.errorOccurred = true;
|
||||
console.error(error);
|
||||
if (error.error) {
|
||||
this.errorMessage = error.error.error;
|
||||
} else {
|
||||
this.errorMessage = 'Failed to upload the profile picture.';
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.errorOccurred = true;
|
||||
this.errorMessage = 'Please select a file to upload.';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired when the input of the file select changes.
|
||||
* @param event
|
||||
*/
|
||||
onFileInputChange(event) {
|
||||
this.errorOccurred = false;
|
||||
this.errorMessage = '';
|
||||
this.file = event.target.files[0];
|
||||
const reader = new FileReader();
|
||||
reader.onload = (e: any) => {
|
||||
this.localFileUrl = e.target.result;
|
||||
};
|
||||
reader.readAsDataURL(this.file);
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
<div id="file-upload-dialog">
|
||||
<h1 mat-dialog-title align="center">Upload a new group picture!</h1>
|
||||
<div class="uploadDialogContent" mat-dialog-content>
|
||||
<input style="display: none" id="input-file" type="file" accept="image/*" (change)="onFileInputChange($event)" #name>
|
||||
<label for="input-file" class="mat-button mat-raised-button mat-primary">Choose File</label>
|
||||
<div id="inputPreviewWrapper">
|
||||
<h2 *ngIf="localFileUrl">Preview:</h2>
|
||||
<img *ngIf="localFileUrl" id="inputPreview" [src]="localFileUrl"/>
|
||||
</div>
|
||||
<mat-progress-bar id="progress-bar" *ngIf="uploading" mode="indeterminate"></mat-progress-bar>
|
||||
</div>
|
||||
<mat-error id="error" *ngIf="errorOccurred">{{getErrorMessage()}}</mat-error>
|
||||
<div mat-dialog-actions align="end">
|
||||
<button mat-button (click)="onCancelClicked()">Cancel</button>
|
||||
<button class="confirmationButton" mat-raised-button cdkFocusInitial (click)="onOkClicked()">Upload</button>
|
||||
</div>
|
||||
</div>
|
@ -1,13 +1,19 @@
|
||||
import {IEvent} from './interfaces/IEvent';
|
||||
|
||||
export class Event {
|
||||
id: string;
|
||||
name: string;
|
||||
date: string;
|
||||
joined: boolean;
|
||||
|
||||
constructor(pId: string, pName: string, pdate: string, pjoined: boolean) {
|
||||
this.id = pId;
|
||||
this.name = pName;
|
||||
this.date = pdate;
|
||||
this.joined = pjoined;
|
||||
public assignFromResponse(eventDataResponse: IEvent) {
|
||||
this.id = eventDataResponse.id;
|
||||
this.name = eventDataResponse.name;
|
||||
const temp = new Date(Number(eventDataResponse.dueDate));
|
||||
this.date = temp.toLocaleString('en-GB');
|
||||
this.joined = eventDataResponse.joined;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,14 +1,56 @@
|
||||
import {User} from 'src/app/models/user';
|
||||
import {Event} from 'src/app/models/event';
|
||||
import {IGroup} from './interfaces/IGroup';
|
||||
import {environment} from 'src/environments/environment';
|
||||
|
||||
export class Group {
|
||||
id: number;
|
||||
name: string;
|
||||
handle: string;
|
||||
creator: User = new User();
|
||||
picture: string;
|
||||
members: User[] = [];
|
||||
admins: User[] = [];
|
||||
events: Event[] = [];
|
||||
joined: boolean;
|
||||
allowedToJoinGroup = false;
|
||||
|
||||
public assignFromResponse(groupDataResponse: IGroup) {
|
||||
if (!groupDataResponse) {
|
||||
return null;
|
||||
}
|
||||
this.id = groupDataResponse.id;
|
||||
this.name = groupDataResponse.name;
|
||||
this.picture = this.buildPictureUrl(groupDataResponse.picture);
|
||||
let user = new User();
|
||||
this.creator = user.assignFromResponse(groupDataResponse.creator);
|
||||
if (groupDataResponse.members) {
|
||||
for (const member of groupDataResponse.members) {
|
||||
user = new User();
|
||||
this.members.push(user.assignFromResponse(member));
|
||||
}
|
||||
}
|
||||
if (groupDataResponse.admins) {
|
||||
for (const admin of groupDataResponse.admins) {
|
||||
user = new User();
|
||||
this.admins.push(user.assignFromResponse(admin));
|
||||
}
|
||||
}
|
||||
if (groupDataResponse.events) {
|
||||
for (const event of groupDataResponse.events) {
|
||||
const event_ = new Event();
|
||||
this.events.push(event_.assignFromResponse(event));
|
||||
}
|
||||
}
|
||||
this.joined = groupDataResponse.joined;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
buildPictureUrl(path: string): string {
|
||||
if (path) {
|
||||
return environment.greenvironmentUrl + path;
|
||||
} else {
|
||||
return 'assets/images/default-grouppic.svg';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,23 @@
|
||||
import {environment} from 'src/environments/environment';
|
||||
|
||||
export class GroupInfo {
|
||||
id: number;
|
||||
name: string;
|
||||
picture: string;
|
||||
allowedToJoinGroup = false;
|
||||
|
||||
constructor(pId: number, pName: string) {
|
||||
constructor(pId: number, pName: string, picture: string) {
|
||||
this.id = pId;
|
||||
this.name = pName;
|
||||
this.picture = this.buildPictureUrl(picture);
|
||||
}
|
||||
|
||||
buildPictureUrl(path: string): string {
|
||||
if (path) {
|
||||
return environment.greenvironmentUrl + path;
|
||||
} else {
|
||||
return 'assets/images/default-grouppic.svg';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
export interface IEvent {
|
||||
|
||||
id: string;
|
||||
|
||||
name: string;
|
||||
|
||||
dueDate: string;
|
||||
|
||||
joined: boolean;
|
||||
}
|
@ -0,0 +1,129 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="256px"
|
||||
height="256px"
|
||||
viewBox="0 0 256 256"
|
||||
version="1.1"
|
||||
id="SVGRoot"
|
||||
inkscape:version="0.92.4 5da689c313, 2019-01-14"
|
||||
sodipodi:docname="default-grouppic.svg">
|
||||
<defs
|
||||
id="defs3721" />
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="2.8284271"
|
||||
inkscape:cx="102.34915"
|
||||
inkscape:cy="126.03557"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="g4729"
|
||||
showgrid="false"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1131"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:grid-bbox="true" />
|
||||
<metadata
|
||||
id="metadata3724">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:groupmode="layer"
|
||||
id="layer2"
|
||||
inkscape:label="Layer 2"
|
||||
style="display:inline">
|
||||
<g
|
||||
id="g4671"
|
||||
transform="matrix(0.95295459,0,0,0.95295459,6.0218124,5.0688566)" />
|
||||
<g
|
||||
id="g4729">
|
||||
<g
|
||||
id="g4555"
|
||||
transform="matrix(0.601511,0,0,0.601511,-14.481854,52.459176)"
|
||||
style="display:inline">
|
||||
<a
|
||||
id="a845">
|
||||
<circle
|
||||
style="fill:#8bc34a;fill-opacity:1;stroke:none;stroke-width:6.62765312;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="path4571"
|
||||
cx="127.37563"
|
||||
cy="65.066956"
|
||||
r="55.672287" />
|
||||
</a>
|
||||
<path
|
||||
style="fill:#8bc34a;fill-opacity:1;stroke:none;stroke-width:5.33326387;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 186.37446,186.04588 c 16.02202,16.28834 -9.2932,49.07975 -58.99883,49.07975 -49.705624,0 -89.999994,-19.61141 -89.999997,-43.8033 -8e-6,-24.1919 40.294365,-43.80331 89.999997,-43.80331 49.70563,0 40.16315,19.37811 58.99883,38.52686 z"
|
||||
id="path4620"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="sssss" />
|
||||
</g>
|
||||
<g
|
||||
style="display:inline"
|
||||
id="g4555-3"
|
||||
transform="matrix(0.601511,0,0,0.601511,51.382155,98.065036)">
|
||||
<a
|
||||
id="a845-5">
|
||||
<circle
|
||||
style="fill:#8bc34a;fill-opacity:1;stroke:none;stroke-width:6.62765312;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="path4571-6"
|
||||
cx="127.37563"
|
||||
cy="65.066956"
|
||||
r="55.672287" />
|
||||
</a>
|
||||
<ellipse
|
||||
ry="43.803303"
|
||||
rx="90"
|
||||
cy="191.32233"
|
||||
cx="127.37563"
|
||||
id="path4620-2"
|
||||
style="fill:#8bc34a;fill-opacity:1;stroke:none;stroke-width:5.33326387;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||
</g>
|
||||
<g
|
||||
style="display:inline"
|
||||
id="g4555-9"
|
||||
transform="matrix(0.601511,0,0,0.601511,119.22436,50.417304)" />
|
||||
<g
|
||||
id="g4555-7"
|
||||
transform="matrix(-0.601511,0,0,0.601511,270.48185,52.459176)"
|
||||
style="display:inline">
|
||||
<a
|
||||
id="a845-9">
|
||||
<circle
|
||||
style="fill:#8bc34a;fill-opacity:1;stroke:none;stroke-width:6.62765312;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="path4571-2"
|
||||
cx="127.37563"
|
||||
cy="65.066956"
|
||||
r="55.672287" />
|
||||
</a>
|
||||
<path
|
||||
style="fill:#8bc34a;fill-opacity:1;stroke:none;stroke-width:5.33326387;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 186.37446,186.04588 c 16.02202,16.28834 -9.2932,49.07975 -58.99883,49.07975 -49.705624,0 -89.999994,-19.61141 -89.999997,-43.8033 -8e-6,-24.1919 40.294365,-43.80331 89.999997,-43.80331 49.70563,0 40.16315,19.37811 58.99883,38.52686 z"
|
||||
id="path4620-0"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="sssss" />
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 4.6 KiB |
Loading…
Reference in New Issue