import { Routes } from '@angular/router';

import { UserRouteAccessService } from 'app/core/auth/user-route-access.service';
import { ASC } from 'app/config/navigation.constants';
import { EmissionFactorComponent } from './list/emission-factor.component';
import { EmissionFactorPublicComponent } from './list/public/emission-factor-public.component';
import { EmissionFactorDetailComponent } from './detail/emission-factor-detail.component';
import { EmissionFactorUpdateComponent } from './update/emission-factor-update.component';
import EmissionFactorResolve from './route/emission-factor-routing-resolve.service';
import { SecurityAction } from 'app/security/security-action.model';
import { Resources } from 'app/security/resources.model';
import { EmissionFactorService } from './service/emission-factor.service';

const emissionFactorRoute: Routes = [
  {
    path: '',
    component: EmissionFactorComponent,
    data: {
      defaultSort: 'id,' + ASC,
    },
    canActivate: [UserRouteAccessService],
  },
  
  {
    path: 'list',
    component: EmissionFactorPublicComponent,
    canActivate: [UserRouteAccessService],
    data: {
      defaultSort: 'id,' + ASC,
      action: SecurityAction.READ,
      service: EmissionFactorService,
      resource: Resources.EMISSION_FACTOR,
      authorities: ['ROLE_ADMIN', 'ROLE_MANAGER', 'ROLE_COORDINATOR', 'ROLE_USER'],
    }
  },
  {
    path: ':id/view',
    component: EmissionFactorDetailComponent,
    resolve: {
      emissionFactor: EmissionFactorResolve,
    },
    canActivate: [UserRouteAccessService],
    data: {
      action: SecurityAction.READ,
      service: EmissionFactorService,
      resource: Resources.EMISSION_FACTOR,
      authorities: ['ROLE_ADMIN', 'ROLE_MANAGER'],
    }
  },
  {
    path: 'new',
    component: EmissionFactorUpdateComponent,
    resolve: {
      emissionFactor: EmissionFactorResolve,
    },
    canActivate: [UserRouteAccessService],
    data: {
      action: SecurityAction.CREATE,
      service: EmissionFactorService,
      resource: Resources.EMISSION_FACTOR,
      authorities: ['ROLE_ADMIN', 'ROLE_MANAGER'],
    }
  },
  {
    path: ':id/edit',
    component: EmissionFactorUpdateComponent,
    resolve: {
      emissionFactor: EmissionFactorResolve,
    },
    canActivate: [UserRouteAccessService],
    data: {
      action: SecurityAction.UPDATE,
      service: EmissionFactorService,
      resource: Resources.EMISSION_FACTOR,
      authorities: ['ROLE_ADMIN', 'ROLE_MANAGER'],
    }
  },
  {
    path: ':id/clone',
    component: EmissionFactorUpdateComponent,
    resolve: {
      emissionFactor: EmissionFactorResolve,
    },
    canActivate: [UserRouteAccessService],
    data: {
      action: SecurityAction.CREATE,
      service: EmissionFactorService,
      resource: Resources.EMISSION_FACTOR,
      authorities: ['ROLE_ADMIN', 'ROLE_MANAGER'],
    }
  },
];

export default emissionFactorRoute;
