"use strict"
if (!Object.values) Object.values = function (obj) {
  if (obj !== Object(obj))
    throw new TypeError('Object.values called on a non-object');
  var val = [], key;
  for (key in obj) {
    if (Object.prototype.hasOwnProperty.call(obj, key)) {
      val.push(obj[key]);
    }
  }
  return val;
}


var PLG_BUTTON = {
  value: {
    addBtn: function () {
      return '<i class="layui-icon layui-icon-add-1" style="color:#467cfd"></i>' + _t("新增")
    },
    delBtn: function () {
      return '<i class="layui-icon layui-icon-delete"></i>' + _t("删除")
    },
    alldelBtn: function () {
      return '<i class="layui-icon layui-icon-delete"></i>' + _t("批量删除")
    },
    logBtn: function () {
      return '<i class="layui-icon layui-icon-log" style="color:#467cfd"></i>' + _t("日志")
    },
    editBtn: function () {
      return '<i class="layui-icon layui-icon-edit" style="color:#467cfd"></i>' + _t("编辑")
    },
    saveBtn: function () {
      return '<i class="iconfont p-icon-save" style="font-size: 14px;" ></i> ' + _t("保存")
    },
    importBtn: function () {
      return '<i class="iconfont p-icon-daoru" style="color:#467cfd"></i> ' + _t("导入")
    },
    exportBtn: function () {
      return '<i class="iconfont p-icon-daochu" style="color:#467cfd"></i> ' + _t("导出")
    },
    downBtn: function () {
      return '<i class="iconfont p-icon-xiazaimoban" style="color:#467cfd"></i> ' + _t("模版")
    },
    searchBtn: function () {
      return '<i class="layui-icon layui-icon-search" style="color:#467cfd"></i>' + _t("查询")
    },
    resetBtn: function () {
      return '<i class="layui-icon layui-icon-refresh-1" style="color:#467cfd"></i>' + _t("重置")
    }
  },
  warehouseId: {
    type: "hidden",
    name: "warehouseId",
    notToggle: true
  }
}


var APIS = Object.create({ base_url: '/api' }, {})

//资源管理
APIS.resource = {
  //查询资源，添加资源
  getResource: function () {
    return this.base_url + "/service-authorization/resource"
  }.bind(APIS),

  getList: function () {
    return this.getResource() + "/list"
  },

  //查询所有服务名【自动加载】
  getSysNames: function () {
    return this.getResource() + "/instance/names"
  },
  //根据服务名查询所有接口【自动加载】
  getNameByList: function () {
    return this.getResource() + "/instance"
  },


  //导入服务接口【自动加载】
  importInterface: function () {
    return this.getResource() + "/importinstance"
  },

  //删除资源
  delete: function () {
    return this.getResource() + "/delete"
  },

  //多个删除资源
  deleteAll: function () {
    return this.delete() + "/multiple"
  },

  //修改资源
  update: function () {
    return this.getResource() + "/update"
  },
  // 导出Excel数据
  export: function () {
    return this.getResource() + "/export"
  },
  // 导入模版
  import: function () {
    return this.getResource() + "/import"// 【批量导入】
  },
  // 下载模版下载
  download: function () {
    return this.getResource() + "/download/template"// 【导入模版下载】
  },

    //没有分配的资源
  listnotingroup:function(){
      return this.getResource() + "/listnotingroup"
    },
    //分配的资源
    listbygroup:function(){
      return this.getResource() + "/listbygroup"
    },
  
      //根据clientid分页查询资源
  listbyclient: function () {
    return this.getResource() + "/listbyclient"

  },
  //根据客户端id查询不包含的资源
  notlistbyclient: function () {
    return this.getResource() + "/listnotinclient"

  }
}


//资源组管理
APIS.groupResource = {
  getList: function () {
    //return this.base_url + "/data/mock/resource/groupResource.json"
    return this.base_url + "/service-authorization/group"
  }.bind(APIS),

  //添加资源
  addRes: function () {
    return this.getList() + "/recources/add"

  },
   //删除资源
  removeRes: function () {
    return this.getList() + "/resource/remove"
  },

  //添加资源组
  groupAdd: function () {
    return this.getList() + "/add"
  },
  groupDelete: function () {
    return this.getList() + "/delete"
  },
  update() {
    return this.getList() + "/update"
  },


      //根据clientid分页查询资源下组
      listbyclient: function () {
        return this.getList() + "/listbyclient"
    
      },
      //根据客户端id查询不包含的资源组
      notlistbyclient: function () {
        return this.getList() +	"/listothersbyclient"
    
      },

  
};

 //用户资源

 APIS.client={

  authmgr: function () {
    return this.base_url + "/service-authorization/authmgr"
  }.bind(APIS),
  update:function () {
    return this.authmgr() + "/update"
  },
  getAuthmgr:function(){
    return this.authmgr() + "/like"
  },
  addAuthmgr:function(){
    return this.authmgr() + "/add"
  },
  deleteAuthmgr:function(){
    return this.authmgr() + "/delete"
  },


  //分配资源
  addResource:function(){
    return this.authmgr() + "/resource/add"

  },

  //删除资源
  removeResource:function(){
    return this.authmgr() + "/resource/remove"

  },

  //分配资源组

  addGroup:function(){
    return this.authmgr() + "/group/add"

  },
  //删除资源组
  removeGroup:function(){
    return this.authmgr() + "/group/remove"
  },

  //激活客户端
  active:function(){
    return this.authmgr() + "/active"
  },

  //解冻客户端
  unfreeze:function(){
    return this.authmgr() + "/unfreeze"
  },
  //冻结客户端
  freeze:function(){
    return this.authmgr() + "/freeze"
  },
  //重置初始密码
  resetpassword:function(){
    return this.authmgr() + "/resetpassword"
  },
    //更新密码
  updatepassword:function(){
    return this.authmgr() + "/updatepassword"
  },

    //重置权限
    refreshauths:function(){
    return this.authmgr() + "/refreshauths"
  }
}


APIS.home={
  
  statistics: function () {
    return this.base_url + "/service-authorization/statistics"
  }.bind(APIS),
  userStatus:function(){
    return this.statistics()+"/distribute/auclient"
  },
  entry:function(){
    return this.statistics()+"/entry/resource/count"
  },
  service:function(){
    return this.statistics()+"/entry/service/count"
  },
  reginstance:function(){
    return this.statistics()+"/reg/instance/count"
  },
  regService:function(){
    return this.statistics()+"/reg/service/count"
  },

  distribute:function(){
    return this.statistics()+"/distribute/resource"
  }
}

//服务器管理
APIS.settings={
  server:{
    serviceDevopsbackstage:function () {
      return  "/api/service-devopsbackstage"
    }.bind(APIS),
    /*请求列表*/
    serverinfo: function () {
      return this.serviceDevopsbackstage() + "/serverinfo"
    },
    getAllServers:function () {
      return this.serverinfo()+"/getAllServers"
    },
  



    instanceInfo:function () {
      return this.serviceDevopsbackstage() + "/instanceInfo"

    },
    //部署
    setArrange:function () {
      return this.instanceInfo()+"/arrange"
    },
    //启动容器
    toggleContainer:function () {
      return this.instanceInfo()+"/startStopContainer"
    },
    

  },
  
}



APIS.languageGroup={
  zh_CN:"简体中文",
  en:"English"
  };
APIS.lang={
  baseUrl: function () {
    return APIS.base_url + "/service-internationalize"
  },
  getMenu:function(){
    return this.baseUrl() + "/menu/getMenu"
  },

  language:function(){
    return this.baseUrl() + "/language"
  },
  languageDel:function(){
    return this.baseUrl() + "/language/del"
  },


  languageGetAll:function(){
    return this.baseUrl() + "/language/getAll"
  },
  pageItem:function(){
    return this.baseUrl() + "/pageItem"
  },
  pageItemDel:function(){
    return this.baseUrl() + "/pageItem/del"
  },

  pageLanguage:function(){
    return this.baseUrl() + "/pageLanguage"
  }

}




