Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add console button #97

Merged
merged 1 commit into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 3 additions & 77 deletions layouts/_default/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,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=5e2dea" 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 @@ -1005,81 +1006,6 @@ <h4>Legal</h4>
{{ 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("Stash")').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>
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
Loading