diff --git a/package-lock.json b/package-lock.json index 629e208..b3ce097 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2034,6 +2034,35 @@ "tslib": "^1.9.0" } }, + "angular-calendar": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/angular-calendar/-/angular-calendar-0.25.2.tgz", + "integrity": "sha512-sFzqwioLIEbRIpFcZq6Ap0tW8n8NNApwbbbs0DTmjnQjr6N1VZArlkKCecfqkYYG6dE496t7V616Ak7gTBa4QA==", + "requires": { + "angular-draggable-droppable": "^3.0.0", + "angular-resizable-element": "^3.0.0", + "calendar-utils": "^0.1.2", + "date-fns": "^1.28.5", + "positioning": "^1.3.1", + "tslib": "^1.9.0" + } + }, + "angular-draggable-droppable": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/angular-draggable-droppable/-/angular-draggable-droppable-3.0.1.tgz", + "integrity": "sha512-+GYYq4U5rPcoNwaCdoY3sNBBKd80JT7+R8n4QINJKvtToisyGpsXmX68SkKfHsNtXyTzoxX/h/37XJgE0y8KLw==", + "requires": { + "tslib": "^1.9.0" + } + }, + "angular-resizable-element": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/angular-resizable-element/-/angular-resizable-element-3.2.2.tgz", + "integrity": "sha512-Lf3jnZMdndAdasAXRImpmFMe+I596rY2ttMPmWMW9zIp2QeyriNbr8l3VEfUJWnCW14oNsO8SHRAYUXBphm/Lw==", + "requires": { + "tslib": "^1.9.0" + } + }, "angular-tree-component": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/angular-tree-component/-/angular-tree-component-7.2.0.tgz", @@ -3042,6 +3071,11 @@ "schema-utils": "^0.4.2" } }, + "calendar-utils": { + "version": "0.1.2", + "resolved": "http://registry.npmjs.org/calendar-utils/-/calendar-utils-0.1.2.tgz", + "integrity": "sha512-9j4Zd1itopNYTSWzFU4MqD2IDHMqznfxsGr8UWGh7hWv+lKzjRJz0LS29iAg5rHtP6+6x3ikQnhoMGqFUzoD2Q==" + }, "callsite": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/callsite/-/callsite-1.0.0.tgz", @@ -5247,6 +5281,14 @@ "is-obj": "^1.0.0" } }, + "download-file": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/download-file/-/download-file-0.1.5.tgz", + "integrity": "sha1-ylC6ZNkJSwyHAu+f/5LSGJ4UERc=", + "requires": { + "mkdirp": "^0.5.0" + } + }, "duplexer": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz", @@ -5878,7 +5920,7 @@ }, "express": { "version": "4.16.3", - "resolved": "https://registry.npmjs.org/express/-/express-4.16.3.tgz", + "resolved": "http://registry.npmjs.org/express/-/express-4.16.3.tgz", "integrity": "sha1-avilAjUNsyRuzEvs9rWjTSL37VM=", "requires": { "accepts": "~1.3.5", @@ -5929,7 +5971,7 @@ }, "finalhandler": { "version": "1.1.1", - "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.1.tgz", + "resolved": "http://registry.npmjs.org/finalhandler/-/finalhandler-1.1.1.tgz", "integrity": "sha512-Y1GUDo39ez4aHAw7MysnUD5JzYX+WaIj8I57kO3aEPT1fFRL4sr7mjei97FgnwhAyyzRYmQZaTHb2+9uZ1dPtg==", "requires": { "debug": "2.6.9", @@ -6387,6 +6429,11 @@ "schema-utils": "^0.4.5" } }, + "file-saver": { + "version": "1.3.8", + "resolved": "http://registry.npmjs.org/file-saver/-/file-saver-1.3.8.tgz", + "integrity": "sha512-spKHSBQIxxS81N/O21WmuXA2F6wppUCsutpzenOeZzOCCJ5gEfcbqJP983IrpLXzYmXnMUa6J03SubcNPdKrlg==" + }, "filename-regex": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/filename-regex/-/filename-regex-2.0.1.tgz", @@ -6686,14 +6733,12 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -6708,20 +6753,17 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -6838,8 +6880,7 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -6851,7 +6892,6 @@ "version": "1.0.0", "bundled": true, "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -6866,7 +6906,6 @@ "version": "3.0.4", "bundled": true, "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -6978,8 +7017,7 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "4.1.1", @@ -6991,7 +7029,6 @@ "version": "1.4.0", "bundled": true, "dev": true, - "optional": true, "requires": { "wrappy": "1" } @@ -7113,7 +7150,6 @@ "version": "1.0.2", "bundled": true, "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -12732,6 +12768,11 @@ } } }, + "positioning": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/positioning/-/positioning-1.4.0.tgz", + "integrity": "sha512-LbN+mgAXtcDdN46xMJ3yZwjndqqYJODaO5qKmU+MVMu5tL3K2dlm1Qha/zh1k2JAFym5HDaZpnPfO4gr91VTRw==" + }, "posix-character-classes": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", @@ -14900,6 +14941,11 @@ "integrity": "sha1-1cdSgl5TZ+eG944Y5EXqIjoVWVI=", "dev": true }, + "string-similarity": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/string-similarity/-/string-similarity-2.0.0.tgz", + "integrity": "sha512-62FBZrVXV5cI23bQ9L49Y4d9u9yaH61JhAwLyUFUzQbHDjdihxdfCwIherg+vylR/s4ucCddK8iKSEO7kinffQ==" + }, "string-width": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", @@ -15520,6 +15566,11 @@ } } }, + "text-diff": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/text-diff/-/text-diff-1.0.1.tgz", + "integrity": "sha1-bBBZBUNeM3hXN1ydL2ymPkU/9WU=" + }, "text-extensions": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/text-extensions/-/text-extensions-1.7.0.tgz", @@ -16023,6 +16074,11 @@ "integrity": "sha1-sxxa6CVIRKOoKBVBzisEuGWnNP8=", "dev": true }, + "uniqid": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/uniqid/-/uniqid-5.0.3.tgz", + "integrity": "sha512-R2qx3X/LYWSdGRaluio4dYrPXAJACTqyUjuyXHoJLBUOIfmMcnYOyY2d6Y4clZcIz5lK6ZaI0Zzmm0cPfsIqzQ==" + }, "unique-filename": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/unique-filename/-/unique-filename-1.1.0.tgz", diff --git a/package.json b/package.json index b77dfd2..f214b72 100644 --- a/package.json +++ b/package.json @@ -64,6 +64,7 @@ "ckeditor": "4.7.3", "classlist.js": "1.1.20150312", "core-js": "2.5.1", + "download-file": "^0.1.5", "echarts": "^4.1.0", "elasticsearch": "^15.1.1", "express": "^4.16.3", @@ -98,8 +99,11 @@ "simple-oauth2": "^1.6.0", "socicon": "3.0.5", "socket.io": "^2.1.1", + "string-similarity": "^2.0.0", + "text-diff": "^1.0.1", "tinymce": "4.5.7", "typeface-exo": "0.0.22", + "uniqid": "^5.0.3", "web-animations-js": "2.2.5", "zone.js": "^0.8.26" }, diff --git a/server.js b/server.js index 79711c3..1bbf5b2 100644 --- a/server.js +++ b/server.js @@ -4,6 +4,11 @@ const path = require('path'); const http = require('http'); const bodyParser = require('body-parser'); +var fs = require('fs'); +// Uniqid module. Generates random id +var uniqid = require('uniqid'); +// Download-file module +var download = require('download-file'); // Request method var request = require('request'); // Load configuration @@ -70,11 +75,102 @@ app.get('/', (req, res) => { res.sendFile(path.join(__dirname, 'dist/index.html')); }); +//Files Management +var oldFile; +//Download config file from remote to node app.get('/download', (req, res) => { + var url = req.query.url; + var options = { + directory: "./downloads", + filename: uniqid(req.query.instance + '&') + } + download(url, options, function(err) { + if(err) throw err + }) + oldFile = options.filename; + res.send(options.filename); +}); + +//Download config file from node to the frontend +app.get('/download/:file', (req, res) => { + console.log("?downloads/file"); + var path = __dirname + '/downloads/' + req.params.file; + res.download(path); +}); + +//Download log file from remote to frontend +app.get('/download/log-file', (req, res) => { request(req.query.url).pipe(res) res.set('Content-Type', 'text/plain'); }); +app.post('/validate', (req, res) => { + var savedFile = fs.readFileSync(__dirname + '/downloads/' + oldFile, 'utf-8'); + var newFile = req.body.newFile; + savedFile = JSON.stringify(savedFile); + savedFile = JSON.parse(savedFile); + + function convertToHash(file){ + var hash = {}; + var lines = file.split("\n"); //split file by lines + lines.forEach(function(line) { + line = line.replace(/ /g,''); //removing whitespaces + if(!line.match(/^#/) && !line.match(/^\[/) && line != ''){ //Avoid lines that begin with # , [ and empty lines + if(line.match("#")){ + line = line.split("#"); //splitting lines that contain # + line = line[0]; //getting the left string of the split + } + if(line.match(/.*=.*/)){ //pushing into the list the lines that are not empty + var split = line.split("="); + hash[split[0]] = split[1]; + } else { + hash[line] = 'on'; + } + } + }); + return hash; + } + + var old_config = convertToHash(savedFile); + var new_config = convertToHash(newFile); + + function compareHash(parameters, old_config, new_config){ + var list = []; + Object.keys(new_config).forEach(function(key){ + var properties = { + name: '', + value: '' + }; + console.log("comparing property: " + key + " new value: " + new_config[key] + " old value: " + old_config[key]); + var line = key + '=' + new_config[key]; + if(parameters[key] && (new_config[key] != old_config[key])){ + properties.name = line; + properties.value = false; + list.push(properties); + } else { + properties.name = line; + properties.value = true; + list.push(properties); + } + }); + console.log(list); + return list; + } + /*function compareHash(parameters, old_config, new_config){ + var list = {}; + Object.keys(new_config).forEach(function(key){ + console.log("comparing property: " + key + " new value: " + new_config[key] + " old value: " + old_config[key]); + var line = key + '=' + new_config[key]; + if(parameters[key] && (new_config[key] != old_config[key])){ + list[line] = false; + } else list[line] = true; + }); + return list; + }*/ + var comp = compareHash(config.parameters, old_config, new_config); + res.send(comp); +}); + app.get('/logout', (req, res) => { console.log('Destroying session SID: ' + req.session.id); req.session.destroy((error) => { diff --git a/server/config.js b/server/config.js index 1bfe06b..f7e0126 100644 --- a/server/config.js +++ b/server/config.js @@ -47,4 +47,50 @@ elasticsearch.indexNames = indexNames config.elasticsearch = elasticsearch -module.exports = config \ No newline at end of file +var parameters = {} + +parameters.max_user_connections = '300' +parameters.max_heap_table_size = '32M' +parameters['server-id'] = '1' +parameters['general-log-file'] = '/ORA/dbs03/PINOCHO/mysql/mysql.log' +parameters.max_connections = '1000' +parameters.performance_schema +parameters.innodb_flush_method = 'O_DIRECT' +parameters['innodb-read-io-threads'] = '4' +parameters.innodb_flush_log_at_trx_commit = '1' +parameters['log-slave-updates'] +parameters.binlog_format = 'MIXED' +parameters.port = '5500' +parameters.socket = '/var/lib/mysql/mysql.sock.pinocho.5500' +parameters.tmp_table_size = '32M' +parameters.innodb_io_capacity = '200' +parameters.sync_binlog = '1' +parameters.query_cache_size = '128M' +parameters.expire_logs_days = '32' +parameters.innodb_write_io_threads = '4' +parameters.slow_query_log = '1' +parameters.thread_cache_size = '50' +parameters.innodb_open_files = '500' +parameters.table_definition_cache = '1000' +parameters.table_open_cache = '1000' +parameters.key_buffer_size = '256M' +parameters.innodb_file_per_table +parameters.log_output = 'FILE' +parameters.datadir = '/ORA/dbs03/PINOCHO/mysql' +parameters['log-bin'] = '/ORA/dbs02/PINOCHO/mysql/binlog' +parameters.innodb_log_file_size = '16M' +parameters.innodb_buffer_pool_size = '1G' +parameters.max_binlog_size = '1073741824' +parameters.slow_query_log_file = '/ORA/dbs03/PINOCHO/mysql/slow_queries.log' +parameters.max_allowed_packet='64M' +parameters.innodb_checksum_algorithm='innodb' +parameters.binlog_checksum='none' +parameters.query_cache_type='1' +parameters['ssl-cert']='/etc/dbod/certificates/hostcert.pem' +parameters['ssl-ca']='/etc/dbod/certificates/ca.pem' +parameters['ssl-key']='/etc/dbod/certificates/hostkey_mysql.pem' +parameters['ssl-cipher']='DHE-RSA-AES256-SHA:AES128-SHA' + +config.parameters = parameters + +module.exports = config diff --git a/src/app/@theme/styles/styles.scss b/src/app/@theme/styles/styles.scss index 9e0b633..9add72d 100644 --- a/src/app/@theme/styles/styles.scss +++ b/src/app/@theme/styles/styles.scss @@ -37,4 +37,4 @@ @import url("https://fonts.googleapis.com/icon?family=Material+Icons"); // angular-calendar -@import "../../../../node_modules/angular-calendar/css/angular-calendar.css"; \ No newline at end of file +@import "../../../../node_modules/angular-calendar/css/angular-calendar.css"; diff --git a/src/app/pages/admin-instances/admin-instances.module.ts b/src/app/pages/admin-instances/admin-instances.module.ts index 55c6a13..073a929 100644 --- a/src/app/pages/admin-instances/admin-instances.module.ts +++ b/src/app/pages/admin-instances/admin-instances.module.ts @@ -22,6 +22,7 @@ import { MatTableModule } from '@angular/material'; import { MatPaginatorModule } from '@angular/material'; import { MatSortModule } from '@angular/material'; import { MatIconModule } from '@angular/material/icon'; +import { ExpiredPendingDialogComponent } from './expired-pending/expired-pending-dialog/expired-pending-dialog.component'; @NgModule({ imports: [ @@ -48,11 +49,13 @@ import { MatIconModule } from '@angular/material/icon'; AdminInstancesComponent, ExpiredPendingComponent, UpgradesComponent, + ExpiredPendingDialogComponent, ], providers: [ InstanceService, ], entryComponents: [ + ExpiredPendingDialogComponent ], }) export class AdminInstancesModule { } diff --git a/src/app/pages/admin-instances/expired-pending/expired-pending-dialog/expired-pending-dialog.component.html b/src/app/pages/admin-instances/expired-pending/expired-pending-dialog/expired-pending-dialog.component.html new file mode 100644 index 0000000..132efe3 --- /dev/null +++ b/src/app/pages/admin-instances/expired-pending/expired-pending-dialog/expired-pending-dialog.component.html @@ -0,0 +1,34 @@ +
+
+

Validate instance

+ + Are you sure you want to validate the instance ? + + + + + +
+ +
+

Rescue instance

+ + Are you sure you want to rescue the instance ? + + + + + +
+ +
+

Destroy instance

+ + Are you sure you want to destroy the instance ? + + + + + +
+
diff --git a/src/app/pages/admin-instances/expired-pending/expired-pending-dialog/expired-pending-dialog.component.ts b/src/app/pages/admin-instances/expired-pending/expired-pending-dialog/expired-pending-dialog.component.ts new file mode 100644 index 0000000..c49f751 --- /dev/null +++ b/src/app/pages/admin-instances/expired-pending/expired-pending-dialog/expired-pending-dialog.component.ts @@ -0,0 +1,43 @@ +import { Component, Inject } from '@angular/core'; +import {MAT_DIALOG_DATA} from '@angular/material'; +import { HttpClient } from '@angular/common/http'; +import { MatSpinner } from '@angular/material'; +import { MatBadge } from '@angular/material'; +import { RundeckService } from '../../../../services/rundeck/rundeck.service'; + +@Component({ + selector: 'expired-pending-dialog', + templateUrl: './expired-pending-dialog.component.html', +}) +export class ExpiredPendingDialogComponent { + Action = { + Validate: 0, + Rescue: 1, + Destroy: 2, + Loading: 3, + Success: 4, + Error: 5 + } + + action; + resMessage: string; + resStatus: number; + + constructor(@Inject(MAT_DIALOG_DATA) public data: any, private rundeckService: RundeckService) { + if(data.buttonAction == this.Action['Validate']){ + this.action = this.Action['Validate']; + console.log(this.action); + } else { + if(data.buttonAction == this.Action['Rescue']){ + this.action = this.Action['Rescue']; + console.log(this.action); + } + else { + if(data.buttonAction == this.Action['Destroy']){ + this.action = this.Action['Destroy']; + console.log(this.action); + } + } + } +} +} diff --git a/src/app/pages/admin-instances/expired-pending/expired-pending.component.html b/src/app/pages/admin-instances/expired-pending/expired-pending.component.html index 1a719c7..a230045 100644 --- a/src/app/pages/admin-instances/expired-pending/expired-pending.component.html +++ b/src/app/pages/admin-instances/expired-pending/expired-pending.component.html @@ -39,19 +39,19 @@ Validate - + Rescue - + Destroy - + diff --git a/src/app/pages/admin-instances/expired-pending/expired-pending.component.ts b/src/app/pages/admin-instances/expired-pending/expired-pending.component.ts index 367e415..a13ff7d 100644 --- a/src/app/pages/admin-instances/expired-pending/expired-pending.component.ts +++ b/src/app/pages/admin-instances/expired-pending/expired-pending.component.ts @@ -1,8 +1,9 @@ import { Component, OnInit, Input, ViewChild } from '@angular/core'; import { InstanceService } from '../../../services/instance'; import { MatPaginator, MatSort, MatTableDataSource } from '@angular/material'; - +import {MatDialog} from '@angular/material'; import { AuthenticationService } from '../../../services/authentication/authentication.service'; +import { ExpiredPendingDialogComponent } from './expired-pending-dialog/expired-pending-dialog.component'; @Component({ selector: 'expired-pending', @@ -18,7 +19,7 @@ export class ExpiredPendingComponent implements OnInit { @ViewChild(MatPaginator) paginator: MatPaginator; @ViewChild(MatSort) sort: MatSort; - constructor(private authService: AuthenticationService, private _InstanceService: InstanceService) { + constructor(private authService: AuthenticationService, private _InstanceService: InstanceService, public dialog: MatDialog) { this.dataSource = new MatTableDataSource([{'name': '', 'owner': '', 'egroup': '', 'project': '', 'type': '', 'category': '', 'expiry_date': ''}]); } @@ -45,4 +46,13 @@ export class ExpiredPendingComponent implements OnInit { this.dataSource.paginator.firstPage(); } } + + changeInstance(value){ + const dialogRef = this.dialog.open(ExpiredPendingDialogComponent, { + data: { + buttonAction: value, + } + }); + } + } diff --git a/src/app/pages/admin-instances/upgrades/upgrades.component.html b/src/app/pages/admin-instances/upgrades/upgrades.component.html index e12c646..284490e 100644 --- a/src/app/pages/admin-instances/upgrades/upgrades.component.html +++ b/src/app/pages/admin-instances/upgrades/upgrades.component.html @@ -4,7 +4,7 @@
diff --git a/src/app/pages/instance/instance-expiry-date-dialog/instance-expiry-date-dialog.component.html b/src/app/pages/instance/instance-expiry-date-dialog/instance-expiry-date-dialog.component.html index 0d634d9..ed784bc 100644 --- a/src/app/pages/instance/instance-expiry-date-dialog/instance-expiry-date-dialog.component.html +++ b/src/app/pages/instance/instance-expiry-date-dialog/instance-expiry-date-dialog.component.html @@ -1,5 +1,5 @@
-
+

Invalid date

Expiry date cannot be in the past diff --git a/src/app/pages/instance/instance-expiry-date-dialog/instance-expiry-date-dialog.component.ts b/src/app/pages/instance/instance-expiry-date-dialog/instance-expiry-date-dialog.component.ts index ce30c34..f8b21a2 100644 --- a/src/app/pages/instance/instance-expiry-date-dialog/instance-expiry-date-dialog.component.ts +++ b/src/app/pages/instance/instance-expiry-date-dialog/instance-expiry-date-dialog.component.ts @@ -11,7 +11,7 @@ import { InstanceService } from '../../../services/instance/instance.service'; }) export class InstanceExpiryDateDialogComponent { ExpiryDate = { - LessDate: 0, + PastDate: 0, HigherDate: 1, InvalidChange: 2 } diff --git a/src/app/pages/instance/instance-file-editor/instance-file-editor.component.html b/src/app/pages/instance/instance-file-editor/instance-file-editor.component.html index 5124e6b..dfe3ee7 100644 --- a/src/app/pages/instance/instance-file-editor/instance-file-editor.component.html +++ b/src/app/pages/instance/instance-file-editor/instance-file-editor.component.html @@ -22,13 +22,19 @@
- +
-
- + +
+ +
+
+
{{item.name}}
Loading... diff --git a/src/app/pages/instance/instance-file-editor/instance-file-editor.component.scss b/src/app/pages/instance/instance-file-editor/instance-file-editor.component.scss index bc422db..30df1a2 100644 --- a/src/app/pages/instance/instance-file-editor/instance-file-editor.component.scss +++ b/src/app/pages/instance/instance-file-editor/instance-file-editor.component.scss @@ -4,4 +4,9 @@ flex-wrap: wrap; margin-top:2px; margin-bottom:10px; -} \ No newline at end of file +} + +.red{ + text-decoration: underline; + text-decoration-color: red; +} diff --git a/src/app/pages/instance/instance-file-editor/instance-file-editor.component.ts b/src/app/pages/instance/instance-file-editor/instance-file-editor.component.ts index 1f9574c..63ac766 100644 --- a/src/app/pages/instance/instance-file-editor/instance-file-editor.component.ts +++ b/src/app/pages/instance/instance-file-editor/instance-file-editor.component.ts @@ -22,6 +22,9 @@ export class InstanceFileEditorComponent implements OnInit { content: null, }; displayedContent = null; + oldFile = null; + list = null; + items = []; constructor(private rundeckService: RundeckService, private fileDownloaderService: FileDownloaderService, public dialog: MatDialog) { } @@ -47,12 +50,13 @@ export class InstanceFileEditorComponent implements OnInit { "filepath": this.selectedConfigFile.filepath, }}).then( async (data: any) => { var url = data.log + this.selectedConfigFile.filepath; - this.selectedConfigFile.content = await this.fileDownloaderService.getFile(url); + this.oldFile = await this.fileDownloaderService.saveFile(url, this.data.name); + this.selectedConfigFile.content = await this.fileDownloaderService.getConfigFile(this.oldFile); this.displayedContent = this.selectedConfigFile.content; }, err => console.log(err)); } - async downloadConfigFile() { + downloadConfigFile() { if(this.selectedConfigFile.content!=null){ var blob = new Blob([this.selectedConfigFile.content]); FileSaver.saveAs(blob, this.selectedConfigFile.title); @@ -83,7 +87,40 @@ export class InstanceFileEditorComponent implements OnInit { } } + async validateFile(){ + if(this.displayedContent!=null){ + var newContent = this.displayedContent; + var validated_contents = await this.fileDownloaderService.getValidation(newContent); + newContent = JSON.stringify(newContent); + var newe = JSON.parse(newContent); + console.log("NEW: " + newe); + console.log(validated_contents); + this.list = validated_contents; + console.log("content: " + newContent); +/* + for(var i = 0; i < this.list.length; i++){ + console.log(this.list[i].name); + console.log(this.list[i].value); + } +*/ + /*for(var i = 0; i < this.list.length; i++){ + if(this.list[i][1] == false){ + console.log(this.list[i][0]); + } + }*/ + /*this.list = Object.keys(validated_contents).map(function(key) { + return [String(key), validated_contents[key]]; + }); + console.log("RES: " + this.list); + }*/ + } + } + + saveItems(item){ + this.items.push(item); + console.log("adding: " + item); + } submitChanges() { if(this.selectedConfigFile.title!=null && this.displayedContent!=null) { diff --git a/src/app/pages/instance/instance-jobs/instance-jobs.component.html b/src/app/pages/instance/instance-jobs/instance-jobs.component.html index 648afe1..ae79a60 100644 --- a/src/app/pages/instance/instance-jobs/instance-jobs.component.html +++ b/src/app/pages/instance/instance-jobs/instance-jobs.component.html @@ -4,9 +4,9 @@ All - Finished - Failed - Running + Finished + Failed + Running @@ -35,9 +35,9 @@ - Finished - Failed - Running + Finished + Failed + Running {{ item.creation_date | date : 'medium' }} {{ item.completion_date | date : 'medium' }} @@ -45,6 +45,6 @@ {{ item.command_name }} requested by {{ item.requester }} - + - \ No newline at end of file + diff --git a/src/app/pages/instance/instance-logs/instance-logs.component.html b/src/app/pages/instance/instance-logs/instance-logs.component.html index 6f3eaf0..dbe97eb 100644 --- a/src/app/pages/instance/instance-logs/instance-logs.component.html +++ b/src/app/pages/instance/instance-logs/instance-logs.component.html @@ -1,5 +1,5 @@
- +
+
@@ -56,8 +56,10 @@ PROD +
Notifications EOS backup +
diff --git a/src/app/services/file-downloader/file-downloader.service.ts b/src/app/services/file-downloader/file-downloader.service.ts index 8d7720a..9329c4a 100644 --- a/src/app/services/file-downloader/file-downloader.service.ts +++ b/src/app/services/file-downloader/file-downloader.service.ts @@ -9,13 +9,43 @@ import { AuthenticationService } from '../../services/authentication/authenticat export class FileDownloaderService { constructor(private http: Http, private authService: AuthenticationService) { } - getFile(url) { + saveFile(url, instance) { return new Promise( (resolve, reject) => { this.authService.loadUser().then( () => { - this.http.get('/download', {"params": {"url": url}}) + this.http.get('/download', {"params": {"url": url, "instance": instance}}) .map((res:any) => res.text()) .subscribe( (res) => resolve(res)); }, (err) => reject(err)); }) } + + getConfigFile(file) { + return new Promise( (resolve, reject) => { + this.authService.loadUser().then( () => { + this.http.get('/download/' + file) + .map((res:any) => res.text()) + .subscribe( (res) => resolve(res)); + }, (err) => reject(err)); + }) + } + + getLogFile(url) { + return new Promise( (resolve, reject) => { + this.authService.loadUser().then( () => { + this.http.get('/download/log-file', {"params": {"url": url}}) + .map((res:any) => res.text()) + .subscribe( (res) => resolve(res)); + }, (err) => reject(err)); + }) + } + + getValidation(newFile){ + return new Promise( (resolve, reject) => { + this.authService.loadUser().then( () => { + this.http.post('/validate', {"newFile": newFile}) + .map((res:any) => res.json()) + .subscribe( (res) => resolve(res)); + }, (err) => reject(err)); + }) + } }