///
///
///
///
module Configs{
export var KubeController = controller('KubeController', ["$scope", "$templateCache", "$location", "$routeParams", "$http", "$timeout",
($scope, $templateCache:ng.ITemplateCacheService, $location, $routeParams, $http, $timeout) => {
$scope.model= [{
"name": "",
"status": "OK",
"ip": "10.188.2.3",
"_id": 1
},
{
"name": "camel-041",
"status": "OK",
"ip": "10.188.2.20",
"_id": 2
},
{
"name": "activemq-004",
"status": "failed",
"ip": "10.188.2.111",
"_id": 3
}];
$scope.tableConfig={
data: "model",
selectedItems: [{
name: "activemq-004",
status: "failed",
ip: "10.188.2.111",
_id: 2
}],
columnDefs: [{
field: "_id",
displayName: "序号"
},
{
field: "name",
displayName: "名称"
},
{
field: "ip",
displayName: "IP"
},
{
field: "port",
displayName: "端口号"
},
{
field: "userName",
displayName: "用户名"
},
{
field: "password",
displayName: "密码"
},
{
field: "serviceName",
displayName: "服务名"
},
{
field: "status",
displayName: "连接状态"
},
{
field: "entity",
displayName: "操作",
cellTemplate: $templateCache.get("tableEdit.html")
}],
enableRowClickSelection: true,
showSelectionCheckbox: false,
multiSelect: false,
sortInfo: {
sortBy: "_id",
ascending: true
}
}
shareInit($scope, $location, $routeParams);
$scope.create = () =>{
$scope.add= true;
$scope.edit = false;
$scope.tableForm = createNewObejct($scope.tableConfig.columnDefs, null);
removeElementsByValue($scope.tableForm, [{key: "name", value: "序号"},{key: "name", value: "连接状态"},{key: "name", value: "操作"}]);
}
$scope.onSubmit = () => {
$scope.edit = false;
$scope.add = false;
console.log($scope.tableForm);
}
$scope.$on("editRow", (event, data) =>{
$scope.edit = true;
$scope.add = false;
$scope.tableForm = createNewObejct($scope.tableConfig.columnDefs, data);
removeElementsByValue($scope.tableForm, [{key: "name", value: "序号"},{key: "name", value: "连接状态"},{key: "name", value: "操作"}]);
}) ;
$scope.$on("deleteRow", (event, data) =>{
removeElementByValue($scope.model, data._id, "_id");
}) ;
}]);
}