Skip to content

Commit

Permalink
auto theme change
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeTWC1984 committed Mar 30, 2024
1 parent a9a6e74 commit 1e1d106
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions htdocs/js/pages/Admin.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ Class.subclass( Page.Base, "Page.Admin", {
onDeactivate: function() {
// called when page is deactivated
// this.div.html( '' );
if(this.observer) this.observer.disconnect()
return true;
}

Expand Down
9 changes: 8 additions & 1 deletion htdocs/js/pages/Home.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ Class.subclass( Page.Base, "Page.Home", {
this.refresh_header_stats();
this.refresh_completed_job_chart();
this.refresh_event_queues();

const self = this;
self.observer = new MutationObserver((mutationList, observer)=> {
self.refresh_completed_job_chart();
});
self.observer.observe(document.querySelector('body'), {attributes: true})

return true;
},
Expand Down Expand Up @@ -404,7 +410,7 @@ Class.subclass( Page.Base, "Page.Home", {
let scaleType = $('#fe_cmp_job_chart_scale').val() || 'logarithmic';

// if chart is already generated only update data
if(app.jobHistoryChart) {
if(app.jobHistoryChart) {
app.jobHistoryChart.data.datasets = datasets;
app.jobHistoryChart.data.labels = labels;
app.jobHistoryChart.options.scales.yAxes[0].type = scaleType;
Expand Down Expand Up @@ -824,6 +830,7 @@ Class.subclass( Page.Base, "Page.Home", {
onDeactivate: function() {
// called when page is deactivated
// this.div.html( '' );
if(this.observer) this.observer.disconnect()
return true;
}

Expand Down
10 changes: 8 additions & 2 deletions htdocs/js/pages/admin/Secrets.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ Class.add( Page.Admin, {
app.setWindowTitle("Secrets");
self.div.addClass('loading');
self.secret = {};
self.secretId = args.id

self.secretId = args.id
if(self.observer) self.observer.disconnect() // kill old observer if set by editor

app.api.post('/api/app/get_secret', { id: args.id || 'globalenv' }, self.receive_secrets.bind(self));
},

Expand Down Expand Up @@ -42,6 +43,11 @@ Class.add( Page.Admin, {

editor.setValue(secret.data || '');

self.observer = new MutationObserver((mutationList, observer)=> {
editor.setOption('theme', app.getPref('theme') == 'light' ? 'default' : 'solarized dark')
});
self.observer.observe(document.querySelector('body'), {attributes: true})

},

receive_secrets: function(resp) {
Expand Down

0 comments on commit 1e1d106

Please sign in to comment.