Skip to content

Commit

Permalink
API & UI relative paths
Browse files Browse the repository at this point in the history
This allows to work behind a http proxy
  • Loading branch information
Victor Castell committed Nov 16, 2015
1 parent e04f9e4 commit 0f18a4a
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 25 deletions.
5 changes: 4 additions & 1 deletion dkron/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
const (
tmplPath = "templates"
dashboardPathPrefix = "dashboard"
apiPathPrefix = "v1"
)

type commonDashboardData struct {
Expand All @@ -20,6 +21,7 @@ type commonDashboardData struct {
MemberName string
Backend string
Path string
APIPath string
}

func newCommonDashboardData(a *AgentCommand, nodeName, path string) *commonDashboardData {
Expand All @@ -29,7 +31,8 @@ func newCommonDashboardData(a *AgentCommand, nodeName, path string) *commonDashb
LeaderName: l.Name,
MemberName: nodeName,
Backend: a.config.Backend,
Path: fmt.Sprintf("%s/%s", dashboardPathPrefix, path),
Path: fmt.Sprintf("%s%s", path, dashboardPathPrefix),
APIPath: fmt.Sprintf("%s%s", path, apiPathPrefix),
}
}

Expand Down
12 changes: 6 additions & 6 deletions static/js/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ var dkron = angular.module('dkron', ['angular-rickshaw']);

dkron.controller('JobListCtrl', function ($scope, $http, $interval) {
$scope.click = function(jobName) {
var response = $http.put('/v1/jobs/' + jobName);
var response = $http.put(DKRON_API_PATH + '/jobs/' + jobName);
response.success(function(data, status, headers, config) {
$('#message').html('<div class="alert alert-success fade in"><button type="button" class="close close-alert" data-dismiss="alert" aria-hidden="true">x</button>Success running jo ' + jobName + '</div>');
$('#message').html('<div class="alert alert-success fade in"><button type="button" class="close close-alert" data-dismiss="alert" aria-hidden="true">x</button>Success running job ' + jobName + '</div>');
});

response.error(function(data, status, headers, config) {
$('#message').html('<div class="alert alert-danger fade in"><button type="button" class="close close-alert" data-dismiss="alert" aria-hidden="true">x</button>Error running jo ' + jobName + '</div>');
$('#message').html('<div class="alert alert-danger fade in"><button type="button" class="close close-alert" data-dismiss="alert" aria-hidden="true">x</button>Error running job ' + jobName + '</div>');
});
};

var updateView = function() {
var response = $http.get('/v1/jobs/');
var response = $http.get(DKRON_API_PATH + '/jobs');
response.success(function(data, status, headers, config) {
$scope.updateStatus(data);
});
Expand Down Expand Up @@ -97,7 +97,7 @@ dkron.controller('IndexCtrl', function ($scope, $http, $interval, $element) {
};

updateView = function() {
var response = $http.get('/v1/jobs/');
var response = $http.get(DKRON_API_PATH + '/jobs');
response.success(function(data, status, headers, config) {
$scope.updateGraph(data);
});
Expand All @@ -106,7 +106,7 @@ dkron.controller('IndexCtrl', function ($scope, $http, $interval, $element) {
$('#message').html('<div class="alert alert-danger fade in"><button type="button" class="close close-alert" data-dismiss="alert" aria-hidden="true">x</button>Error getting data</div>');
});

var mq = $http.get('/v1/members/');
var mq = $http.get(DKRON_API_PATH + '/members');
mq.success(function(data, status, headers, config) {
$scope.members = data;
});
Expand Down
30 changes: 17 additions & 13 deletions templates/dashboard.html.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,26 @@
<head>
<title>Dkron</title>

<link rel="stylesheet" href="{{ .Common.Path }}css/bootstrap-custom.min.css">
<link rel="stylesheet" href="{{ .Common.Path }}css/font-awesome.css">
<link rel="stylesheet" href="{{ .Common.Path }}css/app.css">
<link rel="stylesheet" href="{{ .Common.Path }}/css/bootstrap-custom.min.css">
<link rel="stylesheet" href="{{ .Common.Path }}/css/font-awesome.css">
<link rel="stylesheet" href="{{ .Common.Path }}/css/app.css">

<script src="{{ .Common.Path }}bower_components/angular/angular.js"></script>
<script src="{{ .Common.Path }}bower_components/angular-route/angular-route.js"></script>
<script src="{{ .Common.Path }}js/dashboard.js"></script>
<script src="{{ .Common.Path }}/bower_components/angular/angular.js"></script>
<script src="{{ .Common.Path }}/bower_components/angular-route/angular-route.js"></script>
<script src="{{ .Common.Path }}/js/dashboard.js"></script>

<script src="{{ .Common.Path }}jquery/jquery-2.1.3.min.js"></script>
<script src="{{ .Common.Path }}js/bootstrap.min.js"></script>
<script src="{{ .Common.Path }}/jquery/jquery-2.1.3.min.js"></script>
<script src="{{ .Common.Path }}/js/bootstrap.min.js"></script>

<link rel="stylesheet" href="{{ .Common.Path }}bower_components/rickshaw/rickshaw.min.css">
<link rel="stylesheet" href="{{ .Common.Path }}/bower_components/rickshaw/rickshaw.min.css">

<script src="{{ .Common.Path }}bower_components/d3/d3.min.js"></script>
<script src="{{ .Common.Path }}bower_components/rickshaw/rickshaw.min.js"></script>
<script src="{{ .Common.Path }}bower_components/angular-rickshaw/rickshaw.js"></script>
<script src="{{ .Common.Path }}/bower_components/d3/d3.min.js"></script>
<script src="{{ .Common.Path }}/bower_components/rickshaw/rickshaw.min.js"></script>
<script src="{{ .Common.Path }}/bower_components/angular-rickshaw/rickshaw.js"></script>

<script>
var DKRON_API_PATH = "{{ .Common.APIPath }}";
</script>
</head>

<body>
Expand Down Expand Up @@ -51,7 +55,7 @@
</a>
</li>
<li>
<a href="{{ .Common.Path }}jobs">
<a href="{{ .Common.Path }}/jobs">
<i class="fa fa-clock-o fa-lg"></i>
Jobs
</a>
Expand Down
4 changes: 0 additions & 4 deletions templates/index.html.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,5 @@
</tr>
</table>
</div>

<div class="row">
<h2>Backend: {{ .Common.Backend }}</h2>
</div>
</div>
{{end}}
2 changes: 1 addition & 1 deletion templates/jobs.html.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</tr>
{{ range $job := .Jobs }}
<tr>
<td><a href="{{ .Common.Path }}jobs/{{$job.Name}}/executions">{{ $job.Name }}</a></td>
<td><a href="jobs/{{$job.Name}}/executions">{{ $job.Name }}</a></td>
<td>{{ $job.SuccessCount }}</td>
<td>{{ $job.ErrorCount }}</td>
<td>
Expand Down

0 comments on commit 0f18a4a

Please sign in to comment.