-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPortal.aspx
1306 lines (1297 loc) · 56.3 KB
/
Portal.aspx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Portal.aspx.cs" Inherits="CreekPortal.Portal"
ValidateRequest="false" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Creek Portal - the P2P Download Platform Administration Dashboard</title>
<link rel="shortcut icon" type="image/x-icon" href="jQuery/themes/Creek Icons/favicon.ico" />
<link rel="stylesheet" type="text/css" href="jQuery/themes/gray/easyui.css" />
<link rel="stylesheet" type="text/css" href="jQuery/themes/icon.css" />
<link rel="stylesheet" type="text/css" href="jQuery/themes/Creek Icon.css" />
<link rel="stylesheet" type="text/css" href="Portal.css" />
<script type="text/javascript" src="jQuery/jquery-1.6.min.js"></script>
<script type="text/javascript" src="jQuery/jquery.easyui.min.js"></script>
<script type="text/javascript" src="jQuery/jquery.json-2.3.min.js"></script>
</head>
<body onload="onload();" style="overflow: hidden;">
<div id="main_dashboard" class="easyui-layout" style="width: 100%; height: 100%;">
<!-- Title of Dashboard -->
<div region="north" split="false" style="overflow: hidden; height: 26px; padding: 0px">
<h2 class="panel-header" style="font-size: medium; border: 0px;">
<span id="portal_banner" style="background-image: url('jQuery/themes/Creek Icons/application-monitor.png');
background-repeat: no-repeat"></span>
</h2>
</div>
<!-- Content List Panel -->
<div region="west" title="Content List" icon="icon-blue-documents" split="true" style="width: 200px;">
<div id="tb_content_list" class="datagrid-toolbar">
<a href="#" id="cmd_content_refresh"></a><a href="#" id="cmd_new_content"></a>
</div>
<ul id="tr_content_list">
</ul>
</div>
<!-- Seed List Panel -->
<div region="east" title="Seed List" icon="icon-network-clouds" split="true" style="width: 200px;">
<div id="tb_seed_list" class="datagrid-toolbar">
<a href="#" id="cmd_seed_refresh"></a>
</div>
<ul id="tr_seed_list">
</ul>
</div>
<!-- System Notification Panel -->
<div region="south" title="System Notifications" icon="icon-system-monitor-network"
split="true" style="height: 200px;">
<table id="gd_notification_list">
</table>
</div>
<!-- Content Detail Panel -->
<div region="center" style="overflow: auto">
<div id="ac_content_detail" class="easyui-accordion" fit="true" border="false">
<!-- Content Summary -->
<div title="Summary" iconcls="icon-blue-document" style="overflow: auto;" selected="true">
<table id="gd_content_summary">
</table>
<div id="tb_content_summary">
<a href="#" id="cmd_new_version"></a>
</div>
</div>
<!-- Work in Progress -->
<div title="Work in Progress" iconcls="icon-blue-document-task" style="overflow: auto;">
<table id="gd_work_in_progress">
</table>
<div id="tb_work_in_progress">
<a href="#" id="cmd_interrupt_all"></a>
</div>
</div>
<!-- Content Version List -->
<div title="Version List" iconcls="icon-blue-document" style="overflow: auto;">
<table id="gd_version_list">
</table>
<div id="tb_version_list">
<a href="#" id="cmd_deploy_content"></a><a href="#" id="cmd_content_offline"></a>
<a href="#" id="cmd_pause_seeds"></a><a href="#" id="cmd_resume_seeds"></a>
<a href="#" id="cmd_get_metafile"></a><a href="#" id="cmd_get_downloader"></a>
<a href="#" id="cmd_regen_downloader"></a>
</div>
</div>
<!-- Torrent Seed Detail -->
<div title="Version Status" iconcls="icon-blue-document" style="overflow: auto;">
<table id="gd_torrent_seed_detail">
</table>
</div>
</div>
</div>
</div>
<!-- begin of new content dialog box ui definitions -->
<div id="nc_dlg" class="easyui-dialog" style="padding: 10px 25px; width: 500px; height: 450px;"
title="建立新的下載內容物" buttons="#nc_dlg_buttons" iconcls="icon-blue-document" closed="true"
shadow="true" modal="true">
<form id="nc_form">
<div class="ftitle">
下載內容物</div>
<div class="fitem">
<label>
內容代碼:</label>
<input id="nc_content_id" class="combo" style="width: 240px; height: 20px" />
<input id="nc_auto_deploy" type="checkbox" class="tree-checkbox" style="height: 20px" /><span>佈署?</span>
</div>
<div class="fitem">
<label>
顯示名稱:</label>
<input id="nc_downloader_display_name" name="DownloaderDisplayName" class="combo"
style="width: 300px; height: 20px" />
</div>
<div class="fitem">
<label>
內容來源:</label>
<input id="nc_content_source_url" name="ContentSourceUrl" class="combo" style="width: 300px;
height: 20px" />
</div>
<div class="fitem">
<label>
HTTP種子:</label>
<input id="nc_http_seed_url" name="HttpSeedsUrl" class="combo" style="width: 240px;
height: 20px" />
<input id="nc_same_to_content_src_url" type="checkbox" class="tree-checkbox" style="height: 20px" /><span>同上?</span>
</div>
<div class="fitem">
<label>
官網位址:</label>
<input id="nc_downloader_home_url" name="DownloaderHomeUrl" class="combo" style="width: 300px;
height: 20px" />
</div>
<div class="fitem">
<label>
FAQ位址:</label>
<input id="nc_online_faq_url" name="OnlineFaqUrl" class="combo" style="width: 300px;
height: 20px" />
</div>
<div class="fitem">
<label>
下載器圖示:</label>
<input id="nc_icon_file" style="width: 300px; height: 20px" />
</div>
<div class="fitem">
<label>
免責聲明:</label>
<input id="nc_disclaimer_file" style="width: 300px; height: 20px" />
</div>
<div class="ftitle">
Google Analytics報表</div>
<div class="fitem">
<label>
資源編號:</label>
<input id="nc_ga_profile_id" name="GAProfileId" class="combo" style="width: 300px;
height: 20px" />
</div>
<div class="ftitle">
索取虛寶活動</div>
<div class="fitem">
<label>
活動序號:</label>
<input id="nc_promotion_event_id" name="PromotionEventID" class="combo" style="width: 300px;
height: 20px" />
</div>
<div class="fitem">
<label>
活動伺服器:</label>
<input id="nc_promotion_event_server_url" name="PromotionEventServerUrl" class="combo"
style="width: 300px; height: 20px" />
</div>
<div class="ftitle">
壓縮下載器</div>
<div class="fitem">
<label>
是否壓縮?</label>
<input id="nc_upx_compression" name="UPXCompression" type="checkbox" class="tree-checkbox"
style="height: 20px" />
</div>
<input id="nc_content_hash_code" name="ContentHashCode" type="hidden" />
</form>
</div>
<div id="nc_dlg_buttons">
<a id="cmd_nc_confirm" href="#" class="easyui-linkbutton" iconcls="icon-ok">確 定</a>
<a id="cmd_nc_cancel" href="#" class="easyui-linkbutton" iconcls="icon-cancel">取 消</a>
</div>
<!-- end of new content dialog box ui definitions -->
<!-- begin of new version dialog box ui definitions -->
<div id="nv_dlg" class="easyui-dialog" style="padding: 10px 25px; width: 500px; height: 450px;"
title="建立新版本的下載內容物" buttons="#nv_dlg_buttons" iconcls="icon-blue-document" closed="true"
shadow="true" modal="true">
<form id="nv_form">
<div class="ftitle">
下載內容物</div>
<div class="fitem">
<label>
內容代碼:</label>
<input id="nv_content_id" class="combo" style="width: 240px; height: 20px" />
<input id="nv_auto_deploy" type="checkbox" class="tree-checkbox" style="height: 20px" /><span>佈署?</span>
</div>
<div class="fitem">
<label>
顯示名稱:</label>
<input id="nv_downloader_display_name" style="width: 300px; height: 20px" />
</div>
<div class="fitem">
<label>
內容來源:</label>
<input id="nv_content_source_url" class="combo" style="width: 300px; height: 20px" />
</div>
<div class="fitem">
<label>
HTTP種子:</label>
<input id="nv_http_seed_url" class="combo" style="width: 240px; height: 20px" />
<input id="nv_same_to_content_src_url" type="checkbox" class="tree-checkbox" style="height: 20px" /><span>同上?</span>
</div>
<div class="fitem">
<label>
官網位址:</label>
<input id="nv_downloader_home_url" style="width: 300px; height: 20px" />
</div>
<div class="fitem">
<label>
FAQ位址:</label>
<input id="nv_online_faq_url" style="width: 300px; height: 20px" />
</div>
<div class="fitem">
<label>
下載器圖示:</label>
<input id="nv_icon_file" style="width: 300px; height: 20px" />
</div>
<div class="fitem">
<label>
免責聲明:</label>
<input id="nv_disclaimer_file" style="width: 300px; height: 20px" />
</div>
<div class="ftitle">
Google Analytics報表</div>
<div class="fitem">
<label>
資源編號:</label>
<input id="nv_ga_profile_id" style="width: 300px; height: 20px" />
</div>
<div class="ftitle">
索取虛寶活動</div>
<div class="fitem">
<label>
活動序號:</label>
<input id="nv_promotion_event_id" style="width: 300px; height: 20px" />
</div>
<div class="fitem">
<label>
活動伺服器:</label>
<input id="nv_promotion_event_server_url" style="width: 300px; height: 20px" />
</div>
<div class="ftitle">
壓縮下載器</div>
<div class="fitem">
<label>
是否壓縮?</label>
<input id="nv_upx_compression" type="checkbox" class="tree-checkbox" style="height: 20px" />
</div>
</form>
</div>
<div id="nv_dlg_buttons">
<a id="cmd_nv_confirm" href="#" class="easyui-linkbutton" iconcls="icon-ok">確 定</a>
<a id="cmd_nv_cancel" href="#" class="easyui-linkbutton" iconcls="icon-cancel">取 消</a>
</div>
<!-- end of new version dialog box ui definitions -->
</body>
<script type="text/javascript">
$.messager.progress({
title: '系統載入',
msg: '畫面載入並進行初始化中, 請稍後...',
text: '載入中...'
});
</script>
<script type="text/javascript">
function initSeedList() {
// Seed List Panel
$('#cmd_seed_refresh').linkbutton({ text: '', disabled: false, iconCls: 'icon-reload', plain: true });
$('#tr_seed_list').tree({
method: 'GET',
url: 'CommandHandler.axd?cmd=query-seed-list&online=icon-dummy-happy&offline=icon-dummy-sad&torrent=icon-blue-document',
onLoadError: function () {
$.messager.progress('close');
$.messager.alert('錯誤', 'Seed List Data Loading Failed', 'error');
},
onLoadSuccess: function (node, data) {
$('#tr_seed_list').tree('collapseAll');
$.messager.progress('close');
},
onBeforeSelect: function () {
return false;
}
});
$('#cmd_seed_refresh').click(function () {
$.messager.progress({
title: '資料同步',
msg: '官方種子清單讀取中, 請稍後...',
text: '讀取中...'
});
$('#tr_seed_list').tree('reload');
});
}
</script>
<script type="text/javascript">
function initSysNotification() {
// System Notification Panel
$('#gd_notification_list').datagrid({
border: false,
fit: true,
fitColumns: true,
singleSelect: true,
pagination: true,
method: 'GET',
url: 'CommandHandler.axd',
queryParams: { cmd: 'query-sys-notification' },
columns: [[
{ field: 'Time', title: '通知時間', width: 140, resizable: true },
{ field: 'Level', title: '通知類別', width: 60, resizable: true },
{ field: 'Message', title: '詳細內容', width: 800, resizable: true}]],
rowStyler: function (inx, row) {
if (row.Level == 'Error') return 'color:red'; else return '';
},
onLoadError: function () {
$.messager.alert('錯誤', 'Sys Notification Data Loading Failed', 'error');
},
onSelect: function () {
$('#gd_notification_list').datagrid('unselectAll');
}
});
}
</script>
<script type="text/javascript">
function initContentSummary() {
// Content Summary
$('#cmd_new_version').linkbutton({ text: '新增版本', disabled: true, iconCls: 'icon-blue-document-plus', plain: true });
$('#gd_content_summary').datagrid({
border: false,
fit: true,
fitColumns: false,
singleSelect: true,
noHeader: true,
toolbar: '#tb_content_summary',
pagination: false,
method: 'GET',
url: 'CommandHandler.axd',
columns: [[
{ field: 'Name', title: '屬性', width: 100, resizable: true },
{ field: 'Value', title: '屬性值', width: 200, resizable: true }
]],
rowStyler: function (inx, row) {
if (row.Name == 'Name') { row.Name = '內容代碼'; return; }
if (row.Name == 'DateCreated') { row.Name = '建立時間'; return; }
if (row.Name == 'Count') { row.Name = '版本各數'; return; }
},
onBeforeLoad: function (p) {
if (p.cmd == undefined) return false; else {
$('#gd_content_summary').datagrid('options').isLoading = true;
return true;
}
},
onLoadError: function () {
$('#cmd_new_version').linkbutton('disable');
$.messager.alert('錯誤', 'load data failed', 'error');
$('#gd_content_summary').datagrid('options').isLoading = false;
},
onLoadSuccess: function () {
if ($(this).datagrid('getRows').length > 0) {
$('#cmd_new_version').linkbutton('enable');
}
else {
$('#cmd_new_version').linkbutton('disable');
}
$('#gd_content_summary').datagrid('options').isLoading = false;
},
onSelect: function () {
$('#gd_content_summary').datagrid('unselectAll');
}
});
$.extend($('#gd_content_summary').datagrid('options'), { isLoading: false });
$('#cmd_new_version').click(function () {
if ($(this).linkbutton('options').disabled == true) return false;
var contentId = $('#tr_content_list').tree('find', $('#tr_content_list').tree('options').currentViewContentId).text;
openNewVersionWindow(contentId);
});
}
</script>
<script type="text/javascript">
// Work in Progress
$('#cmd_interrupt_all').linkbutton({ text: '中斷', disabled: true, iconCls: 'icon-blue-document-minus', plain: true });
$('#gd_work_in_progress').datagrid({
border: false,
fit: true,
fitColumns: false,
singleSelect: true,
toolbar: '#tb_work_in_progress',
pagination: false,
method: 'GET',
url: 'CommandHandler.axd',
columns: [[
{ field: 'Time', title: '執行時間', width: 140, resizable: true },
{ field: 'Percentage', title: '完成度', width: 60, resizable: true, align: 'right' }
]],
onBeforeLoad: function (p) {
if (p.cmd == undefined) return false; else {
$('#gd_work_in_progress').datagrid('options').isLoading = true;
return true;
}
},
onLoadError: function () {
$('#cmd_interrupt_all').linkbutton('disable');
$.messager.alert('錯誤', 'load data failed', 'error');
$('#gd_work_in_progress').datagrid('options').isLoading = false;
},
onLoadSuccess: function () {
if ($(this).datagrid('getRows').length > 0) {
$('#cmd_interrupt_all').linkbutton('enable');
}
else {
$('#cmd_interrupt_all').linkbutton('disable');
}
$('#gd_work_in_progress').datagrid('options').isLoading = false;
},
onSelect: function () {
$('#gd_work_in_progress').datagrid('unselectAll');
}
});
$.extend($('#gd_work_in_progress').datagrid('options'), { isLoading: false });
$('#cmd_interrupt_all').click(function () {
if ($(this).linkbutton('options').disabled == true) return false;
var contentId = $('#tr_content_list').tree('find', $('#tr_content_list').tree('options').currentViewContentId).text;
$.messager.progress({
title: '指令執行',
msg: '指令正在執行中, 請稍後...',
text: '執行中...'
});
$.ajax({
url: 'CommandHandler.axd',
type: 'GET',
data: {
cmd: 'interrupt-content-gen',
content_id: contentId
}
})
.success(function (data, status) {
setTimeout(function () {
$.messager.progress('close');
$('#gd_work_in_progress').datagrid('load', {
cmd: 'query-work-in-progress',
content_id: contentId
});
}, 1000);
})
.error(function (xhr) {
$.messager.progress('close');
$.messager.alert(
'指令執行失敗',
'<font color=\'red\'>錯誤代碼: ' + '(' + xhr.status + ') ' + xhr.statusText + '</font>',
'error');
});
});
</script>
<script type="text/javascript">
function initContentVersionList() {
// Content Version List
$('#cmd_deploy_content').linkbutton({ text: '佈署', disabled: true, iconCls: 'icon-blue-document-share', plain: true });
$('#cmd_content_offline').linkbutton({ text: '下架', disabled: true, iconCls: 'icon-broom', plain: true });
$('#cmd_pause_seeds').linkbutton({ text: '暫停', disabled: true, iconCls: 'icon-control-pause', plain: true });
$('#cmd_resume_seeds').linkbutton({ text: '恢復', disabled: true, iconCls: 'icon-control', plain: true });
$('#cmd_get_metafile').linkbutton({ text: '取得中介檔', disabled: true, iconCls: 'icon-drive-download', plain: true });
$('#cmd_get_downloader').linkbutton({ text: '取得下載器', disabled: true, iconCls: 'icon-drive-download', plain: true });
$('#cmd_regen_downloader').linkbutton({ text: '重建下載器', disabled: true, iconCls: 'icon-arrow-circle', plain: true });
$('#gd_version_list').datagrid({
border: false,
fit: true,
fitColumns: false,
singleSelect: true,
toolbar: '#tb_version_list',
pagination: false,
method: 'GET',
url: 'CommandHandler.axd',
idField: 'Hash',
columns: [[
{ field: 'Time', title: '建立時間', width: 140, resizable: true },
{ field: 'Name', title: '檔案名稱', width: 200, resizable: true },
{ field: 'Hash', title: 'Hash值', width: 320, resizable: true },
{ field: 'DeployToTracker', title: '已發佈', width: 60, resizable: true, align: 'right' },
{ field: 'SeedDeploymentRatio', title: '佈署率', width: 60, resizable: true, align: 'right' },
{ field: 'SeedingRatio', title: '執行率', width: 60, resizable: true, align: 'right' }
]],
rowStyler: function (inx, row) {
if (row.DeployToTracker == true) row.DeployToTracker = '是'; else row.DeployToTracker = '否';
row.SeedDeploymentRatio = (row.SeedDeploymentRatio * 100).toString() + '%';
row.SeedingRatio = (row.SeedingRatio * 100).toString() + '%';
if (row.SeedDeploymentRatio != '100%' || row.SeedingRatio != '100%') return 'color:red'; else return '';
},
onSelect: function (inx, row) {
if ($('#tr_content_list').tree('find', $('#tr_content_list').tree('options').currentViewContentId) != null) {
var contentId = $('#tr_content_list').tree('find', $('#tr_content_list').tree('options').currentViewContentId).text;
$('#gd_version_list').datagrid('options').currentViewContentHash = row.Hash;
$('#gd_torrent_seed_detail').datagrid('load', {
cmd: 'query-torrent-seed-detail',
content_id: contentId,
content_hash: row.Hash
});
}
},
onBeforeLoad: function (p) {
if (p.cmd == undefined) return false; else {
$('#gd_version_list').datagrid('options').isLoading = true;
return true;
}
},
onLoadError: function () {
var dummyData = { "total": 0, "rows": [] };
$('#gd_torrent_seed_detail').datagrid('loadData', dummyData);
$('#cmd_deploy_content').linkbutton('disable');
$('#cmd_content_offline').linkbutton('disable');
$('#cmd_pause_seeds').linkbutton('disable');
$('#cmd_resume_seeds').linkbutton('disable');
$('#cmd_get_metafile').linkbutton('disable');
$('#cmd_get_downloader').linkbutton('disable');
$('#cmd_regen_downloader').linkbutton('disable');
$.messager.alert('錯誤', 'load data failed', 'error');
$('#gd_version_list').datagrid('options').isLoading = false;
},
onLoadSuccess: function () {
if ($(this).datagrid('getRows').length > 0) {
if ($('#gd_version_list').datagrid('options').currentViewContentHash != '') {
var chash = $('#gd_version_list').datagrid('options').currentViewContentHash;
if ($('#gd_version_list').datagrid('getRowIndex', chash) < 0) {
$(this).datagrid('selectRow', 0);
}
else {
$('#gd_version_list').datagrid('selectRecord', chash);
}
}
else {
$(this).datagrid('selectRow', 0);
}
$('#cmd_deploy_content').linkbutton('enable');
$('#cmd_content_offline').linkbutton('enable');
$('#cmd_pause_seeds').linkbutton('enable');
$('#cmd_resume_seeds').linkbutton('enable');
$('#cmd_get_metafile').linkbutton('enable');
$('#cmd_get_downloader').linkbutton('enable');
$('#cmd_regen_downloader').linkbutton('enable');
}
else {
var dummyData = { "total": 0, "rows": [] };
$('#gd_torrent_seed_detail').datagrid('loadData', dummyData);
$('#cmd_deploy_content').linkbutton('disable');
$('#cmd_content_offline').linkbutton('disable');
$('#cmd_pause_seeds').linkbutton('disable');
$('#cmd_resume_seeds').linkbutton('disable');
$('#cmd_get_metafile').linkbutton('disable');
$('#cmd_get_downloader').linkbutton('disable');
$('#cmd_regen_downloader').linkbutton('disable');
$('#gd_version_list').datagrid('options').currentViewContentHash = '';
}
$('#gd_version_list').datagrid('options').isLoading = false;
}
});
$.extend($('#gd_version_list').datagrid('options'), { isLoading: false });
$.extend($('#gd_version_list').datagrid('options'), { currentViewContentHash: '' });
$('#cmd_deploy_content').click(function () {
$.messager.confirm(
'指令執行提示',
'確定要執行內容佈署作業指令?',
function (bConfirm) {
if (bConfirm == true) {
doContentOperation($('#cmd_deploy_content'), 'deploy-content');
}
}
);
});
$('#cmd_content_offline').click(function () {
$.messager.confirm(
'指令執行提示',
'確定要執行內容下架作業指令?',
function (bConfirm) {
if (bConfirm == true) {
doContentOperation($('#cmd_content_offline'), 'content-offline');
}
}
);
});
$('#cmd_pause_seeds').click(function () {
$.messager.confirm(
'指令執行提示',
'確定要執行內容暫停散播作業指令?',
function (bConfirm) {
if (bConfirm == true) {
doContentOperation($('#cmd_pause_seeds'), 'pause-seeds');
}
}
);
});
$('#cmd_resume_seeds').click(function () {
$.messager.confirm(
'指令執行提示',
'確定要執行內容恢復散播作業指令?',
function (bConfirm) {
if (bConfirm == true) {
doContentOperation($('#cmd_resume_seeds'), 'resume-seeds');
}
}
);
});
$('#cmd_get_metafile').click(function () {
if ($(this).linkbutton('options').disabled == true) return false;
var contentId = $('#tr_content_list').tree('find', $('#tr_content_list').tree('options').currentViewContentId).text;
var contentHash = $('#gd_version_list').datagrid('getSelected').Hash;
if (contentId != '' && contentHash != '') {
$.messager.progress({
title: '指令執行',
msg: '指令正在執行中, 請稍後...',
text: '執行中...'
});
// Evaluate if the command is successful first then download it later
$.ajax({
url: 'CommandHandler.axd',
type: 'GET',
data: {
cmd: 'get-metafile',
content_id: contentId,
content_hash: contentHash
}
})
.success(function (data, status) {
setTimeout(function () {
$.messager.progress('close');
window.location.href = 'CommandHandler.axd?' + 'cmd=get-metafile' +
'&content_id=' + encodeURIComponent(contentId) +
'&content_hash=' + encodeURIComponent(contentHash);
}, 500);
})
.error(function (xhr) {
$.messager.progress('close');
$.messager.alert(
'指令執行失敗',
'<font color=\'red\'>錯誤代碼: ' + '(' + xhr.status + ') ' + xhr.statusText + '</font>',
'error');
});
}
});
$('#cmd_get_downloader').click(function () {
if ($(this).linkbutton('options').disabled == true) return false;
var contentId = $('#tr_content_list').tree('find', $('#tr_content_list').tree('options').currentViewContentId).text;
var contentHash = $('#gd_version_list').datagrid('getSelected').Hash;
if (contentId != '' && contentHash != '') {
$.messager.progress({
title: '指令執行',
msg: '指令正在執行中, 請稍後...',
text: '執行中...'
});
// Evaluate if the command is successful first then download it later
$.ajax({
url: 'CommandHandler.axd',
type: 'GET',
data: {
cmd: 'get-downloader',
content_id: contentId,
content_hash: contentHash
}
})
.success(function (data, status) {
setTimeout(function () {
$.messager.progress('close');
window.location.href = 'CommandHandler.axd?' + 'cmd=get-downloader' +
'&content_id=' + encodeURIComponent(contentId) +
'&content_hash=' + encodeURIComponent(contentHash);
}, 500);
})
.error(function (xhr) {
$.messager.progress('close');
$.messager.alert(
'指令執行失敗',
'<font color=\'red\'>錯誤代碼: ' + '(' + xhr.status + ') ' + xhr.statusText + '</font>',
'error');
});
}
});
$('#cmd_regen_downloader').click(function () {
if ($(this).linkbutton('options').disabled == true) return false;
var contentId = $('#tr_content_list').tree('find', $('#tr_content_list').tree('options').currentViewContentId).text;
var contentHash = $('#gd_version_list').datagrid('getSelected').Hash;
if (contentId != '' && contentHash != '') {
openRegenDownloaderWindow(contentId, contentHash);
}
});
}
function doContentOperation(cmdButton, opCmd) {
if ($(cmdButton).linkbutton('options').disabled == true) return false;
var contentId = $('#tr_content_list').tree('find', $('#tr_content_list').tree('options').currentViewContentId).text;
var contentHash = $('#gd_version_list').datagrid('getSelected').Hash;
$.messager.progress({
title: '指令執行',
msg: '指令正在執行中, 請稍後...',
text: '執行中...'
});
$.ajax({
url: 'CommandHandler.axd',
type: 'GET',
data: {
cmd: opCmd,
content_id: contentId,
content_hash: contentHash
}
})
.success(function (data, status) {
setTimeout(function () {
$.messager.progress('close');
$.messager.show({
title: '指令執行完成',
msg: '請刷新系統通知及內容清單以查看指令的執行結果.',
timeout: 3000,
showType: 'slide'
});
}, 500);
})
.error(function (xhr) {
$.messager.progress('close');
$.messager.alert(
'指令執行失敗',
'<font color=\'red\'>錯誤代碼: ' + '(' + xhr.status + ') ' + xhr.statusText + '</font>',
'error');
});
}
</script>
<script type="text/javascript">
function initTorrentSeedDetail() {
// Torrent Seed Detail
$('#gd_torrent_seed_detail').datagrid({
border: false,
fit: true,
fitColumns: false,
singleSelect: true,
pagination: false,
method: 'GET',
url: 'CommandHandler.axd',
columns: [[
{ field: 'IP', title: '官方種子', width: 80, resizable: true },
{ field: 'Size', title: '檔案大小', width: 100, resizable: true, align: 'right' },
{ field: 'Done', title: '完成度', width: 60, resizable: true, align: 'right' },
{ field: 'Status', title: '狀態', width: 100, resizable: true },
{ field: 'Error', title: '錯誤訊息', width: 500, resizable: true }
]],
rowStyler: function (inx, row) {
row.Size = (Math.round((row.Size * 100) / (1024 * 1024)) / 100).toString() + 'MB';
row.Done = (Math.round(row.Done * 1000) / 10).toString() + '%';
if (row.Status == 'Unknown') return 'color:red'; else return '';
},
onBeforeLoad: function (p) { if (p.cmd == undefined) return false; else return true; },
onLoadError: function () {
$.messager.alert('錯誤', 'load data failed', 'error');
},
onSelect: function () {
$('#gd_torrent_seed_detail').datagrid('unselectAll');
}
});
}
</script>
<script type="text/javascript">
function initContentList() {
// Content List Panel
$('#cmd_content_refresh').linkbutton({ text: '', disabled: false, iconCls: 'icon-reload', plain: true });
$('#cmd_new_content').linkbutton({ text: '新增內容', disabled: false, iconCls: 'icon-blue-document-plus', plain: true });
$('#tr_content_list').tree({
method: 'GET',
url: 'CommandHandler.axd?cmd=query-content-list&online=icon-blue-document&offline=icon-blue-document-exclamation',
onSelect: function (node) {
$('#tr_content_list').tree('options').currentViewContentId = node.id;
if ($('#gd_content_summary').datagrid('options').isLoading == false) {
$('#gd_content_summary').datagrid('load', {
cmd: 'query-content-summary',
content_id: node.text
});
}
if ($('#gd_work_in_progress').datagrid('options').isLoading == false) {
$('#gd_work_in_progress').datagrid('load', {
cmd: 'query-work-in-progress',
content_id: node.text
});
}
if ($('#gd_version_list').datagrid('options').isLoading == false) {
$('#gd_version_list').datagrid('load', {
cmd: 'query-version-list',
content_id: node.text
});
}
//var panelFocus = $('#ac_content_detail').accordion('getSelected');
//if (panelFocus != null && panelFocus.panel('options').title == 'Version Status') {
// $('#ac_content_detail').accordion('select', 'Version List');
//}
},
onLoadError: function () {
$.messager.progress('close');
var dummyData = { "total": 0, "rows": [] };
$('#gd_content_summary').datagrid('loadData', dummyData);
$('#gd_work_in_progress').datagrid('loadData', dummyData);
$('#gd_version_list').datagrid('loadData', dummyData);
$('#gd_torrent_seed_detail').datagrid('loadData', dummyData);
$.messager.alert('錯誤', 'load data failed', 'error');
},
onLoadSuccess: function (node, data) {
$.messager.progress('close');
if ($('#tr_content_list').tree('options').currentViewContentId != '') {
var cid = $('#tr_content_list').tree('options').currentViewContentId;
var n = $('#tr_content_list').tree('find', cid);
if (n != null) {
$('#tr_content_list').tree('select', n.target);
}
else {
var dummyData = { "total": 0, "rows": [] };
$('#gd_content_summary').datagrid('loadData', dummyData);
$('#gd_work_in_progress').datagrid('loadData', dummyData);
$('#gd_version_list').datagrid('loadData', dummyData);
$('#gd_torrent_seed_detail').datagrid('loadData', dummyData);
}
}
}
});
$.extend($('#tr_content_list').tree('options'), { currentViewContentId: '' });
$('#cmd_content_refresh').click(function () {
$.messager.progress({
title: '資料同步',
msg: '內容清單讀取中, 請稍後...',
text: '讀取中...'
});
$('#tr_content_list').tree('reload');
});
$('#cmd_new_content').click(function () {
openNewContentWindow();
});
}
</script>
<script type="text/javascript">
function initNewContentDlg() {
// New Content Dialog
$('#nc_content_id').validatebox({
required: true
});
$('#nc_downloader_display_name').validatebox({
required: true
});
$('#nc_content_source_url').validatebox({
required: true,
validType: 'url'
});
$('#nc_http_seed_url').validatebox({
required: false,
validType: 'url'
});
$('#nc_downloader_home_url').validatebox({
required: true,
validType: 'url'
});
$('#nc_online_faq_url').validatebox({
required: true,
validType: 'url'
});
$('#nc_icon_file').combobox({
required: true,
valueField: 'id',
textField: 'text',
mode: 'remote',
method: 'GET',
formatter: function (row) {
return '<span class="item-text">' + $('<div/>').text(row.text).html() + '</span>';
}
});
$('#nc_disclaimer_file').combobox({
required: true,
valueField: 'id',
textField: 'text',
mode: 'remote',
method: 'GET',
formatter: function (row) {
return '<span class="item-text">' + $('<div/>').text(row.text).html() + '</span>';
}
});
$('#nc_ga_profile_id').validatebox({
required: true
});
$('#nc_promotion_event_id').validatebox({
required: false
});
$('#nc_promotion_event_server_url').validatebox({
required: false,
validType: 'url'
});
$('#nc_content_source_url').change(function () {
if ($('#nc_same_to_content_src_url').prop('checked') == true) {
$('#nc_http_seed_url').val($('#nc_content_source_url').val());
}
});
$('#nc_same_to_content_src_url').change(function () {
if ($('#nc_same_to_content_src_url').prop('checked') == true) {
$('#nc_http_seed_url').val($('#nc_content_source_url').val());
$('#nc_http_seed_url').prop('disabled', true);
}
else {
$('#nc_http_seed_url').val('');
$('#nc_http_seed_url').prop('disabled', false);
}
});
$('#nc_promotion_event_id').change(function () {
if ($('#nc_promotion_event_id').val().length > 0) {
$('#nc_promotion_event_server_url').prop('disabled', false);
}
else {
$('#nc_promotion_event_server_url').val('');
$('#nc_promotion_event_server_url').prop('disabled', true);
}
});
$('#cmd_nc_confirm').click(function () {
confirmNewContentWindow();
});
$('#cmd_nc_cancel').click(function () {
cancelNewContentWindow();
});
}
</script>
<script type="text/javascript">
function initNewVersionDlg() {
// New Version Dialog
$('#nv_content_id').validatebox({
required: true
});
$('#nv_downloader_display_name').combobox({
required: true,
valueField: 'id',
textField: 'text',
mode: 'remote',
method: 'GET',
formatter: function (row) {
return '<span class="item-text">' + $('<div/>').text(row.text).html() + '</span>';
}
});
$('#nv_content_source_url').validatebox({
required: true,
validType: 'url'
});
$('#nv_http_seed_url').validatebox({
required: false,
validType: 'url'
});
$('#nv_downloader_home_url').combobox({
required: true,
validType: 'url',
valueField: 'id',
textField: 'text',
mode: 'remote',
method: 'GET',
formatter: function (row) {
return '<span class="item-text">' + $('<div/>').text(row.text).html() + '</span>';
}
});
$('#nv_online_faq_url').combobox({
required: true,
validType: 'url',
valueField: 'id',
textField: 'text',
mode: 'remote',
method: 'GET',
formatter: function (row) {
return '<span class="item-text">' + $('<div/>').text(row.text).html() + '</span>';
}
});
$('#nv_icon_file').combobox({
required: true,
valueField: 'id',
textField: 'text',
mode: 'remote',
method: 'GET',
formatter: function (row) {
return '<span class="item-text">' + $('<div/>').text(row.text).html() + '</span>';
}
});
$('#nv_disclaimer_file').combobox({
required: true,
valueField: 'id',
textField: 'text',
mode: 'remote',
method: 'GET',
formatter: function (row) {
return '<span class="item-text">' + $('<div/>').text(row.text).html() + '</span>';
}
});
$('#nv_ga_profile_id').combobox({
required: true,
valueField: 'id',
textField: 'text',
mode: 'remote',
method: 'GET',
formatter: function (row) {
return '<span class="item-text">' + $('<div/>').text(row.text).html() + '</span>';
}
});
$('#nv_promotion_event_id').combobox({
required: false,
valueField: 'id',
textField: 'text',
mode: 'remote',
method: 'GET',
formatter: function (row) {
return '<span class="item-text">' + $('<div/>').text(row.text).html() + '</span>';