Skip to content

Commit

Permalink
Remove absolute urls, fix attrVal bug
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptobioz committed Aug 1, 2017
1 parent 623d714 commit f4a391e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 31 deletions.
22 changes: 11 additions & 11 deletions static/search.html
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<div class="row">
<div class="col-sm-2">
<div class="col-xs-2 col-sm-2 col-md-2">
<label for="resource_type">Resource Type</label>
</div>
<div class="col-sm-2">
<div class="col-xs-2 col-sm-2 col-md-2">
<label for="resource_id">Resource ID</label>
</div>
<div class="col-sm-2">
<div class="col-xs-2 col-sm-2 col-md-2">
<label for="attribute_key">Attribute Key</label>
</div>
<div class="col-sm-2">
<div class="col-xs-2 col-sm-2 col-md-2">
<label for="attribute_value">Attribute Value</label>
</div>
</div>
<div class="row">
<form class="form-inline" role="form">
<div class="form-group col-sm-2">
<form class="form-inline" ng-submit="doSearch()" role="form">
<div class="form-group col-xs-2 col-sm-2 col-md-2">
<ui-select id="resource_type"
ng-model="$parent.resType"
theme="bootstrap"
Expand All @@ -29,7 +29,7 @@
</ui-select-choices>
</ui-select>
</div>
<div class="form-group col-sm-2">
<div class="form-group col-xs-2 col-sm-2 col-md-2">
<ui-select id="resource_id"
ng-model="$parent.resID"
theme="bootstrap"
Expand All @@ -44,7 +44,7 @@
</ui-select-choices>
</ui-select>
</div>
<div class="form-group col-sm-2">
<div class="form-group col-xs-2 col-sm-2 col-md-2">
<ui-select id="attribute_key"
ng-model="$parent.attrKey"
theme="bootstrap"
Expand All @@ -62,10 +62,10 @@
</ui-select-choices>
</ui-select>
</div>
<div class="form-group col-sm-2">
<input id="attribute_value" type="text" class="form-control" placeholder="Attribute Value" ng-model="$parent.attrVal" ng-change="doSearch()" />
<div class="form-group col-xs-2 col-sm-2 col-md-2">
<input id="attribute_value" type="text" class="form-control" ng-value="attrVal" placeholder="Attribute Value" ng-model="$parent.attrVal" ng-change="doSearch()" />
</div>
<button class="btn btn-primary" type="submit" ng-click="createPermalink()">Permalink</button>
<button class="btn btn-primary" type="submit" ng-click="createPermalink()">Search</button>
<button class="clear btn btn-warning" ng-click="clearForm()">Reset</button>
</form>
</div>
Expand Down
38 changes: 18 additions & 20 deletions static/terraboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,16 +276,16 @@ app.controller("tbSearchCtrl", ['$scope', '$http', '$location', '$routeParams',

$scope.doSearch = function(page) {
var params = {};
if ($scope.resType != "") {
if ($scope.resType != undefined) {
params.type = $scope.resType;
}
if ($scope.resID != "") {
if ($scope.resID != undefined) {
params.name = $scope.resID;
}
if ($scope.attrKey != "") {
if ($scope.attrKey != undefined) {
params.key = $scope.attrKey;
}
if ($scope.attrVal != "") {
if ($scope.attrVal != undefined) {
params.value = $scope.attrVal;
}
if (page != undefined) {
Expand All @@ -304,16 +304,16 @@ app.controller("tbSearchCtrl", ['$scope', '$http', '$location', '$routeParams',
}

// On page load
if ($location.search().type != "") {
if ($location.search().type != undefined) {
$scope.resType = $location.search().type;
}
if ($location.search().name != "") {
if ($location.search().name != undefined) {
$scope.resID = $location.search().name;
}
if ($location.search().key != "") {
if ($location.search().key != undefined) {
$scope.attrKey = $location.search().key;
}
if ($location.search().val != "") {
if ($location.search().value != undefined) {
$scope.attrVal = $location.search().value;
}
$scope.doSearch(1);
Expand All @@ -324,27 +324,25 @@ app.controller("tbSearchCtrl", ['$scope', '$http', '$location', '$routeParams',
$scope.attrKey = undefined;
$scope.attrVal = undefined;
$scope.results = undefined;
$location.url('/search');
$location.url($location.path());
}

$scope.createPermalink = function(page) {
var params = {};
if ($scope.resType != "") {
params.type = $scope.resType;
if ($scope.resType != undefined) {
$location.search("type", $scope.resType);
}
if ($scope.resID != "") {
params.name = $scope.resID;
if ($scope.resID != undefined) {
$location.search("name", $scope.resID);
}
if ($scope.attrKey != "") {
params.key = $scope.attrKey;
if ($scope.attrKey != undefined) {
$location.search("key", $scope.attrKey);
}
if ($scope.attrVal != "") {
params.value = $scope.attrVal;
if ($scope.attrVal != undefined) {
$location.search("value", $scope.attrVal);
}
if (page != undefined) {
params.page = page;
}
var query = $.param(params);
$location.url('/search?'+query);
$location.url();
}
}]);

0 comments on commit f4a391e

Please sign in to comment.