diff --git a/assets/javascripts/admintable.js b/assets/javascripts/admintable.js index 6ddcd56f..2fc05b22 100644 --- a/assets/javascripts/admintable.js +++ b/assets/javascripts/admintable.js @@ -325,7 +325,11 @@ function renderAdminTableActions(data, type, row, meta) { return ''; } var url = $("#admintable_api_url").val(); - res = ''; + var noActions = document.getElementById("regionmirrorproviderpanel"); + var res = ''; + if (! noActions ) { + res = ''; + } if (url == '/rest/server' && data) { return res + ''; } else { diff --git a/lib/MirrorCache/WebAPI/Controller/App/Myserver.pm b/lib/MirrorCache/WebAPI/Controller/App/Myserver.pm index df733000..3309ae40 100644 --- a/lib/MirrorCache/WebAPI/Controller/App/Myserver.pm +++ b/lib/MirrorCache/WebAPI/Controller/App/Myserver.pm @@ -17,7 +17,17 @@ package MirrorCache::WebAPI::Controller::App::Myserver; use Mojo::Base 'MirrorCache::WebAPI::Controller::App::Table'; sub index { - shift->SUPER::admintable('myserver'); + my $c = shift; + my $mirror_provider = $c->mcconfig->mirror_provider; + if (my $url = $c->mcconfig->mirror_provider) { + $url =~ s!^https?://(?:www\.)?!!i; + $url =~ s!/.*!!; + $url =~ s/[\?\#\:].*//; + my $mirror_provider_url = 'https://' . $url . '/app/server'; + $c->stash( mirror_provider_url => $mirror_provider_url ); + } + + $c->SUPER::admintable('myserver'); } sub update { diff --git a/lib/MirrorCache/WebAPI/Controller/App/Server.pm b/lib/MirrorCache/WebAPI/Controller/App/Server.pm index c85214c5..8a722d29 100644 --- a/lib/MirrorCache/WebAPI/Controller/App/Server.pm +++ b/lib/MirrorCache/WebAPI/Controller/App/Server.pm @@ -17,7 +17,17 @@ package MirrorCache::WebAPI::Controller::App::Server; use Mojo::Base 'MirrorCache::WebAPI::Controller::App::Table'; sub index { - shift->SUPER::admintable('server'); + my $c = shift; + my $mirror_provider = $c->mcconfig->mirror_provider; + if (my $url = $c->mcconfig->mirror_provider) { + $url =~ s!^https?://(?:www\.)?!!i; + $url =~ s!/.*!!; + $url =~ s/[\?\#\:].*//; + my $mirror_provider_url = 'https://' . $url . '/app/server'; + $c->stash( mirror_provider_url => $mirror_provider_url ); + } + + $c->SUPER::admintable('server'); } sub update { diff --git a/t/environ/01-smoke-mirror-provider.sh b/t/environ/01-smoke-mirror-provider.sh index 6ee61b92..851f6081 100755 --- a/t/environ/01-smoke-mirror-provider.sh +++ b/t/environ/01-smoke-mirror-provider.sh @@ -8,9 +8,6 @@ mcnaeast=$(environ mc2 $(pwd)) ap8=$(environ ap8) ap7=$(environ ap7) -$mcmirror/gen_env MIRRORCACHE_MODE=mirror_provider - - $mcmirror/start $mcmirror/sql "insert into server(hostname,urldir,enabled,country,region) select '$($ap7/print_address)','','t','us','na'" diff --git a/templates/app/myserver/index.html.ep b/templates/app/myserver/index.html.ep index f8fbf336..9123d88b 100644 --- a/templates/app/myserver/index.html.ep +++ b/templates/app/myserver/index.html.ep @@ -17,6 +17,11 @@ %= include 'layouts/info' + % if (eval ('$mirror_provider_url')) { +
+ This view is readonly, it is imported from >mirror provider +
+ % } @@ -38,7 +43,7 @@
- % if (current_user) { + % if (current_user && !eval('$mirror_provider_url')) {
diff --git a/templates/app/server/index.html.ep b/templates/app/server/index.html.ep index daec1daf..51abb4ba 100644 --- a/templates/app/server/index.html.ep +++ b/templates/app/server/index.html.ep @@ -17,6 +17,11 @@ %= include 'layouts/info' + % if (eval ('$mirror_provider_url')) { +
+ This view is readonly, it is imported from >mirror provider +
+ % } @@ -38,7 +43,7 @@
- % if (is_admin) { + % if (is_admin && !eval('$mirror_provider_url')) {