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

System.register(["app/core/core_module"],function(a,b){"use strict";function c(){return{restrict:"E",template:e,controller:f,bindToController:!0,controllerAs:"ctrl",scope:{dismiss:"&"}}}b&&b.id;a("saveDashboardAsDirective",c);var d,e,f;return{setters:[function(a){d=a}],execute:function(){e='\n<div class="modal-body">\n\t<div class="modal-header">\n\t\t<h2 class="modal-header-title">\n\t\t\t<i class="fa fa-copy"></i>\n\t\t\t<span class="p-l-1">Save As...</span>\n\t\t</h2>\n\n\t\t<a class="modal-header-close" ng-click="ctrl.dismiss();">\n\t\t\t<i class="fa fa-remove"></i>\n\t\t</a>\n\t</div>\n\n\t<form name="ctrl.saveForm" ng-submit="ctrl.save()" class="modal-content" novalidate>\n\t\t<div class="p-t-2">\n\t\t\t<div class="gf-form">\n\t\t\t\t<label class="gf-form-label">New name</label>\n\t\t\t\t<input type="text" class="gf-form-input" ng-model="ctrl.clone.title" give-focus="true" required>\n\t\t\t</div>\n\t\t</div>\n\n\t\t<div class="gf-form-button-row text-center">\n\t\t\t<button type="submit" class="btn btn-success" ng-disabled="ctrl.saveForm.$invalid">Save</button>\n\t\t\t<a class="btn-text" ng-click="ctrl.dismiss();">Cancel</a>\n\t\t</div>\n\t</form>\n</div>\n',f=function(){function a(a,b){this.$scope=a,this.dashboardSrv=b;var c=this.dashboardSrv.getCurrent();this.clone=c.getSaveModelClone(),this.clone.id=null,this.clone.title+=" Copy",this.clone.editable=!0,this.clone.hideControls=!1,c.id>0&&this.clone.rows.forEach(function(a){a.panels.forEach(function(a){delete a.thresholds,delete a.alert})}),delete this.clone.autoUpdate}return a.$inject=["$scope","dashboardSrv"],a.prototype.save=function(){return this.dashboardSrv.save(this.clone).then(this.dismiss)},a.prototype.keyDown=function(a){13===a.keyCode&&this.save()},a}(),a("SaveDashboardAsModalCtrl",f),d.default.directive("saveDashboardAsModal",c)}}});