Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use bootstrap-vue #269

Merged
merged 29 commits into from
Oct 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
4c6e34e
Use window.addEventListener instead of `$(document).ready`
okkez Oct 3, 2018
0c9fbae
Add bootstrap-vue
okkez Oct 3, 2018
db817c1
Import CSS for bootstrap-vue
okkez Oct 3, 2018
14c24c5
Use BootstrapVue
okkez Oct 3, 2018
ea66cdc
Use bootstrap-vue
okkez Oct 3, 2018
d1a1aff
Use bootstrap-vue for misc/information
okkez Oct 3, 2018
a2f7234
Remove unused code
okkez Oct 3, 2018
9f65e67
Use proper label
okkez Oct 3, 2018
093a484
Add label for clear
okkez Oct 4, 2018
6cd589c
Decorate plugins
okkez Oct 4, 2018
3bef15e
Plugin#installed? and Plugin#processing? should return true/false
okkez Oct 4, 2018
eb7c2ca
Add helper method plguins_json
okkez Oct 4, 2018
cbd8c57
Use bootstrap-vue on /plugins/recommended
okkez Oct 4, 2018
947883c
Remove a garbage
okkez Oct 4, 2018
9e9a0f3
Use bootstrap-vue on /plugins/installed
okkez Oct 4, 2018
e5f07f8
Use small table
okkez Oct 4, 2018
e3f393a
Use b-collapse
okkez Oct 4, 2018
b715a02
Use b-col and b-row
okkez Oct 4, 2018
7feeeeb
Convert to Haml
okkez Oct 4, 2018
e82e6b4
Use b-card
okkez Oct 4, 2018
a6523b5
Convert navigation to Haml format
okkez Oct 9, 2018
f159af0
Display logout link
okkez Oct 9, 2018
1bc3540
Use bootstrap-vue's tooltip component
okkez Oct 9, 2018
3229e3e
Remove unused partial template
okkez Oct 9, 2018
f318407
Remove unused data attributes
okkez Oct 9, 2018
e1b3842
Use bootstrap-vue's tooltip component
okkez Oct 9, 2018
9d2ec4b
Remove debug print
okkez Oct 9, 2018
f99f8ff
Use bootstrap-vue's dropdown component
okkez Oct 9, 2018
3cfff4a
Use bootstrap-vue components
okkez Oct 9, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*
*= require font-awesome
*= require bootstrap/dist/css/bootstrap
*= require bootstrap-vue/dist/bootstrap-vue
*= require startbootstrap-sb-admin/css/sb-admin.css
*= require datatables.net-bs4/css/dataTables.bootstrap4.css
*= require codemirror/lib/codemirror
Expand Down
8 changes: 8 additions & 0 deletions app/controllers/misc_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
class MiscController < ApplicationController
after_action :update!, only: [:update_fluentd_ui]

helper_method :env_items

def show
redirect_to misc_information_path
end
Expand Down Expand Up @@ -75,4 +77,10 @@ def add_version_file_to(zip)
def update!
FluentdUiRestart.perform_later
end

def env_items
@env.map do |key, value|
{ key: key, value: value }
end
end
end
23 changes: 20 additions & 3 deletions app/controllers/plugins_controller.rb
Original file line number Diff line number Diff line change
@@ -1,25 +1,36 @@
class PluginsController < ApplicationController
helper_method :plugins_json

def index
redirect_to installed_plugins_path
end

def installed
@plugins = Plugin.installed.reject{|plugin| plugin.processing? }
@plugins = PluginDecorator.decorate_collection(Plugin.installed.reject{|plugin| plugin.processing? })
end

def recommended
@plugins = PluginDecorator.decorate_collection(Plugin.recommended)
end

def updated
@plugins = Plugin.installed.reject{|plugin| plugin.latest_version? }
@plugins = PluginDecorator.decorate_collection(Plugin.installed.reject{|plugin| plugin.latest_version? })
end

def install
params[:plugins].each do |gem_name|
GemInstallerJob.perform_later(gem_name)
end
redirect_to plugins_path
respond_to do |format|
format.html do
redirect_to plugins_path
end
format.json do
plugins = PluginDecorator.decorate_collection(Plugin.recommended.select {|item| params[:plugins].include?(item.gem_name)})
render json: plugins.map(&:to_hash).to_json
end
end

end

def uninstall
Expand All @@ -41,4 +52,10 @@ def bulk_upgrade
end
redirect_to plugins_path
end

private

def plugins_json
JSON.pretty_generate(@plugins.map(&:to_hash))
end
end
18 changes: 18 additions & 0 deletions app/decorators/plugin_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,22 @@ def status
I18n.t("terms.not_installed")
end
end

def to_hash
{
is_installed: installed?,
is_processing: processing?,
uninstall_button: "plugin-modal-#{gem_name}",
name: gem_name,
authors: authors,
summary: summary,
api_version: api_version,
category: category,
status: status,
installed_version: installed_version,
latest_version: latest_version,
is_latest_version: latest_version?,
rubygems_org_page: rubygems_org_page
}
end
end
8 changes: 5 additions & 3 deletions app/javascript/packs/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
// To reference this file, add <%= javascript_pack_tag 'application' %> to the appropriate
// layout file, like app/views/layouts/application.html.erb

console.log("Hello World from Webpacker");

import jQuery from "jquery/dist/jquery";

window.$ = jQuery;
Expand All @@ -27,6 +25,10 @@ import "startbootstrap-sb-admin/js/sb-admin-datatables";

import Vue from "vue/dist/vue.esm";
import Vuex from "vuex/dist/vuex.esm";
import BootstrapVue from "bootstrap-vue/dist/bootstrap-vue.esm";

Vue.use(Vuex);
Vue.use(BootstrapVue);

Vue.filter("to_json", function (value) {
return JSON.stringify(value);
Expand All @@ -37,6 +39,6 @@ window.Vuex = Vuex;

import "../stylesheets/application.scss";

$(document).ready(() => {
window.addEventListener("load", () => {
$("[data-toggle=tooltip]").tooltip();
});
10 changes: 3 additions & 7 deletions app/javascript/packs/config_field.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,6 @@ const ConfigField = {
if (this.option.name === "time_format") {
this.timeFormat = this.initialTimeFormat;
}
this.$nextTick(() => {
console.log("config-field updated");
if ($("[data-toggle=tooltip]").tooltip) {
$("[data-toggle=tooltip]").tooltip("dispose");
$("[data-toggle=tooltip]").tooltip("enable");
}
});
},

methods: {
Expand All @@ -87,6 +80,9 @@ const ConfigField = {
}
this.$emit("change-parse-config", {});
},
labelId: function(pluginType, option) {
return `label_${this.inputId(pluginType, option)}`;
},
inputId: function(pluginType, option) {
if (pluginType === "output") {
return `setting_${option.name}`;
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/packs/filter_grep_setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "lodash/lodash";

import GrepContainer from "./grep_container";

$(document).ready(() => {
window.addEventListener("load", () => {
new Vue({
el: "#filter-grep-setting",
components: {
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/packs/fluent_log.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"use strict";
$(document).ready(()=> {
window.addEventListener("load", ()=> {
new Vue({
el: "#fluent-log",
data: {
Expand Down
4 changes: 3 additions & 1 deletion app/javascript/packs/grep_pattern.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ const GrepPattern = {
remove: function(event) {
this.$emit("remove-grep-pattern", this.grepType, this.subIndex);
},
labelId: function(name, index, subIndex) {
return `label_${this.inputId(name, index, subIndex)}`;
},
inputId: function(name, index, subIndex) {
return `setting_${this.containerType}_${index}_${this.grepType}_${subIndex}__${name}`;
},

inputName: function(name, index, subIndex) {
return `setting[${this.containerType}[${index}]][${this.grepType}[${subIndex}]][${name}]`;
}
Expand Down
10 changes: 1 addition & 9 deletions app/javascript/packs/in_tail_parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import "bootstrap/dist/js/bootstrap";
import ParserPluginForm from "./parser_plugin_form";
import store from "./store";

$(document).ready(() => {
window.addEventListener("load", () => {
new Vue({
el: "#in-tail-parse",
store,
Expand Down Expand Up @@ -51,14 +51,6 @@ $(document).ready(() => {
this.parseType = this.initialPluginName;
this.preview();
},
updated: function() {
this.$nextTick(() => {
if ($("[data-toggle=tooltip]").tooltip) {
$("[data-toggle=tooltip]").tooltip("dispose");
$("[data-toggle=tooltip]").tooltip("enable");
}
});
},
methods: {
onChangePluginName: function(name) {
console.log("#in-tail-parse onChangePluginName", name);
Expand Down
62 changes: 62 additions & 0 deletions app/javascript/packs/navigation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
const POLLING_INTERVAL = 3 * 1000;
const POLLING_URL = "/polling/alerts";

window.addEventListener("load", () => {
new Vue({
el: "#mainNav",
data: function() {
return {
alerts: []
};
},

computed: {
alertsCount: {
get: function() { return this.alerts.length; }
},
hasAlerts: {
get: function() { return this.alertsCount > 0; }
}
},

created: function(){
let timer;
let self = this;
let currentInterval = POLLING_INTERVAL;
let fetch = function(){
self.fetchAlertsData().then(function(alerts){
if(self.alerts.toString() == alerts.toString()) {
currentInterval *= 1.1;
} else {
currentInterval = POLLING_INTERVAL;
}
self.alerts = alerts;
timer = setTimeout(fetch, currentInterval);
})["catch"](function(xhr){
if(xhr.status === 401) {
// signed out
}
if(xhr.status === 0) {
// server unreachable (maybe down)
}
});
};
window.addEventListener("focus", function(_event){
currentInterval = POLLING_INTERVAL;
timer = setTimeout(fetch, currentInterval);
}, false);
window.addEventListener("blur", function(_event){
clearTimeout(timer);
}, false);
fetch();
},

methods: {
fetchAlertsData: function() {
return new Promise(function(resolve, reject) {
$.getJSON(POLLING_URL, resolve).fail(reject);
});
}
}
});
});
2 changes: 1 addition & 1 deletion app/javascript/packs/nested_settings.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* global _ */
"use strict";
import "lodash/lodash";
$(document).ready(()=> {
window.addEventListener("load", () => {
var $firstSetting = $(".js-nested-column.js-multiple:first");

if ($firstSetting.length === 0) {
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/packs/notification.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const POLLING_INTERVAL = 3 * 1000;
const POLLING_URL = "/polling/alerts";

$(document).ready(()=> {
window.addEventListener("load", ()=> {
new Vue({
el: "#vue-notification",
data: {
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/packs/out_forward_setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import TransportConfig from "./transport_config";
import OwnedPluginForm from "./owned_plugin_form";

$(document).ready(() => {
window.addEventListener("load", () => {
new Vue({
el: "#out-forward-setting",
components: {
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/packs/out_s3_setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import OwnedPluginForm from "./owned_plugin_form";
import AwsCredential from "./aws_credential";

$(document).ready(() => {
window.addEventListener("load", () => {
new Vue({
el: "#out-s3-setting",
components: {
Expand Down
9 changes: 0 additions & 9 deletions app/javascript/packs/owned_plugin_form.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,6 @@ const OwnedPluginForm = {
this.$emit("data-loaded");
},

updated: function() {
this.$nextTick(() => {
if ($("[data-toggle=tooltip]").tooltip) {
$("[data-toggle=tooltip]").tooltip("dispose");
$("[data-toggle=tooltip]").tooltip("enable");
}
});
},

methods: {
onChange: function() {
this.updateSection();
Expand Down
9 changes: 0 additions & 9 deletions app/javascript/packs/parser_plugin_form.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,6 @@ const ParserPluginForm = {
this.$emit("data-loaded");
},

updated: function() {
this.$nextTick(() => {
if ($("[data-toggle=tooltip]").tooltip) {
$("[data-toggle=tooltip]").tooltip("dispose");
$("[data-toggle=tooltip]").tooltip("enable");
}
});
},

methods: {
onChange: function(event) {
store.dispatch("parserParams/updateType", event);
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/packs/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import "lodash/lodash";

$(document).ready(() => {
window.addEventListener("load", () => {
const SettingSection = {
template: "#vue-setting-section",
props: [
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/packs/transport_section.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "lodash/lodash";

import ConfigField from "./config_field";

$(document).ready(() => {
window.addEventListener("load", () => {
new Vue({
el: "#transport-section",
components: {
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/packs/treeview.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* global _ */
"use strict";
import "lodash/lodash";
$(document).ready(() => {
window.addEventListener("load", () => {
new Vue({
el: "#treeview",
props: {
Expand Down
8 changes: 4 additions & 4 deletions app/models/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,18 @@ def upgrade!(new_version)
end

def installed?
self.class.installed.find do |plugin|
self.class.installed.any? do |plugin|
plugin.gem_name == gem_name
end
end

def processing?
!!WORKING.find{|data| data[:plugin].gem_name == gem_name}
WORKING.any?{|data| data[:plugin].gem_name == gem_name}
end

def installed_version
return unless inst = installed?
inst.version
return unless installed?
version
end

def latest_version?
Expand Down
Loading