mirror of
https://github.com/portainer/portainer.git
synced 2025-08-05 05:45:22 +02:00
refactor(ui): updated image view (#112)
This commit is contained in:
parent
111cd4ac64
commit
9293b28ef4
6 changed files with 198 additions and 117 deletions
|
@ -94,7 +94,6 @@ angular.module('uifordocker.filters', [])
|
|||
if (state === undefined) {
|
||||
return 'label-default';
|
||||
}
|
||||
|
||||
if (state.Ghost && state.Running) {
|
||||
return 'label-important';
|
||||
}
|
||||
|
@ -169,6 +168,32 @@ angular.module('uifordocker.filters', [])
|
|||
return moment.unix(timestamp).format('YYYY-MM-DD HH:mm:ss');
|
||||
};
|
||||
})
|
||||
.filter('getisodate', function () {
|
||||
'use strict';
|
||||
return function (date) {
|
||||
return moment(date).format('YYYY-MM-DD HH:mm:ss');
|
||||
};
|
||||
})
|
||||
.filter('command', function () {
|
||||
'use strict';
|
||||
return function (command) {
|
||||
if (command) {
|
||||
return command.join(' ');
|
||||
}
|
||||
};
|
||||
})
|
||||
.filter('key', function () {
|
||||
'use strict';
|
||||
return function (pair) {
|
||||
return pair.slice(0, pair.indexOf('='));
|
||||
};
|
||||
})
|
||||
.filter('value', function () {
|
||||
'use strict';
|
||||
return function (pair) {
|
||||
return pair.slice(pair.indexOf('=') + 1);
|
||||
};
|
||||
})
|
||||
.filter('errorMsg', function () {
|
||||
return function (object) {
|
||||
var idx = 0;
|
||||
|
|
25
app/shared/responseHandlers.js
Normal file
25
app/shared/responseHandlers.js
Normal file
|
@ -0,0 +1,25 @@
|
|||
// Events query API return a list of JSON object.
|
||||
// This handler wrap the JSON objects in an array.
|
||||
function queryEventsHandler(data) {
|
||||
var str = "[" + data.replace(/\n/g, " ").replace(/\}\s*\{/g, "}, {") + "]";
|
||||
return angular.fromJson(str);
|
||||
}
|
||||
|
||||
// Image create API return a list of JSON object.
|
||||
// This handler wrap the JSON objects in an array.
|
||||
function createImageHandler(data) {
|
||||
var str = "[" + data.replace(/\n/g, " ").replace(/\}\s*\{/g, "}, {") + "]";
|
||||
return angular.fromJson(str);
|
||||
}
|
||||
|
||||
// Image delete API returns an array on success and an object on error.
|
||||
// This handler creates an array from an object in case of error.
|
||||
function deleteImageHandler(data) {
|
||||
var response = angular.fromJson(data);
|
||||
if (!Array.isArray(response)) {
|
||||
var arr = [];
|
||||
arr.push(response);
|
||||
return arr;
|
||||
}
|
||||
return response;
|
||||
}
|
|
@ -92,28 +92,28 @@ angular.module('uifordocker.services', ['ngResource', 'ngSanitize'])
|
|||
get: {method: 'GET', params: {action: 'json'}},
|
||||
search: {method: 'GET', params: {action: 'search'}},
|
||||
history: {method: 'GET', params: {action: 'history'}, isArray: true},
|
||||
create: {
|
||||
method: 'POST', isArray: true, transformResponse: [function f(data) {
|
||||
var str = "[" + data.replace(/\n/g, " ").replace(/\}\s*\{/g, "}, {") + "]";
|
||||
return angular.fromJson(str);
|
||||
}],
|
||||
params: {action: 'create', fromImage: '@fromImage', tag: '@tag'}
|
||||
},
|
||||
insert: {method: 'POST', params: {id: '@id', action: 'insert'}},
|
||||
push: {method: 'POST', params: {id: '@id', action: 'push'}},
|
||||
tag: {method: 'POST', params: {id: '@id', action: 'tag', force: 0, repo: '@repo', tag: '@tag'}},
|
||||
remove: {method: 'DELETE', params: {id: '@id'}, isArray: true},
|
||||
inspect: {method: 'GET', params: {id: '@id', action: 'json'}}
|
||||
inspect: {method: 'GET', params: {id: '@id', action: 'json'}},
|
||||
create: {
|
||||
method: 'POST', params: {action: 'create', fromImage: '@fromImage', tag: '@tag'},
|
||||
isArray: true, transformResponse: createImageHandler,
|
||||
},
|
||||
remove: {
|
||||
method: 'DELETE', params: {id: '@id'},
|
||||
isArray: true, transformResponse: deleteImageHandler
|
||||
}
|
||||
});
|
||||
}])
|
||||
.factory('Events', ['$resource', 'Settings', function EventFactory($resource, Settings) {
|
||||
'use strict';
|
||||
// http://docs.docker.com/reference/api/docker_remote_api_<%= remoteApiVersion %>/#/monitor-docker-s-events
|
||||
return $resource(Settings.url + '/events', {}, {
|
||||
query: {method: 'GET', params: {since: '@since', until: '@until'}, isArray: true, transformResponse: [function f(data) {
|
||||
var str = "[" + data.replace(/\n/g, " ").replace(/\}\s*\{/g, "}, {") + "]";
|
||||
return angular.fromJson(str);
|
||||
}]}
|
||||
query: {
|
||||
method: 'GET', params: {since: '@since', until: '@until'},
|
||||
isArray: true, transformResponse: queryEventsHandler,
|
||||
}
|
||||
});
|
||||
}])
|
||||
.factory('Version', ['$resource', 'Settings', function VersionFactory($resource, Settings) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue