Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SitesManager plugins: added group managment to admin UI #4

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions lang/en.php
Expand Up @@ -1070,7 +1070,9 @@
'SitesManager_NoWebsites' => 'You don\'t have any website to administrate.', 'SitesManager_NoWebsites' => 'You don\'t have any website to administrate.',
'SitesManager_AddSite' => 'Add a new website', 'SitesManager_AddSite' => 'Add a new website',
'SitesManager_NotFound' => 'No websites found for', '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_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_Urls' => 'URLs',
'SitesManager_MenuSites' => 'Websites', 'SitesManager_MenuSites' => 'Websites',
'SitesManager_DeleteConfirm_js' => 'Are you sure you want to delete the website %s?', 'SitesManager_DeleteConfirm_js' => 'Are you sure you want to delete the website %s?',
Expand Down
13 changes: 13 additions & 0 deletions plugins/SitesManager/templates/SitesManager.js
Expand Up @@ -37,6 +37,7 @@ function SitesManager ( _timezones, _currencies, _defaultTimezone, _defaultCurre


var parameters = {}; var parameters = {};
var siteName = $(row).find('input#name').val(); var siteName = $(row).find('input#name').val();
var group = $(row).find('input#group').val();
var urls = $(row).find('textarea#urls').val(); var urls = $(row).find('textarea#urls').val();
urls = getApiFormatUrls(urls); urls = getApiFormatUrls(urls);
var excludedIps = $(row).find('textarea#excludedIps').val(); var excludedIps = $(row).find('textarea#excludedIps').val();
Expand All @@ -53,6 +54,8 @@ function SitesManager ( _timezones, _currencies, _defaultTimezone, _defaultCurre
request += '&method=SitesManager.addSite'; request += '&method=SitesManager.addSite';
siteName = encodeURIComponent(siteName); siteName = encodeURIComponent(siteName);
request += '&siteName='+siteName; request += '&siteName='+siteName;
group = encodeURIComponent(group);
request += '&group='+group;
request += '&timezone='+timezone; request += '&timezone='+timezone;
request += '&currency='+currency; request += '&currency='+currency;
request += '&ecommerce='+ecommerce; request += '&ecommerce='+ecommerce;
Expand Down Expand Up @@ -81,6 +84,7 @@ function SitesManager ( _timezones, _currencies, _defaultTimezone, _defaultCurre
ajaxRequest.type = 'POST'; ajaxRequest.type = 'POST';


var siteName = $(row).find('input#siteName').val(); var siteName = $(row).find('input#siteName').val();
var group = $(row).find('input#group').val();
var idSite = $(row).children('#idSite').html(); var idSite = $(row).children('#idSite').html();
var urls = $(row).find('textarea#urls').val(); var urls = $(row).find('textarea#urls').val();
urls = getApiFormatUrls(urls); urls = getApiFormatUrls(urls);
Expand All @@ -97,6 +101,8 @@ function SitesManager ( _timezones, _currencies, _defaultTimezone, _defaultCurre
request += '&method=SitesManager.updateSite'; request += '&method=SitesManager.updateSite';
siteName = encodeURIComponent(siteName); siteName = encodeURIComponent(siteName);
request += '&siteName='+siteName; request += '&siteName='+siteName;
group = encodeURIComponent(group);
request += '&group='+group;
request += '&idSite='+idSite; request += '&idSite='+idSite;
request += '&timezone='+timezone; request += '&timezone='+timezone;
request += '&currency='+currency; request += '&currency='+currency;
Expand Down Expand Up @@ -144,6 +150,7 @@ function SitesManager ( _timezones, _currencies, _defaultTimezone, _defaultCurre
$(' <tr id="'+newRowId+'">\ $(' <tr id="'+newRowId+'">\
<td>&nbsp;</td>\ <td>&nbsp;</td>\
<td><input id="name" value="Name" size="15" /><br/><br/><br/>'+submitButtonHtml+'</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="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="excludedIps"></textarea><br />'+excludedIpHelp+'</td>\
<td><textarea cols="20" rows="4" id="excludedQueryParameters"></textarea><br />'+excludedQueryParametersHelp+'</td>\ <td><textarea cols="20" rows="4" id="excludedQueryParameters"></textarea><br />'+excludedQueryParametersHelp+'</td>\
Expand Down Expand Up @@ -221,6 +228,12 @@ function SitesManager ( _timezones, _currencies, _defaultTimezone, _defaultCurre
.append(inputSave) .append(inputSave)
.append(spanCancel); .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') else if(idName == 'urls')
{ {
var contentAfter = '<textarea cols="25" rows="3" id="urls">'+contentBefore.replace(/<br *\/? *>/gi,"\n")+'</textarea>'; var contentAfter = '<textarea cols="25" rows="3" id="urls">'+contentBefore.replace(/<br *\/? *>/gi,"\n")+'</textarea>';
Expand Down
3 changes: 3 additions & 0 deletions plugins/SitesManager/templates/SitesManager.tpl
Expand Up @@ -7,6 +7,7 @@
{capture assign=excludedIpHelpPlain}{'SitesManager_HelpExcludedIps'|translate:"1.2.3.*":"1.2.*.*"}<br /><br /> {'SitesManager_YourCurrentIpAddressIs'|translate:"<i>$currentIpAddress</i>"}{/capture} {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} {assign var=excludedIpHelp value=$excludedIpHelpPlain|inlineHelp}
var excludedIpHelp = '{$excludedIpHelp|escape:javascript}'; var excludedIpHelp = '{$excludedIpHelp|escape:javascript}';
var groupHelp = '{'SitesManager_GroupHelp'|translate|inlineHelp|escape:javascript}';
var aliasUrlsHelp = '{'SitesManager_AliasUrlHelp'|translate|inlineHelp|escape:javascript}'; var aliasUrlsHelp = '{'SitesManager_AliasUrlHelp'|translate|inlineHelp|escape:javascript}';
{capture assign=defaultTimezoneHelpPlain} {capture assign=defaultTimezoneHelpPlain}
{if $timezoneSupported} {if $timezoneSupported}
Expand Down Expand Up @@ -119,6 +120,7 @@ vertical-align:middle;
<tr> <tr>
<th>{'General_Id'|translate}</th> <th>{'General_Id'|translate}</th>
<th>{'General_Name'|translate}</th> <th>{'General_Name'|translate}</th>
<th>{'SitesManager_Group'|translate}</th>
<th>{'SitesManager_Urls'|translate}</th> <th>{'SitesManager_Urls'|translate}</th>
<th>{'SitesManager_ExcludedIps'|translate}</th> <th>{'SitesManager_ExcludedIps'|translate}</th>
<th>{'SitesManager_ExcludedParameters'|translate|replace:" ":"<br />"}</th> <th>{'SitesManager_ExcludedParameters'|translate|replace:" ":"<br />"}</th>
Expand All @@ -135,6 +137,7 @@ vertical-align:middle;
<tr id="row{$i}"> <tr id="row{$i}">
<td id="idSite">{$site.idsite}</td> <td id="idSite">{$site.idsite}</td>
<td id="siteName" class="editableSite">{$site.name}</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="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="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> <td id="excludedQueryParameters" class="editableSite">{foreach from=$site.excluded_parameters item=parameter}{$parameter}<br />{/foreach}</td>
Expand Down