Skip to content

Commit 0d0cf00

Browse files
committed
fix bug: length of null
1 parent 9af5879 commit 0d0cf00

File tree

13 files changed

+57
-34
lines changed

13 files changed

+57
-34
lines changed

src/app/app.component.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
display: flex;
77
align-items: top;
88
justify-content: center;
9-
width: 190px;
9+
width: 140px;
1010
}
1111

1212
mat-icon {

src/app/app.component.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,35 +15,35 @@
1515
<mat-list-item>
1616
<a routerLink="/certificates">
1717
<mat-icon>lock_outline</mat-icon>
18-
<span i18n="@@cert_mgmt">Certificate Management</span>
18+
<span i18n="@@cert_mgmt">Certificate</span>
1919
</a>
2020
</mat-list-item>
2121

2222
<mat-list-item>
2323
<a routerLink="/applications">
2424
<mat-icon>format_color_text</mat-icon>
25-
<span i18n="@@app_mgmt">Application Management</span>
25+
<span i18n="@@app_mgmt">Application</span>
2626
</a>
2727
</mat-list-item>
2828

29-
<mat-list-item>
29+
<mat-list-item *ngIf="applicationService.auth_user.is_super_admin==true">
3030
<a routerLink="/nodes">
3131
<mat-icon>games</mat-icon>
32-
<span i18n="@@node_mgmt">Node Management</span>
32+
<span i18n="@@node_mgmt">Node</span>
3333
</a>
3434
</mat-list-item>
3535

3636
<mat-list-item>
3737
<a routerLink="/usermgmt">
3838
<mat-icon>supervisor_account</mat-icon>
39-
<span i18n="@@user_mgmt">User Management</span>
39+
<span i18n="@@user_mgmt">User</span>
4040
</a>
4141
</mat-list-item>
4242

43-
<mat-list-item>
43+
<mat-list-item *ngIf="applicationService.auth_user.is_super_admin==true">
4444
<a routerLink="/waf">
4545
<mat-icon>security</mat-icon>
46-
<span i18n="@@waf_mgmt">WAF Management</span>
46+
<span i18n="@@waf_mgmt">WAF</span>
4747
</a>
4848
</mat-list-item>
4949

src/app/application-detail/application-detail.component.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ export class ApplicationDetailComponent implements OnInit {
4040
const id = +this.route.snapshot.paramMap.get('id');
4141
if(id>0) {
4242
var self = this;
43-
this.applicationService.getResponse('getapp', function(obj: Application){
44-
self.application = obj;
43+
this.applicationService.getResponse('getapp', function(obj: Application){
44+
self.application = obj;
4545
},id);
4646
} else {
4747
this.readOnlyValue = false;
@@ -65,6 +65,10 @@ export class ApplicationDetailComponent implements OnInit {
6565
setApplication() {
6666
var self=this;
6767
this.applicationService.getResponse('updateapp', function(obj: Application){
68+
if(obj==null) {
69+
self.messageService.add("Update failed.");
70+
return;
71+
}
6872
let new_id = obj.id;
6973
if(self.application.id == new_id) {
7074
self.application = obj;
@@ -153,16 +157,10 @@ export class ApplicationDetailComponent implements OnInit {
153157
return;
154158
}
155159
this.application.domains.splice(i,1);
156-
//console.log(this.application.domains);
157160
}
158161

159162
ngOnInit() {
160163
//init IPMethod enum
161-
/*
162-
var enum_ip_method_values = Object.values(IPMethod);
163-
var ip_method_length = (enum_ip_method_values.length)/2;
164-
this.enum_ip_method_values = enum_ip_method_values.slice(ip_method_length);
165-
*/
166164
for(var n in IPMethod) {
167165
if (typeof IPMethod[n] == 'number') {
168166
this.enum_ip_method_values.push({value: <any>IPMethod[n], name: n});
@@ -185,15 +183,15 @@ export class ApplicationDetailComponent implements OnInit {
185183
let self=this;
186184
this.applicationService.getResponseByURL('/janusec-admin/oauth/get',
187185
function(obj: OAuthInfo){
188-
self.oauth=obj;
186+
self.oauth=obj;
189187
});
190188
}
191189

192190

193191
getCertificates() {
194192
var self = this;
195-
this.applicationService.getResponse('getcerts', function(obj: Certificate[]){
196-
self.optionCertificates = obj.concat(self.no_certificate);
193+
this.applicationService.getResponse('getcerts', function(obj: Certificate[]){
194+
self.optionCertificates = obj.concat(self.no_certificate);
197195
});
198196
}
199197

src/app/application.service.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ export class ApplicationService {
4545
catchError(this.handleError<APIResponse>('Get response'))
4646
).subscribe((response: APIResponse) => {
4747
if(response.err==null) {
48-
callback(response.object);
48+
if(response.object!=null) {
49+
callback(response.object);
50+
}
4951
}
5052
else this.messageService.add('Error: ' + response.err);
5153
});
@@ -57,7 +59,9 @@ export class ApplicationService {
5759
catchError(this.handleError<APIResponse>('Get response'))
5860
).subscribe((response: APIResponse) => {
5961
if(response.err==null) {
60-
callback(response.object);
62+
if(response.object!=null) {
63+
callback(response.object);
64+
}
6165
}
6266
else this.messageService.add('Error: ' + response.err);
6367
});
@@ -70,16 +74,18 @@ export class ApplicationService {
7074
catchError(this.handleError<APIResponse>('Get response'))
7175
).subscribe((response: APIResponse) => {
7276
if(response.err==null) {
73-
callback(response.object);
77+
if(response.object!=null) {
78+
callback(response.object);
79+
}
7480
}
7581
else this.messageService.add('Error: ' + response.err);
7682
});
7783
}
7884

7985
getApplications() {
8086
var self = this;
81-
this.getResponse('getapps', function(obj: Application[]){
82-
self.applications = obj;
87+
this.getResponse('getapps', function(obj: Application[]){
88+
self.applications = obj;
8389
});
8490
}
8591

src/app/cclogs/cclogs.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ export class CCLogsComponent implements OnInit {
3838
}
3939
if(this.applicationService.applications.length==0) {
4040
var self = this;
41-
this.applicationService.getResponse('getapps', function(obj: Application[]){
42-
self.applicationService.applications = obj;
43-
self.app_id = self.applicationService.applications[0].id;
41+
this.applicationService.getResponse('getapps', function(obj: Application[]){
42+
self.applicationService.applications = obj;
43+
self.app_id = self.applicationService.applications[0].id;
4444
});
4545
} else {
4646
this.app_id = this.applicationService.applications[0].id;

src/app/firewall/firewall.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
</mat-paginator>
3535
</div>
3636
<div>
37-
<button mat-raised-button i18n="@@add_policy" (click)="newGroupPolicy()" color="primary">Add Policy</button>
37+
<button *ngIf="applicationService.auth_user.is_super_admin" mat-raised-button i18n="@@add_policy" (click)="newGroupPolicy()" color="primary">Add Policy</button>
3838
</div>
3939
</div>
4040
</mat-tab>

src/app/firewall/firewall.component.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ export class FirewallComponent implements OnInit {
3434
private router: Router) {
3535
this.global_cc_policy=new(CCPolicy);
3636
this.app_cc_policy=new(CCPolicy);
37+
if (this.applicationService.auth_user.logged) {
38+
if(this.applicationService.applications.length==0) {
39+
this.applicationService.getApplications();
40+
}
41+
if(this.applicationService.vulntypes.length==0) {
42+
this.applicationService.getVulnTypes(function(){});
43+
}
44+
this.getGroupPolicies(0);
45+
this.getCCPolicy(0);
46+
}
3747
}
3848

3949
ngOnInit() {
@@ -44,7 +54,7 @@ export class FirewallComponent implements OnInit {
4454
if (this.applicationService.auth_user.need_modify_pwd) {
4555
this.router.navigate(['/appuser/'+this.applicationService.auth_user.user_id]);
4656
}
47-
57+
/*
4858
if(this.applicationService.applications.length==0) {
4959
this.applicationService.getApplications();
5060
}
@@ -53,6 +63,7 @@ export class FirewallComponent implements OnInit {
5363
}
5464
this.getGroupPolicies(0);
5565
this.getCCPolicy(0);
66+
*/
5667
/*
5768
var enum_policy_action_values = Object.values(PolicyAction);
5869
var action_length = (enum_policy_action_values.length)/2;

src/app/login-form/login-form.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ <h1 i18n="@@login_title">Admin Login</h1>
1717
</div>
1818
</div>
1919
<div fxFlex="30%"></div>
20-
</div>
20+
</div>

src/app/navbar/navbar.component.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@
1717
}
1818
.logo {
1919
height: 36px;
20+
width: 139px;
2021
}

src/app/nodes/nodes.component.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ export class NodesComponent implements OnInit {
1414
hexNodesKey: string;
1515
constructor(private messageService: MessageService,
1616
public applicationService: ApplicationService,
17-
private router: Router) { }
17+
private router: Router) {
18+
if (this.applicationService.auth_user.logged) {
19+
this.applicationService.getNodesKey();
20+
this.applicationService.getNodes();
21+
}
22+
}
1823

1924
ngOnInit() {
2025
if (this.applicationService.auth_user.logged==false) {
@@ -24,8 +29,10 @@ export class NodesComponent implements OnInit {
2429
if (this.applicationService.auth_user.need_modify_pwd) {
2530
this.router.navigate(['/appuser/'+this.applicationService.auth_user.user_id]);
2631
}
32+
/*
2733
this.applicationService.getNodesKey();
2834
this.applicationService.getNodes();
35+
*/
2936
}
3037

3138
/*

0 commit comments

Comments
 (0)