yesterday train ride
This commit is contained in:
1 parent
9fcf26ea75
commit
18959cc4f9
7 files changed
+97
-7
No files matched your search
@@ -0,0 +1,45 @@
|
|||||||
|
package shared
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/base64"
|
||||||
|
"gopkg.in/mgo.v2/bson"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestObjectIdToString(t *testing.T) {
|
||||||
|
b := bson.ObjectIdHex("5596d9b7f6fb5e195e000004")
|
||||||
|
s := ObjectIdToPublicId(b)
|
||||||
|
key, err := base64.URLEncoding.DecodeString(s)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if len(key) != 16 {
|
||||||
|
t.Error("key must be of length 16 bytes to be compatible with siphash.", len(key))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestStringToObjectId(t *testing.T) {
|
||||||
|
s := "O725hlWW2bf2-14ZXgAABA=="
|
||||||
|
oid, err := PublicIdToObjectId(s)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
} else if oid != bson.ObjectIdHex("5596d9b7f6fb5e195e000004") {
|
||||||
|
t.Error(oid)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestValidateId(t *testing.T) {
|
||||||
|
if id, err := base64.URLEncoding.DecodeString("cGOZFFWW2bf2-14ZXgAABA=="); err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
} else if err = validateId(id); err == nil {
|
||||||
|
t.Error()
|
||||||
|
}
|
||||||
|
|
||||||
|
if id, err := base64.URLEncoding.DecodeString("O725hlWW2bf2-14ZXgAA"); err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
} else if err = validateId(id); err == nil {
|
||||||
|
t.Error()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
define ["app", "lodash", "directives/ratinput"], (app, _, ratinput) ->
|
define ["app", "lodash", "directives/ratinput"], (app, _, ratinput) ->
|
||||||
|
|
||||||
app.controller "DoormanCtrl", ["$scope", "$http","$routeParams","$location", ($scope, $http, $routeParams, $location) ->
|
app.controller "DoormanCtrl", ["$scope", "$http","$routeParams","$location", "$timeout", ($scope, $http, $routeParams, $location, $timeout) ->
|
||||||
$scope.doorman = {values: []}
|
$scope.doorman = {values: []}
|
||||||
$scope.somevalue = "2/6"
|
$scope.somevalue = "2/6"
|
||||||
$scope.apiurl = "/api/doormen/#{$routeParams.id}"
|
$scope.apiurl = "/api/doormen/#{$routeParams.id}"
|
||||||
$scope.user = localStorage.getItem("email")
|
$scope.user = localStorage.getItem("email")
|
||||||
|
$scope.doormanChanged = false
|
||||||
|
|
||||||
$http.get($scope.apiurl).then((res) ->
|
$http.get($scope.apiurl).then((res) ->
|
||||||
$scope.doorman = res.data
|
$scope.doorman = res.data
|
||||||
@@ -61,6 +62,11 @@ define ["app", "lodash", "directives/ratinput"], (app, _, ratinput) ->
|
|||||||
params = {params: {user: $scope.user}}
|
params = {params: {user: $scope.user}}
|
||||||
$http.put($scope.apiurl, $scope.doorman, params).then((ret)->
|
$http.put($scope.apiurl, $scope.doorman, params).then((ret)->
|
||||||
console.log "update"
|
console.log "update"
|
||||||
|
).then((res) ->
|
||||||
|
$scope.doormanChanged = true
|
||||||
|
$timeout(() ->
|
||||||
|
$scope.doormanChanged = false
|
||||||
|
, 3000)
|
||||||
).catch((res) ->
|
).catch((res) ->
|
||||||
$scope.error =
|
$scope.error =
|
||||||
message: res.data
|
message: res.data
|
||||||
|
|||||||
@@ -4,6 +4,11 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="columns large-12">
|
||||||
|
<h3>End points</h3>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="row wab-apispect">
|
<div class="row wab-apispect">
|
||||||
<table class="columns large-12">
|
<table class="columns large-12">
|
||||||
@@ -26,3 +31,23 @@
|
|||||||
|
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="columns large-12">
|
||||||
|
<h3>Authentication</h3>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="columns large-12">
|
||||||
|
<p>
|
||||||
|
All calls that change an asset requires authentication.
|
||||||
|
Authentication is done by adding a <code class="light">
|
||||||
|
user={user_name}</code> parameter to the endpoint. For example, to
|
||||||
|
authenticate to <code class="light">/api/doormen/zST8_FWcPDT2-14wDQAAAQ==</code>
|
||||||
|
with a user called "bob", the url becomes
|
||||||
|
<code class="light">/api/doormen/zST8_FWcPDT2-14wDQAAAQ==?user=bob</code>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -12,8 +12,16 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row" ng-repeat="value in doorman.values">
|
<div class="row" ng-repeat="value in doorman.values">
|
||||||
<div class="columns large-7 small-10">
|
<div class="columns large-8 small-10">
|
||||||
<label >name<input type="text" placeholder="value name" ng-value="value.name" disabled></label>
|
<div class="row">
|
||||||
|
<div class="large-2 columns">
|
||||||
|
<a class="button prefix disabled" ng-bind="$index"> </a>
|
||||||
|
</div>
|
||||||
|
<div class="large-10 columns">
|
||||||
|
<input type="text" placeholder="value name" ng-value="value.name" disabled>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="columns large-4 small-2">
|
<div class="columns large-4 small-2">
|
||||||
<label >
|
<label >
|
||||||
@@ -76,7 +84,9 @@
|
|||||||
<div class="large-12 small-12 columns">
|
<div class="large-12 small-12 columns">
|
||||||
<ul class="button-group">
|
<ul class="button-group">
|
||||||
<li><a ng-click="updateDoorman()" class="small button" ng-class="{disabled: !validate()}">Update</a></li>
|
<li><a ng-click="updateDoorman()" class="small button" ng-class="{disabled: !validate()}">Update</a></li>
|
||||||
<li><a ng-click="deleteDoorman()" class="small button">Delete</a></li>
|
|
||||||
</ul>
|
</ul>
|
||||||
|
<span ng-show="doormanChanged">
|
||||||
|
doorman changed
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
<input type="text" placeholder="email" ng-model="email">
|
<input type="text" placeholder="email" ng-model="email">
|
||||||
</div>
|
</div>
|
||||||
<div class="small-2 columns">
|
<div class="small-2 columns">
|
||||||
<input type="submit" class="button postfix" >Login!</input>
|
<button type="submit" class="button postfix" >Login!</input>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -91,11 +91,11 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="large-11 columns">
|
<div class="large-9 columns">
|
||||||
<button ng-click="createDoorman()" ng-class="{disabled: !isDoormanValid()}">create</button>
|
<button ng-click="createDoorman()" ng-class="{disabled: !isDoormanValid()}">create</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="large-1 columns">
|
<div class="large-3 columns">
|
||||||
<span >propability remaning: {{ getProbabilityRemaining() | ratpp}}</span>
|
<span >propability remaning: {{ getProbabilityRemaining() | ratpp}}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -61,3 +61,7 @@ h1, h2{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.light{
|
||||||
|
border-style: none;
|
||||||
|
}
|
||||||
Reference in new issue
Block a user