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

Reorganizing the Dashboard plugin file #68

Merged
merged 1 commit into from
May 2, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions plugins/Dashboard/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ protected function _getDashboardView($template)

public function embeddedIndex()
{
$view = $this->_getDashboardView('@Dashboard/index');
$view = $this->_getDashboardView('@Dashboard/embeddedIndex');

echo $view->render();
}

public function index()
{
$view = $this->_getDashboardView('@Dashboard/standalone');
$view = $this->_getDashboardView('@Dashboard/index');
$view->dashboards = array();
if (!Piwik::isUserIsAnonymous()) {
$login = Piwik::getCurrentUserLogin();
Expand Down
10 changes: 5 additions & 5 deletions plugins/Dashboard/Dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,11 @@ function getJsFiles($notification)
{
$jsFiles = & $notification->getNotificationObject();

$jsFiles[] = "plugins/Dashboard/templates/widgetMenu.js";
$jsFiles[] = "plugins/Dashboard/javascripts/widgetMenu.js";
$jsFiles[] = "libs/javascript/json2.js";
$jsFiles[] = "plugins/Dashboard/templates/dashboardObject.js";
$jsFiles[] = "plugins/Dashboard/templates/dashboardWidget.js";
$jsFiles[] = "plugins/Dashboard/templates/dashboard.js";
$jsFiles[] = "plugins/Dashboard/javascripts/dashboardObject.js";
$jsFiles[] = "plugins/Dashboard/javascripts/dashboardWidget.js";
$jsFiles[] = "plugins/Dashboard/javascripts/dashboard.js";
}

/**
Expand All @@ -249,7 +249,7 @@ function getCssFiles($notification)
$cssFiles = & $notification->getNotificationObject();

$cssFiles[] = "plugins/CoreHome/templates/datatable.css";
$cssFiles[] = "plugins/Dashboard/templates/dashboard.css";
$cssFiles[] = "plugins/Dashboard/stylesheets/dashboard.css";
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ function initDashboard(dashboardId, dashboardLayout) {

widgetsHelper.getAvailableWidgets();

$('#dashboardWidgetsArea').on('dashboardempty', showEmptyDashboardNotification);

$('#dashboardWidgetsArea').dashboard({
idDashboard: dashboardId,
layout: dashboardLayout
});
$('#dashboardWidgetsArea')
.on('dashboardempty', showEmptyDashboardNotification)
.dashboard({
idDashboard: dashboardId,
layout: dashboardLayout
});

$('#dashboardSettings').widgetPreview({
isWidgetAvailable: function (widgetUniqueId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@
columnNumber = 1;
}

// do not try to add widget if given columnnumber is to high
// do not try to add widget if given column number is to high
if (columnNumber > $('.col', dashboardElement).length) {
return;
}
Expand Down
130 changes: 130 additions & 0 deletions plugins/Dashboard/templates/embeddedIndex.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
{{ loadJavascriptTranslations(['CoreHome','Dashboard'])|raw }}

<script type="text/javascript">
widgetsHelper.availableWidgets = {{ availableWidgets|raw }};
$(document).ready(function () {
initDashboard({{ dashboardId }}, {{ dashboardLayout|raw }});
});
</script>
<div id="dashboard">
<div class="ui-confirm" id="confirm">
<h2>{{ 'Dashboard_DeleteWidgetConfirm'|translate }}</h2>
<input role="yes" type="button" value="{{ 'General_Yes'|translate }}"/>
<input role="no" type="button" value="{{ 'General_Cancel'|translate }}"/>
</div>

<div class="ui-confirm" id="setAsDefaultWidgetsConfirm">
<h2>{{ 'Dashboard_SetAsDefaultWidgetsConfirm'|translate }}</h2>
{% set resetDashboard %}{{ 'Dashboard_ResetDashboard'|translate }}{% endset %}
<div class="popoverSubMessage">{{ 'Dashboard_SetAsDefaultWidgetsConfirmHelp'|translate(resetDashboard) }}</div>
<input role="yes" type="button" value="{{ 'General_Yes'|translate }}"/>
<input role="no" type="button" value="{{ 'General_Cancel'|translate }}"/>
</div>

<div class="ui-confirm" id="resetDashboardConfirm">
<h2>{{ 'Dashboard_ResetDashboardConfirm'|translate }}</h2>
<input role="yes" type="button" value="{{ 'General_Yes'|translate }}"/>
<input role="no" type="button" value="{{ 'General_Cancel'|translate }}"/>
</div>

<div class="ui-confirm" id="dashboardEmptyNotification">
<h2>{{ 'Dashboard_DashboardEmptyNotification'|translate }}</h2>
<input role="addWidget" type="button" value="{{ 'Dashboard_AddAWidget'|translate }}"/>
<input role="resetDashboard" type="button" value="{{ 'Dashboard_ResetDashboard'|translate }}"/>
</div>

<div class="ui-confirm" id="changeDashboardLayout">
<h2>{{ 'Dashboard_SelectDashboardLayout'|translate }}</h2>

<div id="columnPreview">
{% for layout in availableLayouts %}
<div>
{% for column in layout %}
<div class="width-{{ column }}"><span></span></div>
{% endfor %}
</div>
{% endfor %}
</div>
<input role="yes" type="button" value="{{ 'General_Save'|translate }}"/>
</div>

<div class="ui-confirm" id="renameDashboardConfirm">
<h2>{{ 'Dashboard_RenameDashboard'|translate }}</h2>

<div id="newDashboardNameInput"><label for="newDashboardName">{{ 'Dashboard_DashboardName'|translate }} </label>
<input type="input" name="newDashboardName" id="newDashboardName" value=""/>
</div>
<input role="yes" type="button" value="{{ 'General_Save'|translate }}"/>
<input role="cancel" type="button" value="{{ 'General_Cancel'|translate }}"/>
</div>

{% if isSuperUser %}
<div class="ui-confirm" id="copyDashboardToUserConfirm">
<h2>{{ 'Dashboard_CopyDashboardToUser'|translate }}</h2>

<div class="inputs">
<label for="copyDashboardName">{{ 'Dashboard_DashboardName'|translate }} </label>
<input type="input" name="copyDashboardName" id="copyDashboardName" value=""/>
<label for="copyDashboardUser">{{ 'General_Username'|translate }} </label>
<select name="copyDashboardUser" id="copyDashboardUser"></select>
</div>
<input role="yes" type="button" value="{{ 'General_Ok'|translate }}"/>
<input role="cancel" type="button" value="{{ 'General_Cancel'|translate }}"/>
</div>
{% endif %}

<div class="ui-confirm" id="createDashboardConfirm">
<h2>{{ 'Dashboard_CreateNewDashboard'|translate }}</h2>

<div id="createDashboardNameInput">
<label>{{ 'Dashboard_DashboardName'|translate }} <input type="input" name="newDashboardName" id="createDashboardName" value=""/></label><br/>
<label><input type="radio" checked="checked" name="type" value="default" id="dashboard_type_default">{{ 'Dashboard_DefaultDashboard'|translate }}
</label><br/>
<label><input type="radio" name="type" value="empty" id="dashboard_type_empty">{{ 'Dashboard_EmptyDashboard'|translate }}</label>
</div>
<input role="yes" type="button" value="{{ 'General_Yes'|translate }}"/>
<input role="no" type="button" value="{{ 'General_Cancel'|translate }}"/>
</div>

<div class="ui-confirm" id="removeDashboardConfirm">
<h2>{{ 'Dashboard_RemoveDashboardConfirm'|translate('<span></span>') }}</h2>

<div class="popoverSubMessage">{{ 'Dashboard_NotUndo'|translate(resetDashboard) }}</div>
<input role="yes" type="button" value="{{ 'General_Yes'|translate }}"/>
<input role="no" type="button" value="{{ 'General_Cancel'|translate }}"/>
</div>

<div id="dashboardSettings">
<span>{{ 'Dashboard_WidgetsAndDashboard'|translate }}</span>
<ul class="submenu">
<li>
<div id="addWidget">{{ 'Dashboard_AddAWidget'|translate }} &darr;</div>
<ul class="widgetpreview-categorylist"></ul>
</li>
<li>
<div id="manageDashboard">{{ 'Dashboard_ManageDashboard'|translate }} &darr;</div>
<ul>
<li onclick="resetDashboard();">{{ 'Dashboard_ResetDashboard'|translate }}</li>
<li onclick="showChangeDashboardLayoutDialog();">{{ 'Dashboard_ChangeDashboardLayout'|translate }}</li>
{% if userLogin and userLogin != 'anonymous' %}
<li onclick="renameDashboard();">{{ 'Dashboard_RenameDashboard'|translate }}</li>
<li onclick="removeDashboard();" id="removeDashboardLink">{{ 'Dashboard_RemoveDashboard'|translate }}</li>
{% if isSuperUser %}
<li onclick="setAsDefaultWidgets();">{{ 'Dashboard_SetAsDefaultWidgets'|translate }}</li>
<li onclick="copyDashboardToUser();">{{ 'Dashboard_CopyDashboardToUser'|translate }}</li>
{% endif %}
{% endif %}
</ul>
</li>
{% if (userLogin and 'anonymous' != userLogin) %}
<li onclick="createDashboard();">{{ 'Dashboard_CreateNewDashboard'|translate }}</li>
{% endif %}
</ul>
<ul class="widgetpreview-widgetlist"></ul>
<div class="widgetpreview-preview"></div>
</div>

<div class="clear"></div>

<div id="dashboardWidgetsArea"></div>
</div>
138 changes: 13 additions & 125 deletions plugins/Dashboard/templates/index.twig
Original file line number Diff line number Diff line change
@@ -1,130 +1,18 @@
{{ loadJavascriptTranslations(['CoreHome','Dashboard'])|raw }}

<script type="text/javascript">
widgetsHelper.availableWidgets = {{ availableWidgets|raw }};
$(document).ready(function () {
initDashboard({{ dashboardId }}, {{ dashboardLayout|raw }});
});
</script>
<div id="dashboard">
<div class="ui-confirm" id="confirm">
<h2>{{ 'Dashboard_DeleteWidgetConfirm'|translate }}</h2>
<input role="yes" type="button" value="{{ 'General_Yes'|translate }}"/>
<input role="no" type="button" value="{{ 'General_Cancel'|translate }}"/>
</div>

<div class="ui-confirm" id="setAsDefaultWidgetsConfirm">
<h2>{{ 'Dashboard_SetAsDefaultWidgetsConfirm'|translate }}</h2>
{% set resetDashboard %}{{ 'Dashboard_ResetDashboard'|translate }}{% endset %}
<div class="popoverSubMessage">{{ 'Dashboard_SetAsDefaultWidgetsConfirmHelp'|translate(resetDashboard) }}</div>
<input role="yes" type="button" value="{{ 'General_Yes'|translate }}"/>
<input role="no" type="button" value="{{ 'General_Cancel'|translate }}"/>
</div>

<div class="ui-confirm" id="resetDashboardConfirm">
<h2>{{ 'Dashboard_ResetDashboardConfirm'|translate }}</h2>
<input role="yes" type="button" value="{{ 'General_Yes'|translate }}"/>
<input role="no" type="button" value="{{ 'General_Cancel'|translate }}"/>
</div>

<div class="ui-confirm" id="dashboardEmptyNotification">
<h2>{{ 'Dashboard_DashboardEmptyNotification'|translate }}</h2>
<input role="addWidget" type="button" value="{{ 'Dashboard_AddAWidget'|translate }}"/>
<input role="resetDashboard" type="button" value="{{ 'Dashboard_ResetDashboard'|translate }}"/>
</div>

<div class="ui-confirm" id="changeDashboardLayout">
<h2>{{ 'Dashboard_SelectDashboardLayout'|translate }}</h2>

<div id="columnPreview">
{% for layout in availableLayouts %}
<div>
{% for column in layout %}
<div class="width-{{ column }}"><span></span></div>
{% endfor %}
</div>
{% include "@Dashboard/_header.twig" %}
<div id="menuHead">
{% include "@CoreHome/period_select.twig" %}
<div id="Dashboard">
<ul>
{% for dashboard in dashboards %}
<li class="dashboardMenuItem" id="Dashboard_embeddedIndex_{{ dashboard.iddashboard }}"><a
href="javascript:$('#dashboardWidgetsArea').dashboard('loadDashboard', {{ dashboard.iddashboard }});">{{ dashboard.name|escape }}</a></li>
{% endfor %}
</div>
<input role="yes" type="button" value="{{ 'General_Save'|translate }}"/>
</div>

<div class="ui-confirm" id="renameDashboardConfirm">
<h2>{{ 'Dashboard_RenameDashboard'|translate }}</h2>

<div id="newDashboardNameInput"><label for="newDashboardName">{{ 'Dashboard_DashboardName'|translate }} </label>
<input type="input" name="newDashboardName" id="newDashboardName" value=""/>
</div>
<input role="yes" type="button" value="{{ 'General_Save'|translate }}"/>
<input role="cancel" type="button" value="{{ 'General_Cancel'|translate }}"/>
</div>

{% if isSuperUser %}
<div class="ui-confirm" id="copyDashboardToUserConfirm">
<h2>{{ 'Dashboard_CopyDashboardToUser'|translate }}</h2>

<div class="inputs">
<label for="copyDashboardName">{{ 'Dashboard_DashboardName'|translate }} </label>
<input type="input" name="copyDashboardName" id="copyDashboardName" value=""/>
<label for="copyDashboardUser">{{ 'General_Username'|translate }} </label>
<select name="copyDashboardUser" id="copyDashboardUser"></select>
</div>
<input role="yes" type="button" value="{{ 'General_Ok'|translate }}"/>
<input role="cancel" type="button" value="{{ 'General_Cancel'|translate }}"/>
</div>
{% endif %}

<div class="ui-confirm" id="createDashboardConfirm">
<h2>{{ 'Dashboard_CreateNewDashboard'|translate }}</h2>

<div id="createDashboardNameInput">
<label>{{ 'Dashboard_DashboardName'|translate }} <input type="input" name="newDashboardName" id="createDashboardName" value=""/></label><br/>
<label><input type="radio" checked="checked" name="type" value="default" id="dashboard_type_default">{{ 'Dashboard_DefaultDashboard'|translate }}
</label><br/>
<label><input type="radio" name="type" value="empty" id="dashboard_type_empty">{{ 'Dashboard_EmptyDashboard'|translate }}</label>
</div>
<input role="yes" type="button" value="{{ 'General_Yes'|translate }}"/>
<input role="no" type="button" value="{{ 'General_Cancel'|translate }}"/>
</div>

<div class="ui-confirm" id="removeDashboardConfirm">
<h2>{{ 'Dashboard_RemoveDashboardConfirm'|translate('<span></span>') }}</h2>

<div class="popoverSubMessage">{{ 'Dashboard_NotUndo'|translate(resetDashboard) }}</div>
<input role="yes" type="button" value="{{ 'General_Yes'|translate }}"/>
<input role="no" type="button" value="{{ 'General_Cancel'|translate }}"/>
</div>

<div id="dashboardSettings">
<span>{{ 'Dashboard_WidgetsAndDashboard'|translate }}</span>
<ul class="submenu">
<li>
<div id="addWidget">{{ 'Dashboard_AddAWidget'|translate }} &darr;</div>
<ul class="widgetpreview-categorylist"></ul>
</li>
<li>
<div id="manageDashboard">{{ 'Dashboard_ManageDashboard'|translate }} &darr;</div>
<ul>
<li onclick="resetDashboard();">{{ 'Dashboard_ResetDashboard'|translate }}</li>
<li onclick="showChangeDashboardLayoutDialog();">{{ 'Dashboard_ChangeDashboardLayout'|translate }}</li>
{% if userLogin and userLogin != 'anonymous' %}
<li onclick="renameDashboard();">{{ 'Dashboard_RenameDashboard'|translate }}</li>
<li onclick="removeDashboard();" id="removeDashboardLink">{{ 'Dashboard_RemoveDashboard'|translate }}</li>
{% if isSuperUser %}
<li onclick="setAsDefaultWidgets();">{{ 'Dashboard_SetAsDefaultWidgets'|translate }}</li>
<li onclick="copyDashboardToUser();">{{ 'Dashboard_CopyDashboardToUser'|translate }}</li>
{% endif %}
{% endif %}
</ul>
</li>
{% if (userLogin and 'anonymous' != userLogin) %}
<li onclick="createDashboard();">{{ 'Dashboard_CreateNewDashboard'|translate }}</li>
{% endif %}
</ul>
<ul class="widgetpreview-widgetlist"></ul>
<div class="widgetpreview-preview"></div>
</div>

<div class="clear"></div>

<div id="dashboardWidgetsArea"></div>
</div>
{% import 'ajaxMacros.twig' as ajax %}
{{ ajax.loadingDiv }}
{% include "@Dashboard/embeddedIndex.twig" %}
</body>
</html>
18 changes: 0 additions & 18 deletions plugins/Dashboard/templates/standalone.twig

This file was deleted.

3 changes: 1 addition & 2 deletions plugins/MultiSites/templates/index.twig
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{% set showSitesSelection=false %}

{% extends 'dashboard.twig' %}
{% if not isWidgetized %}{% endif %}
{% extends 'dashboard.twig' %}

{% block content %}
<div id="multisites">
Expand Down
4 changes: 2 additions & 2 deletions plugins/Widgetize/Widgetize.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function getJsFiles($notification)
$jsFiles[] = "libs/jquery/jquery.scrollTo.js";
$jsFiles[] = "themes/default/common.js";
$jsFiles[] = "plugins/CoreHome/templates/datatable.js";
$jsFiles[] = "plugins/Dashboard/templates/widgetMenu.js";
$jsFiles[] = "plugins/Dashboard/javascripts/widgetMenu.js";
$jsFiles[] = "plugins/Widgetize/templates/widgetize.js";
}

Expand All @@ -69,6 +69,6 @@ function getCssFiles($notification)
$cssFiles[] = "plugins/CoreHome/templates/styles.css";
$cssFiles[] = "plugins/CoreHome/templates/datatable.css";
$cssFiles[] = "plugins/CoreHome/templates/cloud.css";
$cssFiles[] = "plugins/Dashboard/templates/dashboard.css";
$cssFiles[] = "plugins/Dashboard/stylesheets/dashboard.css";
}
}