Merge branch 'HollyFang-feature/SceemaGroup'
This commit is contained in:
commit
5554496de1
@ -145,11 +145,13 @@ function JsonForm($compile, $templateCache, $mdColorPicker) {
|
|||||||
};
|
};
|
||||||
schema.strict = true;
|
schema.strict = true;
|
||||||
var form = scope.form ? angular.copy(scope.form) : [ "*" ];
|
var form = scope.form ? angular.copy(scope.form) : [ "*" ];
|
||||||
|
var groupInfoes = scope.groupInfoes ? angular.copy(scope.groupInfoes) : [];
|
||||||
var model = scope.model || {};
|
var model = scope.model || {};
|
||||||
scope.model = inspector.sanitize(schema, model).data;
|
scope.model = inspector.sanitize(schema, model).data;
|
||||||
scope.formProps.option.formDefaults.readonly = readonly;
|
scope.formProps.option.formDefaults.readonly = readonly;
|
||||||
scope.formProps.schema = schema;
|
scope.formProps.schema = schema;
|
||||||
scope.formProps.form = form;
|
scope.formProps.form = form;
|
||||||
|
scope.formProps.groupInfoes = groupInfoes;
|
||||||
scope.formProps.model = angular.copy(scope.model);
|
scope.formProps.model = angular.copy(scope.model);
|
||||||
if (!skipRerender) {
|
if (!skipRerender) {
|
||||||
recompile();
|
recompile();
|
||||||
@ -176,6 +178,12 @@ function JsonForm($compile, $templateCache, $mdColorPicker) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
scope.$watch('groupInfoes',function(newValue, prevValue) {
|
||||||
|
if (newValue && newValue != prevValue) {
|
||||||
|
scope.updateValues();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
scope.validate();
|
scope.validate();
|
||||||
|
|
||||||
recompile();
|
recompile();
|
||||||
@ -189,6 +197,7 @@ function JsonForm($compile, $templateCache, $mdColorPicker) {
|
|||||||
form: '=',
|
form: '=',
|
||||||
model: '=',
|
model: '=',
|
||||||
formControl: '=',
|
formControl: '=',
|
||||||
|
groupInfoes: '=',
|
||||||
readonly: '='
|
readonly: '='
|
||||||
},
|
},
|
||||||
link: linker
|
link: linker
|
||||||
|
|||||||
@ -47,6 +47,7 @@ class ReactSchemaForm extends React.Component {
|
|||||||
ReactSchemaForm.propTypes = {
|
ReactSchemaForm.propTypes = {
|
||||||
schema: React.PropTypes.object,
|
schema: React.PropTypes.object,
|
||||||
form: React.PropTypes.array,
|
form: React.PropTypes.array,
|
||||||
|
groupInfoes: React.PropTypes.array,
|
||||||
model: React.PropTypes.object,
|
model: React.PropTypes.object,
|
||||||
option: React.PropTypes.object,
|
option: React.PropTypes.object,
|
||||||
onModelChange: React.PropTypes.func,
|
onModelChange: React.PropTypes.func,
|
||||||
@ -56,7 +57,8 @@ ReactSchemaForm.propTypes = {
|
|||||||
|
|
||||||
ReactSchemaForm.defaultProps = {
|
ReactSchemaForm.defaultProps = {
|
||||||
schema: {},
|
schema: {},
|
||||||
form: [ "*" ]
|
form: [ "*" ],
|
||||||
|
groupInfoes:[]
|
||||||
}
|
}
|
||||||
|
|
||||||
ReactSchemaForm.childContextTypes = {
|
ReactSchemaForm.childContextTypes = {
|
||||||
|
|||||||
@ -83,6 +83,7 @@ class ThingsboardSchemaForm extends React.Component {
|
|||||||
this.props.onToggleFullscreen();
|
this.props.onToggleFullscreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
builder(form, model, index, onChange, onColorClick, onToggleFullscreen, mapper) {
|
builder(form, model, index, onChange, onColorClick, onToggleFullscreen, mapper) {
|
||||||
var type = form.type;
|
var type = form.type;
|
||||||
let Field = this.mapper[type];
|
let Field = this.mapper[type];
|
||||||
@ -99,8 +100,8 @@ class ThingsboardSchemaForm extends React.Component {
|
|||||||
return <Field model={model} form={form} key={index} onChange={onChange} onColorClick={onColorClick} onToggleFullscreen={onToggleFullscreen} mapper={mapper} builder={this.builder}/>
|
return <Field model={model} form={form} key={index} onChange={onChange} onColorClick={onColorClick} onToggleFullscreen={onToggleFullscreen} mapper={mapper} builder={this.builder}/>
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
createSchema(theForm) {
|
||||||
let merged = utils.merge(this.props.schema, this.props.form, this.props.ignore, this.props.option);
|
let merged = utils.merge(this.props.schema, theForm, this.props.ignore, this.props.option);
|
||||||
let mapper = this.mapper;
|
let mapper = this.mapper;
|
||||||
if(this.props.mapper) {
|
if(this.props.mapper) {
|
||||||
mapper = _.merge(this.mapper, this.props.mapper);
|
mapper = _.merge(this.mapper, this.props.mapper);
|
||||||
@ -118,5 +119,43 @@ class ThingsboardSchemaForm extends React.Component {
|
|||||||
<div style={{width: '100%'}} className={formClass}>{forms}</div>
|
<div style={{width: '100%'}} className={formClass}>{forms}</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
if(this.props.groupInfoes&&this.props.groupInfoes.length>0){
|
||||||
|
let content=[];
|
||||||
|
for(let info of this.props.groupInfoes){
|
||||||
|
let forms = this.createSchema(this.props.form[info.formIndex]);
|
||||||
|
let item = <ThingsboardSchemaGroup key={content.length} forms={forms} info={info}></ThingsboardSchemaGroup>;
|
||||||
|
content.push(item);
|
||||||
|
}
|
||||||
|
return (<div>{content}</div>);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return this.createSchema(this.props.form);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
export default ThingsboardSchemaForm;
|
export default ThingsboardSchemaForm;
|
||||||
|
|
||||||
|
|
||||||
|
class ThingsboardSchemaGroup extends React.Component{
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.state={
|
||||||
|
showGroup:true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
toogleGroup(index) {
|
||||||
|
this.setState({
|
||||||
|
showGroup:!this.state.showGroup
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
let theCla = "pull-right fa fa-chevron-down md-toggle-icon"+(this.state.showGroup?"":" tb-toggled")
|
||||||
|
return (<section className="md-whiteframe-z1" style={{marginTop: '10px'}}>
|
||||||
|
<div className='SchemaGroupname md-button-toggle' onClick={this.toogleGroup.bind(this)}>{this.props.info.GroupTitle}<span className={theCla}></span></div>
|
||||||
|
<div style={{padding: '20px'}} className={this.state.showGroup?"":"invisible"}>{this.props.forms}</div>
|
||||||
|
</section>);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -121,3 +121,12 @@ label.tb-label {
|
|||||||
.tb-head-label {
|
.tb-head-label {
|
||||||
color: rgba(0, 0, 0, .54);
|
color: rgba(0, 0, 0, .54);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.SchemaGroupname{
|
||||||
|
padding: 10px 20px;
|
||||||
|
background-color: #f1f1f1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.invisible{
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|||||||
@ -63,6 +63,8 @@ function WidgetConfig($compile, $templateCache, $rootScope, $translate, $timeout
|
|||||||
type: "object",
|
type: "object",
|
||||||
properties: {}
|
properties: {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
scope.emptySettingsGroupInfoes=[];
|
||||||
scope.defaultSettingsForm = [
|
scope.defaultSettingsForm = [
|
||||||
'*'
|
'*'
|
||||||
];
|
];
|
||||||
@ -90,6 +92,7 @@ function WidgetConfig($compile, $templateCache, $rootScope, $translate, $timeout
|
|||||||
|
|
||||||
scope.currentSettingsSchema = {};
|
scope.currentSettingsSchema = {};
|
||||||
scope.currentSettings = angular.copy(scope.emptySettingsSchema);
|
scope.currentSettings = angular.copy(scope.emptySettingsSchema);
|
||||||
|
scope.currentSettingsGroupInfoes = angular.copy(scope.emptySettingsGroupInfoes);
|
||||||
|
|
||||||
scope.targetDeviceAlias = {
|
scope.targetDeviceAlias = {
|
||||||
value: null
|
value: null
|
||||||
@ -191,10 +194,12 @@ function WidgetConfig($compile, $templateCache, $rootScope, $translate, $timeout
|
|||||||
if (scope.widgetSettingsSchema && scope.widgetSettingsSchema.schema) {
|
if (scope.widgetSettingsSchema && scope.widgetSettingsSchema.schema) {
|
||||||
scope.currentSettingsSchema = scope.widgetSettingsSchema.schema;
|
scope.currentSettingsSchema = scope.widgetSettingsSchema.schema;
|
||||||
scope.currentSettingsForm = scope.widgetSettingsSchema.form || angular.copy(scope.defaultSettingsForm);
|
scope.currentSettingsForm = scope.widgetSettingsSchema.form || angular.copy(scope.defaultSettingsForm);
|
||||||
|
scope.currentSettingsGroupInfoes = scope.widgetSettingsSchema.groupInfoes;
|
||||||
scope.currentSettings = scope.settings;
|
scope.currentSettings = scope.settings;
|
||||||
} else {
|
} else {
|
||||||
scope.currentSettingsForm = angular.copy(scope.defaultSettingsForm);
|
scope.currentSettingsForm = angular.copy(scope.defaultSettingsForm);
|
||||||
scope.currentSettingsSchema = angular.copy(scope.emptySettingsSchema);
|
scope.currentSettingsSchema = angular.copy(scope.emptySettingsSchema);
|
||||||
|
scope.currentSettingsGroupInfoes = angular.copy(scope.emptySettingsGroupInfoes);
|
||||||
scope.currentSettings = {};
|
scope.currentSettings = {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -286,6 +286,7 @@
|
|||||||
<tb-json-form flex schema="currentSettingsSchema"
|
<tb-json-form flex schema="currentSettingsSchema"
|
||||||
form="currentSettingsForm"
|
form="currentSettingsForm"
|
||||||
model="currentSettings"
|
model="currentSettings"
|
||||||
|
group-infoes="currentSettingsGroupInfoes"
|
||||||
form-control="ngform">
|
form-control="ngform">
|
||||||
</tb-json-form>
|
</tb-json-form>
|
||||||
</ng-form>
|
</ng-form>
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
@ -83,10 +83,10 @@ export default class TbMapWidgetV2 {
|
|||||||
this.map = new TbGoogleMap($element, this.utils, initCallback, this.defaultZoomLevel, this.dontFitMapBounds, settings.disableScrollZooming, minZoomLevel, settings.gmApiKey, settings.gmDefaultMapType);
|
this.map = new TbGoogleMap($element, this.utils, initCallback, this.defaultZoomLevel, this.dontFitMapBounds, settings.disableScrollZooming, minZoomLevel, settings.gmApiKey, settings.gmDefaultMapType);
|
||||||
} else if (mapProvider === 'openstreet-map') {
|
} else if (mapProvider === 'openstreet-map') {
|
||||||
if (settings.useCustomProvider && settings.customProviderTileUrl) {
|
if (settings.useCustomProvider && settings.customProviderTileUrl) {
|
||||||
openStreetMapProvider.name = settings.customProviderTileUrl;
|
openStreetMapProvider.name = settings.customProviderTileUrl;
|
||||||
openStreetMapProvider.isCustom = true;
|
openStreetMapProvider.isCustom = true;
|
||||||
} else {
|
} else {
|
||||||
openStreetMapProvider.name = settings.mapProvider;
|
openStreetMapProvider.name = settings.mapProvider;
|
||||||
}
|
}
|
||||||
this.map = new TbOpenStreetMap($element, this.utils, initCallback, this.defaultZoomLevel, this.dontFitMapBounds, settings.disableScrollZooming, minZoomLevel, openStreetMapProvider);
|
this.map = new TbOpenStreetMap($element, this.utils, initCallback, this.defaultZoomLevel, this.dontFitMapBounds, settings.disableScrollZooming, minZoomLevel, openStreetMapProvider);
|
||||||
} else if (mapProvider === 'here') {
|
} else if (mapProvider === 'here') {
|
||||||
@ -669,22 +669,49 @@ export default class TbMapWidgetV2 {
|
|||||||
var schema;
|
var schema;
|
||||||
if (mapProvider === 'google-map') {
|
if (mapProvider === 'google-map') {
|
||||||
schema = angular.copy(googleMapSettingsSchema);
|
schema = angular.copy(googleMapSettingsSchema);
|
||||||
|
schema.groupInfoes=[{
|
||||||
|
"formIndex":0,
|
||||||
|
"GroupTitle":"Google Map Settings"
|
||||||
|
}];
|
||||||
} else if (mapProvider === 'openstreet-map') {
|
} else if (mapProvider === 'openstreet-map') {
|
||||||
schema = angular.copy(openstreetMapSettingsSchema);
|
schema = angular.copy(openstreetMapSettingsSchema);
|
||||||
|
schema.groupInfoes=[{
|
||||||
|
"formIndex":0,
|
||||||
|
"GroupTitle":"Openstreet Map Settings"
|
||||||
|
}];
|
||||||
} else if (mapProvider === 'image-map') {
|
} else if (mapProvider === 'image-map') {
|
||||||
return imageMapSettingsSchema;
|
return imageMapSettingsSchema;
|
||||||
} else if (mapProvider === 'tencent-map') {
|
} else if (mapProvider === 'tencent-map') {
|
||||||
schema = angular.copy(tencentMapSettingsSchema);
|
schema = angular.copy(tencentMapSettingsSchema);
|
||||||
|
schema.groupInfoes=[{
|
||||||
|
"formIndex":0,
|
||||||
|
"GroupTitle":"Tencent Map Settings"
|
||||||
|
}];
|
||||||
} else if (mapProvider === 'here') {
|
} else if (mapProvider === 'here') {
|
||||||
schema = angular.copy(hereMapSettingsSchema);
|
schema = angular.copy(hereMapSettingsSchema);
|
||||||
|
schema.groupInfoes=[{
|
||||||
|
"formIndex":0,
|
||||||
|
"GroupTitle":"Here Map Settings"
|
||||||
|
}];
|
||||||
}
|
}
|
||||||
|
if(!schema.groupInfoes)schema.groupInfoes=[];
|
||||||
|
schema.form = [schema.form];
|
||||||
|
|
||||||
angular.merge(schema.schema.properties, commonMapSettingsSchema.schema.properties);
|
angular.merge(schema.schema.properties, commonMapSettingsSchema.schema.properties);
|
||||||
schema.schema.required = schema.schema.required.concat(commonMapSettingsSchema.schema.required);
|
schema.schema.required = schema.schema.required.concat(commonMapSettingsSchema.schema.required);
|
||||||
schema.form = schema.form.concat(commonMapSettingsSchema.form);
|
schema.form.push(commonMapSettingsSchema.form);//schema.form.concat(commonMapSettingsSchema.form);
|
||||||
|
schema.groupInfoes.push({
|
||||||
|
"formIndex":schema.groupInfoes.length,
|
||||||
|
"GroupTitle":"Common Map Settings"
|
||||||
|
});
|
||||||
if (drawRoutes) {
|
if (drawRoutes) {
|
||||||
angular.merge(schema.schema.properties, routeMapSettingsSchema.schema.properties);
|
angular.merge(schema.schema.properties, routeMapSettingsSchema.schema.properties);
|
||||||
schema.schema.required = schema.schema.required.concat(routeMapSettingsSchema.schema.required);
|
schema.schema.required = schema.schema.required.concat(routeMapSettingsSchema.schema.required);
|
||||||
schema.form = schema.form.concat(routeMapSettingsSchema.form);
|
schema.form.push(routeMapSettingsSchema.form);//schema.form = schema.form.concat(routeMapSettingsSchema.form);
|
||||||
|
schema.groupInfoes.push({
|
||||||
|
"formIndex":schema.groupInfoes.length,
|
||||||
|
"GroupTitle":"Route Map Settings"
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return schema;
|
return schema;
|
||||||
}
|
}
|
||||||
@ -871,16 +898,16 @@ const openstreetMapSettingsSchema =
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"default": "OpenStreetMap.Mapnik"
|
"default": "OpenStreetMap.Mapnik"
|
||||||
},
|
},
|
||||||
"useCustomProvider": {
|
"useCustomProvider": {
|
||||||
"title": "Use custom provider",
|
"title": "Use custom provider",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": false
|
"default": false
|
||||||
},
|
},
|
||||||
"customProviderTileUrl": {
|
"customProviderTileUrl": {
|
||||||
"title": "Custom provider tile URL",
|
"title": "Custom provider tile URL",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"default": "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
|
"default": "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": []
|
"required": []
|
||||||
},
|
},
|
||||||
@ -920,8 +947,8 @@ const openstreetMapSettingsSchema =
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"useCustomProvider",
|
"useCustomProvider",
|
||||||
"customProviderTileUrl"
|
"customProviderTileUrl"
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -965,7 +965,9 @@ function tripAnimationController($document, $scope, $log, $http, $timeout, $filt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (trip && vm.activeTripIndex !== trip.dSIndex) vm.activeTripIndex = trip.dSIndex;
|
if (trip && vm.activeTripIndex !== trip.dSIndex) vm.activeTripIndex = trip.dSIndex;
|
||||||
vm.mainTooltip = vm.trips[vm.activeTripIndex].settings.tooltipText;
|
if (vm.trips.length) {
|
||||||
|
vm.mainTooltip = vm.trips[vm.activeTripIndex].settings.tooltipText;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function showHidePointTooltip(text, index) {
|
function showHidePointTooltip(text, index) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user