Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
209 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
import { Component, OnInit, ViewChild } from '@angular/core'; | ||
import { GroupsApiService } from '../Services/GroupsApiService'; | ||
import { MessageService } from '../Services/MessageService'; | ||
import { filter, map, switchMap } from 'rxjs/operators'; | ||
import { ActivatedRoute, Params, Router } from '@angular/router'; | ||
import { GroupConversation } from '../Models/GroupConversation'; | ||
import { ConversationApiService } from '../Services/ConversationApiService'; | ||
import Swal from 'sweetalert2'; | ||
import { TimerService } from '../Services/TimerService'; | ||
import { Values } from '../values'; | ||
import { UploadService } from '../Services/UploadService'; | ||
import { ElectronService } from 'ngx-electron'; | ||
|
||
@Component({ | ||
templateUrl: '../Views/manageGroup.html', | ||
styleUrls: ['../Styles/menu.scss', | ||
'../Styles/userDetail.scss', | ||
'../Styles/button.scss', | ||
'../Styles/progress.scss' | ||
] | ||
}) | ||
export class ManageGroupComponent implements OnInit { | ||
|
||
public conversation: GroupConversation; | ||
@ViewChild('imageInput', {static: false}) public imageInput; | ||
|
||
constructor(public groupsApiService: GroupsApiService, | ||
public messageService: MessageService, | ||
public conversationApiService: ConversationApiService, | ||
public route: ActivatedRoute, | ||
private router: Router, | ||
public timerService: TimerService, | ||
public uploadService: UploadService, | ||
public _electronService: ElectronService | ||
) { | ||
|
||
} | ||
|
||
ngOnInit(): void { | ||
if (!this.messageService.conversation) { | ||
this.route.params | ||
.pipe( | ||
switchMap((params: Params) => this.conversationApiService.ConversationDetail(+params['id'])), | ||
filter(t => t.code === 0), | ||
map(t => t.value) | ||
) | ||
.subscribe(conversation => { | ||
this.messageService.conversation = conversation; | ||
this.conversation = <GroupConversation>conversation; | ||
this.conversation.avatarURL = Values.fileAddress + this.conversation.groupImageKey; | ||
|
||
}); | ||
} else { | ||
this.conversation = <GroupConversation>this.messageService.conversation; | ||
} | ||
} | ||
|
||
public transferOwner(): void { | ||
const inputOptions = {}; | ||
this.conversation.users.forEach(val => inputOptions[val.user.id] = val.user.nickName); | ||
|
||
Swal.fire({ | ||
title: 'Transfer owner to', | ||
input: 'select', | ||
inputOptions: inputOptions, | ||
showCancelButton: true | ||
}).then((willTransfer) => { | ||
if (willTransfer.value) { | ||
this.groupsApiService.TransferOwner(this.conversation.groupName, willTransfer.value) | ||
.subscribe(response => { | ||
if (response.code === 0) { | ||
(<GroupConversation>this.messageService.conversation).ownerId = willTransfer.value; | ||
Swal.fire('Success', response.message, 'success'); | ||
this.router.navigate(['/group', this.conversation.id]); | ||
} else { | ||
Swal.fire('Error', response.message, 'error'); | ||
} | ||
}); | ||
} | ||
}); | ||
} | ||
|
||
public changePasswd() { | ||
Swal.fire({ | ||
title: 'Set your new join password', | ||
text: 'leave the input box empty to remove the password.', | ||
input: 'text', | ||
inputAttributes: { | ||
maxlength: '100' | ||
}, | ||
showCancelButton: true | ||
}).then((result) => { | ||
if (result.dismiss) { | ||
return; | ||
} | ||
this.groupsApiService.UpdateGroupPassword(this.conversation.groupName, result.value).subscribe(res => { | ||
if (res.code === 0) { | ||
Swal.fire('Success', res.message, 'success'); | ||
} else { | ||
Swal.fire('Error', res.message, 'error'); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
public uploadAvatar() { | ||
if (this.imageInput) { | ||
const fileBrowser = this.imageInput.nativeElement; | ||
if (fileBrowser.files && fileBrowser.files[0]) { | ||
this.uploadService.uploadGroupAvater(this.conversation, fileBrowser.files[0]); | ||
} | ||
} | ||
} | ||
|
||
public saveInfo() { | ||
this.groupsApiService.UpdateGroupInfo(this.conversation.groupName, this.conversation.groupImageKey).subscribe(res => { | ||
if (res.code === 0) { | ||
Swal.fire('Success', res.message, 'success'); | ||
} else { | ||
Swal.fire('Error', res.message, 'error'); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<app-header></app-header> | ||
|
||
<div *ngIf="conversation && messageService.checkOwner()"> | ||
<div class="menu-header"> | ||
Information | ||
</div> | ||
<div class="profile avatar"> | ||
<label>Group Avatar</label> | ||
<a class="user-img" href="{{conversation.avatarURL}}" target="_blank"> | ||
<img class="user-img" src="{{conversation.avatarURL}}?w=140&h=140"> | ||
</a> | ||
<label id="upload" class="button primary inputButton" for="image">Upload new avatar</label> | ||
<input type="file" name="image" id="image" #imageInput (change)="uploadAvatar()" | ||
accept="image/png, image/jpeg, image/bmp"/> | ||
</div> | ||
<div class="buttons"> | ||
<button id="save" class="button primary" (click)="saveInfo()" i18n="@@save">Save</button> | ||
</div> | ||
<div class="menu-header"> | ||
Security | ||
</div> | ||
<div class="menu-button" (click)="timerService.setTimer(conversation.id)"> | ||
<div class="img"> | ||
<i class="fa fa-clock-o"></i> | ||
</div> | ||
<div class="text">Self-destruct Timer</div> | ||
</div> | ||
<div class="menu-button" (click)="transferOwner()"> | ||
<div class="img"> | ||
<i class="fa fa-exchange"></i> | ||
</div> | ||
<div class="text">Transfer Owner</div> | ||
</div> | ||
<div class="menu-button" (click)="changePasswd()"> | ||
<div class="img"> | ||
<i class="fa fa-lock"></i> | ||
</div> | ||
<div class="text">Change Join Password</div> | ||
</div> | ||
</div> | ||
<div *ngIf="conversation && !messageService.checkOwner()"> | ||
You don't have the permission to manage the group. | ||
</div> | ||
<progress *ngIf="uploadService.uploading" max="100" value={{uploadService.progress}} | ||
[ngClass]="{ 'macOS-electron': _electronService.isElectronApp && _electronService.isMacOS }"></progress> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters