Reintroducinedo catexp y pictocat pues son necesarios para conocer la jerarquía…

Reintroducinedo catexp y pictocat pues son necesarios para conocer la jerarquía de categorías de symbolstix
parent 3d548583
......@@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.android.tools.build:gradle:2.3.0-alpha3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
......
......@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
buildToolsVersion '25.0.0'
defaultConfig {
minSdkVersion 21
......
#Mon Aug 29 01:05:09 CEST 2016
#Sun Jan 15 10:11:11 CET 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.2-all.zip
......@@ -11,7 +11,7 @@ android {
}*/
compileSdkVersion 24
buildToolsVersion "23.0.2"
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "com.yottacode.supervisor_tablet"
minSdkVersion 21
......
......@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
android {
compileSdkVersion 24
buildToolsVersion "23.0.2"
buildToolsVersion '25.0.0'
defaultConfig {
minSdkVersion 21
targetSdkVersion 22
......
......@@ -3,7 +3,7 @@ apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "23.0.2"
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "com.yottacode.watch"
......
......@@ -11,7 +11,7 @@ android {
}*/
compileSdkVersion 24
buildToolsVersion "23.0.2"
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "com.yottacode.pictogram.yotta_tablet"
minSdkVersion 21
......@@ -34,6 +34,10 @@ android {
resValue "string", "server", "https://pre.yottacode.com"
resValue "bool", "ssl_connect", "true"
}
LocalFlavor {
resValue "string", "server", "http://192.168.1.36:1337"
resValue "bool", "ssl_connect", "false"
}
}
}
......
-- MySQL dump 10.13 Distrib 5.7.13, for Linux (x86_64)
--
-- Host: localhost Database: pictodbclean
-- ------------------------------------------------------
-- Server version 5.7.13
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `pictocat`
--
DROP TABLE IF EXISTS `pictocat`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `pictocat` (
`id` int(11) NOT NULL,
`id_supercat` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Identifies a category, which, itself, may belong to another category';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `pictocat`
--
LOCK TABLES `pictocat` WRITE;
/*!40000 ALTER TABLE `pictocat` DISABLE KEYS */;
INSERT INTO `pictocat` VALUES (1,0),(2,1),(3,1),(4,0),(5,0),(6,1),(7,0),(8,1),(9,0),(10,0),(11,0),(12,0),(13,0),(14,0),(15,0),(16,0),(17,16),(18,16),(19,0),(20,0),(21,16),(22,0),(23,22),(24,16),(25,16),(26,0),(27,0),(28,0),(29,0),(30,29),(31,29),(32,29),(33,0),(34,0),(35,22),(36,0),(37,5),(38,0),(39,0),(40,12),(41,15),(42,0),(43,0),(44,0),(45,9),(46,0),(47,0),(48,0),(49,0),(50,0),(51,0),(52,0),(53,0),(54,53),(55,53),(56,53),(57,53),(58,53),(59,53),(60,53),(61,53),(62,53),(63,53),(64,53),(65,51),(66,20),(67,0),(68,0),(69,0),(70,0),(71,0),(72,20),(73,0),(74,0),(75,0),(76,71),(77,20),(78,51),(79,0),(80,0),(81,5),(82,22),(83,0),(84,0),(85,84),(86,84),(87,51),(88,0),(89,20),(90,0),(91,51),(92,80),(93,0),(94,0),(95,0),(96,0),(97,0),(98,97),(99,97),(100,80),(101,69),(102,51),(103,51),(104,0),(105,51),(106,69),(107,69),(108,0),(109,69),(110,69),(111,69),(112,69),(113,69),(114,0),(115,71),(116,0),(117,0),(118,0),(119,0),(120,0),(121,0),(122,0);
/*!40000 ALTER TABLE `pictocat` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2017-01-17 9:48:07
......@@ -44,6 +44,20 @@ CREATE TABLE IF NOT EXISTS `action` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1
COMMENT="This table registers and action performed by a user at a given time, all information of the action is in JSON format in the 'description' column and the operation performed is one of the possible for the 'type' column. NOTE: timestamps must support fractional seconds, so MySQL versions >= 5.6.4 are required.";
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `catexp`
--
CREATE TABLE IF NOT EXISTS `catexp`(
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_cat` int(11) NOT NULL,
`lang` char(5),
`exp` varchar(30) NOT NULL,
PRIMARY KEY(`id`),
UNIQUE(exp,lang),
CHECK (lang IN ('es-es','en-gb','en-us'))
)
COMMENT="Stores the expressions available in several languages for a given category (id_cat)";
-- --------------------------------------------------------
......@@ -180,6 +194,18 @@ COMMENT="Stablish access rights to pictos";
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `pictocat`
--
CREATE TABLE IF NOT EXISTS `pictocat`(
`id` int(11) PRIMARY KEY,
`id_supercat` int(11)
)
COMMENT="Identifies a category, which, itself, may belong to another category";
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `picto_core`
--
......
......@@ -39,15 +39,15 @@ module.exports = {
.then(function (categories) {
res.ok(categories);
})
.catch(function () {
res.serverError();
.catch(function (err) {
throw err;
});
} else {
res.badRequest();
}
})
.catch(function () {
res.serverError();
.catch(function (err) {
res.serverError(err);
});
},
......
......@@ -929,8 +929,6 @@ module.exports = {
//
update_picto: function (req, res) {
var params = req.allParams();
console.log('Updating attributes for picto student ' + JSON.stringify(params));
console.log(JSON.stringify(params));
query = params.id_stuPicto ? {
id: params.id_stuPicto
......@@ -946,7 +944,6 @@ module.exports = {
if (!updated)
throw new Error ("error on update");
console.log('Updated attributes for picto student:' + JSON.stringify(updated[0]));
// return res.json(updated[0]);
return res.ok({
id: updated[0].id, // id of stu_picto
......@@ -961,6 +958,56 @@ module.exports = {
});
},
/*
* Updates the category picto for all pictos in the student collection
* @param {request} req {
* 'id_stu': <student_id>,
* 'prev_id_stu_pic': <ID of previous category entry in stu_picto>,
* 'new_id_pic': <ID of the picto to be the replacement>
* }
* @param {response} res {
* 'id_stu_pic': <id of the new category in stu_picto>,
* 'attributes': <attributes of the new category picto>,
* 'picto': <picto information used as new category>
* }
*
*/
update_category: function (req, res) {
var params = req.allParams();
var attrs = {};
// Get previous entry
StuPicto.findOne(params.prev_id_stu_pic)
.then((prev) => {
if (!prev)
throw new Error ("error on update");
// Create new one
var newsp = StuPicto.create({
student: params.id_stu,
picto: params.new_id_pic,
attributes: prev.attributes
})
.then(newsp => newsp)
.catch(err => {throw err});
var picto = Picto.findOne(params.new_id_pic)
.then(p => p)
.catch(err => {throw err});
return [prev, newsp, picto];
})
.spread(function(prev, newsp, picto) {
// Destroy previous entry
StuPicto.destroy({id: prev.id})
.then(() => {res.ok(newsp)})
.catch(err => {throw err});
})
.catch(err => {
return res.serverError('Unable to update category for student: ' + err);
});
},
// update action
// update picto atributes for a studentPicto
//
......
/**
* catexp.js
*
* @description :: TODO: Write a short summary of how this model works and what it represents here.
* @docs :: http://sailsjs.org/#!documentation/models
*/
module.exports = {
tableName : 'catexp',
migrate : 'safe',
schema : true,
autoPK : false,
autoCreatedAt : false,
autoUpdatedAt : false,
attributes: {
id: {
type: "integer",
primaryKey: true,
unique: true
},
id_cat: {
type: "integer",
required: true,
model: 'PictoCat'
},
lang: {
required: true,
type: "string",
size: 5
},
exp: {
required: false,
type: "string",
size: 30
}
}
};
\ No newline at end of file
/**
* pictocat.js
*
* @description :: TODO: Write a short summary of how this model works and what it represents here.
* @docs :: http://sailsjs.org/#!documentation/models
*/
module.exports = {
tableName : 'pictocat',
migrate : 'safe',
schema : true,
autoPK : false,
autoCreatedAt : false,
autoUpdatedAt : false,
attributes: {
id: {
type: "integer",
primaryKey: true,
unique: true
},
id_supercat: {
type: "integer",
required: false
},
exps: {
collection: "CatExp",
via: 'id_cat'
}
}
};
\ No newline at end of file
......@@ -138,45 +138,6 @@ dashboardControllers.controller('AddPictoCtrl', function (
};
/**
* It replaces the image associated to a picto (making a
* POST request to /picto/upload) but keeping the rest of attributes.
* @param {Array of Objects} $files Array of pictos to be uploaded the file
* itself (as binary data) will be sent.
*/
$scope.changePictoImg = function ($files, id_pic) {
$files.forEach(function (file) {
if (file.type === 'image/jpeg' || file.type === 'image/png' || file.type === 'image/gif') {
$upload.upload({
url: '/picto/update',
method: 'UPDATE',
fields: { owner: supervisor.id, id_pic: id_pic},
file: file
}).success(function (picto) {
$translate('picto_upload_success').then(function (translation) {
ngToast.success(translation);
});
picto.expressions = [];
$scope.pictos.push(picto);
$scope.open_exp(picto);
}).error(function (err) {
if (err.code == "E_EXCEEDS_UPLOAD_LIMIT")
$translate('picto_upload_limit').then(function (translation) {
ngToast.danger(translation);
});
else
$translate('picto_upload_error').then(function (translation) {
ngToast.danger(translation);
});
});
} else {
$translate('invalid_file_type').then(function (translation) {
ngToast.danger(translation);
});
}
});
};
/**
* When a image file is selected it tries to upload it as custom picto (making a
* POST request to /picto/upload).
* @param {Array of Objects} $files Array of pictos to be uploaded the file
......
......@@ -310,7 +310,54 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
});
};
// Modal window to add pictos
//
// Change category's pictogram
//
$scope.change_category = function (picto_cat) {
var modalInstance = $modal.open({
animation: true,
templateUrl: 'modules/student/views/addpicto.html',
controller: 'AddPictoCtrl',
size: 'lg',
resolve: {
student: function () {
return $scope.studentData;
},
supervisor: function () {
return $scope.user;
}
}
});
// Returned data from the modal window
modalInstance.result.then(function (pictoId) {
// Send the picto to the server
$http.put(config.backend + '/stu/' + $scope.studentData.id + '/cat', {
prev_id_stu_pic: picto_cat.id,
new_id_pic: pictoId
})
.success(function (studentPicto) {
console.log(studentPicto.attributes);
placePicto(studentPicto);
// notify
io.socket.post('/stu/vocabulary', {
action: 'update',
attributes: {
id_stu: $scope.studentData.id,
stu_picto: studentPicto
}
}, function () {});
})
.error(function () {
ngToast.danger({ content: $translate.instant('error_updating_category') });
});
});
};
//
// Adds a new pictogram
//
$scope.open_add = function (col, row) {
console.log(col + " " +row);
var modalInstance = $modal.open({
......@@ -355,9 +402,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
})
.error(function () {
$translate('error_adding_picto').then(function (translation) {
ngToast.danger({ content: translation });
});
ngToast.danger({ content: $translate.instant('error_adding_picto') });
});
// not needed
......
......@@ -175,7 +175,8 @@
title="{{ studentPicto.attributes.status | translate}}"></i>
</a>
<a
ng-click=""
ng-click="change_category(studentPicto)"
ng-if="studentPicto !== emptyStudentPicto && studentPicto.attributes.coord_y != '0'"
class="picto_cat_edit">
<i class="glyphicon glyphicon-picture" aria-hidden="true"></i>
</a>
......
......@@ -97,6 +97,7 @@ module.exports.policies = {
update: ['tokenAuth'],
update_picto: ['tokenAuth', 'isSupervisorOfStudent'],
update_legend: ['tokenAuth'],
update_category: ['tokenAuth', 'isSupervisorOfStudent'],
login: true,
create: ['tokenAuth', 'isSupAdmin'],
upload: ['tokenAuth'],
......
......@@ -83,6 +83,7 @@ module.exports.routes = {
'PUT /stu/:id_stu/picto/:id_stuPicto': 'StudentController.update_picto',
'PUT /stu/:id_stu/legend/:legend_value': 'StudentController.update_legend',
'PUT /stu/:id_stu/picto': 'StudentController.update_picto',
'PUT /stu/:id_stu/cat': 'StudentController.update_category',
'POST /stu/login': 'StudentController.login',
'POST /stu': 'StudentController.create',
'POST /stu/upload': 'StudentController.upload',
......
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