diff --git a/cmd/traefik/traefik.go b/cmd/traefik/traefik.go index 2c198abf1..d9607347e 100644 --- a/cmd/traefik/traefik.go +++ b/cmd/traefik/traefik.go @@ -205,6 +205,10 @@ func setupServer(staticConfiguration *static.Configuration) (*server.Server, err log.WithoutContext().Warn("Traefik Pilot has been removed.") } + if staticConfiguration.API != nil { + version.DisableDashboardAd = staticConfiguration.API.DisableDashboardAd + } + // Plugins pluginBuilder, err := createPluginBuilder(staticConfiguration) diff --git a/docs/content/reference/static-configuration/cli-ref.md b/docs/content/reference/static-configuration/cli-ref.md index e9385b08b..fbc3eb389 100644 --- a/docs/content/reference/static-configuration/cli-ref.md +++ b/docs/content/reference/static-configuration/cli-ref.md @@ -45,6 +45,9 @@ Activate dashboard. (Default: ```true```) `--api.debug`: Enable additional endpoints for debugging and profiling. (Default: ```false```) +`--api.disabledashboardad`: +Disable ad in the dashboard. (Default: ```false```) + `--api.insecure`: Activate API directly on the entryPoint named traefik. (Default: ```false```) diff --git a/docs/content/reference/static-configuration/env-ref.md b/docs/content/reference/static-configuration/env-ref.md index 184c4202b..9f59741ce 100644 --- a/docs/content/reference/static-configuration/env-ref.md +++ b/docs/content/reference/static-configuration/env-ref.md @@ -45,6 +45,9 @@ Activate dashboard. (Default: ```true```) `TRAEFIK_API_DEBUG`: Enable additional endpoints for debugging and profiling. (Default: ```false```) +`TRAEFIK_API_DISABLEDASHBOARDAD`: +Disable ad in the dashboard. (Default: ```false```) + `TRAEFIK_API_INSECURE`: Activate API directly on the entryPoint named traefik. (Default: ```false```) diff --git a/docs/content/reference/static-configuration/file.toml b/docs/content/reference/static-configuration/file.toml index ca95739c9..a4698a6f5 100644 --- a/docs/content/reference/static-configuration/file.toml +++ b/docs/content/reference/static-configuration/file.toml @@ -265,6 +265,7 @@ insecure = true dashboard = true debug = true + disabledashboardad = false [metrics] [metrics.prometheus] diff --git a/docs/content/reference/static-configuration/file.yaml b/docs/content/reference/static-configuration/file.yaml index c3b6e830c..3d2ee7c88 100644 --- a/docs/content/reference/static-configuration/file.yaml +++ b/docs/content/reference/static-configuration/file.yaml @@ -292,6 +292,7 @@ api: insecure: true dashboard: true debug: true + disabledashboardad: false metrics: prometheus: buckets: diff --git a/pkg/config/static/static_config.go b/pkg/config/static/static_config.go index 9bdb43730..e3419fd7a 100644 --- a/pkg/config/static/static_config.go +++ b/pkg/config/static/static_config.go @@ -104,9 +104,10 @@ type ServersTransport struct { // API holds the API configuration. type API struct { - Insecure bool `description:"Activate API directly on the entryPoint named traefik." json:"insecure,omitempty" toml:"insecure,omitempty" yaml:"insecure,omitempty" export:"true"` - Dashboard bool `description:"Activate dashboard." json:"dashboard,omitempty" toml:"dashboard,omitempty" yaml:"dashboard,omitempty" export:"true"` - Debug bool `description:"Enable additional endpoints for debugging and profiling." json:"debug,omitempty" toml:"debug,omitempty" yaml:"debug,omitempty" export:"true"` + Insecure bool `description:"Activate API directly on the entryPoint named traefik." json:"insecure,omitempty" toml:"insecure,omitempty" yaml:"insecure,omitempty" export:"true"` + Dashboard bool `description:"Activate dashboard." json:"dashboard,omitempty" toml:"dashboard,omitempty" yaml:"dashboard,omitempty" export:"true"` + Debug bool `description:"Enable additional endpoints for debugging and profiling." json:"debug,omitempty" toml:"debug,omitempty" yaml:"debug,omitempty" export:"true"` + DisableDashboardAd bool `description:"Disable ad in the dashboard." json:"disableDashboardAd,omitempty" toml:"disableDashboardAd,omitempty" yaml:"disableDashboardAd,omitempty" export:"true"` // TODO: Re-enable statistics // Statistics *types.Statistics `description:"Enable more detailed statistics." json:"statistics,omitempty" toml:"statistics,omitempty" yaml:"statistics,omitempty" label:"allowEmpty" file:"allowEmpty" export:"true"` } diff --git a/pkg/version/version.go b/pkg/version/version.go index 49b4f9e1e..d9ede515f 100644 --- a/pkg/version/version.go +++ b/pkg/version/version.go @@ -22,7 +22,8 @@ var ( BuildDate = "I don't remember exactly" // StartDate holds the start date of traefik. StartDate = time.Now() - // UUID instance uuid. + // DisableDashboardAd disables ad in the dashboard. + DisableDashboardAd = false ) // Handler expose version routes. @@ -37,14 +38,16 @@ func (v Handler) Append(router *mux.Router) { router.Methods(http.MethodGet).Path("/api/version"). HandlerFunc(func(response http.ResponseWriter, request *http.Request) { v := struct { - Version string - Codename string - StartDate time.Time `json:"startDate"` - UUID string `json:"uuid,omitempty"` + Version string + Codename string + StartDate time.Time `json:"startDate"` + UUID string `json:"uuid,omitempty"` + DisableDashboardAd bool `json:"disableDashboardAd,omitempty"` }{ - Version: Version, - Codename: Codename, - StartDate: StartDate, + Version: Version, + Codename: Codename, + StartDate: StartDate, + DisableDashboardAd: DisableDashboardAd, } if err := templatesRenderer.JSON(response, http.StatusOK, v); err != nil { diff --git a/webui/src/components/_commons/NavBar.vue b/webui/src/components/_commons/NavBar.vue index 854ff8ea1..4e1a02d46 100644 --- a/webui/src/components/_commons/NavBar.vue +++ b/webui/src/components/_commons/NavBar.vue @@ -30,12 +30,9 @@
-
- -
-

Extend your capabilities to API Management

- -
+
+ +
@@ -89,14 +86,41 @@ export default { }, name () { return config.productName + }, + disableDashboardAd () { + return this.coreVersion.disableDashboardAd + } + }, + data () { + return { + hasHubButtonComponent: false } }, methods: { - ...mapActions('core', { getVersion: 'getVersion' }), - getHubLogoSrc (isDarkMode) { - return isDarkMode - ? 'statics/hub-logo-horizontal-dark.png' - : 'statics/hub-logo-horizontal-clear.png' + ...mapActions('core', { getVersion: 'getVersion' }) + }, + watch: { + disableDashboardAd (newValue) { + if (!newValue && customElements.get('hub-button-app') === undefined) { + const hubButtonScript = document.createElement('script') + hubButtonScript.async = true + hubButtonScript.onerror = () => { + const hubButtonScriptLocal = document.createElement('script') + hubButtonScriptLocal.async = true + hubButtonScriptLocal.onload = () => { + this.hasHubButtonComponent = customElements.get('hub-button-app') !== undefined + } + // Sources: https://github.com/traefik/traefiklabs-hub-button-app + hubButtonScriptLocal.src = 'statics/traefiklabs-hub-button-app/main-v1.js' + document.head.appendChild(hubButtonScriptLocal) + } + hubButtonScript.onload = () => { + this.hasHubButtonComponent = customElements.get('hub-button-app') !== undefined + } + // Sources: https://github.com/traefik/traefiklabs-hub-button-app + hubButtonScript.src = 'https://traefik.github.io/traefiklabs-hub-button-app/main-v1.js' + document.head.appendChild(hubButtonScript) + } } }, created () { @@ -164,11 +188,6 @@ export default { font-weight: 600; } - .btn-hub { - color: #dedede; - background: #5f6572; - } - .q-item { padding: 0; } @@ -178,69 +197,4 @@ export default { align-items: flex-start; } - .tooltip { - display: inline-block; - - .content { - display: flex; - align-items: center; - visibility: hidden; - font-size: 16px; - padding: 20px; - border-radius: 16px; - background-color: #fff; - box-shadow: 0 0 6px rgba(0,0,0,0.16), 0 0 6px rgba(0,0,0,0.23); - - /* Position the tooltip text */ - position: absolute; - z-index: 1; - top: 90%; - left: -5%; - - /* Fade in tooltip */ - opacity: 0; - transition: opacity 0.3s; - - &::after { - content: ""; - position: absolute; - top: -10px; - left: 22%; - border-left: 7px solid transparent; - border-right: 7px solid transparent; - border-bottom: 10px solid #fff; - } - - p { - align-self: baseline; - color: var(--q-color-primary); - font-weight: bold; - margin: 0 20px 0 0; - max-width: 180px; - } - - img { - margin: 0 20px; - } - } - - &.is-dark-mode .content { - background-color: #262626; - box-shadow: 0 0 6px rgba(10,18,36,0.16), 0 0 6px rgba(10,18,36,0.23); - - &::after { - border-bottom: 10px solid #262626; - } - - p { - color: #fff; - } - } - - &:hover .content { - visibility: visible; - opacity: 1; - } - } - diff --git a/webui/src/statics/hub-logo-horizontal-clear.png b/webui/src/statics/hub-logo-horizontal-clear.png deleted file mode 100644 index 9fdabf2af..000000000 Binary files a/webui/src/statics/hub-logo-horizontal-clear.png and /dev/null differ diff --git a/webui/src/statics/hub-logo-horizontal-dark.png b/webui/src/statics/hub-logo-horizontal-dark.png deleted file mode 100644 index aff782355..000000000 Binary files a/webui/src/statics/hub-logo-horizontal-dark.png and /dev/null differ diff --git a/webui/src/statics/traefiklabs-hub-button-app/main-v1.js b/webui/src/statics/traefiklabs-hub-button-app/main-v1.js new file mode 100644 index 000000000..480bc15d9 --- /dev/null +++ b/webui/src/statics/traefiklabs-hub-button-app/main-v1.js @@ -0,0 +1,3 @@ +/* eslint-disable */ +!function(){var e={110:function(e,t,n){"use strict";var r=n(441),a={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},l={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},o={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},i={};function u(e){return r.isMemo(e)?o:i[e.$$typeof]||a}i[r.ForwardRef]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},i[r.Memo]=o;var s=Object.defineProperty,c=Object.getOwnPropertyNames,d=Object.getOwnPropertySymbols,f=Object.getOwnPropertyDescriptor,p=Object.getPrototypeOf,m=Object.prototype;e.exports=function e(t,n,r){if("string"!==typeof n){if(m){var a=p(n);a&&a!==m&&e(t,a,r)}var o=c(n);d&&(o=o.concat(d(n)));for(var i=u(t),h=u(n),g=0;g