diff options
-rw-r--r-- | .eslintrc.js | 12 | ||||
-rw-r--r-- | .prettierrc.js | 10 | ||||
-rw-r--r-- | babel.config.js | 2 | ||||
-rw-r--r-- | jest.config.js | 2 | ||||
-rw-r--r-- | src/components/AppHeader/index.js | 2 | ||||
-rw-r--r-- | src/components/AppNavigation/index.js | 2 | ||||
-rw-r--r-- | src/main.js | 16 | ||||
-rw-r--r-- | src/router/index.js | 40 | ||||
-rw-r--r-- | src/store/api.js | 2 | ||||
-rw-r--r-- | src/store/index.js | 10 | ||||
-rw-r--r-- | src/store/modules/AccessControl/LocalUserMangementStore.js | 16 | ||||
-rw-r--r-- | src/store/modules/Authentication/AuthenticanStore.js | 32 | ||||
-rw-r--r-- | src/store/modules/GlobalStore.js | 8 | ||||
-rw-r--r-- | src/views/AccessControl/LocalUserManagement/index.js | 2 | ||||
-rw-r--r-- | src/views/Login/index.js | 2 | ||||
-rw-r--r-- | src/views/Overview/index.js | 2 | ||||
-rw-r--r-- | tests/unit/example.spec.js | 10 | ||||
-rw-r--r-- | vue.config.js | 20 |
18 files changed, 100 insertions, 90 deletions
diff --git a/.eslintrc.js b/.eslintrc.js index 8d83430f..2e8a358a 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -3,19 +3,19 @@ module.exports = { env: { node: true }, - extends: ["plugin:vue/essential", "@vue/prettier"], + extends: ['plugin:vue/essential', '@vue/prettier'], rules: { - "no-console": "off", - "no-debugger": process.env.NODE_ENV === "production" ? "error" : "off" + 'no-console': 'off', + 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off' }, parserOptions: { - parser: "babel-eslint" + parser: 'babel-eslint' }, overrides: [ { files: [ - "**/__tests__/*.{j,t}s?(x)", - "**/tests/unit/**/*.spec.{j,t}s?(x)" + '**/__tests__/*.{j,t}s?(x)', + '**/tests/unit/**/*.spec.{j,t}s?(x)' ], env: { jest: true diff --git a/.prettierrc.js b/.prettierrc.js new file mode 100644 index 00000000..948879ba --- /dev/null +++ b/.prettierrc.js @@ -0,0 +1,10 @@ +module.exports = { + overrides: [ + { + files: '*.js', + options: { + singleQuote: true + } + } + ] +}; diff --git a/babel.config.js b/babel.config.js index a1c27e1c..03e1dd91 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,3 +1,3 @@ module.exports = { - presets: [["@vue/cli-plugin-babel/preset", { useBuiltIns: "entry" }]] + presets: [['@vue/cli-plugin-babel/preset', { useBuiltIns: 'entry' }]] }; diff --git a/jest.config.js b/jest.config.js index 3c6f7c86..86648009 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,3 +1,3 @@ module.exports = { - preset: "@vue/cli-plugin-unit-jest" + preset: '@vue/cli-plugin-unit-jest' }; diff --git a/src/components/AppHeader/index.js b/src/components/AppHeader/index.js index b8f3ab3c..e180e80f 100644 --- a/src/components/AppHeader/index.js +++ b/src/components/AppHeader/index.js @@ -1,2 +1,2 @@ -import AppHeader from "./AppHeader"; +import AppHeader from './AppHeader'; export default AppHeader; diff --git a/src/components/AppNavigation/index.js b/src/components/AppNavigation/index.js index 8046f702..88fe8eb6 100644 --- a/src/components/AppNavigation/index.js +++ b/src/components/AppNavigation/index.js @@ -1,2 +1,2 @@ -import AppNavigation from "./AppNavigation"; +import AppNavigation from './AppNavigation'; export default AppNavigation; diff --git a/src/main.js b/src/main.js index 695c0084..023c24ec 100644 --- a/src/main.js +++ b/src/main.js @@ -1,8 +1,8 @@ -import Vue from "vue"; -import App from "./App.vue"; -import router from "./router"; -import store from "./store"; -import { dateFilter } from "vue-date-fns"; +import Vue from 'vue'; +import App from './App.vue'; +import router from './router'; +import store from './store'; +import { dateFilter } from 'vue-date-fns'; import { BadgePlugin, ButtonPlugin, @@ -20,9 +20,9 @@ import { NavbarPlugin, NavPlugin, TablePlugin -} from "bootstrap-vue"; +} from 'bootstrap-vue'; -Vue.filter("date", dateFilter); +Vue.filter('date', dateFilter); Vue.use(BadgePlugin); Vue.use(ButtonPlugin); @@ -46,4 +46,4 @@ new Vue({ router, store, render: h => h(App) -}).$mount("#app"); +}).$mount('#app'); diff --git a/src/router/index.js b/src/router/index.js index 9c802340..99f2a12f 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -1,42 +1,42 @@ -import Vue from "vue"; -import VueRouter from "vue-router"; -import store from "../store/index"; -import AppLayout from "../layouts/AppLayout.vue"; +import Vue from 'vue'; +import VueRouter from 'vue-router'; +import store from '../store/index'; +import AppLayout from '../layouts/AppLayout.vue'; Vue.use(VueRouter); const routes = [ { - path: "/", - name: "", + path: '/', + name: '', meta: { requiresAuth: true }, component: AppLayout, children: [ { - path: "", - component: () => import("@/views/Overview"), + path: '', + component: () => import('@/views/Overview'), meta: { - title: "Server Overview" + title: 'Server Overview' } }, { - path: "/access-control/local-user-management", - name: "local-users", - component: () => import("@/views/AccessControl/LocalUserManagement"), + path: '/access-control/local-user-management', + name: 'local-users', + component: () => import('@/views/AccessControl/LocalUserManagement'), meta: { - title: "Manage Local Users" + title: 'Manage Local Users' } } ] }, { - path: "/login", - name: "login", - component: () => import("@/views/Login"), + path: '/login', + name: 'login', + component: () => import('@/views/Login'), meta: { - title: "Login" + title: 'Login' } } ]; @@ -44,16 +44,16 @@ const routes = [ const router = new VueRouter({ base: process.env.BASE_URL, routes, - linkExactActiveClass: "nav__link--current" + linkExactActiveClass: 'nav__link--current' }); router.beforeEach((to, from, next) => { if (to.matched.some(record => record.meta.requiresAuth)) { - if (store.getters["authentication/isLoggedIn"]) { + if (store.getters['authentication/isLoggedIn']) { next(); return; } - next("/login"); + next('/login'); } else { next(); } diff --git a/src/store/api.js b/src/store/api.js index c50bcbee..da6f3982 100644 --- a/src/store/api.js +++ b/src/store/api.js @@ -1,4 +1,4 @@ -import Axios from "axios"; +import Axios from 'axios'; const api = Axios.create({ withCredentials: true diff --git a/src/store/index.js b/src/store/index.js index b4be6ccd..4ef1c9d0 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1,9 +1,9 @@ -import Vue from "vue"; -import Vuex from "vuex"; +import Vue from 'vue'; +import Vuex from 'vuex'; -import GlobalStore from "./modules/GlobalStore"; -import AuthenticationStore from "./modules/Authentication/AuthenticanStore"; -import LocalUserManagementStore from "./modules/AccessControl/LocalUserMangementStore"; +import GlobalStore from './modules/GlobalStore'; +import AuthenticationStore from './modules/Authentication/AuthenticanStore'; +import LocalUserManagementStore from './modules/AccessControl/LocalUserMangementStore'; Vue.use(Vuex); diff --git a/src/store/modules/AccessControl/LocalUserMangementStore.js b/src/store/modules/AccessControl/LocalUserMangementStore.js index de79a2d7..815c1661 100644 --- a/src/store/modules/AccessControl/LocalUserMangementStore.js +++ b/src/store/modules/AccessControl/LocalUserMangementStore.js @@ -1,4 +1,4 @@ -import api from "../../api"; +import api from '../../api'; const LocalUserManagementStore = { namespaced: true, @@ -18,12 +18,12 @@ const LocalUserManagementStore = { actions: { getUsers({ commit }) { api - .get("/redfish/v1/AccountService/Accounts") - .then(response => response.data.Members.map(user => user["@odata.id"])) + .get('/redfish/v1/AccountService/Accounts') + .then(response => response.data.Members.map(user => user['@odata.id'])) .then(userIds => api.all(userIds.map(user => api.get(user)))) .then(users => { const userData = users.map(user => user.data); - commit("setUsers", userData); + commit('setUsers', userData); }) .catch(error => console.log(error)); }, @@ -35,8 +35,8 @@ const LocalUserManagementStore = { Enabled: status }; api - .post("/redfish/v1/AccountService/Accounts", data) - .then(() => dispatch("getUsers")) + .post('/redfish/v1/AccountService/Accounts', data) + .then(() => dispatch('getUsers')) .catch(error => console.log(error)); }, updateUser( @@ -50,13 +50,13 @@ const LocalUserManagementStore = { if (status !== undefined) data.Enabled = status; api .patch(`/redfish/v1/AccountService/Accounts/${originalUsername}`, data) - .then(() => dispatch("getUsers")) + .then(() => dispatch('getUsers')) .catch(error => console.log(error)); }, deleteUser({ dispatch }, username) { api .delete(`/redfish/v1/AccountService/Accounts/${username}`) - .then(() => dispatch("getUsers")) + .then(() => dispatch('getUsers')) .catch(error => console.log(error)); } } diff --git a/src/store/modules/Authentication/AuthenticanStore.js b/src/store/modules/Authentication/AuthenticanStore.js index 3512e2da..88456e95 100644 --- a/src/store/modules/Authentication/AuthenticanStore.js +++ b/src/store/modules/Authentication/AuthenticanStore.js @@ -1,11 +1,11 @@ -import api from "../../api"; -import Cookies from "js-cookie"; +import api from '../../api'; +import Cookies from 'js-cookie'; const AuthenticationStore = { namespaced: true, state: { - status: "", - cookie: Cookies.get("XSRF-TOKEN") + status: '', + cookie: Cookies.get('XSRF-TOKEN') }, getters: { authStatus: state => state.status, @@ -13,35 +13,35 @@ const AuthenticationStore = { }, mutations: { authRequest(state) { - state.status = "loading"; + state.status = 'loading'; }, authSuccess(state) { - state.status = "authenticated"; - state.cookie = Cookies.get("XSRF-TOKEN"); + state.status = 'authenticated'; + state.cookie = Cookies.get('XSRF-TOKEN'); }, authError(state) { - state.status = "error"; + state.status = 'error'; }, logout(state) { - state.status = ""; - Cookies.remove("XSRF-TOKEN"); + state.status = ''; + Cookies.remove('XSRF-TOKEN'); } }, actions: { login({ commit }, auth) { - commit("authRequest"); + commit('authRequest'); return api - .post("/login", { data: auth }) - .then(() => commit("authSuccess")) + .post('/login', { data: auth }) + .then(() => commit('authSuccess')) .catch(error => { - commit("authError"); + commit('authError'); throw new Error(error); }); }, logout({ commit }) { api - .post("/logout", { data: [] }) - .then(() => commit("logout")) + .post('/logout', { data: [] }) + .then(() => commit('logout')) .catch(error => console.log(error)); } } diff --git a/src/store/modules/GlobalStore.js b/src/store/modules/GlobalStore.js index 332c8017..8cf2e8eb 100644 --- a/src/store/modules/GlobalStore.js +++ b/src/store/modules/GlobalStore.js @@ -1,9 +1,9 @@ -import api from "../api"; +import api from '../api'; const GlobalStore = { namespaced: true, state: { - hostName: "--", + hostName: '--', hostStatus: null }, getters: { @@ -22,10 +22,10 @@ const GlobalStore = { actions: { getHostName({ commit }) { api - .get("/xyz/openbmc_project/network/config/attr/HostName") + .get('/xyz/openbmc_project/network/config/attr/HostName') .then(response => { const hostName = response.data.data; - commit("setHostName", hostName); + commit('setHostName', hostName); }) .catch(error => console.log(error)); } diff --git a/src/views/AccessControl/LocalUserManagement/index.js b/src/views/AccessControl/LocalUserManagement/index.js index 9137645d..315748af 100644 --- a/src/views/AccessControl/LocalUserManagement/index.js +++ b/src/views/AccessControl/LocalUserManagement/index.js @@ -1,2 +1,2 @@ -import LocalUserManagement from "./LocalUserManagement.vue"; +import LocalUserManagement from './LocalUserManagement.vue'; export default LocalUserManagement; diff --git a/src/views/Login/index.js b/src/views/Login/index.js index 7fc2b5ca..8fe0250d 100644 --- a/src/views/Login/index.js +++ b/src/views/Login/index.js @@ -1,2 +1,2 @@ -import Login from "./Login.vue"; +import Login from './Login.vue'; export default Login; diff --git a/src/views/Overview/index.js b/src/views/Overview/index.js index 6b0e1aff..8553ef3d 100644 --- a/src/views/Overview/index.js +++ b/src/views/Overview/index.js @@ -1,2 +1,2 @@ -import Overview from "./Overview.vue"; +import Overview from './Overview.vue'; export default Overview; diff --git a/tests/unit/example.spec.js b/tests/unit/example.spec.js index a846fbdb..cb7abba3 100644 --- a/tests/unit/example.spec.js +++ b/tests/unit/example.spec.js @@ -1,9 +1,9 @@ -import { shallowMount } from "@vue/test-utils"; -import HelloWorld from "@/components/HelloWorld.vue"; +import { shallowMount } from '@vue/test-utils'; +import HelloWorld from '@/components/HelloWorld.vue'; -describe("HelloWorld.vue", () => { - it("renders props.msg when passed", () => { - const msg = "new message"; +describe('HelloWorld.vue', () => { + it('renders props.msg when passed', () => { + const msg = 'new message'; const wrapper = shallowMount(HelloWorld, { propsData: { msg } }); diff --git a/vue.config.js b/vue.config.js index 4b7c2924..9e1e1e1a 100644 --- a/vue.config.js +++ b/vue.config.js @@ -1,18 +1,18 @@ -const CompressionPlugin = require("compression-webpack-plugin"); +const CompressionPlugin = require('compression-webpack-plugin'); module.exports = { devServer: { proxy: { - "/": { + '/': { target: process.env.BASE_URL, onProxyRes: proxyRes => { - if (proxyRes.headers["set-cookie"]) { + if (proxyRes.headers['set-cookie']) { // Need to remove 'Secure' flag on set-cookie value so browser // can create cookie for local development - const cookies = proxyRes.headers["set-cookie"].map(cookie => - cookie.replace(/; secure/gi, "") + const cookies = proxyRes.headers['set-cookie'].map(cookie => + cookie.replace(/; secure/gi, '') ); - proxyRes.headers["set-cookie"] = cookies; + proxyRes.headers['set-cookie'] = cookies; } } } @@ -21,7 +21,7 @@ module.exports = { }, productionSourceMap: false, configureWebpack: config => { - if (process.env.NODE_ENV === "production") { + if (process.env.NODE_ENV === 'production') { config.plugins.push( new CompressionPlugin({ deleteOriginalAssets: true @@ -30,9 +30,9 @@ module.exports = { } }, chainWebpack: config => { - if (process.env.NODE_ENV === "production") { - config.plugins.delete("prefetch"); - config.plugins.delete("preload"); + if (process.env.NODE_ENV === 'production') { + config.plugins.delete('prefetch'); + config.plugins.delete('preload'); } } }; |