Commit 2a05d668 authored by fv3rdugo's avatar fv3rdugo
Browse files

Form save data in db

parent 6792ed88
......@@ -47,12 +47,15 @@ sub BUILD {
my $name = $_[0]->{name};
my $address = $_[0]->{address};
my $description = $_[0]->{description};
my $all_domains = $_[0]->{all_domains} ? 1 : 0;
my $no_domains = $_[0]->{no_domains} ? 1: 0;
$name = "" unless defined $name;
_init_connector();
if ( $name ne '' ) {
my $row = $self -> _select_net_db( $name, $address, $description);
my $row = $self -> _select_net_db( $name, $address, $description, $all_domains, $no_domains );
};
}
=head2 allowed
......@@ -160,13 +163,15 @@ sub _insert_net_db {
my $name = shift;
my $address = shift;
my $description = shift;
my $all_domains = shift;
my $no_domains = shift;
my $sth = $$CONNECTOR->dbh->prepare(
"INSERT INTO networks (name, address, description) "
." VALUES(?,?,?)"
"INSERT INTO networks (name, address, description, all_domains, no_domains) "
." VALUES(?,?,?,?,?)"
);
$sth->execute($name,$address,$description);
$sth->execute($name,$address,$description,$all_domains,$no_domains);
$sth->finish;
return $self->_do_select_net_db( $name); ;
}
......
......@@ -190,9 +190,23 @@ any '/admin/networks' => sub {
my $c = shift;
push @{$c->stash->{css}}, '/css/admin.css';
push @{$c->stash->{js}}, '/js/admin.js';
$c->render(template => 'main/networks');
networks($c);
};
sub networks {
my $c = shift;
if ($c->param('name') && $c->param('address') ) {
Ravada::Network->new(
name => $c->param('name'),
address => $c->param('address'),
description => $c->param('description'),
all_domains => $c->param('all_domains'),
no_domains => $c->param('no_domains') )
}
$c->render(template => 'main/networks');
}
any '/admin/(#type)' => sub {
my $c = shift;
......
......@@ -15,18 +15,18 @@
<fieldset>
<div class="pure-control-group">
<label>Name</label>
<input name="net_name" ng-model="network.name" type="text" placeholder="insert a network name" required>
<div class="field-message" ng-messages="frm.net_name.$error" ng-if='frm.net_name.$dirty' ng-cloak>
<label>Name*</label>
<input name="name" id='name' type="text" placeholder="insert a network name" required >
<div class="field-message" ng-messages="frm.name.$error" ng-if='frm.name.$dirty' ng-cloak>
<div ng-message="required">Network name is required</div>
</div>
</div>
<div class="pure-control-group">
<label>Network</label>
<label>Network*</label>
<!--<input name="network" ng-model="net.address" type="text" placeholder="i.e. 192.168.10.0/24" required ng-minlength="6" ng-maxlength="10"> -->
<input name="network" ng-model="net.address" type="text" placeholder="i.e. 192.168.10.0/24" required >
<div class="field-message" ng-messages="frm.network.$error" ng-if='frm.network.$dirty' ng-cloak>
<input name="address" id='address' type="text" placeholder="i.e. 192.168.10.0/24" required >
<div class="field-message" ng-messages="frm.address.$error" ng-if='frm.address.$dirty' ng-cloak>
<div ng-message="required">Network address is required</div>
<div ng-message="minlength">TODO Network address must have minimum 6 characters</div>
<div ng-message="maxlength">TODO Password must have maximum 10 characters</div>
......@@ -35,27 +35,27 @@
<div class="pure-control-group">
<label>Description</label>
<input name="description" ng-model="net.description" type="text" placeholder="info about this network" >
<input name="description" id='description' type="text" placeholder="info about this network" >
<div class="field-message" ng-messages="frm.description.$error" ng-if='frm.description.$dirty' ng-cloak>
</div>
</div>
<div class="pure-control-group">
<label class="pure-checkbox">
<input name="all_domains" ng-model="alldomains" type="checkbox">
<input name="all_domains" id='all_domains' type="checkbox" value="1">
Enable for all domains
</label>
</div>
<div class="pure-control-group">
<label class="pure-checkbox">
<input name="no_domains" ng-model="nodomains" type="checkbox">
<input name="no_domains" id='no_domains' type="checkbox" value="1" >
Disable for all domains
</label>
</div>
<div class="pure-controls">
<input type="submit" class="pure-button pure-button-primary"
<input type="submit" class="pure-button pure-button-primary" value="Submit"
ng-disabled="frm.$invalid" ></input>
</div>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment