Document download new directive added : kdk

This commit is contained in:
resicovenba 2018-02-26 15:18:44 +05:30
parent e520bc3fb6
commit dfd6459abc
3 changed files with 54 additions and 7 deletions

View File

@ -1130,6 +1130,28 @@ app.controller('studentCtrl', ["$scope", "toaster", "$filter", "ngTableParams",
}
}
$scope.printPdf = function (file_Uid){
alert(file_Uid);
$http({
url : 'http://localhost/apollo_New_Update_20_02_2018/apollodec/Apollo/images/'+ file_Uid,
method : 'GET',
headers : {
'Content-type' : 'application/pdf'
},
responseType : 'arraybuffer'
}).success(function(data, status, headers, config) {
var pdfFile = new Blob([ data ], {
type : 'application/pdf'
});
var pdfUrl = URL.createObjectURL(pdfFile);
var printwWindow = $window.open(pdfUrl);
// printwWindow.print();
}).error(function(data, status, headers, config) {
alert('Sorry, something went wrong')
});
};
// end : entrollment document upload ====================================
$scope.stepsModelEdit = [];
@ -2709,4 +2731,27 @@ app.controller('ModalInstanceCtrl1', ["$scope", "$modalInstance", "items1", "Wor
};
}]);
}]);
// Hook in a directive
app.directive('fileDownload', function(){
return {
restrict: 'E', // applied on 'element'
scope: {
fileurl: '@fileurl',
linktext: '@linktext'
},
template: '<a href="{{ fileurl }}" download><button tooltip="Download" class="btn btn-xs btn-primary"><i class="ti-download"> </i></button></a>', // need this so that the inner HTML can be re-used
link: function(scope, elem, attrs) {
/* Ref: https://thinkster.io/egghead/isolate-scope-at
* This block is used when we have
* scope: {
fileurl: '=fileurl',
linktext: '=linktext'
}
scope.fileurl = attrs.fileurl;
scope.linktext = attrs.linktext;*/
}
}
})

View File

@ -396,7 +396,7 @@
</div>
</form>
</tab>
<!--<tab heading="Document Details" id="documentDetails">
<tab heading="Document Details" id="documentDetails">
<tabset class="tabbable" style="border: 1px solid #c5c5c5; border-radius: 3px; box-shadow: 3px 5px #c3c3c3;">
<tab heading="Add Document Details">
@ -464,8 +464,10 @@
<tr>
<td>{{doc.DocumentName}}</td>
<td>{{doc.DocumentStorePath}}</td>
<td class="center"><button tooltip="Download" class="btn btn-xs btn-primary"><i class="ti-download">
<a ng-href="http://localhost/apollo_New_Update_20_02_2018/apollodec/Apollo/images/{{doc.DocumentStorePath}}" target="_blank"></a> </i></button>
<td class="center">
<!--<td class="center"><button tooltip="Download" class="btn btn-xs btn-primary" ng-click="printPdf(doc.DocumentStorePath)"><i class="ti-download">
<a ng-href="http://localhost/apollo_New_Update_20_02_2018/apollodec/Apollo/images/{{doc.DocumentStorePath}}" target="_blank"></a> </i></button>-->
<file-download fileurl="http://localhost/apollo_New_Update_20_02_2018/apollodec/Apollo/images/{{doc.DocumentStorePath}}" linktext="Click here!"></file-download>
<button tooltip="Delete" class="btn btn-xs btn-danger" ng-click="deleteDocDetails(doc.ID, p.StudentID)"><i class="ti-trash">
</i></button>
</td>
@ -479,7 +481,7 @@
</div>
</div>
</tab>
<tab heading="Pending Document Details">
<!--<tab heading="Pending Document Details">
<fieldset style="background-color: #eaeaea;">
<legend>
Pending Document Details
@ -565,8 +567,8 @@
</div>
</div>
</div>
</tab>
</tab>-->
</tabset>
</tab>-->
</tab>
</tabset>
<!-- class="editRowTd" -->