Handle hostnames with upper-case letters
[webmin.git] / bacula-backup / edit_device.cgi
1 #!/usr/local/bin/perl
2 # Show the details of one device device
3
4 require './bacula-backup-lib.pl';
5 &ReadParse();
6 $conf = &get_storage_config();
7 @devices = &find("Device", $conf);
8
9 if ($in{'new'}) {
10         &ui_print_header(undef, $text{'device_title1'}, "");
11         $mems = [ { 'name' => 'Media Type',
12                     'value' => 'File' },
13                   { 'name' => 'LabelMedia',
14                     'value' => 'yes' },
15                   { 'name' => 'Random Access',
16                     'value' => 'yes' },
17                   { 'name' => 'AutomaticMount',
18                     'value' => 'yes' },
19                   { 'name' => 'RemovableMedia',
20                     'value' => 'no' },
21                   { 'name' => 'AlwaysOpen',
22                     'value' => 'no' },
23                 ];
24         $device = { 'members' => $mems };
25         }
26 else {
27         &ui_print_header(undef, $text{'device_title2'}, "");
28         $device = &find_by("Name", $in{'name'}, \@devices);
29         $device || &error($text{'device_egone'});
30         $mems = $device->{'members'};
31         }
32
33 # Show details
34 print &ui_form_start("save_device.cgi", "post");
35 print &ui_hidden("new", $in{'new'}),"\n";
36 print &ui_hidden("old", $in{'name'}),"\n";
37 print &ui_table_start($text{'device_header'}, "width=100%", 4);
38
39 # Device name
40 print &ui_table_row($text{'device_name'},
41         &ui_textbox("name", $name=&find_value("Name", $mems), 40), 3);
42
43 # Archive device or file
44 print &ui_table_row($text{'device_device'},
45         &ui_textbox("device", $device=&find_value("Archive Device", $mems), 40)." ".
46         &file_chooser_button("device", 0), 3);
47
48 # Media type
49 print &ui_table_row($text{'device_media'},
50         &ui_textbox("media", $media=&find_value("Media Type", $mems), 20));
51
52 # Various yes/no options
53 print &ui_table_row($text{'device_label'},
54         &bacula_yesno("label", "LabelMedia", $mems));
55 print &ui_table_row($text{'device_random'},
56         &bacula_yesno("random", "Random Access", $mems));
57 print &ui_table_row($text{'device_auto'},
58         &bacula_yesno("auto", "AutomaticMount", $mems));
59 print &ui_table_row($text{'device_removable'},
60         &bacula_yesno("removable", "RemovableMedia", $mems));
61 print &ui_table_row($text{'device_always'},
62         &bacula_yesno("always", "AlwaysOpen", $mems));
63
64 # All done
65 print &ui_table_end();
66 if ($in{'new'}) {
67         print &ui_form_end([ [ "create", $text{'create'} ] ]);
68         }
69 else {
70         print &ui_form_end([ [ "save", $text{'save'} ],
71                              [ "delete", $text{'delete'} ] ]);
72         }
73 &ui_print_footer("list_devices.cgi", $text{'devices_return'});
74