Skip to content

Commit

Permalink
Dynamically remove chatboxes of type 'compiler' #27
Browse files Browse the repository at this point in the history
  • Loading branch information
trunisam committed Apr 28, 2023
1 parent 882a92e commit c1f4dd9
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 15 deletions.
8 changes: 8 additions & 0 deletions app/scripts/controllers/ide.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,14 +427,22 @@ app.controller('IdeCtrl', [

let reqAddMsg = IdeMsgService.msgAddHelpMessage(chatLineCard, 'compiler', 'Roby', 'worried');
$rootScope.$broadcast(reqAddMsg.msg, reqAddMsg.data);
// broadcast event that code gets compiled and has a syntax-error
$scope.$broadcast('compilerError');
}
},
function (error) {
console.log(error);
$log.debug('An error occurred while trying to create help message for compilation error.');
}
);
} else {
// broadcast event that code gets compiled and has no syntax error (make sure with $timeout that the chatbox is available)
$timeout(()=> {
$scope.$broadcast('noCompilerError');
})
}

};

displayWSOutputStream(data.streamUrl, data.startUrl, onMessageReceived, onConnectionClosed);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ angular.module('codeboardApp')

let slug = 'help',
avatarName = "Roby"; // todo dieser Benutzername ist eingetlich nicht statisch ...
let lastCompilerChatboxIndex = -1;

// scope variables
$scope.chatLines = [];
Expand Down Expand Up @@ -123,7 +124,34 @@ angular.module('codeboardApp')
filterCompilerChatLines();
filterTipChatLines();
filterHelpChatLines();
}, true);
}, true);

$scope.$on('compilerError', function () {
$timeout(() => {
// remove last compilation error chatbox
if (lastCompilerChatboxIndex !== -1) {
$scope.chatLines.splice(lastCompilerChatboxIndex, 1);
}

// find the new last compilation error chatbox index
$scope.chatLines.forEach((chatLine, index) => {
if (chatLine.type === 'compiler') {
lastCompilerChatboxIndex = index;
}
});
});
});

$scope.$on('noCompilerError', function() {
// remove last compilation error chatbox
if (lastCompilerChatboxIndex !== -1) {
$scope.chatLines.splice(lastCompilerChatboxIndex, 1);
lastCompilerChatboxIndex = -1;
} else {
console.log("No Compiler message found!");
}
})


/**
* init this tab by loading chat history and read tips
Expand Down
14 changes: 7 additions & 7 deletions app/styles/chat.css
Original file line number Diff line number Diff line change
Expand Up @@ -341,12 +341,12 @@
align-items: center;
margin-bottom: 10px;
margin-top: 15px;
}
.button-description {
}

.button-description {
margin-left: 10px;
}
.info-heading {
}

.info-heading {
text-align: center;
}
}
5 changes: 1 addition & 4 deletions app/views/partials/chat/chat.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
<div class="row">

<ul class="chat px-4">

<ng-transclude ng-transclude-slot="beforeChat"></ng-transclude>

<li class="clear chat-line my-4 clearfix text" ng-repeat="chatLine in chatLines">

<div ng-switch="chatLine.type">

<div ng-switch-when="card">
<chat-line alignment="{{chatLine.alignment}}" author="{{chatLine.author}}" created-at="{{chatLine.createdAt}}" avatar="chatLine.avatar">
<chat-line-card card-title="{{chatLine.message.cardHeader}}" card-reference="{{chatLine.message.cardReference}}" card-type="{{chatLine.message.cardType}}">
Expand Down Expand Up @@ -44,6 +40,7 @@
<chat-line alignment="{{chatLine.alignment}}" author="{{chatLine.author}}" created-at="{{chatLine.createdAt}}" avatar="chatLine.avatar">
<chat-line-simple>
<div ng-bind-html="chatLine.message"></div>
</chat-line-simple>
</chat-line>
</div>

Expand Down
3 changes: 1 addition & 2 deletions app/views/partials/chat/chatLineCard.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
<span ng-show="!cardReference">{{cardTitle}}</span>
<a ng-hide="!cardReference" href="{{cardReference}}">{{cardTitle}}</a>
</div>
<div class="card-body" ng-transclude>
</div>
<div class="card-body" ng-transclude></div>
</div>
2 changes: 1 addition & 1 deletion app/views/partials/navBarRight/navBarRightCompiler.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ <h1 class="modal-title">Hier findest du die Erklärungen zu den Compiler-Meldung
</chat-line-simple>
</chat-line>
</li>
<hr class="chat-horizontal-line">
<hr class="chat-horizontal-line" />
</before-chat>
</chat>
</div>
Expand Down

0 comments on commit c1f4dd9

Please sign in to comment.