it('calls back with tribes on success', async function () {
                const expectedTribes = [{
                    _id: 'one'
                }, {
                    _id: 'two'
                }];

                const getSpy = spyOn(axios, 'get')
                    .and.returnValue(Bluebird.resolve({data: expectedTribes}));

                const resultTribes = await Coupling.getTribes();
                expect(getSpy).toHaveBeenCalledWith('/api/tribes');
                expect(angular.toJson(resultTribes)).toEqual(angular.toJson(expectedTribes));
            });
Beispiel #2
0
  set(title, text, severity, timeout) {
    var newAlert = {
      title: title || '',
      text: text || '',
      severity: severity || 'info',
    };

    var newAlertJson = angular.toJson(newAlert);

    // remove same alert if it already exists
    _.remove(this.list, function(value) {
      return angular.toJson(value) === newAlertJson;
    });

    this.list.push(newAlert);
    if (timeout > 0) {
      this.$timeout(() => {
        this.list = _.without(this.list, newAlert);
      }, timeout);
    }

    if (!this.$rootScope.$$phase) {
      this.$rootScope.$digest();
    }

    return(newAlert);
  }
  constructor (
    private $mdDialog: ng.material.IDialogService,
    private $scope: any,
    private $rootScope: ng.IRootScopeService,
    private $state: StateService,
    private ApiService,
    private NotificationService,
    private resolvedEvents,
    private $timeout
  ) {
    'ngInject';
    this.api = JSON.parse(angular.toJson(_.cloneDeep(this.$scope.$parent.apiCtrl.api)));
    this.events = resolvedEvents.data;
    this.eventsSelected = [];
    this.eventsTimeline = [];
    this.eventsToCompare = [];
    this.eventSelected = {};
    this.diffMode = false;
    this.eventToCompareRequired = false;
    this.eventTypes = "PUBLISH_API";

    this.cleanAPI(this.api);
    this.init();
    this.initTimeline(this.events);
  }
Beispiel #4
0
      private wechatPay(prepayid){

        let appid="wxd585ab5057bdc266";
        let noncestr = this.commonUtil.randomString(32);
        let timestamp = Math.round(new Date().getTime()/1000).toString();//时间戳 单位需要为秒(10位数字)
        let temp="appid="+appid+"&partnerid=1505050301&prepayid="+prepayid+"&package=Sign=WXPay&noncestr="+noncestr+"&timestamp="+timestamp+"";
        let signTemp = temp+"&key=zjlgwlapipasswordaaaaaaaaaaaaaaa" //商户平台设置的密钥key
        alert("noncestr:"+noncestr.length)
        let sign = Md5.hashStr(signTemp).toString().toUpperCase() //MD5签名方式

        let params = {
            appid : appid,
            partnerid: '1505050301',
            prepayid: prepayid,
            package:'Sign=WXPay',
            noncestr: noncestr,
            timestamp: timestamp,
            sign: sign,
         };

         console.log(params)
        alert(angular.toJson(params))
        this.wechat.sendPaymentRequest(params).then((result)=>{
             //支付成功
            alert(result)
          },(error)=>{
          //支付失败
            alert(error)
          })
               
      }
Beispiel #5
0
 .then(res=>{
   alert(angular.toJson(res))
   if(res.retcode == AppConfig.responseCode.successCode){
     let resultData = this.commonUtil.parseData(res.retObj)
     this.wechatPay(resultData.prepay_id);
   }
 })
Beispiel #6
0
  set(title, text, severity, timeout) {
    if (_.isObject(text)) {
      console.log('alert error', text);
      if (text.statusText) {
        text = `HTTP Error (${text.status}) ${text.statusText}`;
      }
    }

    var newAlert = {
      title: title || '',
      text: text || '',
      severity: severity || 'info',
    };

    var newAlertJson = angular.toJson(newAlert);

    // remove same alert if it already exists
    _.remove(this.list, function(value) {
      return angular.toJson(value) === newAlertJson;
    });

    this.list.push(newAlert);
    if (timeout > 0) {
      this.$timeout(() => {
        this.list = _.without(this.list, newAlert);
      }, timeout);
    }

    if (!this.$rootScope.$$phase) {
      this.$rootScope.$digest();
    }

    return(newAlert);
  }
Beispiel #7
0
 getQueryHeader(searchType, timeFrom, timeTo) {
   return angular.toJson({
       search_type: searchType,
       "ignore_unavailable": true,
       index: this.indexPattern.getIndexList(timeFrom, timeTo),
   });
 }
Beispiel #8
0
  getTerms(queryDef) {
    const range = this.timeSrv.timeRange();
    const searchType = this.esVersion >= 5 ? 'query_then_fetch' : 'count';
    const header = this.getQueryHeader(searchType, range.from, range.to);
    let esQuery = angular.toJson(this.queryBuilder.getTermsQuery(queryDef));

    esQuery = esQuery.replace(/\$timeFrom/g, range.from.valueOf());
    esQuery = esQuery.replace(/\$timeTo/g, range.to.valueOf());
    esQuery = header + '\n' + esQuery + '\n';

    const url = this.getMultiSearchUrl();

    return this.post(url, esQuery).then(res => {
      if (!res.responses[0].aggregations) {
        return [];
      }

      const buckets = res.responses[0].aggregations['1'].buckets;
      return _.map(buckets, bucket => {
        return {
          text: bucket.key_as_string || bucket.key,
          value: bucket.key,
        };
      });
    });
  }
Beispiel #9
0
  hasChanges() {
    let current = this.cleanDashboardFromIgnoredChanges(this.current.getSaveModelClone());
    let original = this.cleanDashboardFromIgnoredChanges(this.original);

    var currentTimepicker = _.find(current.nav, { type: 'timepicker' });
    var originalTimepicker = _.find(original.nav, { type: 'timepicker' });

    if (currentTimepicker && originalTimepicker) {
      currentTimepicker.now = originalTimepicker.now;
    }

    var currentJson = angular.toJson(current, true);
    var originalJson = angular.toJson(original, true);

    return currentJson !== originalJson;
  }
Beispiel #10
0
 return function(arr) {
   if (_.isObject(arr) && !_.isArray(arr)) {
     return angular.toJson(arr);
   } else {
     return _.isNull(arr) ? null : arr.toString();
   }
 };