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
e942d14e
authored
Sep 07, 2017
by
Arturo Montejo Ráez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
working on TPV integration
parent
30176d00
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
172 additions
and
10 deletions
sails/roles/database/files/upgrade.sql
sails/src/assets/app/bower.json
sails/src/assets/scripts/app.js
sails/src/assets/scripts/modules/student/controllers/setup.js
sails/src/assets/scripts/modules/student/controllers/tpvmodal.js
sails/src/assets/scripts/modules/student/views/tpvmodal.html
sails/src/assets/styles/main.css
sails/src/tasks/config/concat.js
sails/roles/database/files/upgrade.sql
View file @
e942d14e
...
...
@@ -126,3 +126,5 @@ ALTER TABLE stu_sup
ADD
CONSTRAINT
`stu_sup_ibfk_2`
FOREIGN
KEY
(
`id_sup`
)
REFERENCES
`supervisor`
(
`id`
);
DROP
TABLE
office
;
source
triggers
-
enrolments
-
integrity
-
constraints
.
sql
;
sails/src/assets/app/bower.json
View file @
e942d14e
...
...
@@ -30,7 +30,9 @@
"ngMask"
:
"angular-mask#~3.1.1"
,
"angular-recaptcha"
:
"^4.0.1"
,
"ui-bootstrap"
:
"~2.5.0"
,
"ngInfiniteScroll"
:
"^1.3.4"
"ngInfiniteScroll"
:
"^1.3.4"
,
"fast-sha256"
:
"^1.0.0"
,
"tweetnacl-util"
:
"^0.15.0"
},
"resolutions"
:
{
"angular"
:
">=1 <1.3.0"
,
...
...
sails/src/assets/scripts/app.js
View file @
e942d14e
...
...
@@ -27,7 +27,10 @@ var dashboardApp = angular.module('dashboardApp', [
dashboardApp
.
constant
(
'CONSTANTS'
,
{
appName
:
'Pictogram Dashboard'
,
appVersion
:
0.1
,
password_minlength
:
8
password_minlength
:
8
,
tpvKey
:
'sq7HjrUOBfKmC576ILgskD5srU870gJ7'
,
tpvPriceOneYearEuros
:
70
,
tpvPriceForeverEuros
:
120
,
});
...
...
sails/src/assets/scripts/modules/student/controllers/setup.js
View file @
e942d14e
...
...
@@ -19,11 +19,9 @@ dashboardControllers.controller('StudentSetupCtrl', function StudentSetupCtrl(
// For tab navigation (here too, if the user refresh the page...)
$scope
.
nav
.
tab
=
'setup'
;
// Set upload button to filestyle
/*$(":file").filestyle({
buttonText: " " + $translate.instant('change_picture'),
input: false
});*/
//
// Student setup
//
$scope
.
supsForm
=
{};
$scope
.
section
=
{
val
:
'account'
};
...
...
@@ -128,9 +126,9 @@ dashboardControllers.controller('StudentSetupCtrl', function StudentSetupCtrl(
$scope
.
formUser
.
country
=
data
.
country
;
$scope
.
formUser
.
gender
=
data
.
gender
;
$scope
.
formUser
.
lang
=
data
.
lang
;
$scope
.
formUser
.
name
=
data
.
name
;
$scope
.
studentData
.
name
=
data
.
name
;
$scope
.
studentData
.
surname
=
data
.
surname
;
$scope
.
formUser
.
name
=
data
.
name
;
$scope
.
studentData
.
name
=
data
.
name
;
$scope
.
studentData
.
surname
=
data
.
surname
;
$scope
.
formUser
.
notes
=
data
.
notes
;
$scope
.
formUser
.
surname
=
data
.
surname
;
$scope
.
formUser
.
username
=
data
.
username
;
...
...
@@ -256,4 +254,63 @@ dashboardControllers.controller('StudentSetupCtrl', function StudentSetupCtrl(
ngToast
.
danger
(
$translate
.
instant
(
'attributes_not_updated'
));
});
},
300
);
// ---------------------------------------------------------------------------
// TPV modal window
//
var
modalInstance
=
$modal
.
open
({
animation
:
true
,
templateUrl
:
'modules/student/views/tpvmodal.html'
,
controller
:
'TPVModalCtrl'
,
size
:
'lg'
,
resolve
:
{
student
:
function
()
{
return
$scope
.
studentData
;
},
supervisor
:
function
()
{
return
$rootScope
.
user
;
}
}
});
// Returned data from the modal window
modalInstance
.
result
.
then
(
function
(
pictoId
)
{
if
(
!
pictoId
)
return
;
// Send the picto to the server
$http
.
post
(
config
.
backend
+
'/stu/'
+
$scope
.
studentData
.
id
+
'/picto/'
+
pictoId
,
{
attributes
:
{
id_cat
:
(
$scope
.
showFreeCategory
||
mainCatGrid
)
?
null
:
$scope
.
getCategoryId
(
$scope
.
selectedCategory
),
coord_x
:
$scope
.
showFreeCategory
?
null
:
col
,
coord_y
:
$scope
.
showFreeCategory
?
null
:
row
,
status
:
'enabled'
,
free_category_coord_x
:
$scope
.
showFreeCategory
?
col
:
null
,
free_category_coord_y
:
$scope
.
showFreeCategory
?
row
:
null
},
id_scene
:
$scope
.
viewingScene
.
id
})
.
success
(
function
(
studentPicto
)
{
placePicto
(
studentPicto
);
io
.
socket
.
post
(
'/stu/vocabulary'
,
{
action
:
'add'
,
attributes
:
{
id_stu
:
$scope
.
studentData
.
id
,
id_scene
:
$scope
.
viewingScene
.
id
,
stu_picto
:
studentPicto
}
},
function
()
{});
})
.
error
(
function
(
err
)
{
if
(
err
.
code
&&
err
.
code
==
1
)
// codes are in sails/config/pictogram.js
ngToast
.
danger
({
content
:
$translate
.
instant
(
'error_duplicated_picto'
)
});
else
ngToast
.
danger
({
content
:
$translate
.
instant
(
'error_adding_picto'
)
});
});
});
});
sails/src/assets/scripts/modules/student/controllers/tpvmodal.js
0 → 100644
View file @
e942d14e
'use strict'
;
// Please note that $modalInstance represents a modal window (instance) dependency.
// It is not the same as the $modal service used above.
dashboardControllers
.
controller
(
'TPVModalCtrl'
,
function
(
$scope
,
$modalInstance
,
$http
,
CONSTANTS
,
config
,
supervisor
,
student
)
{
$scope
.
foreverPrice
=
CONSTANTS
.
tpvForeverPriceEuros
;
$scope
.
oneYearPrice
=
CONSTANTS
.
tpvOneYearPriceEuros
;
var
tpvdata
=
{
Ds_Merchant_PayMethods
:
'O'
,
// Payment managed by RedSys
Ds_Merchant_MerchantCode
:
'152038485'
,
// Number of commerce (Yotta)
Ds_Merchant_Terminal
:
'001'
,
// Terminal number
Ds_Merchant_Currency
:
'000 ("978")'
,
// Terminal currency
Ds_Merchant_Amount
:
CONSTANTS
.
tpvAnualPrice
,
// Amount
Ds_Merchant_MerchantUrl
:
config
.
backend
+
"/stu/buypro"
,
Ds_Merchant_UrlOk
:
config
.
backend
+
'/app/#/student'
+
student
.
id
+
"/setup"
,
// Returning URL
};
// HMAC SHA256 encryption in Base64
var
merchantParameters
=
nacl
.
util
.
encodeBase64
(
sha256
.
hmac
(
CONSTANTS
.
tpvKey
,
JSON
.
stringify
(
tpvdata
)));
// Save expression
$scope
.
sendToRedSys
=
function
()
{
$http
.
post
(
'https://sis-t.redsys.es:25443/sis/realizarPago'
,
{
'Ds_SignatureVersion'
:
"HMAC_SHA256_V1"
,
'Ds_MerchantParameters'
:
merchantParameters
,
'Ds_Signature'
:
signature
,
})
.
success
(
function
(
data
,
status
,
headers
,
config
)
{
console
.
log
(
"Expression changed: "
+
JSON
.
stringify
(
data
));
// Close the modal instance
$modalInstance
.
close
(
data
);
})
.
error
(
function
(
data
,
status
,
headers
,
config
)
{
console
.
log
(
"Error from API: "
+
data
.
error
);
});
};
$scope
.
close
=
function
()
{
$modalInstance
.
dismiss
(
'cancel'
);
};
});
sails/src/assets/scripts/modules/student/views/tpvmodal.html
0 → 100644
View file @
e942d14e
<div
id=
"tpvmodal"
>
<div
class=
"modal-header"
>
<button
type=
"button"
class=
"close"
ng-click=
"close()"
>
<span
aria-hidden=
"true"
>
×
</span><span
class=
"sr-only"
translate
>
close
</span>
</button>
<h4
class=
"modal-title"
translate
>
tpv_title
</h4>
</div>
<div
class=
"modal-body"
>
<form
name=
"tpvForm"
>
<div
class=
"row"
>
<div
class=
"md-col-6"
>
<h4
translate
>
one_year_license
</h4>
<h1
class=
"tpv-price"
>
{{ oneYearPrice }} €
</h1>
</div>
<div
class=
"md-col-6"
>
<h4
translate
>
forever_license
</h4>
<h1
class=
"tpv-price"
>
{{ foreverPrice }} €
</h1>
</div>
</div>
<div
class=
"row"
>
<div
class=
"md-col-6"
>
<span
class=
"input-group-btn"
>
<button
class=
"btn btn-success"
ng-click=
"sendToRedSys('oneYear')"
translate
><span
class=
"glyphicon glyphicon-shopping-cart"
aria-hidden=
"true"
></span>
buy
</button>
</span>
</div>
<div
class=
"md-col-6"
>
<span
class=
"input-group-btn"
>
<button
class=
"btn btn-success"
ng-click=
"sendToRedSys('forever')"
translate
><span
class=
"glyphicon glyphicon-shopping-cart"
aria-hidden=
"true"
></span>
buy
</button>
</span>
</div>
</div>
</form>
</div>
</div>
<!-- End modal-body -->
</div>
sails/src/assets/styles/main.css
View file @
e942d14e
...
...
@@ -1205,3 +1205,9 @@ input.editable.scene-name {
.navbar-default
.navbar-nav
>
.active
>
a
{
border-radius
:
.4em
;
}
/* Estilos TPV */
.tpv-price
{
font-size
:
xx-large
;
}
sails/src/tasks/config/concat.js
View file @
e942d14e
...
...
@@ -31,6 +31,8 @@ module.exports = function (grunt) {
'assets/app/bower_components/ngImgCrop/compile/minified/ng-img-crop.js'
,
'assets/app/bower_components/bootstrap-filestyle/src/bootstrap-filestyle.min.js'
,
'assets/app/bower_components/ngMask/dist/ngMask.min.js'
,
'assets/app/bower_components/fast-sha256/sha256.min.js'
,
'assets/app/bower_components/tweetnacl-util/nacl-util.min.js'
,
'assets/scripts/lib/sails.io.js'
];
...
...
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