Skip to content

Commit

Permalink
Merge pull request #847 from AiursoftWeb/dev
Browse files Browse the repository at this point in the history
Release 4.0.0 at April fool's day
  • Loading branch information
Anduin2017 authored Mar 31, 2020
2 parents 7feeacf + d65a732 commit ee0d209
Show file tree
Hide file tree
Showing 68 changed files with 964 additions and 434 deletions.
30 changes: 18 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kahla",
"version": "3.9.3",
"version": "4.0.0",
"description": "Kahla is a cross-platform business messaging app.",
"author": "Aiursoft <service@aiursoft.com> (https://www.aiursoft.com/)",
"build": {
Expand Down
11 changes: 10 additions & 1 deletion src/app/Controllers/about.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { Component } from '@angular/core';
import { CheckService } from '../Services/CheckService';
import { Values } from '../values';
import { ApiService } from '../Services/ApiService';
import { ElectronService } from 'ngx-electron';
import { environment } from '../../environments/environment';

@Component({
templateUrl: '../Views/about.html',
Expand All @@ -13,13 +15,20 @@ import { ElectronService } from 'ngx-electron';

export class AboutComponent {
public sourceCodeURL = Values.sourceCodeURL;
public website = environment.officialServerList;

constructor(
public checkService: CheckService,
public electronService: ElectronService
public electronService: ElectronService,
public apiService: ApiService
) {
}

public check(): void {
this.checkService.checkVersion(true);
}

public getCurrentYear(): number {
return new Date().getFullYear();
}
}
4 changes: 2 additions & 2 deletions src/app/Controllers/add-friend.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ export class AddFriendComponent implements OnInit {
this.showUsers = selectUsers;
}

SearchBoxKeyUp(event: KeyboardEvent, element: HTMLInputElement) {
SearchBoxKeyUp(event: KeyboardEvent, value: string) {
if (event.key === 'Enter') {
event.preventDefault();
this.search(element.value, 0);
this.search(value, 0);
}
}
}
14 changes: 0 additions & 14 deletions src/app/Controllers/advanced-setting.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Component, OnInit } from '@angular/core';
import { AuthApiService } from '../Services/AuthApiService';
import { KahlaUser } from '../Models/KahlaUser';
import Swal from 'sweetalert2';
import { DevicesApiService } from '../Services/DevicesApiService';
import { CacheService } from '../Services/CacheService';
import { ProbeService } from '../Services/ProbeService';
import { Subscription } from 'rxjs';
Expand All @@ -21,7 +20,6 @@ export class AdvancedSettingComponent implements OnInit {

constructor(
private authApiService: AuthApiService,
private devicesApiService: DevicesApiService,
private cacheService: CacheService,
private probeService: ProbeService,
) {
Expand Down Expand Up @@ -61,18 +59,6 @@ export class AdvancedSettingComponent implements OnInit {
});
}

public testPush(): void {
this.devicesApiService.PushTestMessage().subscribe(t => {
if (t.code === 0) {
Swal.fire(
'Successfully sent!',
t.message,
'info'
);
}
});
}

public todo(): void {
Swal.fire('Under development', 'This features is still under development ^_^.', 'info');
}
Expand Down
19 changes: 9 additions & 10 deletions src/app/Controllers/changePassword.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { catchError } from 'rxjs/operators';
@Component({
templateUrl: '../Views/changePassword.html',
styleUrls: [
'../Styles/userDetail.scss',
'../Styles/button.scss'
'../Styles/userDetail.scss',
'../Styles/button.scss'
]
})
export class ChangePasswordComponent {
Expand All @@ -24,22 +24,22 @@ export class ChangePasswordComponent {

public checkValid(): void {
this.samePassword = this.newPassword === this.confirmPassword;
if (this.oldPassword.length >= 6 && this.oldPassword.length <= 32 && this.newPassword.length >= 6 &&
this.newPassword.length <= 32 && this.samePassword) {
this.valid = true;
if (/^.{6,32}$/.test(this.oldPassword) && /^.{6,32}$/.test(this.newPassword)) {
this.valid = true;
}
}

public onSubmit(): void {
this.checkValid();
if (!this.samePassword) {
Swal.fire('Passwords are not same!', 'error');
return;
}
if (!this.valid && this.samePassword) {
Swal.fire('Password length should between six and thirty-two');
if (!this.valid) {
Swal.fire('Password length should between 6 and 32.');
return;
}
if (this.valid) {
this.authApiServer.ChangePassword(this.oldPassword, this.newPassword, this.confirmPassword)
this.authApiServer.ChangePassword(this.oldPassword, this.newPassword, this.confirmPassword)
.pipe(catchError(error => {
Swal.fire('Network issue', 'Could not connect to Kahla server.', 'error');
return Promise.reject(error.message || error);
Expand All @@ -51,6 +51,5 @@ export class ChangePasswordComponent {
Swal.fire('Try again', result.message, 'error');
}
});
}
}
}
1 change: 1 addition & 0 deletions src/app/Controllers/conversations.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { HomeService } from '../Services/HomeService';
})
export class ConversationsComponent implements OnInit, OnDestroy {
public loadingImgURL = Values.loadingImgURL;

constructor(
private router: Router,
public cacheService: CacheService,
Expand Down
62 changes: 60 additions & 2 deletions src/app/Controllers/devices.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,32 @@ import { Component, OnInit } from '@angular/core';
import { CacheService } from '../Services/CacheService';
import Swal from 'sweetalert2';
import { Device } from '../Models/Device';
import { ElectronService } from 'ngx-electron';
import { DevicesApiService } from '../Services/DevicesApiService';
import { PushSubscriptionSetting } from '../Models/PushSubscriptionSetting';
import { InitService } from '../Services/InitService';

@Component({
templateUrl: '../Views/devices.html',
styleUrls: ['../Styles/menu.scss']
styleUrls: ['../Styles/menu.scss',
'../Styles/toggleButton.scss']
})
export class DevicesComponent implements OnInit {
constructor(
public cacheService: CacheService,
public electronService: ElectronService,
public devicesApiService: DevicesApiService,
public initService: InitService,
) {
}

public webPushEnabled: boolean;

public ngOnInit(): void {
this.cacheService.updateDevice();
this.cacheService.updateDevice();
if (this.webpushSupported()) {
this.webPushEnabled = this.getWebPushStatus();
}
}

public detail(device: Device): void {
Expand All @@ -27,4 +40,49 @@ export class DevicesComponent implements OnInit {
});
}
}

public webpushSupported(): boolean {
return !this.electronService.isElectronApp && 'Notification' in window && 'serviceWorker' in navigator;
}

public testPush(): void {
this.devicesApiService.PushTestMessage().subscribe(t => {
if (t.code === 0) {
Swal.fire(
'Successfully sent!',
t.message,
'info'
);
}
});
}

public getWebPushStatus(): boolean {
if (!localStorage.getItem('setting-pushSubscription')) {
return true;
}
const status: PushSubscriptionSetting = JSON.parse(localStorage.getItem('setting-pushSubscription'));
return status.enabled;
}

public setWebPushStatus(value: boolean) {
const status: PushSubscriptionSetting = localStorage.getItem('setting-pushSubscription') ?
JSON.parse(localStorage.getItem('setting-pushSubscription')) :
{
enabled: value,
deviceId: 0
};
status.enabled = value;
localStorage.setItem('setting-pushSubscription', JSON.stringify(status));
this.webPushEnabled = value;
this.initService.subscribeUser();
}

public getElectronNotify(): boolean {
return localStorage.getItem('setting-electronNotify') !== 'false';
}

public setElectronNotify(value: boolean) {
localStorage.setItem('setting-electronNotify', value ? 'true' : 'false');
}
}
10 changes: 9 additions & 1 deletion src/app/Controllers/file-history.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { ActivatedRoute, Router } from '@angular/router';
import { FileHistoryApiModel } from '../Models/ApiModels/FileHistoryApiModel';
import { switchMap } from 'rxjs/operators';
import { ConversationApiService } from '../Services/ConversationApiService';
Expand All @@ -22,6 +22,7 @@ export class FileHistoryComponent implements OnInit {
private route: ActivatedRoute,
private conversationApiService: ConversationApiService,
public probeService: ProbeService,
public router: Router,
) {

}
Expand Down Expand Up @@ -58,4 +59,11 @@ export class FileHistoryComponent implements OnInit {
});
return `${count} files. Total Size:${this.probeService.getFileSizeText(totalSize)}`;
}

public share(file: ProbeFile, dir: ProbeFolder) {
this.router.navigate(['share-target', {
message: `[file]${this.files.siteName}/${this.files.rootPath}/${
dir.folderName}/${file.fileName}|${file.fileName}|${this.probeService.getFileSizeText(file.fileSize)}`
}]);
}
}
24 changes: 13 additions & 11 deletions src/app/Controllers/manageGroup.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import { ProbeService } from '../Services/ProbeService';
templateUrl: '../Views/manageGroup.html',
styleUrls: ['../Styles/menu.scss',
'../Styles/userDetail.scss',
'../Styles/button.scss'
'../Styles/button.scss',
'../Styles/toggleButton.scss'
]
})
export class ManageGroupComponent implements OnInit {
Expand Down Expand Up @@ -135,17 +136,18 @@ export class ManageGroupComponent implements OnInit {
}

public saveInfo() {
this.groupsApiService.UpdateGroupInfo(this.conversation.groupName, this.conversation.groupImagePath, this.newGroupName)
this.groupsApiService.UpdateGroupInfo(this.conversation.groupName, this.conversation.listInSearchResult,
this.conversation.groupImagePath, this.newGroupName)
.subscribe(res => {
if (res.code === 0) {
Swal.fire('Success', res.message, 'success');
this.conversation.groupName = this.newGroupName;
} else if (res.code === -10 && (res as AiurCollection<string>).items) {
Swal.fire('Error', (res as AiurCollection<string>).items.join('<br/>'), 'error');
} else {
Swal.fire('Error', res.message, 'error');
}
});
if (res.code === 0) {
Swal.fire('Success', res.message, 'success');
this.conversation.groupName = this.newGroupName;
} else if (res.code === -10 && (res as AiurCollection<string>).items) {
Swal.fire('Error', (res as AiurCollection<string>).items.join('<br/>'), 'error');
} else {
Swal.fire('Error', res.message, 'error');
}
});
}

public kickMember() {
Expand Down
Loading

0 comments on commit ee0d209

Please sign in to comment.