Skip to content

Instantly share code, notes, and snippets.

@luisrudge
Created December 18, 2012 17:39
Show Gist options
  • Save luisrudge/4330133 to your computer and use it in GitHub Desktop.
Save luisrudge/4330133 to your computer and use it in GitHub Desktop.
var dashboard;
(function (dashboard) {
var queryParameters = (function () {
function queryParameters(campaignId, interval, date, from, to) {
this.campaignId = campaignId;
this.interval = interval;
this.date = date;
this.from = from;
this.to = to;
}
return queryParameters;
})();
dashboard.queryParameters = queryParameters;
var dataContext = (function () {
function dataContext(baseUrl) {
this.baseUrl = baseUrl;
}
dataContext.prototype.ajaxRequest = function (url, data, type) {
if (typeof type === "undefined") { type = 'GET'; }
var options = {
dataType: "json",
contentType: "application/json",
cache: true,
type: type,
data: ko.toJSON(data)
};
return $.ajax(url, options);
};
dataContext.prototype.avaibleCampaigns = function () {
return this.ajaxRequest('api/campaign');
};
dataContext.prototype.loadTopSellingProducts = function (query) {
return this.ajaxRequest('api/topSellingProducts', query);
};
dataContext.prototype.loadSalesByProduct = function (query) {
return this.ajaxRequest('api/salesByProduct', query);
};
dataContext.prototype.loadTopSellingCatalogues = function (query) {
return this.ajaxRequest('api/topSellingCatalogues', query);
};
dataContext.prototype.loadTopPaymentMethods = function (query) {
return this.ajaxRequest('api/topPaymentMethods', query);
};
dataContext.prototype.loadSalesByState = function (query) {
return this.ajaxRequest('api/salesByState', query);
};
return dataContext;
})();
dashboard.dataContext = dataContext;
var app = (function () {
function app(baseUrl) {
this.main = new dashboard.main(baseUrl);
}
return app;
})();
dashboard.app = app;
})(dashboard || (dashboard = {}));
$(function () {
var app = new app('/');
});
var dashboard;
(function (dashboard) {
var main = (function () {
function main(baseUrl) {
var _this = this;
this.data = new dashboard.dataContext(baseUrl);
var self = this;
self.hideAll();
var app = Sammy('#main', function () {
var sammy = this;
this.get('#/', function (context) {
self.activateContent('#home');
});
this.get('#/report/:id', function (context) {
var reportId;
reportId = context.params['id'];
self.activateContent('#report-' + reportId);
_this.runReport(reportId);
});
this.get('#/logout', function (context) {
});
});
app.run('#/');
}
main.prototype.hideAll = function () {
$('section.report').hide().removeClass('active').addClass('inactive').css('opacity', 0).css('margin-left', 18);
};
main.prototype.activateContent = function (id) {
this.hideAll();
$(id).show().animate({
marginRight: 0,
marginLeft: 0,
opacity: 1
}, 450, 'swing').removeClass('inactive').addClass('active');
};
main.prototype.runReport = function (reportId) {
switch(reportId) {
case 1: {
break;
}
case 2:
case 3:
case 4:
default: {
break;
}
}
};
return main;
})();
dashboard.main = main;
})(dashboard || (dashboard = {}));
var dashboard;
(function (dashboard) {
var report1ViewModel = (function () {
function report1ViewModel() { }
return report1ViewModel;
})();
dashboard.report1ViewModel = report1ViewModel;
var selectedItems = (function () {
function selectedItems() { }
return selectedItems;
})();
dashboard.selectedItems = selectedItems;
var summary = (function () {
function summary() { }
return summary;
})();
dashboard.summary = summary;
var topSellingProductViewModel = (function () {
function topSellingProductViewModel() { }
return topSellingProductViewModel;
})();
dashboard.topSellingProductViewModel = topSellingProductViewModel;
var topSellingCatalogueViewModel = (function () {
function topSellingCatalogueViewModel() { }
return topSellingCatalogueViewModel;
})();
dashboard.topSellingCatalogueViewModel = topSellingCatalogueViewModel;
var topPaymentMethodViewModel = (function () {
function topPaymentMethodViewModel() { }
return topPaymentMethodViewModel;
})();
dashboard.topPaymentMethodViewModel = topPaymentMethodViewModel;
var topSellingPerStateViewModel = (function () {
function topSellingPerStateViewModel() { }
return topSellingPerStateViewModel;
})();
dashboard.topSellingPerStateViewModel = topSellingPerStateViewModel;
})(dashboard || (dashboard = {}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment