Permalink
Browse files

Merge pull request #87 from mozilla/b2g-history-labels

added url based history and HTML5 labels to b2g UI, removed pushlog pane...
  • Loading branch information...
2 parents a33e9bd + 36ff23d commit 4dde690274daf69b1644ada42b2ea81254a083c1 @jeads jeads committed Mar 12, 2013
Showing with 497 additions and 149 deletions.
  1. +8 −0 datazilla/settings/base.py
  2. +1 −0 datazilla/webapp/apps/datazilla/views.py
  3. +1 −1 datazilla/webapp/static/css/apps-summary-min.css
  4. +0 −29 datazilla/webapp/static/css/apps.css
  5. +184 −12 datazilla/webapp/static/js/b2g_apps/AppsPage.js
  6. +109 −8 datazilla/webapp/static/js/b2g_apps/GraphControlsComponent.js
  7. +64 −79 datazilla/webapp/static/js/b2g_apps/PerformanceGraphComponent.js
  8. +3 −1 datazilla/webapp/static/js/b2g_apps/ReplicateGraphComponent.js
  9. +1 −1 datazilla/webapp/static/js/b2g_apps/apps-summary-min.js
  10. +1 −1 datazilla/webapp/static/js/metric_summary/MetricDashboardComponent.js
  11. +2 −1 datazilla/webapp/static/js/metric_summary/MetricSummaryPage.js
  12. +1 −1 datazilla/webapp/static/js/metric_summary/metric-summary-min.js
  13. +1 −0 datazilla/webapp/static/js/plugins/jquery.history.js
  14. +9 −14 datazilla/webapp/templates/apps.summary.html
  15. +1 −1 datazilla/webapp/templates/metrics.summary.html
  16. +1 −0 requirements/pure.txt
  17. 0 vendor/corsheaders/__init__.py
  18. +30 −0 vendor/corsheaders/defaults.py
  19. +47 −0 vendor/corsheaders/middleware.py
  20. +1 −0 vendor/datasource/t/character_encoding_data.txt
  21. +10 −0 vendor/django_cors_headers-0.06-py2.6.egg-info/PKG-INFO
  22. +9 −0 vendor/django_cors_headers-0.06-py2.6.egg-info/SOURCES.txt
  23. +1 −0 vendor/django_cors_headers-0.06-py2.6.egg-info/dependency_links.txt
  24. +11 −0 vendor/django_cors_headers-0.06-py2.6.egg-info/installed-files.txt
  25. +1 −0 vendor/django_cors_headers-0.06-py2.6.egg-info/top_level.txt
@@ -91,6 +91,7 @@
MIDDLEWARE_CLASSES = [
"django.middleware.common.CommonMiddleware",
+ "corsheaders.middleware.CorsMiddleware",
# "django.contrib.sessions.middleware.SessionMiddleware",
# "django.contrib.auth.middleware.AuthenticationMiddleware",
# "django.contrib.messages.middleware.MessageMiddleware",
@@ -119,8 +120,15 @@
"datazilla.webapp.apps.datazilla",
"datazilla.webapp.apps.dataviews",
"datazilla.webapp.apps.summary",
+
+ "corsheaders",
]
+CORS_ORIGIN_ALLOW_ALL = True
+
+CORS_ALLOW_METHODS = (
+ 'GET'
+)
# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error.
@@ -122,6 +122,7 @@ def set_test_data(request, project=""):
"size": len(unquoted_json_data),
}
+ id = 0
try:
dm = PerformanceTestModel(project)
id = dm.store_test_data(unquoted_json_data, error)
@@ -143,35 +143,6 @@ div.app-no-data-message {
font-size: 18px;
font-weight: bold;
}
-.app-arrow-box {
- position: relative;
- background: #ffffff;
- border: 2px solid #5CB2CB;
-}
-.app-arrow-box:after, .app-arrow-box:before {
- bottom: 100%;
- border: solid transparent;
- content: " ";
- height: 0;
- width: 0;
- position: absolute;
- pointer-events: none;
-}
-
-.app-arrow-box:after {
- border-color: rgba(255, 255, 255, 0);
- border-bottom-color: #ffffff;
- border-width: 10px;
- left: 50%;
- margin-left: -10px;
-}
-.app-arrow-box:before {
- border-color: rgba(92, 178, 203, 0);
- border-bottom-color: #5CB2CB;
- border-width: 13px;
- left: 50%;
- margin-left: -13px;
-}
button:hover {
cursor:pointer;
}
@@ -20,22 +20,130 @@ var AppsPage = new Class( {
this.gaiaHrefBase = "https://github.com/mozilla-b2g/gaia/commit/";
this.geckoHrefBase = "http://git.mozilla.org/?p=releases/gecko.git;a=commit;h=";
this.buildHrefBase = "https://github.com/mozilla-b2g/platform_build/commit/";
+
+ this.history = window.History;
+
+ this.stateChangeEvent = 'STATE_CHANGE_EV';
+
+ this.appContainerSel = '#app_container';
+
+ //If it's set to true the STATE_CHANGE_EV is from a
+ //change in history (back/forward button clicked)
+ this.historyEvent = false;
+
+ //If set to true, it disables the abbility to saveState
+ //this allows component defined events to specify whether
+ //they are added to the history
+ this.disableSaveState = false;
+
+ this.history.Adapter.bind(
+ window, 'statechange', _.bind(this.stateChange, this)
+ );
+
+ this.paramKeys = [ 'branch', 'range', 'test', 'app', 'app_list',
+ 'gaia_rev', 'gecko_rev' ];
+
+ },
+ saveState: function(){
+
+ if( (this.historyEvent === true) || (this.disableSaveState === true) ){
+ this.historyEvent = false;
+ return;
+ }
+
+ var params = this.getParams();
+ var paramData = this.getParamsStrAndHash(params.params);
+
+ paramData['lookup'] = params['lookup'];
+
+ this.history.pushState(
+ {state:paramData},
+ "Perf-o-Matic",
+ this.refData.project + '?' + paramData['params_str']
+ );
+
+ },
+ getParams: function(){
+
+ var view = this.performanceGraphComponent.view;
+
+ var params = [];
+ var lookup = {};
+
+ var branch = $(view.branchSel).find(":selected").text();
+ if(branch != ""){
+ params.push('branch=' + branch);
+ lookup['branch'] = branch;
+ }
+
+ var range = $(view.timeRangeSel).find(":selected").val();
+ if(range != ""){
+ params.push('range=' + range);
+ lookup['range'] = range;
+ }
+
+ var test = $(view.testSeriesSel).find('input:checked').next().text();
+ if(test != ""){
+ params.push('test=' + test);
+ lookup['test'] = test;
+ }
+
+ var app = $(view.appNameSpanSel).text();
+ if(app != ""){
+ params.push('app=' + app);
+ lookup['app'] = app;
+ }
+
+ var appListEls = $(view.appSeriesSel).find("input:checkbox:checked");
+ var appList = [];
+ _.map(appListEls, function(el){
+ appList.push( $(el).next().text() );
+ });
+
+ if(appList.length > 0){
+ params.push('app_list=' + appList.join(','));
+ }
+ //Always store the app_list lookup so we can represent
+ //0 selected apps in the app_list
+ lookup['app_list'] = appList;
+
+ var gaiaRev = $(view.gaiaRevisionSel).text();
+ if(gaiaRev != ""){
+ params.push('gaia_rev=' + gaiaRev);
+ lookup['gaia_rev'] = gaiaRev;
+ }
+
+ var geckoRev = $(view.geckoRevisionSel).text();
+ if(geckoRev != ""){
+ params.push('gecko_rev=' + geckoRev);
+ lookup['gecko_rev'] = geckoRev;
+ }
+
+ return { 'params':params , 'lookup':lookup };
+
},
+ getParamsStrAndHash: function(params){
+
+ var paramsStr = params.join('&');
+ return { 'params_str':paramsStr,
+ 'params':params,
+ 'hash':paramsStr.hashCode() };
+ },
setRefData: function(){
- APPS_PAGE.refData = {};
+ this.refData = {};
- var urlObj = APPS_PAGE.urlObj.data;
- APPS_PAGE.refData.project = urlObj.seg.path[0];
+ var urlObj = jQuery.url(window.location).data;
+ this.refData.project = urlObj.seg.path[0];
- APPS_PAGE.urlBase = urlObj.attr.base + urlObj.attr.directory;
+ this.urlBase = urlObj.attr.base + urlObj.attr.directory;
- APPS_PAGE.defaults = {};
- APPS_PAGE.defaults['branch'] = urlObj.param.query.branch;
- APPS_PAGE.defaults['range'] = urlObj.param.query.range;
- APPS_PAGE.defaults['test'] = urlObj.param.query.test;
- APPS_PAGE.defaults['app'] = urlObj.param.query.app;
+ this.defaults = {};
+ this.defaults['branch'] = urlObj.param.query.branch;
+ this.defaults['range'] = urlObj.param.query.range;
+ this.defaults['test'] = urlObj.param.query.test;
+ this.defaults['app'] = urlObj.param.query.app;
if( urlObj.param.query.app_list != undefined ){
@@ -48,15 +156,78 @@ var AppsPage = new Class( {
}
);
- APPS_PAGE.defaults['app_list'] = appLookup;
+ this.defaults['app_list'] = appLookup;
}
- APPS_PAGE.defaults['gaia_rev'] = urlObj.param.query.gaia_rev;
- APPS_PAGE.defaults['gecko_rev'] = urlObj.param.query.gecko_rev;
+ this.defaults['gaia_rev'] = urlObj.param.query.gaia_rev;
+ this.defaults['gecko_rev'] = urlObj.param.query.gecko_rev;
},
getRevisionSlice: function(revision){
return revision.slice(0, this.revisionLength);
+ },
+ stateChange: function(){
+
+ this.setRefData();
+
+ var historyState = this.history.getState();
+ var params = this.getParams();
+ var paramData = this.getParamsStrAndHash(params.params);
+
+ if(this.isHistoryStateChange(historyState, paramData)){
+
+ var modifiedParams = this.getModifiedParams(
+ historyState.data.state.lookup, params.lookup
+ );
+
+ this.historyEvent = true;
+
+ $(this.appContainerSel).trigger(
+ this.stateChangeEvent, modifiedParams
+ )
+ }
+ },
+ isHistoryStateChange: function(historyState, paramData){
+
+ var historyStateChange = false;
+
+ if( (historyState.data.state != undefined) &&
+ (historyState.data.state.hash != paramData.hash) ){
+ historyStateChange = true;
+ }
+
+ return historyStateChange;
+ },
+ getModifiedParams: function(oldParams, newParams){
+
+ var key = "";
+ var modifiedParams = {};
+ var i = 0;
+
+ for(i=0; i < this.paramKeys.length; i++){
+
+ key = this.paramKeys[i];
+
+ if(oldParams[key] != newParams[key]){
+ modifiedParams[key] = oldParams[key];
+ }
+ }
+
+ var keyHash = this.getDatapointHashCode(
+ oldParams['app'], oldParams['gaia_rev'],
+ oldParams['gecko_rev']
+ );
+
+ modifiedParams['datapoint_hash'] = keyHash;
+
+ return modifiedParams;
+ },
+ getDatapointHashCode: function(appName, gaiaRevision, geckoRevision){
+
+ var key = appName +
+ this.getRevisionSlice(gaiaRevision) +
+ this.getRevisionSlice(geckoRevision);
+ return key.hashCode();
}
});
@@ -71,4 +242,5 @@ $(document).ready(function() {
APPS_PAGE.performanceGraphComponent = new PerformanceGraphComponent();
APPS_PAGE.replicateGaphComponent = new ReplicateGraphComponent();
+
});
Oops, something went wrong. Retry.

0 comments on commit 4dde690

Please sign in to comment.