async connect({ state, commit, dispatch }, { hostname = location.host, username = defaultUsername, password = defaultPassword } = {}) {
			if (!hostname || hostname === defaultMachine) {
				throw new Error('Invalid hostname');
			}
			if (state.machines.hasOwnProperty(hostname)) {
				throw new Error(`Host ${hostname} is already connected!`);
			}
			if (state.isConnecting) {
				throw new Error('Already connecting');
			}

			commit('setConnecting', true);
			try {
				const connectorInstance = await connector.connect(hostname, username, password);
				const moduleInstance = machine(hostname, connectorInstance);
				commit('addMachine', { hostname, moduleInstance });
				connectorInstance.register(moduleInstance);

				commit('setSelectedMachine', hostname);
				logGlobal('success', i18n.t('events.connected', [hostname]));

				if (state.isLocal) {
					commit('settings/setLastHostname', hostname);
				}
				await dispatch('machine/settings/load');
				await dispatch('machine/cache/load');
			} catch (e) {
				if (!(e instanceof InvalidPasswordError) || password !== defaultPassword) {
					logGlobal('error', i18n.t('error.connect', [hostname]), e.message);
				}
				if (e instanceof InvalidPasswordError) {
					commit('askForPassword');
				}
			}
			commit('setConnecting', false);
		}
// Connect to the given hostname using the specified credentials
Connect to the given hostname using the specified credentials
Connect to the given hostname using the specified credentials
async connect({ state, commit, dispatch }, { hostname = location.host, username = defaultUsername, password = defaultPassword } = {}) {
			if (!hostname || hostname === defaultMachine) {
				throw new Error('Invalid hostname');
			}
			if (state.machines.hasOwnProperty(hostname)) {
				throw new Error(`Host ${hostname} is already connected!`);
			}
			if (state.isConnecting) {
				throw new Error('Already connecting');
			}
			commit('setConnecting', true);
			try {
				const connectorInstance = await connector.connect(hostname, username, password);
				const moduleInstance = machine(hostname, connectorInstance);
				commit('addMachine', { hostname, moduleInstance });
				connectorInstance.register(moduleInstance);
				commit('setSelectedMachine', hostname);
				logGlobal('success', i18n.t('events.connected', [hostname]));
				if (state.isLocal) {
					commit('settings/setLastHostname', hostname);
				}
				await dispatch('machine/settings/load');
				await dispatch('machine/cache/load');
			} catch (e) {
				if (!(e instanceof InvalidPasswordError) || password !== defaultPassword) {
					logGlobal('error', i18n.t('error.connect', [hostname]), e.message);
				}
				if (e instanceof InvalidPasswordError) {
					commit('askForPassword');
				}
			}
			commit('setConnecting', false);
		}
async connect ( { state , commit , dispatch } , { hostname = location . host , username = defaultUsername , password = defaultPassword } = { } ) { if ( ! hostname || hostname === defaultMachine ) { throw new Error ( 'Invalid hostname' ) ; } if ( state . machines . hasOwnProperty ( hostname ) ) { throw new Error ( ` ${ hostname } ` ) ; } if ( state . isConnecting ) { throw new Error ( 'Already connecting' ) ; } commit ( 'setConnecting' , true ) ; try { const connectorInstance = await connector . connect ( hostname , username , password ) ; const moduleInstance = machine ( hostname , connectorInstance ) ; commit ( 'addMachine' , { hostname , moduleInstance } ) ; connectorInstance . register ( moduleInstance ) ; commit ( 'setSelectedMachine' , hostname ) ; logGlobal ( 'success' , i18n . t ( 'events.connected' , [ hostname ] ) ) ; if ( state . isLocal ) { commit ( 'settings/setLastHostname' , hostname ) ; } await dispatch ( 'machine/settings/load' ) ; await dispatch ( 'machine/cache/load' ) ; } catch ( e ) { if ( ! ( e instanceof InvalidPasswordError ) || password !== defaultPassword ) { logGlobal ( 'error' , i18n . t ( 'error.connect' , [ hostname ] ) , e . message ) ; } if ( e instanceof InvalidPasswordError ) { commit ( 'askForPassword' ) ; } } commit ( 'setConnecting' , false ) ; }
Connect to the given hostname using the specified credentials
Connect to the given hostname using the specified credentials