Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
javalikescript committed Dec 26, 2024
1 parent 01fac85 commit 7c351b9
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 39 deletions.
4 changes: 1 addition & 3 deletions extensions/hue-v2/hue-v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ define(['./hue-v2.xml'], function(aPageTemplate) {
fetch('/hue-api/config', {
method: 'PUT',
body: JSON.stringify({touchlink: true})
}).then(function(response) {
return response.text();
}).then(function(logLevel) {
}).then(assertIsOk).then(getResponseText).then(function(logLevel) {
page.logLevel = logLevel.toLowerCase();
});
}
Expand Down
4 changes: 1 addition & 3 deletions extensions/web-base/www/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -539,9 +539,7 @@ var homePage = new Vue({
var self = this;
self.working = true;
toaster.toast('Backup in progress...');
fetch('/engine/admin/backup/create', {method: 'POST'}).then(assertIsOk).then(function(response) {
return response.text();
}).then(function(filename) {
fetch('/engine/admin/backup/create', {method: 'POST'}).then(assertIsOk).then(getResponseText).then(function(filename) {
self.filename = filename;
toaster.toast('Backup created');
}).finally(function() {
Expand Down
8 changes: 2 additions & 6 deletions extensions/web-chart/web-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,7 @@ define(['./web-chart.xml'], function(pageXml) {
fetch('/engine/historicalData/', {
method: 'GET',
headers: headers
}).then(function(response) {
return response.json();
}).then(function(dataPointSets) {
}).then(getResponseJson).then(function(dataPointSets) {
//console.log('fetch()', response);
var dates = null;
var datasets = [];
Expand All @@ -219,9 +217,7 @@ define(['./web-chart.xml'], function(pageXml) {
fetch('/engine/historicalData/' + path, {
method: 'GET',
headers: this.getHistoricalDataHeaders()
}).then(function(response) {
return response.json();
}).then(function(dataPointSet) {
}).then(getResponseJson).then(function(dataPointSet) {
//console.log('fetch()', response);
self.createChart(listDates(dataPointSet), createChartDataSets(dataPointSet));
});
Expand Down
25 changes: 7 additions & 18 deletions extensions/web-scripts/web-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,12 +305,8 @@ define(['./scripts.xml', './scripts-add.xml',
return Promise.reject('workspace not initialized');
}
return Promise.all([
fetch(scriptFilesPath + this.scriptId + '/blocks.xml').then(function(response) {
return response.text();
}),
fetch(scriptFilesPath + this.scriptId + '/manifest.json').then(function(response) {
return response.json();
})
fetch(scriptFilesPath + this.scriptId + '/blocks.xml').then(getResponseText),
fetch(scriptFilesPath + this.scriptId + '/manifest.json').then(getResponseJson)
]).then(apply(this, function(xmlText, manifest) {
workspace.clear();
var xml = Blockly.Xml.textToDom(xmlText);
Expand Down Expand Up @@ -340,14 +336,13 @@ define(['./scripts.xml', './scripts-add.xml',
onRename: onRename,
onApply: onApply,
onSave: function() {
var scriptId = this.scriptId;
console.log('scriptsEditor.onSave(), scriptId is "' + scriptId + '"');
if (!scriptId) {
console.log('scriptsEditor.onSave(), scriptId is "' + this.scriptId + '"');
if (!this.scriptId) {
return;
}
return Promise.all([
fetch(scriptFilesPath + scriptId + '/view.xml', {method: 'PUT', body: this.text}).then(assertIsOk),
fetch(scriptFilesPath + scriptId + '/init.js', {method: 'PUT', body: viewInitJs}).then(assertIsOk)
fetch(scriptFilesPath + this.scriptId + '/view.xml', {method: 'PUT', body: this.text}).then(assertIsOk),
fetch(scriptFilesPath + this.scriptId + '/init.js', {method: 'PUT', body: viewInitJs}).then(assertIsOk)
]).then(function() {
toaster.toast('Saved');
});
Expand Down Expand Up @@ -486,13 +481,7 @@ define(['./scripts.xml', './scripts-add.xml',
onShow: function () {
this.scripts = [];
var self = this;
fetch(scriptPath, {
headers: {
"Accept": 'application/json'
}
}).then(function(response) {
return response.json();
}).then(function(scripts) {
fetch(scriptPath, {headers: {"Accept": 'application/json'}}).then(getResponseJson).then(function(scripts) {
self.scripts = scripts;
});
},
Expand Down
12 changes: 3 additions & 9 deletions extensions/web-tools/web-tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ define(['./web-tools.xml'], function(toolsTemplate) {
methods: {
onShow: function() {
var page = this;
fetch('/engine/admin/getLogLevel').then(function(response) {
return response.text();
}).then(function(logLevel) {
fetch('/engine/admin/getLogLevel').then(getResponseText).then(function(logLevel) {
page.logLevel = logLevel.toLowerCase();
});
},
Expand All @@ -48,18 +46,14 @@ define(['./web-tools.xml'], function(toolsTemplate) {
execute: function() {
var page = this;
page.cmdOut = '';
fetch('/engine/tools/execute', {method: 'POST', body: this.cmd}).then(assertIsOk).then(function(response) {
return response.text();
}).then(function(out) {
fetch('/engine/tools/execute', {method: 'POST', body: this.cmd}).then(assertIsOk).then(getResponseText).then(function(out) {
page.cmdOut = out;
});
},
run: function() {
var page = this;
page.luaOut = '';
fetch('/engine/tools/run', {method: 'POST', body: this.lua}).then(assertIsOk).then(function(response) {
return response.text();
}).then(function(out) {
fetch('/engine/tools/run', {method: 'POST', body: this.lua}).then(assertIsOk).then(getResponseText).then(function(out) {
page.luaOut = out;
});
},
Expand Down

0 comments on commit 7c351b9

Please sign in to comment.