Skip to content

Commit

Permalink
feat(scan): add "Report fields", override default fields in report
Browse files Browse the repository at this point in the history
  • Loading branch information
popstas committed Mar 11, 2021
1 parent f542bfa commit 87cddf7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
29 changes: 24 additions & 5 deletions pages/scan.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,23 @@
</el-form-item>

<el-form-item label="Ignore robots.txt">
<el-switch v-model="form.ignoreRobotsTxt"></el-switch>
<el-switch v-model="form.ignoreRobotsTxt" title="Scan all found pages"></el-switch>
</el-form-item>

<el-form-item label="Follow sitemap.xml">
<el-switch v-model="form.followXmlSitemap"></el-switch>
</el-form-item>

<el-form-item label="URL contains URL list">
<el-form-item label="URL contains URL list" title="Parse URL as URL list">
<el-switch v-model="form.urlList"></el-switch>
</el-form-item>

<el-form-item label="Report name">
<el-input class="scan__out-name" v-model="form.outName"></el-input>
<el-input class="scan__out-name" v-model="form.outName" title="Default: domain name"></el-input>
</el-form-item>

<el-form-item label="Report fields">
<el-input class="scan__report-fields" v-model="form.reportFields" title="Example: url,h1,readability_length"></el-input>
</el-form-item>

<el-form-item label="Arguments">
Expand Down Expand Up @@ -104,7 +108,7 @@

</el-row>

<NuxtLink :to="'/?url='+itemsJsonUrl" v-if="itemsJsonUrl"
<NuxtLink :to="reportUrl" v-if="itemsJsonUrl"
:class="{'scan__report-link': true, 'el-button': true, 'is-round': true, 'el-button--success': isReportSuccess}"
>
Report: {{ $store.getters.shortReportUrl(itemsJsonUrl) }}
Expand Down Expand Up @@ -221,7 +225,8 @@
font-family: monospace;
}
.scan__out-name {
.scan__out-name,
.scan__report-fields {
width: 180px;
}
Expand Down Expand Up @@ -332,6 +337,10 @@ const controlsMap = {
arg: '--out-name',
// type: 'string',
},
reportFields: {
arg: '--report-fields',
// type: 'string',
},
};
export default {
Expand Down Expand Up @@ -438,6 +447,12 @@ export default {
return this.lastUpdated && !this.currentScanPage;
},
reportUrl() {
return '/?' +
(this.form.reportFields ? `fields=${this.form.reportFields}&` : '') +
`url=${this.itemsJsonUrl}`;
},
urlList() {
return this.urls.
split(/[,\s]/).
Expand Down Expand Up @@ -600,6 +615,7 @@ export default {
args += ' ' + conf.arg;
}
else {
if (val === '') continue;
args += ` ${conf.arg} ${val}`;
}
}
Expand All @@ -622,6 +638,9 @@ export default {
args: this.buildArgs(true, overrides)
};
// hack: remove virtual arg, it used only for report link generate
opts.args = opts.args.replace(/--report-fields .*?(\s|$)/, '');
this.updateUrlQuery(true); // set in url only scanned
Expand Down
1 change: 1 addition & 0 deletions store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const state = () => ({
lighthouse: false,
urlList: false,
outName: '',
reportFields: '',
},

// app state
Expand Down

0 comments on commit 87cddf7

Please sign in to comment.