export function regimenSerializer(input: Regimen): ApiRegimen {
    const regimen = _.clone<Regimen>(input);
    const regimen_items = regimen
        .regimen_items
        .map<ApiRegimenItem>(function wow(r) {
            if (r && r.sequence && r.sequence.id) {
                return {
                    time_offset: r.time_offset,
                    sequence_id: r.sequence.id
                };
            } else {
                throw new Error(`Array regimen.regimen_items may only contain
                           objects with an "id" property.`);
            }
        });

    return {
        name: regimen.name,
        color: regimen.color,
        regimen_items
    };
};
Beispiel #2
0
  beforeEach(() => {
    testBed = TestUtils.configureProviderTestingModule([
      { provide: BwcProvider, useClass: BwcProviderMock },
      { provide: PersistenceProvider, useClass: PersistenceProviderMock }
    ]);
    profileProvider = testBed.get(ProfileProvider);
    actionSheetProvider = testBed.get(ActionSheetProvider);
    configProvider = testBed.get(ConfigProvider);
    popupProvider = testBed.get(PopupProvider);
    replaceParametersProvider = testBed.get(ReplaceParametersProvider);
    platformProvider = testBed.get(PlatformProvider);
    txFormatProvider = testBed.get(TxFormatProvider);

    profileProvider.wallet = _.clone(walletMock);
    profileProvider.profile = Profile.create();

    events = testBed.get(Events);
    eventsPublishSpy = spyOn(events, 'publish');
    spyOn(events, 'subscribe').and.returnValue({
      walletId: 'id1'
    });
  });
Beispiel #3
0
 _.forEach(filtered, function(ot: any) {
     ot.koodiUri = ot.koodiUri || null;
     ot.koodiArvo = ot.koodiUri || null;
     var koodiUriKaytossa = _.any($scope.osatutkinnot, function(toinen: any) {
         return ot !== toinen && ot.koodiUri && toinen.koodiUri === ot.koodiUri;
     });
     if (koodiUriKaytossa) {
         ot.$syy = ["excel-ei-kahta-samaa"];
     } else {
         var cop = _.clone(ot);
         cop.tavoitteet = {};
         cop.tila = "luonnos";
         cop.osanTyyppi = "tutkinnonosa";
         cop.$laajuus = cop.laajuus;
         delete cop.laajuus;
         PerusteTutkinnonosat.save(
             {
                 perusteId: $scope.haettuPeruste.id,
                 suoritustapa: $scope.suoritustapa || $scope.haettuPeruste.suoritustavat[0].suoritustapakoodi
             },
             {
                 tutkinnonOsa: cop,
                 laajuus: cop.$laajuus
             },
             function(re) {
                 ot.$ladattu = 0;
                 ot.id = re._tutkinnonOsa;
                 doneSuccess();
             },
             function(err) {
                 if (err) {
                     ot.$syy = [err.data.syy];
                     ot.$ladattu = 1;
                 }
             }
         );
     }
 });
Beispiel #4
0
    it('should call showDesktopNotifications and go through NewTxProposal path', async () => {
      let newWalletClient = _.clone(walletClientMock);
      newWalletClient.copayerId = 'copayerId1';
      newWalletClient.credentials.m = 2;
      newWalletClient.credentials.n = 2;

      spyOn(BwcProviderMock.prototype, 'getClient').and.returnValue(
        newWalletClient
      );

      onEventNotificationType = 'NewTxProposal';
      const replaceSpy = spyOn(
        replaceParametersProvider,
        'replace'
      ).and.returnValue('body1');

      // Using importWallet just to test showDesktopNotifications private function
      await profileProvider.importWallet(str, opts).catch(err => {
        expect(err).not.toBeDefined();
      });

      expect(replaceSpy).toHaveBeenCalledTimes(1);
    });
  $onInit() {
    this.searchGatewayInstances = '';
    this.instances = this.startedInstances = _.clone(_.filter(this.instances, { 'state': 'started'}));
    this._displayEmptyMode = this.startedInstances.length === 0;

    this.$scope.displayAllInstances = false;

    this.$scope.switchDisplayInstances = () => {
      this.$scope.displayAllInstances = !this.$scope.displayAllInstances;

      if (this.$scope.displayAllInstances) {
        this._displayEmptyMode = this.instances.length === 0;
        if (this.allInstances) {
          this.instances = this.allInstances;
        } else {
          this.InstancesService.list(true).then(response => this.instances = this.allInstances = response.data);
        }
      } else {
        this._displayEmptyMode = this.startedInstances.length === 0;
        this.instances = this.startedInstances;
      }
    };
  }
Beispiel #6
0
export default function SystemStatusReducer(state: SystemStatus = defaultStatus, action: any = { type: "" }) {
    /**
     *
     *
     * DO NOT UNCOMMENTS
     *     CAUSING INFINITE LOOP
     *
     *
     *
     *
     */
    const newstate = _.clone(state);
    if (action.type.startsWith("App/")) {

        newstate.currentAction = action.type;
    }
    if (action.type.endsWith("_ERROR")) {
        Log.info("SystemStatusReducer", "canged sfetch Status to action.payload.error.message");
        newstate.fetchStatus = action.payload.error.message;
    }
    return newstate;
    //return state;
}
Beispiel #7
0
  return (dispatch, getState) => {
    const {
      edit: { article },
    } = getState()
    let data = {}

    if (typeof key === "object") {
      // extend article with an object of key
      data = key
    } else {
      const nestedObject = key.split(".")

      if (nestedObject.length > 1) {
        // change a nested object value
        const existingValue = clone(article[nestedObject[0]]) || {}
        data = set(existingValue, key, value)
      } else {
        // change a single key's value
        data[key] = value
      }
    }
    dispatch(changeArticle(data))
  }
Beispiel #8
0
      function configureAxisOptions(data, options) {
        var defaults = {
          position: 'left',
          show: panel.yaxes[0].show,
          index: 1,
          logBase: panel.yaxes[0].logBase || 1,
          max: 100, // correct later
        };

        options.yaxes.push(defaults);

        if (_.find(data, {yaxis: 2})) {
          var secondY = _.clone(defaults);
          secondY.index = 2;
          secondY.show = panel.yaxes[1].show;
          secondY.logBase = panel.yaxes[1].logBase || 1;
          secondY.position = 'right';
          options.yaxes.push(secondY);
          configureAxisMode(options.yaxes[1], panel.percentage && panel.stack ? "percent" : panel.yaxes[1].format);
        }

        applyLogScale(options.yaxes[0], data);
        configureAxisMode(options.yaxes[0], panel.percentage && panel.stack ? "percent" : panel.yaxes[0].format);
      }
    it('sort movies by year descending, runtime ascending, id', () => {
      var testdata = makeMovies();
      var original = _.clone(testdata);

      testdata.sort(jsonCompare([
        '-year',
        '+runtime',
        'id'
      ]));
      original.sort(function (a, b) {
        var result = (b.year | 0) - (a.year | 0);
        if (result === 0) {
          result = (a.runtime | 0) - (b.runtime | 0);
          if (result === 0) {
            result = a.id.localeCompare(b.id);
          }
        }
        return result;
      });

      for (var j = 0; j < testdata.length; ++j) {
        assert.equal(testdata[j], original[j], 'order at #' + j);
      }
    })
Beispiel #10
0
 const setComponentValue = () => {
   const uriValue = get(URIStorageName, false);
   const currentValue = this[propertyName];
   // if uriValue is undefined, we will ensure that the property has the
   // default value
   if (uriValue === undefined) {
     let valueToSet: T;
     // if we are using localStorage, we will set the value to the value
     // from localStorage. Then, the corresponding observer will proxy
     // the localStorage value into URI storage.
     // in this way, localStorage takes precedence over the default val
     // but not over the URI value.
     if (useLocalStorage) {
       const useLocalStorageValue = get(URIStorageName, true);
       valueToSet = useLocalStorageValue === undefined ?
           defaultVal :
           useLocalStorageValue;
     } else {
       valueToSet = defaultVal;
     }
     if (!_.isEqual(currentValue, valueToSet)) {
       // If we don't have an explicit URI value, then we need to ensure
       // the property value is equal to the default value.
       // We will assign a clone rather than the canonical default, because
       // the component receiving this property may mutate it, and we need
       // to keep a pristine copy of the default.
       this[propertyName] = _.clone(valueToSet);
     }
     // In this case, we have an explicit URI value, so we will ensure that
     // the component has an equivalent value.
   } else {
     if (!_.isEqual(uriValue, currentValue)) {
       this[propertyName] = uriValue;
     }
   }
 };