@@ -289,63 +289,38 @@ $("#show_all_projects").click(function () {
289
289
290
290
$ ( "#edit-project-button" ) . click ( function ( ) {
291
291
var name = $ ( "#name" ) . val ( ) ;
292
- var repo_type = $ ( "input[name=repo_type]:checked" ) . val ( ) ;
293
292
var repository = $ ( "#repository" ) . val ( ) ;
294
- var branch = $ ( "#branch" ) . val ( ) ;
295
- var username = $ ( "#username" ) . val ( ) ;
296
- var password = $ ( "#password" ) . val ( ) ;
293
+ var author = $ ( "#author" ) . val ( ) ;
294
+ var remark = $ ( "#remark" ) . val ( ) ;
297
295
298
296
if ( ! name || name == "" ) {
299
- var tres = '<div class="alert alert-danger alert-dismissible" role="alert">' ;
300
- tres += '<button type="button" class="close" data-dismiss="alert" aria-label="Close">' ;
301
- tres += '<span aria-hidden="true">×</span></button>' ;
302
- tres += '<strong>name cannot be empty!</strong></div>' ;
303
- $ ( "#edit-project-result" ) . html ( tres ) . fadeIn ( 1000 ) ;
297
+ showAlert ( 'danger' , 'name can not be empty!' , 'edit-project-result' ) ;
304
298
return false ;
305
299
}
306
300
307
- if ( ! repo_type || repo_type == "" ) {
308
- var tres = '<div class="alert alert-danger alert-dismissible" role="alert">' ;
309
- tres += '<button type="button" class="close" data-dismiss="alert" aria-label="Close">' ;
310
- tres += '<span aria-hidden="true">×</span></button>' ;
311
- tres += '<strong>repo type error.</strong></div>' ;
312
- $ ( "#edit-project-result" ) . html ( tres ) . fadeIn ( 1000 ) ;
301
+ if ( ! repository || repository == "" ) {
302
+ showAlert ( 'danger' , 'repository can not be empty!' , '#edit-project-result' ) ;
313
303
return false ;
314
304
}
315
-
316
- if ( ! repository || repository == "" ) {
317
- var tres = '<div class="alert alert-danger alert-dismissible" role="alert">' ;
318
- tres += '<button type="button" class="close" data-dismiss="alert" aria-label="Close">' ;
319
- tres += '<span aria-hidden="true">×</span></button>' ;
320
- tres += '<strong>repository cannot be empty!</strong></div>' ;
321
- $ ( "#edit-project-result" ) . html ( tres ) . fadeIn ( 1000 ) ;
305
+ if ( ! remark || remark == "" ) {
306
+ showAlert ( 'danger' , 'remark can not be empty!' , '#edit-project-result' ) ;
322
307
return false ;
323
308
}
324
309
325
- if ( ! branch || branch == "" ) {
326
- var tres = '<div class="alert alert-danger alert-dismissible" role="alert">' ;
327
- tres += '<button type="button" class="close" data-dismiss="alert" aria-label="Close">' ;
328
- tres += '<span aria-hidden="true">×</span></button>' ;
329
- tres += '<strong>branch cannot be empty!</strong></div>' ;
330
- $ ( "#edit-project-result" ) . html ( tres ) . fadeIn ( 1000 ) ;
310
+ if ( ! author || author == "" ) {
311
+ showAlert ( 'danger' , 'author cannot be empty!' , '#edit-project-result' ) ;
331
312
return false ;
332
313
}
333
314
334
315
data = {
335
316
'project_id' : cur_project_id ,
336
317
'name' : name ,
337
- 'repo_type' : repo_type ,
338
318
'repository' : repository ,
339
- 'branch' : branch ,
340
- 'username' : username ,
341
- 'password' : password
319
+ 'author' : author ,
320
+ 'remark' : remark
342
321
} ;
343
322
$ . post ( 'edit_project/' + cur_project_id , data , function ( res ) {
344
- var tres = '<div class="alert alert-' + res . tag + ' alert-dismissible" role="alert">' ;
345
- tres += '<button type="button" class="close" data-dismiss="alert" aria-label="Close">' ;
346
- tres += '<span aria-hidden="true">×</span></button>' ;
347
- tres += '<strong>' + res . msg + '</strong></div>' ;
348
- $ ( "#edit-project-result" ) . html ( tres ) . fadeIn ( 1000 ) ;
323
+ showAlert ( res . tag , res . msg , '#edit-project-result' ) ;
349
324
} ) ;
350
325
} ) ;
351
326
} ) ;
@@ -377,21 +352,44 @@ $("#show_all_projects").click(function () {
377
352
378
353
// show all white lists click
379
354
$ ( "#show_all_whitelists" ) . click ( function ( ) {
380
- console . log ( 'show all white list' ) ;
381
355
$ . get ( 'whitelists' , function ( data ) {
382
356
$ ( "#main-div" ) . html ( data ) ;
383
357
384
358
// edit the special white list
385
359
$ ( "[id^=edit-whitelist]" ) . click ( function ( ) {
386
360
var cur_id = $ ( this ) . attr ( 'id' ) . split ( '-' ) [ 2 ] ;
387
361
console . log ( "edit the " + cur_id ) ;
362
+
363
+ $ . get ( 'edit_whitelist/' + cur_id , function ( data ) {
364
+ $ ( "#main-div" ) . html ( data ) ;
365
+
366
+ $ ( "#edit-whitelist-button" ) . click ( function ( ) {
367
+ var project = $ ( "#project" ) . val ( ) ;
368
+ var rule = $ ( "#rule" ) . val ( ) ;
369
+ var path = $ ( "#path" ) . val ( ) ;
370
+ var reason = $ ( "#reason" ) . val ( ) ;
371
+ var status = $ ( "#status:checked" ) . val ( ) ;
372
+
373
+ data = {
374
+ 'whitelist_id' : cur_id ,
375
+ 'project' : project ,
376
+ 'rule' : rule ,
377
+ 'path' : path ,
378
+ 'reason' : reason ,
379
+ 'status' : status
380
+ } ;
381
+
382
+ $ . post ( "edit_whitelist/" + cur_id , data , function ( result ) {
383
+ showAlert ( result . tag , result . msg , '#edit-whitelist-result' ) ;
384
+ } ) ;
385
+ } ) ;
386
+ } ) ;
388
387
} ) ;
389
388
390
389
391
390
// delete the special white list
392
391
$ ( "[id^=del-whitelist]" ) . click ( function ( ) {
393
392
var cur_id = $ ( this ) . attr ( 'id' ) . split ( '-' ) [ 2 ] ;
394
- console . log ( "delete the " + cur_id ) ;
395
393
$ . post ( 'del_whitelist' , { 'whitelist_id' : cur_id } , function ( data ) {
396
394
showAlert ( data . tag , data . msg , "#operate_result" ) ;
397
395
$ ( "#show_all_whitelists" ) . click ( ) ;
@@ -410,7 +408,7 @@ $("#add_new_whitelist").click(function () {
410
408
$ ( "#add-new-whitelist-button" ) . click ( function ( ) {
411
409
var project_id = $ ( "#project" ) . val ( ) ;
412
410
var rule_id = $ ( "#rule" ) . val ( ) ;
413
- var file = $ ( "#file " ) . val ( ) ;
411
+ var path = $ ( "#path " ) . val ( ) ;
414
412
var reason = $ ( "#reason" ) . val ( ) ;
415
413
416
414
if ( ! project_id || project_id == "" ) {
@@ -423,7 +421,7 @@ $("#add_new_whitelist").click(function () {
423
421
return false ;
424
422
}
425
423
426
- if ( ! file || file == "" ) {
424
+ if ( ! path || path == "" ) {
427
425
showAlert ( 'danger' , 'file cannot be empty.' ) ;
428
426
return false ;
429
427
}
@@ -436,7 +434,7 @@ $("#add_new_whitelist").click(function () {
436
434
data = {
437
435
'project_id' : project_id ,
438
436
'rule_id' : rule_id ,
439
- 'file ' : file ,
437
+ 'path ' : path ,
440
438
'reason' : reason
441
439
} ;
442
440
0 commit comments