示例#1
0
import { each, kebabCase } from 'lodash';
import { ModuleTitle, Semester, ModuleCode } from 'types/modules';
import { Venue } from 'types/venues';
import { SemTimetableConfig } from 'types/timetables';
import { serializeTimetable } from 'utils/timetables';
import config from 'config';

// IMPORTANT: Remember to update any route changes on the sitemap

// Cache semester -> path and path -> semester mappings
export const fromSemester: { [semester: string]: string } = {};
const toSemester: { [key: string]: Semester } = {};
each(config.shortSemesterNames, (name, semester) => {
  const path = kebabCase(name);
  fromSemester[semester] = path;
  toSemester[path] = Number(semester);
});

// Semester -> Timetable path
export function timetablePage(semester: Semester): string {
  return `/timetable/${fromSemester[semester]}`;
}

export const TIMETABLE_SHARE = 'share';
export function timetableShare(semester: Semester, timetable: SemTimetableConfig): string {
  return `${timetablePage(semester)}/${TIMETABLE_SHARE}?${serializeTimetable(timetable)}`;
}

// Timetable path -> Semester
export function semesterForTimetablePage(semStr: string | null | undefined): Semester | null {
  if (!semStr) return null;
示例#2
0
  init() {
    var app = angular.module('grafana', []);

    moment.locale(config.bootData.user.locale);

    app.config(($locationProvider, $controllerProvider, $compileProvider, $filterProvider, $httpProvider, $provide) => {
      // pre assing bindings before constructor calls
      $compileProvider.preAssignBindingsEnabled(true);

      if (config.buildInfo.env !== 'development') {
        $compileProvider.debugInfoEnabled(false);
      }

      $httpProvider.useApplyAsync(true);

      this.registerFunctions.controller = $controllerProvider.register;
      this.registerFunctions.directive  = $compileProvider.directive;
      this.registerFunctions.factory    = $provide.factory;
      this.registerFunctions.service    = $provide.service;
      this.registerFunctions.filter     = $filterProvider.register;

      $provide.decorator("$http", ["$delegate", "$templateCache", function($delegate, $templateCache) {
        var get = $delegate.get;
        $delegate.get = function(url, config) {
          if (url.match(/\.html$/)) {
            // some template's already exist in the cache
            if (!$templateCache.get(url)) {
              url += "?v=" + new Date().getTime();
            }
          }
          return get(url, config);
        };
        return $delegate;
      }]);
    });

    this.ngModuleDependencies = [
      'grafana.core',
      'ngRoute',
      'ngSanitize',
      '$strap.directives',
      'ang-drag-drop',
      'grafana',
      'pasvaz.bindonce',
      'ui.bootstrap',
      'ui.bootstrap.tpls',
      'react'
    ];

    var module_types = ['controllers', 'directives', 'factories', 'services', 'filters', 'routes'];

    _.each(module_types, type => {
      var moduleName = 'grafana.' + type;
      this.useModule(angular.module(moduleName, []));
    });

    // makes it possible to add dynamic stuff
    this.useModule(coreModule);

    // register react angular wrappers
    registerAngularDirectives();

    var preBootRequires = [System.import('app/features/all')];

    Promise.all(preBootRequires).then(() => {
      // disable tool tip animation
      $.fn.tooltip.defaults.animation = false;
      // bootstrap the app
      angular.bootstrap(document, this.ngModuleDependencies).invoke(() => {
        _.each(this.preBootModules, module => {
          _.extend(module, this.registerFunctions);
        });

        this.preBootModules = null;
      });
    }).catch(function(err) {
      console.log('Application boot failed:', err);
    });
  }
export function generateTreatments(evidenceTreatments:any)
{
    var treatments: any = {};
    var result: any[] = [];

    _.each(evidenceTreatments, function(content, type) {
        _.each(content, function(item, index) {
            var _level = getLevel(item.level);
            var _treatment = treatmentsToStr(item.content);
            var _tumorType = item.tumorType;
            var _alterations = item.alterations.map(function(alt:any) {
                return alt.alteration;
            }).join(',');
            if (!treatments.hasOwnProperty(_level)) {
                treatments[_level] = {};
            }
            if (!treatments[_level].hasOwnProperty(_alterations)) {
                treatments[_level][_alterations] = {};
            }

            if (!treatments[_level][_alterations].hasOwnProperty(_treatment)) {
                treatments[_level][_alterations][_treatment] = {};
            }

            if (!treatments[_level][_alterations][_treatment].hasOwnProperty(_tumorType)) {
                treatments[_level][_alterations][_treatment][_tumorType] = {
                    articles: [],
                    tumorType: _tumorType,
                    alterations: item.alterations,
                    level: _level,
                    description: item.description,
                    treatment: _treatment
                };
            } else {
                treatments[_level][_alterations][_treatment][_tumorType].description = [treatments[_level][_alterations][_treatment][_tumorType].description, '<br/>', item.description].join();
            }
            treatments[_level][_alterations][_treatment][_tumorType].articles = _.union(treatments[_level][_alterations][_treatment][_tumorType].articles, item.articles);
        });
    });

    _.each(_.keys(treatments).sort(function(a, b) {
        return LEVELS.all.indexOf(a) > LEVELS.all.indexOf(b) ? -1 : 1;
    }), function(level) {
        _.each(_.keys(treatments[level]).sort(), function(_alteration) {
            _.each(_.keys(treatments[level][_alteration]).sort(), function(_treatment) {
                _.each(_.keys(treatments[level][_alteration][_treatment]).sort(), function(_tumorType) {
                    var content = treatments[level][_alteration][_treatment][_tumorType];
                    result.push({
                        level: content.level,
                        variant: content.alterations.map(function(alteration:any) {
                            return alteration.alteration;
                        }),
                        treatment: _treatment,
                        pmids: content.articles.filter(function(article:any) {
                            return !isNaN(article.pmid);
                        }).map(function(article:any) {
                            return Number(article.pmid);
                        }).sort(),
                        abstracts: content.articles.filter(function(article:any) {
                            return _.isString(article.abstract);
                        }).map(function(article:any) {
                            return {
                                abstract: article.abstract,
                                link: article.link
                            };
                        }),
                        description: content.description,
                        cancerType: content.tumorType
                    });
                });
            });
        });
    });

    return result;
}
示例#4
0
  _handleIncomingPayments(coin, network, data) {
    if (!data) return;
    // console.log('[blockchainmonitor.js.158:data:]',data); //TODO

    let outs: any[];
    // ! v8?
    if (!data.outs) {
      if (!data.vout) return;
      outs = _.compact(
        _.map(data.vout, (v) => {
          let addr = _.keys(v)[0];
          const amount = +v[addr];

          return {
            address: addr,
            amount
          };
        })
      );
      if (_.isEmpty(outs)) return;
    } else {
      outs = data.outs;
      _.each(outs, x => {
        if (x.amount) {
          // to satoshis
          x.amount = +(x.amount * 1e8).toFixed(0);
        }
      });
    }
    async.each(
      outs,
      (out, next) => {
        if (!out.address) return next();

        // toDo, remove coin  here: no more same address for diff coins
        this.storage.fetchAddressByCoin(coin, out.address, (
          err,
          address
        ) => {
          if (err) {
            log.error('Could not fetch addresses from the db');
            return next(err);
          }
          if (!address || address.isChange) return next();

          const walletId = address.walletId;
          log.debug(
            'Incoming tx for wallet ' +
            walletId +
            ' [' +
            out.amount +
            'sat -> ' +
            out.address +
            ']'
          );

          const fromTs = Date.now() - 24 * 3600 * 1000;
          this.storage.fetchNotifications(walletId, null, fromTs, (
            err,
            notifications
          ) => {
            if (err) return next(err);
            const alreadyNotified = _.some(notifications, (n) => {
              return (
                n.type == 'NewIncomingTx' && n.data && n.data.txid == data.txid
              );
            });
            if (alreadyNotified) {
              log.debug(
                'The incoming tx ' + data.txid + ' was already notified'
              );
              return next();
            }

            const notification = Notification.create({
              type: 'NewIncomingTx',
              data: {
                txid: data.txid,
                address: out.address,
                amount: out.amount
              },
              walletId
            });

            this._storeAndBroadcastNotification(notification, next);
          });
        });
      },
      (err) => {
        return;
      }
    );
  }
 (acc, results) => {
     _.each(results, result => {
         result.filePath = atom.project.relativizePath(result.filePath)[1];
     });
     return acc.concat(results);
 },
示例#6
0
function generateProjects(): any {

    let companyIds = Object.keys(store.companyMap);

    let projects = [
        'Cheerful Planet',
        'Star Rainbow',
        'Brave Mountain',
        'Electron',
        'Locomotive',
        'Compass',
        'Plutonium',
        'Jupiter',
        'Scoreboard',
        'Zeus',
        'Gamma',
        'Winter',
        'Helium',
        'Orange Fox',
        'Star Burst',
        'Puppet',
        'Eastern Railroad',
        'April Showers',
        'Dinosaur',
        'Elastic Cloud',
        'Rare Jazz',
        'Tungsten',
        'Sapphire',
        'Golden Viper',
        'Pink Floyd',
        'Aerosmith',
        'Stones',
        'Zeppelin',
        'Eagles',
        'Maroon Five'
    ];

    let locations = [
        'ATL',
        'BOS',
        'DEN',
        'DET',
        'LAS',
        'LAX',
        'MIA',
        'NYC',
        'ORD',
        'SFO'
    ];

    let projectMap: any = {};

    _.each(projects, company => {
        let id = nextId++;
        projectMap[id] = {
            id: id,
            name: company,
            location: chance.pick(locations),
            companyId: parseInt(chance.pick(companyIds))
        };
    });

    return projectMap;
}
示例#7
0
  { from: 'now-2d', to: 'now', display: 'Last 2 days', section: 0 },
  { from: 'now-7d', to: 'now', display: 'Last 7 days', section: 0 },
  { from: 'now-30d', to: 'now', display: 'Last 30 days', section: 0 },
  { from: 'now-90d', to: 'now', display: 'Last 90 days', section: 0 },
  { from: 'now-6M', to: 'now', display: 'Last 6 months', section: 0 },
  { from: 'now-1y', to: 'now', display: 'Last 1 year', section: 0 },
  { from: 'now-2y', to: 'now', display: 'Last 2 years', section: 0 },
  { from: 'now-5y', to: 'now', display: 'Last 5 years', section: 0 },
];

const absoluteFormat = 'MMM D, YYYY HH:mm:ss';

const rangeIndex = {};
_.each(rangeOptions, frame => {
  rangeIndex[frame.from + ' to ' + frame.to] = frame;
});

export function getRelativeTimesList(timepickerSettings, currentDisplay) {
  const groups = _.groupBy(rangeOptions, (option: any) => {
    option.active = option.display === currentDisplay;
    return option.section;
  });

  // _.each(timepickerSettings.time_options, (duration: string) => {
  //   let info = describeTextRange(duration);
  //   if (info.section) {
  //     groups[info.section].push(info);
  //   }
  // });
示例#8
0
 _.each(seriesList, function(series) {
     _.each(series.datapoints, function(dp) {
         text += series.alias + ',' + new Date(dp[1]).toISOString() + ',' + dp[0] + '\n';
     });
 });
示例#9
0
文件: gfunc.ts 项目: arcolife/grafana
addFuncDef({
  name: 'aliasByTags',
  category: categories.Special,
  params: [
    { name: 'tag', type: 'string' },
    { name: 'tag', type: 'string', optional: true },
    { name: 'tag', type: 'string', optional: true },
    { name: 'tag', type: 'string', optional: true },
  ],
  defaultParams: ['tag'],
  version: '1.1',
});

_.each(categories, function(funcList, catName) {
  categories[catName] = _.sortBy(funcList, 'name');
});

function isVersionRelatedFunction(func, graphiteVersion) {
  return isVersionGtOrEq(graphiteVersion, func.version) || !func.version;
}

export class FuncInstance {
  def: any;
  params: any;
  text: any;
  added: boolean;

  constructor(funcDef, options) {
    this.def = funcDef;
    this.params = [];
示例#10
0
 function mapModel() {
     _.each($scope.fields, field => {
         field.visible = $scope.fieldOps.hasContent(field);
     });
 }