refactor: fixed more sonarcloud issues

This commit is contained in:
Corentin Thomasset 2021-06-01 00:07:04 +02:00
parent a866ac6070
commit b34eb4c1ac
No known key found for this signature in database
GPG key ID: DBD997E935996158
12 changed files with 32 additions and 109 deletions

View file

@ -1,18 +1,12 @@
<script lang="ts">
import {Component, mixins} from 'nuxt-property-decorator'
import ToolWrapper from '~/components/ToolWrapper.vue'
import type {ToolConfig} from '~/types/ToolConfig'
import {ToolConfigMixin} from '~/mixins/tool-config.mixin'
@Component({
components: {ToolWrapper}
})
export default class Tool extends mixins(ToolConfigMixin) {
config(): ToolConfig {
return {
title: 'ADD A <tool> TAG'
} as unknown as ToolConfig
};
public head() {
const {title, description, keywords} = this.$toolConfig

View file

@ -117,9 +117,6 @@
<nuxt />
</v-container>
</v-main>
<!--<v-footer app>-->
<!-- <span>&copy; {{ new Date().getFullYear() }}</span>-->
<!--</v-footer>-->
</v-app>
</template>
@ -180,10 +177,6 @@ export default class DefaultLayout extends Vue {
}
}
.v-navigation-drawer__content {
.pretty-scrollbar;
}
.v-toolbar__content {
a {
color: #ffffff;
@ -235,6 +228,8 @@ export default class DefaultLayout extends Vue {
}
.v-navigation-drawer__content {
.pretty-scrollbar;
.v-list-item--active {
color: var(--v-anchor-base);
border-left: 3px solid var(--v-primary-base);

View file

@ -11,10 +11,5 @@ import {Component, Vue} from 'nuxt-property-decorator'
@Component
export default class HowToReportBugOrRequest extends Vue {
}
</script>
<style lang="less">
</style>

View file

@ -61,8 +61,8 @@ path: '/base-converter'
<script lang="ts">
import {Component, Ref} from 'nuxt-property-decorator'
import {CopyableMixin} from '~/mixins/copyable.mixin'
import Tool from '~/components/Tool.vue'
import {CopyableMixin} from '~/mixins/copyable.mixin'
import type {VForm} from '~/types/VForm'
const convertBase = (value: string, fromBase: number, toBase: number) => {
@ -117,6 +117,3 @@ export default class BaseConverter extends Tool {
}
}
</script>
<style scoped lang="less">
</style>

View file

@ -53,6 +53,3 @@ export default class Base64StringConverter extends Tool {
}
</script>
<style scoped>
</style>

View file

@ -128,6 +128,3 @@ export default class DateConverter extends Tool {
}
</script>
<style scoped lang="less">
</style>

View file

@ -62,9 +62,9 @@ export default class Bip39Generator extends Tool {
languageList = Object
.keys(bip39.wordlists)
.filter(k => !k.match(/[A-Z]{2}/))
.map(k => ({
text: k.split('_').map(k => k.charAt(0).toUpperCase() + k.slice(1)).join(' '),
value: k
.map(v => ({
text: v.split('_').map(k => k.charAt(0).toUpperCase() + k.slice(1)).join(' '),
value: v
}))
rules = {
@ -103,6 +103,3 @@ export default class Bip39Generator extends Tool {
}
</script>
<style scoped>
</style>

View file

@ -99,6 +99,3 @@ export default class CypherUncyferText extends Tool {
}
}
</script>
<style lang="less">
</style>

View file

@ -71,6 +71,3 @@ export default class HashText extends Tool {
}
</script>
<style>
</style>

View file

@ -2,18 +2,18 @@
<ToolWrapper :config="$toolConfig">
<v-row no-gutters>
<v-col lg="6" md="12">
<v-switch v-model="withLowercase" label="Lowercase (abc...)" />
<v-switch v-model="withUppercase" label="Uppercase (ABC...)" />
<v-switch v-model="config.withLowercase" label="Lowercase (abc...)"/>
<v-switch v-model="config.withUppercase" label="Uppercase (ABC...)"/>
</v-col>
<v-col lg="6" md="12">
<v-switch v-model="withNumbers" label="Numbers (123...)" />
<v-switch v-model="withSpecials" label="Specials (#]-...)" />
<v-switch v-model="config.withNumbers" label="Numbers (123...)"/>
<v-switch v-model="config.withSpecials" label="Specials (#]-...)"/>
</v-col>
</v-row>
<v-slider v-model="length" :label="`Length (${length})`" min="1" max="512" />
<v-slider v-model="config.length" :label="`Length (${config.length})`" min="1" max="512"/>
<v-textarea v-model="token" outlined />
<v-textarea v-model="token" outlined/>
<div class="text-center">
<v-btn depressed class="mr-4" @click="refreshToken()">
@ -30,12 +30,12 @@
title: 'Token generator'
description: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Delectus distinctio dolor dolorum eaque eligendi, facilis impedit laboriosam odit placeat.'
icon: 'mdi-key-chain-variant'
keywords: ['token', 'random', 'string', 'alphanumeric', 'symbols']
keywords: [ 'token', 'random', 'string', 'alphanumeric', 'symbols' ]
path: '/token-generator'
</tool>
<script lang="ts">
import {Component} from 'nuxt-property-decorator'
import {Component, Watch} from 'nuxt-property-decorator'
import Tool from '~/components/Tool.vue'
import {CopyableMixin} from '~/mixins/copyable.mixin'
import {shuffle} from '~/utils/string'
@ -49,42 +49,36 @@ const specials = '.,;:!?./-"\'#{([-|\\@)]=}*+'
mixins: [CopyableMixin]
})
export default class TokenGenerator extends Tool {
withNumbers = true;
withLowercase = true;
withUppercase = true;
withSpecials = false;
length = 64;
refreshBool = true;
refreshToken() {
this.refreshBool = !this.refreshBool
token = '';
config = {
withNumbers: true,
withLowercase: true,
withUppercase: true,
withSpecials: false,
length: 64
}
get token() {
if (this.refreshBool) {
(() => {
})()
} // To force recomputation
created() {
this.refreshToken()
}
@Watch('config', {deep: true})
refreshToken() {
let result = ''
if (this.withLowercase) {
if (this.config.withLowercase) {
result += lowercase
}
if (this.withUppercase) {
if (this.config.withUppercase) {
result += uppercase
}
if (this.withNumbers) {
if (this.config.withNumbers) {
result += numbers
}
if (this.withSpecials) {
if (this.config.withSpecials) {
result += specials
}
return shuffle(result.repeat(this.length)).substring(0, this.length)
this.token = shuffle(result.repeat(this.config.length)).substring(0, this.config.length)
}
}
</script>
<style scoped>
</style>

View file

@ -65,39 +65,4 @@ export default class FileToBase64 extends Tool {
}
}
}
// export default {
// name: 'FileToBase64',
// components: {FileUploader},
// data() {
// return {
// file: undefined,
// loading: false,
// base64: '',
// copyBase64() {
// copyToClipboard(this.base64)
// this.$toast.success('Copied to clipboard.')
// }
// }
// },
// watch: {
// file() {
// this.loading = true
// this.base64 = ''
// const reader = new FileReader()
// reader.onload = () => this.handleBase64(reader.result)
// reader.onerror = () => this.handleBase64('[An error as occurred]')
// reader.readAsDataURL(this.file)
// }
// },
// methods: {
// handleBase64(base64) {
// this.base64 = base64
// this.loading = false
// }
// }
// }
</script>
<style scoped>
</style>

View file

@ -1,7 +1,5 @@
import {random} from './random'
const capitalise = (s: string) => s.charAt(0).toUpperCase() + s.slice(1)
const shuffle = (s: string) => s.split('').sort(() => 0.5 - random()).join('')
const shuffle = (s: string) => s.split('').sort(() => 0.5 - Math.random()).join('')
export {capitalise, shuffle}