Skip to content

Commit

Permalink
#22 More typescript routes that were missed. Fixing some template mes…
Browse files Browse the repository at this point in the history
…siness.
  • Loading branch information
nadnoslen committed Mar 21, 2019
1 parent 77ed4ca commit 6f2e7b6
Show file tree
Hide file tree
Showing 33 changed files with 61 additions and 177 deletions.
2 changes: 1 addition & 1 deletion ADDONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ ember install ember-cli-sass
ember install ember-cli-text-support-mixins

# installing typescript to make life happy
ember install ember-cli-typescript
ember install ember-cli-typescript@latest

# Used to manipulate arrays template-side
ember install ember-composable-helpers
Expand Down
2 changes: 1 addition & 1 deletion app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ Router.map(function () {
});
});
this.route('profile', function () {
this.route('attributes');
this.route('configure-mfa');
this.route('change-password');
this.route('attributes');
this.route('name');
this.route('address');
this.route('locale-timezone');
Expand Down
4 changes: 2 additions & 2 deletions app/routes/forgot-password.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default class ForgotPassword extends Route {
};

@action
forgotPassword(session, username) {
forgotPassword(session, username: string) {
session
.forgotPassword(username)
.then(() => {
Expand All @@ -22,7 +22,7 @@ export default class ForgotPassword extends Route {
return false;
}

model(params) {
model(params: { email?: string }) {
return hash({
username: getWithDefault(params, 'email', '')
});
Expand Down
9 changes: 5 additions & 4 deletions app/routes/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ export default class Login extends Route.extend(UnauthenticatedRouteMixin) {
queryParams = {
username: {refreshModel: false}
};

@service session;

@action
completePassword(authenticationState, newPassword, additionalAttributes = {}/*, submitEvent*/) {
completePassword(authenticationState, newPassword: string, additionalAttributes = {}/*, submitEvent*/) {
this.session
.completePassword(authenticationState, newPassword, additionalAttributes)
.then(authenticationState => {
Expand All @@ -25,15 +26,15 @@ export default class Login extends Route.extend(UnauthenticatedRouteMixin) {
}

@action
confirmSignIn(authenticationState, code) {
confirmSignIn(authenticationState, code: string) {
this.session
.confirmSignIn(authenticationState, code)
.catch(response => this.notify.error(response.message));
return false;
}

@action
signIn(username, password) {
signIn(username: string, password: string) {
const notification = this.notify.info('Signing you in...');
this.session
.signIn(username, password)
Expand All @@ -49,7 +50,7 @@ export default class Login extends Route.extend(UnauthenticatedRouteMixin) {
return false;
}

model(params) {
model(params: { username?: string }) {
return {
additionalAttributes: {},
authenticationState: {}, // will be set during sign in if MFA is enabled
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { set } from '@ember/object';
import { hash } from 'rsvp';
import {set} from '@ember/object';
import {hash} from 'rsvp';
import Route from '@ember/routing/route';

export default class Index extends Route {
Expand All @@ -9,7 +9,7 @@ export default class Index extends Route {

model() {
return hash({
roles: this.store.query('role', { sort: 'name' })
roles: this.store.query('role', {sort: 'name'})
});
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { hash } from 'rsvp';
import { set } from '@ember/object';
import {hash} from 'rsvp';
import {set} from '@ember/object';
import Route from '@ember/routing/route';
import User from "ermahgerd-emberjs-cognito/models/user";
import {RecordArray} from "ember-data";

export default class Index extends Route {
afterModel(resolvedModel) {
afterModel(resolvedModel: { users: RecordArray<User> }) {
set(resolvedModel, 'usersCount', resolvedModel.users.meta['record-count']);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { hash } from 'rsvp';
import {hash} from 'rsvp';
import Route from '@ember/routing/route';

export default class New extends Route {
model() {
return hash({
roles: this.store.query('role', { sort: 'name' })
roles: this.store.query('role', {sort: 'name'})
})
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { action } from '@ember-decorators/object';
import { isBlank } from '@ember/utils';
import { hash } from 'rsvp';
import {action} from '@ember-decorators/object';
import {isBlank} from '@ember/utils';
import {hash} from 'rsvp';
import Route from '@ember/routing/route';
import User from "ermahgerd-emberjs-cognito/models/user";
import Role from 'ermahgerd-emberjs-cognito/models/role';
import {RecordArray} from "ember-data";

export default class Index extends Route {
@action
chooseRole(user, chosenRole) {
chooseRole(user: User, chosenRole: Role) {
if (isBlank(chosenRole)) {
return true;
}
Expand All @@ -15,7 +18,7 @@ export default class Index extends Route {
}

@action
save(user) {
save(user: User) {
user
.save()
.then((/*response*/) => {
Expand All @@ -28,7 +31,7 @@ export default class Index extends Route {
return false;
}

model() {
model(): hash<{ roles: RecordArray<Role>, users: RecordArray<User> }> {
return hash({
roles: this.modelFor('protected.configuration.users.new').roles,
user: this.store.createRecord('user')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default class User extends Route {
beforeModel() {
const params = this.paramsFor('protected.configuration.users.user');
return this.store.query('user', {
filter: { id: params.user_id },
filter: {id: params.user_id},
include: '' +
'roles' +
',sessions' +
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import { hash } from 'rsvp';
import { set } from '@ember/object';
import {hash} from 'rsvp';
import {set} from '@ember/object';
import Route from '@ember/routing/route';
import {RecordArray} from "ember-data";
import Session from 'ermahgerd-emberjs-cognito/models/session';

export default class Index extends Route {
afterModel(resolvedModel) {
afterModel(resolvedModel: { sessions: RecordArray<Session> }) {
set(resolvedModel, 'sessionsCount', resolvedModel.sessions.meta['record-count']);
}

model() {
const user = this.modelFor('protected.configuration.users.user');
return hash({
sessions: this.store.query('session', {
filter: { user: user.id },
filter: {user: user.id},
sort: '' +
'-created-at'
})
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion app/routes/protected/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default class Profile extends Route {
@service session;

@action
update(session, subjectAttributes) {
update(session, subjectAttributes: {}) {
session
.updateUserAttributes(subjectAttributes)
.then(() => this.notify.success('Your profile was updated successfully.'))
Expand Down
File renamed without changes.
20 changes: 0 additions & 20 deletions app/routes/protected/profile/attributes.js

This file was deleted.

7 changes: 7 additions & 0 deletions app/routes/protected/profile/attributes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Route from '@ember/routing/route';

/**
* TODO: this route should be renamed to `social-sites`
*/
export default class Attributes extends Route {
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { action } from '@ember-decorators/object';
import { hash } from 'rsvp';
import {action} from '@ember-decorators/object';
import {hash} from 'rsvp';
import Route from '@ember/routing/route';

export default class ChangePassword extends Route {
@action
changePassword(session, currentPassword, newPassword) {
changePassword(session, currentPassword: string, newPassword: string) {
session
.changePassword(currentPassword, newPassword)
.then(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { action } from '@ember-decorators/object';
import { set } from '@ember/object';
import { hash } from 'rsvp';
import {action} from '@ember-decorators/object';
import {set} from '@ember/object';
import {hash} from 'rsvp';
import Route from '@ember/routing/route';

export default class ConfigureMfa extends Route {
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions app/routes/reset-password.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default class ResetPassword extends Route {
@service session;

@action
setPassword(session, username, code, password) {
setPassword(session, username: string, code: string, password: string) {
session
.resetPassword(username, code, password)
.then(() => {
Expand All @@ -24,7 +24,7 @@ export default class ResetPassword extends Route {
return false;
}

model(params) {
model(params: { username?: string }) {
return hash({
code: '',
password: '',
Expand Down
2 changes: 1 addition & 1 deletion app/routes/sign-up.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import UnauthenticatedRouteMixin from 'ember-simple-auth/mixins/unauthenticated-

export default class SignUp extends Route.extend(UnauthenticatedRouteMixin) {
@action
signUp(session, username, password, passwordConfirmation, givenName, familyName) {
signUp(session, username: string, password: string, passwordConfirmation: string, givenName: string, familyName: string) {
session.signUp({
username,
password,
Expand Down
2 changes: 1 addition & 1 deletion app/templates/protected/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<h1 class="flex-fill">
<span class="text-success">Protected</span> Path
<small class="text-muted">
Welcome {{session.data.authenticated.attributes.given_name}}
Welcome {{session.data.authenticated.attributes.name}}
</small>
</h1>
<div class="align-self-center">
Expand Down
3 changes: 3 additions & 0 deletions app/templates/protected/profile.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
{{#link-to "protected.profile.locale-timezone" class="list-group-item list-group-item-action"}}
Locale/Timezone
{{/link-to}}
{{#link-to "protected.profile.attributes" class="list-group-item list-group-item-action"}}
Social/Sites
{{/link-to}}
{{#link-to "protected.profile.change-password" class="list-group-item list-group-item-action"}}
Change Password
{{/link-to}}
Expand Down
Loading

0 comments on commit 6f2e7b6

Please sign in to comment.