Exemplo n.º 1
0
 out.forEach((x) => {
   if ( x.available < x.total ) {
     set(x, 'enabled', false);
   } else {
     set(x, 'enabled', true);
   }
 });
Exemplo n.º 2
0
 ruleKeyDidChange: observer('rule.key', function() {
   if ( get(this, 'rule.key') === 'event' ) {
     set(this, 'rule.value', eventChoices[0].value);
   } else {
     set(this, 'rule.value', '');
   }
 }),
Exemplo n.º 3
0
  let tag = run(() => {
    tag = store.createRecord('tag');

    set(tag, 'name', 'testing');
    set(tag, 'name', undefined);

    return tag;
  });
Exemplo n.º 4
0
  principalChanged: observer('principal', 'member', function() {
    let principal = (get(this, 'principal'));

    if (principal) {
      set(this, 'member.principalId', get(principal, 'id'));
      set(this, 'member.memberType', get(principal, 'principalType'));
    }
  }),
Exemplo n.º 5
0
        }).catch((xhr) => {
          if (get(member, 'principalId')) {
            set(this, 'principalId', get(member, 'principalId'));
            set(this, 'principalGravatarSrc', `data:image/png;base64,${ new Identicon(AWS.util.crypto.md5(get(member, 'principalId') || 'Unknown', 'hex'), 80, 0.01).toString() }`)
          }

          return xhr;
        });
Exemplo n.º 6
0
  expandAllObserver: on('init', observer('expandAll', function() {
    var ea = get(this, 'expandAll');

    if (ea) {
      set(this, 'expanded', true);
    } else {
      set(this, 'expanded', false);
    }
  })),
Exemplo n.º 7
0
 projectDidChange: observer('primaryResource.project.id', function() {
   set(this, 'switchingProject', true);
   next(() => {
     set(this, 'switchingProject', false);
   });
   if ( !get(this, 'primaryResource.project.resourceQuota') ) {
     set(this, 'primaryResource.resourceQuota', null);
   }
 }),
Exemplo n.º 8
0
      requiredElements.forEach((element) => {
        const selectedElement = document.querySelector(element.selector);

        if (allElementsPresent && (!selectedElement || elementIsHidden(selectedElement))) {
          allElementsPresent = false;
          set(this, 'errorTitle', element.title);
          set(this, 'messageForUser', element.message);
        }
      });
Exemplo n.º 9
0
        .then((saveAlertResponse) => {

          // Step 2: If any edits were made to the Notification Group, prep a POST object to save Config entity
          if (isEditedConfigGroup) {

            // Whether its a new Config object or existing, assign new user-supplied values to these props:
            set(postConfigBody, 'application', newApplication);
            set(postConfigBody, 'recipients', cleanRecipientsArr);

            // Make sure current Id is part of new config array
            if (postConfigBody && postConfigBody.emailConfig) {
              postConfigBody.emailConfig.functionIds = dedupedGroupAlertIdArray;
            } else {
              postConfigBody.emailConfig = { functionIds: dedupedGroupAlertIdArray };
            }

            // Re-use the postProps object, now for config group data
            postProps.body = JSON.stringify(postConfigBody);

            // Save the edited or new config object (we've added the new Alert Id to it)
            return fetch(configUrl, postProps)
              .then((res) => checkStatus(res, 'post'))
              .then((saveConfigResponseA) => {
                this.setProperties({
                  selectedConfigGroupRecipients: cleanRecipientsArr,
                  alertGroupNewRecipient: null,
                  newConfigGroupName: null
                });

                // If the user switched config groups or created a new one, remove Alert Id from previous group
                if (isNewConfigGroup && originalConfigGroup) {
                  _.pull(originalConfigGroup.emailConfig.functionIds, currentId);
                  postProps.body = JSON.stringify(originalConfigGroup);
                  return fetch(configUrl, postProps)
                    .then((res) => checkStatus(res, 'post'))
                    .then((saveConfigResponseB) => {

                      // If save successful, update new config group name before model refresh (avoid big data delay)
                      this.set('updatedRecipients', cleanRecipientsArr);
                      if (isPresent(newGroupName)) {
                        this.setProperties({
                          isNewConfigGroupSaved: true,
                          selectedConfigGroup: newConfigGroupObj
                        });
                      }
                      this.confirmEditSuccess();
                    });
                } else {
                  this.confirmEditSuccess();
                }
              });
          } else {
            this.confirmEditSuccess();
          }
        })
Exemplo n.º 10
0
    return store.findRecord('person', 1).then(person => {
      assert.equal(person._internalModel._attributes.name, undefined, 'the `_attributes` hash is clean');

      set(person, 'name', 'Niceguy Dale');

      assert.equal(person._internalModel._attributes.name, 'Niceguy Dale', 'the `_attributes` hash contains the changed value');

      set(person, 'name', 'Scumbag Dale');

      assert.equal(person._internalModel._attributes.name, undefined, 'the `_attributes` hash is reset');
    });
Exemplo n.º 11
0
	return function() {

		if ( isPresent(values) ) {
			let idx = values.indexOf( get(obj, prop) );
			let nxt = values[idx+1] || values[0];
			return set(obj, prop, nxt);
		}

		return set(obj, prop, !get(obj, prop));

	};
Exemplo n.º 12
0
 return this._super(...arguments).then(function(item) {
     const nodes = get(item, 'Nodes');
     const service = get(nodes, 'firstObject');
     const tags = nodes
       .reduce(function(prev, item) {
         return prev.concat(get(item, 'Service.Tags') || []);
       }, [])
       .uniq();
     set(service, 'Tags', tags);
     set(service, 'Nodes', nodes);
     return service;
   });
Exemplo n.º 13
0
        }).then((xhr) => {
          if ( xhr.status === 204 ) {
            return;
          }

          if ( xhr.body && typeof xhr.body === 'object') {
            set(this, 'principal', set(this, 'external', xhr.body));
            this.principalChanged();
          }

          return xhr;
        }).catch((xhr) => {
Exemplo n.º 14
0
test('it renders when created from GitHub', function(assert) {
  assert.expect(3);

  set(this, 'user', { username: '******' });
  set(this, 'createdAt', moment().subtract(2, 'days'));
  set(this, 'createdFrom', 'github');

  renderPage();

  assert.equal(page.username.text, 'tester', 'The username of the comment author renders.');
  assert.equal(page.createdAt.text, '2 days ago', 'The time ago text renders.');
  assert.equal(page.createdFrom.text, '— from GitHub', 'The created from text renders.');
});
Exemplo n.º 15
0
  modeChanged: observer('mode', function() {
    const mode = get(this, 'mode');

    const xip = get(this, `settings.${ C.SETTING.INGRESS_IP_DOMAIN }`);

    if ( mode === 'automatic' ) {
      set(this, 'value', xip);
    } else {
      if ( get(this, 'value') === xip ) {
        set(this, 'value', '');
      }
    }
  }),
Exemplo n.º 16
0
Arquivo: component.js Projeto: go/ui
 configAnswersDidChange: observer('configAnswers', function() {
   const configAnswers = get(this, 'configAnswers');
   let selectedCloudProvider = get(this, 'selectedCloudProvider');
   switch (selectedCloudProvider) {
     case 'azure':
       set(this, AZURE_PATH, configAnswers);
       break;
     case 'amazonec2':
       set(this, AWS_PATH, configAnswers);
       break;
     default:
       set(this, GENERIC_PATH, configAnswers);
       break;
   }
 }),
Exemplo n.º 17
0
Arquivo: component.js Projeto: go/ui
    return get(this, 'globalStore').findAll('nodeDriver').then((allNodeDrivers) => {
      set(this, 'allNodeDrivers', allNodeDrivers);

      const active = get(this, 'availableDrivers');

      if ( !driver || !active.findBy('name', driver) ) {
        driver = get(active, 'firstObject.name');
      }

      set(this, 'driver', driver);

      return this.loadCustomUi().then(() => {
        set(this, 'loading', false);
      });
    }).catch((err) => {
Exemplo n.º 18
0
  selectedChanged: observer('selected', function() {
    let id = get(this, 'selected');
    let str = null;
    let dnsRecord = null;

    if (id) {
      dnsRecord = get(this, 'allDnsRecords').byId(id);
      if (dnsRecord) {
        str = `${ get(dnsRecord, 'namespace')  }/${  get(dnsRecord, 'name') }`;
      }
    }

    set(this, 'value', str);
    set(this, 'obj', dnsRecord);
  }),
Exemplo n.º 19
0
  zoneChoices: computed('allSubnets.@each.{zone}', function() {
    const choices = (get(this, 'allSubnets') || []).map((subnet) => {
      return get(subnet, 'zone');
    }).sort().uniq();

    if ( choices.length ) {
      if ( get(this, 'config.zone.length') ) {
        set(this, 'selectedZone', `${ get(this, 'config.region') }${ get(this, 'config.zone') }`);
      } else {
        set(this, 'selectedZone', choices[0]);
      }
    }

    return choices;
  }),
Exemplo n.º 20
0
        }).catch((err) => {
          this.send('waiting', provider);

          if ( err && [401, 403].includes(err.status) ) {
            let key = 'loginPage.error.authFailed'

            if ( USER_PASS_PROVIDERS.includes(provider) ) {
              key = 'loginPage.error.authFailedCreds';
            }

            set(this, 'errorMsg', get(this, 'intl').t(key));
          } else {
            set(this, 'errorMsg', (err ? err.message : 'No response received'));
          }
        })
test('it renders the skills sorted by match and then alphabetically', function(assert) {
  assert.expect(9);

  set(this, 'skills', skills);
  stubService(this, 'session', mockSession);

  this.render(hbs`{{skill-list-items skills=skills}}`);

  assert.equal(page.listItemCount, 4, 'Renders the correct number of skills');

  page.listItems(0).as((item) => {
    assert.equal(item.skillListItemSpan.text, 'HTML');
    assert.ok(item.skillListItemSpan.hasMatched);
  });

  page.listItems(1).as((item) => {
    assert.equal(item.skillListItemSpan.text, 'Ember.js');
    assert.notOk(item.skillListItemSpan.hasMatched);
  });

  page.listItems(2).as((item) => {
    assert.equal(item.skillListItemSpan.text, 'Rails');
    assert.notOk(item.skillListItemSpan.hasMatched);
  });

  page.listItems(3).as((item) => {
    assert.equal(item.skillListItemSpan.text, 'Ruby');
    assert.notOk(item.skillListItemSpan.hasMatched);
  });
});
Exemplo n.º 22
0
    socket.onclose = () => {
      if (this.isDestroyed || this.isDestroying) {
        return;
      }

      set(this, 'status', 'disconnected');
    };
Exemplo n.º 23
0
    socket.onmessage = (message) => {
      let ansiup = new AnsiUp;

      set(this, 'status', 'connected');
      const data = AWS.util.base64.decode(message.data).toString();
      let html = '';

      data.trim().split(/\n/)
        .filter((line) => line)
        .forEach((line) => {
          var match = line.match(/^\[?([^ \]]+)\]?\s?/);
          var dateStr = '';
          var msg = '';

          if (match && this.isDate(new Date(match[1]))) {
            var date = new Date(match[1]);

            msg = line.substr(match[0].length);
            dateStr = `<span class="log-date">${  Util.escapeHtml(date.toLocaleDateString())  } ${  Util.escapeHtml(date.toLocaleTimeString())  } </span>`;
          } else {
            msg = line;
          }

          // @@TODO@@ - 10-13-17 - needed to remove the escaping here because it was being double escaped but double verify that its acutally being escaped
          html += `<div class="log-msg log-combined">${
            dateStr
          }${ ansiup.ansi_to_html(msg)
          }</div>`
        });

      body.insertAdjacentHTML('beforeend', html);
    };
test('it opens, closes, and renders the correct states', async function(assert) {
  assert.expect(8);

  set(this, 'status', 'open');

  renderPage();

  assert.ok(page.openButton.isVisible, 'The open button is visible');

  await page.openButton.click();

  assert.ok(page.openButton.isActive, 'The open button is active');
  assert.ok(page.openLink.isActive, 'The open link is active');
  assert.notOk(page.closedLink.isActive, 'The close link is not active');

  await page.closedLink.click();
  await page.closedButton.click();

  assert.ok(page.closedButton.isActive, 'The close button is active');
  assert.notOk(page.openLink.isActive, 'The open link is not active');
  assert.ok(page.closedLink.isActive, 'The close link is active');

  await page.openLink.click();

  assert.ok(page.openButton.isVisible, 'The open button is visible');
});
Exemplo n.º 25
0
    once(() => {
      var interval = window.setInterval(() => {
        set(this, 'dateNow', Date.now())
      }, 1000);

      set(this, 'dateInterval', interval);
    });
test('it renders loading spinnner if skill is loading', function(assert) {
  assert.expect(2);
  set(this, 'skill', { isLoading: true, title: 'Test' });
  renderPage();
  assert.ok(page.isLoading, 'Component is rendered as loading');
  assert.equal(page.text, '', 'Title is not rendered');
});
Exemplo n.º 27
0
      ec2.describeVpcs({}, (err, vpcs) => {
        if ( err ) {
          let errors = get(self, 'errors') || [];

          errors.pushObject(err);
          set(this, 'errors', errors);
          if (cb && typeof cb === 'function') {
            cb();
          }

          return;
        }

        vpcs.Vpcs.forEach((vpc) => {
          vpcNames[vpc.VpcId] = nameFromResource(vpc, 'VpcId');
          vpcTags[vpc.VpcId] = tagsFromResource(vpc);
        });

        ec2.describeSubnets({}, (err, data) => {
          if ( err ) {
            let errors = get(self, 'errors') || [];

            errors.pushObject(err);
            set(this, 'errors', errors);
            if (cb && typeof cb === 'function') {
              cb();
            }

            return;
          }

          set(this, `clients.${ rName }`, ec2);

          data.Subnets.forEach((subnet) => {
            if ( (subnet.State || '').toLowerCase() !== 'available' ) {
              return;
            }

            subnets.pushObject(EmberObject.create({
              subnetName: nameFromResource(subnet, 'SubnetId'),
              subnetId:   subnet.SubnetId,
              subnetTags: tagsFromResource(subnet),
              vpcName:    vpcNames[subnet.VpcId] || subnet.VpcId,
              vpcId:      subnet.VpcId,
              vpcTags:    vpcTags[subnet.VpcId] || [],
              zone:       subnet.AvailabilityZone,
              region:     rName
            }));
          });

          setProperties(this, {
            'allSubnets': subnets,
            'step':       2,
          });
          if (cb && typeof cb === 'function') {
            cb();
          }
        });
      });
test('it renders correctly when there is a stripeConnectAccount', function(assert) {
  assert.expect(3);
  set(this, 'stripeConnectAccount', { id: 1 });
  renderPage();
  assert.ok(page.rendersHeader, 'Renders header');
  assert.ok(page.hasVerifiedStatus, 'Is verified');
  assert.notOk(page.rendersSection, 'Does not render section');
});
test('it renders correctly when there is no stripeConnectAccount', function(assert) {
  assert.expect(3);
  set(this, 'stripeConnectAccount', null);
  renderPage();
  assert.ok(page.rendersHeader, 'Renders header');
  assert.ok(page.hasRequiredStatus, 'Is required');
  assert.ok(page.rendersSection, 'Renders section');
});
test('it disables controls when busy', function(assert) {
  assert.expect(1);

  set(this, 'isBusy', true);

  renderPage();
  assert.ok(page.submitButtonIsDisabled, 'Submit button is disabled when busy.');
});