Skip to content
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
31 changes: 31 additions & 0 deletions .github/workflows/sonarqube.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Sonarqube

on:
push:
branches:
- main
- dev
pull_request:
types: [opened, synchronize, reopened]

jobs:
build:
name: Analyze
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- uses: SonarSource/sonarqube-scan-action@v5
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
# If you wish to fail your job when the Quality Gate is red, uncomment the
# following lines. This would typically be used to fail a deployment.
# We do not recommend to use this in a pull request. Prefer using pull request
# decoration instead.
# - uses: SonarSource/sonarqube-quality-gate-action@v1
# timeout-minutes: 5
# env:
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ func main() {
apiMux.HandleFunc("DELETE /queue/{queue}", discussion.DeleteQueue)
apiMux.HandleFunc("GET /queue/{queue}/path", discussion.GetQueuePath)
apiMux.HandleFunc("GET /discussion", discussion.GetDiscussion)
apiMux.HandleFunc("PUT /discussion/reset", discussion.ResetDiscussion)
apiMux.HandleFunc("/joinws", ws_server.WebsocketConnect)

http.Handle("/api/", http.StripPrefix("/api", auth.Handler(apiMux)))
Expand Down
31 changes: 31 additions & 0 deletions queue/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,37 @@ func SetupDiscussion(wsServer *dq_websocket.WsServer) *Discussion {
return &discussion
}

func (discussion *Discussion) ResetDiscussion(w http.ResponseWriter, r *http.Request) {
userInfo := auth.GetUserClaims(r)

if !userInfo.IsEboard {
w.WriteHeader(http.StatusForbidden)
return
}

discussion.queueCount = 0
discussion.queueMap = make(map[int]*Queue)

baseQueue := Queue{
Id: discussion.queueCount,
Points: make([]QueueEntry, 0),
Clarifiers: make([]QueueEntry, 0),
Children: make([]*Queue, 0),
Topic: "Big long discussion",
pointCount: 0,
}

discussion.queueCount++
discussion.Queue = &baseQueue
discussion.queueMap[baseQueue.Id] = &baseQueue

discussion.wsServer.SendWSMessage(struct {
Type string `json:"type"`
}{
Type: "refresh",
})
}

func (discussion *Discussion) NewQueue(w http.ResponseWriter, r *http.Request) {
userInfo := auth.GetUserClaims(r)

Expand Down
45 changes: 36 additions & 9 deletions static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,16 @@ <h2 class="m-0 fs-3 p-1">
<input class="discussion-title" value="AGH" onchange="changeTopic(event)" />
</h2>
<div class="ms-auto d-flex flex-row align-items-center">
<a href="#" id="remove-queue" onclick="closeActiveQueue()">
<a href="#" class="ms-2" id="remove-queue" onclick="closeActiveQueue()">
<i class="bi bi-x text-danger fs-3"></i>
</a>
<a href="#" class="ms-2" onclick="rebuildQueue(); return false">
<i class="bi bi-repeat text-muted fs-5"></i>
</a>
<button class="ms-3 btn btn-sm btn-danger" href="#" id="reset-discussion"
data-bs-toggle="modal" data-bs-target="#resetDiscussionModal">
Reset
</button>
</div>
</div>
</div>
Expand All @@ -129,14 +133,12 @@ <h2 class="m-0 fs-3 p-1">
</p>
</div>
<div class="card-footer mb-0 d-flex justify-content-center">
<div class="mx-auto">
<button class="new-btns btn btn-lg btn-primary fs-2 py-4 px-5 py-lg-3 px-lg-4 mx-5 mx-lg-3"
onclick="enterQueue('clarifier')">Clarifier</button>
<button class="new-btns btn btn-lg btn-primary fs-2 py-4 px-5 py-lg-3 px-lg-4 mx-5 mx-lg-3"
onclick="enterQueue('point')">New Point</button>
<button class="new-btns btn btn-lg btn-primary fs-2 py-4 px-5 py-lg-3 px-lg-4 mx-5 mx-lg-3"
id="createQueueModalBtn" data-bs-toggle="modal" data-bs-target="#createQueueModal">New Topic</button>
</div>
<button class="new-btns btn btn-lg btn-primary fs-2 py-4 px-3 py-lg-3 px-lg-4 mx-2 mx-lg-3"
onclick="enterQueue('clarifier')">Clarifier</button>
<button class="new-btns btn btn-lg btn-primary fs-2 py-4 px-3 py-lg-3 px-lg-4 mx-2 mx-lg-3"
onclick="enterQueue('point')">New Point</button>
<button class="new-btns btn btn-lg btn-primary fs-2 py-4 px-3 py-lg-3 px-lg-4 mx-2 mx-lg-3"
id="createQueueModalBtn" data-bs-toggle="modal" data-bs-target="#createQueueModal">New Topic</button>
</div>
</div>
</div>
Expand Down Expand Up @@ -166,6 +168,31 @@ <h1 class="modal-title fs-5" id="createQueueModalLabel">New Queue</h1>
</div>
</div>

<!-- Reset Discussion Modal -->
<div class="modal fade" id="resetDiscussionModal" tabindex="-1" aria-labelledby="resetDiscussionModalLabel"
aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="resetDiscussionModalLabel">Reset Discussion</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="mb-3">
<div class="alert alert-info" role="alert">
NOTE: this will clear ALL data on Dairy Queen
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-bs-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" data-bs-dismiss="modal"
onclick="resetDiscussionFormSubmit()">Reset Discussion</button>
</div>
</div>
</div>
</div>

<div class="toast-container position-absolute d-flex flex-column">
<div class="toast" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
Expand Down
16 changes: 15 additions & 1 deletion static/javascript/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,23 @@ function newQueueFormSubmit() {
topicElement.value = "";
}

function resetDiscussionFormSubmit() {
if (!window.userInfo.is_eboard) {
console.error("Only E-Board members can create reset queues");
return;
}

fetchAPI(`${window.location.origin}/api/discussion/reset`, {
method: "PUT"
})
}

function joinWebsocket(retryCount = 0) {
const isSecure = window.location.protocol == "https:";
const protocol = isSecure ? "wss" : "ws";
const socket = new WebSocket(`${protocol}://${window.location.host}/api/joinws`);

socket.addEventListener("message", (event) => {
socket.addEventListener("message", async (event) => {
const eventData = JSON.parse(event.data);

switch (eventData.type) {
Expand All @@ -143,6 +154,9 @@ function joinWebsocket(retryCount = 0) {
case "move-to-queue":
loadQueueDom(eventData.queue);
break;
case "refresh":
await rebuildQueue();
break;
}
});

Expand Down
Loading