Commit 87a27ff0 authored by Romain Loth's avatar Romain Loth

annotation app: basic functionality resored

parent cd21d78a
......@@ -28,13 +28,14 @@
if (newValue === undefined) return;
// reformat lists to allListsSelect
var allListsSelect = [];
console.log($rootScope.lists)
angular.forEach($rootScope.lists, function(value, key) {
this.push({
'id': key,
'label': value
});
// initialize activeLists with the MiamList by default
if (value == 'MiamList') {
if (value == 'MAINLIST') {
$rootScope.activeLists = {};
$rootScope.activeLists[key] = value;
}
......@@ -44,7 +45,7 @@
$timeout(function() {
$('.selectpicker').selectpicker();
$('.selectpicker').selectpicker('val', ['MiamList']);
$('.selectpicker').selectpicker('val', ['MAINLIST']);
});
});
......
......@@ -6,13 +6,13 @@
*/
.MiamList {
.MAINLIST {
color: black;
background-color: rgba(60, 118, 61, 0.5);
cursor: pointer;
}
.StopList {
.STOPLIST {
color: black;
background-color: rgba(169, 68, 66, 0.2);
cursor: pointer;
......
......@@ -71,8 +71,8 @@
function toggleMenu(context, annotation) {
$timeout(function() {
$scope.$apply(function() {
var miamlist_id = _.invert($rootScope.lists).MiamList;
var stoplist_id = _.invert($rootScope.lists).StopList;
var miamlist_id = _.invert($rootScope.lists).MAINLIST;
var stoplist_id = _.invert($rootScope.lists).STOPLIST;
// variable used in onClick
$scope.selection_text = angular.copy(annotation);
......@@ -87,7 +87,7 @@
'listName': $rootScope.lists[annotation.list_id]
}
];
if ($rootScope.lists[annotation.list_id] == "MiamList") {
if ($rootScope.lists[annotation.list_id] == "MAPLIST") {
// Add to the alternative list
$scope.menuItems.push({
'action': 'post',
......@@ -95,7 +95,7 @@
'verb': 'Move to',
'listName': $rootScope.lists[stoplist_id]
});
} else if ($rootScope.lists[annotation.list_id] == "StopList") {
} else if ($rootScope.lists[annotation.list_id] == "STOPLIST") {
// Add to the alternative list
$scope.menuItems.push({
'action': 'post',
......
......@@ -47,23 +47,23 @@
/*
* Create, modify or delete 1 Ngram
*/
// http.factory('NgramHttpService', function ($resource) {
// return $resource(
// window.ANNOTATION_API_URL + 'lists/:listId/ngrams/:ngramId',
// {
// listId: '@listId',
// ngramId: '@id'
// },
// {
// post: {
// method: 'POST',
// params: {'listId': '@listId', 'ngramId': '@ngramId'}
// },
// delete: {
// method: 'DELETE',
// params: {'listId': '@listId', 'ngramId': '@ngramId'}
// }
// }
// );
// });
http.factory('NgramHttpService', function ($resource) {
return $resource(
window.ANNOTATION_API_URL + 'lists/:listId/ngrams/:ngramId',
{
listId: '@listId',
ngramId: '@id'
},
{
post: {
method: 'POST',
params: {'listId': '@listId', 'ngramId': '@ngramId'}
},
delete: {
method: 'DELETE',
params: {'listId': '@listId', 'ngramId': '@ngramId'}
}
}
);
});
})(window);
......@@ -58,7 +58,7 @@
<div>
<h5>Select lists</h5>
<select class="selectpicker" multiple ng-change="activeListsChange()" ng-model="lists" ng-controller="ActiveListsController">
<option ng-repeat="item in allListsSelect" id="list---{[{item.id}]}" ng-disabled="{[{ item.label == 'MiamList' }]}">{[{item.label}]}</option>
<option ng-repeat="item in allListsSelect" id="list---{[{item.id}]}" ng-disabled="{[{ item.label == 'MAINLIST' }]}">{[{item.label}]}</option>
</select>
</div>
</div>
......
......@@ -42,12 +42,14 @@ class NgramList(APIView):
corpus_id = int(corpus_id)
doc_id = int(doc_id)
lists = {}
for list_type in ['MiamList', 'StopList']:
list_id = listIds(user_id=request.user.id, corpus_id=int(corpus_id), typeList=list_type)
lists["%s" % list_id[0][0]] = list_type
for list_type in ['MAINLIST']:
corpus_nod = cache.Node[corpus_id]
list_nod = corpus_nod.children(typename=list_type).first()
list_id = list_nod.id
lists["%s" % list_id] = list_type
# ngrams for the corpus_id (ignoring doc_id for the moment):
doc_ngram_list = listNgramIds(corpus_id=corpus_id, doc_id=doc_id, user_id=request.user.id)
doc_ngram_list = [(obj.id, obj.terms, w) for (w,obj) in list_nod.ngrams.all()]
data = { '%s' % corpus_id : {
'%s' % doc_id : [
{
......@@ -56,7 +58,7 @@ class NgramList(APIView):
'occurrences': ngram_occurrences,
'list_id': list_id,
}
for ngram_id, ngram_text, ngram_occurrences, list_id in doc_ngram_list],
for ngram_id, ngram_text, ngram_occurrences in doc_ngram_list],
'lists': lists
}}
return Response(data)
......
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 to comment