From e959b27efb5796e150fec777511a0b1c9e504b7a Mon Sep 17 00:00:00 2001 From: ziggi Date: Fri, 15 Dec 2017 02:03:39 +0200 Subject: [PATCH] Added quota form/handlers for domain and user --- templs/domain-add-form.html.ep | 7 +++++ templs/domain-add-handler.html.ep | 3 +- templs/domain-list.html.ep | 5 ++++ templs/domain-rename-form.html.ep | 44 ++++++++++++++++++++++++++++ templs/domain-rename-handler.html.ep | 42 ++++++++++++++++++++++++++ templs/domain-update-form.html.ep | 7 +++-- templs/domain-update-handler.html.ep | 20 +++++-------- templs/user-add-form.html.ep | 6 +++- templs/user-list.html.ep | 6 ++++ templs/user-update-form.html.ep | 6 ++++ templs/user-update-handler.html.ep | 4 ++- 11 files changed, 131 insertions(+), 19 deletions(-) create mode 100644 templs/domain-rename-form.html.ep create mode 100644 templs/domain-rename-handler.html.ep diff --git a/templs/domain-add-form.html.ep b/templs/domain-add-form.html.ep index a88224b..09939a2 100644 --- a/templs/domain-add-form.html.ep +++ b/templs/domain-add-form.html.ep @@ -7,6 +7,7 @@ % use Mojo::Util qw(dumper); % my $u = $c->app->user; +% my $quota = 1024*1024;
@@ -18,6 +19,12 @@ Mandatory, 5 or more letter + + +
Escape diff --git a/templs/domain-add-handler.html.ep b/templs/domain-add-handler.html.ep index 5189a19..bdd24e0 100644 --- a/templs/domain-add-handler.html.ep +++ b/templs/domain-add-handler.html.ep @@ -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) {
Domain <%= $name %> already exists
% } % unless ($id) { - % my $res = $u->domain_add($name); + % my $res = $u->domain_add($name, $quota); % if ($res) {
Domain <%= $name %> has been added.
% } diff --git a/templs/domain-list.html.ep b/templs/domain-list.html.ep index 955e61f..43934cb 100644 --- a/templs/domain-list.html.ep +++ b/templs/domain-list.html.ep @@ -30,8 +30,10 @@ # domain + + @@ -45,12 +47,15 @@ % my $id = $row->{id}; % my $name = $row->{name}; % my $size = $row->{size}; + % my $quota = $row->{quota}; <%= $n %> <%= $name %> <%= $size %> + <%= $quota %> <%= $u->domain_user_count($id) %> <%= $u->domain_alias_count($id) %> + diff --git a/templs/domain-rename-form.html.ep b/templs/domain-rename-form.html.ep new file mode 100644 index 0000000..c4034ba --- /dev/null +++ b/templs/domain-rename-form.html.ep @@ -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}; + +
+
+
+ +
+
Edit domain
+ + +
+ + Escape +
+
+ +
+
+
+% } + +% unless ($profile) { +
Domain with id <%= $domain_id %> not exist
+% } + + +%#EOF diff --git a/templs/domain-rename-handler.html.ep b/templs/domain-rename-handler.html.ep new file mode 100644 index 0000000..b31d9d4 --- /dev/null +++ b/templs/domain-rename-handler.html.ep @@ -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) { +
Domain <%= $new_name %> already exists, domain name <%= $name %> was not changed.
+ % } + + % unless ($cid) { + % my $res = $u->domain_update($domain_id, name => $new_name); + % if ($res) { +
Domain <%= $name %> has been renamed to <%= $new_name %>.
+ % } + + % unless ($res) { +
Domain <%= $name %> was not updated.
+ % } + % } +% } + +% unless ($profile) { +
Domain with id <%= $domain_id %> not exist
+% } + +%#EOF + + + + diff --git a/templs/domain-update-form.html.ep b/templs/domain-update-form.html.ep index bf2c866..e87c220 100644 --- a/templs/domain-update-form.html.ep +++ b/templs/domain-update-form.html.ep @@ -13,6 +13,7 @@ % if ($profile) { % my $domain_name = $profile->{name}; + % my $quota = $profile->{quota} || 0;
@@ -21,9 +22,9 @@
Edit domain
-