Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
yotta
/
pictogram
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
60
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
22e66774
authored
Mar 17, 2017
by
Jose Antonio
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Working arasaac
parent
e8155468
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
87 additions
and
11 deletions
sails/src/api/controllers/PictoController.js
sails/src/assets/scripts/modules/student/controllers/addpicto.js
sails/src/assets/scripts/modules/student/views/addpicto.html
sails/src/api/controllers/PictoController.js
View file @
22e66774
...
...
@@ -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.
* @param {request} req
* {
...
...
sails/src/assets/scripts/modules/student/controllers/addpicto.js
View file @
22e66774
...
...
@@ -288,16 +288,22 @@ dashboardControllers.controller('AddPictoCtrl', function (
$scope
.
page
+=
1
;
var
request
=
""
;
if
(
$scope
.
breadcrumbs
.
length
==
1
)
{
if
(
$scope
.
source
==
"symbolstx"
){
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
=
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
;
'/pic_fromArasaac/page/'
+
$scope
.
page
+
'/limit/'
+
$scope
.
limit
;
}
$http
.
get
(
request
)
.
success
(
function
(
data
)
{
$scope
.
pictos
=
$scope
.
pictos
.
concat
(
data
);
...
...
@@ -324,17 +330,19 @@ dashboardControllers.controller('AddPictoCtrl', function (
}
else
if
(
length
==
0
){
// If there is no word, reset pictos
if
(
$scope
.
onlyOwn
||
$scope
.
source
==
"ownpictos"
){
$scope
.
load_own_pictos
();
}
else
{
}
else
if
(
$scope
.
source
==
"symbolstx"
)
{
$scope
.
open_category_from_bc
(
0
);
}
else
if
(
$scope
.
source
==
"arasaac"
){
$scope
.
load_arasaac_pictos
();
}
}
else
{
var
request
=
""
;
var
source
=
1
;
var
source
=
1
;
//symbolstx
$scope
.
closeAlert
();
$scope
.
loadingCatPictos
=
true
;
//category to look in
var
category
;
var
category
=
0
;
//All pictos
if
(
!
$scope
.
onlyOwn
){
category
=
$scope
.
breadcrumbs
[
$scope
.
breadcrumbs
.
length
-
1
].
id
;
if
(
category
==
999
){
...
...
@@ -344,7 +352,8 @@ dashboardControllers.controller('AddPictoCtrl', function (
if
(
$scope
.
source
==
"ownpictos"
){
source
=
2
;
category
=
0
;
}
else
if
(
$scope
.
source
==
"ownpictos"
){
source
=
3
;
}
request
=
config
.
backend
+
'/sup/'
+
supervisor
.
id
+
'/pic_fromSearch/'
+
$scope
.
srch_term_picto
+
'/category/'
+
category
+
...
...
sails/src/assets/scripts/modules/student/views/addpicto.html
View file @
22e66774
...
...
@@ -21,6 +21,9 @@
<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
</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()"
>
<span
class=
"glyphicon glyphicon-picture"
></span>
{{ 'own_pictos' | translate }}
</button>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment