用量
application: application_name { label: "Application Label" url: "application_url" file: "application_file_path" sri_hash: "SRI_hash_value" mount_points: { dashboard_vis: yes | no dashboard_tile: yes | no standalone: yes | no } entitlements: { local_storage: yes | no navigation: yes | no new_window: yes | no new_window_external_urls: ["url1", "url2", ...] use_form_submit: yes | no use_embeds: yes | no use_downloads: yes | no use_iframes: yes | no use_clipboard: yes | no core_api_methods: ["api_method1", "api_method2", ...] external_api_urls: ["api_url1", "api_url2", ...] oauth2_urls: ["oauth2_url1", "oauth2_url2", ...] global_user_attributes: ["user_attribute1", "user_attribute2", ...] scoped_user_attributes: ["user_attribute1", "user_attribute2", ...] } }
|
階層
application |
預設值
無
接受
應用程式名稱和定義應用程式的子參數
特別規則
application 必須有 url 或 file 參數,但不能同時有這兩個參數
|
定義
application 參數會定義 Looker 擴充功能架構的應用程式。將擴充功能新增至專案後,具備適當權限的 Looker 使用者就能在mount_points 參數定義的位置看到擴充功能。如未指定 mount_points 參數,擴充功能會列在 Looker 選單的「應用程式」部分。
application 參數包含下列子參數:
應用程式必須有
url參數或file參數,但不得同時有這兩個參數。
label
指定應用程式名稱,這個名稱會顯示在主選單的「應用程式」部分。如果您將 LookML 模型本地化,label 即可本地化。
url
url 參數僅供開發用途,應指向開發人員電腦上執行的開發伺服器。例如:
url: "http://localhost:8080/bundle.js"
開發完成後,您可以將檔案拖曳至 Looker IDE,然後使用 file 參數指向該檔案。
file
指定定義應用程式的 JavaScript 檔案路徑 (副檔名為 .js)。路徑是相對於專案根目錄。舉例來說,這個 file 參數會指向 LookML 專案 apps 目錄中的 bundle.js 檔案:
file: "apps/bundle.js"
sri_hash
指定 Subresource Integrity (SRI) 雜湊,用於驗證 JavaScript。這項參數可與 file 或 url 參數搭配使用。sri_hash 值不得包含 sha384- 前置字元。
如果 url 指定開發伺服器,系統就會略過 sri_hash。
mount_points
mount_points 參數會決定擴充功能在 Looker UI 中的列出位置,以及是否向使用者提供擴充功能,並決定擴充功能是否會提供自己的資料。要在資訊主頁圖塊中執行的擴充功能必須指定 mount_points。如未指定 mount_points,擴充功能會列在 Looker 選單的「應用程式」部分。可使用多個 mount_points。
| 參數 | 說明 | 範例 |
|---|---|---|
dashboard_vis |
啟用後,擴充功能會顯示在探索的視覺化清單中,您可以選取擴充功能並儲存為資訊主頁圖塊。執行資訊主頁時,資訊主頁會執行與圖塊相關聯的查詢,並將資料提供給擴充功能。這與自訂視覺化的運作方式類似。自訂資料圖表與在啟用 dashboard_vis 的資訊主頁圖塊中執行的擴充功能之間的主要差異在於,擴充功能可能會發出 Looker API 呼叫。
|
dashboard_vis: yes |
dashboard_tile |
啟用後,當使用者編輯資訊主頁並點選「新增」按鈕,然後選取「擴充功能」選項時,擴充功能就會顯示在「擴充功能」面板中。這類擴充功能負責擷取自己的資料。 | dashboard_tile: yes |
standalone |
指定擴充功能是否會列在 Looker 選單的「應用程式」部分。如未指定 mount_points 參數,擴充功能的預設設定為 standalone: yes。
|
standalone: yes |
entitlements
entitlements 參數會指定擴充功能可存取的資源。除非擴充功能列於 entitlements 中,否則無法存取資源。
擴充功能應用程式必須指定授權,否則無法執行。
entitlements 參數包含下列子參數。如果未加入子參數,擴充功能預設無法存取該權利。
| 參數 | 說明 | 範例 |
|---|---|---|
local_storage |
指定擴充功能是否可存取本機儲存空間。 | local_storage: yes |
navigation |
指定擴充功能是否可前往 Looker 中的其他頁面。 | navigation: yes |
new_window |
指定擴充功能是否可開啟新的瀏覽器視窗或分頁。 | new_window: yes |
new_window_external_urls |
以半形逗號分隔的網址或部分網址清單,擴充功能可為這些網址開啟新視窗。這項授權需要 new_window 授權。您可以加入子網域和路徑的萬用字元,例如 *。
|
new_window_external_urls: ["https://www.gmail.com"] |
use_form_submit |
指定擴充功能是否可以提交表單。使用 HTML 表單的 Looker 元件需要 use_form_submit: yes 才能正常運作。
|
use_form_submit: yes |
use_embeds |
指定擴充功能是否可使用 Looker Embed SDK。 | use_embeds: yes |
use_downloads |
已新增 21.6 指定擴充功能是否可下載檔案。 | use_downloads: yes |
use_iframes |
新增 21.6 指出擴充功能是否可建立 iframe。 | use_iframes: yes |
use_clipboard |
Added 21.8 指出擴充功能是否可寫入系統剪貼簿。為確保安全性,擴充功能不得從系統剪貼簿讀取內容。 | use_clipboard: yes |
core_api_methods |
擴充功能使用的 Looker API 方法清單,以半形逗號分隔。 | core_api_methods: ["run_inline_query", "lookml_model_explore", "all_lookml_models"] |
external_api_urls |
擴充功能使用的外部 API 網址清單,以半形逗號分隔。如範例所示,您可以加入萬用字元,例如 *。從 Looker 21.6 開始,直接使用 fetch 或 XHR.open JavaScript 呼叫 (而非使用 extensionSDK.fetchProxy 或 extensionSDK.serverProxy API 呼叫) 的擴充功能,必須在清單中加入網址。
|
external_api_urls: ["http://example.com:3000", "https://*.googleapis.com"] |
oauth2_urls |
擴充功能使用的 OAuth 2.0 驗證和程式碼交換網址清單 (以半形逗號分隔)。 | oauth2_urls: ["https://accounts.google.com/o/oauth2/v2/auth"] |
global_user_attributes |
擴充功能使用的全系統使用者屬性清單 (以半形逗號分隔)。 | global_user_attributes: ["company", "department"] |
scoped_user_attributes |
擴充功能使用的擴充功能專屬使用者屬性清單 (以半形逗號分隔)。 | scoped_user_attributes: ["first_name", "last_name"] |
範例
以下是 Looker「kitchen sink」擴充功能範例的專案資訊清單檔案中的 application 參數:
application: kitchensink {
label: "Kitchen sink"
url: "http://localhost:8080/bundle.js"
entitlements: {
local_storage: yes
navigation: yes
new_window: yes
use_form_submit: yes
use_embeds: yes
core_api_methods: ["all_connections","search_folders", "run_inline_query", "me", "all_looks", "run_look"]
external_api_urls: ["http://127.0.0.1:3000", "http://localhost:3000", "https://∗.googleapis.com", "https://∗.github.com", "https://REPLACE_ME.auth0.com"]
oauth2_urls: ["https://accounts.google.com/o/oauth2/v2/auth", "https://github.com/login/oauth/authorize", "https://dev-5eqts7im.auth0.com/authorize", "https://dev-5eqts7im.auth0.com/login/oauth/token", "https://github.com/login/oauth/access_token"]
scoped_user_attributes: ["user_value"]
global_user_attributes: ["locale"]
}
}
如需其他範例,請參閱 Looker 的 extension-examples 存放區。