Ejemplo n.º 1
0
Archivo: app.js Proyecto: go/ui
import Resource from 'ember-api-store/models/resource';
import { reference } from 'ember-api-store/utils/denormalize';
import { computed, get } from '@ember/object';
import { parseHelmExternalId } from 'ui/utils/parse-externalid';
import StateCounts from 'ui/mixins/state-counts';
import { inject as service } from '@ember/service';

const App = Resource.extend(StateCounts, {
  catalog: service(),
  router: service(),
  clusterStore: service(),

  namespace: reference('targetNamespace', 'namespace', 'clusterStore'),
  pods: computed('namespace.pods.@each.workloadId', 'workloads.@each.workloadLabels', function() {
    return (get(this, 'namespace.pods') || []).filter((item) => {
      if ( item['labels'] ) {
        const inApp = item['labels']['io.cattle.field/appId'] === get(this, 'name');
        if ( inApp ) {
          return true;
        }
      }

      const workload = get(item, 'workload');
      if ( workload ) {
        const found = get(this, 'workloads').filterBy('id', get(workload, 'id'));
        return found.length > 0;
      }
    });
  }),
  services: computed('namespace.services', function() {
    return (get(this, 'namespace.services') || []).filter((item) => {
Ejemplo n.º 2
0
import { inject as service } from "@ember/service";
import { reference } from 'ember-api-store/utils/denormalize';
import ResourceUsage from 'shared/mixins/resource-usage';

var Node = Resource.extend(StateCounts, ResourceUsage, {
  type: 'node',

  modalService: service('modal'),
  settings: service(),
  prefs: service(),
  router: service(),
  globalStore: service(),
  clusterStore: service(),
  intl: service(),

  cluster: reference('clusterId','cluster'),
  nodePool: reference('nodePoolId'),

  init() {
    this._super(...arguments);
    this.defineStateCounts('arrangedInstances', 'instanceStates', 'instanceCountSort');
  },

  actions: {
    activate: function() {
      return this.doAction('activate');
    },

    deactivate: function() {
      return this.doAction('deactivate');
    },
Ejemplo n.º 3
0
Archivo: pod.js Proyecto: orangedeng/ui
import DisplayImage from 'shared/mixins/display-image';

var Pod = Resource.extend(DisplayImage, {
  router:       service(),
  modalService:  service('modal'),
  globalStore:  service(),
  clusterStore:  service(),
  scope:        service(),

  canHaveLabels: true,
  escToClose:    true,

  canEdit:      false,
  canClone: false,

  namespace:    reference('namespaceId', 'namespace', 'clusterStore'),
  node:          reference('nodeId', 'node', 'globalStore'),
  workload:      reference('workloadId'),
  hasSidekicks:  gt('containers.length', 1),
  canEditYaml:  computed('links.update', 'actions.edit', function() {
    return !!get(this, 'links.update') && !!get(this, 'actions.edit');
  }),

  availableActions: computed('combinedState', function() {
    let isRunning = get(this, 'combinedState') === 'running';

    var choices = [
      {
        label:     'action.execute',
        icon:      'icon icon-terminal',
        action:    'shell',
Ejemplo n.º 4
0
import Resource from 'ember-api-store/models/resource';
import { get, computed } from '@ember/object'
import { reference } from 'ember-api-store/utils/denormalize';
import { parseSi, formatSi } from 'shared/utils/parse-unit';
import { inject as service } from '@ember/service';

var PersistentVolumeClaim = Resource.extend({
  clusterStore:     service(),
  type:             'persistentVolumeClaim',
  canEdit:      false,

  storageClass:     reference('storageClassId', 'storageClass', 'clusterStore'),
  persistentVolume: reference('volumeId', 'persistentVolume', 'clusterStore'),
  namespace:        reference('namespaceId', 'namespace', 'clusterStore'),

  sizeBytes: computed('status.capacity.storage', function() {
    const str = get(this, 'status.capacity.storage');

    if ( str ) {
      return parseSi(str, 1024);
    }
  }),

  displaySize: computed('sizeBytes', function() {
    const bytes = get(this, 'sizeBytes');

    if ( bytes ) {
      return formatSi(bytes, 1024, 'iB', 'B');
    }
  }),
});
Ejemplo n.º 5
0
import DockerCredential from './dockercredential';
import { reference } from 'ember-api-store/utils/denormalize';
import { inject as service } from '@ember/service';

export default DockerCredential.extend({
  clusterStore: service(),
  namespace: reference('namespaceId', 'namespace', 'clusterStore'),
});