Issue #277 : Move storage services to dedicated package

This commit is contained in:
jdescottes 2015-09-17 00:03:25 +02:00
parent d576c56068
commit 551e15e67b
6 changed files with 17 additions and 42 deletions

View File

@ -109,10 +109,13 @@
this.canvasBackgroundController = new pskl.controller.CanvasBackgroundController(); this.canvasBackgroundController = new pskl.controller.CanvasBackgroundController();
this.canvasBackgroundController.init(); this.canvasBackgroundController.init();
this.localStorageService = new pskl.service.LocalStorageService(this.piskelController); this.galleryStorageService = new pskl.service.storage.GalleryStorageService(this.piskelController);
this.galleryStorageService.init();
this.localStorageService = new pskl.service.storage.LocalStorageService(this.piskelController);
this.localStorageService.init(); this.localStorageService.init();
this.desktopStorageService = new pskl.service.DesktopStorageService(this.piskelController); this.desktopStorageService = new pskl.service.storage.DesktopStorageService(this.piskelController);
this.desktopStorageService.init(); this.desktopStorageService.init();
this.imageUploadService = new pskl.service.ImageUploadService(); this.imageUploadService = new pskl.service.ImageUploadService();
@ -135,13 +138,6 @@
document.querySelector('#drawing-canvas-container')); document.querySelector('#drawing-canvas-container'));
this.fileDropperService.init(); this.fileDropperService.init();
if (this.isAppEngineVersion) {
this.storageService = new pskl.service.AppEngineStorageService(this.piskelController);
} else {
this.storageService = new pskl.service.GithubStorageService(this.piskelController);
}
this.storageService.init();
var drawingLoop = new pskl.rendering.DrawingLoop(); var drawingLoop = new pskl.rendering.DrawingLoop();
drawingLoop.addCallback(this.render, this); drawingLoop.addCallback(this.render, this);
drawingLoop.start(); drawingLoop.start();

View File

@ -1,13 +0,0 @@
(function () {
var ns = $.namespace('pskl.service');
ns.GithubStorageService = function (piskelController) {
this.piskelController = piskelController;
};
ns.GithubStorageService.prototype.init = function () {};
ns.GithubStorageService.prototype.store = function (callbacks) {
throw 'Github save is no longer available. Use local save instead';
};
})();

View File

@ -1,5 +1,5 @@
(function () { (function () {
var ns = $.namespace('pskl.service'); var ns = $.namespace('pskl.service.storage');
ns.DesktopStorageService = function(piskelController) { ns.DesktopStorageService = function(piskelController) {
this.piskelController = piskelController || pskl.app.piskelController; this.piskelController = piskelController || pskl.app.piskelController;

View File

@ -1,14 +1,13 @@
(function () { (function () {
var ns = $.namespace('pskl.service'); var ns = $.namespace('pskl.service.storage');
ns.AppEngineStorageService = function (piskelController) { ns.GalleryStorageService = function (piskelController) {
this.piskelController = piskelController; this.piskelController = piskelController;
}; };
ns.AppEngineStorageService.prototype.init = function () {}; ns.GalleryStorageService.prototype.init = function () {};
ns.AppEngineStorageService.prototype.store = function (callbacks) { ns.GalleryStorageService.prototype.store = function (piskel, onSuccess, onError) {
var piskel = this.piskelController.getPiskel();
var descriptor = piskel.getDescriptor(); var descriptor = piskel.getDescriptor();
var data = { var data = {
@ -25,16 +24,10 @@
data.public = true; data.public = true;
} }
var success = function () { var errorCallback = function (response) {
callbacks.success(); onError(response.status);
callbacks.after();
}; };
var error = function (response) { pskl.utils.Xhr.post(Constants.APPENGINE_SAVE_URL, data, onSuccess, errorCallback);
callbacks.error(response.status);
callbacks.after();
};
pskl.utils.Xhr.post(Constants.APPENGINE_SAVE_URL, data, success, error);
}; };
})(); })();

View File

@ -1,5 +1,5 @@
(function () { (function () {
var ns = $.namespace('pskl.service'); var ns = $.namespace('pskl.service.storage');
ns.LocalStorageService = function (piskelController) { ns.LocalStorageService = function (piskelController) {
if (piskelController === undefined) { if (piskelController === undefined) {

View File

@ -136,10 +136,6 @@
"js/widgets/SizeInput.js", "js/widgets/SizeInput.js",
// Services // Services
"js/service/LocalStorageService.js",
"js/service/GithubStorageService.js",
"js/service/AppEngineStorageService.js",
"js/service/DesktopStorageService.js",
"js/service/BackupService.js", "js/service/BackupService.js",
"js/service/BeforeUnloadService.js", "js/service/BeforeUnloadService.js",
"js/service/HistoryService.js", "js/service/HistoryService.js",
@ -162,6 +158,9 @@
"js/service/FileDropperService.js", "js/service/FileDropperService.js",
"js/service/SelectedColorsService.js", "js/service/SelectedColorsService.js",
"js/service/MouseStateService.js", "js/service/MouseStateService.js",
"js/service/storage/LocalStorageService.js",
"js/service/storage/GalleryStorageService.js",
"js/service/storage/DesktopStorageService.js",
// Tools // Tools
"js/tools/ToolsHelper.js", "js/tools/ToolsHelper.js",