Skip to content

Commit

Permalink
ES6: migrated "main"
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregor Herdmann committed Apr 26, 2017
1 parent 00e5f3b commit cf624a7
Show file tree
Hide file tree
Showing 16 changed files with 780 additions and 709 deletions.
1 change: 0 additions & 1 deletion app/page/template/_dist/app.htm
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@
<script src="/script/telemetry/app_init/AppInitTimingsStep.js"></script>
<!-- Initialization -->
<script src="/script/main/auth.js"></script>
<script src="/script/main/auth_init.js"></script>
<!-- User -->
<script src="/script/user/ConnectionStatus.js"></script>
<script src="/script/user/UserError.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion app/script/assets/Asset.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ z.assets.Asset = class Asset {
const value = this.payload[key];
payload.push(`${key}=${value}`);
}

return payload.join(';');
}

};
7 changes: 5 additions & 2 deletions app/script/audio/AudioRepository.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,11 @@ window.z.audio.AudioRepository = class AudioRepository {
*/
_subscribe_to_events() {
amplify.subscribe(z.event.WebApp.EVENT.NOTIFICATION_HANDLING_STATE, this, (handling_notifications) => {
this.muted = handling_notifications !== z.event.NOTIFICATION_HANDLING_STATE.WEB_SOCKET;
this.logger.info(`Set muted state to '${this.muted}'`);
const new_muted_state = handling_notifications !== z.event.NOTIFICATION_HANDLING_STATE.WEB_SOCKET;
if (this.muted !== new_muted_state) {
this.muted = new_muted_state;
this.logger.info(`Set muted state to '${this.muted}'`);
}
});

amplify.subscribe(z.event.WebApp.PROPERTIES.UPDATED, this, (properties) => {
Expand Down
505 changes: 0 additions & 505 deletions app/script/main/app.coffee

This file was deleted.

674 changes: 674 additions & 0 deletions app/script/main/app.js

Large diffs are not rendered by default.

36 changes: 0 additions & 36 deletions app/script/main/auth.coffee

This file was deleted.

71 changes: 71 additions & 0 deletions app/script/main/auth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* Wire
* Copyright (C) 2017 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*
*/

'use strict';

window.z = window.z || {};
window.z.main = z.main || {};

z.main.Auth = class Auth {
/**
* Constructs objects needed for app authentication.
*
* @param {Object} settings - Collection of URL settings
* @param {string} settings.environment - Handle of the backend environment (staging, etc.)
* @param {string} settings.web_socket_url - URL to the backend's WebSocket
* @param {string} settings.rest_url - URL to the backend's REST service
* @param {string} settings.parameter - Additional parameters for the webapp's login URL
* @returns {Auth} New authentication object
*/
constructor(settings) {
this.settings = settings;
this.audio = new z.audio.AudioRepository();
this.client = new z.service.Client(this.settings);
this.service = new z.auth.AuthService(this.client);
this.repository = new z.auth.AuthRepository(this.service);
return this;
}
};

//##############################################################################
// Setting up the Environment (DIST)
//##############################################################################
$(function() {
const default_env = z.util.Environment.frontend.is_production() ? z.service.BackendEnvironment.PRODUCTION : z.service.BackendEnvironment.STAGING;
const env = z.util.get_url_parameter(z.auth.URLParameter.ENVIRONMENT) || default_env;
let settings;

if (env === z.service.BackendEnvironment.STAGING) {
settings = {
environment: z.service.BackendEnvironment.STAGING,
rest_url: 'https://staging-nginz-https.zinfra.io',
web_socket_url: 'wss://staging-nginz-ssl.zinfra.io',
};
} else {
settings = {
environment: z.service.BackendEnvironment.PRODUCTION,
rest_url: 'https://prod-nginz-https.wire.com',
web_socket_url: 'wss://prod-nginz-ssl.wire.com',
};
}

window.wire = {
auth: new z.main.Auth(settings),
};
});
36 changes: 0 additions & 36 deletions app/script/main/auth_init_dist.coffee

This file was deleted.

29 changes: 0 additions & 29 deletions app/script/main/auth_init_prod.coffee

This file was deleted.

36 changes: 0 additions & 36 deletions app/script/main/auth_init_staging.coffee

This file was deleted.

2 changes: 1 addition & 1 deletion app/script/util/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ z.util.is_valid_email = function(email) {
z.util.is_valid_phone_number = function(phone_number) {
let regular_expression;

if (z.util.Environment.backend.current === 'production') {
if (z.util.Environment.backend.current === z.service.BackendEnvironment.PRODUCTION) {
regular_expression = /^\+[1-9]\d{1,14}$/;
} else {
regular_expression = /^\+[0-9]\d{1,14}$/;
Expand Down
28 changes: 2 additions & 26 deletions grunt/config/coffee.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,7 @@ module.exports =
dest: '<%= dir.dist %>'
expand: true
ext: '.js'
src: ['**/*.coffee', '!**/auth_init*.coffee']

dist_init:
cwd: '<%= dir.app_ %>'
dest: '<%= dir.dist %>'
expand: true
ext: '.js'
src: '**/auth_init_dist.coffee'
rename: (dest, src) -> return "#{dest}/script/main/auth_init.js"
src: '**/*.coffee'

test:
cwd: '<%= dir.test.unit_tests %>'
Expand All @@ -52,22 +44,6 @@ module.exports =
dest: '<%= dir.deploy %>'
expand: true
ext: '.js'
src: ['**/*.coffee', '!**/auth_init*.coffee']

staging:
cwd: '<%= dir.app_ %>'
dest: '<%= dir.deploy %>'
expand: true
ext: '.js'
src: '**/auth_init_staging.coffee'
rename: (dest, src) -> return "#{dest}/script/main/auth_init.js"

prod:
cwd: '<%= dir.app_ %>'
dest: '<%= dir.deploy %>'
expand: true
ext: '.js'
src: '**/auth_init_prod.coffee'
rename: (dest, src) -> return "#{dest}/script/main/auth_init.js"
src: '**/*.coffee'


3 changes: 0 additions & 3 deletions grunt/tasks/misc.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ module.exports = (grunt) ->
grunt.registerTask 'prepare_dist', [
'clean:dist'
'coffee:dist'
'coffee:dist_init'
'less:dist'
'postcss:distribution'
'copy:dist'
Expand All @@ -72,7 +71,6 @@ module.exports = (grunt) ->
'clean:deploy'
'coffeelint:deploy'
'coffee:deploy'
'coffee:staging'
'less:deploy'
'postcss:deploy'
'copy:deploy'
Expand All @@ -89,7 +87,6 @@ module.exports = (grunt) ->
grunt.registerTask 'prepare_prod', [
'clean:deploy'
'coffee:deploy'
'coffee:prod'
'less:deploy'
'postcss:deploy'
'copy:deploy'
Expand Down
30 changes: 16 additions & 14 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
*
*/

module.exports = function (config) {
/* eslint-disable sort-keys */

module.exports = function(config) {
config.set({

// base path that will be used to resolve all patterns (eg. files, exclude)
Expand All @@ -40,7 +42,7 @@ module.exports = function (config) {
// pre-process matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'../dist/script/**/*.js': ['coverage']
'../dist/script/**/*.js': ['coverage'],
},

// test results reporter to use
Expand Down Expand Up @@ -68,8 +70,8 @@ module.exports = function (config) {
customLaunchers: {
Chrome_travis_ci: {
base: 'Chrome',
flags: ['--no-sandbox']
}
flags: ['--no-sandbox'],
},
},

// Continuous Integration mode
Expand All @@ -84,34 +86,34 @@ module.exports = function (config) {
reporters: [
{
dir: '../docs/coverage',
type: 'html'
type: 'html',
},
{
dir: '../docs/coverage',
file: 'coverage-summary.txt',
type: 'text-summary'
}
type: 'text-summary',
},
],
check: {
global: {
statements: 40,
branches: 25,
functions: 20,
lines: 40
lines: 40,
},
each: {
statements: 2,
statements: 0,
branches: 0,
functions: 0,
lines: 2
}
}
}
lines: 0,
},
},
},
});

if (process.env.TRAVIS) {
config.set({
port: 9877
port: 9877,
});
}
};
Loading

0 comments on commit cf624a7

Please sign in to comment.