Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
humanities
gargantext
Commits
2bcae9a7
Commit
2bcae9a7
authored
Jun 28, 2015
by
Elias
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Annotations : basic error callbacks in ngResource, more uniform coding
parent
37a54e55
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
13 deletions
+35
-13
app.js
annotations/static/annotations/app.js
+33
-11
http.js
annotations/static/annotations/http.js
+2
-2
No files found.
annotations/static/annotations/app.js
View file @
2bcae9a7
(
function
()
{
(
function
()
{
'use strict'
;
'use strict'
;
/*
* Django STATIC_URL given to angular to load async resources
*/
var
S
=
window
.
STATIC_URL
;
var
S
=
window
.
STATIC_URL
;
window
.
annotationsApp
=
angular
.
module
(
'annotationsApp'
,
[
'annotationsAppHttp'
]);
window
.
annotationsApp
=
angular
.
module
(
'annotationsApp'
,
[
'annotationsAppHttp'
]);
/*
* Angular Templates must not conflict with Django's
*/
window
.
annotationsApp
.
config
(
function
(
$interpolateProvider
)
{
window
.
annotationsApp
.
config
(
function
(
$interpolateProvider
)
{
$interpolateProvider
.
startSymbol
(
'{[{'
);
$interpolateProvider
.
startSymbol
(
'{[{'
);
$interpolateProvider
.
endSymbol
(
'}]}'
);
$interpolateProvider
.
endSymbol
(
'}]}'
);
...
@@ -27,18 +33,23 @@
...
@@ -27,18 +33,23 @@
window
.
annotationsApp
.
controller
(
'ExtraAnnotationController'
,
window
.
annotationsApp
.
controller
(
'ExtraAnnotationController'
,
[
'$scope'
,
'$rootScope'
,
'$element'
,
'NgramHttpService'
,
[
'$scope'
,
'$rootScope'
,
'$element'
,
'NgramHttpService'
,
function
(
$scope
,
$rootScope
,
$element
,
NgramHttpService
)
{
function
(
$scope
,
$rootScope
,
$element
,
NgramHttpService
)
{
// TODO use the tooltip ?
/*
* Click on the 'delete' cross button
*/
$scope
.
onDeleteClick
=
function
()
{
$scope
.
onDeleteClick
=
function
()
{
NgramHttpService
.
delete
({
NgramHttpService
.
delete
({
'listId'
:
$scope
.
keyword
.
list_id
,
'listId'
:
$scope
.
keyword
.
list_id
,
'ngramId'
:
$scope
.
keyword
.
uuid
'ngramId'
:
$scope
.
keyword
.
uuid
}
).
$promise
.
then
(
function
(
data
)
{
}
,
function
(
data
)
{
$
.
each
(
$rootScope
.
annotations
,
function
(
index
,
element
)
{
$
.
each
(
$rootScope
.
annotations
,
function
(
index
,
element
)
{
if
(
element
.
list_id
==
$scope
.
keyword
.
list_id
&&
element
.
uuid
==
$scope
.
keyword
.
uuid
)
{
if
(
element
.
list_id
==
$scope
.
keyword
.
list_id
&&
element
.
uuid
==
$scope
.
keyword
.
uuid
)
{
$rootScope
.
annotations
.
splice
(
index
,
1
);
$rootScope
.
annotations
.
splice
(
index
,
1
);
return
false
;
return
false
;
}
}
});
});
},
function
(
data
)
{
console
.
log
(
data
);
console
.
error
(
"unable to delete the Ngram "
+
$scope
.
keyword
.
uuid
);
});
});
};
};
}]);
}]);
...
@@ -213,29 +224,39 @@
...
@@ -213,29 +224,39 @@
*/
*/
$scope
.
onMenuClick
=
function
(
$event
,
action
,
listId
)
{
$scope
.
onMenuClick
=
function
(
$event
,
action
,
listId
)
{
if
(
angular
.
isObject
(
$scope
.
selection_text
))
{
if
(
angular
.
isObject
(
$scope
.
selection_text
))
{
//
delete from the current list
//
action on an existing Ngram
NgramHttpService
[
action
]({
NgramHttpService
[
action
]({
'listId'
:
listId
,
'listId'
:
listId
,
'ngramId'
:
$scope
.
selection_text
.
uuid
'ngramId'
:
$scope
.
selection_text
.
uuid
}
).
$promise
.
then
(
function
(
data
)
{
}
,
function
(
data
)
{
$
.
each
(
$rootScope
.
annotations
,
function
(
index
,
element
)
{
$
.
each
(
$rootScope
.
annotations
,
function
(
index
,
element
)
{
if
(
element
.
list_id
==
listId
&&
element
.
uuid
==
$scope
.
selection_text
.
uuid
)
{
if
(
element
.
list_id
==
listId
&&
element
.
uuid
==
$scope
.
selection_text
.
uuid
)
{
$rootScope
.
annotations
.
splice
(
index
,
1
);
$rootScope
.
annotations
.
splice
(
index
,
1
);
return
false
;
return
false
;
}
}
});
});
});
},
function
(
data
)
{
console
.
log
(
data
);
console
.
error
(
"unable to edit the Ngram "
+
$scope
.
selection_text
);
}
);
}
else
if
(
$scope
.
selection_text
.
trim
()
!==
""
)
{
}
else
if
(
$scope
.
selection_text
.
trim
()
!==
""
)
{
// new annotation from selection
// new annotation from selection
NgramHttpService
.
post
(
NgramHttpService
.
post
(
{
{
'listId'
:
listId
'listId'
:
listId
,
'ngramId'
:
'new'
},
},
{
'annotation'
:
{
'text'
:
$scope
.
selection_text
.
trim
()}}
{
).
$promise
.
then
(
function
(
data
)
{
'annotation'
:
{
'text'
:
$scope
.
selection_text
.
trim
()}
$rootScope
.
annotations
.
push
(
data
);
},
function
(
data
)
{
});
$rootScope
.
annotations
.
push
(
data
);
},
function
(
data
)
{
console
.
log
(
data
);
console
.
error
(
"unable to edit the Ngram "
+
$scope
.
selection_text
);
}
);
}
}
// hide the highlighted text the the menu
// hide the highlighted text the the menu
$
(
".text-panel"
).
removeClass
(
"selection"
);
$
(
".text-panel"
).
removeClass
(
"selection"
);
...
@@ -385,7 +406,7 @@
...
@@ -385,7 +406,7 @@
});
});
/*
/*
* Add a new NGram from the
free
user input in the extra-text list
* Add a new NGram from the user input in the extra-text list
*/
*/
$scope
.
onListSubmit
=
function
(
$event
,
listId
)
{
$scope
.
onListSubmit
=
function
(
$event
,
listId
)
{
var
inputEltId
=
"#"
+
listId
+
"-input"
;
var
inputEltId
=
"#"
+
listId
+
"-input"
;
...
@@ -413,6 +434,7 @@
...
@@ -413,6 +434,7 @@
},
function
(
data
)
{
},
function
(
data
)
{
// on error
// on error
$
(
inputEltId
).
addClass
(
"error"
);
$
(
inputEltId
).
addClass
(
"error"
);
console
.
error
(
"error adding Ngram "
+
value
);
}
}
);
);
};
};
...
...
annotations/static/annotations/http.js
View file @
2bcae9a7
...
@@ -57,11 +57,11 @@
...
@@ -57,11 +57,11 @@
{
{
post
:
{
post
:
{
method
:
'POST'
,
method
:
'POST'
,
params
:
{
'listId'
:
'@listId'
,
'ngramId'
:
''
}
params
:
{
'listId'
:
'@listId'
,
'ngramId'
:
'
@ngramId
'
}
},
},
delete
:
{
delete
:
{
method
:
'DELETE'
,
method
:
'DELETE'
,
params
:
{
'listId'
:
'@listId'
,
'ngramId'
:
'@
i
d'
}
params
:
{
'listId'
:
'@listId'
,
'ngramId'
:
'@
ngramI
d'
}
}
}
}
}
);
);
...
...
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