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.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.desktopStorageService = new pskl.service.DesktopStorageService(this.piskelController);
this.desktopStorageService = new pskl.service.storage.DesktopStorageService(this.piskelController);
this.desktopStorageService.init();
this.imageUploadService = new pskl.service.ImageUploadService();
@ -135,13 +138,6 @@
document.querySelector('#drawing-canvas-container'));
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();
drawingLoop.addCallback(this.render, this);
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 () {
var ns = $.namespace('pskl.service');
var ns = $.namespace('pskl.service.storage');
ns.DesktopStorageService = function(piskelController) {
this.piskelController = piskelController || pskl.app.piskelController;

View File

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

View File

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

View File

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