Skip to content

Commit

Permalink
Add console button and fix minor design issues (#81)
Browse files Browse the repository at this point in the history
Signed-off-by: mohin7 <[email protected]>
  • Loading branch information
mohin7 authored Feb 13, 2024
1 parent 0f756fa commit ca4c814
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 423 deletions.
82 changes: 4 additions & 78 deletions layouts/_default/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,9 @@ <h6>RESOURCES</h6>
<!-- navbar items end -->
{{ $currentPageType := index (split .Page.Permalink "/") 3 }}
<div class="buttons">
<a id="ac-sign-in-button" href="https://accounts.appscode.com/user/login"
class="button ac-button is-loading {{ if eq $currentPageType "docs" }} is-hidden {{ end }}"><span>SIGN IN</span></a>
<iframe src="https://appscode.com/embed/?color=326ce5" frameborder="0" scrolling="no" style="height: 40px; margin-bottom: 8px; width: 185px; overflow: hidden;"></iframe>
<!-- <a id="ac-sign-in-button" href="https://accounts.appscode.com/user/login"
class="button ac-button is-loading {{ if eq $currentPageType "docs" }} is-hidden {{ end }}"><span>SIGN IN</span></a> -->
<a href="{{ $.Site.Params.domain_appscode }}/contact/"
class="button ac-button is-primary {{ if eq $currentPageType "docs" }} is-outlined {{ end }}">CONTACT
SALES</a>
Expand Down Expand Up @@ -1007,81 +1008,6 @@ <h4>Legal</h4>
<!-- Meilisearch -->
{{ block "footer-script" . }}
{{ end }}

<!-- console beta tag start -->
<script>
const acSignInButton = document.getElementById('ac-sign-in-button')

// define Beta tag
const betaSpan = document.createElement("span")
betaSpan.innerText = "BETA"
betaSpan.classList.add('tag')

// function to get cookie
function getCookie(cname) {
let name = cname + "=";
let ca = document.cookie.split(';');
for(let i = 0; i < ca.length; i++) {
let c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}

// function to fetch user
async function fetchUser() {
try {
const hostname = window.location.hostname;
const protocol = window.location.protocol;
const port = window.location.port;

const apiDomain = protocol + "//api." + hostname + (port? ":3003" : "");
const consoleDomain = protocol + "//console." + hostname + (port? ":5990" : "");

acSignInButton.classList.add('is-loading');

const response = await fetch(apiDomain + "/api/v1/user", {
method: "GET",
credentials: "include",
headers: {
"X-Csrf-Token": getCookie("_csrf"),
"X-Requested-With": "xmlhttprequest"
}
})

if(response.status === 200) {
// user is logged in
// show console link
acSignInButton.firstElementChild.innerHTML = "CONSOLE"
acSignInButton.href = consoleDomain
}
} catch(error) {
console.log("Failed to fetch user", error)
}
// remove the loader
acSignInButton.classList.remove('is-loading');
// append beta tag
acSignInButton.appendChild(betaSpan);
}

window.addEventListener('load', function() {
jQuery('a:contains("KubeVault")').click(function() {
gtag('event', 'conversion', {
'send_to': 'AW-10933819571/j5J-CL2sweQDELOx090o'
});
})


// fetch if user is logged in or not
fetchUser();
});
</script>
<!-- console beta tag end -->
</body>

</html>
</html>
4 changes: 2 additions & 2 deletions layouts/docs/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ <h6>{{ .Name }}</h6>
{{ end }}
</ul>
<!-- =============searchbar area start ===========================-->
<div class="ac-searchbar">
<label for="acSearch">
<div class="ac-searchbar is-flex is-align-items-center">
<label for="acSearch" class="is-flex">
<lord-icon src="https://cdn.lordicon.com/msoeawqm.json" target="#acSearch" trigger="hover"
style="width:22px;height:22px">
</lord-icon>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit ca4c814

Please sign in to comment.