Added quota form/handlers for domain and user
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
% use Mojo::Util qw(dumper);
|
||||
|
||||
% my $u = $c->app->user;
|
||||
% my $quota = 1024*1024;
|
||||
|
||||
<div class="grid-container">
|
||||
<div class="grid-x grid-padding-x">
|
||||
@@ -18,6 +19,12 @@
|
||||
<input type="text" name="domain_name" placeholder="domain.org" required pattern="[_.-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{5,42}"/>
|
||||
<span class="form-error">Mandatory, 5 or more letter</span>
|
||||
</label>
|
||||
|
||||
<label>Domain quota
|
||||
<input type="number" name="quota" value="<%= $quota %>" required pattern="[0-9]{1,15}"/>
|
||||
<span class="form-error">Mandatory, one or more ciphers</span>
|
||||
</label>
|
||||
|
||||
<div class="text-center">
|
||||
<button type="submit" class="button">Accept</button>
|
||||
<a class="button" href="/domain/list">Escape</a>
|
||||
|
||||
@@ -9,13 +9,14 @@
|
||||
% my $u = $c->app->user;
|
||||
% my $name = $c->req->param('domain_name');
|
||||
% my $id = $u->domain_exist($name);
|
||||
% my $quota = $c->req->param('quota') || 0;
|
||||
|
||||
% if ($id) {
|
||||
<div class="callout warning">Domain <%= $name %> already exists</div>
|
||||
% }
|
||||
|
||||
% unless ($id) {
|
||||
% my $res = $u->domain_add($name);
|
||||
% my $res = $u->domain_add($name, $quota);
|
||||
% if ($res) {
|
||||
<div class="callout success">Domain <%= $name %> has been added.</div>
|
||||
% }
|
||||
|
||||
@@ -30,8 +30,10 @@
|
||||
<th>#</th>
|
||||
<th>domain</th>
|
||||
<th><i class="fi-graph-pie"></i></th>
|
||||
<th><i class="fi-alert"></i></th>
|
||||
<th><i class="fi-male"></i></th>
|
||||
<th><i class="fi-male-female"></i></th>
|
||||
<th><i class="fi-address-book"></i></th>
|
||||
<th><i class="fi-pencil"></i></th>
|
||||
<th><i class="fi-trash"></i></th>
|
||||
</tr>
|
||||
@@ -45,12 +47,15 @@
|
||||
% my $id = $row->{id};
|
||||
% my $name = $row->{name};
|
||||
% my $size = $row->{size};
|
||||
% my $quota = $row->{quota};
|
||||
<tr>
|
||||
<td><%= $n %></td>
|
||||
<td><%= $name %></td>
|
||||
<td><%= $size %></td>
|
||||
<td><%= $quota %></td>
|
||||
<td><a href="/user/list?domain_id=<%= $id %>"><%= $u->domain_user_count($id) %></a></td>
|
||||
<td><a href="/alias/list?domain_id=<%= $id %>"><%= $u->domain_alias_count($id) %></a></td>
|
||||
<td><a href="/domain/rename/form?domain_id=<%= $id %>"><i class="fi-address-book"></i></a></td>
|
||||
<td><a href="/domain/update/form?domain_id=<%= $id %>"><i class="fi-pencil"></i></a></td>
|
||||
<td><a href="/domain/delete/form?domain_id=<%= $id %>"><i class="fi-trash"></i></a></td>
|
||||
</tr>
|
||||
|
||||
44
templs/domain-rename-form.html.ep
Normal file
44
templs/domain-rename-form.html.ep
Normal file
@@ -0,0 +1,44 @@
|
||||
%#
|
||||
%# $Id$
|
||||
%#
|
||||
% layout 'default';
|
||||
% title 'Maacom';
|
||||
|
||||
% use Mojo::Util qw(dumper);
|
||||
|
||||
% my $u = $c->app->user;
|
||||
|
||||
% my $domain_id = $c->req->param('domain_id') || 0;
|
||||
% my $profile = $u->domain_profile($domain_id);
|
||||
|
||||
% if ($profile) {
|
||||
% my $domain_name = $profile->{name};
|
||||
|
||||
<div class="grid-container">
|
||||
<div class="grid-x grid-padding-x">
|
||||
<div class="medium-6 medium-centered cell">
|
||||
|
||||
<form accept-charset="UTF-8" action="/domain/rename/handler" method="post" data-abide novalidate>
|
||||
<h5 class="text-center">Edit domain</h5>
|
||||
<input type="hidden" name="domain_id" value="<%= $domain_id %>"/>
|
||||
<label>Domain name
|
||||
<input type="text" value="<%= $domain_name %>" name="domain_name" required pattern="[_.-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{5,42}"/>
|
||||
<span class="form-error">Mandatory, 5 or more letter</span>
|
||||
</label>
|
||||
<div class="text-center">
|
||||
<button type="submit" class="button">Accept</button>
|
||||
<a class="button" href="/domain/list">Escape</a>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
% }
|
||||
|
||||
% unless ($profile) {
|
||||
<div class="callout warning">Domain with id <%= $domain_id %> not exist</div>
|
||||
% }
|
||||
|
||||
|
||||
%#EOF
|
||||
42
templs/domain-rename-handler.html.ep
Normal file
42
templs/domain-rename-handler.html.ep
Normal file
@@ -0,0 +1,42 @@
|
||||
%#
|
||||
%# $Id$
|
||||
%#
|
||||
% layout 'default';
|
||||
% title 'Maacom';
|
||||
|
||||
% use Mojo::Util qw(dumper);
|
||||
|
||||
% my $u = $c->app->user;
|
||||
|
||||
% my $new_name = $c->req->param('domain_name');
|
||||
% my $domain_id = $c->req->param('domain_id') || 0;
|
||||
% my $profile = $u->domain_profile($domain_id);
|
||||
|
||||
% if ($profile) {
|
||||
% my $name = $profile->{name};
|
||||
% my $cid = $u->domain_exist($new_name);
|
||||
% if ($cid) {
|
||||
<div class="callout warning">Domain <%= $new_name %> already exists, domain name <%= $name %> was not changed.</div>
|
||||
% }
|
||||
|
||||
% unless ($cid) {
|
||||
% my $res = $u->domain_update($domain_id, name => $new_name);
|
||||
% if ($res) {
|
||||
<div class="callout success">Domain <%= $name %> has been renamed to <%= $new_name %>.</div>
|
||||
% }
|
||||
|
||||
% unless ($res) {
|
||||
<div class="callout alert">Domain <%= $name %> was not updated.</div>
|
||||
% }
|
||||
% }
|
||||
% }
|
||||
|
||||
% unless ($profile) {
|
||||
<div class="callout warning">Domain with id <%= $domain_id %> not exist</div>
|
||||
% }
|
||||
|
||||
%#EOF
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
% if ($profile) {
|
||||
% my $domain_name = $profile->{name};
|
||||
% my $quota = $profile->{quota} || 0;
|
||||
|
||||
<div class="grid-container">
|
||||
<div class="grid-x grid-padding-x">
|
||||
@@ -21,9 +22,9 @@
|
||||
<form accept-charset="UTF-8" action="/domain/update/handler" method="post" data-abide novalidate>
|
||||
<h5 class="text-center">Edit domain</h5>
|
||||
<input type="hidden" name="domain_id" value="<%= $domain_id %>"/>
|
||||
<label>Domain name
|
||||
<input type="text" value="<%= $domain_name %>" name="domain_name" required pattern="[_.-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{5,42}"/>
|
||||
<span class="form-error">Mandatory, 5 or more letter</span>
|
||||
<label>Quota
|
||||
<input type="number" name="quota" value="<%= $quota %>" required pattern="[0-9]{1,15}"/>
|
||||
<span class="form-error">Mandatory, one or more ciphers</span>
|
||||
</label>
|
||||
<div class="text-center">
|
||||
<button type="submit" class="button">Accept</button>
|
||||
|
||||
@@ -8,25 +8,19 @@
|
||||
|
||||
% my $u = $c->app->user;
|
||||
|
||||
% my $name = $c->req->param('domain_name');
|
||||
% my $domain_id = $c->req->param('domain_id') || 0;
|
||||
% my $profile = $u->domain_profile($domain_id);
|
||||
% my $quota = $c->req->param('quota') || $profile->{quota};
|
||||
|
||||
% if ($profile) {
|
||||
% my $cid = $u->domain_exist($name);
|
||||
% if ($cid) {
|
||||
<div class="callout warning">Domain <%= $name %> already exists</div>
|
||||
% my $name = $profile->{name};
|
||||
% my $res = $u->domain_update($domain_id, quota => $quota);
|
||||
% if ($res) {
|
||||
<div class="callout success">Domain <%= $name %> has been updated.</div>
|
||||
% }
|
||||
|
||||
% unless ($cid) {
|
||||
% my $res = $u->domain_update($domain_id, name => $name);
|
||||
% if ($res) {
|
||||
<div class="callout success">Domain <%= $name %> has been updated.</div>
|
||||
% }
|
||||
|
||||
% unless ($res) {
|
||||
<div class="callout alert">Domain <%= $name %> was not updated.</div>
|
||||
% }
|
||||
% unless ($res) {
|
||||
<div class="callout alert">Domain <%= $name %> was not updated.</div>
|
||||
% }
|
||||
% }
|
||||
|
||||
|
||||
@@ -9,11 +9,11 @@
|
||||
% my $u = $c->app->user;
|
||||
|
||||
% my $domain_id = $c->req->param('domain_id');
|
||||
% my $quota = 1024*10;
|
||||
|
||||
% if ($domain_id) {
|
||||
% my $profile = $u->domain_profile($domain_id);
|
||||
% my $domain_name = $profile->{name};
|
||||
% my $quota = 1024*1024*1024*10;
|
||||
<div class="grid-container">
|
||||
<div class="grid-x grid-padding-x">
|
||||
<div class="medium-6 medium-centered cell">
|
||||
@@ -70,6 +70,10 @@
|
||||
% }
|
||||
</select >
|
||||
</label>
|
||||
<label>Quota
|
||||
<input type="number" name="quota" value="<%= $quota %>" required pattern="[0-9]{1,15}"/>
|
||||
<span class="form-error">Mandatory, one or more ciphers</span>
|
||||
</label>
|
||||
|
||||
<div class="text-center">
|
||||
<button type="submit" class="button">Accept</button>
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
<th>#</th>
|
||||
<th>address</th>
|
||||
<th><i class="fi-graph-pie"></i></th>
|
||||
<th><i class="fi-alert"></i></th>
|
||||
<th><i class="fi-address-book"></i></th>
|
||||
<th><i class="fi-pencil"></i></th>
|
||||
<th><i class="fi-trash"></i></th>
|
||||
@@ -42,10 +43,12 @@
|
||||
% my $user_id = $row->{id};
|
||||
% my $domain_id = $row->{domain_id};
|
||||
% my $size = $row->{size} || 0;
|
||||
% my $quota = $row->{quota} || 0;
|
||||
<tr>
|
||||
<td><%= $n %></td>
|
||||
<td><%= $address %></td>
|
||||
<td><%= $size %></td>
|
||||
<td><%= $quota %></td>
|
||||
<td><a href="/user/rename/form?user_id=<%= $user_id %>"><i class="fi-address-book"></i></a></td>
|
||||
<td><a href="/user/update/form?user_id=<%= $user_id %>"><i class="fi-pencil"></i></a></td>
|
||||
<td><a href="/user/delete/form?user_id=<%= $user_id %>"><i class="fi-trash"></i></a></td>
|
||||
@@ -72,6 +75,7 @@
|
||||
<th>#</th>
|
||||
<th>address</th>
|
||||
<th><i class="fi-graph-pie"></i></th>
|
||||
<th><i class="fi-alert"></i></th>
|
||||
<th><i class="fi-at-sign"></i></th>
|
||||
<th><i class="fi-address-book"></i></th>
|
||||
<th><i class="fi-pencil"></i></th>
|
||||
@@ -87,10 +91,12 @@
|
||||
% my $user_id = $row->{id};
|
||||
% my $domain_id = $row->{domain_id};
|
||||
% my $size = $row->{size} || 0;
|
||||
% my $quota = $row->{quota} || 0;
|
||||
<tr>
|
||||
<td><%= $n %></td>
|
||||
<td><%= $address %></td>
|
||||
<td><%= $size %></td>
|
||||
<td><%= $quota %></td>
|
||||
<td><a href="/user/list?domain_id=<%= $domain_id %>"><i class="fi-at-sign"></i></a></td>
|
||||
<td><a href="/user/rename/form?user_id=<%= $user_id %>"><i class="fi-address-book"></i></a></td>
|
||||
<td><a href="/user/update/form?user_id=<%= $user_id %>"><i class="fi-pencil"></i></a></td>
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
% my $domain_id = $profile->{domain_id};
|
||||
% my $password = $profile->{password};
|
||||
% my $address = $profile->{address};
|
||||
% my $quota = $profile->{quota};
|
||||
|
||||
<div class="grid-container">
|
||||
<div class="grid-x grid-padding-x">
|
||||
@@ -29,6 +30,11 @@
|
||||
<input type="text" value="<%= $password %>" name="password" required pattern="[_.-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{6,42}"/>
|
||||
<span class="form-error">Mandatory, 6 or more letter</span>
|
||||
</label>
|
||||
<label>Quota
|
||||
<input type="number" name="quota" value="<%= $quota %>" required pattern="[0-9]{1,15}"/>
|
||||
<span class="form-error">Mandatory, one or more ciphers</span>
|
||||
</label>
|
||||
|
||||
<div class="text-center">
|
||||
<button type="submit" class="button">Accept</button>
|
||||
<a class="button" href="/user/list?">Escape</a>
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
% my $user_id = $c->req->param('user_id') || 0;
|
||||
% my $password = $c->req->param('password');
|
||||
% my $quota = $c->req->param('quota');
|
||||
|
||||
% my $profile = $u->user_profile($user_id);
|
||||
|
||||
@@ -17,8 +18,9 @@
|
||||
% my $domain_id = $profile->{domain_id};
|
||||
% my $domain_name = $profile->{domain_name};
|
||||
% my $address = $profile->{address};
|
||||
% my $quota = $quota || $profile->{quota};
|
||||
|
||||
% my $res = $u->user_update($user_id, password => $password);
|
||||
% my $res = $u->user_update($user_id, password => $password, quota => $quota);
|
||||
% if ($res) {
|
||||
<div class="callout success">User <%= $address %> has been updated.</div>
|
||||
% }
|
||||
|
||||
Reference in New Issue
Block a user