mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-16 18:26:06 +01:00
Fixed toggler for stable/testing channel
This commit is contained in:
@@ -287,9 +287,10 @@ class AdminController
|
||||
|
||||
// Default release state
|
||||
$release = 'stable';
|
||||
$reload = false;
|
||||
|
||||
// Get the testing release value if set
|
||||
if ($this->grav['uri']->param('release') == 'testing') {
|
||||
if ($this->post['release'] == 'testing') {
|
||||
$release = 'testing';
|
||||
}
|
||||
|
||||
@@ -308,7 +309,11 @@ class AdminController
|
||||
// Save the configuration
|
||||
$data->save();
|
||||
$config->reload();
|
||||
$reload = true;
|
||||
}
|
||||
|
||||
$this->admin->json_response = ['status' => 'success', 'reload' => $reload];
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
7
pages/admin/ajax.md
Normal file
7
pages/admin/ajax.md
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
title: Generic Ajax
|
||||
|
||||
access:
|
||||
admin.configuration: true
|
||||
admin.super: true
|
||||
---
|
||||
24
themes/grav/app/updates/channel-switcher.js
Normal file
24
themes/grav/app/updates/channel-switcher.js
Normal file
@@ -0,0 +1,24 @@
|
||||
import $ from 'jquery';
|
||||
import request from '../utils/request';
|
||||
|
||||
const switcher = $('input[type="radio"][name="channel-switch"]');
|
||||
|
||||
if (switcher) {
|
||||
switcher.on('change', (event) => {
|
||||
let radio = $(event.target);
|
||||
let url = `${radio.parent('[data-url]').data('url')}`;
|
||||
|
||||
request(url, {
|
||||
method: 'post',
|
||||
body: {
|
||||
task: 'gpmRelease',
|
||||
release: radio.val()
|
||||
}
|
||||
},
|
||||
(response) => {
|
||||
if (response.reload) {
|
||||
global.location.reload();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import formatBytes from '../utils/formatbytes';
|
||||
import { Instance as gpm } from '../utils/gpm';
|
||||
import './check';
|
||||
import './update';
|
||||
import './channel-switcher';
|
||||
|
||||
export default class Updates {
|
||||
constructor(payload = {}) {
|
||||
|
||||
4
themes/grav/js/admin.min.js
vendored
4
themes/grav/js/admin.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -1,8 +1,8 @@
|
||||
<form id="gpm-release-toggle">
|
||||
<div class="switch-toggle switch-grav" data-url="{{ base_url }}/task:gpmRelease">
|
||||
<input type="radio" value="stable" id="stable" name="mode-switch" class="highlight" {% if config.system.gpm.releases == 'stable' %} checked="checked"{% endif %}>
|
||||
<div class="switch-toggle switch-grav" data-url="{{ base_url }}/ajax.json/task:gpmRelease">
|
||||
<input type="radio" value="stable" id="stable" name="channel-switch" class="highlight" {% if config.system.gpm.releases == 'stable' %} checked="checked"{% endif %}>
|
||||
<label for="stable">{{ "PLUGIN_ADMIN.STABLE"|tu }}</label>
|
||||
<input type="radio" value="testing" id="testing" name="mode-switch" class="highlight" {% if config.system.gpm.releases == 'testing' %} checked="checked"{% endif %}>
|
||||
<input type="radio" value="testing" id="testing" name="channel-switch" class="highlight" {% if config.system.gpm.releases == 'testing' %} checked="checked"{% endif %}>
|
||||
<label for="testing">{{ "PLUGIN_ADMIN.TESTING"|tu }}</label>
|
||||
<a></a>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user