Skip to content

Commit

Permalink
feat: feature flags, disable interface parts
Browse files Browse the repository at this point in the history
  • Loading branch information
popstas committed Jun 23, 2021
1 parent 42d9661 commit a65de65
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 20 deletions.
1 change: 1 addition & 0 deletions components/FilterPresetButton.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<button
@click="setPreset"
v-if="$store.state.flags.navigation"
class="filter-presets__button"
:title="'Filter:\n' + preset.q"
:class="{
Expand Down
6 changes: 3 additions & 3 deletions layouts/default.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<el-container>
<el-header height="66px">
<el-header height="66px" v-if="$store.state.serverUrl || $store.state.flags.login">
<el-row>
<el-col :span="12">
<el-menu :default-active="activeIndex" mode="horizontal" @select="handleSelect" class="header__menu">
Expand All @@ -9,7 +9,7 @@
</el-menu>
</el-col>
<el-col :span="12">
<Profile></Profile>
<Profile v-if="$store.state.flags.login"></Profile>
</el-col>
</el-row>
</el-header>
Expand All @@ -18,7 +18,7 @@
<nuxt />
</el-main>

<el-footer height="36px">
<el-footer v-if="$store.state.flags.footer" height="36px">
<a
target="_blank"
href="https://github.com/viasite/site-audit-seo-viewer/releases"
Expand Down
7 changes: 6 additions & 1 deletion nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ module.exports = {
JSON_URL: process.env.JSON_URL,
SERVER_URL: process.env.SERVER_URL,
SCAN_DEFAULT_MAX_REQUESTS: parseInt(process.env.SCAN_DEFAULT_MAX_REQUESTS),
NO_FOOTER: process.env.NO_FOOTER,
NO_LOGIN: process.env.NO_LOGIN,
NO_FILTERS: process.env.NO_FILTERS,
NO_TOUR: process.env.NO_TOUR,
NO_NAVIGATION: process.env.NO_NAVIGATION,
},

io: {
Expand All @@ -60,7 +65,7 @@ module.exports = {

head: {
link: [
// { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
{ rel: 'icon', type: 'image/x-icon', href: process.env.FAVICON || '/favicon.ico' },
{ rel: 'stylesheet', href: 'https://stackpath.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css' }
]
},
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"dev-popstas": "cross-env SERVER_URL=http://popstas-server:5301 HOST=0.0.0.0 PORT=5302 nuxt",
"dev-popstas-prod": "cross-env SCAN_DEFAULT_MAX_REQUESTS=10 FRONTEND_URL=https://site-audit.popstas.ru SERVER_URL=https://site-audit-server.popstas.ru HOST=0.0.0.0 PORT=5302 nuxt",
"dev-popstas-prod-stable": "cross-env SCAN_DEFAULT_MAX_REQUESTS=10 FRONTEND_URL=https://site-audit.popstas.ru SERVER_URL=https://site-audit-server-stable.popstas.ru HOST=0.0.0.0 PORT=5302 nuxt",
"dev-no-interface": "cross-env NO_NAVIGATION=1 NO_LOGIN=1 NO_FOOTER=1 NO_FILTERS=1 NO_TOUR=1 SERVER_URL=\"\" HOST=0.0.0.0 PORT=5302 nuxt",
"dev-clean": "nuxt",
"build": "nuxt build",
"deploy-prod": "bash scripts/deploy.sh",
Expand Down
3 changes: 3 additions & 0 deletions pages/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,9 @@ header {
top: 0;
box-shadow: 0 0 3px #ccc;
}
.VueTables__filters-row th {
top: 45px;
}

.VueTables__child-row-toggler {
position: absolute;
Expand Down
20 changes: 10 additions & 10 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
</div>

<div v-else>
<v-tour name="introTour" :steps="introTourSteps" :options="{ highlight: true }"></v-tour>
<v-tour v-if="$store.state.flags.tour" name="introTour" :steps="introTourSteps" :options="{ highlight: true }"></v-tour>

<header>
<header v-if="$store.state.flags.navigation">
<el-button
v-if="$store.state.flags.tour"
class="help-tour-button"
:plain="!isNewUser"
:type="isNewUser ? 'primary' : ''" @click="startIntroTour"
Expand All @@ -27,23 +28,22 @@

<div class="total">total: {{ filteredItems.length }}</div>
</header>
<br>

<div v-if="jsonLoadError">
<div class="msg danger">Failed to load {{ itemsJsonUrl}}</div>
</div>
<div v-if="jsonLoading"><i class="el-icon-loading"></i> Loading...</div>

<div v-if="!jsonLoading && !jsonLoadError">
<el-collapse v-model="openedPanels" class="panels">
<el-collapse v-if="$store.state.flags.navigation" v-model="openedPanels" class="panels">

<!-- Тулбар -->
<Panel title="columns explorer" icon="el-icon-folder-opened" name="columns">
<Toolbar @toggleField="toggleField" @setFields="setFields"></Toolbar>
</Panel>

<!-- Выбранные колонки -->
<Panel title="current columns" icon="el-icon-caret-right" name="current_columns" class="current-columns">
<!-- <Panel title="current columns" icon="el-icon-caret-right" name="current_columns" class="current-columns">
<ColumnField
:field="field"
:checked="$store.getters.fieldExists(field)"
Expand All @@ -52,7 +52,7 @@
v-for="field of fields"
:key="field.name"
></ColumnField>
</Panel>
</Panel> -->

<!-- Сводка по таблице -->
<Panel title="filtered stats" icon="el-icon-s-data" name="stats">
Expand Down Expand Up @@ -86,11 +86,11 @@

</el-collapse>

<div><br>
<div v-if="$store.state.flags.navigation"><br>
total: {{ filteredItems.length }}
</div>

<div class="table-actions">
<div class="table-actions" v-if="$store.state.flags.navigation">
<el-checkbox class="human-columns-switch" v-model="showHumanColumns">
Human column names
</el-checkbox>
Expand All @@ -114,7 +114,7 @@
<ItemDetails @hideTable="onHideTable" :item="$store.getters.getItemByDefaultField(props.row[$store.state.defaultField])"></ItemDetails>
</template>
<template slot="prependHead">
<tr class="table__column-controls">
<tr v-if="$store.state.flags.navigation" class="table__column-controls">
<td></td>
<td v-for="field in fields" :key="field.name">
<ColumnField
Expand Down Expand Up @@ -791,7 +791,7 @@ export default {
if (field.type === 'boolean') {
if (valueText == 'true' || valueText === true) valueText = 1;
valueText = parseInt(valueText) ? "yes" : "no"; // tolang
valueText = parseInt(valueText) ? "Yes" : "No"; // tolang
}
return valueText;
Expand Down
38 changes: 32 additions & 6 deletions store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ export const state = () => ({

// constants
itemsJsonUrl: process.env.JSON_URL || '',
flags: {
footer: !process.env.HIDE_FOOTER,
login: !process.env.NO_LOGIN,
filters: !process.env.NO_FILTERS,
tour: !process.env.NO_TOUR,
navigation: !process.env.NO_NAVIGATION,
compare: false,
},
jsonUrlHistory: {},
compareList: [],
scanHistory: [],
Expand All @@ -34,10 +42,6 @@ export const state = () => ({
presetName: '',
},

flags: {
compare: false,
},

// app state
visitCount: 0,
fields: [],
Expand Down Expand Up @@ -223,7 +227,16 @@ export const getters = {
if(res) {
const operator = res[1];
let expected = res[2];
if(!['==', '==='].includes(operator)) expected = parseFloat(expected);

console.log('expected: ', expected);
const dateNow = expected.match(/^\{now\}([\+\-])(\d+)$/);
if (dateNow) {
const k = dateNow == '+' ? 1 : -1;
expected = Date.now() + parseInt(dateNow[2] * k);
console.log('expected2: ', expected);
console.log('new Date(expected): ', new Date(expected));
}
else if(!['==', '==='].includes(operator)) expected = parseFloat(expected);

// always not match for empty values (except 0)
const funcReturn = (val, condition) => {
Expand Down Expand Up @@ -613,7 +626,20 @@ function fieldsByItems(items, tests){
const info = tests[fieldName];
if (info) {
// TODO: remove fields list?
for (let fName of ['comment', 'description', 'command', 'validate', 'default', 'align', 'type', 'stat', 'filterType']) {
const fieldsAllowed = [
'comment',
'description',
'command',
'validate',
'default',
'align',
'type',
'stat',
'filterType',
'href',
'format',
];
for (let fName of fieldsAllowed) {
if(info[fName]) field[fName] = info[fName];
}
}
Expand Down

0 comments on commit a65de65

Please sign in to comment.