Add bot name input

This commit is contained in:
Matthias 2021-08-29 13:15:41 +02:00
parent a330a39fe0
commit f346f49e60
4 changed files with 17 additions and 1 deletions

View File

@ -1,6 +1,15 @@
<template> <template>
<div> <div>
<form ref="form" novalidate @submit.stop.prevent="handleSubmit" @reset="handleReset"> <form ref="form" novalidate @submit.stop.prevent="handleSubmit" @reset="handleReset">
<b-form-group label="Bot Name" label-for="name-input">
<b-form-input
id="name-input"
v-model="auth.botName"
required
placeholder="Bot Name"
@keydown.enter.native="handleOk"
></b-form-input>
</b-form-group>
<b-form-group <b-form-group
:state="urlState" :state="urlState"
label="API Url" label="API Url"
@ -26,6 +35,7 @@
v-model="auth.username" v-model="auth.username"
:state="nameState" :state="nameState"
required required
placeholder="Freqtrader"
@keydown.enter.native="handleOk" @keydown.enter.native="handleOk"
></b-form-input> ></b-form-input>
</b-form-group> </b-form-group>
@ -84,6 +94,7 @@ export default class Login extends Vue {
}; };
auth: AuthPayload = { auth: AuthPayload = {
botName: '',
url: defaultURL, url: defaultURL,
username: '', username: '',
password: '', password: '',

View File

@ -56,6 +56,7 @@ export class UserService {
return info[this.botId]; return info[this.botId];
} }
return { return {
botName: '',
apiUrl: '', apiUrl: '',
refreshToken: '', refreshToken: '',
accessToken: '', accessToken: '',
@ -100,6 +101,7 @@ export class UserService {
); );
if (result.data.access_token && result.data.refresh_token) { if (result.data.access_token && result.data.refresh_token) {
const obj: AuthStorage = { const obj: AuthStorage = {
botName: auth.botName,
apiUrl: auth.url, apiUrl: auth.url,
accessToken: result.data.access_token || '', accessToken: result.data.access_token || '',
refreshToken: result.data.refresh_token || '', refreshToken: result.data.refresh_token || '',
@ -169,6 +171,7 @@ export class UserService {
typeof accessToken === 'string' typeof accessToken === 'string'
) { ) {
const loginInfo: AuthStorage = { const loginInfo: AuthStorage = {
botName: '',
apiUrl, apiUrl,
refreshToken, refreshToken,
accessToken, accessToken,

View File

@ -31,7 +31,7 @@ export default function createBotStore(store) {
}, },
[MultiBotStoreGetters.nextBotId](state: FTMultiBotState): string { [MultiBotStoreGetters.nextBotId](state: FTMultiBotState): string {
let botCount = state.availableBots.length; let botCount = state.availableBots.length;
while (`ftbot.${botCount}` in state.availableBots) { while (state.availableBots.includes(`ftbot.${botCount}`)) {
botCount += 1; botCount += 1;
} }
return `ftbot.${botCount}`; return `ftbot.${botCount}`;

View File

@ -1,10 +1,12 @@
export interface AuthPayload { export interface AuthPayload {
botName: string;
url: string; url: string;
username: string; username: string;
password: string; password: string;
} }
export interface AuthStorage { export interface AuthStorage {
botName: string;
apiUrl: string; apiUrl: string;
refreshToken: string; refreshToken: string;
accessToken: string; accessToken: string;