Skip to content

Commit

Permalink
Add default_frontend to status and a link in UI
Browse files Browse the repository at this point in the history
  • Loading branch information
tailhook committed Apr 23, 2018
1 parent 10ca149 commit 422705e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions doc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Verwalter 0.11.3

* Feature: Added exerimental route ``/v1/leader-redirect-by-node-name/`` that
returns redirect to a leader node
* Feature: Add a link to default frontend "common" frontend


.. _changelog-0.11.2:
Expand Down
4 changes: 4 additions & 0 deletions frontend/main.khufu
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ view _navbar(status, frontend_version, @expert_mode, router):
<div.dropdown-menu>
metrics.expanded(status)

if status.default_frontend != 'common':
<li>
<a href=`/~${status.default_frontend}/`>
<span.glyphicon.glyphicon-new-window>
if status and status.errors:
<li.text-danger
title=format_error_hint(status)>
Expand Down
8 changes: 6 additions & 2 deletions src/daemon/frontend/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use fetch;
use frontend::error_page::{error_page};
use frontend::routing::{ApiRoute, Format};
use frontend::to_json::ToJson;
use frontend::{reply, read_json};
use frontend::{Config, reply, read_json};
use id::Id;
use shared::{SharedState, PushActionError};

Expand Down Expand Up @@ -147,11 +147,13 @@ pub fn respond_204<S>(mut e: Encoder<S>)
ok(e.done())
}

pub fn serve<S: 'static>(state: &SharedState, route: &ApiRoute, format: Format)
pub fn serve<S: 'static>(state: &SharedState, config: &Arc<Config>,
route: &ApiRoute, format: Format)
-> Result<Request<S>, Error>
{
use self::ApiRoute::*;
let state = state.clone();
let config = config.clone();
match *route {
Status => {
Ok(reply(move |e| {
Expand Down Expand Up @@ -187,6 +189,7 @@ pub fn serve<S: 'static>(state: &SharedState, route: &ApiRoute, format: Format)
election_state: &'a Arc<ElectionState>,
schedule_id: Option<&'a String>,
schedule_status: &'a str,
default_frontend: &'a str,
}
let peers = state.peers();
let election = state.election();
Expand Down Expand Up @@ -264,6 +267,7 @@ pub fn serve<S: 'static>(state: &SharedState, route: &ApiRoute, format: Format)
election_state: &election,
schedule_id: stable_schedule.as_ref().map(|x| &x.hash),
schedule_status: status,
default_frontend: &config.default_frontend,
}))
}))
}
Expand Down
2 changes: 1 addition & 1 deletion src/daemon/frontend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl<S: AsyncWrite + Send + 'static> DispatcherTrait<S> for Dispatcher {
disk::serve_backup(name, headers, &self.config.schedule_dir)
}
Api(ref route, fmt) => {
api::serve(&self.state, route, fmt)
api::serve(&self.state, &self.config, route, fmt)
}
Log(ref route) => {
log::serve(headers, &self.state, route)
Expand Down

0 comments on commit 422705e

Please sign in to comment.