diff --git a/classes/controller.php b/classes/controller.php index 22a3f4fd3..905e6ca05 100644 --- a/classes/controller.php +++ b/classes/controller.php @@ -287,9 +287,10 @@ protected function taskGpmRelease() // 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 @@ protected function taskGpmRelease() // Save the configuration $data->save(); $config->reload(); + $reload = true; } + + $this->admin->json_response = ['status' => 'success', 'reload' => $reload]; + return true; } /** diff --git a/pages/admin/ajax.md b/pages/admin/ajax.md new file mode 100644 index 000000000..3dc67f725 --- /dev/null +++ b/pages/admin/ajax.md @@ -0,0 +1,7 @@ +--- +title: Generic Ajax + +access: + admin.configuration: true + admin.super: true +--- diff --git a/themes/grav/app/updates/channel-switcher.js b/themes/grav/app/updates/channel-switcher.js new file mode 100644 index 000000000..8531eb86a --- /dev/null +++ b/themes/grav/app/updates/channel-switcher.js @@ -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(); + } + }); + }); +} diff --git a/themes/grav/app/updates/index.js b/themes/grav/app/updates/index.js index 215400404..a6a0df015 100644 --- a/themes/grav/app/updates/index.js +++ b/themes/grav/app/updates/index.js @@ -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 = {}) { diff --git a/themes/grav/js/admin.min.js b/themes/grav/js/admin.min.js index b55ec4dd0..1af4e28ef 100644 --- a/themes/grav/js/admin.min.js +++ b/themes/grav/js/admin.min.js @@ -1,7 +1,7 @@ var Grav=webpackJsonpGrav([0],[function(e,t,n){(function(e){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var i=n(1),o=r(i),a=n(2),s=r(a),u=n(301),c=r(u),l=n(302),f=r(l),d=n(307),h=r(d),p=n(312),m=r(p),v=n(395),g=r(v),_=n(494),y=r(_);n(496),n(498),n(499),n(500),n(501),n(502);var b=n(504),k=r(b);c["default"].start(),e.setInterval(function(){_.Instance.update(),b.Instance.scroller.update()},150),(0,o["default"])(e).on("sidebar_state._grav",function(){(0,o["default"])(".admin-menu-wrapper").data("scrollbar").update(),(0,o["default"])("#admin-main .content-wrapper").data("scrollbar").update(),Object.keys(h["default"].Chart.Instances).forEach(function(e){h["default"].Chart.Instances[e].chart.update()})}),t["default"]={GPM:{GPM:s["default"],Instance:a.Instance},KeepAlive:c["default"],Dashboard:h["default"],Pages:m["default"],Forms:g["default"],Scrollbar:{Scrollbar:y["default"],Instance:_.Instance},Updates:{Updates:f["default"],Instance:l.Instance},Sidebar:{Sidebar:k["default"],Instance:b.Instance}}}).call(t,function(){return this}())},,function(e,t,n){(function(e){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0}),t.Instance=void 0;var a=function(){function e(e,t){for(var n=0;n-1?t:e}function f(e,t){t=t||{};var n=t.body;if(f.prototype.isPrototypeOf(e)){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new i(e.headers)),this.method=e.method,this.mode=e.mode,n||(n=e._bodyInit,e.bodyUsed=!0)}else this.url=e;if(this.credentials=t.credentials||this.credentials||"omit",!t.headers&&this.headers||(this.headers=new i(t.headers)),this.method=l(t.method||this.method||"GET"),this.mode=t.mode||this.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&n)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(n)}function d(e){var t=new FormData;return e.trim().split("&").forEach(function(e){if(e){var n=e.split("="),r=n.shift().replace(/\+/g," "),i=n.join("=").replace(/\+/g," ");t.append(decodeURIComponent(r),decodeURIComponent(i))}}),t}function h(e){var t=new i,n=e.getAllResponseHeaders().trim().split("\n");return n.forEach(function(e){var n=e.trim().split(":"),r=n.shift().trim(),i=n.join(":").trim();t.append(r,i)}),t}function p(e,t){t||(t={}),this.type="default",this.status=t.status,this.ok=this.status>=200&&this.status<300,this.statusText=t.statusText,this.headers=t.headers instanceof i?t.headers:new i(t.headers),this.url=t.url||"",this._initBody(e)}if(!e.fetch){i.prototype.append=function(e,t){e=n(e),t=r(t);var i=this.map[e];i||(i=[],this.map[e]=i),i.push(t)},i.prototype["delete"]=function(e){delete this.map[n(e)]},i.prototype.get=function(e){var t=this.map[n(e)];return t?t[0]:null},i.prototype.getAll=function(e){return this.map[n(e)]||[]},i.prototype.has=function(e){return this.map.hasOwnProperty(n(e))},i.prototype.set=function(e,t){this.map[n(e)]=[r(t)]},i.prototype.forEach=function(e,t){Object.getOwnPropertyNames(this.map).forEach(function(n){this.map[n].forEach(function(r){e.call(t,r,n,this)},this)},this)};var m={blob:"FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(e){return!1}}(),formData:"FormData"in e,arrayBuffer:"ArrayBuffer"in e},v=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];f.prototype.clone=function(){return new f(this)},c.call(f.prototype),c.call(p.prototype),p.prototype.clone=function(){return new p(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new i(this.headers),url:this.url})},p.error=function(){var e=new p(null,{status:0,statusText:""});return e.type="error",e};var g=[301,302,303,307,308];p.redirect=function(e,t){if(-1===g.indexOf(t))throw new RangeError("Invalid status code");return new p(null,{status:t,headers:{location:e}})},e.Headers=i,e.Request=f,e.Response=p,e.fetch=function(e,n){return new t(function(t,r){function i(){return"responseURL"in a?a.responseURL:/^X-Request-URL:/m.test(a.getAllResponseHeaders())?a.getResponseHeader("X-Request-URL"):void 0}var o;o=f.prototype.isPrototypeOf(e)&&!n?e:new f(e,n);var a=new XMLHttpRequest;a.onload=function(){var e=1223===a.status?204:a.status;if(100>e||e>599)return void r(new TypeError("Network request failed"));var n={status:e,statusText:a.statusText,headers:h(a),url:i()},o="response"in a?a.response:a.responseText;t(new p(o,n))},a.onerror=function(){r(new TypeError("Network request failed"))},a.open(o.method,o.url,!0),"include"===o.credentials&&(a.withCredentials=!0),"responseType"in a&&m.blob&&(a.responseType="blob"),o.headers.forEach(function(e,t){a.setRequestHeader(t,e)}),a.send("undefined"==typeof o._bodyInit?null:o._bodyInit)})},e.fetch.polyfill=!0}}("undefined"!=typeof self?self:this),e.exports=n.fetch}).call(n)}).call(t,n(4),function(){return this}())},function(e,t,n){(function(t){(function(){"use strict";function r(e,t,n){e[t]||Object[i](e,t,{writable:!0,configurable:!0,value:n})}if(n(5),n(290),n(292),t._babelPolyfill)throw new Error("only one instance of babel-polyfill is allowed");t._babelPolyfill=!0;var i="defineProperty";r(String.prototype,"padLeft","".padStart),r(String.prototype,"padRight","".padEnd),"pop,reverse,shift,keys,values,entries,indexOf,every,some,forEach,map,filter,find,findIndex,includes,join,slice,concat,push,splice,unshift,sort,lastIndexOf,reduce,reduceRight,copyWithin,fill".split(",").forEach(function(e){[][e]&&r(Array,e,Function.call.bind([][e]))}),e.exports=t.Promise}).call(t)}).call(t,function(){return this}())},function(e,t,n){n(6),n(53),n(54),n(55),n(56),n(58),n(61),n(62),n(63),n(64),n(65),n(66),n(67),n(68),n(69),n(71),n(73),n(75),n(77),n(80),n(81),n(82),n(86),n(88),n(90),n(94),n(95),n(96),n(97),n(99),n(100),n(101),n(102),n(103),n(104),n(105),n(107),n(108),n(109),n(111),n(112),n(113),n(115),n(116),n(117),n(118),n(119),n(120),n(121),n(122),n(123),n(124),n(125),n(126),n(127),n(128),n(133),n(134),n(138),n(139),n(140),n(141),n(143),n(144),n(145),n(146),n(147),n(148),n(149),n(150),n(151),n(152),n(153),n(154),n(155),n(156),n(157),n(158),n(159),n(161),n(162),n(168),n(169),n(171),n(172),n(173),n(176),n(177),n(178),n(179),n(180),n(182),n(183),n(184),n(185),n(188),n(190),n(191),n(192),n(194),n(196),n(198),n(199),n(200),n(202),n(203),n(204),n(205),n(211),n(214),n(215),n(217),n(218),n(221),n(222),n(225),n(226),n(227),n(228),n(229),n(230),n(231),n(232),n(233),n(234),n(235),n(236),n(237),n(238),n(239),n(240),n(241),n(242),n(243),n(245),n(246),n(247),n(248),n(249),n(250),n(252),n(253),n(254),n(255),n(256),n(257),n(259),n(260),n(262),n(263),n(264),n(265),n(268),n(269),n(270),n(271),n(272),n(273),n(274),n(275),n(277),n(278),n(279),n(280),n(281),n(282),n(283),n(284),n(285),n(288),n(289),e.exports=n(8)},function(e,t,n){"use strict";var r=n(7),i=n(8),o=n(9),a=n(10),s=n(12),u=n(21),c=n(25).KEY,l=n(11),f=n(26),d=n(27),h=n(22),p=n(28),m=n(29),v=n(42),g=n(45),_=n(15),y=n(32),b=n(19),k=n(20),x=n(46),w=n(49),S=n(51),A=n(14),E=S.f,M=A.f,I=w.f,O=r.Symbol,C=r.JSON,P=C&&C.stringify,j=!1,z="prototype",T=p("_hidden"),D=p("toPrimitive"),L={}.propertyIsEnumerable,q=f("symbol-registry"),N=f("symbols"),F=Object[z],R="function"==typeof O,U=r.QObject,B=a&&l(function(){return 7!=x(M({},"a",{get:function(){return M(this,"a",{value:7}).a}})).a})?function(e,t,n){var r=E(F,t);r&&delete F[t],M(e,t,n),r&&e!==F&&M(F,t,r)}:M,V=function(e){var t=N[e]=x(O[z]);return t._k=e,a&&j&&B(F,e,{configurable:!0,set:function(t){o(this,T)&&o(this[T],e)&&(this[T][e]=!1),B(this,e,k(1,t))}}),t},H=R&&"symbol"==typeof O.iterator?function(e){return"symbol"==typeof e}:function(e){return e instanceof O},W=function(e,t,n){return _(e),t=b(t,!0),_(n),o(N,t)?(n.enumerable?(o(e,T)&&e[T][t]&&(e[T][t]=!1),n=x(n,{enumerable:k(0,!1)})):(o(e,T)||M(e,T,k(1,{})),e[T][t]=!0),B(e,t,n)):M(e,t,n)},K=function(e,t){_(e);for(var n,r=v(t=y(t)),i=0,o=r.length;o>i;)W(e,n=r[i++],t[n]);return e},G=function(e,t){return void 0===t?x(e):K(x(e),t)},$=function(e){var t=L.call(this,e=b(e,!0));return t||!o(this,e)||!o(N,e)||o(this,T)&&this[T][e]?t:!0},J=function(e,t){var n=E(e=y(e),t=b(t,!0));return!n||!o(N,t)||o(e,T)&&e[T][t]||(n.enumerable=!0),n},Y=function(e){for(var t,n=I(y(e)),r=[],i=0;n.length>i;)o(N,t=n[i++])||t==T||t==c||r.push(t);return r},X=function(e){for(var t,n=I(y(e)),r=[],i=0;n.length>i;)o(N,t=n[i++])&&r.push(N[t]);return r},Q=function(e){if(void 0!==e&&!H(e)){for(var t,n,r=[e],i=1;arguments.length>i;)r.push(arguments[i++]);return t=r[1],"function"==typeof t&&(n=t),!n&&g(t)||(t=function(e,t){return n&&(t=n.call(this,e,t)),H(t)?void 0:t}),r[1]=t,P.apply(C,r)}},Z=l(function(){var e=O();return"[null]"!=P([e])||"{}"!=P({a:e})||"{}"!=P(Object(e))});R||(O=function(){if(this instanceof O)throw TypeError("Symbol is not a constructor!");return V(h(arguments.length>0?arguments[0]:void 0))},u(O[z],"toString",function(){return this._k}),S.f=J,A.f=W,n(50).f=w.f=Y,n(44).f=$,n(43).f=X,a&&!n(52)&&u(F,"propertyIsEnumerable",$,!0)),s(s.G+s.W+s.F*!R,{Symbol:O});for(var ee="hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables".split(","),te=0;ee.length>te;){var ne=ee[te++],re=i.Symbol,ie=p(ne);ne in re||M(re,ne,{value:R?ie:V(ie)})}U&&U[z]&&U[z].findChild||(j=!0),s(s.S+s.F*!R,"Symbol",{"for":function(e){return o(q,e+="")?q[e]:q[e]=O(e)},keyFor:function(e){if(H(e))return m(q,e);throw TypeError(e+" is not a symbol!")},useSetter:function(){j=!0},useSimple:function(){j=!1}}),s(s.S+s.F*!R,"Object",{create:G,defineProperty:W,defineProperties:K,getOwnPropertyDescriptor:J,getOwnPropertyNames:Y,getOwnPropertySymbols:X}),C&&s(s.S+s.F*(!R||Z),"JSON",{stringify:Q}),O[z][D]||n(13)(O[z],D,O[z].valueOf),d(O,"Symbol"),d(Math,"Math",!0),d(r.JSON,"JSON",!0)},function(e,t){var n=e.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=n)},function(e,t){var n=e.exports={version:"2.2.2"};"number"==typeof __e&&(__e=n)},function(e,t){var n={}.hasOwnProperty;e.exports=function(e,t){return n.call(e,t)}},function(e,t,n){e.exports=!n(11)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(e,t){e.exports=function(e){try{return!!e()}catch(t){return!0}}},function(e,t,n){var r=n(7),i=n(8),o=n(13),a=n(21),s=n(23),u="prototype",c=function(e,t,n){var l,f,d,h,p=e&c.F,m=e&c.G,v=e&c.S,g=e&c.P,_=e&c.B,y=m?r:v?r[t]||(r[t]={}):(r[t]||{})[u],b=m?i:i[t]||(i[t]={}),k=b[u]||(b[u]={});m&&(n=t);for(l in n)f=!p&&y&&void 0!==y[l],d=(f?y:n)[l],h=_&&f?s(d,r):g&&"function"==typeof d?s(Function.call,d):d,y&&a(y,l,d,e&c.U),b[l]!=d&&o(b,l,h),g&&k[l]!=d&&(k[l]=d)};r.core=i,c.F=1,c.G=2,c.S=4,c.P=8,c.B=16,c.W=32,c.U=64,c.R=128,e.exports=c},function(e,t,n){var r=n(14),i=n(20);e.exports=n(10)?function(e,t,n){return r.f(e,t,i(1,n))}:function(e,t,n){return e[t]=n,e}},function(e,t,n){var r=n(15),i=n(17),o=n(19),a=Object.defineProperty;t.f=n(10)?Object.defineProperty:function(e,t,n){if(r(e),t=o(t,!0),r(n),i)try{return a(e,t,n)}catch(s){}if("get"in n||"set"in n)throw TypeError("Accessors not supported!");return"value"in n&&(e[t]=n.value),e}},function(e,t,n){var r=n(16);e.exports=function(e){if(!r(e))throw TypeError(e+" is not an object!");return e}},function(e,t){e.exports=function(e){return"object"==typeof e?null!==e:"function"==typeof e}},function(e,t,n){e.exports=!n(10)&&!n(11)(function(){return 7!=Object.defineProperty(n(18)("div"),"a",{get:function(){return 7}}).a})},function(e,t,n){var r=n(16),i=n(7).document,o=r(i)&&r(i.createElement);e.exports=function(e){return o?i.createElement(e):{}}},function(e,t,n){var r=n(16);e.exports=function(e,t){if(!r(e))return e;var n,i;if(t&&"function"==typeof(n=e.toString)&&!r(i=n.call(e)))return i;if("function"==typeof(n=e.valueOf)&&!r(i=n.call(e)))return i;if(!t&&"function"==typeof(n=e.toString)&&!r(i=n.call(e)))return i;throw TypeError("Can't convert object to primitive value")}},function(e,t){e.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}},function(e,t,n){var r=n(7),i=n(13),o=n(9),a=n(22)("src"),s="toString",u=Function[s],c=(""+u).split(s);n(8).inspectSource=function(e){return u.call(e)},(e.exports=function(e,t,n,s){var u="function"==typeof n;u&&(o(n,"name")||i(n,"name",t)),e[t]!==n&&(u&&(o(n,a)||i(n,a,e[t]?""+e[t]:c.join(String(t)))),e===r?e[t]=n:s?e[t]?e[t]=n:i(e,t,n):(delete e[t],i(e,t,n)))})(Function.prototype,s,function(){return"function"==typeof this&&this[a]||u.call(this)})},function(e,t){var n=0,r=Math.random();e.exports=function(e){return"Symbol(".concat(void 0===e?"":e,")_",(++n+r).toString(36))}},function(e,t,n){var r=n(24);e.exports=function(e,t,n){if(r(e),void 0===t)return e;switch(n){case 1:return function(n){return e.call(t,n)};case 2:return function(n,r){return e.call(t,n,r)};case 3:return function(n,r,i){return e.call(t,n,r,i)}}return function(){return e.apply(t,arguments)}}},function(e,t){e.exports=function(e){if("function"!=typeof e)throw TypeError(e+" is not a function!");return e}},function(e,t,n){var r=n(22)("meta"),i=n(16),o=n(9),a=n(14).f,s=0,u=Object.isExtensible||function(){return!0},c=!n(11)(function(){return u(Object.preventExtensions({}))}),l=function(e){a(e,r,{value:{i:"O"+ ++s,w:{}}})},f=function(e,t){if(!i(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!o(e,r)){if(!u(e))return"F";if(!t)return"E";l(e)}return e[r].i},d=function(e,t){if(!o(e,r)){if(!u(e))return!0;if(!t)return!1;l(e)}return e[r].w},h=function(e){return c&&p.NEED&&u(e)&&!o(e,r)&&l(e),e},p=e.exports={KEY:r,NEED:!1,fastKey:f,getWeak:d,onFreeze:h}},function(e,t,n){var r=n(7),i="__core-js_shared__",o=r[i]||(r[i]={});e.exports=function(e){return o[e]||(o[e]={})}},function(e,t,n){var r=n(14).f,i=n(9),o=n(28)("toStringTag");e.exports=function(e,t,n){e&&!i(e=n?e:e.prototype,o)&&r(e,o,{configurable:!0,value:t})}},function(e,t,n){var r=n(26)("wks"),i=n(22),o=n(7).Symbol,a="function"==typeof o;e.exports=function(e){return r[e]||(r[e]=a&&o[e]||(a?o:i)("Symbol."+e))}},function(e,t,n){var r=n(30),i=n(32);e.exports=function(e,t){for(var n,o=i(e),a=r(o),s=a.length,u=0;s>u;)if(o[n=a[u++]]===t)return n}},function(e,t,n){var r=n(31),i=n(41);e.exports=Object.keys||function(e){return r(e,i)}},function(e,t,n){var r=n(9),i=n(32),o=n(36)(!1),a=n(40)("IE_PROTO");e.exports=function(e,t){var n,s=i(e),u=0,c=[];for(n in s)n!=a&&r(s,n)&&c.push(n);for(;t.length>u;)r(s,n=t[u++])&&(~o(c,n)||c.push(n));return c}},function(e,t,n){var r=n(33),i=n(35);e.exports=function(e){return r(i(e))}},function(e,t,n){var r=n(34);e.exports=Object("z").propertyIsEnumerable(0)?Object:function(e){return"String"==r(e)?e.split(""):Object(e)}},function(e,t){var n={}.toString;e.exports=function(e){return n.call(e).slice(8,-1)}},function(e,t){e.exports=function(e){if(void 0==e)throw TypeError("Can't call method on "+e);return e}},function(e,t,n){var r=n(32),i=n(37),o=n(39);e.exports=function(e){return function(t,n,a){var s,u=r(t),c=i(u.length),l=o(a,c);if(e&&n!=n){for(;c>l;)if(s=u[l++],s!=s)return!0}else for(;c>l;l++)if((e||l in u)&&u[l]===n)return e||l||0;return!e&&-1}}},function(e,t,n){var r=n(38),i=Math.min;e.exports=function(e){return e>0?i(r(e),9007199254740991):0}},function(e,t){var n=Math.ceil,r=Math.floor;e.exports=function(e){return isNaN(e=+e)?0:(e>0?r:n)(e)}},function(e,t,n){var r=n(38),i=Math.max,o=Math.min;e.exports=function(e,t){return e=r(e),0>e?i(e+t,0):o(e,t)}},function(e,t,n){var r=n(26)("keys"),i=n(22);e.exports=function(e){return r[e]||(r[e]=i(e))}},function(e,t){e.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(e,t,n){var r=n(30),i=n(43),o=n(44);e.exports=function(e){var t=r(e),n=i.f;if(n)for(var a,s=n(e),u=o.f,c=0;s.length>c;)u.call(e,a=s[c++])&&t.push(a);return t}},function(e,t){t.f=Object.getOwnPropertySymbols},function(e,t){t.f={}.propertyIsEnumerable},function(e,t,n){var r=n(34);e.exports=Array.isArray||function(e){return"Array"==r(e)}},function(e,t,n){var r=n(15),i=n(47),o=n(41),a=n(40)("IE_PROTO"),s=function(){},u="prototype",c=function(){var e,t=n(18)("iframe"),r=o.length,i=">";for(t.style.display="none",n(48).appendChild(t),t.src="javascript:",e=t.contentWindow.document,e.open(),e.write("