用量
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 嵌入 SDK。 | use_embeds: yes |
use_downloads |
新增 21.6 指定擴充功能是否可下載檔案。 | use_downloads: yes |
use_iframes |
新增 21.6 指出擴充功能是否可建立 iframe。 | use_iframes: yes |
use_clipboard |
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 存放區。