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