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

import { UserRouteAccessService } from 'app/core/auth/user-route-access.service';
import { ASC } from 'app/config/navigation.constants';
import { DashboardComponentComponent } from './list/dashboard-component.component';
import { DashboardComponentPreviewComponent } from './preview/dashboard-component-preview.component';
import { DashboardComponentDetailComponent } from './detail/dashboard-component-detail.component';
import { DashboardComponentUpdateComponent } from './update/dashboard-component-update.component';
import DashboardComponentResolve from './route/dashboard-component-routing-resolve.service';
import { DashboardComponentService } from './service/dashboard-component.service';
import { SecurityAction} from 'app/security/security-action.model';
import { Resources }   from 'app/security/resources.model';

const dashboardComponentRoute: Routes = [
  {
    path: '',
    component: DashboardComponentComponent,
    data: {
      defaultSort: 'id,' + ASC,
      authorities: ['ROLE_ADMIN', 'ROLE_MANAGER'],
    },
    canActivate: [UserRouteAccessService],
  },
  {
    path: ':id/view',
    component: DashboardComponentDetailComponent,
    resolve: {
      dashboardComponent: DashboardComponentResolve,
    },
    canActivate: [UserRouteAccessService],
    data: {
      action: SecurityAction.READ,
      service: DashboardComponentService,
      resource: Resources.DASHBOARD_COMPONENT,
      authorities: ['ROLE_ADMIN', 'ROLE_MANAGER'],
    }
  },
  {
    path: ':id/preview',
    component: DashboardComponentPreviewComponent,
    resolve: {
      dashboardComponent: DashboardComponentResolve,
    },
    canActivate: [UserRouteAccessService],
    data: {
      authorities: ['ROLE_ADMIN', 'ROLE_MANAGER'],
    }
  },
  {
    path: 'new',
    component: DashboardComponentUpdateComponent,
    resolve: {
      dashboardComponent: DashboardComponentResolve,
    },
    canActivate: [UserRouteAccessService],
    data: {
      action: SecurityAction.CREATE,
      service: DashboardComponentService,
      resource: Resources.DASHBOARD_COMPONENT,
      authorities: ['ROLE_ADMIN', 'ROLE_MANAGER'],
    }
  },
  {
    path: ':id/edit',
    component: DashboardComponentUpdateComponent,
    resolve: {
      dashboardComponent: DashboardComponentResolve,
    },
    canActivate: [UserRouteAccessService],
    data: {
      action: SecurityAction.UPDATE,
      service: DashboardComponentService,
      resource: Resources.DASHBOARD_COMPONENT,
      authorities: ['ROLE_ADMIN', 'ROLE_MANAGER'],
    }
  },
];

export default dashboardComponentRoute;
