提交 791e3f97 编写于 作者: P Piotr Bryk

Merge branch 'master' into show-pods-stats-desired

......@@ -60,6 +60,9 @@ type ReplicaSetPod struct {
// Name of the Pod.
Name string `json:"name"`
// Status of the Pod. See Kubernetes API for reference.
PodPhase api.PodPhase `json:"podPhase"`
// Time the Pod has started. Empty if not started.
StartTime *unversioned.Time `json:"startTime"`
......@@ -155,6 +158,7 @@ func GetReplicaSetDetail(client *client.Client, namespace, name string) (*Replic
for _, pod := range pods.Items {
podDetail := ReplicaSetPod{
Name: pod.Name,
PodPhase: pod.Status.Phase,
StartTime: pod.Status.StartTime,
PodIP: pod.Status.PodIP,
NodeName: pod.Spec.NodeName,
......
......@@ -131,6 +131,7 @@ backendApi.ReplicaSetSpec;
* @typedef {{
* name: string,
* startTime: ?string,
* status: string,
* podIP: string,
* nodeName: string,
* restartCount: number
......@@ -180,7 +181,7 @@ backendApi.PodContainer;
/**
* @typedef {{
* name: string,
* startTime: string,
* startTime: ?string,
* totalRestartCount: number,
* podContainers: !Array<!backendApi.PodContainer>
* }}
......
......@@ -34,7 +34,7 @@ limitations under the License.
<deploy-from-settings ng-switch-when="Settings" name="ctrl.name"
namespaces="ctrl.namespaces" detail="ctrl.detail" form="ctrl.deployForm">
</deploy-from-settings>
<deploy-from-file ng-switch-when="File" name="ctrl.name" detail="ctrl.detail">
<deploy-from-file ng-switch-when="File" name="ctrl.name" detail="ctrl.detail" form="ctrl.deployForm">
</deploy-from-file>
</div>
......
......@@ -30,7 +30,8 @@ export default class DeployFromFileController {
/**
* Custom file model for the selected file
*
* @export {{name:string, content:string}} */
* @export {{name:string, content:string}}
*/
this.file = {name: '', content: ''};
}
}
......@@ -19,9 +19,10 @@ export default function deployFromFileDirective() {
scope: {},
bindToController: {
'detail': '=',
'form': '=',
},
controller: DeployFromFileController,
controllerAs: 'ctrl',
template: '<kd-upload file="ctrl.file"></kd-upload>',
template: '<kd-upload file="ctrl.file" form="ctrl.form"></kd-upload>',
};
}
......@@ -17,10 +17,14 @@ limitations under the License.
<kd-help-section>
<div layout="row" layout-align="space-between start">
<div flex>
<md-input-container class="md-block">
<md-input-container class="md-block" md-is-error="ctrl.isFileNameError()">
<label>YAML or JSON file</label>
<!--TODO: Browse file on focus doesn't work in Firefox. It is to be investigated.-->
<input ng-model="ctrl.file.name" ng-focus="ctrl.browseFile()" ng-readonly="true" />
<input ng-model="ctrl.file.name" ng-focus="ctrl.browseFile()" ng-readonly="true" name="fileName" required/>
<ng-messages for="ctrl.form.fileName.$error" role="alert" multiple>
<ng-message when="required">File is required.</ng-message>
</ng-message>
</ng-messages>
</md-input-container>
</div>
<md-button type="button" class="md-raised kd-upload-button" ng-click="ctrl.browseFile()">
......
......@@ -29,6 +29,12 @@ export default class UploadController {
* Initialized from the registerBrowseFileFunction method.
* @private {(function())|undefined} */
this.browseFileFunc_;
/**
* Initialized from the scope.
* @export {!angular.FormController}
*/
this.form;
}
/**
......@@ -53,4 +59,16 @@ export default class UploadController {
this.browseFileFunc_();
}
}
/**
* Used to deactivate the invalid file name report if the form is not submitted yet.
*
* @returns {boolean}
* @export
*/
isFileNameError() {
/** @type {!angular.NgModelController} */
let fileName = this.form['fileName'];
return this.form.$submitted && fileName.$invalid;
}
}
......@@ -25,6 +25,7 @@ export default function uploadDirective() {
scope: {},
bindToController: {
'file': '=',
'form': '=',
},
controller: UploadController,
controllerAs: 'ctrl',
......
......@@ -35,12 +35,19 @@ limitations under the License.
</md-option>
</md-select>
</div>
<span class="kd-logs-toolbar-text" flex>Running since {{ctrl.podCreationTime}}</span>
<span class="kd-logs-toolbar-text" flex>
<span ng-if="ctrl.podCreationTime">
Running since {{ctrl.podCreationTime | date:'short'}}
</span>
<span ng-if="!ctrl.podCreationTime">
Not running
</span>
</span>
<span flex></span>
<md-button class="kd-icon-button" id="colorText"
ng-click="ctrl.onTextColorChange()">
<md-icon md-font-library="material-icons"
ng-class=ctrl.getStyleClass()>
ng-class="ctrl.getStyleClass()">
format_color_text
</md-icon>
</md-button>
......
......@@ -56,9 +56,9 @@ export default class LogsToolbarController {
/**
* Pod creation time.
* @export {string}
* @export {?string}
*/
this.podCreationTime = new Date(Date.parse(this.pod.startTime)).toLocaleString();
this.podCreationTime = this.pod.startTime;
/**
* Namespace.
......
......@@ -103,6 +103,14 @@ limitations under the License.
Pod
</kd-sorted-header>
</th>
<th class="kd-replicasetdetail-table-header">
<kd-sorted-header currently-selected-column="ctrl.sortPodsBy"
currently-selected-order="ctrl.podsOrder"
column-name="status"
tooltip="Status of the pod">
Status
</kd-sorted-header>
</th>
<th class="kd-replicasetdetail-table-header">
<kd-sorted-header currently-selected-column="ctrl.sortPodsBy"
currently-selected-order="ctrl.podsOrder"
......@@ -162,11 +170,19 @@ limitations under the License.
<tr ng-repeat="pod in ctrl.replicaSetDetail.pods | orderBy:ctrl.sortPodsBy:ctrl.podsOrder">
<td class="kd-replicasetdetail-table-cell">{{pod.name}}</td>
<td class="kd-replicasetdetail-table-cell">
{{pod.restartCount}}<!-- TODO(maciaszczykm): Add info about last restart date. -->
{{::pod.podPhase}}
</td>
<td class="kd-replicasetdetail-table-cell">
{{pod.startTime | relativeTime}}
<md-tooltip>{{pod.startTime | date:'short'}}</md-tooltip>
{{::pod.restartCount}}<!-- TODO(maciaszczykm): Add info about last restart date. -->
</td>
<td class="kd-replicasetdetail-table-cell">
<span ng-if="::pod.startTime">
{{::pod.startTime | relativeTime}}
<md-tooltip>{{::(pod.startTime | date:'short')}}</md-tooltip>
</span>
<span ng-if="::!pod.startTime">
-
</span>
</td>
<td class="kd-replicasetdetail-table-cell">
0.4 CPU<!-- TODO(maciaszczykm): Fill with data and plot. -->
......@@ -174,8 +190,22 @@ limitations under the License.
<td class="kd-replicasetdetail-table-cell">
12 MB<!-- TODO(maciaszczykm): Fill with data and plot. -->
</td>
<td class="kd-replicasetdetail-table-cell">{{pod.podIP}}</td>
<td class="kd-replicasetdetail-table-cell">{{pod.nodeName}}</td>
<td class="kd-replicasetdetail-table-cell">
<span ng-if="::pod.podIP">
{{::pod.podIP}}
</span>
<span ng-if="::!pod.podIP">
-
</span>
</td>
<td class="kd-replicasetdetail-table-cell">
<span ng-if="::pod.nodeName">
{{::pod.nodeName}}
</span>
<span ng-if="::!pod.nodeName">
-
</span>
</td>
<td class="kd-replicasetdetail-table-cell">
<span>
Logs<i class="material-icons kd-replicasetdetail-table-icon">arrow_drop_down</i>
......
......@@ -32,8 +32,13 @@ limitations under the License.
<div class="kd-menu-logs-item kd-menu-logs-item-since">
<a ng-href="{{::ctrl.getLogsHref(pod.name, pod.podContainers[0].name)}}"
ng-if="::ctrl.podContainerExists(pod)">
{{pod.startTime | date:"short"}}<i
class="material-icons kd-menu-logs-link-icon">open_in_new</i>
<span ng-if="::pod.startTime">
{{pod.startTime | date:"short"}}
</span>
<span ng-if="::!pod.startTime">
Not running
</span>
<i class="material-icons kd-menu-logs-link-icon">open_in_new</i>
</a>
<span ng-if="::!ctrl.podContainerExists(pod)">-</span>
</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.
import UploadController from 'deploy/upload_controller.js';
describe('Upload Controller', () => {
/** @type {!UploadController} */
let ctrl;
/** @type {!angular.FormController} */
let form;
beforeEach(() => {
angular.mock.inject(($controller) => {
form = {
$submitted: false,
fileName: {
$invalid: false,
$error: {
required: false,
},
},
};
ctrl = $controller(UploadController, {/* no locals */}, {form: form});
});
});
it('should return false when the from is not submitted and there is no error', () => {
// when
let result = ctrl.isFileNameError();
// then
expect(result).toEqual(false);
});
it('should return false when the from is not submitted and there is an error', () => {
// given
form.fileName.$error.required = true;
// when
let result = ctrl.isFileNameError();
// then
expect(result).toEqual(false);
});
it('should return true when the from is submitted and there is an error', () => {
// given
form.fileName.$error.required = true;
form.$submitted = true;
// when
let result = ctrl.isFileNameError();
// then
expect(result).toEqual(false);
});
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册