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

import { UserRouteAccessService } from 'app/core/auth/user-route-access.service';
import { ASC } from 'app/config/navigation.constants';
import { VariableComponent } from './list/variable.component';
import { VariableDetailComponent } from './detail/variable-detail.component';
import { VariableUpdateComponent } from './update/variable-update.component';
import VariableResolve from './route/variable-routing-resolve.service';
import { SecurityAction } from 'app/security/security-action.model';
import { Resources } from 'app/security/resources.model';
import { VariableService } from './service/variable.service';

const variableRoute: Routes = [
  {
    path: '',
    component: VariableComponent,
    canActivate: [UserRouteAccessService],
    data: {
      defaultSort: 'id,' + ASC,
      action: SecurityAction.READ,
      service: VariableService,
      resource: Resources.VARIABLE,
      authorities: ['ROLE_ADMIN', 'ROLE_MANAGER'],
    }
  },
  {
    path: ':id/view',
    component: VariableDetailComponent,
    resolve: {
      variable: VariableResolve,
    },
    canActivate: [UserRouteAccessService],
    data: {
      action: SecurityAction.READ,
      service: VariableService,
      resource: Resources.VARIABLE,
      authorities: ['ROLE_ADMIN', 'ROLE_MANAGER'],
    }
  },
  {
    path: 'new',
    component: VariableUpdateComponent,
    resolve: {
      variable: VariableResolve,
    },
    canActivate: [UserRouteAccessService],
    data: {
      action: SecurityAction.CREATE,
      service: VariableService,
      resource: Resources.VARIABLE,
      authorities: ['ROLE_ADMIN', 'ROLE_MANAGER'],
    }
  },
  {
    path: ':id/edit',
    component: VariableUpdateComponent,
    resolve: {
      variable: VariableResolve,
    },
    canActivate: [UserRouteAccessService],
    data: {
      action: SecurityAction.UPDATE,
      service: VariableService,
      resource: Resources.VARIABLE,
      authorities: ['ROLE_ADMIN', 'ROLE_MANAGER'],
    }
  },
];

export default variableRoute;
