Skip to content

Commit

Permalink
feat(info): add switch carrier info
Browse files Browse the repository at this point in the history
  • Loading branch information
zack9433 committed Jun 22, 2017
1 parent dea67bd commit 8a30033
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/component/info/container.component.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import CellularInfoContainerController from './container.controller';

const CellularInfoContainerComponent = {
template: `<sanji-cellular-info data="$ctrl.data" tab-index="$ctrl.sanjiWindowMgr.tabIndex"></sanji-cellular-info>`,
template: `<sanji-cellular-info data="$ctrl.data"
carrier="$ctrl.carrier"
on-fetch-carrier="$ctrl.onFetchCarrier($event)"
tab-index="$ctrl.sanjiWindowMgr.tabIndex"></sanji-cellular-info>`,
controller: CellularInfoContainerController
};
export default CellularInfoContainerComponent;
11 changes: 8 additions & 3 deletions src/component/info/container.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const $inject = ['$scope', '$ngRedux', 'sanjiWindowService', 'cellularActions'];
const WINDOW_ID = 'sanji-cellular-ui';
class CellularInfoContainerController {
constructor(...injects) {
CellularInfoContainerController.$inject.forEach((item, index) => this[item] = injects[index]);
CellularInfoContainerController.$inject.forEach((item, index) => (this[item] = injects[index]));
}

$onInit() {
Expand All @@ -19,13 +19,18 @@ class CellularInfoContainerController {

mapStateToThis(state) {
return {
data: state.cellulars
data: state.cellulars,
carrier: state.carrier
};
}

onFetchCarrier(event) {
return this.getCellularCarrier(event.id);
}

onRefresh(event, args) {
if (args.id === WINDOW_ID) {
this.sanjiWindowMgr.promise = this.getCellulars({force: true});
this.sanjiWindowMgr.promise = this.getCellulars({ force: true });
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/component/info/info.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import CellularInfoController from './info.controller';
const CellularInfoComponent = {
bindings: {
tabs: '<data',
carrier: '<',
onFetchCarrier: '&',
tabIndex: '='
},
templateUrl: 'sanji-cellular-info.tpl.html',
Expand Down
13 changes: 12 additions & 1 deletion src/component/info/info.controller.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
const $inject = [];
class CellularInfoController {
constructor(...injects) {
CellularInfoController.$inject.forEach((item, index) => this[item] = injects[index]);
CellularInfoController.$inject.forEach((item, index) => (this[item] = injects[index]));
}

$onInit() {
this.currentCarrier = {};
this.onFetchCarrier({
$event: {
id: (this.tabIndex || 0) + 1
}
}).then(carrier => {
this.currentCarrier = carrier.current;
});
}
}
CellularInfoController.$inject = $inject;
Expand Down
4 changes: 4 additions & 0 deletions src/component/info/info.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@
<span ng-bind="tab.content.keepalive.intervalSec"></span>
<span translate="CELLULAR_SEC"></span>
</md-list-item>
<md-list-item ng-if="$ctrl.carrier.switchable">
<p class="md-body-2" translate="CELLULAR_FORM_CARRIER"></p>
<span ng-bind="$ctrl.currentCarrier.carrier"></span>
</md-list-item>
</md-list>
</md-tab>
</md-tabs>
Expand Down

0 comments on commit 8a30033

Please sign in to comment.