Skip to content

Commit

Permalink
Post Survey feedback to Gitlab
Browse files Browse the repository at this point in the history
  • Loading branch information
Lilyheart committed Dec 7, 2019
1 parent c16ac2a commit 47738f3
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 32 deletions.
2 changes: 2 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"currURL": true,
"serverDetails": true,
"gitlabKey": true,
"feedbackRepo": true,
"projectID": true,
"currProjectName": true,
"currProjecURL": true,
Expand Down Expand Up @@ -58,6 +59,7 @@
"burndown": true,
"hours": true,
"Survey": true,
"survey": true,
"surveyJSON": true
},
"rules": {
Expand Down
14 changes: 8 additions & 6 deletions gitlab_servers.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
var gitlabServers = [
{id: "Bucknell",
clientID: "06ed28b4a14e68fa4448b98c257f5c606971c971cbcfae43dab3ca6e5bf5e8a5",
authURL: "https://gitlab.bucknell.edu/oauth/authorize",
baseURL: "https://gitlab.bucknell.edu/api/v4/"},
clientID: "06ed28b4a14e68fa4448b98c257f5c606971c971cbcfae43dab3ca6e5bf5e8a5",
authURL: "https://gitlab.bucknell.edu/oauth/authorize",
baseURL: "https://gitlab.bucknell.edu/api/v4/",
feedbackRepo: "3930"},
{id: "gitlab.com",
clientID: "a95d0d4d1d29754efe3d41f76209bc3f8cf200188ad1687a6e3fe8605269bdf0",
authURL: "https://gitlab.com/oauth/authorize",
baseURL: "https://gitlab.com/api/v4/"}
clientID: "a95d0d4d1d29754efe3d41f76209bc3f8cf200188ad1687a6e3fe8605269bdf0",
authURL: "https://gitlab.com/oauth/authorize",
baseURL: "https://gitlab.com/api/v4/",
feedbackRepo: ""}
];
5 changes: 3 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ <h3 class="pad-below">Gitlab Setup</h3>
<li class="nav-item">
<a class="nav-link active" id="faq-tab" data-toggle="tab" href="#faqtab" role="tab" aria-controls="faqtab" aria-selected="true" onclick="checkForUpdates()">FAQ</a>
</li>
<li class="nav-item">
<a class="nav-link" id="survey-tab" data-toggle="tab" href="#surveytab" role="tab" aria-controls="surveytab" aria-selected="true" onclick="checkForUpdates()">Survey</a>
<li class="nav-item d-none" id="survey-tab-item">
<a class="nav-link survey-tab" id="survey-tab" data-toggle="tab" href="#surveytab" role="tab" aria-controls="surveytab" aria-selected="true" onclick="checkForUpdates()">Survey</a>
</li>
</ul>
<div class="tab-content" id="myTabContent">
Expand Down Expand Up @@ -350,6 +350,7 @@ <h4 class="d-inline-flex">Warnings</h4>
<!-- Local -->
<script type="text/javascript" src="libraries/selectize.min.js?ver=v0.12.6"></script>
<script type="text/javascript" src="libraries/defiant.min.js?ver=v2.2.6"></script>
<script type="text/javascript" src="scripts/survey.js?ver=0.2.7"></script>
<script type="text/javascript" src="scripts/projects.js?ver=0.2.7"></script>
<script type="text/javascript" src="scripts/issues.js?ver=0.2.7d"></script>
<script type="text/javascript" src="scripts/burndown.js?ver=0.2.7e"></script>
Expand Down
24 changes: 6 additions & 18 deletions scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ See Scripts folder for additional Scripts.
This file contains general code and global variable declarations
*/

var baseURL, currURL, serverDetails, gitlabKey, projectID, currProjectName, currProjecURL,
currProjStartDate, currUserName, projectList, lastUpdate, issueListArr,
issueListJSON, milestoneList, spentTimeList, estimateTimeList, paramDict,
var baseURL, currURL, serverDetails, gitlabKey, feedbackRepo, projectID,
currProjectName, currProjecURL, currProjStartDate, currUserName, projectList,
lastUpdate, issueListArr, issueListJSON, milestoneList, spentTimeList,
estimateTimeList, paramDict,
searchDict = {},
isBookmark = false,
isLoaded = false;
Expand Down Expand Up @@ -314,6 +315,7 @@ function restart() {

function setupAuthenticate(server) {
serverDetails = defiant.json.search( gitlabServers, '//*[id="' + server + '"]' )[0];
feedbackRepo = serverDetails.feedbackRepo;

document.getElementById("base_url").value = serverDetails.baseURL;

Expand Down Expand Up @@ -398,8 +400,7 @@ function setFeedback() {
}

function setInit() {
let survey,
scrollAnimate = 500;
let scrollAnimate = 500;

$("#estimate-type-dropdown").selectize();

Expand All @@ -411,19 +412,6 @@ function setInit() {
}, scrollAnimate);
});

Survey.StylesManager.applyTheme("bootstrap");

function sendDataToServer(sendSurvey) {
//TODO Post as issue on Gitlab Repo
alert("The results are:" + JSON.stringify(sendSurvey.data));
}

survey = new Survey.Model(surveyJSON);
$("#surveyContainer").Survey({
model: survey,
onComplete: sendDataToServer
});

// $("#burndownchart-types").DataTable({
// scrollY: "200px"
// });
Expand Down
2 changes: 2 additions & 0 deletions scripts/projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ var projects = (function () {
// projFilter = ["user", "all", "auto", "bookmarked"]
let url, projectPages;

survey.surveyInit();

// Build URL and get project list
if (projFilter === "all" || currUserName === null) {
url = baseURL + "projects?order_by=name&sort=asc&simple=true&" + gitlabKey;
Expand Down
49 changes: 49 additions & 0 deletions scripts/survey.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
var survey = (function () {
let cookieList,
surveyModel = new Survey.Model(surveyJSON);

function hasCookie(name) {
cookieList = {};
document.cookie.split("; ").map(cookie => {
cookieList[cookie.split("=")[0]] = (cookie.split("=")[1]);
});

return cookieList.hasOwnProperty(name);
}

function surveyInit() {
if (hasCookie(surveyJSON.cookieName) || baseURL !== gitlabServers[0].baseURL) {
return;
}

document.getElementById("survey-tab-item").classList.remove("d-none");

Survey.StylesManager.applyTheme("bootstrap");

function sendDataToServer(sendSurvey) {
let url, data;

url = baseURL + "projects/" + feedbackRepo + "/issues?" + gitlabKey;
data = {
title: `Survey for ${currUserName}`,
description: JSON.stringify(sendSurvey.data),
confidential: true
};
$.post(url, data, function(rData, status) {});

document.getElementById("survey-tab-item").classList.add("d-none");
}

$("#surveyContainer").Survey({
model: surveyModel,
onComplete: sendDataToServer
});
}

return {
surveyInit: function() {
surveyInit();
}
};

})();
10 changes: 5 additions & 5 deletions scripts/surveyJSON.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var surveyJSON = {
"cookieName": "2019futureSurvey",
"pages": [
{
"name": "page1",
Expand Down Expand Up @@ -58,7 +59,7 @@ var surveyJSON = {
"elements": [
{
"type": "html",
"name": "question1",
"name": "futureOutline",
"html": " <h2>The Future</h2>\n\n <p>In 2020, the website will be developed into a one-stop Scrum tool. Several features will be added such as</p>\n <ul>\n <li>Managing Spent and Estimated time within the tool</li>\n <li>Combinging several sprints into a release (aka Epic)</li>\n <li>Managing User Stories that span several sprints</li>\n <li>A more detailed breakdown of member information: Hours Assigned, Hours Completed and Percentage of assigned work completed</li>\n </ul>"
},
{
Expand Down Expand Up @@ -203,23 +204,22 @@ var surveyJSON = {
"elements": [
{
"type": "text",
"name": "question2",
"name": "annoying",
"title": "What part(s) of the tool do you find annoying?"
},
{
"type": "text",
"name": "question4",
"name": "helpful",
"title": "What part(s) of the tool do you find the most helpful?"
},
{
"type": "text",
"name": "question3",
"name": "wish",
"title": "What else do you wish the website would do?"
}
]
}
],
"cookieName": "agilesurvey",
"showPageTitles": false,
"showQuestionNumbers": "off"
}
2 changes: 1 addition & 1 deletion style/main.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions style/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -261,3 +261,18 @@ td a {
@extend %inverse-color-text;
}
}

.survey-tab {
-webkit-animation: flash linear 1.5s infinite;
animation: flash linear 1.5s infinite;
}
@-webkit-keyframes flash {
0% { opacity: 1; }
50% { opacity: .35; }
100% { opacity: 1; }
}
@keyframes flash {
0% { opacity: 1; }
50% { opacity: .35; }
100% { opacity: 1; }
}

0 comments on commit 47738f3

Please sign in to comment.