stateconfig.js 2.7 KB
Newer Older
1
// Copyright 2017 The Kubernetes Authors.
D
Denis Poisson 已提交
2 3 4 5 6 7 8 9 10 11 12 13 14
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

S
Sebastian Florek 已提交
15 16 17
import {actionbarViewName, stateName as chromeStateName} from '../../chrome/state';
import {breadcrumbsConfig} from '../../common/components/breadcrumbs/service';
import {appendDetailParamsToUrl} from '../../common/resource/resourcedetail';
M
Marcin Maciaszczyk 已提交
18

S
Sebastian Florek 已提交
19 20
import {stateName as podList} from '../list/state';
import {stateName as parentState, stateUrl} from '../state';
21
import {ActionBarController} from './actionbar_controller';
S
Sebastian Florek 已提交
22
import {PodDetailController} from './controller';
D
Denis Poisson 已提交
23 24

/**
S
Sebastian Florek 已提交
25
 * Config state object for the Pod detail view.
D
Denis Poisson 已提交
26
 *
S
Sebastian Florek 已提交
27
 * @type {!ui.router.StateConfig}
D
Denis Poisson 已提交
28
 */
S
Sebastian Florek 已提交
29 30
export const config = {
  url: appendDetailParamsToUrl(stateUrl),
31
  parent: parentState,
S
Sebastian Florek 已提交
32 33 34 35 36 37 38 39
  resolve: {
    'podDetailResource': getPodDetailResource,
    'podDetail': getPodDetail,
  },
  data: {
    [breadcrumbsConfig]: {
      'label': '{{$stateParams.objectName}}',
      'parent': podList,
D
Denis Poisson 已提交
40
    },
S
Sebastian Florek 已提交
41 42 43 44 45 46
  },
  views: {
    '': {
      controller: PodDetailController,
      controllerAs: 'ctrl',
      templateUrl: 'pod/detail/detail.html',
D
Denis Poisson 已提交
47
    },
48
    [`${actionbarViewName}@${chromeStateName}`]: {
S
Sebastian Florek 已提交
49 50 51
      controller: ActionBarController,
      controllerAs: '$ctrl',
      templateUrl: 'pod/detail/actionbar.html',
D
Denis Poisson 已提交
52
    },
S
Sebastian Florek 已提交
53 54 55 56 57 58 59 60 61 62
  },
};

/**
 * @param {!angular.$resource} $resource
 * @return {!angular.Resource}
 * @ngInject
 */
export function podEventsResource($resource) {
  return $resource('api/v1/pod/:namespace/:name/event');
D
Denis Poisson 已提交
63 64 65
}

/**
S
Sebastian Florek 已提交
66
 * @param {!./../../common/resource/resourcedetail.StateParams} $stateParams
D
Denis Poisson 已提交
67
 * @param {!angular.$resource} $resource
S
Sebastian Florek 已提交
68
 * @return {!angular.Resource}
D
Denis Poisson 已提交
69 70 71
 * @ngInject
 */
export function getPodDetailResource($resource, $stateParams) {
B
bryk 已提交
72
  return $resource(`api/v1/pod/${$stateParams.objectNamespace}/${$stateParams.objectName}`);
D
Denis Poisson 已提交
73 74 75
}

/**
S
Sebastian Florek 已提交
76
 * @param {!angular.Resource} podDetailResource
D
Denis Poisson 已提交
77 78 79 80 81 82
 * @return {!angular.$q.Promise}
 * @ngInject
 */
export function getPodDetail(podDetailResource) {
  return podDetailResource.get().$promise;
}
83 84 85 86 87 88 89 90 91

/**
 * @param {!angular.$resource} $resource
 * @return {!angular.Resource}
 * @ngInject
 */
export function podPersistentVolumeClaimsResource($resource) {
  return $resource(`api/v1/pod/:namespace/:name/persistentvolumeclaim`);
}