You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
aggregation-platform/plugins/kubernetes/ts/dataInfnModel.ts

192 lines
5.0 KiB

/// <reference path="../../includes.ts"/>
/// <reference path="kubernetesPlugin.ts"/>
module Kubernetes{
export class dataInfoModelService{
public serverdata = {};
public promiseobject = {};
public localdata = {};
public selectednodes = [];
public resumablejs = [];
public selecteditems = [];
public serveritems = [];
public uploadprocess ={};
public uploadedStatus = "";
public get uploadProcess():Object {
return this.uploadprocess
}
public set uploadProcess(uploadProcess:Object){
this.uploadprocess = uploadProcess;
}
public folderList = {
length:0
};
public get serverItems():Array<any> {
return this.serveritems;
}
public set serverItems(serverItems: Array<any>){
this.serveritems = serverItems;
}
public get resumableJs():Array<any> {
return this.resumableJs;
}
public set resumableJs(resumableJs: Array<any>){
this.resumablejs = resumableJs;
}
public get selectedItems():Array<any> {
return this.selecteditems;
}
public set selectedItems(selectedItems: Array<any>){
this.selecteditems = selectedItems;
}
public get selectedNodes():Array<any> {
return this.selectednodes;
}
public set selectedNodes(selectedNodes: Array<any>){
this.selectednodes = selectedNodes;
}
public isContainsNodes(node: Object){
for(var item in this.selectednodes){
if(this.selectednodes[item].id === node.id)
return true;
}
return false;
}
public findNodes(node: any) {
var id = "-1";
if(typeof(node) === "object" ){
id = node.id;
}else if(typeof(node) === "number"){
id =node.toString();
}else if(typeof(node) === "string"){
id = node;
}else{
return "-1";
}
for(var item in this.selectednodes){
if(this.selectednodes[item].id === id)
return item;
}
return "-1";
}
public findItemIndex(item: any){
var id = -1;
if(typeof(item) === "object" ){
id = item.id;
}else if(typeof(item) === "number"){
id =item.toString();
}else if(typeof(item) === "string"){
id = item;
}else{
return -1;
}
for(var it in this.selecteditems){
if(this.selecteditems[it].id === id)
return it;
}
return -1;
}
public createFolderList(files: Object ,rootPath: string){
for(var i=0; i< files.length; i++){
var relativePath = files[i].webkitRelativePath.replace(RegExp("^"+rootPath+"/"),"");
var paths=relativePath.split("/");
if(!this.folderList.hasOwnProperty(paths[0])){
this.folderList[paths[0]]={
length:0
};
this.folderList.length++;
}
var Obj = this.folderList[paths[0]];
Obj[Obj.length] = files[i];
Obj.length++;
this.folderList[paths[0]] = Obj;
}
}
public updateNodeById(nodeId,key,value){
for(var item in this.selectednodes){
var node = this.selectednodes[item];
if(node.id === nodeId){
node[key] = value;
break;
}
}
}
public get serverData():Object {
return this.serverData;
}
public set serverData(serverData:Object){
this.serverdata=serverData;
}
public get promiseObject():Object {
return this.promiseobject;
}
public set promise(promiseObject:Object){
this.promiseobject = promiseObject;
}
public get localData():Object {
return this.localdata;
}
public set localData(localData:Object){
this.localdata = localData;
}
public updataDataModel(){
this.promiseobject.success(function(data,header,config,status){
this.serverdata =data;
});
this.promiseobject.error(function(data,status,hedaers,config){
this.serverdata = {};
});
}
}
_module.factory('DataInfoModel', ['$http', ($http) => {
var $scope =new dataInfoModelService();
$scope.promiseobject=$http({
url:'/xmlformserver',
method:'POST'
});
updateDataFromServer($scope.serverdata, (data,header,config,status) => {
$scope.serverdata = data;
});
function updateDataFromServer(data,callback){
$http({
url:'/xmlformserver',
method:'POST'
}).success(function(data,header,config,status){
if(data)
callback(data,header,config,status);
}).error(function(data,header,config,status){
console.log("error");
});
};
return $scope;
}]);
}