diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 4467c78..f332f7b 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -12,31 +12,12 @@ export class AppComponent implements OnInit { constructor(private data: DatasharingService, private selfservice: SelfService) { } - userInfo: User; - - loggedIn = false; - userID: number; - username: string; - handle: string; - email: string; - points: number; - level: number; - - friendIDs: number[]; - groupIDs: number[]; - chatIDs: number[]; - - requestIDs: number[]; - ngOnInit() { this.data.currentUserInfo.subscribe(user => { - this.userInfo = user; - console.log(this.userInfo); - this.data.changeChatIDs(user.chatIDs); + if (user.loggedIn !== true) { + this.selfservice.checkIfLoggedIn(); + } }); - if (this.loggedIn !== true) { - this.selfservice.checkIfLoggedIn(); - } } } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 8dcff6a..10631d8 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -23,6 +23,7 @@ import { PostlistComponent } from './components/feed/postlist/postlist.component import { GraphQLModule } from './graphql.module'; import { HttpClientModule } from '@angular/common/http'; import { ProfileComponent } from './components/profile/profile.component'; +import { GroupComponent } from './components/group/group.component'; import { ImprintComponent } from './components/imprint/imprint.component'; import { AboutComponent } from './components/about/about.component'; import { ChatcontactsComponent } from './components/chatmanager/chatcontacts/chatcontacts.component'; @@ -58,6 +59,8 @@ import { SearchComponent } from './components/search/search.component'; import {DomSanitizer} from '@angular/platform-browser'; import {MatIconRegistry} from '@angular/material/icon'; import {MatDialogModule} from '@angular/material/dialog'; +import {MatTooltipModule} from '@angular/material/tooltip'; +import {MatExpansionModule} from '@angular/material/expansion'; // import logo from 'src/assets/gv-new-logo.svg'; import logo from '!!raw-loader!./gv-new-logo-white.svg'; @@ -68,6 +71,7 @@ const config: SocketIoConfig = { url: 'http://localhost:4444', options: {} }; const appRoutes: Routes = [ { path: '', component: HomeComponent }, { path: 'profile/:id', component: ProfileComponent }, + { path: 'group/:id', component: GroupComponent }, { path: 'login', component: LoginComponent }, { path: 'register', component: RegisterComponent }, { path: 'about', component: AboutComponent }, @@ -96,7 +100,8 @@ const appRoutes: Routes = [ ProfileComponent, MainNavigationComponent, SearchComponent, - DialogCreateGroupComponent + DialogCreateGroupComponent, + GroupComponent ], imports: [ BrowserModule, @@ -134,6 +139,8 @@ const appRoutes: Routes = [ MatBadgeModule, MatProgressSpinnerModule, MatDialogModule, + MatTooltipModule, + MatExpansionModule ], entryComponents: [ DialogCreateGroupComponent ], providers: [], diff --git a/src/app/components/feed/feed.component.ts b/src/app/components/feed/feed.component.ts index bd35acb..ef80553 100644 --- a/src/app/components/feed/feed.component.ts +++ b/src/app/components/feed/feed.component.ts @@ -43,7 +43,6 @@ export class FeedComponent implements OnInit { this.feedNew = this.feedService.renderAllPosts(response.json()); this.parentSelectedPostList = this.feedNew; this.feedMostLiked = this.feedNew; - console.log(this.feedNew); }); } else { this.feedService.getAllPostsRaw().subscribe(response => { @@ -51,10 +50,8 @@ export class FeedComponent implements OnInit { this.feedNew = this.feedService.renderAllPosts(response.json()); this.parentSelectedPostList = this.feedNew; this.feedMostLiked = this.feedNew; - console.log(this.feedNew); }); - } - + } }); } @@ -69,7 +66,6 @@ export class FeedComponent implements OnInit { } showNew() { - console.log('showNew()'); this.feedService.getAllPostsRawByUserId(this.userId).subscribe(response => { this.feedNew = this.feedService.renderAllPosts(response.json()); this.parentSelectedPostList = this.feedNew; }); @@ -78,7 +74,6 @@ export class FeedComponent implements OnInit { } showMostLiked() { - console.log('showMostLiked()'); this.feedService.getAllPostsRawByUserId(this.userId).subscribe(response => { this.feedMostLiked = this.feedService.renderAllPosts(response.json()); this.parentSelectedPostList = this.feedMostLiked; }); @@ -90,7 +85,6 @@ export class FeedComponent implements OnInit { refresh($event) { this.feedService.getAllPostsRawByUserId(this.userId).subscribe(response => { this.parentSelectedPostList = this.feedService.renderAllPosts(response.json()); - console.log('Refresh'); }); } diff --git a/src/app/components/feed/postlist/postlist.component.html b/src/app/components/feed/postlist/postlist.component.html index 919f013..6d6d510 100644 --- a/src/app/components/feed/postlist/postlist.component.html +++ b/src/app/components/feed/postlist/postlist.component.html @@ -27,7 +27,7 @@ @@ -46,12 +46,12 @@

- {{post.upvotes}} - diff --git a/src/app/components/feed/postlist/postlist.component.sass b/src/app/components/feed/postlist/postlist.component.sass index e9b0e0b..12f3e95 100644 --- a/src/app/components/feed/postlist/postlist.component.sass +++ b/src/app/components/feed/postlist/postlist.component.sass @@ -5,10 +5,10 @@ box-sizing: border-box width: 100% margin-top: 0.5em + outline: none + user-select: none ::ng-deep .mat-card-header-text margin: 0px - .mat-card-header - .mat-card-subtitle display: contents a:hover @@ -16,4 +16,9 @@ #button-box text-align: right margin-left: auto + ::ng-deep img + max-width: 100% + height: auto + border-radius: 4px + diff --git a/src/app/components/group/group.component.html b/src/app/components/group/group.component.html new file mode 100644 index 0000000..55dfe65 --- /dev/null +++ b/src/app/components/group/group.component.html @@ -0,0 +1,28 @@ +
+
+ + +
+ {{groupProfile.name}} + created by {{groupProfile.creator.username}} @{{groupProfile.creator.handle}} + +
+ +
+ {{groupProfile.members.length}} member(s) +
+
+
+
+
+

Group not found :(

+
+ +
+ + \ No newline at end of file diff --git a/src/app/components/group/group.component.sass b/src/app/components/group/group.component.sass new file mode 100644 index 0000000..335d7d1 --- /dev/null +++ b/src/app/components/group/group.component.sass @@ -0,0 +1,65 @@ +@import '../../../styles/mixins.sass' +@import '../../../styles/vars.sass' + +#profile-page + position: fixed + width: 100% + height: calc(100% - 56px) + overflow: scroll + +#profile + padding: 2em + max-width: 1200px + margin: 0 auto + +#profile-card-container + margin: 0 auto + width: 100% + max-width: 690px + .icon-box + text-align: right + width: 100% +.request-button + margin-top: 0.5em + margin-bottom: 0.5em + margin-left: auto +#toolbar + margin-top: 32px + .mat-toolbar-row + max-height: 40px + #info-box + font-size: 14px + margin-left: calc(100px + 0.5em) + .info + margin-right: 3em + #username + margin: 0 0.5em + #handle + font-size: 14px + + +.mat-table + width: 100% + max-width: 690px + margin: 0 auto +.mat-header-cell + padding-right: 0.5em + +$mat-card-header-size: 100px !default +.profile-picture + background-image: url(https://material.angular.io/assets/img/examples/shiba1.jpg) + height: $mat-card-header-size + width: $mat-card-header-size + border-radius: 50% + flex-shrink: 0 + background-size: cover + // Makes `` tags behave like `background-size: cover`. Not supported + // in IE, but we're using it as a progressive enhancement. + object-fit: cover + + + +#postlist + margin: 0.5em auto + padding: 0 + max-width: 690px \ No newline at end of file diff --git a/src/app/components/group/group.component.spec.ts b/src/app/components/group/group.component.spec.ts new file mode 100644 index 0000000..50601d0 --- /dev/null +++ b/src/app/components/group/group.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { GroupComponent } from './group.component'; + +describe('GroupComponent', () => { + let component: GroupComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ GroupComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(GroupComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/components/group/group.component.ts b/src/app/components/group/group.component.ts new file mode 100644 index 0000000..3fe5209 --- /dev/null +++ b/src/app/components/group/group.component.ts @@ -0,0 +1,64 @@ +import { Component, OnInit, ViewChild} from '@angular/core'; +import {Router, NavigationEnd} from '@angular/router'; +import { User } from 'src/app/models/user'; +import {MatSort} from '@angular/material/sort'; +import { RequestService } from 'src/app/services/request/request.service'; +import { DatasharingService } from '../../services/datasharing.service'; +import { GroupService } from 'src/app/services/group/group.service'; +import { Group } from 'src/app/models/group'; + +@Component({ + selector: 'app-profile', + templateUrl: './group.component.html', + styleUrls: ['./group.component.sass'] +}) + +export class GroupComponent implements OnInit { + groupProfile: Group = new Group(); + self: User; + id: string; + groupNotFound = false; + + loading = false; + + constructor( + private router: Router, + private requestService: RequestService, + private data: DatasharingService, + private groupService: GroupService) { + router.events.forEach((event) => { + // check if url changes + if (event instanceof NavigationEnd) { + const possibleID = this.router.url.substr(this.router.url.lastIndexOf('/') + 1); + if (this.id !== possibleID && this.id && this.router.url.includes('group/')) { + // reload the group + console.log('search for group id: ' + this.router.url.substr(this.router.url.lastIndexOf('/') + 1)); + this.ngOnInit(); + } + } + }); + } + + @ViewChild(MatSort, {static: true}) sort: MatSort; + ngOnInit() { + this.loading = true; + this.id = this.router.url.substr(this.router.url.lastIndexOf('/') + 1); + this.data.currentUserInfo.subscribe(user => { + this.self = user; + }); + this.groupService.getGroupData(this.id); + this.groupService.group.subscribe(response => { + if (response) { + this.groupProfile = response; + // tslint:disable-next-line:max-line-length + this.groupProfile.allowedToJoinGroup = this.requestService.isAllowedToJoinGroup(this.groupProfile.id, this.self); + } else { this.groupNotFound = true; } + this.loading = false; + }); + } + + public joinGroup(group: Group) { + group.allowedToJoinGroup = false; + this.requestService.joinGroup(group); + } +} diff --git a/src/app/components/login/login.component.ts b/src/app/components/login/login.component.ts index c3f9fc0..f7545d1 100644 --- a/src/app/components/login/login.component.ts +++ b/src/app/components/login/login.component.ts @@ -26,19 +26,15 @@ export class LoginComponent implements OnInit { } public loginError(error: any) { - console.log(error.errors[0].message); this.errorOccurred = true; this.errorMessage = error.errors[0].message; } onClickSubmit(pEmail: string, pPasswordHash: string) { - console.log('try to login with mail adress:' + pEmail); this.errorOccurred = false; this.errorMessage = ' '; this.login.email = pEmail.trim().toLowerCase(); this.login.passwordHash = sha512.sha512(pPasswordHash); - console.log(this.login.email); - this.loginService.login(this.login, error => this.loginError(error.json())); } diff --git a/src/app/components/main-navigation/main-navigation.component.html b/src/app/components/main-navigation/main-navigation.component.html index b325689..1936530 100644 --- a/src/app/components/main-navigation/main-navigation.component.html +++ b/src/app/components/main-navigation/main-navigation.component.html @@ -38,8 +38,8 @@ fxShow="true" fxHide.gt-sm="true"> menu - - Greenvironment + + Greenvironment