Skip to content

Commit

Permalink
fix(service): add success message
Browse files Browse the repository at this point in the history
  • Loading branch information
zack9433 committed Mar 22, 2016
1 parent 7183a13 commit 1a2877e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
10 changes: 7 additions & 3 deletions app/component/component.service.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const $inject = ['$q', 'rest', 'exception', '_', 'pathToRegexp'];
const $inject = ['$q', 'rest', 'exception', '_', 'pathToRegexp', '$filter', 'logger'];
const config = require('./component.resource.json');
class CellularService {
constructor(...injects) {
Expand Down Expand Up @@ -46,7 +46,7 @@ class CellularService {

get() {
let toPath = this.pathToRegexp.compile(config.get.url);
return this.rest.get(toPath(), (__DEV__) ? {basePath: 'http://localhost:8000'} : undefined)
return this.rest.get(toPath(), (__DEV__) ? {basePath: __BASE_PATH__} : undefined)
.then(res => {
this.data = this._transform(res.data);
})
Expand All @@ -59,7 +59,11 @@ class CellularService {
update(data) {
let toPath = this.pathToRegexp.compile(config.put.url);
let path = (undefined !== data.content.id) ? toPath({id: data.content.id}) : toPath();
return this.rest.put(path, data.content, data.formOptions.files, (__DEV__) ? {basePath: 'http://localhost:8000' } : undefined)
return this.rest.put(path, data.content, data.formOptions.files, (__DEV__) ? {basePath: __BASE_PATH__} : undefined)
.then(res => {
this.logger.success(this.$filter('translate')('CELLULAR_FORM_SAVE_SUCCESS'), res.data);
return res.data;
})
.catch(err => {
this.exception.catcher('[CellularService] Update data error.')(err);
return this.$q.reject();
Expand Down
1 change: 1 addition & 0 deletions app/component/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"CELLULAR_FORM_LABEL_TARGET_HOST": "Target Host",
"CELLULAR_FORM_LABEL_PING_INTERVAL": "Ping Interval",
"CELLULAR_FORM_SAVE": "Save",
"CELLULAR_FORM_SAVE_SUCCESS": "Update data successfully.",
"CELLULAR_INFO_BASIC": "Basic Information",
"CELLULAR_INFO_OPERATOR": "Operator Name",
"CELLULAR_INFO_CONNECTION_STATUS": "Connection Status",
Expand Down
1 change: 1 addition & 0 deletions app/component/lang/zh-tw.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"CELLULAR_FORM_LABEL_TARGET_HOST": "目標主機",
"CELLULAR_FORM_LABEL_PING_INTERVAL": "Ping 間隔",
"CELLULAR_FORM_SAVE": "儲存",
"CELLULAR_FORM_SAVE_SUCCESS": "更新資料成功",
"CELLULAR_INFO_BASIC": "基本資訊",
"CELLULAR_INFO_OPERATOR": "營運商名稱",
"CELLULAR_INFO_CONNECTION_STATUS": "連線狀態",
Expand Down
1 change: 1 addition & 0 deletions webpack.build.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ config.entry = {
};
config.output.filename = 'sanji-cellular-ui.js';
config.output.libraryTarget = 'umd';
config.output.library = 'sjCellular';
config.externals = [
'angular',
'sanji-core-ui'
Expand Down
4 changes: 3 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
var path = require('path');
var webpack = require('webpack');
var NODE_ENV = process.env.NODE_ENV;
var BASE_PATH = process.env.BASE_PATH;
var nodeRoot = path.join(__dirname, 'node_modules');
var appRoot = path.join(__dirname, 'app');
var config = {
Expand Down Expand Up @@ -40,7 +41,8 @@ var config = {
new webpack.DefinePlugin({
__TEST__: 'test' === NODE_ENV,
__DEV__: 'development' === NODE_ENV,
__RELEASE__: 'production' === NODE_ENV
__RELEASE__: 'production' === NODE_ENV,
__BASE_PATH__: JSON.stringify(BASE_PATH) || '"http://localhost:8000"'
}),
new webpack.NoErrorsPlugin()
]
Expand Down

0 comments on commit 1a2877e

Please sign in to comment.