export default class JobsController {

    constructor($log, $state, $stateParams, jobManager) {
        'ngInject';
        this.$log = $log;
        this.$state = $state;
        this.$stateParams = $stateParams;
        this.jobManager = jobManager;
    }

    $onInit() {
        // check product param
        this.productId = this.$state.params.productId;
        this.jobManager.setCurrentProductId(this.productId);
        this.configureJobs();
    }

    configureJobs() {
        if(this.isProductView()){
            this.title = "Product - Jobs";
            this.jobs = this.jobManager.getProductJobs();
        }else{
            this.title = "Jobs View";
            this.jobs = this.jobManager.getProjectJobs();
        }
    }

    isProductView() {
        return this.productId ? true : false;
    }

    goBack() {
        this.$state.go('catalog');
    }

}
