-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
332 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#copy-button { | ||
cursor: pointer; | ||
} | ||
|
||
#clone-url { | ||
cursor: text; | ||
} | ||
|
||
.table-center { | ||
display: table-cell; | ||
vertical-align: middle; | ||
text-align: center; | ||
} | ||
|
||
.stat-title { | ||
color: #999; | ||
font-size: 14px; | ||
font-variant: small-caps; | ||
} | ||
|
||
.stat-value { | ||
font-size: 21px; | ||
} | ||
|
||
.commit { | ||
padding: 5px; | ||
margin-left: 20px; | ||
} | ||
|
||
.commit-id { | ||
color: #999; | ||
} | ||
|
||
.commit-message { | ||
margin-bottom: 4px; | ||
border-bottom: solid 1px #efefef; | ||
} | ||
.commit-author { | ||
font-weight: bold; | ||
color: #999; | ||
} | ||
|
||
.commit-timestamp { | ||
color: #999; | ||
} | ||
|
||
#copy-button.fa { | ||
display: table-cell; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
'use strict'; | ||
|
||
(function() { | ||
|
||
var module = angular.module('geogit', []); | ||
var http, rootScope; | ||
var service_ = null; | ||
var q = null; | ||
|
||
|
||
module.service('geoGitService', function($q, $http) { | ||
return { | ||
geogitCommand: function(url) { | ||
var deferred = new $q.defer(); | ||
if (url) { | ||
var request = url + '&callback=JSON_CALLBACK'; | ||
$http.jsonp(request).success(function(data, status) { | ||
deferred.resolve(data); | ||
}).error(function(error) { | ||
deferred.reject(error); | ||
}); | ||
return deferred.promise; | ||
} | ||
} | ||
}; | ||
}); | ||
|
||
/* | ||
* Main search controller | ||
* Load data from api and defines the multiple and single choice handlers | ||
* Syncs the browser url with the selections | ||
*/ | ||
module.controller('geogitController', function($scope, geogitConfig, geoGitService) { | ||
var errorText = 'There was an error receiving the latest GeoGit stats.'; | ||
$scope.geoserverURL = geogitConfig.geoserverURL; | ||
$scope.workspace = geogitConfig.workspace; | ||
$scope.typename = geogitConfig.typename; | ||
$scope.store = geogitConfig.store; | ||
$scope.statisticsURL = geogitConfig.statisticsURL; | ||
$scope.logURL = geogitConfig.logURL; | ||
$scope.repoURL = geogitConfig.repoURL; | ||
|
||
if ($scope.statisticsURL) { | ||
geoGitService.geogitCommand($scope.statisticsURL).then( | ||
function(data) { | ||
if (data.response.success) { | ||
$scope.stats = data.response.Statistics; | ||
$('#geogit-message').hide(); | ||
$('#geogit-stats').show(); | ||
} | ||
}, | ||
function(error) { | ||
$scope.error = error; | ||
$('#geogit-message > h4').text(errorText); | ||
console.log(error); | ||
}); | ||
} | ||
|
||
if ($scope.logURL) { | ||
geoGitService.geogitCommand($scope.logURL).then( | ||
function(data) { | ||
if (data.response.success) { | ||
$('#geogit-message').hide(); | ||
$('#geogit-stats').show(); | ||
var response = data.response.commit; | ||
if (!Array.isArray(response)) { | ||
$scope.commits = [response]; | ||
} else { | ||
$scope.commits = response; | ||
} | ||
for (var i = 0; i < $scope.commits.length; i++) { | ||
var commit = $scope.commits[i]; | ||
if (commit.author) { | ||
commit.commitTimeSince = moment().calendar(commit.author.timestamp); | ||
} | ||
} | ||
} | ||
}, | ||
function(error) { | ||
$scope.error = error; | ||
$('#geogit-message > h4').text(errorText); | ||
}); | ||
} | ||
|
||
}); | ||
})(); |
55 changes: 55 additions & 0 deletions
55
geonode/contrib/geogit/templates/_geogit_layer_detail.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{% load dialogos_tags %} | ||
{% load bootstrap_tags %} | ||
{% load i18n %} | ||
|
||
|
||
{% verbatim %} | ||
<div id="geogit" ng-controller="geogitController"> | ||
<div id="geogit-tab"> | ||
<div id="geogit-message"> | ||
<i class="fa fa-spinner fa-spin"></i> | ||
<h4>Pulling latest GeoGit data.</h4> | ||
</div> | ||
<div id="geogit-stats" style="display: none"> | ||
<dt>Clone URL:</dt> | ||
<div class="form-group"> | ||
<div class="input-group"> | ||
<i class="input-group-addon fa fa-clipboard" data-clipboard-text="{{ repoURL }}" id="copy-button" data-toggle="tooltip" | ||
title="Copy the clone url."></i> | ||
<input class="form-control" id="clone-url" type="email" value="{{ repoURL }}" readonly> | ||
</div> | ||
</div> | ||
<dt>About this GeoGit Layer:</dt> | ||
<table class="table table-bordered"> | ||
<tr> | ||
<td class="table-center"> | ||
<div class="stat-title">total commits</div> | ||
<div class="stat-value">{{ stats.totalCommits | number}}</div> | ||
|
||
</td> | ||
<td class="table-center"> | ||
<div class="stat-title">total contributors</div> | ||
<div class="stat-value">{{ stats.Authors.totalAuthors || 0 | number}}</div> | ||
</td> | ||
</tr> | ||
</table> | ||
<dt>Recent Commit History:</dt> | ||
|
||
<div ng-repeat-start="commit in commits"> | ||
<div class="commit" id="commit-{{ commit.id }}"> | ||
<span class="label label-primary pull-right">{{ commit.id | limitTo: 10 }}</span> | ||
<h4 class="commit-message">{{ commit.message }}</h4> | ||
<span class="commit-timestamp">Authored <span class="gray">{{ commit.commitTimeSince }}</span> by: </span> | ||
<span class="commit-author">{{ commit.author.name || 'Unknown' }}</span> | ||
|
||
</div> | ||
|
||
|
||
|
||
</div> | ||
<span ng-repeat-end></span> | ||
</div> | ||
</div> | ||
|
||
</div> | ||
{% endverbatim %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{% load geogit_tags %} | ||
|
||
{% if DEBUG_STATIC %} | ||
<script src="{{ STATIC_URL }}lib/js/jquery.min.js"></script> | ||
<script src="{{ STATIC_URL }}lib/js/angular.js"></script> | ||
<script src="{{ STATIC_URL }}lib/js/bootstrap.min.js"></script> | ||
<script src="{{ STATIC_URL }}lib/js/ZeroClipboard.min.js"></script> | ||
<script src="{{ STATIC_URL }}lib/js/moment.min.js"></script> | ||
{% endif %} | ||
<script src="{{ STATIC_URL }}geogit/geogit.js"></script> | ||
<link href="{{ STATIC_URL }}geogit/css/geogit.css" rel="stylesheet"/> | ||
|
||
<script type="text/javascript"> | ||
var module = angular.module('g', ['geogit']); | ||
module.constant('geogitConfig', { | ||
workspace: '{{ resource.workspace }}', | ||
store: '{{ resource.store }}', | ||
typename: '{{ resource.typename }}', | ||
geoserverURL: '{{ GEOSERVER_BASE_URL }}', | ||
statisticsURL: '{% geogit_statistics_url resource %}', | ||
logURL: '{% geogit_log_url resource %}', | ||
repoURL: '{% geogit_repo_url resource %}' | ||
}); | ||
angular.bootstrap(document, ['g']); | ||
|
||
ZeroClipboard.config( { swfPath: '/static/lib/img/ZeroClipboard.swf' } ); | ||
var client = new ZeroClipboard( document.getElementById("copy-button") ); | ||
|
||
client.on( 'ready', function( readyEvent ) { | ||
client.on( 'aftercopy', function( event ) { | ||
alert('Copied ' + event.data['text/plain'] + ' to the clipboard.'); | ||
} ); | ||
} ); | ||
|
||
moment.lang('en', { | ||
calendar : { | ||
lastDay : '[Yesterday at] LT', | ||
sameDay : '[Today at] LT', | ||
nextDay : '[Tomorrow at] LT', | ||
lastWeek : '[last] dddd [at] LT', | ||
nextWeek : 'dddd [at] LT', | ||
sameElse : '[on] D MMM YYYY' | ||
} | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from django import template | ||
|
||
register = template.Library() | ||
|
||
@register.simple_tag | ||
def geogit_statistics_url(layer): | ||
return getattr(layer.link_set.filter(name__icontains='geogit statistics').first(), 'url', None) | ||
|
||
@register.simple_tag | ||
def geogit_log_url(layer): | ||
return getattr(layer.link_set.filter(name__icontains='geogit log').first(), 'url', None) | ||
|
||
@register.simple_tag | ||
def geogit_repo_url(layer): | ||
return getattr(layer.link_set.filter(name__icontains='clone in geogit').first(), 'url', None) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.