Skip to content

Commit

Permalink
Merge pull request #20 from AresMUSH/dev
Browse files Browse the repository at this point in the history
Beta 41
  • Loading branch information
lynnfaraday committed Feb 11, 2019
2 parents 52cc9e2 + 450382a commit 144ecff
Show file tree
Hide file tree
Showing 17 changed files with 116 additions and 56 deletions.
32 changes: 15 additions & 17 deletions app/controllers/chat.js
Expand Up @@ -9,23 +9,21 @@ export default Controller.extend({
chatMessage: '',
scrollPaused: false,

onChatMessage: function(msg) {
onChatMessage: function(msg, timestamp) {
let splitMsg = msg.split('|');
let channelKey = splitMsg[0];

this.get('gameApi').requestOne('chat').then( response => {
this.set(`model.channels.${channelKey}.messages`, response.get(`channels.${channelKey}.messages`))
this.set(`model.channels.${channelKey}.who`, response.get(`channels.${channelKey}.who`))
if (channelKey === this.get('selectedChannel').toLowerCase()) {
this.scrollChatWindow();
}
else {
let messageCount = this.get(`model.channels.${channelKey}.new_messages`) || 0;
this.set(`model.channels.${channelKey}.new_messages`, messageCount + 1);
}
this.get('gameSocket').notify('New chat activity!');

});
let newMessage = splitMsg[1];

let messages = this.get(`model.channels.${channelKey}.messages`);
messages.pushObject({message: newMessage, timestamp: timestamp });
if (channelKey === this.get('selectedChannel').toLowerCase()) {
this.scrollChatWindow();
}
else {
let messageCount = this.get(`model.channels.${channelKey}.new_messages`) || 0;
this.set(`model.channels.${channelKey}.new_messages`, messageCount + 1);
}
this.get('gameSocket').notify('New chat activity!');
},

scrollChatWindow: function() {
Expand All @@ -49,8 +47,8 @@ export default Controller.extend({

setupCallback: function() {
let self = this;
this.get('gameSocket').set('chatCallback', function(channel) {
self.onChatMessage(channel) } );
this.get('gameSocket').set('chatCallback', function(msg, timestamp) {
self.onChatMessage(msg, timestamp) } );
},

getCurrentChannelKey: function() {
Expand Down
15 changes: 11 additions & 4 deletions app/controllers/job-create.js
Expand Up @@ -8,11 +8,13 @@ export default Controller.extend({
title: '',
category: '',
description: '',
submitter: null,

resetOnExit: function() {
this.set('title', '');
this.set('category', this.get('model.request_category'));
this.set('category', this.get('model.options.request_category'));
this.set('description', '');
this.set('submitter', null);
},

actions: {
Expand All @@ -24,15 +26,20 @@ export default Controller.extend({
let api = this.get('gameApi');
api.requestOne('jobCreate', {
title: this.get('title'),
category: this.get('category') || this.get('model.request_category'),
description: this.get('description')}, null)
category: this.get('category') || this.get('model.options.request_category'),
description: this.get('description'),
submitter: this.get('submitter.name') }, null)
.then( (response) => {
if (response.error) {
return;
}
this.transitionToRoute('job', response.id);
this.get('flashMessages').success('Job created!');
});
}
},

submitterChanged(submitter) {
this.set('submitter', submitter);
},
}
});
4 changes: 0 additions & 4 deletions app/controllers/plot-create.js
Expand Up @@ -11,10 +11,6 @@ export default Controller.extend({
description: '',
storyteller: null,

defaultStoryteller: function() {
return this.get('model').find(c => c.id == this.get('session.data.authenticated.id'));
}.property(),

resetOnExit: function() {
this.set('title', '');
this.set('summary', '');
Expand Down
23 changes: 16 additions & 7 deletions app/controllers/scene-live.js
Expand Up @@ -19,14 +19,23 @@ export default Controller.extend(AuthenticatedController, {
onSceneActivity: function(msg /* , timestamp */) {
let splitMsg = msg.split('|');
let sceneId = splitMsg[0];
//let data = splitMsg[1];

let char = splitMsg[1];
let poseData = splitMsg[2];
// For poses we can just add it to the display. Other events require a reload.
if (sceneId === this.get('model.scene.id')) {
this.get('gameApi').requestOne('liveScene', { id: this.get('model.scene.id') }).then( response => {
this.set(`model.scene`, response)
this.get('gameSocket').notify('New scene activity!');
this.scrollSceneWindow();
});
if (poseData) {
poseData = JSON.parse(poseData);
let poses = this.get('model.scene.poses');
poses.pushObject(poseData);
this.get('gameSocket').notify('New scene activity!');
this.scrollSceneWindow();
} else {
this.get('gameApi').requestOne('liveScene', { id: this.get('model.scene.id') }).then( response => {
this.set(`model.scene`, response)
this.get('gameSocket').notify('New scene activity!');
this.scrollSceneWindow();
});
}
}
else {
this.get('model.my_scenes').forEach(s => {
Expand Down
2 changes: 1 addition & 1 deletion app/instance-initializers/error-handler.js
@@ -1,6 +1,6 @@
import Ember from 'ember';

const { RSVP, set } = Ember;
const { RSVP } = Ember;

export function initialize(appInstance) {
let service = appInstance.lookup('service:gameApi');
Expand Down
6 changes: 5 additions & 1 deletion app/routes/application.js
Expand Up @@ -26,6 +26,10 @@ export default Route.extend(ApplicationRouteMixin, ReloadableRoute, {
return { game_down: true };
}
response['socketConnected'] = this.get('gameSocket.connected');

if (response.token_expiry_warning) {
this.get('flashMessages').warning(`Your login expires today (in ${response.token_expiry_warning}). You should log out and back in before that happens so you don't lose any work.'`);
}
return response;
})
.catch(() => {
Expand Down Expand Up @@ -69,7 +73,7 @@ export default Route.extend(ApplicationRouteMixin, ReloadableRoute, {
willTransition() {
this.doReload();
},
error(error, transition) {
error(error) {
this.get('gameApi').reportError({ message: error });
}
}
Expand Down
11 changes: 9 additions & 2 deletions app/routes/job-create.js
Expand Up @@ -2,18 +2,25 @@ import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
import DefaultRoute from 'ares-webportal/mixins/default-route';
import RouteResetOnExit from 'ares-webportal/mixins/route-reset-on-exit';
import RSVP from 'rsvp';

export default Route.extend(DefaultRoute, RouteResetOnExit, {
gameApi: service(),
gameSocket: service(),

model: function() {
let api = this.get('gameApi');
return api.requestOne('jobOptions');

return RSVP.hash({
options: api.requestOne('jobOptions'),
characters: api.requestMany('characters', { select: 'all' })
})
.then((model) => Ember.Object.create(model));
},

setupController: function(controller, model) {
this._super(controller, model);
controller.set('category', model.get('request_category'));
controller.set('category', model.get('options.request_category'));
controller.set('submitter', model.get('characters').find(c => c.id == this.get('session.data.authenticated.id')));
}
});
2 changes: 1 addition & 1 deletion app/routes/mail-send.js
Expand Up @@ -6,7 +6,7 @@ import { inject as service } from '@ember/service';
export default Route.extend(RouteResetOnExit, AuthenticatedRoute, {
gameApi: service(),

model: function(params) {
model: function() {
let api = this.get('gameApi');
return api.requestMany('characters', { select: 'all' });
}
Expand Down
5 changes: 5 additions & 0 deletions app/routes/plot-create.js
Expand Up @@ -9,5 +9,10 @@ export default Route.extend(AuthenticatedRoute, RouteResetOnExit, {
model: function() {
let api = this.get('gameApi');
return api.requestMany('characters', { select: 'include_staff' });
},

setupController: function(controller, model) {
this._super(controller, model);
controller.set('storyteller', model.find(c => c.id == this.get('session.data.authenticated.id')));
}
});
2 changes: 0 additions & 2 deletions app/routes/search-locations.js
@@ -1,6 +1,4 @@
import Route from '@ember/routing/route';
import RSVP from 'rsvp';
import { inject as service } from '@ember/service';
import DefaultRoute from 'ares-webportal/mixins/default-route';
import ReloadableRoute from 'ares-webportal/mixins/reloadable-route';
import RouteResetOnExit from 'ares-webportal/mixins/route-reset-on-exit';
Expand Down
4 changes: 2 additions & 2 deletions app/services/game-socket.js
Expand Up @@ -27,7 +27,7 @@ export default Service.extend({
},

// Regular alert notification
notify(msg, timeOutSecs = 5, type = 'success') {
notify(msg, timeOutSecs = 10, type = 'success') {

if (msg) {
alertify.notify(msg, type, timeOutSecs);
Expand Down Expand Up @@ -179,7 +179,7 @@ export default Service.extend({
}
else if (notification_type == "new_chat") {
if (this.get('chatCallback')) {
this.get('chatCallback')(data.args.message);
this.get('chatCallback')(data.args.message, data.args.timestamp);
}
notify = false;
}
Expand Down
3 changes: 2 additions & 1 deletion app/templates/characters.hbs
Expand Up @@ -4,7 +4,8 @@
<div class="pull-right">
{{#link-to 'search-chars'}}<i class="fa fa-search" aria-hidden="true"></i> Search Characters{{/link-to}}
</div>

<p>Here you can browse the profiles for all approved characters.</p>
<div class="clearfix"/>
<ul class="nav nav-tabs">

{{#each model.characters.group_names as |group|}}
Expand Down
4 changes: 3 additions & 1 deletion app/templates/home.hbs
@@ -1,5 +1,7 @@
<div class="jumbotron">
<div class="jumbotron-image"/>

<img src="/game/uploads/theme_images/jumbotron.png" />

{{{ansi-format text=model.game.website_welcome}}}

<p>{{model.game.name}} is a MUSH - a multi-player text-based storytelling game. New to MUSHing? Check out the <a href="http://aresmush.com/mush-101" target="_blank">MUSH 101 Tutorial</a>. This is the <b>Web Portal</b>, which lets you interact with the game from a web browser. You can {{#link-to 'chargen'}}create your character{{/link-to}} online, view and edit {{#link-to 'characters'}}character profiles{{/link-to}}, browse the game's {{#link-to 'wiki'}}wiki{{/link-to}}, read {{#link-to 'scenes'}}scene logs{{/link-to}} and more!</p>
Expand Down
28 changes: 25 additions & 3 deletions app/templates/job-create.hbs
@@ -1,4 +1,4 @@
{{#if model.is_job_admin}}
{{#if model.options.is_job_admin}}
{{title 'Create Job'}}
<h1>Create a Job</h1>
{{else}}
Expand All @@ -21,12 +21,34 @@
</td>
</tr>

<tr>
<td>
<label>Submitter:</label>
</td>

<td>

{{#power-select selected=submitter options=model.characters searchField="name" onchange=(action "submitterChanged") as |char|}}
{{char.name}}
{{/power-select}}

</td>
</tr>

<tr>
<td>
<label>Category:</label>
</td>
<td>
<span class="label label-info job-category job-category-{{model.category}}">{{category}}</span>
{{#if category}}
<span class="label label-info job-category job-category-{{category}}">
{{category}}
</span>
{{else}}
<span class="label label-info job-category job-category-{{model.options.request_category}}">
{{model.options.request_category}}
</span>
{{/if}}
</td>
<td>
<ul class="nav">
Expand All @@ -35,7 +57,7 @@

<span class="btn btn-default" href="#" role="button">Change Category <span class="caret"></span></span> </a>
<ul class="dropdown-menu">
{{#each model.category_values as |category| }}
{{#each model.options.category_values as |category| }}
<li><a href="#" {{action 'changeCategory' category}}><span class="label job-category job-category-{{category}}">&nbsp;</span> {{category}}</a></li>
{{/each}}
</ul>
Expand Down
27 changes: 19 additions & 8 deletions app/templates/scene-live.hbs
Expand Up @@ -71,15 +71,22 @@
</i>
{{/if}}

{{#if pose.live_update}}
<i class="fas fa-lock" >
{{#bs-tooltip placement="left"}}Please reload the page if you need to edit or delete this pose.{{/bs-tooltip}}
</i>
{{/if}}
{{#if (and isApproved pose.can_edit)}}
{{#if (not pose.editActive)}}
<a href="#" {{action 'editScenePose' pose}}><i class="fa fa-edit" aria-hidden="true">
{{#bs-tooltip placement="left"}}Edit pose.{{/bs-tooltip}}
</i></a>
{{#if pose.can_delete}}
<a href="#" {{action (mut confirmDeleteScenePose) pose}}><i class="fa fa-trash" aria-hidden="true">
{{#bs-tooltip placement="left"}}Delete pose.{{/bs-tooltip}}
</i></a>
{{/if}}
{{/if}}
{{/if}}
</div>

Expand All @@ -89,15 +96,20 @@
</div>
{{else}}
<div class="scene-pose-header">
{{#link-to "char" pose.char.name}}
{{#if pose.char.icon}}
<img class="small-profile-icon {{icon-class}}" src="/game/uploads/{{pose.char.icon}}" />
{{else}}
{{#if pose.restarted_scene_pose}}
<img class="small-profile-icon {{icon-class}}" src="/game/uploads/theme_images/noicon.png" />
{{/if}}
{{/link-to}}
Scene Restarted
{{else}}
{{#link-to "char" pose.char.name}}
{{#if pose.char.icon}}
<img class="small-profile-icon {{icon-class}}" src="/game/uploads/{{pose.char.icon}}" />
{{else}}
<img class="small-profile-icon {{icon-class}}" src="/game/uploads/theme_images/noicon.png" />
{{/if}}
{{/link-to}}

{{#link-to "char" pose.char.name}} {{pose.char.name}} {{/link-to}}
{{#link-to "char" pose.char.name}} {{pose.char.name}} {{/link-to}}
{{/if}}
</div>
{{#if pose.editActive}}
{{markdown-editor text=pose.raw_pose}}
Expand Down Expand Up @@ -268,7 +280,6 @@
{{input type="text" size=25 id="rollString" enter="addSceneRoll" value=rollString}}

{{/bs-modal-simple}}

</div>
</div>
{{outlet}}
2 changes: 1 addition & 1 deletion app/templates/setup.hbs
Expand Up @@ -3,7 +3,7 @@

<p>Here you can edit your game's configuration files.</p>

<div class="alert alert-warning">This section contains advanced configuration options. Please read the <a href="http://aresmush.com/tutorials/config">AresMUSH.com tutorials</a> before attempting to configure your game here.</div>
<div class="alert alert-warning">Please read the <a href="http://aresmush.com/tutorials/config">AresMUSH.com tutorials</a> before attempting to configure your game.</div>

<h2>Game Information</h2>
<ul>
Expand Down
2 changes: 1 addition & 1 deletion public/scripts/aresweb_version.js
@@ -1 +1 @@
var aresweb_version = "0.40";
var aresweb_version = "0.41";

0 comments on commit 144ecff

Please sign in to comment.