${this.edit.plainBox ? html`
` : html`
`}
-
+
+
+
${this.alertLine}
@@ -57,6 +65,14 @@ render() {
`;
}
+extChange(e){
+ this.edit.ext = e.target.value;
+ localStorage.setItem('config_editorExt',this.edit.ext);
+ this.openedFile = '';
+ this.oldText(this);
+ this.List();
+}
+
plainChange(e){
if(this.edit.plainBox = !this.edit.plainBox){
localStorage.setItem('config_editorPlain','1');
@@ -95,10 +111,10 @@ async Coder(){
}
async List(){
this.infoLine = 'List Loading...';
- const e=(await this._hass.callWS({type: "config_editor/ws", action: 'list', data: '', file: ''}));
+ const e=(await this._hass.callWS({type: "config_editor/ws", action: 'list', data: '', file: '', ext: this.edit.ext}));
this.infoLine = e.msg;
this.fileList = e.file.slice().sort();
- if(this.openedFile){
+ if(this.openedFile.endsWith("."+this.edit.ext)){
setTimeout(this.oldText, 500, this);
}
}
@@ -108,7 +124,7 @@ async Load(x) {
this.openedFile = x.target.value
if(this.openedFile){
this.infoLine = 'Loading: '+this.openedFile;
- const e=(await this._hass.callWS({type: "config_editor/ws", action: 'load', data: '', file: this.openedFile}));
+ const e=(await this._hass.callWS({type: "config_editor/ws", action: 'load', data: '', file: this.openedFile, ext: this.edit.ext}));
this.openedFile = e.file;
this.infoLine = e.msg;
const uns={f:localStorage.getItem('config_editorOpen'),d:localStorage.getItem('config_editorText')};
@@ -134,7 +150,7 @@ async Save() {
if(this.openedFile && this.openedFile.endsWith(".yaml")){
if(!this.code){this.infoLine='';this.infoLine = 'Text is empty!'; return;}
this.infoLine = 'Saving: '+this.openedFile;
- const e=(await this._hass.callWS({type: "config_editor/ws", action: 'save', data: this.code, file: this.openedFile}));
+ const e=(await this._hass.callWS({type: "config_editor/ws", action: 'save', data: this.code, file: this.openedFile, ext: this.edit.ext}));
this.infoLine = e.msg;
localStorage.removeItem('config_editorText');
}else{this.openedFile='';}
@@ -146,7 +162,7 @@ getCardSize() {
}
setConfig(config) {
- this.edit = {options: config, plainBox: false};
+ this.edit = {options: config, plainBox: false, ext: ''};
this.Coder();
}