hunk
dict
file
stringlengths
0
11.8M
file_path
stringlengths
2
234
label
int64
0
1
commit_url
stringlengths
74
103
dependency_score
sequencelengths
5
5
{ "id": 3, "code_window": [ "\n", "4. Some new fields will appear. Fill in a name for the service account in the `Service account name` field and then choose the `Monitoring Viewer` role from the `Role` dropdown:\n", "\n", " ![Choose role](/img/docs/v53/stackdriver_service_account_choose_role.png)\n", "\n", "5. Click the Create button. A JSON key file will be created and downloaded to your computer. Store this file in a secure place as it allows access to your Stackdriver data.\n", "6. Upload it to Grafana on the datasource Configuration page. You can either upload the file or paste in the contents of the file.\n", "\n" ], "labels": [ "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep" ], "after_edit": [ " {{< docs-imagebox img=\"/img/docs/v53/stackdriver_service_account_choose_role.png\" class=\"docs-image--no-shadow\" caption=\"Choose role\" >}}\n", " \n" ], "file_path": "docs/sources/features/datasources/stackdriver.md", "type": "replace", "edit_start_line_idx": 65 }
package text import ( "bytes" "math" ) var ( nl = []byte{'\n'} sp = []byte{' '} ) const defaultPenalty = 1e5 // Wrap wraps s into a paragraph of lines of length lim, with minimal // raggedness. func Wrap(s string, lim int) string { return string(WrapBytes([]byte(s), lim)) } // WrapBytes wraps b into a paragraph of lines of length lim, with minimal // raggedness. func WrapBytes(b []byte, lim int) []byte { words := bytes.Split(bytes.Replace(bytes.TrimSpace(b), nl, sp, -1), sp) var lines [][]byte for _, line := range WrapWords(words, 1, lim, defaultPenalty) { lines = append(lines, bytes.Join(line, sp)) } return bytes.Join(lines, nl) } // WrapWords is the low-level line-breaking algorithm, useful if you need more // control over the details of the text wrapping process. For most uses, either // Wrap or WrapBytes will be sufficient and more convenient. // // WrapWords splits a list of words into lines with minimal "raggedness", // treating each byte as one unit, accounting for spc units between adjacent // words on each line, and attempting to limit lines to lim units. Raggedness // is the total error over all lines, where error is the square of the // difference of the length of the line and lim. Too-long lines (which only // happen when a single word is longer than lim units) have pen penalty units // added to the error. func WrapWords(words [][]byte, spc, lim, pen int) [][][]byte { n := len(words) length := make([][]int, n) for i := 0; i < n; i++ { length[i] = make([]int, n) length[i][i] = len(words[i]) for j := i + 1; j < n; j++ { length[i][j] = length[i][j-1] + spc + len(words[j]) } } nbrk := make([]int, n) cost := make([]int, n) for i := range cost { cost[i] = math.MaxInt32 } for i := n - 1; i >= 0; i-- { if length[i][n-1] <= lim || i == n-1 { cost[i] = 0 nbrk[i] = n } else { for j := i + 1; j < n; j++ { d := lim - length[i][j-1] c := d*d + cost[j] if length[i][j-1] > lim { c += pen // too-long lines get a worse penalty } if c < cost[i] { cost[i] = c nbrk[i] = j } } } } var lines [][][]byte i := 0 for i < n { lines = append(lines, words[i:nbrk[i]]) i = nbrk[i] } return lines }
vendor/github.com/kr/text/wrap.go
0
https://github.com/grafana/grafana/commit/03fefd7beaa322ea4fbfb2cb0aa2f8bc3d5dd6ff
[ 0.0001741393789416179, 0.00017121166456490755, 0.0001633319625398144, 0.00017166169709526002, 0.000003010759655808215 ]
{ "id": 3, "code_window": [ "\n", "4. Some new fields will appear. Fill in a name for the service account in the `Service account name` field and then choose the `Monitoring Viewer` role from the `Role` dropdown:\n", "\n", " ![Choose role](/img/docs/v53/stackdriver_service_account_choose_role.png)\n", "\n", "5. Click the Create button. A JSON key file will be created and downloaded to your computer. Store this file in a secure place as it allows access to your Stackdriver data.\n", "6. Upload it to Grafana on the datasource Configuration page. You can either upload the file or paste in the contents of the file.\n", "\n" ], "labels": [ "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep" ], "after_edit": [ " {{< docs-imagebox img=\"/img/docs/v53/stackdriver_service_account_choose_role.png\" class=\"docs-image--no-shadow\" caption=\"Choose role\" >}}\n", " \n" ], "file_path": "docs/sources/features/datasources/stackdriver.md", "type": "replace", "edit_start_line_idx": 65 }
+++ title = "Authentication" description = "Authentication" type = "docs" [menu.docs] name = "Authentication" identifier = "authentication" parent = "admin" weight = 3 +++
docs/sources/auth/index.md
0
https://github.com/grafana/grafana/commit/03fefd7beaa322ea4fbfb2cb0aa2f8bc3d5dd6ff
[ 0.0001733873359626159, 0.00016999660874716938, 0.00016660589608363807, 0.00016999660874716938, 0.0000033907199394889176 ]
{ "id": 4, "code_window": [ "5. Click the Create button. A JSON key file will be created and downloaded to your computer. Store this file in a secure place as it allows access to your Stackdriver data.\n", "6. Upload it to Grafana on the datasource Configuration page. You can either upload the file or paste in the contents of the file.\n", "\n", " ![Choose role](/img/docs/v53/stackdriver_grafana_upload_key.png)\n", "\n", "7. The file contents will be encrypted and saved in the Grafana database. Don't forget to save after uploading the file!\n", "\n" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep" ], "after_edit": [ " {{< docs-imagebox img=\"/img/docs/v53/stackdriver_grafana_upload_key.png\" class=\"docs-image--no-shadow\" caption=\"Upload service key file to Grafana\" >}}\n" ], "file_path": "docs/sources/features/datasources/stackdriver.md", "type": "replace", "edit_start_line_idx": 70 }
+++ title = "Grafana documentation" description = "Guides, Installation & Feature Documentation" keywords = ["grafana", "installation", "documentation"] type = "docs" aliases = ["v1.1", "guides/reference/admin"] +++ # Grafana Documentation <h2>Installing Grafana</h2> <div class="nav-cards"> <a href="{{< relref "installation/debian.md" >}}" class="nav-cards__item nav-cards__item--install"> <div class="nav-cards__icon fa fa-linux"> </div> <h5>Installing on Linux</h5> </a> <a href="{{< relref "installation/mac.md" >}}" class="nav-cards__item nav-cards__item--install"> <div class="nav-cards__icon fa fa-apple"> </div> <h5>Installing on Mac OS X</h5> </a> <a href="{{< relref "installation/windows.md" >}}" class="nav-cards__item nav-cards__item--install"> <div class="nav-cards__icon fa fa-windows"> </div> <h5>Installing on Windows</h5> </a> <a href="https://grafana.com/cloud/grafana" class="nav-cards__item nav-cards__item--install"> <div class="nav-cards__icon fa fa-cloud"> </div> <h5>Grafana Cloud</h5> </a> <a href="https://grafana.com/grafana/download" class="nav-cards__item nav-cards__item--install"> <div class="nav-cards__icon fa fa-moon-o"> </div> <h5>Nightly Builds</h5> </a> <div class="nav-cards__item nav-cards__item--install"> <h5>For other platforms Read the <a href="{{< relref "project/building_from_source.md" >}}">build from source</a> instructions for more information.</h5> </div> </div> <h2>Guides</h2> <div class="nav-cards"> <a href="https://grafana.com/grafana" class="nav-cards__item nav-cards__item--guide"> <h4>What is Grafana?</h4> <p>Grafana feature highlights.</p> </a> <a href="{{< relref "installation/configuration.md" >}}" class="nav-cards__item nav-cards__item--guide"> <h4>Configure Grafana</h4> <p>Article on all the Grafana configuration and setup options.</p> </a> <a href="{{< relref "guides/getting_started.md" >}}" class="nav-cards__item nav-cards__item--guide"> <h4>Getting Started</h4> <p>A guide that walks you through the basics of using Grafana</p> </a> <a href="{{< relref "administration/provisioning.md" >}}" class="nav-cards__item nav-cards__item--guide"> <h4>Provisioning</h4> <p>A guide to help you automate your Grafana setup & configuration.</p> </a> <a href="{{< relref "guides/whats-new-in-v5-2.md" >}}" class="nav-cards__item nav-cards__item--guide"> <h4>What's new in v5.2</h4> <p>Article on all the new cool features and enhancements in v5.2</p> </a> <a href="{{< relref "tutorials/screencasts.md" >}}" class="nav-cards__item nav-cards__item--guide"> <h4>Screencasts</h4> <p>Video tutorials & guides</p> </a> </div> <h2>Data Source Guides</h2> <div class="nav-cards"> <a href="{{< relref "features/datasources/graphite.md" >}}" class="nav-cards__item nav-cards__item--ds"> <img src="/img/docs/logos/icon_graphite.svg" > <h5>Graphite</h5> </a> <a href="{{< relref "features/datasources/elasticsearch.md" >}}" class="nav-cards__item nav-cards__item--ds"> <img src="/img/docs/logos/icon_elasticsearch.svg" > <h5>Elasticsearch</h5> </a> <a href="{{< relref "features/datasources/influxdb.md" >}}" class="nav-cards__item nav-cards__item--ds"> <img src="/img/docs/logos/icon_influxdb.svg" > <h5>InfluxDB</h5> </a> <a href="{{< relref "features/datasources/prometheus.md" >}}" class="nav-cards__item nav-cards__item--ds"> <img src="/img/docs/logos/icon_prometheus.svg" > <h5>Prometheus</h5> </a> <a href="{{< relref "features/datasources/opentsdb.md" >}}" class="nav-cards__item nav-cards__item--ds"> <img src="/img/docs/logos/icon_opentsdb.png" > <h5>OpenTSDB</h5> </a> <a href="{{< relref "features/datasources/mysql.md" >}}" class="nav-cards__item nav-cards__item--ds"> <img src="/img/docs/logos/icon_mysql.png" > <h5>MySQL</h5> </a> <a href="{{< relref "features/datasources/postgres.md" >}}" class="nav-cards__item nav-cards__item--ds"> <img src="/img/docs/logos/icon_postgres.svg" > <h5>Postgres</h5> </a> <a href="{{< relref "features/datasources/cloudwatch.md" >}}" class="nav-cards__item nav-cards__item--ds"> <img src="/img/docs/logos/icon_cloudwatch.svg"> <h5>Cloudwatch</h5> </a> <a href="{{< relref "features/datasources/mssql.md" >}}" class="nav-cards__item nav-cards__item--ds"> <img src="/img/docs/logos/sql_server_logo.svg"> <h5>Microsoft SQL Server</h5> </a> <a href="{{< relref "features/datasources/stackdriver.md" >}}" class="nav-cards__item nav-cards__item--ds"> <img src="/img/docs/logos/stackdriver_logo.png"> <h5>Google Stackdriver</h5> </a> </div>
docs/sources/index.md
1
https://github.com/grafana/grafana/commit/03fefd7beaa322ea4fbfb2cb0aa2f8bc3d5dd6ff
[ 0.0005690956022590399, 0.0002322099171578884, 0.00016585001139901578, 0.00017828147974796593, 0.00011949128384003416 ]
{ "id": 4, "code_window": [ "5. Click the Create button. A JSON key file will be created and downloaded to your computer. Store this file in a secure place as it allows access to your Stackdriver data.\n", "6. Upload it to Grafana on the datasource Configuration page. You can either upload the file or paste in the contents of the file.\n", "\n", " ![Choose role](/img/docs/v53/stackdriver_grafana_upload_key.png)\n", "\n", "7. The file contents will be encrypted and saved in the Grafana database. Don't forget to save after uploading the file!\n", "\n" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep" ], "after_edit": [ " {{< docs-imagebox img=\"/img/docs/v53/stackdriver_grafana_upload_key.png\" class=\"docs-image--no-shadow\" caption=\"Upload service key file to Grafana\" >}}\n" ], "file_path": "docs/sources/features/datasources/stackdriver.md", "type": "replace", "edit_start_line_idx": 70 }
// Copyright 2013 by Dobrosław Żybort. All rights reserved. // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. package slug import ( "bytes" "regexp" "sort" "strings" "github.com/rainycape/unidecode" ) var ( // CustomSub stores custom substitution map CustomSub map[string]string // CustomRuneSub stores custom rune substitution map CustomRuneSub map[rune]string // MaxLength stores maximum slug length. // It's smart so it will cat slug after full word. // By default slugs aren't shortened. // If MaxLength is smaller than length of the first word, then returned // slug will contain only substring from the first word truncated // after MaxLength. MaxLength int regexpNonAuthorizedChars = regexp.MustCompile("[^a-z0-9-_]") regexpMultipleDashes = regexp.MustCompile("-+") ) //============================================================================= // Make returns slug generated from provided string. Will use "en" as language // substitution. func Make(s string) (slug string) { return MakeLang(s, "en") } // MakeLang returns slug generated from provided string and will use provided // language for chars substitution. func MakeLang(s string, lang string) (slug string) { slug = strings.TrimSpace(s) // Custom substitutions // Always substitute runes first slug = SubstituteRune(slug, CustomRuneSub) slug = Substitute(slug, CustomSub) // Process string with selected substitution language switch lang { case "de": slug = SubstituteRune(slug, deSub) case "en": slug = SubstituteRune(slug, enSub) case "pl": slug = SubstituteRune(slug, plSub) case "es": slug = SubstituteRune(slug, esSub) case "gr": slug = SubstituteRune(slug, grSub) default: // fallback to "en" if lang not found slug = SubstituteRune(slug, enSub) } // Process all non ASCII symbols slug = unidecode.Unidecode(slug) slug = strings.ToLower(slug) // Process all remaining symbols slug = regexpNonAuthorizedChars.ReplaceAllString(slug, "-") slug = regexpMultipleDashes.ReplaceAllString(slug, "-") slug = strings.Trim(slug, "-") if MaxLength > 0 { slug = smartTruncate(slug) } return slug } // Substitute returns string with superseded all substrings from // provided substitution map. Substitution map will be applied in alphabetic // order. Many passes, on one substitution another one could apply. func Substitute(s string, sub map[string]string) (buf string) { buf = s var keys []string for k := range sub { keys = append(keys, k) } sort.Strings(keys) for _, key := range keys { buf = strings.Replace(buf, key, sub[key], -1) } return } // SubstituteRune substitutes string chars with provided rune // substitution map. One pass. func SubstituteRune(s string, sub map[rune]string) string { var buf bytes.Buffer for _, c := range s { if d, ok := sub[c]; ok { buf.WriteString(d) } else { buf.WriteRune(c) } } return buf.String() } func smartTruncate(text string) string { if len(text) < MaxLength { return text } var truncated string words := strings.SplitAfter(text, "-") // If MaxLength is smaller than length of the first word return word // truncated after MaxLength. if len(words[0]) > MaxLength { return words[0][:MaxLength] } for _, word := range words { if len(truncated)+len(word)-1 <= MaxLength { truncated = truncated + word } else { break } } return strings.Trim(truncated, "-") } // IsSlug returns True if provided text does not contain white characters, // punctuation, all letters are lower case and only from ASCII range. // It could contain `-` and `_` but not at the beginning or end of the text. // It should be in range of the MaxLength var if specified. // All output from slug.Make(text) should pass this test. func IsSlug(text string) bool { if text == "" || (MaxLength > 0 && len(text) > MaxLength) || text[0] == '-' || text[0] == '_' || text[len(text)-1] == '-' || text[len(text)-1] == '_' { return false } for _, c := range text { if (c < 'a' || c > 'z') && c != '-' && c != '_' && (c < '0' || c > '9') { return false } } return true }
vendor/github.com/gosimple/slug/slug.go
0
https://github.com/grafana/grafana/commit/03fefd7beaa322ea4fbfb2cb0aa2f8bc3d5dd6ff
[ 0.00018256963812746108, 0.00016882280760910362, 0.00016588938888162374, 0.000167203601449728, 0.000004212714429741027 ]
{ "id": 4, "code_window": [ "5. Click the Create button. A JSON key file will be created and downloaded to your computer. Store this file in a secure place as it allows access to your Stackdriver data.\n", "6. Upload it to Grafana on the datasource Configuration page. You can either upload the file or paste in the contents of the file.\n", "\n", " ![Choose role](/img/docs/v53/stackdriver_grafana_upload_key.png)\n", "\n", "7. The file contents will be encrypted and saved in the Grafana database. Don't forget to save after uploading the file!\n", "\n" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep" ], "after_edit": [ " {{< docs-imagebox img=\"/img/docs/v53/stackdriver_grafana_upload_key.png\" class=\"docs-image--no-shadow\" caption=\"Upload service key file to Grafana\" >}}\n" ], "file_path": "docs/sources/features/datasources/stackdriver.md", "type": "replace", "edit_start_line_idx": 70 }
+++ title = "Search" keywords = ["grafana", "dashboard", "documentation", "search"] type = "docs" [menu.docs] parent = "dashboard_features" weight = 5 +++ # Dashboard Search Dashboards can be searched by the dashboard name, filtered by one (or many) tags or filtered by starred status. The dashboard search is accessed through the dashboard picker, available in the dashboard top nav area. The dashboard search can also be opened by using the shortcut `F`. <img class="no-shadow" src="/img/docs/v50/dashboard_search_annotated.png" width="700px"> 1. `Search Bar`: The search bar allows you to enter any string and search both database and file based dashboards in real-time. 2. `Starred`: Here you find all your starred dashboards. 3. `Recent`: Here you find the latest created dashboards. 4. `Folders`: The tags filter allows you to filter the list by dashboard tags. 5. `Root`: The root contains all dashboards that are not placed in a folder. 6. `Tags`: The tags filter allows you to filter the list by dashboard tags. When using only a keyboard, you can use your keyboard arrow keys to navigate the results, hit enter to open the selected dashboard. ## Find by dashboard name Begin typing any part of the desired dashboard names in the search bar. Search will return results for for any partial string match in real-time, as you type. Dashboard search is: - Real-time - *Not* case sensitive - Functional across stored *and* file based dashboards. ## Filter by Tag(s) Tags are a great way to organize your dashboards, especially as the number of dashboards grow. Tags can be added and managed in the dashboard `Settings`. To filter the dashboard list by tag, click on any tag appearing in the right column. The list may be further filtered by clicking on additional tags: Alternately, to see a list of all available tags, click the tags dropdown menu. All tags will be shown, and when a tag is selected, the dashboard search will be instantly filtered: When using only a keyboard: `tab` to focus on the *tags* link, `▼` down arrow key to find a tag and select with the `Enter` key. **Note**: When multiple tags are selected, Grafana will show dashboards that include **all**.
docs/sources/reference/search.md
0
https://github.com/grafana/grafana/commit/03fefd7beaa322ea4fbfb2cb0aa2f8bc3d5dd6ff
[ 0.00019258965039625764, 0.0001770085364114493, 0.00016867188969627023, 0.00017505652795080096, 0.000008380638973903842 ]
{ "id": 4, "code_window": [ "5. Click the Create button. A JSON key file will be created and downloaded to your computer. Store this file in a secure place as it allows access to your Stackdriver data.\n", "6. Upload it to Grafana on the datasource Configuration page. You can either upload the file or paste in the contents of the file.\n", "\n", " ![Choose role](/img/docs/v53/stackdriver_grafana_upload_key.png)\n", "\n", "7. The file contents will be encrypted and saved in the Grafana database. Don't forget to save after uploading the file!\n", "\n" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep" ], "after_edit": [ " {{< docs-imagebox img=\"/img/docs/v53/stackdriver_grafana_upload_key.png\" class=\"docs-image--no-shadow\" caption=\"Upload service key file to Grafana\" >}}\n" ], "file_path": "docs/sources/features/datasources/stackdriver.md", "type": "replace", "edit_start_line_idx": 70 }
package migrations import ( . "github.com/grafana/grafana/pkg/services/sqlstore/migrator" ) func addQuotaMigration(mg *Migrator) { var quotaV1 = Table{ Name: "quota", Columns: []*Column{ {Name: "id", Type: DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true}, {Name: "org_id", Type: DB_BigInt, Nullable: true}, {Name: "user_id", Type: DB_BigInt, Nullable: true}, {Name: "target", Type: DB_NVarchar, Length: 190, Nullable: false}, {Name: "limit", Type: DB_BigInt, Nullable: false}, {Name: "created", Type: DB_DateTime, Nullable: false}, {Name: "updated", Type: DB_DateTime, Nullable: false}, }, Indices: []*Index{ {Cols: []string{"org_id", "user_id", "target"}, Type: UniqueIndex}, }, } mg.AddMigration("create quota table v1", NewAddTableMigration(quotaV1)) //------- indexes ------------------ addTableIndicesMigrations(mg, "v1", quotaV1) mg.AddMigration("Update quota table charset", NewTableCharsetMigration("quota", []*Column{ {Name: "target", Type: DB_NVarchar, Length: 190, Nullable: false}, })) }
pkg/services/sqlstore/migrations/quota_mig.go
0
https://github.com/grafana/grafana/commit/03fefd7beaa322ea4fbfb2cb0aa2f8bc3d5dd6ff
[ 0.00026691649691201746, 0.00019180806702934206, 0.00016616737411823124, 0.00016707420581951737, 0.000043366886529838666 ]
{ "id": 5, "code_window": [ "\n", "7. The file contents will be encrypted and saved in the Grafana database. Don't forget to save after uploading the file!\n", "\n", " ![Choose role](/img/docs/v53/stackdriver_grafana_key_uploaded.png)\n", "\n", "## Metric Query Editor\n", "\n", "{{< docs-imagebox img=\"/img/docs/v53/stackdriver_query_editor.png\" max-width= \"400px\" class=\"docs-image--right\" >}}\n" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " {{< docs-imagebox img=\"/img/docs/v53/stackdriver_grafana_key_uploaded.png\" class=\"docs-image--no-shadow\" caption=\"Service key file is uploaded to Grafana\" >}}\n" ], "file_path": "docs/sources/features/datasources/stackdriver.md", "type": "replace", "edit_start_line_idx": 74 }
+++ title = "Using Stackdriver in Grafana" description = "Guide for using Stackdriver in Grafana" keywords = ["grafana", "stackdriver", "google", "guide"] type = "docs" aliases = ["/datasources/stackdriver"] [menu.docs] name = "Stackdriver" parent = "datasources" weight = 11 +++ # Using Google Stackdriver in Grafana > Only available in Grafana v5.3+. > The datasource is currently a beta feature and is subject to change. Grafana ships with built-in support for Google Stackdriver. Just add it as a datasource and you are ready to build dashboards for your Stackdriver metrics. ## Adding the data source to Grafana 1. Open the side menu by clicking the Grafana icon in the top header. 2. In the side menu under the `Dashboards` link you should find a link named `Data Sources`. 3. Click the `+ Add data source` button in the top header. 4. Select `Stackdriver` from the _Type_ dropdown. 5. Upload or paste in the Service Account Key file. See below for steps on how to create a Service Account Key file. > NOTE: If you're not seeing the `Data Sources` link in your side menu it means that your current user does not have the `Admin` role for the current organization. | Name | Description | | --------------------- | ----------------------------------------------------------------------------------- | | _Name_ | The datasource name. This is how you refer to the datasource in panels & queries. | | _Default_ | Default datasource means that it will be pre-selected for new panels. | | _Service Account Key_ | Service Account Key File for a GCP Project. Instructions below on how to create it. | ## Authentication ### Service Account Credentials - Private Key File To authenticate with the Stackdriver API, you need to create a Google Cloud Platform (GCP) Service Account for the Project you want to show data for. A Grafana datasource integrates with one GCP Project. If you want to visualize data from multiple GCP Projects then you need to create one datasource per GCP Project. #### Enable APIs The following APIs need to be enabled first: * [Monitoring API](https://console.cloud.google.com/apis/library/monitoring.googleapis.com) * [Cloud Resource Manager API](https://console.cloud.google.com/apis/library/cloudresourcemanager.googleapis.com) Click on the links above and click the `Enable` button: ![Enable GCP APIs](/img/docs/v53/stackdriver_enable_api.png) #### Create a GCP Service Account for a Project 1. Navigate to the [APIs & Services Credentials page](https://console.cloud.google.com/apis/credentials). 2. Click on the `Create credentials` dropdown/button and choose the `Service account key` option. ![Create service account button](/img/docs/v53/stackdriver_create_service_account_button.png) 3. On the `Create service account key` page, choose key type `JSON`. Then in the `Service Account` dropdown, choose the `New service account` option: ![Create service account key](/img/docs/v53/stackdriver_create_service_account_key.png) 4. Some new fields will appear. Fill in a name for the service account in the `Service account name` field and then choose the `Monitoring Viewer` role from the `Role` dropdown: ![Choose role](/img/docs/v53/stackdriver_service_account_choose_role.png) 5. Click the Create button. A JSON key file will be created and downloaded to your computer. Store this file in a secure place as it allows access to your Stackdriver data. 6. Upload it to Grafana on the datasource Configuration page. You can either upload the file or paste in the contents of the file. ![Choose role](/img/docs/v53/stackdriver_grafana_upload_key.png) 7. The file contents will be encrypted and saved in the Grafana database. Don't forget to save after uploading the file! ![Choose role](/img/docs/v53/stackdriver_grafana_key_uploaded.png) ## Metric Query Editor {{< docs-imagebox img="/img/docs/v53/stackdriver_query_editor.png" max-width= "400px" class="docs-image--right" >}} The Stackdriver query editor allows you to select metrics and group by multiple labels and use filter the results. Begin by choosing a `Service` and then a metric from the `Metric` dropdown. Use the plus and minus icons in the filter and group by sections to add/remove filters or group by clauses. Stackdriver metrics can be of different kinds (GAUGE, DELTA, CUMULATIVE) and these kinds have support for different aggregation options (reducers and aligners). The Grafana query editor shows the list of available aggregation methods for a selected metric and sets a default reducer and aligner when you select the metric. Units for the Y-axis are also automatically selected by the query editor. ### Filter To add a filter, click the plus icon and choose a field to filter by and enter a filter value e.g. `instance_name = grafana-1`. You can remove the filter by clicking on the filter name and select `--remove filter--`. #### Simple wildcards When the operator is set to `=` or `!=` it is possible to add wildcards to the filter value field. E.g `us-*` will capture all values that starts with "us-" and `*central-a` will capture all values that ends with "central-a". `*-central-*` captures all values that has the substring of -central-. Simple wildcards are less expensive than regular expressions. #### Regular expressions When the operator is set to `=~` or `!=~` it is possible to add regular expressions to the filter value field. E.g `us-central[1-3]-[af]` would match all values that starts with "us-central", is followed by a number in the range of 1 to 3, a dash and then either an "a" or an "f". Leading and trailing slashes are not needed when creating regular expressions. ### Aggregation The aggregation field lets you combine time series based on common statistics. Read more about this option [here](https://cloud.google.com/monitoring/charts/metrics-selector#aggregation-options). The `Aligner` field allows you to align multiple time series after the same group by time interval. Read more about how it works [here](https://cloud.google.com/monitoring/charts/metrics-selector#alignment). #### Alignment Period/Group by Time The `Alignment Period` groups a metric by time if an aggregation is chosen. The default is to use the GCP Stackdriver default groupings (which allows you to compare graphs in Grafana with graphs in the Stackdriver UI). The option is called `Stackdriver auto` and the defaults are: * 1m for time ranges < 23 hours * 5m for time ranges >= 23 hours and < 6 days * 1h for time ranges >= 6 days The other automatic option is `Grafana auto`. This will automatically set the group by time depending on the time range chosen and the width of the graph panel. Read more about the details [here](http://docs.grafana.org/reference/templating/#the-interval-variable). It is also possible to choose fixed time intervals to group by, like `1h` or `1d`. ### Group By Group by resource or metric labels to reduce the number of time series and to aggregate the results by a group by. E.g. Group by instance_name to see an aggregated metric for a Compute instance. ### Alias Patterns The Alias By field allows you to control the format of the legend keys. The default is to show the metric name and labels. This can be long and hard to read. Using the following patterns in the alias field, you can format the legend key the way you want it. #### Metric Type Patterns | Alias Pattern | Description | Example Result | | -------------------- | ---------------------------- | ------------------------------------------------- | | `{{metric.type}}` | returns the full Metric Type | `compute.googleapis.com/instance/cpu/utilization` | | `{{metric.name}}` | returns the metric name part | `instance/cpu/utilization` | | `{{metric.service}}` | returns the service part | `compute` | #### Label Patterns In the Group By dropdown, you can see a list of metric and resource labels for a metric. These can be included in the legend key using alias patterns. | Alias Pattern Format | Description | Alias Pattern Example | Example Result | | ------------------------ | -------------------------------- | -------------------------------- | ---------------- | | `{{metric.label.xxx}}` | returns the metric label value | `{{metric.label.instance_name}}` | `grafana-1-prod` | | `{{resource.label.xxx}}` | returns the resource label value | `{{resource.label.zone}}` | `us-east1-b` | Example Alias By: `{{metric.type}} - {{metric.labels.instance_name}}` Example Result: `compute.googleapis.com/instance/cpu/usage_time - server1-prod` ## Templating Instead of hard-coding things like server, application and sensor name in you metric queries you can use variables in their place. Variables are shown as dropdown select boxes at the top of the dashboard. These dropdowns makes it easy to change the data being displayed in your dashboard. Checkout the [Templating]({{< relref "reference/templating.md" >}}) documentation for an introduction to the templating feature and the different types of template variables. ### Query Variable Writing variable queries is not supported yet. ### Using variables in queries There are two syntaxes: * `$<varname>` Example: `metric.label.$metric_label` * `[[varname]]` Example: `metric.label.[[metric_label]]` Why two ways? The first syntax is easier to read and write but does not allow you to use a variable in the middle of a word. When the _Multi-value_ or _Include all value_ options are enabled, Grafana converts the labels from plain text to a regex compatible string, which means you have to use `=~` instead of `=`. ## Annotations {{< docs-imagebox img="/img/docs/v53/stackdriver_annotations_query_editor.png" max-width= "400px" class="docs-image--right" >}} [Annotations]({{< relref "reference/annotations.md" >}}) allows you to overlay rich event information on top of graphs. You add annotation queries via the Dashboard menu / Annotations view. Annotation rendering is expensive so it is important to limit the number of rows returned. There is no support for showing Stackdriver annotations and events yet but it works well with [custom metrics](https://cloud.google.com/monitoring/custom-metrics/) in Stackdriver. With the query editor for annotations, you can select a metric and filters. The `Title` and `Text` fields support templating and can use data returned from the query. For example, the Title field could have the following text: `{{metric.type}} has value: {{metric.value}}` Example Result: `monitoring.googleapis.com/uptime_check/http_status has this value: 502` ### Patterns for the Annotation Query Editor | Alias Pattern Format | Description | Alias Pattern Example | Example Result | | ------------------------ | -------------------------------- | -------------------------------- | ------------------------------------------------- | | `{{metric.value}}` | value of the metric/point | `{{metric.value}}` | `555` | | `{{metric.type}}` | returns the full Metric Type | `{{metric.type}}` | `compute.googleapis.com/instance/cpu/utilization` | | `{{metric.name}}` | returns the metric name part | `{{metric.name}}` | `instance/cpu/utilization` | | `{{metric.service}}` | returns the service part | `{{metric.service}}` | `compute` | | `{{metric.label.xxx}}` | returns the metric label value | `{{metric.label.instance_name}}` | `grafana-1-prod` | | `{{resource.label.xxx}}` | returns the resource label value | `{{resource.label.zone}}` | `us-east1-b` | ## Configure the Datasource with Provisioning It's now possible to configure datasources using config files with Grafana's provisioning system. You can read more about how it works and all the settings you can set for datasources on the [provisioning docs page](/administration/provisioning/#datasources) Here is a provisioning example for this datasource. ```yaml apiVersion: 1 datasources: - name: Stackdriver type: stackdriver access: proxy jsonData: tokenUri: https://oauth2.googleapis.com/token clientEmail: [email protected] secureJsonData: privateKey: | -----BEGIN PRIVATE KEY----- POSEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCb1u1Srw8ICYHS ... yA+23427282348234= -----END PRIVATE KEY----- ```
docs/sources/features/datasources/stackdriver.md
1
https://github.com/grafana/grafana/commit/03fefd7beaa322ea4fbfb2cb0aa2f8bc3d5dd6ff
[ 0.9855652451515198, 0.045202188193798065, 0.00016413582488894463, 0.00020158362167421728, 0.20520563423633575 ]
{ "id": 5, "code_window": [ "\n", "7. The file contents will be encrypted and saved in the Grafana database. Don't forget to save after uploading the file!\n", "\n", " ![Choose role](/img/docs/v53/stackdriver_grafana_key_uploaded.png)\n", "\n", "## Metric Query Editor\n", "\n", "{{< docs-imagebox img=\"/img/docs/v53/stackdriver_query_editor.png\" max-width= \"400px\" class=\"docs-image--right\" >}}\n" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " {{< docs-imagebox img=\"/img/docs/v53/stackdriver_grafana_key_uploaded.png\" class=\"docs-image--no-shadow\" caption=\"Service key file is uploaded to Grafana\" >}}\n" ], "file_path": "docs/sources/features/datasources/stackdriver.md", "type": "replace", "edit_start_line_idx": 74 }
// Copyright 2016 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // +build openbsd // +build 386 amd64 arm package unix import ( "syscall" "unsafe" ) const ( SYS_PLEDGE = 108 ) // Pledge implements the pledge syscall. For more information see pledge(2). func Pledge(promises string, paths []string) error { promisesPtr, err := syscall.BytePtrFromString(promises) if err != nil { return err } promisesUnsafe, pathsUnsafe := unsafe.Pointer(promisesPtr), unsafe.Pointer(nil) if paths != nil { var pathsPtr []*byte if pathsPtr, err = syscall.SlicePtrFromStrings(paths); err != nil { return err } pathsUnsafe = unsafe.Pointer(&pathsPtr[0]) } _, _, e := syscall.Syscall(SYS_PLEDGE, uintptr(promisesUnsafe), uintptr(pathsUnsafe), 0) if e != 0 { return e } return nil }
vendor/golang.org/x/sys/unix/openbsd_pledge.go
0
https://github.com/grafana/grafana/commit/03fefd7beaa322ea4fbfb2cb0aa2f8bc3d5dd6ff
[ 0.00017407811537850648, 0.0001692310906946659, 0.00016577364294789732, 0.0001685362949501723, 0.00000301762088383839 ]
{ "id": 5, "code_window": [ "\n", "7. The file contents will be encrypted and saved in the Grafana database. Don't forget to save after uploading the file!\n", "\n", " ![Choose role](/img/docs/v53/stackdriver_grafana_key_uploaded.png)\n", "\n", "## Metric Query Editor\n", "\n", "{{< docs-imagebox img=\"/img/docs/v53/stackdriver_query_editor.png\" max-width= \"400px\" class=\"docs-image--right\" >}}\n" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " {{< docs-imagebox img=\"/img/docs/v53/stackdriver_grafana_key_uploaded.png\" class=\"docs-image--no-shadow\" caption=\"Service key file is uploaded to Grafana\" >}}\n" ], "file_path": "docs/sources/features/datasources/stackdriver.md", "type": "replace", "edit_start_line_idx": 74 }
package pq import ( "bytes" "database/sql/driver" "encoding/binary" "encoding/hex" "errors" "fmt" "math" "strconv" "strings" "sync" "time" "github.com/lib/pq/oid" ) func binaryEncode(parameterStatus *parameterStatus, x interface{}) []byte { switch v := x.(type) { case []byte: return v default: return encode(parameterStatus, x, oid.T_unknown) } } func encode(parameterStatus *parameterStatus, x interface{}, pgtypOid oid.Oid) []byte { switch v := x.(type) { case int64: return strconv.AppendInt(nil, v, 10) case float64: return strconv.AppendFloat(nil, v, 'f', -1, 64) case []byte: if pgtypOid == oid.T_bytea { return encodeBytea(parameterStatus.serverVersion, v) } return v case string: if pgtypOid == oid.T_bytea { return encodeBytea(parameterStatus.serverVersion, []byte(v)) } return []byte(v) case bool: return strconv.AppendBool(nil, v) case time.Time: return formatTs(v) default: errorf("encode: unknown type for %T", v) } panic("not reached") } func decode(parameterStatus *parameterStatus, s []byte, typ oid.Oid, f format) interface{} { switch f { case formatBinary: return binaryDecode(parameterStatus, s, typ) case formatText: return textDecode(parameterStatus, s, typ) default: panic("not reached") } } func binaryDecode(parameterStatus *parameterStatus, s []byte, typ oid.Oid) interface{} { switch typ { case oid.T_bytea: return s case oid.T_int8: return int64(binary.BigEndian.Uint64(s)) case oid.T_int4: return int64(int32(binary.BigEndian.Uint32(s))) case oid.T_int2: return int64(int16(binary.BigEndian.Uint16(s))) case oid.T_uuid: b, err := decodeUUIDBinary(s) if err != nil { panic(err) } return b default: errorf("don't know how to decode binary parameter of type %d", uint32(typ)) } panic("not reached") } func textDecode(parameterStatus *parameterStatus, s []byte, typ oid.Oid) interface{} { switch typ { case oid.T_char, oid.T_varchar, oid.T_text: return string(s) case oid.T_bytea: b, err := parseBytea(s) if err != nil { errorf("%s", err) } return b case oid.T_timestamptz: return parseTs(parameterStatus.currentLocation, string(s)) case oid.T_timestamp, oid.T_date: return parseTs(nil, string(s)) case oid.T_time: return mustParse("15:04:05", typ, s) case oid.T_timetz: return mustParse("15:04:05-07", typ, s) case oid.T_bool: return s[0] == 't' case oid.T_int8, oid.T_int4, oid.T_int2: i, err := strconv.ParseInt(string(s), 10, 64) if err != nil { errorf("%s", err) } return i case oid.T_float4, oid.T_float8: bits := 64 if typ == oid.T_float4 { bits = 32 } f, err := strconv.ParseFloat(string(s), bits) if err != nil { errorf("%s", err) } return f } return s } // appendEncodedText encodes item in text format as required by COPY // and appends to buf func appendEncodedText(parameterStatus *parameterStatus, buf []byte, x interface{}) []byte { switch v := x.(type) { case int64: return strconv.AppendInt(buf, v, 10) case float64: return strconv.AppendFloat(buf, v, 'f', -1, 64) case []byte: encodedBytea := encodeBytea(parameterStatus.serverVersion, v) return appendEscapedText(buf, string(encodedBytea)) case string: return appendEscapedText(buf, v) case bool: return strconv.AppendBool(buf, v) case time.Time: return append(buf, formatTs(v)...) case nil: return append(buf, "\\N"...) default: errorf("encode: unknown type for %T", v) } panic("not reached") } func appendEscapedText(buf []byte, text string) []byte { escapeNeeded := false startPos := 0 var c byte // check if we need to escape for i := 0; i < len(text); i++ { c = text[i] if c == '\\' || c == '\n' || c == '\r' || c == '\t' { escapeNeeded = true startPos = i break } } if !escapeNeeded { return append(buf, text...) } // copy till first char to escape, iterate the rest result := append(buf, text[:startPos]...) for i := startPos; i < len(text); i++ { c = text[i] switch c { case '\\': result = append(result, '\\', '\\') case '\n': result = append(result, '\\', 'n') case '\r': result = append(result, '\\', 'r') case '\t': result = append(result, '\\', 't') default: result = append(result, c) } } return result } func mustParse(f string, typ oid.Oid, s []byte) time.Time { str := string(s) // check for a 30-minute-offset timezone if (typ == oid.T_timestamptz || typ == oid.T_timetz) && str[len(str)-3] == ':' { f += ":00" } t, err := time.Parse(f, str) if err != nil { errorf("decode: %s", err) } return t } var errInvalidTimestamp = errors.New("invalid timestamp") type timestampParser struct { err error } func (p *timestampParser) expect(str string, char byte, pos int) { if p.err != nil { return } if pos+1 > len(str) { p.err = errInvalidTimestamp return } if c := str[pos]; c != char && p.err == nil { p.err = fmt.Errorf("expected '%v' at position %v; got '%v'", char, pos, c) } } func (p *timestampParser) mustAtoi(str string, begin int, end int) int { if p.err != nil { return 0 } if begin < 0 || end < 0 || begin > end || end > len(str) { p.err = errInvalidTimestamp return 0 } result, err := strconv.Atoi(str[begin:end]) if err != nil { if p.err == nil { p.err = fmt.Errorf("expected number; got '%v'", str) } return 0 } return result } // The location cache caches the time zones typically used by the client. type locationCache struct { cache map[int]*time.Location lock sync.Mutex } // All connections share the same list of timezones. Benchmarking shows that // about 5% speed could be gained by putting the cache in the connection and // losing the mutex, at the cost of a small amount of memory and a somewhat // significant increase in code complexity. var globalLocationCache = newLocationCache() func newLocationCache() *locationCache { return &locationCache{cache: make(map[int]*time.Location)} } // Returns the cached timezone for the specified offset, creating and caching // it if necessary. func (c *locationCache) getLocation(offset int) *time.Location { c.lock.Lock() defer c.lock.Unlock() location, ok := c.cache[offset] if !ok { location = time.FixedZone("", offset) c.cache[offset] = location } return location } var infinityTsEnabled = false var infinityTsNegative time.Time var infinityTsPositive time.Time const ( infinityTsEnabledAlready = "pq: infinity timestamp enabled already" infinityTsNegativeMustBeSmaller = "pq: infinity timestamp: negative value must be smaller (before) than positive" ) // EnableInfinityTs controls the handling of Postgres' "-infinity" and // "infinity" "timestamp"s. // // If EnableInfinityTs is not called, "-infinity" and "infinity" will return // []byte("-infinity") and []byte("infinity") respectively, and potentially // cause error "sql: Scan error on column index 0: unsupported driver -> Scan // pair: []uint8 -> *time.Time", when scanning into a time.Time value. // // Once EnableInfinityTs has been called, all connections created using this // driver will decode Postgres' "-infinity" and "infinity" for "timestamp", // "timestamp with time zone" and "date" types to the predefined minimum and // maximum times, respectively. When encoding time.Time values, any time which // equals or precedes the predefined minimum time will be encoded to // "-infinity". Any values at or past the maximum time will similarly be // encoded to "infinity". // // If EnableInfinityTs is called with negative >= positive, it will panic. // Calling EnableInfinityTs after a connection has been established results in // undefined behavior. If EnableInfinityTs is called more than once, it will // panic. func EnableInfinityTs(negative time.Time, positive time.Time) { if infinityTsEnabled { panic(infinityTsEnabledAlready) } if !negative.Before(positive) { panic(infinityTsNegativeMustBeSmaller) } infinityTsEnabled = true infinityTsNegative = negative infinityTsPositive = positive } /* * Testing might want to toggle infinityTsEnabled */ func disableInfinityTs() { infinityTsEnabled = false } // This is a time function specific to the Postgres default DateStyle // setting ("ISO, MDY"), the only one we currently support. This // accounts for the discrepancies between the parsing available with // time.Parse and the Postgres date formatting quirks. func parseTs(currentLocation *time.Location, str string) interface{} { switch str { case "-infinity": if infinityTsEnabled { return infinityTsNegative } return []byte(str) case "infinity": if infinityTsEnabled { return infinityTsPositive } return []byte(str) } t, err := ParseTimestamp(currentLocation, str) if err != nil { panic(err) } return t } // ParseTimestamp parses Postgres' text format. It returns a time.Time in // currentLocation iff that time's offset agrees with the offset sent from the // Postgres server. Otherwise, ParseTimestamp returns a time.Time with the // fixed offset offset provided by the Postgres server. func ParseTimestamp(currentLocation *time.Location, str string) (time.Time, error) { p := timestampParser{} monSep := strings.IndexRune(str, '-') // this is Gregorian year, not ISO Year // In Gregorian system, the year 1 BC is followed by AD 1 year := p.mustAtoi(str, 0, monSep) daySep := monSep + 3 month := p.mustAtoi(str, monSep+1, daySep) p.expect(str, '-', daySep) timeSep := daySep + 3 day := p.mustAtoi(str, daySep+1, timeSep) minLen := monSep + len("01-01") + 1 isBC := strings.HasSuffix(str, " BC") if isBC { minLen += 3 } var hour, minute, second int if len(str) > minLen { p.expect(str, ' ', timeSep) minSep := timeSep + 3 p.expect(str, ':', minSep) hour = p.mustAtoi(str, timeSep+1, minSep) secSep := minSep + 3 p.expect(str, ':', secSep) minute = p.mustAtoi(str, minSep+1, secSep) secEnd := secSep + 3 second = p.mustAtoi(str, secSep+1, secEnd) } remainderIdx := monSep + len("01-01 00:00:00") + 1 // Three optional (but ordered) sections follow: the // fractional seconds, the time zone offset, and the BC // designation. We set them up here and adjust the other // offsets if the preceding sections exist. nanoSec := 0 tzOff := 0 if remainderIdx < len(str) && str[remainderIdx] == '.' { fracStart := remainderIdx + 1 fracOff := strings.IndexAny(str[fracStart:], "-+ ") if fracOff < 0 { fracOff = len(str) - fracStart } fracSec := p.mustAtoi(str, fracStart, fracStart+fracOff) nanoSec = fracSec * (1000000000 / int(math.Pow(10, float64(fracOff)))) remainderIdx += fracOff + 1 } if tzStart := remainderIdx; tzStart < len(str) && (str[tzStart] == '-' || str[tzStart] == '+') { // time zone separator is always '-' or '+' (UTC is +00) var tzSign int switch c := str[tzStart]; c { case '-': tzSign = -1 case '+': tzSign = +1 default: return time.Time{}, fmt.Errorf("expected '-' or '+' at position %v; got %v", tzStart, c) } tzHours := p.mustAtoi(str, tzStart+1, tzStart+3) remainderIdx += 3 var tzMin, tzSec int if remainderIdx < len(str) && str[remainderIdx] == ':' { tzMin = p.mustAtoi(str, remainderIdx+1, remainderIdx+3) remainderIdx += 3 } if remainderIdx < len(str) && str[remainderIdx] == ':' { tzSec = p.mustAtoi(str, remainderIdx+1, remainderIdx+3) remainderIdx += 3 } tzOff = tzSign * ((tzHours * 60 * 60) + (tzMin * 60) + tzSec) } var isoYear int if isBC { isoYear = 1 - year remainderIdx += 3 } else { isoYear = year } if remainderIdx < len(str) { return time.Time{}, fmt.Errorf("expected end of input, got %v", str[remainderIdx:]) } t := time.Date(isoYear, time.Month(month), day, hour, minute, second, nanoSec, globalLocationCache.getLocation(tzOff)) if currentLocation != nil { // Set the location of the returned Time based on the session's // TimeZone value, but only if the local time zone database agrees with // the remote database on the offset. lt := t.In(currentLocation) _, newOff := lt.Zone() if newOff == tzOff { t = lt } } return t, p.err } // formatTs formats t into a format postgres understands. func formatTs(t time.Time) []byte { if infinityTsEnabled { // t <= -infinity : ! (t > -infinity) if !t.After(infinityTsNegative) { return []byte("-infinity") } // t >= infinity : ! (!t < infinity) if !t.Before(infinityTsPositive) { return []byte("infinity") } } return FormatTimestamp(t) } // FormatTimestamp formats t into Postgres' text format for timestamps. func FormatTimestamp(t time.Time) []byte { // Need to send dates before 0001 A.D. with " BC" suffix, instead of the // minus sign preferred by Go. // Beware, "0000" in ISO is "1 BC", "-0001" is "2 BC" and so on bc := false if t.Year() <= 0 { // flip year sign, and add 1, e.g: "0" will be "1", and "-10" will be "11" t = t.AddDate((-t.Year())*2+1, 0, 0) bc = true } b := []byte(t.Format("2006-01-02 15:04:05.999999999Z07:00")) _, offset := t.Zone() offset = offset % 60 if offset != 0 { // RFC3339Nano already printed the minus sign if offset < 0 { offset = -offset } b = append(b, ':') if offset < 10 { b = append(b, '0') } b = strconv.AppendInt(b, int64(offset), 10) } if bc { b = append(b, " BC"...) } return b } // Parse a bytea value received from the server. Both "hex" and the legacy // "escape" format are supported. func parseBytea(s []byte) (result []byte, err error) { if len(s) >= 2 && bytes.Equal(s[:2], []byte("\\x")) { // bytea_output = hex s = s[2:] // trim off leading "\\x" result = make([]byte, hex.DecodedLen(len(s))) _, err := hex.Decode(result, s) if err != nil { return nil, err } } else { // bytea_output = escape for len(s) > 0 { if s[0] == '\\' { // escaped '\\' if len(s) >= 2 && s[1] == '\\' { result = append(result, '\\') s = s[2:] continue } // '\\' followed by an octal number if len(s) < 4 { return nil, fmt.Errorf("invalid bytea sequence %v", s) } r, err := strconv.ParseInt(string(s[1:4]), 8, 9) if err != nil { return nil, fmt.Errorf("could not parse bytea value: %s", err.Error()) } result = append(result, byte(r)) s = s[4:] } else { // We hit an unescaped, raw byte. Try to read in as many as // possible in one go. i := bytes.IndexByte(s, '\\') if i == -1 { result = append(result, s...) break } result = append(result, s[:i]...) s = s[i:] } } } return result, nil } func encodeBytea(serverVersion int, v []byte) (result []byte) { if serverVersion >= 90000 { // Use the hex format if we know that the server supports it result = make([]byte, 2+hex.EncodedLen(len(v))) result[0] = '\\' result[1] = 'x' hex.Encode(result[2:], v) } else { // .. or resort to "escape" for _, b := range v { if b == '\\' { result = append(result, '\\', '\\') } else if b < 0x20 || b > 0x7e { result = append(result, []byte(fmt.Sprintf("\\%03o", b))...) } else { result = append(result, b) } } } return result } // NullTime represents a time.Time that may be null. NullTime implements the // sql.Scanner interface so it can be used as a scan destination, similar to // sql.NullString. type NullTime struct { Time time.Time Valid bool // Valid is true if Time is not NULL } // Scan implements the Scanner interface. func (nt *NullTime) Scan(value interface{}) error { nt.Time, nt.Valid = value.(time.Time) return nil } // Value implements the driver Valuer interface. func (nt NullTime) Value() (driver.Value, error) { if !nt.Valid { return nil, nil } return nt.Time, nil }
vendor/github.com/lib/pq/encode.go
0
https://github.com/grafana/grafana/commit/03fefd7beaa322ea4fbfb2cb0aa2f8bc3d5dd6ff
[ 0.0011156623950228095, 0.00018646204262040555, 0.00016318312555085868, 0.00017021174426190555, 0.0001203134233946912 ]
{ "id": 5, "code_window": [ "\n", "7. The file contents will be encrypted and saved in the Grafana database. Don't forget to save after uploading the file!\n", "\n", " ![Choose role](/img/docs/v53/stackdriver_grafana_key_uploaded.png)\n", "\n", "## Metric Query Editor\n", "\n", "{{< docs-imagebox img=\"/img/docs/v53/stackdriver_query_editor.png\" max-width= \"400px\" class=\"docs-image--right\" >}}\n" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " {{< docs-imagebox img=\"/img/docs/v53/stackdriver_grafana_key_uploaded.png\" class=\"docs-image--no-shadow\" caption=\"Service key file is uploaded to Grafana\" >}}\n" ], "file_path": "docs/sources/features/datasources/stackdriver.md", "type": "replace", "edit_start_line_idx": 74 }
+++ title = "Heatmap Panel" description = "Heatmap panel documentation" keywords = ["grafana", "heatmap", "panel", "documentation"] type = "docs" [menu.docs] name = "Heatmap" parent = "panels" weight = 3 +++ # Heatmap Panel ![](/img/docs/v43/heatmap_panel_cover.jpg) > New panel only available in Grafana v4.3+ The Heatmap panel allows you to view histograms over time. To fully understand and use this panel you need understand what Histograms are and how they are created. Read on below to for a quick introduction to the term Histogram. ## Histograms and buckets A histogram is a graphical representation of the distribution of numerical data. You group values into buckets (some times also called bins) and then count how many values fall into each bucket. Instead of graphing the actual values you then graph the buckets. Each bar represents a bucket and the bar height represents the frequency (i.e. count) of values that fell into that bucket's interval. Example Histogram: ![](/img/docs/v43/heatmap_histogram.png) The above histogram shows us that most value distribution of a couple of time series. We can easily see that most values land between 240-300 with a peak between 260-280. Histograms just look at value distributions over specific time range. So you cannot see any trend or changes in the distribution over time, this is where heatmaps become useful. ## Heatmap A Heatmap is like a histogram but over time where each time slice represents its own histogram. Instead of using bar height as a representation of frequency you use cells and color the cell proportional to the number of values in the bucket. Example: ![](/img/docs/v43/heatmap_histogram_over_time.png) Here we can clearly see what values are more common and how they trend over time. ## Data Options Data and bucket options can be found in the `Axes` tab. ### Data Formats Data format | Description ------------ | ------------- *Time series* | Grafana does the bucketing by going through all time series values. The bucket sizes & intervals will be determined using the Buckets options. *Time series buckets* | Each time series already represents a Y-Axis bucket. The time series name (alias) needs to be a numeric value representing the upper or lower interval for the bucket. Grafana does no bucketing so the bucket size options are hidden. ### Bucket bound When Data format is *Time series buckets* datasource returns series with names representing bucket bound. But depending on datasource, a bound may be *upper* or *lower*. This option allows to adjust a bound type. If *Auto* is set, a bound option will be chosen based on panels' datasource type. ### Bucket Size The Bucket count & size options are used by Grafana to calculate how big each cell in the heatmap is. You can define the bucket size either by count (the first input box) or by specifying a size interval. For the Y-Axis the size interval is just a value but for the X-bucket you can specify a time range in the *Size* input, for example, the time range `1h`. This will make the cells 1h wide on the X-axis. ### Pre-bucketed data If you have a data that is already organized into buckets you can use the `Time series buckets` data format. This format requires that your metric query return regular time series and that each time series has a numeric name that represent the upper or lower bound of the interval. There are a number of datasources supporting histogram over time like Elasticsearch (by using a Histogram bucket aggregation) or Prometheus (with [histogram](https://prometheus.io/docs/concepts/metric_types/#histogram) metric type and *Format as* option set to Heatmap). But generally, any datasource could be used if it meets the requirements: returns series with names representing bucket bound or returns series sorted by the bound in ascending order. With Elasticsearch you control the size of the buckets using the Histogram interval (Y-Axis) and the Date Histogram interval (X-axis). ![Elastic histogram](/img/docs/v43/elastic_histogram.png) With Prometheus you can only control X-axis by adjusting *Min step* and *Resolution* options. ![Prometheus histogram](/img/docs/v51/prometheus_histogram.png) ## Display Options In the heatmap *Display* tab you define how the cells are rendered and what color they are assigned. ### Color Mode & Spectrum {{< imgbox max-width="40%" img="/img/docs/v43/heatmap_scheme.png" caption="Color spectrum" >}} The color spectrum controls the mapping between value count (in each bucket) and the color assigned to each bucket. The left most color on the spectrum represents the minimum count and the color on the right most side represents the maximum count. Some color schemes are automatically inverted when using the light theme. You can also change the color mode to `Opacity`. In this case, the color will not change but the amount of opacity will change with the bucket count. ## Raw data vs aggregated If you use the heatmap with regular time series data (not pre-bucketed). Then it's important to keep in mind that your data is often already by aggregated by your time series backend. Most time series queries do not return raw sample data but include a group by time interval or maxDataPoints limit coupled with an aggregation function (usually average). This all depends on the time range of your query of course. But the important point is to know that the Histogram bucketing that Grafana performs may be done on already aggregated and averaged data. To get more accurate heatmaps it is better to do the bucketing during metric collection or store the data in Elasticsearch, or in the other data source which supports doing Histogram bucketing on the raw data. If you remove or lower the group by time (or raise maxDataPoints) in your query to return more data points your heatmap will be more accurate but this can also be very CPU & Memory taxing for your browser and could cause hangs and crashes if the number of data points becomes unreasonably large.
docs/sources/features/panels/heatmap.md
0
https://github.com/grafana/grafana/commit/03fefd7beaa322ea4fbfb2cb0aa2f8bc3d5dd6ff
[ 0.00022275655646808445, 0.0001730752264847979, 0.00016343493189197034, 0.00016751115617807955, 0.00001517725922894897 ]
{ "id": 6, "code_window": [ "\n", "## Metric Query Editor\n", "\n", "{{< docs-imagebox img=\"/img/docs/v53/stackdriver_query_editor.png\" max-width= \"400px\" class=\"docs-image--right\" >}}\n", "\n", "The Stackdriver query editor allows you to select metrics and group by multiple labels and use filter the results.\n", "\n", "Begin by choosing a `Service` and then a metric from the `Metric` dropdown. Use the plus and minus icons in the filter and group by sections to add/remove filters or group by clauses.\n", "\n" ], "labels": [ "keep", "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep" ], "after_edit": [ "The Stackdriver query editor allows you to select metrics, group/aggregate by labels and by time, and use filters to specify which time series you want in the results.\n" ], "file_path": "docs/sources/features/datasources/stackdriver.md", "type": "replace", "edit_start_line_idx": 80 }
+++ title = "Using Stackdriver in Grafana" description = "Guide for using Stackdriver in Grafana" keywords = ["grafana", "stackdriver", "google", "guide"] type = "docs" aliases = ["/datasources/stackdriver"] [menu.docs] name = "Stackdriver" parent = "datasources" weight = 11 +++ # Using Google Stackdriver in Grafana > Only available in Grafana v5.3+. > The datasource is currently a beta feature and is subject to change. Grafana ships with built-in support for Google Stackdriver. Just add it as a datasource and you are ready to build dashboards for your Stackdriver metrics. ## Adding the data source to Grafana 1. Open the side menu by clicking the Grafana icon in the top header. 2. In the side menu under the `Dashboards` link you should find a link named `Data Sources`. 3. Click the `+ Add data source` button in the top header. 4. Select `Stackdriver` from the _Type_ dropdown. 5. Upload or paste in the Service Account Key file. See below for steps on how to create a Service Account Key file. > NOTE: If you're not seeing the `Data Sources` link in your side menu it means that your current user does not have the `Admin` role for the current organization. | Name | Description | | --------------------- | ----------------------------------------------------------------------------------- | | _Name_ | The datasource name. This is how you refer to the datasource in panels & queries. | | _Default_ | Default datasource means that it will be pre-selected for new panels. | | _Service Account Key_ | Service Account Key File for a GCP Project. Instructions below on how to create it. | ## Authentication ### Service Account Credentials - Private Key File To authenticate with the Stackdriver API, you need to create a Google Cloud Platform (GCP) Service Account for the Project you want to show data for. A Grafana datasource integrates with one GCP Project. If you want to visualize data from multiple GCP Projects then you need to create one datasource per GCP Project. #### Enable APIs The following APIs need to be enabled first: * [Monitoring API](https://console.cloud.google.com/apis/library/monitoring.googleapis.com) * [Cloud Resource Manager API](https://console.cloud.google.com/apis/library/cloudresourcemanager.googleapis.com) Click on the links above and click the `Enable` button: ![Enable GCP APIs](/img/docs/v53/stackdriver_enable_api.png) #### Create a GCP Service Account for a Project 1. Navigate to the [APIs & Services Credentials page](https://console.cloud.google.com/apis/credentials). 2. Click on the `Create credentials` dropdown/button and choose the `Service account key` option. ![Create service account button](/img/docs/v53/stackdriver_create_service_account_button.png) 3. On the `Create service account key` page, choose key type `JSON`. Then in the `Service Account` dropdown, choose the `New service account` option: ![Create service account key](/img/docs/v53/stackdriver_create_service_account_key.png) 4. Some new fields will appear. Fill in a name for the service account in the `Service account name` field and then choose the `Monitoring Viewer` role from the `Role` dropdown: ![Choose role](/img/docs/v53/stackdriver_service_account_choose_role.png) 5. Click the Create button. A JSON key file will be created and downloaded to your computer. Store this file in a secure place as it allows access to your Stackdriver data. 6. Upload it to Grafana on the datasource Configuration page. You can either upload the file or paste in the contents of the file. ![Choose role](/img/docs/v53/stackdriver_grafana_upload_key.png) 7. The file contents will be encrypted and saved in the Grafana database. Don't forget to save after uploading the file! ![Choose role](/img/docs/v53/stackdriver_grafana_key_uploaded.png) ## Metric Query Editor {{< docs-imagebox img="/img/docs/v53/stackdriver_query_editor.png" max-width= "400px" class="docs-image--right" >}} The Stackdriver query editor allows you to select metrics and group by multiple labels and use filter the results. Begin by choosing a `Service` and then a metric from the `Metric` dropdown. Use the plus and minus icons in the filter and group by sections to add/remove filters or group by clauses. Stackdriver metrics can be of different kinds (GAUGE, DELTA, CUMULATIVE) and these kinds have support for different aggregation options (reducers and aligners). The Grafana query editor shows the list of available aggregation methods for a selected metric and sets a default reducer and aligner when you select the metric. Units for the Y-axis are also automatically selected by the query editor. ### Filter To add a filter, click the plus icon and choose a field to filter by and enter a filter value e.g. `instance_name = grafana-1`. You can remove the filter by clicking on the filter name and select `--remove filter--`. #### Simple wildcards When the operator is set to `=` or `!=` it is possible to add wildcards to the filter value field. E.g `us-*` will capture all values that starts with "us-" and `*central-a` will capture all values that ends with "central-a". `*-central-*` captures all values that has the substring of -central-. Simple wildcards are less expensive than regular expressions. #### Regular expressions When the operator is set to `=~` or `!=~` it is possible to add regular expressions to the filter value field. E.g `us-central[1-3]-[af]` would match all values that starts with "us-central", is followed by a number in the range of 1 to 3, a dash and then either an "a" or an "f". Leading and trailing slashes are not needed when creating regular expressions. ### Aggregation The aggregation field lets you combine time series based on common statistics. Read more about this option [here](https://cloud.google.com/monitoring/charts/metrics-selector#aggregation-options). The `Aligner` field allows you to align multiple time series after the same group by time interval. Read more about how it works [here](https://cloud.google.com/monitoring/charts/metrics-selector#alignment). #### Alignment Period/Group by Time The `Alignment Period` groups a metric by time if an aggregation is chosen. The default is to use the GCP Stackdriver default groupings (which allows you to compare graphs in Grafana with graphs in the Stackdriver UI). The option is called `Stackdriver auto` and the defaults are: * 1m for time ranges < 23 hours * 5m for time ranges >= 23 hours and < 6 days * 1h for time ranges >= 6 days The other automatic option is `Grafana auto`. This will automatically set the group by time depending on the time range chosen and the width of the graph panel. Read more about the details [here](http://docs.grafana.org/reference/templating/#the-interval-variable). It is also possible to choose fixed time intervals to group by, like `1h` or `1d`. ### Group By Group by resource or metric labels to reduce the number of time series and to aggregate the results by a group by. E.g. Group by instance_name to see an aggregated metric for a Compute instance. ### Alias Patterns The Alias By field allows you to control the format of the legend keys. The default is to show the metric name and labels. This can be long and hard to read. Using the following patterns in the alias field, you can format the legend key the way you want it. #### Metric Type Patterns | Alias Pattern | Description | Example Result | | -------------------- | ---------------------------- | ------------------------------------------------- | | `{{metric.type}}` | returns the full Metric Type | `compute.googleapis.com/instance/cpu/utilization` | | `{{metric.name}}` | returns the metric name part | `instance/cpu/utilization` | | `{{metric.service}}` | returns the service part | `compute` | #### Label Patterns In the Group By dropdown, you can see a list of metric and resource labels for a metric. These can be included in the legend key using alias patterns. | Alias Pattern Format | Description | Alias Pattern Example | Example Result | | ------------------------ | -------------------------------- | -------------------------------- | ---------------- | | `{{metric.label.xxx}}` | returns the metric label value | `{{metric.label.instance_name}}` | `grafana-1-prod` | | `{{resource.label.xxx}}` | returns the resource label value | `{{resource.label.zone}}` | `us-east1-b` | Example Alias By: `{{metric.type}} - {{metric.labels.instance_name}}` Example Result: `compute.googleapis.com/instance/cpu/usage_time - server1-prod` ## Templating Instead of hard-coding things like server, application and sensor name in you metric queries you can use variables in their place. Variables are shown as dropdown select boxes at the top of the dashboard. These dropdowns makes it easy to change the data being displayed in your dashboard. Checkout the [Templating]({{< relref "reference/templating.md" >}}) documentation for an introduction to the templating feature and the different types of template variables. ### Query Variable Writing variable queries is not supported yet. ### Using variables in queries There are two syntaxes: * `$<varname>` Example: `metric.label.$metric_label` * `[[varname]]` Example: `metric.label.[[metric_label]]` Why two ways? The first syntax is easier to read and write but does not allow you to use a variable in the middle of a word. When the _Multi-value_ or _Include all value_ options are enabled, Grafana converts the labels from plain text to a regex compatible string, which means you have to use `=~` instead of `=`. ## Annotations {{< docs-imagebox img="/img/docs/v53/stackdriver_annotations_query_editor.png" max-width= "400px" class="docs-image--right" >}} [Annotations]({{< relref "reference/annotations.md" >}}) allows you to overlay rich event information on top of graphs. You add annotation queries via the Dashboard menu / Annotations view. Annotation rendering is expensive so it is important to limit the number of rows returned. There is no support for showing Stackdriver annotations and events yet but it works well with [custom metrics](https://cloud.google.com/monitoring/custom-metrics/) in Stackdriver. With the query editor for annotations, you can select a metric and filters. The `Title` and `Text` fields support templating and can use data returned from the query. For example, the Title field could have the following text: `{{metric.type}} has value: {{metric.value}}` Example Result: `monitoring.googleapis.com/uptime_check/http_status has this value: 502` ### Patterns for the Annotation Query Editor | Alias Pattern Format | Description | Alias Pattern Example | Example Result | | ------------------------ | -------------------------------- | -------------------------------- | ------------------------------------------------- | | `{{metric.value}}` | value of the metric/point | `{{metric.value}}` | `555` | | `{{metric.type}}` | returns the full Metric Type | `{{metric.type}}` | `compute.googleapis.com/instance/cpu/utilization` | | `{{metric.name}}` | returns the metric name part | `{{metric.name}}` | `instance/cpu/utilization` | | `{{metric.service}}` | returns the service part | `{{metric.service}}` | `compute` | | `{{metric.label.xxx}}` | returns the metric label value | `{{metric.label.instance_name}}` | `grafana-1-prod` | | `{{resource.label.xxx}}` | returns the resource label value | `{{resource.label.zone}}` | `us-east1-b` | ## Configure the Datasource with Provisioning It's now possible to configure datasources using config files with Grafana's provisioning system. You can read more about how it works and all the settings you can set for datasources on the [provisioning docs page](/administration/provisioning/#datasources) Here is a provisioning example for this datasource. ```yaml apiVersion: 1 datasources: - name: Stackdriver type: stackdriver access: proxy jsonData: tokenUri: https://oauth2.googleapis.com/token clientEmail: [email protected] secureJsonData: privateKey: | -----BEGIN PRIVATE KEY----- POSEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCb1u1Srw8ICYHS ... yA+23427282348234= -----END PRIVATE KEY----- ```
docs/sources/features/datasources/stackdriver.md
1
https://github.com/grafana/grafana/commit/03fefd7beaa322ea4fbfb2cb0aa2f8bc3d5dd6ff
[ 0.21403490006923676, 0.010802931152284145, 0.00016263713769149035, 0.00028274854412302375, 0.04439293220639229 ]
{ "id": 6, "code_window": [ "\n", "## Metric Query Editor\n", "\n", "{{< docs-imagebox img=\"/img/docs/v53/stackdriver_query_editor.png\" max-width= \"400px\" class=\"docs-image--right\" >}}\n", "\n", "The Stackdriver query editor allows you to select metrics and group by multiple labels and use filter the results.\n", "\n", "Begin by choosing a `Service` and then a metric from the `Metric` dropdown. Use the plus and minus icons in the filter and group by sections to add/remove filters or group by clauses.\n", "\n" ], "labels": [ "keep", "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep" ], "after_edit": [ "The Stackdriver query editor allows you to select metrics, group/aggregate by labels and by time, and use filters to specify which time series you want in the results.\n" ], "file_path": "docs/sources/features/datasources/stackdriver.md", "type": "replace", "edit_start_line_idx": 80 }
<page-header model="ctrl.navModel"></page-header> <div class="page-container page-body"> <h3 class="page-sub-heading" ng-hide="ctrl.isNew">Edit Notification Channel</h3> <h3 class="page-sub-heading" ng-show="ctrl.isNew">New Notification Channel</h3> <form name="ctrl.theForm" ng-if="ctrl.notifiers"> <div class="gf-form-group"> <div class="gf-form"> <span class="gf-form-label width-12">Name</span> <input type="text" required class="gf-form-input max-width-15" ng-model="ctrl.model.name" required></input> </div> <div class="gf-form"> <span class="gf-form-label width-12">Type</span> <div class="gf-form-select-wrapper width-15"> <select class="gf-form-input" ng-model="ctrl.model.type" ng-options="t.type as t.name for t in ctrl.notifiers" ng-change="ctrl.typeChanged(notification, $index)"> </select> </div> </div> <gf-form-switch class="gf-form" label="Send on all alerts" label-class="width-12" checked="ctrl.model.isDefault" tooltip="Use this notification for all alerts"> </gf-form-switch> <gf-form-switch class="gf-form" label="Include image" label-class="width-12" checked="ctrl.model.settings.uploadImage" tooltip="Captures an image and include it in the notification"> </gf-form-switch> <gf-form-switch class="gf-form" label="Send reminders" label-class="width-12" checked="ctrl.model.sendReminder" tooltip="Send additional notifications for triggered alerts"> </gf-form-switch> <div class="gf-form-inline"> <div class="gf-form" ng-if="ctrl.model.sendReminder"> <span class="gf-form-label width-12">Send reminder every <info-popover mode="right-normal" position="top center"> Specify how often reminders should be sent, e.g. every 30s, 1m, 10m, 30m or 1h etc. </info-popover> </span> <input type="text" placeholder="Select or specify custom" class="gf-form-input width-15" ng-model="ctrl.model.frequency" bs-typeahead="ctrl.getFrequencySuggestion" data-min-length=0 ng-required="ctrl.model.sendReminder"> </div> </div> <div class="gf-form"> <span class="alert alert-info width-30" ng-if="ctrl.model.sendReminder"> Alert reminders are sent after rules are evaluated. Therefore a reminder can never be sent more frequently than a configured alert rule evaluation interval. </span> </div> </div> <div class="gf-form-group" ng-include src="ctrl.notifierTemplateId"> </div> <div class="gf-form-group gf-form-button-row"> <button type="submit" ng-click="ctrl.save()" class="btn btn-success width-7">Save</button> <button type="submit" ng-click="ctrl.testNotification()" class="btn btn-secondary width-7">Send Test</button> <a href="alerting/notifications" class="btn btn-inverse">Back</a> </div> </form> </div>
public/app/features/alerting/partials/notification_edit.html
0
https://github.com/grafana/grafana/commit/03fefd7beaa322ea4fbfb2cb0aa2f8bc3d5dd6ff
[ 0.000173470180016011, 0.00017204348114319146, 0.00017061977996490896, 0.00017155321256723255, 0.0000011575741609703982 ]
{ "id": 6, "code_window": [ "\n", "## Metric Query Editor\n", "\n", "{{< docs-imagebox img=\"/img/docs/v53/stackdriver_query_editor.png\" max-width= \"400px\" class=\"docs-image--right\" >}}\n", "\n", "The Stackdriver query editor allows you to select metrics and group by multiple labels and use filter the results.\n", "\n", "Begin by choosing a `Service` and then a metric from the `Metric` dropdown. Use the plus and minus icons in the filter and group by sections to add/remove filters or group by clauses.\n", "\n" ], "labels": [ "keep", "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep" ], "after_edit": [ "The Stackdriver query editor allows you to select metrics, group/aggregate by labels and by time, and use filters to specify which time series you want in the results.\n" ], "file_path": "docs/sources/features/datasources/stackdriver.md", "type": "replace", "edit_start_line_idx": 80 }
import $ from 'jquery'; import baron from 'baron'; import coreModule from 'app/core/core_module'; const scrollBarHTML = ` <div class="baron__track"> <div class="baron__bar"></div> </div> `; const scrollRootClass = 'baron baron__root'; const scrollerClass = 'baron__scroller'; export function geminiScrollbar() { return { restrict: 'A', link: (scope, elem, attrs) => { let scrollRoot = elem.parent(); const scroller = elem; if (attrs.grafanaScrollbar && attrs.grafanaScrollbar === 'scrollonroot') { scrollRoot = scroller; } scrollRoot.addClass(scrollRootClass); $(scrollBarHTML).appendTo(scrollRoot); elem.addClass(scrollerClass); const scrollParams = { root: scrollRoot[0], scroller: scroller[0], bar: '.baron__bar', barOnCls: '_scrollbar', scrollingCls: '_scrolling', track: '.baron__track', direction: 'v', }; const scrollbar = baron(scrollParams); scope.$on('$destroy', () => { scrollbar.dispose(); }); }, }; } coreModule.directive('grafanaScrollbar', geminiScrollbar);
public/app/core/components/scroll/scroll.ts
0
https://github.com/grafana/grafana/commit/03fefd7beaa322ea4fbfb2cb0aa2f8bc3d5dd6ff
[ 0.000172521045897156, 0.00017048127483576536, 0.00016891735140234232, 0.00017054624913726002, 0.0000012852856343670283 ]
{ "id": 6, "code_window": [ "\n", "## Metric Query Editor\n", "\n", "{{< docs-imagebox img=\"/img/docs/v53/stackdriver_query_editor.png\" max-width= \"400px\" class=\"docs-image--right\" >}}\n", "\n", "The Stackdriver query editor allows you to select metrics and group by multiple labels and use filter the results.\n", "\n", "Begin by choosing a `Service` and then a metric from the `Metric` dropdown. Use the plus and minus icons in the filter and group by sections to add/remove filters or group by clauses.\n", "\n" ], "labels": [ "keep", "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep" ], "after_edit": [ "The Stackdriver query editor allows you to select metrics, group/aggregate by labels and by time, and use filters to specify which time series you want in the results.\n" ], "file_path": "docs/sources/features/datasources/stackdriver.md", "type": "replace", "edit_start_line_idx": 80 }
import React, { PureComponent } from 'react'; import { connect } from 'react-redux'; import SlideDown from 'app/core/components/Animations/SlideDown'; import Tooltip from 'app/core/components/Tooltip/Tooltip'; import { TeamGroup } from '../../types'; import { addTeamGroup, loadTeamGroups, removeTeamGroup } from './state/actions'; import { getTeamGroups } from './state/selectors'; export interface Props { groups: TeamGroup[]; loadTeamGroups: typeof loadTeamGroups; addTeamGroup: typeof addTeamGroup; removeTeamGroup: typeof removeTeamGroup; } interface State { isAdding: boolean; newGroupId?: string; } const headerTooltip = `Sync LDAP or OAuth groups with your Grafana teams.`; export class TeamGroupSync extends PureComponent<Props, State> { constructor(props) { super(props); this.state = { isAdding: false, newGroupId: '' }; } componentDidMount() { this.fetchTeamGroups(); } async fetchTeamGroups() { await this.props.loadTeamGroups(); } onToggleAdding = () => { this.setState({ isAdding: !this.state.isAdding }); }; onNewGroupIdChanged = event => { this.setState({ newGroupId: event.target.value }); }; onAddGroup = event => { event.preventDefault(); this.props.addTeamGroup(this.state.newGroupId); this.setState({ isAdding: false, newGroupId: '' }); }; onRemoveGroup = (group: TeamGroup) => { this.props.removeTeamGroup(group.groupId); }; isNewGroupValid() { return this.state.newGroupId.length > 1; } renderGroup(group: TeamGroup) { return ( <tr key={group.groupId}> <td>{group.groupId}</td> <td style={{ width: '1%' }}> <a className="btn btn-danger btn-mini" onClick={() => this.onRemoveGroup(group)}> <i className="fa fa-remove" /> </a> </td> </tr> ); } render() { const { isAdding, newGroupId } = this.state; const groups = this.props.groups; return ( <div> <div className="page-action-bar"> <h3 className="page-sub-heading">External group sync</h3> <Tooltip className="page-sub-heading-icon" placement="auto" content={headerTooltip}> <i className="gicon gicon-question gicon--has-hover" /> </Tooltip> <div className="page-action-bar__spacer" /> {groups.length > 0 && ( <button className="btn btn-success pull-right" onClick={this.onToggleAdding}> <i className="fa fa-plus" /> Add group </button> )} </div> <SlideDown in={isAdding}> <div className="cta-form"> <button className="cta-form__close btn btn-transparent" onClick={this.onToggleAdding}> <i className="fa fa-close" /> </button> <h5>Add External Group</h5> <form className="gf-form-inline" onSubmit={this.onAddGroup}> <div className="gf-form"> <input type="text" className="gf-form-input width-30" value={newGroupId} onChange={this.onNewGroupIdChanged} placeholder="cn=ops,ou=groups,dc=grafana,dc=org" /> </div> <div className="gf-form"> <button className="btn btn-success gf-form-btn" type="submit" disabled={!this.isNewGroupValid()}> Add group </button> </div> </form> </div> </SlideDown> {groups.length === 0 && !isAdding && ( <div className="empty-list-cta"> <div className="empty-list-cta__title">There are no external groups to sync with</div> <button onClick={this.onToggleAdding} className="empty-list-cta__button btn btn-xlarge btn-success"> <i className="gicon gicon-add-team" /> Add Group </button> <div className="empty-list-cta__pro-tip"> <i className="fa fa-rocket" /> {headerTooltip} <a className="text-link empty-list-cta__pro-tip-link" href="asd" target="_blank"> Learn more </a> </div> </div> )} {groups.length > 0 && ( <div className="admin-list-table"> <table className="filter-table filter-table--hover form-inline"> <thead> <tr> <th>External Group ID</th> <th style={{ width: '1%' }} /> </tr> </thead> <tbody>{groups.map(group => this.renderGroup(group))}</tbody> </table> </div> )} </div> ); } } function mapStateToProps(state) { return { groups: getTeamGroups(state.team), }; } const mapDispatchToProps = { loadTeamGroups, addTeamGroup, removeTeamGroup, }; export default connect(mapStateToProps, mapDispatchToProps)(TeamGroupSync);
public/app/features/teams/TeamGroupSync.tsx
0
https://github.com/grafana/grafana/commit/03fefd7beaa322ea4fbfb2cb0aa2f8bc3d5dd6ff
[ 0.00023009169672150165, 0.0001720528962323442, 0.00016366464842576534, 0.00016807738575153053, 0.000014807555089646485 ]
{ "id": 7, "code_window": [ " </a>\n", " <a href=\"{{< relref \"features/datasources/prometheus.md\" >}}\" class=\"nav-cards__item nav-cards__item--ds\">\n", " <img src=\"/img/docs/logos/icon_prometheus.svg\" >\n", " <h5>Prometheus</h5>\n", " </a>\n", " <a href=\"{{< relref \"features/datasources/opentsdb.md\" >}}\" class=\"nav-cards__item nav-cards__item--ds\">\n", " <img src=\"/img/docs/logos/icon_opentsdb.png\" >\n", " <h5>OpenTSDB</h5>\n", " </a>\n", " <a href=\"{{< relref \"features/datasources/mysql.md\" >}}\" class=\"nav-cards__item nav-cards__item--ds\">\n", " <img src=\"/img/docs/logos/icon_mysql.png\" >\n", " <h5>MySQL</h5>\n" ], "labels": [ "keep", "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " <a href=\"{{< relref \"features/datasources/stackdriver.md\" >}}\" class=\"nav-cards__item nav-cards__item--ds\">\n", " <img src=\"/img/docs/logos/stackdriver_logo.png\">\n", " <h5>Google Stackdriver</h5>\n", " </a>\n", " <a href=\"{{< relref \"features/datasources/cloudwatch.md\" >}}\" class=\"nav-cards__item nav-cards__item--ds\">\n", " <img src=\"/img/docs/logos/icon_cloudwatch.svg\">\n", " <h5>Cloudwatch</h5>\n" ], "file_path": "docs/sources/index.md", "type": "replace", "edit_start_line_idx": 90 }
+++ title = "Using Stackdriver in Grafana" description = "Guide for using Stackdriver in Grafana" keywords = ["grafana", "stackdriver", "google", "guide"] type = "docs" aliases = ["/datasources/stackdriver"] [menu.docs] name = "Stackdriver" parent = "datasources" weight = 11 +++ # Using Google Stackdriver in Grafana > Only available in Grafana v5.3+. > The datasource is currently a beta feature and is subject to change. Grafana ships with built-in support for Google Stackdriver. Just add it as a datasource and you are ready to build dashboards for your Stackdriver metrics. ## Adding the data source to Grafana 1. Open the side menu by clicking the Grafana icon in the top header. 2. In the side menu under the `Dashboards` link you should find a link named `Data Sources`. 3. Click the `+ Add data source` button in the top header. 4. Select `Stackdriver` from the _Type_ dropdown. 5. Upload or paste in the Service Account Key file. See below for steps on how to create a Service Account Key file. > NOTE: If you're not seeing the `Data Sources` link in your side menu it means that your current user does not have the `Admin` role for the current organization. | Name | Description | | --------------------- | ----------------------------------------------------------------------------------- | | _Name_ | The datasource name. This is how you refer to the datasource in panels & queries. | | _Default_ | Default datasource means that it will be pre-selected for new panels. | | _Service Account Key_ | Service Account Key File for a GCP Project. Instructions below on how to create it. | ## Authentication ### Service Account Credentials - Private Key File To authenticate with the Stackdriver API, you need to create a Google Cloud Platform (GCP) Service Account for the Project you want to show data for. A Grafana datasource integrates with one GCP Project. If you want to visualize data from multiple GCP Projects then you need to create one datasource per GCP Project. #### Enable APIs The following APIs need to be enabled first: * [Monitoring API](https://console.cloud.google.com/apis/library/monitoring.googleapis.com) * [Cloud Resource Manager API](https://console.cloud.google.com/apis/library/cloudresourcemanager.googleapis.com) Click on the links above and click the `Enable` button: ![Enable GCP APIs](/img/docs/v53/stackdriver_enable_api.png) #### Create a GCP Service Account for a Project 1. Navigate to the [APIs & Services Credentials page](https://console.cloud.google.com/apis/credentials). 2. Click on the `Create credentials` dropdown/button and choose the `Service account key` option. ![Create service account button](/img/docs/v53/stackdriver_create_service_account_button.png) 3. On the `Create service account key` page, choose key type `JSON`. Then in the `Service Account` dropdown, choose the `New service account` option: ![Create service account key](/img/docs/v53/stackdriver_create_service_account_key.png) 4. Some new fields will appear. Fill in a name for the service account in the `Service account name` field and then choose the `Monitoring Viewer` role from the `Role` dropdown: ![Choose role](/img/docs/v53/stackdriver_service_account_choose_role.png) 5. Click the Create button. A JSON key file will be created and downloaded to your computer. Store this file in a secure place as it allows access to your Stackdriver data. 6. Upload it to Grafana on the datasource Configuration page. You can either upload the file or paste in the contents of the file. ![Choose role](/img/docs/v53/stackdriver_grafana_upload_key.png) 7. The file contents will be encrypted and saved in the Grafana database. Don't forget to save after uploading the file! ![Choose role](/img/docs/v53/stackdriver_grafana_key_uploaded.png) ## Metric Query Editor {{< docs-imagebox img="/img/docs/v53/stackdriver_query_editor.png" max-width= "400px" class="docs-image--right" >}} The Stackdriver query editor allows you to select metrics and group by multiple labels and use filter the results. Begin by choosing a `Service` and then a metric from the `Metric` dropdown. Use the plus and minus icons in the filter and group by sections to add/remove filters or group by clauses. Stackdriver metrics can be of different kinds (GAUGE, DELTA, CUMULATIVE) and these kinds have support for different aggregation options (reducers and aligners). The Grafana query editor shows the list of available aggregation methods for a selected metric and sets a default reducer and aligner when you select the metric. Units for the Y-axis are also automatically selected by the query editor. ### Filter To add a filter, click the plus icon and choose a field to filter by and enter a filter value e.g. `instance_name = grafana-1`. You can remove the filter by clicking on the filter name and select `--remove filter--`. #### Simple wildcards When the operator is set to `=` or `!=` it is possible to add wildcards to the filter value field. E.g `us-*` will capture all values that starts with "us-" and `*central-a` will capture all values that ends with "central-a". `*-central-*` captures all values that has the substring of -central-. Simple wildcards are less expensive than regular expressions. #### Regular expressions When the operator is set to `=~` or `!=~` it is possible to add regular expressions to the filter value field. E.g `us-central[1-3]-[af]` would match all values that starts with "us-central", is followed by a number in the range of 1 to 3, a dash and then either an "a" or an "f". Leading and trailing slashes are not needed when creating regular expressions. ### Aggregation The aggregation field lets you combine time series based on common statistics. Read more about this option [here](https://cloud.google.com/monitoring/charts/metrics-selector#aggregation-options). The `Aligner` field allows you to align multiple time series after the same group by time interval. Read more about how it works [here](https://cloud.google.com/monitoring/charts/metrics-selector#alignment). #### Alignment Period/Group by Time The `Alignment Period` groups a metric by time if an aggregation is chosen. The default is to use the GCP Stackdriver default groupings (which allows you to compare graphs in Grafana with graphs in the Stackdriver UI). The option is called `Stackdriver auto` and the defaults are: * 1m for time ranges < 23 hours * 5m for time ranges >= 23 hours and < 6 days * 1h for time ranges >= 6 days The other automatic option is `Grafana auto`. This will automatically set the group by time depending on the time range chosen and the width of the graph panel. Read more about the details [here](http://docs.grafana.org/reference/templating/#the-interval-variable). It is also possible to choose fixed time intervals to group by, like `1h` or `1d`. ### Group By Group by resource or metric labels to reduce the number of time series and to aggregate the results by a group by. E.g. Group by instance_name to see an aggregated metric for a Compute instance. ### Alias Patterns The Alias By field allows you to control the format of the legend keys. The default is to show the metric name and labels. This can be long and hard to read. Using the following patterns in the alias field, you can format the legend key the way you want it. #### Metric Type Patterns | Alias Pattern | Description | Example Result | | -------------------- | ---------------------------- | ------------------------------------------------- | | `{{metric.type}}` | returns the full Metric Type | `compute.googleapis.com/instance/cpu/utilization` | | `{{metric.name}}` | returns the metric name part | `instance/cpu/utilization` | | `{{metric.service}}` | returns the service part | `compute` | #### Label Patterns In the Group By dropdown, you can see a list of metric and resource labels for a metric. These can be included in the legend key using alias patterns. | Alias Pattern Format | Description | Alias Pattern Example | Example Result | | ------------------------ | -------------------------------- | -------------------------------- | ---------------- | | `{{metric.label.xxx}}` | returns the metric label value | `{{metric.label.instance_name}}` | `grafana-1-prod` | | `{{resource.label.xxx}}` | returns the resource label value | `{{resource.label.zone}}` | `us-east1-b` | Example Alias By: `{{metric.type}} - {{metric.labels.instance_name}}` Example Result: `compute.googleapis.com/instance/cpu/usage_time - server1-prod` ## Templating Instead of hard-coding things like server, application and sensor name in you metric queries you can use variables in their place. Variables are shown as dropdown select boxes at the top of the dashboard. These dropdowns makes it easy to change the data being displayed in your dashboard. Checkout the [Templating]({{< relref "reference/templating.md" >}}) documentation for an introduction to the templating feature and the different types of template variables. ### Query Variable Writing variable queries is not supported yet. ### Using variables in queries There are two syntaxes: * `$<varname>` Example: `metric.label.$metric_label` * `[[varname]]` Example: `metric.label.[[metric_label]]` Why two ways? The first syntax is easier to read and write but does not allow you to use a variable in the middle of a word. When the _Multi-value_ or _Include all value_ options are enabled, Grafana converts the labels from plain text to a regex compatible string, which means you have to use `=~` instead of `=`. ## Annotations {{< docs-imagebox img="/img/docs/v53/stackdriver_annotations_query_editor.png" max-width= "400px" class="docs-image--right" >}} [Annotations]({{< relref "reference/annotations.md" >}}) allows you to overlay rich event information on top of graphs. You add annotation queries via the Dashboard menu / Annotations view. Annotation rendering is expensive so it is important to limit the number of rows returned. There is no support for showing Stackdriver annotations and events yet but it works well with [custom metrics](https://cloud.google.com/monitoring/custom-metrics/) in Stackdriver. With the query editor for annotations, you can select a metric and filters. The `Title` and `Text` fields support templating and can use data returned from the query. For example, the Title field could have the following text: `{{metric.type}} has value: {{metric.value}}` Example Result: `monitoring.googleapis.com/uptime_check/http_status has this value: 502` ### Patterns for the Annotation Query Editor | Alias Pattern Format | Description | Alias Pattern Example | Example Result | | ------------------------ | -------------------------------- | -------------------------------- | ------------------------------------------------- | | `{{metric.value}}` | value of the metric/point | `{{metric.value}}` | `555` | | `{{metric.type}}` | returns the full Metric Type | `{{metric.type}}` | `compute.googleapis.com/instance/cpu/utilization` | | `{{metric.name}}` | returns the metric name part | `{{metric.name}}` | `instance/cpu/utilization` | | `{{metric.service}}` | returns the service part | `{{metric.service}}` | `compute` | | `{{metric.label.xxx}}` | returns the metric label value | `{{metric.label.instance_name}}` | `grafana-1-prod` | | `{{resource.label.xxx}}` | returns the resource label value | `{{resource.label.zone}}` | `us-east1-b` | ## Configure the Datasource with Provisioning It's now possible to configure datasources using config files with Grafana's provisioning system. You can read more about how it works and all the settings you can set for datasources on the [provisioning docs page](/administration/provisioning/#datasources) Here is a provisioning example for this datasource. ```yaml apiVersion: 1 datasources: - name: Stackdriver type: stackdriver access: proxy jsonData: tokenUri: https://oauth2.googleapis.com/token clientEmail: [email protected] secureJsonData: privateKey: | -----BEGIN PRIVATE KEY----- POSEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCb1u1Srw8ICYHS ... yA+23427282348234= -----END PRIVATE KEY----- ```
docs/sources/features/datasources/stackdriver.md
1
https://github.com/grafana/grafana/commit/03fefd7beaa322ea4fbfb2cb0aa2f8bc3d5dd6ff
[ 0.00017669069347903132, 0.00016970158321782947, 0.00016019136819522828, 0.00016973339370451868, 0.0000044946782509214245 ]
{ "id": 7, "code_window": [ " </a>\n", " <a href=\"{{< relref \"features/datasources/prometheus.md\" >}}\" class=\"nav-cards__item nav-cards__item--ds\">\n", " <img src=\"/img/docs/logos/icon_prometheus.svg\" >\n", " <h5>Prometheus</h5>\n", " </a>\n", " <a href=\"{{< relref \"features/datasources/opentsdb.md\" >}}\" class=\"nav-cards__item nav-cards__item--ds\">\n", " <img src=\"/img/docs/logos/icon_opentsdb.png\" >\n", " <h5>OpenTSDB</h5>\n", " </a>\n", " <a href=\"{{< relref \"features/datasources/mysql.md\" >}}\" class=\"nav-cards__item nav-cards__item--ds\">\n", " <img src=\"/img/docs/logos/icon_mysql.png\" >\n", " <h5>MySQL</h5>\n" ], "labels": [ "keep", "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " <a href=\"{{< relref \"features/datasources/stackdriver.md\" >}}\" class=\"nav-cards__item nav-cards__item--ds\">\n", " <img src=\"/img/docs/logos/stackdriver_logo.png\">\n", " <h5>Google Stackdriver</h5>\n", " </a>\n", " <a href=\"{{< relref \"features/datasources/cloudwatch.md\" >}}\" class=\"nav-cards__item nav-cards__item--ds\">\n", " <img src=\"/img/docs/logos/icon_cloudwatch.svg\">\n", " <h5>Cloudwatch</h5>\n" ], "file_path": "docs/sources/index.md", "type": "replace", "edit_start_line_idx": 90 }
# Should not be included apiVersion: 1 #datasources: # - name: name # type: type # access: proxy # orgId: 2 # url: url # password: password # user: user # database: database # basicAuth: true # basicAuthUser: basic_auth_user # basicAuthPassword: basic_auth_password # withCredentials: true # jsonData: # graphiteVersion: "1.1" # tlsAuth: true # tlsAuthWithCACert: true # secureJsonData: # tlsCACert: "MjNOcW9RdkbUDHZmpco2HCYzVq9dE+i6Yi+gmUJotq5CDA==" # tlsClientCert: "ckN0dGlyMXN503YNfjTcf9CV+GGQneN+xmAclQ==" # tlsClientKey: "ZkN4aG1aNkja/gKAB1wlnKFIsy2SRDq4slrM0A==" # editable: true # version: 10 # #deleteDatasources: # - name: old-graphite3 # orgId: 2
pkg/services/provisioning/datasources/testdata/all-properties/sample.yaml
0
https://github.com/grafana/grafana/commit/03fefd7beaa322ea4fbfb2cb0aa2f8bc3d5dd6ff
[ 0.0001698553969617933, 0.00016742173465900123, 0.00016556844639126211, 0.00016713155491743237, 0.0000015998850813048193 ]
{ "id": 7, "code_window": [ " </a>\n", " <a href=\"{{< relref \"features/datasources/prometheus.md\" >}}\" class=\"nav-cards__item nav-cards__item--ds\">\n", " <img src=\"/img/docs/logos/icon_prometheus.svg\" >\n", " <h5>Prometheus</h5>\n", " </a>\n", " <a href=\"{{< relref \"features/datasources/opentsdb.md\" >}}\" class=\"nav-cards__item nav-cards__item--ds\">\n", " <img src=\"/img/docs/logos/icon_opentsdb.png\" >\n", " <h5>OpenTSDB</h5>\n", " </a>\n", " <a href=\"{{< relref \"features/datasources/mysql.md\" >}}\" class=\"nav-cards__item nav-cards__item--ds\">\n", " <img src=\"/img/docs/logos/icon_mysql.png\" >\n", " <h5>MySQL</h5>\n" ], "labels": [ "keep", "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " <a href=\"{{< relref \"features/datasources/stackdriver.md\" >}}\" class=\"nav-cards__item nav-cards__item--ds\">\n", " <img src=\"/img/docs/logos/stackdriver_logo.png\">\n", " <h5>Google Stackdriver</h5>\n", " </a>\n", " <a href=\"{{< relref \"features/datasources/cloudwatch.md\" >}}\" class=\"nav-cards__item nav-cards__item--ds\">\n", " <img src=\"/img/docs/logos/icon_cloudwatch.svg\">\n", " <h5>Cloudwatch</h5>\n" ], "file_path": "docs/sources/index.md", "type": "replace", "edit_start_line_idx": 90 }
// mkerrors.sh // Code generated by the command above; see README.md. DO NOT EDIT. // Created by cgo -godefs - DO NOT EDIT // cgo -godefs -- _const.go // +build arm,openbsd package unix import "syscall" const ( AF_APPLETALK = 0x10 AF_BLUETOOTH = 0x20 AF_CCITT = 0xa AF_CHAOS = 0x5 AF_CNT = 0x15 AF_COIP = 0x14 AF_DATAKIT = 0x9 AF_DECnet = 0xc AF_DLI = 0xd AF_E164 = 0x1a AF_ECMA = 0x8 AF_ENCAP = 0x1c AF_HYLINK = 0xf AF_IMPLINK = 0x3 AF_INET = 0x2 AF_INET6 = 0x18 AF_IPX = 0x17 AF_ISDN = 0x1a AF_ISO = 0x7 AF_KEY = 0x1e AF_LAT = 0xe AF_LINK = 0x12 AF_LOCAL = 0x1 AF_MAX = 0x24 AF_MPLS = 0x21 AF_NATM = 0x1b AF_NS = 0x6 AF_OSI = 0x7 AF_PUP = 0x4 AF_ROUTE = 0x11 AF_SIP = 0x1d AF_SNA = 0xb AF_UNIX = 0x1 AF_UNSPEC = 0x0 ARPHRD_ETHER = 0x1 ARPHRD_FRELAY = 0xf ARPHRD_IEEE1394 = 0x18 ARPHRD_IEEE802 = 0x6 B0 = 0x0 B110 = 0x6e B115200 = 0x1c200 B1200 = 0x4b0 B134 = 0x86 B14400 = 0x3840 B150 = 0x96 B1800 = 0x708 B19200 = 0x4b00 B200 = 0xc8 B230400 = 0x38400 B2400 = 0x960 B28800 = 0x7080 B300 = 0x12c B38400 = 0x9600 B4800 = 0x12c0 B50 = 0x32 B57600 = 0xe100 B600 = 0x258 B7200 = 0x1c20 B75 = 0x4b B76800 = 0x12c00 B9600 = 0x2580 BIOCFLUSH = 0x20004268 BIOCGBLEN = 0x40044266 BIOCGDIRFILT = 0x4004427c BIOCGDLT = 0x4004426a BIOCGDLTLIST = 0xc008427b BIOCGETIF = 0x4020426b BIOCGFILDROP = 0x40044278 BIOCGHDRCMPLT = 0x40044274 BIOCGRSIG = 0x40044273 BIOCGRTIMEOUT = 0x400c426e BIOCGSTATS = 0x4008426f BIOCIMMEDIATE = 0x80044270 BIOCLOCK = 0x20004276 BIOCPROMISC = 0x20004269 BIOCSBLEN = 0xc0044266 BIOCSDIRFILT = 0x8004427d BIOCSDLT = 0x8004427a BIOCSETF = 0x80084267 BIOCSETIF = 0x8020426c BIOCSETWF = 0x80084277 BIOCSFILDROP = 0x80044279 BIOCSHDRCMPLT = 0x80044275 BIOCSRSIG = 0x80044272 BIOCSRTIMEOUT = 0x800c426d BIOCVERSION = 0x40044271 BPF_A = 0x10 BPF_ABS = 0x20 BPF_ADD = 0x0 BPF_ALIGNMENT = 0x4 BPF_ALU = 0x4 BPF_AND = 0x50 BPF_B = 0x10 BPF_DIRECTION_IN = 0x1 BPF_DIRECTION_OUT = 0x2 BPF_DIV = 0x30 BPF_H = 0x8 BPF_IMM = 0x0 BPF_IND = 0x40 BPF_JA = 0x0 BPF_JEQ = 0x10 BPF_JGE = 0x30 BPF_JGT = 0x20 BPF_JMP = 0x5 BPF_JSET = 0x40 BPF_K = 0x0 BPF_LD = 0x0 BPF_LDX = 0x1 BPF_LEN = 0x80 BPF_LSH = 0x60 BPF_MAJOR_VERSION = 0x1 BPF_MAXBUFSIZE = 0x200000 BPF_MAXINSNS = 0x200 BPF_MEM = 0x60 BPF_MEMWORDS = 0x10 BPF_MINBUFSIZE = 0x20 BPF_MINOR_VERSION = 0x1 BPF_MISC = 0x7 BPF_MSH = 0xa0 BPF_MUL = 0x20 BPF_NEG = 0x80 BPF_OR = 0x40 BPF_RELEASE = 0x30bb6 BPF_RET = 0x6 BPF_RSH = 0x70 BPF_ST = 0x2 BPF_STX = 0x3 BPF_SUB = 0x10 BPF_TAX = 0x0 BPF_TXA = 0x80 BPF_W = 0x0 BPF_X = 0x8 BRKINT = 0x2 CFLUSH = 0xf CLOCAL = 0x8000 CREAD = 0x800 CRTSCTS = 0x10000 CS5 = 0x0 CS6 = 0x100 CS7 = 0x200 CS8 = 0x300 CSIZE = 0x300 CSTART = 0x11 CSTATUS = 0xff CSTOP = 0x13 CSTOPB = 0x400 CSUSP = 0x1a CTL_HW = 0x6 CTL_KERN = 0x1 CTL_MAXNAME = 0xc CTL_NET = 0x4 DIOCOSFPFLUSH = 0x2000444e DLT_ARCNET = 0x7 DLT_ATM_RFC1483 = 0xb DLT_AX25 = 0x3 DLT_CHAOS = 0x5 DLT_C_HDLC = 0x68 DLT_EN10MB = 0x1 DLT_EN3MB = 0x2 DLT_ENC = 0xd DLT_FDDI = 0xa DLT_IEEE802 = 0x6 DLT_IEEE802_11 = 0x69 DLT_IEEE802_11_RADIO = 0x7f DLT_LOOP = 0xc DLT_MPLS = 0xdb DLT_NULL = 0x0 DLT_PFLOG = 0x75 DLT_PFSYNC = 0x12 DLT_PPP = 0x9 DLT_PPP_BSDOS = 0x10 DLT_PPP_ETHER = 0x33 DLT_PPP_SERIAL = 0x32 DLT_PRONET = 0x4 DLT_RAW = 0xe DLT_SLIP = 0x8 DLT_SLIP_BSDOS = 0xf DT_BLK = 0x6 DT_CHR = 0x2 DT_DIR = 0x4 DT_FIFO = 0x1 DT_LNK = 0xa DT_REG = 0x8 DT_SOCK = 0xc DT_UNKNOWN = 0x0 ECHO = 0x8 ECHOCTL = 0x40 ECHOE = 0x2 ECHOK = 0x4 ECHOKE = 0x1 ECHONL = 0x10 ECHOPRT = 0x20 EMT_TAGOVF = 0x1 EMUL_ENABLED = 0x1 EMUL_NATIVE = 0x2 ENDRUNDISC = 0x9 ETHERMIN = 0x2e ETHERMTU = 0x5dc ETHERTYPE_8023 = 0x4 ETHERTYPE_AARP = 0x80f3 ETHERTYPE_ACCTON = 0x8390 ETHERTYPE_AEONIC = 0x8036 ETHERTYPE_ALPHA = 0x814a ETHERTYPE_AMBER = 0x6008 ETHERTYPE_AMOEBA = 0x8145 ETHERTYPE_AOE = 0x88a2 ETHERTYPE_APOLLO = 0x80f7 ETHERTYPE_APOLLODOMAIN = 0x8019 ETHERTYPE_APPLETALK = 0x809b ETHERTYPE_APPLITEK = 0x80c7 ETHERTYPE_ARGONAUT = 0x803a ETHERTYPE_ARP = 0x806 ETHERTYPE_AT = 0x809b ETHERTYPE_ATALK = 0x809b ETHERTYPE_ATOMIC = 0x86df ETHERTYPE_ATT = 0x8069 ETHERTYPE_ATTSTANFORD = 0x8008 ETHERTYPE_AUTOPHON = 0x806a ETHERTYPE_AXIS = 0x8856 ETHERTYPE_BCLOOP = 0x9003 ETHERTYPE_BOFL = 0x8102 ETHERTYPE_CABLETRON = 0x7034 ETHERTYPE_CHAOS = 0x804 ETHERTYPE_COMDESIGN = 0x806c ETHERTYPE_COMPUGRAPHIC = 0x806d ETHERTYPE_COUNTERPOINT = 0x8062 ETHERTYPE_CRONUS = 0x8004 ETHERTYPE_CRONUSVLN = 0x8003 ETHERTYPE_DCA = 0x1234 ETHERTYPE_DDE = 0x807b ETHERTYPE_DEBNI = 0xaaaa ETHERTYPE_DECAM = 0x8048 ETHERTYPE_DECCUST = 0x6006 ETHERTYPE_DECDIAG = 0x6005 ETHERTYPE_DECDNS = 0x803c ETHERTYPE_DECDTS = 0x803e ETHERTYPE_DECEXPER = 0x6000 ETHERTYPE_DECLAST = 0x8041 ETHERTYPE_DECLTM = 0x803f ETHERTYPE_DECMUMPS = 0x6009 ETHERTYPE_DECNETBIOS = 0x8040 ETHERTYPE_DELTACON = 0x86de ETHERTYPE_DIDDLE = 0x4321 ETHERTYPE_DLOG1 = 0x660 ETHERTYPE_DLOG2 = 0x661 ETHERTYPE_DN = 0x6003 ETHERTYPE_DOGFIGHT = 0x1989 ETHERTYPE_DSMD = 0x8039 ETHERTYPE_ECMA = 0x803 ETHERTYPE_ENCRYPT = 0x803d ETHERTYPE_ES = 0x805d ETHERTYPE_EXCELAN = 0x8010 ETHERTYPE_EXPERDATA = 0x8049 ETHERTYPE_FLIP = 0x8146 ETHERTYPE_FLOWCONTROL = 0x8808 ETHERTYPE_FRARP = 0x808 ETHERTYPE_GENDYN = 0x8068 ETHERTYPE_HAYES = 0x8130 ETHERTYPE_HIPPI_FP = 0x8180 ETHERTYPE_HITACHI = 0x8820 ETHERTYPE_HP = 0x8005 ETHERTYPE_IEEEPUP = 0xa00 ETHERTYPE_IEEEPUPAT = 0xa01 ETHERTYPE_IMLBL = 0x4c42 ETHERTYPE_IMLBLDIAG = 0x424c ETHERTYPE_IP = 0x800 ETHERTYPE_IPAS = 0x876c ETHERTYPE_IPV6 = 0x86dd ETHERTYPE_IPX = 0x8137 ETHERTYPE_IPXNEW = 0x8037 ETHERTYPE_KALPANA = 0x8582 ETHERTYPE_LANBRIDGE = 0x8038 ETHERTYPE_LANPROBE = 0x8888 ETHERTYPE_LAT = 0x6004 ETHERTYPE_LBACK = 0x9000 ETHERTYPE_LITTLE = 0x8060 ETHERTYPE_LLDP = 0x88cc ETHERTYPE_LOGICRAFT = 0x8148 ETHERTYPE_LOOPBACK = 0x9000 ETHERTYPE_MATRA = 0x807a ETHERTYPE_MAX = 0xffff ETHERTYPE_MERIT = 0x807c ETHERTYPE_MICP = 0x873a ETHERTYPE_MOPDL = 0x6001 ETHERTYPE_MOPRC = 0x6002 ETHERTYPE_MOTOROLA = 0x818d ETHERTYPE_MPLS = 0x8847 ETHERTYPE_MPLS_MCAST = 0x8848 ETHERTYPE_MUMPS = 0x813f ETHERTYPE_NBPCC = 0x3c04 ETHERTYPE_NBPCLAIM = 0x3c09 ETHERTYPE_NBPCLREQ = 0x3c05 ETHERTYPE_NBPCLRSP = 0x3c06 ETHERTYPE_NBPCREQ = 0x3c02 ETHERTYPE_NBPCRSP = 0x3c03 ETHERTYPE_NBPDG = 0x3c07 ETHERTYPE_NBPDGB = 0x3c08 ETHERTYPE_NBPDLTE = 0x3c0a ETHERTYPE_NBPRAR = 0x3c0c ETHERTYPE_NBPRAS = 0x3c0b ETHERTYPE_NBPRST = 0x3c0d ETHERTYPE_NBPSCD = 0x3c01 ETHERTYPE_NBPVCD = 0x3c00 ETHERTYPE_NBS = 0x802 ETHERTYPE_NCD = 0x8149 ETHERTYPE_NESTAR = 0x8006 ETHERTYPE_NETBEUI = 0x8191 ETHERTYPE_NOVELL = 0x8138 ETHERTYPE_NS = 0x600 ETHERTYPE_NSAT = 0x601 ETHERTYPE_NSCOMPAT = 0x807 ETHERTYPE_NTRAILER = 0x10 ETHERTYPE_OS9 = 0x7007 ETHERTYPE_OS9NET = 0x7009 ETHERTYPE_PACER = 0x80c6 ETHERTYPE_PAE = 0x888e ETHERTYPE_PCS = 0x4242 ETHERTYPE_PLANNING = 0x8044 ETHERTYPE_PPP = 0x880b ETHERTYPE_PPPOE = 0x8864 ETHERTYPE_PPPOEDISC = 0x8863 ETHERTYPE_PRIMENTS = 0x7031 ETHERTYPE_PUP = 0x200 ETHERTYPE_PUPAT = 0x200 ETHERTYPE_QINQ = 0x88a8 ETHERTYPE_RACAL = 0x7030 ETHERTYPE_RATIONAL = 0x8150 ETHERTYPE_RAWFR = 0x6559 ETHERTYPE_RCL = 0x1995 ETHERTYPE_RDP = 0x8739 ETHERTYPE_RETIX = 0x80f2 ETHERTYPE_REVARP = 0x8035 ETHERTYPE_SCA = 0x6007 ETHERTYPE_SECTRA = 0x86db ETHERTYPE_SECUREDATA = 0x876d ETHERTYPE_SGITW = 0x817e ETHERTYPE_SG_BOUNCE = 0x8016 ETHERTYPE_SG_DIAG = 0x8013 ETHERTYPE_SG_NETGAMES = 0x8014 ETHERTYPE_SG_RESV = 0x8015 ETHERTYPE_SIMNET = 0x5208 ETHERTYPE_SLOW = 0x8809 ETHERTYPE_SNA = 0x80d5 ETHERTYPE_SNMP = 0x814c ETHERTYPE_SONIX = 0xfaf5 ETHERTYPE_SPIDER = 0x809f ETHERTYPE_SPRITE = 0x500 ETHERTYPE_STP = 0x8181 ETHERTYPE_TALARIS = 0x812b ETHERTYPE_TALARISMC = 0x852b ETHERTYPE_TCPCOMP = 0x876b ETHERTYPE_TCPSM = 0x9002 ETHERTYPE_TEC = 0x814f ETHERTYPE_TIGAN = 0x802f ETHERTYPE_TRAIL = 0x1000 ETHERTYPE_TRANSETHER = 0x6558 ETHERTYPE_TYMSHARE = 0x802e ETHERTYPE_UBBST = 0x7005 ETHERTYPE_UBDEBUG = 0x900 ETHERTYPE_UBDIAGLOOP = 0x7002 ETHERTYPE_UBDL = 0x7000 ETHERTYPE_UBNIU = 0x7001 ETHERTYPE_UBNMC = 0x7003 ETHERTYPE_VALID = 0x1600 ETHERTYPE_VARIAN = 0x80dd ETHERTYPE_VAXELN = 0x803b ETHERTYPE_VEECO = 0x8067 ETHERTYPE_VEXP = 0x805b ETHERTYPE_VGLAB = 0x8131 ETHERTYPE_VINES = 0xbad ETHERTYPE_VINESECHO = 0xbaf ETHERTYPE_VINESLOOP = 0xbae ETHERTYPE_VITAL = 0xff00 ETHERTYPE_VLAN = 0x8100 ETHERTYPE_VLTLMAN = 0x8080 ETHERTYPE_VPROD = 0x805c ETHERTYPE_VURESERVED = 0x8147 ETHERTYPE_WATERLOO = 0x8130 ETHERTYPE_WELLFLEET = 0x8103 ETHERTYPE_X25 = 0x805 ETHERTYPE_X75 = 0x801 ETHERTYPE_XNSSM = 0x9001 ETHERTYPE_XTP = 0x817d ETHER_ADDR_LEN = 0x6 ETHER_ALIGN = 0x2 ETHER_CRC_LEN = 0x4 ETHER_CRC_POLY_BE = 0x4c11db6 ETHER_CRC_POLY_LE = 0xedb88320 ETHER_HDR_LEN = 0xe ETHER_MAX_DIX_LEN = 0x600 ETHER_MAX_LEN = 0x5ee ETHER_MIN_LEN = 0x40 ETHER_TYPE_LEN = 0x2 ETHER_VLAN_ENCAP_LEN = 0x4 EVFILT_AIO = -0x3 EVFILT_PROC = -0x5 EVFILT_READ = -0x1 EVFILT_SIGNAL = -0x6 EVFILT_SYSCOUNT = 0x7 EVFILT_TIMER = -0x7 EVFILT_VNODE = -0x4 EVFILT_WRITE = -0x2 EV_ADD = 0x1 EV_CLEAR = 0x20 EV_DELETE = 0x2 EV_DISABLE = 0x8 EV_ENABLE = 0x4 EV_EOF = 0x8000 EV_ERROR = 0x4000 EV_FLAG1 = 0x2000 EV_ONESHOT = 0x10 EV_SYSFLAGS = 0xf000 EXTA = 0x4b00 EXTB = 0x9600 EXTPROC = 0x800 FD_CLOEXEC = 0x1 FD_SETSIZE = 0x400 FLUSHO = 0x800000 F_DUPFD = 0x0 F_DUPFD_CLOEXEC = 0xa F_GETFD = 0x1 F_GETFL = 0x3 F_GETLK = 0x7 F_GETOWN = 0x5 F_RDLCK = 0x1 F_SETFD = 0x2 F_SETFL = 0x4 F_SETLK = 0x8 F_SETLKW = 0x9 F_SETOWN = 0x6 F_UNLCK = 0x2 F_WRLCK = 0x3 HUPCL = 0x4000 HW_MACHINE = 0x1 ICANON = 0x100 ICMP6_FILTER = 0x12 ICRNL = 0x100 IEXTEN = 0x400 IFAN_ARRIVAL = 0x0 IFAN_DEPARTURE = 0x1 IFA_ROUTE = 0x1 IFF_ALLMULTI = 0x200 IFF_BROADCAST = 0x2 IFF_CANTCHANGE = 0x8e52 IFF_DEBUG = 0x4 IFF_LINK0 = 0x1000 IFF_LINK1 = 0x2000 IFF_LINK2 = 0x4000 IFF_LOOPBACK = 0x8 IFF_MULTICAST = 0x8000 IFF_NOARP = 0x80 IFF_NOTRAILERS = 0x20 IFF_OACTIVE = 0x400 IFF_POINTOPOINT = 0x10 IFF_PROMISC = 0x100 IFF_RUNNING = 0x40 IFF_SIMPLEX = 0x800 IFF_UP = 0x1 IFNAMSIZ = 0x10 IFT_1822 = 0x2 IFT_A12MPPSWITCH = 0x82 IFT_AAL2 = 0xbb IFT_AAL5 = 0x31 IFT_ADSL = 0x5e IFT_AFLANE8023 = 0x3b IFT_AFLANE8025 = 0x3c IFT_ARAP = 0x58 IFT_ARCNET = 0x23 IFT_ARCNETPLUS = 0x24 IFT_ASYNC = 0x54 IFT_ATM = 0x25 IFT_ATMDXI = 0x69 IFT_ATMFUNI = 0x6a IFT_ATMIMA = 0x6b IFT_ATMLOGICAL = 0x50 IFT_ATMRADIO = 0xbd IFT_ATMSUBINTERFACE = 0x86 IFT_ATMVCIENDPT = 0xc2 IFT_ATMVIRTUAL = 0x95 IFT_BGPPOLICYACCOUNTING = 0xa2 IFT_BLUETOOTH = 0xf8 IFT_BRIDGE = 0xd1 IFT_BSC = 0x53 IFT_CARP = 0xf7 IFT_CCTEMUL = 0x3d IFT_CEPT = 0x13 IFT_CES = 0x85 IFT_CHANNEL = 0x46 IFT_CNR = 0x55 IFT_COFFEE = 0x84 IFT_COMPOSITELINK = 0x9b IFT_DCN = 0x8d IFT_DIGITALPOWERLINE = 0x8a IFT_DIGITALWRAPPEROVERHEADCHANNEL = 0xba IFT_DLSW = 0x4a IFT_DOCSCABLEDOWNSTREAM = 0x80 IFT_DOCSCABLEMACLAYER = 0x7f IFT_DOCSCABLEUPSTREAM = 0x81 IFT_DOCSCABLEUPSTREAMCHANNEL = 0xcd IFT_DS0 = 0x51 IFT_DS0BUNDLE = 0x52 IFT_DS1FDL = 0xaa IFT_DS3 = 0x1e IFT_DTM = 0x8c IFT_DUMMY = 0xf1 IFT_DVBASILN = 0xac IFT_DVBASIOUT = 0xad IFT_DVBRCCDOWNSTREAM = 0x93 IFT_DVBRCCMACLAYER = 0x92 IFT_DVBRCCUPSTREAM = 0x94 IFT_ECONET = 0xce IFT_ENC = 0xf4 IFT_EON = 0x19 IFT_EPLRS = 0x57 IFT_ESCON = 0x49 IFT_ETHER = 0x6 IFT_FAITH = 0xf3 IFT_FAST = 0x7d IFT_FASTETHER = 0x3e IFT_FASTETHERFX = 0x45 IFT_FDDI = 0xf IFT_FIBRECHANNEL = 0x38 IFT_FRAMERELAYINTERCONNECT = 0x3a IFT_FRAMERELAYMPI = 0x5c IFT_FRDLCIENDPT = 0xc1 IFT_FRELAY = 0x20 IFT_FRELAYDCE = 0x2c IFT_FRF16MFRBUNDLE = 0xa3 IFT_FRFORWARD = 0x9e IFT_G703AT2MB = 0x43 IFT_G703AT64K = 0x42 IFT_GIF = 0xf0 IFT_GIGABITETHERNET = 0x75 IFT_GR303IDT = 0xb2 IFT_GR303RDT = 0xb1 IFT_H323GATEKEEPER = 0xa4 IFT_H323PROXY = 0xa5 IFT_HDH1822 = 0x3 IFT_HDLC = 0x76 IFT_HDSL2 = 0xa8 IFT_HIPERLAN2 = 0xb7 IFT_HIPPI = 0x2f IFT_HIPPIINTERFACE = 0x39 IFT_HOSTPAD = 0x5a IFT_HSSI = 0x2e IFT_HY = 0xe IFT_IBM370PARCHAN = 0x48 IFT_IDSL = 0x9a IFT_IEEE1394 = 0x90 IFT_IEEE80211 = 0x47 IFT_IEEE80212 = 0x37 IFT_IEEE8023ADLAG = 0xa1 IFT_IFGSN = 0x91 IFT_IMT = 0xbe IFT_INFINIBAND = 0xc7 IFT_INTERLEAVE = 0x7c IFT_IP = 0x7e IFT_IPFORWARD = 0x8e IFT_IPOVERATM = 0x72 IFT_IPOVERCDLC = 0x6d IFT_IPOVERCLAW = 0x6e IFT_IPSWITCH = 0x4e IFT_ISDN = 0x3f IFT_ISDNBASIC = 0x14 IFT_ISDNPRIMARY = 0x15 IFT_ISDNS = 0x4b IFT_ISDNU = 0x4c IFT_ISO88022LLC = 0x29 IFT_ISO88023 = 0x7 IFT_ISO88024 = 0x8 IFT_ISO88025 = 0x9 IFT_ISO88025CRFPINT = 0x62 IFT_ISO88025DTR = 0x56 IFT_ISO88025FIBER = 0x73 IFT_ISO88026 = 0xa IFT_ISUP = 0xb3 IFT_L2VLAN = 0x87 IFT_L3IPVLAN = 0x88 IFT_L3IPXVLAN = 0x89 IFT_LAPB = 0x10 IFT_LAPD = 0x4d IFT_LAPF = 0x77 IFT_LINEGROUP = 0xd2 IFT_LOCALTALK = 0x2a IFT_LOOP = 0x18 IFT_MEDIAMAILOVERIP = 0x8b IFT_MFSIGLINK = 0xa7 IFT_MIOX25 = 0x26 IFT_MODEM = 0x30 IFT_MPC = 0x71 IFT_MPLS = 0xa6 IFT_MPLSTUNNEL = 0x96 IFT_MSDSL = 0x8f IFT_MVL = 0xbf IFT_MYRINET = 0x63 IFT_NFAS = 0xaf IFT_NSIP = 0x1b IFT_OPTICALCHANNEL = 0xc3 IFT_OPTICALTRANSPORT = 0xc4 IFT_OTHER = 0x1 IFT_P10 = 0xc IFT_P80 = 0xd IFT_PARA = 0x22 IFT_PFLOG = 0xf5 IFT_PFLOW = 0xf9 IFT_PFSYNC = 0xf6 IFT_PLC = 0xae IFT_PON155 = 0xcf IFT_PON622 = 0xd0 IFT_POS = 0xab IFT_PPP = 0x17 IFT_PPPMULTILINKBUNDLE = 0x6c IFT_PROPATM = 0xc5 IFT_PROPBWAP2MP = 0xb8 IFT_PROPCNLS = 0x59 IFT_PROPDOCSWIRELESSDOWNSTREAM = 0xb5 IFT_PROPDOCSWIRELESSMACLAYER = 0xb4 IFT_PROPDOCSWIRELESSUPSTREAM = 0xb6 IFT_PROPMUX = 0x36 IFT_PROPVIRTUAL = 0x35 IFT_PROPWIRELESSP2P = 0x9d IFT_PTPSERIAL = 0x16 IFT_PVC = 0xf2 IFT_Q2931 = 0xc9 IFT_QLLC = 0x44 IFT_RADIOMAC = 0xbc IFT_RADSL = 0x5f IFT_REACHDSL = 0xc0 IFT_RFC1483 = 0x9f IFT_RS232 = 0x21 IFT_RSRB = 0x4f IFT_SDLC = 0x11 IFT_SDSL = 0x60 IFT_SHDSL = 0xa9 IFT_SIP = 0x1f IFT_SIPSIG = 0xcc IFT_SIPTG = 0xcb IFT_SLIP = 0x1c IFT_SMDSDXI = 0x2b IFT_SMDSICIP = 0x34 IFT_SONET = 0x27 IFT_SONETOVERHEADCHANNEL = 0xb9 IFT_SONETPATH = 0x32 IFT_SONETVT = 0x33 IFT_SRP = 0x97 IFT_SS7SIGLINK = 0x9c IFT_STACKTOSTACK = 0x6f IFT_STARLAN = 0xb IFT_T1 = 0x12 IFT_TDLC = 0x74 IFT_TELINK = 0xc8 IFT_TERMPAD = 0x5b IFT_TR008 = 0xb0 IFT_TRANSPHDLC = 0x7b IFT_TUNNEL = 0x83 IFT_ULTRA = 0x1d IFT_USB = 0xa0 IFT_V11 = 0x40 IFT_V35 = 0x2d IFT_V36 = 0x41 IFT_V37 = 0x78 IFT_VDSL = 0x61 IFT_VIRTUALIPADDRESS = 0x70 IFT_VIRTUALTG = 0xca IFT_VOICEDID = 0xd5 IFT_VOICEEM = 0x64 IFT_VOICEEMFGD = 0xd3 IFT_VOICEENCAP = 0x67 IFT_VOICEFGDEANA = 0xd4 IFT_VOICEFXO = 0x65 IFT_VOICEFXS = 0x66 IFT_VOICEOVERATM = 0x98 IFT_VOICEOVERCABLE = 0xc6 IFT_VOICEOVERFRAMERELAY = 0x99 IFT_VOICEOVERIP = 0x68 IFT_X213 = 0x5d IFT_X25 = 0x5 IFT_X25DDN = 0x4 IFT_X25HUNTGROUP = 0x7a IFT_X25MLP = 0x79 IFT_X25PLE = 0x28 IFT_XETHER = 0x1a IGNBRK = 0x1 IGNCR = 0x80 IGNPAR = 0x4 IMAXBEL = 0x2000 INLCR = 0x40 INPCK = 0x10 IN_CLASSA_HOST = 0xffffff IN_CLASSA_MAX = 0x80 IN_CLASSA_NET = 0xff000000 IN_CLASSA_NSHIFT = 0x18 IN_CLASSB_HOST = 0xffff IN_CLASSB_MAX = 0x10000 IN_CLASSB_NET = 0xffff0000 IN_CLASSB_NSHIFT = 0x10 IN_CLASSC_HOST = 0xff IN_CLASSC_NET = 0xffffff00 IN_CLASSC_NSHIFT = 0x8 IN_CLASSD_HOST = 0xfffffff IN_CLASSD_NET = 0xf0000000 IN_CLASSD_NSHIFT = 0x1c IN_LOOPBACKNET = 0x7f IN_RFC3021_HOST = 0x1 IN_RFC3021_NET = 0xfffffffe IN_RFC3021_NSHIFT = 0x1f IPPROTO_AH = 0x33 IPPROTO_CARP = 0x70 IPPROTO_DIVERT = 0x102 IPPROTO_DIVERT_INIT = 0x2 IPPROTO_DIVERT_RESP = 0x1 IPPROTO_DONE = 0x101 IPPROTO_DSTOPTS = 0x3c IPPROTO_EGP = 0x8 IPPROTO_ENCAP = 0x62 IPPROTO_EON = 0x50 IPPROTO_ESP = 0x32 IPPROTO_ETHERIP = 0x61 IPPROTO_FRAGMENT = 0x2c IPPROTO_GGP = 0x3 IPPROTO_GRE = 0x2f IPPROTO_HOPOPTS = 0x0 IPPROTO_ICMP = 0x1 IPPROTO_ICMPV6 = 0x3a IPPROTO_IDP = 0x16 IPPROTO_IGMP = 0x2 IPPROTO_IP = 0x0 IPPROTO_IPCOMP = 0x6c IPPROTO_IPIP = 0x4 IPPROTO_IPV4 = 0x4 IPPROTO_IPV6 = 0x29 IPPROTO_MAX = 0x100 IPPROTO_MAXID = 0x103 IPPROTO_MOBILE = 0x37 IPPROTO_MPLS = 0x89 IPPROTO_NONE = 0x3b IPPROTO_PFSYNC = 0xf0 IPPROTO_PIM = 0x67 IPPROTO_PUP = 0xc IPPROTO_RAW = 0xff IPPROTO_ROUTING = 0x2b IPPROTO_RSVP = 0x2e IPPROTO_TCP = 0x6 IPPROTO_TP = 0x1d IPPROTO_UDP = 0x11 IPV6_AUTH_LEVEL = 0x35 IPV6_AUTOFLOWLABEL = 0x3b IPV6_CHECKSUM = 0x1a IPV6_DEFAULT_MULTICAST_HOPS = 0x1 IPV6_DEFAULT_MULTICAST_LOOP = 0x1 IPV6_DEFHLIM = 0x40 IPV6_DONTFRAG = 0x3e IPV6_DSTOPTS = 0x32 IPV6_ESP_NETWORK_LEVEL = 0x37 IPV6_ESP_TRANS_LEVEL = 0x36 IPV6_FAITH = 0x1d IPV6_FLOWINFO_MASK = 0xffffff0f IPV6_FLOWLABEL_MASK = 0xffff0f00 IPV6_FRAGTTL = 0x78 IPV6_HLIMDEC = 0x1 IPV6_HOPLIMIT = 0x2f IPV6_HOPOPTS = 0x31 IPV6_IPCOMP_LEVEL = 0x3c IPV6_JOIN_GROUP = 0xc IPV6_LEAVE_GROUP = 0xd IPV6_MAXHLIM = 0xff IPV6_MAXPACKET = 0xffff IPV6_MMTU = 0x500 IPV6_MULTICAST_HOPS = 0xa IPV6_MULTICAST_IF = 0x9 IPV6_MULTICAST_LOOP = 0xb IPV6_NEXTHOP = 0x30 IPV6_OPTIONS = 0x1 IPV6_PATHMTU = 0x2c IPV6_PIPEX = 0x3f IPV6_PKTINFO = 0x2e IPV6_PORTRANGE = 0xe IPV6_PORTRANGE_DEFAULT = 0x0 IPV6_PORTRANGE_HIGH = 0x1 IPV6_PORTRANGE_LOW = 0x2 IPV6_RECVDSTOPTS = 0x28 IPV6_RECVDSTPORT = 0x40 IPV6_RECVHOPLIMIT = 0x25 IPV6_RECVHOPOPTS = 0x27 IPV6_RECVPATHMTU = 0x2b IPV6_RECVPKTINFO = 0x24 IPV6_RECVRTHDR = 0x26 IPV6_RECVTCLASS = 0x39 IPV6_RTABLE = 0x1021 IPV6_RTHDR = 0x33 IPV6_RTHDRDSTOPTS = 0x23 IPV6_RTHDR_LOOSE = 0x0 IPV6_RTHDR_STRICT = 0x1 IPV6_RTHDR_TYPE_0 = 0x0 IPV6_SOCKOPT_RESERVED1 = 0x3 IPV6_TCLASS = 0x3d IPV6_UNICAST_HOPS = 0x4 IPV6_USE_MIN_MTU = 0x2a IPV6_V6ONLY = 0x1b IPV6_VERSION = 0x60 IPV6_VERSION_MASK = 0xf0 IP_ADD_MEMBERSHIP = 0xc IP_AUTH_LEVEL = 0x14 IP_DEFAULT_MULTICAST_LOOP = 0x1 IP_DEFAULT_MULTICAST_TTL = 0x1 IP_DF = 0x4000 IP_DIVERTFL = 0x1022 IP_DROP_MEMBERSHIP = 0xd IP_ESP_NETWORK_LEVEL = 0x16 IP_ESP_TRANS_LEVEL = 0x15 IP_HDRINCL = 0x2 IP_IPCOMP_LEVEL = 0x1d IP_IPSECFLOWINFO = 0x24 IP_IPSEC_LOCAL_AUTH = 0x1b IP_IPSEC_LOCAL_CRED = 0x19 IP_IPSEC_LOCAL_ID = 0x17 IP_IPSEC_REMOTE_AUTH = 0x1c IP_IPSEC_REMOTE_CRED = 0x1a IP_IPSEC_REMOTE_ID = 0x18 IP_MAXPACKET = 0xffff IP_MAX_MEMBERSHIPS = 0xfff IP_MF = 0x2000 IP_MINTTL = 0x20 IP_MIN_MEMBERSHIPS = 0xf IP_MSS = 0x240 IP_MULTICAST_IF = 0x9 IP_MULTICAST_LOOP = 0xb IP_MULTICAST_TTL = 0xa IP_OFFMASK = 0x1fff IP_OPTIONS = 0x1 IP_PIPEX = 0x22 IP_PORTRANGE = 0x13 IP_PORTRANGE_DEFAULT = 0x0 IP_PORTRANGE_HIGH = 0x1 IP_PORTRANGE_LOW = 0x2 IP_RECVDSTADDR = 0x7 IP_RECVDSTPORT = 0x21 IP_RECVIF = 0x1e IP_RECVOPTS = 0x5 IP_RECVRETOPTS = 0x6 IP_RECVRTABLE = 0x23 IP_RECVTTL = 0x1f IP_RETOPTS = 0x8 IP_RF = 0x8000 IP_RTABLE = 0x1021 IP_TOS = 0x3 IP_TTL = 0x4 ISIG = 0x80 ISTRIP = 0x20 IXANY = 0x800 IXOFF = 0x400 IXON = 0x200 KERN_HOSTNAME = 0xa KERN_OSRELEASE = 0x2 KERN_OSTYPE = 0x1 KERN_VERSION = 0x4 LCNT_OVERLOAD_FLUSH = 0x6 LOCK_EX = 0x2 LOCK_NB = 0x4 LOCK_SH = 0x1 LOCK_UN = 0x8 MADV_DONTNEED = 0x4 MADV_FREE = 0x6 MADV_NORMAL = 0x0 MADV_RANDOM = 0x1 MADV_SEQUENTIAL = 0x2 MADV_SPACEAVAIL = 0x5 MADV_WILLNEED = 0x3 MAP_ANON = 0x1000 MAP_ANONYMOUS = 0x1000 MAP_COPY = 0x2 MAP_FILE = 0x0 MAP_FIXED = 0x10 MAP_FLAGMASK = 0x3ff7 MAP_HASSEMAPHORE = 0x0 MAP_INHERIT = 0x0 MAP_INHERIT_COPY = 0x1 MAP_INHERIT_NONE = 0x2 MAP_INHERIT_SHARE = 0x0 MAP_INHERIT_ZERO = 0x3 MAP_NOEXTEND = 0x0 MAP_NORESERVE = 0x0 MAP_PRIVATE = 0x2 MAP_RENAME = 0x0 MAP_SHARED = 0x1 MAP_TRYFIXED = 0x0 MCL_CURRENT = 0x1 MCL_FUTURE = 0x2 MSG_BCAST = 0x100 MSG_CMSG_CLOEXEC = 0x800 MSG_CTRUNC = 0x20 MSG_DONTROUTE = 0x4 MSG_DONTWAIT = 0x80 MSG_EOR = 0x8 MSG_MCAST = 0x200 MSG_NOSIGNAL = 0x400 MSG_OOB = 0x1 MSG_PEEK = 0x2 MSG_TRUNC = 0x10 MSG_WAITALL = 0x40 MS_ASYNC = 0x1 MS_INVALIDATE = 0x4 MS_SYNC = 0x2 NAME_MAX = 0xff NET_RT_DUMP = 0x1 NET_RT_FLAGS = 0x2 NET_RT_IFLIST = 0x3 NET_RT_MAXID = 0x6 NET_RT_STATS = 0x4 NET_RT_TABLE = 0x5 NOFLSH = 0x80000000 NOTE_ATTRIB = 0x8 NOTE_CHILD = 0x4 NOTE_DELETE = 0x1 NOTE_EOF = 0x2 NOTE_EXEC = 0x20000000 NOTE_EXIT = 0x80000000 NOTE_EXTEND = 0x4 NOTE_FORK = 0x40000000 NOTE_LINK = 0x10 NOTE_LOWAT = 0x1 NOTE_PCTRLMASK = 0xf0000000 NOTE_PDATAMASK = 0xfffff NOTE_RENAME = 0x20 NOTE_REVOKE = 0x40 NOTE_TRACK = 0x1 NOTE_TRACKERR = 0x2 NOTE_TRUNCATE = 0x80 NOTE_WRITE = 0x2 OCRNL = 0x10 ONLCR = 0x2 ONLRET = 0x80 ONOCR = 0x40 ONOEOT = 0x8 OPOST = 0x1 O_ACCMODE = 0x3 O_APPEND = 0x8 O_ASYNC = 0x40 O_CLOEXEC = 0x10000 O_CREAT = 0x200 O_DIRECTORY = 0x20000 O_DSYNC = 0x80 O_EXCL = 0x800 O_EXLOCK = 0x20 O_FSYNC = 0x80 O_NDELAY = 0x4 O_NOCTTY = 0x8000 O_NOFOLLOW = 0x100 O_NONBLOCK = 0x4 O_RDONLY = 0x0 O_RDWR = 0x2 O_RSYNC = 0x80 O_SHLOCK = 0x10 O_SYNC = 0x80 O_TRUNC = 0x400 O_WRONLY = 0x1 PARENB = 0x1000 PARMRK = 0x8 PARODD = 0x2000 PENDIN = 0x20000000 PF_FLUSH = 0x1 PRIO_PGRP = 0x1 PRIO_PROCESS = 0x0 PRIO_USER = 0x2 PROT_EXEC = 0x4 PROT_NONE = 0x0 PROT_READ = 0x1 PROT_WRITE = 0x2 RLIMIT_CORE = 0x4 RLIMIT_CPU = 0x0 RLIMIT_DATA = 0x2 RLIMIT_FSIZE = 0x1 RLIMIT_NOFILE = 0x8 RLIMIT_STACK = 0x3 RLIM_INFINITY = 0x7fffffffffffffff RTAX_AUTHOR = 0x6 RTAX_BRD = 0x7 RTAX_DST = 0x0 RTAX_GATEWAY = 0x1 RTAX_GENMASK = 0x3 RTAX_IFA = 0x5 RTAX_IFP = 0x4 RTAX_LABEL = 0xa RTAX_MAX = 0xb RTAX_NETMASK = 0x2 RTAX_SRC = 0x8 RTAX_SRCMASK = 0x9 RTA_AUTHOR = 0x40 RTA_BRD = 0x80 RTA_DST = 0x1 RTA_GATEWAY = 0x2 RTA_GENMASK = 0x8 RTA_IFA = 0x20 RTA_IFP = 0x10 RTA_LABEL = 0x400 RTA_NETMASK = 0x4 RTA_SRC = 0x100 RTA_SRCMASK = 0x200 RTF_ANNOUNCE = 0x4000 RTF_BLACKHOLE = 0x1000 RTF_BROADCAST = 0x400000 RTF_CLONED = 0x10000 RTF_CLONING = 0x100 RTF_DONE = 0x40 RTF_DYNAMIC = 0x10 RTF_FMASK = 0x70f808 RTF_GATEWAY = 0x2 RTF_HOST = 0x4 RTF_LLINFO = 0x400 RTF_LOCAL = 0x200000 RTF_MASK = 0x80 RTF_MODIFIED = 0x20 RTF_MPATH = 0x40000 RTF_MPLS = 0x100000 RTF_PERMANENT_ARP = 0x2000 RTF_PROTO1 = 0x8000 RTF_PROTO2 = 0x4000 RTF_PROTO3 = 0x2000 RTF_REJECT = 0x8 RTF_STATIC = 0x800 RTF_UP = 0x1 RTF_USETRAILERS = 0x8000 RTF_XRESOLVE = 0x200 RTM_ADD = 0x1 RTM_CHANGE = 0x3 RTM_DELADDR = 0xd RTM_DELETE = 0x2 RTM_DESYNC = 0x10 RTM_GET = 0x4 RTM_IFANNOUNCE = 0xf RTM_IFINFO = 0xe RTM_LOCK = 0x8 RTM_LOSING = 0x5 RTM_MAXSIZE = 0x800 RTM_MISS = 0x7 RTM_NEWADDR = 0xc RTM_REDIRECT = 0x6 RTM_RESOLVE = 0xb RTM_RTTUNIT = 0xf4240 RTM_VERSION = 0x5 RTV_EXPIRE = 0x4 RTV_HOPCOUNT = 0x2 RTV_MTU = 0x1 RTV_RPIPE = 0x8 RTV_RTT = 0x40 RTV_RTTVAR = 0x80 RTV_SPIPE = 0x10 RTV_SSTHRESH = 0x20 RT_TABLEID_MAX = 0xff RUSAGE_CHILDREN = -0x1 RUSAGE_SELF = 0x0 RUSAGE_THREAD = 0x1 SCM_RIGHTS = 0x1 SCM_TIMESTAMP = 0x4 SHUT_RD = 0x0 SHUT_RDWR = 0x2 SHUT_WR = 0x1 SIOCADDMULTI = 0x80206931 SIOCAIFADDR = 0x8040691a SIOCAIFGROUP = 0x80246987 SIOCALIFADDR = 0x8218691c SIOCATMARK = 0x40047307 SIOCBRDGADD = 0x8054693c SIOCBRDGADDS = 0x80546941 SIOCBRDGARL = 0x806e694d SIOCBRDGDADDR = 0x81286947 SIOCBRDGDEL = 0x8054693d SIOCBRDGDELS = 0x80546942 SIOCBRDGFLUSH = 0x80546948 SIOCBRDGFRL = 0x806e694e SIOCBRDGGCACHE = 0xc0146941 SIOCBRDGGFD = 0xc0146952 SIOCBRDGGHT = 0xc0146951 SIOCBRDGGIFFLGS = 0xc054693e SIOCBRDGGMA = 0xc0146953 SIOCBRDGGPARAM = 0xc03c6958 SIOCBRDGGPRI = 0xc0146950 SIOCBRDGGRL = 0xc028694f SIOCBRDGGSIFS = 0xc054693c SIOCBRDGGTO = 0xc0146946 SIOCBRDGIFS = 0xc0546942 SIOCBRDGRTS = 0xc0186943 SIOCBRDGSADDR = 0xc1286944 SIOCBRDGSCACHE = 0x80146940 SIOCBRDGSFD = 0x80146952 SIOCBRDGSHT = 0x80146951 SIOCBRDGSIFCOST = 0x80546955 SIOCBRDGSIFFLGS = 0x8054693f SIOCBRDGSIFPRIO = 0x80546954 SIOCBRDGSMA = 0x80146953 SIOCBRDGSPRI = 0x80146950 SIOCBRDGSPROTO = 0x8014695a SIOCBRDGSTO = 0x80146945 SIOCBRDGSTXHC = 0x80146959 SIOCDELMULTI = 0x80206932 SIOCDIFADDR = 0x80206919 SIOCDIFGROUP = 0x80246989 SIOCDIFPHYADDR = 0x80206949 SIOCDLIFADDR = 0x8218691e SIOCGETKALIVE = 0xc01869a4 SIOCGETLABEL = 0x8020699a SIOCGETPFLOW = 0xc02069fe SIOCGETPFSYNC = 0xc02069f8 SIOCGETSGCNT = 0xc0147534 SIOCGETVIFCNT = 0xc0147533 SIOCGETVLAN = 0xc0206990 SIOCGHIWAT = 0x40047301 SIOCGIFADDR = 0xc0206921 SIOCGIFASYNCMAP = 0xc020697c SIOCGIFBRDADDR = 0xc0206923 SIOCGIFCONF = 0xc0086924 SIOCGIFDATA = 0xc020691b SIOCGIFDESCR = 0xc0206981 SIOCGIFDSTADDR = 0xc0206922 SIOCGIFFLAGS = 0xc0206911 SIOCGIFGATTR = 0xc024698b SIOCGIFGENERIC = 0xc020693a SIOCGIFGMEMB = 0xc024698a SIOCGIFGROUP = 0xc0246988 SIOCGIFHARDMTU = 0xc02069a5 SIOCGIFMEDIA = 0xc0286936 SIOCGIFMETRIC = 0xc0206917 SIOCGIFMTU = 0xc020697e SIOCGIFNETMASK = 0xc0206925 SIOCGIFPDSTADDR = 0xc0206948 SIOCGIFPRIORITY = 0xc020699c SIOCGIFPSRCADDR = 0xc0206947 SIOCGIFRDOMAIN = 0xc02069a0 SIOCGIFRTLABEL = 0xc0206983 SIOCGIFRXR = 0x802069aa SIOCGIFTIMESLOT = 0xc0206986 SIOCGIFXFLAGS = 0xc020699e SIOCGLIFADDR = 0xc218691d SIOCGLIFPHYADDR = 0xc218694b SIOCGLIFPHYRTABLE = 0xc02069a2 SIOCGLIFPHYTTL = 0xc02069a9 SIOCGLOWAT = 0x40047303 SIOCGPGRP = 0x40047309 SIOCGSPPPPARAMS = 0xc0206994 SIOCGVH = 0xc02069f6 SIOCGVNETID = 0xc02069a7 SIOCIFCREATE = 0x8020697a SIOCIFDESTROY = 0x80206979 SIOCIFGCLONERS = 0xc00c6978 SIOCSETKALIVE = 0x801869a3 SIOCSETLABEL = 0x80206999 SIOCSETPFLOW = 0x802069fd SIOCSETPFSYNC = 0x802069f7 SIOCSETVLAN = 0x8020698f SIOCSHIWAT = 0x80047300 SIOCSIFADDR = 0x8020690c SIOCSIFASYNCMAP = 0x8020697d SIOCSIFBRDADDR = 0x80206913 SIOCSIFDESCR = 0x80206980 SIOCSIFDSTADDR = 0x8020690e SIOCSIFFLAGS = 0x80206910 SIOCSIFGATTR = 0x8024698c SIOCSIFGENERIC = 0x80206939 SIOCSIFLLADDR = 0x8020691f SIOCSIFMEDIA = 0xc0206935 SIOCSIFMETRIC = 0x80206918 SIOCSIFMTU = 0x8020697f SIOCSIFNETMASK = 0x80206916 SIOCSIFPHYADDR = 0x80406946 SIOCSIFPRIORITY = 0x8020699b SIOCSIFRDOMAIN = 0x8020699f SIOCSIFRTLABEL = 0x80206982 SIOCSIFTIMESLOT = 0x80206985 SIOCSIFXFLAGS = 0x8020699d SIOCSLIFPHYADDR = 0x8218694a SIOCSLIFPHYRTABLE = 0x802069a1 SIOCSLIFPHYTTL = 0x802069a8 SIOCSLOWAT = 0x80047302 SIOCSPGRP = 0x80047308 SIOCSSPPPPARAMS = 0x80206993 SIOCSVH = 0xc02069f5 SIOCSVNETID = 0x802069a6 SOCK_CLOEXEC = 0x8000 SOCK_DGRAM = 0x2 SOCK_NONBLOCK = 0x4000 SOCK_RAW = 0x3 SOCK_RDM = 0x4 SOCK_SEQPACKET = 0x5 SOCK_STREAM = 0x1 SOL_SOCKET = 0xffff SOMAXCONN = 0x80 SO_ACCEPTCONN = 0x2 SO_BINDANY = 0x1000 SO_BROADCAST = 0x20 SO_DEBUG = 0x1 SO_DONTROUTE = 0x10 SO_ERROR = 0x1007 SO_KEEPALIVE = 0x8 SO_LINGER = 0x80 SO_NETPROC = 0x1020 SO_OOBINLINE = 0x100 SO_PEERCRED = 0x1022 SO_RCVBUF = 0x1002 SO_RCVLOWAT = 0x1004 SO_RCVTIMEO = 0x1006 SO_REUSEADDR = 0x4 SO_REUSEPORT = 0x200 SO_RTABLE = 0x1021 SO_SNDBUF = 0x1001 SO_SNDLOWAT = 0x1003 SO_SNDTIMEO = 0x1005 SO_SPLICE = 0x1023 SO_TIMESTAMP = 0x800 SO_TYPE = 0x1008 SO_USELOOPBACK = 0x40 TCIFLUSH = 0x1 TCIOFLUSH = 0x3 TCOFLUSH = 0x2 TCP_MAXBURST = 0x4 TCP_MAXSEG = 0x2 TCP_MAXWIN = 0xffff TCP_MAX_SACK = 0x3 TCP_MAX_WINSHIFT = 0xe TCP_MD5SIG = 0x4 TCP_MSS = 0x200 TCP_NODELAY = 0x1 TCP_NOPUSH = 0x10 TCP_NSTATES = 0xb TCP_SACK_ENABLE = 0x8 TCSAFLUSH = 0x2 TIOCCBRK = 0x2000747a TIOCCDTR = 0x20007478 TIOCCONS = 0x80047462 TIOCDRAIN = 0x2000745e TIOCEXCL = 0x2000740d TIOCEXT = 0x80047460 TIOCFLAG_CLOCAL = 0x2 TIOCFLAG_CRTSCTS = 0x4 TIOCFLAG_MDMBUF = 0x8 TIOCFLAG_PPS = 0x10 TIOCFLAG_SOFTCAR = 0x1 TIOCFLUSH = 0x80047410 TIOCGETA = 0x402c7413 TIOCGETD = 0x4004741a TIOCGFLAGS = 0x4004745d TIOCGPGRP = 0x40047477 TIOCGSID = 0x40047463 TIOCGTSTAMP = 0x400c745b TIOCGWINSZ = 0x40087468 TIOCMBIC = 0x8004746b TIOCMBIS = 0x8004746c TIOCMGET = 0x4004746a TIOCMODG = 0x4004746a TIOCMODS = 0x8004746d TIOCMSET = 0x8004746d TIOCM_CAR = 0x40 TIOCM_CD = 0x40 TIOCM_CTS = 0x20 TIOCM_DSR = 0x100 TIOCM_DTR = 0x2 TIOCM_LE = 0x1 TIOCM_RI = 0x80 TIOCM_RNG = 0x80 TIOCM_RTS = 0x4 TIOCM_SR = 0x10 TIOCM_ST = 0x8 TIOCNOTTY = 0x20007471 TIOCNXCL = 0x2000740e TIOCOUTQ = 0x40047473 TIOCPKT = 0x80047470 TIOCPKT_DATA = 0x0 TIOCPKT_DOSTOP = 0x20 TIOCPKT_FLUSHREAD = 0x1 TIOCPKT_FLUSHWRITE = 0x2 TIOCPKT_IOCTL = 0x40 TIOCPKT_NOSTOP = 0x10 TIOCPKT_START = 0x8 TIOCPKT_STOP = 0x4 TIOCREMOTE = 0x80047469 TIOCSBRK = 0x2000747b TIOCSCTTY = 0x20007461 TIOCSDTR = 0x20007479 TIOCSETA = 0x802c7414 TIOCSETAF = 0x802c7416 TIOCSETAW = 0x802c7415 TIOCSETD = 0x8004741b TIOCSFLAGS = 0x8004745c TIOCSIG = 0x8004745f TIOCSPGRP = 0x80047476 TIOCSTART = 0x2000746e TIOCSTAT = 0x80047465 TIOCSTI = 0x80017472 TIOCSTOP = 0x2000746f TIOCSTSTAMP = 0x8008745a TIOCSWINSZ = 0x80087467 TIOCUCNTL = 0x80047466 TOSTOP = 0x400000 VDISCARD = 0xf VDSUSP = 0xb VEOF = 0x0 VEOL = 0x1 VEOL2 = 0x2 VERASE = 0x3 VINTR = 0x8 VKILL = 0x5 VLNEXT = 0xe VMIN = 0x10 VQUIT = 0x9 VREPRINT = 0x6 VSTART = 0xc VSTATUS = 0x12 VSTOP = 0xd VSUSP = 0xa VTIME = 0x11 VWERASE = 0x4 WALTSIG = 0x4 WCONTINUED = 0x8 WCOREFLAG = 0x80 WNOHANG = 0x1 WUNTRACED = 0x2 ) // Errors const ( E2BIG = syscall.Errno(0x7) EACCES = syscall.Errno(0xd) EADDRINUSE = syscall.Errno(0x30) EADDRNOTAVAIL = syscall.Errno(0x31) EAFNOSUPPORT = syscall.Errno(0x2f) EAGAIN = syscall.Errno(0x23) EALREADY = syscall.Errno(0x25) EAUTH = syscall.Errno(0x50) EBADF = syscall.Errno(0x9) EBADRPC = syscall.Errno(0x48) EBUSY = syscall.Errno(0x10) ECANCELED = syscall.Errno(0x58) ECHILD = syscall.Errno(0xa) ECONNABORTED = syscall.Errno(0x35) ECONNREFUSED = syscall.Errno(0x3d) ECONNRESET = syscall.Errno(0x36) EDEADLK = syscall.Errno(0xb) EDESTADDRREQ = syscall.Errno(0x27) EDOM = syscall.Errno(0x21) EDQUOT = syscall.Errno(0x45) EEXIST = syscall.Errno(0x11) EFAULT = syscall.Errno(0xe) EFBIG = syscall.Errno(0x1b) EFTYPE = syscall.Errno(0x4f) EHOSTDOWN = syscall.Errno(0x40) EHOSTUNREACH = syscall.Errno(0x41) EIDRM = syscall.Errno(0x59) EILSEQ = syscall.Errno(0x54) EINPROGRESS = syscall.Errno(0x24) EINTR = syscall.Errno(0x4) EINVAL = syscall.Errno(0x16) EIO = syscall.Errno(0x5) EIPSEC = syscall.Errno(0x52) EISCONN = syscall.Errno(0x38) EISDIR = syscall.Errno(0x15) ELAST = syscall.Errno(0x5b) ELOOP = syscall.Errno(0x3e) EMEDIUMTYPE = syscall.Errno(0x56) EMFILE = syscall.Errno(0x18) EMLINK = syscall.Errno(0x1f) EMSGSIZE = syscall.Errno(0x28) ENAMETOOLONG = syscall.Errno(0x3f) ENEEDAUTH = syscall.Errno(0x51) ENETDOWN = syscall.Errno(0x32) ENETRESET = syscall.Errno(0x34) ENETUNREACH = syscall.Errno(0x33) ENFILE = syscall.Errno(0x17) ENOATTR = syscall.Errno(0x53) ENOBUFS = syscall.Errno(0x37) ENODEV = syscall.Errno(0x13) ENOENT = syscall.Errno(0x2) ENOEXEC = syscall.Errno(0x8) ENOLCK = syscall.Errno(0x4d) ENOMEDIUM = syscall.Errno(0x55) ENOMEM = syscall.Errno(0xc) ENOMSG = syscall.Errno(0x5a) ENOPROTOOPT = syscall.Errno(0x2a) ENOSPC = syscall.Errno(0x1c) ENOSYS = syscall.Errno(0x4e) ENOTBLK = syscall.Errno(0xf) ENOTCONN = syscall.Errno(0x39) ENOTDIR = syscall.Errno(0x14) ENOTEMPTY = syscall.Errno(0x42) ENOTSOCK = syscall.Errno(0x26) ENOTSUP = syscall.Errno(0x5b) ENOTTY = syscall.Errno(0x19) ENXIO = syscall.Errno(0x6) EOPNOTSUPP = syscall.Errno(0x2d) EOVERFLOW = syscall.Errno(0x57) EPERM = syscall.Errno(0x1) EPFNOSUPPORT = syscall.Errno(0x2e) EPIPE = syscall.Errno(0x20) EPROCLIM = syscall.Errno(0x43) EPROCUNAVAIL = syscall.Errno(0x4c) EPROGMISMATCH = syscall.Errno(0x4b) EPROGUNAVAIL = syscall.Errno(0x4a) EPROTONOSUPPORT = syscall.Errno(0x2b) EPROTOTYPE = syscall.Errno(0x29) ERANGE = syscall.Errno(0x22) EREMOTE = syscall.Errno(0x47) EROFS = syscall.Errno(0x1e) ERPCMISMATCH = syscall.Errno(0x49) ESHUTDOWN = syscall.Errno(0x3a) ESOCKTNOSUPPORT = syscall.Errno(0x2c) ESPIPE = syscall.Errno(0x1d) ESRCH = syscall.Errno(0x3) ESTALE = syscall.Errno(0x46) ETIMEDOUT = syscall.Errno(0x3c) ETOOMANYREFS = syscall.Errno(0x3b) ETXTBSY = syscall.Errno(0x1a) EUSERS = syscall.Errno(0x44) EWOULDBLOCK = syscall.Errno(0x23) EXDEV = syscall.Errno(0x12) ) // Signals const ( SIGABRT = syscall.Signal(0x6) SIGALRM = syscall.Signal(0xe) SIGBUS = syscall.Signal(0xa) SIGCHLD = syscall.Signal(0x14) SIGCONT = syscall.Signal(0x13) SIGEMT = syscall.Signal(0x7) SIGFPE = syscall.Signal(0x8) SIGHUP = syscall.Signal(0x1) SIGILL = syscall.Signal(0x4) SIGINFO = syscall.Signal(0x1d) SIGINT = syscall.Signal(0x2) SIGIO = syscall.Signal(0x17) SIGIOT = syscall.Signal(0x6) SIGKILL = syscall.Signal(0x9) SIGPIPE = syscall.Signal(0xd) SIGPROF = syscall.Signal(0x1b) SIGQUIT = syscall.Signal(0x3) SIGSEGV = syscall.Signal(0xb) SIGSTOP = syscall.Signal(0x11) SIGSYS = syscall.Signal(0xc) SIGTERM = syscall.Signal(0xf) SIGTHR = syscall.Signal(0x20) SIGTRAP = syscall.Signal(0x5) SIGTSTP = syscall.Signal(0x12) SIGTTIN = syscall.Signal(0x15) SIGTTOU = syscall.Signal(0x16) SIGURG = syscall.Signal(0x10) SIGUSR1 = syscall.Signal(0x1e) SIGUSR2 = syscall.Signal(0x1f) SIGVTALRM = syscall.Signal(0x1a) SIGWINCH = syscall.Signal(0x1c) SIGXCPU = syscall.Signal(0x18) SIGXFSZ = syscall.Signal(0x19) ) // Error table var errorList = [...]struct { num syscall.Errno name string desc string }{ {1, "EPERM", "operation not permitted"}, {2, "ENOENT", "no such file or directory"}, {3, "ESRCH", "no such process"}, {4, "EINTR", "interrupted system call"}, {5, "EIO", "input/output error"}, {6, "ENXIO", "device not configured"}, {7, "E2BIG", "argument list too long"}, {8, "ENOEXEC", "exec format error"}, {9, "EBADF", "bad file descriptor"}, {10, "ECHILD", "no child processes"}, {11, "EDEADLK", "resource deadlock avoided"}, {12, "ENOMEM", "cannot allocate memory"}, {13, "EACCES", "permission denied"}, {14, "EFAULT", "bad address"}, {15, "ENOTBLK", "block device required"}, {16, "EBUSY", "device busy"}, {17, "EEXIST", "file exists"}, {18, "EXDEV", "cross-device link"}, {19, "ENODEV", "operation not supported by device"}, {20, "ENOTDIR", "not a directory"}, {21, "EISDIR", "is a directory"}, {22, "EINVAL", "invalid argument"}, {23, "ENFILE", "too many open files in system"}, {24, "EMFILE", "too many open files"}, {25, "ENOTTY", "inappropriate ioctl for device"}, {26, "ETXTBSY", "text file busy"}, {27, "EFBIG", "file too large"}, {28, "ENOSPC", "no space left on device"}, {29, "ESPIPE", "illegal seek"}, {30, "EROFS", "read-only file system"}, {31, "EMLINK", "too many links"}, {32, "EPIPE", "broken pipe"}, {33, "EDOM", "numerical argument out of domain"}, {34, "ERANGE", "result too large"}, {35, "EWOULDBLOCK", "resource temporarily unavailable"}, {36, "EINPROGRESS", "operation now in progress"}, {37, "EALREADY", "operation already in progress"}, {38, "ENOTSOCK", "socket operation on non-socket"}, {39, "EDESTADDRREQ", "destination address required"}, {40, "EMSGSIZE", "message too long"}, {41, "EPROTOTYPE", "protocol wrong type for socket"}, {42, "ENOPROTOOPT", "protocol not available"}, {43, "EPROTONOSUPPORT", "protocol not supported"}, {44, "ESOCKTNOSUPPORT", "socket type not supported"}, {45, "EOPNOTSUPP", "operation not supported"}, {46, "EPFNOSUPPORT", "protocol family not supported"}, {47, "EAFNOSUPPORT", "address family not supported by protocol family"}, {48, "EADDRINUSE", "address already in use"}, {49, "EADDRNOTAVAIL", "can't assign requested address"}, {50, "ENETDOWN", "network is down"}, {51, "ENETUNREACH", "network is unreachable"}, {52, "ENETRESET", "network dropped connection on reset"}, {53, "ECONNABORTED", "software caused connection abort"}, {54, "ECONNRESET", "connection reset by peer"}, {55, "ENOBUFS", "no buffer space available"}, {56, "EISCONN", "socket is already connected"}, {57, "ENOTCONN", "socket is not connected"}, {58, "ESHUTDOWN", "can't send after socket shutdown"}, {59, "ETOOMANYREFS", "too many references: can't splice"}, {60, "ETIMEDOUT", "operation timed out"}, {61, "ECONNREFUSED", "connection refused"}, {62, "ELOOP", "too many levels of symbolic links"}, {63, "ENAMETOOLONG", "file name too long"}, {64, "EHOSTDOWN", "host is down"}, {65, "EHOSTUNREACH", "no route to host"}, {66, "ENOTEMPTY", "directory not empty"}, {67, "EPROCLIM", "too many processes"}, {68, "EUSERS", "too many users"}, {69, "EDQUOT", "disk quota exceeded"}, {70, "ESTALE", "stale NFS file handle"}, {71, "EREMOTE", "too many levels of remote in path"}, {72, "EBADRPC", "RPC struct is bad"}, {73, "ERPCMISMATCH", "RPC version wrong"}, {74, "EPROGUNAVAIL", "RPC program not available"}, {75, "EPROGMISMATCH", "program version wrong"}, {76, "EPROCUNAVAIL", "bad procedure for program"}, {77, "ENOLCK", "no locks available"}, {78, "ENOSYS", "function not implemented"}, {79, "EFTYPE", "inappropriate file type or format"}, {80, "EAUTH", "authentication error"}, {81, "ENEEDAUTH", "need authenticator"}, {82, "EIPSEC", "IPsec processing failure"}, {83, "ENOATTR", "attribute not found"}, {84, "EILSEQ", "illegal byte sequence"}, {85, "ENOMEDIUM", "no medium found"}, {86, "EMEDIUMTYPE", "wrong medium type"}, {87, "EOVERFLOW", "value too large to be stored in data type"}, {88, "ECANCELED", "operation canceled"}, {89, "EIDRM", "identifier removed"}, {90, "ENOMSG", "no message of desired type"}, {91, "ELAST", "not supported"}, } // Signal table var signalList = [...]struct { num syscall.Signal name string desc string }{ {1, "SIGHUP", "hangup"}, {2, "SIGINT", "interrupt"}, {3, "SIGQUIT", "quit"}, {4, "SIGILL", "illegal instruction"}, {5, "SIGTRAP", "trace/BPT trap"}, {6, "SIGABRT", "abort trap"}, {7, "SIGEMT", "EMT trap"}, {8, "SIGFPE", "floating point exception"}, {9, "SIGKILL", "killed"}, {10, "SIGBUS", "bus error"}, {11, "SIGSEGV", "segmentation fault"}, {12, "SIGSYS", "bad system call"}, {13, "SIGPIPE", "broken pipe"}, {14, "SIGALRM", "alarm clock"}, {15, "SIGTERM", "terminated"}, {16, "SIGURG", "urgent I/O condition"}, {17, "SIGSTOP", "suspended (signal)"}, {18, "SIGTSTP", "suspended"}, {19, "SIGCONT", "continued"}, {20, "SIGCHLD", "child exited"}, {21, "SIGTTIN", "stopped (tty input)"}, {22, "SIGTTOU", "stopped (tty output)"}, {23, "SIGIO", "I/O possible"}, {24, "SIGXCPU", "cputime limit exceeded"}, {25, "SIGXFSZ", "filesize limit exceeded"}, {26, "SIGVTALRM", "virtual timer expired"}, {27, "SIGPROF", "profiling timer expired"}, {28, "SIGWINCH", "window size changes"}, {29, "SIGINFO", "information request"}, {30, "SIGUSR1", "user defined signal 1"}, {31, "SIGUSR2", "user defined signal 2"}, {32, "SIGTHR", "thread AST"}, }
vendor/golang.org/x/sys/unix/zerrors_openbsd_arm.go
0
https://github.com/grafana/grafana/commit/03fefd7beaa322ea4fbfb2cb0aa2f8bc3d5dd6ff
[ 0.0007904875092208385, 0.00017720970208756626, 0.00016068028344307095, 0.00016647124721203, 0.00005723967115045525 ]
{ "id": 7, "code_window": [ " </a>\n", " <a href=\"{{< relref \"features/datasources/prometheus.md\" >}}\" class=\"nav-cards__item nav-cards__item--ds\">\n", " <img src=\"/img/docs/logos/icon_prometheus.svg\" >\n", " <h5>Prometheus</h5>\n", " </a>\n", " <a href=\"{{< relref \"features/datasources/opentsdb.md\" >}}\" class=\"nav-cards__item nav-cards__item--ds\">\n", " <img src=\"/img/docs/logos/icon_opentsdb.png\" >\n", " <h5>OpenTSDB</h5>\n", " </a>\n", " <a href=\"{{< relref \"features/datasources/mysql.md\" >}}\" class=\"nav-cards__item nav-cards__item--ds\">\n", " <img src=\"/img/docs/logos/icon_mysql.png\" >\n", " <h5>MySQL</h5>\n" ], "labels": [ "keep", "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " <a href=\"{{< relref \"features/datasources/stackdriver.md\" >}}\" class=\"nav-cards__item nav-cards__item--ds\">\n", " <img src=\"/img/docs/logos/stackdriver_logo.png\">\n", " <h5>Google Stackdriver</h5>\n", " </a>\n", " <a href=\"{{< relref \"features/datasources/cloudwatch.md\" >}}\" class=\"nav-cards__item nav-cards__item--ds\">\n", " <img src=\"/img/docs/logos/icon_cloudwatch.svg\">\n", " <h5>Cloudwatch</h5>\n" ], "file_path": "docs/sources/index.md", "type": "replace", "edit_start_line_idx": 90 }
package tsdb import ( "context" "github.com/grafana/grafana/pkg/models" ) type HandleRequestFunc func(ctx context.Context, dsInfo *models.DataSource, req *TsdbQuery) (*Response, error) func HandleRequest(ctx context.Context, dsInfo *models.DataSource, req *TsdbQuery) (*Response, error) { endpoint, err := getTsdbQueryEndpointFor(dsInfo) if err != nil { return nil, err } return endpoint.Query(ctx, dsInfo, req) }
pkg/tsdb/request.go
0
https://github.com/grafana/grafana/commit/03fefd7beaa322ea4fbfb2cb0aa2f8bc3d5dd6ff
[ 0.0002302920911461115, 0.00019832502584904432, 0.00016635794600006193, 0.00019832502584904432, 0.00003196707257302478 ]
{ "id": 8, "code_window": [ " <img src=\"/img/docs/logos/icon_postgres.svg\" >\n", " <h5>Postgres</h5>\n", " </a>\n", " <a href=\"{{< relref \"features/datasources/cloudwatch.md\" >}}\" class=\"nav-cards__item nav-cards__item--ds\">\n", " <img src=\"/img/docs/logos/icon_cloudwatch.svg\">\n", " <h5>Cloudwatch</h5>\n", " </a>\n", " <a href=\"{{< relref \"features/datasources/mssql.md\" >}}\" class=\"nav-cards__item nav-cards__item--ds\">\n", " <img src=\"/img/docs/logos/sql_server_logo.svg\">\n", " <h5>Microsoft SQL Server</h5>\n", " </a>\n" ], "labels": [ "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [], "file_path": "docs/sources/index.md", "type": "replace", "edit_start_line_idx": 102 }
+++ title = "Using Stackdriver in Grafana" description = "Guide for using Stackdriver in Grafana" keywords = ["grafana", "stackdriver", "google", "guide"] type = "docs" aliases = ["/datasources/stackdriver"] [menu.docs] name = "Stackdriver" parent = "datasources" weight = 11 +++ # Using Google Stackdriver in Grafana > Only available in Grafana v5.3+. > The datasource is currently a beta feature and is subject to change. Grafana ships with built-in support for Google Stackdriver. Just add it as a datasource and you are ready to build dashboards for your Stackdriver metrics. ## Adding the data source to Grafana 1. Open the side menu by clicking the Grafana icon in the top header. 2. In the side menu under the `Dashboards` link you should find a link named `Data Sources`. 3. Click the `+ Add data source` button in the top header. 4. Select `Stackdriver` from the _Type_ dropdown. 5. Upload or paste in the Service Account Key file. See below for steps on how to create a Service Account Key file. > NOTE: If you're not seeing the `Data Sources` link in your side menu it means that your current user does not have the `Admin` role for the current organization. | Name | Description | | --------------------- | ----------------------------------------------------------------------------------- | | _Name_ | The datasource name. This is how you refer to the datasource in panels & queries. | | _Default_ | Default datasource means that it will be pre-selected for new panels. | | _Service Account Key_ | Service Account Key File for a GCP Project. Instructions below on how to create it. | ## Authentication ### Service Account Credentials - Private Key File To authenticate with the Stackdriver API, you need to create a Google Cloud Platform (GCP) Service Account for the Project you want to show data for. A Grafana datasource integrates with one GCP Project. If you want to visualize data from multiple GCP Projects then you need to create one datasource per GCP Project. #### Enable APIs The following APIs need to be enabled first: * [Monitoring API](https://console.cloud.google.com/apis/library/monitoring.googleapis.com) * [Cloud Resource Manager API](https://console.cloud.google.com/apis/library/cloudresourcemanager.googleapis.com) Click on the links above and click the `Enable` button: ![Enable GCP APIs](/img/docs/v53/stackdriver_enable_api.png) #### Create a GCP Service Account for a Project 1. Navigate to the [APIs & Services Credentials page](https://console.cloud.google.com/apis/credentials). 2. Click on the `Create credentials` dropdown/button and choose the `Service account key` option. ![Create service account button](/img/docs/v53/stackdriver_create_service_account_button.png) 3. On the `Create service account key` page, choose key type `JSON`. Then in the `Service Account` dropdown, choose the `New service account` option: ![Create service account key](/img/docs/v53/stackdriver_create_service_account_key.png) 4. Some new fields will appear. Fill in a name for the service account in the `Service account name` field and then choose the `Monitoring Viewer` role from the `Role` dropdown: ![Choose role](/img/docs/v53/stackdriver_service_account_choose_role.png) 5. Click the Create button. A JSON key file will be created and downloaded to your computer. Store this file in a secure place as it allows access to your Stackdriver data. 6. Upload it to Grafana on the datasource Configuration page. You can either upload the file or paste in the contents of the file. ![Choose role](/img/docs/v53/stackdriver_grafana_upload_key.png) 7. The file contents will be encrypted and saved in the Grafana database. Don't forget to save after uploading the file! ![Choose role](/img/docs/v53/stackdriver_grafana_key_uploaded.png) ## Metric Query Editor {{< docs-imagebox img="/img/docs/v53/stackdriver_query_editor.png" max-width= "400px" class="docs-image--right" >}} The Stackdriver query editor allows you to select metrics and group by multiple labels and use filter the results. Begin by choosing a `Service` and then a metric from the `Metric` dropdown. Use the plus and minus icons in the filter and group by sections to add/remove filters or group by clauses. Stackdriver metrics can be of different kinds (GAUGE, DELTA, CUMULATIVE) and these kinds have support for different aggregation options (reducers and aligners). The Grafana query editor shows the list of available aggregation methods for a selected metric and sets a default reducer and aligner when you select the metric. Units for the Y-axis are also automatically selected by the query editor. ### Filter To add a filter, click the plus icon and choose a field to filter by and enter a filter value e.g. `instance_name = grafana-1`. You can remove the filter by clicking on the filter name and select `--remove filter--`. #### Simple wildcards When the operator is set to `=` or `!=` it is possible to add wildcards to the filter value field. E.g `us-*` will capture all values that starts with "us-" and `*central-a` will capture all values that ends with "central-a". `*-central-*` captures all values that has the substring of -central-. Simple wildcards are less expensive than regular expressions. #### Regular expressions When the operator is set to `=~` or `!=~` it is possible to add regular expressions to the filter value field. E.g `us-central[1-3]-[af]` would match all values that starts with "us-central", is followed by a number in the range of 1 to 3, a dash and then either an "a" or an "f". Leading and trailing slashes are not needed when creating regular expressions. ### Aggregation The aggregation field lets you combine time series based on common statistics. Read more about this option [here](https://cloud.google.com/monitoring/charts/metrics-selector#aggregation-options). The `Aligner` field allows you to align multiple time series after the same group by time interval. Read more about how it works [here](https://cloud.google.com/monitoring/charts/metrics-selector#alignment). #### Alignment Period/Group by Time The `Alignment Period` groups a metric by time if an aggregation is chosen. The default is to use the GCP Stackdriver default groupings (which allows you to compare graphs in Grafana with graphs in the Stackdriver UI). The option is called `Stackdriver auto` and the defaults are: * 1m for time ranges < 23 hours * 5m for time ranges >= 23 hours and < 6 days * 1h for time ranges >= 6 days The other automatic option is `Grafana auto`. This will automatically set the group by time depending on the time range chosen and the width of the graph panel. Read more about the details [here](http://docs.grafana.org/reference/templating/#the-interval-variable). It is also possible to choose fixed time intervals to group by, like `1h` or `1d`. ### Group By Group by resource or metric labels to reduce the number of time series and to aggregate the results by a group by. E.g. Group by instance_name to see an aggregated metric for a Compute instance. ### Alias Patterns The Alias By field allows you to control the format of the legend keys. The default is to show the metric name and labels. This can be long and hard to read. Using the following patterns in the alias field, you can format the legend key the way you want it. #### Metric Type Patterns | Alias Pattern | Description | Example Result | | -------------------- | ---------------------------- | ------------------------------------------------- | | `{{metric.type}}` | returns the full Metric Type | `compute.googleapis.com/instance/cpu/utilization` | | `{{metric.name}}` | returns the metric name part | `instance/cpu/utilization` | | `{{metric.service}}` | returns the service part | `compute` | #### Label Patterns In the Group By dropdown, you can see a list of metric and resource labels for a metric. These can be included in the legend key using alias patterns. | Alias Pattern Format | Description | Alias Pattern Example | Example Result | | ------------------------ | -------------------------------- | -------------------------------- | ---------------- | | `{{metric.label.xxx}}` | returns the metric label value | `{{metric.label.instance_name}}` | `grafana-1-prod` | | `{{resource.label.xxx}}` | returns the resource label value | `{{resource.label.zone}}` | `us-east1-b` | Example Alias By: `{{metric.type}} - {{metric.labels.instance_name}}` Example Result: `compute.googleapis.com/instance/cpu/usage_time - server1-prod` ## Templating Instead of hard-coding things like server, application and sensor name in you metric queries you can use variables in their place. Variables are shown as dropdown select boxes at the top of the dashboard. These dropdowns makes it easy to change the data being displayed in your dashboard. Checkout the [Templating]({{< relref "reference/templating.md" >}}) documentation for an introduction to the templating feature and the different types of template variables. ### Query Variable Writing variable queries is not supported yet. ### Using variables in queries There are two syntaxes: * `$<varname>` Example: `metric.label.$metric_label` * `[[varname]]` Example: `metric.label.[[metric_label]]` Why two ways? The first syntax is easier to read and write but does not allow you to use a variable in the middle of a word. When the _Multi-value_ or _Include all value_ options are enabled, Grafana converts the labels from plain text to a regex compatible string, which means you have to use `=~` instead of `=`. ## Annotations {{< docs-imagebox img="/img/docs/v53/stackdriver_annotations_query_editor.png" max-width= "400px" class="docs-image--right" >}} [Annotations]({{< relref "reference/annotations.md" >}}) allows you to overlay rich event information on top of graphs. You add annotation queries via the Dashboard menu / Annotations view. Annotation rendering is expensive so it is important to limit the number of rows returned. There is no support for showing Stackdriver annotations and events yet but it works well with [custom metrics](https://cloud.google.com/monitoring/custom-metrics/) in Stackdriver. With the query editor for annotations, you can select a metric and filters. The `Title` and `Text` fields support templating and can use data returned from the query. For example, the Title field could have the following text: `{{metric.type}} has value: {{metric.value}}` Example Result: `monitoring.googleapis.com/uptime_check/http_status has this value: 502` ### Patterns for the Annotation Query Editor | Alias Pattern Format | Description | Alias Pattern Example | Example Result | | ------------------------ | -------------------------------- | -------------------------------- | ------------------------------------------------- | | `{{metric.value}}` | value of the metric/point | `{{metric.value}}` | `555` | | `{{metric.type}}` | returns the full Metric Type | `{{metric.type}}` | `compute.googleapis.com/instance/cpu/utilization` | | `{{metric.name}}` | returns the metric name part | `{{metric.name}}` | `instance/cpu/utilization` | | `{{metric.service}}` | returns the service part | `{{metric.service}}` | `compute` | | `{{metric.label.xxx}}` | returns the metric label value | `{{metric.label.instance_name}}` | `grafana-1-prod` | | `{{resource.label.xxx}}` | returns the resource label value | `{{resource.label.zone}}` | `us-east1-b` | ## Configure the Datasource with Provisioning It's now possible to configure datasources using config files with Grafana's provisioning system. You can read more about how it works and all the settings you can set for datasources on the [provisioning docs page](/administration/provisioning/#datasources) Here is a provisioning example for this datasource. ```yaml apiVersion: 1 datasources: - name: Stackdriver type: stackdriver access: proxy jsonData: tokenUri: https://oauth2.googleapis.com/token clientEmail: [email protected] secureJsonData: privateKey: | -----BEGIN PRIVATE KEY----- POSEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCb1u1Srw8ICYHS ... yA+23427282348234= -----END PRIVATE KEY----- ```
docs/sources/features/datasources/stackdriver.md
1
https://github.com/grafana/grafana/commit/03fefd7beaa322ea4fbfb2cb0aa2f8bc3d5dd6ff
[ 0.00017699084128253162, 0.00016966521798167378, 0.000160918541951105, 0.00017069645400624722, 0.0000054730694500904065 ]
{ "id": 8, "code_window": [ " <img src=\"/img/docs/logos/icon_postgres.svg\" >\n", " <h5>Postgres</h5>\n", " </a>\n", " <a href=\"{{< relref \"features/datasources/cloudwatch.md\" >}}\" class=\"nav-cards__item nav-cards__item--ds\">\n", " <img src=\"/img/docs/logos/icon_cloudwatch.svg\">\n", " <h5>Cloudwatch</h5>\n", " </a>\n", " <a href=\"{{< relref \"features/datasources/mssql.md\" >}}\" class=\"nav-cards__item nav-cards__item--ds\">\n", " <img src=\"/img/docs/logos/sql_server_logo.svg\">\n", " <h5>Microsoft SQL Server</h5>\n", " </a>\n" ], "labels": [ "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [], "file_path": "docs/sources/index.md", "type": "replace", "edit_start_line_idx": 102 }
//+build !noasm //+build !appengine // Copyright 2015, Klaus Post, see LICENSE for details. // func crc32sse(a []byte) uint32 TEXT ·crc32sse(SB), 4, $0 MOVQ a+0(FP), R10 XORQ BX, BX // CRC32 dword (R10), EBX BYTE $0xF2; BYTE $0x41; BYTE $0x0f BYTE $0x38; BYTE $0xf1; BYTE $0x1a MOVL BX, ret+24(FP) RET // func crc32sseAll(a []byte, dst []uint32) TEXT ·crc32sseAll(SB), 4, $0 MOVQ a+0(FP), R8 // R8: src MOVQ a_len+8(FP), R10 // input length MOVQ dst+24(FP), R9 // R9: dst SUBQ $4, R10 JS end JZ one_crc MOVQ R10, R13 SHRQ $2, R10 // len/4 ANDQ $3, R13 // len&3 XORQ BX, BX ADDQ $1, R13 TESTQ R10, R10 JZ rem_loop crc_loop: MOVQ (R8), R11 XORQ BX, BX XORQ DX, DX XORQ DI, DI MOVQ R11, R12 SHRQ $8, R11 MOVQ R12, AX MOVQ R11, CX SHRQ $16, R12 SHRQ $16, R11 MOVQ R12, SI // CRC32 EAX, EBX BYTE $0xF2; BYTE $0x0f BYTE $0x38; BYTE $0xf1; BYTE $0xd8 // CRC32 ECX, EDX BYTE $0xF2; BYTE $0x0f BYTE $0x38; BYTE $0xf1; BYTE $0xd1 // CRC32 ESI, EDI BYTE $0xF2; BYTE $0x0f BYTE $0x38; BYTE $0xf1; BYTE $0xfe MOVL BX, (R9) MOVL DX, 4(R9) MOVL DI, 8(R9) XORQ BX, BX MOVL R11, AX // CRC32 EAX, EBX BYTE $0xF2; BYTE $0x0f BYTE $0x38; BYTE $0xf1; BYTE $0xd8 MOVL BX, 12(R9) ADDQ $16, R9 ADDQ $4, R8 XORQ BX, BX SUBQ $1, R10 JNZ crc_loop rem_loop: MOVL (R8), AX // CRC32 EAX, EBX BYTE $0xF2; BYTE $0x0f BYTE $0x38; BYTE $0xf1; BYTE $0xd8 MOVL BX, (R9) ADDQ $4, R9 ADDQ $1, R8 XORQ BX, BX SUBQ $1, R13 JNZ rem_loop end: RET one_crc: MOVQ $1, R13 XORQ BX, BX JMP rem_loop // func matchLenSSE4(a, b []byte, max int) int TEXT ·matchLenSSE4(SB), 4, $0 MOVQ a_base+0(FP), SI MOVQ b_base+24(FP), DI MOVQ DI, DX MOVQ max+48(FP), CX cmp8: // As long as we are 8 or more bytes before the end of max, we can load and // compare 8 bytes at a time. If those 8 bytes are equal, repeat. CMPQ CX, $8 JLT cmp1 MOVQ (SI), AX MOVQ (DI), BX CMPQ AX, BX JNE bsf ADDQ $8, SI ADDQ $8, DI SUBQ $8, CX JMP cmp8 bsf: // If those 8 bytes were not equal, XOR the two 8 byte values, and return // the index of the first byte that differs. The BSF instruction finds the // least significant 1 bit, the amd64 architecture is little-endian, and // the shift by 3 converts a bit index to a byte index. XORQ AX, BX BSFQ BX, BX SHRQ $3, BX ADDQ BX, DI // Subtract off &b[0] to convert from &b[ret] to ret, and return. SUBQ DX, DI MOVQ DI, ret+56(FP) RET cmp1: // In the slices' tail, compare 1 byte at a time. CMPQ CX, $0 JEQ matchLenEnd MOVB (SI), AX MOVB (DI), BX CMPB AX, BX JNE matchLenEnd ADDQ $1, SI ADDQ $1, DI SUBQ $1, CX JMP cmp1 matchLenEnd: // Subtract off &b[0] to convert from &b[ret] to ret, and return. SUBQ DX, DI MOVQ DI, ret+56(FP) RET // func histogram(b []byte, h []int32) TEXT ·histogram(SB), 4, $0 MOVQ b+0(FP), SI // SI: &b MOVQ b_len+8(FP), R9 // R9: len(b) MOVQ h+24(FP), DI // DI: Histogram MOVQ R9, R8 SHRQ $3, R8 JZ hist1 XORQ R11, R11 loop_hist8: MOVQ (SI), R10 MOVB R10, R11 INCL (DI)(R11*4) SHRQ $8, R10 MOVB R10, R11 INCL (DI)(R11*4) SHRQ $8, R10 MOVB R10, R11 INCL (DI)(R11*4) SHRQ $8, R10 MOVB R10, R11 INCL (DI)(R11*4) SHRQ $8, R10 MOVB R10, R11 INCL (DI)(R11*4) SHRQ $8, R10 MOVB R10, R11 INCL (DI)(R11*4) SHRQ $8, R10 MOVB R10, R11 INCL (DI)(R11*4) SHRQ $8, R10 INCL (DI)(R10*4) ADDQ $8, SI DECQ R8 JNZ loop_hist8 hist1: ANDQ $7, R9 JZ end_hist XORQ R10, R10 loop_hist1: MOVB (SI), R10 INCL (DI)(R10*4) INCQ SI DECQ R9 JNZ loop_hist1 end_hist: RET
vendor/github.com/klauspost/compress/flate/crc32_amd64.s
0
https://github.com/grafana/grafana/commit/03fefd7beaa322ea4fbfb2cb0aa2f8bc3d5dd6ff
[ 0.00017842877423390746, 0.0001732370728859678, 0.00016216730000451207, 0.00017386108811479062, 0.000003970925263274694 ]
{ "id": 8, "code_window": [ " <img src=\"/img/docs/logos/icon_postgres.svg\" >\n", " <h5>Postgres</h5>\n", " </a>\n", " <a href=\"{{< relref \"features/datasources/cloudwatch.md\" >}}\" class=\"nav-cards__item nav-cards__item--ds\">\n", " <img src=\"/img/docs/logos/icon_cloudwatch.svg\">\n", " <h5>Cloudwatch</h5>\n", " </a>\n", " <a href=\"{{< relref \"features/datasources/mssql.md\" >}}\" class=\"nav-cards__item nav-cards__item--ds\">\n", " <img src=\"/img/docs/logos/sql_server_logo.svg\">\n", " <h5>Microsoft SQL Server</h5>\n", " </a>\n" ], "labels": [ "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [], "file_path": "docs/sources/index.md", "type": "replace", "edit_start_line_idx": 102 }
import coreModule from 'app/core/core_module'; export class AlertingSrv { dashboard: any; alerts: any[]; init(dashboard, alerts) { this.dashboard = dashboard; this.alerts = alerts || []; } } coreModule.service('alertingSrv', AlertingSrv);
public/app/features/dashboard/alerting_srv.ts
0
https://github.com/grafana/grafana/commit/03fefd7beaa322ea4fbfb2cb0aa2f8bc3d5dd6ff
[ 0.00017443535034544766, 0.00017293173004873097, 0.0001714281243039295, 0.00017293173004873097, 0.0000015036130207590759 ]
{ "id": 8, "code_window": [ " <img src=\"/img/docs/logos/icon_postgres.svg\" >\n", " <h5>Postgres</h5>\n", " </a>\n", " <a href=\"{{< relref \"features/datasources/cloudwatch.md\" >}}\" class=\"nav-cards__item nav-cards__item--ds\">\n", " <img src=\"/img/docs/logos/icon_cloudwatch.svg\">\n", " <h5>Cloudwatch</h5>\n", " </a>\n", " <a href=\"{{< relref \"features/datasources/mssql.md\" >}}\" class=\"nav-cards__item nav-cards__item--ds\">\n", " <img src=\"/img/docs/logos/sql_server_logo.svg\">\n", " <h5>Microsoft SQL Server</h5>\n", " </a>\n" ], "labels": [ "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [], "file_path": "docs/sources/index.md", "type": "replace", "edit_start_line_idx": 102 }
<page-header model="navModel"></page-header> <div class="page-container page-body"> <h2 class="page-sub-heading">Edit Organization</h2> <form name="orgDetailsForm" class="gf-form-group"> <div class="gf-form"> <span class="gf-form-label width-10">Name</span> <input type="text" required ng-model="org.name" class="gf-form-input max-width-14" > </div> <div class="gf-form-button-row"> <button type="submit" class="btn btn-success" ng-click="update()" ng-show="!createMode">Update</button> </div> </form> <h3 class="page-heading">Organization Users</h3> <table class="filter-table"> <tr> <th>Username</th> <th>Email</th> <th>Role</th> <th></th> </tr> <tr ng-repeat="orgUser in orgUsers"> <td>{{orgUser.login}}</td> <td>{{orgUser.email}}</td> <td> <div class="gf-form"> <span class="gf-form-select-wrapper"> <select type="text" ng-model="orgUser.role" class="gf-form-input max-width-8" ng-options="f for f in ['Viewer', 'Editor', 'Admin']" ng-change="updateOrgUser(orgUser)"> </select> </span> </div> </td> <td style="width: 1%"> <a ng-click="removeOrgUser(orgUser)" class="btn btn-danger btn-mini"> <i class="fa fa-remove"></i> </a> </td> </tr> </table> </div>
public/app/features/admin/partials/edit_org.html
0
https://github.com/grafana/grafana/commit/03fefd7beaa322ea4fbfb2cb0aa2f8bc3d5dd6ff
[ 0.00017506770382169634, 0.00017204562027473003, 0.00017047650180757046, 0.00017143318837042898, 0.0000016566048088861862 ]
{ "id": 9, "code_window": [ " <img src=\"/img/docs/logos/sql_server_logo.svg\">\n", " <h5>Microsoft SQL Server</h5>\n", " </a>\n", " <a href=\"{{< relref \"features/datasources/stackdriver.md\" >}}\" class=\"nav-cards__item nav-cards__item--ds\">\n", " <img src=\"/img/docs/logos/stackdriver_logo.png\">\n", " <h5>Google Stackdriver</h5>\n", " </a>\n", "</div>" ], "labels": [ "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep" ], "after_edit": [ " <a href=\"{{< relref \"features/datasources/opentsdb.md\" >}}\" class=\"nav-cards__item nav-cards__item--ds\">\n", " <img src=\"/img/docs/logos/icon_opentsdb.png\" >\n", " <h5>OpenTSDB</h5>\n" ], "file_path": "docs/sources/index.md", "type": "replace", "edit_start_line_idx": 110 }
+++ title = "Using Stackdriver in Grafana" description = "Guide for using Stackdriver in Grafana" keywords = ["grafana", "stackdriver", "google", "guide"] type = "docs" aliases = ["/datasources/stackdriver"] [menu.docs] name = "Stackdriver" parent = "datasources" weight = 11 +++ # Using Google Stackdriver in Grafana > Only available in Grafana v5.3+. > The datasource is currently a beta feature and is subject to change. Grafana ships with built-in support for Google Stackdriver. Just add it as a datasource and you are ready to build dashboards for your Stackdriver metrics. ## Adding the data source to Grafana 1. Open the side menu by clicking the Grafana icon in the top header. 2. In the side menu under the `Dashboards` link you should find a link named `Data Sources`. 3. Click the `+ Add data source` button in the top header. 4. Select `Stackdriver` from the _Type_ dropdown. 5. Upload or paste in the Service Account Key file. See below for steps on how to create a Service Account Key file. > NOTE: If you're not seeing the `Data Sources` link in your side menu it means that your current user does not have the `Admin` role for the current organization. | Name | Description | | --------------------- | ----------------------------------------------------------------------------------- | | _Name_ | The datasource name. This is how you refer to the datasource in panels & queries. | | _Default_ | Default datasource means that it will be pre-selected for new panels. | | _Service Account Key_ | Service Account Key File for a GCP Project. Instructions below on how to create it. | ## Authentication ### Service Account Credentials - Private Key File To authenticate with the Stackdriver API, you need to create a Google Cloud Platform (GCP) Service Account for the Project you want to show data for. A Grafana datasource integrates with one GCP Project. If you want to visualize data from multiple GCP Projects then you need to create one datasource per GCP Project. #### Enable APIs The following APIs need to be enabled first: * [Monitoring API](https://console.cloud.google.com/apis/library/monitoring.googleapis.com) * [Cloud Resource Manager API](https://console.cloud.google.com/apis/library/cloudresourcemanager.googleapis.com) Click on the links above and click the `Enable` button: ![Enable GCP APIs](/img/docs/v53/stackdriver_enable_api.png) #### Create a GCP Service Account for a Project 1. Navigate to the [APIs & Services Credentials page](https://console.cloud.google.com/apis/credentials). 2. Click on the `Create credentials` dropdown/button and choose the `Service account key` option. ![Create service account button](/img/docs/v53/stackdriver_create_service_account_button.png) 3. On the `Create service account key` page, choose key type `JSON`. Then in the `Service Account` dropdown, choose the `New service account` option: ![Create service account key](/img/docs/v53/stackdriver_create_service_account_key.png) 4. Some new fields will appear. Fill in a name for the service account in the `Service account name` field and then choose the `Monitoring Viewer` role from the `Role` dropdown: ![Choose role](/img/docs/v53/stackdriver_service_account_choose_role.png) 5. Click the Create button. A JSON key file will be created and downloaded to your computer. Store this file in a secure place as it allows access to your Stackdriver data. 6. Upload it to Grafana on the datasource Configuration page. You can either upload the file or paste in the contents of the file. ![Choose role](/img/docs/v53/stackdriver_grafana_upload_key.png) 7. The file contents will be encrypted and saved in the Grafana database. Don't forget to save after uploading the file! ![Choose role](/img/docs/v53/stackdriver_grafana_key_uploaded.png) ## Metric Query Editor {{< docs-imagebox img="/img/docs/v53/stackdriver_query_editor.png" max-width= "400px" class="docs-image--right" >}} The Stackdriver query editor allows you to select metrics and group by multiple labels and use filter the results. Begin by choosing a `Service` and then a metric from the `Metric` dropdown. Use the plus and minus icons in the filter and group by sections to add/remove filters or group by clauses. Stackdriver metrics can be of different kinds (GAUGE, DELTA, CUMULATIVE) and these kinds have support for different aggregation options (reducers and aligners). The Grafana query editor shows the list of available aggregation methods for a selected metric and sets a default reducer and aligner when you select the metric. Units for the Y-axis are also automatically selected by the query editor. ### Filter To add a filter, click the plus icon and choose a field to filter by and enter a filter value e.g. `instance_name = grafana-1`. You can remove the filter by clicking on the filter name and select `--remove filter--`. #### Simple wildcards When the operator is set to `=` or `!=` it is possible to add wildcards to the filter value field. E.g `us-*` will capture all values that starts with "us-" and `*central-a` will capture all values that ends with "central-a". `*-central-*` captures all values that has the substring of -central-. Simple wildcards are less expensive than regular expressions. #### Regular expressions When the operator is set to `=~` or `!=~` it is possible to add regular expressions to the filter value field. E.g `us-central[1-3]-[af]` would match all values that starts with "us-central", is followed by a number in the range of 1 to 3, a dash and then either an "a" or an "f". Leading and trailing slashes are not needed when creating regular expressions. ### Aggregation The aggregation field lets you combine time series based on common statistics. Read more about this option [here](https://cloud.google.com/monitoring/charts/metrics-selector#aggregation-options). The `Aligner` field allows you to align multiple time series after the same group by time interval. Read more about how it works [here](https://cloud.google.com/monitoring/charts/metrics-selector#alignment). #### Alignment Period/Group by Time The `Alignment Period` groups a metric by time if an aggregation is chosen. The default is to use the GCP Stackdriver default groupings (which allows you to compare graphs in Grafana with graphs in the Stackdriver UI). The option is called `Stackdriver auto` and the defaults are: * 1m for time ranges < 23 hours * 5m for time ranges >= 23 hours and < 6 days * 1h for time ranges >= 6 days The other automatic option is `Grafana auto`. This will automatically set the group by time depending on the time range chosen and the width of the graph panel. Read more about the details [here](http://docs.grafana.org/reference/templating/#the-interval-variable). It is also possible to choose fixed time intervals to group by, like `1h` or `1d`. ### Group By Group by resource or metric labels to reduce the number of time series and to aggregate the results by a group by. E.g. Group by instance_name to see an aggregated metric for a Compute instance. ### Alias Patterns The Alias By field allows you to control the format of the legend keys. The default is to show the metric name and labels. This can be long and hard to read. Using the following patterns in the alias field, you can format the legend key the way you want it. #### Metric Type Patterns | Alias Pattern | Description | Example Result | | -------------------- | ---------------------------- | ------------------------------------------------- | | `{{metric.type}}` | returns the full Metric Type | `compute.googleapis.com/instance/cpu/utilization` | | `{{metric.name}}` | returns the metric name part | `instance/cpu/utilization` | | `{{metric.service}}` | returns the service part | `compute` | #### Label Patterns In the Group By dropdown, you can see a list of metric and resource labels for a metric. These can be included in the legend key using alias patterns. | Alias Pattern Format | Description | Alias Pattern Example | Example Result | | ------------------------ | -------------------------------- | -------------------------------- | ---------------- | | `{{metric.label.xxx}}` | returns the metric label value | `{{metric.label.instance_name}}` | `grafana-1-prod` | | `{{resource.label.xxx}}` | returns the resource label value | `{{resource.label.zone}}` | `us-east1-b` | Example Alias By: `{{metric.type}} - {{metric.labels.instance_name}}` Example Result: `compute.googleapis.com/instance/cpu/usage_time - server1-prod` ## Templating Instead of hard-coding things like server, application and sensor name in you metric queries you can use variables in their place. Variables are shown as dropdown select boxes at the top of the dashboard. These dropdowns makes it easy to change the data being displayed in your dashboard. Checkout the [Templating]({{< relref "reference/templating.md" >}}) documentation for an introduction to the templating feature and the different types of template variables. ### Query Variable Writing variable queries is not supported yet. ### Using variables in queries There are two syntaxes: * `$<varname>` Example: `metric.label.$metric_label` * `[[varname]]` Example: `metric.label.[[metric_label]]` Why two ways? The first syntax is easier to read and write but does not allow you to use a variable in the middle of a word. When the _Multi-value_ or _Include all value_ options are enabled, Grafana converts the labels from plain text to a regex compatible string, which means you have to use `=~` instead of `=`. ## Annotations {{< docs-imagebox img="/img/docs/v53/stackdriver_annotations_query_editor.png" max-width= "400px" class="docs-image--right" >}} [Annotations]({{< relref "reference/annotations.md" >}}) allows you to overlay rich event information on top of graphs. You add annotation queries via the Dashboard menu / Annotations view. Annotation rendering is expensive so it is important to limit the number of rows returned. There is no support for showing Stackdriver annotations and events yet but it works well with [custom metrics](https://cloud.google.com/monitoring/custom-metrics/) in Stackdriver. With the query editor for annotations, you can select a metric and filters. The `Title` and `Text` fields support templating and can use data returned from the query. For example, the Title field could have the following text: `{{metric.type}} has value: {{metric.value}}` Example Result: `monitoring.googleapis.com/uptime_check/http_status has this value: 502` ### Patterns for the Annotation Query Editor | Alias Pattern Format | Description | Alias Pattern Example | Example Result | | ------------------------ | -------------------------------- | -------------------------------- | ------------------------------------------------- | | `{{metric.value}}` | value of the metric/point | `{{metric.value}}` | `555` | | `{{metric.type}}` | returns the full Metric Type | `{{metric.type}}` | `compute.googleapis.com/instance/cpu/utilization` | | `{{metric.name}}` | returns the metric name part | `{{metric.name}}` | `instance/cpu/utilization` | | `{{metric.service}}` | returns the service part | `{{metric.service}}` | `compute` | | `{{metric.label.xxx}}` | returns the metric label value | `{{metric.label.instance_name}}` | `grafana-1-prod` | | `{{resource.label.xxx}}` | returns the resource label value | `{{resource.label.zone}}` | `us-east1-b` | ## Configure the Datasource with Provisioning It's now possible to configure datasources using config files with Grafana's provisioning system. You can read more about how it works and all the settings you can set for datasources on the [provisioning docs page](/administration/provisioning/#datasources) Here is a provisioning example for this datasource. ```yaml apiVersion: 1 datasources: - name: Stackdriver type: stackdriver access: proxy jsonData: tokenUri: https://oauth2.googleapis.com/token clientEmail: [email protected] secureJsonData: privateKey: | -----BEGIN PRIVATE KEY----- POSEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCb1u1Srw8ICYHS ... yA+23427282348234= -----END PRIVATE KEY----- ```
docs/sources/features/datasources/stackdriver.md
1
https://github.com/grafana/grafana/commit/03fefd7beaa322ea4fbfb2cb0aa2f8bc3d5dd6ff
[ 0.0003201718791387975, 0.00018067601195070893, 0.0001597829832462594, 0.00016603959375061095, 0.00004183745477348566 ]
{ "id": 9, "code_window": [ " <img src=\"/img/docs/logos/sql_server_logo.svg\">\n", " <h5>Microsoft SQL Server</h5>\n", " </a>\n", " <a href=\"{{< relref \"features/datasources/stackdriver.md\" >}}\" class=\"nav-cards__item nav-cards__item--ds\">\n", " <img src=\"/img/docs/logos/stackdriver_logo.png\">\n", " <h5>Google Stackdriver</h5>\n", " </a>\n", "</div>" ], "labels": [ "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep" ], "after_edit": [ " <a href=\"{{< relref \"features/datasources/opentsdb.md\" >}}\" class=\"nav-cards__item nav-cards__item--ds\">\n", " <img src=\"/img/docs/logos/icon_opentsdb.png\" >\n", " <h5>OpenTSDB</h5>\n" ], "file_path": "docs/sources/index.md", "type": "replace", "edit_start_line_idx": 110 }
package search import "strings" import "github.com/grafana/grafana/pkg/models" type HitType string const ( DashHitDB HitType = "dash-db" DashHitHome HitType = "dash-home" DashHitFolder HitType = "dash-folder" ) type Hit struct { Id int64 `json:"id"` Uid string `json:"uid"` Title string `json:"title"` Uri string `json:"uri"` Url string `json:"url"` Type HitType `json:"type"` Tags []string `json:"tags"` IsStarred bool `json:"isStarred"` FolderId int64 `json:"folderId,omitempty"` FolderUid string `json:"folderUid,omitempty"` FolderTitle string `json:"folderTitle,omitempty"` FolderUrl string `json:"folderUrl,omitempty"` } type HitList []*Hit func (s HitList) Len() int { return len(s) } func (s HitList) Swap(i, j int) { s[i], s[j] = s[j], s[i] } func (s HitList) Less(i, j int) bool { if s[i].Type == "dash-folder" && s[j].Type == "dash-db" { return true } if s[i].Type == "dash-db" && s[j].Type == "dash-folder" { return false } return strings.ToLower(s[i].Title) < strings.ToLower(s[j].Title) } type Query struct { Title string Tags []string OrgId int64 SignedInUser *models.SignedInUser Limit int IsStarred bool Type string DashboardIds []int64 FolderIds []int64 Permission models.PermissionType Result HitList } type FindPersistedDashboardsQuery struct { Title string OrgId int64 SignedInUser *models.SignedInUser IsStarred bool DashboardIds []int64 Type string FolderIds []int64 Tags []string Limit int Permission models.PermissionType Result HitList }
pkg/services/search/models.go
0
https://github.com/grafana/grafana/commit/03fefd7beaa322ea4fbfb2cb0aa2f8bc3d5dd6ff
[ 0.00017810819554142654, 0.00017004620167426765, 0.00016580874216742814, 0.00016993351164273918, 0.000003630464561865665 ]
{ "id": 9, "code_window": [ " <img src=\"/img/docs/logos/sql_server_logo.svg\">\n", " <h5>Microsoft SQL Server</h5>\n", " </a>\n", " <a href=\"{{< relref \"features/datasources/stackdriver.md\" >}}\" class=\"nav-cards__item nav-cards__item--ds\">\n", " <img src=\"/img/docs/logos/stackdriver_logo.png\">\n", " <h5>Google Stackdriver</h5>\n", " </a>\n", "</div>" ], "labels": [ "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep" ], "after_edit": [ " <a href=\"{{< relref \"features/datasources/opentsdb.md\" >}}\" class=\"nav-cards__item nav-cards__item--ds\">\n", " <img src=\"/img/docs/logos/icon_opentsdb.png\" >\n", " <h5>OpenTSDB</h5>\n" ], "file_path": "docs/sources/index.md", "type": "replace", "edit_start_line_idx": 110 }
// Copyright 2014 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package http2 import "fmt" // WriteScheduler is the interface implemented by HTTP/2 write schedulers. // Methods are never called concurrently. type WriteScheduler interface { // OpenStream opens a new stream in the write scheduler. // It is illegal to call this with streamID=0 or with a streamID that is // already open -- the call may panic. OpenStream(streamID uint32, options OpenStreamOptions) // CloseStream closes a stream in the write scheduler. Any frames queued on // this stream should be discarded. It is illegal to call this on a stream // that is not open -- the call may panic. CloseStream(streamID uint32) // AdjustStream adjusts the priority of the given stream. This may be called // on a stream that has not yet been opened or has been closed. Note that // RFC 7540 allows PRIORITY frames to be sent on streams in any state. See: // https://tools.ietf.org/html/rfc7540#section-5.1 AdjustStream(streamID uint32, priority PriorityParam) // Push queues a frame in the scheduler. In most cases, this will not be // called with wr.StreamID()!=0 unless that stream is currently open. The one // exception is RST_STREAM frames, which may be sent on idle or closed streams. Push(wr FrameWriteRequest) // Pop dequeues the next frame to write. Returns false if no frames can // be written. Frames with a given wr.StreamID() are Pop'd in the same // order they are Push'd. Pop() (wr FrameWriteRequest, ok bool) } // OpenStreamOptions specifies extra options for WriteScheduler.OpenStream. type OpenStreamOptions struct { // PusherID is zero if the stream was initiated by the client. Otherwise, // PusherID names the stream that pushed the newly opened stream. PusherID uint32 } // FrameWriteRequest is a request to write a frame. type FrameWriteRequest struct { // write is the interface value that does the writing, once the // WriteScheduler has selected this frame to write. The write // functions are all defined in write.go. write writeFramer // stream is the stream on which this frame will be written. // nil for non-stream frames like PING and SETTINGS. stream *stream // done, if non-nil, must be a buffered channel with space for // 1 message and is sent the return value from write (or an // earlier error) when the frame has been written. done chan error } // StreamID returns the id of the stream this frame will be written to. // 0 is used for non-stream frames such as PING and SETTINGS. func (wr FrameWriteRequest) StreamID() uint32 { if wr.stream == nil { if se, ok := wr.write.(StreamError); ok { // (*serverConn).resetStream doesn't set // stream because it doesn't necessarily have // one. So special case this type of write // message. return se.StreamID } return 0 } return wr.stream.id } // DataSize returns the number of flow control bytes that must be consumed // to write this entire frame. This is 0 for non-DATA frames. func (wr FrameWriteRequest) DataSize() int { if wd, ok := wr.write.(*writeData); ok { return len(wd.p) } return 0 } // Consume consumes min(n, available) bytes from this frame, where available // is the number of flow control bytes available on the stream. Consume returns // 0, 1, or 2 frames, where the integer return value gives the number of frames // returned. // // If flow control prevents consuming any bytes, this returns (_, _, 0). If // the entire frame was consumed, this returns (wr, _, 1). Otherwise, this // returns (consumed, rest, 2), where 'consumed' contains the consumed bytes and // 'rest' contains the remaining bytes. The consumed bytes are deducted from the // underlying stream's flow control budget. func (wr FrameWriteRequest) Consume(n int32) (FrameWriteRequest, FrameWriteRequest, int) { var empty FrameWriteRequest // Non-DATA frames are always consumed whole. wd, ok := wr.write.(*writeData) if !ok || len(wd.p) == 0 { return wr, empty, 1 } // Might need to split after applying limits. allowed := wr.stream.flow.available() if n < allowed { allowed = n } if wr.stream.sc.maxFrameSize < allowed { allowed = wr.stream.sc.maxFrameSize } if allowed <= 0 { return empty, empty, 0 } if len(wd.p) > int(allowed) { wr.stream.flow.take(allowed) consumed := FrameWriteRequest{ stream: wr.stream, write: &writeData{ streamID: wd.streamID, p: wd.p[:allowed], // Even if the original had endStream set, there // are bytes remaining because len(wd.p) > allowed, // so we know endStream is false. endStream: false, }, // Our caller is blocking on the final DATA frame, not // this intermediate frame, so no need to wait. done: nil, } rest := FrameWriteRequest{ stream: wr.stream, write: &writeData{ streamID: wd.streamID, p: wd.p[allowed:], endStream: wd.endStream, }, done: wr.done, } return consumed, rest, 2 } // The frame is consumed whole. // NB: This cast cannot overflow because allowed is <= math.MaxInt32. wr.stream.flow.take(int32(len(wd.p))) return wr, empty, 1 } // String is for debugging only. func (wr FrameWriteRequest) String() string { var des string if s, ok := wr.write.(fmt.Stringer); ok { des = s.String() } else { des = fmt.Sprintf("%T", wr.write) } return fmt.Sprintf("[FrameWriteRequest stream=%d, ch=%v, writer=%v]", wr.StreamID(), wr.done != nil, des) } // replyToWriter sends err to wr.done and panics if the send must block // This does nothing if wr.done is nil. func (wr *FrameWriteRequest) replyToWriter(err error) { if wr.done == nil { return } select { case wr.done <- err: default: panic(fmt.Sprintf("unbuffered done channel passed in for type %T", wr.write)) } wr.write = nil // prevent use (assume it's tainted after wr.done send) } // writeQueue is used by implementations of WriteScheduler. type writeQueue struct { s []FrameWriteRequest } func (q *writeQueue) empty() bool { return len(q.s) == 0 } func (q *writeQueue) push(wr FrameWriteRequest) { q.s = append(q.s, wr) } func (q *writeQueue) shift() FrameWriteRequest { if len(q.s) == 0 { panic("invalid use of queue") } wr := q.s[0] // TODO: less copy-happy queue. copy(q.s, q.s[1:]) q.s[len(q.s)-1] = FrameWriteRequest{} q.s = q.s[:len(q.s)-1] return wr } // consume consumes up to n bytes from q.s[0]. If the frame is // entirely consumed, it is removed from the queue. If the frame // is partially consumed, the frame is kept with the consumed // bytes removed. Returns true iff any bytes were consumed. func (q *writeQueue) consume(n int32) (FrameWriteRequest, bool) { if len(q.s) == 0 { return FrameWriteRequest{}, false } consumed, rest, numresult := q.s[0].Consume(n) switch numresult { case 0: return FrameWriteRequest{}, false case 1: q.shift() case 2: q.s[0] = rest } return consumed, true } type writeQueuePool []*writeQueue // put inserts an unused writeQueue into the pool. func (p *writeQueuePool) put(q *writeQueue) { for i := range q.s { q.s[i] = FrameWriteRequest{} } q.s = q.s[:0] *p = append(*p, q) } // get returns an empty writeQueue. func (p *writeQueuePool) get() *writeQueue { ln := len(*p) if ln == 0 { return new(writeQueue) } x := ln - 1 q := (*p)[x] (*p)[x] = nil *p = (*p)[:x] return q }
vendor/golang.org/x/net/http2/writesched.go
0
https://github.com/grafana/grafana/commit/03fefd7beaa322ea4fbfb2cb0aa2f8bc3d5dd6ff
[ 0.0006639323546551168, 0.00018591625848785043, 0.00015756090579088777, 0.00016563870303798467, 0.00009765502181835473 ]
{ "id": 9, "code_window": [ " <img src=\"/img/docs/logos/sql_server_logo.svg\">\n", " <h5>Microsoft SQL Server</h5>\n", " </a>\n", " <a href=\"{{< relref \"features/datasources/stackdriver.md\" >}}\" class=\"nav-cards__item nav-cards__item--ds\">\n", " <img src=\"/img/docs/logos/stackdriver_logo.png\">\n", " <h5>Google Stackdriver</h5>\n", " </a>\n", "</div>" ], "labels": [ "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep" ], "after_edit": [ " <a href=\"{{< relref \"features/datasources/opentsdb.md\" >}}\" class=\"nav-cards__item nav-cards__item--ds\">\n", " <img src=\"/img/docs/logos/icon_opentsdb.png\" >\n", " <h5>OpenTSDB</h5>\n" ], "file_path": "docs/sources/index.md", "type": "replace", "edit_start_line_idx": 110 }
apiVersion: 1 providers: - name: 'Bulk dashboards' folder: 'Bulk dashboards' type: file options: path: devenv/bulk-dashboards
devenv/bulk-dashboards/bulk-dashboards.yaml
0
https://github.com/grafana/grafana/commit/03fefd7beaa322ea4fbfb2cb0aa2f8bc3d5dd6ff
[ 0.00016936294559855014, 0.00016936294559855014, 0.00016936294559855014, 0.00016936294559855014, 0 ]
{ "id": 0, "code_window": [ " &,\n", " &:hover {\n", " background: @table-expanded-row-bg;\n", " }\n", "\n", " .@{table-prefix-cls}-wrapper {\n", " margin: -@table-padding-vertical -@table-padding-horizontal -@table-padding-vertical - 1px;\n", " }\n", " }\n", "\n", " .@{table-prefix-cls}-row-indent + .@{table-prefix-cls}-row-expand-icon {\n" ], "labels": [ "keep", "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ], "after_edit": [ " td > .@{table-prefix-cls}-wrapper {\n" ], "file_path": "components/table/style/index.less", "type": "replace", "edit_start_line_idx": 547 }
@table-padding-vertical-md: @table-padding-vertical * 3 / 4; @table-padding-horizontal-md: @table-padding-horizontal / 2; @table-padding-vertical-sm: @table-padding-vertical / 2; @table-padding-horizontal-sm: @table-padding-horizontal / 2; .@{table-prefix-cls}-middle { > .@{table-prefix-cls}-title, > .@{table-prefix-cls}-footer { padding: @table-padding-vertical-md @table-padding-horizontal-md; } > .@{table-prefix-cls}-content { > .@{table-prefix-cls}-header > table, > .@{table-prefix-cls}-body > table, > .@{table-prefix-cls}-scroll > .@{table-prefix-cls}-header > table, > .@{table-prefix-cls}-scroll > .@{table-prefix-cls}-body > table, > .@{table-prefix-cls}-fixed-left > .@{table-prefix-cls}-header > table, > .@{table-prefix-cls}-fixed-right > .@{table-prefix-cls}-header > table, > .@{table-prefix-cls}-fixed-left > .@{table-prefix-cls}-body-outer > .@{table-prefix-cls}-body-inner > table, > .@{table-prefix-cls}-fixed-right > .@{table-prefix-cls}-body-outer > .@{table-prefix-cls}-body-inner > table { > .@{table-prefix-cls}-thead > tr > th, > .@{table-prefix-cls}-tbody > tr > td { padding: @table-padding-vertical-md @table-padding-horizontal-md; } } } tr.@{table-prefix-cls}-expanded-row .@{table-prefix-cls}-wrapper { margin: -@table-padding-vertical-md -@table-padding-horizontal -@table-padding-vertical-md - 1px; } } .@{table-prefix-cls}-small { border: @border-width-base @border-style-base @border-color-split; border-radius: @border-radius-base; > .@{table-prefix-cls}-title, > .@{table-prefix-cls}-footer { padding: @table-padding-vertical-sm @table-padding-horizontal-sm; } > .@{table-prefix-cls}-title { border-bottom: @border-width-base @border-style-base @border-color-split; top: 0; } > .@{table-prefix-cls}-content { > .@{table-prefix-cls}-body { margin: 0 @table-padding-horizontal-sm; } > .@{table-prefix-cls}-header > table, > .@{table-prefix-cls}-body > table, > .@{table-prefix-cls}-scroll > .@{table-prefix-cls}-header > table, > .@{table-prefix-cls}-scroll > .@{table-prefix-cls}-body > table, > .@{table-prefix-cls}-fixed-left > .@{table-prefix-cls}-header > table, > .@{table-prefix-cls}-fixed-right > .@{table-prefix-cls}-header > table, > .@{table-prefix-cls}-fixed-left > .@{table-prefix-cls}-body-outer > .@{table-prefix-cls}-body-inner > table, > .@{table-prefix-cls}-fixed-right > .@{table-prefix-cls}-body-outer > .@{table-prefix-cls}-body-inner > table { border: 0; > .@{table-prefix-cls}-thead > tr > th, > .@{table-prefix-cls}-tbody > tr > td { padding: @table-padding-vertical-sm @table-padding-horizontal-sm; } > .@{table-prefix-cls}-thead > tr > th { background-color: @component-background; border-bottom: @border-width-base @border-style-base @border-color-split; } > .@{table-prefix-cls}-thead > tr > th.@{table-prefix-cls}-column-sort { background-color: @table-body-sort-bg; } } > .@{table-prefix-cls}-scroll > .@{table-prefix-cls}-header > table, > .@{table-prefix-cls}-scroll > .@{table-prefix-cls}-body > table, > .@{table-prefix-cls}-fixed-left > .@{table-prefix-cls}-header > table, > .@{table-prefix-cls}-fixed-right > .@{table-prefix-cls}-header > table, > .@{table-prefix-cls}-fixed-left > .@{table-prefix-cls}-body-outer > .@{table-prefix-cls}-body-inner > table, > .@{table-prefix-cls}-fixed-right > .@{table-prefix-cls}-body-outer > .@{table-prefix-cls}-body-inner > table { padding: 0; } .@{table-prefix-cls}-header { background-color: @component-background; } .@{table-prefix-cls}-placeholder, .@{table-prefix-cls}-row:last-child td { border-bottom: 0; } } &.@{table-prefix-cls}-bordered { border-right: 0; .@{table-prefix-cls}-title { border: 0; border-bottom: @border-width-base @border-style-base @border-color-split; border-right: @border-width-base @border-style-base @border-color-split; } .@{table-prefix-cls}-content { border-right: @border-width-base @border-style-base @border-color-split; } .@{table-prefix-cls}-footer { border: 0; border-top: @border-width-base @border-style-base @border-color-split; border-right: @border-width-base @border-style-base @border-color-split; &:before { display: none; } } .@{table-prefix-cls}-placeholder { border-left: 0; border-bottom: 0; border-right: 0; } .@{table-prefix-cls}-thead > tr > th:last-child, .@{table-prefix-cls}-tbody > tr > td:last-child { border-right: none; } .@{table-prefix-cls}-fixed-left { .@{table-prefix-cls}-thead > tr > th:last-child, .@{table-prefix-cls}-tbody > tr > td:last-child { border-right: @border-width-base @border-style-base @border-color-split; } } .@{table-prefix-cls}-fixed-right { border-left: @border-width-base @border-style-base @border-color-split; border-right: @border-width-base @border-style-base @border-color-split; } } tr.@{table-prefix-cls}-expanded-row .@{table-prefix-cls}-wrapper { margin: -@table-padding-vertical-sm -@table-padding-horizontal -@table-padding-vertical-sm - 1px; } }
components/table/style/size.less
1
https://github.com/ant-design/ant-design/commit/368468829f8f60280c100e33de9993be54cf120c
[ 0.0014307152014225721, 0.0004938372876495123, 0.00016637762018945068, 0.000297346618026495, 0.0004177369992248714 ]
{ "id": 0, "code_window": [ " &,\n", " &:hover {\n", " background: @table-expanded-row-bg;\n", " }\n", "\n", " .@{table-prefix-cls}-wrapper {\n", " margin: -@table-padding-vertical -@table-padding-horizontal -@table-padding-vertical - 1px;\n", " }\n", " }\n", "\n", " .@{table-prefix-cls}-row-indent + .@{table-prefix-cls}-row-expand-icon {\n" ], "labels": [ "keep", "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ], "after_edit": [ " td > .@{table-prefix-cls}-wrapper {\n" ], "file_path": "components/table/style/index.less", "type": "replace", "edit_start_line_idx": 547 }
import Button from './button'; import ButtonGroup from './button-group'; export { ButtonProps, ButtonShape, ButtonSize, ButtonType } from './button'; export { ButtonGroupProps } from './button-group'; Button.Group = ButtonGroup; export default Button;
components/button/index.tsx
0
https://github.com/ant-design/ant-design/commit/368468829f8f60280c100e33de9993be54cf120c
[ 0.00017552987264934927, 0.00017552987264934927, 0.00017552987264934927, 0.00017552987264934927, 0 ]
{ "id": 0, "code_window": [ " &,\n", " &:hover {\n", " background: @table-expanded-row-bg;\n", " }\n", "\n", " .@{table-prefix-cls}-wrapper {\n", " margin: -@table-padding-vertical -@table-padding-horizontal -@table-padding-vertical - 1px;\n", " }\n", " }\n", "\n", " .@{table-prefix-cls}-row-indent + .@{table-prefix-cls}-row-expand-icon {\n" ], "labels": [ "keep", "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ], "after_edit": [ " td > .@{table-prefix-cls}-wrapper {\n" ], "file_path": "components/table/style/index.less", "type": "replace", "edit_start_line_idx": 547 }
--- order: 9 title: zh-CN: 自定义点状步骤条 en-US: Customized Dot Style --- ## zh-CN 为点状步骤条增加自定义展示。 ## en-US You can customize the display for Steps with progress dot style. ````jsx import { Steps, Popover } from 'antd'; const Step = Steps.Step; const customDot = (dot, { status, index }) => ( <Popover content={<span>step {index} status: {status}</span>}> {dot} </Popover> ); ReactDOM.render( <Steps current={1} progressDot={customDot}> <Step title="Finished" description="You can hover on the dot." /> <Step title="In Progress" description="You can hover on the dot." /> <Step title="Waiting" description="You can hover on the dot." /> <Step title="Waiting" description="You can hover on the dot." /> </Steps>, mountNode); ````
components/steps/demo/customized-progress-dot.md
0
https://github.com/ant-design/ant-design/commit/368468829f8f60280c100e33de9993be54cf120c
[ 0.00024676352040842175, 0.00018763879779726267, 0.00016509552369825542, 0.00016934808809310198, 0.000034181011869804934 ]
{ "id": 0, "code_window": [ " &,\n", " &:hover {\n", " background: @table-expanded-row-bg;\n", " }\n", "\n", " .@{table-prefix-cls}-wrapper {\n", " margin: -@table-padding-vertical -@table-padding-horizontal -@table-padding-vertical - 1px;\n", " }\n", " }\n", "\n", " .@{table-prefix-cls}-row-indent + .@{table-prefix-cls}-row-expand-icon {\n" ], "labels": [ "keep", "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ], "after_edit": [ " td > .@{table-prefix-cls}-wrapper {\n" ], "file_path": "components/table/style/index.less", "type": "replace", "edit_start_line_idx": 547 }
--- order: 10 debug: true title: zh-CN: 老版图标 en-US: Test old icons --- ## zh-CN 测试 3.9.0 之前的老图标。 ## en-US Test old icons before `3.9.0`. ````jsx import { Icon } from 'antd'; const icons = [ 'step-backward', 'step-forward', 'fast-backward', 'fast-forward', 'shrink', 'arrows-alt', 'down', 'up', 'left', 'right', 'caret-up', 'caret-down', 'caret-left', 'caret-right', 'up-circle', 'down-circle', 'left-circle', 'right-circle', 'up-circle-o', 'down-circle-o', 'right-circle-o', 'left-circle-o', 'double-right', 'double-left', 'verticle-left', 'verticle-right', 'forward', 'backward', 'rollback', 'enter', 'retweet', 'swap', 'swap-left', 'swap-right', 'arrow-up', 'arrow-down', 'arrow-left', 'arrow-right', 'play-circle', 'play-circle-o', 'up-square', 'down-square', 'left-square', 'right-square', 'up-square-o', 'down-square-o', 'left-square-o', 'right-square-o', 'login', 'logout', 'menu-fold', 'menu-unfold', 'question', 'question-circle-o', 'question-circle', 'plus', 'plus-circle-o', 'plus-circle', 'pause', 'pause-circle-o', 'pause-circle', 'minus', 'minus-circle-o', 'minus-circle', 'plus-square', 'plus-square-o', 'minus-square', 'minus-square-o', 'info', 'info-circle-o', 'info-circle', 'exclamation', 'exclamation-circle-o', 'exclamation-circle', 'close', 'cross', 'close-circle', 'close-circle-o', 'close-square', 'close-square-o', 'check', 'check-circle', 'check-circle-o', 'check-square', 'check-square-o', 'clock-circle-o', 'clock-circle', 'warning', 'lock', 'unlock', 'area-chart', 'pie-chart', 'bar-chart', 'dot-chart', 'bars', 'book', 'calendar', 'cloud', 'cloud-download', 'code', 'code-o', 'copy', 'credit-card', 'delete', 'desktop', 'download', 'edit', 'ellipsis', 'file', 'file-text', 'file-unknown', 'file-pdf', 'file-word', 'file-excel', 'file-jpg', 'file-ppt', 'file-markdown', 'file-add', 'folder', 'folder-open', 'folder-add', 'hdd', 'frown', 'frown-o', 'meh', 'meh-o', 'smile', 'smile-o', 'inbox', 'laptop', 'appstore-o', 'appstore', 'line-chart', 'link', 'mail', 'mobile', 'notification', 'paper-clip', 'picture', 'poweroff', 'reload', 'search', 'setting', 'share-alt', 'shopping-cart', 'tablet', 'tag', 'tag-o', 'tags', 'tags-o', 'to-top', 'upload', 'user', 'video-camera', 'home', 'loading', 'loading-3-quarters', 'cloud-upload-o', 'cloud-download-o', 'cloud-upload', 'cloud-o', 'star-o', 'star', 'heart-o', 'heart', 'environment', 'environment-o', 'eye', 'eye-o', 'camera', 'camera-o', 'save', 'team', 'solution', 'phone', 'filter', 'exception', 'export', 'customer-service', 'qrcode', 'scan', 'like', 'like-o', 'dislike', 'dislike-o', 'message', 'pay-circle', 'pay-circle-o', 'calculator', 'pushpin', 'pushpin-o', 'bulb', 'select', 'switcher', 'rocket', 'bell', 'disconnect', 'database', 'compass', 'barcode', 'hourglass', 'key', 'flag', 'layout', 'printer', 'sound', 'usb', 'skin', 'tool', 'sync', 'wifi', 'car', 'schedule', 'user-add', 'user-delete', 'usergroup-add', 'usergroup-delete', 'man', 'woman', 'shop', 'gift', 'idcard', 'medicine-box', 'red-envelope', 'coffee', 'copyright', 'trademark', 'safety', 'wallet', 'bank', 'trophy', 'contacts', 'global', 'shake', 'api', 'fork', 'dashboard', 'form', 'table', 'profile', 'android', 'android-o', 'apple', 'apple-o', 'windows', 'windows-o', 'ie', 'chrome', 'github', 'aliwangwang', 'aliwangwang-o', 'dingding', 'dingding-o', 'weibo-square', 'weibo-circle', 'taobao-circle', 'html5', 'weibo', 'twitter', 'wechat', 'youtube', 'alipay-circle', 'taobao', 'skype', 'qq', 'medium-workmark', 'gitlab', 'medium', 'linkedin', 'google-plus', 'dropbox', 'facebook', 'codepen', 'amazon', 'google', 'codepen-circle', 'alipay', 'ant-design', 'aliyun', 'zhihu', 'slack', 'slack-square', 'behance', 'behance-square', 'dribbble', 'dribbble-square', 'instagram', 'yuque', ]; ReactDOM.render( <div> {icons.map(icon => <Icon key={icon} type={icon} />)} </div>, mountNode); ````
components/icon/demo/old-icons.md
0
https://github.com/ant-design/ant-design/commit/368468829f8f60280c100e33de9993be54cf120c
[ 0.00017522402049507946, 0.00017181910516228527, 0.00016456758021377027, 0.00017235173436347395, 0.0000019148451428918634 ]
{ "id": 1, "code_window": [ " padding: @table-padding-vertical-md @table-padding-horizontal-md;\n", " }\n", " }\n", " }\n", "\n", " tr.@{table-prefix-cls}-expanded-row .@{table-prefix-cls}-wrapper {\n", " margin: -@table-padding-vertical-md -@table-padding-horizontal -@table-padding-vertical-md - 1px;\n", " }\n", "}\n", "\n", ".@{table-prefix-cls}-small {\n" ], "labels": [ "keep", "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ], "after_edit": [ " tr.@{table-prefix-cls}-expanded-row td > .@{table-prefix-cls}-wrapper {\n" ], "file_path": "components/table/style/size.less", "type": "replace", "edit_start_line_idx": 26 }
@table-padding-vertical-md: @table-padding-vertical * 3 / 4; @table-padding-horizontal-md: @table-padding-horizontal / 2; @table-padding-vertical-sm: @table-padding-vertical / 2; @table-padding-horizontal-sm: @table-padding-horizontal / 2; .@{table-prefix-cls}-middle { > .@{table-prefix-cls}-title, > .@{table-prefix-cls}-footer { padding: @table-padding-vertical-md @table-padding-horizontal-md; } > .@{table-prefix-cls}-content { > .@{table-prefix-cls}-header > table, > .@{table-prefix-cls}-body > table, > .@{table-prefix-cls}-scroll > .@{table-prefix-cls}-header > table, > .@{table-prefix-cls}-scroll > .@{table-prefix-cls}-body > table, > .@{table-prefix-cls}-fixed-left > .@{table-prefix-cls}-header > table, > .@{table-prefix-cls}-fixed-right > .@{table-prefix-cls}-header > table, > .@{table-prefix-cls}-fixed-left > .@{table-prefix-cls}-body-outer > .@{table-prefix-cls}-body-inner > table, > .@{table-prefix-cls}-fixed-right > .@{table-prefix-cls}-body-outer > .@{table-prefix-cls}-body-inner > table { > .@{table-prefix-cls}-thead > tr > th, > .@{table-prefix-cls}-tbody > tr > td { padding: @table-padding-vertical-md @table-padding-horizontal-md; } } } tr.@{table-prefix-cls}-expanded-row .@{table-prefix-cls}-wrapper { margin: -@table-padding-vertical-md -@table-padding-horizontal -@table-padding-vertical-md - 1px; } } .@{table-prefix-cls}-small { border: @border-width-base @border-style-base @border-color-split; border-radius: @border-radius-base; > .@{table-prefix-cls}-title, > .@{table-prefix-cls}-footer { padding: @table-padding-vertical-sm @table-padding-horizontal-sm; } > .@{table-prefix-cls}-title { border-bottom: @border-width-base @border-style-base @border-color-split; top: 0; } > .@{table-prefix-cls}-content { > .@{table-prefix-cls}-body { margin: 0 @table-padding-horizontal-sm; } > .@{table-prefix-cls}-header > table, > .@{table-prefix-cls}-body > table, > .@{table-prefix-cls}-scroll > .@{table-prefix-cls}-header > table, > .@{table-prefix-cls}-scroll > .@{table-prefix-cls}-body > table, > .@{table-prefix-cls}-fixed-left > .@{table-prefix-cls}-header > table, > .@{table-prefix-cls}-fixed-right > .@{table-prefix-cls}-header > table, > .@{table-prefix-cls}-fixed-left > .@{table-prefix-cls}-body-outer > .@{table-prefix-cls}-body-inner > table, > .@{table-prefix-cls}-fixed-right > .@{table-prefix-cls}-body-outer > .@{table-prefix-cls}-body-inner > table { border: 0; > .@{table-prefix-cls}-thead > tr > th, > .@{table-prefix-cls}-tbody > tr > td { padding: @table-padding-vertical-sm @table-padding-horizontal-sm; } > .@{table-prefix-cls}-thead > tr > th { background-color: @component-background; border-bottom: @border-width-base @border-style-base @border-color-split; } > .@{table-prefix-cls}-thead > tr > th.@{table-prefix-cls}-column-sort { background-color: @table-body-sort-bg; } } > .@{table-prefix-cls}-scroll > .@{table-prefix-cls}-header > table, > .@{table-prefix-cls}-scroll > .@{table-prefix-cls}-body > table, > .@{table-prefix-cls}-fixed-left > .@{table-prefix-cls}-header > table, > .@{table-prefix-cls}-fixed-right > .@{table-prefix-cls}-header > table, > .@{table-prefix-cls}-fixed-left > .@{table-prefix-cls}-body-outer > .@{table-prefix-cls}-body-inner > table, > .@{table-prefix-cls}-fixed-right > .@{table-prefix-cls}-body-outer > .@{table-prefix-cls}-body-inner > table { padding: 0; } .@{table-prefix-cls}-header { background-color: @component-background; } .@{table-prefix-cls}-placeholder, .@{table-prefix-cls}-row:last-child td { border-bottom: 0; } } &.@{table-prefix-cls}-bordered { border-right: 0; .@{table-prefix-cls}-title { border: 0; border-bottom: @border-width-base @border-style-base @border-color-split; border-right: @border-width-base @border-style-base @border-color-split; } .@{table-prefix-cls}-content { border-right: @border-width-base @border-style-base @border-color-split; } .@{table-prefix-cls}-footer { border: 0; border-top: @border-width-base @border-style-base @border-color-split; border-right: @border-width-base @border-style-base @border-color-split; &:before { display: none; } } .@{table-prefix-cls}-placeholder { border-left: 0; border-bottom: 0; border-right: 0; } .@{table-prefix-cls}-thead > tr > th:last-child, .@{table-prefix-cls}-tbody > tr > td:last-child { border-right: none; } .@{table-prefix-cls}-fixed-left { .@{table-prefix-cls}-thead > tr > th:last-child, .@{table-prefix-cls}-tbody > tr > td:last-child { border-right: @border-width-base @border-style-base @border-color-split; } } .@{table-prefix-cls}-fixed-right { border-left: @border-width-base @border-style-base @border-color-split; border-right: @border-width-base @border-style-base @border-color-split; } } tr.@{table-prefix-cls}-expanded-row .@{table-prefix-cls}-wrapper { margin: -@table-padding-vertical-sm -@table-padding-horizontal -@table-padding-vertical-sm - 1px; } }
components/table/style/size.less
1
https://github.com/ant-design/ant-design/commit/368468829f8f60280c100e33de9993be54cf120c
[ 0.4461677670478821, 0.030869893729686737, 0.0001756393612595275, 0.00041117137880064547, 0.11100874096155167 ]
{ "id": 1, "code_window": [ " padding: @table-padding-vertical-md @table-padding-horizontal-md;\n", " }\n", " }\n", " }\n", "\n", " tr.@{table-prefix-cls}-expanded-row .@{table-prefix-cls}-wrapper {\n", " margin: -@table-padding-vertical-md -@table-padding-horizontal -@table-padding-vertical-md - 1px;\n", " }\n", "}\n", "\n", ".@{table-prefix-cls}-small {\n" ], "labels": [ "keep", "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ], "after_edit": [ " tr.@{table-prefix-cls}-expanded-row td > .@{table-prefix-cls}-wrapper {\n" ], "file_path": "components/table/style/size.less", "type": "replace", "edit_start_line_idx": 26 }
--- category: Components type: Data Display title: Timeline --- Vertical display timeline. ## When To Use - When a series of information needs to be ordered by time (ascend or descend). - When you need a timeline to make a visual connection. ## API ```jsx <Timeline> <Timeline.Item>step1 2015-09-01</Timeline.Item> <Timeline.Item>step2 2015-09-01</Timeline.Item> <Timeline.Item>step3 2015-09-01</Timeline.Item> <Timeline.Item>step4 2015-09-01</Timeline.Item> </Timeline> ``` ### Timeline Timeline | Property | Description | Type | Default | | -------- | ----------- | ---- | ------- | | pending | Set the last ghost node's existence or its content | boolean\|string\|ReactNode | `false` | | pendingDot | Set the dot of the last ghost node when pending is true | \|string\|ReactNode | `<Icon type="loading" />` | | reverse | reverse nodes or not | boolean | false | | mode | By sending `alternate` the timeline will distribute the nodes to the left and right. | `left` \| `alternate` \| `right` | `left` | ### Timeline.Item Node of timeline | Property | Description | Type | Default | | -------- | ----------- | ---- | ------- | | color | Set the circle's color to `blue`, `red`, `green` or other custom colors | string | `blue` | | dot | Customize timeline dot | string\|ReactNode | - |
components/timeline/index.en-US.md
0
https://github.com/ant-design/ant-design/commit/368468829f8f60280c100e33de9993be54cf120c
[ 0.00017510126053821295, 0.00017171449144370854, 0.00016966598923318088, 0.0001710940123302862, 0.0000018947902162835817 ]
{ "id": 1, "code_window": [ " padding: @table-padding-vertical-md @table-padding-horizontal-md;\n", " }\n", " }\n", " }\n", "\n", " tr.@{table-prefix-cls}-expanded-row .@{table-prefix-cls}-wrapper {\n", " margin: -@table-padding-vertical-md -@table-padding-horizontal -@table-padding-vertical-md - 1px;\n", " }\n", "}\n", "\n", ".@{table-prefix-cls}-small {\n" ], "labels": [ "keep", "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ], "after_edit": [ " tr.@{table-prefix-cls}-expanded-row td > .@{table-prefix-cls}-wrapper {\n" ], "file_path": "components/table/style/size.less", "type": "replace", "edit_start_line_idx": 26 }
import ca_ES from '../../date-picker/locale/ca_ES'; export default ca_ES;
components/calendar/locale/ca_ES.tsx
0
https://github.com/ant-design/ant-design/commit/368468829f8f60280c100e33de9993be54cf120c
[ 0.00017553071666043252, 0.00017553071666043252, 0.00017553071666043252, 0.00017553071666043252, 0 ]
{ "id": 1, "code_window": [ " padding: @table-padding-vertical-md @table-padding-horizontal-md;\n", " }\n", " }\n", " }\n", "\n", " tr.@{table-prefix-cls}-expanded-row .@{table-prefix-cls}-wrapper {\n", " margin: -@table-padding-vertical-md -@table-padding-horizontal -@table-padding-vertical-md - 1px;\n", " }\n", "}\n", "\n", ".@{table-prefix-cls}-small {\n" ], "labels": [ "keep", "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ], "after_edit": [ " tr.@{table-prefix-cls}-expanded-row td > .@{table-prefix-cls}-wrapper {\n" ], "file_path": "components/table/style/size.less", "type": "replace", "edit_start_line_idx": 26 }
/** * Created by Andrey Gayvoronsky on 13/04/16. */ import CalendarLocale from 'rc-calendar/lib/locale/ru_RU'; import TimePickerLocale from '../../time-picker/locale/ru_RU'; const locale = { lang: { placeholder: 'Выберите дату', rangePlaceholder: ['Начальная дата', 'Конечная дата'], ...CalendarLocale, }, timePickerLocale: { ...TimePickerLocale, }, }; // All settings at: // https://github.com/ant-design/ant-design/blob/master/components/date-picker/locale/example.json export default locale;
components/date-picker/locale/ru_RU.tsx
0
https://github.com/ant-design/ant-design/commit/368468829f8f60280c100e33de9993be54cf120c
[ 0.00017365686653647572, 0.00016862161282915622, 0.0001647825411055237, 0.00016742540174163878, 0.0000037203571991994977 ]
{ "id": 2, "code_window": [ " }\n", " }\n", "\n", " tr.@{table-prefix-cls}-expanded-row .@{table-prefix-cls}-wrapper {\n", " margin: -@table-padding-vertical-sm -@table-padding-horizontal -@table-padding-vertical-sm - 1px;\n", " }\n", "}" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep" ], "after_edit": [ " tr.@{table-prefix-cls}-expanded-row td > .@{table-prefix-cls}-wrapper {\n" ], "file_path": "components/table/style/size.less", "type": "replace", "edit_start_line_idx": 137 }
@table-padding-vertical-md: @table-padding-vertical * 3 / 4; @table-padding-horizontal-md: @table-padding-horizontal / 2; @table-padding-vertical-sm: @table-padding-vertical / 2; @table-padding-horizontal-sm: @table-padding-horizontal / 2; .@{table-prefix-cls}-middle { > .@{table-prefix-cls}-title, > .@{table-prefix-cls}-footer { padding: @table-padding-vertical-md @table-padding-horizontal-md; } > .@{table-prefix-cls}-content { > .@{table-prefix-cls}-header > table, > .@{table-prefix-cls}-body > table, > .@{table-prefix-cls}-scroll > .@{table-prefix-cls}-header > table, > .@{table-prefix-cls}-scroll > .@{table-prefix-cls}-body > table, > .@{table-prefix-cls}-fixed-left > .@{table-prefix-cls}-header > table, > .@{table-prefix-cls}-fixed-right > .@{table-prefix-cls}-header > table, > .@{table-prefix-cls}-fixed-left > .@{table-prefix-cls}-body-outer > .@{table-prefix-cls}-body-inner > table, > .@{table-prefix-cls}-fixed-right > .@{table-prefix-cls}-body-outer > .@{table-prefix-cls}-body-inner > table { > .@{table-prefix-cls}-thead > tr > th, > .@{table-prefix-cls}-tbody > tr > td { padding: @table-padding-vertical-md @table-padding-horizontal-md; } } } tr.@{table-prefix-cls}-expanded-row .@{table-prefix-cls}-wrapper { margin: -@table-padding-vertical-md -@table-padding-horizontal -@table-padding-vertical-md - 1px; } } .@{table-prefix-cls}-small { border: @border-width-base @border-style-base @border-color-split; border-radius: @border-radius-base; > .@{table-prefix-cls}-title, > .@{table-prefix-cls}-footer { padding: @table-padding-vertical-sm @table-padding-horizontal-sm; } > .@{table-prefix-cls}-title { border-bottom: @border-width-base @border-style-base @border-color-split; top: 0; } > .@{table-prefix-cls}-content { > .@{table-prefix-cls}-body { margin: 0 @table-padding-horizontal-sm; } > .@{table-prefix-cls}-header > table, > .@{table-prefix-cls}-body > table, > .@{table-prefix-cls}-scroll > .@{table-prefix-cls}-header > table, > .@{table-prefix-cls}-scroll > .@{table-prefix-cls}-body > table, > .@{table-prefix-cls}-fixed-left > .@{table-prefix-cls}-header > table, > .@{table-prefix-cls}-fixed-right > .@{table-prefix-cls}-header > table, > .@{table-prefix-cls}-fixed-left > .@{table-prefix-cls}-body-outer > .@{table-prefix-cls}-body-inner > table, > .@{table-prefix-cls}-fixed-right > .@{table-prefix-cls}-body-outer > .@{table-prefix-cls}-body-inner > table { border: 0; > .@{table-prefix-cls}-thead > tr > th, > .@{table-prefix-cls}-tbody > tr > td { padding: @table-padding-vertical-sm @table-padding-horizontal-sm; } > .@{table-prefix-cls}-thead > tr > th { background-color: @component-background; border-bottom: @border-width-base @border-style-base @border-color-split; } > .@{table-prefix-cls}-thead > tr > th.@{table-prefix-cls}-column-sort { background-color: @table-body-sort-bg; } } > .@{table-prefix-cls}-scroll > .@{table-prefix-cls}-header > table, > .@{table-prefix-cls}-scroll > .@{table-prefix-cls}-body > table, > .@{table-prefix-cls}-fixed-left > .@{table-prefix-cls}-header > table, > .@{table-prefix-cls}-fixed-right > .@{table-prefix-cls}-header > table, > .@{table-prefix-cls}-fixed-left > .@{table-prefix-cls}-body-outer > .@{table-prefix-cls}-body-inner > table, > .@{table-prefix-cls}-fixed-right > .@{table-prefix-cls}-body-outer > .@{table-prefix-cls}-body-inner > table { padding: 0; } .@{table-prefix-cls}-header { background-color: @component-background; } .@{table-prefix-cls}-placeholder, .@{table-prefix-cls}-row:last-child td { border-bottom: 0; } } &.@{table-prefix-cls}-bordered { border-right: 0; .@{table-prefix-cls}-title { border: 0; border-bottom: @border-width-base @border-style-base @border-color-split; border-right: @border-width-base @border-style-base @border-color-split; } .@{table-prefix-cls}-content { border-right: @border-width-base @border-style-base @border-color-split; } .@{table-prefix-cls}-footer { border: 0; border-top: @border-width-base @border-style-base @border-color-split; border-right: @border-width-base @border-style-base @border-color-split; &:before { display: none; } } .@{table-prefix-cls}-placeholder { border-left: 0; border-bottom: 0; border-right: 0; } .@{table-prefix-cls}-thead > tr > th:last-child, .@{table-prefix-cls}-tbody > tr > td:last-child { border-right: none; } .@{table-prefix-cls}-fixed-left { .@{table-prefix-cls}-thead > tr > th:last-child, .@{table-prefix-cls}-tbody > tr > td:last-child { border-right: @border-width-base @border-style-base @border-color-split; } } .@{table-prefix-cls}-fixed-right { border-left: @border-width-base @border-style-base @border-color-split; border-right: @border-width-base @border-style-base @border-color-split; } } tr.@{table-prefix-cls}-expanded-row .@{table-prefix-cls}-wrapper { margin: -@table-padding-vertical-sm -@table-padding-horizontal -@table-padding-vertical-sm - 1px; } }
components/table/style/size.less
1
https://github.com/ant-design/ant-design/commit/368468829f8f60280c100e33de9993be54cf120c
[ 0.794792115688324, 0.05649968236684799, 0.00017699069576337934, 0.0014033092884346843, 0.19741898775100708 ]
{ "id": 2, "code_window": [ " }\n", " }\n", "\n", " tr.@{table-prefix-cls}-expanded-row .@{table-prefix-cls}-wrapper {\n", " margin: -@table-padding-vertical-sm -@table-padding-horizontal -@table-padding-vertical-sm - 1px;\n", " }\n", "}" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep" ], "after_edit": [ " tr.@{table-prefix-cls}-expanded-row td > .@{table-prefix-cls}-wrapper {\n" ], "file_path": "components/table/style/size.less", "type": "replace", "edit_start_line_idx": 137 }
--- order: 0 title: zh-CN: 基本 en-US: Basic --- ## zh-CN 数字输入框。 ## en-US Numeric-only input box. ````jsx import { InputNumber } from 'antd'; function onChange(value) { console.log('changed', value); } ReactDOM.render( <InputNumber min={1} max={10} defaultValue={3} onChange={onChange} />, mountNode); ````
components/input-number/demo/basic.md
0
https://github.com/ant-design/ant-design/commit/368468829f8f60280c100e33de9993be54cf120c
[ 0.00017195330292452127, 0.0001704972964944318, 0.00016836739087011665, 0.00017117119568865746, 0.0000015395446553156944 ]
{ "id": 2, "code_window": [ " }\n", " }\n", "\n", " tr.@{table-prefix-cls}-expanded-row .@{table-prefix-cls}-wrapper {\n", " margin: -@table-padding-vertical-sm -@table-padding-horizontal -@table-padding-vertical-sm - 1px;\n", " }\n", "}" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep" ], "after_edit": [ " tr.@{table-prefix-cls}-expanded-row td > .@{table-prefix-cls}-wrapper {\n" ], "file_path": "components/table/style/size.less", "type": "replace", "edit_start_line_idx": 137 }
import CalendarLocale from 'rc-calendar/lib/locale/zh_CN'; import TimePickerLocale from '../../time-picker/locale/zh_CN'; const locale = { lang: { placeholder: '请选择日期', rangePlaceholder: ['开始日期', '结束日期'], ...CalendarLocale, }, timePickerLocale: { ...TimePickerLocale, }, }; // should add whitespace between char in Button locale.lang.ok = '确 定'; // All settings at: // https://github.com/ant-design/ant-design/blob/master/components/date-picker/locale/example.json export default locale;
components/date-picker/locale/zh_CN.tsx
0
https://github.com/ant-design/ant-design/commit/368468829f8f60280c100e33de9993be54cf120c
[ 0.00017552768986206502, 0.00017251046665478498, 0.00016913442232180387, 0.00017286933143623173, 0.000002622346073621884 ]
{ "id": 2, "code_window": [ " }\n", " }\n", "\n", " tr.@{table-prefix-cls}-expanded-row .@{table-prefix-cls}-wrapper {\n", " margin: -@table-padding-vertical-sm -@table-padding-horizontal -@table-padding-vertical-sm - 1px;\n", " }\n", "}" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep" ], "after_edit": [ " tr.@{table-prefix-cls}-expanded-row td > .@{table-prefix-cls}-wrapper {\n" ], "file_path": "components/table/style/size.less", "type": "replace", "edit_start_line_idx": 137 }
--- order: 3 title: zh-CN: 自动调整位置 en-US: Adjust placement automatically debug: true --- ## zh-CN 气泡框不可见时自动调整位置 ## en-US Adjust popup placement automatically when popup is invisible ````jsx import { Tooltip, Button } from 'antd'; const wrapStyles = { overflow: 'hidden', position: 'relative', padding: '24px', border: '1px solid #e9e9e9', }; ReactDOM.render( <div style={wrapStyles}> <Tooltip placement="left" title="Prompt Text" getPopupContainer={trigger => trigger.parentElement}> <Button>Adjust automatically / 自动调整</Button> </Tooltip> <br /> <Tooltip placement="left" title="Prompt Text" getPopupContainer={trigger => trigger.parentElement} autoAdjustOverflow={false}> <Button>Ingore / 不处理</Button> </Tooltip> </div>, mountNode); ```` <style> .code-box-demo .ant-btn { margin-right: 1em; margin-bottom: 1em; } </style>
components/tooltip/demo/auto-adjust-overflow.md
0
https://github.com/ant-design/ant-design/commit/368468829f8f60280c100e33de9993be54cf120c
[ 0.00017472266335971653, 0.00017200849833898246, 0.00016804774350021034, 0.0001731317606754601, 0.0000025131425900326576 ]
{ "id": 0, "code_window": [ " setPersonName(event.target.value);\n", " };\n", "\n", " return (\n", " <div>\n", " <FormControl sx={{ m: 1, minWidth: 120, maxWidth: 300 }}>\n", " <InputLabel id=\"demo-multiple-name-label\">Name</InputLabel>\n", " <Select\n", " labelId=\"demo-multiple-name-label\"\n", " id=\"demo-multiple-name\"\n", " multiple\n" ], "labels": [ "keep", "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ], "after_edit": [ " <FormControl sx={{ m: 1, width: 300 }}>\n" ], "file_path": "docs/src/pages/components/selects/MultipleSelect.js", "type": "replace", "edit_start_line_idx": 51 }
import * as React from 'react'; import { Theme, useTheme } from '@material-ui/core/styles'; import Box from '@material-ui/core/Box'; import OutlinedInput from '@material-ui/core/OutlinedInput'; import InputLabel from '@material-ui/core/InputLabel'; import MenuItem from '@material-ui/core/MenuItem'; import FormControl from '@material-ui/core/FormControl'; import Select from '@material-ui/core/Select'; import Chip from '@material-ui/core/Chip'; const ITEM_HEIGHT = 48; const ITEM_PADDING_TOP = 8; const MenuProps = { PaperProps: { style: { maxHeight: ITEM_HEIGHT * 4.5 + ITEM_PADDING_TOP, width: 250, }, }, }; const names = [ 'Oliver Hansen', 'Van Henry', 'April Tucker', 'Ralph Hubbard', 'Omar Alexander', 'Carlos Abbott', 'Miriam Wagner', 'Bradley Wilkerson', 'Virginia Andrews', 'Kelly Snyder', ]; function getStyles(name: string, personName: readonly string[], theme: Theme) { return { fontWeight: personName.indexOf(name) === -1 ? theme.typography.fontWeightRegular : theme.typography.fontWeightMedium, }; } export default function MultipleSelectChip() { const theme = useTheme(); const [personName, setPersonName] = React.useState<string[]>([]); const handleChange = (event: React.ChangeEvent<{ value: unknown }>) => { setPersonName(event.target.value as string[]); }; return ( <div> <FormControl sx={{ m: 1, minWidth: 120, maxWidth: 300 }}> <InputLabel id="demo-multiple-chip-label">Chip</InputLabel> <Select labelId="demo-multiple-chip-label" id="demo-multiple-chip" multiple value={personName} onChange={handleChange} input={<OutlinedInput id="select-multiple-chip" label="Chip" />} renderValue={(selected) => ( <Box sx={{ display: 'flex', flexWrap: 'wrap' }}> {selected.map((value) => ( <Chip key={value} label={value} sx={{ m: '2px' }} /> ))} </Box> )} MenuProps={MenuProps} > {names.map((name) => ( <MenuItem key={name} value={name} style={getStyles(name, personName, theme)} > {name} </MenuItem> ))} </Select> </FormControl> </div> ); }
docs/src/pages/components/selects/MultipleSelectChip.tsx
1
https://github.com/mui/material-ui/commit/ae1b29b68f9b1bf021e0fe471e5b8f07c13e71b5
[ 0.02058020606637001, 0.0027184782084077597, 0.00016575577319599688, 0.0001703117450233549, 0.006361453793942928 ]
{ "id": 0, "code_window": [ " setPersonName(event.target.value);\n", " };\n", "\n", " return (\n", " <div>\n", " <FormControl sx={{ m: 1, minWidth: 120, maxWidth: 300 }}>\n", " <InputLabel id=\"demo-multiple-name-label\">Name</InputLabel>\n", " <Select\n", " labelId=\"demo-multiple-name-label\"\n", " id=\"demo-multiple-name\"\n", " multiple\n" ], "labels": [ "keep", "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ], "after_edit": [ " <FormControl sx={{ m: 1, width: 300 }}>\n" ], "file_path": "docs/src/pages/components/selects/MultipleSelect.js", "type": "replace", "edit_start_line_idx": 51 }
import createSvgIcon from './utils/createSvgIcon.js'; import { jsx as _jsx } from "react/jsx-runtime"; export default createSvgIcon( /*#__PURE__*/_jsx("path", { d: "M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.89-2-2-2zm0 16H5V5h14v14zm-9.5-4H11v-1.49h1V12h-1V9H9.5v3H8V9H6.5v4.5h3zm8.7 0-2-3 2-3h-1.7l-2 3 2 3zm-3.7-3V9H13v6h1.5z" }), 'FourKOutlined');
packages/material-ui-icons/lib/FourKOutlined.js
0
https://github.com/mui/material-ui/commit/ae1b29b68f9b1bf021e0fe471e5b8f07c13e71b5
[ 0.00017323992506135255, 0.00017323992506135255, 0.00017323992506135255, 0.00017323992506135255, 0 ]
{ "id": 0, "code_window": [ " setPersonName(event.target.value);\n", " };\n", "\n", " return (\n", " <div>\n", " <FormControl sx={{ m: 1, minWidth: 120, maxWidth: 300 }}>\n", " <InputLabel id=\"demo-multiple-name-label\">Name</InputLabel>\n", " <Select\n", " labelId=\"demo-multiple-name-label\"\n", " id=\"demo-multiple-name\"\n", " multiple\n" ], "labels": [ "keep", "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ], "after_edit": [ " <FormControl sx={{ m: 1, width: 300 }}>\n" ], "file_path": "docs/src/pages/components/selects/MultipleSelect.js", "type": "replace", "edit_start_line_idx": 51 }
import createSvgIcon from './utils/createSvgIcon.js'; import { jsx as _jsx } from "react/jsx-runtime"; export default createSvgIcon( /*#__PURE__*/_jsx("path", { d: "m8.1 13.34 2.83-2.83L3.91 3.5c-1.56 1.56-1.56 4.09 0 5.66l4.19 4.18zm6.78-1.81c1.53.71 3.68.21 5.27-1.38 1.91-1.91 2.28-4.65.81-6.12-1.46-1.46-4.2-1.1-6.12.81-1.59 1.59-2.09 3.74-1.38 5.27L3.7 19.87l1.41 1.41L12 14.41l6.88 6.88 1.41-1.41L13.41 13l1.47-1.47z" }), 'RestaurantMenuSharp');
packages/material-ui-icons/lib/RestaurantMenuSharp.js
0
https://github.com/mui/material-ui/commit/ae1b29b68f9b1bf021e0fe471e5b8f07c13e71b5
[ 0.0001731339143589139, 0.0001731339143589139, 0.0001731339143589139, 0.0001731339143589139, 0 ]
{ "id": 0, "code_window": [ " setPersonName(event.target.value);\n", " };\n", "\n", " return (\n", " <div>\n", " <FormControl sx={{ m: 1, minWidth: 120, maxWidth: 300 }}>\n", " <InputLabel id=\"demo-multiple-name-label\">Name</InputLabel>\n", " <Select\n", " labelId=\"demo-multiple-name-label\"\n", " id=\"demo-multiple-name\"\n", " multiple\n" ], "labels": [ "keep", "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ], "after_edit": [ " <FormControl sx={{ m: 1, width: 300 }}>\n" ], "file_path": "docs/src/pages/components/selects/MultipleSelect.js", "type": "replace", "edit_start_line_idx": 51 }
import { generateUtilityClass, generateUtilityClasses } from '@material-ui/unstyled'; export interface IconButtonClasses { /** Styles applied to the root element. */ root: string; /** Styles applied to the root element if `edge="start"`. */ edgeStart: string; /** Styles applied to the root element if `edge="end"`. */ edgeEnd: string; /** Styles applied to the root element if `color="inherit"`. */ colorInherit: string; /** Styles applied to the root element if `color="primary"`. */ colorPrimary: string; /** Styles applied to the root element if `color="secondary"`. */ colorSecondary: string; /** Pseudo-class applied to the root element if `disabled={true}`. */ disabled: string; /** Styles applied to the root element if `size="small"`. */ sizeSmall: string; /** Styles applied to the children container element. */ label: string; } export type IconButtonClassKey = keyof IconButtonClasses; export function getIconButtonUtilityClass(slot: string): string { return generateUtilityClass('MuiIconButton', slot); } const iconButtonClasses: IconButtonClasses = generateUtilityClasses('MuiIconButton', [ 'root', 'disabled', 'colorInherit', 'colorPrimary', 'colorSecondary', 'edgeStart', 'edgeEnd', 'sizeSmall', 'sizeMedium', 'label', ]); export default iconButtonClasses;
packages/material-ui/src/IconButton/iconButtonClasses.ts
0
https://github.com/mui/material-ui/commit/ae1b29b68f9b1bf021e0fe471e5b8f07c13e71b5
[ 0.0001725616748444736, 0.00016881625924725085, 0.00016583751130383462, 0.0001684478484094143, 0.000002267536501676659 ]
{ "id": 1, "code_window": [ " setPersonName(event.target.value as string[]);\n", " };\n", "\n", " return (\n", " <div>\n", " <FormControl sx={{ m: 1, minWidth: 120, maxWidth: 300 }}>\n", " <InputLabel id=\"demo-multiple-name-label\">Name</InputLabel>\n", " <Select\n", " labelId=\"demo-multiple-name-label\"\n", " id=\"demo-multiple-name\"\n" ], "labels": [ "keep", "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " <FormControl sx={{ m: 1, width: 300 }}>\n" ], "file_path": "docs/src/pages/components/selects/MultipleSelect.tsx", "type": "replace", "edit_start_line_idx": 51 }
import * as React from 'react'; import { useTheme } from '@material-ui/core/styles'; import Box from '@material-ui/core/Box'; import OutlinedInput from '@material-ui/core/OutlinedInput'; import InputLabel from '@material-ui/core/InputLabel'; import MenuItem from '@material-ui/core/MenuItem'; import FormControl from '@material-ui/core/FormControl'; import Select from '@material-ui/core/Select'; import Chip from '@material-ui/core/Chip'; const ITEM_HEIGHT = 48; const ITEM_PADDING_TOP = 8; const MenuProps = { PaperProps: { style: { maxHeight: ITEM_HEIGHT * 4.5 + ITEM_PADDING_TOP, width: 250, }, }, }; const names = [ 'Oliver Hansen', 'Van Henry', 'April Tucker', 'Ralph Hubbard', 'Omar Alexander', 'Carlos Abbott', 'Miriam Wagner', 'Bradley Wilkerson', 'Virginia Andrews', 'Kelly Snyder', ]; function getStyles(name, personName, theme) { return { fontWeight: personName.indexOf(name) === -1 ? theme.typography.fontWeightRegular : theme.typography.fontWeightMedium, }; } export default function MultipleSelectChip() { const theme = useTheme(); const [personName, setPersonName] = React.useState([]); const handleChange = (event) => { setPersonName(event.target.value); }; return ( <div> <FormControl sx={{ m: 1, minWidth: 120, maxWidth: 300 }}> <InputLabel id="demo-multiple-chip-label">Chip</InputLabel> <Select labelId="demo-multiple-chip-label" id="demo-multiple-chip" multiple value={personName} onChange={handleChange} input={<OutlinedInput id="select-multiple-chip" label="Chip" />} renderValue={(selected) => ( <Box sx={{ display: 'flex', flexWrap: 'wrap' }}> {selected.map((value) => ( <Chip key={value} label={value} sx={{ m: '2px' }} /> ))} </Box> )} MenuProps={MenuProps} > {names.map((name) => ( <MenuItem key={name} value={name} style={getStyles(name, personName, theme)} > {name} </MenuItem> ))} </Select> </FormControl> </div> ); }
docs/src/pages/components/selects/MultipleSelectChip.js
1
https://github.com/mui/material-ui/commit/ae1b29b68f9b1bf021e0fe471e5b8f07c13e71b5
[ 0.01323160994797945, 0.0019718788098543882, 0.00016459502512589097, 0.00016767911438364536, 0.004098905716091394 ]
{ "id": 1, "code_window": [ " setPersonName(event.target.value as string[]);\n", " };\n", "\n", " return (\n", " <div>\n", " <FormControl sx={{ m: 1, minWidth: 120, maxWidth: 300 }}>\n", " <InputLabel id=\"demo-multiple-name-label\">Name</InputLabel>\n", " <Select\n", " labelId=\"demo-multiple-name-label\"\n", " id=\"demo-multiple-name\"\n" ], "labels": [ "keep", "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " <FormControl sx={{ m: 1, width: 300 }}>\n" ], "file_path": "docs/src/pages/components/selects/MultipleSelect.tsx", "type": "replace", "edit_start_line_idx": 51 }
import createSvgIcon from './utils/createSvgIcon.js'; import { jsx as _jsx } from "react/jsx-runtime"; export default createSvgIcon( /*#__PURE__*/_jsx("path", { d: "M10.5 15H8v-3h2.5V9.5h3V12H16v3h-2.5v2.5h-3V15zM19 8v11c0 1.1-.9 2-2 2H7c-1.1 0-2-.9-2-2V8c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2zm-2 0H7v11h10V8zm1-5H6v2h12V3z" }), 'MedicationOutlined');
packages/material-ui-icons/lib/MedicationOutlined.js
0
https://github.com/mui/material-ui/commit/ae1b29b68f9b1bf021e0fe471e5b8f07c13e71b5
[ 0.00017248782387468964, 0.00017248782387468964, 0.00017248782387468964, 0.00017248782387468964, 0 ]
{ "id": 1, "code_window": [ " setPersonName(event.target.value as string[]);\n", " };\n", "\n", " return (\n", " <div>\n", " <FormControl sx={{ m: 1, minWidth: 120, maxWidth: 300 }}>\n", " <InputLabel id=\"demo-multiple-name-label\">Name</InputLabel>\n", " <Select\n", " labelId=\"demo-multiple-name-label\"\n", " id=\"demo-multiple-name\"\n" ], "labels": [ "keep", "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " <FormControl sx={{ m: 1, width: 300 }}>\n" ], "file_path": "docs/src/pages/components/selects/MultipleSelect.tsx", "type": "replace", "edit_start_line_idx": 51 }
import createSvgIcon from './utils/createSvgIcon.js'; import { jsx as _jsx } from "react/jsx-runtime"; export default createSvgIcon( /*#__PURE__*/_jsx("path", { d: "M9 11H7v2h2v-2zm4 4h-2v2h2v-2zM9 3H7v2h2V3zm4 8h-2v2h2v-2zM5 3H3v2h2V3zm8 4h-2v2h2V7zm4 4h-2v2h2v-2zm-4-8h-2v2h2V3zm4 0h-2v2h2V3zm2 10h2v-2h-2v2zm0 4h2v-2h-2v2zM5 7H3v2h2V7zm14-4v2h2V3h-2zm0 6h2V7h-2v2zM5 11H3v2h2v-2zM3 21h18v-2H3v2zm2-6H3v2h2v-2z" }), 'BorderBottom');
packages/material-ui-icons/lib/BorderBottom.js
0
https://github.com/mui/material-ui/commit/ae1b29b68f9b1bf021e0fe471e5b8f07c13e71b5
[ 0.00017092966299969703, 0.00017092966299969703, 0.00017092966299969703, 0.00017092966299969703, 0 ]
{ "id": 1, "code_window": [ " setPersonName(event.target.value as string[]);\n", " };\n", "\n", " return (\n", " <div>\n", " <FormControl sx={{ m: 1, minWidth: 120, maxWidth: 300 }}>\n", " <InputLabel id=\"demo-multiple-name-label\">Name</InputLabel>\n", " <Select\n", " labelId=\"demo-multiple-name-label\"\n", " id=\"demo-multiple-name\"\n" ], "labels": [ "keep", "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " <FormControl sx={{ m: 1, width: 300 }}>\n" ], "file_path": "docs/src/pages/components/selects/MultipleSelect.tsx", "type": "replace", "edit_start_line_idx": 51 }
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0z" fill="none"/><path d="M20 2H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zM8 20H4v-4h4v4zm0-6H4v-4h4v4zm0-6H4V4h4v4zm6 12h-4v-4h4v4zm0-6h-4v-4h4v4zm0-6h-4V4h4v4zm6 12h-4v-4h4v4zm0-6h-4v-4h4v4zm0-6h-4V4h4v4z"/></svg>
packages/material-ui-icons/material-icons/grid_on_24px.svg
0
https://github.com/mui/material-ui/commit/ae1b29b68f9b1bf021e0fe471e5b8f07c13e71b5
[ 0.00016791590314824134, 0.00016791590314824134, 0.00016791590314824134, 0.00016791590314824134, 0 ]
{ "id": 2, "code_window": [ "\n", " return (\n", " <div>\n", " <FormControl sx={{ m: 1, minWidth: 120, maxWidth: 300 }}>\n", " <InputLabel id=\"demo-multiple-checkbox-label\">Tag</InputLabel>\n", " <Select\n", " labelId=\"demo-multiple-checkbox-label\"\n", " id=\"demo-multiple-checkbox\"\n" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " <FormControl sx={{ m: 1, width: 300 }}>\n" ], "file_path": "docs/src/pages/components/selects/MultipleSelectCheckmarks.js", "type": "replace", "edit_start_line_idx": 42 }
import * as React from 'react'; import { useTheme } from '@material-ui/core/styles'; import Box from '@material-ui/core/Box'; import OutlinedInput from '@material-ui/core/OutlinedInput'; import InputLabel from '@material-ui/core/InputLabel'; import MenuItem from '@material-ui/core/MenuItem'; import FormControl from '@material-ui/core/FormControl'; import Select from '@material-ui/core/Select'; import Chip from '@material-ui/core/Chip'; const ITEM_HEIGHT = 48; const ITEM_PADDING_TOP = 8; const MenuProps = { PaperProps: { style: { maxHeight: ITEM_HEIGHT * 4.5 + ITEM_PADDING_TOP, width: 250, }, }, }; const names = [ 'Oliver Hansen', 'Van Henry', 'April Tucker', 'Ralph Hubbard', 'Omar Alexander', 'Carlos Abbott', 'Miriam Wagner', 'Bradley Wilkerson', 'Virginia Andrews', 'Kelly Snyder', ]; function getStyles(name, personName, theme) { return { fontWeight: personName.indexOf(name) === -1 ? theme.typography.fontWeightRegular : theme.typography.fontWeightMedium, }; } export default function MultipleSelectChip() { const theme = useTheme(); const [personName, setPersonName] = React.useState([]); const handleChange = (event) => { setPersonName(event.target.value); }; return ( <div> <FormControl sx={{ m: 1, minWidth: 120, maxWidth: 300 }}> <InputLabel id="demo-multiple-chip-label">Chip</InputLabel> <Select labelId="demo-multiple-chip-label" id="demo-multiple-chip" multiple value={personName} onChange={handleChange} input={<OutlinedInput id="select-multiple-chip" label="Chip" />} renderValue={(selected) => ( <Box sx={{ display: 'flex', flexWrap: 'wrap' }}> {selected.map((value) => ( <Chip key={value} label={value} sx={{ m: '2px' }} /> ))} </Box> )} MenuProps={MenuProps} > {names.map((name) => ( <MenuItem key={name} value={name} style={getStyles(name, personName, theme)} > {name} </MenuItem> ))} </Select> </FormControl> </div> ); }
docs/src/pages/components/selects/MultipleSelectChip.js
1
https://github.com/mui/material-ui/commit/ae1b29b68f9b1bf021e0fe471e5b8f07c13e71b5
[ 0.003234736155718565, 0.0005527729517780244, 0.0001669105695327744, 0.00017386827676091343, 0.0009549981914460659 ]
{ "id": 2, "code_window": [ "\n", " return (\n", " <div>\n", " <FormControl sx={{ m: 1, minWidth: 120, maxWidth: 300 }}>\n", " <InputLabel id=\"demo-multiple-checkbox-label\">Tag</InputLabel>\n", " <Select\n", " labelId=\"demo-multiple-checkbox-label\"\n", " id=\"demo-multiple-checkbox\"\n" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " <FormControl sx={{ m: 1, width: 300 }}>\n" ], "file_path": "docs/src/pages/components/selects/MultipleSelectCheckmarks.js", "type": "replace", "edit_start_line_idx": 42 }
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0z" fill="none"/><path d="M11 24h2v-2h-2v2zm-4 0h2v-2H7v2zm8 0h2v-2h-2v2zm2.71-18.29L12 0h-1v7.59L6.41 3 5 4.41 10.59 10 5 15.59 6.41 17 11 12.41V20h1l5.71-5.71-4.3-4.29 4.3-4.29zM13 3.83l1.88 1.88L13 7.59V3.83zm1.88 10.46L13 16.17v-3.76l1.88 1.88z"/></svg>
packages/material-ui-icons/material-icons/settings_bluetooth_24px.svg
0
https://github.com/mui/material-ui/commit/ae1b29b68f9b1bf021e0fe471e5b8f07c13e71b5
[ 0.000172189247678034, 0.000172189247678034, 0.000172189247678034, 0.000172189247678034, 0 ]
{ "id": 2, "code_window": [ "\n", " return (\n", " <div>\n", " <FormControl sx={{ m: 1, minWidth: 120, maxWidth: 300 }}>\n", " <InputLabel id=\"demo-multiple-checkbox-label\">Tag</InputLabel>\n", " <Select\n", " labelId=\"demo-multiple-checkbox-label\"\n", " id=\"demo-multiple-checkbox\"\n" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " <FormControl sx={{ m: 1, width: 300 }}>\n" ], "file_path": "docs/src/pages/components/selects/MultipleSelectCheckmarks.js", "type": "replace", "edit_start_line_idx": 42 }
<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24" viewBox="0 0 24 24" width="24"><g><path d="M0,0h24v24H0V0z" fill="none"/></g><g><g><rect enable-background="new" height="4" opacity=".3" width="4" x="5" y="15"/><rect enable-background="new" height="4" opacity=".3" width="4" x="5" y="5"/><rect enable-background="new" height="4" opacity=".3" width="4" x="15" y="5"/><path d="M3,11h8V3H3V11z M5,5h4v4H5V5z"/><path d="M13,3v8h8V3H13z M19,9h-4V5h4V9z"/><path d="M3,21h8v-8H3V21z M5,15h4v4H5V15z"/><polygon points="18,13 16,13 16,16 13,16 13,18 16,18 16,21 18,21 18,18 21,18 21,16 18,16"/></g></g></svg>
packages/material-ui-icons/material-icons/dashboard_customize_two_tone_24px.svg
0
https://github.com/mui/material-ui/commit/ae1b29b68f9b1bf021e0fe471e5b8f07c13e71b5
[ 0.0001729256910039112, 0.0001729256910039112, 0.0001729256910039112, 0.0001729256910039112, 0 ]
{ "id": 2, "code_window": [ "\n", " return (\n", " <div>\n", " <FormControl sx={{ m: 1, minWidth: 120, maxWidth: 300 }}>\n", " <InputLabel id=\"demo-multiple-checkbox-label\">Tag</InputLabel>\n", " <Select\n", " labelId=\"demo-multiple-checkbox-label\"\n", " id=\"demo-multiple-checkbox\"\n" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " <FormControl sx={{ m: 1, width: 300 }}>\n" ], "file_path": "docs/src/pages/components/selects/MultipleSelectCheckmarks.js", "type": "replace", "edit_start_line_idx": 42 }
import createSvgIcon from './utils/createSvgIcon.js'; import { jsx as _jsx } from "react/jsx-runtime"; export default createSvgIcon( /*#__PURE__*/_jsx("path", { d: "M.31 2c-.39.39-.39 1.02 0 1.41l.69.68V16c0 1.1.9 2 2 2h7v2H9c-.55 0-1 .45-1 1s.45 1 1 1h6c.55 0 1-.45 1-1s-.45-1-1-1h-1v-2h.9l5.29 5.29c.39.39 1.02.39 1.41 0 .39-.39.39-1.02 0-1.41L1.72 2A.9959.9959 0 0 0 .31 2zm2.68 13V6.09L12.9 16H3.99c-.55 0-1-.45-1-1zM4.55 2l2 2H20c.55 0 1 .45 1 1v10c0 .55-.45 1-1 1h-1.45l2 2h.44c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2H4.55z" }), 'DesktopAccessDisabledRounded');
packages/material-ui-icons/lib/DesktopAccessDisabledRounded.js
0
https://github.com/mui/material-ui/commit/ae1b29b68f9b1bf021e0fe471e5b8f07c13e71b5
[ 0.0001672194484854117, 0.0001672194484854117, 0.0001672194484854117, 0.0001672194484854117, 0 ]
{ "id": 3, "code_window": [ " };\n", "\n", " return (\n", " <div>\n", " <FormControl sx={{ m: 1, minWidth: 120, maxWidth: 300 }}>\n", " <InputLabel id=\"demo-multiple-checkbox-label\">Tag</InputLabel>\n", " <Select\n", " labelId=\"demo-multiple-checkbox-label\"\n", " id=\"demo-multiple-checkbox\"\n" ], "labels": [ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " <FormControl sx={{ m: 1, width: 300 }}>\n" ], "file_path": "docs/src/pages/components/selects/MultipleSelectCheckmarks.tsx", "type": "replace", "edit_start_line_idx": 42 }
import * as React from 'react'; import { useTheme } from '@material-ui/core/styles'; import OutlinedInput from '@material-ui/core/OutlinedInput'; import MenuItem from '@material-ui/core/MenuItem'; import FormControl from '@material-ui/core/FormControl'; import Select from '@material-ui/core/Select'; const ITEM_HEIGHT = 48; const ITEM_PADDING_TOP = 8; const MenuProps = { PaperProps: { style: { maxHeight: ITEM_HEIGHT * 4.5 + ITEM_PADDING_TOP, width: 250, }, }, }; const names = [ 'Oliver Hansen', 'Van Henry', 'April Tucker', 'Ralph Hubbard', 'Omar Alexander', 'Carlos Abbott', 'Miriam Wagner', 'Bradley Wilkerson', 'Virginia Andrews', 'Kelly Snyder', ]; function getStyles(name, personName, theme) { return { fontWeight: personName.indexOf(name) === -1 ? theme.typography.fontWeightRegular : theme.typography.fontWeightMedium, }; } export default function MultipleSelectPlaceholder() { const theme = useTheme(); const [personName, setPersonName] = React.useState([]); const handleChange = (event) => { setPersonName(event.target.value); }; return ( <div> <FormControl sx={{ m: 1, minWidth: 120, maxWidth: 300, mt: 3 }}> <Select multiple displayEmpty value={personName} onChange={handleChange} input={<OutlinedInput />} renderValue={(selected) => { if (selected.length === 0) { return <em>Placeholder</em>; } return selected.join(', '); }} MenuProps={MenuProps} inputProps={{ 'aria-label': 'Without label' }} > <MenuItem disabled value=""> <em>Placeholder</em> </MenuItem> {names.map((name) => ( <MenuItem key={name} value={name} style={getStyles(name, personName, theme)} > {name} </MenuItem> ))} </Select> </FormControl> </div> ); }
docs/src/pages/components/selects/MultipleSelectPlaceholder.js
1
https://github.com/mui/material-ui/commit/ae1b29b68f9b1bf021e0fe471e5b8f07c13e71b5
[ 0.00539332116022706, 0.0010450509143993258, 0.00016492826398462057, 0.00017180645954795182, 0.0016732807271182537 ]
{ "id": 3, "code_window": [ " };\n", "\n", " return (\n", " <div>\n", " <FormControl sx={{ m: 1, minWidth: 120, maxWidth: 300 }}>\n", " <InputLabel id=\"demo-multiple-checkbox-label\">Tag</InputLabel>\n", " <Select\n", " labelId=\"demo-multiple-checkbox-label\"\n", " id=\"demo-multiple-checkbox\"\n" ], "labels": [ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " <FormControl sx={{ m: 1, width: 300 }}>\n" ], "file_path": "docs/src/pages/components/selects/MultipleSelectCheckmarks.tsx", "type": "replace", "edit_start_line_idx": 42 }
export { default } from './AlertTitle'; export { default as alertTitleClasses } from './alertTitleClasses'; export * from './alertTitleClasses';
packages/material-ui/src/AlertTitle/index.js
0
https://github.com/mui/material-ui/commit/ae1b29b68f9b1bf021e0fe471e5b8f07c13e71b5
[ 0.00017446013225708157, 0.00017446013225708157, 0.00017446013225708157, 0.00017446013225708157, 0 ]
{ "id": 3, "code_window": [ " };\n", "\n", " return (\n", " <div>\n", " <FormControl sx={{ m: 1, minWidth: 120, maxWidth: 300 }}>\n", " <InputLabel id=\"demo-multiple-checkbox-label\">Tag</InputLabel>\n", " <Select\n", " labelId=\"demo-multiple-checkbox-label\"\n", " id=\"demo-multiple-checkbox\"\n" ], "labels": [ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " <FormControl sx={{ m: 1, width: 300 }}>\n" ], "file_path": "docs/src/pages/components/selects/MultipleSelectCheckmarks.tsx", "type": "replace", "edit_start_line_idx": 42 }
{ "componentDescription": "", "propDescriptions": { "children": "The content of the component.", "classes": "Override or extend the styles applied to the component. See <a href=\"#css\">CSS API</a> below for more details." }, "classDescriptions": { "root": { "description": "Styles applied to the root element." } } }
docs/translations/api-docs/dialog-content-text/dialog-content-text-ja.json
0
https://github.com/mui/material-ui/commit/ae1b29b68f9b1bf021e0fe471e5b8f07c13e71b5
[ 0.00017155813111457974, 0.00016835483256727457, 0.00016515154857188463, 0.00016835483256727457, 0.0000032032912713475525 ]
{ "id": 3, "code_window": [ " };\n", "\n", " return (\n", " <div>\n", " <FormControl sx={{ m: 1, minWidth: 120, maxWidth: 300 }}>\n", " <InputLabel id=\"demo-multiple-checkbox-label\">Tag</InputLabel>\n", " <Select\n", " labelId=\"demo-multiple-checkbox-label\"\n", " id=\"demo-multiple-checkbox\"\n" ], "labels": [ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " <FormControl sx={{ m: 1, width: 300 }}>\n" ], "file_path": "docs/src/pages/components/selects/MultipleSelectCheckmarks.tsx", "type": "replace", "edit_start_line_idx": 42 }
# Localization <p class="description">Localization (also referred to as "l10n") is the process of adapting a product or content to a specific locale or market.</p> The default locale of Material-UI is English (United States). If you want to use other locales, follow the instructions below. ## Locale text Use the theme to configure the locale text globally: ```jsx import { createTheme, ThemeProvider } from '@material-ui/core/styles'; import { zhCN } from '@material-ui/core/locale'; const theme = createTheme({ palette: { primary: { main: '#1976d2' }, }, }, zhCN); <ThemeProvider theme={theme}> <App /> </ThemeProvider> ``` ### 例 {{"demo": "pages/guides/localization/Locales.js", "defaultCodeOpen": false}} ### Supported locales | Locale | BCP 47 language tag | Import name | |:----------------------- |:------------------- |:----------- | | Arabic (Egypt) | ar-EG | `arEG` | | Armenian | hy-AM | `hyAM` | | Azerbaijani | az-AZ | `azAZ` | | Bulgarian | bg-BG | `bgBG` | | Catalan | ca-ES | `caES` | | Chinese (Simplified) | zh-CN | `zhCN` | | Czech | cs-CZ | `csCZ` | | Dutch | nl-NL | `nlNL` | | English (United States) | en-US | `enUS` | | Estonian | et-EE | `etEE` | | Finnish | fi-FI | `fiFI` | | French | fr-FR | `frFR` | | German | de-DE | `deDE` | | Greek | el-GR | `elGR` | | Hebrew | he-IL | `heIL` | | Hindi | hi-IN | `hiIN` | | Hungarian | hu-HU | `huHU` | | Icelandic | is-IS | `isIS` | | Indonesian | id-ID | `idID` | | Italian | it-IT | `itIT` | | Japanese | ja-JP | `jaJP` | | Kazakh | kz-KZ | `kzKZ` | | Korean | ko-KR | `koKR` | | Persian | fa-IR | `faIR` | | Polish | pl-PL | `plPL` | | Portuguese (Brazil) | pt-BR | `ptBR` | | Portuguese | pt-PT | `ptPT` | | Romanian | ro-RO | `roRO` | | Russian | ru-RU | `ruRU` | | Slovak | sk-SK | `skSK` | | Spanish | es-ES | `esES` | | Swedish | sv-SE | `svSE` | | Turkish | tr-TR | `trTR` | | Thai | th-TH | `thTH` | | Ukrainian | uk-UA | `ukUA` | | Vietnamese | vi-VN | `viVN` | <!-- #default-branch-switch --> You can [find the source](https://github.com/mui-org/material-ui/blob/next/packages/material-ui/src/locale/index.ts) in the GitHub repository. To create your own translation, or to customise the English text, copy this file to your project, make any changes needed and import the locale from there. Please do consider contributing new translations back to Material-UI by opening a pull request. However, Material-UI aims to support the [100 most common](https://en.wikipedia.org/wiki/List_of_languages_by_number_of_native_speakers) [locales](https://www.ethnologue.com/guides/ethnologue200), we might not accept contributions for locales that are not frequently used, for instance `gl-ES` that has "only" 2.5 million native speakers. ## RTL Support Right-to-left languages such as Arabic, Persian or Hebrew are supported. Follow [this guide](/guides/right-to-left/) to use them.
docs/src/pages/guides/localization/localization-ja.md
0
https://github.com/mui/material-ui/commit/ae1b29b68f9b1bf021e0fe471e5b8f07c13e71b5
[ 0.0001740485749905929, 0.0001700406864983961, 0.00016645394498482347, 0.00016945599054452032, 0.000002807673581628478 ]
{ "id": 4, "code_window": [ " };\n", "\n", " return (\n", " <div>\n", " <FormControl sx={{ m: 1, minWidth: 120, maxWidth: 300 }}>\n", " <InputLabel id=\"demo-multiple-chip-label\">Chip</InputLabel>\n", " <Select\n", " labelId=\"demo-multiple-chip-label\"\n", " id=\"demo-multiple-chip\"\n" ], "labels": [ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " <FormControl sx={{ m: 1, width: 300 }}>\n" ], "file_path": "docs/src/pages/components/selects/MultipleSelectChip.js", "type": "replace", "edit_start_line_idx": 53 }
import * as React from 'react'; import { Theme, useTheme } from '@material-ui/core/styles'; import Box from '@material-ui/core/Box'; import OutlinedInput from '@material-ui/core/OutlinedInput'; import InputLabel from '@material-ui/core/InputLabel'; import MenuItem from '@material-ui/core/MenuItem'; import FormControl from '@material-ui/core/FormControl'; import Select from '@material-ui/core/Select'; import Chip from '@material-ui/core/Chip'; const ITEM_HEIGHT = 48; const ITEM_PADDING_TOP = 8; const MenuProps = { PaperProps: { style: { maxHeight: ITEM_HEIGHT * 4.5 + ITEM_PADDING_TOP, width: 250, }, }, }; const names = [ 'Oliver Hansen', 'Van Henry', 'April Tucker', 'Ralph Hubbard', 'Omar Alexander', 'Carlos Abbott', 'Miriam Wagner', 'Bradley Wilkerson', 'Virginia Andrews', 'Kelly Snyder', ]; function getStyles(name: string, personName: readonly string[], theme: Theme) { return { fontWeight: personName.indexOf(name) === -1 ? theme.typography.fontWeightRegular : theme.typography.fontWeightMedium, }; } export default function MultipleSelectChip() { const theme = useTheme(); const [personName, setPersonName] = React.useState<string[]>([]); const handleChange = (event: React.ChangeEvent<{ value: unknown }>) => { setPersonName(event.target.value as string[]); }; return ( <div> <FormControl sx={{ m: 1, minWidth: 120, maxWidth: 300 }}> <InputLabel id="demo-multiple-chip-label">Chip</InputLabel> <Select labelId="demo-multiple-chip-label" id="demo-multiple-chip" multiple value={personName} onChange={handleChange} input={<OutlinedInput id="select-multiple-chip" label="Chip" />} renderValue={(selected) => ( <Box sx={{ display: 'flex', flexWrap: 'wrap' }}> {selected.map((value) => ( <Chip key={value} label={value} sx={{ m: '2px' }} /> ))} </Box> )} MenuProps={MenuProps} > {names.map((name) => ( <MenuItem key={name} value={name} style={getStyles(name, personName, theme)} > {name} </MenuItem> ))} </Select> </FormControl> </div> ); }
docs/src/pages/components/selects/MultipleSelectChip.tsx
1
https://github.com/mui/material-ui/commit/ae1b29b68f9b1bf021e0fe471e5b8f07c13e71b5
[ 0.9970344305038452, 0.11159680783748627, 0.00016562514065299183, 0.00026382424402981997, 0.313052237033844 ]
{ "id": 4, "code_window": [ " };\n", "\n", " return (\n", " <div>\n", " <FormControl sx={{ m: 1, minWidth: 120, maxWidth: 300 }}>\n", " <InputLabel id=\"demo-multiple-chip-label\">Chip</InputLabel>\n", " <Select\n", " labelId=\"demo-multiple-chip-label\"\n", " id=\"demo-multiple-chip\"\n" ], "labels": [ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " <FormControl sx={{ m: 1, width: 300 }}>\n" ], "file_path": "docs/src/pages/components/selects/MultipleSelectChip.js", "type": "replace", "edit_start_line_idx": 53 }
import createSvgIcon from './utils/createSvgIcon.js'; import { jsx as _jsx } from "react/jsx-runtime"; export default createSvgIcon( /*#__PURE__*/_jsx("path", { d: "M10.5 7.67V3.5c0-.83.67-1.5 1.5-1.5s1.5.67 1.5 1.5V9l8.5 5v2l-4.49-1.32-7.01-7.01zm9.28 14.94 1.41-1.41-7.69-7.7-3.94-3.94-6.75-6.75-1.42 1.41 6.38 6.38L2 14v2l8.5-2.5V19L8 20.5V22l4-1 4 1v-1.5L13.5 19v-2.67l6.28 6.28z" }), 'AirplanemodeInactiveOutlined');
packages/material-ui-icons/lib/AirplanemodeInactiveOutlined.js
0
https://github.com/mui/material-ui/commit/ae1b29b68f9b1bf021e0fe471e5b8f07c13e71b5
[ 0.0001761443418217823, 0.0001761443418217823, 0.0001761443418217823, 0.0001761443418217823, 0 ]
{ "id": 4, "code_window": [ " };\n", "\n", " return (\n", " <div>\n", " <FormControl sx={{ m: 1, minWidth: 120, maxWidth: 300 }}>\n", " <InputLabel id=\"demo-multiple-chip-label\">Chip</InputLabel>\n", " <Select\n", " labelId=\"demo-multiple-chip-label\"\n", " id=\"demo-multiple-chip\"\n" ], "labels": [ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " <FormControl sx={{ m: 1, width: 300 }}>\n" ], "file_path": "docs/src/pages/components/selects/MultipleSelectChip.js", "type": "replace", "edit_start_line_idx": 53 }
<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24" viewBox="0 0 24 24" width="24"><g><path d="M0,0h24v24H0V0z" fill="none"/></g><g><g><path d="M6,13c0-1.65,0.67-3.15,1.76-4.24L6.34,7.34C4.9,8.79,4,10.79,4,13c0,4.08,3.05,7.44,7,7.93v-2.02 C8.17,18.43,6,15.97,6,13z M20,13c0-4.42-3.58-8-8-8c-0.06,0-0.12,0.01-0.18,0.01l1.09-1.09L11.5,2.5L8,6l3.5,3.5l1.41-1.41 l-1.08-1.08C11.89,7.01,11.95,7,12,7c3.31,0,6,2.69,6,6c0,2.97-2.17,5.43-5,5.91v2.02C16.95,20.44,20,17.08,20,13z"/></g></g></svg>
packages/material-ui-icons/material-icons/restart_alt_outlined_24px.svg
0
https://github.com/mui/material-ui/commit/ae1b29b68f9b1bf021e0fe471e5b8f07c13e71b5
[ 0.0001696846156846732, 0.0001696846156846732, 0.0001696846156846732, 0.0001696846156846732, 0 ]
{ "id": 4, "code_window": [ " };\n", "\n", " return (\n", " <div>\n", " <FormControl sx={{ m: 1, minWidth: 120, maxWidth: 300 }}>\n", " <InputLabel id=\"demo-multiple-chip-label\">Chip</InputLabel>\n", " <Select\n", " labelId=\"demo-multiple-chip-label\"\n", " id=\"demo-multiple-chip\"\n" ], "labels": [ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " <FormControl sx={{ m: 1, width: 300 }}>\n" ], "file_path": "docs/src/pages/components/selects/MultipleSelectChip.js", "type": "replace", "edit_start_line_idx": 53 }
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M17 7H7V4H5v16h14V4h-2z" opacity=".3"/><path d="M19 2h-4.18C14.4.84 13.3 0 12 0S9.6.84 9.18 2H5c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-7 0c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm7 18H5V4h2v3h10V4h2v16z"/></svg>
packages/material-ui-icons/material-icons/content_paste_two_tone_24px.svg
0
https://github.com/mui/material-ui/commit/ae1b29b68f9b1bf021e0fe471e5b8f07c13e71b5
[ 0.00017100073455367237, 0.00017100073455367237, 0.00017100073455367237, 0.00017100073455367237, 0 ]
{ "id": 5, "code_window": [ " };\n", "\n", " return (\n", " <div>\n", " <FormControl sx={{ m: 1, minWidth: 120, maxWidth: 300 }}>\n", " <InputLabel id=\"demo-multiple-chip-label\">Chip</InputLabel>\n", " <Select\n", " labelId=\"demo-multiple-chip-label\"\n", " id=\"demo-multiple-chip\"\n" ], "labels": [ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " <FormControl sx={{ m: 1, width: 300 }}>\n" ], "file_path": "docs/src/pages/components/selects/MultipleSelectChip.tsx", "type": "replace", "edit_start_line_idx": 53 }
import * as React from 'react'; import { useTheme } from '@material-ui/core/styles'; import OutlinedInput from '@material-ui/core/OutlinedInput'; import MenuItem from '@material-ui/core/MenuItem'; import FormControl from '@material-ui/core/FormControl'; import Select from '@material-ui/core/Select'; const ITEM_HEIGHT = 48; const ITEM_PADDING_TOP = 8; const MenuProps = { PaperProps: { style: { maxHeight: ITEM_HEIGHT * 4.5 + ITEM_PADDING_TOP, width: 250, }, }, }; const names = [ 'Oliver Hansen', 'Van Henry', 'April Tucker', 'Ralph Hubbard', 'Omar Alexander', 'Carlos Abbott', 'Miriam Wagner', 'Bradley Wilkerson', 'Virginia Andrews', 'Kelly Snyder', ]; function getStyles(name, personName, theme) { return { fontWeight: personName.indexOf(name) === -1 ? theme.typography.fontWeightRegular : theme.typography.fontWeightMedium, }; } export default function MultipleSelectPlaceholder() { const theme = useTheme(); const [personName, setPersonName] = React.useState([]); const handleChange = (event) => { setPersonName(event.target.value); }; return ( <div> <FormControl sx={{ m: 1, minWidth: 120, maxWidth: 300, mt: 3 }}> <Select multiple displayEmpty value={personName} onChange={handleChange} input={<OutlinedInput />} renderValue={(selected) => { if (selected.length === 0) { return <em>Placeholder</em>; } return selected.join(', '); }} MenuProps={MenuProps} inputProps={{ 'aria-label': 'Without label' }} > <MenuItem disabled value=""> <em>Placeholder</em> </MenuItem> {names.map((name) => ( <MenuItem key={name} value={name} style={getStyles(name, personName, theme)} > {name} </MenuItem> ))} </Select> </FormControl> </div> ); }
docs/src/pages/components/selects/MultipleSelectPlaceholder.js
1
https://github.com/mui/material-ui/commit/ae1b29b68f9b1bf021e0fe471e5b8f07c13e71b5
[ 0.007086047902703285, 0.001235962612554431, 0.00016396782302763313, 0.00017162291624117643, 0.002210126956924796 ]
{ "id": 5, "code_window": [ " };\n", "\n", " return (\n", " <div>\n", " <FormControl sx={{ m: 1, minWidth: 120, maxWidth: 300 }}>\n", " <InputLabel id=\"demo-multiple-chip-label\">Chip</InputLabel>\n", " <Select\n", " labelId=\"demo-multiple-chip-label\"\n", " id=\"demo-multiple-chip\"\n" ], "labels": [ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " <FormControl sx={{ m: 1, width: 300 }}>\n" ], "file_path": "docs/src/pages/components/selects/MultipleSelectChip.tsx", "type": "replace", "edit_start_line_idx": 53 }
<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24" viewBox="0 0 24 24" width="24"><g><rect fill="none" height="24" width="24"/></g><g><g><path d="M5,19h14V5H5V19z M18,13.5V16c0,0.55-0.45,1-1,1h-2v1.5h-1.5v-6H17C17.55,12.5,18,12.95,18,13.5z M13,9 c0-0.55,0.45-1,1-1h2V7h-3V5.5h3.5c0.55,0,1,0.45,1,1V8c0,0.55-0.45,1-1,1h-2v1h3v1.5H13V9z M6.5,9c0-0.55,0.45-1,1-1h2V7h-3V5.5 H10c0.55,0,1,0.45,1,1V8c0,0.55-0.45,1-1,1H8v1h3v1.5H6.5V9z M6,13.5c0-0.55,0.45-1,1-1h4.5c0.55,0,1,0.45,1,1v5H11V14h-1v3H8.5 v-3h-1v4.5H6V13.5z" opacity=".3"/><rect height="1.5" opacity=".3" width="1.5" x="15" y="14"/><path d="M7.5,14h1v3H10v-3h1v4.5h1.5v-5c0-0.55-0.45-1-1-1H7c-0.55,0-1,0.45-1,1v5h1.5V14z"/><path d="M13.5,12.5v6H15V17h2c0.55,0,1-0.45,1-1v-2.5c0-0.55-0.45-1-1-1H13.5z M16.5,15.5H15V14h1.5V15.5z"/><path d="M19,3H5C3.9,3,3,3.9,3,5v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5C21,3.9,20.1,3,19,3z M19,19H5V5h14V19z"/><path d="M11,10H8V9h2c0.55,0,1-0.45,1-1V6.5c0-0.55-0.45-1-1-1H6.5V7h3v1h-2c-0.55,0-1,0.45-1,1v2.5H11V10z"/><path d="M17.5,10h-3V9h2c0.55,0,1-0.45,1-1V6.5c0-0.55-0.45-1-1-1H13V7h3v1h-2c-0.55,0-1,0.45-1,1v2.5h4.5V10z"/></g></g></svg>
packages/material-ui-icons/material-icons/22mp_two_tone_24px.svg
0
https://github.com/mui/material-ui/commit/ae1b29b68f9b1bf021e0fe471e5b8f07c13e71b5
[ 0.00020229854271747172, 0.00020229854271747172, 0.00020229854271747172, 0.00020229854271747172, 0 ]
{ "id": 5, "code_window": [ " };\n", "\n", " return (\n", " <div>\n", " <FormControl sx={{ m: 1, minWidth: 120, maxWidth: 300 }}>\n", " <InputLabel id=\"demo-multiple-chip-label\">Chip</InputLabel>\n", " <Select\n", " labelId=\"demo-multiple-chip-label\"\n", " id=\"demo-multiple-chip\"\n" ], "labels": [ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " <FormControl sx={{ m: 1, width: 300 }}>\n" ], "file_path": "docs/src/pages/components/selects/MultipleSelectChip.tsx", "type": "replace", "edit_start_line_idx": 53 }
<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24" viewBox="0 0 24 24" width="24"><g><path d="M0,0h24v24H0V0z" fill="none"/></g><g><path d="M19,19V5c0-1.1-0.9-2-2-2H7C5.9,3,5,3.9,5,5v14H3v2h18v-2H19z M17,19H7V5h10V19z M13,11h2v2h-2V11z"/></g></svg>
packages/material-ui-icons/material-icons/door_front_outlined_24px.svg
0
https://github.com/mui/material-ui/commit/ae1b29b68f9b1bf021e0fe471e5b8f07c13e71b5
[ 0.0001737096899887547, 0.0001737096899887547, 0.0001737096899887547, 0.0001737096899887547, 0 ]
{ "id": 5, "code_window": [ " };\n", "\n", " return (\n", " <div>\n", " <FormControl sx={{ m: 1, minWidth: 120, maxWidth: 300 }}>\n", " <InputLabel id=\"demo-multiple-chip-label\">Chip</InputLabel>\n", " <Select\n", " labelId=\"demo-multiple-chip-label\"\n", " id=\"demo-multiple-chip\"\n" ], "labels": [ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " <FormControl sx={{ m: 1, width: 300 }}>\n" ], "file_path": "docs/src/pages/components/selects/MultipleSelectChip.tsx", "type": "replace", "edit_start_line_idx": 53 }
import createSvgIcon from './utils/createSvgIcon.js'; import { jsx as _jsx } from "react/jsx-runtime"; export default createSvgIcon( /*#__PURE__*/_jsx("path", { d: "M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM8.5 8c.83 0 1.5.67 1.5 1.5S9.33 11 8.5 11 7 10.33 7 9.5 7.67 8 8.5 8zM12 18c-2.28 0-4.22-1.66-5-4h10c-.78 2.34-2.72 4-5 4zm3.5-7c-.83 0-1.5-.67-1.5-1.5S14.67 8 15.5 8s1.5.67 1.5 1.5-.67 1.5-1.5 1.5z" }), 'EmojiEmotionsSharp');
packages/material-ui-icons/lib/EmojiEmotionsSharp.js
0
https://github.com/mui/material-ui/commit/ae1b29b68f9b1bf021e0fe471e5b8f07c13e71b5
[ 0.00017554560326971114, 0.00017554560326971114, 0.00017554560326971114, 0.00017554560326971114, 0 ]
{ "id": 6, "code_window": [ "\n", " return (\n", " <div>\n", " <FormControl sx={{ m: 1, minWidth: 120, maxWidth: 300, mt: 3 }}>\n", " <Select\n", " multiple\n", " displayEmpty\n" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep" ], "after_edit": [ " <FormControl sx={{ m: 1, width: 300, mt: 3 }}>\n" ], "file_path": "docs/src/pages/components/selects/MultipleSelectPlaceholder.js", "type": "replace", "edit_start_line_idx": 50 }
import * as React from 'react'; import { Theme, useTheme } from '@material-ui/core/styles'; import OutlinedInput from '@material-ui/core/OutlinedInput'; import InputLabel from '@material-ui/core/InputLabel'; import MenuItem from '@material-ui/core/MenuItem'; import FormControl from '@material-ui/core/FormControl'; import Select from '@material-ui/core/Select'; const ITEM_HEIGHT = 48; const ITEM_PADDING_TOP = 8; const MenuProps = { PaperProps: { style: { maxHeight: ITEM_HEIGHT * 4.5 + ITEM_PADDING_TOP, width: 250, }, }, }; const names = [ 'Oliver Hansen', 'Van Henry', 'April Tucker', 'Ralph Hubbard', 'Omar Alexander', 'Carlos Abbott', 'Miriam Wagner', 'Bradley Wilkerson', 'Virginia Andrews', 'Kelly Snyder', ]; function getStyles(name: string, personName: string[], theme: Theme) { return { fontWeight: personName.indexOf(name) === -1 ? theme.typography.fontWeightRegular : theme.typography.fontWeightMedium, }; } export default function MultipleSelect() { const theme = useTheme(); const [personName, setPersonName] = React.useState<string[]>([]); const handleChange = (event: React.ChangeEvent<{ value: unknown }>) => { setPersonName(event.target.value as string[]); }; return ( <div> <FormControl sx={{ m: 1, minWidth: 120, maxWidth: 300 }}> <InputLabel id="demo-multiple-name-label">Name</InputLabel> <Select labelId="demo-multiple-name-label" id="demo-multiple-name" multiple value={personName} onChange={handleChange} input={<OutlinedInput label="Name" />} MenuProps={MenuProps} > {names.map((name) => ( <MenuItem key={name} value={name} style={getStyles(name, personName, theme)} > {name} </MenuItem> ))} </Select> </FormControl> </div> ); }
docs/src/pages/components/selects/MultipleSelect.tsx
1
https://github.com/mui/material-ui/commit/ae1b29b68f9b1bf021e0fe471e5b8f07c13e71b5
[ 0.0026097092777490616, 0.0005803632084280252, 0.0001667867909418419, 0.00017410235886927694, 0.0008096093079075217 ]
{ "id": 6, "code_window": [ "\n", " return (\n", " <div>\n", " <FormControl sx={{ m: 1, minWidth: 120, maxWidth: 300, mt: 3 }}>\n", " <Select\n", " multiple\n", " displayEmpty\n" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep" ], "after_edit": [ " <FormControl sx={{ m: 1, width: 300, mt: 3 }}>\n" ], "file_path": "docs/src/pages/components/selects/MultipleSelectPlaceholder.js", "type": "replace", "edit_start_line_idx": 50 }
<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24" viewBox="0 0 24 24" width="24"><g><path d="M0,0h24v24H0V0z" fill="none"/></g><g><g><path d="M16.23,7h2.6c-0.06-0.47-0.36-0.94-0.79-1.17L11.4,2.45c-0.56-0.29-1.23-0.29-1.8-0.01L2.8,5.83C2.32,6.09,2,6.64,2,7.17 V15c0,1.1,0.9,2,2,2V7.4L10.5,4L16.23,7z"/><path d="M20,8H7c-1.1,0-2,0.9-2,2v9c0,1.1,0.9,2,2,2h13c1.1,0,2-0.9,2-2v-9C22,8.9,21.1,8,20,8z M20,11.46 c0,0.33-0.19,0.64-0.48,0.79l-5.61,2.88c-0.25,0.13-0.56,0.13-0.81,0l-5.61-2.88C7.19,12.1,7,11.79,7,11.46v0 c0-0.67,0.7-1.1,1.3-0.79l5.2,2.67l5.2-2.67C19.3,10.36,20,10.79,20,11.46L20,11.46z"/></g></g></svg>
packages/material-ui-icons/material-icons/mark_as_unread_rounded_24px.svg
0
https://github.com/mui/material-ui/commit/ae1b29b68f9b1bf021e0fe471e5b8f07c13e71b5
[ 0.00017346256936434656, 0.00017346256936434656, 0.00017346256936434656, 0.00017346256936434656, 0 ]
{ "id": 6, "code_window": [ "\n", " return (\n", " <div>\n", " <FormControl sx={{ m: 1, minWidth: 120, maxWidth: 300, mt: 3 }}>\n", " <Select\n", " multiple\n", " displayEmpty\n" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep" ], "after_edit": [ " <FormControl sx={{ m: 1, width: 300, mt: 3 }}>\n" ], "file_path": "docs/src/pages/components/selects/MultipleSelectPlaceholder.js", "type": "replace", "edit_start_line_idx": 50 }
import createSvgIcon from './utils/createSvgIcon.js'; import { jsx as _jsx } from "react/jsx-runtime"; export default createSvgIcon([/*#__PURE__*/_jsx("circle", { cx: "4.5", cy: "9.5", r: "2.5" }, "0"), /*#__PURE__*/_jsx("circle", { cx: "9", cy: "5.5", r: "2.5" }, "1"), /*#__PURE__*/_jsx("circle", { cx: "15", cy: "5.5", r: "2.5" }, "2"), /*#__PURE__*/_jsx("circle", { cx: "19.5", cy: "9.5", r: "2.5" }, "3"), /*#__PURE__*/_jsx("path", { d: "M17.34 14.86c-.87-1.02-1.6-1.89-2.48-2.91-.46-.54-1.05-1.08-1.75-1.32-.11-.04-.22-.07-.33-.09-.25-.04-.52-.04-.78-.04s-.53 0-.79.05c-.11.02-.22.05-.33.09-.7.24-1.28.78-1.75 1.32-.87 1.02-1.6 1.89-2.48 2.91-1.31 1.31-2.92 2.76-2.62 4.79.29 1.02 1.02 2.03 2.33 2.32.73.15 3.06-.44 5.54-.44h.18c2.48 0 4.81.58 5.54.44 1.31-.29 2.04-1.31 2.33-2.32.31-2.04-1.3-3.49-2.61-4.8z" }, "4")], 'PetsRounded');
packages/material-ui-icons/lib/PetsRounded.js
0
https://github.com/mui/material-ui/commit/ae1b29b68f9b1bf021e0fe471e5b8f07c13e71b5
[ 0.00017516656953375787, 0.0001723926980048418, 0.0001696542021818459, 0.0001723572931950912, 0.0000022505537344841287 ]
{ "id": 6, "code_window": [ "\n", " return (\n", " <div>\n", " <FormControl sx={{ m: 1, minWidth: 120, maxWidth: 300, mt: 3 }}>\n", " <Select\n", " multiple\n", " displayEmpty\n" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep" ], "after_edit": [ " <FormControl sx={{ m: 1, width: 300, mt: 3 }}>\n" ], "file_path": "docs/src/pages/components/selects/MultipleSelectPlaceholder.js", "type": "replace", "edit_start_line_idx": 50 }
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0z" fill="none"/><path d="M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"/></svg>
packages/material-ui-icons/material-icons/expand_more_24px.svg
0
https://github.com/mui/material-ui/commit/ae1b29b68f9b1bf021e0fe471e5b8f07c13e71b5
[ 0.00017164387099910527, 0.00017164387099910527, 0.00017164387099910527, 0.00017164387099910527, 0 ]
{ "id": 7, "code_window": [ "\n", " return (\n", " <div>\n", " <FormControl sx={{ m: 1, minWidth: 120, maxWidth: 300, mt: 3 }}>\n", " <Select\n", " multiple\n", " displayEmpty\n", " value={personName}\n" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " <FormControl sx={{ m: 1, width: 300, mt: 3 }}>\n" ], "file_path": "docs/src/pages/components/selects/MultipleSelectPlaceholder.tsx", "type": "replace", "edit_start_line_idx": 50 }
import * as React from 'react'; import OutlinedInput from '@material-ui/core/OutlinedInput'; import InputLabel from '@material-ui/core/InputLabel'; import MenuItem from '@material-ui/core/MenuItem'; import FormControl from '@material-ui/core/FormControl'; import ListItemText from '@material-ui/core/ListItemText'; import Select from '@material-ui/core/Select'; import Checkbox from '@material-ui/core/Checkbox'; const ITEM_HEIGHT = 48; const ITEM_PADDING_TOP = 8; const MenuProps = { PaperProps: { style: { maxHeight: ITEM_HEIGHT * 4.5 + ITEM_PADDING_TOP, width: 250, }, }, }; const names = [ 'Oliver Hansen', 'Van Henry', 'April Tucker', 'Ralph Hubbard', 'Omar Alexander', 'Carlos Abbott', 'Miriam Wagner', 'Bradley Wilkerson', 'Virginia Andrews', 'Kelly Snyder', ]; export default function MultipleSelectCheckmarks() { const [personName, setPersonName] = React.useState<string[]>([]); const handleChange = (event: React.ChangeEvent<{ value: unknown }>) => { setPersonName(event.target.value as string[]); }; return ( <div> <FormControl sx={{ m: 1, minWidth: 120, maxWidth: 300 }}> <InputLabel id="demo-multiple-checkbox-label">Tag</InputLabel> <Select labelId="demo-multiple-checkbox-label" id="demo-multiple-checkbox" multiple value={personName} onChange={handleChange} input={<OutlinedInput label="Tag" />} renderValue={(selected) => selected.join(', ')} MenuProps={MenuProps} > {names.map((name) => ( <MenuItem key={name} value={name}> <Checkbox checked={personName.indexOf(name) > -1} /> <ListItemText primary={name} /> </MenuItem> ))} </Select> </FormControl> </div> ); }
docs/src/pages/components/selects/MultipleSelectCheckmarks.tsx
1
https://github.com/mui/material-ui/commit/ae1b29b68f9b1bf021e0fe471e5b8f07c13e71b5
[ 0.006957497447729111, 0.0013801789609715343, 0.00016493360453750938, 0.0002045927249127999, 0.0023277169093489647 ]
{ "id": 7, "code_window": [ "\n", " return (\n", " <div>\n", " <FormControl sx={{ m: 1, minWidth: 120, maxWidth: 300, mt: 3 }}>\n", " <Select\n", " multiple\n", " displayEmpty\n", " value={personName}\n" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " <FormControl sx={{ m: 1, width: 300, mt: 3 }}>\n" ], "file_path": "docs/src/pages/components/selects/MultipleSelectPlaceholder.tsx", "type": "replace", "edit_start_line_idx": 50 }
<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24" viewBox="0 0 24 24" width="24"><g><path d="M0,0h24v24H0V0z" fill="none"/></g><g><g><path d="M20,5V3h-4v2h-1v5h2v9h-4V3H5v11H3v5h1v2h4v-2h1v-5H7V5h4v16h8V10h2V5H20z"/></g></g></svg>
packages/material-ui-icons/material-icons/cable_sharp_24px.svg
0
https://github.com/mui/material-ui/commit/ae1b29b68f9b1bf021e0fe471e5b8f07c13e71b5
[ 0.00017288548406213522, 0.00017288548406213522, 0.00017288548406213522, 0.00017288548406213522, 0 ]
{ "id": 7, "code_window": [ "\n", " return (\n", " <div>\n", " <FormControl sx={{ m: 1, minWidth: 120, maxWidth: 300, mt: 3 }}>\n", " <Select\n", " multiple\n", " displayEmpty\n", " value={personName}\n" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " <FormControl sx={{ m: 1, width: 300, mt: 3 }}>\n" ], "file_path": "docs/src/pages/components/selects/MultipleSelectPlaceholder.tsx", "type": "replace", "edit_start_line_idx": 50 }
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M21 11l2-2c-3.73-3.73-8.87-5.15-13.7-4.31l2.58 2.58c3.3-.02 6.61 1.22 9.12 3.73zM9 17l3 3 3-3c-1.65-1.66-4.34-1.66-6 0zm10-4c-1.08-1.08-2.36-1.85-3.72-2.33l3.02 3.02.7-.69zM3.41 1.64L2 3.05 5.05 6.1C3.59 6.83 2.22 7.79 1 9l2 2c1.23-1.23 2.65-2.16 4.17-2.78l2.24 2.24C7.79 10.89 6.27 11.74 5 13l2 2c1.35-1.35 3.11-2.04 4.89-2.06l7.08 7.08 1.41-1.41L3.41 1.64z"/></svg>
packages/material-ui-icons/material-icons/wifi_off_sharp_24px.svg
0
https://github.com/mui/material-ui/commit/ae1b29b68f9b1bf021e0fe471e5b8f07c13e71b5
[ 0.00016676849918439984, 0.00016676849918439984, 0.00016676849918439984, 0.00016676849918439984, 0 ]
{ "id": 7, "code_window": [ "\n", " return (\n", " <div>\n", " <FormControl sx={{ m: 1, minWidth: 120, maxWidth: 300, mt: 3 }}>\n", " <Select\n", " multiple\n", " displayEmpty\n", " value={personName}\n" ], "labels": [ "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ], "after_edit": [ " <FormControl sx={{ m: 1, width: 300, mt: 3 }}>\n" ], "file_path": "docs/src/pages/components/selects/MultipleSelectPlaceholder.tsx", "type": "replace", "edit_start_line_idx": 50 }
Foo.propTypes = { bothTypes: function (props, propName) { if (props[propName] == null) { return new Error("Prop '" + propName + "' is required but wasn't specified"); } else if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) { return new Error("Expected prop '" + propName + "' to be of type Element"); } }, element: function (props, propName) { if (props[propName] == null) { return new Error("Prop '" + propName + "' is required but wasn't specified"); } else if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) { return new Error("Expected prop '" + propName + "' to be of type Element"); } }, htmlElement: function (props, propName) { if (props[propName] == null) { return new Error("Prop '" + propName + "' is required but wasn't specified"); } else if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) { return new Error("Expected prop '" + propName + "' to be of type Element"); } }, optional: function (props, propName) { if (props[propName] == null) { return null; } else if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) { return new Error("Expected prop '" + propName + "' to be of type Element"); } }, };
packages/typescript-to-proptypes/test/generator/html-elements/output.js
0
https://github.com/mui/material-ui/commit/ae1b29b68f9b1bf021e0fe471e5b8f07c13e71b5
[ 0.00017445864796172827, 0.00017297359590884298, 0.00017202644085045904, 0.0001727046474115923, 9.020188826980302e-7 ]
{ "id": 0, "code_window": [ "if (fs.existsSync(reduxSrc) && fs.existsSync(reduxNodeModules)) {\n", " // Resolve Redux to source\n", " module.exports.resolve = { alias: { 'redux': reduxSrc } }\n", " // Compile Redux from source\n", " module.exports.module.loaders.push({\n", " test: /\\.js$/,\n", " loaders: ['babel'],\n", " include: reduxSrc\n" ], "labels": [ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ], "after_edit": [ " // Our root .babelrc needs this flag for CommonJS output\n", " process.env.BABEL_ENV = 'commonjs'\n" ], "file_path": "examples/async/webpack.config.js", "type": "add", "edit_start_line_idx": 40 }
var path = require('path') var webpack = require('webpack') module.exports = { devtool: 'cheap-module-eval-source-map', entry: [ 'webpack-hot-middleware/client', './index' ], output: { path: path.join(__dirname, 'dist'), filename: 'bundle.js', publicPath: '/static/' }, plugins: [ new webpack.optimize.OccurenceOrderPlugin(), new webpack.HotModuleReplacementPlugin(), new webpack.NoErrorsPlugin() ], module: { loaders: [ { test: /\.js$/, loaders: [ 'babel' ], exclude: /node_modules/, include: __dirname } ] } } // When inside Redux repo, prefer src to compiled version. // You can safely delete these lines in your project. var reduxSrc = path.join(__dirname, '..', '..', 'src') var reduxNodeModules = path.join(__dirname, '..', '..', 'node_modules') var fs = require('fs') if (fs.existsSync(reduxSrc) && fs.existsSync(reduxNodeModules)) { // Resolve Redux to source module.exports.resolve = { alias: { 'redux': reduxSrc } } // Compile Redux from source module.exports.module.loaders.push({ test: /\.js$/, loaders: [ 'babel' ], include: reduxSrc }) }
examples/todos/webpack.config.js
1
https://github.com/reduxjs/redux/commit/872f2314838f44da9ff6dcbd5ad09f78bec5dbd6
[ 0.9734659194946289, 0.21341410279273987, 0.00028132801526226103, 0.00039758512866683304, 0.3817017078399658 ]
{ "id": 0, "code_window": [ "if (fs.existsSync(reduxSrc) && fs.existsSync(reduxNodeModules)) {\n", " // Resolve Redux to source\n", " module.exports.resolve = { alias: { 'redux': reduxSrc } }\n", " // Compile Redux from source\n", " module.exports.module.loaders.push({\n", " test: /\\.js$/,\n", " loaders: ['babel'],\n", " include: reduxSrc\n" ], "labels": [ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ], "after_edit": [ " // Our root .babelrc needs this flag for CommonJS output\n", " process.env.BABEL_ENV = 'commonjs'\n" ], "file_path": "examples/async/webpack.config.js", "type": "add", "edit_start_line_idx": 40 }
# Data Flow Redux architecture revolves around a **strict unidirectional data flow**. This means that all data in an application follows the same lifecycle pattern, making the logic of your app more predictable and easier to understand. It also encourages data normalization, so that you don't end up with multiple, independent copies of the same data that are unaware of one another. If you're still not convinced, read [Motivation](../introduction/Motivation.md) and [The Case for Flux](https://medium.com/@dan_abramov/the-case-for-flux-379b7d1982c6) for a compelling argument in favor of unidirectional data flow. Although [Redux is not exactly Flux](../introduction/PriorArt.md), it shares the same key benefits. The data lifecycle in any Redux app follows these 4 steps: 1. **You call** [`store.dispatch(action)`](../api/Store.md#dispatch). An [action](Actions.md) is a plain object describing *what happened*. For example: ```js { type: 'LIKE_ARTICLE', articleId: 42 } { type: 'FETCH_USER_SUCCESS', response: { id: 3, name: 'Mary' } } { type: 'ADD_TODO', text: 'Read the Redux docs.' } ``` Think of an action as a very brief snippet of news. “Mary liked article 42.” or “‘Read the Redux docs.’ was added to the list of todos.” You can call [`store.dispatch(action)`](../api/Store.md#dispatch) from anywhere in your app, including components and XHR callbacks, or even at scheduled intervals. 2. **The Redux store calls the reducer function you gave it.** The [store](Store.md) will pass two arguments to the [reducer](Reducers.md): the current state tree and the action. For example, in the todo app, the root reducer might receive something like this: ```js // The current application state (list of todos and chosen filter) let previousState = { visibleTodoFilter: 'SHOW_ALL', todos: [ { text: 'Read the docs.', complete: false } ] } // The action being performed (adding a todo) let action = { type: 'ADD_TODO', text: 'Understand the flow.' } // Your reducer returns the next application state let nextState = todoApp(previousState, action) ``` Note that a reducer is a pure function. It only *computes* the next state. It should be completely predictable: calling it with the same inputs many times should produce the same outputs. It shouldn’t perform any side effects like API calls or router transitions. These should happen before an action is dispatched. 3. **The root reducer may combine the output of multiple reducers into a single state tree.** How you structure the root reducer is completely up to you. Redux ships with a [`combineReducers()`](../api/combineReducers.md) helper function, useful for “splitting” the root reducer into separate functions that each manage one branch of the state tree. Here’s how [`combineReducers()`](../api/combineReducers.md) works. Let’s say you have two reducers, one for a list of todos, and another for the currently selected filter setting: ```js function todos(state = [], action) { // Somehow calculate it... return nextState } function visibleTodoFilter(state = 'SHOW_ALL', action) { // Somehow calculate it... return nextState } let todoApp = combineReducers({ todos, visibleTodoFilter }) ``` When you emit an action, `todoApp` returned by `combineReducers` will call both reducers: ```js let nextTodos = todos(state.todos, action) let nextVisibleTodoFilter = visibleTodoFilter(state.visibleTodoFilter, action) ``` It will then combine both sets of results into a single state tree: ```js return { todos: nextTodos, visibleTodoFilter: nextVisibleTodoFilter } ``` While [`combineReducers()`](../api/combineReducers.md) is a handy helper utility, you don’t have to use it; feel free to write your own root reducer! 4. **The Redux store saves the complete state tree returned by the root reducer.** This new tree is now the next state of your app! Every listener registered with [`store.subscribe(listener)`](../api/Store.md#subscribe) will now be invoked; listeners may call [`store.getState()`](../api/Store.md#getState) to get the current state. Now, the UI can be updated to reflect the new state. If you use bindings like [React Redux](https://github.com/gaearon/react-redux), this is the point at which `component.setState(newState)` is called. ## Next Steps Now that you know how Redux works, let’s [connect it to a React app](UsageWithReact.md). >##### Note for Advanced Users >If you’re already familiar with the basic concepts and have previously completed this tutorial, don’t forget to check out [async flow](../advanced/AsyncFlow.md) in the [advanced tutorial](../advanced/README.md) to learn how middleware transforms [async actions](../advanced/AsyncActions.md) before they reach the reducer.
docs/basics/DataFlow.md
0
https://github.com/reduxjs/redux/commit/872f2314838f44da9ff6dcbd5ad09f78bec5dbd6
[ 0.00020331684208940715, 0.00017105293227359653, 0.00016235325892921537, 0.00016933176084421575, 0.00001050690480042249 ]
{ "id": 0, "code_window": [ "if (fs.existsSync(reduxSrc) && fs.existsSync(reduxNodeModules)) {\n", " // Resolve Redux to source\n", " module.exports.resolve = { alias: { 'redux': reduxSrc } }\n", " // Compile Redux from source\n", " module.exports.module.loaders.push({\n", " test: /\\.js$/,\n", " loaders: ['babel'],\n", " include: reduxSrc\n" ], "labels": [ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ], "after_edit": [ " // Our root .babelrc needs this flag for CommonJS output\n", " process.env.BABEL_ENV = 'commonjs'\n" ], "file_path": "examples/async/webpack.config.js", "type": "add", "edit_start_line_idx": 40 }
import { CALL_API, Schemas } from '../middleware/api' export const USER_REQUEST = 'USER_REQUEST' export const USER_SUCCESS = 'USER_SUCCESS' export const USER_FAILURE = 'USER_FAILURE' // Fetches a single user from Github API. // Relies on the custom API middleware defined in ../middleware/api.js. function fetchUser(login) { return { [CALL_API]: { types: [ USER_REQUEST, USER_SUCCESS, USER_FAILURE ], endpoint: `users/${login}`, schema: Schemas.USER } } } // Fetches a single user from Github API unless it is cached. // Relies on Redux Thunk middleware. export function loadUser(login, requiredFields = []) { return (dispatch, getState) => { const user = getState().entities.users[login] if (user && requiredFields.every(key => user.hasOwnProperty(key))) { return null } return dispatch(fetchUser(login)) } } export const REPO_REQUEST = 'REPO_REQUEST' export const REPO_SUCCESS = 'REPO_SUCCESS' export const REPO_FAILURE = 'REPO_FAILURE' // Fetches a single repository from Github API. // Relies on the custom API middleware defined in ../middleware/api.js. function fetchRepo(fullName) { return { [CALL_API]: { types: [ REPO_REQUEST, REPO_SUCCESS, REPO_FAILURE ], endpoint: `repos/${fullName}`, schema: Schemas.REPO } } } // Fetches a single repository from Github API unless it is cached. // Relies on Redux Thunk middleware. export function loadRepo(fullName, requiredFields = []) { return (dispatch, getState) => { const repo = getState().entities.repos[fullName] if (repo && requiredFields.every(key => repo.hasOwnProperty(key))) { return null } return dispatch(fetchRepo(fullName)) } } export const STARRED_REQUEST = 'STARRED_REQUEST' export const STARRED_SUCCESS = 'STARRED_SUCCESS' export const STARRED_FAILURE = 'STARRED_FAILURE' // Fetches a page of starred repos by a particular user. // Relies on the custom API middleware defined in ../middleware/api.js. function fetchStarred(login, nextPageUrl) { return { login, [CALL_API]: { types: [ STARRED_REQUEST, STARRED_SUCCESS, STARRED_FAILURE ], endpoint: nextPageUrl, schema: Schemas.REPO_ARRAY } } } // Fetches a page of starred repos by a particular user. // Bails out if page is cached and user didn’t specifically request next page. // Relies on Redux Thunk middleware. export function loadStarred(login, nextPage) { return (dispatch, getState) => { const { nextPageUrl = `users/${login}/starred`, pageCount = 0 } = getState().pagination.starredByUser[login] || {} if (pageCount > 0 && !nextPage) { return null } return dispatch(fetchStarred(login, nextPageUrl)) } } export const STARGAZERS_REQUEST = 'STARGAZERS_REQUEST' export const STARGAZERS_SUCCESS = 'STARGAZERS_SUCCESS' export const STARGAZERS_FAILURE = 'STARGAZERS_FAILURE' // Fetches a page of stargazers for a particular repo. // Relies on the custom API middleware defined in ../middleware/api.js. function fetchStargazers(fullName, nextPageUrl) { return { fullName, [CALL_API]: { types: [ STARGAZERS_REQUEST, STARGAZERS_SUCCESS, STARGAZERS_FAILURE ], endpoint: nextPageUrl, schema: Schemas.USER_ARRAY } } } // Fetches a page of stargazers for a particular repo. // Bails out if page is cached and user didn’t specifically request next page. // Relies on Redux Thunk middleware. export function loadStargazers(fullName, nextPage) { return (dispatch, getState) => { const { nextPageUrl = `repos/${fullName}/stargazers`, pageCount = 0 } = getState().pagination.stargazersByRepo[fullName] || {} if (pageCount > 0 && !nextPage) { return null } return dispatch(fetchStargazers(fullName, nextPageUrl)) } } export const RESET_ERROR_MESSAGE = 'RESET_ERROR_MESSAGE' // Resets the currently visible error message. export function resetErrorMessage() { return { type: RESET_ERROR_MESSAGE } }
examples/real-world/actions/index.js
0
https://github.com/reduxjs/redux/commit/872f2314838f44da9ff6dcbd5ad09f78bec5dbd6
[ 0.0002080686972476542, 0.00017230781668331474, 0.00016256920935120434, 0.00016800231242086738, 0.000011474275197542738 ]
{ "id": 0, "code_window": [ "if (fs.existsSync(reduxSrc) && fs.existsSync(reduxNodeModules)) {\n", " // Resolve Redux to source\n", " module.exports.resolve = { alias: { 'redux': reduxSrc } }\n", " // Compile Redux from source\n", " module.exports.module.loaders.push({\n", " test: /\\.js$/,\n", " loaders: ['babel'],\n", " include: reduxSrc\n" ], "labels": [ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ], "after_edit": [ " // Our root .babelrc needs this flag for CommonJS output\n", " process.env.BABEL_ENV = 'commonjs'\n" ], "file_path": "examples/async/webpack.config.js", "type": "add", "edit_start_line_idx": 40 }
import { combineReducers } from 'redux' import { default as cart, getQuantity, getAddedIds } from './cart' import { default as products, getProduct } from './products' export function getTotal(state) { return getAddedIds(state.cart).reduce((total, id) => total + getProduct(state.products, id).price * getQuantity(state.cart, id), 0 ).toFixed(2) } export function getCartProducts(state) { return getAddedIds(state.cart).map(id => Object.assign( {}, getProduct(state.products, id), { quantity: getQuantity(state.cart, id) } )) } export default combineReducers({ cart, products })
examples/shopping-cart/reducers/index.js
0
https://github.com/reduxjs/redux/commit/872f2314838f44da9ff6dcbd5ad09f78bec5dbd6
[ 0.00017762044444680214, 0.00017234862025361508, 0.00016848270024638623, 0.00017094268696382642, 0.0000038606613088632 ]
{ "id": 1, "code_window": [ "var fs = require('fs')\n", "if (fs.existsSync(reduxSrc) && fs.existsSync(reduxNodeModules)) {\n", " // Resolve Redux to source\n", " module.exports.resolve = { alias: { 'redux': reduxSrc } }\n", " // Compile Redux from source\n", " module.exports.module.loaders.push({\n", " test: /\\.js$/,\n", " loaders: [ 'babel' ],\n" ], "labels": [ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ], "after_edit": [ " // Our root .babelrc needs this flag for CommonJS output\n", " process.env.BABEL_ENV = 'commonjs'\n" ], "file_path": "examples/counter/webpack.config.js", "type": "add", "edit_start_line_idx": 40 }
var path = require('path') var webpack = require('webpack') module.exports = { devtool: 'cheap-module-eval-source-map', entry: [ 'webpack-hot-middleware/client', './index' ], output: { path: path.join(__dirname, 'dist'), filename: 'bundle.js', publicPath: '/static/' }, plugins: [ new webpack.optimize.OccurenceOrderPlugin(), new webpack.HotModuleReplacementPlugin(), new webpack.NoErrorsPlugin() ], module: { loaders: [ { test: /\.js$/, loaders: [ 'babel' ], exclude: /node_modules/, include: __dirname } ] } } // When inside Redux repo, prefer src to compiled version. // You can safely delete these lines in your project. var reduxSrc = path.join(__dirname, '..', '..', 'src') var reduxNodeModules = path.join(__dirname, '..', '..', 'node_modules') var fs = require('fs') if (fs.existsSync(reduxSrc) && fs.existsSync(reduxNodeModules)) { // Resolve Redux to source module.exports.resolve = { alias: { 'redux': reduxSrc } } // Compile Redux from source module.exports.module.loaders.push({ test: /\.js$/, loaders: [ 'babel' ], include: reduxSrc }) }
examples/tree-view/webpack.config.js
1
https://github.com/reduxjs/redux/commit/872f2314838f44da9ff6dcbd5ad09f78bec5dbd6
[ 0.997426450252533, 0.22200468182563782, 0.0003182770451530814, 0.0005511750350706279, 0.390082448720932 ]
{ "id": 1, "code_window": [ "var fs = require('fs')\n", "if (fs.existsSync(reduxSrc) && fs.existsSync(reduxNodeModules)) {\n", " // Resolve Redux to source\n", " module.exports.resolve = { alias: { 'redux': reduxSrc } }\n", " // Compile Redux from source\n", " module.exports.module.loaders.push({\n", " test: /\\.js$/,\n", " loaders: [ 'babel' ],\n" ], "labels": [ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ], "after_edit": [ " // Our root .babelrc needs this flag for CommonJS output\n", " process.env.BABEL_ENV = 'commonjs'\n" ], "file_path": "examples/counter/webpack.config.js", "type": "add", "edit_start_line_idx": 40 }
# Middleware You’ve seen middleware in action in the [Async Actions](../advanced/AsyncActions.md) example. If you’ve used server-side libraries like [Express](http://expressjs.com/) and [Koa](http://koajs.com/), you were also probably already familiar with the concept of *middleware*. In these frameworks, middleware is some code you can put between the framework receiving a request, and the framework generating a response. For example, Express or Koa middleware may add CORS headers, logging, compression, and more. The best feature of middleware is that it’s composable in a chain. You can use multiple independent third-party middleware in a single project. Redux middleware solves different problems than Express or Koa middleware, but in a conceptually similar way. **It provides a third-party extension point between dispatching an action, and the moment it reaches the reducer.** People use Redux middleware for logging, crash reporting, talking to an asynchronous API, routing, and more. This article is divided into an in-depth intro to help you grok the concept, and [a few practical examples](#seven-examples) to show the power of middleware at the very end. You may find it helpful to switch back and forth between them, as you flip between feeling bored and inspired. ## Understanding Middleware While middleware can be used for a variety of things, including asynchronous API calls, it’s really important that you understand where it comes from. We’ll guide you through the thought process leading to middleware, by using logging and crash reporting as examples. ### Problem: Logging One of the benefits of Redux is that it makes state changes predictable and transparent. Every time an action is dispatched, the new state is computed and saved. The state cannot change by itself, it can only change as a consequence of a specific action. Wouldn’t it be nice if we logged every action that happens in the app, together with the state computed after it? When something goes wrong, we can look back at our log, and figure out which action corrupted the state. <img src='http://i.imgur.com/BjGBlES.png' width='70%'> How do we approach this with Redux? ### Attempt #1: Logging Manually The most naïve solution is just to log the action and the next state yourself every time you call [`store.dispatch(action)`](../api/Store.md#dispatch). It’s not really a solution, but just a first step towards understanding the problem. >##### Note >If you’re using [react-redux](https://github.com/gaearon/react-redux) or similar bindings, you likely won’t have direct access to the store instance in your components. For the next few paragraphs, just assume you pass the store down explicitly. Say, you call this when creating a todo: ```js store.dispatch(addTodo('Use Redux')) ``` To log the action and state, you can change it to something like this: ```js let action = addTodo('Use Redux') console.log('dispatching', action) store.dispatch(action) console.log('next state', store.getState()) ``` This produces the desired effect, but you wouldn’t want to do it every time. ### Attempt #2: Wrapping Dispatch You can extract logging into a function: ```js function dispatchAndLog(store, action) { console.log('dispatching', action) store.dispatch(action) console.log('next state', store.getState()) } ``` You can then use it everywhere instead of `store.dispatch()`: ```js dispatchAndLog(store, addTodo('Use Redux')) ``` We could end this here, but it’s not very convenient to import a special function every time. ### Attempt #3: Monkeypatching Dispatch What if we just replace the `dispatch` function on the store instance? The Redux store is just a plain object with [a few methods](../api/Store.md), and we’re writing JavaScript, so we can just monkeypatch the `dispatch` implementation: ```js let next = store.dispatch store.dispatch = function dispatchAndLog(action) { console.log('dispatching', action) let result = next(action) console.log('next state', store.getState()) return result } ``` This is already closer to what we want! No matter where we dispatch an action, it is guaranteed to be logged. Monkeypatching never feels right, but we can live with this for now. ### Problem: Crash Reporting What if we want to apply **more than one** such transformation to `dispatch`? A different useful transformation that comes to my mind is reporting JavaScript errors in production. The global `window.onerror` event is not reliable because it doesn’t provide stack information in some older browsers, which is crucial to understand why an error is happening. Wouldn’t it be useful if, any time an error is thrown as a result of dispatching an action, we would send it to a crash reporting service like [Sentry](https://getsentry.com/welcome/) with the stack trace, the action that caused the error, and the current state? This way it’s much easier to reproduce the error in development. However, it is important that we keep logging and crash reporting separate. Ideally we want them to be different modules, potentially in different packages. Otherwise we can’t have an ecosystem of such utilities. (Hint: we’re slowly getting to what middleware is!) If logging and crash reporting are separate utilities, they might look like this: ```js function patchStoreToAddLogging(store) { let next = store.dispatch store.dispatch = function dispatchAndLog(action) { console.log('dispatching', action) let result = next(action) console.log('next state', store.getState()) return result } } function patchStoreToAddCrashReporting(store) { let next = store.dispatch store.dispatch = function dispatchAndReportErrors(action) { try { return next(action) } catch (err) { console.error('Caught an exception!', err) Raven.captureException(err, { extra: { action, state: store.getState() } }) throw err } } } ``` If these functions are published as separate modules, we can later use them to patch our store: ```js patchStoreToAddLogging(store) patchStoreToAddCrashReporting(store) ``` Still, this isn’t nice. ### Attempt #4: Hiding Monkeypatching Monkeypatching is a hack. “Replace any method you like”, what kind of API is that? Let’s figure out the essence of it instead. Previously, our functions replaced `store.dispatch`. What if they *returned* the new `dispatch` function instead? ```js function logger(store) { let next = store.dispatch // Previously: // store.dispatch = function dispatchAndLog(action) { return function dispatchAndLog(action) { console.log('dispatching', action) let result = next(action) console.log('next state', store.getState()) return result } } ``` We could provide a helper inside Redux that would apply the actual monkeypatching as an implementation detail: ```js function applyMiddlewareByMonkeypatching(store, middlewares) { middlewares = middlewares.slice() middlewares.reverse() // Transform dispatch function with each middleware. middlewares.forEach(middleware => store.dispatch = middleware(store) ) } ``` We could use it to apply multiple middleware like this: ```js applyMiddlewareByMonkeypatching(store, [ logger, crashReporter ]) ``` However, it is still monkeypatching. The fact that we hide it inside the library doesn’t alter this fact. ### Attempt #5: Removing Monkeypatching Why do we even overwrite `dispatch`? Of course, to be able to call it later, but there’s also another reason: so that every middleware can access (and call) the previously wrapped `store.dispatch`: ```js function logger(store) { // Must point to the function returned by the previous middleware: let next = store.dispatch return function dispatchAndLog(action) { console.log('dispatching', action) let result = next(action) console.log('next state', store.getState()) return result } } ``` It is essential to chaining middleware! If `applyMiddlewareByMonkeypatching` doesn’t assign `store.dispatch` immediately after processing the first middleware, `store.dispatch` will keep pointing to the original `dispatch` function. Then the second middleware will also be bound to the original `dispatch` function. But there’s also a different way to enable chaining. The middleware could accept the `next()` dispatch function as a parameter instead of reading it from the `store` instance. ```js function logger(store) { return function wrapDispatchToAddLogging(next) { return function dispatchAndLog(action) { console.log('dispatching', action) let result = next(action) console.log('next state', store.getState()) return result } } } ``` It’s a [“we need to go deeper”](http://knowyourmeme.com/memes/we-need-to-go-deeper) kind of moment, so it might take a while for this to make sense. The function cascade feels intimidating. ES6 arrow functions make this [currying](https://en.wikipedia.org/wiki/Currying) easier on eyes: ```js const logger = store => next => action => { console.log('dispatching', action) let result = next(action) console.log('next state', store.getState()) return result } const crashReporter = store => next => action => { try { return next(action) } catch (err) { console.error('Caught an exception!', err) Raven.captureException(err, { extra: { action, state: store.getState() } }) throw err } } ``` **This is exactly what Redux middleware looks like.** Now middleware takes the `next()` dispatch function, and returns a dispatch function, which in turn serves as `next()` to the middleware to the left, and so on. It’s still useful to have access to some store methods like `getState()`, so `store` stays available as the top-level argument. ### Attempt #6: Naïvely Applying the Middleware Instead of `applyMiddlewareByMonkeypatching()`, we could write `applyMiddleware()` that first obtains the final, fully wrapped `dispatch()` function, and returns a copy of the store using it: ```js // Warning: Naïve implementation! // That's *not* Redux API. function applyMiddleware(store, middlewares) { middlewares = middlewares.slice() middlewares.reverse() let dispatch = store.dispatch middlewares.forEach(middleware => dispatch = middleware(store)(dispatch) ) return Object.assign({}, store, { dispatch }) } ``` The implementation of [`applyMiddleware()`](../api/applyMiddleware.md) that ships with Redux is similar, but **different in three important aspects**: * It only exposes a subset of the [store API](../api/Store.md) to the middleware: [`dispatch(action)`](../api/Store.md#dispatch) and [`getState()`](../api/Store.md#getState). * It does a bit of trickery to make sure that if you call `store.dispatch(action)` from your middleware instead of `next(action)`, the action will actually travel the whole middleware chain again, including the current middleware. This is useful for asynchronous middleware, as we have seen [previously](AsyncActions.md). * To ensure that you may only apply middleware once, it operates on `createStore()` rather than on `store` itself. Instead of `(store, middlewares) => store`, its signature is `(...middlewares) => (createStore) => createStore`. Because it is cumbersome to apply functions to `createStore()` before using it, `createStore()` accepts an optional last argument to specify such functions. ### The Final Approach Given this middleware we just wrote: ```js const logger = store => next => action => { console.log('dispatching', action) let result = next(action) console.log('next state', store.getState()) return result } const crashReporter = store => next => action => { try { return next(action) } catch (err) { console.error('Caught an exception!', err) Raven.captureException(err, { extra: { action, state: store.getState() } }) throw err } } ``` Here’s how to apply it to a Redux store: ```js import { createStore, combineReducers, applyMiddleware } from 'redux' let todoApp = combineReducers(reducers) let store = createStore( todoApp, // applyMiddleware() tells createStore() how to handle middleware applyMiddleware(logger, crashReporter) ) ``` That’s it! Now any actions dispatched to the store instance will flow through `logger` and `crashReporter`: ```js // Will flow through both logger and crashReporter middleware! store.dispatch(addTodo('Use Redux')) ``` ## Seven Examples If your head boiled from reading the above section, imagine what it was like to write it. This section is meant to be a relaxation for you and me, and will help get your gears turning. Each function below is a valid Redux middleware. They are not equally useful, but at least they are equally fun. ```js /** * Logs all actions and states after they are dispatched. */ const logger = store => next => action => { console.group(action.type) console.info('dispatching', action) let result = next(action) console.log('next state', store.getState()) console.groupEnd(action.type) return result } /** * Sends crash reports as state is updated and listeners are notified. */ const crashReporter = store => next => action => { try { return next(action) } catch (err) { console.error('Caught an exception!', err) Raven.captureException(err, { extra: { action, state: store.getState() } }) throw err } } /** * Schedules actions with { meta: { delay: N } } to be delayed by N milliseconds. * Makes `dispatch` return a function to cancel the timeout in this case. */ const timeoutScheduler = store => next => action => { if (!action.meta || !action.meta.delay) { return next(action) } let timeoutId = setTimeout( () => next(action), action.meta.delay ) return function cancel() { clearTimeout(timeoutId) } } /** * Schedules actions with { meta: { raf: true } } to be dispatched inside a rAF loop * frame. Makes `dispatch` return a function to remove the action from the queue in * this case. */ const rafScheduler = store => next => { let queuedActions = [] let frame = null function loop() { frame = null try { if (queuedActions.length) { next(queuedActions.shift()) } } finally { maybeRaf() } } function maybeRaf() { if (queuedActions.length && !frame) { frame = requestAnimationFrame(loop) } } return action => { if (!action.meta || !action.meta.raf) { return next(action) } queuedActions.push(action) maybeRaf() return function cancel() { queuedActions = queuedActions.filter(a => a !== action) } } } /** * Lets you dispatch promises in addition to actions. * If the promise is resolved, its result will be dispatched as an action. * The promise is returned from `dispatch` so the caller may handle rejection. */ const vanillaPromise = store => next => action => { if (typeof action.then !== 'function') { return next(action) } return Promise.resolve(action).then(store.dispatch) } /** * Lets you dispatch special actions with a { promise } field. * * This middleware will turn them into a single action at the beginning, * and a single success (or failure) action when the `promise` resolves. * * For convenience, `dispatch` will return the promise so the caller can wait. */ const readyStatePromise = store => next => action => { if (!action.promise) { return next(action) } function makeAction(ready, data) { let newAction = Object.assign({}, action, { ready }, data) delete newAction.promise return newAction } next(makeAction(false)) return action.promise.then( result => next(makeAction(true, { result })), error => next(makeAction(true, { error })) ) } /** * Lets you dispatch a function instead of an action. * This function will receive `dispatch` and `getState` as arguments. * * Useful for early exits (conditions over `getState()`), as well * as for async control flow (it can `dispatch()` something else). * * `dispatch` will return the return value of the dispatched function. */ const thunk = store => next => action => typeof action === 'function' ? action(store.dispatch, store.getState) : next(action) // You can use all of them! (It doesn’t mean you should.) let todoApp = combineReducers(reducers) let store = createStore( todoApp, applyMiddleware( rafScheduler, timeoutScheduler, thunk, vanillaPromise, readyStatePromise, logger, crashReporter ) ) ```
docs/advanced/Middleware.md
0
https://github.com/reduxjs/redux/commit/872f2314838f44da9ff6dcbd5ad09f78bec5dbd6
[ 0.00035559944808483124, 0.00017807881522458047, 0.00016146064444910735, 0.00016753528325352818, 0.00003417922926018946 ]
{ "id": 1, "code_window": [ "var fs = require('fs')\n", "if (fs.existsSync(reduxSrc) && fs.existsSync(reduxNodeModules)) {\n", " // Resolve Redux to source\n", " module.exports.resolve = { alias: { 'redux': reduxSrc } }\n", " // Compile Redux from source\n", " module.exports.module.loaders.push({\n", " test: /\\.js$/,\n", " loaders: [ 'babel' ],\n" ], "labels": [ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ], "after_edit": [ " // Our root .babelrc needs this flag for CommonJS output\n", " process.env.BABEL_ENV = 'commonjs'\n" ], "file_path": "examples/counter/webpack.config.js", "type": "add", "edit_start_line_idx": 40 }
# Contributor Code of Conduct As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities. We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion. Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct. Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team. Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers. This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
CODE_OF_CONDUCT.md
0
https://github.com/reduxjs/redux/commit/872f2314838f44da9ff6dcbd5ad09f78bec5dbd6
[ 0.0001758652797434479, 0.00017211399972438812, 0.00016836273425724357, 0.00017211399972438812, 0.000003751272743102163 ]
{ "id": 1, "code_window": [ "var fs = require('fs')\n", "if (fs.existsSync(reduxSrc) && fs.existsSync(reduxNodeModules)) {\n", " // Resolve Redux to source\n", " module.exports.resolve = { alias: { 'redux': reduxSrc } }\n", " // Compile Redux from source\n", " module.exports.module.loaders.push({\n", " test: /\\.js$/,\n", " loaders: [ 'babel' ],\n" ], "labels": [ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ], "after_edit": [ " // Our root .babelrc needs this flag for CommonJS output\n", " process.env.BABEL_ENV = 'commonjs'\n" ], "file_path": "examples/counter/webpack.config.js", "type": "add", "edit_start_line_idx": 40 }
import createStore from './createStore' import combineReducers from './combineReducers' import bindActionCreators from './bindActionCreators' import applyMiddleware from './applyMiddleware' import compose from './compose' import warning from './utils/warning' /* * This is a dummy function to check if the function name has been altered by minification. * If the function has been minified and NODE_ENV !== 'production', warn the user. */ function isCrushed() {} if ( process.env.NODE_ENV !== 'production' && typeof isCrushed.name === 'string' && isCrushed.name !== 'isCrushed' ) { warning( 'You are currently using minified code outside of NODE_ENV === \'production\'. ' + 'This means that you are running a slower development build of Redux. ' + 'You can use loose-envify (https://github.com/zertosh/loose-envify) for browserify ' + 'or DefinePlugin for webpack (http://stackoverflow.com/questions/30030031) ' + 'to ensure you have the correct code for your production build.' ) } export { createStore, combineReducers, bindActionCreators, applyMiddleware, compose }
src/index.js
0
https://github.com/reduxjs/redux/commit/872f2314838f44da9ff6dcbd5ad09f78bec5dbd6
[ 0.0001732207601889968, 0.00016896247689146549, 0.00016431983385700732, 0.00016915466403588653, 0.0000033213298138434766 ]
{ "id": 2, "code_window": [ "if (fs.existsSync(reduxSrc) && fs.existsSync(reduxNodeModules)) {\n", " // Resolve Redux to source\n", " module.exports.resolve = { alias: { 'redux': reduxSrc } }\n", " // Compile Redux from source\n", " module.exports.module.loaders.push({\n", " test: /\\.js$/,\n" ], "labels": [ "keep", "keep", "add", "keep", "keep", "keep" ], "after_edit": [ " // Our root .babelrc needs this flag for CommonJS output\n", " process.env.BABEL_ENV = 'commonjs'\n" ], "file_path": "examples/real-world/webpack.config.js", "type": "add", "edit_start_line_idx": 40 }
var path = require('path') var webpack = require('webpack') module.exports = { devtool: 'cheap-module-eval-source-map', entry: [ 'webpack-hot-middleware/client', './index' ], output: { path: path.join(__dirname, 'dist'), filename: 'bundle.js', publicPath: '/static/' }, plugins: [ new webpack.optimize.OccurenceOrderPlugin(), new webpack.HotModuleReplacementPlugin(), new webpack.NoErrorsPlugin() ], module: { loaders: [ { test: /\.js$/, loaders: [ 'babel' ], exclude: /node_modules/, include: __dirname }, { test: /\.json$/, loaders: [ 'json' ], exclude: /node_modules/, include: __dirname } ] } } // When inside Redux repo, prefer src to compiled version. // You can safely delete these lines in your project. var reduxSrc = path.join(__dirname, '..', '..', 'src') var reduxNodeModules = path.join(__dirname, '..', '..', 'node_modules') var fs = require('fs') if (fs.existsSync(reduxSrc) && fs.existsSync(reduxNodeModules)) { // Resolve Redux to source module.exports.resolve = { alias: { 'redux': reduxSrc } } // Compile Redux from source module.exports.module.loaders.push({ test: /\.js$/, loaders: [ 'babel' ], include: reduxSrc }) }
examples/shopping-cart/webpack.config.js
1
https://github.com/reduxjs/redux/commit/872f2314838f44da9ff6dcbd5ad09f78bec5dbd6
[ 0.9947598576545715, 0.16673724353313446, 0.0002114851085934788, 0.0009585891384631395, 0.37030449509620667 ]
{ "id": 2, "code_window": [ "if (fs.existsSync(reduxSrc) && fs.existsSync(reduxNodeModules)) {\n", " // Resolve Redux to source\n", " module.exports.resolve = { alias: { 'redux': reduxSrc } }\n", " // Compile Redux from source\n", " module.exports.module.loaders.push({\n", " test: /\\.js$/,\n" ], "labels": [ "keep", "keep", "add", "keep", "keep", "keep" ], "after_edit": [ " // Our root .babelrc needs this flag for CommonJS output\n", " process.env.BABEL_ENV = 'commonjs'\n" ], "file_path": "examples/real-world/webpack.config.js", "type": "add", "edit_start_line_idx": 40 }
var webpack = require('webpack') var webpackDevMiddleware = require('webpack-dev-middleware') var webpackHotMiddleware = require('webpack-hot-middleware') var config = require('./webpack.config') var app = new (require('express'))() var port = 3000 var compiler = webpack(config) app.use(webpackDevMiddleware(compiler, { noInfo: true, publicPath: config.output.publicPath })) app.use(webpackHotMiddleware(compiler)) app.get("/", function(req, res) { res.sendFile(__dirname + '/index.html') }) app.listen(port, function(error) { if (error) { console.error(error) } else { console.info("==> 🌎 Listening on port %s. Open up http://localhost:%s/ in your browser.", port, port) } })
examples/tree-view/server.js
0
https://github.com/reduxjs/redux/commit/872f2314838f44da9ff6dcbd5ad09f78bec5dbd6
[ 0.00017258340085390955, 0.0001701878063613549, 0.00016625598073005676, 0.0001717240666039288, 0.0000028022741389577277 ]
{ "id": 2, "code_window": [ "if (fs.existsSync(reduxSrc) && fs.existsSync(reduxNodeModules)) {\n", " // Resolve Redux to source\n", " module.exports.resolve = { alias: { 'redux': reduxSrc } }\n", " // Compile Redux from source\n", " module.exports.module.loaders.push({\n", " test: /\\.js$/,\n" ], "labels": [ "keep", "keep", "add", "keep", "keep", "keep" ], "after_edit": [ " // Our root .babelrc needs this flag for CommonJS output\n", " process.env.BABEL_ENV = 'commonjs'\n" ], "file_path": "examples/real-world/webpack.config.js", "type": "add", "edit_start_line_idx": 40 }
# Patrons The work on Redux was [funded by the community](https://www.patreon.com/reactdx). Meet some of the outstanding companies and individuals that made it possible: * [Webflow](https://github.com/webflow) * [Ximedes](https://www.ximedes.com/) * [Herman J. Radtke III](http://hermanradtke.com) * [Ken Wheeler](http://kenwheeler.github.io/) * [Chung Yen Li](https://www.facebook.com/prototocal.lee) * [Sunil Pai](https://twitter.com/threepointone) * [Charlie Cheever](https://twitter.com/ccheever) * [Eugene G](https://twitter.com/e1g) * [Matt Apperson](https://twitter.com/mattapperson) * [Jed Watson](https://twitter.com/jedwatson) * [Sasha Aickin](https://twitter.com/xander76) * [Stefan Tennigkeit](https://twitter.com/whobubble) * [Sam Vincent](https://twitter.com/samvincent) * Olegzandr Denman
PATRONS.md
0
https://github.com/reduxjs/redux/commit/872f2314838f44da9ff6dcbd5ad09f78bec5dbd6
[ 0.0001716666156426072, 0.00016972620505839586, 0.0001677857944741845, 0.00016972620505839586, 0.0000019404105842113495 ]
{ "id": 2, "code_window": [ "if (fs.existsSync(reduxSrc) && fs.existsSync(reduxNodeModules)) {\n", " // Resolve Redux to source\n", " module.exports.resolve = { alias: { 'redux': reduxSrc } }\n", " // Compile Redux from source\n", " module.exports.module.loaders.push({\n", " test: /\\.js$/,\n" ], "labels": [ "keep", "keep", "add", "keep", "keep", "keep" ], "after_edit": [ " // Our root .babelrc needs this flag for CommonJS output\n", " process.env.BABEL_ENV = 'commonjs'\n" ], "file_path": "examples/real-world/webpack.config.js", "type": "add", "edit_start_line_idx": 40 }
# Reducers [Actions](./Actions.md) describe the fact that *something happened*, but don’t specify how the application’s state changes in response. This is the job of a reducer. ## Designing the State Shape In Redux, all application state is stored as a single object. It’s a good idea to think of its shape before writing any code. What’s the minimal representation of your app’s state as an object? For our todo app, we want to store two different things: * The currently selected visibility filter; * The actual list of todos. You’ll often find that you need to store some data, as well as some UI state, in the state tree. This is fine, but try to keep the data separate from the UI state. ```js { visibilityFilter: 'SHOW_ALL', todos: [ { text: 'Consider using Redux', completed: true, }, { text: 'Keep all state in a single tree', completed: false } ] } ``` >##### Note on Relationships >In a more complex app, you’re going to want different entities to reference each other. We suggest that you keep your state as normalized as possible, without any nesting. Keep every entity in an object stored with an ID as a key, and use IDs to reference it from other entities, or lists. Think of the app’s state as a database. This approach is described in [normalizr's](https://github.com/gaearon/normalizr) documentation in detail. For example, keeping `todosById: { id -> todo }` and `todos: array<id>` inside the state would be a better idea in a real app, but we’re keeping the example simple. ## Handling Actions Now that we’ve decided what our state object looks like, we’re ready to write a reducer for it. The reducer is a pure function that takes the previous state and an action, and returns the next state. ```js (previousState, action) => newState ``` It’s called a reducer because it’s the type of function you would pass to [`Array.prototype.reduce(reducer, ?initialValue)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce). It’s very important that the reducer stays pure. Things you should **never** do inside a reducer: * Mutate its arguments; * Perform side effects like API calls and routing transitions; * Calling non-pure functions, e.g. `Date.now()` or `Math.random()`. We’ll explore how to perform side effects in the [advanced walkthrough](../advanced/README.md). For now, just remember that the reducer must be pure. **Given the same arguments, it should calculate the next state and return it. No surprises. No side effects. No API calls. No mutations. Just a calculation.** With this out of the way, let’s start writing our reducer by gradually teaching it to understand the [actions](Actions.md) we defined earlier. We’ll start by specifying the initial state. Redux will call our reducer with an `undefined` state for the first time. This is our chance to return the initial state of our app: ```js import { VisibilityFilters } from './actions' const initialState = { visibilityFilter: VisibilityFilters.SHOW_ALL, todos: [] } function todoApp(state, action) { if (typeof state === 'undefined') { return initialState } // For now, don’t handle any actions // and just return the state given to us. return state } ``` One neat trick is to use the [ES6 default arguments syntax](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Functions/default_parameters) to write this in a more compact way: ```js function todoApp(state = initialState, action) { // For now, don’t handle any actions // and just return the state given to us. return state } ``` Now let’s handle `SET_VISIBILITY_FILTER`. All it needs to do is to change `visibilityFilter` on the state. Easy: ```js function todoApp(state = initialState, action) { switch (action.type) { case SET_VISIBILITY_FILTER: return Object.assign({}, state, { visibilityFilter: action.filter }) default: return state } } ``` Note that: 1. **We don’t mutate the `state`.** We create a copy with [`Object.assign()`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign). `Object.assign(state, { visibilityFilter: action.filter })` is also wrong: it will mutate the first argument. You **must** supply an empty object as the first parameter. You can also enable the experimental [object spread syntax](https://github.com/sebmarkbage/ecmascript-rest-spread) proposed for ES7 to write `{ ...state, ...newState }` instead. 2. **We return the previous `state` in the `default` case.** It’s important to return the previous `state` for any unknown action. >##### Note on `Object.assign` >[`Object.assign()`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) is a part of ES6, but is not implemented by most browsers yet. You’ll need to either use a polyfill, a [Babel plugin](https://www.npmjs.com/package/babel-plugin-object-assign), or a helper from another library like [`_.assign()`](https://lodash.com/docs#assign). >##### Note on `switch` and Boilerplate >The `switch` statement is *not* the real boilerplate. The real boilerplate of Flux is conceptual: the need to emit an update, the need to register the Store with a Dispatcher, the need for the Store to be an object (and the complications that arise when you want a universal app). Redux solves these problems by using pure reducers instead of event emitters. >It’s unfortunate that many still choose a framework based on whether it uses `switch` statements in the documentation. If you don’t like `switch`, you can use a custom `createReducer` function that accepts a handler map, as shown in [“reducing boilerplate”](../recipes/ReducingBoilerplate.md#reducers). ## Handling More Actions We have two more actions to handle! Let’s extend our reducer to handle `ADD_TODO`. ```js function todoApp(state = initialState, action) { switch (action.type) { case SET_VISIBILITY_FILTER: return Object.assign({}, state, { visibilityFilter: action.filter }) case ADD_TODO: return Object.assign({}, state, { todos: [ ...state.todos, { text: action.text, completed: false } ] }) default: return state } } ``` Just like before, we never write directly to `state` or its fields, and instead we return new objects. The new `todos` is equal to the old `todos` concatenated with a single new item at the end. The fresh todo was constructed using the data from the action. Finally, the implementation of the `COMPLETE_TODO` handler shouldn’t come as a complete surprise: ```js case COMPLETE_TODO: return Object.assign({}, state, { todos: [ ...state.todos.slice(0, action.index), Object.assign({}, state.todos[action.index], { completed: true }), ...state.todos.slice(action.index + 1) ] }) ``` Because we want to update a specific item in the array without resorting to mutations, we have to slice it before and after the item. If you find yourself often writing such operations, it’s a good idea to use a helper like [react-addons-update](https://facebook.github.io/react/docs/update.html), [updeep](https://github.com/substantial/updeep), or even a library like [Immutable](http://facebook.github.io/immutable-js/) that has native support for deep updates. Just remember to never assign to anything inside the `state` unless you clone it first. ## Splitting Reducers Here is our code so far. It is rather verbose: ```js function todoApp(state = initialState, action) { switch (action.type) { case SET_VISIBILITY_FILTER: return Object.assign({}, state, { visibilityFilter: action.filter }) case ADD_TODO: return Object.assign({}, state, { todos: [ ...state.todos, { text: action.text, completed: false } ] }) case COMPLETE_TODO: return Object.assign({}, state, { todos: [ ...state.todos.slice(0, action.index), Object.assign({}, state.todos[action.index], { completed: true }), ...state.todos.slice(action.index + 1) ] }) default: return state } } ``` Is there a way to make it easier to comprehend? It seems like `todos` and `visibilityFilter` are updated completely independently. Sometimes state fields depend on one another and more consideration is required, but in our case we can easily split updating `todos` into a separate function: ```js function todos(state = [], action) { switch (action.type) { case ADD_TODO: return [ ...state, { text: action.text, completed: false } ] case COMPLETE_TODO: return [ ...state.slice(0, action.index), Object.assign({}, state[action.index], { completed: true }), ...state.slice(action.index + 1) ] default: return state } } function todoApp(state = initialState, action) { switch (action.type) { case SET_VISIBILITY_FILTER: return Object.assign({}, state, { visibilityFilter: action.filter }) case ADD_TODO: case COMPLETE_TODO: return Object.assign({}, state, { todos: todos(state.todos, action) }) default: return state } } ``` Note that `todos` also accepts `state`—but it’s an array! Now `todoApp` just gives it the slice of the state to manage, and `todos` knows how to update just that slice. **This is called *reducer composition*, and it’s the fundamental pattern of building Redux apps.** Let’s explore reducer composition more. Can we also extract a reducer managing just `visibilityFilter`? We can: ```js function visibilityFilter(state = SHOW_ALL, action) { switch (action.type) { case SET_VISIBILITY_FILTER: return action.filter default: return state } } ``` Now we can rewrite the main reducer as a function that calls the reducers managing parts of the state, and combines them into a single object. It also doesn’t need to know the complete initial state anymore. It’s enough that the child reducers return their initial state when given `undefined` at first. ```js function todos(state = [], action) { switch (action.type) { case ADD_TODO: return [ ...state, { text: action.text, completed: false } ] case COMPLETE_TODO: return [ ...state.slice(0, action.index), Object.assign({}, state[action.index], { completed: true }), ...state.slice(action.index + 1) ] default: return state } } function visibilityFilter(state = SHOW_ALL, action) { switch (action.type) { case SET_VISIBILITY_FILTER: return action.filter default: return state } } function todoApp(state = {}, action) { return { visibilityFilter: visibilityFilter(state.visibilityFilter, action), todos: todos(state.todos, action) } } ``` **Note that each of these reducers is managing its own part of the global state. The `state` parameter is different for every reducer, and corresponds to the part of the state it manages.** This is already looking good! When the app is larger, we can split the reducers into separate files and keep them completely independent and managing different data domains. Finally, Redux provides a utility called [`combineReducers()`](../api/combineReducers.md) that does the same boilerplate logic that the `todoApp` above currently does. With its help, we can rewrite `todoApp` like this: ```js import { combineReducers } from 'redux' const todoApp = combineReducers({ visibilityFilter, todos }) export default todoApp ``` Note that this is completely equivalent to: ```js export default function todoApp(state = {}, action) { return { visibilityFilter: visibilityFilter(state.visibilityFilter, action), todos: todos(state.todos, action) } } ``` You could also give them different keys, or call functions differently. These two ways to write a combined reducer are completely equivalent: ```js const reducer = combineReducers({ a: doSomethingWithA, b: processB, c: c }) ``` ```js function reducer(state, action) { return { a: doSomethingWithA(state.a, action), b: processB(state.b, action), c: c(state.c, action) } } ``` All [`combineReducers()`](../api/combineReducers.md) does is generate a function that calls your reducers **with the slices of state selected according to their keys**, and combining their results into a single object again. [It’s not magic.](https://github.com/rackt/redux/issues/428#issuecomment-129223274) >##### Note for ES6 Savvy Users >Because `combineReducers` expects an object, we can put all top-level reducers into a separate file, `export` each reducer function, and use `import * as reducers` to get them as an object with their names as the keys: >```js >import { combineReducers } from 'redux' >import * as reducers from './reducers' > >const todoApp = combineReducers(reducers) >``` > >Because `import *` is still new syntax, we don’t use it anymore in the documentation to avoid [confusion](https://github.com/rackt/redux/issues/428#issuecomment-129223274), but you may encounter it in some community examples. ## Source Code #### `reducers.js` ```js import { combineReducers } from 'redux' import { ADD_TODO, COMPLETE_TODO, SET_VISIBILITY_FILTER, VisibilityFilters } from './actions' const { SHOW_ALL } = VisibilityFilters function visibilityFilter(state = SHOW_ALL, action) { switch (action.type) { case SET_VISIBILITY_FILTER: return action.filter default: return state } } function todos(state = [], action) { switch (action.type) { case ADD_TODO: return [ ...state, { text: action.text, completed: false } ] case COMPLETE_TODO: return [ ...state.slice(0, action.index), Object.assign({}, state[action.index], { completed: true }), ...state.slice(action.index + 1) ] default: return state } } const todoApp = combineReducers({ visibilityFilter, todos }) export default todoApp ``` ## Next Steps Next, we’ll explore how to [create a Redux store](Store.md) that holds the state and takes care of calling your reducer when you dispatch an action.
docs/basics/Reducers.md
0
https://github.com/reduxjs/redux/commit/872f2314838f44da9ff6dcbd5ad09f78bec5dbd6
[ 0.0004550442681647837, 0.0001843241334427148, 0.0001614296925254166, 0.00017306946392636746, 0.00005147761476109736 ]
{ "id": 3, "code_window": [ "var reduxNodeModules = path.join(__dirname, '..', '..', 'node_modules')\n", "var fs = require('fs')\n", "if (fs.existsSync(reduxSrc) && fs.existsSync(reduxNodeModules)) {\n", " // Resolve Redux to source\n", " module.exports.resolve = { alias: { 'redux': reduxSrc } }\n", " // Compile Redux from source\n", " module.exports.module.loaders.push({\n", " test: /\\.js$/,\n", " loaders: [ 'babel' ],\n" ], "labels": [ "keep", "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ], "after_edit": [ " // Our root .babelrc needs this flag for CommonJS output\n", " process.env.BABEL_ENV = 'commonjs'\n" ], "file_path": "examples/shopping-cart/webpack.config.js", "type": "add", "edit_start_line_idx": 46 }
var path = require('path') var webpack = require('webpack') module.exports = { devtool: 'cheap-module-eval-source-map', entry: [ 'webpack-hot-middleware/client', './index' ], output: { path: path.join(__dirname, 'dist'), filename: 'bundle.js', publicPath: '/static/' }, plugins: [ new webpack.optimize.OccurenceOrderPlugin(), new webpack.HotModuleReplacementPlugin(), new webpack.NoErrorsPlugin() ], module: { loaders: [ { test: /\.js$/, loaders: [ 'babel' ], exclude: /node_modules/, include: __dirname }, { test: /\.css?$/, loaders: [ 'style', 'raw' ], include: __dirname } ] } } // When inside Redux repo, prefer src to compiled version. // You can safely delete these lines in your project. var reduxSrc = path.join(__dirname, '..', '..', 'src') var reduxNodeModules = path.join(__dirname, '..', '..', 'node_modules') var fs = require('fs') if (fs.existsSync(reduxSrc) && fs.existsSync(reduxNodeModules)) { // Resolve Redux to source module.exports.resolve = { alias: { 'redux': reduxSrc } } // Compile Redux from source module.exports.module.loaders.push({ test: /\.js$/, loaders: [ 'babel' ], include: reduxSrc }) }
examples/todomvc/webpack.config.js
1
https://github.com/reduxjs/redux/commit/872f2314838f44da9ff6dcbd5ad09f78bec5dbd6
[ 0.998731791973114, 0.16756278276443481, 0.00016688572941347957, 0.0019060637569054961, 0.3717109262943268 ]
{ "id": 3, "code_window": [ "var reduxNodeModules = path.join(__dirname, '..', '..', 'node_modules')\n", "var fs = require('fs')\n", "if (fs.existsSync(reduxSrc) && fs.existsSync(reduxNodeModules)) {\n", " // Resolve Redux to source\n", " module.exports.resolve = { alias: { 'redux': reduxSrc } }\n", " // Compile Redux from source\n", " module.exports.module.loaders.push({\n", " test: /\\.js$/,\n", " loaders: [ 'babel' ],\n" ], "labels": [ "keep", "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ], "after_edit": [ " // Our root .babelrc needs this flag for CommonJS output\n", " process.env.BABEL_ENV = 'commonjs'\n" ], "file_path": "examples/shopping-cart/webpack.config.js", "type": "add", "edit_start_line_idx": 46 }
import React, { PropTypes } from 'react' import Todo from './Todo' const TodoList = ({ todos, onTodoClick }) => ( <ul> {todos.map(todo => <Todo key={todo.id} {...todo} onClick={() => onTodoClick(todo.id)} /> )} </ul> ) TodoList.propTypes = { todos: PropTypes.arrayOf(PropTypes.shape({ id: PropTypes.number.isRequired, completed: PropTypes.bool.isRequired, text: PropTypes.string.isRequired }).isRequired).isRequired, onTodoClick: PropTypes.func.isRequired } export default TodoList
examples/todos/components/TodoList.js
0
https://github.com/reduxjs/redux/commit/872f2314838f44da9ff6dcbd5ad09f78bec5dbd6
[ 0.00017622245650272816, 0.00017387409752700478, 0.0001718315324978903, 0.00017356830358039588, 0.0000018055812915918068 ]
{ "id": 3, "code_window": [ "var reduxNodeModules = path.join(__dirname, '..', '..', 'node_modules')\n", "var fs = require('fs')\n", "if (fs.existsSync(reduxSrc) && fs.existsSync(reduxNodeModules)) {\n", " // Resolve Redux to source\n", " module.exports.resolve = { alias: { 'redux': reduxSrc } }\n", " // Compile Redux from source\n", " module.exports.module.loaders.push({\n", " test: /\\.js$/,\n", " loaders: [ 'babel' ],\n" ], "labels": [ "keep", "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ], "after_edit": [ " // Our root .babelrc needs this flag for CommonJS output\n", " process.env.BABEL_ENV = 'commonjs'\n" ], "file_path": "examples/shopping-cart/webpack.config.js", "type": "add", "edit_start_line_idx": 46 }
const visibilityFilter = (state = 'SHOW_ALL', action) => { switch (action.type) { case 'SET_VISIBILITY_FILTER': return action.filter default: return state } } export default visibilityFilter
examples/todos-with-undo/reducers/visibilityFilter.js
0
https://github.com/reduxjs/redux/commit/872f2314838f44da9ff6dcbd5ad09f78bec5dbd6
[ 0.00017857583588920534, 0.00017482326074969023, 0.00017107068561017513, 0.00017482326074969023, 0.000003752575139515102 ]
{ "id": 3, "code_window": [ "var reduxNodeModules = path.join(__dirname, '..', '..', 'node_modules')\n", "var fs = require('fs')\n", "if (fs.existsSync(reduxSrc) && fs.existsSync(reduxNodeModules)) {\n", " // Resolve Redux to source\n", " module.exports.resolve = { alias: { 'redux': reduxSrc } }\n", " // Compile Redux from source\n", " module.exports.module.loaders.push({\n", " test: /\\.js$/,\n", " loaders: [ 'babel' ],\n" ], "labels": [ "keep", "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ], "after_edit": [ " // Our root .babelrc needs this flag for CommonJS output\n", " process.env.BABEL_ENV = 'commonjs'\n" ], "file_path": "examples/shopping-cart/webpack.config.js", "type": "add", "edit_start_line_idx": 46 }
import React, { PropTypes } from 'react' const Todo = ({ onClick, completed, text }) => ( <li onClick={onClick} style={{ textDecoration: completed ? 'line-through' : 'none' }} > {text} </li> ) Todo.propTypes = { onClick: PropTypes.func.isRequired, completed: PropTypes.bool.isRequired, text: PropTypes.string.isRequired } export default Todo
examples/todos-with-undo/components/Todo.js
0
https://github.com/reduxjs/redux/commit/872f2314838f44da9ff6dcbd5ad09f78bec5dbd6
[ 0.00017857583588920534, 0.0001758599391905591, 0.00017375938477925956, 0.0001752445677993819, 0.000002013877292483812 ]
{ "id": 4, "code_window": [ "var reduxNodeModules = path.join(__dirname, '..', '..', 'node_modules')\n", "var fs = require('fs')\n", "if (fs.existsSync(reduxSrc) && fs.existsSync(reduxNodeModules)) {\n", " // Resolve Redux to source\n", " module.exports.resolve = { alias: { 'redux': reduxSrc } }\n", " // Compile Redux from source\n", " module.exports.module.loaders.push({\n", " test: /\\.js$/,\n" ], "labels": [ "keep", "keep", "keep", "keep", "add", "keep", "keep", "keep" ], "after_edit": [ " // Our root .babelrc needs this flag for CommonJS output\n", " process.env.BABEL_ENV = 'commonjs'\n" ], "file_path": "examples/todomvc/webpack.config.js", "type": "add", "edit_start_line_idx": 45 }
var path = require('path') var webpack = require('webpack') module.exports = { devtool: 'cheap-module-eval-source-map', entry: [ 'webpack-hot-middleware/client', './index' ], output: { path: path.join(__dirname, 'dist'), filename: 'bundle.js', publicPath: '/static/' }, plugins: [ new webpack.optimize.OccurenceOrderPlugin(), new webpack.HotModuleReplacementPlugin(), new webpack.NoErrorsPlugin() ], module: { loaders: [ { test: /\.js$/, loaders: [ 'babel' ], exclude: /node_modules/, include: __dirname } ] } } // When inside Redux repo, prefer src to compiled version. // You can safely delete these lines in your project. var reduxSrc = path.join(__dirname, '..', '..', 'src') var reduxNodeModules = path.join(__dirname, '..', '..', 'node_modules') var fs = require('fs') if (fs.existsSync(reduxSrc) && fs.existsSync(reduxNodeModules)) { // Resolve Redux to source module.exports.resolve = { alias: { 'redux': reduxSrc } } // Compile Redux from source module.exports.module.loaders.push({ test: /\.js$/, loaders: [ 'babel' ], include: reduxSrc }) }
examples/counter/webpack.config.js
1
https://github.com/reduxjs/redux/commit/872f2314838f44da9ff6dcbd5ad09f78bec5dbd6
[ 0.9984843134880066, 0.21709807217121124, 0.00029117235681042075, 0.0025004607159644365, 0.3920067250728607 ]
{ "id": 4, "code_window": [ "var reduxNodeModules = path.join(__dirname, '..', '..', 'node_modules')\n", "var fs = require('fs')\n", "if (fs.existsSync(reduxSrc) && fs.existsSync(reduxNodeModules)) {\n", " // Resolve Redux to source\n", " module.exports.resolve = { alias: { 'redux': reduxSrc } }\n", " // Compile Redux from source\n", " module.exports.module.loaders.push({\n", " test: /\\.js$/,\n" ], "labels": [ "keep", "keep", "keep", "keep", "add", "keep", "keep", "keep" ], "after_edit": [ " // Our root .babelrc needs this flag for CommonJS output\n", " process.env.BABEL_ENV = 'commonjs'\n" ], "file_path": "examples/todomvc/webpack.config.js", "type": "add", "edit_start_line_idx": 45 }
let nextTodoId = 0 export const addTodo = (text) => { return { type: 'ADD_TODO', id: nextTodoId++, text } } export const setVisibilityFilter = (filter) => { return { type: 'SET_VISIBILITY_FILTER', filter } } export const toggleTodo = (id) => { return { type: 'TOGGLE_TODO', id } }
examples/todos/actions/index.js
0
https://github.com/reduxjs/redux/commit/872f2314838f44da9ff6dcbd5ad09f78bec5dbd6
[ 0.00017559013213030994, 0.00017007662972901016, 0.00016721099382266402, 0.00016742876323405653, 0.0000038996481634967495 ]
{ "id": 4, "code_window": [ "var reduxNodeModules = path.join(__dirname, '..', '..', 'node_modules')\n", "var fs = require('fs')\n", "if (fs.existsSync(reduxSrc) && fs.existsSync(reduxNodeModules)) {\n", " // Resolve Redux to source\n", " module.exports.resolve = { alias: { 'redux': reduxSrc } }\n", " // Compile Redux from source\n", " module.exports.module.loaders.push({\n", " test: /\\.js$/,\n" ], "labels": [ "keep", "keep", "keep", "keep", "add", "keep", "keep", "keep" ], "after_edit": [ " // Our root .babelrc needs this flag for CommonJS output\n", " process.env.BABEL_ENV = 'commonjs'\n" ], "file_path": "examples/todomvc/webpack.config.js", "type": "add", "edit_start_line_idx": 45 }
if (process.env.NODE_ENV === 'production') { module.exports = require('./configureStore.prod') } else { module.exports = require('./configureStore.dev') }
examples/real-world/store/configureStore.js
0
https://github.com/reduxjs/redux/commit/872f2314838f44da9ff6dcbd5ad09f78bec5dbd6
[ 0.00080298405373469, 0.00080298405373469, 0.00080298405373469, 0.00080298405373469, 0 ]
{ "id": 4, "code_window": [ "var reduxNodeModules = path.join(__dirname, '..', '..', 'node_modules')\n", "var fs = require('fs')\n", "if (fs.existsSync(reduxSrc) && fs.existsSync(reduxNodeModules)) {\n", " // Resolve Redux to source\n", " module.exports.resolve = { alias: { 'redux': reduxSrc } }\n", " // Compile Redux from source\n", " module.exports.module.loaders.push({\n", " test: /\\.js$/,\n" ], "labels": [ "keep", "keep", "keep", "keep", "add", "keep", "keep", "keep" ], "after_edit": [ " // Our root .babelrc needs this flag for CommonJS output\n", " process.env.BABEL_ENV = 'commonjs'\n" ], "file_path": "examples/todomvc/webpack.config.js", "type": "add", "edit_start_line_idx": 45 }
import { combineReducers } from 'redux' import todos from './todos' import visibilityFilter from './visibilityFilter' const todoApp = combineReducers({ todos, visibilityFilter }) export default todoApp
examples/todos-with-undo/reducers/index.js
0
https://github.com/reduxjs/redux/commit/872f2314838f44da9ff6dcbd5ad09f78bec5dbd6
[ 0.00021351201576180756, 0.00018988542433362454, 0.00016625883290544152, 0.00018988542433362454, 0.00002362659142818302 ]
{ "id": 5, "code_window": [ "if (fs.existsSync(reduxSrc) && fs.existsSync(reduxNodeModules)) {\n", " // Resolve Redux to source\n", " module.exports.resolve = { alias: { 'redux': reduxSrc } }\n", " // Compile Redux from source\n", " module.exports.module.loaders.push({\n", " test: /\\.js$/,\n", " loaders: ['babel'],\n" ], "labels": [ "keep", "keep", "add", "keep", "keep", "keep", "keep" ], "after_edit": [ " // Our root .babelrc needs this flag for CommonJS output\n", " process.env.BABEL_ENV = 'commonjs'\n" ], "file_path": "examples/todos-with-undo/webpack.config.js", "type": "add", "edit_start_line_idx": 38 }
var path = require('path') var webpack = require('webpack') module.exports = { devtool: 'cheap-module-eval-source-map', entry: [ 'webpack-hot-middleware/client', './index' ], output: { path: path.join(__dirname, 'dist'), filename: 'bundle.js', publicPath: '/static/' }, plugins: [ new webpack.optimize.OccurenceOrderPlugin(), new webpack.HotModuleReplacementPlugin(), new webpack.NoErrorsPlugin() ], module: { loaders: [ { test: /\.js$/, loaders: [ 'babel' ], exclude: /node_modules/, include: __dirname }, { test: /\.json$/, loaders: [ 'json' ], exclude: /node_modules/, include: __dirname } ] } } // When inside Redux repo, prefer src to compiled version. // You can safely delete these lines in your project. var reduxSrc = path.join(__dirname, '..', '..', 'src') var reduxNodeModules = path.join(__dirname, '..', '..', 'node_modules') var fs = require('fs') if (fs.existsSync(reduxSrc) && fs.existsSync(reduxNodeModules)) { // Resolve Redux to source module.exports.resolve = { alias: { 'redux': reduxSrc } } // Compile Redux from source module.exports.module.loaders.push({ test: /\.js$/, loaders: [ 'babel' ], include: reduxSrc }) }
examples/shopping-cart/webpack.config.js
1
https://github.com/reduxjs/redux/commit/872f2314838f44da9ff6dcbd5ad09f78bec5dbd6
[ 0.9968530535697937, 0.1668204516172409, 0.00023471741587854922, 0.000512785161845386, 0.3712027370929718 ]
{ "id": 5, "code_window": [ "if (fs.existsSync(reduxSrc) && fs.existsSync(reduxNodeModules)) {\n", " // Resolve Redux to source\n", " module.exports.resolve = { alias: { 'redux': reduxSrc } }\n", " // Compile Redux from source\n", " module.exports.module.loaders.push({\n", " test: /\\.js$/,\n", " loaders: ['babel'],\n" ], "labels": [ "keep", "keep", "add", "keep", "keep", "keep", "keep" ], "after_edit": [ " // Our root .babelrc needs this flag for CommonJS output\n", " process.env.BABEL_ENV = 'commonjs'\n" ], "file_path": "examples/todos-with-undo/webpack.config.js", "type": "add", "edit_start_line_idx": 38 }
import { ADD_TODO, DELETE_TODO, EDIT_TODO, COMPLETE_TODO, COMPLETE_ALL, CLEAR_COMPLETED } from '../constants/ActionTypes' const initialState = [ { text: 'Use Redux', completed: false, id: 0 } ] export default function todos(state = initialState, action) { switch (action.type) { case ADD_TODO: return [ { id: state.reduce((maxId, todo) => Math.max(todo.id, maxId), -1) + 1, completed: false, text: action.text }, ...state ] case DELETE_TODO: return state.filter(todo => todo.id !== action.id ) case EDIT_TODO: return state.map(todo => todo.id === action.id ? Object.assign({}, todo, { text: action.text }) : todo ) case COMPLETE_TODO: return state.map(todo => todo.id === action.id ? Object.assign({}, todo, { completed: !todo.completed }) : todo ) case COMPLETE_ALL: const areAllMarked = state.every(todo => todo.completed) return state.map(todo => Object.assign({}, todo, { completed: !areAllMarked })) case CLEAR_COMPLETED: return state.filter(todo => todo.completed === false) default: return state } }
examples/todomvc/reducers/todos.js
0
https://github.com/reduxjs/redux/commit/872f2314838f44da9ff6dcbd5ad09f78bec5dbd6
[ 0.00048240646719932556, 0.00022422528127208352, 0.0001667708856984973, 0.00017505238065496087, 0.00011550546332728118 ]
{ "id": 5, "code_window": [ "if (fs.existsSync(reduxSrc) && fs.existsSync(reduxNodeModules)) {\n", " // Resolve Redux to source\n", " module.exports.resolve = { alias: { 'redux': reduxSrc } }\n", " // Compile Redux from source\n", " module.exports.module.loaders.push({\n", " test: /\\.js$/,\n", " loaders: ['babel'],\n" ], "labels": [ "keep", "keep", "add", "keep", "keep", "keep", "keep" ], "after_edit": [ " // Our root .babelrc needs this flag for CommonJS output\n", " process.env.BABEL_ENV = 'commonjs'\n" ], "file_path": "examples/todos-with-undo/webpack.config.js", "type": "add", "edit_start_line_idx": 38 }
import React, { Component, PropTypes } from 'react' import TodoItem from './TodoItem' import Footer from './Footer' import { SHOW_ALL, SHOW_COMPLETED, SHOW_ACTIVE } from '../constants/TodoFilters' const TODO_FILTERS = { [SHOW_ALL]: () => true, [SHOW_ACTIVE]: todo => !todo.completed, [SHOW_COMPLETED]: todo => todo.completed } class MainSection extends Component { constructor(props, context) { super(props, context) this.state = { filter: SHOW_ALL } } handleClearCompleted() { this.props.actions.clearCompleted() } handleShow(filter) { this.setState({ filter }) } renderToggleAll(completedCount) { const { todos, actions } = this.props if (todos.length > 0) { return ( <input className="toggle-all" type="checkbox" checked={completedCount === todos.length} onChange={actions.completeAll} /> ) } } renderFooter(completedCount) { const { todos } = this.props const { filter } = this.state const activeCount = todos.length - completedCount if (todos.length) { return ( <Footer completedCount={completedCount} activeCount={activeCount} filter={filter} onClearCompleted={this.handleClearCompleted.bind(this)} onShow={this.handleShow.bind(this)} /> ) } } render() { const { todos, actions } = this.props const { filter } = this.state const filteredTodos = todos.filter(TODO_FILTERS[filter]) const completedCount = todos.reduce((count, todo) => todo.completed ? count + 1 : count, 0 ) return ( <section className="main"> {this.renderToggleAll(completedCount)} <ul className="todo-list"> {filteredTodos.map(todo => <TodoItem key={todo.id} todo={todo} {...actions} /> )} </ul> {this.renderFooter(completedCount)} </section> ) } } MainSection.propTypes = { todos: PropTypes.array.isRequired, actions: PropTypes.object.isRequired } export default MainSection
examples/todomvc/components/MainSection.js
0
https://github.com/reduxjs/redux/commit/872f2314838f44da9ff6dcbd5ad09f78bec5dbd6
[ 0.0001776145218173042, 0.0001715373364277184, 0.00016600728849880397, 0.00017224096518475562, 0.0000034044439871649956 ]
{ "id": 5, "code_window": [ "if (fs.existsSync(reduxSrc) && fs.existsSync(reduxNodeModules)) {\n", " // Resolve Redux to source\n", " module.exports.resolve = { alias: { 'redux': reduxSrc } }\n", " // Compile Redux from source\n", " module.exports.module.loaders.push({\n", " test: /\\.js$/,\n", " loaders: ['babel'],\n" ], "labels": [ "keep", "keep", "add", "keep", "keep", "keep", "keep" ], "after_edit": [ " // Our root .babelrc needs this flag for CommonJS output\n", " process.env.BABEL_ENV = 'commonjs'\n" ], "file_path": "examples/todos-with-undo/webpack.config.js", "type": "add", "edit_start_line_idx": 38 }
import 'babel-polyfill' import React from 'react' import { render } from 'react-dom' import { Provider } from 'react-redux' import configureStore from '../common/store/configureStore' import App from '../common/containers/App' const initialState = window.__INITIAL_STATE__ const store = configureStore(initialState) const rootElement = document.getElementById('app') render( <Provider store={store}> <App/> </Provider>, rootElement )
examples/universal/client/index.js
0
https://github.com/reduxjs/redux/commit/872f2314838f44da9ff6dcbd5ad09f78bec5dbd6
[ 0.00017037037468980998, 0.00016848306404426694, 0.00016659573884680867, 0.00016848306404426694, 0.000001887317921500653 ]
{ "id": 6, "code_window": [ "var reduxNodeModules = path.join(__dirname, '..', '..', 'node_modules')\n", "var fs = require('fs')\n", "if (fs.existsSync(reduxSrc) && fs.existsSync(reduxNodeModules)) {\n", " // Resolve Redux to source\n", " module.exports.resolve = { alias: { 'redux': reduxSrc } }\n", " // Compile Redux from source\n", " module.exports.module.loaders.push({\n", " test: /\\.js$/,\n" ], "labels": [ "keep", "keep", "keep", "keep", "add", "keep", "keep", "keep" ], "after_edit": [ " // Our root .babelrc needs this flag for CommonJS output\n", " process.env.BABEL_ENV = 'commonjs'\n" ], "file_path": "examples/todos/webpack.config.js", "type": "add", "edit_start_line_idx": 40 }
var path = require('path') var webpack = require('webpack') module.exports = { devtool: 'cheap-module-eval-source-map', entry: [ 'webpack-hot-middleware/client', './index' ], output: { path: path.join(__dirname, 'dist'), filename: 'bundle.js', publicPath: '/static/' }, plugins: [ new webpack.optimize.OccurenceOrderPlugin(), new webpack.HotModuleReplacementPlugin(), new webpack.NoErrorsPlugin() ], module: { loaders: [ { test: /\.js$/, loaders: [ 'babel' ], exclude: /node_modules/, include: __dirname } ] } } // When inside Redux repo, prefer src to compiled version. // You can safely delete these lines in your project. var reduxSrc = path.join(__dirname, '..', '..', 'src') var reduxNodeModules = path.join(__dirname, '..', '..', 'node_modules') var fs = require('fs') if (fs.existsSync(reduxSrc) && fs.existsSync(reduxNodeModules)) { // Resolve Redux to source module.exports.resolve = { alias: { 'redux': reduxSrc } } // Compile Redux from source module.exports.module.loaders.push({ test: /\.js$/, loaders: [ 'babel' ], include: reduxSrc }) }
examples/todos/webpack.config.js
1
https://github.com/reduxjs/redux/commit/872f2314838f44da9ff6dcbd5ad09f78bec5dbd6
[ 0.9984843134880066, 0.21709807217121124, 0.00029117235681042075, 0.0025004607159644365, 0.3920067250728607 ]
{ "id": 6, "code_window": [ "var reduxNodeModules = path.join(__dirname, '..', '..', 'node_modules')\n", "var fs = require('fs')\n", "if (fs.existsSync(reduxSrc) && fs.existsSync(reduxNodeModules)) {\n", " // Resolve Redux to source\n", " module.exports.resolve = { alias: { 'redux': reduxSrc } }\n", " // Compile Redux from source\n", " module.exports.module.loaders.push({\n", " test: /\\.js$/,\n" ], "labels": [ "keep", "keep", "keep", "keep", "add", "keep", "keep", "keep" ], "after_edit": [ " // Our root .babelrc needs this flag for CommonJS output\n", " process.env.BABEL_ENV = 'commonjs'\n" ], "file_path": "examples/todos/webpack.config.js", "type": "add", "edit_start_line_idx": 40 }
import isPlainObject from 'lodash/isPlainObject' /** * These are private action types reserved by Redux. * For any unknown actions, you must return the current state. * If the current state is undefined, you must return the initial state. * Do not reference these action types directly in your code. */ export var ActionTypes = { INIT: '@@redux/INIT' } /** * Creates a Redux store that holds the state tree. * The only way to change the data in the store is to call `dispatch()` on it. * * There should only be a single store in your app. To specify how different * parts of the state tree respond to actions, you may combine several reducers * into a single reducer function by using `combineReducers`. * * @param {Function} reducer A function that returns the next state tree, given * the current state tree and the action to handle. * * @param {any} [initialState] The initial state. You may optionally specify it * to hydrate the state from the server in universal apps, or to restore a * previously serialized user session. * If you use `combineReducers` to produce the root reducer function, this must be * an object with the same shape as `combineReducers` keys. * * @param {Function} enhancer The store enhancer. You may optionally specify it * to enhance the store with third-party capabilities such as middleware, * time travel, persistence, etc. The only store enhancer that ships with Redux * is `applyMiddleware()`. * * @returns {Store} A Redux store that lets you read the state, dispatch actions * and subscribe to changes. */ export default function createStore(reducer, initialState, enhancer) { if (typeof initialState === 'function' && typeof enhancer === 'undefined') { enhancer = initialState initialState = undefined } if (typeof enhancer !== 'undefined') { if (typeof enhancer !== 'function') { throw new Error('Expected the enhancer to be a function.') } return enhancer(createStore)(reducer, initialState) } if (typeof reducer !== 'function') { throw new Error('Expected the reducer to be a function.') } var currentReducer = reducer var currentState = initialState var currentListeners = [] var nextListeners = currentListeners var isDispatching = false function ensureCanMutateNextListeners() { if (nextListeners === currentListeners) { nextListeners = currentListeners.slice() } } /** * Reads the state tree managed by the store. * * @returns {any} The current state tree of your application. */ function getState() { return currentState } /** * Adds a change listener. It will be called any time an action is dispatched, * and some part of the state tree may potentially have changed. You may then * call `getState()` to read the current state tree inside the callback. * * You may call `dispatch()` from a change listener, with the following * caveats: * * 1. The subscriptions are snapshotted just before every `dispatch()` call. * If you subscribe or unsubscribe while the listeners are being invoked, this * will not have any effect on the `dispatch()` that is currently in progress. * However, the next `dispatch()` call, whether nested or not, will use a more * recent snapshot of the subscription list. * * 2. The listener should not expect to see all states changes, as the state * might have been updated multiple times during a nested `dispatch()` before * the listener is called. It is, however, guaranteed that all subscribers * registered before the `dispatch()` started will be called with the latest * state by the time it exits. * * @param {Function} listener A callback to be invoked on every dispatch. * @returns {Function} A function to remove this change listener. */ function subscribe(listener) { if (typeof listener !== 'function') { throw new Error('Expected listener to be a function.') } var isSubscribed = true ensureCanMutateNextListeners() nextListeners.push(listener) return function unsubscribe() { if (!isSubscribed) { return } isSubscribed = false ensureCanMutateNextListeners() var index = nextListeners.indexOf(listener) nextListeners.splice(index, 1) } } /** * Dispatches an action. It is the only way to trigger a state change. * * The `reducer` function, used to create the store, will be called with the * current state tree and the given `action`. Its return value will * be considered the **next** state of the tree, and the change listeners * will be notified. * * The base implementation only supports plain object actions. If you want to * dispatch a Promise, an Observable, a thunk, or something else, you need to * wrap your store creating function into the corresponding middleware. For * example, see the documentation for the `redux-thunk` package. Even the * middleware will eventually dispatch plain object actions using this method. * * @param {Object} action A plain object representing “what changed”. It is * a good idea to keep actions serializable so you can record and replay user * sessions, or use the time travelling `redux-devtools`. An action must have * a `type` property which may not be `undefined`. It is a good idea to use * string constants for action types. * * @returns {Object} For convenience, the same action object you dispatched. * * Note that, if you use a custom middleware, it may wrap `dispatch()` to * return something else (for example, a Promise you can await). */ function dispatch(action) { if (!isPlainObject(action)) { throw new Error( 'Actions must be plain objects. ' + 'Use custom middleware for async actions.' ) } if (typeof action.type === 'undefined') { throw new Error( 'Actions may not have an undefined "type" property. ' + 'Have you misspelled a constant?' ) } if (isDispatching) { throw new Error('Reducers may not dispatch actions.') } try { isDispatching = true currentState = currentReducer(currentState, action) } finally { isDispatching = false } var listeners = currentListeners = nextListeners for (var i = 0; i < listeners.length; i++) { listeners[i]() } return action } /** * Replaces the reducer currently used by the store to calculate the state. * * You might need this if your app implements code splitting and you want to * load some of the reducers dynamically. You might also need this if you * implement a hot reloading mechanism for Redux. * * @param {Function} nextReducer The reducer for the store to use instead. * @returns {void} */ function replaceReducer(nextReducer) { if (typeof nextReducer !== 'function') { throw new Error('Expected the nextReducer to be a function.') } currentReducer = nextReducer dispatch({ type: ActionTypes.INIT }) } // When a store is created, an "INIT" action is dispatched so that every // reducer returns their initial state. This effectively populates // the initial state tree. dispatch({ type: ActionTypes.INIT }) return { dispatch, subscribe, getState, replaceReducer } }
src/createStore.js
0
https://github.com/reduxjs/redux/commit/872f2314838f44da9ff6dcbd5ad09f78bec5dbd6
[ 0.0002500648843124509, 0.000169558115885593, 0.00016020418843254447, 0.00016602009418420494, 0.000017842390661826357 ]
{ "id": 6, "code_window": [ "var reduxNodeModules = path.join(__dirname, '..', '..', 'node_modules')\n", "var fs = require('fs')\n", "if (fs.existsSync(reduxSrc) && fs.existsSync(reduxNodeModules)) {\n", " // Resolve Redux to source\n", " module.exports.resolve = { alias: { 'redux': reduxSrc } }\n", " // Compile Redux from source\n", " module.exports.module.loaders.push({\n", " test: /\\.js$/,\n" ], "labels": [ "keep", "keep", "keep", "keep", "add", "keep", "keep", "keep" ], "after_edit": [ " // Our root .babelrc needs this flag for CommonJS output\n", " process.env.BABEL_ENV = 'commonjs'\n" ], "file_path": "examples/todos/webpack.config.js", "type": "add", "edit_start_line_idx": 40 }
# Patrons The work on Redux was [funded by the community](https://www.patreon.com/reactdx). Meet some of the outstanding companies and individuals that made it possible: * [Webflow](https://github.com/webflow) * [Ximedes](https://www.ximedes.com/) * [Herman J. Radtke III](http://hermanradtke.com) * [Ken Wheeler](http://kenwheeler.github.io/) * [Chung Yen Li](https://www.facebook.com/prototocal.lee) * [Sunil Pai](https://twitter.com/threepointone) * [Charlie Cheever](https://twitter.com/ccheever) * [Eugene G](https://twitter.com/e1g) * [Matt Apperson](https://twitter.com/mattapperson) * [Jed Watson](https://twitter.com/jedwatson) * [Sasha Aickin](https://twitter.com/xander76) * [Stefan Tennigkeit](https://twitter.com/whobubble) * [Sam Vincent](https://twitter.com/samvincent) * Olegzandr Denman
PATRONS.md
0
https://github.com/reduxjs/redux/commit/872f2314838f44da9ff6dcbd5ad09f78bec5dbd6
[ 0.0001687227195361629, 0.00016549279098398983, 0.00016226287698373199, 0.00016549279098398983, 0.000003229921276215464 ]
{ "id": 6, "code_window": [ "var reduxNodeModules = path.join(__dirname, '..', '..', 'node_modules')\n", "var fs = require('fs')\n", "if (fs.existsSync(reduxSrc) && fs.existsSync(reduxNodeModules)) {\n", " // Resolve Redux to source\n", " module.exports.resolve = { alias: { 'redux': reduxSrc } }\n", " // Compile Redux from source\n", " module.exports.module.loaders.push({\n", " test: /\\.js$/,\n" ], "labels": [ "keep", "keep", "keep", "keep", "add", "keep", "keep", "keep" ], "after_edit": [ " // Our root .babelrc needs this flag for CommonJS output\n", " process.env.BABEL_ENV = 'commonjs'\n" ], "file_path": "examples/todos/webpack.config.js", "type": "add", "edit_start_line_idx": 40 }
import expect from 'expect' import React from 'react' import TestUtils from 'react-addons-test-utils' import Header from '../../components/Header' import TodoTextInput from '../../components/TodoTextInput' function setup() { const props = { addTodo: expect.createSpy() } const renderer = TestUtils.createRenderer() renderer.render(<Header {...props} />) const output = renderer.getRenderOutput() return { props: props, output: output, renderer: renderer } } describe('components', () => { describe('Header', () => { it('should render correctly', () => { const { output } = setup() expect(output.type).toBe('header') expect(output.props.className).toBe('header') const [ h1, input ] = output.props.children expect(h1.type).toBe('h1') expect(h1.props.children).toBe('todos') expect(input.type).toBe(TodoTextInput) expect(input.props.newTodo).toBe(true) expect(input.props.placeholder).toBe('What needs to be done?') }) it('should call addTodo if length of text is greater than 0', () => { const { output, props } = setup() const input = output.props.children[1] input.props.onSave('') expect(props.addTodo.calls.length).toBe(0) input.props.onSave('Use Redux') expect(props.addTodo.calls.length).toBe(1) }) }) })
examples/todomvc/test/components/Header.spec.js
0
https://github.com/reduxjs/redux/commit/872f2314838f44da9ff6dcbd5ad09f78bec5dbd6
[ 0.00021351181203499436, 0.00017817066691350192, 0.00016706660971976817, 0.00017243721231352538, 0.000016240581317106262 ]
{ "id": 7, "code_window": [ "var reduxNodeModules = path.join(__dirname, '..', '..', 'node_modules')\n", "var fs = require('fs')\n", "if (fs.existsSync(reduxSrc) && fs.existsSync(reduxNodeModules)) {\n", " // Resolve Redux to source\n", " module.exports.resolve = { alias: { 'redux': reduxSrc } }\n", " // Compile Redux from source\n", " module.exports.module.loaders.push({\n", " test: /\\.js$/,\n", " loaders: [ 'babel' ],\n", " include: reduxSrc\n" ], "labels": [ "keep", "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ], "after_edit": [ " // Our root .babelrc needs this flag for CommonJS output\n", " process.env.BABEL_ENV = 'commonjs'\n" ], "file_path": "examples/tree-view/webpack.config.js", "type": "add", "edit_start_line_idx": 40 }
var path = require('path') var webpack = require('webpack') module.exports = { devtool: 'cheap-module-eval-source-map', entry: [ 'webpack-hot-middleware/client', './index' ], output: { path: path.join(__dirname, 'dist'), filename: 'bundle.js', publicPath: '/static/' }, plugins: [ new webpack.optimize.OccurenceOrderPlugin(), new webpack.HotModuleReplacementPlugin(), new webpack.NoErrorsPlugin() ], module: { loaders: [ { test: /\.js$/, loaders: ['babel'], exclude: /node_modules/, include: __dirname } ] } } // When inside Redux repo, prefer src to compiled version. // You can safely delete these lines in your project. var reduxSrc = path.join(__dirname, '..', '..', 'src') var reduxNodeModules = path.join(__dirname, '..', '..', 'node_modules') var fs = require('fs') if (fs.existsSync(reduxSrc) && fs.existsSync(reduxNodeModules)) { // Resolve Redux to source module.exports.resolve = { alias: { 'redux': reduxSrc } } // Compile Redux from source module.exports.module.loaders.push({ test: /\.js$/, loaders: ['babel'], include: reduxSrc }) }
examples/async/webpack.config.js
1
https://github.com/reduxjs/redux/commit/872f2314838f44da9ff6dcbd5ad09f78bec5dbd6
[ 0.9985215067863464, 0.20854823291301727, 0.000283763773040846, 0.0017696964787319303, 0.39529433846473694 ]
{ "id": 7, "code_window": [ "var reduxNodeModules = path.join(__dirname, '..', '..', 'node_modules')\n", "var fs = require('fs')\n", "if (fs.existsSync(reduxSrc) && fs.existsSync(reduxNodeModules)) {\n", " // Resolve Redux to source\n", " module.exports.resolve = { alias: { 'redux': reduxSrc } }\n", " // Compile Redux from source\n", " module.exports.module.loaders.push({\n", " test: /\\.js$/,\n", " loaders: [ 'babel' ],\n", " include: reduxSrc\n" ], "labels": [ "keep", "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ], "after_edit": [ " // Our root .babelrc needs this flag for CommonJS output\n", " process.env.BABEL_ENV = 'commonjs'\n" ], "file_path": "examples/tree-view/webpack.config.js", "type": "add", "edit_start_line_idx": 40 }
import React from 'react' import ReactDOM from 'react-dom' import { createStore } from 'redux' import Counter from './components/Counter' import counter from './reducers' const store = createStore(counter) const rootEl = document.getElementById('root') function render() { ReactDOM.render( <Counter value={store.getState()} onIncrement={() => store.dispatch({ type: 'INCREMENT' })} onDecrement={() => store.dispatch({ type: 'DECREMENT' })} />, rootEl ) } render() store.subscribe(render)
examples/counter/index.js
0
https://github.com/reduxjs/redux/commit/872f2314838f44da9ff6dcbd5ad09f78bec5dbd6
[ 0.00017591306823305786, 0.00017354408919345587, 0.00016916991444304585, 0.00017554929945617914, 0.000003096575255767675 ]