提交 f878ab33 编写于 作者: P Piotr Bryk 提交者: Marcin Maciaszczyk

Config map details and list frontend (#1019)

上级 de4232ce
......@@ -481,4 +481,16 @@
<translation id="4032745949688106366" key="MSG_PORT_MAPPINGS_PORT_EMPTY_WARNING" source="/Users/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="This warning appears when the user specifies an empty port.">Port cannot be empty</translation>
<translation id="1976944901672561616" key="MSG_PORT_MAPPINGS_TARGET_PORT_EMPTY_WARNING" source="/Users/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="This warning appears when the user specifies an empty target port.">Target port cannot be empty</translation>
<translation id="712304056244084010" key="MSG_LOGS_FONT_SIZE_LABEL" source="/home/maciaszczykm/workspace/dashboard/.tmp/serve/app-dev.js" desc="Label 'Font size' on the toolbar of the logs page. Ends with colon.">Font size:</translation>
<translation id="3212328899649855136" key="MSG_BREADCRUMBS_CONFIG_MAPS_LABEL" source="/usr/local/google/home/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Label 'Config Maps' that appears as a breadcrumbs on the action bar.">Config Maps</translation>
<translation id="8099933273342853319" key="MSG_CONFIG_MAP_DETAIL_CONFIG_MAP_LABEL" source="/usr/local/google/home/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Label 'Config Map' which appears at the top of the delete dialog, opened from a config map details page.">Config Map</translation>
<translation id="8701051638018097742" key="MSG_CONFIG_MAP_INFO_DATA_SECTION" source="/usr/local/google/home/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Config map info details section name.">Data</translation>
<translation id="2091041876152209152" key="MSG_CONFIG_MAP_INFO_DETAILS_SECTION" source="/usr/local/google/home/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Config map info details section name.">Details</translation>
<translation id="4363261291725330828" key="MSG_CONFIG_MAP_INFO_NAME_ENTRY" source="/usr/local/google/home/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Config map info details section name entry.">Name</translation>
<translation id="7011542908669537169" key="MSG_CONFIG_MAP_INFO_NAMESPACE_ENTRY" source="/usr/local/google/home/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Config map info details section namespace entry.">Namespace</translation>
<translation id="2270101948850564235" key="MSG_CONFIG_MAP_INFO_LABELS_ENTRY" source="/usr/local/google/home/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Config map info details section labels entry.">Labels</translation>
<translation id="9181886817358182792" key="MSG_CONFIG_MAP_LIST_CREATED_AT_TOOLTIP" source="/usr/local/google/home/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Tooltip 'Created at [some date]' showing the exact creation time of config map.">Created at <ph name="CREATION_DATE" /></translation>
<translation id="4378004401906214903" key="MSG_CONFIG_MAP_LIST_CONFIG_MAP_LABEL" source="/usr/local/google/home/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Label 'Config Map' which will appear in the config map delete dialog opened from a config map card on the list page.">Config Map</translation>
<translation id="3616985890724187653" key="MSG_CONFIG_MAP_LIST_HEADER_NAME" source="/usr/local/google/home/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Pet set list header: name.">Name</translation>
<translation id="4209685907033468465" key="MSG_CONFIG_MAP_LIST_HEADER_LABELS" source="/usr/local/google/home/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Pet set list header: labels.">Labels</translation>
<translation id="5177068392612742589" key="MSG_CONFIG_MAP_LIST_HEADER_AGE" source="/usr/local/google/home/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Pet set list header: age.">Age</translation>
</translationbundle>
\ No newline at end of file
......@@ -670,4 +670,16 @@
<translation id="4032745949688106366" key="MSG_PORT_MAPPINGS_PORT_EMPTY_WARNING" source="/Users/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="This warning appears when the user specifies an empty port.">Port cannot be empty</translation>
<translation id="1976944901672561616" key="MSG_PORT_MAPPINGS_TARGET_PORT_EMPTY_WARNING" source="/Users/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="This warning appears when the user specifies an empty target port.">Target port cannot be empty</translation>
<translation id="712304056244084010" key="MSG_LOGS_FONT_SIZE_LABEL" source="/home/maciaszczykm/workspace/dashboard/.tmp/serve/app-dev.js" desc="Label 'Font size' on the toolbar of the logs page. Ends with colon.">Font size:</translation>
<translation id="3212328899649855136" key="MSG_BREADCRUMBS_CONFIG_MAPS_LABEL" source="/usr/local/google/home/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Label 'Config Maps' that appears as a breadcrumbs on the action bar.">Config Maps</translation>
<translation id="8099933273342853319" key="MSG_CONFIG_MAP_DETAIL_CONFIG_MAP_LABEL" source="/usr/local/google/home/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Label 'Config Map' which appears at the top of the delete dialog, opened from a config map details page.">Config Map</translation>
<translation id="8701051638018097742" key="MSG_CONFIG_MAP_INFO_DATA_SECTION" source="/usr/local/google/home/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Config map info details section name.">Data</translation>
<translation id="2091041876152209152" key="MSG_CONFIG_MAP_INFO_DETAILS_SECTION" source="/usr/local/google/home/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Config map info details section name.">Details</translation>
<translation id="4363261291725330828" key="MSG_CONFIG_MAP_INFO_NAME_ENTRY" source="/usr/local/google/home/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Config map info details section name entry.">Name</translation>
<translation id="7011542908669537169" key="MSG_CONFIG_MAP_INFO_NAMESPACE_ENTRY" source="/usr/local/google/home/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Config map info details section namespace entry.">Namespace</translation>
<translation id="2270101948850564235" key="MSG_CONFIG_MAP_INFO_LABELS_ENTRY" source="/usr/local/google/home/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Config map info details section labels entry.">Labels</translation>
<translation id="9181886817358182792" key="MSG_CONFIG_MAP_LIST_CREATED_AT_TOOLTIP" source="/usr/local/google/home/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Tooltip 'Created at [some date]' showing the exact creation time of config map.">Created at <ph name="CREATION_DATE" /></translation>
<translation id="4378004401906214903" key="MSG_CONFIG_MAP_LIST_CONFIG_MAP_LABEL" source="/usr/local/google/home/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Label 'Config Map' which will appear in the config map delete dialog opened from a config map card on the list page.">Config Map</translation>
<translation id="3616985890724187653" key="MSG_CONFIG_MAP_LIST_HEADER_NAME" source="/usr/local/google/home/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Pet set list header: name.">Name</translation>
<translation id="4209685907033468465" key="MSG_CONFIG_MAP_LIST_HEADER_LABELS" source="/usr/local/google/home/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Pet set list header: labels.">Labels</translation>
<translation id="5177068392612742589" key="MSG_CONFIG_MAP_LIST_HEADER_AGE" source="/usr/local/google/home/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Pet set list header: age.">Age</translation>
</translationbundle>
\ No newline at end of file
......@@ -281,6 +281,31 @@ backendApi.PetSetDetail;
*/
backendApi.PetSetList;
/**
* @typedef {{
* objectMeta: !backendApi.ObjectMeta,
* typeMeta: !backendApi.TypeMeta,
* }}
*/
backendApi.ConfigMap;
/**
* @typedef {{
* objectMeta: !backendApi.ObjectMeta,
* typeMeta: !backendApi.TypeMeta,
* data: !Object<string, string>,
* }}
*/
backendApi.ConfigMapDetail;
/**
* @typedef {{
* items: !Array<!backendApi.ConfigMap>,
* listMeta: !backendApi.ListMeta
* }}
*/
backendApi.ConfigMapList;
/**
* @typedef {{
* objectMeta: !backendApi.ObjectMeta,
......
<!--
Copyright 2015 Google Inc. All Rights Reserved.
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.
-->
<kd-actionbar-detail-buttons
resource-kind-name="{{::$ctrl.i18n.MSG_CONFIG_MAP_DETAIL_CONFIG_MAP_LABEL}}"
type-meta="$ctrl.details.typeMeta"
object-meta="$ctrl.details.objectMeta">
</kd-actionbar-detail-buttons>
// Copyright 2015 Google Inc. All Rights Reserved.
//
// 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.
/**
* @final
*/
export class ActionBarController {
/**
* @param {!backendApi.ConfigMapDetail} configMapDetail
* @ngInject
*/
constructor(configMapDetail) {
/** @export {!backendApi.ConfigMapDetail} */
this.details = configMapDetail;
/** @export */
this.i18n = i18n;
}
}
const i18n = {
/** @export {string} @desc Label 'Config Map' which appears at the top of the
delete dialog, opened from a config map details page. */
MSG_CONFIG_MAP_DETAIL_CONFIG_MAP_LABEL: goog.getMsg('Config Map'),
};
<!--
Copyright 2015 Google Inc. All Rights Reserved.
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.
-->
<div layout="column">
<kd-config-map-info config-map="::$ctrl.configMapDetail"></kd-config-map-info>
<kd-info-card>
<kd-info-card-section name="{{::$ctrl.i18n.MSG_CONFIG_MAP_INFO_DATA_SECTION}}">
<kd-info-card-entry ng-repeat="(key, value) in ::$ctrl.configMapDetail.data"
title="{{::key}}">
<pre>{{::value}}</pre>
</kd-info-card-entry>
</kd-info-card-section>
</kd-info-card>
</div>
// Copyright 2015 Google Inc. All Rights Reserved.
//
// 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.
/**
* @final
*/
export class ConfigMapDetailController {
/**
* @param {!backendApi.ConfigMapDetail} configMapDetail
* @ngInject
*/
constructor(configMapDetail) {
/** @export {!backendApi.ConfigMapDetail} */
this.configMapDetail = configMapDetail;
/** @export */
this.i18n = i18n;
}
}
const i18n = {
/** @export {string} @desc Config map info details section name. */
MSG_CONFIG_MAP_INFO_DATA_SECTION: goog.getMsg('Data'),
};
// Copyright 2015 Google Inc. All Rights Reserved.
//
// 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.
import chromeModule from 'chrome/chrome_module';
import componentsModule from 'common/components/components_module';
import eventsModule from 'events/events_module';
import filtersModule from 'common/filters/filters_module';
import stateConfig from './configmapdetail_stateconfig';
import {configMapInfoComponent} from './configmapinfo_component';
/**
* Angular module for the Config Map details view.
*
* The view shows detailed view of a Config Map.
*/
export default angular
.module(
'kubernetesDashboard.configMapDetail',
[
'ngMaterial',
'ngResource',
'ui.router',
componentsModule.name,
filtersModule.name,
eventsModule.name,
chromeModule.name,
])
.config(stateConfig)
.component('kdConfigMapInfo', configMapInfoComponent);
// Copyright 2015 Google Inc. All Rights Reserved.
//
// 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.
/** Name of the state. Can be used in, e.g., $state.go method. */
export const stateName = 'configmapdetail';
// Copyright 2015 Google Inc. All Rights Reserved.
//
// 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.
import {actionbarViewName, stateName as chromeStateName} from 'chrome/chrome_state';
import {breadcrumbsConfig} from 'common/components/breadcrumbs/breadcrumbs_service';
import {appendDetailParamsToUrl} from 'common/resource/resourcedetail';
import {stateName as configMapList, stateUrl} from 'configmaplist/configmaplist_state';
import {ActionBarController} from './actionbar_controller';
import {ConfigMapDetailController} from './configmapdetail_controller';
import {stateName} from './configmapdetail_state';
/**
* Configures states for the config map details view.
*
* @param {!ui.router.$stateProvider} $stateProvider
* @ngInject
*/
export default function stateConfig($stateProvider) {
$stateProvider.state(stateName, {
url: appendDetailParamsToUrl(stateUrl),
parent: chromeStateName,
resolve: {
'configMapDetailResource': getConfigMapDetailResource,
'configMapDetail': getConfigMapDetail,
},
data: {
[breadcrumbsConfig]: {
'label': '{{$stateParams.objectName}}',
'parent': configMapList,
},
},
views: {
'': {
controller: ConfigMapDetailController,
controllerAs: '$ctrl',
templateUrl: 'configmapdetail/configmapdetail.html',
},
[actionbarViewName]: {
controller: ActionBarController,
controllerAs: '$ctrl',
templateUrl: 'configmapdetail/actionbar.html',
},
},
});
}
/**
* @param {!./../common/resource/resourcedetail.StateParams} $stateParams
* @param {!angular.$resource} $resource
* @return {!angular.Resource<!backendApi.ConfigMapDetail>}
* @ngInject
*/
export function getConfigMapDetailResource($resource, $stateParams) {
return $resource(`api/v1/configmap/${$stateParams.objectNamespace}/${$stateParams.objectName}`);
}
/**
* @param {!angular.Resource<!backendApi.ConfigMapDetail>} configMapDetailResource
* @return {!angular.$q.Promise}
* @ngInject
*/
export function getConfigMapDetail(configMapDetailResource) {
return configMapDetailResource.get().$promise;
}
<!--
Copyright 2015 Google Inc. All Rights Reserved.
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.
-->
<kd-info-card>
<kd-info-card-section name="{{::$ctrl.i18n.MSG_CONFIG_MAP_INFO_DETAILS_SECTION}}">
<kd-info-card-entry title="{{::$ctrl.i18n.MSG_CONFIG_MAP_INFO_NAME_ENTRY}}">
<kd-middle-ellipsis
display-string="{{::$ctrl.configMap.objectMeta.name}}">
</kd-middle-ellipsis>
</kd-info-card-entry>
<kd-info-card-entry title="{{::$ctrl.i18n.MSG_CONFIG_MAP_INFO_NAMESPACE_ENTRY}}">
{{::$ctrl.configMap.objectMeta.namespace}}
</kd-info-card-entry>
<kd-info-card-entry title="{{::$ctrl.i18n.MSG_CONFIG_MAP_INFO_LABELS_ENTRY}}">
<kd-labels labels="::$ctrl.configMap.objectMeta.labels"></kd-labels>
</kd-info-card-entry>
</kd-info-card-section>
</kd-info-card>
// Copyright 2015 Google Inc. All Rights Reserved.
//
// 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.
/**
* @final
*/
export default class ConfigMapInfoController {
/**
* Constructs pettion controller info object.
*/
constructor() {
/**
* Config map details. Initialized from the scope.
* @export {!backendApi.ConfigMapDetail}
*/
this.configMap;
/** @export */
this.i18n = i18n;
}
}
/**
* Definition object for the component that displays config map info.
*
* @return {!angular.Directive}
*/
export const configMapInfoComponent = {
controller: ConfigMapInfoController,
templateUrl: 'configmapdetail/configmapinfo.html',
bindings: {
/** {!backendApi.ConfigMapDetail} */
'configMap': '=',
},
};
const i18n = {
/** @export {string} @desc Config map info details section name. */
MSG_CONFIG_MAP_INFO_DETAILS_SECTION: goog.getMsg('Details'),
/** @export {string} @desc Config map info details section name entry. */
MSG_CONFIG_MAP_INFO_NAME_ENTRY: goog.getMsg('Name'),
/** @export {string} @desc Config map info details section namespace entry. */
MSG_CONFIG_MAP_INFO_NAMESPACE_ENTRY: goog.getMsg('Namespace'),
/** @export {string} @desc Config map info details section labels entry. */
MSG_CONFIG_MAP_INFO_LABELS_ENTRY: goog.getMsg('Labels'),
};
<!--
Copyright 2015 Google Inc. All Rights Reserved.
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.
-->
<kd-actionbar-list-buttons></kd-actionbar-list-buttons>
<!--
Copyright 2015 Google Inc. All Rights Reserved.
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.
-->
<kd-resource-card object-meta="$ctrl.configMap.objectMeta" type-meta="$ctrl.configMap.typeMeta">
<kd-resource-card-columns>
<kd-resource-card-column>
<div>
<a ng-href="{{::$ctrl.getConfigMapDetailHref()}}" class="kd-middle-ellipsised-link">
<kd-middle-ellipsis display-string="{{$ctrl.configMap.objectMeta.name}}">
</kd-middle-ellipsis>
</a>
</div>
</kd-resource-card-column>
<kd-resource-card-column>
<kd-labels labels="::$ctrl.configMap.objectMeta.labels"></kd-labels>
</kd-resource-card-column>
<kd-resource-card-column>
{{::$ctrl.configMap.objectMeta.creationTimestamp | relativeTime}}
<md-tooltip>
{{::$ctrl.getCreatedAtTooltip($ctrl.configMap.objectMeta.creationTimestamp)}}
</md-tooltip>
</kd-resource-card-column>
<kd-resource-card-column class="kd-row-layout-column kd-icon-column">
<kd-resource-card-menu>
<kd-resource-card-delete-menu-item
resource-kind-name="{{::$ctrl.i18n.MSG_CONFIG_MAP_LIST_CONFIG_MAP_LABEL}}">
</kd-resource-card-delete-menu-item>
<kd-resource-card-edit-menu-item
resource-kind-name="{{::$ctrl.i18n.MSG_CONFIG_MAP_LIST_CONFIG_MAP_LABEL}}">
</kd-resource-card-edit-menu-item>
</kd-resource-card-menu>
</kd-resource-card-column>
</kd-resource-card-columns>
</kd-resource-card>
// Copyright 2015 Google Inc. All Rights Reserved.
//
// 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.
import {StateParams} from 'common/resource/resourcedetail';
import {stateName} from 'configmapdetail/configmapdetail_state';
/**
* Controller for the config map card.
*
* @final
*/
export default class ConfigMapCardController {
/**
* @param {!ui.router.$state} $state
* @param {!angular.$interpolate} $interpolate
* @ngInject
*/
constructor($state, $interpolate) {
/**
* Initialized from the scope.
* @export {!backendApi.ConfigMap}
*/
this.configMap;
/** @private {!ui.router.$state} */
this.state_ = $state;
/** @private */
this.interpolate_ = $interpolate;
/** @export */
this.i18n = i18n;
}
/**
* @return {string}
* @export
*/
getConfigMapDetailHref() {
return this.state_.href(
stateName,
new StateParams(this.configMap.objectMeta.namespace, this.configMap.objectMeta.name));
}
/**
* @export
* @param {string} creationDate - creation date of the config map
* @return {string} localized tooltip with the formated creation date
*/
getCreatedAtTooltip(creationDate) {
let filter = this.interpolate_(`{{date | date:'short'}}`);
/** @type {string} @desc Tooltip 'Created at [some date]' showing the exact creation time of
* config map. */
let MSG_CONFIG_MAP_LIST_CREATED_AT_TOOLTIP =
goog.getMsg('Created at {$creationDate}', {'creationDate': filter({'date': creationDate})});
return MSG_CONFIG_MAP_LIST_CREATED_AT_TOOLTIP;
}
}
/**
* @return {!angular.Component}
*/
export const configMapCardComponent = {
bindings: {
'configMap': '=',
},
controller: ConfigMapCardController,
templateUrl: 'configmaplist/configmapcard.html',
};
const i18n = {
/** @export {string} @desc Label 'Config Map' which will appear in the config map
delete dialog opened from a config map card on the list page. */
MSG_CONFIG_MAP_LIST_CONFIG_MAP_LABEL: goog.getMsg('Config Map'),
};
<!--
Copyright 2015 Google Inc. All Rights Reserved.
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.
-->
<kd-resource-card-list selectable="false" with-statuses="false">
<kd-resource-card-header-columns>
<kd-resource-card-header-column grow="2">
{{::$ctrl.i18n.MSG_CONFIG_MAP_LIST_HEADER_NAME}}
</kd-resource-card-header-column>
<kd-resource-card-header-column grow="2">
{{::$ctrl.i18n.MSG_CONFIG_MAP_LIST_HEADER_LABELS}}
</kd-resource-card-header-column>
<kd-resource-card-header-column grow="nogrow" size="small">
{{::$ctrl.i18n.MSG_CONFIG_MAP_LIST_HEADER_AGE}}
</kd-resource-card-header-column>
<kd-resource-card-header-column size="small" grow="nogrow">
</kd-resource-card-header-column>
</kd-resource-card-header-columns>
<kd-config-map-card dir-paginate="configMap in $ctrl.configMapList.items | itemsPerPage: default"
config-map="configMap" pagination-id="configmaps">
</kd-config-map-card>
<kd-resource-card-list-footer>
<kd-resource-card-list-pagination pagination-id="configmaps" list="$ctrl.configMapList">
</kd-resource-card-list-pagination>
</kd-resource-card-list-footer>
</kd-resource-card-list>
// Copyright 2015 Google Inc. All Rights Reserved.
//
// 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.
/**
* Controller for config map card list.
*
* @final
*/
export class ConfigMapCardListController {
/**
* @ngInject
*/
constructor() {
/** @export */
this.i18n = i18n;
}
}
/**
* @return {!angular.Component}
*/
export const configMapCardListComponent = {
transclude: true,
controller: ConfigMapCardListController,
bindings: {
'configMapList': '<',
},
templateUrl: 'configmaplist/configmapcardlist.html',
};
const i18n = {
/** @export {string} @desc Pet set list header: name. */
MSG_CONFIG_MAP_LIST_HEADER_NAME: goog.getMsg('Name'),
/** @export {string} @desc Pet set list header: labels. */
MSG_CONFIG_MAP_LIST_HEADER_LABELS: goog.getMsg('Labels'),
/** @export {string} @desc Pet set list header: age. */
MSG_CONFIG_MAP_LIST_HEADER_AGE: goog.getMsg('Age'),
};
<!--
Copyright 2015 Google Inc. All Rights Reserved.
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.
-->
<kd-content-card ng-if="!$ctrl.shouldShowZeroState()">
<kd-content>
<kd-config-map-card-list config-map-list="$ctrl.configMapList">
</kd-config-map-card-list>
</kd-content>
</kd-content-card>
<kd-zero-state ng-if="$ctrl.shouldShowZeroState()"></kd-zero-state>
// Copyright 2015 Google Inc. All Rights Reserved.
//
// 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.
/**
* Controller for the config map list view.
*
* @final
*/
export class ConfigMapListController {
/**
* @param {!backendApi.ConfigMapList} configMapList
* @ngInject
*/
constructor(configMapList) {
/** @export {!backendApi.ConfigMapList} */
this.configMapList = configMapList;
}
/**
* @return {boolean}
* @export
*/
shouldShowZeroState() { return this.configMapList.items.length === 0; }
}
// Copyright 2015 Google Inc. All Rights Reserved.
//
// 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.
import stateConfig from './configmaplist_stateconfig';
import filtersModule from 'common/filters/filters_module';
import componentsModule from 'common/components/components_module';
import chromeModule from 'chrome/chrome_module';
import configMapDetailModule from 'configmapdetail/configmapdetail_module';
import {configMapCardComponent} from './configmapcard_component';
import {configMapCardListComponent} from './configmapcardlist_component';
/**
* Angular module for the Config Map list view.
*/
export default angular
.module(
'kubernetesDashboard.configMapList',
[
'ngMaterial',
'ngResource',
'ui.router',
filtersModule.name,
componentsModule.name,
configMapDetailModule.name,
chromeModule.name,
])
.config(stateConfig)
.component('kdConfigMapCardList', configMapCardListComponent)
.component('kdConfigMapCard', configMapCardComponent);
// Copyright 2015 Google Inc. All Rights Reserved.
//
// 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.
/** Name of the state. Can be used in, e.g., $state.go method. */
export const stateName = 'configmap';
/** Absolute URL of the state. */
export const stateUrl = '/configmap';
// Copyright 2015 Google Inc. All Rights Reserved.
//
// 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.
import {actionbarViewName, stateName as chromeStateName} from 'chrome/chrome_state';
import {breadcrumbsConfig} from 'common/components/breadcrumbs/breadcrumbs_service';
import {stateName as workloadsState} from 'workloads/workloads_state';
import {ConfigMapListController} from './configmaplist_controller';
import {stateName, stateUrl} from './configmaplist_state';
/**
* Configures states for the config map list view.
*
* @param {!ui.router.$stateProvider} $stateProvider
* @ngInject
*/
export default function stateConfig($stateProvider) {
$stateProvider.state(stateName, {
url: stateUrl,
parent: chromeStateName,
resolve: {
'configMapList': resolveConfigMapList,
},
data: {
[breadcrumbsConfig]: {
'label': i18n.MSG_BREADCRUMBS_CONFIG_MAPS_LABEL,
'parent': workloadsState,
},
},
views: {
'': {
controller: ConfigMapListController,
controllerAs: '$ctrl',
templateUrl: 'configmaplist/configmaplist.html',
},
[actionbarViewName]: {
templateUrl: 'configmaplist/actionbar.html',
},
},
});
}
/**
* @param {!angular.$resource} $resource
* @param {!./../chrome/chrome_state.StateParams} $stateParams
* @return {!angular.$q.Promise}
* @ngInject
*/
export function resolveConfigMapList($resource, $stateParams) {
/** @type {!angular.Resource<!backendApi.ConfigMapList>} */
let resource = $resource(`api/v1/configmap/${$stateParams.namespace || ''}`);
return resource.get().$promise;
}
const i18n = {
/** @type {string} @desc Label 'Config Maps' that appears as a breadcrumbs on the action bar. */
MSG_BREADCRUMBS_CONFIG_MAPS_LABEL: goog.getMsg('Config Maps'),
};
......@@ -34,6 +34,8 @@ import serviceListModule from './servicelist/servicelist_module';
import workloadsModule from './workloads/workloads_module';
import podDetailModule from './poddetail/poddetail_module';
import petSetListModule from './petsetlist/petsetlist_module';
import configMapListModule from './configmaplist/configmaplist_module';
import configMapDetailModule from './configmapdetail/configmapdetail_module';
export default angular
.module(
......@@ -62,6 +64,8 @@ export default angular
serviceListModule.name,
podDetailModule.name,
petSetListModule.name,
configMapListModule.name,
configMapDetailModule.name,
])
.config(indexConfig)
.config(routeConfig);
// Copyright 2015 Google Inc. All Rights Reserved.
//
// 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.
import {ActionBarController} from 'configmapdetail/actionbar_controller';
import module from 'configmapdetail/configmapdetail_module';
describe('Action Bar controller', () => {
/** @type {!ActionBarController} */
let ctrl;
let details = {};
beforeEach(() => {
angular.mock.module(module.name);
angular.mock.inject(
($controller) => { ctrl = $controller(ActionBarController, {configMapDetail: details}); });
});
it('should initialize details', () => { expect(ctrl.details).toBe(details); });
});
// Copyright 2015 Google Inc. All Rights Reserved.
//
// 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.
import {ConfigMapDetailController} from 'configmapdetail/configmapdetail_controller';
import configMapDetailModule from 'configmapdetail/configmapdetail_module';
describe('Config Map Detail controller', () => {
beforeEach(() => { angular.mock.module(configMapDetailModule.name); });
it('should initialize config map controller', angular.mock.inject(($controller) => {
let data = {};
/** @type {!ConfigMapDetailController} */
let ctrl = $controller(ConfigMapDetailController, {configMapDetail: data});
expect(ctrl.configMapDetail).toBe(data);
}));
});
// Copyright 2015 Google Inc. All Rights Reserved.
//
// 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.
import configMapDetailModule from 'configmapdetail/configmapdetail_module';
describe('Config Map Info controller', () => {
/** @type {!ConfigMapInfoController} */
let ctrl;
beforeEach(() => {
angular.mock.module(configMapDetailModule.name);
angular.mock.inject(($componentController, $rootScope) => {
ctrl = $componentController('kdConfigMapInfo', {$scope: $rootScope}, {
configMap: {
data: {foo: 'bar'},
},
});
});
});
it('should initialize the ctrl', () => { expect(ctrl.i18n).not.toBeUndefined(); });
});
// Copyright 2015 Google Inc. All Rights Reserved.
//
// 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.
import configMapListModule from 'configmaplist/configmaplist_module';
describe('Config Map card', () => {
/** @type {!configmaplist/configmapcard_component.ConfigMapCardController} */
let ctrl;
beforeEach(() => {
angular.mock.module(configMapListModule.name);
angular.mock.inject(($componentController, $rootScope) => {
ctrl = $componentController('kdConfigMapCard', {$scope: $rootScope});
});
});
it('should get details href', () => {
ctrl.configMap = {
objectMeta: {
namespace: 'foo',
name: 'bar',
},
};
expect(ctrl.getConfigMapDetailHref()).toBe('#/configmap/foo/bar');
});
it('should format the "created at" tooltip correctly', () => {
expect(ctrl.getCreatedAtTooltip('2016-06-06T09:13:12Z')).toMatch('Created at 6/6/16.*');
});
});
// Copyright 2015 Google Inc. All Rights Reserved.
//
// 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.
import configMapListModule from 'configmaplist/configmaplist_module';
describe('Config Map card list', () => {
/** @type {!configmaplist/configmapcard_component.ConfigMapCardListController} */
let ctrl;
beforeEach(() => {
angular.mock.module(configMapListModule.name);
angular.mock.inject(($componentController, $rootScope) => {
ctrl = $componentController('kdConfigMapCardList', {$scope: $rootScope});
});
});
it('should init i18n', () => { expect(ctrl.i18n).not.toBeUndefined(); });
});
// Copyright 2015 Google Inc. All Rights Reserved.
//
// 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.
import {ConfigMapListController} from 'configmaplist/configmaplist_controller';
import configMapListModule from 'configmaplist/configmaplist_module';
describe('Config Map list controller', () => {
/** @type {!configmaplist/configmaplist_controller.ConfigMapListController} */
let ctrl;
beforeEach(() => {
angular.mock.module(configMapListModule.name);
angular.mock.inject(($controller) => {
ctrl = $controller(ConfigMapListController, {configMapList: {items: []}});
});
});
it('should initialize config map controller', angular.mock.inject(($controller) => {
let ctrls = {};
/** @type {!ConfigMapListController} */
let ctrl = $controller(ConfigMapListController, {configMapList: {items: ctrls}});
expect(ctrl.configMapList.items).toBe(ctrls);
}));
it('should show zero state', () => { expect(ctrl.shouldShowZeroState()).toBe(true); });
it('should hide zero state', () => {
// given
ctrl.configMapList = {items: ['mock']};
// then
expect(ctrl.shouldShowZeroState()).toBe(false);
});
});
// Copyright 2015 Google Inc. All Rights Reserved.
//
// 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.
import configMapListModule from 'configmaplist/configmaplist_module';
import {resolveConfigMapList} from 'configmaplist/configmaplist_stateconfig';
describe('StateConfig for config map controller list', () => {
beforeEach(() => { angular.mock.module(configMapListModule.name); });
it('should resolve config map list with namespace', angular.mock.inject(($q) => {
let promise = $q.defer().promise;
let resource = jasmine.createSpy('$resource');
resource.and.returnValue({get: function() { return {$promise: promise}; }});
let actual = resolveConfigMapList(resource, {});
expect(resource).toHaveBeenCalledWith('api/v1/configmap/');
expect(actual).toBe(promise);
}));
it('should resolve config map list with no namespace', angular.mock.inject(($q) => {
let promise = $q.defer().promise;
let resource = jasmine.createSpy('$resource');
resource.and.returnValue({get: function() { return {$promise: promise}; }});
let actual = resolveConfigMapList(resource, {namespace: 'foo'});
expect(resource).toHaveBeenCalledWith('api/v1/configmap/foo');
expect(actual).toBe(promise);
}));
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册