• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript FetchProvider.default函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中logic/rest/FetchProvider.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了default函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: require

/// <reference path="../../../declarations/bluebird/bluebird.d.ts" />

import jsRoutes = require('routing/jsRoutes');
const URLUtils = require('util/URLUtils');
const fetch = require('logic/rest/FetchProvider').default;

const UserNotification = require('util/UserNotification');

export interface UsageStatsOptOutState {
    opt_out: boolean
}

export var UsageStatsOptOutStore = {
    pluginEnabled(): Promise<boolean> {
        var url = URLUtils.qualifyUrl(jsRoutes.controllers.api.UsageStatsApiController.pluginEnabled().url);
        var promise = fetch('GET', url);

        promise = promise
            .then(response => {
                return response.enabled;
            })
            .catch(() => {
                // When the plugin is not loaded the CORS options request will fail and we can't tell at this point
                // what was the cause for the problem. Therefore, we return false and don't notify the user.
                return false;
            });

        return promise;
    },
    getOptOutState(): Promise<UsageStatsOptOutState> {
        var url = URLUtils.qualifyUrl(jsRoutes.controllers.api.UsageStatsApiController.setOptOutState().url);
开发者ID:RootR90,项目名称:graylog2-server,代码行数:31,代码来源:UsageStatsOptOutStore.ts


示例2: require

import UserNotification = require("../../util/UserNotification");
import URLUtils = require("../../util/URLUtils");
import jsRoutes = require('routing/jsRoutes');
const fetch = require('logic/rest/FetchProvider').default;

interface Output {
  id: string;
  title: string;
  type: string;
}

const OutputsStore = {
  OUTPUTS_URL: URLUtils.qualifyUrl(jsRoutes.controllers.api.OutputsApiController.index().url),

  load(callback : (outputs: Array<Output>) => void) {
    fetch('GET', this.OUTPUTS_URL).then(callback, this._failCallback);
  },
  loadForStreamId(streamId: string, callback: (outputs: Array<Output>) => void) {
    const url = URLUtils.qualifyUrl(jsRoutes.controllers.api.StreamOutputsApiController.index(streamId).url);
    fetch('GET', url).then(callback, this._failCallback);
  },
  loadAvailableTypes(callback: (available: any) => void) {
    const url = URLUtils.qualifyUrl(jsRoutes.controllers.api.OutputsApiController.availableTypes().url);
    fetch('GET', url).then(callback, this._failCallback);
  },
  loadAvailable(typeName: string, callback: (available: any) => void) {
    const url = URLUtils.qualifyUrl(jsRoutes.controllers.api.OutputsApiController.availableTypes().url);
    fetch('GET', url).then((resp) => {
      return resp.types[typeName];
    }, this._failCallback).then(callback);
  },
开发者ID:Graylog2,项目名称:graylog2-web-interface,代码行数:31,代码来源:OutputsStore.ts


示例3: require

/// <reference path="../../../declarations/bluebird/bluebird.d.ts" />

import ApiRoutes = require('routing/ApiRoutes');
const URLUtils = require('util/URLUtils');
const UserNotification = require('util/UserNotification');
const fetch = require('logic/rest/FetchProvider').default;

const ToolsStore = {
    testNaturalDate(text: string): Promise<string[]> {
        const url = ApiRoutes.ToolsApiController.naturalDateTest(text).url;
        const promise = fetch('GET', URLUtils.qualifyUrl(url));

        promise.catch((errorThrown) => {
            if (errorThrown.additional.status !== 422) {
                UserNotification.error("Loading keyword preview failed with status: " + errorThrown,
                    "Could not load keyword preview");
            }
        });

        return promise;
    },
    testGrok(pattern: string, string: string): Promise<Object> {
        const url = ApiRoutes.ToolsApiController.grokTest().url;
        const promise = fetch('POST', URLUtils.qualifyUrl(url), {pattern: pattern, string: string});

        promise.catch((errorThrown) => {
            UserNotification.error('Details: ' + errorThrown,
                'We were not able to run the grok extraction. Please check your parameters.');
        });

        return promise;
开发者ID:GMarciales,项目名称:graylog2-server,代码行数:31,代码来源:ToolsStore.ts


示例4: require

/// <reference path="../../../declarations/bluebird/bluebird.d.ts" />

import ApiRoutes = require('routing/ApiRoutes');
const URLUtils = require('util/URLUtils');
const UserNotification = require('util/UserNotification');
const fetch = require('logic/rest/FetchProvider').default;

const ToolsStore = {
    testNaturalDate(text: string): Promise<string[]> {
        const url = ApiRoutes.ToolsApiController.naturalDateTest(text).url;
        const promise = fetch('GET', URLUtils.qualifyUrl(url));

        promise.catch((errorThrown) => {
            if (errorThrown.additional.status !== 422) {
                UserNotification.error("Loading keyword preview failed with status: " + errorThrown,
                    "Could not load keyword preview");
            }
        });

        return promise;
    },
    testGrok(pattern: string, namedCapturesOnly: boolean, string: string): Promise<Object> {
        const url = ApiRoutes.ToolsApiController.grokTest().url;
        const promise = fetch('POST', URLUtils.qualifyUrl(url), {pattern: pattern, string: string, named_captures_only: namedCapturesOnly});

        promise.catch((errorThrown) => {
            UserNotification.error('Details: ' + errorThrown,
                'We were not able to run the grok extraction. Please check your parameters.');
        });

        return promise;
开发者ID:mcenirm-forks,项目名称:graylog2-server,代码行数:31,代码来源:ToolsStore.ts


示例5: require

const fetch = require('logic/rest/FetchProvider').default;

interface Role {
  name: string;
  description: string;
  permissions: string[];
}

interface RoleMembership {
  role: string;
  users: UsersStore.User[];
}

const RolesStore = {
  loadRoles(): Promise<string[]> {
    const promise = fetch('GET', URLUtils.qualifyUrl(ApiRoutes.RolesApiController.listRoles().url))
      .then(
        response => response.roles,
        error => {
          if (error.additional.status !== 404) {
            UserNotification.error("Loading role list failed with status: " + error,
              "Could not load role list");
          }
        }
      );

    return promise;
  },

  createRole(role: Role): Promise<Role> {
    const url = URLUtils.qualifyUrl(ApiRoutes.RolesApiController.createRole().url);
开发者ID:mcenirm-forks,项目名称:graylog2-server,代码行数:31,代码来源:RolesStore.ts


示例6: fetch

 list(streamId: String, skip: Number, limit: Number) {
     var failCallback = (error) => {
         UserNotification.error("Fetching alerts failed with status: " + error.message,
             "Could not retrieve alerts.");
     };
     var url = URLUtils.qualifyUrl(ApiRoutes.AlertsApiController.list(streamId, skip, limit).url);
     return fetch('GET', url).catch(failCallback);
 }
开发者ID:JJediny,项目名称:graylog2-server,代码行数:8,代码来源:AlertsStore.ts


示例7: fetch

    listForAlert(streamId: String, alertId: String) {
        var failCallback = (error) => {
            UserNotification.error("Fetching alarm callback history failed with status: " + error,
                "Could not retrieve alarm callback history.");
        };
        var url = URLUtils.qualifyUrl(jsRoutes.controllers.api.AlarmCallbackHistoryApiController.list(streamId, alertId).url);

        return fetch('GET', url).catch(failCallback);
    }
开发者ID:Graylog2,项目名称:graylog2-web-interface,代码行数:9,代码来源:AlarmCallbackHistoryStore.ts


示例8: loadMessage

interface Field {
    name: string;
    value: string;
}

interface Message {
    id: string;
    index: number;
    fields: Array<Field>;
}

var MessagesStore = {
    loadMessage(index: string, messageId: string): Promise<Message> {
        var url = ApiRoutes.MessagesController.single(index.trim(), messageId.trim()).url;
        const promise = fetch('GET', URLUtils.qualifyUrl(url))
            .then(response => {
                const message = response.message;
                const fields = message.fields;
                const filteredFields = MessageFieldsFilter.filterFields(fields);
                const newMessage = {
                    id: message.id,
                    timestamp: moment(message.timestamp).unix(),
                    filtered_fields: filteredFields,
                    formatted_fields: filteredFields,
                    fields: fields,
                    index: response.index,
                    source_node_id: fields.gl2_source_node,
                    source_input_id: fields.gl2_source_input,
                    stream_ids: message.streams,
                };
开发者ID:GMarciales,项目名称:graylog2-server,代码行数:30,代码来源:MessagesStore.ts


示例9: fetch

            case 'absolute':
                timerange['from'] = originalSearchURLParams.get('from');
                timerange['to'] = originalSearchURLParams.get('to');
                break;
            case 'keyword':
                timerange['keyword'] = originalSearchURLParams.get('keyword');
                break;
        }

        var url = ApiRoutes.UniversalSearchApiController.fieldTerms(
            rangeType,
            originalSearchURLParams.get('q') || '*',
            field,
            timerange,
            streamId
        ).url;

        url = URLUtils.qualifyUrl(url);

        var promise = fetch('GET', url);
        promise.catch(error => {
            UserNotification.error('Loading quick values failed with status: ' + error,
                'Could not load quick values');
        });

        return promise;
    },
};

module.exports = FieldQuickValuesStore;
开发者ID:3nity-sol,项目名称:graylog2-server,代码行数:30,代码来源:FieldQuickValuesStore.ts


示例10: loadSources

        total += count;
        sourcesArray.push({name: StringUtils.escapeHTML(name), message_count: count})
    });
    sourcesArray.forEach((d) => {
        d.percentage = d.message_count / total * 100;
    });
    return sourcesArray;
};

const SourcesStore = {
    SOURCES_URL: '/sources',

    loadSources(range: number, callback: (sources: Array<Source>) => void) {
        let url = URLUtils.qualifyUrl(this.SOURCES_URL);
        if (typeof range !== 'undefined') {
            url += "?range=" + range;
        }
        fetch('GET', url)
            .then(response => {
                var sources = processSourcesData(response.sources);
                callback(sources);
            })
            .catch((errorThrown) => {
                UserNotification.error("Loading of sources data failed with status: " + errorThrown + ". Try reloading the page.",
                    "Could not load sources data");
            });
    }
};

export = SourcesStore;
开发者ID:3nity-sol,项目名称:graylog2-server,代码行数:30,代码来源:SourcesStore.ts



注:本文中的logic/rest/FetchProvider.default函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript loglevel.debug函数代码示例发布时间:2022-05-25
下一篇:
TypeScript logic-base.IResourceLogic类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap