|
|
@ -80,11 +80,11 @@ THE SOFTWARE.
|
|
|
|
<div :class="`column ${splitColumn ? 'is-half' : 'is-full'} is-full-mobile is-full-tablet`">
|
|
|
|
<div :class="`column ${splitColumn ? 'is-half' : 'is-full'} is-full-mobile is-full-tablet`">
|
|
|
|
<h2>{{ i18n.templates.app.configFiles }}</h2>
|
|
|
|
<h2>{{ i18n.templates.app.configFiles }}</h2>
|
|
|
|
<div ref="files" class="columns is-multiline">
|
|
|
|
<div ref="files" class="columns is-multiline">
|
|
|
|
<NginxPrism v-for="(conf, i) in confFilesOutput"
|
|
|
|
<NginxPrism v-for="(confContents, confName) in confFilesOutput"
|
|
|
|
:key="`${conf[0]}-${i}-${hash(conf[1])}`"
|
|
|
|
:key="`${confName}-${hash(confContents)}`"
|
|
|
|
:name="`${nginxDir}/${conf[0]}`"
|
|
|
|
:name="`${nginxDir}/${confName}`"
|
|
|
|
:conf="conf[1]"
|
|
|
|
:conf="confContents"
|
|
|
|
:half="confFilesOutput.length > 1 && !splitColumn"
|
|
|
|
:half="Object.keys(confFilesOutput).length > 1 && !splitColumn"
|
|
|
|
></NginxPrism>
|
|
|
|
></NginxPrism>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
@ -132,8 +132,8 @@ THE SOFTWARE.
|
|
|
|
ready: false,
|
|
|
|
ready: false,
|
|
|
|
splitColumn: false,
|
|
|
|
splitColumn: false,
|
|
|
|
confWatcherWaiting: false,
|
|
|
|
confWatcherWaiting: false,
|
|
|
|
confFilesPrevious: [],
|
|
|
|
confFilesPrevious: {},
|
|
|
|
confFilesOutput: [],
|
|
|
|
confFilesOutput: {},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
},
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
computed: {
|
|
|
@ -222,17 +222,21 @@ THE SOFTWARE.
|
|
|
|
this.$nextTick(() => this.checkChange(this.confFiles));
|
|
|
|
this.$nextTick(() => this.checkChange(this.confFiles));
|
|
|
|
},
|
|
|
|
},
|
|
|
|
updateDiff(newConf, oldConf) {
|
|
|
|
updateDiff(newConf, oldConf) {
|
|
|
|
|
|
|
|
const newFiles = {};
|
|
|
|
|
|
|
|
|
|
|
|
// Work through each file in the new config
|
|
|
|
// Work through each file in the new config
|
|
|
|
const newFiles = [];
|
|
|
|
for (const newFileName in newConf) {
|
|
|
|
for (const [newFileName, newFileConf] of newConf) {
|
|
|
|
if (!Object.prototype.hasOwnProperty.call(newConf, newFileName)) continue;
|
|
|
|
|
|
|
|
const newFileConf = newConf[newFileName];
|
|
|
|
|
|
|
|
|
|
|
|
// If a file with the same name existed before, diff!
|
|
|
|
// If a file with the same name existed before, diff!
|
|
|
|
// TODO: Handle diffing across file renames (eg. when a user changes a domain name)
|
|
|
|
// TODO: Handle diffing across file renames (eg. when a user changes a domain name)
|
|
|
|
const old = oldConf && oldConf.find(c => c[0] === newFileName);
|
|
|
|
const old = oldConf && oldConf[newFileName];
|
|
|
|
if (old && this.hash(old[1]) !== this.hash(newFileConf)) {
|
|
|
|
if (old && this.hash(old) !== this.hash(newFileConf)) {
|
|
|
|
console.info(`Diffing ${newFileName}...`);
|
|
|
|
console.info(`Diffing ${newFileName}...`);
|
|
|
|
|
|
|
|
|
|
|
|
// Get the diff
|
|
|
|
// Get the diff
|
|
|
|
const diff = diffLines(old[1], newFileConf);
|
|
|
|
const diff = diffLines(old, newFileConf);
|
|
|
|
|
|
|
|
|
|
|
|
// Wrap additions in <mark>, drop removals
|
|
|
|
// Wrap additions in <mark>, drop removals
|
|
|
|
const output = diff.map((change, index, array) => {
|
|
|
|
const output = diff.map((change, index, array) => {
|
|
|
@ -263,13 +267,15 @@ THE SOFTWARE.
|
|
|
|
}).join('');
|
|
|
|
}).join('');
|
|
|
|
|
|
|
|
|
|
|
|
// Store
|
|
|
|
// Store
|
|
|
|
newFiles.push([newFileName, output]);
|
|
|
|
newFiles[newFileName] = output;
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// No diffing, just store the new file
|
|
|
|
// No diffing, just store the new file
|
|
|
|
newFiles.push([newFileName, newFileConf]);
|
|
|
|
newFiles[newFileName] = newFileConf;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Store
|
|
|
|
this.$data.confFilesOutput = newFiles;
|
|
|
|
this.$data.confFilesOutput = newFiles;
|
|
|
|
this.$nextTick(() => this.$data.confWatcherWaiting = false);
|
|
|
|
this.$nextTick(() => this.$data.confWatcherWaiting = false);
|
|
|
|
},
|
|
|
|
},
|
|
|
|