Skip to content

Commit

Permalink
Merge pull request #523 from AiursoftWeb/groupMgr
Browse files Browse the repository at this point in the history
feat: allow owner to change the group name
  • Loading branch information
xxyzz committed Jun 6, 2019
2 parents b949832 + 99daf30 commit 731ee54
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/app/Controllers/manageGroup.component.ts
Expand Up @@ -23,6 +23,7 @@ export class ManageGroupComponent implements OnInit {

public conversation: GroupConversation;
@ViewChild('imageInput', {static: false}) public imageInput;
public newGroupName: string;

constructor(public groupsApiService: GroupsApiService,
public messageService: MessageService,
Expand All @@ -48,10 +49,12 @@ export class ManageGroupComponent implements OnInit {
this.messageService.conversation = conversation;
this.conversation = <GroupConversation>conversation;
this.conversation.avatarURL = Values.fileAddress + this.conversation.groupImageKey;

this.newGroupName = this.conversation.groupName;
});
} else {
this.conversation = <GroupConversation>this.messageService.conversation;
this.conversation.avatarURL = Values.fileAddress + this.conversation.groupImageKey;
this.newGroupName = this.conversation.groupName;
}
}

Expand Down Expand Up @@ -129,7 +132,8 @@ export class ManageGroupComponent implements OnInit {
}

public saveInfo() {
this.groupsApiService.UpdateGroupInfo(this.conversation.groupName, this.conversation.groupImageKey).subscribe(res => {
this.groupsApiService.UpdateGroupInfo(this.conversation.groupName, this.conversation.groupImageKey, this.newGroupName)
.subscribe(res => {
if (res.code === 0) {
Swal.fire('Success', res.message, 'success');
} else {
Expand Down
3 changes: 2 additions & 1 deletion src/app/Services/GroupsApiService.ts
Expand Up @@ -46,10 +46,11 @@ export class GroupsApiService {
});
}

public UpdateGroupInfo(groupName: string, avatarKey?: number): Observable<AiurProtocal> {
public UpdateGroupInfo(groupName: string, avatarKey?: number, newName?: string): Observable<AiurProtocal> {
return this.apiService.Post(GroupsApiService.serverPath + '/UpdateGroupInfo', {
GroupName: groupName,
AvatarKey: avatarKey,
NewName: newName
});
}

Expand Down
4 changes: 4 additions & 0 deletions src/app/Views/manageGroup.html
Expand Up @@ -13,6 +13,10 @@
<input type="file" name="image" id="image" #imageInput (change)="uploadAvatar()"
accept="image/png, image/jpeg, image/bmp"/>
</div>
<div class="profile">
<label>Group Name</label>
<input [(ngModel)]="newGroupName" placeholder="Enter the group name" type="text" (keyup.enter)="saveInfo()"/>
</div>
<div class="buttons">
<button id="save" class="button primary" (click)="saveInfo()" i18n="@@save">Save</button>
</div>
Expand Down

0 comments on commit 731ee54

Please sign in to comment.