Don't use duplicated computed value for nginx dir, watch initial value
parent
16a860f5ca
commit
e4f219a286
|
@ -139,9 +139,6 @@ THE SOFTWARE.
|
||||||
activeDomains() {
|
activeDomains() {
|
||||||
return this.$data.domains.map((domain, index) => [domain, index]).filter(d => d[0] !== null);
|
return this.$data.domains.map((domain, index) => [domain, index]).filter(d => d[0] !== null);
|
||||||
},
|
},
|
||||||
nginxDir() {
|
|
||||||
return this.$data.global.nginx.nginxConfigDirectory.computed.replace(/\/+$/, '');
|
|
||||||
},
|
|
||||||
confFiles() {
|
confFiles() {
|
||||||
return generators(this.$data.domains.filter(d => d !== null), this.$data.global);
|
return generators(this.$data.domains.filter(d => d !== null), this.$data.global);
|
||||||
},
|
},
|
||||||
|
@ -217,7 +214,7 @@ THE SOFTWARE.
|
||||||
updateDiff(newConf, oldConf) {
|
updateDiff(newConf, oldConf) {
|
||||||
// Calculate the diff & highlight after render
|
// Calculate the diff & highlight after render
|
||||||
this.$data.confFilesOutput = Object.values(diff(newConf, oldConf)).map(conf => {
|
this.$data.confFilesOutput = Object.values(diff(newConf, oldConf)).map(conf => {
|
||||||
const name = `${escape(this.nginxDir)}/${conf[0]}`;
|
const name = `${escape(this.$data.global.nginx.nginxConfigDirectory.computed)}/${conf[0]}`;
|
||||||
return [
|
return [
|
||||||
name,
|
name,
|
||||||
conf[1],
|
conf[1],
|
||||||
|
|
|
@ -165,7 +165,7 @@ THE SOFTWARE.
|
||||||
<input v-model="sslCertificate"
|
<input v-model="sslCertificate"
|
||||||
class="input"
|
class="input"
|
||||||
type="text"
|
type="text"
|
||||||
:placeholder="`${nginxDir}/ssl/${$parent.$props.data.server.domain.computed}.crt`"
|
:placeholder="`${$parent.$parent.$data.global.nginx.nginxConfigDirectory.computed}/ssl/${$parent.$props.data.server.domain.computed}.crt`"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -182,7 +182,7 @@ THE SOFTWARE.
|
||||||
<input v-model="sslCertificateKey"
|
<input v-model="sslCertificateKey"
|
||||||
class="input"
|
class="input"
|
||||||
type="text"
|
type="text"
|
||||||
:placeholder="`${nginxDir}/ssl/${$parent.$props.data.server.domain.computed}.key`"
|
:placeholder="`${$parent.$parent.$data.global.nginx.nginxConfigDirectory.computed}/ssl/${$parent.$props.data.server.domain.computed}.key`"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -247,28 +247,23 @@ THE SOFTWARE.
|
||||||
};
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'DomainHTTPS', // Component name
|
name: 'DomainHTTPS', // Component name
|
||||||
display: i18n.common.https, // Display name for tab
|
display: i18n.common.https, // Display name for tab
|
||||||
key: 'https', // Key for data in parent
|
key: 'https', // Key for data in parent
|
||||||
delegated: delegatedFromDefaults(defaults), // Data the parent will present here
|
delegated: delegatedFromDefaults(defaults), // Data the parent will present here
|
||||||
components: {
|
components: {
|
||||||
PrettyCheck,
|
PrettyCheck,
|
||||||
PrettyRadio,
|
PrettyRadio,
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
data: Object, // Data delegated back to us from parent
|
data: Object, // Data delegated back to us from parent
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
i18n,
|
i18n,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: computedFromDefaults(defaults, 'https'), // Getters & setters for the delegated data
|
||||||
...computedFromDefaults(defaults, 'https'), // Getters & setters for the delegated data
|
|
||||||
nginxDir() {
|
|
||||||
return this.$parent.$parent.$data.global.nginx.nginxConfigDirectory.computed.replace(/\/+$/, '');
|
|
||||||
},
|
|
||||||
},
|
|
||||||
watch: {
|
watch: {
|
||||||
// Disable everything if https is disabled
|
// Disable everything if https is disabled
|
||||||
'$props.data.https': {
|
'$props.data.https': {
|
||||||
|
|
|
@ -128,6 +128,7 @@ THE SOFTWARE.
|
||||||
const defaults = {
|
const defaults = {
|
||||||
nginxConfigDirectory: {
|
nginxConfigDirectory: {
|
||||||
default: '/etc/nginx/',
|
default: '/etc/nginx/',
|
||||||
|
computed: '/etc/nginx', // We use a watcher to trim trailing slashes
|
||||||
enabled: true,
|
enabled: true,
|
||||||
},
|
},
|
||||||
workerProcesses: {
|
workerProcesses: {
|
||||||
|
@ -170,6 +171,16 @@ THE SOFTWARE.
|
||||||
},
|
},
|
||||||
computed: computedFromDefaults(defaults, 'nginx'), // Getters & setters for the delegated data
|
computed: computedFromDefaults(defaults, 'nginx'), // Getters & setters for the delegated data
|
||||||
watch: {
|
watch: {
|
||||||
|
// Clean nginx directory of trailing slashes
|
||||||
|
'$props.data.nginxConfigDirectory': {
|
||||||
|
handler(data) {
|
||||||
|
// This might cause recursion, but seems not to
|
||||||
|
if (data.enabled)
|
||||||
|
if (data.computed.endsWith('/'))
|
||||||
|
data.computed = data.computed.replace(/\/+$/, '');
|
||||||
|
},
|
||||||
|
deep: true,
|
||||||
|
},
|
||||||
// Check worker processes selection is valid
|
// Check worker processes selection is valid
|
||||||
'$props.data.workerProcesses': {
|
'$props.data.workerProcesses': {
|
||||||
handler(data) {
|
handler(data) {
|
||||||
|
|
|
@ -94,9 +94,6 @@ THE SOFTWARE.
|
||||||
if (index >= 0) return tabs[index];
|
if (index >= 0) return tabs[index];
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
nginxDir() {
|
|
||||||
return this.$props.data.global.nginx.nginxConfigDirectory.computed.replace(/\/+$/, '');
|
|
||||||
},
|
|
||||||
tarName() {
|
tarName() {
|
||||||
const domains = this.$props.data.domains.filter(d => d !== null).map(d => d.server.domain.computed);
|
const domains = this.$props.data.domains.filter(d => d !== null).map(d => d.server.domain.computed);
|
||||||
return `nginxconfig.io-${domains.join(',')}.tar.gz`;
|
return `nginxconfig.io-${domains.join(',')}.tar.gz`;
|
||||||
|
@ -149,7 +146,7 @@ THE SOFTWARE.
|
||||||
|
|
||||||
// Convert it to base64 string
|
// Convert it to base64 string
|
||||||
const b64 = btoa(String.fromCharCode(...contents));
|
const b64 = btoa(String.fromCharCode(...contents));
|
||||||
return `echo '${b64}' | base64 --decode > ${this.nginxDir}/${this.tarName}`;
|
return `echo '${b64}' | base64 --decode > ${this.$props.data.global.nginx.nginxConfigDirectory.computed}/${this.tarName}`;
|
||||||
},
|
},
|
||||||
setupCopy() {
|
setupCopy() {
|
||||||
const originalText = this.$refs.copyTar.textContent;
|
const originalText = this.$refs.copyTar.textContent;
|
||||||
|
|
|
@ -113,9 +113,6 @@ THE SOFTWARE.
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
nginxDir() {
|
|
||||||
return this.$props.data.global.nginx.nginxConfigDirectory.computed.replace(/\/+$/, '');
|
|
||||||
},
|
|
||||||
letsEncryptDir() {
|
letsEncryptDir() {
|
||||||
return this.$props.data.global.https.letsEncryptRoot.computed.replace(/\/+$/, '');
|
return this.$props.data.global.https.letsEncryptRoot.computed.replace(/\/+$/, '');
|
||||||
},
|
},
|
||||||
|
@ -128,12 +125,13 @@ THE SOFTWARE.
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
sitesAvailable() {
|
sitesAvailable() {
|
||||||
if (!this.$props.data.global.tools.modularizedStructure.computed) return `${this.nginxDir}/nginx.conf`;
|
if (!this.$props.data.global.tools.modularizedStructure.computed)
|
||||||
|
return `${this.$props.data.global.nginx.nginxConfigDirectory.computed}/nginx.conf`;
|
||||||
|
|
||||||
const enabledAvailable = this.$props.data.global.tools.symlinkVhost.computed ? 'available' : 'enabled';
|
const enabledAvailable = this.$props.data.global.tools.symlinkVhost.computed ? 'available' : 'enabled';
|
||||||
return this.$props.data.domains
|
return this.$props.data.domains
|
||||||
.filter(domain => domain.https.certType.computed === 'letsEncrypt')
|
.filter(domain => domain.https.certType.computed === 'letsEncrypt')
|
||||||
.map(domain => `${this.nginxDir}/sites-${enabledAvailable}/${domain.server.domain.computed}.conf`)
|
.map(domain => `${this.$props.data.global.nginx.nginxConfigDirectory.computed}/sites-${enabledAvailable}/${domain.server.domain.computed}.conf`)
|
||||||
.join(' ');
|
.join(' ');
|
||||||
},
|
},
|
||||||
certbotCmds() {
|
certbotCmds() {
|
||||||
|
|
|
@ -33,7 +33,7 @@ THE SOFTWARE.
|
||||||
<b> <a @click="$parent.downloadTar">{{ $parent.tarName }}</a></b>
|
<b> <a @click="$parent.downloadTar">{{ $parent.tarName }}</a></b>
|
||||||
<br />
|
<br />
|
||||||
<span v-html="i18n.templates.setupSections.download.andUploadItToYourServers"></span>
|
<span v-html="i18n.templates.setupSections.download.andUploadItToYourServers"></span>
|
||||||
<code class="slim">{{ $parent.nginxDir }}</code>
|
<code class="slim">{{ $props.data.global.nginx.nginxConfigDirectory.computed }}</code>
|
||||||
{{ i18n.templates.setupSections.download.directory }}
|
{{ i18n.templates.setupSections.download.directory }}
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
|
@ -50,7 +50,9 @@ THE SOFTWARE.
|
||||||
<p>
|
<p>
|
||||||
<span v-html="i18n.templates.setupSections.download.navigateToYourNginxConfigurationDirectoryOnYourServer"></span>
|
<span v-html="i18n.templates.setupSections.download.navigateToYourNginxConfigurationDirectoryOnYourServer"></span>
|
||||||
<br />
|
<br />
|
||||||
<BashPrism :key="$parent.nginxDir" :cmd="`cd ${$parent.nginxDir}`"></BashPrism>
|
<BashPrism :key="$props.data.global.nginx.nginxConfigDirectory.computed"
|
||||||
|
:cmd="`cd ${$props.data.global.nginx.nginxConfigDirectory.computed}`"
|
||||||
|
></BashPrism>
|
||||||
</p>
|
</p>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,8 @@ THE SOFTWARE.
|
||||||
<p>
|
<p>
|
||||||
<span v-html="i18n.templates.setupSections.ssl.generateDiffieHellmanKeysByRunningThisCommandOnYourServer"></span>
|
<span v-html="i18n.templates.setupSections.ssl.generateDiffieHellmanKeysByRunningThisCommandOnYourServer"></span>
|
||||||
<br />
|
<br />
|
||||||
<BashPrism :key="`${nginxDir}-${diffieHellmanValue}`"
|
<BashPrism :key="`${$props.data.global.nginx.nginxConfigDirectory.computed}-${diffieHellmanValue}`"
|
||||||
:cmd="`openssl dhparam -out ${nginxDir}/dhparam.pem ${diffieHellmanValue}`"
|
:cmd="`openssl dhparam -out ${$props.data.global.nginx.nginxConfigDirectory.computed}/dhparam.pem ${diffieHellmanValue}`"
|
||||||
></BashPrism>
|
></BashPrism>
|
||||||
</p>
|
</p>
|
||||||
</li>
|
</li>
|
||||||
|
@ -83,9 +83,6 @@ THE SOFTWARE.
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
nginxDir() {
|
|
||||||
return this.$props.data.global.nginx.nginxConfigDirectory.computed.replace(/\/+$/, '');
|
|
||||||
},
|
|
||||||
letsEncryptDir() {
|
letsEncryptDir() {
|
||||||
return this.$props.data.global.https.letsEncryptRoot.computed.replace(/\/+$/, '');
|
return this.$props.data.global.https.letsEncryptRoot.computed.replace(/\/+$/, '');
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue