JS: Fix scrutinizer warnings and indentation for services
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
committed by
Julius Härtl
parent
9014ae1490
commit
320f2bf5c8
@@ -20,8 +20,9 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
app.factory('ApiService', function($http, $q){
|
/** global: oc_defaults */
|
||||||
var ApiService = function(http, endpoint) {
|
app.factory('ApiService', function ($http, $q) {
|
||||||
|
var ApiService = function (http, endpoint) {
|
||||||
this.endpoint = endpoint;
|
this.endpoint = endpoint;
|
||||||
this.baseUrl = OC.generateUrl('/apps/deck/' + endpoint);
|
this.baseUrl = OC.generateUrl('/apps/deck/' + endpoint);
|
||||||
this.http = http;
|
this.http = http;
|
||||||
@@ -31,7 +32,7 @@ app.factory('ApiService', function($http, $q){
|
|||||||
this.sorted = [];
|
this.sorted = [];
|
||||||
};
|
};
|
||||||
|
|
||||||
ApiService.prototype.fetchAll = function(){
|
ApiService.prototype.fetchAll = function () {
|
||||||
var deferred = $q.defer();
|
var deferred = $q.defer();
|
||||||
var self = this;
|
var self = this;
|
||||||
$http.get(this.baseUrl).then(function (response) {
|
$http.get(this.baseUrl).then(function (response) {
|
||||||
@@ -51,17 +52,17 @@ app.factory('ApiService', function($http, $q){
|
|||||||
this.id = id;
|
this.id = id;
|
||||||
var deferred = $q.defer();
|
var deferred = $q.defer();
|
||||||
|
|
||||||
if(id===undefined) {
|
if (id === undefined) {
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
$http.get(this.baseUrl + '/' + id).then(function (response) {
|
$http.get(this.baseUrl + '/' + id).then(function (response) {
|
||||||
data = response.data;
|
var data = response.data;
|
||||||
if(self.data[data.id]===undefined) {
|
if (self.data[data.id] === undefined) {
|
||||||
self.data[data.id] = response.data;
|
self.data[data.id] = response.data;
|
||||||
}
|
}
|
||||||
$.each(response.data, function(key, value) {
|
$.each(response.data, function (key, value) {
|
||||||
self.data[data.id][key] = value;
|
self.data[data.id][key] = value;
|
||||||
});
|
});
|
||||||
deferred.resolve(response.data);
|
deferred.resolve(response.data);
|
||||||
@@ -114,12 +115,12 @@ app.factory('ApiService', function($http, $q){
|
|||||||
|
|
||||||
|
|
||||||
// methods for managing data
|
// methods for managing data
|
||||||
ApiService.prototype.clear = function() {
|
ApiService.prototype.clear = function () {
|
||||||
this.data = {};
|
this.data = {};
|
||||||
};
|
};
|
||||||
ApiService.prototype.add = function (entity) {
|
ApiService.prototype.add = function (entity) {
|
||||||
var element = this.data[entity.id];
|
var element = this.data[entity.id];
|
||||||
if(element===undefined) {
|
if (element === undefined) {
|
||||||
this.data[entity.id] = entity;
|
this.data[entity.id] = entity;
|
||||||
} else {
|
} else {
|
||||||
Object.keys(entity).forEach(function (key) {
|
Object.keys(entity).forEach(function (key) {
|
||||||
@@ -128,14 +129,14 @@ app.factory('ApiService', function($http, $q){
|
|||||||
element.status = {};
|
element.status = {};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
ApiService.prototype.remove = function(id) {
|
ApiService.prototype.remove = function (id) {
|
||||||
if (this.data[id] !== undefined) {
|
if (this.data[id] !== undefined) {
|
||||||
delete this.data[id];
|
delete this.data[id];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
ApiService.prototype.addAll = function (entities) {
|
ApiService.prototype.addAll = function (entities) {
|
||||||
var self = this;
|
var self = this;
|
||||||
angular.forEach(entities, function(entity) {
|
angular.forEach(entities, function (entity) {
|
||||||
self.add(entity);
|
self.add(entity);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -149,9 +150,8 @@ app.factory('ApiService', function($http, $q){
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
ApiService.prototype.getData = function () {
|
||||||
ApiService.prototype.getData = function() {
|
return $.map(this.data, function (value, index) {
|
||||||
return $.map(this.data, function(value, index) {
|
|
||||||
return [value];
|
return [value];
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -160,7 +160,7 @@ app.factory('ApiService', function($http, $q){
|
|||||||
return this.data;
|
return this.data;
|
||||||
};
|
};
|
||||||
|
|
||||||
ApiService.prototype.getName = function() {
|
ApiService.prototype.getName = function () {
|
||||||
var funcNameRegex = /function (.{1,})\(/;
|
var funcNameRegex = /function (.{1,})\(/;
|
||||||
var results = (funcNameRegex).exec((this).constructor.toString());
|
var results = (funcNameRegex).exec((this).constructor.toString());
|
||||||
return (results && results.length > 1) ? results[1] : "";
|
return (results && results.length > 1) ? results[1] : "";
|
||||||
|
|||||||
@@ -20,8 +20,9 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
app.factory('BoardService', function(ApiService, $http, $q){
|
/** global: OC */
|
||||||
var BoardService = function($http, ep, $q) {
|
app.factory('BoardService', function (ApiService, $http, $q) {
|
||||||
|
var BoardService = function ($http, ep, $q) {
|
||||||
ApiService.call(this, $http, ep, $q);
|
ApiService.call(this, $http, ep, $q);
|
||||||
};
|
};
|
||||||
BoardService.prototype = angular.copy(ApiService.prototype);
|
BoardService.prototype = angular.copy(ApiService.prototype);
|
||||||
@@ -113,7 +114,7 @@ app.factory('BoardService', function(ApiService, $http, $q){
|
|||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
BoardService.prototype.generateAcl = function(type, ocsItem) {
|
BoardService.prototype.generateAcl = function (type, ocsItem) {
|
||||||
return {
|
return {
|
||||||
boardId: null,
|
boardId: null,
|
||||||
id: null,
|
id: null,
|
||||||
@@ -148,7 +149,7 @@ app.factory('BoardService', function(ApiService, $http, $q){
|
|||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
BoardService.prototype.deleteAcl = function(acl) {
|
BoardService.prototype.deleteAcl = function (acl) {
|
||||||
var board = this.getCurrent();
|
var board = this.getCurrent();
|
||||||
var deferred = $q.defer();
|
var deferred = $q.defer();
|
||||||
var self = this;
|
var self = this;
|
||||||
@@ -162,7 +163,7 @@ app.factory('BoardService', function(ApiService, $http, $q){
|
|||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
BoardService.prototype.updateAcl = function(acl) {
|
BoardService.prototype.updateAcl = function (acl) {
|
||||||
var board = this.getCurrent();
|
var board = this.getCurrent();
|
||||||
var deferred = $q.defer();
|
var deferred = $q.defer();
|
||||||
var self = this;
|
var self = this;
|
||||||
@@ -177,45 +178,44 @@ app.factory('BoardService', function(ApiService, $http, $q){
|
|||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
BoardService.prototype.canRead = function() {
|
BoardService.prototype.canRead = function () {
|
||||||
if(!this.getCurrent() || !this.getCurrent().permissions) {
|
if (!this.getCurrent() || !this.getCurrent().permissions) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return this.getCurrent().permissions['PERMISSION_READ'];
|
return this.getCurrent().permissions['PERMISSION_READ'];
|
||||||
};
|
};
|
||||||
|
|
||||||
BoardService.prototype.canEdit = function() {
|
BoardService.prototype.canEdit = function () {
|
||||||
if(!this.getCurrent() || !this.getCurrent().permissions) {
|
if (!this.getCurrent() || !this.getCurrent().permissions) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return this.getCurrent().permissions['PERMISSION_EDIT'];
|
return this.getCurrent().permissions['PERMISSION_EDIT'];
|
||||||
};
|
};
|
||||||
|
|
||||||
BoardService.prototype.canManage = function(board) {
|
BoardService.prototype.canManage = function (board) {
|
||||||
if(board !== null && board !== undefined) {
|
if (board !== null && board !== undefined) {
|
||||||
return board.permissions['PERMISSION_MANAGE'];
|
return board.permissions['PERMISSION_MANAGE'];
|
||||||
}
|
}
|
||||||
if(!this.getCurrent() || !this.getCurrent().permissions) {
|
if (!this.getCurrent() || !this.getCurrent().permissions) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return this.getCurrent().permissions['PERMISSION_MANAGE'];
|
return this.getCurrent().permissions['PERMISSION_MANAGE'];
|
||||||
};
|
};
|
||||||
|
|
||||||
BoardService.prototype.canShare = function() {
|
BoardService.prototype.canShare = function () {
|
||||||
if(!this.getCurrent() || !this.getCurrent().permissions) {
|
if (!this.getCurrent() || !this.getCurrent().permissions) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return this.getCurrent().permissions['PERMISSION_SHARE'];
|
return this.getCurrent().permissions['PERMISSION_SHARE'];
|
||||||
};
|
};
|
||||||
|
|
||||||
BoardService.prototype.isArchived = function () {
|
BoardService.prototype.isArchived = function () {
|
||||||
if(!this.getCurrent() || this.getCurrent().archived) {
|
if (!this.getCurrent() || this.getCurrent().archived) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
service = new BoardService($http, 'boards', $q);
|
return new BoardService($http, 'boards', $q);
|
||||||
return service;
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -20,11 +20,10 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
app.factory('LabelService', function(ApiService, $http, $q){
|
app.factory('LabelService', function (ApiService, $http, $q) {
|
||||||
var LabelService = function($http, ep, $q) {
|
var LabelService = function ($http, ep, $q) {
|
||||||
ApiService.call(this, $http, ep, $q);
|
ApiService.call(this, $http, ep, $q);
|
||||||
};
|
};
|
||||||
LabelService.prototype = angular.copy(ApiService.prototype);
|
LabelService.prototype = angular.copy(ApiService.prototype);
|
||||||
service = new LabelService($http, 'labels', $q);
|
return new LabelService($http, 'labels', $q);
|
||||||
return service;
|
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user