/*! grafana - v3.1.0 - 2016-07-18
 * Copyright (c) 2016 Torkel Ödegaard; Licensed Apache-2.0 */

System.register(["app/core/core_module"],function(a){function b(a,b,c){return{restrict:"E",template:d,scope:{onUpload:"&"},link:function(a){function c(b){for(var c,d=b.target.files,e=function(){return function(b){var c;try{c=JSON.parse(b.target.result)}catch(d){return console.log(d),void a.appEvent("alert-error",["Import failed","JSON -> JS Serialization failed: "+d.message])}a.$apply(function(){a.onUpload({dash:c})})}},f=0;c=d[f];f++){var g=new FileReader;g.onload=e(),g.readAsText(c)}}var d=window;d.File&&d.FileReader&&d.FileList&&d.Blob?document.getElementById("dashupload").addEventListener("change",c,!1):b.set("Oops","Sorry, the HTML5 File APIs are not fully supported in this browser.","error")}}}b.$inject=["timer","alertSrv","$location"];var c,d;return{setters:[function(a){c=a}],execute:function(){d='\n<input type="file" id="dashupload" name="dashupload" class="hide"/>\n<label class="btn btn-secondary" for="dashupload">\n  <i class="fa fa-upload"></i>\n  Upload .json File\n</label>\n',c["default"].directive("dashUpload",b)}}});