YARN-10233. Fix YARN UI2 Daemon Logs

Contributed by Akhil PB.
This commit is contained in:
Prabhu Joseph 2020-04-15 13:39:33 +05:30 committed by Prabhu Joseph
parent 55fcbcb5c2
commit 94f7470c71
5 changed files with 25 additions and 19 deletions

View File

@ -2,3 +2,4 @@ tmp/
node_modules/ node_modules/
bower_components/ bower_components/
dist/ dist/
node/

View File

@ -19,5 +19,6 @@
import DS from 'ember-data'; import DS from 'ember-data';
export default DS.Model.extend({ export default DS.Model.extend({
logfileName: DS.attr() logFileName: DS.attr(),
logFileUrl: DS.attr()
}); });

View File

@ -19,8 +19,8 @@
import DS from 'ember-data'; import DS from 'ember-data';
export default DS.JSONAPISerializer.extend({ export default DS.JSONAPISerializer.extend({
normalizeResponse(store, primaryModelClass, payload, id, requestType) { normalizeResponse(store, primaryModelClass, payload) {
const pattern = new RegExp('<A HREF="/logs/.+">', 'g'); const pattern = new RegExp('<A HREF="/logs/.+">|<a href="/logs/.+">', 'g');
let fileNames = payload.match(pattern); let fileNames = payload.match(pattern);
if (fileNames == null) { if (fileNames == null) {
@ -29,13 +29,17 @@ export default DS.JSONAPISerializer.extend({
let logfileNames = []; let logfileNames = [];
for (var i = 0; i < fileNames.length; i++) { for (var i = 0; i < fileNames.length; i++) {
var fileName = fileNames[i].match(/<A HREF="(\/logs\/.+)">/); var fileNameMatch = fileNames[i].match(/<A HREF="(\/logs\/.+)">.+<\/A>|<a href="(\/logs\/.+)">.+<\/a>/);
if (fileName.length != null) { var logFileUrl = fileNameMatch[1] || fileNameMatch[2];
var logFileName = logFileUrl.replace('logs', '').replace(/\//g, '');
if (fileNameMatch.length != null) {
logfileNames.push({ logfileNames.push({
id: i, id: i,
type: primaryModelClass.modelName, type: primaryModelClass.modelName,
attributes: { attributes: {
logfileName: fileName[1] logFileUrl: logFileUrl,
logFileName: logFileName
} }
}); });
} }

View File

@ -52,7 +52,7 @@
{{/link-to}} {{/link-to}}
{{/link-to}} {{/link-to}}
{{#link-to 'yarn-tools.yarn-rm-log' tagName="li"}} {{#link-to 'yarn-tools.yarn-rm-log' tagName="li"}}
{{#link-to 'yarn-tools.yarn-rm-log'}}YARN Daemon logs {{#link-to 'yarn-tools.yarn-rm-log'}}YARN Daemon Logs
{{/link-to}} {{/link-to}}
{{/link-to}} {{/link-to}}
</ul> </ul>

View File

@ -17,15 +17,15 @@
}} }}
<h1>YARN Daemon Logs</h1> <h1>YARN Daemon Logs</h1>
<div class="col-md-12 container-fluid"> <div class="row">
<div class="col-md-10"> <div class="col-md-12">
<div class="panel panel-default"> <div class="panel panel-default">
<ul class="list-group"> <ul class="list-group">
{{#if model.logs}} {{#if model.logs}}
{{#each model.logs as |log|}} {{#each model.logs as |log|}}
<li class=list-group-item> <li class="list-group-item">
{{#link-to 'yarn-tools.yarn-rm-log' (query-params filename=log.logfileName)}} {{#link-to 'yarn-tools.yarn-rm-log' (query-params filename=log.logFileUrl)}}
{{log.logfileName}} {{log.logFileName}}
{{/link-to}} {{/link-to}}
</li> </li>
{{/each}} {{/each}}