Example #1
0
 it('样式中获取图片和字体的链接', function() {
   assert.equal(find(log.modules, {src: 'foo.css'}).destHash, 'eca2ee19e030494d38885512da999ec5');
 });
Example #2
0
 getPackage(packageName) {
   return lo_find(this.packages, (x) => x.name === packageName);
 }
Example #3
0
}, (accessToken, refreshToken, extraParams, profile, done) => {
  // accessToken is the token to call Auth0 API (not needed in the most cases)
  // extraParams.id_token has the JSON Web Token
  // profile has all the information from the user
  log.info('Auth0 login')
  console.log(profile)
  // check if user has a local user object
  let hosts = []

  if (profile._json['https://maphubs.com/hosts']) {
    hosts = profile._json['https://maphubs.com/hosts']
  }

  const host = _find(hosts, {host: local.host})
  if (host && host.user_id) {
    // local user already linked
    return AuthUsers.find(host.user_id).then(async (maphubsUser) => {
      if (maphubsUser.id !== '1' && local.requireInvite) {
        const allowed = await Admin.checkInviteEmail(maphubsUser.email)
        if (!allowed) {
          log.warn(`unauthorized user: ${maphubsUser.email}`)
          return false
        }
      }
      // attach MapHubs User
      log.info(`Auth0 login successful for ${maphubsUser.id} ${maphubsUser.display_name} ${maphubsUser.email}`)
      profile.maphubsUser = {
        id: maphubsUser.id,
        display_name: maphubsUser.display_name,
        email: maphubsUser.email
      }
      return profile
    }).asCallback(done)
  } else {
    log.warn(`local user not linked: ${profile._json.email}`)
    // attempt to lookup user by email
    return AuthUsers.findByEmail(profile._json.email)
      .then(async (maphubsUser) => {
        if (maphubsUser) {
          if (maphubsUser.id !== '1' && local.requireInvite) {
            const allowed = await Admin.checkInviteEmail(maphubsUser.email)
            if (!allowed) {
              log.warn(`unauthorized user: ${maphubsUser.email}`)
              return false
            }
          }
          // link it back to the Auth0 account
          return saveMapHubsIDToAuth0(profile, maphubsUser.id)
            .then(() => {
              profile.maphubsUser = {
                id: maphubsUser.id,
                display_name: maphubsUser.display_name,
                email: maphubsUser.email
              }
              return profile
            })
        } else {
          // local user not found
          if (!local.requireInvite) {
            // create local user
            return Promise.resolve(createMapHubsUser(profile)) // wrap to support asCallback()
          } else {
            // check if email is in invite list
            return Admin.checkInviteConfirmed(profile._json.email)
              .then(confirmed => {
                if (confirmed) {
                  return createMapHubsUser(profile)
                } else {
                  log.warn(`unauthorized user: ${profile._json.email}`)
                  return false
                }
              })
          }
        }
      }).asCallback(done)
  }
})
Example #4
0
 /**
  * get a plugin by its name.
  * @method getPlugin
  * @param {String} name of the plugin.
  * @return {Object} the plugin instance
  * @example
  * ```javascript
  * var poster = player.getPlugin('poster');
  * poster.hidePlayButton();
  * ```
  */
 getPlugin(name) {
   var plugins = this.core.plugins.concat(this.core.mediaControl.container.plugins);
   return find(plugins, function(plugin) {
     return plugin.name === name;
   });
 }
Example #5
0
 findPlaybackPlugin(source, mimeType) {
   return find(this.loader.playbackPlugins, (p) => { return p.canPlay(source, mimeType) })
 }
 outOfOrder.forEach(function (imp) {
   var found = find(imported, function hasHigherRank(importedItem) {
     return importedItem.rank > imp.rank;
   });
   context.report(imp.node, '`' + imp.name + '` import should occur ' + order + ' import of `' + found.name + '`');
 });
Example #7
0
 getPlugin(name) {
   return find(this.plugins, (plugin) => { return plugin.name === name });
 }
 value: function getColumnMetadataByName(name) {
   return find(this.columnMetadata, { columnName: name });
 }
Example #9
0
 function ensureGeneral(conversations) {
   assert(find(conversations, function(conversation) {
     return conversation.tags.indexOf('LOCKED') > -1 && conversation.tags.indexOf('TEAM') > -1;
   }));
 }
Example #10
0
 Files.getAllFiles(function (_, files) {
   let found = find(files, two)
   should.exist(found)
   two.checksum = found.checksum
   done()
 })
Example #11
0
 Files.getAllFiles(function (_, files) {
   should.exist(find(files, one))
   should.exist(find(files, two))
   should.not.exist(find(files, tmp))
   done()
 })
Example #12
0
 function returnAttributes(fields) {
   var toReturn = [];
   for (var x in fields)
     toReturn.push(find(attributes, { lowercase: fields[x] }));
   return toReturn;
 }
function anyConditions(conditions) {
  return Boolean(find(conditions, function(cond){
    return cond();
  }));
}
Example #14
0
 it('脚本中获取样式的链接', function() {
   assert.equal(find(log.modules, {src: 'foo.js'}).destHash, 'd40fc589eaa82ddb58997ec7e6e2c78b');
 });
 changedFiles = changedFiles.filter(file => {
   return !find(this.publishConfig.ignore, pattern => {
     return minimatch(file, pattern, {matchBase: true});
   });
 });
Example #16
0
 forEach(stats.details, function (stat, object_id) {
   const label = find(ctrl.chosen, {id: object_id})
   ctrl.stats[label.name_label] = stat[ctrl.selectedMetric]
 })
 changedFiles = changedFiles.filter((file) => {
   return !find(this.flags.ignore, (pattern) => {
     return minimatch(file, pattern, {matchBase: true});
   });
 });
Example #18
0
GitGraphViewModel.getHEAD = function(nodes) {
	return find(nodes, function(node) { return find(node.refs(), 'isLocalHEAD'); });
}
Example #19
0
 showLayerDesigner = (layerId: number) => {
   const layer = _find(this.state.mapLayers, {layer_id: layerId})
   this.setState({showMapLayerDesigner: true, layerDesignerLayer: layer})
 }
Example #20
0
	return find(nodes, function(node) { return find(node.refs(), 'isLocalHEAD'); });
Example #21
0
const Breakjs = function(bpEntries) {
  if (!bpEntries) {
    throw new Error('No breakpoints were defined!');
  }

  let bps = [];
  for (let key in bpEntries) {
    let entry = {name: key, value: bpEntries[key]};

    if (find(bps, bp => bp.value === entry.value)) {
      throw new Error('Breakpoint values must be unique.');
    }

    bps.push(entry);
  }

  let breakpoints = bps
    .sort((a, b) => { return a.value > b.value; })
    .map((bp, index) => {
      if (typeof bp.name !== 'string') {
        throw new Error('Invalid breakpoint name -- should be a string.');
      }

      if (typeof bp.value !== 'number' || bp.value < 0 || bp.value >= 9999) {
        throw new Error(`Invalid breakpoint value for ${bp.name}: ${bp.value}`);
      }

      let breakpoint = {name: bp.name};

      // only query
      if (bps.length === 1) {
        breakpoint.query = query(0, null);
      }

      // last query
      else if (index === bps.length - 1) {
        breakpoint.query = query(bp.value, null);
      }

      // query inbetween
      else {
        breakpoint.query = query(bp.value, bps[index + 1].value);
      }

      return breakpoint;
    });

  function getBreakpoint(breakpointName) {
    let findObj = find(breakpoints, bp => bp.name === breakpointName);

    if (!findObj) {
      throw new Error('invalid breakpoint name');
    }

    return findObj;
  }

  let changeListeners = [];

  return {
    breakpoints: bps,

    /**
     * Check if the current window size is the given size
     * @param  {String} size
     * @return {Boolean}
     */
    is(name) {
      return getBreakpoint(name).query.is.matches;
    },

    /**
     * Check if the current window size at least the given size
     * @param  {String} size
     * @return {Boolean}
     */
    atLeast(name) {
      return getBreakpoint(name).query.atLeast.matches;
    },

    /**
     * Check if the current window size at most the given size
     * @param  {String} size
     * @return {Boolean}
     */
    atMost(name) {
      return getBreakpoint(name).query.atMost.matches;
    },

    current() {
      let findObj = find(breakpoints, bp => bp.query.is.matches);

      if (findObj) {
        return findObj.name;
      }
    },

    addChangeListener(listener) {
      breakpoints.forEach(bp => {
        let changeListener = () => {
          var current = this.current();
          if (current === bp.name) {
            listener(current);
          }
        };

        changeListeners.push({
          original: listener,
          created: changeListener
        });

        bp.query.is.addListener(changeListener);
      });
    },

    removeChangeListener(listener) {
      breakpoints.forEach(bp => {
        let findObj = find(changeListeners, cl => cl.original === listener);

        if (findObj) {
          bp.query.is.removeListener(findObj.created);
          changeListeners.splice(changeListeners.indexOf(findObj), 1);
        }
      });
    }
  };
};
Example #22
0
GerritIntegrationViewModel.prototype.getChange = function(changeId) {
	return find(this.changes(), { data: { id: changeId } });
}
Example #23
0
            this.add({ id, properties })
            searchFeatures[id] = feature
          })
        }
        debug.log('***search index initialized***')
        resolve()
      })
    })
  },

  getNameFieldForResult (result: Object) {
    const {t} = this.props

    const source = this.overlayMapStyle.sources[result.source]
    const presets = source.metadata['maphubs:presets']
    const nameFieldPreset = _find(presets, {isName: true})
    let nameField = nameFieldPreset ? nameFieldPreset.tag : undefined

    if (!nameField) {
      const matchNameArr = []
      if (presets && presets.length > 0) {
        presets.forEach(preset => {
          if (preset && preset.label) {
            const label = t(preset.label).toString()
            if (label.match(/.*[N,n]ame.*/g)) {
              matchNameArr.push(preset.tag)
            }
          }
        })
        if (matchNameArr.length > 0) {
          // found something that matches Name
Example #24
0
 forEach(job.paramsVector.items[0].values, value => {
   const vm = find(vms, vm => vm.id === value.id)
   vm && selectedVms.push(vm)
 })
Example #25
0
 forEach(ids, id => {
   const item = find(list, item => item.id === id)
   if (item) {
     collection.push(item)
   }
 })
Example #26
0
exports.findCurrency = function (currencyCode) {
  return find(currencies, function (c) { return c.code === currencyCode })
}
Example #27
0
									this._repos[i].milestones = map(result.body, (m) => {
										m.repository = this._repos[i];
										return m;
									});
								});

								dispatcher.dispatch({ type: actions.REPOS_STORE_UPDATED });
								this.emitChange();
							});
					});
			});
	},

	getById (id) {
		return find(this._repos, (i) => i.id === id);
	},

	getAll () {
		return this._repos;
	},

	poll () {
		this.pollId = window.setInterval(bind(this.fetch, this), 1000 * 60 * 3);
	},

	stopPolling () {
		if (this.pollId)
			window.clearInterval(this.pollId);
	}
});
Example #28
0
 Object.assign({},searchFields.map((item) =>{
     searchValues[item.key] = {
         value: item.type === 'select' ? find(item.options, (option)=>option.selected).value : item.value,
         type: item.type
     }
 }));
Example #29
0
 function getPackageInfo(packageName) {
   return lo_find(pm.listPackages(), (x) => x.name === packageName);
 }
Example #30
0
 it('脚本中获取样式的链接', function() {
   assert.equal(find(log.modules, {src: 'foo.js'}).destHash, 'b29f885b71ec2053aeaf52f1e2f6ece4');
 });