-
Notifications
You must be signed in to change notification settings - Fork 0
/
muton.html
1557 lines (1445 loc) · 50 KB
/
muton.html
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
<!DOCTYPE html>
<!--
ADD Login to top level screen and test if logged in everytime screen shown.
BUGS
database list: next, next, next; change rows to 100, cannot get back to first database
popus blow the back stack
CHECK SESSION FIRST
DONE Creating a database (PUT /database)
DONE, BUT COMMENTED OUT Deleting a database (DELETE /database)
* Creating a design document (PUT /database/_design/app)
* Updating a design document (PUT /database/_design/app?rev=1-4E2)
* Deleting a design document (DELETE /database/_design/app?rev=1-6A7)
* Triggering compaction (POST /_compact)
DONE Reading the task status list (GET /_active_tasks)
* Restarting the server (POST /_restart)
DONE Reading the active configuration (GET /_config)
* Updating the active configuration (PUT /_config)
)))))))))))))))) Admin must be logged in to do this operation.
TODO to get first two screens like Futon
startPg
- x Overview
- Configuration
x get config
x list sections
x list options/value
edit value
- Replicator
- Status
- n/a Test Suite
- Login (todo: failure not handled correctly)
dbListPg
- x add database
TODO if error (not permissions, ask to log in)
- x next, previous
- x change number of items on page
- number of documents in bubble with one call each to api (make advance option)
- TODO bug with variable j
- x showing 1 of x
docListPg
extra
new document
x delete database
security
x compact and cleanup
x jump to document
view
x all
x design
temp views
run view
x next, previous, rows
fieldListPg
x don't allow edit of _fields like _id, _rev, etc.
x highlight value not key
x edit
attachments object not displayed properly
extra
save document
add field
upload attachment
delete document
change view/display/
key/value
value/key
editPg
- x save button working
NOTE: save document still needs to work
-->
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Muton for CouchDB</title>
<meta name="apple-mobile-web-app-capable" content="yes" />
<!--
<link href="http://code.jquery.com/mobile/latest/jquery.mobile.min.css" rel="stylesheet" type="text/css" />
<script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script src="http://code.jquery.com/mobile/latest/jquery.mobile.min.js"></script>
-->
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0rc1/jquery.mobile-1.0rc1.min.css" />
<script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script src="http://code.jquery.com/mobile/1.0rc1/jquery.mobile-1.0rc1.min.js"></script>
<!--
<link rel="stylesheet" href="jquery.mobile-1.0rc1.min.css" />
<script src="jquery-1.6.4.min.js"></script>
<script src="jquery.mobile-1.0rc1.min.js"></script>
-->
<style>
.xof {text-align: center;}
.errorMsg {color: red;}
#fromRemoteDiv {display: none;}
#toRemoteDiv {display: none;}
</style>
</head>
<body>
<div data-role="page" id="startPg" data-add-back-btn="true" data-theme="e">
<div data-role="header">
<h1>Muton for CouchDB</h1>
</div>
<div data-role="content">
<ul data-role="listview" data-inset="true">
<li><a id="startDbListPg" href="#dbListPg">Databases</a></li>
<li><a href="#configPg">Configuration</a></li>
<li><a id="startReplicatePg" href="#replicatePg">Replicator</a></li>
<li><a href="#statusPg">Status</a></li>
<li><a href="#loginPg" data-rel="dialog">Login</a></li>
<!-- <li><a href="#">Test Suite</a></li> -->
</ul>
</div>
</div><!-- /startPg -->
<div data-role="page" id="loginPg" data-add-back-btn="true" data-theme="e">
<div data-role="header">
<h1>Login</h1>
</div>
<div data-role="content">
<p>Login to CouchDB with your name and password.</p>
<div class="errorMsg" id="loginErrorMsg"></div> <div data-role="fieldcontain">
<label for="username">Username: </label>
<input type="text" name="username" id="username" />
<label for="password">Password: </label>
<input type="password" name="password" id="password" />
<a id="butLoginPg" href="#" data-role="button">Login</a>
</div>
</div>
</div><!-- /about -->
<div data-role="page" id="aboutPg" data-add-back-btn="true" data-theme="e">
<div data-role="header">
<h1>About Muton</h1>
</div>
<div class="branding">Muton For CouchDB</div>
<div data-role="content">
<p>Muton is an administration console for CouchDB meant for mobile devices.</p>
<p>Support for various mobile devices and most modern web browsers is possible using the jQuery Mobile library. See their <a href="http://jquerymobile.com/gbs/">page on device support</a>.</p>
<p>Project is maintained on GitHub (future).</p>
</div>
</div><!-- /about -->
<div data-role="page" id="rowDbPg" data-theme="e">
<div data-role="header">
<h1>Change # of Rows</h1>
</div>
<div data-role="content">
<div data-role="fieldcontain">
<fieldset data-role="controlgroup" data-role="controlgroup">
<input type="radio" name="rowsDb" id="rowsDb-5" class="rowsDbClass" value="5" />
<label for="rowsDb-5">5</label>
<input type="radio" name="rowsDb" id="rowsDb-10" class="rowsDbClass" value="10" />
<label for="rowsDb-10">10</label>
<input type="radio" name="rowsDb" id="rowsDb-25" class="rowsDbClass" value="25" />
<label for="rowsDb-25">25</label>
<input type="radio" name="rowsDb" id="rowsDb-50" class="rowsDbClass" value="50" />
<label for="rowsDb-50">50</label>
<input type="radio" name="rowsDb" id="rowsDb-100" class="rowsDbClass" value="100" />
<label for="rowsDb-100">100</label>
</fieldset>
</div>
<a href="#dbListPg" data-rel="back" data-role="button">Close</a>
</div>
</div><!-- /rowDbPg -->
<div data-role="page" id="dbListPg" data-add-back-btn="true" data-theme="e">
<div data-role="header">
<h1>database list</h1>
<a href="#createDbPg" class="ui-btn-right" data-icon="plus" data-rel="dialog">Create DB</a>
</div>
<div data-role="content">
<ul id="dbListUL" data-role="listview" data-inset="true" data-filter="true">
<li><a href="#docListPg">db1</a><span class="ui-li-count">47</span></li>
</ul>
</div>
<fieldset class="ui-grid-b">
<div class="ui-block-a"><a id="butDbListPrevious" href="#" data-role="button" data-icon="arrow-l">Previous</a></div>
<div class="ui-block-b"><a href="#rowDbPg" data-rel="dialog" data-role="button">Rows</a></div>
<div class="ui-block-c"><a id="butDbListNext" href="#" data-role="button" data-icon="arrow-r" data-iconpos="right">Next</a></div>
</fieldset>
</div><!-- /dbListPg -->
<div data-role="page" id="docListPg" data-add-back-btn="true" data-theme="e">
<div data-role="header">
<h1>document list</h1>
<a href="#dbListMorePg" class="ui-btn-right" data-icon="arrow-r">More</a>
</div>
<div data-role="content">
<div data-role="fieldcontain">
<label for="jumpDocInput">Jump to </label>
<input type="search" name="jumpDocInput" id="jumpDocInput" value="" placeholder="doc id" />
</div>
<ul id="docsListUL" data-role="listview" data-inset="true">
<li><a href="#docPg">doc id here</a><span class="ui-li-count">47</span></li>
</ul>
<div data-role="fieldcontain">
<label for="docViewInput">View </label>
<select name="docViewInput" id="docViewInput" data-native-menu="false">
<option value="all">All Documents</option>
<option value="design">Design documents</option>
<option value="temporary">Temporary View</option>
<option value="runView">Run Views</option>
</select>
</div>
</div>
<fieldset class="ui-grid-a">
<div class="ui-block-a"><a id="butDocListPrevious" href="#" data-role="button" data-icon="arrow-l">Previous</a></div>
<div class="ui-block-b"><a id="butDocListNext" href="#" data-role="button" data-icon="arrow-r" data-iconpos="right">Next</a></div>
</fieldset>
</div><!-- /docListPg -->
<div data-role="page" id="runViewsPg" data-add-back-btn="true" data-theme="e">
<div data-role="header">
<h1>Run Views</h1>
</div>
<div data-role="content">
<ul id="runViewsUL" data-role="listview" data-inset="true">
<li data-role="list-divider">Design Doc 1</li>
<li><a href="#" id="" class="">View 1</a></li>
<li><a href="#" id="" class="">View 2</a></li>
<li data-role="list-divider">Design Doc 2</li>
<li><a href="#" id="" class="">View 1</a></li>
<li><a href="#" id="" class="">View 2</a></li>
</ul>
</div>
</div><!-- /runViewsPg -->
<div data-role="page" id="dbListMorePg" data-add-back-btn="true" data-theme="e">
<div data-role="header">
<h1>More Actions</h1>
</div>
<div data-role="content">
<ul id="" data-role="listview" data-inset="true">
<li id="#butNewDoc"><a href="#">New Document</a></li>
<li><a href="#dbSecurityPg" data-rel="dialog">Security</a></li>
<li><a href="#compactPg" data-rel="dialog">Compact and Cleanup</a></li>
<li><a href="#dbDeletePg" data-rel="dialog">Delete Database</a></li>
</ul>
</div>
</div><!-- /dbListMorePg -->
<div data-role="page" id="dbSecurityPg" data-add-back-btn="true" data-theme="e">
<div data-role="header">
<h1>Database Security</h1>
</div>
<div data-role="content">
dbSecurityPg
</div>
</div><!-- /dbSecurityPg -->
<div data-role="page" id="compactPg" data-add-back-btn="true" data-theme="e">
<div data-role="header">
<h1>Compact Database</h1>
</div>
<div data-role="content">
<fieldset data-role="none">
<input type="radio" name="compact" id="compact-1" class="compactClass" value="database" checked="checked" />
<label for="compact-1">Compact Database</label>
Compacting a database removes deleted documents and previous revisions. It is an irreversible operation and may take a while to complete for large databases.
<input type="radio" name="compact" id="compact-2" class="compactClass" value="views" />
<label for="compact-2">Compact Views</label>
View compaction will affect all views in this design document. This operation may take some time to complete. Your views will still operate normally during compaction.
<input type="radio" name="compact" id="compact-3" class="compactClass" value="cleanup" />
<label for="compact-3">Cleanup Views</label>
Cleaning up views in a database removes old view files still stored on the filesystem. It is an irreversible operation.
</fieldset>
<a id="butCompactDb" href="#" data-role="button" data-icon="check">Run</a>
<a data-rel="back" href="#dbListMorePg" data-role="button" data-icon="delete">Cancel</a>
</div>
</div><!-- /compactPg -->
<div data-role="page" id="dbDeletePg" data-add-back-btn="true" data-theme="e">
<div data-role="header">
<h1>Delete Database</h1>
</div>
<div data-role="content">
Are you sure you want to delete this database? Note that this is an irreversible operation!
<a id="butDeleteDb" href="#" data-role="button" data-icon="check">Delete Database</a>
<a data-rel="back" href="#dbListMorePg" data-role="button" data-icon="delete">Cancel</a>
</div>
</div><!-- /dbDeletePg -->
<div data-role="page" id="docPg" data-add-back-btn="true" data-theme="e">
<div data-role="header">
<h1>view document</h1>
<a href="#docAdvancePg" class="ui-btn-right" data-icon="arrow-r">Advanced</a>
</div>
<div data-role="content">
<ul id="fieldListUL" data-role="listview" data-inset="true" data-filter="true">
<li><a href="#docPg">key here
<p class="ui-li-desc">value here</p>
</a></li>
</ul>
</div>
</div><!-- /docPg -->
<div data-role="page" id="statusPg" data-add-back-btn="true" data-theme="e">
<div data-role="header">
<h1>Status</h1>
</div>
<div data-role="content">
<div data-role="fieldcontain">
<label for="statusPoll">Poll interval in seconds:</label>
<input type="range" name="statusPoll" id="statusPoll" value="5" min="0" max="30" />
</div>
<div class="errorMsg" id="statusErrorMsg"></div>
<ul id="statusListUL" data-role="listview" data-inset="true">
</ul>
</div>
</div><!-- /statusPg -->
<div data-role="page" id="createDbPg" data-theme="e">
<div data-role="header">
<h1>Create New Database</h1>
</div>
<div data-role="content">
Please enter the name of the database. Note that only lowercase characters (a-z), digits (0-9), or any of the characters _, $, (, ), +, -, and / are allowed.
<div data-role="fieldcontain">
<label for="newDbName" class="select">Database name: </label>
<input type="text" name="newDbName" id="newDbName" value="" />
</div>
<div class="errorMsg" id="createDbErrorMsg"></div>
</div>
<a id="butCreateDb" href="#" data-role="button" data-icon="check">Create</a>
<!-- butCreateDb$('#createDbPg').dialog('close') -->
</div><!-- /createDbPg -->
<div data-role="page" id="editPg" data-theme="e" data-add-back-btn="true" >
<div data-role="header">
<h1>Edit</h1>
</div>
<div data-role="content">
<div class="errorMsg" id="editErrorMsg"></div>
<div data-role="fieldcontain">
<label id="editKeyLabel" for="editKey" class="select">Key: </label>
<input type="text" name="editKey" id="editKey" value="value" />
</div>
</div>
<a id="butEditSave" href="#" data-role="button" data-icon="check">Save</a>
<a data-rel="back" href="#docPg" data-role="button" data-icon="delete">Cancel</a>
</div><!-- /editPg -->
<div data-role="page" id="replicatePg" data-theme="e" data-add-back-btn="true">
<div data-role="header">
<h1>Replicate Changes</h1>
</div>
<div data-role="content">
<div class="errorMsg" id="replicateErrorMsg"></div>
<div data-role="fieldcontain">
<label for="fromSlider">From:</label>
<select name="fromSlider" id="fromSlider" data-role="slider">
<option value="true">Local</option>
<option value="false">Remote</option>
</select>
</div>
<div data-role="fieldcontain" id="fromLocalDiv">
<label for="fromLocal" class="select">Local database:</label>
<select name="fromLocal" id="fromLocal" data-native-menu="false">
<option value="standard"></option>
</select>
</div>
<div data-role="fieldcontain" id="fromRemoteDiv">
<label for="fromRemote">Remote database: </label>
<input type="text" name="fromRemote" id="fromRemote" value="http://" />
</div>
<div data-role="fieldcontain">
<label for="toSlider">To:</label>
<select name="toSlider" id="toSlider" data-role="slider">
<option value="true">Local</option>
<option value="false">Remote</option>
</select>
</div>
<div data-role="fieldcontain" id="toLocalDiv">
<label for="toLocal" class="select">Local database:</label>
<select name="toLocal" id="toLocal" data-native-menu="false">
<option value="standard"></option>
</select>
</div>
<div data-role="fieldcontain" id="toRemoteDiv">
<label for="toRemote">Remote database: </label>
<input type="text" name="toRemote" id="toRemote" value="http://" />
</div>
<a id="butReverse" href="#" data-role="button" data-icon="refresh">Reverse</a>
<div data-role="fieldcontain">
<fieldset data-role="controlgroup">
<input type="checkbox" name="continuous" id="continuous" />
<label for="continuous">Continuous</label>
</fieldset>
</div>
<div data-role="fieldcontain">
<a id="butReplicator" href="#" data-role="button" data-icon="check">Replicate</a>
</div>
</div>
<div data-role="content">
<ul id="replicatorEventUL" data-role="listview" data-theme="a" data-inset="true">
<li data-role="list-divider">Events</li>
<li id="replicatorEvent"></li>
</ul>
</div>
</div><!-- /replicatePg -->
<div data-role="page" id="replicatePg2" data-theme="e" data-close-btn-text="Back">
<div data-role="header">
<h1>Replicate Changes</h1>
</div>
<div data-role="content">
<div class="errorMsg" id="replicateErrorMsg"></div>
<div data-role="fieldcontain">
<label for="fromSlider">From:</label>
<select name="fromSlider" id="fromSlider" data-role="slider">
<option value="true">Local</option>
<option value="false">Remote</option>
</select>
</div>
<div data-role="fieldcontain" id="fromLocalDiv">
<label for="fromLocal" class="select">Local database:</label>
<select name="fromLocal" id="fromLocal" data-native-menu="false">
<option value="standard">Standard: 7 day</option>
<option value="rush">Rush: 3 days</option>
<option value="express">Express: next day</option>
<option value="overnight">Overnight</option>
</select>
</div>
<div data-role="fieldcontain" id="fromRemoteDiv">
<label for="fromRemote">Remote database: </label>
<input type="text" name="fromRemote" id="fromRemote" value="http://" />
</div>
<div data-role="fieldcontain">
<label for="toSlider">To:</label>
<select name="toSlider" id="toSlider" data-role="slider">
<option value="true">Local</option>
<option value="false">Remote</option>
</select>
</div>
<div data-role="fieldcontain" id="toLocalDiv">
<label for="toLocal" class="select">Local database:</label>
<select name="toLocal" id="toLocal" data-native-menu="false">
<option value="standard">Standard: 7 day</option>
<option value="rush">Rush: 3 days</option>
<option value="express">Express: next day</option>
<option value="overnight">Overnight</option>
</select>
</div>
<div data-role="fieldcontain" id="toRemoteDiv">
<label for="toRemote">Remote database: </label>
<input type="text" name="toRemote" id="toRemote" value="http://" />
</div>
<!--
<p>From: (select local or remote)</p>
<div data-role="collapsible-set">
<div data-role="collapsible" data-collapsed="false" data-theme="a">
<h3>Local</h3>
<div data-role="fieldcontain" id="toLocalDiv3">
<label for="toLocal3" class="select">Local database:</label>
<select name="toLocal3" id="toLocal3" data-native-menu="false">
<option value="standard">Standard: 7 day</option>
<option value="rush">Rush: 3 days</option>
<option value="express">Express: next day</option>
<option value="overnight">Overnight</option>
</select>
</div>
</div>
<div data-role="collapsible" data-theme="a">
<h3>Remote</h3>
<div data-role="fieldcontain" id="toRemoteDiv3">
<label for="toRemote">Remote database: </label>
<input type="text" name="toRemote" id="toRemote" value="http://" />
</div>
</div>
</div>
<p>To: (select local or remote)</p>
<div data-role="collapsible-set">
<div data-role="collapsible" data-collapsed="false" data-theme="b">
<h3>Local</h3>
<div data-role="fieldcontain" id="toLocalDiv2">
<label for="toLocal2" class="select">Local database:</label>
<select name="toLocal2" id="toLocal2" data-native-menu="false">
<option value="standard">Standard: 7 day</option>
<option value="rush">Rush: 3 days</option>
<option value="express">Express: next day</option>
<option value="overnight">Overnight</option>
</select>
</div>
</div>
<div data-role="collapsible" data-theme="b">
<h3>Remote</h3>
<div data-role="fieldcontain" id="toRemoteDiv2">
<label for="toRemote2">Remote database: </label>
<input type="text" name="toRemote2" id="toRemote2" value="http://" />
</div>
</div>
</div>
-->
<a id="butReverse" href="#" data-role="button" data-icon="refresh">Reverse</a>
<div data-role="fieldcontain">
<fieldset data-role="controlgroup">
<input type="checkbox" name="continuous" id="continuous" />
<label for="continuous">Continuous</label>
</fieldset>
</div>
<a id="butReplicator" href="#" data-role="button" data-icon="check">Replicate</a>
</div>
</div><!-- /replicatePg -->
<!-- sever pages not used due to same domain issue -->
<div data-role="page" id="serverPg" data-theme="e">
<div data-role="header">
<h1>Muton</h1>
<a href="#aboutPg" class="ui-btn-right" data-icon="info">About</a>
</div>
<div data-role="content">
<ul id="serverListUL" data-role="listview" data-inset="true">
<li class="serverListA" id="http://127.0.0.1:5984"><a href="#startPg">Local Host</a></li>
</ul>
<fieldset class="ui-grid-a">
<div class="ui-block-a"><a href="#serverDeletePg" data-rel="dialog" data-role="button" data-icon="delete" data-iconpos="left">Delete</a></div>
<div class="ui-block-b"><a href="#serverNewPg" data-rel="dialog" data-role="button" data-icon="add" data-iconpos="right">New</a></div>
</fieldset>
</div>
</div><!-- /serverPg -->
<div data-role="page" id="serverDeletePg" data-theme="e">
<div data-role="header">
<h1>Server Delete</h1>
</div>
<div data-role="content">
<div data-role="fieldcontain">
<p>Select servers to delete</p>
<fieldset id="serverDeleteGroup" data-role="controlgroup" data-role="controlgroup">
<input type="radio" name="name" id="name" value="0" />
<label for="name">name</label>
</fieldset>
<a id="butDeleteServer" href="#" data-role="button" data-icon="delete" data-iconpos="right">Delete</a>
</div>
</div>
</div><!-- /serverDeletePg -->
<div data-role="page" id="serverNewPg" data-theme="e">
<div data-role="header">
<h1>New Server</h1>
</div>
<div data-role="content">
<div data-role="fieldcontain">
<label for="serverName">Server Name:</label>
<input type="text" name="serverName" id="serverName" value="" />
</div>
<div data-role="fieldcontain">
<label for="serverAddress">Server Address:</label>
<input type="text" name="serverAddress" id="serverAddress" value="http://" />
</div>
<p id="serverNewMsg" class="errorMsg"> </p>
<a id="butTestServer" href="#" data-role="button" data-icon="refresh">Test</a>
<a id="butAddServer" href="#" data-role="button" data-icon="plus">Add Server</a>
</div>
</div><!-- /serverNewPg -->
<div data-role="page" id="configPg" data-add-back-btn="true" data-theme="e">
<div data-role="header">
<h1>Configuration</h1>
</div>
<span class="errorMsg" id="configStatusErrorMsg"></span>
<div data-role="content">
<ul id="ulConfig" data-role="listview" data-inset="true">
</ul>
</div>
</div><!-- /configPg -->
<div data-role="page" id="configDetailPg" data-add-back-btn="true" data-theme="e">
<div data-role="header">
<h1 id="titleConfigDetail"></h1>
</div>
<span class="errorMsg" id="configDetailErrorMsg"></span>
<div data-role="content">
<ul id="ulConfigDetail" data-role="listview" data-inset="true">
</ul>
</div>
</div><!-- /configDetailPg -->
<div data-role="page" id="configEditPg" data-theme="e" data-add-back-btn="true" >
<div data-role="header">
<h1>Edit</h1>
</div>
<div data-role="content">
<div id="configEditErrorMsg"></div>
<div data-role="fieldcontain">
<label id="configEditKeyLabel" for="configEditKey" class="select">Key: </label>
<input type="text" name="configEditKey" id="configEditKey" value="value" />
</div>
</div>
<a id="butConfigEditSave" href="#" data-role="button" data-icon="check">Save</a>
<a data-rel="back" href="#docPg" data-role="button" data-icon="delete">Cancel</a>
</div><!-- /configEditPg -->
<script type="text/javascript">
function typeOf(value) {
//['object','array', 'string', 'number', 'boolean', 'null', 'undefined']
var s = typeof value;
if (s === 'object') {
if (value) {
if (value instanceof Array) {
s = 'array';
}
} else {
s = 'null';
}
}
return s;
}
$(document).ready(function() {
$(".fieldListA").live("click", function(){
//alert('clicked fieldListA id='+this.id)
//muton.docsStart=0;//reset start for new database
muton.getDoc(this.id.substring(4));
$.mobile.changePage ($("#docPg"));
});
$(".dbListA").live("click", function(){
//alert('clicked dbListA anchor id='+this.id)
muton.docsStart=0;//reset start for new database
muton.populateDocsList(this.id.substring(3));
$.mobile.changePage ($("#docListPg"));
});
$(".fieldDetailA").live("click", function(){
//alert('clicked fieldDetailA anchor id='+this.id)
//move key and value into editPg if string, number or bolean
//TODO make sure current record is in muton.field, push value into editPg
//TODO make sure current record dirty flag, check dirty before leaving page
var x=this.id.substring(6);
$("#editKeyLabel").html(x);
$("#editKey").val(muton.recordCurrent[x]);
$.mobile.changePage ($("#editPg"));
});
$(".viewsList").live("click", function(){
var x=this.id.split(',');
alert('clicked view id='+x);
var y=muton.views.rows[x[1]].doc.views[x[2]];
var z=muton.views.rows[x[1]].key;
//alert(y);
var url='/'+muton.dbCurrent+'/'+z+'/_view/'+x[2]+'?limit=11'
alert ('url='+url);
//muton.populateDocsList(db,view);
//$.mobile.changePage ($("#editPg"));
});
//muton.populateDbList(muton.dbListStart,muton.dbListIncrement);
//muton.populateDocsList("books");
$("#startDbListPg").live("click", function(){
muton.populateDbList(muton.dbListStart,muton.dbListIncrement);
});
$("#startReplicatePg").live("click", function(){
muton.populateReplicationPg();
$("#replicateErrorMsg").html('');
$("#replicatorEvent").html('');
$("#replicatorEventUL").listview('refresh');
});
$("#butReverse").live("click", function(){
//alert('reverse me');
if (muton.isReverse){
muton.isReverse=false;
$("#fromSlider-label").html("From");
$("#toSlider-label").html("To");
}else{
muton.isReverse=true;
$("#fromSlider-label").html("To");
$("#toSlider-label").html("From");
}
});
$("#butReplicator").live("click", function(){
//alert('@replicate with continuous='+$("#continuous").val());
//must not be blank inputs
//read from
if ($("select#toSlider")[0].selectedIndex){
var to=$("#toRemote").val();
}else{
var to=$("#toLocal").val();
}
if ($("select#fromSlider")[0].selectedIndex){
var from=$("#fromRemote").val();
}else{
var from=$("#fromLocal").val();
}
//check isReverse to see direction
if (muton.isReverse){
var x=to;
to=from;
from=x;
}
//TODO add trim to and from
if (to.length==0 || from.length==0 || to==from){
$("#replicateErrorMsg").html("You must select two databases.");
}
//check continuous - cannot read checkbox, see forum
//alert("to="+to+" and from="+from);
//must be logged in
var url="/_session";
$.getJSON(url, function(data) {
if (muton.isSession(data)){
//alert('clicked anchor id='+this.id)
var errorMsg="";
var url="/_replicate";
var repo={};
repo.source=from;
repo.target=to;
//repo.continuous=false;
if ($("#continuous").attr("checked")){
repo.continuous=true;
}
/*
POST /_replicate HTTP/1.1
{"source":"example-database",
"target":"http://admin:password@127.0.0.1:5984/example-database",
"continuous":true}
*/
$.ajax({
type: 'POST',
dataType: 'json',
contentType: "application/json",
data: JSON.stringify(repo),
url: url,
success: function(sdata){
$("#replicatorEvent").html("<p>"+sdata+"</p>");
$("#replicatorEventUL").listview('refresh');
}
});
$("#replicateErrorMsg").html(errorMsg);
}else{
$("#replicateErrorMsg").html("Admin must be logged in to do this operation.");
}
});
});
$("#butLoginPg").live("click", function(){
//try login in, if not display error
$("#loginErrorMsg").html("");
var x=$.trim($("#password").val());
var y=$.trim($("#username").val());
//if either empty, display error
if (x.length<1 || y.length<1){
$("#loginErrorMsg").html("Username and password required.");
}else{
var url="/_session";
var login={};
login.name=y;
login.password=x;
$.ajax({
type: 'POST',
dataType: 'json',
data: login,
url: url,
failure: function(ldata){
//Error logging in: Name or password is incorrect.
$("#loginErrorMsg").html("Error logging in: "+ldata.reason);
},
success: function(ldata){
if (ldata.ok){
//see if logged in
$('#loginPg').dialog('close');
}else{
//Error logging in: Name or password is incorrect.
$("#loginErrorMsg").html("Error logging in: "+ldata.reason);
}
}
});
}
});
//previous and next for docList
$("#butDocListPrevious").live("click", function(){
muton.docsDescending=true;
var x=muton.docsStart-muton.docsLimit;
if (x>=0) {
muton.docsStart=x;
muton.populateDocsList(muton.dbCurrent);
}
});
$("#butDocListNext").live("click", function(){
//alert('next docList');
muton.docsDescending=false;
var x=muton.docsStart+muton.docsLimit;
if (x<muton.docsMax) {
muton.docsStart=x;
muton.populateDocsList(muton.dbCurrent);
}
});
//previous and next for dbList
$("#butDbListPrevious").live("click", function(){
var x=muton.dbStart-muton.dbLimit;
if (x>=0) {
muton.dbStart=x;
muton.populateDbList();
}
});
$("#butDbListNext").live("click", function(){
//alert('next dbList');
var x=muton.dbStart+muton.dbLimit;
if (x<muton.dbMax) {
muton.dbStart=x;
muton.populateDbList();
}
});
$("#butEditSave").live("click", function(){
//alert('@butEdit Save');
//dirty flag for record, update field in json, close dialog
muton.recordCurrentDirty=true;
var x=$("#editKeyLabel").html();
muton.recordCurrent[x]=$("#editKey").val();
muton.populateFieldsList(muton.recordCurrent);
$.mobile.changePage ($("#docPg"));//close and return to previous page
});
$("#butCompactDb").live("click", function(){
//alert('@butCompactDb db='+muton.dbCurrent);
var url="/"+muton.dbCurrent+"/_compact";
var x=$('.compactClass":checked').val();
//values of database, views, cleanup
if (x=="views"){
alert("Compact Views requires focus on a view!");
}
if (x=="cleanup"){
//url view cleanup POST http://localhost:5984/dbname/_view_cleanup
url="/"+muton.dbCurrent+"/_view_cleanup";
}
if (x!="views"){
$.ajax({
type: 'POST',
dataType: 'json',
url: url,
success: function(){
//TODO repopulate dblist - maybe sould be on show event????
muton.populateDbList(muton.dbListStart,muton.dbListIncrement);
}
});
}
$('#compactPg').dialog('close');
});
$("#butDeleteDb").live("click", function(){
//alert("@butDeleteDb");
var url="/_session";
$.getJSON(url, function(data) {
if (muton.isSession(data)){
var url="/"+muton.dbCurrent;
/*
$.ajax({
type: 'DELETE',
dataType: 'json',
url: url,
success: function(){
//TODO repopulate dblist - maybe sould be on show event????
}
});
*/
$('#dbDeletePg').dialog('close');
}else{
$("#createDbErrorMsg").html("Admin must be logged in to do this operation.");
}
});
});
$("#butNewDoc").live("click", function(){
alert("@butNewDoc");
//get uuid
var url="/_uuids?count=1";
$.ajax({
type: 'get',
dataType: 'json',
url: url,
success: function(){
alert ("uuid="+data.uuids[0]);
}
});
$('#dbDeletePg').dialog('close');
});
//clear interval and set timeout for status page
//muton.statusInterval is interval in seconds
$('#statusPg').live('pagebeforeshow',function(event, ui){
var url="/_session";
$.getJSON(url, function(data) {
if (muton.isSession(data)){
$("#statusErrorMsg").html('');
muton.populateStatus();
muton.status=setInterval(muton.populateStatus,1000*muton.statusInterval);
}else{
$("#statusErrorMsg").html("Admin must be logged in to do this operation.");
}
});
});
$('#statusPg').live('pagehide',function(event, ui){
clearInterval(muton.status);
});
$("#statusPoll").live("change", function(){
var x=parseInt($("#statusPoll").val());
//alert('statusPoll='+x)
if (x!=muton.statusInterval && x>0 & x<10000){
muton.statusInterval=x;
clearInterval(muton.status);
muton.status=setInterval(muton.populateStatus,1000*muton.statusInterval);
}
muton.populateStatus();
});
$("#fromSlider").live("change", function(){
$("#fromLocalDiv").toggle();
$("#fromRemoteDiv").toggle();
});
$("#toSlider").live("change", function(){
$("#toLocalDiv").toggle();
$("#toRemoteDiv").toggle();
});
//change number of rows in display
$('#rowDbPg').live('pageshow',function(event, ui){
//set radio to current muton.dbLimit
$(".rowsDbClass").val([muton.dbLimit]);
//alert('radio = '+ $('.rowsDbClass":checked').val());
$(".rowsDbClass").checkboxradio("refresh");
});
$('#rowDbPg').live('pagehide',function(event, ui){
//read value to radio, if new value redraw page, set muton.dbLimit
var x=$('.rowsDbClass":checked').val();
if (x!=muton.dbLimit){
muton.dbLimit=x;
muton.populateDbList();
}
});
$('#jumpDocInput').live('change',function(event,ui){
var x=$.trim($("#jumpDocInput").val());
if (x.length>0){
//alert('TODO accept input only on enter='+x);
muton.getDoc(x);
$.mobile.changePage ($("#docPg"));
$("#jumpDocInput").val('');
}
});
//action from dialog for creating new database
$("#butCreateDb").live("click", function(){
var url="/_session";
$.getJSON(url, function(data) {
if (muton.isSession(data)){
//alert('clicked anchor id='+this.id)
var errorMsg="";
var x=$.trim($("#newDbName").val());
if (x.length==0){
errorMsg="Please enter a name.";
}else{
//TODO regex to all only legal names (a-z), digits (0-9), or _, $, (, ), +, -, and /
var url="/"+x+"/";
$.ajax({
type: 'PUT',
url: url,
success: function(){
//TODO repopulate dblist - maybe sould be on show event????
muton.populateDbList(muton.dbListStart,muton.dbListIncrement);
$('#createDbPg').dialog('close');
}
});
}
$("#createDbErrorMsg").html(errorMsg);
}else{
$("#createDbErrorMsg").html("Admin must be logged in to do this operation.");
}
});
});