mirror of
https://github.com/fluent/fluentd-ui.git
synced 2025-08-13 09:47:07 +02:00
Separate vue components
This commit is contained in:
parent
5d32e167a8
commit
15d3d3248f
30
app/assets/javascripts/fluent_log.js
Normal file
30
app/assets/javascripts/fluent_log.js
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
(function(){
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
$(function(){
|
||||||
|
if($('#fluent-log').length === 0) return;
|
||||||
|
|
||||||
|
new Vue({
|
||||||
|
el: "#fluent-log",
|
||||||
|
data: {
|
||||||
|
"logs": [],
|
||||||
|
},
|
||||||
|
|
||||||
|
created: function(){
|
||||||
|
this.fetchLogs();
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
fetchLogs: function() {
|
||||||
|
var self = this;
|
||||||
|
new Promise(function(resolve, reject) {
|
||||||
|
$.getJSON("/tutorials/log_tail", resolve).fail(reject);
|
||||||
|
}).then(function(logs){
|
||||||
|
self.logs = logs;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
|
@ -2,12 +2,13 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
$(function(){
|
$(function(){
|
||||||
|
// At tutorial chapter1, sending request to fluentd
|
||||||
|
|
||||||
if($('#chapter1').length === 0) return;
|
if($('#chapter1').length === 0) return;
|
||||||
|
|
||||||
new Vue({
|
new Vue({
|
||||||
el: "#chapter1",
|
el: "#chapter1",
|
||||||
data: {
|
data: {
|
||||||
"logs": [],
|
|
||||||
"payloads": [
|
"payloads": [
|
||||||
{
|
{
|
||||||
"path": "/debug.foo",
|
"path": "/debug.foo",
|
||||||
@ -37,19 +38,7 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
created: function(){
|
|
||||||
this.fetchLogs();
|
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
fetchLogs: function() {
|
|
||||||
var self = this;
|
|
||||||
new Promise(function(resolve, reject) {
|
|
||||||
$.getJSON("/tutorials/log_tail", resolve).fail(reject);
|
|
||||||
}).then(function(logs){
|
|
||||||
self.logs = logs;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
sendRequest: function(payload){
|
sendRequest: function(payload){
|
||||||
new Promise(function(resolve, reject) {
|
new Promise(function(resolve, reject) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
@ -20,7 +20,11 @@
|
|||||||
</code>
|
</code>
|
||||||
</p>
|
</p>
|
||||||
</form>
|
</form>
|
||||||
|
</div>
|
||||||
|
<!-- /vue.js -->
|
||||||
|
|
||||||
|
<!-- vue.js -->
|
||||||
|
<div id="fluent-log">
|
||||||
<pre>
|
<pre>
|
||||||
<button class="btn btn-primary" v-on="click: fetchLogs"><%= t ".reload_log" %></button>
|
<button class="btn btn-primary" v-on="click: fetchLogs"><%= t ".reload_log" %></button>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user