Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

SitesManager plugins: added group managment to admin UI #4

Closed
wants to merge 1 commit into from

2 participants

@shesek

Just some simple additions to make the "group" field editable via the SitesManager admin UI. This seems to have gotten stuck for quite some time on http://dev.piwik.org/trac/ticket/2174, would be great if you could merge it into core.

@robocoder
Collaborator

Thanks. The project is still using Trac+svn, so I have linked the Trac ticket to your patch.

@robocoder robocoder closed this
This was referenced
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 14, 2012
This page is out of date. Refresh to see the latest.
View
2  lang/en.php
@@ -1070,7 +1070,9 @@
'SitesManager_NoWebsites' => 'You don\'t have any website to administrate.',
'SitesManager_AddSite' => 'Add a new website',
'SitesManager_NotFound' => 'No websites found for',
+ 'SitesManager_GroupHelp' => 'The group the website belongs to (optional). If set, can be used by third party tools via the API to filter and classify websites.',
'SitesManager_AliasUrlHelp' => 'It is recommended, but not required, to specify the various URLs, one per line, that your visitors use to access this website. Alias URLs for a website will not appear in the Referrers > Websites report. Note that it is not necessary to specify the URLs with and without \'www\' as Piwik automatically considers both.',
+ 'SitesManager_Group' => 'Group',
'SitesManager_Urls' => 'URLs',
'SitesManager_MenuSites' => 'Websites',
'SitesManager_DeleteConfirm_js' => 'Are you sure you want to delete the website %s?',
View
13 plugins/SitesManager/templates/SitesManager.js
@@ -37,6 +37,7 @@ function SitesManager ( _timezones, _currencies, _defaultTimezone, _defaultCurre
var parameters = {};
var siteName = $(row).find('input#name').val();
+ var group = $(row).find('input#group').val();
var urls = $(row).find('textarea#urls').val();
urls = getApiFormatUrls(urls);
var excludedIps = $(row).find('textarea#excludedIps').val();
@@ -53,6 +54,8 @@ function SitesManager ( _timezones, _currencies, _defaultTimezone, _defaultCurre
request += '&method=SitesManager.addSite';
siteName = encodeURIComponent(siteName);
request += '&siteName='+siteName;
+ group = encodeURIComponent(group);
+ request += '&group='+group;
request += '&timezone='+timezone;
request += '&currency='+currency;
request += '&ecommerce='+ecommerce;
@@ -81,6 +84,7 @@ function SitesManager ( _timezones, _currencies, _defaultTimezone, _defaultCurre
ajaxRequest.type = 'POST';
var siteName = $(row).find('input#siteName').val();
+ var group = $(row).find('input#group').val();
var idSite = $(row).children('#idSite').html();
var urls = $(row).find('textarea#urls').val();
urls = getApiFormatUrls(urls);
@@ -97,6 +101,8 @@ function SitesManager ( _timezones, _currencies, _defaultTimezone, _defaultCurre
request += '&method=SitesManager.updateSite';
siteName = encodeURIComponent(siteName);
request += '&siteName='+siteName;
+ group = encodeURIComponent(group);
+ request += '&group='+group;
request += '&idSite='+idSite;
request += '&timezone='+timezone;
request += '&currency='+currency;
@@ -144,6 +150,7 @@ function SitesManager ( _timezones, _currencies, _defaultTimezone, _defaultCurre
$(' <tr id="'+newRowId+'">\
<td>&nbsp;</td>\
<td><input id="name" value="Name" size="15" /><br/><br/><br/>'+submitButtonHtml+'</td>\
+ <td><input id="group" value="Group Name" size="15" />'+groupHelp+'</td>\
<td><textarea cols="25" rows="3" id="urls">http://siteUrl.com/\nhttp://siteUrl2.com/</textarea><br />'+aliasUrlsHelp+'</td>\
<td><textarea cols="20" rows="4" id="excludedIps"></textarea><br />'+excludedIpHelp+'</td>\
<td><textarea cols="20" rows="4" id="excludedQueryParameters"></textarea><br />'+excludedQueryParametersHelp+'</td>\
@@ -221,6 +228,12 @@ function SitesManager ( _timezones, _currencies, _defaultTimezone, _defaultCurre
.append(inputSave)
.append(spanCancel);
}
+ else if(idName == 'group')
+ {
+ var contentAfter = '<input id="group" value="'+piwikHelper.htmlEntities(contentBefore)+'" size="15" /">';
+ contentAfter += '<br />'+groupHelp;
+ $(n).html(contentAfter);
+ }
else if(idName == 'urls')
{
var contentAfter = '<textarea cols="25" rows="3" id="urls">'+contentBefore.replace(/<br *\/? *>/gi,"\n")+'</textarea>';
View
3  plugins/SitesManager/templates/SitesManager.tpl
@@ -7,6 +7,7 @@
{capture assign=excludedIpHelpPlain}{'SitesManager_HelpExcludedIps'|translate:"1.2.3.*":"1.2.*.*"}<br /><br /> {'SitesManager_YourCurrentIpAddressIs'|translate:"<i>$currentIpAddress</i>"}{/capture}
{assign var=excludedIpHelp value=$excludedIpHelpPlain|inlineHelp}
var excludedIpHelp = '{$excludedIpHelp|escape:javascript}';
+var groupHelp = '{'SitesManager_GroupHelp'|translate|inlineHelp|escape:javascript}';
var aliasUrlsHelp = '{'SitesManager_AliasUrlHelp'|translate|inlineHelp|escape:javascript}';
{capture assign=defaultTimezoneHelpPlain}
{if $timezoneSupported}
@@ -119,6 +120,7 @@ vertical-align:middle;
<tr>
<th>{'General_Id'|translate}</th>
<th>{'General_Name'|translate}</th>
+ <th>{'SitesManager_Group'|translate}</th>
<th>{'SitesManager_Urls'|translate}</th>
<th>{'SitesManager_ExcludedIps'|translate}</th>
<th>{'SitesManager_ExcludedParameters'|translate|replace:" ":"<br />"}</th>
@@ -135,6 +137,7 @@ vertical-align:middle;
<tr id="row{$i}">
<td id="idSite">{$site.idsite}</td>
<td id="siteName" class="editableSite">{$site.name}</td>
+ <td id="group" class="editableSite">{$site.group}</td>
<td id="urls" class="editableSite">{foreach from=$site.alias_urls item=url}{$url|replace:"http://":""}<br />{/foreach}</td>
<td id="excludedIps" class="editableSite">{foreach from=$site.excluded_ips item=ip}{$ip}<br />{/foreach}</td>
<td id="excludedQueryParameters" class="editableSite">{foreach from=$site.excluded_parameters item=parameter}{$parameter}<br />{/foreach}</td>
Something went wrong with that request. Please try again.