Added room_owner and welcome message thingy(client-side)

Took 36 minutes
This commit is contained in:
Tobias Hopp 2020-10-04 17:11:51 +02:00
parent 3a9cdec161
commit f48ed79fd9
3 changed files with 109 additions and 25 deletions

30
.idea/workspace.xml generated
View File

@ -21,8 +21,6 @@
<component name="ChangeListManager">
<list default="true" id="fc13552d-b118-4828-b78f-fc8714e0cfdc" name="Default Changelist" comment="Final COMMIT!!!">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/controller/FaqController.class.inc.php" beforeDir="false" afterPath="$PROJECT_DIR$/controller/FaqController.class.inc.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/model/FaqModel.class.inc.php" beforeDir="false" afterPath="$PROJECT_DIR$/model/FaqModel.class.inc.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/templates/faq.tmpl.html" beforeDir="false" afterPath="$PROJECT_DIR$/templates/faq.tmpl.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/vendor/js/faq.js" beforeDir="false" afterPath="$PROJECT_DIR$/vendor/js/faq.js" afterDir="false" />
</list>
@ -35,7 +33,7 @@
<execution />
</component>
<component name="DarkyenusTimeTracker">
<option name="totalTimeSeconds" value="76591" />
<option name="totalTimeSeconds" value="78719" />
<option name="gitIntegration" value="true" />
<option name="naggedAbout" value="1" />
</component>
@ -81,7 +79,7 @@
<updated>1601618466935</updated>
<workItem from="1601618467981" duration="36776000" />
<workItem from="1601809534320" duration="1558000" />
<workItem from="1601811106543" duration="2864000" />
<workItem from="1601811106543" duration="5297000" />
</task>
<task id="LOCAL-00001" summary="Initial commit">
<created>1601618764031</created>
@ -181,7 +179,21 @@
<option name="project" value="LOCAL" />
<updated>1601810664354</updated>
</task>
<option name="localTasksCounter" value="15" />
<task id="LOCAL-00015" summary="Fix issue #2">
<created>1601818313902</created>
<option name="number" value="00015" />
<option name="presentableId" value="LOCAL-00015" />
<option name="project" value="LOCAL" />
<updated>1601818313902</updated>
</task>
<task id="LOCAL-00016" summary="Fix issue #4">
<created>1601818395954</created>
<option name="number" value="00016" />
<option name="presentableId" value="LOCAL-00016" />
<option name="project" value="LOCAL" />
<updated>1601818395954</updated>
</task>
<option name="localTasksCounter" value="17" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
@ -212,7 +224,9 @@
<MESSAGE value="Final COMMIT!!!" />
<MESSAGE value="Fix issue #1" />
<MESSAGE value="Done issue #5 and #3" />
<option name="LAST_COMMIT_MESSAGE" value="Done issue #5 and #3" />
<MESSAGE value="Fix issue #2" />
<MESSAGE value="Fix issue #4" />
<option name="LAST_COMMIT_MESSAGE" value="Fix issue #4" />
</component>
<component name="WindowStateProjectService">
<state x="728" y="326" width="800" height="683" key="#com.intellij.execution.impl.EditConfigurationsDialog" timestamp="1601632929047">
@ -251,10 +265,10 @@
<screen x="0" y="34" width="1920" height="1046" />
</state>
<state x="441" y="192" width="1037" height="736" key="SettingsEditor/0.34.1920.1046@0.34.1920.1046" timestamp="1601632853044" />
<state x="555" y="292" width="800" height="535" key="Vcs.Push.Dialog.v2" timestamp="1601810665321">
<state x="555" y="292" width="800" height="535" key="Vcs.Push.Dialog.v2" timestamp="1601818397210">
<screen x="0" y="34" width="1920" height="1046" />
</state>
<state x="555" y="292" width="800" height="535" key="Vcs.Push.Dialog.v2/0.34.1920.1046@0.34.1920.1046" timestamp="1601810665321" />
<state x="555" y="292" width="800" height="535" key="Vcs.Push.Dialog.v2/0.34.1920.1046@0.34.1920.1046" timestamp="1601818397210" />
<state x="809" y="122" width="639" height="876" key="com.intellij.database.view.ui.AbstractDbRefactoringDialog" timestamp="1601632983240">
<screen x="0" y="34" width="1920" height="1046" />
</state>

View File

@ -83,6 +83,7 @@
</div>
</div>
<div class="modal fade" id="answerModal" tabindex="-1" role="dialog" aria-labelledby="answerModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
@ -126,6 +127,27 @@
</div>
</div>
<div class="modal fade" id="welcomeModal" tabindex="-1" role="dialog" aria-labelledby="welcomeModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="welcomeModalLabel">Welcome - Readme first</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<span>In the following page you can ask unlimited questions.<br>Your question should be contain 10 up to 500 characters.<br>The owner of this room then can answer your question.</span>
<hr>
<span id="welcomeModalText" class="text-justify">You are an XXX of this room.<br>This means you can XXX</span>
</div>
<div class="modal-footer">
<button type="button" id="welcomeModalClose" class="btn btn-info" data-dismiss="modal">Okay</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="errorModal" tabindex="-1" role="dialog" aria-labelledby="errorModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
@ -139,7 +161,8 @@
<span id="errorMsg"></span>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" onclick="location.reload();" data-dismiss="modal">Reload</button>
</div>
</div>
</div>

77
vendor/js/faq.js vendored
View File

@ -1,19 +1,23 @@
errorModal = $( '#errorModal' );
askQuestionModal = $( '#askQuestionModal' );
readMoreModal = $( '#readMoreModal' );
answerModal = $( '#answerModal' );
answerText = $('#answer' );
answerModalTitle = $('#answerModalLabel');
const errorModal = $( '#errorModal' );
const askQuestionModal = $( '#askQuestionModal' );
const readMoreModal = $( '#readMoreModal' );
const answerModal = $( '#answerModal' );
const welcomeModal = $('#welcomeModal' );
const welcomeModalText = $('#welcomeModalText');
const welcomeModalClose = $('#welcomeModalClose' );
const answerText = $('#answer' );
const answerModalTitle = $('#answerModalLabel');
readMoreModalText = $('#readMoreModalText' );
readMoreModalTitle = $('#readMoreModalLabel' );
errorMsg = $( '#errorMsg' );
askErrorMsg = $('#askErrorMsg')
answerErrorMsg = $('#answerErrorMsg' );
questions = $( '#questions' )
question = $('#question' );
askButton = $('#askBtn' );
nickname = $('#nickname' );
const readMoreModalTitle = $('#readMoreModalLabel' );
const errorMsg = $( '#errorMsg' );
const askErrorMsg = $('#askErrorMsg')
const answerErrorMsg = $('#answerErrorMsg' );
const questions = $( '#questions' )
const question = $('#question' );
const askButton = $('#askBtn' );
const nickname = $('#nickname' );
let is_owner = false;
function request( a_uri, a_data, a_successhandler, a_errorhandler )
{
@ -138,6 +142,14 @@ function openAnswerModal( id )
{
answerModalTitle.html( 'Answer ' + 'XXX' + " question" );
answerErrorMsg.html( '' );
if( !is_owner )
{
errorModal.modal( 'show' );
errorMsg.html( 'You are not allowed to answer questions!<br>Ask the room-owner for permissions.' );
return;
}
answerModal.modal( 'show' );
request( 'getQuestion', {"question_id":id}, function( result )
@ -236,5 +248,40 @@ function getQuestions()
);
}
getQuestions();
function welcomeMessage()
{
// Starting welcome modal
welcomeModal.modal( 'show' );
welcomeModalClose.prop( 'disabled', true );
request( 'getWelcomeInfo', {}, function( result ) {
if ( result.data.is_owner === true )
{
welcomeModalText.html( 'You are the owner of this room.<br>This means you are allowed to ask and <strong>answer</strong> questions!<br><br>To share your room code, use the share-url or the room-code.' );
is_owner = true;
}
else
{
welcomeModalText.html( 'You are an guest of this room.<br>This means you are allowed to ask questions.<br>To ask a question, click on "Ask a question", then enter your name and your question.' );
is_owner = false;
}
setTimeout( function() { welcomeModalClose.prop( 'disabled', false ); }, 1500 );
}, function()
{
is_owner = false;
setTimeout( function() {
welcomeModal.modal('hide');
}, 500 );
setTimeout( function(){
errorMsg.html( "Oopsie! Your user information cannot be loaded.<br>Try reloading the page!" );
errorModal.modal( 'show' );
}, 800 );
});
}
setInterval( function() { getQuestions(); }, 1500 );
welcomeMessage();