Added support filter variables and history items

This commit is contained in:
Siteshwar Vashisht 2013-09-07 22:36:23 +05:30
parent 72431456ff
commit 5e53c1cde8
3 changed files with 30 additions and 4 deletions

View File

@ -1,6 +1,10 @@
<div id="table_filter_container" style="display: block;">
<input id="table_filter_text_box" class="filter_text_box text_box_transient" placeholder="Filter" ng-model="query">
</div>
<table id="data_table" style="display: table;" >
<tbody>
<tr class="data_table_row" ng-repeat="item in historyItems">
<tr class="data_table_row" ng-repeat="item in historyItems | filter:query">
<td class="data_table_cell no_overflow" style="text-align: left; padding-right: 30px;">{{ item }}</td>
<td class="data_table_cell" style="text-align: right; width: 25px">
<a ng-click="deleteHistoryItem(item)">

View File

@ -1,9 +1,12 @@
<div id="table_filter_container" style="display: block;">
<input id="table_filter_text_box" class="filter_text_box text_box_transient" placeholder="Filter" ng-model="query">
</div>
<table id="data_table" style="display: table;">
<tbody>
<tr class="data_table_row" ng-repeat="variable in variables">
<td class="data_table_cell no_overflow" style="text-align: left; padding-right: 30px;">{{ variable.name }}</td>
<tr class="data_table_row" ng-repeat="variable in variables | filterVariable:query">
<td class="data_table_cell no_overflow" style="text-align: right; padding-right: 30px;">{{ variable.name }}</td>
<td class="data_table_cell no_overflow" style="text-align: left; padding-right: 30px;">{{ variable.value }}</td>
</tr>
</tbody>
</table>

View File

@ -1,5 +1,22 @@
webconfig = angular.module("webconfig", []);
webconfig.filter("filterVariable", function() {
return function(variables, query) {
var result = []
if (variables == undefined) return result;
if (query == null) { return variables };
for(i=0; i<variables.length; ++i) {
variable = variables[i];
if (variable.name.indexOf(query) != -1 || variable.value.indexOf(query) != -1) {
result.push(variable);
}
}
return result;
}
});
webconfig.config(
["$routeProvider", function($routeProvider) {
$routeProvider
@ -155,10 +172,12 @@ webconfig.controller("functionsController", function($scope, $http) {
});
webconfig.controller("variablesController", function($scope, $http) {
$scope.query = null;
$scope.fetchVariables= function() {
$http.get("/variables/").success(function(data, status, headers, config) {
$scope.variables = data;
})};
$scope.fetchVariables();
});