clean messages and error.
authorcavaliet
Fri, 10 Oct 2014 17:07:06 +0200
changeset 11 c0f9f9ab2a8a
parent 10 90918426079c
child 12 a0f1f77148d9
clean messages and error.
client/README.md
client/app/annotationclient.html
client/app/app.js
client/bower.json
client/data/categories.json
--- a/client/README.md	Fri Oct 10 14:59:09 2014 +0200
+++ b/client/README.md	Fri Oct 10 17:07:06 2014 +0200
@@ -11,4 +11,6 @@
 TODO:
 -----
 
+- serveur has to send message with success or error code, 
+  then client has to display green or red feedback.
 - unit tests
--- a/client/app/annotationclient.html	Fri Oct 10 14:59:09 2014 +0200
+++ b/client/app/annotationclient.html	Fri Oct 10 17:07:06 2014 +0200
@@ -24,7 +24,7 @@
       </div>
     </div>
     <div class="row mons-content">
-        <div class="mons-button hand return" ng-style="returnVisStyle" ng-click="selectLevel(false)" ng-init="returnVisStyle={visibility:'hidden'}">
+        <div class="mons-button hand return" ng-style="returnVisStyle" ng-click="selectLevel()" ng-init="returnVisStyle={visibility:'hidden'}">
           <div class="content">
               <div class="table">
                 <div class="table-cell">
@@ -47,7 +47,7 @@
     <div class="mons-content">
       <div ng-show="!selectedlevel">
           <div class="mons-button hand" ng-repeat="c in data.categories" style="background-color: {{ '{{' }} c.color {{ '}}' }}" 
-                                        ng-click="selectLevel(c.event_code, c)" ng-class="{'success-border':c.sendSuccess}">
+                                        ng-click="selectLevel(c.label, c.code, c)" ng-class="{'success-border':c.sendSuccess}">
             <div class="content">
                 <div class="table">
                   <div class="table-cell">
@@ -60,7 +60,7 @@
       </div>
       <div ng-show="selectedlevel">
           <div class="mons-button hand" ng-repeat="c in selectedlevel" style="background-color: {{ '{{' }} c.color {{ '}}' }}" 
-                                        ng-click="sendAnnotation(c.event_code, c)" ng-class="{'success-border':c.sendSuccess}">
+                                        ng-click="sendAnnotation(c.label, c.code, c)" ng-class="{'success-border':c.sendSuccess}">
             <div class="content">
                 <div class="table">
                   <div class="table-cell">
--- a/client/app/app.js	Fri Oct 10 14:59:09 2014 +0200
+++ b/client/app/app.js	Fri Oct 10 17:07:06 2014 +0200
@@ -138,19 +138,22 @@
                 };
             }
 
-            $scope.sendAnnotation = function(eventCode, c){
+            $scope.sendAnnotation = function(label, code, c){
                 if($scope.username==='' || typeof $scope.username==='undefined'){
                     showAlert('Vous devez indiquer un nom d\'utilisateur.', false);
                     return;
                 }
-                if(eventCode==='' || typeof eventCode==='undefined'){
+                if(label==='' || typeof label==='undefined'){
                     showAlert('Vous devez indiquer un nom de catégorie.', false);
                     return;
                 }
                 // Send query
                 if (sock) {
+                    if(typeof code==='undefined' || code===''){
+                        code = window.S(label).slugify().s;
+                    }
                     var new_annot = {
-                            categories : eventCode,
+                            category: {code: code, label: label},
                             user : $scope.username
                     };
                     sock.send(JSON.stringify(new_annot));
@@ -172,7 +175,7 @@
             };
             
             // Interface management
-            $scope.selectLevel = function(eventCode, c){
+            $scope.selectLevel = function(label, code, c){
                 if(typeof c==='undefined'){
                     $scope.returnVisStyle = {visibility:'hidden'};
                     $scope.selectedlevel = false;
@@ -185,7 +188,7 @@
                 else{
                     // Send query
                     console.log('send ntm', c);
-                    $scope.sendAnnotation(eventCode, c);
+                    $scope.sendAnnotation(label, code, c);
                 }
             };
             
--- a/client/bower.json	Fri Oct 10 14:59:09 2014 +0200
+++ b/client/bower.json	Fri Oct 10 17:07:06 2014 +0200
@@ -20,6 +20,7 @@
     "angular-resource": "~1.3",
     "angular-bootstrap": "~0.11.0",
     "allmighty-autocomplete": "*",
-    "bootstrap": "~3.1.1"
+    "bootstrap": "~3.1.1",
+    "string": "*"
   }
 }
--- a/client/data/categories.json	Fri Oct 10 14:59:09 2014 +0200
+++ b/client/data/categories.json	Fri Oct 10 17:07:06 2014 +0200
@@ -9,25 +9,25 @@
           "label": "Batterie",
           "full_label": "sous-catégorie 1-1",
           "color": "rgb(205,200,63)",
-          "event_code": "ntm"
+          "code": "ntm"
         },
         {
           "label": "Clavier",
           "full_label": "sous-catégorie 1-2",
           "color": "rgb(205,200,63)",
-          "event_code": "iam"
+          "code": "iam"
         },
         {
           "label": "Guitare",
           "full_label": "sous-catégorie 1-3",
           "color": "rgb(205,200,63)",
-          "event_code": "hip"
+          "code": "hip"
         },
         {
           "label": "Trombone",
           "full_label": "sous-catégorie 1-4",
           "color": "rgb(205,200,63)",
-          "event_code": "hop"
+          "code": "hop"
         }
       ]
     },
@@ -40,19 +40,19 @@
           "label": "Accélération",
           "full_label": "sous-catégorie 2-1",
           "color": "rgb(222,139,83)",
-          "event_code": "rock"
+          "code": "rock"
         },
         {
           "label": "Décélération",
           "full_label": "sous-catégorie 2-2",
           "color": "rgb(222,139,83)",
-          "event_code": "rap"
+          "code": "rap"
         },
         {
           "label": "Pause",
           "full_label": "sous-catégorie 2-3",
           "color": "rgb(222,139,83)",
-          "event_code": "classic"
+          "code": "classic"
         }
       ]
     },
@@ -65,13 +65,13 @@
           "label": "sub cat 3-1",
           "full_label": "sous-catégorie 3-1",
           "color": "rgb(197,163,202)",
-          "event_code": "drums"
+          "code": "drums"
         },
         {
           "label": "sub cat 3-2",
           "full_label": "sous-catégorie 3-2",
           "color": "rgb(197,163,202)",
-          "event_code": "guitar"
+          "code": "guitar"
         }
       ]
     },
@@ -79,7 +79,7 @@
       "label": "Annot'direct",
       "full_label": "catégorie 4",
       "color": "rgb(121,187,146)",
-      "event_code": "bass"
+      "code": "bass"
     }
   ]
 }
\ No newline at end of file