UNPKG

unserver-unify

Version:

141 lines (135 loc) 4.85 kB
angular.module('bamboo.material').controller('ApplicationCtrl', function($scope, ApiService, loginService, $state, CommonService, $sce, $stateParams) { var _self = this; this.id = $stateParams.jid; this.application = {}; this.editmode; this.photoPath = ApiService.SHOST + '/job/' + this.id + "/"; this.companypath = ApiService.SHOST + '/company/'; this.defaultPhoto = ApiService.SHOST + "/public/images/details.png"; this.tab = 0; this.resumePath = ApiService.SHOST + "/resume/"; loginService.getMyProfile(true).then(function(result) { $scope.user = result; console.log($scope.user); }); function getInfo() { ApiService.get("/job/" + _self.id).then(function(result) { // console.log(result); if (result.data.success) { console.log(result.data.data); _self.item = result.data.data || {}; if (_self.item.audio) { _self.item.audiourl = $sce.trustAsResourceUrl(_self.photoPath + encodeURI(_self.item.audio)); } _self.imageUrl = _self.item.photo ? _self.photoPath + _self.item.photo : _self.defaultPhoto; if (_self.item.companyId) { getCompanyInfo(_self.item.companyId); } } }); } getInfo(); function getCompanyInfo(id) { var info = { action: "getcompany", id: id, } ApiService.post("/business", info).then(function(result) { if (result.data.success) { _self.company = result.data.data || {}; console.log(_self.company); _self.companyUrl = _self.company.photo ? _self.companypath + _self.company._id + '/' + _self.company.photo : _self.defaultLogoPhoto; } }); } this.application = {}; var filesetting = { promise: true, s3: true, title: 'Select Resume', maxSize: 50000, randomFlag: true, resPath: 'job/' + _self.id + '/', }; this.upload = function() { CommonService.uploadFile(filesetting).then(function(data) { console.log(data); if (data.result) { _self.application.resume = data.fileName; _self.updateapplication(); // CommonService.showInfo("Upload Completed!"); } }); } this.updateapplication = function() { var object = { brief: _self.application.brief, defaultresume: _self.application.defaultresume, skillSets:_self.application.skillSets, } if (_self.application.resume) { object.resume = _self.application.resume; } // var resumeurl; // var resumename; if (object.defaultresume) { object.resumeurl = _self.resumePath + $scope.user.id + '/' + $scope.user.resume; object.resumename = $scope.user.resume; } else { object.resumeurl = _self.photoPath + _self.application.resume; object.resumename = _self.application.resume; } console.log(object); /* if (!_self.application._id) { var tip = "</br>If the file can not be downloaded successfully , please Copy and Paste the URL into your Browser Address Bar ." _self.cvpath = $scope.user.resume ? _self.resumePath +$scope.user.id+'/'+ $scope.user.resume : null; } else { _self.cvpath = _self.application.resume ? _self.photoPath + _self.application.resume : null; } if (!_self.application._id && _self.cvpath) { var tip = "</br>If the file can not be downloaded successfully , please Copy and Paste the URL into your Browser Address Bar ." var link = "</br><a href='https:" + _self.cvpath+ "' download target='_blank' >https:" + _self.cvpath + "</a>"; object.brief += link; object.brief += tip; object.resumeurl=resumeurl; object.resumename=resumename; } */ console.log(object.brief); var info = { object: object, action: "createapplication", jid: _self.id, owner: loginService.school.name, } console.log(info); if (_self.application._id) { info.action = "updateapplication"; info.id = _self.application._id; } ApiService.post("/job", info).then(function(result) { if (result.data.success) { CommonService.showInfo("Your Application Submitted Successfully."); $state.reload(); } else { CommonService.showError(result.data.error); } }) } function getMyApplication() { var info = { jid: _self.id, action: 'getmyapplication' }; ApiService.post("/job", info).then(function(result) { if (result.data.success) { console.log(result.data.data); if (result.data.data) { _self.application = result.data.data; } } else { CommonService.showError(result.data.error); } }) } getMyApplication(); });