Commit 22e66774 by Jose Antonio

Working arasaac

parent e8155468
...@@ -372,6 +372,70 @@ module.exports = { ...@@ -372,6 +372,70 @@ module.exports = {
}, },
/** /**
* Return all pictos from Arasaac using the language of the specified supervisor.
* @param {request} req {} (with supervisorId as url parameters)
* @param {response} res
* [
* {
* expressions: [
* // There should be just one expression per picto
* // with the language being used by the supervisor
* {
* id: 1234,
* lang: 'es-es',
* text: 'nacimiento',
* picto: 23
* }
* ],
* source: 1,
* owner: null,
* id: 23,
* uri: 'picto/uri.jpg',
* category: 41
* }
* ]
*/
fromArasaac: function (req, res) {
var l = [];
var fs = require('fs');
Supervisor.findOne({ id: req.params.id }).then(function (supervisor) {
if (supervisor) {
Picto.find({ source: 3})
.paginate({page: req.params.page, limit:req.params.limit})
.populate('expressions', { lang: supervisor.lang })
.then(function (pictos) {
async.eachSeries(pictos, function(picto, next_cb) {
// check picto has expressions associated in student language
if (picto.expressions.length == 0 || picto.expressions[0].text.length == 0)
return next_cb();
// check picto image is available
picto.imageFileExists((found) => {
if (found) {
l.push(picto);
next_cb();
}
else
next_cb();
});
},
function (err) { // loop has end
if (err) throw err;
sails.log.debug(pictos.length + " pictos sent from Arasaac in language " + supervisor.lang);
return res.ok(l);
}); // end async.eachSeries
})
.catch(() => res.badRequest());
} else {
return res.badRequest();
}
})
.catch(() => res.serverError());
},
/**
* Add a tag to an existing picto. This tag is associated to the supervisor. * Add a tag to an existing picto. This tag is associated to the supervisor.
* @param {request} req * @param {request} req
* { * {
......
...@@ -288,16 +288,22 @@ dashboardControllers.controller('AddPictoCtrl', function ( ...@@ -288,16 +288,22 @@ dashboardControllers.controller('AddPictoCtrl', function (
$scope.page += 1; $scope.page += 1;
var request = ""; var request = "";
if($scope.source == "symbolstx"){
if($scope.breadcrumbs.length == 1) { if($scope.breadcrumbs.length == 1) {
//Request page X from all pictos (symbolstx)
request = config.backend + '/sup/' + supervisor.id +
'/pic_fromSymbolStx/page/'+$scope.page+'/limit/'+$scope.limit;
}else{
request = config.backend + '/sup/' + supervisor.id +
'/pic_fromCatSubcat/category/'+$scope.breadcrumbs[$scope.breadcrumbs.length-1].id
+'/page/'+$scope.page+'/limit/'+$scope.limit;
}
}else if($scope.source == "symbolstx"){
//Request page X from all pictos (symbolstx) //Request page X from all pictos (symbolstx)
request = config.backend + '/sup/' + supervisor.id + request = config.backend + '/sup/' + supervisor.id +
'/pic_fromSymbolStx/page/'+$scope.page+'/limit/'+$scope.limit; '/pic_fromArasaac/page/'+$scope.page+'/limit/'+$scope.limit;
}else{
request = config.backend + '/sup/' + supervisor.id +
'/pic_fromCatSubcat/category/'+$scope.breadcrumbs[$scope.breadcrumbs.length-1].id
+'/page/'+$scope.page+'/limit/'+$scope.limit;
} }
$http.get(request) $http.get(request)
.success(function (data) { .success(function (data) {
$scope.pictos = $scope.pictos.concat(data); $scope.pictos = $scope.pictos.concat(data);
...@@ -324,17 +330,19 @@ dashboardControllers.controller('AddPictoCtrl', function ( ...@@ -324,17 +330,19 @@ dashboardControllers.controller('AddPictoCtrl', function (
}else if(length == 0){ // If there is no word, reset pictos }else if(length == 0){ // If there is no word, reset pictos
if ($scope.onlyOwn || $scope.source == "ownpictos"){ if ($scope.onlyOwn || $scope.source == "ownpictos"){
$scope.load_own_pictos(); $scope.load_own_pictos();
}else{ }else if($scope.source == "symbolstx"){
$scope.open_category_from_bc(0); $scope.open_category_from_bc(0);
}else if($scope.source == "arasaac"){
$scope.load_arasaac_pictos();
} }
}else{ }else{
var request = ""; var request = "";
var source = 1; var source = 1; //symbolstx
$scope.closeAlert(); $scope.closeAlert();
$scope.loadingCatPictos = true; $scope.loadingCatPictos = true;
//category to look in //category to look in
var category; var category = 0; //All pictos
if (!$scope.onlyOwn){ if (!$scope.onlyOwn){
category = $scope.breadcrumbs[$scope.breadcrumbs.length-1].id; category = $scope.breadcrumbs[$scope.breadcrumbs.length-1].id;
if(category == 999){ if(category == 999){
...@@ -344,7 +352,8 @@ dashboardControllers.controller('AddPictoCtrl', function ( ...@@ -344,7 +352,8 @@ dashboardControllers.controller('AddPictoCtrl', function (
if($scope.source == "ownpictos"){ if($scope.source == "ownpictos"){
source = 2; source = 2;
category = 0; }else if($scope.source == "ownpictos"){
source = 3;
} }
request = config.backend + '/sup/' + supervisor.id + request = config.backend + '/sup/' + supervisor.id +
'/pic_fromSearch/'+$scope.srch_term_picto+'/category/'+category+ '/pic_fromSearch/'+$scope.srch_term_picto+'/category/'+category+
......
...@@ -21,6 +21,9 @@ ...@@ -21,6 +21,9 @@
<button class="btn btn-default" btn-radio="'symbolstx'" ng-model="source" ng-click="open_category_from_bc('0')"> <button class="btn btn-default" btn-radio="'symbolstx'" ng-model="source" ng-click="open_category_from_bc('0')">
<span class="glyphicon glyphicon-th"></span> SymbolStix <span class="glyphicon glyphicon-th"></span> SymbolStix
</button> </button>
<button class="btn btn-default" btn-radio="'arasaac'" ng-model="source" ng-click="load_arasaac_pictos()">
<i class="fa fa-th" aria-hidden="true"></i> Arasaac
</button>
<button class="btn btn-default" btn-radio="'ownpictos'" ng-model="source" ng-click="load_own_pictos()"> <button class="btn btn-default" btn-radio="'ownpictos'" ng-model="source" ng-click="load_own_pictos()">
<span class="glyphicon glyphicon-picture"></span> {{ 'own_pictos' | translate }} <span class="glyphicon glyphicon-picture"></span> {{ 'own_pictos' | translate }}
</button> </button>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment