This repository has been archived by the owner on Oct 20, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
50ea820
commit d239d11
Showing
11 changed files
with
360 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
124 changes: 124 additions & 0 deletions
124
src/management/components/documentation/import-pages.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
/* | ||
* Copyright (C) 2015 The Gravitee team (http://gravitee.io) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import NotificationService from "../../../services/notification.service"; | ||
import DocumentationService from "../../../services/documentation.service"; | ||
import {StateService} from "@uirouter/core"; | ||
import {IScope} from "angular"; | ||
import _ = require('lodash'); | ||
|
||
interface IPageScope extends IScope { | ||
fetcherJsonSchema: string; | ||
} | ||
const ImportPagesComponent: ng.IComponentOptions = { | ||
bindings: { | ||
resolvedFetchers: '<', | ||
resolvedRootPage: '<' | ||
}, | ||
template: require('./import-pages.html'), | ||
controller: function ( | ||
NotificationService: NotificationService, | ||
DocumentationService: DocumentationService, | ||
$state: StateService, | ||
$scope: IPageScope | ||
) { | ||
'ngInject'; | ||
this.apiId = $state.params.apiId; | ||
|
||
this.codeMirrorOptions = { | ||
lineWrapping: true, | ||
lineNumbers: true, | ||
allowDropFileTypes: true, | ||
autoCloseTags: true, | ||
mode: "javascript" | ||
}; | ||
|
||
this.$onInit = () => { | ||
|
||
this.page = this.resolvedRootPage || { | ||
name: "root", | ||
type: "ROOT" | ||
}; | ||
|
||
this.fetchers = this.resolvedFetchers; | ||
|
||
this.emptyFetcher = { | ||
"type": "object", | ||
"id": "empty", | ||
"properties": {"" : {}} | ||
}; | ||
$scope.fetcherJsonSchema = this.emptyFetcher; | ||
this.fetcherJsonSchemaForm = ["*"]; | ||
|
||
if(!(_.isNil(this.page.source) || _.isNil(this.page.source.type))) { | ||
_.forEach(this.fetchers, fetcher => { | ||
if (fetcher.id === this.page.source.type) { | ||
$scope.fetcherJsonSchema = JSON.parse(fetcher.schema); | ||
} | ||
}); | ||
} | ||
}; | ||
|
||
this.configureFetcher = (fetcher) => { | ||
if (! this.page.source) { | ||
this.page.source = {}; | ||
} | ||
|
||
this.page.source = { | ||
type: fetcher.id, | ||
configuration: {} | ||
}; | ||
$scope.fetcherJsonSchema = JSON.parse(fetcher.schema); | ||
}; | ||
|
||
this.import = () => { | ||
this.page.name="import"; | ||
DocumentationService.import(this.page, this.apiId) | ||
.then( (response: any) => { | ||
if (this.page.id) { | ||
NotificationService.show("'" + response.data.length + "' elements has been updated."); | ||
} else { | ||
NotificationService.show("'" + response.data.length + "' elements has been created."); | ||
} | ||
if (this.apiId) { | ||
$state.go("management.apis.detail.portal.documentation", {apiId: this.apiId}); | ||
} else { | ||
$state.go("management.settings.documentation"); | ||
} | ||
}); | ||
}; | ||
|
||
this.changeContentMode = (newMode) => { | ||
if ("fetcher" === newMode) { | ||
this.page.source = { | ||
configuration: {} | ||
}; | ||
} else { | ||
delete this.page.source; | ||
} | ||
}; | ||
|
||
this.cancel = () => { | ||
if (this.apiId) { | ||
$state.go("management.apis.detail.portal.documentation", {apiId: this.apiId}); | ||
} else { | ||
$state.go("management.settings.documentation"); | ||
} | ||
}; | ||
} | ||
}; | ||
|
||
export default ImportPagesComponent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<!-- | ||
Copyright (C) 2015 The Gravitee team (http://gravitee.io) | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
<div class="gv-forms gv-forms" layout="column"> | ||
<div class="gv-forms-header"> | ||
<h1>Import Files</h1> | ||
<a ng-click="$ctrl.cancel()">Back to Documentation</a> | ||
</div> | ||
<div class="gv-form"> | ||
<h2></h2> | ||
<div class="gv-form-content" layout="column"> | ||
|
||
<div class="gv-page-draft-banner"> | ||
<ng-md-icon icon="warning" style="fill: #ce4844"></ng-md-icon> | ||
All files (with a supported page type) will be imported, generating one request by file to import.<br> | ||
If you use an external source with rate limiting, you can reach your maximum requests authorized. | ||
</div> | ||
|
||
<blockquote> | ||
<p style="font-size: 12px"> | ||
<ng-md-icon icon="info" style="fill:grey;"></ng-md-icon> | ||
You can import a whole directory (only available in few sources), or import a Gravitee.io descriptor (refer to the documentation). | ||
If the filepath is not filled, the root directory will be imported. | ||
</p> | ||
</blockquote> | ||
|
||
<div style="display: inline-block;"> | ||
<md-input-container class="md-block"> | ||
<md-checkbox ng-model="$ctrl.page.published" | ||
aria-label="Published" | ||
class="md-align-top-left" | ||
flex> | ||
Publish all imported pages | ||
</md-checkbox> | ||
</md-input-container> | ||
|
||
<h3>Select your source:</h3> | ||
<div layout="row"> | ||
<md-button ng-repeat="fetcher in $ctrl.fetchers" | ||
ng-click="$ctrl.configureFetcher(fetcher)" | ||
ng-class="{'md-raised': fetcher.id === $ctrl.page.source.type}" | ||
aria-label="fetcher"> | ||
<md-icon md-svg-icon="assets/logo_{{fetcher.id | lowercase}}.svg" style="width:80px;height:40px"></md-icon> | ||
</md-button> | ||
</div> | ||
<div layout="column"> | ||
<form name="PageConfigFetcherForm" sf-schema="fetcherJsonSchema" sf-form="$ctrl.fetcherJsonSchemaForm" sf-model="$ctrl.page.source.configuration"></form> | ||
</div> | ||
</div> | ||
|
||
<div class="md-actions gravitee-api-save-button" layout="row" style="padding-top: 32px;"> | ||
<md-button class="md-raised md-primary" type="submit" ng-click="$ctrl.import()" ng-disabled="!$ctrl.page.source.type"> | ||
Import | ||
</md-button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
Oops, something went wrong.