show drone logs

This commit is contained in:
Sebastian Frank
2019-03-06 15:47:58 +01:00
parent 9ad3cf1aef
commit 908bdb59cb
2 changed files with 180 additions and 2 deletions

View File

@@ -1,7 +1,56 @@
<style>
.uk-modal-details .uk-modal-dialog {
.uk-modal-details .uk-modal-dialog, .uk-modal-logs .uk-modal-dialog {
height: 85%;
}
.uk-modal-logs pre {
color: #d3d3d3;
background-color: #333;
}
.black { color: #000; }
.red { color: #FF0000; }
.green { color: #008000; }
.brown { color: #A52A2A; }
.blue { color: #0000FF; }
.purple { color: #800080; }
.cyan { color: #00FFFF; }
.light-gray { color: #D3D3D3; }
.dark-gray { color: #A9A9A9; }
.light-red { color: #f55; }
.light-green { color: #90EE90; }
.yellow { color: #FFFF00; }
.light-blue { color: #ADD8E6; }
.light-purple { color: #9370DB; }
.light-cyan { color: #E0FFFF; }
.white { color: #fff; }
pre {
border-radius: 5px;
}
pre h2 {
color: black;
display: inline-block;
border-radius: 5px;
padding: 5px;
font-size: 1.5em;
background-color: #d3d3d3;
}
pre h2.success {
background-color: #60cc60;
}
pre h2.failure {
background-color: #ff3333;
}
.stagename {
float: right;
font-size: 0.8em;
padding-left: 30px;
}
</style>
<div>
@@ -42,6 +91,16 @@
</div>
</div>
<div class="uk-modal uk-modal-logs uk-height-viewport">
<div class="uk-modal-dialog uk-modal-dialog-large">
<a href="" class="uk-modal-close uk-close"></a>
<h3>{ deploy && deploy.title }</h3>
<div class="uk-margin uk-flex uk-flex-middle" if="{deploy}">
<pre style="display: inline-block;"></pre>
</div>
</div>
</div>
<div class="uk-form uk-clearfix" show="{!loading}">
<table class="uk-table uk-table-tabbed uk-table-striped uk-margin-top" if="{ !loading && deploys.length }">
<thead>
@@ -52,6 +111,9 @@
<th class="uk-text-small uk-link-muted uk-noselect" width="50">
@lang('Build') #
</th>
<th class="uk-text-small uk-link-muted uk-noselect" width="50">
@lang('Event')
</th>
<th class="uk-text-small uk-link-muted uk-noselect" width="450">
@lang('Title')
</th>
@@ -64,6 +126,9 @@
<th class="uk-text-small uk-link-muted uk-noselect" width="90">
@lang('Deploy time')
</th>
<th class="uk-text-small uk-link-muted uk-noselect" width="50">
@lang('Log')
</th>
</tr>
</thead>
<tbody>
@@ -77,10 +142,12 @@
</a>
</td>
<td>{ deploy.number }</td>
<td>{ deploy.event }: { deploy.message }</td>
<td>{ deploy.event }</td>
<td>{ deploy.message }</td>
<td><span class="uk-badge uk-badge-outline uk-text-muted">{ deploy.created_at }</span></td>
<td><span class="uk-badge uk-badge-outline uk-text-muted">{ deploy.updated_at }</span></td>
<td><span if="{deploy.deploy_time}">{ deploy.deploy_time }s</span></td>
<td><a onclick="{ showdeployLog }"><img src="@url('assets:app/media/icons/text.svg')" style="height: 25px;"></a></td>
</tr>
</tbody>
</table>
@@ -99,6 +166,7 @@
this.on('mount', function() {
$this.loading = false;
$this.modal = UIkit.modal(App.$('.uk-modal-details', this.root), {modal:true});
$this.modalLogs = UIkit.modal(App.$('.uk-modal-logs', this.root), {modal:true});
if ($this.building) {
setTimeout(function() {
$this.fetchData();
@@ -113,11 +181,29 @@
editor = $this.refs.codemirror.editor;
editor.setValue(JSON.stringify($this.deploy, null, 2), true);
editor.setOption("readOnly", true);
editor.setOption("mode", "javascript");
editor.setSize($this.modal.dialog[0].clientWidth - 50, $this.modal.dialog[0].clientHeight - 70);
editor.refresh();
$this.trigger('ready');
}
showdeployLog(e) {
$this.deploy = e.item.deploy;
App.callmodule('drone:fetchLogs', $this.deploy['number'], 'manage.view').then(function(data) {
if (data && data.result && data.result.out) {
area = App.$('.uk-modal-logs pre');
area.html(data.result.out);
$this.modalLogs.show();
area.css('width', $this.modalLogs.dialog[0].clientWidth - 50);
area.css('height', $this.modalLogs.dialog[0].clientHeight - 70);
$this.trigger('ready');
} else {
App.ui.notify(App.i18n.get("Cannot fetch logs from Drone! Try again later."), "danger");
}
$this.update();
});
}
createDeploy() {
if ($this.building) {
App.ui.notify(App.i18n.get("A deploy is already in progress, please wait until finishes."), "warning");
@@ -135,6 +221,7 @@
editor = $this.refs.codemirror.editor;
editor.setValue(JSON.stringify(data, null, 2), true);
editor.setOption("readOnly", true);
editor.setOption("mode", "javascript");
editor.setSize($this.modal.dialog[0].clientWidth - 50, $this.modal.dialog[0].clientHeight - 70);
editor.refresh();
}