Fixed toggler for stable/testing channel

This commit is contained in:
Djamil Legato
2016-04-20 15:59:46 -07:00
parent 22464b000d
commit 69459ec611
6 changed files with 43 additions and 6 deletions

View File

@@ -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
View File

@@ -0,0 +1,7 @@
---
title: Generic Ajax
access:
admin.configuration: true
admin.super: true
---

View 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();
}
});
});
}

View File

@@ -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 = {}) {

File diff suppressed because one or more lines are too long

View File

@@ -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>