-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci_build/: Re-design build-logs webpage
The newly created webpage combines the previous two webpages- info.txt and log/index.html. This web-page combines the results of both the pages and shows them in a better UI/UX with additional features of filtering and searching within the existing logs. The logs are fetched from a JSON file which is created from the logs stored in the log file _site/community.log
- Loading branch information
Showing
12 changed files
with
326 additions
and
56 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ packages: | |
- gci | ||
- gsoc | ||
- gamification | ||
- log | ||
- ci_build | ||
- meta_review | ||
- model | ||
|
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,69 @@ | ||
import re | ||
import json | ||
import os | ||
from django.views.generic import TemplateView | ||
|
||
from community.views import get_header_and_footer | ||
from community.git import (get_org_name, | ||
get_owner, | ||
get_deploy_url, | ||
get_upstream_deploy_url) | ||
|
||
|
||
class BuildLogsView(TemplateView): | ||
template_name = 'build_logs.html' | ||
|
||
def get_build_info(self): | ||
data = { | ||
'Org name': get_org_name(), | ||
'Owner': get_owner(), | ||
'Deploy URL': get_deploy_url(), | ||
} | ||
try: | ||
upstream_deploy_url = get_upstream_deploy_url() | ||
data['Upstream deploy URL'] = upstream_deploy_url | ||
except RuntimeError: | ||
data['Upstream deploy URL'] = 'Not found' | ||
return dict(data) | ||
|
||
def get_build_logs(self): | ||
log_lines = [] | ||
log_level_specific_lines = { | ||
'INFO': [], | ||
'DEBUG': [], | ||
'WARNING': [], | ||
'ERROR': [], | ||
'CRITICAL': [] | ||
} | ||
log_file_path = './_site/community.log' | ||
log_file_exists = os.path.isfile(log_file_path) | ||
if log_file_exists: | ||
with open(log_file_path) as log_file: | ||
previous_found_level = None | ||
for line in log_file: | ||
log_lines.append(line) | ||
levels = re.findall(r'\[[A-Z]+]', line) | ||
if levels: | ||
level = levels[0] | ||
level = previous_found_level = level[1:-1] | ||
log_level_specific_lines[level].append(line) | ||
elif previous_found_level: | ||
log_level_specific_lines[previous_found_level].append( | ||
line) | ||
with open('./_site/ci-build-detailed-logs.json', | ||
'w+') as build_logs_file: | ||
data = { | ||
'logs': log_lines, | ||
'logs_level_Specific': log_level_specific_lines | ||
} | ||
json.dump(data, build_logs_file, indent=4) | ||
return True | ||
else: | ||
return False | ||
|
||
def get_context_data(self, **kwargs): | ||
context = super().get_context_data(**kwargs) | ||
context = get_header_and_footer(context) | ||
context['build_info'] = self.get_build_info() | ||
context['build_logs_stored'] = self.get_build_logs() | ||
return context |
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 was deleted.
Oops, something went wrong.
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,81 @@ | ||
.build-info-section section, | ||
.build-logs-section section { | ||
min-width: 300px; | ||
width: 80%; | ||
} | ||
|
||
.build-information, | ||
.build-logs { | ||
background-color: black; | ||
padding-left: 10px; | ||
font-weight: bold; | ||
color: white; | ||
} | ||
|
||
.build-information p { | ||
font-size: 1.5em; | ||
margin: 0; | ||
} | ||
|
||
.build-logs { | ||
max-height: 900px; | ||
overflow: scroll; | ||
overflow-x: hidden; | ||
} | ||
|
||
.build-logs p { | ||
margin: 0; | ||
} | ||
|
||
.build-logs-section .log-chooser { | ||
max-width: 200px; | ||
min-width: 150px; | ||
border-radius: 100px; | ||
box-shadow: 0px 0px 25px 2px black; | ||
color: #454343; | ||
background-color: #c7da99; | ||
padding-left: 10px; | ||
} | ||
|
||
.build-logs-section .search-field { | ||
max-width: 500px; | ||
min-width: 300px; | ||
border-radius: 100px; | ||
box-shadow: 0px 0px 25px 2px black; | ||
color: #454343; | ||
background-color: #edf5af; | ||
padding: 0px 20px; | ||
flex-flow: row; | ||
} | ||
|
||
.build-logs-section input[type='search']:focus:not(.browser-default) { | ||
background-color: #edf5af; | ||
border-radius: 100px; | ||
font-size: medium; | ||
} | ||
|
||
.main-content h3 { | ||
color: #37474f; | ||
} | ||
|
||
.section-header { | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.section-header form { | ||
display: flex; | ||
justify-content: space-around; | ||
flex-direction: row; | ||
flex-grow: 3; | ||
} | ||
|
||
@media only screen and (max-width: 768px) { | ||
.build-logs-section .search-field { | ||
display: none; | ||
} | ||
} | ||
|
||
.webpage-name { | ||
width: 100%; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
$(document).ready(function(){ | ||
$('select').formSelect(); | ||
|
||
var log_chooser_input = $('#log-chooser-input'); | ||
var search_input = $('#search'); | ||
var log_type = null; | ||
var logs_data = null; | ||
var searched_keyword = ''; | ||
|
||
function addLogsHTML(info){ | ||
var info_el = $('<p></p>').text(info); | ||
$('.build-logs').append(info_el); | ||
} | ||
|
||
function updateBuildLogsHTML(){ | ||
$('.build-logs p').remove(); | ||
if (logs_data.length < 37){ | ||
$('.build-logs').css('overflow-y', 'hidden'); | ||
} | ||
if(logs_data.length > 0) { | ||
for(var entry in logs_data){ | ||
if(logs_data[entry]){ | ||
addLogsHTML(logs_data[entry]); | ||
} | ||
} | ||
} | ||
else { | ||
var info = 'There are no log entries for tag ' + log_type + '.'; | ||
addLogsHTML(info); | ||
} | ||
} | ||
|
||
function updateBuildLogs(type){ | ||
$.getJSON("/static/ci-build-detailed-logs.json", function(data) { | ||
log_type = type; | ||
if(log_type === 'logs') { | ||
logs_data = data[log_type]; | ||
} | ||
else { | ||
logs_data = data.logs_level_Specific[log_type]; | ||
} | ||
updateBuildLogsHTML(); | ||
}) | ||
.fail(function(data, textStatus, error) { | ||
var err = "Request Failed: " + textStatus + ", " + error; | ||
console.error( err); | ||
}); | ||
} | ||
|
||
function searchBuildLogs(){ | ||
var found = false; | ||
var info = ''; | ||
for(var entry in logs_data){ | ||
if(logs_data[entry]){ | ||
info = logs_data[entry]; | ||
if(info.includes(searched_keyword)){ | ||
found = true; | ||
addLogsHTML(info); | ||
} | ||
} | ||
} | ||
if(!found){ | ||
if(log_type === 'logs'){ | ||
info = searched_keyword + ' not found in logs!'; | ||
} | ||
else { | ||
info = searched_keyword + ' not found in ' + log_type + | ||
' level logs!'; | ||
} | ||
addLogsHTML(info); | ||
} | ||
} | ||
|
||
updateBuildLogs('logs'); | ||
|
||
log_chooser_input.on('change', function(){ | ||
updateBuildLogs(log_chooser_input.val()); | ||
}); | ||
|
||
search_input.on('keypress', function(key){ | ||
if(key.which === 13){ | ||
searched_keyword = search_input.val(); | ||
$('.build-logs p').remove(); | ||
searchBuildLogs(); | ||
} | ||
}); | ||
|
||
}); |
Oops, something went wrong.