Skip to content

Commit

Permalink
issue #22 fixed. I also added created and modified owner.
Browse files Browse the repository at this point in the history
  • Loading branch information
dejande committed Jul 22, 2014
1 parent 3c03354 commit d184942
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Olog/public_html/static/html/templates.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<script id="template_log" type="text/template">
<div class="log {{click}} {{color}}">
<input type="hidden" name="id" value="{{id}}" />
<span class="text-info log_header">{{owner}}, {{createdDate}} </span>{{#modified}}<span class="muted log_header_right">{{modifiedDate}}</span>{{/modified}}
<span title="Created" class="text-info log_header">{{owner}}, {{createdDate}} </span>{{#modified}}<span title="Modified" class="muted log_header_right">{{modifiedOwner}}, {{modifiedDate}}</span>{{/modified}}
<br/>
{{description}}
<br />
Expand All @@ -40,7 +40,7 @@
<div class="{{click}} {{parent_color}} child_{{rawId}}" style="display: none">
<div class="log log_history {{color}}">
<input type="hidden" name="id" value="{{id}}" />
<span class="text-info log_header">{{owner}}, {{createdDate}} </span>{{#modified}}<span class="muted log_header_right">{{modifiedDate}}</span>{{/modified}}
<span title="Created" class="text-info log_header">{{owner}}, {{createdDate}} </span>{{#modified}}<span title="Modified" class="muted log_header_right">{{modifiedOwner}}, {{modifiedDate}}</span>{{/modified}}
<br />
{{description}}
<br />
Expand Down
27 changes: 20 additions & 7 deletions Olog/public_html/static/js/rest.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,9 @@ function getLog(id){

// Append include history parameter because we can get old version from
// URL but have history disabled
url += '&' + historyParameter;
if(!("history" in $.url(url).param())) {
url += '&' + historyParameter + '=&';
}

l(url);

Expand Down Expand Up @@ -205,7 +207,9 @@ function getLogNew(id, myFunction){

// Append include history parameter because we can get old version from
// URL but have history disabled
url += '&' + historyParameter;
if(!("history" in $.url(url).param())) {
url += '&' + historyParameter + '=&';
}

l(url);

Expand Down Expand Up @@ -470,8 +474,9 @@ function repeat(source_id, target_id, data, property, showByDefault, showSelecte
* @param {type} i current index of parent log element
* @param {type} children array of children together with parent
* @param {type} prepend should new logs be appended or prepended
* @param {type} logOwners dictionary which holds logs' owners
*/
function prepareParentAndChildren(i, children, prepend) {
function prepareParentAndChildren(i, children, prepend, logOwners) {
var logTemplate = getTemplate("template_log");
var historyTemplate = getTemplate("template_log_history");
var html = "";
Expand All @@ -481,7 +486,8 @@ function prepareParentAndChildren(i, children, prepend) {
// Build customized Log object
var newItem = {
description: returnFirstXWords(item.description, 40),
owner: item.owner,
owner: logOwners[item.id + '_1'],
modifiedOwner: item.owner,
createdDate: formatDate(item.createdDate),
modifiedDate: formatDate(item.modifiedDate),
modified: false,
Expand Down Expand Up @@ -559,7 +565,8 @@ function prepareParentAndChildren(i, children, prepend) {
// Build customized Log object
var childItem = {
description: returnFirstXWords(child.description, 40),
owner: child.owner,
owner: logOwners[child.id + '_1'],
modifiedOwner: child.owner,
createdDate: formatDate(child.createdDate),
modifiedDate: formatDate(child.modifiedDate),
modified: false,
Expand Down Expand Up @@ -608,6 +615,12 @@ function repeatLogs(data, prepend){

var logId = "";
var logIndex = 0;
var logOwners = {};

// HACK: Get owner of the first version of log entry
$.each(data, function(i, item) {
logOwners[item.id + "_" + item.version] = item.owner;
});

// If we are prepending new data, reverse the order of logs so the will be prepended correctly
if(prepend) {
Expand All @@ -630,7 +643,7 @@ function repeatLogs(data, prepend){
children = children.reverse();
}

prepareParentAndChildren(i, children, prepend);
prepareParentAndChildren(i, children, prepend, logOwners);
}

children = [];
Expand All @@ -643,7 +656,7 @@ function repeatLogs(data, prepend){
// Print the last element (with children)
if(children.length > 0) {
logIndex ++;
prepareParentAndChildren(logIndex, children, prepend);
prepareParentAndChildren(logIndex, children, prepend, logOwners);
}
}

Expand Down
11 changes: 8 additions & 3 deletions Olog/public_html/static/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,13 @@ function searchForLogs(searchQuery, resetPageCouner) {
page = 1;
}

searchQuery = serviceurl + 'logs?' + searchQuery + 'page=' + page + '&limit=' + numberOfLogsPerLoad;
searchQuery = serviceurl + 'logs?' + searchQuery + 'page=' + page + '&limit=' + numberOfLogsPerLoad + '&';

// Append include history parameter
if(ologSettings.includeHistory && !("history" in $.url(searchQuery).param())) {
searchQuery += historyParameter + "=&";
}

searchURL = searchQuery;

l(searchURL);
Expand All @@ -111,7 +117,6 @@ function searchForLogs(searchQuery, resetPageCouner) {
scrollToLastLog();

$('.log img').last().load(function(){
//l("ready!");
scrollToLastLog();
});
});
Expand Down Expand Up @@ -253,7 +258,7 @@ function generateSearchQuery(dataArray) {
}

// Append include history parameter
if(ologSettings.includeHistory) {
if(ologSettings.includeHistory && !("history" in $.url(queryString).param())) {
queryString += historyParameter + "=&";
}

Expand Down

0 comments on commit d184942

Please sign in to comment.