Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/components/BotCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

<script>
import { mapGetters } from 'vuex';
import getUserInputType from '../utils/getUserInputType';

const quickActionButtons = [
{ name: '2fa', icon: 'lock' },
Expand All @@ -44,6 +45,7 @@
...mapGetters({
nicknames: 'settings/nicknames',
favButtons: 'settings/favButtons',
headless: 'asf/headless',
}),
isPauseButtonSelected() {
return this.selectedButtons.filter(e => e.name === 'pause').length > 0;
Expand Down Expand Up @@ -76,6 +78,13 @@
},
async start() {
try {
const inputType = getUserInputType(this.bot.requiredInput);

if (this.headless && inputType !== 'None') {
this.$router.push({ name: 'bot-input', params: { bot: this.bot.name, type: inputType } });
return;
}

await this.$http.botAction(this.bot.name, 'start');
await this.$store.dispatch('bots/updateBot', { name: this.bot.name, active: true });
} catch (err) {
Expand Down
12 changes: 12 additions & 0 deletions src/i18n/locale/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,18 @@
"global-config": "Global Config",
"info": "Info",
"input-all-selected": "All values selected",
"input-info-login": "You have not set a login name for this account.",
"input-info-password": "You have not set a password for this account.",
"input-info-steamguard": "This account is currently using Steam Guard.",
"input-info-steamparentalcode": "This account is currently using Steam Family View.",
"input-info-twofactorauthentication": "This account is currently using a Steam authenticator app.",
"input-label-login": "Please enter your Steam login name:",
"input-label-password": "Please enter your Steam password:",
"input-label-steamguard": "Please enter the Steam Guard code that has been sent to you:",
"input-label-steamparentalcode": "Please enter your Steam Parental code:",
"input-label-twofactorauthentication": "Please enter your 2FA code from your Steam authenticator app:",
"input-submit": "Submit",
"input-switch-visibility": "Switch input field visibility",
"input-unknown-type": "Unknown field type",
"keep-unchanged": "<keep unchanged>",
"keys-copied": "Copied keys to clipboard!",
Expand Down
1 change: 1 addition & 0 deletions src/models/Bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export class Bot {
this.walletBalance = data.WalletBalance;
this.walletCurrency = data.WalletCurrency;
this.has2FA = data.HasMobileAuthenticator;
this.requiredInput = data.RequiredInput;

this.active = data.KeepRunning;
this.config = data.BotConfig;
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/icons.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
faTimesCircle, faCheckCircle, faEdit, faTimes, faSquare, faMoon, faPalette, faPlay, faQuestion, faPlus,
faSpinner, faKey, faTrash, faCloudDownloadAlt, faSignOutAlt, faAngleDown, faLanguage, faGamepad, faClone,
faCalendarCheck, faLock, faBookOpen, faExclamation, faCodeBranch, faHourglassEnd, faHourglassHalf, faHourglassStart,
faRedoAlt, faClipboard, faPuzzlePiece, faUndoAlt,
faRedoAlt, faClipboard, faPuzzlePiece, faUndoAlt, faEye, faEyeSlash,
} from '@fortawesome/free-solid-svg-icons';

import { FontAwesomeIcon, FontAwesomeLayers } from '@fortawesome/vue-fontawesome';
Expand All @@ -15,7 +15,7 @@ library.add(faWrench, faBars, faLaptop, faUsers, faFileAlt, faTachometerAlt, faP
faClock, faTimesCircle, faCheckCircle, faEdit, faTimes, faSquare, faMoon, faPalette, faPlay, faQuestion,
faPlus, faSpinner, faKey, faTrash, faCloudDownloadAlt, faSignOutAlt, faAngleDown, faLanguage, faGamepad,
faClone, faCalendarCheck, faLock, faGithub, faBookOpen, faExclamation, faCodeBranch, faHourglassEnd, faHourglassHalf,
faHourglassStart, faRedoAlt, faClipboard, faPuzzlePiece, faUndoAlt);
faHourglassStart, faRedoAlt, faClipboard, faPuzzlePiece, faUndoAlt, faEye, faEyeSlash);

export default {
install(Vue) {
Expand Down
9 changes: 9 additions & 0 deletions src/router/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@ export default [
modal: () => import('../views/modals/Bot2FA.vue')
},
meta: { modal: true }
},
{
path: '/page/bot/:bot/input/:type',
name: 'bot-input',
components: {
default: () => import('../views/Bots.vue'),
modal: () => import('../views/modals/BotInput.vue')
},
meta: { modal: true }
},
{
path: '/page/bot/:bot/delete',
Expand Down
4 changes: 4 additions & 0 deletions src/store/modules/asf.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const state = {
uptime: '0s',
updateChannel: 1,
steamOwnerID: '0',
headless: false,
};

export const mutations = {
Expand All @@ -47,6 +48,7 @@ export const mutations = {
},
updateUpdateChannel: (state, updateChannel) => (state.updateChannel = updateChannel),
updateSteamOwnerID: (state, steamOwnerID) => (state.steamOwnerID = steamOwnerID),
updateHeadless: (state, headless) => (state.headless = headless),
};

export const actions = {
Expand All @@ -69,6 +71,7 @@ export const actions = {
commit('calculateUptime');
commit('updateUpdateChannel', response.GlobalConfig.UpdateChannel);
commit('updateSteamOwnerID', response.GlobalConfig.s_SteamOwnerID);
commit('updateHeadless', response.GlobalConfig.Headless);
} catch (err) {
console.warn(err.message);
}
Expand All @@ -87,4 +90,5 @@ export const getters = {
startTime: state => state.startTime,
updateChannel: state => state.updateChannel,
steamOwnerID: state => state.steamOwnerID,
headless: state => state.headless,
};
14 changes: 14 additions & 0 deletions src/utils/getUserInputType.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Todo: Read EUserInputType from api
Comment thread
MrBurrBurr marked this conversation as resolved.

const types = {
None: 0,
Login: 1,
Password: 2,
SteamGuard: 3,
SteamParentalCode: 4,
TwoFactorAuthentication: 5,
};

export default function getUserInputType(id) {
return Object.keys(types)[id];
}
13 changes: 12 additions & 1 deletion src/views/modals/Bot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,18 @@
import BotFarmingInfo from '../../components/BotFarmingInfo.vue';
import BotGames from '../../components/BotGames.vue';
import BotLink from '../../components/BotLink.vue';
import getUserInputType from '../../utils/getUserInputType';

export default {
name: 'bot',
components: {
BotAction, BotFarmingInfo, BotGames, BotLink,
},
computed: {
...mapGetters({ nicknames: 'settings/nicknames' }),
...mapGetters({
nicknames: 'settings/nicknames',
headless: 'asf/headless',
}),
bot() {
return this.$store.getters['bots/bot'](this.$route.params.bot);
},
Expand Down Expand Up @@ -100,6 +104,13 @@
await this.update({ paused: false });
},
async start() {
const inputType = getUserInputType(this.bot.requiredInput);

if (this.headless && inputType !== 'None') {
this.$router.push({ name: 'bot-input', params: { bot: this.bot.name, type: inputType } });
return;
}

await this.action('start');
await this.update({ active: true });
},
Expand Down
106 changes: 106 additions & 0 deletions src/views/modals/BotInput.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<template>
<main v-if="bot" class="main-container">
<h2 v-if="bot.nickname && nicknames" class="title">{{ bot.nickname }}</h2>
<h2 v-else class="title">{{ bot.name }}</h2>

<div class="form-item">
<div class="form-item__info">{{ $t(`input-info-${inputType}`) }}</div>
<div class="form-item__code">
<div>
<label for="input" class="form-item__label">{{ $t(`input-label-${inputType}`) }}</label>
<input id="input" class="form-item__input" type="password" autocomplete="new-password" v-model="code" />
</div>
<div class="form-item__buttons form-item__buttons--column">
<button class="button button--helper" :title="$t('input-switch-visibility')" @click="switchInputType">
<font-awesome-icon v-if="inputHidden" icon="eye" size="lg"></font-awesome-icon>
<font-awesome-icon v-else icon="eye-slash" size="lg"></font-awesome-icon>
</button>
</div>
</div>
<div class="form-item__buttons form-item__buttons--center">
<button class="button button--confirm" @click="submit">
<font-awesome-icon v-if="submitting" icon="spinner" spin></font-awesome-icon>
<span v-else>{{ $t('input-submit') }}</span>
</button>
</div>
</div>
</main>
</template>

<script>
import { mapGetters } from 'vuex';

export default {
name: 'bot-input',
data() {
return {
submitting: false,
code: '',
inputHidden: true,
};
},
computed: {
...mapGetters({ nicknames: 'settings/nicknames' }),
bot() {
return this.$store.getters['bots/bot'](this.$route.params.bot);
},
inputType() {
return this.$route.params.type.toLowerCase();
},
},
async created() {
if (!this.bot || !this.$route.params.type) this.$router.replace({ name: 'bots' });
},
mounted() {
document.getElementById('input').focus();
},
methods: {
switchInputType() {
this.inputHidden = !this.inputHidden;
const field = document.getElementById('input');

if (field.getAttribute('type') === 'password') field.setAttribute('type', 'text');
else field.setAttribute('type', 'password');
},
async submit() {
if (this.submitting) return;

this.submitting = true;

try {
await this.$http.post(`bot/${this.bot.name}/input`, { type: this.bot.requiredInput, value: this.code });
Comment thread
MrBurrBurr marked this conversation as resolved.
Outdated
await this.$http.botAction(this.bot.name, 'start');
await this.$store.dispatch('bots/updateBot', { name: this.bot.name, active: true });

this.$router.back();
} catch (err) {
this.$error(err.message);
} finally {
this.submitting = false;
}
},
},
};
</script>

<style lang="scss">
.form-item__info {
padding-bottom: 1em;
}

.form-item__code {
display: grid;
grid-column-gap: 0.5em;
grid-template-columns: 1fr auto;
align-items: flex-end;
padding-bottom: 1em;

:focus {
outline: none;
}
}

.button--helper {
max-width: 2em;
}
</style>