Click server name in settings to show webview.

This commit is contained in:
Zhongyi Tong
2017-08-04 13:04:43 +08:00
parent 289417e5a9
commit d25d71cb91
4 changed files with 22 additions and 3 deletions

View File

@@ -127,6 +127,7 @@ img.server-info-icon {
.server-info-alias {
font-weight: bold;
cursor: pointer;
}
.server-info-url {
@@ -225,3 +226,9 @@ img.server-info-icon {
.code {
font-family: Courier New, Courier, monospace;
}
i.open-tab-button {
padding: 0 5px;
font-size: 18px;
cursor: pointer;
}

View File

@@ -161,7 +161,7 @@ class ServerManagerView {
}
activateTab(index, hideOldTab = true) {
if (this.tabs[index].loading) {
if (this.tabs[index].webview.loading) {
return;
}
@@ -178,7 +178,7 @@ class ServerManagerView {
}
destroyTab(name, index) {
if (this.tabs[index].loading) {
if (this.tabs[index].webview.loading) {
return;
}

View File

@@ -1,5 +1,6 @@
'use strict';
const {dialog} = require('electron').remote;
const {ipcRenderer} = require('electron');
const BaseComponent = require(__dirname + '/../../components/base.js');
const DomainUtil = require(__dirname + '/../../utils/domain-util.js');
@@ -19,6 +20,7 @@ class ServerInfoForm extends BaseComponent {
<div class="server-info-right">
<div class="server-info-row">
<span class="server-info-alias">${this.props.server.alias}</span>
<i class="material-icons open-tab-button">open_in_new</i>
</div>
<div class="server-info-row">
<input class="server-info-url" disabled value="${this.props.server.url}"/>
@@ -41,7 +43,9 @@ class ServerInfoForm extends BaseComponent {
initForm() {
this.$serverInfoForm = this.generateNodeFromTemplate(this.template());
this.$serverInfoAlias = this.$serverInfoForm.getElementsByClassName('server-info-alias')[0];
this.$deleteServerButton = this.$serverInfoForm.getElementsByClassName('server-delete-action')[0];
this.$openServerButton = this.$serverInfoForm.getElementsByClassName('open-tab-button')[0];
this.props.$root.appendChild(this.$serverInfoForm);
}
@@ -59,6 +63,14 @@ class ServerInfoForm extends BaseComponent {
}
});
});
this.$openServerButton.addEventListener('click', () => {
ipcRenderer.send('forward-message', 'switch-server-tab', this.props.index);
});
this.$serverInfoAlias.addEventListener('click', () => {
ipcRenderer.send('forward-message', 'switch-server-tab', this.props.index);
});
}
}

View File

@@ -50,7 +50,7 @@ class ServersSection extends BaseComponent {
this.$existingServers.innerHTML = servers.length === 0 ? '' : 'Existing servers';
this.initNewServerForm();
for (const i in servers) {
for (let i = 0; i < servers.length; i++) {
new ServerInfoForm({
$root: this.$serverInfoContainer,
server: servers[i],