-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Load Sockethub dynamically, inform when unavailable
- Loading branch information
Showing
17 changed files
with
144 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import Route from '@ember/routing/route'; | ||
import { inject as service } from '@ember/service'; | ||
import config from 'hyperchannel/config/environment'; | ||
|
||
export default class ConfigureSockethubRoute extends Route { | ||
|
||
@service sockethub; | ||
|
||
model () { | ||
return { config }; | ||
} | ||
|
||
redirect () { | ||
if (this.sockethub.client) { | ||
this.transitionTo('index'); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import Service from '@ember/service'; | ||
import { tracked } from '@glimmer/tracking'; | ||
import config from 'hyperchannel/config/environment'; | ||
|
||
export default class SockethubService extends Service { | ||
@tracked client = null; | ||
|
||
async initialize (/* baseURL */) { | ||
return this.loadSockethubLibs(config.sockethubURL).then(() => { | ||
this.client = new window.SockethubClient( | ||
window.io(config.sockethubURL, { path: '/sockethub' }) | ||
); | ||
}); | ||
} | ||
|
||
async loadSockethubLibs (baseURL) { | ||
await this.loadExternalScript(baseURL + '/socket.io.js'); | ||
await this.loadExternalScript(baseURL + '/sockethub-client.js'); | ||
} | ||
|
||
async loadExternalScript (url) { | ||
return new Promise((resolve, reject) => { | ||
const script = document.createElement('script'); | ||
document.body.appendChild(script); | ||
script.onload = resolve; | ||
script.onerror = reject; | ||
script.async = true; | ||
script.src = url; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<div class="max-w-3xl mx-auto mt-10 lg:mt-40 lg:mb-24 sm:px-6 lg:px-8"> | ||
<div class="bg-white overflow-hidden shadow sm:rounded-lg"> | ||
<div class="px-4 py-10 sm:p-10 text-neutral-800"> | ||
<h2 class="mb-10 text-center text-3xl font-light">Sockethub unavailable</h2> | ||
<p class="mb-4"> | ||
<a href="http://sockethub.org/" target="_blank" class="text-orange-600 underline" rel="noopener noreferrer">Sockethub</a> | ||
is an open-source server program, which this app needs in | ||
order to talk to chat servers. | ||
</p> | ||
<p class="mb-4"> | ||
Unfortunately, the Sockethub server at | ||
<code class="px-2 py-1 bg-orange-100 text-orange-600 font-bold">{{this.model.config.sockethubURL}}</code> | ||
seems to be offline at the moment. | ||
</p> | ||
{{#if (eq this.model.config.environment "development")}} | ||
<p class="mb-10 font-bold"> | ||
The app is running in development mode. Please make sure Sockethub is | ||
running on your machine and try again. | ||
</p> | ||
{{/if}} | ||
</div> | ||
</div> | ||
</div> |
Oops, something went wrong.