Skip to content

Commit

Permalink
remove unused log; new id sort function
Browse files Browse the repository at this point in the history
  • Loading branch information
xrain0610 committed Mar 25, 2023
1 parent c5a6d3b commit e0aba02
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 33 deletions.
5 changes: 2 additions & 3 deletions src/app/http-api.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import {
HttpInterceptor, HttpResponse
} from '@angular/common/http';
import {catchError, mergeMap, Observable, of} from 'rxjs';
import {Router} from '@angular/router';
import {ActivatedRoute, Router} from '@angular/router';
import {NzMessageService} from 'ng-zorro-antd/message';

@Injectable()
export class HttpApiInterceptor implements HttpInterceptor {

constructor(private router: Router, private msg: NzMessageService) {
constructor(private router: Router, private msg: NzMessageService, private route: ActivatedRoute) {
}

intercept(request: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>> {
Expand All @@ -32,7 +32,6 @@ export class HttpApiInterceptor implements HttpInterceptor {
if (error.status === 404 || error.status == 0) {
this.router.navigateByUrl('/login');
}
console.log(error)
return of(error)
}));
}
Expand Down
17 changes: 2 additions & 15 deletions src/app/views/machine-manager/machine-manager.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class MachineManagerComponent implements OnInit {

getList() {
this.api.machineList(this.user).subscribe(x => {
this.machines = x.machines.sort(this.compare('id', true));
this.machines = x.machines.sort((a: any, b: any) => parseInt(a.id) - parseInt(b.id));
this.getRoutes();
if (this.tagEditMachine.id) {
this.tagEditMachine = this.machines.find(x => x.id == this.tagEditMachine.id);
Expand Down Expand Up @@ -90,19 +90,6 @@ export class MachineManagerComponent implements OnInit {
})
}

compare(property: string, asc: boolean) {
return function (value1: { [x: string]: any; }, value2: { [x: string]: any; }) {
let a = value1[property]
let b = value2[property]
// 默认升序
if (asc == undefined) {
return a - b
} else {
return asc ? a - b : b - a
}
}
}

onExpandChange(id: string, checked: boolean): void {
if (checked) {
this.expandSet.add(id);
Expand Down Expand Up @@ -179,7 +166,7 @@ export class MachineManagerComponent implements OnInit {
nzFooter: null
}).afterClose.subscribe(x => {
if (x) {
this.api.machineRegister(this.user, 'nodekey:' + x.replace('nodekey:','')).subscribe(x => {
this.api.machineRegister(this.user, 'nodekey:' + x.replace('nodekey:', '')).subscribe(x => {
this.msg.success('Register machine success');
this.getList();
})
Expand Down
16 changes: 1 addition & 15 deletions src/app/views/user-manager/user-manager.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,16 @@ export class UserManagerComponent implements OnInit {

getList() {
this.api.userList().subscribe(x => {
this.users = x.users.sort(this.compare('id', true));
this.users = x.users.sort((a: any, b: any) => parseInt(a.id) - parseInt(b.id));
});
}

getPreAuthKeys(user: string) {
this.api.preAuthKeyList(user).subscribe(x => {
this.preAuthKeys[user] = x.preAuthKeys;
console.log(x.preAuthKeys)
})
}

compare(property: string, asc: boolean) {
return function (value1: { [x: string]: any; }, value2: { [x: string]: any; }) {
let a = value1[property]
let b = value2[property]
// 默认升序
if (asc == undefined) {
return a - b
} else {
return asc ? a - b : b - a
}
}
}

onExpandChange(name: string, checked: boolean): void {
if (checked) {
this.expandSet.add(name);
Expand Down

0 comments on commit e0aba02

Please sign in to comment.