/*! grafana - v4.5.1 - 2017-09-19
 * Copyright (c) 2017 Torkel Ödegaard; Licensed Apache-2.0 */

System.register(["app/core/config","app/core/core_module","remarkable"],function(a,b){"use strict";var c,d,e,f;b&&b.id;return{setters:[function(a){c=a},function(a){d=a},function(a){e=a}],execute:function(){f=function(){function a(a,b,d,f,g){this.$scope=a,this.$http=b,this.backendSrv=d,this.user={loginOrEmail:"",role:"Viewer"},this.navModel=f.getOrgNav(0),this.get(),this.editor={index:0},this.externalUserMngLinkUrl=c.default.externalUserMngLinkUrl,this.externalUserMngLinkName=c.default.externalUserMngLinkName,c.default.externalUserMngInfo&&(this.externalUserMngInfo=new e.default({linkTarget:"__blank"}).render(c.default.externalUserMngInfo)),this.addUsersBtnName=this.getAddUserBtnName()}return a.$inject=["$scope","$http","backendSrv","navModelSrv","$sce"],a.prototype.getAddUserBtnName=function(){return this.externalUserMngLinkName?this.externalUserMngLinkName:c.default.disableLoginForm?"Add Users":"Add or Invite"},a.prototype.get=function(){var a=this;this.backendSrv.get("/api/org/users").then(function(b){a.users=b}),this.backendSrv.get("/api/org/invites").then(function(b){a.pendingInvites=b})},a.prototype.updateOrgUser=function(a){this.backendSrv.patch("/api/org/users/"+a.userId,a)},a.prototype.removeUser=function(a){var b=this;this.$scope.appEvent("confirm-modal",{title:"Delete",text:"Are you sure you want to delete user "+a.login+"?",yesText:"Delete",icon:"fa-warning",onConfirm:function(){b.removeUserConfirmed(a)}})},a.prototype.removeUserConfirmed=function(a){this.backendSrv.delete("/api/org/users/"+a.userId).then(this.get.bind(this))},a.prototype.revokeInvite=function(a,b){b.stopPropagation(),this.backendSrv.patch("/api/org/invites/"+a.code+"/revoke").then(this.get.bind(this))},a.prototype.copyInviteToClipboard=function(a){a.stopPropagation()},a.prototype.getInviteUrl=function(a){return a.url},a.prototype.openAddUsersView=function(){var a=this.$scope.$new();a.invitesSent=this.get.bind(this);var b=c.default.disableLoginForm?"public/app/features/org/partials/add_user.html":"public/app/features/org/partials/invite.html";this.$scope.appEvent("show-modal",{src:b,modalClass:"invite-modal",scope:a})},a}(),a("OrgUsersCtrl",f),d.default.controller("OrgUsersCtrl",f)}}});