Skip to content

Commit

Permalink
adjust how admin url is generated for api calls from config
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas committed Dec 22, 2016
1 parent 5c984eb commit 1bd95ac
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 35 deletions.
Expand Up @@ -33,13 +33,13 @@ class ProxiBlue_NewRelic_Block_Adminhtml_System_Config_Form_Field_Button_Account
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
{
$this->setElement($element);

$url = Mage::helper("adminhtml")->getUrl("proxiblue_newrelic/api/accountDetails/",array('id'=>Mage::getStoreConfig('newrelic/api/api_key')));

$html = $this->getLayout()->createBlock('adminhtml/widget_button')
->setType('button')
->setClass('scalable')
->setLabel('Fetch Account Details')
->setOnClick("fetchAccountDetails()")
->setOnClick("fetchAccountDetails('{$url}')")
->toHtml();

$html .= $this->addActionJs();
Expand Down
Expand Up @@ -33,13 +33,14 @@ class ProxiBlue_NewRelic_Block_Adminhtml_System_Config_Form_Field_Button_Appname
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
{
$this->setElement($element);

$url = Mage::helper("adminhtml")->getUrl("proxiblue_newrelic/api/names/",array('id'=>Mage::getStoreConfig('newrelic/api/api_key')));


$html = $this->getLayout()->createBlock('adminhtml/widget_button')
->setType('button')
->setClass('scalable')
->setLabel('Fetch Application Names')
->setOnClick("fetchApplicationNames()")
->setOnClick("fetchApplicationNames('{$url}')")
->toHtml();

$html .= $this->addActionJs();
Expand Down
Expand Up @@ -23,7 +23,7 @@ class ProxiBlue_NewRelic_ApiController extends Mage_Core_Controller_Front_Action


public function namesAction() {
if(Mage::helper('proxiblue_newrelic')->testApiKey($this->getRequest()->getParam('key'))) {
if(Mage::helper('proxiblue_newrelic')->testApiKey($this->getRequest()->getParam('id'))) {
$newRelicApi = Mage::getModel('proxiblue_newrelic/api');
$applications = $newRelicApi->getApplications();
$this->getResponse()->setHeader('Content-type', 'application/json');
Expand All @@ -36,7 +36,7 @@ public function namesAction() {
}

public function accountDetailsAction() {
if(Mage::helper('proxiblue_newrelic')->testApiKey($this->getRequest()->getParam('key'))) {
if(Mage::helper('proxiblue_newrelic')->testApiKey($this->getRequest()->getParam('id'))) {
$newRelicApi = Mage::getModel('proxiblue_newrelic/api');
$accountDetails = $newRelicApi->getAccountDetails();
$this->getResponse()->setHeader('Content-type', 'application/json');
Expand Down
1 change: 1 addition & 0 deletions app/code/community/ProxiBlue/NewRelic/etc/changelog.txt
Expand Up @@ -32,6 +32,7 @@
- Ads in useragent string as per newrelic requirements
1.0.1 - Fix namespace change template file not changed
1.0.2 - Fix regex value escaping
1.0.3 - change how api admin url is done in config settings

Reproducing error for 0.0.4 bug release.
In any app/etc/module/ config xml file place a depends to a non-existing module.
Expand Down
11 changes: 1 addition & 10 deletions app/code/community/ProxiBlue/NewRelic/etc/config.xml
Expand Up @@ -2,7 +2,7 @@
<config>
<modules>
<ProxiBlue_NewRelic>
<version>1.0.2</version>
<version>1.0.3</version>
</ProxiBlue_NewRelic>
</modules>
<global>
Expand Down Expand Up @@ -136,13 +136,4 @@
</proxiblue_newrelic>
</routers>
</frontend>
<adminhtml>
<layout>
<updates>
<proxiblue_newrelic>
<file>proxiblue_newrelic.xml</file>
</proxiblue_newrelic>
</updates>
</layout>
</adminhtml>
</config>

This file was deleted.

This file was deleted.

2 changes: 0 additions & 2 deletions composer.json
Expand Up @@ -20,8 +20,6 @@
["/app/design/adminhtml/default/default/template/dashboard/proxiblue_newrelic.phtml", "/app/design/adminhtml/default/default/template/dashboard/proxiblue_newrelic.phtml"],
["/app/code/local/Mage/Core/Exception.php", "/app/code/local/Mage/Core/Exception.php"],
["/js/newrelic.js", "/js/newrelic.js"],
["/app/design/adminhtml/default/default/template/proxiblue_newrelic/init_js.phtml", "/app/design/adminhtml/default/default/template/proxiblue_newrelic/init_js.phtml"],
["/app/design/adminhtml/default/default/layout/proxiblue_newrelic.xml", "/app/design/adminhtml/default/default/layout/proxiblue_newrelic.xml"]
]
}
}
8 changes: 4 additions & 4 deletions js/newrelic.js
Expand Up @@ -9,8 +9,8 @@ Array.prototype.remove = function() {
return this;
};

function fetchApplicationNames() {
new Ajax.Request(newrelic_base_url + 'proxiblue_newrelic/api/names/key/'+$('newrelic_api_api_key').value, {
function fetchApplicationNames(url) {
new Ajax.Request(url, {
onSuccess: function(response) {
var json = response.responseText.evalJSON();
if(json.error) {
Expand Down Expand Up @@ -38,8 +38,8 @@ function fetchApplicationNames() {
});
}

function fetchAccountDetails() {
new Ajax.Request(newrelic_base_url + 'proxiblue_newrelic/api/accountDetails/key/'+$('newrelic_api_api_key').value, {
function fetchAccountDetails(url) {
new Ajax.Request(url, {
onSuccess: function(response) {
var json = response.responseText.evalJSON();
if(json.error) {
Expand Down
2 changes: 0 additions & 2 deletions modman
@@ -1,7 +1,5 @@
app/code/community/ProxiBlue/NewRelic app/code/community/ProxiBlue/NewRelic
app/code/local/Mage/Core/Exception.php app/code/local/Mage/Core/Exception.php
app/design/adminhtml/default/default/layout/proxiblue_newrelic.xml app/design/adminhtml/default/default/layout/proxiblue_newrelic.xml
app/design/adminhtml/default/default/template/dashboard/proxiblue_newrelic.phtml app/design/adminhtml/default/default/template/dashboard/proxiblue_newrelic.phtml
app/design/adminhtml/default/default/template/proxiblue_newrelic/init_js.phtml app/design/adminhtml/default/default/template/proxiblue_newrelic/init_js.phtml
app/etc/modules/ProxiBlue_NewRelic.xml app/etc/modules/ProxiBlue_NewRelic.xml
js/newrelic.js js/newrelic.js

0 comments on commit 1bd95ac

Please sign in to comment.