Skip to content

Commit b63e27b

Browse files
authored
Merge pull request #5 from SpinachWings/redirect_param
Adding redirect param to category embed example
2 parents 33a8ae7 + ed16c5d commit b63e27b

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

static_examples/embed_a_category.html

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ <h1>Need more help?</h1>
2626

2727
<script>
2828
/**
29-
* Category display mode
30-
* |
31-
* Chart Embed URL https://localhost:8224/pi/?categoryMode=1#PA-CA###category/23
32-
* |________________________||__________| |_________________|
33-
* | | |
34-
* This is your | And this bit identifies
35-
* dashboard URL | which category you want
29+
* Category display mode
30+
* |
31+
* Category Embed URL https://localhost:8224/pi/?categoryMode=1#/dashboard-system/#/redirectToDefaultCategoryState/23
32+
* |________________________||__________| |__|
33+
* | | |
34+
* This is your | And this bit identifies
35+
* dashboard URL | which category you want
3636
* |
3737
* This bit tells the dashboard
38-
* that you want a chart
38+
* that you want a category
3939
*/
4040

4141
//I'm separating this here because it makes it easier to insert the token after /chart
@@ -44,9 +44,8 @@ <h1>Need more help?</h1>
4444
var password = "dashboard"; //Change this to user's password
4545
var categoryId = "23"; //Change this to the category you want to see
4646
var mode = "0"; //Change this to change the category mode you want to use
47-
var categoryKey = "#PA-CA###category/";
48-
var categoryFragment = categoryKey + categoryId;
4947
var modeKey = "?categoryMode=";
48+
var redirect = "#/dashboard-system/#/redirectToDefaultCategoryState/"
5049
var modeParam = modeKey + mode;
5150

5251
var apiToken = "pi/api/v2/tokens"
@@ -83,14 +82,14 @@ <h1>Need more help?</h1>
8382
},
8483
success: function (data) {
8584
// Once we have a succesful ajax request with authentication we can just forward the browser and it will use the live session
86-
document.getElementById("category").src = url + "pi/" + modeParam + categoryFragment;
85+
document.getElementById("category").src = url + "pi/" + modeParam + redirect + categoryId;
8786
}
8887
});
8988
}
9089

9190
function changeCategoryMode(catMode) {
92-
var catId = document.getElementById("category").src.split(categoryKey)[1].split('/')[0];
93-
document.getElementById("category").src = url + "/pi" + modeKey + catMode + categoryKey + catId;
91+
var catId = document.getElementById("category").src.split(redirect)[1];
92+
document.getElementById("category").src = url + "/pi" + modeKey + catMode + redirect + catId;
9493
}
9594
</script>
9695
</div>

0 commit comments

Comments
 (0)